36fs::path app_deploy_cfg =
"app:/deploy/deploy.cfg";
37fs::path app_deploy_file =
"deploy/deploy.cfg";
38fs::path app_settings_cfg =
"app:/settings/settings.cfg";
39fs::path editor_cfg = fs::persistent_path() /
"unravel" /
"editor.cfg";
50 project_settings_ = {};
51 deploy_settings_ = {};
57 scr.unload_app_domain();
79 if(!fs::exists(project_path, err))
81 APPLOG_ERROR(
"Project directory doesn't exist {0}", project_path.string());
85 APPLOG_TRACE(
"Opening project directory {0}", project_path.string());
99 set_name(project_path.filename().string());
101 save_editor_settings();
113 load_project_settings();
114 save_project_settings(ctx);
116 load_deploy_settings();
117 save_deploy_settings();
120 auto scn = project_settings_.standalone.startup_scene;
168 if(fs::exists(project_path, err) && !fs::is_empty(project_path, err))
170 APPLOG_ERROR(
"Project directory already exists and is not empty {0}", project_path.string());
174 fs::create_directories(project_path, err);
178 APPLOG_ERROR(
"Failed to create project directory {0}", project_path.string());
187void project_manager::fixup_editor_settings_on_save()
194 if(std::find_if(std::begin(rp),
198 return project_path.generic_string() == prj;
201 rp.emplace_back(std::move(project_path));
204 std::sort(std::begin(rp),
206 [](
const auto& lhs_path,
const auto& rhs_path)
209 auto lhs_time = fs::last_write_time(lhs_path / app_deploy_file, ec);
210 auto rhs_time = fs::last_write_time(rhs_path / app_deploy_file, ec);
212 return lhs_time > rhs_time;
216void project_manager::fixup_editor_settings_on_load()
223 auto iter = std::begin(items);
224 while(iter != items.end())
228 if(!fs::exists(item, err))
230 iter = items.erase(iter);
243 const fs::path config = editor_cfg;
244 if(!fs::exists(config, err))
250 APPLOG_INFO(
"Loading editor settings {}", config.string());
253 fixup_editor_settings_on_load();
260 fixup_editor_settings_on_save();
263 fs::create_directories(editor_cfg.parent_path(), err);
265 const fs::path config = editor_cfg;
271 return project_name_;
276 project_name_ =
name;
281 return project_settings_;
286 return deploy_settings_;
291 return editor_settings_;
319 parser.
set_optional<std::string>(
"p",
"project",
"",
"Project folder to open.");
325 APPLOG_TRACE(
"{}::{}", hpp::type_name_str(*
this), __func__);
328 if(parser.try_get(
"project", project) && !project.empty())
330 if(project ==
"recent")
332 const auto& items = editor_settings_.projects.recent_projects;
335 fs::path project_path = items.front();
336 return open_project(ctx, project_path);
341 fs::path project_path = project;
342 return open_project(ctx, project_path);
351 APPLOG_TRACE(
"{}::{}", hpp::type_name_str(*
this), __func__);
void set_optional(const std::string &name, const std::string &alternative, T defaultValue, const std::string &description="", bool dominant=false)
void watch_assets(rtti::context &ctx, const std::string &protocol, bool wait=false)
void unwatch_assets(rtti::context &ctx, const std::string &protocol)
void save_editor_settings()
void load_editor_settings()
auto init(rtti::context &ctx, const cmd_line::parser &parser) -> bool
auto get_deploy_settings() -> deploy_settings &
project_manager(rtti::context &ctx, cmd_line::parser &parser)
void save_deploy_settings()
void load_project_settings()
void set_name(const std::string &name)
auto has_open_project() const -> bool
auto get_editor_settings() -> editor_settings &
auto open_project(rtti::context &ctx, const fs::path &project_path) -> bool
void load_deploy_settings()
auto deinit(rtti::context &ctx) -> bool
void create_project(rtti::context &ctx, const fs::path &project_path)
auto get_settings() -> settings &
void save_project_settings(rtti::context &ctx)
auto get_name() const -> const std::string &
void close_project(rtti::context &ctx)
#define APPLOG_ERROR(...)
#define APPLOG_TRACE(...)
auto get_data_directory(const std::string &prefix={}) -> std::string
auto get_compiled_directory(const std::string &prefix={}) -> std::string
auto get_meta_directory(const std::string &prefix={}) -> std::string
bool add_path_protocol(const std::string &protocol, const path &dir)
Allows us to map a protocol to a specific directory. A path protocol gives the caller the ability to ...
path resolve_protocol(const path &_path)
Given the specified path/filename, resolve the final full filename. This will be based on either the ...
auto atomic_save_to_file(const fs::path &key, const asset_handle< T > &obj) -> bool
void load_from_file(const std::string &absolute_path, animation_clip &obj)
auto add(Args &&... args) -> T &
Manages the entity-component-system (ECS) operations for the ACE framework.
void unload_scene()
Unloads the current scene.
static auto open_scene_from_asset(rtti::context &ctx, const asset_handle< scene_prefab > &asset) -> bool
static auto new_scene(rtti::context &ctx) -> bool
static void generate_script_workspace()
std::vector< fs::path > recent_projects
struct unravel::editor_settings::projects_settings projects
struct unravel::editor_settings::debugger_settings debugger
hpp::event< void(rtti::context &, const std::string &protocol, uint64_t version)> on_script_recompile
void set_debug_config(const std::string &address, uint32_t port, uint32_t loglevel)
auto load_app_domain(rtti::context &ctx, bool recompile) -> bool