mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 21:01:39 +09:00
Adding game settings gui
This commit is contained in:
@@ -8,3 +8,140 @@ Discord: https://discord.gg/r6dC2uK
|
|||||||
]]
|
]]
|
||||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||||
|
|
||||||
|
--{type='slider',object='',key='',name='',min=x,max=y}
|
||||||
|
--{type='function',object='',key='',name='',param={}}
|
||||||
|
local basic_settings = {
|
||||||
|
-- mining
|
||||||
|
-- crafting
|
||||||
|
-- running
|
||||||
|
-- build distance
|
||||||
|
-- reach
|
||||||
|
-- bot speed
|
||||||
|
-- lab speed
|
||||||
|
-- stack bonus
|
||||||
|
}
|
||||||
|
|
||||||
|
local advanced_settings = {
|
||||||
|
-- hotbar count
|
||||||
|
-- inventory size
|
||||||
|
-- mining prog
|
||||||
|
-- game speed
|
||||||
|
-- force crc -function
|
||||||
|
-- save game -function
|
||||||
|
-- reset force -function
|
||||||
|
-- reload effects -function
|
||||||
|
-- kill bitters -function
|
||||||
|
-- re chart map -function
|
||||||
|
}
|
||||||
|
|
||||||
|
local personal_settings = {
|
||||||
|
-- craft speed
|
||||||
|
-- mining speed
|
||||||
|
-- running speed
|
||||||
|
-- build distance
|
||||||
|
-- reach distance
|
||||||
|
-- quick bar count
|
||||||
|
-- inventory slots
|
||||||
|
}
|
||||||
|
|
||||||
|
local _root_list = {basic_settings=basic_settings,advanced_settings=advanced_settings,personal_settings=personal_settings}
|
||||||
|
|
||||||
|
local function _get_data(root_frame)
|
||||||
|
local object = root_frame.name
|
||||||
|
local key = root_frame.setting_name.caption
|
||||||
|
local data = _root_list[object] and _root_list[object][key]
|
||||||
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _object_list(player) return {game=game,player=player,force=player.force} end
|
||||||
|
|
||||||
|
for name,group in pairs(_root_list) do
|
||||||
|
for key,setting in pairs(group) do
|
||||||
|
if key ~= '_loaded' and key ~= key then
|
||||||
|
local _added = nil
|
||||||
|
if setting.type == 'slider' then
|
||||||
|
_added = Gui.inputs.add_slider('game-settings-'..setting.name,'horizontal',setting.min,setting.max,
|
||||||
|
function(player,root_frame)
|
||||||
|
local data = _get_data(root_frame)
|
||||||
|
local objects = _object_list(player)
|
||||||
|
local object = objects[data.object]
|
||||||
|
return object[data.key] or nil
|
||||||
|
end,
|
||||||
|
function(player,value,percent,element)
|
||||||
|
local data = _get_data(element.parent)
|
||||||
|
local objects = _object_list(player)
|
||||||
|
local object = objects[data.object]
|
||||||
|
object[key] = value
|
||||||
|
element.parent.counter.caption = tostring(value)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
elseif setting.type == 'function' then
|
||||||
|
_added = Gui.add_check('game-settings-'..setting.name,true,nil,false,function(player,element)
|
||||||
|
local data = _get_data(element.parent)
|
||||||
|
local objects = _object_list(player)
|
||||||
|
local object = objects[data.object]
|
||||||
|
pcall(object[data.key],unpack(data.params))
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
setting._loaded = _added
|
||||||
|
setting._group = name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _draw_setting(frame,setting)
|
||||||
|
local frame = frame.add{
|
||||||
|
type='flow',
|
||||||
|
name=setting._group
|
||||||
|
}
|
||||||
|
frame.add{
|
||||||
|
type='label',
|
||||||
|
caption={'game-settings.effect-'..setting.name},
|
||||||
|
style='caption_label'
|
||||||
|
}
|
||||||
|
frame.add{
|
||||||
|
type='label',
|
||||||
|
caption=settings.name,
|
||||||
|
name='setting_name'
|
||||||
|
}
|
||||||
|
if setting.type == 'slider' then
|
||||||
|
local slider = setting._loaded:draw(frame)
|
||||||
|
frame.add{
|
||||||
|
type='label',
|
||||||
|
name='counter',
|
||||||
|
caption=tostring(slider.value)
|
||||||
|
}
|
||||||
|
elseif setting.type == 'function' then
|
||||||
|
setting._loaded:draw(frame)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Gui.center.add{
|
||||||
|
name='game-settings',
|
||||||
|
caption='utility/no_building_material_icon',
|
||||||
|
tooltip={'game-settings.tooltip'}
|
||||||
|
}:add_tab('basic',{'game-settings.basic-name'},{'game-settings.basic-name'},function(frame)
|
||||||
|
for _,setting in pairs(basic_settings) do
|
||||||
|
frame.add{
|
||||||
|
type='label',
|
||||||
|
caption={'game-settings.basic-message'}
|
||||||
|
}
|
||||||
|
_draw_setting(frame,setting)
|
||||||
|
end
|
||||||
|
end):add_tab('advanced',{'game-settings.advanced-name'},{'game-settings.advanced-tooltip'},function(frame)
|
||||||
|
for _,setting in pairs(advanced_settings) do
|
||||||
|
frame.add{
|
||||||
|
type='label',
|
||||||
|
caption={'game-settings.advanced-message'}
|
||||||
|
}
|
||||||
|
_draw_setting(frame,setting)
|
||||||
|
end
|
||||||
|
end):add_tab('personal',{'game-settings.personal-name'},{'game-settings.personal-tooltip'},function(frame)
|
||||||
|
for _,setting in pairs(personal_settings) do
|
||||||
|
frame.add{
|
||||||
|
type='label',
|
||||||
|
caption={'game-settings.personal-message'}
|
||||||
|
}
|
||||||
|
_draw_setting(frame,setting)
|
||||||
|
end
|
||||||
|
end)
|
||||||
12
locale/en/game-settings.cfg
Normal file
12
locale/en/game-settings.cfg
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[game-settings]
|
||||||
|
name=Game Settings
|
||||||
|
tooltip=Allows for editing of the game settings, please use resposibliy.
|
||||||
|
basic-name=Basic Settings
|
||||||
|
basic-tooltip=These settings are safe to change with no large effects.
|
||||||
|
basic-message=These settings are force wide settings which can be used to inprove gameplay and make it more enjoyible for players.
|
||||||
|
advanced-name=Advanced Settings
|
||||||
|
advanced-tooltip=These settings should be left alone unless you know what you are doing.
|
||||||
|
advanced-message=Please do not touch these settings at all unless you know 100% what they do and the effect of using them, leave game.speed alone it has a bigger effect then you think.
|
||||||
|
personal-name=Personal Settings
|
||||||
|
personal-tooltip=These will only effect you, if you are spoted you are on your own.
|
||||||
|
personal-message=These settings will only effect your player any changes you make are to be resposible ones and dont over do it or you may be caught using them.
|
||||||
Reference in New Issue
Block a user