vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Bongos MapBar
3 Makes the minimap frame movable
4 --]]
5  
6 function BongosMinimapScrollFrame_OnMouseWheel()
7 if (Minimap:GetZoom() + arg1 <= Minimap:GetZoomLevels()) and (Minimap:GetZoom() + arg1 >= 0) then
8 Minimap:SetZoom(Minimap:GetZoom() + arg1);
9 end
10 end
11  
12 --[[ Config Functions ]]--
13 local function ToggleTitle(enable)
14 if enable then
15 BMapBarSets.showTitle = 1;
16 MinimapZoneTextButton:Show();
17 MinimapToggleButton:Show();
18 MinimapBorderTop:Show();
19 BMapBar:SetHeight(MinimapCluster:GetHeight());
20  
21 MinimapCluster:ClearAllPoints();
22 MinimapCluster:SetPoint("TOPLEFT", BMapBar, "TOPLEFT", 1, -2);
23 else
24 BMapBarSets.showTitle = nil;
25 BMapBar:SetHeight(MinimapCluster:GetHeight() - 12);
26  
27 MinimapZoneTextButton:Hide();
28 MinimapToggleButton:Hide();
29 MinimapBorderTop:Hide();
30  
31 MinimapCluster:ClearAllPoints();
32 MinimapCluster:SetPoint("TOPLEFT", BMapBar, "TOPLEFT", 1, 10);
33 end
34 end
35  
36 local function ToggleZoomButtons(enable)
37 if enable then
38 BMapBarSets.showZoom = 1;
39  
40 MinimapZoomIn:Show();
41 MinimapZoomOut:Show();
42 else
43 BMapBarSets.showZoom = nil;
44  
45 MinimapZoomIn:Hide();
46 MinimapZoomOut:Hide();
47 end
48 end
49  
50 local function ToggleDayIndicator(enable)
51 if enable then
52 BMapBarSets.showDay = 1;
53 GameTimeFrame:Show();
54 else
55 BMapBarSets.showDay = nil;
56 GameTimeFrame:Hide();
57 end
58 end
59  
60 local function CreateConfigMenu(name)
61 local menu = CreateFrame("Button", name, UIParent, "BongosRightClickMenu");
62 menu:SetWidth(220);
63 menu:SetHeight(222);
64 menu:SetText("Map Bar");
65  
66 local showTitleButton = CreateFrame("CheckButton", name .. "ShowTitle", menu, "BongosCheckButtonTemplate");
67 showTitleButton:SetScript("OnClick", function()
68 ToggleTitle( this:GetChecked() );
69 end);
70 showTitleButton:SetPoint("TOPLEFT", menu, "TOPLEFT", 8, -28);
71 showTitleButton:SetText("Show Title");
72  
73 local showZoomButton = CreateFrame("CheckButton", name .. "ShowZoom", menu, "BongosCheckButtonTemplate");
74 showZoomButton:SetScript("OnClick", function()
75 ToggleZoomButtons( this:GetChecked() );
76 end);
77 showZoomButton:SetPoint("TOP", showTitleButton, "BOTTOM", 0, 0);
78 showZoomButton:SetText("Show Zoom Buttons");
79  
80 local showDayNight = CreateFrame("CheckButton", name .. "ShowDay", menu, "BongosCheckButtonTemplate");
81 showDayNight:SetScript("OnClick", function()
82 ToggleDayIndicator( this:GetChecked() );
83 end);
84 showDayNight:SetPoint("TOP", showZoomButton, "BOTTOM", 0, 0);
85 showDayNight:SetText("Show Time Indicator");
86  
87 local scaleSlider = CreateFrame("Slider", name .. "Scale", menu, "BongosScaleSlider");
88 scaleSlider:SetPoint("TOPLEFT", showDayNight, "BOTTOMLEFT", 2, -16);
89  
90 local opacitySlider = CreateFrame("Slider", name .. "Opacity", menu, "BongosOpacitySlider");
91 opacitySlider:SetPoint("TOP", scaleSlider, "BOTTOM", 0, -24);
92 end
93  
94 local function ShowMenu(bar)
95 if not BongosMapBarMenu then
96 CreateConfigMenu("BongosMapBarMenu");
97 end
98  
99 BongosMapBarMenu.onShow = 1;
100 BongosMapBarMenu.frame = bar;
101  
102 BongosMapBarMenuShowTitle:SetChecked(bar.sets.showTitle);
103 BongosMapBarMenuShowZoom:SetChecked(bar.sets.showZoom);
104 BongosMapBarMenuShowDay:SetChecked(bar.sets.showDay);
105  
106 BongosMapBarMenuScale:SetValue( bar:GetScale() * 100 );
107 BongosMapBarMenuOpacity:SetValue( bar:GetAlpha() * 100 );
108  
109 --Position menu then show it
110 BMenu.ShowMenuForBar(BongosMapBarMenu, bar);
111 BongosMapBarMenu.onShow = nil;
112 end
113  
114 --[[ Startup ]]--
115 BScript.AddStartupAction(function()
116 --create the mapbar
117 local bar = BBar.Create("map", "BMapBar", "BMapBarSets", ShowMenu, 1);
118 bar:SetFrameStrata("BACKGROUND");
119 bar:SetWidth(MinimapCluster:GetWidth());
120 if not bar:IsUserPlaced() then
121 bar:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT");
122 end
123  
124 --attach the minimap to the bar
125 MinimapCluster:SetParent(bar);
126 --hack, this one is to make sure the frame levels of the minimap cluster aren't broken via setparent
127 MinimapCluster:SetFrameLevel(0);
128 --another hack, should be inherited by its parent
129 MinimapCluster:SetAlpha(bar:GetAlpha());
130  
131 --load settings
132 --toggle title actually places the minimap on the bar, and adjusts the bar's height
133 ToggleTitle(bar.sets.showTitle);
134 ToggleZoomButtons(bar.sets.showZoom);
135 ToggleDayIndicator(bar.sets.showDay);
136 end)
137  
138 --[[
139 Compatibility Fixes
140 These functions are for fixing issues with other addons
141 --]]
142  
143  
144 if IsAddOnLoaded("Titan") then
145 local oTitanMovableFrame_CheckTopFrame = TitanMovableFrame_CheckTopFrame;
146 TitanMovableFrame_CheckTopFrame = function(frameTop, top, frameName)
147 if frameName ~= "MinimapCluster" then
148 oTitanMovableFrame_CheckTopFrame(frameTop, top, frameName)
149 end
150 end
151 TitanMovableData["MinimapCluster"] = nil;
152 end
153