mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 05:21:49 +00:00
remove settings-related functions from core
This commit is contained in:
parent
5260062181
commit
a6301c8837
14 changed files with 119 additions and 120 deletions
|
|
@ -1,7 +1,7 @@
|
|||
function on_open()
|
||||
document.langs_btn.text = string.format(
|
||||
"%s: %s", gui.str("Language", "settings"),
|
||||
gui.get_locales_info()[core.get_setting("ui.language")].name
|
||||
gui.get_locales_info()[app.get_setting("ui.language")].name
|
||||
)
|
||||
sections = RadioGroup({
|
||||
audio=document.s_aud,
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
function create_setting(id, name, step, postfix)
|
||||
local info = core.get_setting_info(id)
|
||||
local info = app.get_setting_info(id)
|
||||
postfix = postfix or ""
|
||||
document.root:add(gui.template("track_setting", {
|
||||
id=id,
|
||||
name=gui.str(name, "settings"),
|
||||
value=core.get_setting(id),
|
||||
value=app.get_setting(id),
|
||||
min=info.min,
|
||||
max=info.max,
|
||||
step=step,
|
||||
postfix=postfix
|
||||
}))
|
||||
update_setting(core.get_setting(id), id, name, postfix)
|
||||
update_setting(app.get_setting(id), id, name, postfix)
|
||||
end
|
||||
|
||||
function update_setting(x, id, name, postfix)
|
||||
core.set_setting(id, x)
|
||||
app.set_setting(id, x)
|
||||
-- updating label
|
||||
document[id..".L"].text = string.format(
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
core.str_setting(id),
|
||||
app.str_setting(id),
|
||||
postfix
|
||||
)
|
||||
end
|
||||
|
|
@ -54,7 +54,7 @@ function on_open()
|
|||
create_setting("audio.volume-music", "Music", 0.01)
|
||||
document.root:add("<label context='settings'>@Microphone</label>")
|
||||
document.root:add("<select id='input_device_select' "..
|
||||
"onselect='function(opt) core.set_setting(\"audio.input-device\", opt) end'/>")
|
||||
"onselect='function(opt) app.set_setting(\"audio.input-device\", opt) end'/>")
|
||||
document.root:add("<container id='input_volume_outer' color='#000000' size='4'>"
|
||||
.."<container id='input_volume_inner' color='#00FF00FF' pos='1' size='2'/>"
|
||||
.."</container>")
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ function refresh_sensitivity()
|
|||
document.sensitivity_label.text = string.format(
|
||||
"%s: %s",
|
||||
gui.str("Mouse Sensitivity", "settings"),
|
||||
core.str_setting("camera.sensitivity")
|
||||
app.str_setting("camera.sensitivity")
|
||||
)
|
||||
end
|
||||
|
||||
function change_sensitivity(val)
|
||||
core.set_setting("camera.sensitivity", val)
|
||||
app.set_setting("camera.sensitivity", val)
|
||||
refresh_sensitivity()
|
||||
end
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ function refresh_binding_marks()
|
|||
end
|
||||
|
||||
function on_open()
|
||||
document.sensitivity_track.value = core.get_setting("camera.sensitivity")
|
||||
document.sensitivity_track.value = app.get_setting("camera.sensitivity")
|
||||
refresh_sensitivity()
|
||||
|
||||
local panel = document.bindings_panel
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ tostring_overrides["display.framerate"] = function(x)
|
|||
end
|
||||
|
||||
function create_setting(id, name, step, postfix, tooltip, changeonrelease)
|
||||
local info = core.get_setting_info(id)
|
||||
local info = app.get_setting_info(id)
|
||||
postfix = postfix or ""
|
||||
tooltip = tooltip or ""
|
||||
changeonrelease = changeonrelease or ""
|
||||
document.root:add(gui.template("track_setting", {
|
||||
id=id,
|
||||
name=gui.str(name, "settings"),
|
||||
value=core.get_setting(id),
|
||||
value=app.get_setting(id),
|
||||
min=info.min,
|
||||
max=info.max,
|
||||
step=step,
|
||||
|
|
@ -25,7 +25,7 @@ function create_setting(id, name, step, postfix, tooltip, changeonrelease)
|
|||
tooltip=tooltip,
|
||||
changeonrelease=changeonrelease
|
||||
}))
|
||||
update_setting(core.get_setting(id), id, name, postfix)
|
||||
update_setting(app.get_setting(id), id, name, postfix)
|
||||
end
|
||||
|
||||
function update_setting(x, id, name, postfix)
|
||||
|
|
@ -34,13 +34,13 @@ function update_setting(x, id, name, postfix)
|
|||
if func then
|
||||
str = func(x)
|
||||
else
|
||||
str = core.str_setting(id)
|
||||
str = app.str_setting(id)
|
||||
end
|
||||
-- updating label
|
||||
document[id..".L"].text = string.format(
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
str,
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
str,
|
||||
postfix
|
||||
)
|
||||
end
|
||||
|
|
@ -48,8 +48,8 @@ end
|
|||
function create_checkbox(id, name, tooltip)
|
||||
tooltip = tooltip or ''
|
||||
document.root:add(string.format(
|
||||
"<checkbox consumer='function(x) core.set_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
|
||||
id, core.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
|
||||
"<checkbox consumer='function(x) app.set_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
|
||||
id, app.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
|
||||
))
|
||||
end
|
||||
|
||||
|
|
@ -59,11 +59,11 @@ function on_open()
|
|||
create_setting("display.framerate", "Framerate", 1, "", "", true)
|
||||
|
||||
document.root:add(string.format(
|
||||
"<select context='settings' onselect='function(opt) core.set_setting(\"display.window-mode\", tonumber(opt)) end' selected='%s'>"..
|
||||
"<select context='settings' onselect='function(opt) app.set_setting(\"display.window-mode\", tonumber(opt)) end' selected='%s'>"..
|
||||
"<option value='0'>@Windowed</option>"..
|
||||
"<option value='1'>@Fullscreen</option>"..
|
||||
"<option value='2'>@Borderless</option>"..
|
||||
"</select>", core.get_setting("display.window-mode"))
|
||||
"</select>", app.get_setting("display.window-mode"))
|
||||
)
|
||||
|
||||
create_checkbox("camera.shaking", "Camera Shaking")
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
function create_setting(id, name, step, postfix, tooltip, changeonrelease)
|
||||
local info = core.get_setting_info(id)
|
||||
local info = app.get_setting_info(id)
|
||||
postfix = postfix or ""
|
||||
tooltip = tooltip or ""
|
||||
changeonrelease = changeonrelease or ""
|
||||
document.root:add(gui.template("track_setting", {
|
||||
id=id,
|
||||
name=gui.str(name, "settings"),
|
||||
value=core.get_setting(id),
|
||||
value=app.get_setting(id),
|
||||
min=info.min,
|
||||
max=info.max,
|
||||
step=step,
|
||||
|
|
@ -14,15 +14,15 @@ function create_setting(id, name, step, postfix, tooltip, changeonrelease)
|
|||
tooltip=tooltip,
|
||||
changeonrelease=changeonrelease
|
||||
}))
|
||||
update_setting(core.get_setting(id), id, name, postfix)
|
||||
update_setting(app.get_setting(id), id, name, postfix)
|
||||
end
|
||||
|
||||
function update_setting(x, id, name, postfix)
|
||||
-- updating label
|
||||
document[id..".L"].text = string.format(
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
core.str_setting(id),
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
app.str_setting(id),
|
||||
postfix
|
||||
)
|
||||
end
|
||||
|
|
@ -30,8 +30,8 @@ end
|
|||
function create_checkbox(id, name, tooltip)
|
||||
tooltip = tooltip or ''
|
||||
document.root:add(string.format(
|
||||
"<checkbox consumer='function(x) core.set_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
|
||||
id, core.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
|
||||
"<checkbox consumer='function(x) app.set_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
|
||||
id, app.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
|
||||
))
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ function reset(category)
|
|||
end
|
||||
|
||||
function reset_setting(name)
|
||||
core.set_setting(name, core.get_setting_info(name).def)
|
||||
app.set_setting(name, app.get_setting_info(name).def)
|
||||
end
|
||||
|
||||
function reset_audio()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
function on_open()
|
||||
local worlds = world.get_list()
|
||||
for _, info in ipairs(worlds) do
|
||||
local major, minor = core.get_version()
|
||||
local major, minor = app.get_version()
|
||||
if info.version[1] > major or info.version[2] > minor then
|
||||
info.versionColor = "#A02010"
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<button
|
||||
onclick='core.set_setting("ui.language", "%{id}") menu:back()'>
|
||||
onclick='app.set_setting("ui.language", "%{id}") menu:back()'>
|
||||
%{name}
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
<label id='%{id}.L' margin='0,3,0,0'>%{name}: %{value}%{postfix}</label>
|
||||
<trackbar
|
||||
value='%{value}' min='%{min}' max='%{max}' step='%{step}' tooltip='%{tooltip}'
|
||||
consumer='function(x) core.set_setting("%{id}", x) end' change-on-release='%{changeonrelease}'
|
||||
consumer='function(x) app.set_setting("%{id}", x) end' change-on-release='%{changeonrelease}'
|
||||
sub-consumer='function(x) update_setting(x, "%{id}", "%{name}", "%{postfix}") end'/>
|
||||
</panel>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ local function configure_SSAO()
|
|||
end
|
||||
events.on("core:setting.graphics.ssao.set", update_ssao_quality)
|
||||
|
||||
update_ssao_quality(core.get_setting("graphics.ssao"))
|
||||
update_ssao_quality(__vc_app.get_setting("graphics.ssao"))
|
||||
end
|
||||
|
||||
local function update_hand()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
local enable_experimental = core.get_setting("debug.enable-experimental")
|
||||
local enable_experimental = __vc_app.get_setting("debug.enable-experimental")
|
||||
|
||||
------------------------------------------------
|
||||
------ Extended kit of standard functions ------
|
||||
|
|
@ -24,12 +24,6 @@ function tb_frame_tostring(frame)
|
|||
return s
|
||||
end
|
||||
|
||||
local core_set_setting = core.set_setting
|
||||
function core.set_setting(name, value, ...)
|
||||
core_set_setting(name, value, ...)
|
||||
events.emit("core:setting."..name..".set", value)
|
||||
end
|
||||
|
||||
local __vc__app_script_coroutine
|
||||
|
||||
local function complete_app_lib(app)
|
||||
|
|
@ -37,6 +31,7 @@ local function complete_app_lib(app)
|
|||
local __core_reset_content = core.reset_content
|
||||
local __core_reconfig_packs = core.reconfig_packs
|
||||
local __app_tick = coroutine.yield
|
||||
local __app_set_setting = app.set_setting
|
||||
core.load_content = nil
|
||||
core.reset_content = nil
|
||||
|
||||
|
|
@ -48,10 +43,12 @@ local function complete_app_lib(app)
|
|||
app.close_world = core.close_world
|
||||
app.reopen_world = core.reopen_world
|
||||
app.delete_world = core.delete_world
|
||||
app.get_setting = core.get_setting
|
||||
app.set_setting = core.set_setting
|
||||
|
||||
app.set_setting = function(name, value, ...)
|
||||
__app_set_setting(name, value, ...)
|
||||
events.emit("core:setting."..name..".set", value)
|
||||
end
|
||||
app.tick = __app_tick
|
||||
app.get_setting_info = core.get_setting_info
|
||||
|
||||
local function call_in_app_script_co(func, ...)
|
||||
if coroutine.running() ~= __vc__app_script_coroutine then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue