More bug fixes
This commit is contained in:
+17
-20
@@ -88,7 +88,6 @@ function DF:LoadAllSpells (hashMap, indexTable, allSpellsSameName)
|
||||
end
|
||||
|
||||
elseif (hashMap and indexTable) then
|
||||
--DF_CALC_PERFORMANCE()
|
||||
if (allSpellsSameName) then
|
||||
for i = 1, CONST_MAX_SPELLS do
|
||||
local spellName = GetSpellInfo(i)
|
||||
@@ -128,9 +127,6 @@ local cleanfunction = function() end
|
||||
do
|
||||
local metaPrototype = {
|
||||
WidgetType = "aura_tracker",
|
||||
SetHook = DF.SetHook,
|
||||
RunHooksForWidget = DF.RunHooksForWidget,
|
||||
|
||||
dversion = DF.dversion,
|
||||
}
|
||||
|
||||
@@ -153,6 +149,7 @@ do
|
||||
end
|
||||
|
||||
local AuraTrackerMetaFunctions = _G[DF.GlobalWidgetControlNames["aura_tracker"]]
|
||||
DF:Mixin(AuraTrackerMetaFunctions, DF.ScriptHookMixin)
|
||||
|
||||
--create panels
|
||||
local on_profile_changed = function(self, newdb)
|
||||
@@ -357,13 +354,13 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
|
||||
local buff_blacklist_label = self:CreateLabel(background_add_blacklist, texts.MANUAL_ADD_BLACKLIST_BUFF, DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE"))
|
||||
local debuff_blacklist_label = self:CreateLabel(background_add_blacklist, texts.MANUAL_ADD_BLACKLIST_DEBUFF, DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE"))
|
||||
|
||||
local buff_name_blacklist_entry = self:CreateTextEntry (background_add_blacklist, function()end, textEntryWidth, 20, "AddBuffBlacklistTextBox", _, _, options_dropdown_template)
|
||||
local buff_name_blacklist_entry = self:CreateTextEntry(background_add_blacklist, function()end, textEntryWidth, 20, "AddBuffBlacklistTextBox", _, _, options_dropdown_template)
|
||||
buff_name_blacklist_entry:SetHook("OnEditFocusGained", load_all_spells)
|
||||
buff_name_blacklist_entry:SetJustifyH("left")
|
||||
buff_name_blacklist_entry.tooltip = "Enter the buff name using lower case letters."
|
||||
f_auto.AddBuffBlacklistTextBox = buff_name_blacklist_entry
|
||||
|
||||
local debuff_name_blacklist_entry = self:CreateTextEntry (background_add_blacklist, function()end, textEntryWidth, 20, "AddDebuffBlacklistTextBox", _, _, options_dropdown_template)
|
||||
local debuff_name_blacklist_entry = self:CreateTextEntry(background_add_blacklist, function()end, textEntryWidth, 20, "AddDebuffBlacklistTextBox", _, _, options_dropdown_template)
|
||||
debuff_name_blacklist_entry:SetHook("OnEditFocusGained", load_all_spells)
|
||||
debuff_name_blacklist_entry:SetJustifyH("left")
|
||||
debuff_name_blacklist_entry.tooltip = "Enter the debuff name using lower case letters."
|
||||
@@ -380,9 +377,9 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
|
||||
local spellWithSameName = AllSpellsSameName [spellName]
|
||||
if (spellWithSameName) then
|
||||
if (t) then
|
||||
t [spellName] = DF.table.copy ({}, spellWithSameName)
|
||||
t [spellName] = DF.table.copy({}, spellWithSameName)
|
||||
else
|
||||
db.aura_cache_by_name [spellName] = DF.table.copy ({}, spellWithSameName)
|
||||
db.aura_cache_by_name [spellName] = DF.table.copy({}, spellWithSameName)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -391,7 +388,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
|
||||
|
||||
local get_spellID_from_string = function(text)
|
||||
--check if the user entered a spell ID
|
||||
local isSpellID = tonumber (text)
|
||||
local isSpellID = tonumber(text)
|
||||
if (isSpellID and isSpellID > 1 and isSpellID < 10000000) then
|
||||
local isValidSpellID = GetSpellInfo(isSpellID)
|
||||
if (isValidSpellID) then
|
||||
@@ -530,13 +527,13 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
|
||||
local buff_tracklist_label = self:CreateLabel(background_add_tracklist, texts.MANUAL_ADD_TRACKLIST_BUFF, DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE"))
|
||||
local debuff_tracklist_label = self:CreateLabel(background_add_tracklist, texts.MANUAL_ADD_TRACKLIST_DEBUFF, DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE"))
|
||||
|
||||
local buff_name_tracklist_entry = self:CreateTextEntry (background_add_tracklist, function()end, textEntryWidth, 20, "AddBuffTracklistTextBox", _, _, options_dropdown_template)
|
||||
local buff_name_tracklist_entry = self:CreateTextEntry(background_add_tracklist, function()end, textEntryWidth, 20, "AddBuffTracklistTextBox", _, _, options_dropdown_template)
|
||||
buff_name_tracklist_entry:SetHook("OnEditFocusGained", load_all_spells)
|
||||
buff_name_tracklist_entry:SetJustifyH("left")
|
||||
buff_name_tracklist_entry.tooltip = "Enter the buff name using lower case letters."
|
||||
f_auto.AddBuffTracklistTextBox = buff_name_tracklist_entry
|
||||
|
||||
local debuff_name_tracklist_entry = self:CreateTextEntry (background_add_tracklist, function()end, textEntryWidth, 20, "AddDebuffTracklistTextBox", _, _, options_dropdown_template)
|
||||
local debuff_name_tracklist_entry = self:CreateTextEntry(background_add_tracklist, function()end, textEntryWidth, 20, "AddDebuffTracklistTextBox", _, _, options_dropdown_template)
|
||||
debuff_name_tracklist_entry:SetHook("OnEditFocusGained", load_all_spells)
|
||||
debuff_name_tracklist_entry:SetJustifyH("left")
|
||||
debuff_name_tracklist_entry.tooltip = "Enter the debuff name using lower case letters."
|
||||
@@ -771,7 +768,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
|
||||
line.name:SetText(spellName .. " (" .. spellID .. ")")
|
||||
end
|
||||
line.icon:SetTexture(spellIcon)
|
||||
line.icon:SetTexCoord (.1, .9, .1, .9)
|
||||
line.icon:SetTexCoord(.1, .9, .1, .9)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1024,7 +1021,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
|
||||
if (name) then
|
||||
line.name:SetText(name)
|
||||
line.icon:SetTexture(icon)
|
||||
line.icon:SetTexCoord (.1, .9, .1, .9)
|
||||
line.icon:SetTexCoord(.1, .9, .1, .9)
|
||||
else
|
||||
line.name:SetText(aura)
|
||||
line.icon:SetTexture([[Interface\InventoryItems\WoWUnknownItem01]])
|
||||
@@ -1065,8 +1062,8 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
|
||||
-- build the text entry to type the spellname
|
||||
local new_buff_string = self:CreateLabel(f_manual, "Add Buff")
|
||||
local new_debuff_string = self:CreateLabel(f_manual, "Add Debuff")
|
||||
local new_buff_entry = self:CreateTextEntry (f_manual, function()end, 200, 20, "NewBuffTextBox", _, _, options_dropdown_template)
|
||||
local new_debuff_entry = self:CreateTextEntry (f_manual, function()end, 200, 20, "NewDebuffTextBox", _, _, options_dropdown_template)
|
||||
local new_buff_entry = self:CreateTextEntry(f_manual, function()end, 200, 20, "NewBuffTextBox", _, _, options_dropdown_template)
|
||||
local new_debuff_entry = self:CreateTextEntry(f_manual, function()end, 200, 20, "NewDebuffTextBox", _, _, options_dropdown_template)
|
||||
|
||||
new_buff_entry:SetHook("OnEditFocusGained", load_all_spells)
|
||||
new_debuff_entry:SetHook("OnEditFocusGained", load_all_spells)
|
||||
@@ -1084,7 +1081,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
|
||||
|
||||
if (text ~= "") then
|
||||
--check for more than one spellname
|
||||
if (text:find (";")) then
|
||||
if (text:find(";")) then
|
||||
for _, spellName in ipairs({strsplit(";", text)}) do
|
||||
spellName = self:trim (spellName)
|
||||
local spellID = get_spellID_from_string (spellName)
|
||||
@@ -1131,7 +1128,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
|
||||
new_debuff_entry:ClearFocus()
|
||||
if (text ~= "") then
|
||||
--check for more than one spellname
|
||||
if (text:find (";")) then
|
||||
if (text:find(";")) then
|
||||
for _, spellName in ipairs({strsplit(";", text)}) do
|
||||
spellName = self:trim (spellName)
|
||||
local spellID = get_spellID_from_string (spellName)
|
||||
@@ -1177,7 +1174,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
|
||||
multiple_spells_label:SetSize(350, 24)
|
||||
multiple_spells_label:SetJustifyV ("top")
|
||||
|
||||
local export_box = self:CreateTextEntry (f_manual, function()end, 242, 20, "ExportAuraTextBox", _, _, options_dropdown_template)
|
||||
local export_box = self:CreateTextEntry(f_manual, function()end, 242, 20, "ExportAuraTextBox", _, _, options_dropdown_template)
|
||||
|
||||
local export_buff_button = self:CreateButton(f_manual, function()
|
||||
local str = ""
|
||||
@@ -1188,7 +1185,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
|
||||
end
|
||||
end
|
||||
export_box.text = str
|
||||
export_box:SetFocus (true)
|
||||
export_box:SetFocus(true)
|
||||
export_box:HighlightText()
|
||||
|
||||
end, 120, 20, "Export Buffs", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"))
|
||||
@@ -1203,7 +1200,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
|
||||
end
|
||||
|
||||
export_box.text = str
|
||||
export_box:SetFocus (true)
|
||||
export_box:SetFocus(true)
|
||||
export_box:HighlightText()
|
||||
|
||||
end, 120, 20, "Export Debuffs", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"))
|
||||
|
||||
+93
-120
@@ -6,16 +6,12 @@ if (not DF or not DetailsFrameworkCanLoad) then
|
||||
end
|
||||
|
||||
local _
|
||||
local cleanfunction = function() end
|
||||
local emptyFunction = function() end
|
||||
local APIButtonFunctions = false
|
||||
|
||||
do
|
||||
local metaPrototype = {
|
||||
WidgetType = "button",
|
||||
SetHook = DF.SetHook,
|
||||
HasHook = DF.HasHook,
|
||||
ClearHooks = DF.ClearHooks,
|
||||
RunHooksForWidget = DF.RunHooksForWidget,
|
||||
dversion = DF.dversion
|
||||
}
|
||||
|
||||
@@ -41,6 +37,8 @@ local ButtonMetaFunctions = _G[DF.GlobalWidgetControlNames["button"]]
|
||||
|
||||
DF:Mixin(ButtonMetaFunctions, DF.SetPointMixin)
|
||||
DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
DF:Mixin(ButtonMetaFunctions, DF.TooltipHandlerMixin)
|
||||
DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--metatables
|
||||
@@ -123,7 +121,7 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
ButtonMetaFunctions.GetMembers["fontsize"] = gmember_textsize
|
||||
ButtonMetaFunctions.GetMembers["textcolor"] = gmember_textcolor --alias
|
||||
ButtonMetaFunctions.GetMembers["textfont"] = gmember_textfont --alias
|
||||
ButtonMetaFunctions.GetMembers["textsize"] = gmember_textsize --alias
|
||||
ButtonMetaFunctions.GetMembers["textsize"] = gmember_textsize --alias
|
||||
|
||||
ButtonMetaFunctions.__index = function(_table, _member_requested)
|
||||
|
||||
@@ -131,15 +129,15 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
if (func) then
|
||||
return func (_table, _member_requested)
|
||||
end
|
||||
|
||||
local fromMe = rawget (_table, _member_requested)
|
||||
|
||||
local fromMe = rawget(_table, _member_requested)
|
||||
if (fromMe) then
|
||||
return fromMe
|
||||
end
|
||||
|
||||
|
||||
return ButtonMetaFunctions [_member_requested]
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--tooltip
|
||||
@@ -198,7 +196,7 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
--text color
|
||||
local smember_textcolor = function(_object, _value)
|
||||
local _value1, _value2, _value3, _value4 = DF:ParseColors(_value)
|
||||
return _object.button.text:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
return _object.button.text:SetTextColor(_value1, _value2, _value3, _value4)
|
||||
end
|
||||
|
||||
--text font
|
||||
@@ -261,7 +259,7 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
_object.capsule_textalign = "right"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
ButtonMetaFunctions.SetMembers = ButtonMetaFunctions.SetMembers or {}
|
||||
ButtonMetaFunctions.SetMembers ["tooltip"] = smember_tooltip
|
||||
ButtonMetaFunctions.SetMembers ["show"] = smember_show
|
||||
@@ -281,7 +279,7 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
ButtonMetaFunctions.SetMembers ["texture"] = smember_texture
|
||||
ButtonMetaFunctions.SetMembers ["locked"] = smember_locked
|
||||
ButtonMetaFunctions.SetMembers ["textalign"] = smember_textalign
|
||||
|
||||
|
||||
ButtonMetaFunctions.__newindex = function(_table, _key, _value)
|
||||
local func = ButtonMetaFunctions.SetMembers [_key]
|
||||
if (func) then
|
||||
@@ -294,26 +292,13 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--methods
|
||||
|
||||
--tooltip
|
||||
function ButtonMetaFunctions:SetTooltip(tooltip)
|
||||
if (tooltip) then
|
||||
return rawset(self, "have_tooltip", tooltip)
|
||||
else
|
||||
return rawset(self, "have_tooltip", nil)
|
||||
end
|
||||
end
|
||||
|
||||
function ButtonMetaFunctions:GetTooltip()
|
||||
return rawget(self, "have_tooltip")
|
||||
end
|
||||
|
||||
--functions
|
||||
function ButtonMetaFunctions:SetClickFunction(func, param1, param2, clickType)
|
||||
if (not clickType or string.find(string.lower(clickType), "left")) then
|
||||
if (func) then
|
||||
rawset(self, "func", func)
|
||||
else
|
||||
rawset(self, "func", cleanfunction)
|
||||
rawset(self, "func", emptyFunction)
|
||||
end
|
||||
|
||||
if (param1 ~= nil) then
|
||||
@@ -323,11 +308,11 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
rawset(self, "param2", param2)
|
||||
end
|
||||
|
||||
elseif (clickType or string.find (string.lower (clickType), "right")) then
|
||||
elseif (clickType or string.find(string.lower(clickType), "right")) then
|
||||
if (func) then
|
||||
rawset(self, "funcright", func)
|
||||
else
|
||||
rawset(self, "funcright", cleanfunction)
|
||||
rawset(self, "funcright", emptyFunction)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -521,7 +506,7 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
return
|
||||
end
|
||||
|
||||
button.MyObject.is_mouse_over = true
|
||||
object.is_mouse_over = true
|
||||
|
||||
if (button.texture) then
|
||||
if (button.texture.coords) then
|
||||
@@ -531,23 +516,15 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
end
|
||||
end
|
||||
|
||||
if (button.MyObject.onenter_backdrop_border_color) then
|
||||
button:SetBackdropBorderColor(unpack(button.MyObject.onenter_backdrop_border_color))
|
||||
if (object.onenter_backdrop_border_color) then
|
||||
button:SetBackdropBorderColor(unpack(object.onenter_backdrop_border_color))
|
||||
end
|
||||
|
||||
if (button.MyObject.onenter_backdrop) then
|
||||
button:SetBackdropColor(unpack(button.MyObject.onenter_backdrop))
|
||||
if (object.onenter_backdrop) then
|
||||
button:SetBackdropColor(unpack(object.onenter_backdrop))
|
||||
end
|
||||
|
||||
if (button.MyObject.have_tooltip) then
|
||||
GameCooltip2:Preset(2)
|
||||
if (type(button.MyObject.have_tooltip) == "function") then
|
||||
GameCooltip2:AddLine(button.MyObject.have_tooltip() or "")
|
||||
else
|
||||
GameCooltip2:AddLine(button.MyObject.have_tooltip)
|
||||
end
|
||||
GameCooltip2:ShowCooltip(button, "tooltip")
|
||||
end
|
||||
object:ShowTooltip()
|
||||
end
|
||||
|
||||
local OnLeave = function(button)
|
||||
@@ -558,9 +535,9 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
return
|
||||
end
|
||||
|
||||
button.MyObject.is_mouse_over = false
|
||||
object.is_mouse_over = false
|
||||
|
||||
if (button.texture and not button.MyObject.is_mouse_down) then
|
||||
if (button.texture and not object.is_mouse_down) then
|
||||
if (button.texture.coords) then
|
||||
button.texture:SetTexCoord(unpack(button.texture.coords.Normal))
|
||||
else
|
||||
@@ -568,19 +545,15 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
end
|
||||
end
|
||||
|
||||
if (button.MyObject.onleave_backdrop_border_color) then
|
||||
button:SetBackdropBorderColor(unpack(button.MyObject.onleave_backdrop_border_color))
|
||||
if (object.onleave_backdrop_border_color) then
|
||||
button:SetBackdropBorderColor(unpack(object.onleave_backdrop_border_color))
|
||||
end
|
||||
|
||||
if (button.MyObject.onleave_backdrop) then
|
||||
button:SetBackdropColor(unpack(button.MyObject.onleave_backdrop))
|
||||
if (object.onleave_backdrop) then
|
||||
button:SetBackdropColor(unpack(object.onleave_backdrop))
|
||||
end
|
||||
|
||||
if (button.MyObject.have_tooltip) then
|
||||
if (GameCooltip2:GetText(1) == button.MyObject.have_tooltip or type(button.MyObject.have_tooltip) == "function") then
|
||||
GameCooltip2:Hide()
|
||||
end
|
||||
end
|
||||
object:HideTooltip()
|
||||
end
|
||||
|
||||
local OnHide = function(button)
|
||||
@@ -600,18 +573,18 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
end
|
||||
|
||||
local OnMouseDown = function(button, buttontype)
|
||||
local object = button.MyObject
|
||||
|
||||
if (not button:IsEnabled()) then
|
||||
return
|
||||
end
|
||||
|
||||
local object = button.MyObject
|
||||
|
||||
local kill = object:RunHooksForWidget("OnMouseDown", button, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
|
||||
button.MyObject.is_mouse_down = true
|
||||
object.is_mouse_down = true
|
||||
|
||||
if (button.texture) then
|
||||
if (button.texture.coords) then
|
||||
@@ -621,22 +594,22 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
end
|
||||
end
|
||||
|
||||
if (button.MyObject.capsule_textalign) then
|
||||
if (button.MyObject.icon) then
|
||||
button.MyObject.icon:SetPoint("left", button, "left", 5 + (button.MyObject.icon.leftpadding or 0), -1)
|
||||
if (object.capsule_textalign) then
|
||||
if (object.icon) then
|
||||
object.icon:SetPoint("left", button, "left", 5 + (object.icon.leftpadding or 0), -1)
|
||||
|
||||
elseif (button.MyObject.capsule_textalign == "left") then
|
||||
elseif (object.capsule_textalign == "left") then
|
||||
button.text:SetPoint("left", button, "left", 3, -1)
|
||||
|
||||
elseif (button.MyObject.capsule_textalign == "center") then
|
||||
elseif (object.capsule_textalign == "center") then
|
||||
button.text:SetPoint("center", button, "center", 1, -1)
|
||||
|
||||
elseif (button.MyObject.capsule_textalign == "right") then
|
||||
elseif (object.capsule_textalign == "right") then
|
||||
button.text:SetPoint("right", button, "right", -1, -1)
|
||||
end
|
||||
else
|
||||
if (button.MyObject.icon) then
|
||||
button.MyObject.icon:SetPoint("left", button, "left", 5 + (button.MyObject.icon.leftpadding or 0), -1)
|
||||
if (object.icon) then
|
||||
object.icon:SetPoint("left", button, "left", 5 + (object.icon.leftpadding or 0), -1)
|
||||
else
|
||||
button.text:SetPoint("center", button,"center", 1, -1)
|
||||
end
|
||||
@@ -647,19 +620,19 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
button.x = floor(x)
|
||||
button.y = floor(y)
|
||||
|
||||
if (not button.MyObject.container.isLocked and button.MyObject.container:IsMovable()) then
|
||||
if (not object.container.isLocked and object.container:IsMovable()) then
|
||||
if (not button.isLocked and button:IsMovable()) then
|
||||
button.MyObject.container.isMoving = true
|
||||
button.MyObject.container:StartMoving()
|
||||
object.container.isMoving = true
|
||||
object.container:StartMoving()
|
||||
end
|
||||
end
|
||||
|
||||
if (button.MyObject.options.OnGrab) then
|
||||
if (type(button.MyObject.options.OnGrab) == "string" and button.MyObject.options.OnGrab == "PassClick") then
|
||||
if (object.options.OnGrab) then
|
||||
if (type(object.options.OnGrab) == "string" and object.options.OnGrab == "PassClick") then
|
||||
if (buttontype == "LeftButton") then
|
||||
DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseDown()", button.MyObject.func, button, buttontype, button.MyObject.param1, button.MyObject.param2)
|
||||
DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseDown()", object.func, button, buttontype, object.param1, object.param2)
|
||||
else
|
||||
DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseDown()", button.MyObject.funcright, button, buttontype, button.MyObject.param1, button.MyObject.param2)
|
||||
DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseDown()", object.funcright, button, buttontype, object.param1, object.param2)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -671,22 +644,23 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
end
|
||||
|
||||
local object = button.MyObject
|
||||
|
||||
local kill = object:RunHooksForWidget("OnMouseUp", button, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
|
||||
button.MyObject.is_mouse_down = false
|
||||
object.is_mouse_down = false
|
||||
|
||||
if (button.texture) then
|
||||
if (button.texture.coords) then
|
||||
if (button.MyObject.is_mouse_over) then
|
||||
if (object.is_mouse_over) then
|
||||
button.texture:SetTexCoord(unpack(button.texture.coords.Highlight))
|
||||
else
|
||||
button.texture:SetTexCoord(unpack(coords.Normal))
|
||||
end
|
||||
else
|
||||
if (button.MyObject.is_mouse_over) then
|
||||
if (object.is_mouse_over) then
|
||||
button.texture:SetTexCoord(0, 1, 0.24609375, 0.49609375)
|
||||
else
|
||||
button.texture:SetTexCoord(0, 1, 0, 0.24609375)
|
||||
@@ -694,30 +668,30 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
end
|
||||
end
|
||||
|
||||
if (button.MyObject.capsule_textalign) then
|
||||
if (button.MyObject.icon) then
|
||||
button.MyObject.icon:SetPoint("left", button, "left", 4 + (button.MyObject.icon.leftpadding or 0), 0)
|
||||
if (object.capsule_textalign) then
|
||||
if (object.icon) then
|
||||
object.icon:SetPoint("left", button, "left", 4 + (object.icon.leftpadding or 0), 0)
|
||||
|
||||
elseif (button.MyObject.capsule_textalign == "left") then
|
||||
elseif (object.capsule_textalign == "left") then
|
||||
button.text:SetPoint("left", button, "left", 2, 0)
|
||||
|
||||
elseif (button.MyObject.capsule_textalign == "center") then
|
||||
elseif (object.capsule_textalign == "center") then
|
||||
button.text:SetPoint("center", button, "center", 0, 0)
|
||||
|
||||
elseif (button.MyObject.capsule_textalign == "right") then
|
||||
elseif (object.capsule_textalign == "right") then
|
||||
button.text:SetPoint("right", button, "right", -2, 0)
|
||||
end
|
||||
else
|
||||
if (button.MyObject.icon) then
|
||||
button.MyObject.icon:SetPoint("left", button, "left", 4 + (button.MyObject.icon.leftpadding or 0), 0)
|
||||
if (object.icon) then
|
||||
object.icon:SetPoint("left", button, "left", 4 + (object.icon.leftpadding or 0), 0)
|
||||
else
|
||||
button.text:SetPoint("center", button,"center", 0, 0)
|
||||
end
|
||||
end
|
||||
|
||||
if (button.MyObject.container.isMoving) then
|
||||
button.MyObject.container:StopMovingOrSizing()
|
||||
button.MyObject.container.isMoving = false
|
||||
if (object.container.isMoving) then
|
||||
object.container:StopMovingOrSizing()
|
||||
object.container.isMoving = false
|
||||
end
|
||||
|
||||
local x, y = GetCursorPosition()
|
||||
@@ -728,9 +702,9 @@ DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
|
||||
if ((x == button.x and y == button.y) or (button.mouse_down + 0.5 > GetTime() and button:IsMouseOver())) then
|
||||
if (buttonType == "LeftButton") then
|
||||
DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseUp()", button.MyObject.func, button, buttonType, button.MyObject.param1, button.MyObject.param2)
|
||||
DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseUp()", object.func, button, buttonType, object.param1, object.param2)
|
||||
else
|
||||
DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseUp()", button.MyObject.funcright, button, buttonType, button.MyObject.param1, button.MyObject.param2)
|
||||
DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseUp()", object.funcright, button, buttonType, object.param1, object.param2)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -792,8 +766,8 @@ function ButtonMetaFunctions:SetTemplate(template)
|
||||
end
|
||||
|
||||
if (template.icon) then
|
||||
local i = template.icon
|
||||
self:SetIcon(i.texture, i.width, i.height, i.layout, i.texcoord, i.color, i.textdistance, i.leftpadding)
|
||||
local iconInfo = template.icon
|
||||
self:SetIcon(iconInfo.texture, iconInfo.width, iconInfo.height, iconInfo.layout, iconInfo.texcoord, iconInfo.color, iconInfo.textdistance, iconInfo.leftpadding)
|
||||
end
|
||||
|
||||
if (template.textsize) then
|
||||
@@ -815,7 +789,6 @@ end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--object constructor
|
||||
|
||||
local onDisableFunc = function(self)
|
||||
self.texture_disabled:Show()
|
||||
self.texture_disabled:SetVertexColor(0, 0, 0)
|
||||
@@ -830,10 +803,10 @@ end
|
||||
self:SetSize(100, 20)
|
||||
|
||||
self.text = self:CreateFontString("$parent_Text", "ARTWORK", "GameFontNormal")
|
||||
self:SetFontString(self.text)
|
||||
self.text:SetJustifyH("CENTER")
|
||||
DF:SetFontSize(self.text, 10)
|
||||
self.text:SetPoint("CENTER", self, "CENTER", 0, 0)
|
||||
self:SetFontString(self.text)
|
||||
DF:SetFontSize(self.text, 10)
|
||||
|
||||
self.texture_disabled = self:CreateTexture("$parent_TextureDisabled", "OVERLAY")
|
||||
self.texture_disabled:SetAllPoints()
|
||||
@@ -883,10 +856,9 @@ end
|
||||
DF:Mixin(buttonObject.button, DF.WidgetFunctions)
|
||||
|
||||
createButtonWidgets(buttonObject.button)
|
||||
|
||||
buttonObject.button:SetSize(width or 100, height or 20)
|
||||
buttonObject.widget = buttonObject.button
|
||||
buttonObject.button:SetBackdropColor(0, 0, 0, 0.4)
|
||||
buttonObject.button:SetBackdropBorderColor(1, 1, 1, 1)
|
||||
buttonObject.button.MyObject = buttonObject
|
||||
|
||||
if (not APIButtonFunctions) then
|
||||
APIButtonFunctions = true
|
||||
@@ -901,10 +873,6 @@ end
|
||||
end
|
||||
end
|
||||
|
||||
buttonObject.button:SetWidth(width or 100)
|
||||
buttonObject.button:SetHeight(height or 20)
|
||||
buttonObject.button.MyObject = buttonObject
|
||||
|
||||
buttonObject.text_overlay = _G[name .. "_Text"]
|
||||
buttonObject.disabled_overlay = _G[name .. "_TextureDisabled"]
|
||||
|
||||
@@ -914,7 +882,9 @@ end
|
||||
buttonObject.button:SetDisabledTexture(texture)
|
||||
buttonObject.button:SetHighlightTexture(texture, "ADD")
|
||||
|
||||
buttonObject.button.text:SetText(text or "")
|
||||
local locTable = text
|
||||
DF.Language.SetTextWithLocTableWithDefault(buttonObject.button.text, locTable, text)
|
||||
|
||||
buttonObject.button.text:SetPoint("center", buttonObject.button, "center")
|
||||
|
||||
local textWidth = buttonObject.button.text:GetStringWidth()
|
||||
@@ -943,8 +913,8 @@ end
|
||||
end
|
||||
end
|
||||
|
||||
buttonObject.func = func or cleanfunction
|
||||
buttonObject.funcright = cleanfunction
|
||||
buttonObject.func = func or emptyFunction
|
||||
buttonObject.funcright = emptyFunction
|
||||
buttonObject.param1 = param1
|
||||
buttonObject.param2 = param2
|
||||
buttonObject.short_method = shortMethod
|
||||
@@ -953,10 +923,12 @@ end
|
||||
if (textTemplate.size) then
|
||||
DF:SetFontSize(buttonObject.button.text, textTemplate.size)
|
||||
end
|
||||
|
||||
if (textTemplate.color) then
|
||||
local r, g, b, a = DF:ParseColors(textTemplate.color)
|
||||
buttonObject.button.text:SetTextColor(r, g, b, a)
|
||||
end
|
||||
|
||||
if (textTemplate.font) then
|
||||
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
|
||||
local font = SharedMedia:Fetch("font", textTemplate.font)
|
||||
@@ -1027,31 +999,32 @@ end
|
||||
|
||||
function DF:NewColorPickButton(parent, name, member, callback, alpha, buttonTemplate)
|
||||
--button
|
||||
local button = DF:NewButton(parent, _, name, member, 16, 16, pickcolor, alpha, "param2", nil, nil, nil, buttonTemplate)
|
||||
button.color_callback = callback
|
||||
button.Cancel = colorpickCancel
|
||||
button.SetColor = setColorPickColor
|
||||
button.GetColor = getColorPickColor
|
||||
local colorPickButton = DF:NewButton(parent, _, name, member, 16, 16, pickcolor, alpha, "param2", nil, nil, nil, buttonTemplate)
|
||||
colorPickButton.color_callback = callback
|
||||
colorPickButton.Cancel = colorpickCancel
|
||||
colorPickButton.SetColor = setColorPickColor
|
||||
colorPickButton.GetColor = getColorPickColor
|
||||
|
||||
button.HookList.OnColorChanged = {}
|
||||
colorPickButton.HookList.OnColorChanged = {}
|
||||
|
||||
if (not buttonTemplate) then
|
||||
button:InstallCustomTexture()
|
||||
colorPickButton:SetTemplate(DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"))
|
||||
end
|
||||
|
||||
local background = button:CreateTexture(nil, "background", nil, 2)
|
||||
background:SetPoint("topleft", button.widget, "topleft", 0, 0)
|
||||
background:SetPoint("bottomright", button.widget, "bottomright", 0, 0)
|
||||
--background showing a grid to indicate the transparency
|
||||
local background = colorPickButton:CreateTexture(nil, "background", nil, 2)
|
||||
background:SetPoint("topleft", colorPickButton.widget, "topleft", 0, 0)
|
||||
background:SetPoint("bottomright", colorPickButton.widget, "bottomright", 0, 0)
|
||||
background:SetTexture([[Interface\ITEMSOCKETINGFRAME\UI-EMPTYSOCKET]])
|
||||
background:SetTexCoord(3/16, 13/16, 3/16, 13/16)
|
||||
background:SetAlpha(0.3)
|
||||
|
||||
--color texture
|
||||
local img = DF:NewImage(button, nil, 16, 16, nil, nil, "color_texture", "$parentTex")
|
||||
img:SetColorTexture(1, 1, 1)
|
||||
img:SetPoint("topleft", button.widget, "topleft", 0, 0)
|
||||
img:SetPoint("bottomright", button.widget, "bottomright", 0, 0)
|
||||
img:SetDrawLayer("background", 3)
|
||||
--texture which shows the texture color
|
||||
local colorTexture = DF:NewImage(colorPickButton, nil, 16, 16, nil, nil, "color_texture", "$parentTex")
|
||||
colorTexture:SetColorTexture(1, 1, 1)
|
||||
colorTexture:SetPoint("topleft", colorPickButton.widget, "topleft", 0, 0)
|
||||
colorTexture:SetPoint("bottomright", colorPickButton.widget, "bottomright", 0, 0)
|
||||
colorTexture:SetDrawLayer("background", 3)
|
||||
|
||||
return button
|
||||
return colorPickButton
|
||||
end
|
||||
|
||||
+9
-4
@@ -15,7 +15,7 @@ local max = math.max
|
||||
|
||||
--api locals
|
||||
local PixelUtil = PixelUtil or DFPixelUtil
|
||||
local version = 4
|
||||
local version = 5
|
||||
|
||||
local CONST_MENU_TYPE_MAINMENU = "main"
|
||||
local CONST_MENU_TYPE_SUBMENU = "sub"
|
||||
@@ -1142,7 +1142,7 @@ function DF:CreateCoolTip()
|
||||
function gameCooltip:StatusBar(menuButton, statusBarSettings)
|
||||
if (statusBarSettings) then
|
||||
menuButton.statusbar:SetValue(statusBarSettings[1])
|
||||
menuButton.statusbar:SetStatusBarColor (statusBarSettings[2], statusBarSettings[3], statusBarSettings[4], statusBarSettings[5])
|
||||
menuButton.statusbar:SetStatusBarColor(statusBarSettings[2], statusBarSettings[3], statusBarSettings[4], statusBarSettings[5])
|
||||
menuButton.statusbar:SetHeight(20 + (gameCooltip.OptionsTable.StatusBarHeightMod or 0))
|
||||
|
||||
menuButton.spark2:Hide()
|
||||
@@ -1160,9 +1160,9 @@ function DF:CreateCoolTip()
|
||||
end
|
||||
if (statusBarSettings[7].color) then
|
||||
local colorRed, colorGreen, colorBlue, colorAlpha = DF:ParseColors(statusBarSettings[7].color)
|
||||
menuButton.statusbar2:SetStatusBarColor (colorRed, colorGreen, colorBlue, colorAlpha)
|
||||
menuButton.statusbar2:SetStatusBarColor(colorRed, colorGreen, colorBlue, colorAlpha)
|
||||
else
|
||||
menuButton.statusbar2:SetStatusBarColor (1, 1, 1, 1)
|
||||
menuButton.statusbar2:SetStatusBarColor(1, 1, 1, 1)
|
||||
end
|
||||
else
|
||||
menuButton.statusbar2:SetValue(0)
|
||||
@@ -1961,6 +1961,11 @@ function DF:CreateCoolTip()
|
||||
return gameCooltip.Host
|
||||
end
|
||||
|
||||
function gameCooltip:IsOwner(frame)
|
||||
local currentOwner = gameCooltip:GetOwner()
|
||||
return currentOwner == frame
|
||||
end
|
||||
|
||||
--set the anchor of cooltip, parameters: frame [, cooltip anchor point, frame anchor point[, x mod, y mod]]
|
||||
function gameCooltip:SetOwner(frame, myPoint, hisPoint, x, y)
|
||||
return gameCooltip:SetHost(frame, myPoint, hisPoint, x, y)
|
||||
|
||||
+63
-66
@@ -10,10 +10,6 @@ local loadedAPIDropDownFunctions = false
|
||||
do
|
||||
local metaPrototype = {
|
||||
WidgetType = "dropdown",
|
||||
SetHook = DF.SetHook,
|
||||
HasHook = DF.HasHook,
|
||||
ClearHooks = DF.ClearHooks,
|
||||
RunHooksForWidget = DF.RunHooksForWidget,
|
||||
dversion = DF.dversion,
|
||||
}
|
||||
|
||||
@@ -39,49 +35,58 @@ local DropDownMetaFunctions = _G[DF.GlobalWidgetControlNames["dropdown"]]
|
||||
|
||||
DF:Mixin(DropDownMetaFunctions, DF.SetPointMixin)
|
||||
DF:Mixin(DropDownMetaFunctions, DF.FrameMixin)
|
||||
DF:Mixin(DropDownMetaFunctions, DF.TooltipHandlerMixin)
|
||||
DF:Mixin(DropDownMetaFunctions, DF.ScriptHookMixin)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--metatables
|
||||
|
||||
DropDownMetaFunctions.__call = function(_table, value)
|
||||
DropDownMetaFunctions.__call = function(object, value)
|
||||
--unknown
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--members
|
||||
|
||||
--selected value
|
||||
local gmember_value = function(object)
|
||||
return object:GetValue()
|
||||
end
|
||||
|
||||
--tooltip
|
||||
local gmember_tooltip = function(object)
|
||||
return object:GetTooltip()
|
||||
end
|
||||
|
||||
--shown
|
||||
local gmember_shown = function(object)
|
||||
return object:IsShown()
|
||||
end
|
||||
|
||||
--frame width
|
||||
local gmember_width = function(object)
|
||||
return object.button:GetWidth()
|
||||
end
|
||||
|
||||
--frame height
|
||||
local gmember_height = function(object)
|
||||
return object.button:GetHeight()
|
||||
end
|
||||
|
||||
--current text
|
||||
local gmember_text = function(object)
|
||||
return object.label:GetText()
|
||||
end
|
||||
|
||||
--menu creation function
|
||||
local gmember_function = function(object)
|
||||
return object:GetFunction()
|
||||
end
|
||||
|
||||
--menu width
|
||||
local gmember_menuwidth = function(object)
|
||||
return rawget(object, "realsizeW")
|
||||
end
|
||||
|
||||
--menu height
|
||||
local gmember_menuheight = function(object)
|
||||
return rawget(object, "realsizeH")
|
||||
@@ -118,6 +123,7 @@ DF:Mixin(DropDownMetaFunctions, DF.FrameMixin)
|
||||
local smember_tooltip = function(object, value)
|
||||
return object:SetTooltip(value)
|
||||
end
|
||||
|
||||
--show
|
||||
local smember_show = function(object, value)
|
||||
if (value) then
|
||||
@@ -126,6 +132,7 @@ DF:Mixin(DropDownMetaFunctions, DF.FrameMixin)
|
||||
return object:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
--hide
|
||||
local smember_hide = function(object, value)
|
||||
if (not value) then
|
||||
@@ -134,36 +141,41 @@ DF:Mixin(DropDownMetaFunctions, DF.FrameMixin)
|
||||
return object:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
--frame width
|
||||
local smember_width = function(object, value)
|
||||
return object.dropdown:SetWidth(value)
|
||||
end
|
||||
|
||||
--frame height
|
||||
local smember_height = function(object, value)
|
||||
return object.dropdown:SetHeight(value)
|
||||
end
|
||||
end
|
||||
|
||||
--menu creation function
|
||||
local smember_function = function(object, value)
|
||||
return object:SetFunction(value)
|
||||
end
|
||||
|
||||
--menu width
|
||||
local smember_menuwidth = function(object, value)
|
||||
object:SetMenuSize(value, nil)
|
||||
end
|
||||
|
||||
--menu height
|
||||
local smember_menuheight = function(object, value)
|
||||
object:SetMenuSize(nil, value)
|
||||
end
|
||||
|
||||
DropDownMetaFunctions.SetMembers = DropDownMetaFunctions.SetMembers or {}
|
||||
DropDownMetaFunctions.SetMembers ["tooltip"] = smember_tooltip
|
||||
DropDownMetaFunctions.SetMembers ["show"] = smember_show
|
||||
DropDownMetaFunctions.SetMembers ["hide"] = smember_hide
|
||||
DropDownMetaFunctions.SetMembers ["width"] = smember_width
|
||||
DropDownMetaFunctions.SetMembers ["menuwidth"] = smember_menuwidth
|
||||
DropDownMetaFunctions.SetMembers ["height"] = smember_height
|
||||
DropDownMetaFunctions.SetMembers ["menuheight"] = smember_menuheight
|
||||
DropDownMetaFunctions.SetMembers ["func"] = smember_function
|
||||
DropDownMetaFunctions.SetMembers["tooltip"] = smember_tooltip
|
||||
DropDownMetaFunctions.SetMembers["show"] = smember_show
|
||||
DropDownMetaFunctions.SetMembers["hide"] = smember_hide
|
||||
DropDownMetaFunctions.SetMembers["width"] = smember_width
|
||||
DropDownMetaFunctions.SetMembers["menuwidth"] = smember_menuwidth
|
||||
DropDownMetaFunctions.SetMembers["height"] = smember_height
|
||||
DropDownMetaFunctions.SetMembers["menuheight"] = smember_menuheight
|
||||
DropDownMetaFunctions.SetMembers["func"] = smember_function
|
||||
|
||||
DropDownMetaFunctions.__newindex = function(object, key, value)
|
||||
local func = DropDownMetaFunctions.SetMembers[key]
|
||||
@@ -185,6 +197,7 @@ DF:Mixin(DropDownMetaFunctions, DF.FrameMixin)
|
||||
return rawset(self, "realsizeH", height)
|
||||
end
|
||||
end
|
||||
|
||||
function DropDownMetaFunctions:GetMenuSize()
|
||||
return rawget(self, "realsizeW"), rawget(self, "realsizeH")
|
||||
end
|
||||
@@ -193,6 +206,7 @@ DF:Mixin(DropDownMetaFunctions, DF.FrameMixin)
|
||||
function DropDownMetaFunctions:SetFunction(func)
|
||||
return rawset(self, "func", func)
|
||||
end
|
||||
|
||||
function DropDownMetaFunctions:GetFunction()
|
||||
return rawget(self, "func")
|
||||
end
|
||||
@@ -201,22 +215,11 @@ DF:Mixin(DropDownMetaFunctions, DF.FrameMixin)
|
||||
function DropDownMetaFunctions:GetValue()
|
||||
return rawget(self, "myvalue")
|
||||
end
|
||||
|
||||
function DropDownMetaFunctions:SetValue(value)
|
||||
return rawset(self, "myvalue", value)
|
||||
end
|
||||
|
||||
--tooltip
|
||||
function DropDownMetaFunctions:SetTooltip(tooltip)
|
||||
if (tooltip) then
|
||||
return rawset(self, "have_tooltip", tooltip)
|
||||
else
|
||||
return rawset(self, "have_tooltip", nil)
|
||||
end
|
||||
end
|
||||
function DropDownMetaFunctions:GetTooltip()
|
||||
return rawget(self, "have_tooltip")
|
||||
end
|
||||
|
||||
--frame levels
|
||||
function DropDownMetaFunctions:SetFrameLevel(level, frame)
|
||||
if (not frame) then
|
||||
@@ -362,7 +365,7 @@ local runCallbackFunctionForButton = function(button)
|
||||
--need: the the callback func, the object of the dropdown (capsule), the object (capsule) of the button to get FixedValue and the last need the value of the optionTable
|
||||
local success, errorText = pcall(button.table.onclick, button:GetParent():GetParent():GetParent().MyObject, button.object.FixedValue, button.table.value)
|
||||
if (not success) then
|
||||
error ("Details! Framework: dropdown " .. button:GetParent():GetParent():GetParent().MyObject:GetName() .. " error: " .. errorText)
|
||||
error("Details! Framework: dropdown " .. button:GetParent():GetParent():GetParent().MyObject:GetName() .. " error: " .. errorText)
|
||||
end
|
||||
button:GetParent():GetParent():GetParent().MyObject:RunHooksForWidget("OnOptionSelected", button:GetParent():GetParent():GetParent().MyObject, button.object.FixedValue, button.table.value)
|
||||
end
|
||||
@@ -374,7 +377,7 @@ local canRunCallbackFunctionForOption = function(canRunCallback, optionTable, dr
|
||||
if (optionTable.onclick) then
|
||||
local success, errorText = pcall(optionTable.onclick, dropdownObject, fixedValue, optionTable.value)
|
||||
if (not success) then
|
||||
error ("Details! Framework: dropdown " .. dropdownObject:GetName() .. " error: " .. errorText)
|
||||
error("Details! Framework: dropdown " .. dropdownObject:GetName() .. " error: " .. errorText)
|
||||
end
|
||||
dropdownObject:RunHooksForWidget("OnOptionSelected", dropdownObject, fixedValue, optionTable.value)
|
||||
end
|
||||
@@ -433,6 +436,7 @@ function DropDownMetaFunctions:Select(optionName, byOptionNumber, onlyShown, run
|
||||
self:Selected(optionTableSelected)
|
||||
canRunCallbackFunctionForOption(runCallback, optionTableSelected, self)
|
||||
return true
|
||||
|
||||
else
|
||||
local optionTableSelected = optionsTable[optionIndex]
|
||||
|
||||
@@ -823,90 +827,82 @@ function DetailsFrameworkDropDownOnMouseDown(button, buttontype)
|
||||
end
|
||||
|
||||
function DetailsFrameworkDropDownOnEnter(self)
|
||||
local capsule = self.MyObject
|
||||
local kill = capsule:RunHooksForWidget("OnEnter", self, capsule)
|
||||
local object = self.MyObject
|
||||
local kill = object:RunHooksForWidget("OnEnter", self, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
|
||||
if (self.MyObject.onenter_backdrop) then
|
||||
self:SetBackdropColor(unpack(self.MyObject.onenter_backdrop))
|
||||
if (object.onenter_backdrop) then
|
||||
self:SetBackdropColor(unpack(object.onenter_backdrop))
|
||||
else
|
||||
self:SetBackdropColor(.2, .2, .2, .2)
|
||||
end
|
||||
|
||||
if (self.MyObject.onenter_backdrop_border_color) then
|
||||
self:SetBackdropBorderColor(unpack(self.MyObject.onenter_backdrop_border_color))
|
||||
if (object.onenter_backdrop_border_color) then
|
||||
self:SetBackdropBorderColor(unpack(object.onenter_backdrop_border_color))
|
||||
end
|
||||
|
||||
self.arrowTexture2:Show()
|
||||
if (self.MyObject.have_tooltip) then
|
||||
GameCooltip2:Preset(2)
|
||||
|
||||
if (type(self.MyObject.have_tooltip) == "function") then
|
||||
GameCooltip2:AddLine(self.MyObject.have_tooltip() or "")
|
||||
else
|
||||
GameCooltip2:AddLine(self.MyObject.have_tooltip)
|
||||
end
|
||||
|
||||
GameCooltip2:SetOwner(self)
|
||||
GameCooltip2:ShowCooltip()
|
||||
end
|
||||
object:ShowTooltip()
|
||||
end
|
||||
|
||||
function DetailsFrameworkDropDownOnLeave(self)
|
||||
local capsule = self.MyObject
|
||||
local kill = capsule:RunHooksForWidget("OnLeave", self, capsule)
|
||||
local object = self.MyObject
|
||||
local kill = object:RunHooksForWidget("OnLeave", self, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
|
||||
if (self.MyObject.onleave_backdrop) then
|
||||
self:SetBackdropColor(unpack(self.MyObject.onleave_backdrop))
|
||||
if (object.onleave_backdrop) then
|
||||
self:SetBackdropColor(unpack(object.onleave_backdrop))
|
||||
else
|
||||
self:SetBackdropColor(1, 1, 1, .5)
|
||||
end
|
||||
|
||||
if (self.MyObject.onleave_backdrop_border_color) then
|
||||
self:SetBackdropBorderColor(unpack(self.MyObject.onleave_backdrop_border_color))
|
||||
if (object.onleave_backdrop_border_color) then
|
||||
self:SetBackdropBorderColor(unpack(object.onleave_backdrop_border_color))
|
||||
end
|
||||
|
||||
self.arrowTexture2:Hide()
|
||||
|
||||
if (self.MyObject.have_tooltip) then
|
||||
GameCooltip2:ShowMe(false)
|
||||
end
|
||||
object:HideTooltip()
|
||||
end
|
||||
|
||||
function DetailsFrameworkDropDownOnSizeChanged(self)
|
||||
self.MyObject.label:SetSize(self:GetWidth()-40, 10)
|
||||
local object = self.MyObject
|
||||
object.label:SetSize(self:GetWidth() - 40, 10)
|
||||
end
|
||||
|
||||
function DetailsFrameworkDropDownOnShow(self)
|
||||
local capsule = self.MyObject
|
||||
local kill = capsule:RunHooksForWidget("OnShow", self, capsule)
|
||||
local object = self.MyObject
|
||||
local kill = object:RunHooksForWidget("OnShow", self, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function DetailsFrameworkDropDownOnHide(self)
|
||||
local capsule = self.MyObject
|
||||
local kill = capsule:RunHooksForWidget("OnHide", self, capsule)
|
||||
local object = self.MyObject
|
||||
local kill = object:RunHooksForWidget("OnHide", self, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
self.MyObject:Close()
|
||||
object:Close()
|
||||
end
|
||||
|
||||
function DF:BuildDropDownFontList(onClick, icon, iconTexcoord, iconSize)
|
||||
local t = {}
|
||||
local fontTable = {}
|
||||
|
||||
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
|
||||
for name, fontPath in pairs(SharedMedia:HashTable("font")) do
|
||||
t[#t+1] = {value = name, label = name, onclick = onClick, icon = icon, iconsize = iconSize, texcoord = iconTexcoord, font = fontPath, descfont = "abcdefg ABCDEFG"}
|
||||
fontTable[#fontTable+1] = {value = name, label = name, onclick = onClick, icon = icon, iconsize = iconSize, texcoord = iconTexcoord, font = fontPath, descfont = "abcdefg ABCDEFG"}
|
||||
end
|
||||
table.sort(t, function(t1, t2) return t1.label < t2.label end)
|
||||
return t
|
||||
|
||||
table.sort(fontTable, function(t1, t2) return t1.label < t2.label end)
|
||||
|
||||
return fontTable
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
@@ -1104,6 +1100,7 @@ function DF:NewDropDown(parent, container, name, member, width, height, func, de
|
||||
--initialize first menu selected
|
||||
if (type(default) == "string") then
|
||||
dropDownObject:Select(default)
|
||||
|
||||
elseif (type(default) == "number") then
|
||||
if (not dropDownObject:Select(default)) then
|
||||
dropDownObject:Select(default, true)
|
||||
@@ -1117,7 +1114,7 @@ function DF:NewDropDown(parent, container, name, member, width, height, func, de
|
||||
return dropDownObject
|
||||
end
|
||||
|
||||
local defaultBackdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
|
||||
local defaultBackdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
|
||||
edgeSize = 1, tile = true, tileSize = 16, insets = {left = 1, right = 1, top = 0, bottom = 1}}
|
||||
local borderBackdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, insets = {left = 0, right = 0, top = 0, bottom = 0}}
|
||||
local childBackdrop = {bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 256, insets = {left = 0, right = 0, top = 0, bottom = 0}}
|
||||
|
||||
+141
-189
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
local dversion = 379
|
||||
local dversion = 380
|
||||
local major, minor = "DetailsFramework-1.0", dversion
|
||||
local DF, oldminor = LibStub:NewLibrary(major, minor)
|
||||
|
||||
@@ -179,7 +179,7 @@ function DF:GetRoleByClassicTalentTree()
|
||||
|
||||
--get the spec with more points spent
|
||||
local spec = pointsPerSpec[1]
|
||||
if (spec and spec [2] >= MIN_SPECS) then
|
||||
if (spec and spec[2] >= MIN_SPECS) then
|
||||
local specName = spec[1]
|
||||
local spentPoints = spec[2]
|
||||
local specTexture = spec[3]
|
||||
@@ -337,7 +337,6 @@ local embedFunctions = {
|
||||
"BuildMenu",
|
||||
"ShowTutorialAlertFrame",
|
||||
"GetNpcIdFromGuid",
|
||||
"ShowFeedbackPanel",
|
||||
"SetAsOptionsPanel",
|
||||
"GetPlayerRole",
|
||||
"GetCharacterTalents",
|
||||
@@ -361,7 +360,6 @@ local embedFunctions = {
|
||||
"CreateSplitBar",
|
||||
"CreateTextEntry",
|
||||
"Create1PxPanel",
|
||||
"CreateFeedbackButton",
|
||||
"CreateOptionsFrame",
|
||||
"NewSpecialLuaEditorEntry",
|
||||
"ShowPromptPanel",
|
||||
@@ -676,7 +674,7 @@ function DF:CommaValue(value)
|
||||
|
||||
--source http://richard.warburton.it
|
||||
local left, num, right = string_match (value, '^([^%d]*%d)(%d*)(.-)$')
|
||||
return left .. (num:reverse():gsub ('(%d%d%d)','%1,'):reverse()) .. right
|
||||
return left .. (num:reverse():gsub('(%d%d%d)','%1,'):reverse()) .. right
|
||||
end
|
||||
|
||||
function DF:GroupIterator(callback, ...)
|
||||
@@ -724,7 +722,7 @@ function DF:SetFontFace(fontString, fontface)
|
||||
end
|
||||
function DF:SetFontColor(fontString, r, g, b, a)
|
||||
r, g, b, a = DF:ParseColors(r, g, b, a)
|
||||
fontString:SetTextColor (r, g, b, a)
|
||||
fontString:SetTextColor(r, g, b, a)
|
||||
end
|
||||
|
||||
function DF:SetFontShadow (fontString, r, g, b, a, x, y)
|
||||
@@ -2388,11 +2386,11 @@ end
|
||||
|
||||
function DF:CreateInCombatTexture(frame)
|
||||
if (DF.debug and not frame) then
|
||||
error ("Details! Framework: CreateInCombatTexture invalid frame on parameter 1.")
|
||||
error("Details! Framework: CreateInCombatTexture invalid frame on parameter 1.")
|
||||
end
|
||||
|
||||
local in_combat_background = DF:CreateImage(frame)
|
||||
in_combat_background:SetColorTexture (.6, 0, 0, .1)
|
||||
in_combat_background:SetColorTexture(.6, 0, 0, .1)
|
||||
in_combat_background:Hide()
|
||||
|
||||
local in_combat_label = Plater:CreateLabel(frame, "you are in combat", 24, "silver")
|
||||
@@ -2589,15 +2587,15 @@ end
|
||||
|
||||
local texturetitle = options_frame:CreateTexture(nil, "artwork")
|
||||
texturetitle:SetTexture([[Interface\CURSOR\Interact]])
|
||||
texturetitle:SetTexCoord (0, 1, 0, 1)
|
||||
texturetitle:SetTexCoord(0, 1, 0, 1)
|
||||
texturetitle:SetVertexColor(1, 1, 1, 1)
|
||||
texturetitle:SetPoint("topleft", options_frame, "topleft", 2, -3)
|
||||
texturetitle:SetWidth(36)
|
||||
texturetitle:SetHeight(36)
|
||||
|
||||
local title = DF:NewLabel(options_frame, nil, "$parentTitle", nil, title, nil, 20, "yellow")
|
||||
title:SetPoint("left", texturetitle, "right", 2, -1)
|
||||
DF:SetFontOutline (title, true)
|
||||
local titleLabel = DF:NewLabel(options_frame, nil, "$parentTitle", nil, title, nil, 20, "yellow")
|
||||
titleLabel:SetPoint("left", texturetitle, "right", 2, -1)
|
||||
DF:SetFontOutline (titleLabel, true)
|
||||
|
||||
local c = CreateFrame("Button", nil, options_frame, "UIPanelCloseButton")
|
||||
c:SetWidth(32)
|
||||
@@ -2612,6 +2610,12 @@ end
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
--~templates
|
||||
|
||||
local latinLanguageIds = {"enUS", "deDE", "esES", "esMX", "frFR", "itIT", "ptBR"}
|
||||
local alphbets = {
|
||||
[latinLanguageIds] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"},
|
||||
["zhCN"] = {},
|
||||
}
|
||||
|
||||
--fonts
|
||||
DF.font_templates = DF.font_templates or {}
|
||||
|
||||
@@ -2634,8 +2638,37 @@ function DF:GetClientRegion()
|
||||
end
|
||||
end
|
||||
|
||||
DF.registeredFontPaths = DF.registeredFontPaths or {}
|
||||
|
||||
function DF:GetBestFontPathForLanguage(locale)
|
||||
local fontPath = DF.registeredFontPaths[locale]
|
||||
if (fontPath) then
|
||||
return fontPath
|
||||
end
|
||||
|
||||
--font paths gotten from creating a FontString with template "GameFontNormal" and getting the font returned from FontString:GetFont()
|
||||
if (locale == "enUS" or locale == "deDE" or locale == "esES" or locale == "esMX" or locale == "frFR" or locale == "itIT" or locale == "ptBR") then
|
||||
return [[Fonts\FRIZQT__.TTF]]
|
||||
|
||||
elseif (locale == "ruRU") then
|
||||
return [[Fonts\FRIZQT___CYR.TTF]]
|
||||
|
||||
elseif (locale == "zhCN") then
|
||||
return [[Fonts\ARKai_T.ttf]]
|
||||
|
||||
elseif (locale == "zhTW") then
|
||||
return [[Fonts\blei00d.TTF]]
|
||||
|
||||
elseif (locale == "koKR") then
|
||||
return [[Fonts\2002.TTF]]
|
||||
end
|
||||
|
||||
--the locale passed doesn't exists, so pass the enUS
|
||||
return [[Fonts\FRIZQT__.TTF]]
|
||||
end
|
||||
|
||||
--return the best font to use for the client language
|
||||
function DF:GetBestFontForLanguage (language, western, cyrillic, china, korean, taiwan)
|
||||
function DF:GetBestFontForLanguage(language, western, cyrillic, china, korean, taiwan)
|
||||
if (not language) then
|
||||
language = DF.ClientLanguage
|
||||
end
|
||||
@@ -2644,7 +2677,7 @@ function DF:GetBestFontForLanguage (language, western, cyrillic, china, korean,
|
||||
return western or "Friz Quadrata TT"
|
||||
|
||||
elseif (language == "ruRU") then
|
||||
return cyrillic or "Arial Narrow"
|
||||
return cyrillic or "Friz Quadrata TT"
|
||||
|
||||
elseif (language == "zhCN") then
|
||||
return china or "AR CrystalzcuheiGBK Demibold"
|
||||
@@ -2792,7 +2825,7 @@ function DF:InstallTemplate (widgetType, templateName, template, parentName)
|
||||
end
|
||||
|
||||
function DF:GetTemplate(widget_type, template_name)
|
||||
widget_type = string.lower (widget_type)
|
||||
widget_type = string.lower(widget_type)
|
||||
|
||||
local template_table
|
||||
if (widget_type == "font") then
|
||||
@@ -2809,80 +2842,14 @@ function DF:GetTemplate(widget_type, template_name)
|
||||
return template_table [template_name]
|
||||
end
|
||||
|
||||
function DF.GetParentName (frame)
|
||||
function DF.GetParentName(frame)
|
||||
local parentName = frame:GetName()
|
||||
if (not parentName) then
|
||||
error ("Details! FrameWork: called $parent but parent was no name.", 2)
|
||||
error("Details! FrameWork: called $parent but parent was no name.", 2)
|
||||
end
|
||||
return parentName
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
--widget scripts and hooks
|
||||
|
||||
function DF:RunHooksForWidget (event, ...)
|
||||
local hooks = self.HookList [event]
|
||||
|
||||
if (not hooks) then
|
||||
print(self.widget:GetName(), "no hooks for", event)
|
||||
return
|
||||
end
|
||||
|
||||
for i, func in ipairs(hooks) do
|
||||
local success, canInterrupt = pcall (func, ...)
|
||||
if (not success) then
|
||||
error ("Details! Framework: " .. event .. " hook for " .. self:GetName() .. ": " .. canInterrupt)
|
||||
elseif (canInterrupt) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DF:SetHook(hookType, func)
|
||||
if (self.HookList [hookType]) then
|
||||
if (type(func) == "function") then
|
||||
local isRemoval = false
|
||||
for i = #self.HookList [hookType], 1, -1 do
|
||||
if (self.HookList [hookType] [i] == func) then
|
||||
tremove(self.HookList [hookType], i)
|
||||
isRemoval = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if (not isRemoval) then
|
||||
tinsert(self.HookList [hookType], func)
|
||||
end
|
||||
else
|
||||
if (DF.debug) then
|
||||
print(debugstack())
|
||||
error ("Details! Framework: invalid function for widget " .. self.WidgetType .. ".")
|
||||
end
|
||||
end
|
||||
else
|
||||
if (DF.debug) then
|
||||
error ("Details! Framework: unknown hook type for widget " .. self.WidgetType .. ": '" .. hookType .. "'.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DF:HasHook (hookType, func)
|
||||
if (self.HookList [hookType]) then
|
||||
if (type(func) == "function") then
|
||||
for i = #self.HookList [hookType], 1, -1 do
|
||||
if (self.HookList [hookType] [i] == func) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DF:ClearHooks()
|
||||
for hookType, hookTable in pairs(self.HookList) do
|
||||
table.wipe(hookTable)
|
||||
end
|
||||
end
|
||||
|
||||
function DF:Error (errortext)
|
||||
print("|cFFFF2222Details! Framework Error|r:", errortext, self.GetName and self:GetName(), self.WidgetType, debugstack (2, 3, 0))
|
||||
end
|
||||
@@ -2918,17 +2885,17 @@ function DF:AddMemberForWidget (widgetName, memberType, memberName, func)
|
||||
end
|
||||
else
|
||||
if (DF.debug) then
|
||||
error ("Details! Framework: AddMemberForWidget invalid function.")
|
||||
error("Details! Framework: AddMemberForWidget invalid function.")
|
||||
end
|
||||
end
|
||||
else
|
||||
if (DF.debug) then
|
||||
error ("Details! Framework: AddMemberForWidget unknown memberName or memberType.")
|
||||
error("Details! Framework: AddMemberForWidget unknown memberName or memberType.")
|
||||
end
|
||||
end
|
||||
else
|
||||
if (DF.debug) then
|
||||
error ("Details! Framework: AddMemberForWidget unknown widget type: " .. (widgetName or "") .. ".")
|
||||
error("Details! Framework: AddMemberForWidget unknown widget type: " .. (widgetName or "") .. ".")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2975,11 +2942,11 @@ function DF:OpenInterfaceProfile()
|
||||
if (text == self.__name) then
|
||||
local toggle = _G ["InterfaceOptionsFrameAddOnsButton" .. i .. "Toggle"]
|
||||
if (toggle) then
|
||||
if (toggle:GetNormalTexture():GetTexture():find ("PlusButton")) then
|
||||
if (toggle:GetNormalTexture():GetTexture():find("PlusButton")) then
|
||||
--is minimized, need expand
|
||||
toggle:Click()
|
||||
_G ["InterfaceOptionsFrameAddOnsButton" .. i+1]:Click()
|
||||
elseif (toggle:GetNormalTexture():GetTexture():find ("MinusButton")) then
|
||||
elseif (toggle:GetNormalTexture():GetTexture():find("MinusButton")) then
|
||||
--isn't minimized
|
||||
_G ["InterfaceOptionsFrameAddOnsButton" .. i+1]:Click()
|
||||
end
|
||||
@@ -3512,13 +3479,13 @@ end
|
||||
|
||||
local SetBorderColor = function(self, r, g, b)
|
||||
for _, texture in ipairs(self.Borders.Layer1) do
|
||||
texture:SetColorTexture (r, g, b)
|
||||
texture:SetColorTexture(r, g, b)
|
||||
end
|
||||
for _, texture in ipairs(self.Borders.Layer2) do
|
||||
texture:SetColorTexture (r, g, b)
|
||||
texture:SetColorTexture(r, g, b)
|
||||
end
|
||||
for _, texture in ipairs(self.Borders.Layer3) do
|
||||
texture:SetColorTexture (r, g, b)
|
||||
texture:SetColorTexture(r, g, b)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3554,68 +3521,68 @@ function DF:CreateBorder (parent, alpha1, alpha2, alpha3)
|
||||
parent.SetLayerVisibility = SetLayerVisibility
|
||||
|
||||
local border1 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border1, "topleft", parent, "topleft", -1, 1)
|
||||
PixelUtil.SetPoint (border1, "bottomleft", parent, "bottomleft", -1, -1)
|
||||
border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
|
||||
PixelUtil.SetPoint(border1, "topleft", parent, "topleft", -1, 1)
|
||||
PixelUtil.SetPoint(border1, "bottomleft", parent, "bottomleft", -1, -1)
|
||||
border1:SetColorTexture(0, 0, 0, alpha1 or default_border_color1)
|
||||
local border2 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border2, "topleft", parent, "topleft", -2, 2)
|
||||
PixelUtil.SetPoint (border2, "bottomleft", parent, "bottomleft", -2, -2)
|
||||
border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
|
||||
PixelUtil.SetPoint(border2, "topleft", parent, "topleft", -2, 2)
|
||||
PixelUtil.SetPoint(border2, "bottomleft", parent, "bottomleft", -2, -2)
|
||||
border2:SetColorTexture(0, 0, 0, alpha2 or default_border_color2)
|
||||
local border3 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border3, "topleft", parent, "topleft", -3, 3)
|
||||
PixelUtil.SetPoint (border3, "bottomleft", parent, "bottomleft", -3, -3)
|
||||
border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
|
||||
PixelUtil.SetPoint(border3, "topleft", parent, "topleft", -3, 3)
|
||||
PixelUtil.SetPoint(border3, "bottomleft", parent, "bottomleft", -3, -3)
|
||||
border3:SetColorTexture(0, 0, 0, alpha3 or default_border_color3)
|
||||
|
||||
tinsert(parent.Borders.Layer1, border1)
|
||||
tinsert(parent.Borders.Layer2, border2)
|
||||
tinsert(parent.Borders.Layer3, border3)
|
||||
|
||||
local border1 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border1, "topleft", parent, "topleft", 0, 1)
|
||||
PixelUtil.SetPoint (border1, "topright", parent, "topright", 1, 1)
|
||||
border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
|
||||
PixelUtil.SetPoint(border1, "topleft", parent, "topleft", 0, 1)
|
||||
PixelUtil.SetPoint(border1, "topright", parent, "topright", 1, 1)
|
||||
border1:SetColorTexture(0, 0, 0, alpha1 or default_border_color1)
|
||||
local border2 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border2, "topleft", parent, "topleft", -1, 2)
|
||||
PixelUtil.SetPoint (border2, "topright", parent, "topright", 2, 2)
|
||||
border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
|
||||
PixelUtil.SetPoint(border2, "topleft", parent, "topleft", -1, 2)
|
||||
PixelUtil.SetPoint(border2, "topright", parent, "topright", 2, 2)
|
||||
border2:SetColorTexture(0, 0, 0, alpha2 or default_border_color2)
|
||||
local border3 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border3, "topleft", parent, "topleft", -2, 3)
|
||||
PixelUtil.SetPoint (border3, "topright", parent, "topright", 3, 3)
|
||||
border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
|
||||
PixelUtil.SetPoint(border3, "topleft", parent, "topleft", -2, 3)
|
||||
PixelUtil.SetPoint(border3, "topright", parent, "topright", 3, 3)
|
||||
border3:SetColorTexture(0, 0, 0, alpha3 or default_border_color3)
|
||||
|
||||
tinsert(parent.Borders.Layer1, border1)
|
||||
tinsert(parent.Borders.Layer2, border2)
|
||||
tinsert(parent.Borders.Layer3, border3)
|
||||
|
||||
local border1 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border1, "topright", parent, "topright", 1, 0)
|
||||
PixelUtil.SetPoint (border1, "bottomright", parent, "bottomright", 1, -1)
|
||||
border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
|
||||
PixelUtil.SetPoint(border1, "topright", parent, "topright", 1, 0)
|
||||
PixelUtil.SetPoint(border1, "bottomright", parent, "bottomright", 1, -1)
|
||||
border1:SetColorTexture(0, 0, 0, alpha1 or default_border_color1)
|
||||
local border2 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border2, "topright", parent, "topright", 2, 1)
|
||||
PixelUtil.SetPoint (border2, "bottomright", parent, "bottomright", 2, -2)
|
||||
border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
|
||||
PixelUtil.SetPoint(border2, "topright", parent, "topright", 2, 1)
|
||||
PixelUtil.SetPoint(border2, "bottomright", parent, "bottomright", 2, -2)
|
||||
border2:SetColorTexture(0, 0, 0, alpha2 or default_border_color2)
|
||||
local border3 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border3, "topright", parent, "topright", 3, 2)
|
||||
PixelUtil.SetPoint (border3, "bottomright", parent, "bottomright", 3, -3)
|
||||
border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
|
||||
PixelUtil.SetPoint(border3, "topright", parent, "topright", 3, 2)
|
||||
PixelUtil.SetPoint(border3, "bottomright", parent, "bottomright", 3, -3)
|
||||
border3:SetColorTexture(0, 0, 0, alpha3 or default_border_color3)
|
||||
|
||||
tinsert(parent.Borders.Layer1, border1)
|
||||
tinsert(parent.Borders.Layer2, border2)
|
||||
tinsert(parent.Borders.Layer3, border3)
|
||||
|
||||
local border1 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border1, "bottomleft", parent, "bottomleft", 0, -1)
|
||||
PixelUtil.SetPoint (border1, "bottomright", parent, "bottomright", 0, -1)
|
||||
border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
|
||||
PixelUtil.SetPoint(border1, "bottomleft", parent, "bottomleft", 0, -1)
|
||||
PixelUtil.SetPoint(border1, "bottomright", parent, "bottomright", 0, -1)
|
||||
border1:SetColorTexture(0, 0, 0, alpha1 or default_border_color1)
|
||||
local border2 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border2, "bottomleft", parent, "bottomleft", -1, -2)
|
||||
PixelUtil.SetPoint (border2, "bottomright", parent, "bottomright", 1, -2)
|
||||
border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
|
||||
PixelUtil.SetPoint(border2, "bottomleft", parent, "bottomleft", -1, -2)
|
||||
PixelUtil.SetPoint(border2, "bottomright", parent, "bottomright", 1, -2)
|
||||
border2:SetColorTexture(0, 0, 0, alpha2 or default_border_color2)
|
||||
local border3 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border3, "bottomleft", parent, "bottomleft", -2, -3)
|
||||
PixelUtil.SetPoint (border3, "bottomright", parent, "bottomright", 2, -3)
|
||||
border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
|
||||
PixelUtil.SetPoint(border3, "bottomleft", parent, "bottomleft", -2, -3)
|
||||
PixelUtil.SetPoint(border3, "bottomright", parent, "bottomright", 2, -3)
|
||||
border3:SetColorTexture(0, 0, 0, alpha3 or default_border_color3)
|
||||
|
||||
tinsert(parent.Borders.Layer1, border1)
|
||||
tinsert(parent.Borders.Layer2, border2)
|
||||
@@ -3743,21 +3710,21 @@ function DF:CreateBorderWithSpread (parent, alpha1, alpha2, alpha3, size, spread
|
||||
|
||||
--left
|
||||
local border1 = parent:CreateTexture(nil, "background")
|
||||
border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
|
||||
PixelUtil.SetPoint (border1, "topleft", parent, "topleft", -1 + spread, 1 + (-spread), 0, 0)
|
||||
PixelUtil.SetPoint (border1, "bottomleft", parent, "bottomleft", -1 + spread, -1 + spread, 0, 0)
|
||||
border1:SetColorTexture(0, 0, 0, alpha1 or default_border_color1)
|
||||
PixelUtil.SetPoint(border1, "topleft", parent, "topleft", -1 + spread, 1 + (-spread), 0, 0)
|
||||
PixelUtil.SetPoint(border1, "bottomleft", parent, "bottomleft", -1 + spread, -1 + spread, 0, 0)
|
||||
PixelUtil.SetWidth (border1, size, minPixels)
|
||||
|
||||
local border2 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border2, "topleft", parent, "topleft", -2 + spread, 2 + (-spread))
|
||||
PixelUtil.SetPoint (border2, "bottomleft", parent, "bottomleft", -2 + spread, -2 + spread)
|
||||
border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
|
||||
PixelUtil.SetPoint(border2, "topleft", parent, "topleft", -2 + spread, 2 + (-spread))
|
||||
PixelUtil.SetPoint(border2, "bottomleft", parent, "bottomleft", -2 + spread, -2 + spread)
|
||||
border2:SetColorTexture(0, 0, 0, alpha2 or default_border_color2)
|
||||
PixelUtil.SetWidth (border2, size, minPixels)
|
||||
|
||||
local border3 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border3, "topleft", parent, "topleft", -3 + spread, 3 + (-spread))
|
||||
PixelUtil.SetPoint (border3, "bottomleft", parent, "bottomleft", -3 + spread, -3 + spread)
|
||||
border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
|
||||
PixelUtil.SetPoint(border3, "topleft", parent, "topleft", -3 + spread, 3 + (-spread))
|
||||
PixelUtil.SetPoint(border3, "bottomleft", parent, "bottomleft", -3 + spread, -3 + spread)
|
||||
border3:SetColorTexture(0, 0, 0, alpha3 or default_border_color3)
|
||||
PixelUtil.SetWidth (border3, size, minPixels)
|
||||
|
||||
tinsert(parent.Borders.Layer1, border1)
|
||||
@@ -3766,22 +3733,22 @@ function DF:CreateBorderWithSpread (parent, alpha1, alpha2, alpha3, size, spread
|
||||
|
||||
--top
|
||||
local border1 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border1, "topleft", parent, "topleft", 0 + spread, 1 + (-spread))
|
||||
PixelUtil.SetPoint (border1, "topright", parent, "topright", 1 + (-spread), 1 + (-spread))
|
||||
border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
|
||||
PixelUtil.SetHeight (border1, size, minPixels)
|
||||
PixelUtil.SetPoint(border1, "topleft", parent, "topleft", 0 + spread, 1 + (-spread))
|
||||
PixelUtil.SetPoint(border1, "topright", parent, "topright", 1 + (-spread), 1 + (-spread))
|
||||
border1:SetColorTexture(0, 0, 0, alpha1 or default_border_color1)
|
||||
PixelUtil.SetHeight(border1, size, minPixels)
|
||||
|
||||
local border2 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border2, "topleft", parent, "topleft", -1 + spread, 2 + (-spread))
|
||||
PixelUtil.SetPoint (border2, "topright", parent, "topright", 2 + (-spread), 2 + (-spread))
|
||||
border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
|
||||
PixelUtil.SetHeight (border2, size, minPixels)
|
||||
PixelUtil.SetPoint(border2, "topleft", parent, "topleft", -1 + spread, 2 + (-spread))
|
||||
PixelUtil.SetPoint(border2, "topright", parent, "topright", 2 + (-spread), 2 + (-spread))
|
||||
border2:SetColorTexture(0, 0, 0, alpha2 or default_border_color2)
|
||||
PixelUtil.SetHeight(border2, size, minPixels)
|
||||
|
||||
local border3 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border3, "topleft", parent, "topleft", -2 + spread, 3 + (-spread))
|
||||
PixelUtil.SetPoint (border3, "topright", parent, "topright", 3 + (-spread), 3 + (-spread))
|
||||
border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
|
||||
PixelUtil.SetHeight (border3, size, minPixels)
|
||||
PixelUtil.SetPoint(border3, "topleft", parent, "topleft", -2 + spread, 3 + (-spread))
|
||||
PixelUtil.SetPoint(border3, "topright", parent, "topright", 3 + (-spread), 3 + (-spread))
|
||||
border3:SetColorTexture(0, 0, 0, alpha3 or default_border_color3)
|
||||
PixelUtil.SetHeight(border3, size, minPixels)
|
||||
|
||||
tinsert(parent.Borders.Layer1, border1)
|
||||
tinsert(parent.Borders.Layer2, border2)
|
||||
@@ -3789,21 +3756,21 @@ function DF:CreateBorderWithSpread (parent, alpha1, alpha2, alpha3, size, spread
|
||||
|
||||
--right
|
||||
local border1 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border1, "topright", parent, "topright", 1 + (-spread), 0 + (-spread))
|
||||
PixelUtil.SetPoint (border1, "bottomright", parent, "bottomright", 1 + (-spread), -1 + spread)
|
||||
border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
|
||||
PixelUtil.SetPoint(border1, "topright", parent, "topright", 1 + (-spread), 0 + (-spread))
|
||||
PixelUtil.SetPoint(border1, "bottomright", parent, "bottomright", 1 + (-spread), -1 + spread)
|
||||
border1:SetColorTexture(0, 0, 0, alpha1 or default_border_color1)
|
||||
PixelUtil.SetWidth (border1, size, minPixels)
|
||||
|
||||
local border2 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border2, "topright", parent, "topright", 2 + (-spread), 1 + (-spread))
|
||||
PixelUtil.SetPoint (border2, "bottomright", parent, "bottomright", 2 + (-spread), -2 + spread)
|
||||
border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
|
||||
PixelUtil.SetPoint(border2, "topright", parent, "topright", 2 + (-spread), 1 + (-spread))
|
||||
PixelUtil.SetPoint(border2, "bottomright", parent, "bottomright", 2 + (-spread), -2 + spread)
|
||||
border2:SetColorTexture(0, 0, 0, alpha2 or default_border_color2)
|
||||
PixelUtil.SetWidth (border2, size, minPixels)
|
||||
|
||||
local border3 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border3, "topright", parent, "topright", 3 + (-spread), 2 + (-spread))
|
||||
PixelUtil.SetPoint (border3, "bottomright", parent, "bottomright", 3 + (-spread), -3 + spread)
|
||||
border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
|
||||
PixelUtil.SetPoint(border3, "topright", parent, "topright", 3 + (-spread), 2 + (-spread))
|
||||
PixelUtil.SetPoint(border3, "bottomright", parent, "bottomright", 3 + (-spread), -3 + spread)
|
||||
border3:SetColorTexture(0, 0, 0, alpha3 or default_border_color3)
|
||||
PixelUtil.SetWidth (border3, size, minPixels)
|
||||
|
||||
tinsert(parent.Borders.Layer1, border1)
|
||||
@@ -3811,22 +3778,22 @@ function DF:CreateBorderWithSpread (parent, alpha1, alpha2, alpha3, size, spread
|
||||
tinsert(parent.Borders.Layer3, border3)
|
||||
|
||||
local border1 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border1, "bottomleft", parent, "bottomleft", 0 + spread, -1 + spread)
|
||||
PixelUtil.SetPoint (border1, "bottomright", parent, "bottomright", 0 + (-spread), -1 + spread)
|
||||
border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
|
||||
PixelUtil.SetHeight (border1, size, minPixels)
|
||||
PixelUtil.SetPoint(border1, "bottomleft", parent, "bottomleft", 0 + spread, -1 + spread)
|
||||
PixelUtil.SetPoint(border1, "bottomright", parent, "bottomright", 0 + (-spread), -1 + spread)
|
||||
border1:SetColorTexture(0, 0, 0, alpha1 or default_border_color1)
|
||||
PixelUtil.SetHeight(border1, size, minPixels)
|
||||
|
||||
local border2 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border2, "bottomleft", parent, "bottomleft", -1 + spread, -2 + spread)
|
||||
PixelUtil.SetPoint (border2, "bottomright", parent, "bottomright", 1 + (-spread), -2 + spread)
|
||||
border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
|
||||
PixelUtil.SetHeight (border2, size, minPixels)
|
||||
PixelUtil.SetPoint(border2, "bottomleft", parent, "bottomleft", -1 + spread, -2 + spread)
|
||||
PixelUtil.SetPoint(border2, "bottomright", parent, "bottomright", 1 + (-spread), -2 + spread)
|
||||
border2:SetColorTexture(0, 0, 0, alpha2 or default_border_color2)
|
||||
PixelUtil.SetHeight(border2, size, minPixels)
|
||||
|
||||
local border3 = parent:CreateTexture(nil, "background")
|
||||
PixelUtil.SetPoint (border3, "bottomleft", parent, "bottomleft", -2 + spread, -3 + spread)
|
||||
PixelUtil.SetPoint (border3, "bottomright", parent, "bottomright", 2 + (-spread), -3 + spread)
|
||||
border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
|
||||
PixelUtil.SetHeight (border3, size, minPixels)
|
||||
PixelUtil.SetPoint(border3, "bottomleft", parent, "bottomleft", -2 + spread, -3 + spread)
|
||||
PixelUtil.SetPoint(border3, "bottomright", parent, "bottomright", 2 + (-spread), -3 + spread)
|
||||
border3:SetColorTexture(0, 0, 0, alpha3 or default_border_color3)
|
||||
PixelUtil.SetHeight(border3, size, minPixels)
|
||||
|
||||
tinsert(parent.Borders.Layer1, border1)
|
||||
tinsert(parent.Borders.Layer2, border2)
|
||||
@@ -3940,7 +3907,7 @@ end
|
||||
function DF:GetCurrentSpec()
|
||||
local specIndex = DF.GetSpecialization()
|
||||
if (specIndex) then
|
||||
local specID = DF.GetSpecializationInfo (specIndex)
|
||||
local specID = DF.GetSpecializationInfo(specIndex)
|
||||
if (specID and specID ~= 0) then
|
||||
return specID
|
||||
end
|
||||
@@ -3981,7 +3948,7 @@ function DF:QuickDispatch (func, ...)
|
||||
return
|
||||
end
|
||||
|
||||
local okay, errortext = pcall (func, ...)
|
||||
local okay, errortext = pcall(func, ...)
|
||||
|
||||
if (not okay) then
|
||||
--trigger an error msg
|
||||
@@ -4021,7 +3988,7 @@ function DF:CoreDispatch (context, func, ...)
|
||||
if (type(func) ~= "function") then
|
||||
local stack = debugstack(2)
|
||||
local errortext = "D!Framework " .. context .. " error: invalid function to call\n====================\n" .. stack .. "\n====================\n"
|
||||
error (errortext)
|
||||
error(errortext)
|
||||
end
|
||||
|
||||
local okay, result1, result2, result3, result4 = xpcall(func, geterrorhandler(), ...)
|
||||
@@ -4029,28 +3996,13 @@ function DF:CoreDispatch (context, func, ...)
|
||||
--if (not okay) then --when using pcall
|
||||
--local stack = debugstack(2)
|
||||
--local errortext = "D!Framework (" .. context .. ") error: " .. result1 .. "\n====================\n" .. stack .. "\n====================\n"
|
||||
--error (errortext)
|
||||
--error(errortext)
|
||||
--end
|
||||
|
||||
return result1, result2, result3, result4
|
||||
end
|
||||
|
||||
|
||||
--/run local a, b =32,3; local f=function(c,d) return c+d, 2, 3;end; print(xpcall(f,geterrorhandler(),a,b))
|
||||
function DF_CALC_PERFORMANCE()
|
||||
local F = CreateFrame("frame")
|
||||
local T = GetTime()
|
||||
local J = false
|
||||
F:SetScript("OnUpdate", function(self, deltaTime)
|
||||
if (not J) then
|
||||
J = true
|
||||
return
|
||||
end
|
||||
print("Elapsed Time:", deltaTime)
|
||||
F:SetScript("OnUpdate", nil)
|
||||
end)
|
||||
end
|
||||
|
||||
DF.ClassIndexToFileName = {
|
||||
[6] = "DEATHKNIGHT",
|
||||
[1] = "WARRIOR",
|
||||
@@ -4722,7 +4674,7 @@ DF.DebugMixin = {
|
||||
|
||||
--returns if the unit is tapped (gray health color when another player hit the unit first)
|
||||
function DF:IsUnitTapDenied (unitId)
|
||||
return unitId and not UnitPlayerControlled (unitId) and UnitIsTapDenied (unitId)
|
||||
return unitId and not UnitPlayerControlled(unitId) and UnitIsTapDenied(unitId)
|
||||
end
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ function DF:NewHelp (parent, width, height, x, y, buttonWidth, buttonHeight, nam
|
||||
|
||||
if (not APIHelpFunctions) then
|
||||
APIHelpFunctions = true
|
||||
local idx = getmetatable (helpButton).__index
|
||||
local idx = getmetatable(helpButton).__index
|
||||
for funcName, funcAddress in pairs(idx) do
|
||||
if (not HelpMetaFunctions [funcName]) then
|
||||
HelpMetaFunctions [funcName] = function(object, ...)
|
||||
|
||||
+4
-3
@@ -10,8 +10,6 @@ local loadedAPILabelFunctions = false
|
||||
do
|
||||
local metaPrototype = {
|
||||
WidgetType = "label",
|
||||
SetHook = detailsFramework.SetHook,
|
||||
RunHooksForWidget = detailsFramework.RunHooksForWidget,
|
||||
dversion = detailsFramework.dversion,
|
||||
}
|
||||
|
||||
@@ -36,6 +34,7 @@ end
|
||||
local LabelMetaFunctions = _G[detailsFramework.GlobalWidgetControlNames ["label"]]
|
||||
|
||||
detailsFramework:Mixin(LabelMetaFunctions, detailsFramework.SetPointMixin)
|
||||
detailsFramework:Mixin(LabelMetaFunctions, detailsFramework.ScriptHookMixin)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--metatables
|
||||
@@ -285,7 +284,9 @@ detailsFramework:Mixin(LabelMetaFunctions, detailsFramework.SetPointMixin)
|
||||
container = container.widget
|
||||
end
|
||||
|
||||
font = font == "" and "GameFontHighlightSmall" or font or "GameFontHighlightSmall"
|
||||
if (not font or font == "") then
|
||||
font = "GameFontNormal"
|
||||
end
|
||||
|
||||
labelObject.label = parent:CreateFontString(name, layer or "OVERLAY", font)
|
||||
labelObject.widget = labelObject.label
|
||||
|
||||
+516
-79
@@ -1,7 +1,10 @@
|
||||
--todo: need to send a callback when setting a new language, this will be used by the volatile menu to refresh the menu
|
||||
--todo: compress the language tables that aren't in use
|
||||
--todo: check cooltip fonts
|
||||
|
||||
--[=[
|
||||
namespace = DetailsFramework.Language = DetailsFramework.Language.Register()
|
||||
namespace = DetailsFramework.Language
|
||||
Register() = DetailsFramework.Language.Register()
|
||||
|
||||
Register(addonId, languageId[, gameLanguageOnly])
|
||||
create a language table within an addon namespace
|
||||
@@ -37,17 +40,39 @@
|
||||
fontString:SetText(languageTable["STRING_MY_PHRASE"])
|
||||
|
||||
GetText(addonId, phraseId[, silent])
|
||||
get a text from a registered addonId and phraseId
|
||||
get a text from a registered addonId and phraseId, return a localized string and the languageId where the string was found, otherwise return the phraseId
|
||||
@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
|
||||
@phraseId: any string to identify the a translated text, example: phraseId: "OPTIONS_FRAME_WIDTH" text: "Adjust the Width of the frame."
|
||||
@silent: if true won't error on invalid phrase text and instead use the phraseId as the text, it will still error on invalid addonId
|
||||
|
||||
|
||||
ShowOptionsHelp()
|
||||
print to chat the available options ids, use SetOption to set them
|
||||
|
||||
SetOption(addonId, optionId, value)
|
||||
set an option
|
||||
|
||||
SetCurrentLanguage(addonId, languageId)
|
||||
set the language used by default when retriving a languageTable with DF.Language.GetLanguageTable() and not passing the second argument (languageId) within the call
|
||||
use this in combination with a savedVariable to use a language of the user choice
|
||||
@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
|
||||
@languageId: game languages: "deDE", "enUS", "esES", "esMX", "frFR", "itIT", "koKR", "ptBR", "ruRU", "zhCN", "zhTW", or any other value if 'gameLanguageOnly' is false (default)
|
||||
|
||||
CreateLanguageSelector(addonId, parent, callback, selectedLanguage)
|
||||
create and return a dropdown (using details framework dropdown widget) to select the laguage
|
||||
@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
|
||||
@parent: a frame to use as parent while creating the language selector dropdown
|
||||
@callback: a function which will be called when the user select a new language function(languageId) print("new language:", languageId) end
|
||||
@selectedLanguage: default selected language
|
||||
|
||||
SetFontForLanguageId(addonId, languageId, fontPath)
|
||||
SetFontByAlphabetOrRegion(addonId, latin_FontPath, cyrillic_FontPath, china_FontPath, korean_FontPath, taiwan_FontPath)
|
||||
set the font to be used for different languages, if no font is registered for a language, the lib will guess if the font need to be changed and change to a compatible with the language
|
||||
if a font name is passed the lib will attempt to retrive from LibSharedMedia
|
||||
latin changes the font for "deDE", "enUS", "esES", "esMX", "frFR", "itIT" and "ptBR"
|
||||
cyrillic for "ruRU", china for "zhCN", korean for "koKR" and taiwan for "zhTW"
|
||||
@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
|
||||
@languageId: game languages: "deDE", "enUS", "esES", "esMX", "frFR", "itIT", "koKR", "ptBR", "ruRU", "zhCN", "zhTW", or any other string value to represent a language already registered
|
||||
|
||||
RegisterObject(addonId, object, phraseId[, silent[, ...]])
|
||||
to be registered, the Object need to have a SetText method
|
||||
when setting a languageId with DetailsFramework.Language.SetCurrentLanguage(), automatically change the text of all registered Objects
|
||||
@@ -80,14 +105,14 @@
|
||||
@table: a lua table
|
||||
@key: any value except nil or boolean
|
||||
@vararg: arguments to pass for format(text, ...)
|
||||
|
||||
|
||||
RegisterObjectWithDefault(addonId, object, phraseId, defaultText[, ...])
|
||||
(helper function) register an object if a phraseID is valid or object:SetText(defaultText) is called
|
||||
|
||||
RegisterTableKeyWithDefault(addonId, table, key, phraseId, defaultText[, ...])
|
||||
(helper function) register a tableKey if a phraseID is valid or table[key] = defaultText
|
||||
|
||||
CreateLocTable(addonId, phraseId, shouldRegister[, ...])
|
||||
CreateLocTable(addonId, phraseId[, shouldRegister = true[, ...]])
|
||||
make a table to pass instead of the text while using DetailsFramework widgets
|
||||
this avoid to call the register object function right after creating the widget
|
||||
also make easy to register the same phraseID in many different widgets
|
||||
@@ -95,6 +120,18 @@
|
||||
SetTextWithLocTable(object, locTable)
|
||||
set the text of an object using a locTable, the object need the method SetText
|
||||
|
||||
SetTextWithLocTableWithDefault(object, locTable, defaultText)
|
||||
set the text from the locTable if passed or use the defaultText
|
||||
|
||||
SetTextIfLocTableOrDefault(object, locTable)
|
||||
set the text if locTable is a locTable or SetText(locTable)
|
||||
|
||||
RegisterTableKeyWithLocTable(table, key, locTable[, silence])
|
||||
same as RegisterTableKey() but get addonId, phraseId and arguments from the locTable
|
||||
|
||||
RegisterObjectWithLocTable(object, locTable[, silence])
|
||||
same as RegisterObject() but get addonId, phraseId and arguments from the locTable
|
||||
|
||||
--]=]
|
||||
|
||||
local DF = _G["DetailsFramework"]
|
||||
@@ -106,28 +143,63 @@ local format = string.format
|
||||
local unpack = table.unpack or unpack
|
||||
local GetLocale = _G.GetLocale
|
||||
|
||||
local CONST_LANGAGEID_ENUS = "enUS"
|
||||
local CONST_LANGUAGEID_ENUS = "enUS"
|
||||
local gameLanguage = GetLocale()
|
||||
|
||||
local addonNamespaceOptions = {
|
||||
ChangeOnlyRegisteredFont = false,
|
||||
}
|
||||
local optionsHelp = {
|
||||
ChangeOnlyRegisteredFont = "when changing the language, won't change the font if the font isn't registered for the language or region",
|
||||
}
|
||||
|
||||
local debugElabled = false
|
||||
local printDebug = function(functionName, ...)
|
||||
if (debugElabled) then
|
||||
print("|cFFFFAA00Languages|r:", "|cFFFFFF00" .. functionName .. "|r", ...)
|
||||
end
|
||||
end
|
||||
|
||||
local supportedGameLanguages = {
|
||||
["deDE"] = true,
|
||||
[CONST_LANGAGEID_ENUS] = true,
|
||||
[CONST_LANGUAGEID_ENUS] = true,
|
||||
["esES"] = true,
|
||||
["esMX"] = true,
|
||||
["frFR"] = true,
|
||||
["itIT"] = true,
|
||||
["koKR"] = true,
|
||||
["ptBR"] = true,
|
||||
["koKR"] = true,
|
||||
["ruRU"] = true,
|
||||
["zhCN"] = true,
|
||||
["zhTW"] = true,
|
||||
}
|
||||
|
||||
--functionCallPath
|
||||
local fontLanguageCompatibility = {
|
||||
["deDE"] = 1,
|
||||
[CONST_LANGUAGEID_ENUS] = 1,
|
||||
["esES"] = 1,
|
||||
["esMX"] = 1,
|
||||
["frFR"] = 1,
|
||||
["itIT"] = 1,
|
||||
["ptBR"] = 1,
|
||||
["zhCN"] = 2,
|
||||
["zhTW"] = 2,
|
||||
["koKR"] = 3,
|
||||
["ruRU"] = 4,
|
||||
}
|
||||
|
||||
local fontPathToLanguageId = {
|
||||
["Fonts\\FRIZQT__.TTF"] = "enUS",
|
||||
["Fonts\\FRIZQT___CYR.TTF"] = "ruRU",
|
||||
}
|
||||
|
||||
|
||||
local functionSignature = {
|
||||
["RegisterLanguage"] = "RegisterLanguage(addonID, languageID[, gameLanguageOnly])",
|
||||
["SetCurrentLanguage"] = "SetCurrentLanguage(addonID, languageID)",
|
||||
["GetLanguageTable"] = "GetLanguageTable(addonID[, languageID])",
|
||||
["SetFontByAlphabetOrRegion"] = "SetFontByAlphabetOrRegion(addonId, latin, cyrillic, china, korean, taiwan)",
|
||||
["SetFontForLanguageId"] = "SetFontForLanguageId(addonId, languageId, fontPath)",
|
||||
["GetText"] = "GetText(addonID, phraseID[, silent])",
|
||||
|
||||
["RegisterObject"] = "RegisterObject(addonID, object, phraseID[, silent[, ...]])",
|
||||
@@ -138,18 +210,26 @@ local functionSignature = {
|
||||
["RegisterObjectWithDefault"] = "RegisterObjectWithDefault(addonId, object, phraseId, defaultText[, ...])",
|
||||
["RegisterTableKeyWithDefault"] = "RegisterTableKeyWithDefault(addonId, table, key, phraseId, defaultText[, ...])",
|
||||
|
||||
["CreateLocTable"] = "CreateLocTable(addonId, phraseId, shouldRegister[, ...])",
|
||||
["SetOption"] = "SetOption(addonId, optionId, value)",
|
||||
|
||||
["CreateLocTable"] = "CreateLocTable(addonId, phraseId, shouldRegister[, silent[, ...]])",
|
||||
["UnpackLocTable"] = "UnpackLocTable(locTable)",
|
||||
["CanRegisterLocTable"] = "CanRegisterLocTable(locTable)",
|
||||
["RegisterObjectWithLocTable"] = "RegisterObjectWithLocTable(object, locTable)",
|
||||
["SetTextWithLocTable"] = "SetTextWithLocTable(object, locTable)",
|
||||
["IsLocTable"] = "IsLocTable(locTable)",
|
||||
["CanRegisterLocTable"] = "CanRegisterLocTable(locTable)",
|
||||
["RegisterObjectWithLocTable"] = "RegisterObjectWithLocTable(object, locTable[, silence])",
|
||||
["RegisterTableKeyWithLocTable"] = "RegisterTableKeyWithLocTable(table, key, locTable[, silence])",
|
||||
["SetTextWithLocTable"] = "SetTextWithLocTable(object, locTable)",
|
||||
["SetTextWithLocTableWithDefault"] = "SetTextWithLocTableWithDefault(object, locTable, defaultText)",
|
||||
["SetTextIfLocTableOrDefault"] = "SetTextIfLocTableOrDefault(object, locTable or string)",
|
||||
["CreateLanguageSelector"] = "DetailsFramework.Language.CreateLanguageSelector",
|
||||
}
|
||||
|
||||
local functionCallPath = {
|
||||
["RegisterLanguage"] = "DetailsFramework.Language.RegisterLanguage",
|
||||
["SetCurrentLanguage"] = "DetailsFramework.Language.SetCurrentLanguage",
|
||||
["GetLanguageTable"] = "DetailsFramework.Language.GetLanguageTable",
|
||||
["SetFontByAlphabetOrRegion"] = "DetailsFramework.Language.SetFontByAlphabetOrRegion",
|
||||
["SetFontForLanguageId"] = "DetailsFramework.Language.SetFontForLanguageId",
|
||||
["GetText"] = "DetailsFramework.Language.GetText",
|
||||
|
||||
["RegisterObject"] = "DetailsFramework.Language.RegisterObject",
|
||||
@@ -160,19 +240,27 @@ local functionCallPath = {
|
||||
["RegisterObjectWithDefault"] = "DetailsFramework.Language.RegisterObjectWithDefault",
|
||||
["RegisterTableKeyWithDefault"] = "DetailsFramework.Language.RegisterTableKeyWithDefault",
|
||||
|
||||
["SetOption"] = "DetailsFramework.Language.SetOption",
|
||||
|
||||
["CreateLocTable"] = "DetailsFramework.Language.CreateLocTable",
|
||||
["UnpackLocTable"] = "DetailsFramework.Language.UnpackLocTable",
|
||||
["CanRegisterLocTable"] = "DetailsFramework.Language.CanRegisterLocTable",
|
||||
["RegisterObjectWithLocTable"] = "DetailsFramework.Language.RegisterObjectWithLocTable",
|
||||
["SetTextWithLocTable"] = "DetailsFramework.Language.SetTextWithLocTable",
|
||||
["IsLocTable"] = "DetailsFramework.Language.IsLocTable",
|
||||
["SetTextWithLocTableWithDefault"] = "DetailsFramework.Language.SetTextWithLocTableWithDefault",
|
||||
["SetTextIfLocTableOrDefault"] = "DetailsFramework.Language.SetTextIfLocTableOrDefault",
|
||||
["RegisterTableKeyWithLocTable"] = "DetailsFramework.Language.RegisterTableKeyWithLocTable",
|
||||
["CreateLanguageSelector"] = "CreateLanguageSelector(addonId, parent, callback, selectedLanguage)",
|
||||
}
|
||||
|
||||
local errorText = {
|
||||
["AddonID"] = "require a valid addonID (table or string) on #%d argument",
|
||||
["AddonIDInvalidOrNotRegistered"] = "invalid addonID or no languages registered",
|
||||
["LanguageID"] = "require a languageID supported by the game on #%d argument",
|
||||
["PhraseID"] = "require a string on #%d argument",
|
||||
["PhraseID"] = "require a string (phrase id) on #%d argument",
|
||||
["LanguageIDInvalid"] = "require a string (language id) on #%d argument",
|
||||
["FontPathInvalid"] = "require a string (font path) on #%d argument",
|
||||
["NoLanguages"] = "no languages registered for addonId",
|
||||
["LanguageIDNotRegistered"] = "languageID not registered",
|
||||
["PhraseIDNotRegistered"] = "phraseID not registered",
|
||||
@@ -184,7 +272,8 @@ local errorText = {
|
||||
["InvalidTableKey"] = "require a table key on #%d argument",
|
||||
["TableKeyAlreadyRegistered"] = "table already registered", --not in use
|
||||
["InvalidLocTable"] = "invalid locTable on #%d argument",
|
||||
["LocTableCantRegister"] = "cannot register object, locTable.register == false",
|
||||
["LocTableCantRegister"] = "cannot register object or tableKey, locTable.register == false",
|
||||
["InvalidOptionId"] = "invalid option on #%d argument",
|
||||
}
|
||||
|
||||
|
||||
@@ -201,6 +290,13 @@ local isValid_AddonID = function(addonId)
|
||||
return true
|
||||
end
|
||||
|
||||
local isValid_LanguageID = function(languageId)
|
||||
if (type(languageId) ~= "string") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local isValid_PhraseID = function(phraseId)
|
||||
return type(phraseId) == "string"
|
||||
end
|
||||
@@ -229,11 +325,18 @@ local getOrCreateAddonNamespace = function(addonId, languageId)
|
||||
languages = {},
|
||||
registeredObjects = {},
|
||||
tableKeys = setmetatable({}, {__mode = "k"}),
|
||||
fonts = {},
|
||||
|
||||
--set when the first language table is registered
|
||||
defaultLanguageTable = nil,
|
||||
defaultLanguageTable = false,
|
||||
|
||||
options = {},
|
||||
}
|
||||
|
||||
DF.table.copy(addonNamespaceTable.options, addonNamespaceOptions)
|
||||
DF.Language.RegisteredNamespaces[addonId] = addonNamespaceTable
|
||||
|
||||
printDebug("getOrCreateAddonNamespace", "created new addon namespace for:", addonId)
|
||||
end
|
||||
|
||||
--if the language being register is the language being in use by the client, set this language as current language
|
||||
@@ -251,6 +354,15 @@ local getAddonNamespace = function(addonId)
|
||||
return DF.Language.RegisteredNamespaces[addonId]
|
||||
end
|
||||
|
||||
local setLanguageChangedCallback = function(addonNamespaceTable, callback)
|
||||
printDebug("setLanguageChangedCallback", "addonId:", addonNamespaceTable.addonId, "callbackType:", type(callback))
|
||||
addonNamespaceTable.onLanguageChangeCallback = callback
|
||||
end
|
||||
|
||||
local getLanguageChangedCallback = function(addonNamespaceTable)
|
||||
return addonNamespaceTable.onLanguageChangeCallback
|
||||
end
|
||||
|
||||
local getLanguageTable = function(addonNamespaceTable, languageId)
|
||||
local languageTable = addonNamespaceTable.languages[languageId]
|
||||
if (not languageTable) then
|
||||
@@ -259,10 +371,19 @@ local getLanguageTable = function(addonNamespaceTable, languageId)
|
||||
return languageTable
|
||||
end
|
||||
|
||||
local getRegisteredLanguages = function(addonNamespaceTable)
|
||||
return addonNamespaceTable.languages
|
||||
end
|
||||
|
||||
local getCurrentLanguageId = function(addonNamespaceTable)
|
||||
return addonNamespaceTable.currentLanguageId
|
||||
end
|
||||
|
||||
local setOption = function(addonNamespaceTable, optionId, value)
|
||||
printDebug("setOption", "addonId:", addonNamespaceTable.addonId, "optionId:", optionId, "value:", value, "valueType:", type(value))
|
||||
addonNamespaceTable.options[optionId] = value
|
||||
end
|
||||
|
||||
--if invalid, the __index from the metatable get the value from the first registered table
|
||||
--will return nil if the languageTable is from the first registered language
|
||||
local getTextFromLangugeTable = function(languageTable, phraseId)
|
||||
@@ -273,56 +394,59 @@ local getRegisteredObjects = function(addonNamespaceTable)
|
||||
return addonNamespaceTable.registeredObjects
|
||||
end
|
||||
|
||||
--return a string representing a translated text and the languageId where the string was found
|
||||
--attempt to get from the current selected language, then from the game language and then from english if the other two fails
|
||||
--return false if the phraseId isn't found at all
|
||||
local getText = function(addonNamespaceTable, phraseId)
|
||||
local currentLanguageId = getCurrentLanguageId(addonNamespaceTable)
|
||||
local languageTable = getLanguageTable(addonNamespaceTable, currentLanguageId)
|
||||
|
||||
--if the languageTable is invalid, let the function caller handle it
|
||||
--note: languageTable is always valid when the callstack started at from DF.Language.SetCurrentLanguage
|
||||
if (not languageTable) then
|
||||
return false
|
||||
end
|
||||
|
||||
--by using getTextFromLangugeTable the metatable will get the default of the first registered language
|
||||
--local text = getTextFromLangugeTable(languageTable, phraseId)
|
||||
local text = rawget(languageTable, phraseId)
|
||||
if (isValid_Text(text)) then
|
||||
return text
|
||||
local text = phraseId
|
||||
|
||||
--get the text from the current language table
|
||||
if (languageTable) then
|
||||
text = rawget(languageTable, phraseId)
|
||||
if (isValid_Text(text)) then
|
||||
return text, currentLanguageId
|
||||
end
|
||||
end
|
||||
|
||||
--the translated string wasn't found on the current language table
|
||||
--attempt to get the text from the default language used in the client
|
||||
local clientLanguage = GetLocale()
|
||||
if (currentLanguageId ~= clientLanguage) then
|
||||
languageTable = getLanguageTable(addonNamespaceTable, clientLanguage)
|
||||
if (languageTable) then
|
||||
--text = getTextFromLangugeTable(languageTable, phraseId)
|
||||
text = rawget(languageTable, phraseId)
|
||||
if (isValid_Text(text)) then
|
||||
return text
|
||||
return text, clientLanguage
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--attempt to get from english
|
||||
if (currentLanguageId ~= CONST_LANGAGEID_ENUS and clientLanguage ~= CONST_LANGAGEID_ENUS) then
|
||||
languageTable = getLanguageTable(addonNamespaceTable, CONST_LANGAGEID_ENUS)
|
||||
if (currentLanguageId ~= CONST_LANGUAGEID_ENUS and clientLanguage ~= CONST_LANGUAGEID_ENUS) then
|
||||
languageTable = getLanguageTable(addonNamespaceTable, CONST_LANGUAGEID_ENUS)
|
||||
if (languageTable) then
|
||||
--text = getTextFromLangugeTable(languageTable, phraseId)
|
||||
text = rawget(languageTable, phraseId)
|
||||
if (isValid_Text(text)) then
|
||||
return text
|
||||
return text, CONST_LANGUAGEID_ENUS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
return false, CONST_LANGUAGEID_ENUS
|
||||
end
|
||||
|
||||
local setLanguageTable = function(addonNamespaceTable, languageId, languageTable)
|
||||
local setLanguageTableForLanguageId = function(addonNamespaceTable, languageId, languageTable)
|
||||
local isFirstLanguage = not next(addonNamespaceTable.languages)
|
||||
if (isFirstLanguage) then
|
||||
printDebug("setLanguageTableForLanguageId", "(first to be registered) addonId:", addonNamespaceTable.addonId, "languageId:", languageId, "languageTable:", languageTable, "languageIdType:", type(languageId), "languageTableType:", type(languageTable))
|
||||
--defaultLanguageTable is constant
|
||||
addonNamespaceTable.defaultLanguageTable = languageTable
|
||||
else
|
||||
printDebug("setLanguageTableForLanguageId", "addonId:", addonNamespaceTable.addonId, "languageId:", languageId, "languageTable:", languageTable, "languageIdType:", type(languageId), "languageTableType:", type(languageTable))
|
||||
local defaultLanguageMetatable = {__index = function(table, key) return addonNamespaceTable.defaultLanguageTable[key] or key end}
|
||||
setmetatable(languageTable, defaultLanguageMetatable)
|
||||
end
|
||||
@@ -332,7 +456,15 @@ local setLanguageTable = function(addonNamespaceTable, languageId, languageTable
|
||||
end
|
||||
|
||||
local setCurrentLanguageId = function(addonNamespaceTable, languageId)
|
||||
printDebug("setCurrentLanguageId", "addonId:", addonNamespaceTable.addonId, "languageId:", languageId, "languageIdType:", type(languageId))
|
||||
|
||||
addonNamespaceTable.currentLanguageId = languageId
|
||||
|
||||
local callbackFunc = getLanguageChangedCallback(addonNamespaceTable)
|
||||
if (callbackFunc) then
|
||||
printDebug("setCurrentLanguageId", "addonId:", addonNamespaceTable.addonId, "calling callback", "callbackFuncType:", type(callbackFunc))
|
||||
xpcall(callbackFunc, _G["geterrorhandler"](), languageId)
|
||||
end
|
||||
end
|
||||
|
||||
local parseArguments = function(...)
|
||||
@@ -346,13 +478,55 @@ end
|
||||
|
||||
--hold information about a localization, used by registered objects and keyTables, has .phraesId, .arguments and .key (on keyTables)
|
||||
local createPhraseInfoTable = function(phraseId, key, ...)
|
||||
return {phraseId = phraseId, key = key, arguments = parseArguments(...)}
|
||||
return {
|
||||
phraseId = phraseId,
|
||||
key = key,
|
||||
arguments = parseArguments(...)
|
||||
}
|
||||
end
|
||||
|
||||
local updatePhraseInfoArguments = function(phraseInfoTable, ...)
|
||||
local updatePhraseInfo_PhraseId = function(phraseInfoTable, phraseId)
|
||||
phraseInfoTable.phraseId = phraseId
|
||||
end
|
||||
|
||||
local updatePhraseInfo_Arguments = function(phraseInfoTable, ...)
|
||||
phraseInfoTable.arguments = parseArguments(...)
|
||||
end
|
||||
|
||||
local getFontForLanguageId = function(addonNamespaceTable, languageId)
|
||||
return addonNamespaceTable.fonts[languageId]
|
||||
end
|
||||
|
||||
local shouldChangeFontForNewLanguage = function(addonNamespaceTable, oldLanguageId, newLanguageId)
|
||||
--does it need to change the font?
|
||||
local oldLanguageClusterId = fontLanguageCompatibility[oldLanguageId]
|
||||
local newLanguageClusterId = fontLanguageCompatibility[newLanguageId]
|
||||
|
||||
if (oldLanguageClusterId == newLanguageClusterId) then
|
||||
--does not require to change the font
|
||||
return false
|
||||
else
|
||||
if (addonNamespaceTable.options.ChangeOnlyRegisteredFont) then
|
||||
--can change only if the font was previously registered with SetFontForLanguageId() or SetFontByAlphabetOrRegion()
|
||||
local languageFontPath = getFontForLanguageId(addonNamespaceTable, newLanguageId)
|
||||
if (languageFontPath) then
|
||||
--the font is registered
|
||||
return true, languageFontPath
|
||||
end
|
||||
else
|
||||
local languageFontPath = getFontForLanguageId(addonNamespaceTable, newLanguageId)
|
||||
if (languageFontPath) then
|
||||
--the font is registered
|
||||
return true, languageFontPath
|
||||
else
|
||||
--the font is not registered for this language, get the default font from the framework
|
||||
languageFontPath = DF:GetBestFontPathForLanguage(newLanguageId)
|
||||
return true, languageFontPath
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--get a phraseInfo and text returning a formatted text using arguments if they exists
|
||||
local getFormattedText = function(phraseInfoTable, text)
|
||||
if (phraseInfoTable.arguments) then
|
||||
@@ -362,21 +536,27 @@ local getFormattedText = function(phraseInfoTable, text)
|
||||
end
|
||||
end
|
||||
|
||||
local updateObjectTable_PhraseId = function(phraseInfoTable, phraseId)
|
||||
phraseInfoTable.phraseId = phraseId
|
||||
end
|
||||
|
||||
local getObjectPhraseInfoTable = function(addonNamespaceTable, object)
|
||||
return addonNamespaceTable.registeredObjects[object]
|
||||
end
|
||||
|
||||
local setObject_InternalMembers = function(object, addonId, phraseId, arguments)
|
||||
local setObject_InternalMembers = function(object, addonId, phraseId, arguments, languageId)
|
||||
object.__languageAddonId = addonId or object.__languageAddonId
|
||||
object.__languagePhraseId = phraseId or object.__languagePhraseId
|
||||
object.__languageArguments = arguments or object.__languageArguments
|
||||
object.__languageId = languageId or object.__languageId
|
||||
end
|
||||
|
||||
local setObject_Text = function(object, phraseInfoTable, text)
|
||||
local setObject_Text = function(addonNamespaceTable, object, phraseInfoTable, text, textLanguageId)
|
||||
if (textLanguageId ~= object.__languageId) then
|
||||
local bShouldChangeFont, fontPath = shouldChangeFontForNewLanguage(addonNamespaceTable, object.__languageId, textLanguageId)
|
||||
if (bShouldChangeFont) then
|
||||
local font, size, flags = object:GetFont()
|
||||
object:SetFont(fontPath, size, flags)
|
||||
setObject_InternalMembers(object, false, false, false, textLanguageId)
|
||||
end
|
||||
end
|
||||
|
||||
local formattedText = getFormattedText(phraseInfoTable, text)
|
||||
object:SetText(formattedText)
|
||||
end
|
||||
@@ -387,23 +567,38 @@ local objectMethod_SetTextByPhraseID = function(object, phraseId, ...)
|
||||
local addonNamespaceTable = getAddonNamespace(addonId)
|
||||
|
||||
local phraseInfoTable = getObjectPhraseInfoTable(addonNamespaceTable, object)
|
||||
updateObjectTable_PhraseId(phraseInfoTable, phraseId)
|
||||
updatePhraseInfoArguments(phraseInfoTable, ...)
|
||||
setObject_InternalMembers(object, addonId, phraseId, phraseInfoTable.arguments)
|
||||
updatePhraseInfo_PhraseId(phraseInfoTable, phraseId)
|
||||
updatePhraseInfo_Arguments(phraseInfoTable, ...)
|
||||
|
||||
local text = getText(addonNamespaceTable, phraseId)
|
||||
setObject_Text(object, phraseInfoTable, text)
|
||||
local currentLanguageId = getCurrentLanguageId(addonNamespaceTable)
|
||||
|
||||
--when registering a new object, consider the font already set on the obejct to be a font compatible with the client languageId
|
||||
setObject_InternalMembers(object, addonId, phraseId, phraseInfoTable.arguments, currentLanguageId)
|
||||
|
||||
local text, textLanguageId = getText(addonNamespaceTable, phraseId)
|
||||
setObject_Text(addonNamespaceTable, object, phraseInfoTable, text, textLanguageId)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local registerObject = function(addonNamespaceTable, object, phraseId, ...)
|
||||
local phraseInfoTable = createPhraseInfoTable(phraseId, nil, ...)
|
||||
addonNamespaceTable.registeredObjects[object] = phraseInfoTable
|
||||
local phraseInfoTable = getObjectPhraseInfoTable(addonNamespaceTable, object)
|
||||
|
||||
if (phraseInfoTable) then
|
||||
--the object is already registered, update the phraseId and arguments
|
||||
updatePhraseInfo_PhraseId(phraseInfoTable, phraseId)
|
||||
updatePhraseInfo_Arguments(phraseInfoTable, ...)
|
||||
else
|
||||
phraseInfoTable = createPhraseInfoTable(phraseId, nil, ...)
|
||||
addonNamespaceTable.registeredObjects[object] = phraseInfoTable
|
||||
end
|
||||
|
||||
local currentLanguageId = getCurrentLanguageId(addonNamespaceTable)
|
||||
|
||||
--save internal information about the language directly in the object
|
||||
setObject_InternalMembers(object, addonNamespaceTable.addonId, phraseId, phraseInfoTable.arguments)
|
||||
setObject_InternalMembers(object, addonNamespaceTable.addonId, phraseId, phraseInfoTable.arguments, gameLanguage)
|
||||
|
||||
--give the object a new method
|
||||
object.SetTextByPhraseID = objectMethod_SetTextByPhraseID
|
||||
|
||||
return phraseInfoTable
|
||||
@@ -415,8 +610,8 @@ local updateAllRegisteredObjectsText = function(addonNamespaceTable)
|
||||
for object, phraseInfoTable in pairs(objects) do
|
||||
local phraseId = phraseInfoTable.phraseId
|
||||
--note: text is always valid when the callstack started at from DF.Language.SetCurrentLanguage
|
||||
local text = getText(addonNamespaceTable, phraseId)
|
||||
setObject_Text(object, phraseInfoTable, text)
|
||||
local text, textLanguageId = getText(addonNamespaceTable, phraseId)
|
||||
setObject_Text(addonNamespaceTable, object, phraseInfoTable, text, textLanguageId)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -473,9 +668,17 @@ local registerTableKey = function(addonNamespaceTable, table, key, phraseId, ...
|
||||
registerTableKeyTable(addonNamespaceTable, table, tableKeyTable)
|
||||
end
|
||||
|
||||
--create a table for this table key as a table can hold several keys with localization strings
|
||||
local phraseInfoTable = createPhraseInfoTable(phraseId, key, ...)
|
||||
tableKeyTable[key] = phraseInfoTable
|
||||
local phraseInfoTable = getPhraseInfoFromTableKey(tableKeyTable, key)
|
||||
|
||||
if (phraseInfoTable) then
|
||||
--the key is already registered for this table, update the phraseId and arguments
|
||||
phraseInfoTable.phraseId = phraseId
|
||||
phraseInfoTable.arguments = parseArguments(...)
|
||||
else
|
||||
phraseInfoTable = createPhraseInfoTable(phraseId, key, ...)
|
||||
tableKeyTable[key] = phraseInfoTable
|
||||
end
|
||||
|
||||
return tableKeyTable
|
||||
end
|
||||
|
||||
@@ -486,12 +689,25 @@ local updateAllRegisteredTableKeyText = function(addonNamespaceTable)
|
||||
for key, phraseInfoTable in pairs(tableKeyTable) do
|
||||
local phraseId = phraseInfoTable.phraseId
|
||||
--note: text is always valid when the callstack started at from DF.Language.SetCurrentLanguage
|
||||
local text = getText(addonNamespaceTable, phraseId)
|
||||
local text, textLanguageId = getText(addonNamespaceTable, phraseId)
|
||||
setTableKey_Text(table, key, phraseInfoTable, text)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local updateTextOnAllObjectsAndTableKeys = function(addonNamespaceTable)
|
||||
updateAllRegisteredObjectsText(addonNamespaceTable)
|
||||
updateAllRegisteredTableKeyText(addonNamespaceTable)
|
||||
end
|
||||
|
||||
local setFontForLanguageId = function(addonNamespaceTable, languageId, fontPath)
|
||||
addonNamespaceTable.fonts[languageId] = fontPath
|
||||
--add into the font combatibility table (which fonts can be used for a language)
|
||||
if (not fontLanguageCompatibility[languageId]) then
|
||||
fontLanguageCompatibility[languageId] = fontPath
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--create a language table within an addon namespace
|
||||
--@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
|
||||
@@ -512,15 +728,123 @@ function DF.Language.RegisterLanguage(addonId, languageId, gameLanguageOnly)
|
||||
|
||||
--create a table to hold traslations for this languageId
|
||||
local languageTable = {}
|
||||
setLanguageTable(addonNamespaceTable, languageId, languageTable)
|
||||
setLanguageTableForLanguageId(addonNamespaceTable, languageId, languageTable)
|
||||
|
||||
return languageTable
|
||||
end
|
||||
|
||||
|
||||
--@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
|
||||
--@optionId: the ID of the option, check
|
||||
function DF.Language.SetOption(addonId, optionId, value)
|
||||
if (not isValid_AddonID(addonId)) then
|
||||
error(functionCallPath["SetOption"] .. ": " .. format(errorText["AddonID"], 1) .. ", use: " .. functionSignature["SetOption"] .. ".")
|
||||
end
|
||||
|
||||
if (not addonNamespaceOptions[optionId]) then
|
||||
error(functionCallPath["SetOption"] .. ": " .. format(errorText["InvalidOptionId"], 2) .. ", use: " .. functionSignature["SetOption"] .. ".")
|
||||
end
|
||||
|
||||
local addonNamespaceTable = getAddonNamespace(addonId)
|
||||
if (not addonNamespaceTable) then
|
||||
error(functionCallPath["SetOption"] .. ": " .. errorText["NoLanguages"] .. ", use: " .. functionSignature["RegisterLanguage"] .. ".")
|
||||
end
|
||||
|
||||
setOption(addonNamespaceTable, optionId, value)
|
||||
end
|
||||
|
||||
--print to chat the available option
|
||||
function DF.Language.ShowOptionsHelp()
|
||||
for optionId, descriptionString in pairs(optionsHelp) do
|
||||
print(optionId .. ": " .. descriptionString)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
|
||||
--@languageId: game languages: "deDE", "enUS", "esES", "esMX", "frFR", "itIT", "koKR", "ptBR", "ruRU", "zhCN", "zhTW", or any other string value to represent a language
|
||||
--@fontPath: a path for a font
|
||||
function DF.Language.SetFontForLanguageId(addonId, languageId, fontPath)
|
||||
if (not isValid_AddonID(addonId)) then
|
||||
error(functionCallPath["SetFontForLanguageId"] .. ": " .. format(errorText["AddonID"], 1) .. ", use: " .. functionSignature["SetFontForLanguageId"] .. ".")
|
||||
end
|
||||
|
||||
if (not isValid_LanguageID(languageId)) then
|
||||
error(functionCallPath["SetFontForLanguageId"] .. ": " .. format(errorText["LanguageIDInvalid"], 2) .. ", use: " .. functionSignature["SetFontForLanguageId"] .. ".")
|
||||
end
|
||||
|
||||
if (type(fontPath) ~= "string") then
|
||||
error(functionCallPath["SetFontForLanguageId"] .. ": " .. format(errorText["FontPathInvalid"], 3) .. ", use: " .. functionSignature["SetFontForLanguageId"] .. ".")
|
||||
end
|
||||
|
||||
local addonNamespaceTable = getAddonNamespace(addonId)
|
||||
if (not addonNamespaceTable) then
|
||||
error(functionCallPath["SetFontForLanguageId"] .. ": " .. errorText["NoLanguages"] .. ", use: " .. functionSignature["RegisterLanguage"] .. ".")
|
||||
end
|
||||
|
||||
setFontForLanguageId(addonNamespaceTable, languageId, fontPath)
|
||||
end
|
||||
|
||||
|
||||
--@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
|
||||
--@regions: accept a font name, ignored is nil is passed
|
||||
function DF.Language.SetFontByAlphabetOrRegion(addonId, latin, cyrillic, china, korean, taiwan)
|
||||
if (not isValid_AddonID(addonId)) then
|
||||
error(functionCallPath["SetFontByAlphabetOrRegion"] .. ": " .. format(errorText["AddonID"], 1) .. ", use: " .. functionSignature["SetFontByAlphabetOrRegion"] .. ".")
|
||||
end
|
||||
|
||||
local addonNamespaceTable = getAddonNamespace(addonId)
|
||||
if (not addonNamespaceTable) then
|
||||
error(functionCallPath["SetFontByAlphabetOrRegion"] .. ": " .. errorText["NoLanguages"] .. ", use: " .. functionSignature["RegisterLanguage"] .. ".")
|
||||
end
|
||||
|
||||
if (latin) then
|
||||
local fontPath = latin
|
||||
if (type(fontPath) == "string") then
|
||||
setFontForLanguageId(addonNamespaceTable, "deDE", fontPath)
|
||||
setFontForLanguageId(addonNamespaceTable, "enUS", fontPath)
|
||||
setFontForLanguageId(addonNamespaceTable, "esES", fontPath)
|
||||
setFontForLanguageId(addonNamespaceTable, "esMX", fontPath)
|
||||
setFontForLanguageId(addonNamespaceTable, "frFR", fontPath)
|
||||
setFontForLanguageId(addonNamespaceTable, "itIT", fontPath)
|
||||
setFontForLanguageId(addonNamespaceTable, "ptBR", fontPath)
|
||||
end
|
||||
end
|
||||
|
||||
if (cyrillic) then
|
||||
local fontPath = cyrillic
|
||||
if (type(fontPath) == "string") then
|
||||
setFontForLanguageId(addonNamespaceTable, "ruRU", fontPath)
|
||||
end
|
||||
end
|
||||
|
||||
if (china) then
|
||||
local fontPath = china
|
||||
if (type(fontPath) == "string") then
|
||||
setFontForLanguageId(addonNamespaceTable, "zhCN", fontPath)
|
||||
end
|
||||
end
|
||||
|
||||
if (korean) then
|
||||
local fontPath = korean
|
||||
if (type(fontPath) == "string") then
|
||||
setFontForLanguageId(addonNamespaceTable, "zhTW", fontPath)
|
||||
end
|
||||
end
|
||||
|
||||
if (taiwan) then
|
||||
local fontPath = taiwan
|
||||
if (type(fontPath) == "string") then
|
||||
local taiwanCountryLanguageId = "zhTW"
|
||||
setFontForLanguageId(addonNamespaceTable, taiwanCountryLanguageId, fontPath)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--get the languageTable for the requested languageId within the addon namespace
|
||||
--@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
|
||||
--@languageId: game languages: "deDE", "enUS", "esES", "esMX", "frFR", "itIT", "koKR", "ptBR", "ruRU", "zhCN", "zhTW", or any other value if 'gameLanguageOnly' is false (default)
|
||||
--@languageId: game languages: "deDE", "enUS", "esES", "esMX", "frFR", "itIT", "koKR", "ptBR", "ruRU", "zhCN", "zhTW", or any other string value to represent a language if 'gameLanguageOnly' is false (default)
|
||||
--return value: languageTable
|
||||
function DF.Language.GetLanguageTable(addonId, languageId)
|
||||
if (not isValid_AddonID(addonId)) then
|
||||
@@ -549,8 +873,8 @@ end
|
||||
--set the language used when retriving a languageTable with DF.Language.GetLanguageTable() without passing the second argument (languageId)
|
||||
--use this in combination with a savedVariable to use a language of the user choice
|
||||
--@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
|
||||
--@languageId: game languages: "deDE", "enUS", "esES", "esMX", "frFR", "itIT", "koKR", "ptBR", "ruRU", "zhCN", "zhTW", or any other value if 'gameLanguageOnly' is false (default)
|
||||
function DF.Language.SetCurrentLanguage(addonId, languageId)
|
||||
--@languageId: game languages: "deDE", "enUS", "esES", "esMX", "frFR", "itIT", "koKR", "ptBR", "ruRU", "zhCN", "zhTW", or any other string value to represent a language if 'gameLanguageOnly' is false (default)
|
||||
function DF.Language.SetCurrentLanguage(addonId, newLanguageId)
|
||||
if (not isValid_AddonID(addonId)) then
|
||||
error(functionCallPath["SetCurrentLanguage"] .. ": " .. format(errorText["AddonID"], 1) .. ", use: " .. functionSignature["SetCurrentLanguage"] .. ".")
|
||||
end
|
||||
@@ -560,16 +884,16 @@ function DF.Language.SetCurrentLanguage(addonId, languageId)
|
||||
error(functionCallPath["SetCurrentLanguage"] .. ": " .. errorText["NoLanguages"] .. ", use: " .. functionSignature["RegisterLanguage"] .. ".")
|
||||
end
|
||||
|
||||
local languageTable = getLanguageTable(addonNamespaceTable, languageId)
|
||||
local languageTable = getLanguageTable(addonNamespaceTable, newLanguageId)
|
||||
if (not languageTable) then
|
||||
error(functionCallPath["SetCurrentLanguage"] .. ": " .. errorText["LanguageIDNotRegistered"] .. ", use: " .. functionSignature["RegisterLanguage"] .. ".")
|
||||
end
|
||||
|
||||
setCurrentLanguageId(languageId)
|
||||
setCurrentLanguageId(addonNamespaceTable, newLanguageId)
|
||||
|
||||
--go into the registered objects and KeyTables and change their text
|
||||
updateAllRegisteredObjectsText(addonNamespaceTable)
|
||||
updateAllRegisteredTableKeyText(addonNamespaceTable)
|
||||
updateTextOnAllObjectsAndTableKeys(addonNamespaceTable)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -590,9 +914,9 @@ function DF.Language.GetText(addonId, phraseId, silent)
|
||||
error(functionCallPath["GetText"] .. ": " .. errorText["NoLanguages"] .. ", use: " .. functionSignature["RegisterLanguage"] .. ".")
|
||||
end
|
||||
|
||||
local text = getText(addonNamespaceTable, phraseId)
|
||||
local text, textLanguageId = getText(addonNamespaceTable, phraseId)
|
||||
if (isValid_Text(text)) then
|
||||
return text
|
||||
return text, textLanguageId
|
||||
end
|
||||
|
||||
if (not silent) then
|
||||
@@ -628,7 +952,15 @@ function DF.Language.RegisterObject(addonId, object, phraseId, silent, ...)
|
||||
|
||||
local objectTable = registerObject(addonNamespaceTable, object, phraseId, ...)
|
||||
|
||||
local text = getText(addonNamespaceTable, phraseId)
|
||||
--on being registered the FontObject is not being checked for the current font set on it
|
||||
--this causes the font to have a enUS font from when it was created but wronfully signed as having ruRU font
|
||||
--causing the fontstring to not change the font when settings the text
|
||||
|
||||
--solution: when registering a font string, get the font on it a attempt to identify the font set on it
|
||||
--solution 2: will be most likely to the font to be the default from the client language, e.g. frizz_quadrata_tt if the client is running enUS
|
||||
--solution 3: consider the font being used as the languageId of the client
|
||||
|
||||
local text, textLanguageId = getText(addonNamespaceTable, phraseId)
|
||||
if (not isValid_Text(text)) then
|
||||
if (not silent) then
|
||||
error(functionCallPath["RegisterObject"] .. ": " .. errorText["PhraseIDNotRegistered"] .. ", use: " .. functionSignature["GetLanguageTable"] .. "['PhraseID'] = 'translated text'.")
|
||||
@@ -637,7 +969,7 @@ function DF.Language.RegisterObject(addonId, object, phraseId, silent, ...)
|
||||
end
|
||||
end
|
||||
|
||||
setObject_Text(object, objectTable, text)
|
||||
setObject_Text(addonNamespaceTable, object, objectTable, text, textLanguageId)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -663,10 +995,10 @@ function DF.Language.UpdateObjectArguments(addonId, object, ...)
|
||||
if (not phraseInfoTable) then
|
||||
error(functionCallPath["UpdateObjectArguments"] .. ": " .. errorText["ObjectNotRegistered"] .. ", use: " .. functionSignature["RegisterObject"] .. ".")
|
||||
end
|
||||
updatePhraseInfoArguments(phraseInfoTable, ...)
|
||||
updatePhraseInfo_Arguments(phraseInfoTable, ...)
|
||||
|
||||
local text = getText(addonNamespaceTable, phraseInfoTable.phraseId)
|
||||
setObject_Text(object, phraseInfoTable, text)
|
||||
local text, textLanguageId = getText(addonNamespaceTable, phraseInfoTable.phraseId)
|
||||
setObject_Text(addonNamespaceTable, object, phraseInfoTable, text, textLanguageId)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -701,7 +1033,7 @@ function DF.Language.RegisterTableKey(addonId, table, key, phraseId, silent, ...
|
||||
|
||||
local tableKeyTable = registerTableKey(addonNamespaceTable, table, key, phraseId, ...)
|
||||
|
||||
local text = getText(addonNamespaceTable, phraseId)
|
||||
local text, textLanguageId = getText(addonNamespaceTable, phraseId)
|
||||
if (not isValid_Text(text)) then
|
||||
if (not silent) then
|
||||
error(functionCallPath["RegisterTableKey"] .. ": " .. errorText["PhraseIDNotRegistered"] .. ", use: " .. functionSignature["GetLanguageTable"] .. "['PhraseID'] = 'translated text'.")
|
||||
@@ -747,9 +1079,9 @@ function DF.Language.UpdateTableKeyArguments(addonId, table, key, ...)
|
||||
end
|
||||
|
||||
local phraseInfo = getPhraseInfoFromTableKey(tableKeyTable, key) --can't nil as the line above checked if it exists
|
||||
updatePhraseInfoArguments(phraseInfo, key, ...)
|
||||
updatePhraseInfo_Arguments(phraseInfo, key, ...)
|
||||
|
||||
local text = getText(addonNamespaceTable, phraseInfo.phraseId)
|
||||
local text, textLanguageId = getText(addonNamespaceTable, phraseInfo.phraseId)
|
||||
setTableKey_Text(table, key, tableKeyTable, text)
|
||||
return true
|
||||
end
|
||||
@@ -777,7 +1109,7 @@ function DF.Language.RegisterObjectWithDefault(addonId, object, phraseId, defaul
|
||||
end
|
||||
|
||||
|
||||
function DF.Language.CreateLocTable(addonId, phraseId, shouldRegister, ...)
|
||||
function DF.Language.CreateLocTable(addonId, phraseId, shouldRegister, silent, ...)
|
||||
if (not isValid_AddonID(addonId)) then
|
||||
error(functionCallPath["CreateLocTable"] .. ": " .. format(errorText["AddonID"], 1) .. ", use: " .. functionSignature["CreateLocTable"] .. ".")
|
||||
end
|
||||
@@ -786,6 +1118,23 @@ function DF.Language.CreateLocTable(addonId, phraseId, shouldRegister, ...)
|
||||
error(functionCallPath["CreateLocTable"] .. ": " .. format(errorText["PhraseID"], 2) .. ", use: " .. functionSignature["CreateLocTable"] .. ".")
|
||||
end
|
||||
|
||||
local addonNamespaceTable = getAddonNamespace(addonId)
|
||||
if (not addonNamespaceTable) then
|
||||
error(functionCallPath["CreateLocTable"] .. ": " .. errorText["NoLanguages"] .. ", use: " .. functionSignature["CreateLocTable"] .. ".")
|
||||
end
|
||||
|
||||
local text, textLanguageId = getText(addonNamespaceTable, phraseId)
|
||||
if (not text) then
|
||||
if (not silent) then
|
||||
error(functionCallPath["CreateLocTable"] .. ": " .. errorText["PhraseIDNotRegistered"] .. ", use: " .. functionSignature["CreateLocTable"] .. ".")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if (type(shouldRegister) == "nil") then
|
||||
shouldRegister = true
|
||||
end
|
||||
|
||||
local newLocTable = {
|
||||
addonId = addonId,
|
||||
phraseId = phraseId,
|
||||
@@ -824,7 +1173,22 @@ function DF.Language.UnpackLocTable(locTable)
|
||||
end
|
||||
|
||||
|
||||
function DF.Language.RegisterObjectWithLocTable(object, locTable)
|
||||
function DF.Language.RegisterTableKeyWithLocTable(table, key, locTable, silence)
|
||||
if (not DF.Language.IsLocTable(locTable)) then
|
||||
error(functionCallPath["RegisterTableKeyWithLocTable"] .. ": " .. format(errorText["InvalidLocTable"], 3) .. ", use: " .. functionSignature["RegisterTableKeyWithLocTable"] .. ".")
|
||||
end
|
||||
|
||||
local addonId, phraseId, shouldRegister, arguments = DF.Language.UnpackLocTable(locTable)
|
||||
|
||||
if (not shouldRegister) then
|
||||
error(functionCallPath["RegisterTableKeyWithLocTable"] .. ": " .. errorText["LocTableCantRegister"] .. ", use: " .. functionSignature["RegisterTableKeyWithLocTable"] .. ".")
|
||||
end
|
||||
|
||||
DF.Language.RegisterTableKey(addonId, table, key, phraseId, silence, arguments and unpack(arguments))
|
||||
end
|
||||
|
||||
|
||||
function DF.Language.RegisterObjectWithLocTable(object, locTable, silence)
|
||||
if (not isValid_Object(object)) then
|
||||
error(functionCallPath["RegisterObjectWithLocTable"] .. ": " .. format(errorText["InvalidObject"], 1) .. ", use: " .. functionSignature["RegisterObjectWithLocTable"] .. ".")
|
||||
end
|
||||
@@ -847,7 +1211,7 @@ function DF.Language.RegisterObjectWithLocTable(object, locTable)
|
||||
error(functionCallPath["RegisterObjectWithLocTable"] .. ": " .. errorText["LocTableCantRegister"] .. ", use: " .. functionSignature["RegisterObjectWithLocTable"] .. ".")
|
||||
end
|
||||
|
||||
DF.Language.RegisterObject(addonId, object, phraseId, true, arguments and unpack(arguments))
|
||||
DF.Language.RegisterObject(addonId, object, phraseId, silence, arguments and unpack(arguments))
|
||||
end
|
||||
|
||||
|
||||
@@ -872,9 +1236,82 @@ function DF.Language.SetTextWithLocTable(object, locTable)
|
||||
return true
|
||||
end
|
||||
|
||||
local text = getText(addonNamespaceTable, phraseId)
|
||||
local text, textLanguageId = getText(addonNamespaceTable, phraseId)
|
||||
|
||||
--can use the locTable instead of the phraseInfoTable because both has the .arguments member
|
||||
setObject_Text(object, locTable, text)
|
||||
setObject_Text(addonNamespaceTable, object, locTable, text, textLanguageId)
|
||||
return true
|
||||
end
|
||||
|
||||
--use the locTable is valid or set the text using 'defaultText'
|
||||
--@object: any UIObject or table with SetText method
|
||||
--@locTable: a locTable created from CreateLocTable()
|
||||
--@defaultText: a text string
|
||||
function DF.Language.SetTextWithLocTableWithDefault(object, locTable, defaultText)
|
||||
if (not isValid_Object(object)) then
|
||||
error(functionCallPath["SetTextWithLocTableWithDefault"] .. ": " .. format(errorText["InvalidObject"], 1) .. ", use: " .. functionSignature["SetTextWithLocTableWithDefault"] .. ".")
|
||||
end
|
||||
|
||||
if (not DF.Language.IsLocTable(locTable)) then
|
||||
object:SetText(defaultText or "")
|
||||
else
|
||||
DF.Language.SetTextWithLocTable(object, locTable)
|
||||
end
|
||||
end
|
||||
|
||||
--if the second parameter is a regular string, the text set is the string, otherwise it'll handle the locTable and its parameters
|
||||
--@object: any UIObject or table with SetText method
|
||||
--@locTable: a locTable created from CreateLocTable()
|
||||
function DF.Language.SetTextIfLocTableOrDefault(object, locTable)
|
||||
if (not isValid_Object(object)) then
|
||||
error(functionCallPath["SetTextIfLocTableOrDefault"] .. ": " .. format(errorText["InvalidObject"], 1) .. ", use: " .. functionSignature["SetTextIfLocTableOrDefault"] .. ".")
|
||||
end
|
||||
|
||||
if (not DF.Language.IsLocTable(locTable)) then
|
||||
local textString = locTable
|
||||
object:SetText(textString)
|
||||
else
|
||||
DF.Language.SetTextWithLocTable(object, locTable)
|
||||
end
|
||||
end
|
||||
|
||||
--@addonId: an identifier, can be any table or string, will be used when getting the table with phrase translations, example: "DetailsLocalization", "Details", "PlaterLoc", _G.Plater
|
||||
--@parent: a frame to use as parent while creating the language selector dropdown
|
||||
--@callback: a function which will be called when the user select a new language function(languageId) print("new language:", languageId) end
|
||||
--@selectedLanguage: default selected language
|
||||
function DF.Language.CreateLanguageSelector(addonId, parent, callback, selectedLanguage)
|
||||
if (not isValid_AddonID(addonId)) then
|
||||
error(functionCallPath["CreateLanguageSelector"] .. ": " .. format(errorText["AddonID"], 1) .. ", use: " .. functionSignature["CreateLanguageSelector"] .. ".")
|
||||
end
|
||||
|
||||
if (type(parent) ~= "table" or not parent.GetObjectType or not parent.CreateTexture) then
|
||||
error(functionCallPath["CreateLanguageSelector"] .. ": " .. format("Require a frame on #%2 argument", 2) .. ", use: " .. functionSignature["CreateLanguageSelector"] .. ".")
|
||||
end
|
||||
|
||||
local addonNamespaceTable = getAddonNamespace(addonId)
|
||||
if (not addonNamespaceTable) then
|
||||
error(functionCallPath["CreateLanguageSelector"] .. ": " .. errorText["AddonIDInvalidOrNotRegistered"] .. ", use: " .. functionSignature["RegisterLanguage"] .. ".")
|
||||
end
|
||||
|
||||
setLanguageChangedCallback(addonNamespaceTable, callback)
|
||||
|
||||
local allLanguagesRegistered = getRegisteredLanguages(addonNamespaceTable)
|
||||
|
||||
local onSelectLanguage = function(self, addonId, languageId)
|
||||
DF.Language.SetCurrentLanguage(addonId, languageId)
|
||||
end
|
||||
|
||||
local buildOptionsFunc = function()
|
||||
local resultTable = {}
|
||||
|
||||
for languageId in pairs(allLanguagesRegistered) do
|
||||
resultTable[#resultTable+1] = {value = languageId, label = languageId, onclick = onSelectLanguage} --, icon = icon, iconcolor = iconcolor, iconsize = iconsize
|
||||
end
|
||||
|
||||
return resultTable
|
||||
end
|
||||
|
||||
local languageSelector = DF:CreateDropDown(parent, buildOptionsFunc, selectedLanguage or getCurrentLanguageId(addonNamespaceTable), 80, 20, nil, nil, DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
|
||||
languageSelector:SetFixedParameter(addonId)
|
||||
return languageSelector
|
||||
end
|
||||
+1
-1
@@ -14,7 +14,7 @@ SMALL_FLOAT = 0.000001
|
||||
|
||||
--find distance between two players
|
||||
function DF:GetDistance_Unit (unit1, unit2)
|
||||
if (UnitExists (unit1) and UnitExists (unit2)) then
|
||||
if (UnitExists(unit1) and UnitExists(unit2)) then
|
||||
local u1X, u1Y = UnitPosition (unit1)
|
||||
local u2X, u2Y = UnitPosition (unit2)
|
||||
|
||||
|
||||
+118
-4
@@ -6,6 +6,10 @@ end
|
||||
|
||||
local _
|
||||
|
||||
local getFrame = function(frame)
|
||||
return rawget(frame, "widget") or frame
|
||||
end
|
||||
|
||||
detailsFramework.WidgetFunctions = {
|
||||
GetCapsule = function(self)
|
||||
return self.MyObject
|
||||
@@ -26,6 +30,53 @@ detailsFramework.DefaultMetaFunctionsGet = {
|
||||
end,
|
||||
}
|
||||
|
||||
detailsFramework.TooltipHandlerMixin = {
|
||||
SetTooltip = function(self, tooltip)
|
||||
if (tooltip) then
|
||||
if (detailsFramework.Language.IsLocTable(tooltip)) then
|
||||
--register the locTable as a tableKey
|
||||
local locTable = tooltip
|
||||
detailsFramework.Language.RegisterTableKeyWithLocTable(self, "have_tooltip", locTable)
|
||||
else
|
||||
self.have_tooltip = tooltip
|
||||
end
|
||||
else
|
||||
self.have_tooltip = nil
|
||||
end
|
||||
end,
|
||||
|
||||
GetTooltip = function(self)
|
||||
return self.have_tooltip
|
||||
end,
|
||||
|
||||
ShowTooltip = function(self)
|
||||
local tooltipText = self:GetTooltip()
|
||||
|
||||
if (type(tooltipText) == "function") then
|
||||
local tooltipFunction = tooltipText
|
||||
local gotTooltip, tooltipString = pcall(tooltipFunction)
|
||||
if (gotTooltip) then
|
||||
tooltipText = tooltipString
|
||||
end
|
||||
end
|
||||
|
||||
if (tooltipText) then
|
||||
GameCooltip:Preset(2)
|
||||
GameCooltip:AddLine(tooltipText)
|
||||
GameCooltip:ShowCooltip(getFrame(self), "tooltip")
|
||||
end
|
||||
end,
|
||||
|
||||
HideTooltip = function(self)
|
||||
local tooltipText = self:GetTooltip()
|
||||
if (tooltipText) then
|
||||
if (GameCooltip:IsOwner(getFrame(self))) then
|
||||
GameCooltip:Hide()
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
detailsFramework.DefaultMetaFunctionsSet = {
|
||||
parent = function(object, value)
|
||||
return object:SetParent(value)
|
||||
@@ -72,10 +123,6 @@ detailsFramework.LayeredRegionMetaFunctionsGet = {
|
||||
end,
|
||||
}
|
||||
|
||||
local getFrame = function(frame)
|
||||
return rawget(frame, "widget") or frame
|
||||
end
|
||||
|
||||
detailsFramework.FrameMixin = {
|
||||
SetFrameStrata = function(self, strata)
|
||||
self = getFrame(self)
|
||||
@@ -296,6 +343,73 @@ detailsFramework.PayloadMixin = {
|
||||
end,
|
||||
}
|
||||
|
||||
detailsFramework.ScriptHookMixin = {
|
||||
RunHooksForWidget = function(self, event, ...)
|
||||
local hooks = self.HookList[event]
|
||||
|
||||
if (not hooks) then
|
||||
print(self.widget:GetName(), "no hooks for", event)
|
||||
return
|
||||
end
|
||||
|
||||
for i, func in ipairs(hooks) do
|
||||
local success, canInterrupt = pcall(func, ...)
|
||||
if (not success) then
|
||||
error("Details! Framework: " .. event .. " hook for " .. self:GetName() .. ": " .. canInterrupt)
|
||||
|
||||
elseif (canInterrupt) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
SetHook = function(self, hookType, func)
|
||||
if (self.HookList[hookType]) then
|
||||
if (type(func) == "function") then
|
||||
local isRemoval = false
|
||||
for i = #self.HookList[hookType], 1, -1 do
|
||||
if (self.HookList[hookType][i] == func) then
|
||||
tremove(self.HookList[hookType], i)
|
||||
isRemoval = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if (not isRemoval) then
|
||||
tinsert(self.HookList[hookType], func)
|
||||
end
|
||||
else
|
||||
if (detailsFramework.debug) then
|
||||
print(debugstack())
|
||||
error("Details! Framework: invalid function for widget " .. self.WidgetType .. ".")
|
||||
end
|
||||
end
|
||||
else
|
||||
if (detailsFramework.debug) then
|
||||
error("Details! Framework: unknown hook type for widget " .. self.WidgetType .. ": '" .. hookType .. "'.")
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
HasHook = function(self, hookType, func)
|
||||
if (self.HookList[hookType]) then
|
||||
if (type(func) == "function") then
|
||||
for i = #self.HookList[hookType], 1, -1 do
|
||||
if (self.HookList[hookType][i] == func) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
ClearHooks = function(self)
|
||||
for hookType, hookTable in pairs(self.HookList) do
|
||||
table.wipe(hookTable)
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
detailsFramework.ScrollBoxFunctions = {
|
||||
Refresh = function(self)
|
||||
--hide all frames and tag as not in use
|
||||
|
||||
+26
-28
@@ -20,9 +20,6 @@ local APIBarFunctions
|
||||
do
|
||||
local metaPrototype = {
|
||||
WidgetType = "normal_bar",
|
||||
SetHook = DF.SetHook,
|
||||
RunHooksForWidget = DF.RunHooksForWidget,
|
||||
|
||||
dversion = DF.dversion,
|
||||
}
|
||||
|
||||
@@ -44,7 +41,8 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
local BarMetaFunctions = _G[DF.GlobalWidgetControlNames["normal_bar"]]
|
||||
DF:Mixin(BarMetaFunctions, DF.ScriptHookMixin)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--metatables
|
||||
@@ -227,7 +225,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
local smember_color = function(_object, _value)
|
||||
local _value1, _value2, _value3, _value4 = DF:ParseColors(_value)
|
||||
|
||||
_object.statusbar:SetStatusBarColor (_value1, _value2, _value3, _value4)
|
||||
_object.statusbar:SetStatusBarColor(_value1, _value2, _value3, _value4)
|
||||
_object._texture.original_colors = {_value1, _value2, _value3, _value4}
|
||||
_object.timer_texture:SetVertexColor(_value1, _value2, _value3, _value4)
|
||||
|
||||
@@ -246,7 +244,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
local _value1, _value2 = _unpack(_value)
|
||||
_object._icon:SetTexture(_value1)
|
||||
if (_value2) then
|
||||
_object._icon:SetTexCoord (_unpack(_value2))
|
||||
_object._icon:SetTexCoord(_unpack(_value2))
|
||||
end
|
||||
else
|
||||
_object._icon:SetTexture(_value)
|
||||
@@ -261,12 +259,12 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
_object.timer_texture:SetTexture(_value1)
|
||||
_object.timer_textureR:SetTexture(_value1)
|
||||
if (_value2) then
|
||||
_object._texture:SetTexCoord (_unpack(_value2))
|
||||
_object.timer_texture:SetTexCoord (_unpack(_value2))
|
||||
_object.timer_textureR:SetTexCoord (_unpack(_value2))
|
||||
_object._texture:SetTexCoord(_unpack(_value2))
|
||||
_object.timer_texture:SetTexCoord(_unpack(_value2))
|
||||
_object.timer_textureR:SetTexCoord(_unpack(_value2))
|
||||
end
|
||||
else
|
||||
if (_value:find ("\\")) then
|
||||
if (_value:find("\\")) then
|
||||
_object._texture:SetTexture(_value)
|
||||
else
|
||||
local file = SharedMedia:Fetch ("statusbar", _value)
|
||||
@@ -285,7 +283,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
end
|
||||
--background texture
|
||||
local smember_backgroundtexture = function(_object, _value)
|
||||
if (_value:find ("\\")) then
|
||||
if (_value:find("\\")) then
|
||||
_object.background:SetTexture(_value)
|
||||
else
|
||||
local file = SharedMedia:Fetch ("statusbar", _value)
|
||||
@@ -310,8 +308,8 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
--font color
|
||||
local smember_textcolor = function(_object, _value)
|
||||
local _value1, _value2, _value3, _value4 = DF:ParseColors(_value)
|
||||
_object.textleft:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
return _object.textright:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
_object.textleft:SetTextColor(_value1, _value2, _value3, _value4)
|
||||
return _object.textright:SetTextColor(_value1, _value2, _value3, _value4)
|
||||
end
|
||||
--outline (shadow)
|
||||
local smember_outline = function(_object, _value)
|
||||
@@ -421,7 +419,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
r, g, b, a = DF:ParseColors(r, g, b, a)
|
||||
|
||||
self._texture:SetVertexColor(r, g, b, a)
|
||||
self.statusbar:SetStatusBarColor (r, g, b, a)
|
||||
self.statusbar:SetStatusBarColor(r, g, b, a)
|
||||
self._texture.original_colors = {r, g, b, a}
|
||||
end
|
||||
|
||||
@@ -430,7 +428,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
self._icon:SetTexture(texture)
|
||||
if (...) then
|
||||
local L, R, U, D = _unpack(...)
|
||||
self._icon:SetTexCoord (L, R, U, D)
|
||||
self._icon:SetTexCoord(L, R, U, D)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -490,7 +488,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
|
||||
local OnEnter = function(frame)
|
||||
local capsule = frame.MyObject
|
||||
local kill = capsule:RunHooksForWidget ("OnEnter", frame, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnEnter", frame, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -507,7 +505,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
|
||||
local OnLeave = function(frame)
|
||||
local capsule = frame.MyObject
|
||||
local kill = capsule:RunHooksForWidget ("OnLeave", frame, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnLeave", frame, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -521,7 +519,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
|
||||
local OnHide = function(frame)
|
||||
local capsule = frame.MyObject
|
||||
local kill = capsule:RunHooksForWidget ("OnHide", frame, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnHide", frame, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -529,7 +527,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
|
||||
local OnShow = function(frame)
|
||||
local capsule = frame.MyObject
|
||||
local kill = capsule:RunHooksForWidget ("OnShow", frame, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnShow", frame, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -537,7 +535,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
|
||||
local OnMouseDown = function(frame, button)
|
||||
local capsule = frame.MyObject
|
||||
local kill = capsule:RunHooksForWidget ("OnMouseDown", frame, button, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnMouseDown", frame, button, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -552,7 +550,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
|
||||
local OnMouseUp = function(frame, button)
|
||||
local capsule = frame.MyObject
|
||||
local kill = capsule:RunHooksForWidget ("OnMouseUp", frame, button, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnMouseUp", frame, button, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -568,7 +566,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
|
||||
|
||||
function BarMetaFunctions:OnTimerEnd()
|
||||
local capsule = self
|
||||
local kill = capsule:RunHooksForWidget ("OnTimerEnd", self.widget, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnTimerEnd", self.widget, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -762,14 +760,14 @@ function DF:NewBar (parent, container, name, member, w, h, value, texture_name)
|
||||
DF.BarNameCounter = DF.BarNameCounter + 1
|
||||
|
||||
elseif (not parent) then
|
||||
return error ("Details! FrameWork: parent not found.", 2)
|
||||
return error("Details! FrameWork: parent not found.", 2)
|
||||
elseif (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
local parentName = DF.GetParentName (parent)
|
||||
name = name:gsub ("$parent", parentName)
|
||||
if (name:find("$parent")) then
|
||||
local parentName = DF.GetParentName(parent)
|
||||
name = name:gsub("$parent", parentName)
|
||||
end
|
||||
|
||||
local BarObject = {type = "bar", dframework = true}
|
||||
@@ -797,7 +795,7 @@ function DF:NewBar (parent, container, name, member, w, h, value, texture_name)
|
||||
|
||||
--create widgets
|
||||
BarObject.statusbar = CreateFrame("statusbar", name, parent)
|
||||
DF:Mixin (BarObject.statusbar, DF.WidgetFunctions)
|
||||
DF:Mixin(BarObject.statusbar, DF.WidgetFunctions)
|
||||
|
||||
build_statusbar (BarObject.statusbar)
|
||||
|
||||
@@ -805,7 +803,7 @@ function DF:NewBar (parent, container, name, member, w, h, value, texture_name)
|
||||
|
||||
if (not APIBarFunctions) then
|
||||
APIBarFunctions = true
|
||||
local idx = getmetatable (BarObject.statusbar).__index
|
||||
local idx = getmetatable(BarObject.statusbar).__index
|
||||
for funcName, funcAddress in pairs(idx) do
|
||||
if (not BarMetaFunctions [funcName]) then
|
||||
BarMetaFunctions [funcName] = function(object, ...)
|
||||
|
||||
+1720
-2124
File diff suppressed because it is too large
Load Diff
+1
-2
@@ -10,8 +10,6 @@ local APIImageFunctions = false
|
||||
do
|
||||
local metaPrototype = {
|
||||
WidgetType = "image",
|
||||
SetHook = detailsFramework.SetHook,
|
||||
RunHooksForWidget = detailsFramework.RunHooksForWidget,
|
||||
dversion = detailsFramework.dversion,
|
||||
}
|
||||
|
||||
@@ -36,6 +34,7 @@ end
|
||||
local ImageMetaFunctions = _G[detailsFramework.GlobalWidgetControlNames["image"]]
|
||||
|
||||
detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.SetPointMixin)
|
||||
detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.ScriptHookMixin)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--metatables
|
||||
|
||||
+16
-16
@@ -26,11 +26,11 @@ local CreateImageEditorFrame = function()
|
||||
|
||||
editorWindow.hooks = {}
|
||||
|
||||
local background = DF:NewImage (editorWindow, nil, nil, nil, "background", nil, "background", "$parentBackground")
|
||||
local background = DF:NewImage(editorWindow, nil, nil, nil, "background", nil, "background", "$parentBackground")
|
||||
background:SetAllPoints()
|
||||
background:SetTexture(0, 0, 0, .8)
|
||||
|
||||
local edit_texture = DF:NewImage (editorWindow, nil, 500, 500, "artwork", nil, "edit_texture", "$parentImage")
|
||||
local edit_texture = DF:NewImage(editorWindow, nil, 500, 500, "artwork", nil, "edit_texture", "$parentImage")
|
||||
edit_texture:SetAllPoints()
|
||||
_G.DetailsFrameworkImageEdit_EditTexture = edit_texture
|
||||
|
||||
@@ -63,7 +63,7 @@ local CreateImageEditorFrame = function()
|
||||
|
||||
--Top Slider
|
||||
|
||||
local topCoordTexture = DF:NewImage (editorWindow, nil, nil, nil, "overlay", nil, nil, "$parentImageTopCoord")
|
||||
local topCoordTexture = DF:NewImage(editorWindow, nil, nil, nil, "overlay", nil, nil, "$parentImageTopCoord")
|
||||
topCoordTexture:SetPoint("topleft", editorWindow, "topleft")
|
||||
topCoordTexture:SetPoint("topright", editorWindow, "topright")
|
||||
topCoordTexture:SetColorTexture(1, 0, 0)
|
||||
@@ -95,7 +95,7 @@ local CreateImageEditorFrame = function()
|
||||
|
||||
--Bottom Slider
|
||||
|
||||
local bottomCoordTexture = DF:NewImage (editorWindow, nil, nil, nil, "overlay", nil, nil, "$parentImageBottomCoord")
|
||||
local bottomCoordTexture = DF:NewImage(editorWindow, nil, nil, nil, "overlay", nil, nil, "$parentImageBottomCoord")
|
||||
bottomCoordTexture:SetPoint("bottomleft", editorWindow, "bottomleft", 0, 0)
|
||||
bottomCoordTexture:SetPoint("bottomright", editorWindow, "bottomright", 0, 0)
|
||||
bottomCoordTexture:SetColorTexture(1, 0, 0)
|
||||
@@ -128,7 +128,7 @@ local CreateImageEditorFrame = function()
|
||||
|
||||
--Left Slider
|
||||
|
||||
local leftCoordTexture = DF:NewImage (editorWindow, nil, nil, nil, "overlay", nil, nil, "$parentImageLeftCoord")
|
||||
local leftCoordTexture = DF:NewImage(editorWindow, nil, nil, nil, "overlay", nil, nil, "$parentImageLeftCoord")
|
||||
leftCoordTexture:SetPoint("topleft", editorWindow, "topleft", 0, 0)
|
||||
leftCoordTexture:SetPoint("bottomleft", editorWindow, "bottomleft", 0, 0)
|
||||
leftCoordTexture:SetColorTexture(1, 0, 0)
|
||||
@@ -159,7 +159,7 @@ local CreateImageEditorFrame = function()
|
||||
|
||||
--Right Slider
|
||||
|
||||
local rightCoordTexture = DF:NewImage (editorWindow, nil, nil, nil, "overlay", nil, nil, "$parentImageRightCoord")
|
||||
local rightCoordTexture = DF:NewImage(editorWindow, nil, nil, nil, "overlay", nil, nil, "$parentImageRightCoord")
|
||||
rightCoordTexture:SetPoint("topright", editorWindow, "topright", 0, 0)
|
||||
rightCoordTexture:SetPoint("bottomright", editorWindow, "bottomright", 0, 0)
|
||||
rightCoordTexture:SetColorTexture(1, 0, 0)
|
||||
@@ -211,7 +211,7 @@ local CreateImageEditorFrame = function()
|
||||
if (alphaFrameShown) then
|
||||
alphaFrame:Hide()
|
||||
alphaFrameShown = false
|
||||
button.text:SetTextColor (unpack(originalColor))
|
||||
button.text:SetTextColor(unpack(originalColor))
|
||||
end
|
||||
|
||||
if (ColorPickerFrame:IsShown()) then
|
||||
@@ -219,7 +219,7 @@ local CreateImageEditorFrame = function()
|
||||
end
|
||||
|
||||
if (lastButton) then
|
||||
lastButton.text:SetTextColor (unpack(originalColor))
|
||||
lastButton.text:SetTextColor(unpack(originalColor))
|
||||
end
|
||||
|
||||
if (editingSide == side) then
|
||||
@@ -232,7 +232,7 @@ local CreateImageEditorFrame = function()
|
||||
end
|
||||
|
||||
editingSide = side
|
||||
button.text:SetTextColor (1, 1, 1)
|
||||
button.text:SetTextColor(1, 1, 1)
|
||||
lastButton = button
|
||||
|
||||
editorWindow [side.."Slider"]:Show()
|
||||
@@ -296,11 +296,11 @@ local CreateImageEditorFrame = function()
|
||||
if (alphaFrameShown) then
|
||||
alphaFrame:Hide()
|
||||
alphaFrameShown = false
|
||||
Alpha.button.text:SetTextColor (unpack(originalColor))
|
||||
Alpha.button.text:SetTextColor(unpack(originalColor))
|
||||
end
|
||||
|
||||
if (lastButton) then
|
||||
lastButton.text:SetTextColor (unpack(originalColor))
|
||||
lastButton.text:SetTextColor(unpack(originalColor))
|
||||
if (editingSide) then
|
||||
editorWindow [editingSide.."Slider"]:Hide()
|
||||
end
|
||||
@@ -328,7 +328,7 @@ local CreateImageEditorFrame = function()
|
||||
end
|
||||
|
||||
if (lastButton) then
|
||||
lastButton.text:SetTextColor (unpack(originalColor))
|
||||
lastButton.text:SetTextColor(unpack(originalColor))
|
||||
if (editingSide) then
|
||||
editorWindow [editingSide.."Slider"]:Hide()
|
||||
end
|
||||
@@ -338,11 +338,11 @@ local CreateImageEditorFrame = function()
|
||||
alphaFrame:Show()
|
||||
alphaSlider:SetValue(edit_texture:GetAlpha()*100)
|
||||
alphaFrameShown = true
|
||||
button.text:SetTextColor (1, 1, 1)
|
||||
button.text:SetTextColor(1, 1, 1)
|
||||
else
|
||||
alphaFrame:Hide()
|
||||
alphaFrameShown = false
|
||||
button.text:SetTextColor (unpack(originalColor))
|
||||
button.text:SetTextColor(unpack(originalColor))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -358,8 +358,8 @@ local CreateImageEditorFrame = function()
|
||||
local resizer = CreateFrame("Button", nil, editorWindow.widget, "BackdropTemplate")
|
||||
resizer:SetNormalTexture([[Interface\AddOns\Details\images\skins\default_skin]])
|
||||
resizer:SetHighlightTexture([[Interface\AddOns\Details\images\skins\default_skin]])
|
||||
resizer:GetNormalTexture():SetTexCoord (0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375)
|
||||
resizer:GetHighlightTexture():SetTexCoord (0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375)
|
||||
resizer:GetNormalTexture():SetTexCoord(0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375)
|
||||
resizer:GetHighlightTexture():SetTexCoord(0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375)
|
||||
resizer:SetWidth(16)
|
||||
resizer:SetHeight(16)
|
||||
resizer:SetPoint("BOTTOMRIGHT", editorWindow.widget, "BOTTOMRIGHT", 0, 0)
|
||||
|
||||
+278
-294
File diff suppressed because it is too large
Load Diff
+24
-26
@@ -18,16 +18,13 @@ local APISplitBarFunctions
|
||||
do
|
||||
local metaPrototype = {
|
||||
WidgetType = "split_bar",
|
||||
SetHook = DF.SetHook,
|
||||
RunHooksForWidget = DF.RunHooksForWidget,
|
||||
|
||||
dversion = DF.dversion,
|
||||
}
|
||||
|
||||
--check if there's a metaPrototype already existing
|
||||
if (_G[DF.GlobalWidgetControlNames["split_bar"]]) then
|
||||
--get the already existing metaPrototype
|
||||
local oldMetaPrototype = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
local oldMetaPrototype = _G[DF.GlobalWidgetControlNames["split_bar"]]
|
||||
--check if is older
|
||||
if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < DF.dversion) ) then
|
||||
--the version is older them the currently loading one
|
||||
@@ -38,11 +35,12 @@ do
|
||||
end
|
||||
else
|
||||
--first time loading the framework
|
||||
_G[DF.GlobalWidgetControlNames ["split_bar"]] = metaPrototype
|
||||
_G[DF.GlobalWidgetControlNames["split_bar"]] = metaPrototype
|
||||
end
|
||||
end
|
||||
|
||||
local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames["split_bar"]]
|
||||
DF:Mixin(SplitBarMetaFunctions, DF.ScriptHookMixin)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--metatables
|
||||
@@ -238,7 +236,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
local smember_lcolor = function(_object, _value)
|
||||
local _value1, _value2, _value3, _value4 = DF:ParseColors(_value)
|
||||
|
||||
_object.statusbar:SetStatusBarColor (_value1, _value2, _value3, _value4)
|
||||
_object.statusbar:SetStatusBarColor(_value1, _value2, _value3, _value4)
|
||||
_object.texture.original_colors = {_value1, _value2, _value3, _value4}
|
||||
return _object.texture:SetVertexColor(_value1, _value2, _value3, _value4)
|
||||
end
|
||||
@@ -248,7 +246,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
local _value1, _value2 = _unpack(_value)
|
||||
_object.iconright:SetTexture(_value1)
|
||||
if (_value2) then
|
||||
_object.iconright:SetTexCoord (_unpack(_value2))
|
||||
_object.iconright:SetTexCoord(_unpack(_value2))
|
||||
end
|
||||
else
|
||||
_object.iconright:SetTexture(_value)
|
||||
@@ -261,7 +259,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
local _value1, _value2 = _unpack(_value)
|
||||
_object.iconleft:SetTexture(_value1)
|
||||
if (_value2) then
|
||||
_object.iconleft:SetTexCoord (_unpack(_value2))
|
||||
_object.iconleft:SetTexCoord(_unpack(_value2))
|
||||
end
|
||||
else
|
||||
_object.iconleft:SetTexture(_value)
|
||||
@@ -275,8 +273,8 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
_object.texture:SetTexture(_value1)
|
||||
_object.rightTexture:SetTexture(_value1)
|
||||
if (_value2) then
|
||||
_object.texture:SetTexCoord (_unpack(_value2))
|
||||
_object.rightTexture:SetTexCoord (_unpack(_value2))
|
||||
_object.texture:SetTexCoord(_unpack(_value2))
|
||||
_object.rightTexture:SetTexCoord(_unpack(_value2))
|
||||
end
|
||||
else
|
||||
_object.texture:SetTexture(_value)
|
||||
@@ -297,8 +295,8 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
--font color
|
||||
local smember_textcolor = function(_object, _value)
|
||||
local _value1, _value2, _value3, _value4 = DF:ParseColors(_value)
|
||||
_object.textleft:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
return _object.textright:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
_object.textleft:SetTextColor(_value1, _value2, _value3, _value4)
|
||||
return _object.textright:SetTextColor(_value1, _value2, _value3, _value4)
|
||||
end
|
||||
|
||||
SplitBarMetaFunctions.SetMembers = SplitBarMetaFunctions.SetMembers or {}
|
||||
@@ -421,14 +419,14 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
self.iconleft:SetTexture(texture)
|
||||
if (...) then
|
||||
local L, R, U, D = unpack(...)
|
||||
self.iconleft:SetTexCoord (L, R, U, D)
|
||||
self.iconleft:SetTexCoord(L, R, U, D)
|
||||
end
|
||||
end
|
||||
function SplitBarMetaFunctions:SetRightIcon (texture, ...)
|
||||
self.iconright:SetTexture(texture)
|
||||
if (...) then
|
||||
local L, R, U, D = unpack(...)
|
||||
self.iconright:SetTexCoord (L, R, U, D)
|
||||
self.iconright:SetTexCoord(L, R, U, D)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -564,7 +562,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
|
||||
local OnEnter = function(frame)
|
||||
local capsule = frame.MyObject
|
||||
local kill = capsule:RunHooksForWidget ("OnEnter", frame, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnEnter", frame, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -578,7 +576,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
|
||||
local OnLeave = function(frame)
|
||||
local capsule = frame.MyObject
|
||||
local kill = capsule:RunHooksForWidget ("OnLeave", frame, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnLeave", frame, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -590,7 +588,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
|
||||
local OnHide = function(frame)
|
||||
local capsule = frame.MyObject
|
||||
local kill = capsule:RunHooksForWidget ("OnHide", frame, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnHide", frame, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -598,7 +596,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
|
||||
local OnShow = function(frame)
|
||||
local capsule = frame.MyObject
|
||||
local kill = capsule:RunHooksForWidget ("OnShow", frame, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnShow", frame, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -606,7 +604,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
|
||||
local OnMouseDown = function(frame, button)
|
||||
local capsule = frame.MyObject
|
||||
local kill = capsule:RunHooksForWidget ("OnMouseDown", frame, button, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnMouseDown", frame, button, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -621,7 +619,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
|
||||
|
||||
local OnMouseUp = function(frame, button)
|
||||
local capsule = frame.MyObject
|
||||
local kill = capsule:RunHooksForWidget ("OnMouseUp", frame, button, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnMouseUp", frame, button, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -716,15 +714,15 @@ function DF:NewSplitBar (parent, container, name, member, w, h)
|
||||
DF.SplitBarCounter = DF.SplitBarCounter + 1
|
||||
end
|
||||
if (not parent) then
|
||||
return error ("Details! FrameWork: parent not found.", 2)
|
||||
return error("Details! FrameWork: parent not found.", 2)
|
||||
end
|
||||
if (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
local parentName = DF.GetParentName (parent)
|
||||
name = name:gsub ("$parent", parentName)
|
||||
if (name:find("$parent")) then
|
||||
local parentName = DF.GetParentName(parent)
|
||||
name = name:gsub("$parent", parentName)
|
||||
end
|
||||
|
||||
local SplitBarObject = {type = "barsplit", dframework = true}
|
||||
@@ -754,7 +752,7 @@ function DF:NewSplitBar (parent, container, name, member, w, h)
|
||||
|
||||
if (not APISplitBarFunctions) then
|
||||
APISplitBarFunctions = true
|
||||
local idx = getmetatable (SplitBarObject.statusbar).__index
|
||||
local idx = getmetatable(SplitBarObject.statusbar).__index
|
||||
for funcName, funcAddress in pairs(idx) do
|
||||
if (not SplitBarMetaFunctions [funcName]) then
|
||||
SplitBarMetaFunctions [funcName] = function(object, ...)
|
||||
|
||||
+217
-276
@@ -1,5 +1,5 @@
|
||||
|
||||
local DF = _G ["DetailsFramework"]
|
||||
local DF = _G["DetailsFramework"]
|
||||
if (not DF or not DetailsFrameworkCanLoad) then
|
||||
return
|
||||
end
|
||||
@@ -11,10 +11,6 @@ local APITextEntryFunctions = false
|
||||
do
|
||||
local metaPrototype = {
|
||||
WidgetType = "textentry",
|
||||
SetHook = DF.SetHook,
|
||||
HasHook = DF.HasHook,
|
||||
ClearHooks = DF.ClearHooks,
|
||||
RunHooksForWidget = DF.RunHooksForWidget,
|
||||
dversion = DF.dversion,
|
||||
}
|
||||
|
||||
@@ -40,7 +36,8 @@ local TextEntryMetaFunctions = _G[DF.GlobalWidgetControlNames["textentry"]]
|
||||
|
||||
DF:Mixin(TextEntryMetaFunctions, DF.SetPointMixin)
|
||||
DF:Mixin(TextEntryMetaFunctions, DF.FrameMixin)
|
||||
|
||||
DF:Mixin(TextEntryMetaFunctions, DF.TooltipHandlerMixin)
|
||||
DF:Mixin(TextEntryMetaFunctions, DF.ScriptHookMixin)
|
||||
|
||||
DF.TextEntryCounter = DF.TextEntryCounter or 1
|
||||
|
||||
@@ -227,26 +224,13 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
|
||||
self.label:SetTextColor(1, .2, .2, 1)
|
||||
end
|
||||
|
||||
--tooltip
|
||||
function TextEntryMetaFunctions:SetTooltip(tooltip)
|
||||
if (tooltip) then
|
||||
return rawset(self, "have_tooltip", tooltip)
|
||||
else
|
||||
return rawset(self, "have_tooltip", nil)
|
||||
end
|
||||
end
|
||||
|
||||
function TextEntryMetaFunctions:GetTooltip()
|
||||
return rawget(self, "have_tooltip")
|
||||
end
|
||||
|
||||
--hooks
|
||||
function TextEntryMetaFunctions:Enable()
|
||||
if (not self.editbox:IsEnabled()) then
|
||||
self.editbox:Enable()
|
||||
self.editbox:SetBackdropBorderColor(unpack(self.enabled_border_color))
|
||||
self.editbox:SetBackdropColor(unpack(self.enabled_backdrop_color))
|
||||
self.editbox:SetTextColor (unpack(self.enabled_text_color))
|
||||
self.editbox:SetTextColor(unpack(self.enabled_text_color))
|
||||
if (self.editbox.borderframe) then
|
||||
local r, g, b, a = DF:ParseColors(unpack(self.editbox.borderframe.onleave_backdrop))
|
||||
self.editbox.borderframe:SetBackdropColor(r, g, b, a)
|
||||
@@ -286,59 +270,49 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
|
||||
--scripts and hooks
|
||||
|
||||
local OnEnter = function(textentry)
|
||||
local capsule = textentry.MyObject
|
||||
|
||||
local kill = capsule:RunHooksForWidget ("OnEnter", textentry, capsule)
|
||||
local object = textentry.MyObject
|
||||
local kill = object:RunHooksForWidget("OnEnter", textentry, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
|
||||
if (capsule.have_tooltip) then
|
||||
GameCooltip2:Preset(2)
|
||||
GameCooltip2:AddLine(capsule.have_tooltip)
|
||||
GameCooltip2:ShowCooltip(textentry, "tooltip")
|
||||
end
|
||||
|
||||
textentry.mouse_over = true
|
||||
object:ShowTooltip()
|
||||
|
||||
if (textentry:IsEnabled()) then
|
||||
textentry.mouse_over = true
|
||||
|
||||
if (textentry:IsEnabled()) then
|
||||
textentry.current_bordercolor = textentry.current_bordercolor or {textentry:GetBackdropBorderColor()}
|
||||
textentry:SetBackdropBorderColor(1, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local OnLeave = function(textentry)
|
||||
local capsule = textentry.MyObject
|
||||
|
||||
local kill = capsule:RunHooksForWidget ("OnLeave", textentry, capsule)
|
||||
local object = textentry.MyObject
|
||||
local kill = object:RunHooksForWidget("OnLeave", textentry, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
|
||||
if (textentry.MyObject.have_tooltip) then
|
||||
GameCooltip2:ShowMe(false)
|
||||
end
|
||||
|
||||
textentry.mouse_over = false
|
||||
|
||||
if (textentry:IsEnabled()) then
|
||||
object:HideTooltip()
|
||||
|
||||
textentry.mouse_over = false
|
||||
|
||||
if (textentry:IsEnabled()) then
|
||||
textentry:SetBackdropBorderColor(unpack(textentry.current_bordercolor))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local OnHide = function(textentry)
|
||||
local capsule = textentry.MyObject
|
||||
|
||||
local kill = capsule:RunHooksForWidget ("OnHide", textentry, capsule)
|
||||
local object = textentry.MyObject
|
||||
local kill = object:RunHooksForWidget("OnHide", textentry, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local OnShow = function(textentry)
|
||||
local capsule = textentry.MyObject
|
||||
|
||||
local kill = capsule:RunHooksForWidget ("OnShow", textentry, capsule)
|
||||
local object = textentry.MyObject
|
||||
local kill = object:RunHooksForWidget("OnShow", textentry, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -346,7 +320,6 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
|
||||
|
||||
local OnEnterPressed = function(textentry, byScript)
|
||||
local object = textentry.MyObject
|
||||
|
||||
if (object.ignoreNextCallback) then
|
||||
DF.Schedules.RunNextTick(function() object.ignoreNextCallback = nil end)
|
||||
return
|
||||
@@ -361,6 +334,7 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
|
||||
if (string.len(text) > 0) then
|
||||
textentry.text = text
|
||||
if (textentry.MyObject.func) then
|
||||
--need to have a dispatch here
|
||||
textentry.MyObject.func(textentry.MyObject.param1, textentry.MyObject.param2, text, textentry, byScript or textentry)
|
||||
end
|
||||
else
|
||||
@@ -376,22 +350,21 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local OnEscapePressed = function(textentry)
|
||||
local capsule = textentry.MyObject
|
||||
|
||||
local kill = capsule:RunHooksForWidget ("OnEscapePressed", textentry, capsule, capsule.text)
|
||||
local object = textentry.MyObject
|
||||
local kill = object:RunHooksForWidget("OnEscapePressed", textentry, object, object.text)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
textentry.focuslost = true
|
||||
textentry:ClearFocus()
|
||||
textentry:ClearFocus()
|
||||
end
|
||||
|
||||
local OnSpacePressed = function(textEntry)
|
||||
local object = textEntry.MyObject
|
||||
local kill = object:RunHooksForWidget ("OnSpacePressed", textEntry, object)
|
||||
local kill = object:RunHooksForWidget("OnSpacePressed", textEntry, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -399,7 +372,6 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
|
||||
|
||||
local OnEditFocusLost = function(textEntry)
|
||||
local object = textEntry.MyObject
|
||||
|
||||
if (object.ignoreNextCallback) then
|
||||
DF.Schedules.RunNextTick(function() object.ignoreNextCallback = nil end)
|
||||
return
|
||||
@@ -426,13 +398,13 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
|
||||
textEntry.focuslost = false
|
||||
end
|
||||
|
||||
textEntry.MyObject.label:SetTextColor (.8, .8, .8, 1)
|
||||
textEntry.MyObject.label:SetTextColor(.8, .8, .8, 1)
|
||||
end
|
||||
end
|
||||
|
||||
local OnEditFocusGained = function(textentry)
|
||||
local object = textentry.MyObject
|
||||
local kill = object:RunHooksForWidget ("OnEditFocusGained", textentry, object)
|
||||
local kill = object:RunHooksForWidget("OnEditFocusGained", textentry, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
@@ -445,40 +417,37 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
|
||||
|
||||
local OnChar = function(textentry, char)
|
||||
local object = textentry.MyObject
|
||||
local kill = object:RunHooksForWidget ("OnChar", textentry, char, object)
|
||||
local kill = object:RunHooksForWidget("OnChar", textentry, char, object)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local OnTextChanged = function(textentry, byUser)
|
||||
|
||||
local OnTextChanged = function(textentry, byUser)
|
||||
local capsule = textentry.MyObject
|
||||
|
||||
local kill = capsule:RunHooksForWidget ("OnTextChanged", textentry, byUser, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnTextChanged", textentry, byUser, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local OnTabPressed = function(textentry)
|
||||
|
||||
|
||||
local OnTabPressed = function(textentry)
|
||||
local capsule = textentry.MyObject
|
||||
|
||||
local kill = capsule:RunHooksForWidget ("OnTabPressed", textentry, byUser, capsule)
|
||||
local kill = capsule:RunHooksForWidget("OnTabPressed", textentry, byUser, capsule)
|
||||
if (kill) then
|
||||
return
|
||||
end
|
||||
|
||||
if (textentry.MyObject.next) then
|
||||
OnEnterPressed (textentry, false)
|
||||
|
||||
if (textentry.MyObject.next) then
|
||||
OnEnterPressed(textentry, false)
|
||||
textentry.MyObject.next:SetFocus()
|
||||
end
|
||||
end
|
||||
|
||||
function TextEntryMetaFunctions:PressEnter (byScript)
|
||||
OnEnterPressed (self.editbox, byScript)
|
||||
|
||||
function TextEntryMetaFunctions:PressEnter(byScript)
|
||||
OnEnterPressed(self.editbox, byScript)
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function TextEntryMetaFunctions:SetTemplate(template)
|
||||
@@ -488,7 +457,7 @@ function TextEntryMetaFunctions:SetTemplate(template)
|
||||
if (template.height) then
|
||||
self.editbox:SetHeight(template.height)
|
||||
end
|
||||
|
||||
|
||||
if (template.backdrop) then
|
||||
self.editbox:SetBackdrop(template.backdrop)
|
||||
end
|
||||
@@ -511,199 +480,171 @@ end
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--object constructor
|
||||
|
||||
function DF:CreateTextEntry (parent, func, w, h, member, name, with_label, entry_template, label_template)
|
||||
function DF:CreateTextEntry(parent, func, w, h, member, name, with_label, entry_template, label_template)
|
||||
return DF:NewTextEntry(parent, parent, name, member, w, h, func, nil, nil, nil, with_label, entry_template, label_template)
|
||||
end
|
||||
|
||||
function DF:NewTextEntry(parent, container, name, member, w, h, func, param1, param2, space, with_label, entry_template, label_template)
|
||||
|
||||
function DF:NewTextEntry(parent, container, name, member, width, height, func, param1, param2, space, withLabel, entryTemplate, labelTemplate)
|
||||
if (not name) then
|
||||
name = "DetailsFrameworkTextEntryNumber" .. DF.TextEntryCounter
|
||||
DF.TextEntryCounter = DF.TextEntryCounter + 1
|
||||
|
||||
|
||||
elseif (not parent) then
|
||||
return error ("Details! FrameWork: parent not found.", 2)
|
||||
return error("Details! FrameWork: parent not found.", 2)
|
||||
end
|
||||
|
||||
|
||||
if (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
local parentName = DF.GetParentName (parent)
|
||||
name = name:gsub ("$parent", parentName)
|
||||
|
||||
if (name:find("$parent")) then
|
||||
local parentName = DF.GetParentName(parent)
|
||||
name = name:gsub("$parent", parentName)
|
||||
end
|
||||
|
||||
local TextEntryObject = {type = "textentry", dframework = true}
|
||||
|
||||
|
||||
local newTextEntryObject = {type = "textentry", dframework = true}
|
||||
|
||||
if (member) then
|
||||
parent [member] = TextEntryObject
|
||||
parent[member] = newTextEntryObject
|
||||
end
|
||||
|
||||
if (parent.dframework) then
|
||||
parent = parent.widget
|
||||
end
|
||||
|
||||
if (container.dframework) then
|
||||
container = container.widget
|
||||
end
|
||||
|
||||
--default members:
|
||||
--hooks
|
||||
TextEntryObject.OnEnterHook = nil
|
||||
TextEntryObject.OnLeaveHook = nil
|
||||
TextEntryObject.OnHideHook = nil
|
||||
TextEntryObject.OnShowHook = nil
|
||||
TextEntryObject.OnEnterPressedHook = nil
|
||||
TextEntryObject.OnEscapePressedHook = nil
|
||||
TextEntryObject.OnEditFocusGainedHook = nil
|
||||
TextEntryObject.OnEditFocusLostHook = nil
|
||||
TextEntryObject.OnCharHook = nil
|
||||
TextEntryObject.OnTextChangedHook = nil
|
||||
TextEntryObject.OnTabPressedHook = nil
|
||||
|
||||
--misc
|
||||
TextEntryObject.container = container
|
||||
TextEntryObject.have_tooltip = nil
|
||||
--misc
|
||||
newTextEntryObject.container = container
|
||||
|
||||
TextEntryObject.editbox = CreateFrame("EditBox", name, parent,"BackdropTemplate")
|
||||
TextEntryObject.editbox:SetSize(232, 20)
|
||||
TextEntryObject.editbox:SetBackdrop({bgFile = [["Interface\DialogFrame\UI-DialogBox-Background"]], tileSize = 64, tile = true, edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]], edgeSize = 10, insets = {left = 1, right = 1, top = 0, bottom = 0}})
|
||||
|
||||
TextEntryObject.editbox.label = TextEntryObject.editbox:CreateFontString("$parent_Desc", "OVERLAY", "GameFontHighlightSmall")
|
||||
TextEntryObject.editbox.label:SetJustifyH("left")
|
||||
TextEntryObject.editbox.label:SetPoint("RIGHT", TextEntryObject.editbox, "LEFT", -2, 0)
|
||||
|
||||
TextEntryObject.widget = TextEntryObject.editbox
|
||||
|
||||
TextEntryObject.editbox:SetTextInsets (3, 0, 0, -3)
|
||||
if (not width and space) then
|
||||
width = space
|
||||
end
|
||||
|
||||
--editbox
|
||||
newTextEntryObject.editbox = CreateFrame("EditBox", name, parent,"BackdropTemplate")
|
||||
newTextEntryObject.editbox:SetSize(232, 20)
|
||||
newTextEntryObject.editbox:SetBackdrop({bgFile = [["Interface\DialogFrame\UI-DialogBox-Background"]], tileSize = 64, tile = true, edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]], edgeSize = 10, insets = {left = 1, right = 1, top = 0, bottom = 0}})
|
||||
newTextEntryObject.editbox:SetTextInsets(3, 0, 0, -3)
|
||||
newTextEntryObject.editbox:SetWidth(width)
|
||||
newTextEntryObject.editbox:SetHeight(height)
|
||||
newTextEntryObject.editbox:SetJustifyH("center")
|
||||
newTextEntryObject.editbox:EnableMouse(true)
|
||||
newTextEntryObject.editbox:SetText("")
|
||||
newTextEntryObject.editbox:SetAutoFocus(false)
|
||||
newTextEntryObject.editbox:SetFontObject("GameFontHighlightSmall")
|
||||
|
||||
--editbox label
|
||||
newTextEntryObject.editbox.label = newTextEntryObject.editbox:CreateFontString("$parent_Desc", "OVERLAY", "GameFontHighlightSmall")
|
||||
newTextEntryObject.editbox.label:SetJustifyH("left")
|
||||
newTextEntryObject.editbox.label:SetPoint("RIGHT", newTextEntryObject.editbox, "LEFT", -2, 0)
|
||||
|
||||
newTextEntryObject.label = newTextEntryObject.editbox.label
|
||||
newTextEntryObject.widget = newTextEntryObject.editbox
|
||||
newTextEntryObject.editbox.MyObject = newTextEntryObject
|
||||
|
||||
if (not APITextEntryFunctions) then
|
||||
APITextEntryFunctions = true
|
||||
local idx = getmetatable (TextEntryObject.editbox).__index
|
||||
for funcName, funcAddress in pairs(idx) do
|
||||
if (not TextEntryMetaFunctions [funcName]) then
|
||||
TextEntryMetaFunctions [funcName] = function(object, ...)
|
||||
local x = loadstring ( "return _G['"..object.editbox:GetName().."']:"..funcName.."(...)")
|
||||
return x (...)
|
||||
local idx = getmetatable(newTextEntryObject.editbox).__index
|
||||
for funcName, funcAddress in pairs(idx) do
|
||||
if (not TextEntryMetaFunctions[funcName]) then
|
||||
TextEntryMetaFunctions[funcName] = function(object, ...)
|
||||
local x = loadstring( "return _G['"..object.editbox:GetName().."']:"..funcName.."(...)")
|
||||
return x(...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
TextEntryObject.editbox.MyObject = TextEntryObject
|
||||
|
||||
if (not w and space) then
|
||||
w = space
|
||||
elseif (w and space) then
|
||||
if (DF.debug) then
|
||||
--print("warning: you are using width and space, try use only space for better results.")
|
||||
end
|
||||
end
|
||||
|
||||
TextEntryObject.editbox:SetWidth(w)
|
||||
TextEntryObject.editbox:SetHeight(h)
|
||||
|
||||
TextEntryObject.editbox:SetJustifyH("center")
|
||||
TextEntryObject.editbox:EnableMouse(true)
|
||||
TextEntryObject.editbox:SetText("")
|
||||
newTextEntryObject.editbox.current_bordercolor = {1, 1, 1, 0.7}
|
||||
newTextEntryObject.enabled_border_color = {newTextEntryObject.editbox:GetBackdropBorderColor()}
|
||||
newTextEntryObject.enabled_backdrop_color = {newTextEntryObject.editbox:GetBackdropColor()}
|
||||
newTextEntryObject.enabled_text_color = {newTextEntryObject.editbox:GetTextColor()}
|
||||
newTextEntryObject.onleave_backdrop = {newTextEntryObject.editbox:GetBackdropColor()}
|
||||
newTextEntryObject.onleave_backdrop_border_color = {newTextEntryObject.editbox:GetBackdropBorderColor()}
|
||||
|
||||
TextEntryObject.editbox:SetAutoFocus (false)
|
||||
TextEntryObject.editbox:SetFontObject ("GameFontHighlightSmall")
|
||||
newTextEntryObject.func = func
|
||||
newTextEntryObject.param1 = param1
|
||||
newTextEntryObject.param2 = param2
|
||||
newTextEntryObject.next = nil
|
||||
newTextEntryObject.space = space
|
||||
newTextEntryObject.tab_on_enter = false
|
||||
|
||||
TextEntryObject.editbox.current_bordercolor = {1, 1, 1, 0.7}
|
||||
TextEntryObject.editbox:SetBackdropBorderColor(1, 1, 1, 0.7)
|
||||
TextEntryObject.enabled_border_color = {TextEntryObject.editbox:GetBackdropBorderColor()}
|
||||
TextEntryObject.enabled_backdrop_color = {TextEntryObject.editbox:GetBackdropColor()}
|
||||
TextEntryObject.enabled_text_color = {TextEntryObject.editbox:GetTextColor()}
|
||||
TextEntryObject.onleave_backdrop = {TextEntryObject.editbox:GetBackdropColor()}
|
||||
TextEntryObject.onleave_backdrop_border_color = {TextEntryObject.editbox:GetBackdropBorderColor()}
|
||||
|
||||
TextEntryObject.func = func
|
||||
TextEntryObject.param1 = param1
|
||||
TextEntryObject.param2 = param2
|
||||
TextEntryObject.next = nil
|
||||
TextEntryObject.space = space
|
||||
TextEntryObject.tab_on_enter = false
|
||||
|
||||
TextEntryObject.label = _G [name .. "_Desc"]
|
||||
TextEntryObject.editbox:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, insets = {left = 1, right = 1, top = 1, bottom = 1}})
|
||||
TextEntryObject.editbox:SetBackdropColor(.2, .2, .2, 1)
|
||||
newTextEntryObject.editbox:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, insets = {left = 1, right = 1, top = 1, bottom = 1}})
|
||||
newTextEntryObject.editbox:SetBackdropColor(.2, .2, .2, 1)
|
||||
newTextEntryObject.editbox:SetBackdropBorderColor(1, 1, 1, 0.7)
|
||||
|
||||
--hooks
|
||||
TextEntryObject.HookList = {
|
||||
OnEnter = {},
|
||||
OnLeave = {},
|
||||
OnHide = {},
|
||||
OnShow = {},
|
||||
OnEnterPressed = {},
|
||||
OnEscapePressed = {},
|
||||
OnSpacePressed = {},
|
||||
OnEditFocusLost = {},
|
||||
OnEditFocusGained = {},
|
||||
OnChar = {},
|
||||
OnTextChanged = {},
|
||||
OnTabPressed = {},
|
||||
}
|
||||
|
||||
TextEntryObject.editbox:SetScript("OnEnter", OnEnter)
|
||||
TextEntryObject.editbox:SetScript("OnLeave", OnLeave)
|
||||
TextEntryObject.editbox:SetScript("OnHide", OnHide)
|
||||
TextEntryObject.editbox:SetScript("OnShow", OnShow)
|
||||
|
||||
TextEntryObject.editbox:SetScript("OnEnterPressed", OnEnterPressed)
|
||||
TextEntryObject.editbox:SetScript("OnEscapePressed", OnEscapePressed)
|
||||
TextEntryObject.editbox:SetScript("OnSpacePressed", OnSpacePressed)
|
||||
TextEntryObject.editbox:SetScript("OnEditFocusLost", OnEditFocusLost)
|
||||
TextEntryObject.editbox:SetScript("OnEditFocusGained", OnEditFocusGained)
|
||||
TextEntryObject.editbox:SetScript("OnChar", OnChar)
|
||||
TextEntryObject.editbox:SetScript("OnTextChanged", OnTextChanged)
|
||||
TextEntryObject.editbox:SetScript("OnTabPressed", OnTabPressed)
|
||||
|
||||
setmetatable(TextEntryObject, TextEntryMetaFunctions)
|
||||
|
||||
if (with_label) then
|
||||
local label = DF:CreateLabel(TextEntryObject.editbox, with_label, nil, nil, nil, "label", nil, "overlay")
|
||||
label.text = with_label
|
||||
TextEntryObject.editbox:SetPoint("left", label.widget, "right", 2, 0)
|
||||
if (label_template) then
|
||||
label:SetTemplate(label_template)
|
||||
newTextEntryObject.HookList = {
|
||||
OnEnter = {},
|
||||
OnLeave = {},
|
||||
OnHide = {},
|
||||
OnShow = {},
|
||||
OnEnterPressed = {},
|
||||
OnEscapePressed = {},
|
||||
OnSpacePressed = {},
|
||||
OnEditFocusLost = {},
|
||||
OnEditFocusGained = {},
|
||||
OnChar = {},
|
||||
OnTextChanged = {},
|
||||
OnTabPressed = {},
|
||||
}
|
||||
|
||||
newTextEntryObject.editbox:SetScript("OnEnter", OnEnter)
|
||||
newTextEntryObject.editbox:SetScript("OnLeave", OnLeave)
|
||||
newTextEntryObject.editbox:SetScript("OnHide", OnHide)
|
||||
newTextEntryObject.editbox:SetScript("OnShow", OnShow)
|
||||
newTextEntryObject.editbox:SetScript("OnEnterPressed", OnEnterPressed)
|
||||
newTextEntryObject.editbox:SetScript("OnEscapePressed", OnEscapePressed)
|
||||
newTextEntryObject.editbox:SetScript("OnSpacePressed", OnSpacePressed)
|
||||
newTextEntryObject.editbox:SetScript("OnEditFocusLost", OnEditFocusLost)
|
||||
newTextEntryObject.editbox:SetScript("OnEditFocusGained", OnEditFocusGained)
|
||||
newTextEntryObject.editbox:SetScript("OnChar", OnChar)
|
||||
newTextEntryObject.editbox:SetScript("OnTextChanged", OnTextChanged)
|
||||
newTextEntryObject.editbox:SetScript("OnTabPressed", OnTabPressed)
|
||||
|
||||
setmetatable(newTextEntryObject, TextEntryMetaFunctions)
|
||||
|
||||
if (withLabel) then
|
||||
local label = DF:CreateLabel(newTextEntryObject.editbox, withLabel, nil, nil, nil, "label", nil, "overlay")
|
||||
label.text = withLabel
|
||||
newTextEntryObject.editbox:SetPoint("left", label.widget, "right", 2, 0)
|
||||
if (labelTemplate) then
|
||||
label:SetTemplate(labelTemplate)
|
||||
end
|
||||
with_label = label
|
||||
withLabel = label
|
||||
end
|
||||
|
||||
if (entry_template) then
|
||||
TextEntryObject:SetTemplate(entry_template)
|
||||
end
|
||||
|
||||
return TextEntryObject, with_label
|
||||
|
||||
|
||||
if (entryTemplate) then
|
||||
newTextEntryObject:SetTemplate(entryTemplate)
|
||||
end
|
||||
|
||||
return newTextEntryObject, withLabel
|
||||
end
|
||||
|
||||
function DF:NewSpellEntry (parent, func, w, h, param1, param2, member, name)
|
||||
function DF:NewSpellEntry(parent, func, w, h, param1, param2, member, name)
|
||||
local editbox = DF:NewTextEntry(parent, parent, name, member, w, h, func, param1, param2)
|
||||
|
||||
-- editbox:SetHook("OnEditFocusGained", SpellEntryOnEditFocusGained)
|
||||
-- editbox:SetHook("OnTextChanged", SpellEntryOnTextChanged)
|
||||
|
||||
return editbox
|
||||
return editbox
|
||||
end
|
||||
|
||||
local function_gettext = function(self)
|
||||
return self.editbox:GetText()
|
||||
end
|
||||
|
||||
local function_settext = function(self, text)
|
||||
return self.editbox:SetText(text)
|
||||
end
|
||||
|
||||
local function_clearfocus = function(self)
|
||||
return self.editbox:ClearFocus()
|
||||
end
|
||||
|
||||
local function_setfocus = function(self)
|
||||
return self.editbox:SetFocus (true)
|
||||
return self.editbox:SetFocus(true)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
--auto complete
|
||||
|
||||
@@ -805,7 +746,7 @@ local function ColorSelection ( self, ColorCode )
|
||||
if ( CursorReplacement >= #Replacement ) then -- Cursor beyond end of color
|
||||
Cursor = Cursor + #COLOR_END;
|
||||
end
|
||||
|
||||
|
||||
self:SetCursorPosition( Cursor );
|
||||
-- Highlight selection and wrapper
|
||||
self:HighlightText( Start, #ColorCode + ( #Replacement - #Selection ) + #COLOR_END + End );
|
||||
@@ -830,7 +771,7 @@ end
|
||||
--On Text Changed
|
||||
local AutoComplete_OnTextChanged = function(editboxWidget, byUser, capsule)
|
||||
capsule = capsule or editboxWidget.MyObject or editboxWidget
|
||||
|
||||
|
||||
local chars_now = editboxWidget:GetText():len()
|
||||
if (not editboxWidget.ignore_textchange) then
|
||||
--backspace
|
||||
@@ -892,37 +833,37 @@ local AutoComplete_OnEditFocusGained = function(editboxWidget)
|
||||
--print("last word:", editboxWidget.lastword)
|
||||
editboxWidget.end_selection = nil
|
||||
editboxWidget.focusGained = true
|
||||
capsule.characters_count = editboxWidget:GetText():len()
|
||||
capsule.characters_count = editboxWidget:GetText():len()
|
||||
end
|
||||
|
||||
local OptimizeAutoCompleteTable = function(self, wordList)
|
||||
local optimizedTable = {}
|
||||
|
||||
|
||||
local lower = string.lower
|
||||
local sub = string.sub
|
||||
local len = string.len
|
||||
|
||||
|
||||
local subTables = 0
|
||||
|
||||
|
||||
for i = 1, #wordList do
|
||||
local thisWord = wordList [i]
|
||||
if (len (thisWord) > 0) then
|
||||
thisWord = lower (thisWord)
|
||||
|
||||
|
||||
local firstCharacter = sub (thisWord, 1, 1)
|
||||
|
||||
|
||||
local charTable = optimizedTable [firstCharacter]
|
||||
if (not charTable) then
|
||||
charTable = {}
|
||||
optimizedTable [firstCharacter] = charTable
|
||||
|
||||
|
||||
subTables = subTables + 1
|
||||
end
|
||||
|
||||
|
||||
charTable [#charTable+1] = thisWord
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
wordList.Optimized = optimizedTable
|
||||
end
|
||||
|
||||
@@ -930,14 +871,14 @@ local AutoComplete_OnChar = function(editboxWidget, char, capsule)
|
||||
if (char == "") then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
capsule = capsule or editboxWidget.MyObject or editboxWidget
|
||||
editboxWidget.end_selection = nil
|
||||
|
||||
|
||||
if (editboxWidget.ignore_input) then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--reseta a palavra se acabou de ganhar focus e apertou espa�o
|
||||
if (editboxWidget.focusGained and char == " ") then
|
||||
capsule.lastword = ""
|
||||
@@ -945,37 +886,37 @@ local AutoComplete_OnChar = function(editboxWidget, char, capsule)
|
||||
else
|
||||
editboxWidget.focusGained = nil
|
||||
end
|
||||
|
||||
|
||||
if (char:match ("%a") or (char == " " and capsule.lastword ~= "")) then
|
||||
capsule.lastword = capsule.lastword .. char
|
||||
else
|
||||
capsule.lastword = ""
|
||||
end
|
||||
|
||||
|
||||
editboxWidget.ignore_input = true
|
||||
|
||||
|
||||
if (capsule.lastword:len() >= 2) then
|
||||
|
||||
|
||||
local wordList = capsule [capsule.poolName]
|
||||
if (not wordList) then
|
||||
error ("Details! Framework: TextEntry has AutoComplete but no word list table.")
|
||||
error("Details! Framework: TextEntry has AutoComplete but no word list table.")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if (capsule.ShouldOptimizeAutoComplete) then
|
||||
if (not wordList.Optimized) then
|
||||
OptimizeAutoCompleteTable (capsule, wordList)
|
||||
end
|
||||
|
||||
local firstCharacter = string.lower (string.sub (capsule.lastword, 1, 1))
|
||||
|
||||
local firstCharacter = string.lower(string.sub (capsule.lastword, 1, 1))
|
||||
wordList = wordList.Optimized [firstCharacter]
|
||||
|
||||
|
||||
if (wordList) then
|
||||
for i = 1, #wordList do
|
||||
local thisWord = wordList [i]
|
||||
if (thisWord and (thisWord:find ("^" .. capsule.lastword) or thisWord:lower():find ("^" .. capsule.lastword))) then
|
||||
local rest = thisWord:gsub (capsule.lastword, "")
|
||||
rest = rest:lower():gsub (capsule.lastword, "")
|
||||
if (thisWord and (thisWord:find("^" .. capsule.lastword) or thisWord:lower():find("^" .. capsule.lastword))) then
|
||||
local rest = thisWord:gsub(capsule.lastword, "")
|
||||
rest = rest:lower():gsub(capsule.lastword, "")
|
||||
local cursor_pos = editboxWidget:GetCursorPosition()
|
||||
editboxWidget:Insert (rest)
|
||||
editboxWidget:HighlightText (cursor_pos, cursor_pos + rest:len())
|
||||
@@ -986,16 +927,16 @@ local AutoComplete_OnChar = function(editboxWidget, char, capsule)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
editboxWidget.ignore_input = false
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
for i = 1, #wordList do
|
||||
local thisWord = wordList [i]
|
||||
if (thisWord and (thisWord:find ("^" .. capsule.lastword) or thisWord:lower():find ("^" .. capsule.lastword))) then
|
||||
local rest = thisWord:gsub (capsule.lastword, "")
|
||||
rest = rest:lower():gsub (capsule.lastword, "")
|
||||
if (thisWord and (thisWord:find("^" .. capsule.lastword) or thisWord:lower():find("^" .. capsule.lastword))) then
|
||||
local rest = thisWord:gsub(capsule.lastword, "")
|
||||
rest = rest:lower():gsub(capsule.lastword, "")
|
||||
local cursor_pos = editboxWidget:GetCursorPosition()
|
||||
editboxWidget:Insert (rest)
|
||||
editboxWidget:HighlightText (cursor_pos, cursor_pos + rest:len())
|
||||
@@ -1006,28 +947,28 @@ local AutoComplete_OnChar = function(editboxWidget, char, capsule)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
editboxWidget.ignore_input = false
|
||||
end
|
||||
|
||||
function TextEntryMetaFunctions:SetAsAutoComplete (poolName, poolTable, shouldOptimize)
|
||||
|
||||
|
||||
if (not self.SetHook) then
|
||||
--self is borderframe
|
||||
self = self.editbox
|
||||
self.editbox = self --compatible with fw functions
|
||||
|
||||
|
||||
self.lastword = ""
|
||||
self.characters_count = 0
|
||||
self.poolName = poolName
|
||||
self.GetLastWord = get_last_word --editbox:GetLastWord()
|
||||
self.NoClearFocusOnEnterPressed = true --avoid auto clear focus
|
||||
self.ShouldOptimizeAutoComplete = shouldOptimize
|
||||
|
||||
|
||||
if (poolTable) then
|
||||
self [poolName] = poolTable
|
||||
end
|
||||
|
||||
|
||||
self:HookScript ("OnEditFocusGained", AutoComplete_OnEditFocusGained)
|
||||
self:HookScript ("OnEnterPressed", AutoComplete_OnEnterPressed)
|
||||
self:HookScript ("OnEscapePressed", AutoComplete_OnEscapePressed)
|
||||
@@ -1042,7 +983,7 @@ function TextEntryMetaFunctions:SetAsAutoComplete (poolName, poolTable, shouldOp
|
||||
self.GetLastWord = get_last_word --editbox:GetLastWord()
|
||||
self.NoClearFocusOnEnterPressed = true --avoid auto clear focus
|
||||
self.ShouldOptimizeAutoComplete = shouldOptimize
|
||||
|
||||
|
||||
self:SetHook("OnEditFocusGained", AutoComplete_OnEditFocusGained)
|
||||
self:SetHook("OnEnterPressed", AutoComplete_OnEnterPressed)
|
||||
self.editbox:HookScript ("OnEscapePressed", AutoComplete_OnEscapePressed)
|
||||
@@ -1062,36 +1003,36 @@ end
|
||||
|
||||
function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent, showLineNumbers)
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
local parentName = DF.GetParentName (parent)
|
||||
name = name:gsub ("$parent", parentName)
|
||||
if (name:find("$parent")) then
|
||||
local parentName = DF.GetParentName(parent)
|
||||
name = name:gsub("$parent", parentName)
|
||||
end
|
||||
|
||||
|
||||
local borderframe = CreateFrame("Frame", name, parent,"BackdropTemplate")
|
||||
borderframe:SetSize(w, h)
|
||||
|
||||
|
||||
if (member) then
|
||||
parent [member] = borderframe
|
||||
end
|
||||
|
||||
|
||||
local scrollframe = CreateFrame("ScrollFrame", name, borderframe, "UIPanelScrollFrameTemplate, BackdropTemplate")
|
||||
local scrollframeNumberLines = CreateFrame("ScrollFrame", name .. "NumberLines", borderframe, "UIPanelScrollFrameTemplate, BackdropTemplate")
|
||||
|
||||
scrollframe.editbox = CreateFrame("editbox", "$parentEditBox", scrollframe,"BackdropTemplate")
|
||||
scrollframe.editbox:SetMultiLine (true)
|
||||
scrollframe.editbox:SetAutoFocus (false)
|
||||
scrollframe.editbox:SetAutoFocus(false)
|
||||
scrollframe.editbox:SetScript("OnCursorChanged", _G.ScrollingEdit_OnCursorChanged)
|
||||
scrollframe.editbox:SetScript("OnEscapePressed", _G.EditBox_ClearFocus)
|
||||
scrollframe.editbox:SetFontObject ("GameFontHighlightSmall")
|
||||
scrollframe.editbox:SetFontObject("GameFontHighlightSmall")
|
||||
scrollframe:SetScrollChild (scrollframe.editbox)
|
||||
|
||||
--line number
|
||||
if (showLineNumbers) then
|
||||
scrollframeNumberLines.editbox = CreateFrame("editbox", "$parentLineNumbers", scrollframeNumberLines, "BackdropTemplate")
|
||||
scrollframeNumberLines.editbox:SetMultiLine (true)
|
||||
scrollframeNumberLines.editbox:SetAutoFocus (false)
|
||||
scrollframeNumberLines.editbox:SetAutoFocus(false)
|
||||
scrollframeNumberLines.editbox:SetEnabled (false)
|
||||
scrollframeNumberLines.editbox:SetFontObject ("GameFontHighlightSmall")
|
||||
scrollframeNumberLines.editbox:SetFontObject("GameFontHighlightSmall")
|
||||
scrollframeNumberLines.editbox:SetJustifyH("left")
|
||||
scrollframeNumberLines.editbox:SetJustifyV ("top")
|
||||
scrollframeNumberLines.editbox:SetTextColor(.3, .3, .3, .5)
|
||||
@@ -1148,49 +1089,49 @@ function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent, show
|
||||
end
|
||||
|
||||
borderframe.SetAsAutoComplete = TextEntryMetaFunctions.SetAsAutoComplete
|
||||
|
||||
|
||||
scrollframe:SetScript("OnSizeChanged", function(self)
|
||||
scrollframe.editbox:SetSize(self:GetSize())
|
||||
end)
|
||||
|
||||
|
||||
scrollframe.editbox:SetJustifyH("left")
|
||||
scrollframe.editbox:SetJustifyV ("top")
|
||||
scrollframe.editbox:SetMaxBytes (1024000)
|
||||
scrollframe.editbox:SetMaxLetters (128000)
|
||||
|
||||
|
||||
borderframe.GetText = function_gettext
|
||||
borderframe.SetText = function_settext
|
||||
borderframe.ClearFocus = function_clearfocus
|
||||
borderframe.SetFocus = function_setfocus
|
||||
borderframe.SetTextSize = set_speciallua_editor_font_size
|
||||
|
||||
|
||||
borderframe.Enable = TextEntryMetaFunctions.Enable
|
||||
borderframe.Disable = TextEntryMetaFunctions.Disable
|
||||
|
||||
|
||||
borderframe.SetTemplate = TextEntryMetaFunctions.SetTemplate
|
||||
|
||||
|
||||
if (not nointent) then
|
||||
IndentationLib.enable (scrollframe.editbox, nil, 4)
|
||||
end
|
||||
|
||||
borderframe:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
|
||||
borderframe:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
|
||||
tile = 1, tileSize = 16, edgeSize = 16, insets = {left = 5, right = 5, top = 5, bottom = 5}})
|
||||
|
||||
|
||||
scrollframe.editbox.current_bordercolor = {1, 1, 1, 0.7}
|
||||
borderframe:SetBackdropBorderColor(1, 1, 1, 0.7)
|
||||
borderframe:SetBackdropColor(0.090195, 0.090195, 0.188234, 1)
|
||||
|
||||
|
||||
borderframe.enabled_border_color = {borderframe:GetBackdropBorderColor()}
|
||||
borderframe.enabled_backdrop_color = {borderframe:GetBackdropColor()}
|
||||
borderframe.enabled_text_color = {scrollframe.editbox:GetTextColor()}
|
||||
|
||||
borderframe.onleave_backdrop = {scrollframe.editbox:GetBackdropColor()}
|
||||
borderframe.onleave_backdrop_border_color = {scrollframe.editbox:GetBackdropBorderColor()}
|
||||
|
||||
|
||||
borderframe.scroll = scrollframe
|
||||
borderframe.editbox = scrollframe.editbox
|
||||
borderframe.editbox.borderframe = borderframe
|
||||
|
||||
|
||||
return borderframe
|
||||
end
|
||||
|
||||
|
||||
+8
-18
@@ -1,36 +1,26 @@
|
||||
|
||||
|
||||
local DF = _G ["DetailsFramework"]
|
||||
local DF = _G["DetailsFramework"]
|
||||
if (not DF or not DetailsFrameworkCanLoad) then
|
||||
return
|
||||
end
|
||||
|
||||
local _
|
||||
local rawset = rawset
|
||||
local rawget = rawget
|
||||
local setmetatable = setmetatable
|
||||
local unpack = unpack
|
||||
local type = type
|
||||
local floor = math.floor
|
||||
local GetTime = GetTime
|
||||
|
||||
local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
|
||||
|
||||
local cleanfunction = function() end
|
||||
local APITimeBarFunctions
|
||||
|
||||
do
|
||||
local metaPrototype = {
|
||||
WidgetType = "timebar",
|
||||
SetHook = DF.SetHook,
|
||||
RunHooksForWidget = DF.RunHooksForWidget,
|
||||
dversion = DF.dversion,
|
||||
}
|
||||
|
||||
--check if there's a metaPrototype already existing
|
||||
if (_G[DF.GlobalWidgetControlNames["timebar"]]) then
|
||||
--get the already existing metaPrototype
|
||||
local oldMetaPrototype = _G[DF.GlobalWidgetControlNames ["timebar"]]
|
||||
local oldMetaPrototype = _G[DF.GlobalWidgetControlNames["timebar"]]
|
||||
--check if is older
|
||||
if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < DF.dversion) ) then
|
||||
--the version is older them the currently loading one
|
||||
@@ -41,12 +31,12 @@ do
|
||||
end
|
||||
else
|
||||
--first time loading the framework
|
||||
_G[DF.GlobalWidgetControlNames ["timebar"]] = metaPrototype
|
||||
_G[DF.GlobalWidgetControlNames["timebar"]] = metaPrototype
|
||||
end
|
||||
end
|
||||
|
||||
local TimeBarMetaFunctions = _G[DF.GlobalWidgetControlNames["timebar"]]
|
||||
|
||||
DF:Mixin(TimeBarMetaFunctions, DF.ScriptHookMixin)
|
||||
|
||||
--methods
|
||||
TimeBarMetaFunctions.SetMembers = TimeBarMetaFunctions.SetMembers or {}
|
||||
@@ -62,7 +52,8 @@ TimeBarMetaFunctions.__index = function(table, key)
|
||||
if (fromMe) then
|
||||
return fromMe
|
||||
end
|
||||
return TimeBarMetaFunctions [key]
|
||||
|
||||
return TimeBarMetaFunctions[key]
|
||||
end
|
||||
|
||||
TimeBarMetaFunctions.__newindex = function(table, key, value)
|
||||
@@ -364,16 +355,15 @@ end
|
||||
|
||||
|
||||
function DF:CreateTimeBar(parent, texture, width, height, value, member, name)
|
||||
|
||||
if (not name) then
|
||||
name = "DetailsFrameworkBarNumber" .. DF.BarNameCounter
|
||||
DF.BarNameCounter = DF.BarNameCounter + 1
|
||||
|
||||
elseif (not parent) then
|
||||
return error ("Details! FrameWork: parent not found.", 2)
|
||||
return error("Details! FrameWork: parent not found.", 2)
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
if (name:find("$parent")) then
|
||||
local parentName = DF.GetParentName(parent)
|
||||
name = name:gsub("$parent", parentName)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user