mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Added function to reset radio buttons
This commit is contained in:
@@ -170,7 +170,7 @@ function inputs.add_elem_button(name,elem_type,tooltip,callback)
|
||||
end
|
||||
|
||||
--- Used to define a checkbox callback only on state_changed
|
||||
-- @usage Gui.inputs.add_checkbox('test','Test','Just for testing',function)
|
||||
-- @usage Gui.inputs.add_checkbox('test',false,'Just for testing',function,function,funvtion)
|
||||
-- @tparam string name the name of this button
|
||||
-- @tparam string the display for this button, either text or sprite path
|
||||
-- @tparam string tooltip the tooltip to show on the button
|
||||
@@ -206,6 +206,33 @@ function inputs.add_checkbox(name,radio,display,default,callback_true,callback_f
|
||||
return checkbox
|
||||
end
|
||||
|
||||
--- Used to reset the state of radio buttons, recomened to be called on_state_change to reset any radio buttons it is ment to work with.
|
||||
-- @usage Gui.inputs.reset_radio{radio1,radio2,...}
|
||||
-- @param elements can be a list of elements or a single element
|
||||
function inputs.reset_radio(elements)
|
||||
if #elements > 0 then
|
||||
for _,element in pairs(elements) do
|
||||
if element.valid then
|
||||
local _elements = Gui._get_data('inputs_'..element.type) or {}
|
||||
local _element = _elements[element.name]
|
||||
local state = false
|
||||
local success, err = pcall(_element.data._state,element.parent)
|
||||
if success then state = err else error(err) end
|
||||
element.state = state
|
||||
end
|
||||
end
|
||||
else
|
||||
if elements.valid then
|
||||
local _elements = Gui._get_data('inputs_'..elements.type) or {}
|
||||
local _element = _elements[elements.name]
|
||||
local state = false
|
||||
local success, err = pcall(_element.data._state,elements.parent)
|
||||
if success then state = err else error(err) end
|
||||
element.state = state
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return inputs
|
||||
--[[
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ function Ranking.give_rank(player,rank,by_player,tick)
|
||||
if not old_rank.group.name == 'Jail' then Ranking._presets().old[player.index] = rank.name end
|
||||
if defines.events.rank_change then
|
||||
script.raise_event(defines.events.rank_change,{
|
||||
name=defines.events.rank_change,
|
||||
tick=tick,
|
||||
player_index=player.index,
|
||||
by_player_name=by_player_name,
|
||||
|
||||
Reference in New Issue
Block a user