Skip to content

Commit 02d229c

Browse files
committed
fix: LearnSpell Dropdown
1 parent 5b1615c commit 02d229c

File tree

6 files changed

+75
-93
lines changed

6 files changed

+75
-93
lines changed

AzerothCoreAdmin.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2307,7 +2307,7 @@ function PopupScrollUpdate()
23072307
getglobal("ma_PopupScrollBarEntry"..line):SetText("Id: |cffffffff"..spell["spId"].."|r Name: |cffffffff"..spell["spName"].."|r")
23082308
getglobal("ma_PopupScrollBarEntry"..line):SetScript("OnEnter", function() --[[Do nothing]] end)
23092309
getglobal("ma_PopupScrollBarEntry"..line):SetScript("OnLeave", function() --[[Do nothing]] end)
2310-
getglobal("ma_PopupScrollBarEntry"..line):SetScript("OnClick", function() LearnSpell(spell["spId"], arg1) end)
2310+
getglobal("ma_PopupScrollBarEntry"..line):SetScript("OnClick", function() LearnAndUnlearnSpell(true, spell["spId"]) end)
23112311
getglobal("ma_PopupScrollBarEntry"..line):Enable()
23122312
getglobal("ma_PopupScrollBarEntry"..line):Show()
23132313
if MangAdmin.db.char.requests.spell then

Commands/Commands_Char.lua

Lines changed: 42 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -405,41 +405,30 @@ function teleportToJail(jailCommand)
405405
MangAdmin:LogAction(genericLogGenerator(command[GENERICS_message], { ['value'] = character }))
406406
end
407407

408-
function LearnSpell(value, state)
409-
if MangAdmin:Selection("player") or MangAdmin:Selection("self") or MangAdmin:Selection("none") then
408+
function LearnAndUnlearnSpell(isLearn, value)
409+
if (not value or value == '') then
410+
MangAdmin:Print(Locale["paramError"])
411+
return
412+
end
413+
if commandTargetCheck() then
414+
local command = (isLearn == true and ".learn" or ".unlearn")
415+
local log = (isLearn == true and "Learned" or "Unlearned")
410416
local player = UnitName("target") or UnitName("player")
411-
local class = UnitClass("target") or UnitClass("player")
412-
local command = ".learn"
413-
local logcmd = "Learned"
414-
if state == "RightButton" then
415-
command = ".unlearn"
416-
logcmd = "Unlearned"
417-
end
418-
if type(value) == "string" then
419-
if value == "all" then
420-
MangAdmin:ChatMsg(command .. " all")
421-
MangAdmin:LogAction(logcmd .. " all spells to " .. player .. ".")
422-
elseif value == "all_crafts" then
423-
MangAdmin:ChatMsg(command .. " all_crafts")
424-
MangAdmin:LogAction(logcmd .. " all professions and recipes to " .. player .. ".")
425-
elseif value == "all_gm" then
426-
MangAdmin:ChatMsg(command .. " all_gm")
427-
MangAdmin:LogAction(logcmd .. " all default spells for Game Masters to " .. player .. ".")
428-
elseif value == "all_lang" then
429-
MangAdmin:ChatMsg(command .. " all_lang")
430-
MangAdmin:LogAction(logcmd .. " all languages to " .. player .. ".")
431-
elseif value == "all_myclass" then
432-
MangAdmin:ChatMsg(command .. " all_myclass")
433-
MangAdmin:LogAction(logcmd .. " all spells available to the " .. class .. "-class to " .. player .. ".")
434-
else
435-
MangAdmin:ChatMsg(command .. " " .. value)
436-
MangAdmin:LogAction(logcmd .. " spell " .. value .. " to " .. player .. ".")
437-
end
438-
elseif type(value) == "table" then
439-
for k, v in pairs(value) do
440-
MangAdmin:ChatMsg(command .. " " .. v)
441-
MangAdmin:LogAction(logcmd .. " spell " .. v .. " to " .. player .. ".")
442-
end
417+
if value == "all_crafts" then
418+
MangAdmin:ChatMsg(command .. " all crafts")
419+
MangAdmin:LogAction(log .. " all professions and recipes to " .. player .. ".")
420+
elseif value == "all_gm" then
421+
MangAdmin:ChatMsg(command .. " all gm")
422+
MangAdmin:LogAction(log .. " all default spells for Game Masters to " .. player .. ".")
423+
elseif value == "all_lang" then
424+
MangAdmin:ChatMsg(command .. " all lang")
425+
MangAdmin:LogAction(log .. " all languages to " .. player .. ".")
426+
elseif value == "all_myclass" then
427+
MangAdmin:ChatMsg(command .. " all myclass")
428+
MangAdmin:LogAction(log .. " all spells available to the " .. "-class to " .. player .. ".")
429+
else
430+
MangAdmin:ChatMsg(command .. " " .. value)
431+
MangAdmin:LogAction(log .. " spell " .. value .. " to " .. player .. ".")
443432
end
444433
else
445434
MangAdmin:Print(Locale["selectionError"])
@@ -519,39 +508,39 @@ function Modify(case, value)
519508
end
520509
end
521510

522-
-- LEARN LANG
523-
function LearnLangDropDownInitialize()
511+
-- LEARN Spell Preset
512+
function LearnPresetDropDownInitialize()
524513
local level = 1
525514
local info = UIDropDownMenu_CreateInfo()
526515
local buttons = {
527-
{ Locale["ma_AllLang"], "all_lang" },
528-
{ Locale["Common"], "668" },
529-
{ Locale["Orcish"], "669" },
530-
{ Locale["Taurahe"], "670" },
531-
{ Locale["Darnassian"], "671" },
532-
{ Locale["Dwarvish"], "672" },
533-
{ Locale["Thalassian"], "813" },
534-
{ Locale["Demonic"], "815" },
535-
{ Locale["Draconic"], "814" },
536-
{ Locale["Titan"], "816" },
537-
{ Locale["Kalimag"], "817" },
538-
{ Locale["Gnomish"], "7340" },
539-
{ Locale["Troll"], "7341" },
540-
{ Locale["Gutterspeak"], "17737" },
541-
{ Locale["Draenei"], "29932" }
516+
{ Locale["labelCHAR_languageClass"], "all_lang" },
517+
{ Locale["labelCHAR_languageCommon"], "668" },
518+
{ Locale["labelCHAR_languageOrcish"], "669" },
519+
{ Locale["labelCHAR_languageTaurahe"], "670" },
520+
{ Locale["labelCHAR_languageDarnassian"], "671" },
521+
{ Locale["labelCHAR_languageDwarven"], "672" },
522+
{ Locale["labelCHAR_languageThalassian"], "813" },
523+
{ Locale["labelCHAR_languageDemon"], "815" },
524+
{ Locale["labelCHAR_languageDraconic"], "814" },
525+
{ Locale["labelCHAR_languageTitan"], "816" },
526+
{ Locale["labelCHAR_languageOld"], "817" },
527+
{ Locale["labelCHAR_languageGnomish"], "7340" },
528+
{ Locale["labelCHAR_languageTroll"], "7341" },
529+
{ Locale["labelCHAR_languageGutterspeak"], "17737" },
530+
{ Locale["labelCHAR_languageDraenei"], "29932" }
542531
}
543532
for k, v in pairs(buttons) do
544533
info.text = v[1]
545534
info.value = v[2]
546535
info.func = function()
547-
UIDropDownMenu_SetSelectedValue(ma_learnlangdropdown, this.value)
536+
UIDropDownMenu_SetSelectedValue(CHAR_learnPresetDropdown, this.value)
548537
end
549538
info.checked = nil
550539
info.icon = nil
551540
info.keepShownOnClick = nil
552541
UIDropDownMenu_AddButton(info, level)
553542
end
554-
UIDropDownMenu_SetSelectedValue(ma_learnlangdropdown, "all_lang")
543+
UIDropDownMenu_SetSelectedValue(CHAR_learnPresetDropdown, "all_lang")
555544
end
556545

557546
-- MODIFY

Commands/Commands_GM.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ end
261261
function GM_deleteAccountCommand()
262262
local input = GM_genericCommands[GENERICS_parametersGet]()
263263
local params = {}
264-
local fail = false
265264
for w in input:gmatch("%w+") do
266265
table.insert(params, w)
267266
end

Frames/MangFrames_SectionChar.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,9 +1268,9 @@ function MangAdmin:CreateCharSection()
12681268
},
12691269
text = Locale["label_bagButton"]
12701270
})
1271-
1271+
-- Learn Preset Dropdown
12721272
FrameLib:BuildFrame({
1273-
name = "ma_learnlangdropdown",
1273+
name = "CHAR_learnPresetDropdown",
12741274
group = "char",
12751275
parent = ma_midframe,
12761276
size = {
@@ -1284,25 +1284,25 @@ function MangAdmin:CreateCharSection()
12841284
},
12851285
inherits = "UIDropDownMenuTemplate"
12861286
})
1287-
1287+
-- Learn Preset Button
12881288
FrameLib:BuildButton({
1289-
name = "ma_learnlangbutton",
1289+
name = "CHAR_learnPresetButton",
12901290
group = "char",
12911291
parent = ma_midframe,
12921292
texture = {
1293-
name = "ma_learnlangbutton_texture",
1293+
name = "CHAR_learnPresetButton_texture",
12941294
color = { color.btn.r, color.btn.g, color.btn.b, transparency.btn }
12951295
},
12961296
size = {
1297-
width = 40,
1297+
width = 80,
12981298
height = 20
12991299
},
13001300
setpoint = {
13011301
pos = "TOPLEFT",
13021302
offX = 120,
13031303
offY = -4
13041304
},
1305-
text = Locale["ma_Learn"]
1305+
text = Locale["labelCHAR_learnPresetButton"]
13061306
})
13071307
-- Modify Dropdown
13081308
FrameLib:BuildFrame({

FunctionInit.lua

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -755,11 +755,10 @@ function InitControls()
755755

756756

757757
MangAdmin:PrepareScript(
758-
ma_learnlangbutton,
759-
Locale["tt_learnlangbutton"],
760-
function(self, button, down)
761-
MangAdmin:Print(button)
762-
LearnSpell(UIDropDownMenu_GetSelectedValue(ma_learnlangdropdown), button)
758+
CHAR_learnPresetButton,
759+
Locale["ttCHAR_learnPreset"],
760+
function()
761+
LearnAndUnlearnSpell(true, UIDropDownMenu_GetSelectedValue(CHAR_learnPresetDropdown))
763762
end
764763
)
765764
MangAdmin:PrepareScript(
@@ -776,10 +775,10 @@ function InitControls()
776775
genericCaller(CHAR_KEY, CHAR_resetCommand, UIDropDownMenu_GetSelectedValue(CHAR_resetDropdown))
777776
end
778777
)
779-
LearnLangDropDownInitialize()
780-
UIDropDownMenu_Initialize(ma_learnlangdropdown, LearnLangDropDownInitialize)
781-
UIDropDownMenu_SetWidth(ma_learnlangdropdown, 100)
782-
UIDropDownMenu_SetButtonWidth(ma_learnlangdropdown, 20)
778+
LearnPresetDropDownInitialize()
779+
UIDropDownMenu_Initialize(CHAR_learnPresetDropdown, LearnLangDropDownInitialize)
780+
UIDropDownMenu_SetWidth(CHAR_learnPresetDropdown, 100)
781+
UIDropDownMenu_SetButtonWidth(CHAR_learnPresetDropdown, 20)
783782
ModifyDropDownInitialize()
784783
UIDropDownMenu_Initialize(CHAR_modifyDropdown, ModifyDropDownInitialize)
785784
UIDropDownMenu_SetWidth(CHAR_modifyDropdown, 100)

Locales/enUS.lua

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ function Return_enUS()
334334
["ttCHAR_honorUpdate"] = "Saves Honor for **selected** player",
335335
["ttCHAR_modify"] = "Modify the selected attribute by the entered amount of the selected player",
336336
["ttCHAR_reset"] = "Reset the selected attribute of the selected player",
337+
["ttCHAR_learnPreset"] = "Learn the selected spell(s)",
337338
--[[CHAR-Control-Labels]]
338339
["labelCHAR_killButton"] = "Kill",
339340
["labelCHAR_reviveButton"] = "Revive",
@@ -393,6 +394,7 @@ function Return_enUS()
393394
["labelCHAR_hideMapsButton"] = "Hide Maps",
394395
["labelCHAR_modifyButton"] = "Modify",
395396
["labelCHAR_resetButton"] = "Reset",
397+
["labelCHAR_learnPresetButton"] = "Learn Preset",
396398
["labelCHAR_modifyLevelUPOption"] = "Level up",
397399
["labelCHAR_modifyLevelDownOption"] = "Level down",
398400
["labelCHAR_modifyMoneyOption"] = "Money",
@@ -419,6 +421,21 @@ function Return_enUS()
419421
["labelCHAR_resetHonorOption"] = "Honor",
420422
["labelCHAR_resetLevelOption"] = "Level",
421423
["labelCHAR_resetAchievementsOption"] = "Achievements",
424+
["labelCHAR_languageClass"] = "All Class Langs",
425+
["labelCHAR_languageCommon"] = "Common",
426+
["labelCHAR_languageOrcish"] = "Orcish",
427+
["labelCHAR_languageTaurahe"] = "Taurahe",
428+
["labelCHAR_languageDarnassian"] = "Darnassian",
429+
["labelCHAR_languageDwarven"] = "Dwarven",
430+
["labelCHAR_languageThalassian"] = "Thalassian",
431+
["labelCHAR_languageDraconic"] = "Draconic",
432+
["labelCHAR_languageDemon"] = "Demon Tongue",
433+
["labelCHAR_languageTitan"] = "Titan",
434+
["labelCHAR_languageOld"] = "Old Tongue",
435+
["labelCHAR_languageGnomish"] = "Gnomish",
436+
["labelCHAR_languageTroll"] = "Troll",
437+
["labelCHAR_languageGutterspeak"] = "Gutterspeak",
438+
["labelCHAR_languageDraenei"] = "Draenei",
422439

423440
--[[CHAR-Commands Output]]
424441
["logCHAR_kill"] = "_T_ has been killed",
@@ -480,31 +497,9 @@ function Return_enUS()
480497

481498
["tt_RotateLeft"] = "Rotate left.",
482499
["tt_RotateRight"] = "Rotate right.",
483-
["tt_learnlangbutton"] = "Learn selected langauge(s)",
484500
["tt_modelzoominbutton"] = "Zoom in the selected model",
485501
["tt_modelzoomoutbutton"] = "Zoom out the selected model",
486502

487-
["ma_LearnLangButton"] = "All languages",
488-
["ma_Learn"] = "Learn",
489-
["ma_AllLang"] = "All Languages",
490-
--[[Other]]
491-
492-
-- languages
493-
["Common"] = "Common",
494-
["Orcish"] = "Orcish",
495-
["Taurahe"] = "Taurahe",
496-
["Darnassian"] = "Darnassian",
497-
["Dwarvish"] = "Dwarvish",
498-
["Thalassian"] = "Thalassian",
499-
["Demonic"] = "Demonic",
500-
["Draconic"] = "Draconic",
501-
["Titan"] = "Titan",
502-
["Kalimag"] = "Kalimag",
503-
["Gnomish"] = "Gnomish",
504-
["Troll"] = "Troll",
505-
["Gutterspeak"] = "Gutterspeak",
506-
["Draenei"] = "Draenei",
507-
508503
--[[NPC Tab]]
509504
--[[Name]]
510505
["tabmenu_NPC"] = "NPC",

0 commit comments

Comments
 (0)