|
5 | 5 | MultiBot.MB_PAGE_DEFAULT = string.format("%d/%d", 0, 0) |
6 | 6 | --local MB_TAB_TITLE_DEFAULT = UNKNOWN or "" |
7 | 7 |
|
8 | | --- ===================================================================== |
9 | | --- MINIMAP BUTTON |
10 | | --- ===================================================================== |
11 | | -do |
12 | | - local BTN_NAME = "MultiBot_MinimapButton" |
13 | | - local RADIUS = 80 -- rayon d’ancrage au bord de la minimap |
14 | | - |
15 | | - local function deg2rad(d) return d * math.pi / 180 end |
16 | | - |
17 | | - local function UpdatePosition(self, angle) |
18 | | - local minimap = MultiBot.GetMinimapConfig and MultiBot.GetMinimapConfig() or nil |
19 | | - angle = angle or (minimap and minimap.angle) or 220 |
20 | | - if not Minimap or not Minimap:GetCenter() then return end |
21 | | - local mx, my = Minimap:GetCenter() |
22 | | - local sx, sy = GetScreenWidth(), GetScreenHeight() |
23 | | - if not mx or not my or not sx or not sy then return end |
24 | | - local r = RADIUS * (Minimap:GetEffectiveScale() / UIParent:GetEffectiveScale()) |
25 | | - local x = math.cos(deg2rad(angle)) * r |
26 | | - local y = math.sin(deg2rad(angle)) * r |
27 | | - self:ClearAllPoints() |
28 | | - self:SetPoint("CENTER", Minimap, "CENTER", x, y) |
29 | | - end |
30 | | - |
31 | | - local function SaveAngleFromCursor(self) |
32 | | - local mx, my = Minimap:GetCenter() |
33 | | - local cx, cy = GetCursorPosition() |
34 | | - local scale = UIParent:GetEffectiveScale() |
35 | | - cx, cy = cx/scale, cy/scale |
36 | | - local dx, dy = cx - mx, cy - my |
37 | | - local angle = math.deg(math.atan2(dy, dx)) |
38 | | - if angle < 0 then angle = angle + 360 end |
39 | | - if MultiBot.SetMinimapConfig then |
40 | | - MultiBot.SetMinimapConfig("angle", angle) |
41 | | - end |
42 | | - UpdatePosition(self, angle) |
43 | | - end |
44 | | - |
45 | | - function MultiBot.Minimap_Create() |
46 | | - if _G[BTN_NAME] then |
47 | | - MultiBot.Minimap_Refresh() |
48 | | - return _G[BTN_NAME] |
49 | | - end |
50 | | - -- Respecter l’éventuel “hide” |
51 | | - local minimap = MultiBot.GetMinimapConfig and MultiBot.GetMinimapConfig() or nil |
52 | | - if minimap and minimap.hide then return nil end |
53 | | - |
54 | | - local b = CreateFrame("Button", BTN_NAME, Minimap) |
55 | | - b:SetSize(31, 31) |
56 | | - b:SetFrameStrata("MEDIUM") |
57 | | - b:SetFrameLevel(8) |
58 | | - b:SetMovable(true) |
59 | | - b:SetClampedToScreen(true) |
60 | | - b:RegisterForDrag("LeftButton") |
61 | | - b:RegisterForClicks("AnyUp") |
62 | | - |
63 | | - -- Anneau/bord standard de la minimap |
64 | | - local overlay = b:CreateTexture(nil, "OVERLAY") |
65 | | - overlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder") |
66 | | - overlay:SetSize(56, 56) |
67 | | - overlay:SetPoint("TOPLEFT") |
68 | | - |
69 | | - -- Icône (prends un pictogramme existant du pack) |
70 | | - local icon = b:CreateTexture(nil, "ARTWORK") |
71 | | - icon:SetTexture("Interface\\AddOns\\MultiBot\\Icons\\browse.blp") |
72 | | - icon:SetTexCoord(0.07, 0.93, 0.07, 0.93) |
73 | | - icon:SetSize(20, 20) |
74 | | - icon:SetPoint("CENTER", 0, 0) |
75 | | - b.icon = icon |
76 | | - |
77 | | - local hl = b:CreateTexture(nil, "HIGHLIGHT") |
78 | | - hl:SetTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight") |
79 | | - hl:SetBlendMode("ADD") |
80 | | - hl:SetAllPoints(b) |
81 | | - |
82 | | - b:SetScript("OnDragStart", function(self) |
83 | | - self:SetScript("OnUpdate", SaveAngleFromCursor) |
84 | | - end) |
85 | | - b:SetScript("OnDragStop", function(self) |
86 | | - self:SetScript("OnUpdate", nil) |
87 | | - SaveAngleFromCursor(self) |
88 | | - end) |
89 | | - |
90 | | - b:SetScript("OnEnter", function(self) |
91 | | - GameTooltip:SetOwner(self, "ANCHOR_LEFT") |
92 | | - GameTooltip:ClearLines() |
93 | | - GameTooltip:AddLine(MultiBot.L("info.butttitle"), 1, 1, 1) |
94 | | - GameTooltip:AddLine(MultiBot.L("info.buttontoggle"), 0.9, 0.9, 0.9) |
95 | | - GameTooltip:AddLine(MultiBot.L("info.buttonoptions"), 0.9, 0.9, 0.9) |
96 | | - GameTooltip:Show() |
97 | | - end) |
98 | | - b:SetScript("OnLeave", function() GameTooltip:Hide() end) |
99 | | - |
100 | | - b:SetScript("OnClick", function(self, btn) |
101 | | - if btn == "RightButton" then |
102 | | - if MultiBot.ToggleOptionsPanel then |
103 | | - MultiBot.ToggleOptionsPanel() |
104 | | - elseif InterfaceOptionsFrame_OpenToCategory and MultiBot.BuildOptionsPanel then |
105 | | - MultiBot.BuildOptionsPanel() |
106 | | - InterfaceOptionsFrame_OpenToCategory("MultiBot") |
107 | | - InterfaceOptionsFrame_OpenToCategory("MultiBot") |
108 | | - end |
109 | | - else |
110 | | - -- Clic gauche: même effet que /mb |
111 | | - if SlashCmdList and SlashCmdList["MULTIBOT"] then |
112 | | - SlashCmdList["MULTIBOT"]() |
113 | | - else |
114 | | - -- Fallback local if slash commands are unavailable. |
115 | | - if MultiBot.ToggleMainUIVisibility then |
116 | | - MultiBot.ToggleMainUIVisibility() |
117 | | - end |
118 | | - end |
119 | | - end |
120 | | - end) |
121 | | - |
122 | | - UpdatePosition(b) |
123 | | - b:Show() |
124 | | - MultiBot.MinimapButton = b |
125 | | - return b |
126 | | - end |
127 | | - |
128 | | - function MultiBot.Minimap_Refresh() |
129 | | - local minimap = MultiBot.GetMinimapConfig and MultiBot.GetMinimapConfig() or nil |
130 | | - |
131 | | - local b = _G[BTN_NAME] or MultiBot.MinimapButton |
132 | | - if minimap and minimap.hide then |
133 | | - if b then b:Hide() end |
134 | | - return |
135 | | - end |
136 | | - if not b then b = MultiBot.Minimap_Create() end |
137 | | - if b then |
138 | | - UpdatePosition(b) |
139 | | - b:Show() |
140 | | - end |
141 | | - end |
142 | | -end |
| 8 | +-- Minimap config and button logic moved to UI/MultiBotMinimap.lua. |
143 | 9 |
|
144 | 10 | -- MULTIBAR -- |
145 | 11 | local tMultiBar = MultiBot.addFrame("MultiBar", -322, 144, 36) |
|
0 commit comments