-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFishingBuddyMinimap.lua
89 lines (74 loc) · 2.35 KB
/
FishingBuddyMinimap.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
-- Minimap Button Handling
FishingBuddy.Minimap = {};
local FL = LibStub("LibFishing-1.0");
local icon = LibStub("LibDBIcon-1.0");
local broker = LibStub:GetLibrary("LibDataBroker-1.1")
local GSB = FishingBuddy.GetSettingBool;
local function Minimap_OnClick(self, button, down)
if ( button == "RightButton" ) then
ToggleFishingBuddyFrame("FishingOptionsFrame");
elseif ( FishingBuddy.IsSwitchClick("MinimapClickToSwitch") ) then
FishingBuddy.Command(FBConstants.SWITCH);
else
ToggleFishingBuddyFrame("FishingLocationsFrame");
end
end
local MinimapOptions = {
["MinimapButtonVisible"] = {
["text"] = FBConstants.CONFIG_MINIMAPBUTTON_ONOFF,
["tooltip"] = FBConstants.CONFIG_MINIMAPBUTTON_INFO,
["v"] = 1,
["default"] = false,
},
["MinimapClickToSwitch"] = {
["text"] = FBConstants.CLICKTOSWITCH_ONOFF,
["tooltip"] = FBConstants.CLICKTOSWITCH_INFO,
["v"] = 1,
["default"] = false,
["parents"] = { ["MinimapButtonVisible"] = "d", },
},
};
local function setter(setting, value)
if (setting == "MinimapButtonVisible") then
FishingBuddy_Player["MinimapData"].hide = (not value);
else
FishingBuddy.OptionSetSetting(setting, value);
end
end
local function getter(setting)
if (setting == "MinimapButtonVisible") then
if (not FishingBuddy_Player["MinimapData"].hide) then
return true;
else
return false;
end
else
return FishingBuddy.OptionGetSetting(setting);
end
end
local MinimapEvents = {};
MinimapEvents[FBConstants.OPT_UPDATE_EVT] = function()
if (icon:IsRegistered(FBConstants.NAME)) then
FishingBuddy_Player["MinimapData"].hide = not GSB("MinimapButtonVisible");
icon:Refresh(FBConstants.NAME, FishingBuddy_Player["MinimapData"]);
end
end
MinimapEvents["VARIABLES_LOADED"] = function()
local _, info;
if ( not FishingBuddy_Player["MinimapData"] ) then
FishingBuddy_Player["MinimapData"] = { hide=false };
end
-- Fix Curse bug #246
if ( not FishingBuddy_Player["MinimapData"].minimapPos ) then
FishingBuddy_Player["MinimapData"]["minimapPos"] = 225;
end
if ( not icon:IsRegistered(FBConstants.NAME) ) then
local data = {
icon = "Interface\\Icons\\Trade_Fishing",
OnClick = Minimap_OnClick,
};
icon:Register(FBConstants.NAME, data, FishingBuddy_Player["MinimapData"]);
end
end
FishingBuddy.OptionsFrame.HandleOptions(GENERAL, nil, MinimapOptions, setter, getter);
FishingBuddy.RegisterHandlers(MinimapEvents);