Commit 75dfd733 authored by Ivaria's avatar Ivaria
Browse files

Added custom flag validator which accepts a user defined function.

parent c59c0473
......@@ -6,6 +6,7 @@ VUHDO_BOUQUET_CUSTOM_TYPE_HEALTH = 5;
VUHDO_BOUQUET_CUSTOM_TYPE_HOLY_POWER = 6;
VUHDO_BOUQUET_CUSTOM_TYPE_SECONDS = 7;
VUHDO_BOUQUET_CUSTOM_TYPE_STACKS = 8;
VUHDO_BOUQUET_CUSTOM_TYPE_CUSTOM_FLAG = 9;
VUHDO_FORCE_RESET = false;
......@@ -1001,6 +1002,41 @@ end
--
local function VUHDO_customFlagValidator(anInfo, aCustom)
if aCustom and aCustom["custom"] and aCustom["custom"][1] then
local loadedFunction, errorString = loadstring("local anInfo = _G[\"VUHDO_anInfo\"];" .. aCustom["custom"][1]);
if loadedFunction then
_G["VUHDO_anInfo"] = anInfo;
setfenv(loadedFunction, _G)
local _, ret, ret2, ret3, ret4, ret5 = xpcall(loadedFunction,
function()
DEFAULT_CHAT_FRAME:AddMessage(VUHDO_I18N_ERROR_CUSTOM_FLAG_EXECUTE, 1.0, 0.0, 0.0);
DEFAULT_CHAT_FRAME:AddMessage(debugstack(1, 2, 0), 1.0, 0.0, 0.0);
DEFAULT_CHAT_FRAME:AddMessage(VUHDO_I18N_ERROR_INVALID_VALIDATOR, 1.0, 0.0, 0.0);
DEFAULT_CHAT_FRAME:AddMessage(aCustom["custom"][1], 1.0, 0.0, 0.0);
return false, nil, -1, -1, -1;
end
);
if ret and ret == true then
return true, nil, -1, -1, -1;
end
else
DEFAULT_CHAT_FRAME:AddMessage(VUHDO_I18N_ERROR_CUSTOM_FLAG_LOAD, 1.0, 0.0, 0.0);
DEFAULT_CHAT_FRAME:AddMessage(errorString, 1.0, 0.0, 0.0);
DEFAULT_CHAT_FRAME:AddMessage(VUHDO_I18N_ERROR_INVALID_VALIDATOR, 1.0, 0.0, 0.0);
DEFAULT_CHAT_FRAME:AddMessage(aCustom["custom"][1], 1.0, 0.0, 0.0);
end
end
return false, nil, -1, -1, -1;
end
--
local tUnit;
local function VUHDO_enemyStateValidator(anInfo, _)
......@@ -1593,5 +1629,13 @@ VUHDO_BOUQUET_BUFFS_SPECIAL = {
["validator"] = VUHDO_alwaysTrueValidator,
["interests"] = { },
},
["CUSTOM_FLAG"] = {
["displayName"] = VUHDO_I18N_BOUQUET_CUSTOM_FLAG,
["validator"] = VUHDO_customFlagValidator,
["custom_type"] = VUHDO_BOUQUET_CUSTOM_TYPE_CUSTOM_FLAG,
["interests"] = { VUHDO_UPDATE_INC, VUHDO_UPDATE_HEALTH, VUHDO_UPDATE_RANGE, VUHDO_UPDATE_HEALTH_MAX, VUHDO_UPDATE_ALIVE },
},
};
......@@ -420,3 +420,9 @@ VUHDO_I18N_BOUQUET_STATUS_TOTAL_ABSORB = "Statusbar: Total Absorption %";
VUHDO_I18N_NO_BOSS = "[no NPC]";
VUHDO_I18N_BOSSES = "NPCs";
-- 3.71
VUHDO_I18N_BOUQUET_CUSTOM_FLAG = "Custom Flag";
VUHDO_I18N_ERROR_CUSTOM_FLAG_LOAD = "{VuhDo} Error: Your custom flag validator did not load:";
VUHDO_I18N_ERROR_CUSTOM_FLAG_EXECUTE = "{VuhDo} Error: Your custom flag validator did not execute:";
VUHDO_I18N_ERROR_INVALID_VALIDATOR = "{VuhDo} Error: Invalid validator:";
......@@ -429,3 +429,9 @@ VUHDO_I18N_BOUQUET_STATUS_TOTAL_ABSORB = "Statusbar: Total Absorption %";
VUHDO_I18N_NO_BOSS = "[no NPC]";
VUHDO_I18N_BOSSES = "NPCs";
-- 3.71
VUHDO_I18N_BOUQUET_CUSTOM_FLAG = "Custom Flag";
VUHDO_I18N_ERROR_CUSTOM_FLAG_LOAD = "{VuhDo} Error: Your custom flag validator did not load:";
VUHDO_I18N_ERROR_CUSTOM_FLAG_EXECUTE = "{VuhDo} Error: Your custom flag validator did not execute:";
VUHDO_I18N_ERROR_INVALID_VALIDATOR = "{VuhDo} Error: Invalid validator:";
......@@ -430,3 +430,9 @@ VUHDO_I18N_BOUQUET_STATUS_TOTAL_ABSORB = "Statusbar: Total Absorption %";
VUHDO_I18N_NO_BOSS = "[no NPC]";
VUHDO_I18N_BOSSES = "NPCs";
-- 3.71
VUHDO_I18N_BOUQUET_CUSTOM_FLAG = "Custom Flag";
VUHDO_I18N_ERROR_CUSTOM_FLAG_LOAD = "{VuhDo} Error: Your custom flag validator did not load:";
VUHDO_I18N_ERROR_CUSTOM_FLAG_EXECUTE = "{VuhDo} Error: Your custom flag validator did not execute:";
VUHDO_I18N_ERROR_INVALID_VALIDATOR = "{VuhDo} Error: Invalid validator:";
......@@ -428,3 +428,9 @@ VUHDO_I18N_BOUQUET_STATUS_TOTAL_ABSORB = "Statusbar: Total Absorption %";
VUHDO_I18N_NO_BOSS = "[no NPC]";
VUHDO_I18N_BOSSES = "NPCs";
-- 3.71
VUHDO_I18N_BOUQUET_CUSTOM_FLAG = "Custom Flag";
VUHDO_I18N_ERROR_CUSTOM_FLAG_LOAD = "{VuhDo} Error: Your custom flag validator did not load:";
VUHDO_I18N_ERROR_CUSTOM_FLAG_EXECUTE = "{VuhDo} Error: Your custom flag validator did not execute:";
VUHDO_I18N_ERROR_INVALID_VALIDATOR = "{VuhDo} Error: Invalid validator:";
......@@ -494,3 +494,9 @@ VUHDO_I18N_BOUQUET_STATUS_TOTAL_ABSORB = "Statusbar: Total Absorption %";
VUHDO_I18N_NO_BOSS = "[no NPC]";
VUHDO_I18N_BOSSES = "NPCs";
-- 3.71
VUHDO_I18N_BOUQUET_CUSTOM_FLAG = "Custom Flag";
VUHDO_I18N_ERROR_CUSTOM_FLAG_LOAD = "{VuhDo} Error: Your custom flag validator did not load:";
VUHDO_I18N_ERROR_CUSTOM_FLAG_EXECUTE = "{VuhDo} Error: Your custom flag validator did not execute:";
VUHDO_I18N_ERROR_INVALID_VALIDATOR = "{VuhDo} Error: Invalid validator:";
......@@ -422,3 +422,9 @@ VUHDO_I18N_BOUQUET_STATUS_TOTAL_ABSORB = "Statusbar: Total Absorption %";
VUHDO_I18N_NO_BOSS = "[no NPC]";
VUHDO_I18N_BOSSES = "NPCs";
-- 3.71
VUHDO_I18N_BOUQUET_CUSTOM_FLAG = "Custom Flag";
VUHDO_I18N_ERROR_CUSTOM_FLAG_LOAD = "{VuhDo} Error: Your custom flag validator did not load:";
VUHDO_I18N_ERROR_CUSTOM_FLAG_EXECUTE = "{VuhDo} Error: Your custom flag validator did not execute:";
VUHDO_I18N_ERROR_INVALID_VALIDATOR = "{VuhDo} Error: Invalid validator:";
......@@ -422,3 +422,9 @@ VUHDO_I18N_BOUQUET_STATUS_TOTAL_ABSORB = "Statusbar: Total Absorption %";
VUHDO_I18N_NO_BOSS = "[no NPC]";
VUHDO_I18N_BOSSES = "NPCs";
-- 3.71
VUHDO_I18N_BOUQUET_CUSTOM_FLAG = "Custom Flag";
VUHDO_I18N_ERROR_CUSTOM_FLAG_LOAD = "{VuhDo} Error: Your custom flag validator did not load:";
VUHDO_I18N_ERROR_CUSTOM_FLAG_EXECUTE = "{VuhDo} Error: Your custom flag validator did not execute:";
VUHDO_I18N_ERROR_INVALID_VALIDATOR = "{VuhDo} Error: Invalid validator:";
......@@ -612,6 +612,7 @@ VUHDO_I18N_TT.K553 = "Make the selected profile the default for all new characte
VUHDO_I18N_TT.K554 = "Make the selected key layout the default for all new characters on this account.";
VUHDO_I18N_TT.K555 = "Check to allow the VuhDo menu command to be bound even when using Clique compatibility mode.";
VUHDO_I18N_TT.K556 = "Check this to have an extra panel for boss encounter NPCs (eg. shards on Tectus, mushrooms on Brackenspore).";
VUHDO_I18N_TT.K557 = "Body of the custom flag function. Must return true or false. Example: return (\"YOURNAME\" == anInfo\[\"name\"\])";
VUHDO_I18N_DEFAULT_PROFILE = "Default Profile";
VUHDO_I18N_DEFAULT_LAYOUT = "Default Layout";
......
......@@ -611,6 +611,7 @@ VUHDO_I18N_TT.K553 = "Make the selected profile the default for all new characte
VUHDO_I18N_TT.K554 = "Make the selected key layout the default for all new characters on this account.";
VUHDO_I18N_TT.K555 = "Check to allow the VuhDo menu command to be bound even when using Clique compatibility mode.";
VUHDO_I18N_TT.K556 = "Check this to have an extra panel for boss encounter NPCs (eg. shards on Tectus, mushrooms on Brackenspore).";
VUHDO_I18N_TT.K557 = "Body of the custom flag function. Must return true or false. Example: return (\"YOURNAME\" == anInfo\[\"name\"\])";
VUHDO_I18N_DEFAULT_PROFILE = "Default Profile";
VUHDO_I18N_DEFAULT_LAYOUT = "Default Layout";
......
......@@ -619,6 +619,7 @@ VUHDO_I18N_TT.K553 = "Make the selected profile the default for all new characte
VUHDO_I18N_TT.K554 = "Make the selected key layout the default for all new characters on this account.";
VUHDO_I18N_TT.K555 = "Check to allow the VuhDo menu command to be bound even when using Clique compatibility mode.";
VUHDO_I18N_TT.K556 = "Check this to have an extra panel for boss encounter NPCs (eg. shards on Tectus, mushrooms on Brackenspore).";
VUHDO_I18N_TT.K557 = "Body of the custom flag function. Must return true or false. Example: return (\"YOURNAME\" == anInfo\[\"name\"\])";
VUHDO_I18N_DEFAULT_PROFILE = "Default Profile";
VUHDO_I18N_DEFAULT_LAYOUT = "Default Layout";
......
......@@ -621,6 +621,7 @@ VUHDO_I18N_TT.K553 = "Make the selected profile the default for all new characte
VUHDO_I18N_TT.K554 = "Make the selected key layout the default for all new characters on this account.";
VUHDO_I18N_TT.K555 = "Check to allow the VuhDo menu command to be bound even when using Clique compatibility mode.";
VUHDO_I18N_TT.K556 = "Check this to have an extra panel for boss encounter NPCs (eg. shards on Tectus, mushrooms on Brackenspore).";
VUHDO_I18N_TT.K557 = "Body of the custom flag function. Must return true or false. Example: return (\"YOURNAME\" == anInfo\[\"name\"\])";
VUHDO_I18N_DEFAULT_PROFILE = "Default Profile";
VUHDO_I18N_DEFAULT_LAYOUT = "Default Layout";
......
......@@ -719,6 +719,7 @@ VUHDO_I18N_TT.K553 = "Make the selected profile the default for all new characte
VUHDO_I18N_TT.K554 = "Make the selected key layout the default for all new characters on this account.";
VUHDO_I18N_TT.K555 = "Check to allow the VuhDo menu command to be bound even when using Clique compatibility mode.";
VUHDO_I18N_TT.K556 = "Check this to have an extra panel for boss encounter NPCs (eg. shards on Tectus, mushrooms on Brackenspore).";
VUHDO_I18N_TT.K557 = "Body of the custom flag function. Must return true or false. Example: return (\"YOURNAME\" == anInfo\[\"name\"\])";
VUHDO_I18N_DEFAULT_PROFILE = "Default Profile";
VUHDO_I18N_DEFAULT_LAYOUT = "Default Layout";
......
......@@ -613,6 +613,7 @@ VUHDO_I18N_TT.K553 = "Make the selected profile the default for all new characte
VUHDO_I18N_TT.K554 = "Make the selected key layout the default for all new characters on this account.";
VUHDO_I18N_TT.K555 = "Check to allow the VuhDo menu command to be bound even when using Clique compatibility mode.";
VUHDO_I18N_TT.K556 = "Check this to have an extra panel for boss encounter NPCs (eg. shards on Tectus, mushrooms on Brackenspore).";
VUHDO_I18N_TT.K557 = "Body of the custom flag function. Must return true or false. Example: return (\"YOURNAME\" == anInfo\[\"name\"\])";
VUHDO_I18N_DEFAULT_PROFILE = "Default Profile";
VUHDO_I18N_DEFAULT_LAYOUT = "Default Layout";
......
......@@ -613,6 +613,7 @@ VUHDO_I18N_TT.K553 = "Make the selected profile the default for all new characte
VUHDO_I18N_TT.K554 = "Make the selected key layout the default for all new characters on this account.";
VUHDO_I18N_TT.K555 = "Check to allow the VuhDo menu command to be bound even when using Clique compatibility mode.";
VUHDO_I18N_TT.K556 = "Check this to have an extra panel for boss encounter NPCs (eg. shards on Tectus, mushrooms on Brackenspore).";
VUHDO_I18N_TT.K557 = "Body of the custom flag function. Must return true or false. Example: return (\"YOURNAME\" == anInfo\[\"name\"\])";
VUHDO_I18N_DEFAULT_PROFILE = "Default Profile";
VUHDO_I18N_DEFAULT_LAYOUT = "Default Layout";
......
......@@ -302,6 +302,7 @@ function VUHDO_rebuildBouquetContextEditors(anIndex)
_G[tPanel:GetName() .. "BuffOrIndicatorFrameMineOthersFrame"]:Hide();
_G[tPanel:GetName() .. "BuffOrIndicatorFramePercentFrame"]:Hide();
_G[tPanel:GetName() .. "BuffOrIndicatorFrameCustomFlagEditBox"]:Hide();
tBuffName = VUHDO_lnfGetValueFrom(tModel .. ".name");
......@@ -434,8 +435,13 @@ function VUHDO_rebuildBouquetContextEditors(anIndex)
tSpecialName = VUHDO_BOUQUETS["STORED"][tBouquetName][tIndex]["name"];
VUHDO_lnfSliderOnLoad(tSlider, VUHDO_BOUQUET_BUFFS_SPECIAL[tSpecialName]["displayName"], 0, 50, "#");
tSubPanel:Show();
elseif (VUHDO_BOUQUET_BUFFS_SPECIAL[tBuffName]["custom_type"] == VUHDO_BOUQUET_CUSTOM_TYPE_CUSTOM_FLAG) then
tSubPanel = _G[tInnerPanel:GetName() .. "CustomFlagEditBox"];
VUHDO_lnfSetModel(tSubPanel, tModel .. ".custom.##1");
tSubPanel:Show();
else
_G[tInnerPanel:GetName() .. "PercentFrame"]:Hide();
_G[tInnerPanel:GetName() .. "CustomFlagEditBox"]:Hide();
end
if (VUHDO_BOUQUET_BUFFS_SPECIAL[tBuffName]["no_color"]) then
......
......@@ -818,6 +818,29 @@
</Frame>
</Frames>
</Frame>
<EditBox name="$parentCustomFlagEditBox" inherits="VuhDoEditBoxTemplate">
<Size>
<AbsDimension x="170" y="32" />
</Size>
<Anchors>
<Anchor point="BOTTOM">
<Offset>
<AbsDimension x="0" y="7" />
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
VUHDO_lnfSetModel(self, nil);
VUHDO_lnfSetTooltip(self, VUHDO_I18N_TT.K557);
</OnLoad>
<OnTextChanged>
VUHDO_lnfEditBoxUpdateModel(self);
</OnTextChanged>
</Scripts>
</EditBox>
</Frames>
</Frame>
......
......@@ -18,6 +18,12 @@ Bugfixes:
Improvements:
-- Added custom flag validator which accepts a user defined function.
-- Bouquets can include any valid Lua function which returns true or false.
-- The function can access the 'anInfo' variable which is a map containing
-- the relevant unit information.
-- Example below returns true if the unit is named 'Ivaria':
-- return ("Ivaria" == anInfo["name"])
--------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment