Skip to content

Commit

Permalink
Fixed some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
muleyo committed Oct 29, 2024
1 parent d82bb4d commit 4dd618f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
29 changes: 23 additions & 6 deletions Config/Components/_NPCColors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,9 @@ local function buildWindow()
end
end)

-- Create Input Field
local input = SUIConfig:NumericBox(window, 150, 24)
SUIConfig:GlueBelow(input, window, 0, 40, 'CENTER')

input.button:HookScript("OnClick", function(self)
local npcID = tonumber(self.editBox:GetText()) -- convert to number as it's necessary
-- Add NPC function
local function addNPC(value)
local npcID = tonumber(value) -- convert to number as it's necessary

npcInfo.GetNPCInfoByID(
npcID,
Expand Down Expand Up @@ -189,6 +186,26 @@ local function buildWindow()
print('|cffea00ffS|r|cff00a2ffUI|r: NPC with ID \'' .. npcID .. '\' does not exist.')
end
)
end

-- Create Input Field
local input = SUIConfig:NumericBox(window, 150, 24, nil, function() end)
SUIConfig:GlueBelow(input, window, 0, 40, 'CENTER')

input.button:HookScript("OnClick", function(self)
-- Add NPC
addNPC(self.editBox:GetText())

-- Clear Input Field
self.editBox:SetValue('')
end)

input:HookScript("OnEnterPressed", function(self)
-- Add NPC
addNPC(self:GetText())

-- Clear Input Field
self:SetValue('')
end)

-- Input Field Label
Expand Down
6 changes: 0 additions & 6 deletions Libs/LibNPCInfo/LibNPCInfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,10 @@ end
-- -----------------------------------------------------
function lib.GetNPCInfoByID(npcID, callback, failedCallback)
if not npcID then
print("LibNPCInfo.GetNPCInfoByID: npcID is nil.")
return
end

if type(npcID) ~= "number" or callback and type(callback) ~= "function" then
print('LibNPCInfo.GetNPCInfoByID: "npcID" must be a number and "callback" must be a function or nil.')
return
end

Expand Down Expand Up @@ -156,8 +154,6 @@ function lib.GetNPCInfoByID(npcID, callback, failedCallback)

if failedCallback then
failedCallback(npcID)
else
print("LibNPCInfo.GetNPCInfoByID: failed to fetch data for npcID " .. npcID)
end
end
)
Expand All @@ -179,12 +175,10 @@ end
-- -----------------------------------------------------
function lib.GetNPCInfoWithIDTable(npcIDs, callback)
if not npcIDs then
print("LibNPCInfo.GetNPCInfoWithIDTable: npcIDs is nil.")
return
end

if type(npcIDs) ~= "table" or callback and type(callback) ~= "function" then
print('LibNPCInfo.GetNPCInfoWithIDTable: "npcIDs" must be a table and "callback" must be a function or nil.')
return
end

Expand Down
10 changes: 10 additions & 0 deletions Libs/SUIConfig/widgets/EditBox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ end
--- SearchEditBox
----------------------------------------------------

local NumericBoxEvents = {
OnEnterPressed = function(self)
self:Validate();
end
}

local NumericBoxMethods = {
SetMaxValue = function(self, value)
self.maxValue = value;
Expand Down Expand Up @@ -239,6 +245,10 @@ function SUIConfig:NumericBox(parent, width, height, text, validator)

button:SetScript('OnClick', EditBoxButtonOnClick);

for k, v in pairs(NumericBoxEvents) do
editBox:SetScript(k, v);
end

return editBox;
end

Expand Down

0 comments on commit 4dd618f

Please sign in to comment.