mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 12:01:50 +00:00
add app.start_background_instance (test)
This commit is contained in:
parent
052ae41271
commit
7f813d2eb1
3 changed files with 27 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "interfaces/Serializable.hpp"
|
#include "interfaces/Serializable.hpp"
|
||||||
|
#include "io/path.hpp"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -21,6 +22,7 @@ struct Permissions {
|
||||||
struct Project : Serializable {
|
struct Project : Serializable {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string title;
|
std::string title;
|
||||||
|
io::path path;
|
||||||
std::vector<std::string> basePacks;
|
std::vector<std::string> basePacks;
|
||||||
Permissions permissions;
|
Permissions permissions;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -380,6 +380,7 @@ void Engine::loadAssets() {
|
||||||
void Engine::loadProject() {
|
void Engine::loadProject() {
|
||||||
io::path projectFile = "project:project.toml";
|
io::path projectFile = "project:project.toml";
|
||||||
project = std::make_unique<Project>();
|
project = std::make_unique<Project>();
|
||||||
|
project->path = "project:";
|
||||||
project->deserialize(io::read_object(projectFile));
|
project->deserialize(io::read_object(projectFile));
|
||||||
logger.info() << "loaded project " << util::quote(project->name);
|
logger.info() << "loaded project " << util::quote(project->name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -366,11 +366,33 @@ static int l_start_debug_instance(lua::State* L) {
|
||||||
platform::new_engine_instance(
|
platform::new_engine_instance(
|
||||||
std::move(args),
|
std::move(args),
|
||||||
outputPath.empty() ? "" : io::resolve(std::string(outputPath)),
|
outputPath.empty() ? "" : io::resolve(std::string(outputPath)),
|
||||||
true // debug instance may be detached
|
false
|
||||||
);
|
);
|
||||||
return lua::pushinteger(L, port);
|
return lua::pushinteger(L, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_start_background_instance(lua::State* L) {
|
||||||
|
auto scriptPath = lua::require_lstring(L, 1);
|
||||||
|
io::path outputPath = "user:background.log"; // TODO:
|
||||||
|
const auto& paths = engine->getPaths();
|
||||||
|
|
||||||
|
std::vector<std::string> args {
|
||||||
|
"--headless",
|
||||||
|
"--res", paths.getResourcesFolder().u8string(),
|
||||||
|
"--dir", paths.getUserFilesFolder().u8string(),
|
||||||
|
"--script", io::resolve(scriptPath).u8string(),
|
||||||
|
};
|
||||||
|
args.emplace_back("--project");
|
||||||
|
args.emplace_back(io::resolve(engine->getProject().path).u8string());
|
||||||
|
|
||||||
|
platform::new_engine_instance(
|
||||||
|
std::move(args),
|
||||||
|
outputPath.empty() ? "" : io::resolve(outputPath),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg applib[] = {
|
const luaL_Reg applib[] = {
|
||||||
/// content
|
/// content
|
||||||
{"is_content_loaded", lua::wrap<l_is_content_loaded>},
|
{"is_content_loaded", lua::wrap<l_is_content_loaded>},
|
||||||
|
|
@ -403,5 +425,6 @@ const luaL_Reg applib[] = {
|
||||||
{"get_version", lua::wrap<l_get_version>},
|
{"get_version", lua::wrap<l_get_version>},
|
||||||
{"create_memory_device", lua::wrap<l_create_memory_device>},
|
{"create_memory_device", lua::wrap<l_create_memory_device>},
|
||||||
{"start_debug_instance", lua::wrap<l_start_debug_instance>},
|
{"start_debug_instance", lua::wrap<l_start_debug_instance>},
|
||||||
|
{"start_background_instance", lua::wrap<l_start_background_instance>},
|
||||||
{nullptr, nullptr}
|
{nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue