фикс подписей
This commit is contained in:
@@ -82,6 +82,38 @@ local classTooltips = {};
|
|||||||
local detailedRaceTooltips = {};
|
local detailedRaceTooltips = {};
|
||||||
local detailedClassTooltips = {};
|
local detailedClassTooltips = {};
|
||||||
|
|
||||||
|
local function UTF8Chars(text)
|
||||||
|
return string.gmatch(text or "", "[%z\1-\127\194-\244][\128-\191]*")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function UTF8Length(text)
|
||||||
|
local length = 0
|
||||||
|
for _ in UTF8Chars(text) do
|
||||||
|
length = length + 1
|
||||||
|
end
|
||||||
|
return length
|
||||||
|
end
|
||||||
|
|
||||||
|
local function UTF8Sub(text, startChar, endChar)
|
||||||
|
local chars = {}
|
||||||
|
local currentChar = 1
|
||||||
|
|
||||||
|
startChar = math.max(startChar or 1, 1)
|
||||||
|
endChar = endChar or UTF8Length(text)
|
||||||
|
|
||||||
|
for char in UTF8Chars(text) do
|
||||||
|
if currentChar >= startChar and currentChar <= endChar then
|
||||||
|
chars[#chars + 1] = char
|
||||||
|
elseif currentChar > endChar then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
currentChar = currentChar + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
return table.concat(chars)
|
||||||
|
end
|
||||||
|
|
||||||
local function HideAllTooltips()
|
local function HideAllTooltips()
|
||||||
for button, tooltip in pairs(raceTooltips) do
|
for button, tooltip in pairs(raceTooltips) do
|
||||||
if tooltip then
|
if tooltip then
|
||||||
@@ -1056,16 +1088,16 @@ function CharacterCreateEnumerateClasses(...)
|
|||||||
|
|
||||||
if className == "Caballero de la Muerte" then
|
if className == "Caballero de la Muerte" then
|
||||||
button.nameFrame.text:SetText("Caballero\nde la Muerte");
|
button.nameFrame.text:SetText("Caballero\nde la Muerte");
|
||||||
elseif string.len(className) > 12 then
|
elseif UTF8Length(className) > 12 then
|
||||||
local spacePos = string.find(className, " ", 6)
|
local spacePos = string.find(className, " ", 6)
|
||||||
if spacePos then
|
if spacePos then
|
||||||
local firstPart = string.sub(className, 1, spacePos - 1);
|
local firstPart = string.sub(className, 1, spacePos - 1);
|
||||||
local secondPart = string.sub(className, spacePos + 1);
|
local secondPart = string.sub(className, spacePos + 1);
|
||||||
button.nameFrame.text:SetText(firstPart .. "\n" .. secondPart);
|
button.nameFrame.text:SetText(firstPart .. "\n" .. secondPart);
|
||||||
else
|
else
|
||||||
local midPoint = math.floor(string.len(className) / 2);
|
local midPoint = math.floor(UTF8Length(className) / 2);
|
||||||
local firstPart = string.sub(className, 1, midPoint);
|
local firstPart = UTF8Sub(className, 1, midPoint);
|
||||||
local secondPart = string.sub(className, midPoint + 1);
|
local secondPart = UTF8Sub(className, midPoint + 1);
|
||||||
button.nameFrame.text:SetText(firstPart .. "-\n" .. secondPart);
|
button.nameFrame.text:SetText(firstPart .. "-\n" .. secondPart);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user