- Added size offset options for the chat tab embed feature.

- Revamp on the editor for the custom line text.
This commit is contained in:
Tercio
2018-07-28 18:22:13 -03:00
parent a1c527711c
commit 720a95bc1b
10 changed files with 126 additions and 92 deletions
+7 -7
View File
@@ -173,9 +173,9 @@ end
local y_up = window1.toolbar_side == 1 and -20 or 0
local y_down = (window1.show_statusbar and 14 or 0) + (window1.toolbar_side == 2 and 20 or 0)
window1.baseframe:SetPoint ("topleft", ChatFrameBackground, "topleft", 0, y_up)
window1.baseframe:SetPoint ("bottomright", ChatFrameBackground, "bottomright", 0, y_down)
window1.baseframe:SetPoint ("topleft", ChatFrameBackground, "topleft", 0, y_up + _detalhes.chat_tab_embed.y_offset)
window1.baseframe:SetPoint ("bottomright", ChatFrameBackground, "bottomright", _detalhes.chat_tab_embed.x_offset, y_down)
window1:LockInstance (true)
window1:SaveMainWindowPosition()
@@ -221,11 +221,11 @@ end
local width = ChatFrameBackground:GetWidth() / 2
local height = ChatFrameBackground:GetHeight() - y_down + y_up
window1.baseframe:SetSize (width, height)
window2.baseframe:SetSize (width, height)
window1.baseframe:SetSize (width + (_detalhes.chat_tab_embed.x_offset/2), height + _detalhes.chat_tab_embed.y_offset)
window2.baseframe:SetSize (width + (_detalhes.chat_tab_embed.x_offset/2), height + _detalhes.chat_tab_embed.y_offset)
window1.baseframe:SetPoint ("topleft", ChatFrameBackground, "topleft", 0, y_up)
window2.baseframe:SetPoint ("topright", ChatFrameBackground, "topright", 0, y_up)
window1.baseframe:SetPoint ("topleft", ChatFrameBackground, "topleft", 0, y_up + _detalhes.chat_tab_embed.y_offset)
window2.baseframe:SetPoint ("topright", ChatFrameBackground, "topright", _detalhes.chat_tab_embed.x_offset, y_up + _detalhes.chat_tab_embed.y_offset)
window1:SaveMainWindowPosition()
window2:SaveMainWindowPosition()
+19 -10
View File
@@ -456,27 +456,36 @@
--> replacing data for custom texts
_detalhes.string = {}
local left_side_func
local right_side_func
local function_cache = {}
local arguments_cache = {}
local parameters_cache = {}
local args
local replace_arg = function (i)
return args [tonumber(i)]
return arguments_cache [tonumber(i)]
end
local run_function = function (str)
--> cache functions
local func = function_cache [str]
if (not func) then
func = loadstring (str)
function_cache [str] = func
end
--str = [[local player, combat = ...;]] .. str
local okey, value = _pcall (loadstring (str), args[4], args[5])
local okey, value = _pcall (func, parameters_cache [1], parameters_cache [2])
if (not okey) then
_detalhes:Msg ("|cFFFF9900error on custom text function|r:", value)
_detalhes:Msg ("|cFFFF9900error on custom text|r:", value)
return 0
end
return value or 0
end
function _detalhes.string.replace (str, ...)
args = {...}
function _detalhes.string.replace (str, v1, v2, v3, v4, v5)
arguments_cache [1] = v1
arguments_cache [2] = v2
arguments_cache [3] = v3
parameters_cache [1] = v4
parameters_cache [2] = v5
return (str:gsub ("{data(%d+)}", replace_arg):gsub ("{func(.-)}", run_function))
end
+28 -53
View File
@@ -3024,10 +3024,12 @@
--> row text editor
local panel = _detalhes:CreateWelcomePanel ("DetailsWindowOptionsBarTextEditor", nil, 650, 210, true)
local panel = _detalhes:CreateWelcomePanel ("DetailsWindowOptionsBarTextEditor", nil, 650, 230, true)
panel:SetPoint ("center", UIParent, "center")
panel:Hide()
panel:SetFrameStrata ("FULLSCREEN")
Details.gump:ApplyStandardBackdrop (panel)
Details.gump:CreateTitleBar (panel, "Details! Custom Line Text Editor")
function panel:Open (text, callback, host, default)
if (host) then
@@ -3042,18 +3044,24 @@
panel:Show()
end
local y = -32
local buttonTemplate = Details.gump:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
local textentry = _detalhes.gump:NewSpecialLuaEditorEntry (panel, 450, 185, "editbox", "$parentEntry", true)
textentry:SetPoint ("topleft", panel, "topleft", 10, -12)
textentry:SetPoint ("topleft", panel, "topleft", 10, y)
Details.gump:ApplyStandardBackdrop (textentry)
Details.gump:SetFontSize (textentry.editbox, 14)
Details.gump:ReskinSlider (textentry.scroll)
local arg1_button = _detalhes.gump:NewButton (panel, nil, "$parentButton1", nil, 80, 20, function() textentry.editbox:Insert ("{data1}") end, nil, nil, nil, string.format (Loc ["STRING_OPTIONS_TEXTEDITOR_DATA"], "1"), 1)
local arg2_button = _detalhes.gump:NewButton (panel, nil, "$parentButton2", nil, 80, 20, function() textentry.editbox:Insert ("{data2}") end, nil, nil, nil, string.format (Loc ["STRING_OPTIONS_TEXTEDITOR_DATA"], "2"), 1)
local arg3_button = _detalhes.gump:NewButton (panel, nil, "$parentButton3", nil, 80, 20, function() textentry.editbox:Insert ("{data3}") end, nil, nil, nil, string.format (Loc ["STRING_OPTIONS_TEXTEDITOR_DATA"], "3"), 1)
arg1_button:SetPoint ("topright", panel, "topright", -12, -14)
arg2_button:SetPoint ("topright", panel, "topright", -12, -36)
arg3_button:SetPoint ("topright", panel, "topright", -12, -58)
arg1_button:InstallCustomTexture()
arg2_button:InstallCustomTexture()
arg3_button:InstallCustomTexture()
arg1_button:SetPoint ("topright", panel, "topright", -12, y)
arg2_button:SetPoint ("topright", panel, "topright", -12, y - (20*1))
arg3_button:SetPoint ("topright", panel, "topright", -12, y - (20*2))
arg1_button:SetTemplate (buttonTemplate)
arg2_button:SetTemplate (buttonTemplate)
arg3_button:SetTemplate (buttonTemplate)
arg1_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_DATA_TOOLTIP"]
arg2_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_DATA_TOOLTIP"]
@@ -3168,70 +3176,37 @@
ColorSelection ( textentry.editbox, "|c" .. hex)
end
local func_button = _detalhes.gump:NewButton (panel, nil, "$parentButton4", nil, 80, 20, function() textentry.editbox:Insert ("{func local player = ...; return 0;}") end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_FUNC"], 1)
local func_button = _detalhes.gump:NewButton (panel, nil, "$parentButton4", nil, 80, 20, function() textentry.editbox:Insert ("{func local player, combat = ...; return 0;}") end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_FUNC"], 1)
local color_button = _detalhes.gump:NewColorPickButton (panel, "$parentButton5", nil, color_func)
color_button:SetSize (80, 20)
func_button:SetPoint ("topright", panel, "topright", -12, -80)
color_button:SetPoint ("topright", panel, "topright", -12, -102)
func_button:InstallCustomTexture()
color_button:SetTemplate (buttonTemplate)
func_button:SetPoint ("topright", panel, "topright", -12, y - (20*3))
color_button:SetPoint ("topright", panel, "topright", -12, y - (20*4))
func_button:SetTemplate (buttonTemplate)
color_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_COLOR_TOOLTIP"]
func_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_FUNC_TOOLTIP"]
--color_button:InstallCustomTexture()
--local comma_button = _detalhes.gump:NewButton (panel, nil, "$parentButtonComma", nil, 80, 20, function() textentry.editbox:Insert ("_detalhes:comma_value ( )") end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_COMMA"])
--local tok_button = _detalhes.gump:NewButton (panel, nil, "$parentButtonTok", nil, 80, 20, function() textentry.editbox:Insert ("_detalhes:ToK2 ( )") end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_TOK"])
--comma_button:InstallCustomTexture()
--tok_button:InstallCustomTexture()
--comma_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_COMMA_TOOLTIP"]
--tok_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_TOK_TOOLTIP"]
--comma_button:SetPoint ("topright", panel, "topright", -100, -14)
--tok_button:SetPoint ("topright", panel, "topright", -100, -36)
local done = function()
local text = panel.editbox:GetText()
--text = text:gsub ("\n", "")
--local test = text
--local function errorhandler(err)
-- return geterrorhandler()(err)
--end
--local code = [[local str = "STR"; str = _detalhes.string.replace (str, 100, 50, 75, {nome = "you", total = 10, total_without_pet = 5, damage_taken = 7, last_dps = 1, friendlyfire_total = 6, totalover = 2, totalabsorb = 4, totalover_without_pet = 6, healing_taken = 1, heal_enemy_amt = 2});]]
--code = code:gsub ("STR", test)
--local f = loadstring (code)
--if (not f) then
-- print ("loadstring failed:", f)
--end
--local err, two = xpcall (f, errorhandler)
--if (not err) then
-- return
--end
panel.callback (text)
panel:Hide()
end
local ok_button = _detalhes.gump:NewButton (panel, nil, "$parentButtonOk", nil, 80, 20, done, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_DONE"], 1)
ok_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_DONE_TOOLTIP"]
ok_button:InstallCustomTexture()
ok_button:SetPoint ("topright", panel, "topright", -12, -174)
ok_button:SetTemplate (buttonTemplate)
ok_button:SetPoint ("topright", panel, "topright", -12, -194)
local reset_button = _detalhes.gump:NewButton (panel, nil, "$parentDefaultOk", nil, 80, 20, function() textentry.editbox:SetText (panel.default) end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_RESET"], 1)
reset_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_RESET_TOOLTIP"]
reset_button:InstallCustomTexture()
reset_button:SetPoint ("topright", panel, "topright", -100, -152)
reset_button:SetTemplate (buttonTemplate)
reset_button:SetPoint ("topright", panel, "topright", -100, -172)
local cancel_button = _detalhes.gump:NewButton (panel, nil, "$parentDefaultCancel", nil, 80, 20, function() textentry.editbox:SetText (panel.default_text); done(); end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_CANCEL"], 1)
cancel_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_CANCEL_TOOLTIP"]
cancel_button:InstallCustomTexture()
cancel_button:SetPoint ("topright", panel, "topright", -100, -174)
cancel_button:SetTemplate (buttonTemplate)
cancel_button:SetPoint ("topright", panel, "topright", -100, -194)
--update window
function _detalhes:OpenUpdateWindow()