MCPcopy Create free account
hub / github.com/XorTroll/uLaunch / SaveThemeFile

Function SaveThemeFile

projects/uDesigner/source/main.cpp:1435–1534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1433});
1434
1435void SaveThemeFile() {
1436 auto theme_zip = zip_stream_open(nullptr, 0, ZIP_DEFAULT_COMPRESSION_LEVEL, 'w');
1437
1438 for(auto &elem: g_AllElements) {
1439 if(!elem->Save(theme_zip)) {
1440 ShowErrorFmt("Unable to save element...");
1441 zip_stream_close(theme_zip);
1442 return;
1443 }
1444 }
1445
1446 for(auto &sound_file: g_AllSoundFiles) {
1447 if(sound_file->data != nullptr) {
1448 if(!SaveThemeAsset(theme_zip, sound_file->path, sound_file->data, sound_file->data_size)) {
1449 ShowErrorFmt("Unable to save sound file at '%s'...", sound_file->path.c_str());
1450 zip_stream_close(theme_zip);
1451 return;
1452 }
1453 }
1454 }
1455
1456 g_Manifest["format_version"] = 2;
1457 g_Manifest["name"] = g_ManifestName;
1458 g_Manifest["description"] = g_ManifestDescription;
1459 g_Manifest["author"] = g_ManifestAuthor;
1460 g_Manifest["release"] = g_ManifestRelease;
1461
1462 if(!SaveThemeJsonAsset(theme_zip, ul::design::ManifestPath, g_Manifest)) {
1463 ShowErrorFmt("Unable to save manifest JSON...");
1464 zip_stream_close(theme_zip);
1465 return;
1466 }
1467
1468 #define _UI_SAVE_COLOR(name) { \
1469 g_UiSettings[#name] = GenerateHexColor(g_##name); \
1470 }
1471 _UI_SAVE_COLOR(text_color)
1472 _UI_SAVE_COLOR(menu_focus_color)
1473 _UI_SAVE_COLOR(menu_bg_color)
1474 _UI_SAVE_COLOR(dialog_title_color)
1475 _UI_SAVE_COLOR(dialog_cnt_color)
1476 _UI_SAVE_COLOR(dialog_opt_color)
1477 _UI_SAVE_COLOR(dialog_color)
1478 _UI_SAVE_COLOR(dialog_over_color)
1479
1480 g_UiSettings["suspended_app_final_alpha"] = g_suspended_app_final_alpha;
1481
1482 if(!SaveThemeJsonAsset(theme_zip, ul::design::UiSettingsPath, g_UiSettings)) {
1483 ShowErrorFmt("Unable to save UI settings JSON...");
1484 zip_stream_close(theme_zip);
1485 return;
1486 }
1487
1488 #define _SAVE_BGM_FIELDS(json) { \
1489 if(g_bgm_loop.has_value()) { \
1490 json["bgm_loop"] = g_bgm_loop.value(); \
1491 } \
1492 if(g_bgm_fade_in_ms.has_value()) { \

Callers 1

MainLoopFunction · 0.85

Calls 5

ShowErrorFmtFunction · 0.85
SaveThemeAssetFunction · 0.85
SaveThemeJsonAssetFunction · 0.85
DoSaveThemeFileFunction · 0.85
SaveMethod · 0.45

Tested by

no test coverage detected