remove __vc_app global variable

This commit is contained in:
MihailRis 2026-04-26 23:30:11 +03:00
parent 678e5db03d
commit ab179881e8
5 changed files with 63 additions and 64 deletions

View file

@ -1,4 +1,5 @@
local enable_experimental = __vc_app.get_setting("debug.enable-experimental")
local __app = __vc_app
local enable_experimental = __app.get_setting("debug.enable-experimental")
------------------------------------------------
------ Extended kit of standard functions ------
@ -119,12 +120,7 @@ local function complete_app_lib(app)
end
end
if app then
complete_app_lib(app)
elseif __vc_app then
complete_app_lib(__vc_app)
end
complete_app_lib(__app)
require "core:internal/maths_inline"
require "core:internal/debugging"
require "core:internal/audio_input"
@ -175,18 +171,18 @@ function start_coroutine(chunk, name)
local co = coroutine.create(function()
local status, error = xpcall(chunk, function(err)
local fullmsg = "error: "..string.match(err, ": (.+)").."\n"..debug.traceback()
if hud then
gui.alert(fullmsg, function()
if world.is_open() then
__vc_app.close_world()
else
__vc_app.reset_content()
menu:reset()
menu.page = "main"
end
end)
if vc.is_headless() then
return fullmsg
end
gui.alert(fullmsg, function()
if world.is_open() then
__app.close_world()
else
__app.reset_content()
menu:reset()
menu.page = "main"
end
end)
return fullmsg
end)
if not status then
@ -204,7 +200,7 @@ function __vc_start_app_script(path, name)
if chunk == nil then
error(err)
end
local script_env = setmetatable({app = app or __vc_app}, {__index=_G})
local script_env = setmetatable({app = __app}, {__index=_G})
chunk = setfenv(chunk, script_env)
if name then
start_coroutine(chunk, name)
@ -222,7 +218,7 @@ gui_util = require "core:internal/gui_util"
Document = gui_util.Document
Element = gui_util.Element
RadioGroup = gui_util.RadioGroup
__vc_page_loader = gui_util.load_page
__vc_page_loader = function(...) return gui_util.load_page(__app, ...) end
function __vc_get_document_node(docname, nodeid)
return Element.new(docname, nodeid)
@ -384,6 +380,40 @@ math.randomseed(time.uptime() * 1536227939)
rules = require "core:internal/rules"
local _rules = rules
local function configure_SSAO()
-- Temporary using slot to configure built-in SSAO effect
local slot = gfx.posteffects.index("core:ssao")
gfx.posteffects.set_effect(slot, "ssao")
-- Generating random SSAO samples
local buffer = Bytearray(0)
for i = 0, 63 do
local x = math.random() * 2.0 - 1.0
local y = math.random() * 2.0 - 1.0
local z = math.random() * 2.0
local len = math.sqrt(x * x + y * y + z * z)
if len > 0 then
x = x / len
y = y / len
z = z / len
end
Bytearray.append(buffer, byteutil.pack("fff", x, y, z))
end
gfx.posteffects.set_array(slot, "u_ssaoSamples", Bytearray_as_string(buffer))
local function update_ssao_quality(value)
value = math.min(value, 3)
gfx.posteffects.set_params(slot, {
u_kernelSize = value * 16,
u_radius = 0.4 / value,
u_bias = 0.006 / value / value,
})
end
events.on("core:setting.graphics.ssao.set", update_ssao_quality)
update_ssao_quality(__app.get_setting("graphics.ssao"))
end
function __vc_on_hud_open()
local _hud_is_content_access = hud._is_content_access
local _hud_set_content_access = hud._set_content_access
@ -446,6 +476,8 @@ function __vc_on_hud_open()
end
end)
hud.open_permanent("core:ingame_chat")
configure_SSAO()
end
local Schedule = require "core:schedule"
@ -590,4 +622,5 @@ end
require "core:internal/deprecated"
ffi = nil
__vc_app = nil
__vc_lock_internal_modules()