Skip to content

Commit

Permalink
Attempt to add Russian Cyrillic alphabet into the NickTag lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Jan 18, 2021
1 parent d93fa52 commit 025c7b9
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


local dversion = 229
local dversion = 230

local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
Expand Down Expand Up @@ -3550,7 +3550,7 @@ function DF:GetCharacterRaceList (fullList)

local alliedRaceInfo = C_AlliedRaces.GetRaceInfoByID (i)
if (alliedRaceInfo and DF.AlliedRaceList [alliedRaceInfo.raceID]) then
tinsert (DF.RaceCache, {Name = alliedRaceInfo.name, FileString = alliedRaceInfo.raceFileString})
tinsert (DF.RaceCache, {Name = alliedRaceInfo.maleName, FileString = alliedRaceInfo.raceFileString})
end
end

Expand Down
27 changes: 15 additions & 12 deletions Libs/DF/panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6092,7 +6092,7 @@ function DF:PassLoadFilters (loadTable, encounterID)
local specIndex = DetailsFramework.GetSpecialization()
if (specIndex) then
local specID = DetailsFramework.GetSpecializationInfo (specIndex)
if (not loadTable.spec [specID] or loadTable.spec [specID..""]) then
if not specID or (not loadTable.spec [specID] and not loadTable.spec [specID..""]) then
return false
end
else
Expand All @@ -6114,7 +6114,7 @@ function DF:PassLoadFilters (loadTable, encounterID)
local talentsInUse = DF:GetCharacterTalents (false, true)
local hasTalent
for talentID, _ in pairs (talentsInUse) do
if (loadTable.talent [talentID]) then
if talentID and (loadTable.talent [talentID] or loadTable.talent [talentID .. ""]) then
hasTalent = true
break
end
Expand All @@ -6129,7 +6129,7 @@ function DF:PassLoadFilters (loadTable, encounterID)
local talentsInUse = DF:GetCharacterPvPTalents (false, true)
local hasTalent
for talentID, _ in pairs (talentsInUse) do
if (loadTable.pvptalent [talentID]) then
if talentID and (loadTable.pvptalent [talentID] or loadTable.pvptalent [talentID .. ""]) then
hasTalent = true
break
end
Expand Down Expand Up @@ -6171,7 +6171,7 @@ function DF:PassLoadFilters (loadTable, encounterID)
local level, affixes, wasEnergized = C_ChallengeMode.GetActiveKeystoneInfo()
local hasAffix = false
for _, affixID in ipairs (affixes) do
if (loadTable.affix [affixID]) then
if affixID and (loadTable.affix [affixID] or loadTable.affix [affixID .. ""]) then
hasAffix = true
break
end
Expand Down Expand Up @@ -6285,7 +6285,10 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
f.OnRadioCheckboxClick = function (self, key, value)
--hierarchy: DBKey ["class"] key ["HUNTER"] value TRUE
local DBKey = self:GetParent().DBKey
f.OptionsTable [DBKey] [key] = value and true or nil
f.OptionsTable [DBKey] [key and key .. ""] = value and true or nil
if not value then -- cleanup "number" type values
f.OptionsTable [DBKey] [key] = nil
end
f.OnRadioStateChanged (self:GetParent(), f.OptionsTable [DBKey])
f.RunCallback()
end
Expand Down Expand Up @@ -6347,7 +6350,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = talentTable.Name,
set = f.OnRadioCheckboxClick,
param = talentTable.ID,
get = function() return f.OptionsTable.talent [talentTable.ID] end,
get = function() return f.OptionsTable.talent [talentTable.ID] or f.OptionsTable.talent [talentTable.ID .. ""] end,
texture = talentTable.Texture,
})
end
Expand Down Expand Up @@ -6445,7 +6448,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = talentTable.Name,
set = f.OnRadioCheckboxClick,
param = talentTable.ID,
get = function() return f.OptionsTable.pvptalent [talentTable.ID] end,
get = function() return f.OptionsTable.pvptalent [talentTable.ID] or f.OptionsTable.pvptalent [talentTable.ID .. ""] end,
texture = talentTable.Texture,
})
end
Expand Down Expand Up @@ -6543,7 +6546,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = groupTable.Name,
set = f.OnRadioCheckboxClick,
param = groupTable.ID,
get = function() return f.OptionsTable.group [groupTable.ID] end,
get = function() return f.OptionsTable.group [groupTable.ID] or f.OptionsTable.group [groupTable.ID .. ""] end,
})
end
local groupTypesGroup = DF:CreateRadionGroup (f, groupTypes, name, {width = 200, height = 200, title = "Group Types"})
Expand All @@ -6558,7 +6561,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = roleTable.Texture .. " " .. roleTable.Name,
set = f.OnRadioCheckboxClick,
param = roleTable.ID,
get = function() return f.OptionsTable.role [roleTable.ID] end,
get = function() return f.OptionsTable.role [roleTable.ID] or f.OptionsTable.role [roleTable.ID .. ""] end,
})
end
local roleTypesGroup = DF:CreateRadionGroup (f, roleTypes, name, {width = 200, height = 200, title = "Role Types"})
Expand All @@ -6575,7 +6578,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = affixName,
set = f.OnRadioCheckboxClick,
param = i,
get = function() return f.OptionsTable.affix [i] end,
get = function() return f.OptionsTable.affix [i] or f.OptionsTable.affix [i .. ""] end,
texture = texture,
})
end
Expand Down Expand Up @@ -6643,7 +6646,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = talentTable.Name,
set = DetailsFrameworkLoadConditionsPanel.OnRadioCheckboxClick,
param = talentTable.ID,
get = function() return DetailsFrameworkLoadConditionsPanel.OptionsTable.talent [talentTable.ID] end,
get = function() return DetailsFrameworkLoadConditionsPanel.OptionsTable.talent [talentTable.ID] or DetailsFrameworkLoadConditionsPanel.OptionsTable.talent [talentTable.ID .. ""] end,
texture = talentTable.Texture,
})
end
Expand All @@ -6657,7 +6660,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions)
name = talentTable.Name,
set = DetailsFrameworkLoadConditionsPanel.OnRadioCheckboxClick,
param = talentTable.ID,
get = function() return DetailsFrameworkLoadConditionsPanel.OptionsTable.pvptalent [talentTable.ID] end,
get = function() return DetailsFrameworkLoadConditionsPanel.OptionsTable.pvptalent [talentTable.ID] or DetailsFrameworkLoadConditionsPanel.OptionsTable.pvptalent [talentTable.ID .. ""] end,
texture = talentTable.Texture,
})
end
Expand Down
1 change: 0 additions & 1 deletion Libs/DF/timebar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ function TimeBarMetaFunctions:SetTimer(currentTime, startTime, endTime)
self.statusBar.timeLeft2 = currentTime
end

--print("min|max values:", self.statusBar.starTime, self.statusBar.endTime)
self.statusBar:SetMinMaxValues(self.statusBar.starTime, self.statusBar.endTime)

if (self.direction == "right") then
Expand Down
42 changes: 33 additions & 9 deletions Libs/NickTag-1.0/NickTag-1.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-- NickTag:SetNickname (name) -> set the player nick name, after set nicktag will broadcast the nick over addon guild channel.
--

local major, minor = "NickTag-1.0", 12
local major, minor = "NickTag-1.0", 13
local NickTag, oldminor = LibStub:NewLibrary (major, minor)

if (not NickTag) then
Expand Down Expand Up @@ -452,8 +452,26 @@ end
------------------------------------------------------------------------------------------------------------------------------------------------------
--> basic functions

local cyrillic = "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯЁЂЃЄЅІЇЈЉЊЋЌЎЏҐабвгдежзийклмнопрстуфхцчшщъыьэюяёђѓєѕіїјљњћќўџґАаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя"
local latin = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
local chinese = "ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚ᄀᄁᆪᄂᆬᆭᄃᄄᄅᆰᆱᆲᆳᆴᆵᄚᄆᄇᄈᄡᄉᄊᄋᄌᄍᄎᄏᄐᄑ하ᅢᅣᅤᅥᅦᅧᅨᅩᅪᅫᅬᅭᅮᅯᅰᅱᅲᅳᅴᅵ"

local alphabet = {
cyrillic,
latin,
chinese,
}

local allowedLetters = {}

for _, thisAlphabet in ipairs(alphabet) do
for letter in thisAlphabet:gmatch(".") do
allowedLetters[letter] = true
end
end

--> trim from from http://lua-users.org/wiki/StringTrim
function trim (s)
local function trim (s)
local from = s:match"^%s*()"
return from > #s and "" or s:match(".*%S", from)
end
Expand All @@ -474,31 +492,37 @@ end
end
end


--> we need to keep game smooth checking and formating nicknames.
--> SetNickname and names comming from other player need to be check.
function NickTag:CheckName (name)

--> as nicktag only work internally in the guild, we think that is not necessary a work filter to avoid people using bad language.

if (type (name) ~= "string") then
return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_4"] --> error 4 = name isn't a valid string
end

name = trim (name)

--> limit nickname to 12 characters, same as wow.
--cyrillic seems to double the len using 2 bytes
local len = string.len (name)
if (len > 12) then
return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_1"] --> error 1 = nickname is too long, max of 12 characters.
end

--> check if contain any non allowed characters, by now only accpet letters, numbers and spaces.
--> by default wow do not accetp spaces, but here will allow.
--> tested over lua 5.2 and this capture was okey with accents, not sure why inside wow this doesn't work.
local notallow = string.find (name, "[^a-zA-Z�������%s]")
if (notallow) then
return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_2"] --> error 2 = nickname only support letters, numbers and spaces.

-- local notallow = string.find (name, "[^a-zA-Z�������%s]")
-- if (notallow) then
-- return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_2"] --> error 2 = nickname only support letters, numbers and spaces.
-- end

for letter in name:gmatch(".") do
print(letter, allowedLetters[letter])
if (not allowedLetters[letter]) then
return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_2"] --> error 2 = nickname only support letters, numbers and spaces.
end
end

--> check if there is sequencial repeated characters, like "Jasooon" were repeats 3 times the "o" character.
Expand Down
Binary file modified images/news_images.tga
Binary file not shown.

0 comments on commit 025c7b9

Please sign in to comment.