-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathHud.lua
167 lines (147 loc) · 5.8 KB
/
Hud.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
--This file is part of Game Master Genie.
--Copyright 2011-2014 Chocochaos
--Game Master Genie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
--Game Master Genie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
--You should have received a copy of the GNU General Public License along with Game Master Genie. If not, see <http://www.gnu.org/licenses/>.
GMGenie.Hud = {};
function GMGenie.Hud.onLoad()
GMGenie_Hud:RegisterEvent("PLAYER_ENTERING_WORLD");
GMGenie_Hud:RegisterEvent("UI_ERROR_MESSAGE");
GMGenie_Hud:SetScript("OnEvent", GMGenie.Hud.readNotice);
GMGenie_Hud_GM:SetAttribute("macrotext1", "/run GMGenie.Hud.toggleGm();");
GMGenie_Hud_Chat:SetAttribute("macrotext1", "/run GMGenie.Hud.toggleChat();");
GMGenie_Hud_Visibility:SetAttribute("macrotext1", "/run GMGenie.Hud.toggleVisibility();");
GMGenie_Hud_Whisper:SetAttribute("macrotext1", "/run GMGenie.Hud.toggleWhisper();");
GMGenie_Hud_Fly:SetAttribute("macrotext1", "/target " .. UnitName("player") .. " \n/run GMGenie.Hud.toggleFly();");
if GMGenie_SavedVars.hudClosed then
GMGenie.Hud.toggle();
end
Chronos.schedule(1, GMGenie.Hud.checkStatus);
GMGenie.Hud.flyStatus(false);
end
function GMGenie.Hud.toggle()
if GMGenie_Hud:IsVisible() then
GMGenie_Hud:Hide();
GMGenie_SavedVars.hudClosed = true;
else
GMGenie_Hud:Show();
GMGenie_SavedVars.hudClosed = false;
end
end
--------------------------------------------------
------------ HUD status functionality ------------
--------------------------------------------------
function GMGenie.Hud.checkStatus()
SendChatMessage(".gm", "GUILD");
SendChatMessage(".gm chat", "GUILD");
SendChatMessage(".gm visible", "GUILD");
SendChatMessage(".whispers", "GUILD");
end
function GMGenie.Hud.gmStatus(status)
GMGenie.Hud.gm = status;
if status then
GMGenie_Hud_GM:SetText("|cffffffffGM mode ON|r");
else
GMGenie_Hud_GM:SetText("|cffbfbfffGM mode OFF|r");
end
end
function GMGenie.Hud.chatStatus(status)
GMGenie.Hud.chat = status;
if status then
GMGenie_Hud_Chat:SetText("|cffffffffChat badge ON|r");
else
GMGenie_Hud_Chat:SetText("|cffbfbfffChat badge OFF|r");
end
end
function GMGenie.Hud.visibilityStatus(status)
GMGenie.Hud.visibility = status;
if status then
GMGenie_Hud_Visibility:SetText("|cffffffffYou are VISIBLE|r");
else
GMGenie_Hud_Visibility:SetText("|cffbfbfffYou are INVISIBLE|r");
end
end
function GMGenie.Hud.whisperStatus(status)
GMGenie.Hud.whisper = status;
if status then
GMGenie_Hud_Whisper:SetText("|cffffffffWhispers are ON|r");
else
GMGenie_Hud_Whisper:SetText("|cffbfbfffWhispers are OFF|r");
end
end
function GMGenie.Hud.flyStatus(status)
GMGenie.Hud.fly = status;
if status then
GMGenie_Hud_Fly:SetText("|cffffffffFlight mode ON|r");
else
GMGenie_Hud_Fly:SetText("|cffbfbfffFlight mode OFF|r");
end
end
function GMGenie.Hud.readNotice(_, event, notice)
if event == "UI_ERROR_MESSAGE" then
if notice == "GM mode is ON" then
GMGenie.Hud.gmStatus(true);
elseif notice == "GM mode is OFF" then
GMGenie.Hud.gmStatus(false);
elseif notice == "GM Chat Badge is ON" then
GMGenie.Hud.chatStatus(true);
elseif notice == "GM Chat Badge is OFF" then
GMGenie.Hud.chatStatus(false);
elseif notice == "You are now visible." then
GMGenie.Hud.visibilityStatus(true);
elseif notice == "You are now invisible." then
GMGenie.Hud.visibilityStatus(false);
GMGenie.Hud.toggleWhisper(GMGenie.Hud.whisper);
end
elseif event == "PLAYER_ENTERING_WORLD" and GMGenie.Hud.fly == true then
GMGenie.Hud.toggleFly(GMGenie.Hud.fly);
end
end
function GMGenie.Hud.toggleGm(status)
if (not GMGenie.Hud.gm and status == nil) or status == true then
SendChatMessage(".gm on", "GUILD");
else
SendChatMessage(".gm off", "GUILD");
end
end
function GMGenie.Hud.toggleChat(status)
if (not GMGenie.Hud.chat and status == nil) or status == true then
SendChatMessage(".gm chat on", "GUILD");
else
SendChatMessage(".gm chat off", "GUILD");
end
end
function GMGenie.Hud.toggleVisibility(status)
if (not GMGenie.Hud.visibility and status == nil) or status == true then
SendChatMessage(".gm visible on", "GUILD");
else
SendChatMessage(".gm visible off", "GUILD");
end
end
function GMGenie.Hud.toggleWhisper(status)
if (not GMGenie.Hud.whisper and status == nil) or status == true then
SendChatMessage(".whispers on", "GUILD");
else
SendChatMessage(".whispers off", "GUILD");
end
end
function GMGenie.Hud.toggleFly(status)
if UnitName("target") == UnitName("player") or UnitName("target") == nil then
if (not GMGenie.Hud.fly and status == nil) or status == true then
SendChatMessage(".gm fly on", "GUILD");
else
SendChatMessage(".gm fly off", "GUILD");
end
else
GMGenie.showGMMessage("Could not target self to change flight mode.");
end
end
function GMGenie.Hud.setSpeed()
if UnitName("target") == UnitName("player") or UnitName("target") == nil then
local speed = GMGenie_Hud_Speed:GetText();
GMGenie_Hud_Speed:ClearFocus();
SendChatMessage(".mod speed all " .. speed, "GUILD");
else
GMGenie.showGMMessage("Be sure to target yourself before setting the speed.");
end
end