BaseUI: Clearing the context is now an optional parameter & edit /list command. close #33

This commit is contained in:
Van
2026-03-02 19:54:22 +03:00
parent 1a6086190e
commit 692105abfa
3 changed files with 28 additions and 14 deletions

View File

@@ -2,9 +2,15 @@ local BaseUI, Formspec = Smc.requireBaseUI(), Smc.requireFormspec()
---@param self BaseUI
---@param playerName string
---@param isSelect boolean
---@param isSelect boolean?
---@return string
local function getFormSpecString(self, playerName, isSelect)
if isSelect == nil and self:getContex(playerName, 'select_item') ~= nil then
isSelect = true
else
isSelect = false
end
local items = {}
for name, def in pairs(core.registered_items) do
@@ -58,9 +64,9 @@ local function getFormSpecString(self, playerName, isSelect)
end
---@class AdminListUI : BaseUI
---@field getFormSpecString fun(self:BaseUI,playerName:string,isSelect:boolean):string
---@field showForm fun(self:BaseUI,playerName:string,isSelect:boolean):string
local AdminListUI = BaseUI:new('admin_commands:list_form', getFormSpecString)
---@field getFormSpecString fun(self:BaseUI,playerName:string,isSelect:boolean?):string
---@field showForm fun(self:BaseUI,playerName:string,isSelect:boolean?):string
local AdminListUI = BaseUI:new('admin_commands:list_form', getFormSpecString, false)
AdminListUI:registerOnFormFieldAction('admin_commands:list_items', function(player, fieldName, fieldValue)
local scrollValue = string.match(fieldValue, 'CHG:(%S+)')