more fix for #3

This commit is contained in:
LaYt
2017-01-29 12:32:27 +07:00
parent 400ed4d1af
commit d70e963dc1
+22 -24
View File
@@ -10,11 +10,12 @@ MBB_DefaultOptions = {
["CollapseTimeout"] = 1, ["CollapseTimeout"] = 1,
["ExpandDirection"] = 1, ["ExpandDirection"] = 1,
["MaxButtonsPerLine"] = 0, ["MaxButtonsPerLine"] = 0,
["AltExpandDirection"] = 4 ["AltExpandDirection"] = 4,
["Version"] = MBB_Version
}; };
MBB_Include = { MBB_Include = {
}; };
MBB_Ignore = { MBB_Ignore = {
@@ -49,6 +50,21 @@ MBB_IgnoreSize = {
[7] = "MonkeyBuddyIconButton" [7] = "MonkeyBuddyIconButton"
}; };
--Code by Grayhoof (SCT)
local function CloneTable(t) -- return a copy of the table t
local new = {}; -- create a new table
local i, v = next(t, nil); -- i is an index of t, v = t[i]
while i do
if type(v)=="table" then
v=CloneTable(v);
end
new[i] = v;
i, v = next(t, i); -- get next index
end
return new;
end
MBB_ExtraSize = { MBB_ExtraSize = {
["GathererMinimapButton"] = function() ["GathererMinimapButton"] = function()
GathererMinimapButton.mask:SetHeight(31); GathererMinimapButton.mask:SetHeight(31);
@@ -112,9 +128,7 @@ function MBB_SlashHandler(cmd)
elseif( cmd == "reset position" ) then elseif( cmd == "reset position" ) then
MBB_ResetPosition(); MBB_ResetPosition();
elseif( cmd == "reset all" ) then elseif( cmd == "reset all" ) then
for opt,val in pairs(MBB_DefaultOptions) do MBB_Options = CloneTable(MBB_DefaultOptions);
MBB_Options[opt] = val;
end
for i=1,table.getn(MBB_Exclude) do for i=1,table.getn(MBB_Exclude) do
MBB_AddButton(MBB_Exclude[1]); MBB_AddButton(MBB_Exclude[1]);
end end
@@ -175,25 +189,12 @@ end
function MBB_OnEvent() function MBB_OnEvent()
if(event == "ADDON_LOADED" and (arg1 == "Squeenix" or arg1 == "MBB")) then if(event == "ADDON_LOADED" and (arg1 == "Squeenix" or arg1 == "MBB")) then
MBB_SetButtonPosition(); MBB_SetButtonPosition();
end end
if ( event == "VARIABLES_LOADED" ) then if ( event == "VARIABLES_LOADED" ) then
if ( MBB_Options == nil or MBB_Options["Version"] ~= MBB_Version) then
for opt,val in pairs(MBB_DefaultOptions) do MBB_Options = CloneTable(MBB_DefaultOptions)
if( not MBB_Options or not MBB_Options[opt] ) then end
MBB_Debug(opt .. " option set to default: " .. tostring(val));
MBB_Options[opt] = val;
else
MBB_Debug(opt .. " option exists: " .. tostring(MBB_Options[opt]));
end
end
end end
end end
@@ -565,15 +566,12 @@ function MBB_ResetPosition()
MBB_Options.ButtonPos[1] = MBB_DefaultOptions.ButtonPos[1]; MBB_Options.ButtonPos[1] = MBB_DefaultOptions.ButtonPos[1];
MBB_Options.ButtonPos[2] = MBB_DefaultOptions.ButtonPos[2]; MBB_Options.ButtonPos[2] = MBB_DefaultOptions.ButtonPos[2];
MBB_Options.AttachToMinimap = MBB_DefaultOptions.AttachToMinimap; MBB_Options.AttachToMinimap = MBB_DefaultOptions.AttachToMinimap;
MBB_SetButtonPosition(); MBB_SetButtonPosition();
end end
function MBB_SetButtonPosition() function MBB_SetButtonPosition()
if (not MBB_Options) then MBB_Debug("NO MBB_Options");return; end if (not MBB_Options) then MBB_Debug("NO MBB_Options");return; end
MBB_MinimapButtonFrame:SetScale(1/Minimap:GetEffectiveScale()); MBB_MinimapButtonFrame:SetScale(1/Minimap:GetEffectiveScale());
if( MBB_Options.AttachToMinimap == 1 ) then if( MBB_Options.AttachToMinimap == 1 ) then
MBB_MinimapButtonFrame:ClearAllPoints(); MBB_MinimapButtonFrame:ClearAllPoints();
MBB_MinimapButtonFrame:SetPoint("TOPLEFT", Minimap, "TOPLEFT", MBB_Options.ButtonPos[1], MBB_Options.ButtonPos[2]); MBB_MinimapButtonFrame:SetPoint("TOPLEFT", Minimap, "TOPLEFT", MBB_Options.ButtonPos[1], MBB_Options.ButtonPos[2]);