Skip to content

Commit 288d881

Browse files
authored
Merge pull request #5 from LightDestory/gm-genericCaller
refactor(GM): Implement generics
2 parents 043e331 + 11e0b6b commit 288d881

8 files changed

Lines changed: 2316 additions & 765 deletions

File tree

AzerothCoreAdmin.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,6 @@ function MangAdmin:AddMessage(frame, text, r, g, b, id)
659659
end
660660
-- hook .gps for gridnavigation
661661
for x, y in string.gmatch(text, Strings["ma_GmatchGPS"]) do
662-
message(x)
663-
message(y)
664662
for k,v in pairs(self.db.char.functionQueue) do
665663
if v == "GridNavigate" then
666664
GridNavigate(string.format("%.1f", x), string.format("%.1f", y), nil)
@@ -2588,7 +2586,7 @@ function MangAdmin:InitCheckButtons()
25882586
else
25892587
ma_checktransparencybutton:SetChecked(false)
25902588
end
2591-
ma_instantkillbutton:SetChecked(self.db.char.instantKillMode)
2589+
GM_instantKillModeCheckBox:SetChecked(self.db.char.instantKillMode)
25922590
ma_checklocalsearchstringsbutton:SetChecked(self.db.account.localesearchstring)
25932591
ma_showminimenubutton:SetChecked(self.db.account.style.showminimenu)
25942592
ma_showtooltipsbutton:SetChecked(self.db.account.style.showtooltips)

Commands/Commands_Generics.lua

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,43 @@
1515
--
1616
-------------------------------------------------------------------------------------------------------------
1717

18-
function clearParametersBox(caller)
18+
function genericClearParametersBox(caller)
1919
if (caller == "GM") then
2020
ma_gmParametersInput:SetText("")
2121
end
2222
end
2323

24-
function ShowBag(caller)
24+
function genericBagCommand(caller)
2525
local player = UnitName("player") or UnitName("target")
2626
local param = nil
2727
if (caller == "GM") then
2828
param = ma_gmParametersInput:GetText()
2929
end
30+
param = (param == nil or param == "" and "0" or param)
3031
MangAdmin:ChatMsg(".character check bag " .. param)
31-
MangAdmin:LogAction(Locale["ma_gmBagOutput"] .. player .. " " .. param)
32+
MangAdmin:LogAction(genericLogGenerator("log_bag", {['value'] = param, ['target'] = player}))
3233
end
3334

3435
function genericCaller(dictionaryID, callID, value)
3536
local dictionary = getCallsDictionary(dictionaryID)
3637
local call = dictionary[callID]
37-
local param = "";
38+
local data = {
39+
["value"] = "",
40+
["target"] = nil
41+
}
3842
if call[GENERICS_isValueNeeded] then
39-
param = value
43+
data['value'] = value
4044
elseif call[GENERICS_isParametersNeeded] then
41-
param = dictionary[GENERICS_parametersGet]()
45+
data['value'] = dictionary[GENERICS_parametersGet]()
4246
end
43-
MangAdmin:ChatMsg(call[GENERICS_command].. param)
44-
MangAdmin:LogAction(genericLogGenerator(call[GENERICS_message], param))
47+
if call[GENERICS_isTargetCheckNeeded] then
48+
if commandTargetCheck() then
49+
data['target'] = getCommandTargetName()
50+
else
51+
MangAdmin:Print(Locale["selectionError"])
52+
return
53+
end
54+
end
55+
MangAdmin:ChatMsg(call[GENERICS_command].. data['value'])
56+
MangAdmin:LogAction(genericLogGenerator(call[GENERICS_message], data))
4557
end

0 commit comments

Comments
 (0)