Skip to content

Commit f0d134f

Browse files
committed
refactor: GM rework
1 parent 71a89f8 commit f0d134f

7 files changed

Lines changed: 1923 additions & 1929 deletions

File tree

AzerothCoreAdmin.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ gettingGOBinfo=0
3131
gettingGOBinfoinfo=0
3232

3333
MAJOR_VERSION = "AzerothCoreAdmin"
34-
MINOR_VERSION = "$Revision: 001 $"
34+
MINOR_VERSION = "$Revision: 003 $"
3535
ROOT_PATH = "Interface\\AddOns\\AzerothCoreAdmin\\"
3636
local cont = ""
3737
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end

AzerothCoreAdmin.toc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ Libraries\LibGraph-2.0\LibGraph-2.0.lua
3131
Locales\enUS.lua
3232
Locales\strings.lua
3333
models.lua
34-
Utils\Consts.lua
35-
Utils\Utils.lua
34+
Commands\declarations\command_keys.lua
3635
Commands\Commands_Generics.lua
37-
Commands\Commands_Main.lua
36+
Commands\Commands_GM.lua
3837
Commands\Commands_Tele.lua
3938
Commands\Commands_Log.lua
4039
Commands\Commands_Char.lua
Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,22 @@ GM_genericCommands = {
205205
[GM_dismountPlayerCommand] = {
206206
[GENERICS_command] = ".dismount",
207207
[GENERICS_message] = "logGM_dismountPlayer"
208+
},
209+
[GM_playerSpeedCommand] = {
210+
[GENERICS_command] = ".modify speed",
211+
[GENERICS_message] = "logGM_setSpeed"
212+
},
213+
[GM_playerScaleCommand] = {
214+
[GENERICS_command] = ".modify scale",
215+
[GENERICS_message] = "logGM_setScale"
216+
},
217+
[GM_AllianceJailCommand] = {
218+
[GENERICS_command] = "ma_AllianceJail",
219+
[GENERICS_message] = "logGM_setJailAlliance"
220+
},
221+
[GM_HordeJailCommand] = {
222+
[GENERICS_command] = "ma_HordeJail",
223+
[GENERICS_message] = "logGM_setJailHorde"
208224
}
209225
}
210226

@@ -351,26 +367,16 @@ function GM_setAccountAddonCommand()
351367
print(Locale["operationCompleted"])
352368
end
353369

354-
function setJailAllianceCommand()
355-
MangAdmin:ChatMsg(".tele del ma_AllianceJail")
356-
local i = 1
357-
while i < 100 do
358-
i = i + 1
359-
MangAdmin:ChatMsg(".")
360-
end
361-
MangAdmin:ChatMsg(".tele add ma_AllianceJail")
362-
MangAdmin:LogAction(Locale["logGM_setJailAlliance"])
363-
end
364-
365-
function setJailHordeCommand()
366-
MangAdmin:ChatMsg(".tele del ma_HordeJail")
370+
function GM_setJailCommand(factionCommand)
371+
local command = GM_genericCommands[factionCommand][GENERICS_command]
372+
MangAdmin:ChatMsg(".tele del " .. command)
367373
local i = 1
368374
while i < 100 do
369375
i = i + 1
370376
MangAdmin:ChatMsg(".")
371377
end
372-
MangAdmin:ChatMsg(".tele add ma_HordeJail")
373-
MangAdmin:LogAction(Locale["logGM_setJailHorde"])
378+
MangAdmin:ChatMsg(".tele add " .. command)
379+
MangAdmin:LogAction(Locale[GM_genericCommands[factionCommand][GENERICS_message]])
374380
end
375381

376382
function screen()
@@ -388,26 +394,25 @@ function GM_instantKillModeCommand()
388394
)
389395
end
390396

391-
function GM_setSpeedCommand()
392-
local value = string.format("%.1f", GM_setSpeedSlider:GetValue())
397+
function GM_setSpeedOrScaleCommand(sliderControl, sliderCommand)
398+
local command = GM_genericCommands[sliderCommand][GENERICS_command]
399+
local value = string.format("%.1f", sliderControl:GetValue())
393400
if commandTargetCheck() then
394-
MangAdmin:ChatMsg(".modify speed " .. value)
395-
MangAdmin:LogAction(getCommandTargetName() .. Locale["logGM_setSpeed"] .. value)
401+
MangAdmin:ChatMsg(command .. " " .. value)
402+
MangAdmin:LogAction(getCommandTargetName() .. Locale[GM_genericCommands[sliderCommand][GENERICS_message]] .. value)
396403
else
397404
MangAdmin:Print(Locale["selectionError"])
398-
GM_setSpeedSlider:SetValue(1)
405+
sliderControl:SetValue(1)
399406
end
400407
end
401408

402-
function GM_setScaleCommand()
403-
local value = string.format("%.1f", GM_setScaleSlider:GetValue())
404-
if commandTargetCheck() then
405-
MangAdmin:ChatMsg(".modify scale " .. value)
406-
MangAdmin:LogAction(getCommandTargetName() .. Locale["logGM_setScale"] .. value)
407-
else
408-
MangAdmin:Print(Locale["selectionError"])
409-
GM_setScaleSlider:SetValue(1)
410-
end
409+
function GM_resetSpeedOrScaleSlider(sliderControl, sliderText, sliderCommand)
410+
local command = GM_genericCommands[sliderCommand][GENERICS_command]
411+
local title = (command:find('scale') and "Scale" or "Speed")
412+
sliderControl:SetValue(1)
413+
sliderText:SetText(title .. ": 1.0")
414+
MangAdmin:ChatMsg(command .." 1")
415+
MangAdmin:LogAction(Locale["log_resetSlider"])
411416
end
412417

413418
function GridNavigate(x, y)
@@ -446,17 +451,3 @@ function GridNavigate(x, y)
446451
end
447452
end
448453
end
449-
450-
function GM_resetSpeed()
451-
GM_setSpeedSlider:SetValue(1)
452-
GM_setSpeedSliderText:SetText("Speed: 1.0")
453-
MangAdmin:ChatMsg(".mod speed 1")
454-
MangAdmin:LogAction(Locale["log_resetSlider"])
455-
end
456-
457-
function GM_resetScale()
458-
GM_setScaleSlider:SetValue(1)
459-
GM_setScaleSliderText:SetText("Scale: 1.0")
460-
MangAdmin:ChatMsg(".mod scale 1")
461-
MangAdmin:LogAction(Locale["log_resetSlider"])
462-
end

Commands/Commands_Generics.lua

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,50 @@
1515
--
1616
-------------------------------------------------------------------------------------------------------------
1717

18+
function commandTargetCheck()
19+
return (MangAdmin:Selection("player") or MangAdmin:Selection("self") or MangAdmin:Selection("none"))
20+
end
21+
22+
function getCommandTargetName()
23+
return (UnitName("target") or UnitName("player"))
24+
end
25+
26+
function getCallsDictionary(ID)
27+
if ID == GM_KEY then
28+
return GM_genericCommands
29+
elseif ID == CHAR_KEY then
30+
return CHAR_genericCommands
31+
else
32+
return nil
33+
end
34+
end
35+
1836
function genericClearParametersBox(caller)
1937
if (caller == "GM") then
2038
GM_parameterInput:SetText("")
2139
end
2240
end
2341

42+
function genericLogGenerator(textID, data)
43+
local log = Locale[textID]
44+
local params = {}
45+
if(textID ~= "logGM_GMNotify" and textID ~= "logGM_GMMessage") then
46+
for w in data['value']:gmatch("%w+") do
47+
table.insert(params, w)
48+
end
49+
else
50+
params[1] = data['value']
51+
end
52+
for i = #params, 1, -1 do
53+
local pattern = "_V" .. i .. "_"
54+
log = string.gsub(log, pattern, params[i])
55+
end
56+
if data['target'] ~=nil then
57+
log = string.gsub(log, "_T_", data['target'])
58+
end
59+
return log
60+
end
61+
2462
function genericBagCommand(caller)
2563
local player = UnitName("player") or UnitName("target")
2664
local param = nil
@@ -54,4 +92,4 @@ function genericCaller(dictionaryID, callID, value)
5492
end
5593
MangAdmin:ChatMsg(call[GENERICS_command].. data['value'])
5694
MangAdmin:LogAction(genericLogGenerator(call[GENERICS_message], data))
57-
end
95+
end
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ OFF_OPTION = "off"
44

55
-- Role identity Keys
66
GM_KEY = "GM"
7+
CHAR_KEY = "CHAR"
78

8-
-- Generic Spells Action Keys
9+
-- Generic Commands Action Keys
910
GENERICS_parametersGet = "parametersGet"
1011
GENERICS_isValueNeeded = "isValueNeeded"
1112
GENERICS_isParametersNeeded = "isParametersNeeded"
@@ -50,3 +51,20 @@ GM_petUnLearnCommand = "petUnLearn"
5051
GM_petTalentsLearnCommand = "petTalentsLearn"
5152
GM_bankCommand = "bank"
5253
GM_dismountPlayerCommand = "dismountPlayer"
54+
GM_playerSpeedCommand = "playerSpeed"
55+
GM_playerScaleCommand = "playerScale"
56+
GM_AllianceJailCommand = "allianceJail"
57+
GM_HordeJailCommand = "hordeJail"
58+
59+
CHAR_reviveCommand = "revive"
60+
CHAR_saveCommand = "save"
61+
CHAR_kickCommand = "kick"
62+
CHAR_cooldownCommand = "cooldown"
63+
CHAR_GUIDCommand = "GUID"
64+
CHAR_playerInfoCommand = "playerInfo"
65+
CHAR_distanceCommand = "distance"
66+
CHAR_dieCommand = "die"
67+
CHAR_recallCommand = "recall"
68+
CHAR_morphCommand = "morph"
69+
CHAR_morphResetCommand = "morphReset"
70+

0 commit comments

Comments
 (0)