20#include <filedialog/filedialog.h>
36auto get_vscode_executable() -> fs::path
38 fs::path executablePath;
40#if UNRAVEL_PLATFORM_WINDOWS
45 std::vector<fs::path> possiblePaths = {
"C:\\Program Files\\Microsoft VS Code\\Code.exe",
46 "C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe",
47 fs::path(std::getenv(
"LOCALAPPDATA")) /
"Programs" /
48 "Microsoft VS Code" /
"Code.exe"};
50 for(
const auto& path : possiblePaths)
54 executablePath = path;
59 if(executablePath.empty())
62 const char* pathEnv = std::getenv(
"PATH");
65 std::string pathEnvStr(pathEnv);
66 std::stringstream ss(pathEnvStr);
68 while(std::getline(ss, token,
';'))
70 fs::path codePath = fs::path(token) /
"Code.exe";
71 if(fs::exists(codePath))
73 executablePath = codePath;
80 if(executablePath.empty())
82 std::vector<fs::path> directoriesToSearch = {
"C:\\Program Files",
83 "C:\\Program Files (x86)",
84 fs::path(std::getenv(
"LOCALAPPDATA")) /
"Programs"};
86 for(
const auto& dir : directoriesToSearch)
90 for(
const auto&
entry : fs::recursive_directory_iterator(dir))
92 if(
entry.is_regular_file() &&
entry.path().filename() ==
"Code.exe")
94 executablePath =
entry.path();
98 if(!executablePath.empty())
103 catch(
const fs::filesystem_error&)
111 catch(
const std::exception& e)
113 std::cerr <<
"Error finding VSCode executable path on Windows: " <<
e.what() << std::endl;
116#elif UNRAVEL_PLATFORM_OSX
121 std::vector<fs::path> possibleAppPaths = {
"/Applications/Visual Studio Code.app",
122 "/Applications/Visual Studio Code - Insiders.app",
123 fs::path(std::getenv(
"HOME")) /
"Applications" /
124 "Visual Studio Code.app"};
126 for(
const auto& appPath : possibleAppPaths)
128 if(fs::exists(appPath))
131 fs::path codeExecutable = appPath /
"Contents" /
"MacOS" /
"Electron";
132 if(fs::exists(codeExecutable))
134 executablePath = codeExecutable;
140 if(executablePath.empty())
143 std::vector<fs::path> possibleLinks = {
"/usr/local/bin/code",
"/usr/bin/code"};
144 for(
const auto& linkPath : possibleLinks)
146 if(fs::exists(linkPath))
149 executablePath = fs::canonical(linkPath);
155 if(executablePath.empty())
158 const char* pathEnv = std::getenv(
"PATH");
161 std::string pathEnvStr(pathEnv);
162 std::stringstream ss(pathEnvStr);
164 while(std::getline(ss, token,
':'))
166 fs::path codePath = fs::path(token) /
"code";
167 if(fs::exists(codePath))
169 executablePath = fs::canonical(codePath);
176 catch(
const std::exception& e)
178 std::cerr <<
"Error finding VSCode executable path on macOS: " <<
e.what() << std::endl;
181#elif UNRAVEL_PLATFORM_LINUX
186 const char* pathEnv = std::getenv(
"PATH");
189 std::string pathEnvStr(pathEnv);
190 std::stringstream ss(pathEnvStr);
192 while(std::getline(ss, token,
':'))
194 fs::path codePath = fs::path(token) /
"code";
195 if(fs::exists(codePath) && fs::is_regular_file(codePath))
198 executablePath = fs::canonical(codePath);
204 if(executablePath.empty())
207 std::vector<fs::path> possiblePaths = {
211 "/usr/share/code/bin/code",
212 "/usr/share/code-insiders/bin/code",
213 "/usr/local/share/code/bin/code",
214 "/opt/visual-studio-code/bin/code",
215 "/var/lib/flatpak/app/com.visualstudio.code/current/active/files/bin/code",
216 fs::path(std::getenv(
"HOME")) /
".vscode" /
"bin" /
"code"};
218 for(
const auto& path : possiblePaths)
222 executablePath = path;
228 catch(
const std::exception& e)
230 std::cerr <<
"Error finding VSCode executable path on Linux: " <<
e.what() << std::endl;
234#error "Unsupported operating system."
237 return executablePath;
240void remove_extensions(std::vector<std::vector<std::string>>& resourceExtensions,
241 const std::vector<std::string>& extsToRemove)
244 std::unordered_set<std::string> extsToRemoveSet;
245 for(
const auto& ext : extsToRemove)
250 for(
auto outerIt = resourceExtensions.begin(); outerIt != resourceExtensions.end();)
252 std::vector<std::string>& innerVec = *outerIt;
254 innerVec.erase(std::remove_if(innerVec.begin(),
256 [&extsToRemoveSet](
const std::string& ext)
258 return extsToRemoveSet.find(string_utils::to_lower(ext)) !=
259 extsToRemoveSet.end();
265 outerIt = resourceExtensions.erase(outerIt);
273void generate_workspace_file(
const std::string& file_path,
274 const std::vector<std::vector<std::string>>& exclude_extensions,
275 const editor_settings& settings)
278 std::ostringstream json_stream;
280 json_stream <<
"{\n";
281 json_stream <<
" \"folders\": [\n";
282 json_stream <<
" {\n";
283 json_stream <<
" \"path\": \"..\"\n";
284 json_stream <<
" }\n";
285 json_stream <<
" ],\n";
286 json_stream <<
" \"settings\": {\n";
287 json_stream <<
" \"dotnet.preferCSharpExtension\": true,\n";
288 json_stream <<
" \"files.exclude\": {\n";
289 json_stream <<
" \"**/.git\": true,\n";
290 json_stream <<
" \"**/.svn\": true";
293 for(
const auto& extensions : exclude_extensions)
295 for(
const auto& ext : extensions)
300 std::string pattern =
"**/*" + ext;
303 json_stream <<
",\n";
304 json_stream <<
" \"" << pattern <<
"\": true";
310 json_stream <<
" }\n";
311 json_stream <<
" }\n";
314 json_stream <<
",\n";
315 json_stream <<
" \"extensions\": {\n";
316 json_stream <<
" \"recommendations\": [\n";
317 json_stream <<
" \"ms-vscode.mono-debug\",\n";
318 json_stream <<
" \"ms-dotnettools.csharp\"\n";
319 json_stream <<
" ]\n";
320 json_stream <<
" }\n";
323 json_stream <<
",\n";
324 json_stream <<
" \"launch\": {\n";
325 json_stream <<
" \"version\": \"0.2.0\",\n";
326 json_stream <<
" \"configurations\": [\n";
327 json_stream <<
" {\n";
328 json_stream <<
" \"name\": \"Attach to Mono\",\n";
329 json_stream <<
" \"request\": \"attach\",\n";
330 json_stream <<
" \"type\": \"mono\",\n";
331 json_stream <<
" \"address\": \"" << settings.debugger.ip <<
"\",\n";
332 json_stream <<
" \"port\": " << settings.debugger.port <<
"\n";
333 json_stream <<
" }\n";
334 json_stream <<
" ]\n";
335 json_stream <<
" }\n";
341 std::ofstream file(file_path);
344 file << json_stream.str();
361void generate_csproj(
const fs::path& source_directory,
362 const std::vector<fs::path>& external_dll_paths,
363 const fs::path& output_directory,
364 const std::string& project_name =
"MyLibrary",
365 const std::string& dotnet_sdk_version =
"7.0")
370 fs::create_directories(output_directory);
372 catch(
const fs::filesystem_error& e)
374 throw std::runtime_error(
"Failed to create output directory: " + std::string(
e.what()));
378 if(!fs::exists(source_directory) || !fs::is_directory(source_directory))
380 throw std::runtime_error(
"Source directory does not exist or is not a directory: " + source_directory.string());
384 for(
const auto& dll_path : external_dll_paths)
386 if(!fs::exists(dll_path) || !fs::is_regular_file(dll_path))
388 throw std::runtime_error(
"External DLL does not exist or is not a file: " + dll_path.string());
393 std::vector<fs::path> csharp_sources;
396 for(
const auto&
entry : fs::recursive_directory_iterator(source_directory))
398 if(
entry.is_regular_file() &&
entry.path().extension() ==
".cs")
401 fs::path relative_path = fs::relative(
entry.path(), source_directory);
402 csharp_sources.push_back(relative_path);
406 catch(
const fs::filesystem_error& e)
408 throw std::runtime_error(
"Error while iterating source directory: " + std::string(
e.what()));
412 std::string csharp_source_items;
413 for(
const auto& source_file : csharp_sources)
416 std::string source_file_str = source_file.string();
417 fs::path full_physical_path = fs::absolute(source_directory / source_file);
418 std::string full_physical_path_str = full_physical_path.string();
421 csharp_source_items +=
" <Compile Include=\"" + full_physical_path_str +
"\">\n";
422 csharp_source_items +=
" <Link>" + source_file_str +
"</Link>\n";
423 csharp_source_items +=
" </Compile>\n";
427 std::string external_dll_references;
428 for(
const auto& dll_path : external_dll_paths)
430 std::string dll_name = dll_path.filename().string();
431 fs::path dll_absolute_path = fs::absolute(dll_path);
432 std::string dll_absolute_path_str = dll_absolute_path.string();
434 external_dll_references +=
" <Reference Include=\"" + dll_name +
"\">\n";
435 external_dll_references +=
" <HintPath>" + dll_absolute_path_str +
"</HintPath>\n";
436 external_dll_references +=
" </Reference>\n";
440 std::string csproj_content;
441 csproj_content +=
"<Project Sdk=\"Microsoft.NET.Sdk\">\n";
442 csproj_content +=
" <PropertyGroup>\n";
443 csproj_content +=
" <TargetFramework>net" + dotnet_sdk_version +
"</TargetFramework>\n";
444 csproj_content +=
" <OutputType>Library</OutputType>\n";
446 " <EnableDefaultCompileItems>false</EnableDefaultCompileItems>\n";
447 csproj_content +=
" </PropertyGroup>\n";
448 csproj_content +=
" <ItemGroup>\n";
449 csproj_content += csharp_source_items;
450 csproj_content +=
" </ItemGroup>\n";
451 csproj_content +=
" <ItemGroup>\n";
452 csproj_content += external_dll_references;
453 csproj_content +=
" </ItemGroup>\n";
454 csproj_content +=
"</Project>\n";
457 fs::path csproj_path = output_directory / (project_name +
".csproj");
460 std::ofstream csproj_file(csproj_path);
461 if(!csproj_file.is_open())
463 APPLOG_ERROR(
"Failed to create .csproj file at {}", csproj_path.string());
467 csproj_file << csproj_content;
472void generate_csproj_legacy(
const fs::path& source_directory,
473 const std::vector<fs::path>& external_dll_paths,
474 const fs::path& output_directory,
475 const std::string& project_name =
"MyLibrary",
476 const std::string& dotnet_framework_version =
"v4.7.1")
479 fs::path output_path = fs::path(
"temp") /
"bin" /
"Debug";
480 fs::path intermediate_output_path = fs::path(
"temp") /
"obj" /
"Debug";
485 fs::create_directories(output_directory);
487 catch(
const fs::filesystem_error& e)
489 throw std::runtime_error(
"Failed to create output directory: " + std::string(
e.what()));
493 if(!fs::exists(source_directory) || !fs::is_directory(source_directory))
495 throw std::runtime_error(
"Source directory does not exist or is not a directory: " + source_directory.string());
499 for(
const auto& dll_path : external_dll_paths)
501 if(!fs::exists(dll_path) || !fs::is_regular_file(dll_path))
503 throw std::runtime_error(
"External DLL does not exist or is not a file: " + dll_path.string());
508 std::vector<fs::path> csharp_sources;
511 for(
const auto&
entry : fs::recursive_directory_iterator(source_directory))
513 if(
entry.is_regular_file() &&
entry.path().extension() ==
".cs")
516 fs::path relative_path = fs::relative(
entry.path(), output_directory);
517 csharp_sources.push_back(relative_path);
521 catch(
const fs::filesystem_error& e)
523 throw std::runtime_error(
"Error while iterating source directory: " + std::string(
e.what()));
527 std::string csharp_source_items;
528 for(
const auto& source_file : csharp_sources)
531 std::string source_file_str = source_file.string();
532 csharp_source_items +=
" <Compile Include=\"" + source_file_str +
"\" />\n";
536 std::string external_dll_references;
537 for(
const auto& dll_path : external_dll_paths)
539 std::string dll_name = dll_path.filename().string();
540 fs::path dll_absolute_path = fs::absolute(dll_path);
541 std::string dll_absolute_path_str = dll_absolute_path.string();
543 external_dll_references +=
" <Reference Include=\"" + dll_name +
"\">\n";
544 external_dll_references +=
" <HintPath>" + dll_absolute_path_str +
"</HintPath>\n";
545 external_dll_references +=
" <Private>False</Private>\n";
546 external_dll_references +=
" </Reference>\n";
550 std::string csproj_content;
551 csproj_content +=
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
552 csproj_content +=
"<Project ToolsVersion=\"4.0\" DefaultTargets=\"Build\" "
553 "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n";
554 csproj_content +=
" <PropertyGroup>\n";
555 csproj_content +=
" <LangVersion>9.0</LangVersion>\n";
556 csproj_content +=
" </PropertyGroup>\n";
557 csproj_content +=
" <PropertyGroup>\n";
558 csproj_content +=
" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\n";
559 csproj_content +=
" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>\n";
560 csproj_content +=
" <ProductVersion>10.0.20506</ProductVersion>\n";
561 csproj_content +=
" <SchemaVersion>2.0</SchemaVersion>\n";
562 csproj_content +=
" <RootNamespace></RootNamespace>\n";
563 csproj_content +=
" <ProjectGuid>{" + hpp::to_string_upper(uid) +
"}</ProjectGuid>\n";
564 csproj_content +=
" <OutputType>Library</OutputType>\n";
565 csproj_content +=
" <AppDesignerFolder>Properties</AppDesignerFolder>\n";
566 csproj_content +=
" <AssemblyName>" + project_name +
"</AssemblyName>\n";
567 csproj_content +=
" <TargetFrameworkVersion>" + dotnet_framework_version +
"</TargetFrameworkVersion>\n";
568 csproj_content +=
" <FileAlignment>512</FileAlignment>\n";
569 csproj_content +=
" <BaseDirectory>.</BaseDirectory>\n";
570 csproj_content +=
" <OutputPath>" + output_path.string() +
"</OutputPath>\n";
572 " <IntermediateOutputPath>" + intermediate_output_path.string() +
"</IntermediateOutputPath>\n";
574 csproj_content +=
" </PropertyGroup>\n";
580 csproj_content +=
" <ItemGroup>\n";
581 csproj_content += csharp_source_items;
582 csproj_content +=
" </ItemGroup>\n";
585 csproj_content +=
" <ItemGroup>\n";
586 csproj_content += external_dll_references;
587 csproj_content +=
" </ItemGroup>\n";
593 csproj_content +=
" <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n";
596 csproj_content +=
" <Target Name=\"GenerateTargetFrameworkMonikerAttribute\" />\n";
600 " <!-- To modify your build process, add your task inside one of the targets below and uncomment it.\n";
601 csproj_content +=
" Other similar extension points exist, see Microsoft.Common.targets.\n";
602 csproj_content +=
" <Target Name=\"BeforeBuild\">\n";
603 csproj_content +=
" </Target>\n";
604 csproj_content +=
" <Target Name=\"AfterBuild\">\n";
605 csproj_content +=
" </Target>\n";
606 csproj_content +=
" -->\n";
608 csproj_content +=
"</Project>\n";
611 fs::path csproj_path = output_directory / (project_name +
".csproj");
614 std::ofstream csproj_file(csproj_path);
615 if(!csproj_file.is_open())
617 APPLOG_ERROR(
"Failed to create .csproj file at {}", csproj_path.string());
621 csproj_file << csproj_content;
626auto trim_line = [](std::string& line)
629 line.erase(std::find_if(line.rbegin(),
633 return !std::isspace(int(ch));
639auto parse_line(std::string& line,
const fs::path& fs_parent_path) ->
bool
641#if UNRAVEL_PLATFORM_WINDOWS
643 if(line.find(
"[ApplicationDirectory]") != std::string::npos)
645 std::size_t pos = line.find(
':');
646 if(pos != std::string::npos)
648 line = line.substr(pos + 2);
656 size_t pos = line.find(
"=> ");
657 if(pos != std::string::npos)
659 line = line.substr(pos + 3);
660 size_t address_pos = line.find(
" (0x");
661 if(address_pos != std::string::npos)
663 line = line.substr(0, address_pos);
668 fs::path fs_path(line);
670 if(fs::exists(fs_path) && fs::exists(fs_parent_path))
672 if(fs::equivalent(fs_path.parent_path(), fs_parent_path))
683auto get_subprocess_params(
const fs::path& file) -> std::vector<std::string>
685 std::vector<std::string> params;
687#if UNRAVEL_PLATFORM_WINDOWS
688 params.emplace_back(
fs::resolve_protocol(
"editor:/tools/dependencies/Dependencies.exe").
string());
689 params.emplace_back(
"-modules");
690 params.emplace_back(file.string());
694 params.emplace_back(
"ldd");
695 params.emplace_back(file.string());
700auto parse_dependencies(
const std::string&
input,
const fs::path& fs_parent_path) -> std::vector<std::string>
702 std::vector<std::string> dependencies;
703 std::stringstream ss(
input);
706 while(std::getline(ss, line))
708 if(parse_line(line, fs_parent_path))
710 dependencies.push_back(line);
716auto get_dependencies(
const fs::path& file) -> std::vector<std::string>
718 auto parent_path = file.parent_path();
720 auto params = get_subprocess_params(file);
722 return parse_dependencies(result.out_output, parent_path);
725auto save_scene_impl(
rtti::context& ctx,
const fs::path& path) ->
bool
727 auto& ev = ctx.get_cached<events>();
733 auto& ec = ctx.get_cached<ecs>();
738 auto& em = ctx.get_cached<editing_manager>();
739 em.clear_unsaved_changes();
745auto add_extension_if_missing(
const std::string& p) -> fs::path
747 fs::path def_path =
p;
756auto save_scene_as_impl(
rtti::context& ctx, fs::path& path,
const std::string& default_name = {}) ->
bool
765 if(em.is_prefab_mode())
767 em.save_prefab_changes(ctx);
773 if(!default_name.empty())
775 auto def_path = add_extension_if_missing(default_name);
777 save_path += def_path.string();
781 if(native::save_file_dialog(picked,
789 path = add_extension_if_missing(picked);
791 return save_scene_impl(ctx, path);
797void try_delete_empty_parents(
const fs::path& start,
const fs::path& root, fs::error_code& ec)
799 fs::path current =
start.parent_path();
800 while(current != root && fs::is_empty(current, ec))
802 APPLOG_TRACE(
"Removing Empty Parent Directory {}", current.generic_string());
803 fs::remove(current, ec);
804 current = current.parent_path();
808void remove_unreferenced_files(
const fs::path& root)
811 const fs::recursive_directory_iterator
end;
813 std::vector<fs::path> deleted_dirs;
817 fs::recursive_directory_iterator it(root, ec);
820 const fs::path current_path = it->path();
828 APPLOG_TRACE(
"Removing Script {}", current_path.generic_string());
829 fs::remove(current_path, ec);
830 deleted_dirs.push_back(current_path.parent_path());
839 fs::recursive_directory_iterator it(root, ec);
842 const fs::path current_path = it->path();
845 if(fs::is_directory(current_path, ec) && fs::is_empty(current_path, ec))
847 APPLOG_TRACE(
"Removing Empty Directory {}", current_path.generic_string());
848 fs::remove(current_path, ec);
849 deleted_dirs.push_back(current_path.parent_path());
855 std::sort(deleted_dirs.begin(), deleted_dirs.end());
856 deleted_dirs.erase(std::unique(deleted_dirs.begin(), deleted_dirs.end()), deleted_dirs.end());
857 std::sort(deleted_dirs.begin(),
859 [](
const fs::path&
a,
const fs::path&
b)
861 return a.string().size() > b.string().size();
865 for(
const auto& path : deleted_dirs)
867 try_delete_empty_parents(path, root, ec);
880 prompt_save_scene(ctx, [&ctx]() {
897 ev.set_play_mode(ctx,
false);
901 if(native::open_file_dialog(picked,
913 return open_scene_from_asset(ctx, asset);
921 return prompt_save_scene(ctx, [&ctx, asset]() {
928 auto&
scene = ec.get_scene();
933 em.sync_prefab_instances(ctx, &
scene);
945 auto&
scene = ec.get_scene();
948 if(em.is_prefab_mode())
950 em.save_prefab_changes(ctx);
957 if(save_scene_as_impl(ctx, picked,
"Scene3D"))
969 return save_scene_impl(ctx, path);
977 auto&
scene = ec.get_scene();
980 return save_scene_as_impl(ctx, p,
scene.
source.name());
993 if(!em.has_unsaved_changes())
1000 "Do you want to save the changes you made?",
1025 prompt_save_scene(ctx, [&ctx]() {
1041 if(!pm.has_open_project())
1047 pm.close_project(ctx);
1048 return pm.open_project(ctx, project_path);
1053 auto call_params = params.
deploy_location / (std::string(
"game") + fs::executable_extension());
1058 const deploy_settings& params) -> std::map<std::string, tpp::shared_future<void>>
1062 std::map<std::string, tpp::shared_future<void>> jobs;
1063 std::vector<tpp::shared_future<void>> jobs_seq;
1070 auto project_name = pm.get_name();
1074 if(params.deploy_dependencies)
1076 APPLOG_INFO(
"Clearing {}", params.deploy_location.generic_string());
1077 fs::remove_all(params.deploy_location, ec);
1078 fs::create_directories(params.deploy_location, ec);
1082 ->schedule(
"Deploying Dependencies",
1083 [params, project_name]()
1087 fs::path app_executable =
1089 auto deps = get_dependencies(app_executable);
1092 for(
const auto& dep : deps)
1095 fs::path(dep).generic_string(),
1096 params.deploy_location.generic_string());
1097 fs::copy(dep, params.deploy_location, fs::copy_options::overwrite_existing, ec);
1100 auto executable_path = params.deploy_location / (project_name + fs::executable_extension());
1103 app_executable.generic_string(),
1104 params.deploy_location.generic_string());
1105 fs::copy(app_executable, executable_path, fs::copy_options::overwrite_existing, ec);
1110 jobs[
"Deploying Dependencies"] = job;
1111 jobs_seq.emplace_back(job);
1116 ->schedule(
"Deploying Project Settings",
1122 fs::path dst = params.deploy_location /
"data" /
"app" /
"settings";
1127 fs::remove_all(dst, ec);
1128 fs::create_directories(dst, ec);
1130 APPLOG_TRACE(
"Copying {} -> {}", data.generic_string(), dst.generic_string());
1131 fs::copy(data, dst, fs::copy_options::recursive, ec);
1137 jobs[
"Deploying Project Settings"] = job;
1138 jobs_seq.emplace_back(job);
1145 "Deploying Project Data",
1153 fs::path cached_data =
1156 APPLOG_TRACE(
"Clearing {}", cached_data.generic_string());
1157 fs::remove_all(cached_data, ec);
1158 fs::create_directories(cached_data, ec);
1160 APPLOG_TRACE(
"Copying {} -> {}", data.generic_string(), cached_data.generic_string());
1161 fs::copy(data, cached_data, fs::copy_options::recursive, ec);
1163 remove_unreferenced_files(cached_data);
1167 fs::path cached_data = params.deploy_location /
"data" /
"app" /
"assets.pack";
1168 APPLOG_TRACE(
"Creating Asset Pack -> {}", cached_data.generic_string());
1169 am.save_database(
"app:/", cached_data);
1176 jobs[
"Deploying Project Data"] = job;
1177 jobs_seq.emplace_back(job);
1184 "Deploying Engine Data",
1191 fs::path cached_data =
1195 APPLOG_TRACE(
"Clearing {}", cached_data.generic_string());
1196 fs::remove_all(cached_data, ec);
1197 fs::create_directories(cached_data, ec);
1199 APPLOG_TRACE(
"Copying {} -> {}", data.generic_string(), cached_data.generic_string());
1200 fs::copy(data, cached_data, fs::copy_options::recursive, ec);
1202 remove_unreferenced_files(cached_data);
1206 fs::path cached_data = params.deploy_location /
"data" /
"engine" /
"assets.pack";
1207 APPLOG_TRACE(
"Creating Asset Pack -> {}", cached_data.generic_string());
1208 am.save_database(
"engine:/", cached_data);
1214 jobs[
"Deploying Engine Data..."] = job;
1215 jobs_seq.emplace_back(job);
1223 [params, &am, &ctx]()
1228 fs::path assembly_path = mono::get_core_assembly_path();
1229 fs::path assembly_dir = assembly_path.parent_path().parent_path();
1230 fs::path lib_version = assembly_dir.filename();
1235 fs::path cached_data = params.deploy_location /
"data" /
"engine" /
"mono" /
"lib";
1236 cached_data /=
"mono";
1238 APPLOG_TRACE(
"Clearing {}", cached_data.generic_string());
1239 fs::remove_all(cached_data, ec);
1243 fs::create_directories(cached_data, ec);
1246 assembly_dir.generic_string(),
1247 cached_data.generic_string());
1248 fs::copy(assembly_dir, cached_data, fs::copy_options::recursive, ec);
1251 fs::path config_dir = paths.config_dir;
1252 config_dir /=
"mono";
1255 fs::path cached_data = params.deploy_location /
"data" /
"engine" /
"mono" /
"etc";
1256 cached_data /=
"mono";
1258 APPLOG_TRACE(
"Clearing {}", cached_data.generic_string());
1259 fs::remove_all(cached_data, ec);
1260 fs::create_directories(cached_data, ec);
1262 APPLOG_TRACE(
"Copying {} -> {}", config_dir.generic_string(), cached_data.generic_string());
1263 fs::copy(config_dir, cached_data, fs::copy_options::recursive, ec);
1269 jobs[
"Deploying Mono..."] = job;
1270 jobs_seq.emplace_back(job);
1273 tpp::when_all(std::begin(jobs_seq), std::end(jobs_seq))
1274 .then(tpp::this_thread::get_id(),
1277 if(params.deploy_and_run)
1279 run_project(params);
1283 fs::show_in_graphical_env(params.deploy_location);
1300 fs::create_directories(workspace_folder, err);
1303 formats.emplace_back(std::vector<std::string>{
".meta"});
1309 auto workspace_file = workspace_folder / fmt::format(
"{}-workspace.code-workspace", project_name);
1310 generate_workspace_file(workspace_file.string(), formats,
editor_settings);
1318 generate_csproj_legacy(source_path, {engine_dep}, output_path, project_name);
1326 auto vscode_exe = pm.get_editor_settings().external_tools.vscode_executable;
1328 [vscode_exe, project_name, file, line]()
1330 auto external_tool = vscode_exe;
1331 if(external_tool.empty())
1333 external_tool = get_vscode_executable();
1336 static const char* tool =
"[Visual Studio Code]";
1337 static const char* setup_hint =
"Edit -> Editor Settings -> External Tools";
1339 if(external_tool.empty())
1342 APPLOG_ERROR(
"To configure {} visit : {}", tool, setup_hint);
1345 auto workspace_key = fmt::format(
"app:/.vscode/{}-workspace.code-workspace", project_name);
1349 {workspace_path.string(),
"-g", fmt::format(
"{}:{}", file.string(), line)});
1351 if(result.retcode != 0)
1353 APPLOG_ERROR(
"Cannot open external tool {} for file {}", tool, external_tool.string(), file.string());
1354 APPLOG_ERROR(
"To configure {} visit : {}", tool, setup_hint);
1365 for(
auto& asset : shaders)
1379 for(
auto& asset : textures)
1393 auto assets = am.get_assets<
ui_tree>();
1394 for(
auto& asset : assets)
1402 for(
auto& asset : assets)
1417 for(
auto& asset : scripts)
static void touch(const fs::path &path, bool recursive, fs::file_time_type time=fs::now())
Sets the last modification time of a file or directory. by default sets the time to the current time.
Manages assets, including loading, unloading, and storage.
auto get_asset(const std::string &key, load_flags flags=load_flags::standard) -> asset_handle< T >
Gets an asset by its key.
auto get_assets(const std::string &group={}) const -> std::vector< asset_handle< T > >
Gets all assets in a specified group.
auto get_name() const -> const std::string &
void close_project(rtti::context &ctx)
#define APPLOG_ERROR(...)
#define APPLOG_TRACE(...)
ModalResult
Modal result flags for message box buttons.
auto ShowSaveConfirmation(const std::string &title, const std::string &message, std::function< void(ModalResult)> callback) -> std::shared_ptr< MsgBox >
Show a save confirmation dialog with Save/Don't Save/Cancel buttons.
NOTIFY_INLINE void PushNotification(const ImGuiToast &toast)
Insert a new toast in the list.
auto get_suported_formats< gfx::shader >() -> const std::vector< std::string > &
auto get_all_formats() -> const std::vector< std::vector< std::string > > &
auto get_format(bool include_dot=true) -> std::string
auto get_compiled_directory_no_slash(const std::string &prefix={}) -> std::string
auto is_format(const std::string &ex) -> bool
auto get_compiled_directory(const std::string &prefix={}) -> std::string
auto get_suported_formats() -> const std::vector< std::string > &
auto get_suported_formats_with_wildcard() -> std::vector< std::string >
path reduce_trailing_extensions(const path &_path)
another.
path resolve_protocol(const path &_path)
Given the specified path/filename, resolve the final full filename. This will be based on either the ...
path convert_to_protocol(const path &_path)
Oposite of the resolve_protocol this function tries to convert to protocol path from an absolute one.
void end(encoder *_encoder)
auto start(seq_action action, const seq_scope_policy &scope_policy, hpp::source_location location) -> seq_id_t
Starts a new action.
auto to_lower(const std::string &str) -> std::string
auto call(const std::vector< std::string > &args_array) -> call_result
auto atomic_save_to_file(const fs::path &key, const asset_handle< T > &obj) -> bool
auto generate_uuid() -> hpp::uuid
Represents a handle to an asset, providing access and management functions.
static void create_default_3d_scene(rtti::context &ctx, scene &scn)
Creates a default 3D scene.
Manages the entity-component-system (ECS) operations for the ACE framework.
void unload_scene()
Unloads the current scene.
static auto close_project(rtti::context &ctx) -> bool
static void recompile_all()
static void open_workspace_on_file(const fs::path &file, int line=0)
static void recompile_ui()
static auto open_scene(rtti::context &ctx) -> bool
static void recompile_shaders()
static auto open_scene_from_asset(rtti::context &ctx, const asset_handle< scene_prefab > &asset) -> bool
static void run_project(const deploy_settings ¶ms)
static auto prompt_save_scene(rtti::context &ctx, const std::function< void()> &on_continue) -> bool
static auto save_scene(rtti::context &ctx) -> bool
static auto new_scene(rtti::context &ctx) -> bool
static void recompile_scripts()
static void recompile_textures()
static auto reload_project(rtti::context &ctx) -> bool
static auto save_scene_as(rtti::context &ctx) -> bool
static auto deploy_project(rtti::context &ctx, const deploy_settings ¶ms) -> std::map< std::string, tpp::shared_future< void > >
static void generate_script_workspace()
static auto context() -> rtti::context &
Represents a scene-specific prefab. Inherits from the generic prefab structure.
Represents a scene in the ACE framework, managing entities and their relationships.
asset_handle< scene_prefab > source
The source prefab asset handle for the scene.
auto load_from(const asset_handle< scene_prefab > &pfb) -> bool
Loads a scene from a prefab asset.
static auto get_lib_compiled_key(const std::string &protocol) -> std::string
static auto find_mono(const rtti::context &ctx) -> mono::compiler_paths
Represents a UI style sheet asset (CSS/RCSS document).
Represents a UI visual tree asset (HTML/RML document).