Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.

Commit e35bd1a

Browse files
committed
Add a "Select" console command and switch to using Ace3 GetArgs()
1 parent 78007ba commit e35bd1a

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Localizations/Neuron_X-enUS.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ L["Menu_Description"] = "Open the main menu"
3131
L["Create"] = true
3232
L["Create_Description"] = "Create a blank bar of the given type"
3333

34+
L["Select"] = true
35+
L["Select_Description"] = "Switch the currently selected bar"
36+
3437
L["Delete"] = true
3538
L["Delete_Description"] = "Delete the currently selected bar"
3639

Neuron-Console.lua

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ local L = LibStub("AceLocale-3.0"):GetLocale("Neuron")
2929
local slashFunctions = {
3030
{L["Menu"], L["Menu_Description"], "ToggleMainMenu"},
3131
{L["Create"], L["Create_Description"], "CreateNewBar"},
32+
{L["Select"], L["Select_Description"], "ChangeBar"},
3233
{L["Delete"], L["Delete_Description"], "DeleteBar"},
3334
{L["Config"], L["Config_Description"], "ToggleBarEditMode"},
3435
{L["Add"], L["Add_Description"], "AddObjectsToBar"},
@@ -80,7 +81,7 @@ function Neuron:slashHandler(input)
8081
return
8182
end
8283

83-
local commandAndArgs = {strsplit(" ", input)} --split the input into the command and the arguments
84+
local commandAndArgs = {Neuron:GetArgs(input, 3, 1)} --split the input into the command and the arguments
8485
local command = commandAndArgs[1]:lower()
8586
local args = {}
8687
for i = 2,#commandAndArgs do
@@ -106,6 +107,21 @@ function Neuron:slashHandler(input)
106107
local func = slashFunctions[i][3]
107108
local bar = Neuron.CurrentBar
108109

110+
if func == "ChangeBar" then --intercept our bar assignment and reassign to the new bar, if it exists
111+
local newBar
112+
for _,v in pairs(Neuron.BARIndex) do
113+
if v.data.name == args[1] then
114+
newBar = v
115+
break
116+
end
117+
end
118+
if newBar then
119+
bar = newBar --swap out the current bar with the new bar
120+
else
121+
bar = nil --unassign bar if the entered one doesn't exists
122+
end
123+
end
124+
109125
if Neuron[func] then
110126
Neuron[func](Neuron, args[1])
111127
elseif bar and bar[func] then

0 commit comments

Comments
 (0)