Skip to content

Commit 5b1615c

Browse files
committed
refactor: Modify and Reset CHAR
1 parent 58ac964 commit 5b1615c

File tree

5 files changed

+104
-112
lines changed

5 files changed

+104
-112
lines changed

Commands/Commands_Char.lua

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ CHAR_genericCommands = {
321321
[GENERICS_command] = ".honor update ",
322322
[GENERICS_message] = "logCHAR_honorUpdate"
323323
},
324+
[CHAR_resetCommand] = {
325+
[GENERICS_isValueNeeded] = true,
326+
[GENERICS_isTargetCheckNeeded] = true,
327+
[GENERICS_command] = ".reset ",
328+
[GENERICS_message] = "logCHAR_reset"
329+
},
324330
}
325331
-- Delete
326332
--
@@ -441,7 +447,11 @@ function LearnSpell(value, state)
441447
end
442448

443449
function Modify(case, value)
444-
if MangAdmin:Selection("player") or MangAdmin:Selection("self") or MangAdmin:Selection("none") then
450+
if (not value or value == '') then
451+
MangAdmin:Print(Locale["paramError"])
452+
return
453+
end
454+
if commandTargetCheck() then
445455
local player = UnitName("target") or UnitName("player")
446456
if case == "money" then
447457
MangAdmin:ChatMsg(".modify money " .. value)
@@ -509,16 +519,6 @@ function Modify(case, value)
509519
end
510520
end
511521

512-
function Reset(value)
513-
if MangAdmin:Selection("player") or MangAdmin:Selection("self") or MangAdmin:Selection("none") then
514-
local player = UnitName("target") or UnitName("player")
515-
MangAdmin:ChatMsg(".reset " .. value)
516-
MangAdmin:LogAction("Reset " .. value .. "' for player " .. player .. ".")
517-
else
518-
MangAdmin:Print(Locale["selectionError"])
519-
end
520-
end
521-
522522
-- LEARN LANG
523523
function LearnLangDropDownInitialize()
524524
local level = 1
@@ -559,63 +559,63 @@ function ModifyDropDownInitialize()
559559
local level = 1
560560
local info = UIDropDownMenu_CreateInfo()
561561
local buttons = {
562-
{ Locale["ma_AllSpeeds"], "aspeed" },
563-
{ Locale["ma_Arena"], "arena" },
564-
{ Locale["ma_BackWalk"], "bwalk" },
565-
{ Locale["ma_Drunk"], "drunk" },
566-
{ Locale["ma_Energy"], "energy" },
567-
{ Locale["ma_FlySpeed"], "fly" },
568-
{ Locale["ma_Gender"], "gender" },
569-
{ Locale["ma_Healthpoints"], "health" },
570-
{ Locale["ma_Honor"], "honor" },
571-
{ Locale["ma_LevelUp"], "levelup" },
572-
{ Locale["ma_LevelDown"], "leveldown" },
573-
{ Locale["ma_Mana"], "mana" },
574-
{ Locale["ma_Money"], "money" },
575-
{ Locale["ma_MountSpeed"], "mount" },
576-
{ Locale["ma_Phase"], "phase" },
577-
{ Locale["ma_Rage"], "rage" },
578-
{ Locale["ma_RunicPower"], "runicpower" },
579-
{ Locale["ma_StandSate"], "standstate" },
580-
{ Locale["ma_SwimSpeed"], "swim" },
581-
{ Locale["ma_TalentPoints"], "tp" }
562+
{ Locale["labelCHAR_modifyAllSpeedsOption"], "aspeed" },
563+
{ Locale["labelCHAR_modifyArenaOption"], "arena" },
564+
{ Locale["labelCHAR_modifyBackWalkOption"], "bwalk" },
565+
{ Locale["labelCHAR_modifyDrunkOption"], "drunk" },
566+
{ Locale["labelCHAR_modifyEnergyOption"], "energy" },
567+
{ Locale["labelCHAR_modifyFlySpeedOption"], "fly" },
568+
{ Locale["labelCHAR_modifyGenderOption"], "gender" },
569+
{ Locale["labelCHAR_modifyHealthPointsOption"], "health" },
570+
{ Locale["labelCHAR_modifyHonorOption"], "honor" },
571+
{ Locale["labelCHAR_modifyLevelUPOption"], "levelup" },
572+
{ Locale["labelCHAR_modifyLevelDownOption"], "leveldown" },
573+
{ Locale["labelCHAR_modifyManaOption"], "mana" },
574+
{ Locale["labelCHAR_modifyMoneyOption"], "money" },
575+
{ Locale["labelCHAR_modifyMountSpeedOption"], "mount" },
576+
{ Locale["labelCHAR_modifyPhaseOption"], "phase" },
577+
{ Locale["labelCHAR_modifyRageOption"], "rage" },
578+
{ Locale["labelCHAR_modifyRunicPowerOption"], "runicpower" },
579+
{ Locale["labelCHAR_modifyStandSateOption"], "standstate" },
580+
{ Locale["labelCHAR_modifySwimSpeedOption"], "swim" },
581+
{ Locale["labelCHAR_resetTalentsOption"], "tp" }
582582
}
583583
for k, v in pairs(buttons) do
584584
info.text = v[1]
585585
info.value = v[2]
586586
info.func = function()
587-
UIDropDownMenu_SetSelectedValue(ma_modifydropdown, this.value)
587+
UIDropDownMenu_SetSelectedValue(CHAR_modifyDropdown, this.value)
588588
end
589589
info.checked = nil
590590
info.icon = nil
591591
info.keepShownOnClick = nil
592592
UIDropDownMenu_AddButton(info, level)
593593
end
594-
UIDropDownMenu_SetSelectedValue(ma_modifydropdown, "levelup")
594+
UIDropDownMenu_SetSelectedValue(CHAR_modifyDropdown, "levelup")
595595
end
596596

597597
-- RESET
598598
function ResetDropDownInitialize()
599599
local level = 1
600600
local info = UIDropDownMenu_CreateInfo()
601601
local buttons = {
602-
{ Locale["ma_achievements"], "achievements" },
603-
{ Locale["ma_Honor"], "honor" },
604-
{ Locale["ma_Level"], "level" },
605-
{ Locale["ma_Spells"], "spells" },
606-
{ Locale["ma_Stats"], "stats" },
607-
{ Locale["ma_Talents"], "talents" }
602+
{ Locale["labelCHAR_resetAchievementsOption"], "achievements" },
603+
{ Locale["labelCHAR_resetHonorOption"], "honor" },
604+
{ Locale["labelCHAR_resetLevelOption"], "level" },
605+
{ Locale["labelCHAR_resetSpellsOption"], "spells" },
606+
{ Locale["labelCHAR_resetStatsOption"], "stats" },
607+
{ Locale["labelCHAR_resetTalentsOption"], "talents" }
608608
}
609609
for k, v in pairs(buttons) do
610610
info.text = v[1]
611611
info.value = v[2]
612612
info.func = function()
613-
UIDropDownMenu_SetSelectedValue(ma_resetdropdown, this.value)
613+
UIDropDownMenu_SetSelectedValue(CHAR_resetDropdown, this.value)
614614
end
615615
info.checked = nil
616616
info.icon = nil
617617
info.keepShownOnClick = nil
618618
UIDropDownMenu_AddButton(info, level)
619619
end
620-
UIDropDownMenu_SetSelectedValue(ma_resetdropdown, "achievements")
620+
UIDropDownMenu_SetSelectedValue(CHAR_resetDropdown, "achievements")
621621
end

Commands/declarations/command_keys.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,5 @@ CHAR_damageCommand = "damage"
114114
CHAR_showAreaCommand = "showArea"
115115
CHAR_hideAreaCommand = "hideArea"
116116
CHAR_honorAddCommand = "honorAdd"
117-
CHAR_honorUpdateCommand = "honorUpdate"
117+
CHAR_honorUpdateCommand = "honorUpdate"
118+
CHAR_resetCommand = "reset"

Frames/MangFrames_SectionChar.lua

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,9 +1304,9 @@ function MangAdmin:CreateCharSection()
13041304
},
13051305
text = Locale["ma_Learn"]
13061306
})
1307-
1307+
-- Modify Dropdown
13081308
FrameLib:BuildFrame({
1309-
name = "ma_modifydropdown",
1309+
name = "CHAR_modifyDropdown",
13101310
group = "char",
13111311
parent = ma_midframe,
13121312
size = {
@@ -1320,10 +1320,10 @@ function MangAdmin:CreateCharSection()
13201320
},
13211321
inherits = "UIDropDownMenuTemplate"
13221322
})
1323-
1323+
-- Modify Input Box
13241324
FrameLib:BuildFrame({
13251325
type = "EditBox",
1326-
name = "ma_modifyeditbox",
1326+
name = "CHAR_modifyInputBox",
13271327
group = "char",
13281328
parent = ma_midframe,
13291329
size = {
@@ -1337,13 +1337,13 @@ function MangAdmin:CreateCharSection()
13371337
},
13381338
inherits = "InputBoxTemplate"
13391339
})
1340-
1340+
-- Modify Button
13411341
FrameLib:BuildButton({
1342-
name = "ma_modifybutton",
1342+
name = "CHAR_modifyButton",
13431343
group = "char",
13441344
parent = ma_midframe,
13451345
texture = {
1346-
name = "ma_modifybutton_texture",
1346+
name = "CHAR_modifyButton_texture",
13471347
color = { color.btn.r, color.btn.g, color.btn.b, transparency.btn }
13481348
},
13491349
size = {
@@ -1355,11 +1355,11 @@ function MangAdmin:CreateCharSection()
13551355
offX = 485,
13561356
offY = -4
13571357
},
1358-
text = Locale["ma_Modify"]
1358+
text = Locale["labelCHAR_modifyButton"]
13591359
})
1360-
1360+
-- Reset Dropdown
13611361
FrameLib:BuildFrame({
1362-
name = "ma_resetdropdown",
1362+
name = "CHAR_resetDropdown",
13631363
group = "char",
13641364
parent = ma_midframe,
13651365
size = {
@@ -1373,13 +1373,13 @@ function MangAdmin:CreateCharSection()
13731373
},
13741374
inherits = "UIDropDownMenuTemplate"
13751375
})
1376-
1376+
-- Reset Button
13771377
FrameLib:BuildButton({
1378-
name = "ma_resetbutton",
1378+
name = "CHAR_resetButton",
13791379
group = "char",
13801380
parent = ma_midframe,
13811381
texture = {
1382-
name = "ma_resetbutton_texture",
1382+
name = "CHAR_resetButton_texture",
13831383
color = { color.btn.r, color.btn.g, color.btn.b, transparency.btn }
13841384
},
13851385
size = {
@@ -1391,19 +1391,8 @@ function MangAdmin:CreateCharSection()
13911391
offX = 285,
13921392
offY = -4
13931393
},
1394-
text = Locale["ma_Reset"]
1394+
text = Locale["labelCHAR_resetButton"]
13951395
})
1396-
1397-
1398-
1399-
1400-
1401-
1402-
1403-
1404-
1405-
1406-
14071396
-- Input Box Label
14081397
FrameLib:BuildFontString({
14091398
name = "ma_parameterboxtext",

FunctionInit.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -763,31 +763,31 @@ function InitControls()
763763
end
764764
)
765765
MangAdmin:PrepareScript(
766-
ma_modifybutton,
767-
Locale["tt_modifybutton"],
766+
CHAR_modifyButton,
767+
Locale["ttCHAR_modify"],
768768
function()
769-
Modify(UIDropDownMenu_GetSelectedValue(ma_modifydropdown), ma_modifyeditbox:GetText())
769+
Modify(UIDropDownMenu_GetSelectedValue(CHAR_modifyDropdown), CHAR_modifyInputBox:GetText())
770770
end
771771
)
772772
MangAdmin:PrepareScript(
773-
ma_resetbutton,
774-
Locale["tt_resetbutton"],
773+
CHAR_resetButton,
774+
Locale["ttCHAR_reset"],
775775
function()
776-
Reset(UIDropDownMenu_GetSelectedValue(ma_resetdropdown))
776+
genericCaller(CHAR_KEY, CHAR_resetCommand, UIDropDownMenu_GetSelectedValue(CHAR_resetDropdown))
777777
end
778778
)
779779
LearnLangDropDownInitialize()
780780
UIDropDownMenu_Initialize(ma_learnlangdropdown, LearnLangDropDownInitialize)
781781
UIDropDownMenu_SetWidth(ma_learnlangdropdown, 100)
782782
UIDropDownMenu_SetButtonWidth(ma_learnlangdropdown, 20)
783783
ModifyDropDownInitialize()
784-
UIDropDownMenu_Initialize(ma_modifydropdown, ModifyDropDownInitialize)
785-
UIDropDownMenu_SetWidth(ma_modifydropdown, 100)
786-
UIDropDownMenu_SetButtonWidth(ma_modifydropdown, 20)
784+
UIDropDownMenu_Initialize(CHAR_modifyDropdown, ModifyDropDownInitialize)
785+
UIDropDownMenu_SetWidth(CHAR_modifyDropdown, 100)
786+
UIDropDownMenu_SetButtonWidth(CHAR_modifyDropdown, 20)
787787
ResetDropDownInitialize()
788-
UIDropDownMenu_Initialize(ma_resetdropdown, ResetDropDownInitialize)
789-
UIDropDownMenu_SetWidth(ma_resetdropdown, 100)
790-
UIDropDownMenu_SetButtonWidth(ma_resetdropdown, 20)
788+
UIDropDownMenu_Initialize(CHAR_resetDropdown, ResetDropDownInitialize)
789+
UIDropDownMenu_SetWidth(CHAR_resetDropdown, 100)
790+
UIDropDownMenu_SetButtonWidth(CHAR_resetDropdown, 20)
791791

792792
MangAdmin:PrepareScript(
793793
CHAR_banButton,

Locales/enUS.lua

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ function Return_enUS()
332332
["ttCHAR_hideArea"] = "Hides the specified area to the **selected** player [[Parameters: $areaID]]",
333333
["ttCHAR_honorAdd"] = "Adds the specified amount of honor points to the **selected** player [[ParameterS: $pointsAmount]]",
334334
["ttCHAR_honorUpdate"] = "Saves Honor for **selected** player",
335-
335+
["ttCHAR_modify"] = "Modify the selected attribute by the entered amount of the selected player",
336+
["ttCHAR_reset"] = "Reset the selected attribute of the selected player",
336337
--[[CHAR-Control-Labels]]
337338
["labelCHAR_killButton"] = "Kill",
338339
["labelCHAR_reviveButton"] = "Revive",
@@ -390,6 +391,34 @@ function Return_enUS()
390391
["labelCHAR_honorUpdateButton"] = "HonorUpdt",
391392
["labelCHAR_showMapsButton"] = "Show Maps",
392393
["labelCHAR_hideMapsButton"] = "Hide Maps",
394+
["labelCHAR_modifyButton"] = "Modify",
395+
["labelCHAR_resetButton"] = "Reset",
396+
["labelCHAR_modifyLevelUPOption"] = "Level up",
397+
["labelCHAR_modifyLevelDownOption"] = "Level down",
398+
["labelCHAR_modifyMoneyOption"] = "Money",
399+
["labelCHAR_modifyEnergyOption"] = "Energy",
400+
["labelCHAR_modifyRageOption"] = "Rage",
401+
["labelCHAR_modifyManaOption"] = "Mana",
402+
["labelCHAR_modifyHealthPointsOption"] = "Health Points",
403+
["labelCHAR_modifyAllSpeedsOption"] = "AllSpeeds",
404+
["labelCHAR_modifyArenaOption"] = "ArenaPoints",
405+
["labelCHAR_modifyBackWalkOption"] = "BackWalk",
406+
["labelCHAR_modifyDrunkOption"] = "Drunk",
407+
["labelCHAR_modifyFlySpeedOption"] = "FlySpeed",
408+
["labelCHAR_modifyGenderOption"] = "Gender",
409+
["labelCHAR_modifyHonorOption"] = "Honor",
410+
["labelCHAR_modifyMountSpeedOption"] = "MountSpeed",
411+
["labelCHAR_modifyPhaseOption"] = "Phase",
412+
["labelCHAR_modifyRunicPowerOption"] = "RunicPower",
413+
["labelCHAR_modifyStandSateOption"] = "StandState",
414+
["labelCHAR_modifySwimSpeedOption"] = "SwimSpeed",
415+
["labelCHAR_modifyTalentPointsOption"] = "TalentPoints",
416+
["labelCHAR_resetTalentsOption"] = "Talents",
417+
["labelCHAR_resetStatsOption"] = "Stats",
418+
["labelCHAR_resetSpellsOption"] = "Spells",
419+
["labelCHAR_resetHonorOption"] = "Honor",
420+
["labelCHAR_resetLevelOption"] = "Level",
421+
["labelCHAR_resetAchievementsOption"] = "Achievements",
393422

394423
--[[CHAR-Commands Output]]
395424
["logCHAR_kill"] = "_T_ has been killed",
@@ -442,52 +471,24 @@ function Return_enUS()
442471
["logCHAR_questRemove"] = "Removed questID _V1_ to _T_",
443472
["logCHAR_questComplete"] = "Set questID _V1_ as completed to _T_",
444473
["logCHAR_damage"] = "Applied _V1_ damage to _T_",
445-
446474
["logCHAR_showArea"] = "Showed areaID _V1_ to _T_",
447475
["logCHAR_hideArea"] = "Hide areaID _V1_ to _T_",
448476
["logCHAR_honorAdd"] = "Added _V1_ honor points to _T_",
449477
["logCHAR_honorUpdate"] = "Updated honor of _T_",
478+
["logCHAR_reset"] = "Reset _V1_ for _T_",
479+
450480

451481
["tt_RotateLeft"] = "Rotate left.",
452482
["tt_RotateRight"] = "Rotate right.",
453483
["tt_learnlangbutton"] = "Learn selected langauge(s)",
454-
["tt_modifybutton"] = "Modify the selected attribute by the entered amount",
455-
["tt_resetbutton"] = "Reset the selected attribute",
456484
["tt_modelzoominbutton"] = "Zoom in the selected model",
457485
["tt_modelzoomoutbutton"] = "Zoom out the selected model",
458486

459487
["ma_LearnLangButton"] = "All languages",
460488
["ma_Learn"] = "Learn",
461-
["ma_Modify"] = "Modify",
462-
["ma_Reset"] = "Reset",
463-
--[[Other]]
464-
["ma_LevelUp"] = "Level up",
465-
["ma_LevelDown"] = "Level down",
466-
["ma_Money"] = "Money",
467-
["ma_Energy"] = "Energy",
468-
["ma_Rage"] = "Rage",
469-
["ma_Mana"] = "Mana",
470-
["ma_Healthpoints"] = "Healthpoints",
471-
["ma_Talents"] = "Talents",
472-
["ma_Stats"] = "Stats",
473-
["ma_Spells"] = "Spells",
474-
["ma_Honor"] = "Honor",
475-
["ma_Level"] = "Level",
476489
["ma_AllLang"] = "All Languages",
477-
["ma_achievements"] = "Achievements",
478-
["ma_AllSpeeds"] = "AllSpeeds",
479-
["ma_Arena"] = "Arena",
480-
["ma_BackWalk"] = "BackWalk",
481-
["ma_Drunk"] = "Drunk",
482-
["ma_FlySpeed"] = "FlySpeed",
483-
["ma_Gender"] = "Gender",
484-
["ma_Honor"] = "Honor",
485-
["ma_MountSpeed"] = "MountSpeed",
486-
["ma_Phase"] = "Phase",
487-
["ma_RunicPower"] = "RunicPower",
488-
["ma_StandSate"] = "StandState",
489-
["ma_SwimSpeed"] = "SwimSpeed",
490-
["ma_TalentPoints"] = "TalentPoints",
490+
--[[Other]]
491+
491492
-- languages
492493
["Common"] = "Common",
493494
["Orcish"] = "Orcish",
@@ -503,6 +504,7 @@ function Return_enUS()
503504
["Troll"] = "Troll",
504505
["Gutterspeak"] = "Gutterspeak",
505506
["Draenei"] = "Draenei",
507+
506508
--[[NPC Tab]]
507509
--[[Name]]
508510
["tabmenu_NPC"] = "NPC",

0 commit comments

Comments
 (0)