mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
remove core.set_title & fix app.reset_content args & update app.reconfig_packs
This commit is contained in:
parent
9d4a48096e
commit
43fa181398
3 changed files with 20 additions and 20 deletions
|
|
@ -35,6 +35,7 @@ local __vc__app_script_coroutine
|
|||
local function complete_app_lib(app)
|
||||
local __core_load_content = core.load_content
|
||||
local __core_reset_content = core.reset_content
|
||||
local __core_reconfig_packs = core.reconfig_packs
|
||||
local __app_tick = coroutine.yield
|
||||
core.load_content = nil
|
||||
core.reset_content = nil
|
||||
|
|
@ -47,37 +48,36 @@ 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.reconfig_packs = core.reconfig_packs
|
||||
app.get_setting = core.get_setting
|
||||
app.set_setting = core.set_setting
|
||||
app.tick = __app_tick
|
||||
app.get_version = core.get_version
|
||||
app.get_setting_info = core.get_setting_info
|
||||
|
||||
local function require_app_script_co()
|
||||
local function call_in_app_script_co(func, ...)
|
||||
if coroutine.running() ~= __vc__app_script_coroutine then
|
||||
error("content must be reload in application script coroutine")
|
||||
end
|
||||
func(...)
|
||||
__app_tick()
|
||||
end
|
||||
|
||||
app.load_content = function()
|
||||
require_app_script_co()
|
||||
__core_load_content()
|
||||
__app_tick()
|
||||
app.reconfig_packs = function(...)
|
||||
call_in_app_script_co(__core_reconfig_packs, ...)
|
||||
end
|
||||
app.reset_content = function()
|
||||
require_app_script_co()
|
||||
__core_reset_content()
|
||||
__app_tick()
|
||||
app.load_content = function(...)
|
||||
call_in_app_script_co(__core_load_content, ...)
|
||||
end
|
||||
app.reset_content = function(...)
|
||||
call_in_app_script_co(__core_reset_content, ...)
|
||||
end
|
||||
|
||||
app.is_content_loaded = core.is_content_loaded
|
||||
app.set_title = core.set_title
|
||||
|
||||
|
||||
function app.config_packs(packs_list)
|
||||
-- Check if packs are valid and add dependencies to the configuration
|
||||
packs_list = pack.assemble(packs_list)
|
||||
|
||||
|
||||
local installed = pack.get_installed()
|
||||
local toremove = {}
|
||||
for _, packid in ipairs(installed) do
|
||||
|
|
|
|||
|
|
@ -96,6 +96,12 @@ static int l_reset_content_sources(lua::State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int l_set_title(lua::State* L) {
|
||||
auto title = lua::require_string(L, 1);
|
||||
engine->getWindow().setTitle(title);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg applib[] = {
|
||||
{"start_debug_instance", lua::wrap<l_start_debug_instance>},
|
||||
{"focus", lua::wrap<l_focus>},
|
||||
|
|
@ -103,6 +109,7 @@ const luaL_Reg applib[] = {
|
|||
{"get_content_sources", lua::wrap<l_get_content_sources>},
|
||||
{"set_content_sources", lua::wrap<l_set_content_sources>},
|
||||
{"reset_content_sources", lua::wrap<l_reset_content_sources>},
|
||||
{"set_title", lua::wrap<l_set_title>},
|
||||
// for other functions see libcore.cpp and stdlib.lua
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -300,12 +300,6 @@ static int l_capture_output(lua::State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int l_set_title(lua::State* L) {
|
||||
auto title = lua::require_string(L, 1);
|
||||
engine->getWindow().setTitle(title);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg corelib[] = {
|
||||
{"blank", lua::wrap<l_blank>},
|
||||
{"get_version", lua::wrap<l_get_version>},
|
||||
|
|
@ -327,6 +321,5 @@ const luaL_Reg corelib[] = {
|
|||
{"open_url", lua::wrap<l_open_url>},
|
||||
{"quit", lua::wrap<l_quit>},
|
||||
{"capture_output", lua::wrap<l_capture_output>},
|
||||
{"set_title", lua::wrap<l_set_title>},
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue