mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 22:41:49 +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 function complete_app_lib(app)
|
||||||
local __core_load_content = core.load_content
|
local __core_load_content = core.load_content
|
||||||
local __core_reset_content = core.reset_content
|
local __core_reset_content = core.reset_content
|
||||||
|
local __core_reconfig_packs = core.reconfig_packs
|
||||||
local __app_tick = coroutine.yield
|
local __app_tick = coroutine.yield
|
||||||
core.load_content = nil
|
core.load_content = nil
|
||||||
core.reset_content = nil
|
core.reset_content = nil
|
||||||
|
|
@ -47,32 +48,31 @@ local function complete_app_lib(app)
|
||||||
app.close_world = core.close_world
|
app.close_world = core.close_world
|
||||||
app.reopen_world = core.reopen_world
|
app.reopen_world = core.reopen_world
|
||||||
app.delete_world = core.delete_world
|
app.delete_world = core.delete_world
|
||||||
app.reconfig_packs = core.reconfig_packs
|
|
||||||
app.get_setting = core.get_setting
|
app.get_setting = core.get_setting
|
||||||
app.set_setting = core.set_setting
|
app.set_setting = core.set_setting
|
||||||
app.tick = __app_tick
|
app.tick = __app_tick
|
||||||
app.get_version = core.get_version
|
app.get_version = core.get_version
|
||||||
app.get_setting_info = core.get_setting_info
|
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
|
if coroutine.running() ~= __vc__app_script_coroutine then
|
||||||
error("content must be reload in application script coroutine")
|
error("content must be reload in application script coroutine")
|
||||||
end
|
end
|
||||||
|
func(...)
|
||||||
|
__app_tick()
|
||||||
end
|
end
|
||||||
|
|
||||||
app.load_content = function()
|
app.reconfig_packs = function(...)
|
||||||
require_app_script_co()
|
call_in_app_script_co(__core_reconfig_packs, ...)
|
||||||
__core_load_content()
|
|
||||||
__app_tick()
|
|
||||||
end
|
end
|
||||||
app.reset_content = function()
|
app.load_content = function(...)
|
||||||
require_app_script_co()
|
call_in_app_script_co(__core_load_content, ...)
|
||||||
__core_reset_content()
|
end
|
||||||
__app_tick()
|
app.reset_content = function(...)
|
||||||
|
call_in_app_script_co(__core_reset_content, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
app.is_content_loaded = core.is_content_loaded
|
app.is_content_loaded = core.is_content_loaded
|
||||||
app.set_title = core.set_title
|
|
||||||
|
|
||||||
function app.config_packs(packs_list)
|
function app.config_packs(packs_list)
|
||||||
-- Check if packs are valid and add dependencies to the configuration
|
-- Check if packs are valid and add dependencies to the configuration
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,12 @@ static int l_reset_content_sources(lua::State* L) {
|
||||||
return 0;
|
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[] = {
|
const luaL_Reg applib[] = {
|
||||||
{"start_debug_instance", lua::wrap<l_start_debug_instance>},
|
{"start_debug_instance", lua::wrap<l_start_debug_instance>},
|
||||||
{"focus", lua::wrap<l_focus>},
|
{"focus", lua::wrap<l_focus>},
|
||||||
|
|
@ -103,6 +109,7 @@ const luaL_Reg applib[] = {
|
||||||
{"get_content_sources", lua::wrap<l_get_content_sources>},
|
{"get_content_sources", lua::wrap<l_get_content_sources>},
|
||||||
{"set_content_sources", lua::wrap<l_set_content_sources>},
|
{"set_content_sources", lua::wrap<l_set_content_sources>},
|
||||||
{"reset_content_sources", lua::wrap<l_reset_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
|
// for other functions see libcore.cpp and stdlib.lua
|
||||||
{nullptr, nullptr}
|
{nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -300,12 +300,6 @@ static int l_capture_output(lua::State* L) {
|
||||||
return 1;
|
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[] = {
|
const luaL_Reg corelib[] = {
|
||||||
{"blank", lua::wrap<l_blank>},
|
{"blank", lua::wrap<l_blank>},
|
||||||
{"get_version", lua::wrap<l_get_version>},
|
{"get_version", lua::wrap<l_get_version>},
|
||||||
|
|
@ -327,6 +321,5 @@ const luaL_Reg corelib[] = {
|
||||||
{"open_url", lua::wrap<l_open_url>},
|
{"open_url", lua::wrap<l_open_url>},
|
||||||
{"quit", lua::wrap<l_quit>},
|
{"quit", lua::wrap<l_quit>},
|
||||||
{"capture_output", lua::wrap<l_capture_output>},
|
{"capture_output", lua::wrap<l_capture_output>},
|
||||||
{"set_title", lua::wrap<l_set_title>},
|
|
||||||
{nullptr, nullptr}
|
{nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue