diff options
| author | coco875 <59367621+coco875@users.noreply.github.com> | 2025-12-07 15:34:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-07 07:34:53 -0700 |
| commit | 02ad54ca72f5baf4614cb9b7c30f8dd780764d90 (patch) | |
| tree | bd2719a154830d4c538e0caf91eb845ddb45552d /src/port/Engine.cpp | |
| parent | eec7d650482134352b7cde4801b979ce1ed2044e (diff) | |
Refactor yaml and remove segment (#531)
* move yaml (still need to fix header path)
* fix header
* change kart to karts and add migration
* fix include
* Update migration.py
* fix common_texture_debug_font extraction
* Update torch
* update torch and header
* unduplicate texture for tumble
* Update torch
* Update migration.py
* put the sort by default
* fix replace_segmented_textures_with_o2r_textures
* Update torch
* fix yamls
* add manual_segments in data of course
* comment out replace_segmented_textures_with_o2r_textures and segment 3
* remove segment 5
* (wip) remove segment 6
still plenty of thing to do
* more vtx
* more change
* Update torch
* small fix
* Update BansheeBoardwalk.cpp
* fix blockFort
* Delete test.yaml
* fix bowser castle and simplify track sections
* fix choco mountain
* clean banshee
* fix dk jungle
* fix double deck
* fix macos
* fix error
* fix macos ci
* Update torch
* Update torch
* fix frappe snowland
* fix kalimari desert
* fix koopa troopa beach
* fix luigi raceway
* fix mario raceway and simplify thing
* fix moo moo farm
* fix rainbow road
* Update torch
* Update torch
* hopefully fix windows error
* fix a small error
* fix royal raceway (and podium in theory)
* fix sherbet_land
* fix skyscraper
* fix toads turnpike
* fix wario stadium
* fix yoshi valley
* update torch
* more clang tidy rules
* REMOVE totally SEGMENT (sorry for the PR)
* remove unused field in course and props and unused packed asset
* fix kart texture
* fix particle
* fix track section and transparency
* try fix mode extra
* fix macos build and render
* fix collision in extra
* small change and try fix windows error
* a little of clean
* more cleanup
* forget header and more clean up
* Update Makefile
* fix credits
* fix kart texture offset
* remove LoadTextures and add Unload
* fix definitevely mirror mode
* add unload but it's not perfect
* revert a bad fix
* clean no longer used python script
* fix crash with player
* being able to load the same course twice
* add a comment on DrawWater
* fix render of transparent object
* better hack
* add a proper migration instruction
* fix number
* add basic modsmanager
* add meta/mods.toml
* Update EditorMath.h
* Update ModsManager.cpp
* basic modManager (maybe I should rename it ModLoader)
* use range on dependencies
* add information about mods.toml
* fix coment
* some rename around
* Delete beta-to-v1.md
* Update migrations.md
* Update textures-pack.md
* Update modding.md
* Update modding.md
* clean yamls_old
* move to mods in engine
* rename ModsManger to ModManager
* move init and unload at the top
* rename ModsMetadata to ModMetadata
* fix header
* Update ModManager.cpp
* put core mods at top
Diffstat (limited to 'src/port/Engine.cpp')
| -rw-r--r-- | src/port/Engine.cpp | 46 |
1 files changed, 7 insertions, 39 deletions
diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 2bebc766d..9f0d6d3f9 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -2,6 +2,7 @@ #include "StringHelper.h" #include "GameExtractor.h" +#include "mods/ModManager.h" #include "ui/ImguiUI.h" #include "libultraship/src/Context.h" #include "libultraship/src/controller/controldevice/controller/mapping/ControllerDefaultMappings.h" @@ -79,11 +80,6 @@ GameEngine::GameEngine() { // Initialize context properties early to recognize paths properly for non-portable builds this->context = Ship::Context::CreateUninitializedInstance("Spaghetti Kart", "spaghettify", "spaghettify.cfg.json"); - const std::string main_path = Ship::Context::GetPathRelativeToAppDirectory("mk64.o2r"); - const std::string assets_path = Ship::Context::LocateFileAcrossAppDirs("spaghetti.o2r"); - - std::vector<std::string> archiveFiles; - #ifdef __SWITCH__ Ship::Switch::Init(Ship::PreInitPhase); Ship::Switch::Init(Ship::PostInitPhase); @@ -93,36 +89,6 @@ GameEngine::GameEngine() { AllocConsole(); #endif - if (std::filesystem::exists(main_path)) { - archiveFiles.push_back(main_path); - } else { - if (ShowYesNoBox("No O2R Files", "No O2R files found. Generate one now?") == IDYES) { - if (!GenAssetFile()) { - ShowMessage("Error", "An error occured, no O2R file was generated.\n\nExiting..."); - exit(1); - } else { - archiveFiles.push_back(main_path); - } - } else { - exit(1); - } - } - - if (std::filesystem::exists(assets_path)) { - archiveFiles.push_back(assets_path); - } - if (const std::string patches_path = Ship::Context::GetPathRelativeToAppDirectory("mods"); - !patches_path.empty() && std::filesystem::exists(patches_path)) { - if (std::filesystem::is_directory(patches_path)) { - for (const auto& p : std::filesystem::recursive_directory_iterator(patches_path)) { - auto ext = p.path().extension().string(); - if (StringHelper::IEquals(ext, ".zip") || StringHelper::IEquals(ext, ".o2r")) { - archiveFiles.push_back(p.path().generic_string()); - } - } - } - } - this->context->InitConfiguration(); // without this line InitConsoleVariables fails at Config::Reload() this->context->InitConsoleVariables(); // without this line the controldeck constructor failes in // ShipDeviceIndexMappingManager::UpdateControllerNamesFromConfig() @@ -182,7 +148,7 @@ GameEngine::GameEngine() { ); auto controlDeck = std::make_shared<LUS::ControlDeck>(std::vector<CONTROLLERBUTTONS_T>(), defaultMappings); - this->context->InitResourceManager(archiveFiles, {}, 3); // without this line InitWindow fails in Gui::Init() + this->context->InitResourceManager({}, {}, 3); // without this line InitWindow fails in Gui::Init() this->context->InitConsole(); // without this line the GuiWindow constructor fails in ConsoleWindow::InitElement() auto gui = std::make_shared<Ship::SpaghettiGui>(std::vector<std::shared_ptr<Ship::GuiWindow>>({})); @@ -191,7 +157,7 @@ GameEngine::GameEngine() { // auto wnd = std::make_shared<Fast::Fast3dWindow>(std::vector<std::shared_ptr<Ship::GuiWindow>>({})); // auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow()); - this->context->Init(archiveFiles, {}, 3, { 26800, 512, 1100 }, wnd, controlDeck); + this->context->Init({}, {}, 3, { 26800, 512, 1100 }, wnd, controlDeck); #ifndef __SWITCH__ Ship::Context::GetInstance()->GetLogger()->set_level( @@ -360,6 +326,7 @@ int GameEngine::ShowYesNoBox(const char* title, const char* box) { void GameEngine::Create() { const auto instance = Instance = new GameEngine(); + InitModsSystem(); instance->gHMAS = new HMAS(); instance->AudioInit(); GameUI::SetupGuiElements(); @@ -373,6 +340,7 @@ void GameEngine::Destroy() { #ifdef __SWITCH__ Ship::Switch::Exit(); #endif + UnloadMods(); GameUI::Destroy(); delete GameEngine::Instance; GameEngine::Instance = nullptr; @@ -712,7 +680,7 @@ extern "C" uint32_t GameEngine_GetGameVersion() { return 0x00000001; } -static const char* sOtrSignature = "__OTR__"; +static const char* const sOtrSignature = "__OTR__"; extern "C" bool GameEngine_OTRSigCheck(const char* data) { return strncmp(data, sOtrSignature, strlen(sOtrSignature)) == 0; @@ -725,7 +693,7 @@ extern "C" int32_t GameEngine_ResourceGetTexTypeByName(const char* name) { return (int16_t) res->Type; } - SPDLOG_ERROR("Given texture path is a non-existent resource"); + SPDLOG_ERROR("Given texture path {} is a non-existent resource", name); return -1; } |
