Skip to content

Commit c2e785f

Browse files
committed
refactor(GM): clean up code
1 parent 288d881 commit c2e785f

5 files changed

Lines changed: 110 additions & 96 deletions

File tree

Commands/Commands_Char.lua

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,27 @@
1414
-- Official repository: https://github.com/LightDestory/AzerothCoreAdmin
1515
--
1616
-------------------------------------------------------------------------------------------------------------
17+
-- Generic Command Template
18+
--[[
19+
[COMMAND_NAME_KEY] = {
20+
[GENERICS_isValueNeeded] = false|true,
21+
[GENERICS_isParametersNeeded] = false|true,
22+
[GENERICS_isTargetCheckNeeded] = false|true,
23+
[GENERICS_command] = "command",
24+
[GENERICS_message] = "messageID"
25+
}
26+
]]
27+
CHAR_genericCommands = {
28+
[GENERICS_parametersGet] = function()
29+
return ma_charactertarget:GetText()
30+
end,
31+
}
32+
function InitModelFrame()
33+
ma_modelframe:SetScript("OnUpdate", function() MangAdminModelOnUpdate(arg1) end)
34+
ma_modelframe.rotation = 0.61;
35+
ma_modelframe:SetRotation(ma_modelframe.rotation)
36+
ma_modelframe:SetUnit("player")
37+
end
1738

1839
function ModelRotateLeft()
1940
ma_modelframe.rotation = ma_modelframe.rotation - 0.03
@@ -27,12 +48,20 @@ function ModelRotateRight()
2748
PlaySound("igInventoryRotateCharacter")
2849
end
2950

30-
function InitModelFrame()
31-
ma_modelframe:SetScript("OnUpdate", function() MangAdminModelOnUpdate(arg1) end)
32-
ma_modelframe.rotation = 0.61;
33-
ma_modelframe:SetRotation(ma_modelframe.rotation)
34-
ma_modelframe:SetUnit("player")
51+
function CharModelZoomIn()
52+
ma_modelframe:SetCamera(0)
53+
--ma_modelframe:SetModelScale(ma_modelframe:GetModelScale() + .1)
54+
--ma_modelframe:SetPosition(1,ma_modelframe:GetModelScale()*3,0)
55+
--ma_modelframe:RefreshUnit()
56+
end
3557

58+
function CharModelZoomOut()
59+
ma_modelframe:SetCamera(1)
60+
ma_modelframe:RefreshUnit()
61+
-- ma_modelframe:SetCamera(2)
62+
--ma_modelframe:SetModelScale(ma_modelframe:GetModelScale() * .5)
63+
--ma_modelframe:SetPosition(0,0,0)
64+
--ma_modelframe:RefreshUnit()
3665
end
3766

3867
function MangAdminModelOnUpdate(elapsedTime)
@@ -382,22 +411,6 @@ function ResetDropDownInitialize()
382411
UIDropDownMenu_SetSelectedValue(ma_resetdropdown, "talents")
383412
end
384413

385-
function CharModelZoomIn()
386-
ma_modelframe:SetCamera(0)
387-
--ma_modelframe:SetModelScale(ma_modelframe:GetModelScale() + .1)
388-
--ma_modelframe:SetPosition(1,ma_modelframe:GetModelScale()*3,0)
389-
--ma_modelframe:RefreshUnit()
390-
end
391-
392-
function CharModelZoomOut()
393-
ma_modelframe:SetCamera(1)
394-
ma_modelframe:RefreshUnit()
395-
-- ma_modelframe:SetCamera(2)
396-
--ma_modelframe:SetModelScale(ma_modelframe:GetModelScale() * .5)
397-
--ma_modelframe:SetPosition(0,0,0)
398-
--ma_modelframe:RefreshUnit()
399-
end
400-
401414
function CharBindSight()
402415
local cname = ma_charactertarget:GetText()
403416
MangAdmin:ChatMsg(".bindsight")

Commands/Commands_Generics.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717

1818
function genericClearParametersBox(caller)
1919
if (caller == "GM") then
20-
ma_gmParametersInput:SetText("")
20+
GM_parameterInput:SetText("")
2121
end
2222
end
2323

2424
function genericBagCommand(caller)
2525
local player = UnitName("player") or UnitName("target")
2626
local param = nil
2727
if (caller == "GM") then
28-
param = ma_gmParametersInput:GetText()
28+
param = GM_genericCommands[GENERICS_parametersGet]()
2929
end
3030
param = (param == nil or param == "" and "0" or param)
3131
MangAdmin:ChatMsg(".character check bag " .. param)

Commands/Commands_Main.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
[COMMAND_NAME_KEY] = {
2222
[GENERICS_isValueNeeded] = false|true,
2323
[GENERICS_isParametersNeeded] = false|true,
24+
[GENERICS_isTargetCheckNeeded] = false|true,
2425
[GENERICS_command] = "command",
2526
[GENERICS_message] = "messageID"
2627
}
2728
]]
2829
GM_genericCommands = {
2930
[GENERICS_parametersGet] = function()
30-
return ma_gmParametersInput:GetText()
31+
return GM_parameterInput:GetText()
3132
end,
3233
[GM_displayAccountGMLevelCommand] = {
3334
[GENERICS_command] = ".account",
@@ -214,7 +215,7 @@ function GM_GMModeCommand(value)
214215
end
215216

216217
function GM_createAccountCommand()
217-
local input = ma_gmParametersInput:GetText()
218+
local input = GM_genericCommands[GENERICS_parametersGet]()
218219
local params = {}
219220
local fail = false
220221
for w in input:gmatch("%w+") do
@@ -242,7 +243,7 @@ function GM_createAccountCommand()
242243
end
243244

244245
function GM_deleteAccountCommand()
245-
local input = ma_gmParametersInput:GetText()
246+
local input = GM_genericCommands[GENERICS_parametersGet]()
246247
local params = {}
247248
local fail = false
248249
for w in input:gmatch("%w+") do
@@ -263,7 +264,7 @@ function GM_deleteAccountCommand()
263264
end
264265

265266
function GM_setAccountGMLevelCommand()
266-
local input = ma_gmParametersInput:GetText()
267+
local input = GM_genericCommands[GENERICS_parametersGet]()
267268
local params = {}
268269
local fail = false
269270
for w in input:gmatch("%w+") do
@@ -291,7 +292,7 @@ function GM_setAccountGMLevelCommand()
291292
end
292293

293294
function GM_setAccountPasswordCommand()
294-
local input = ma_gmParametersInput:GetText()
295+
local input = GM_genericCommands[GENERICS_parametersGet]()
295296
local params = {}
296297
local fail = false
297298
for w in input:gmatch("%w+") do
@@ -323,7 +324,7 @@ function GM_setAccountPasswordCommand()
323324
end
324325

325326
function GM_setAccountAddonCommand()
326-
local input = ma_gmParametersInput:GetText()
327+
local input = GM_genericCommands[GENERICS_parametersGet]()
327328
local params = {}
328329
local fail = false
329330
for w in input:gmatch("%w+") do

0 commit comments

Comments
 (0)