From 9db3ffd66b771aa940ecab79562804f94606d8b9 Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Sun, 29 Dec 2024 17:36:00 +0700 Subject: [PATCH 01/14] Update libultraship --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index 57a599474..944f0b474 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 57a599474665fcbad958864fbbecda843d37940f +Subproject commit 944f0b474b5b2c0ca2605890c0b02b30b78f356a From 04595441887d180e6e0aa6d5b96d8586c3d39629 Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Sun, 29 Dec 2024 17:29:39 +0700 Subject: [PATCH 02/14] renames --- mm/2s2h/BenGui/BenInputEditorWindow.cpp | 10 +++++----- mm/2s2h/BenGui/BenInputEditorWindow.h | 2 +- mm/2s2h/BenGui/BenMenuBar.cpp | 6 +++--- mm/2s2h/BenGui/HudEditor.cpp | 2 +- mm/2s2h/BenGui/SearchableMenuItems.h | 10 +++++----- mm/2s2h/BenGui/UIWidgets.cpp | 8 ++++---- mm/2s2h/BenGui/UIWidgets.hpp | 6 +++--- mm/2s2h/BenPort.cpp | 4 ++-- mm/2s2h/DeveloperTools/CollisionViewer.cpp | 2 +- mm/2s2h/DeveloperTools/EventLog.cpp | 4 ++-- mm/2s2h/DeveloperTools/WarpPoint.cpp | 4 ++-- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/mm/2s2h/BenGui/BenInputEditorWindow.cpp b/mm/2s2h/BenGui/BenInputEditorWindow.cpp index 8e3b4334e..211ca9215 100644 --- a/mm/2s2h/BenGui/BenInputEditorWindow.cpp +++ b/mm/2s2h/BenGui/BenInputEditorWindow.cpp @@ -58,7 +58,7 @@ void BenInputEditorWindow::UpdateElement() { } } - Ship::Context::GetInstance()->GetWindow()->GetGui()->BlockImGuiGamepadNavigation(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->BlockGamepadNavigation(); } else { if (mGameInputBlockTimer != INT32_MAX) { mGameInputBlockTimer--; @@ -69,13 +69,13 @@ void BenInputEditorWindow::UpdateElement() { } } - if (Ship::Context::GetInstance()->GetWindow()->GetGui()->ImGuiGamepadNavigationEnabled()) { + if (Ship::Context::GetInstance()->GetWindow()->GetGui()->GamepadNavigationEnabled()) { mMappingInputBlockTimer = ImGui::GetIO().Framerate / 3; } else { mMappingInputBlockTimer = INT32_MAX; } - Ship::Context::GetInstance()->GetWindow()->GetGui()->UnblockImGuiGamepadNavigation(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->UnblockGamepadNavigation(); } } @@ -1237,7 +1237,7 @@ void BenInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::set allLusDeviceIndices; allLusDeviceIndices.insert(Ship::ShipDeviceIndex::Keyboard); for (auto [lusIndex, mapping] : Ship::Context::GetInstance() @@ -1250,7 +1250,7 @@ void BenInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::S std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { auto controllerStick = - stick == Ship::Stick::LEFT_STICK + stick == Ship::StickIndex::LEFT_STICK ? Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetLeftStick() : Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetRightStick(); if (controllerStick->HasMappingsForShipDeviceIndex(lusIndex)) { diff --git a/mm/2s2h/BenGui/BenInputEditorWindow.h b/mm/2s2h/BenGui/BenInputEditorWindow.h index adb1b8be8..038a53108 100644 --- a/mm/2s2h/BenGui/BenInputEditorWindow.h +++ b/mm/2s2h/BenGui/BenInputEditorWindow.h @@ -77,7 +77,7 @@ class BenInputEditorWindow : public Ship::GuiWindow { std::set mButtonsBitmasks; std::set mDpadBitmasks; void DrawButtonDeviceIcons(uint8_t portIndex, std::set bitmasks); - void DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::Stick stick); + void DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::StickIndex stick); void DrawRumbleDeviceIcons(uint8_t portIndex); void DrawGyroDeviceIcons(uint8_t portIndex); void DrawLEDDeviceIcons(uint8_t portIndex); diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index 9d43115e1..059098ec8 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -194,13 +194,13 @@ void DrawSettingsMenu() { AudioSeq_SetPortVolumeScale(SEQ_PLAYER_AMBIENCE, CVarGetFloat("gSettings.Audio.AmbienceVolume", 1.0f)); } - auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetAudioBackend(); + auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetCurrentAudioBackend(); if (UIWidgets::Combobox( "Audio API", ¤tAudioBackend, audioBackendsMap, { .tooltip = "Sets the audio API used by the game. Requires a relaunch to take effect.", .disabled = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1, .disabledTooltip = "Only one audio API is available on this platform." })) { - Ship::Context::GetInstance()->GetAudio()->SetAudioBackend(currentAudioBackend); + Ship::Context::GetInstance()->GetAudio()->SetCurrentAudioBackend(currentAudioBackend); } ImGui::EndMenu(); @@ -265,7 +265,7 @@ void DrawSettingsMenu() { int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); if (hz >= 20 && hz <= 360) { CVarSetInteger("gInterpolationFPS", hz); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } } } else { diff --git a/mm/2s2h/BenGui/HudEditor.cpp b/mm/2s2h/BenGui/HudEditor.cpp index e0cf095b5..2c45b183a 100644 --- a/mm/2s2h/BenGui/HudEditor.cpp +++ b/mm/2s2h/BenGui/HudEditor.cpp @@ -224,7 +224,7 @@ void HudEditorWindow::DrawElement() { break; } } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } for (int i = HUD_EDITOR_ELEMENT_B; i < HUD_EDITOR_ELEMENT_MAX; i++) { diff --git a/mm/2s2h/BenGui/SearchableMenuItems.h b/mm/2s2h/BenGui/SearchableMenuItems.h index dac286c82..d12e9bc1b 100644 --- a/mm/2s2h/BenGui/SearchableMenuItems.h +++ b/mm/2s2h/BenGui/SearchableMenuItems.h @@ -680,7 +680,7 @@ void AddSettings() { int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); if (hz >= 20 && hz <= 360) { CVarSetInteger("gInterpolationFPS", hz); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } }, [](widgetInfo& info) { info.isHidden = disabledMap.at(DISABLE_FOR_NOT_DIRECTX).active; } }, @@ -1564,7 +1564,7 @@ void AddDevTools() { CVarSetFloat(WARP_POINT_CVAR "Z", player->actor.world.pos.z); CVarSetFloat(WARP_POINT_CVAR "Rotation", player->actor.shape.rot.y); CVarSetInteger(WARP_POINT_CVAR "Saved", 1); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); }, [](widgetInfo& info) { info.isHidden = disabledMap.at(DISABLE_FOR_NULL_PLAY_STATE).active; } }, { "Scene Room ID", @@ -1594,7 +1594,7 @@ void AddDevTools() { CVarClear(WARP_POINT_CVAR "Z"); CVarClear(WARP_POINT_CVAR "Rotation"); CVarClear(WARP_POINT_CVAR "Saved"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); }, [](widgetInfo& info) { info.isHidden = disabledMap.at(DISABLE_FOR_NULL_PLAY_STATE).active || @@ -1849,7 +1849,7 @@ void SearchMenuGetItem(widgetInfo& widget) { }; break; case WIDGET_AUDIO_BACKEND: { - auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetAudioBackend(); + auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetCurrentAudioBackend(); if (UIWidgets::Combobox( "Audio API", ¤tAudioBackend, audioBackendsMap, { .color = menuTheme[menuThemeIndex], @@ -1857,7 +1857,7 @@ void SearchMenuGetItem(widgetInfo& widget) { .disabled = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1, .disabledTooltip = "Only one audio API is available on this platform." })) { - Ship::Context::GetInstance()->GetAudio()->SetAudioBackend(currentAudioBackend); + Ship::Context::GetInstance()->GetAudio()->SetCurrentAudioBackend(currentAudioBackend); } } break; case WIDGET_VIDEO_BACKEND: { diff --git a/mm/2s2h/BenGui/UIWidgets.cpp b/mm/2s2h/BenGui/UIWidgets.cpp index db2e403e4..981e022b3 100644 --- a/mm/2s2h/BenGui/UIWidgets.cpp +++ b/mm/2s2h/BenGui/UIWidgets.cpp @@ -275,7 +275,7 @@ bool CVarCheckbox(const char* label, const char* cvarName, const CheckboxOptions bool value = (bool)CVarGetInteger(cvarName, options.defaultValue); if (Checkbox(label, &value, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -384,7 +384,7 @@ bool CVarSliderInt(const char* label, const char* cvarName, int32_t min, int32_t int32_t value = CVarGetInteger(cvarName, defaultValue); if (SliderInt(label, &value, min, max, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -496,7 +496,7 @@ bool CVarSliderFloat(const char* label, const char* cvarName, float min, float m float value = CVarGetFloat(cvarName, defaultValue); if (SliderFloat(label, &value, min, max, options)) { CVarSetFloat(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -514,7 +514,7 @@ bool CVarColorPicker(const char* label, const char* cvarName, Color_RGBA8 defaul color.b = (uint8_t)(colorVec.z * 255.0f); color.a = (uint8_t)(colorVec.w * 255.0f); CVarSetColor(cvarName, color); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); changed = true; } diff --git a/mm/2s2h/BenGui/UIWidgets.hpp b/mm/2s2h/BenGui/UIWidgets.hpp index 3c5280b14..a6b97bb9c 100644 --- a/mm/2s2h/BenGui/UIWidgets.hpp +++ b/mm/2s2h/BenGui/UIWidgets.hpp @@ -351,7 +351,7 @@ namespace UIWidgets { int32_t value = CVarGetInteger(cvarName, options.defaultIndex); if (Combobox(label, &value, comboMap, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -364,7 +364,7 @@ namespace UIWidgets { int32_t value = CVarGetInteger(cvarName, options.defaultIndex); if (Combobox(label, &value, comboVector, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } @@ -377,7 +377,7 @@ namespace UIWidgets { int32_t value = CVarGetInteger(cvarName, options.defaultIndex); if (Combobox(label, &value, comboArray, options)) { CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); ShipInit::Init(cvarName); dirty = true; } diff --git a/mm/2s2h/BenPort.cpp b/mm/2s2h/BenPort.cpp index e28a84b5a..cd781655e 100644 --- a/mm/2s2h/BenPort.cpp +++ b/mm/2s2h/BenPort.cpp @@ -992,10 +992,10 @@ extern "C" uint32_t ResourceMgr_GetGameRegion(int index) { } extern "C" void ResourceMgr_LoadDirectory(const char* resName) { - Ship::Context::GetInstance()->GetResourceManager()->LoadDirectory(resName); + Ship::Context::GetInstance()->GetResourceManager()->LoadResources(resName); } extern "C" void ResourceMgr_DirtyDirectory(const char* resName) { - Ship::Context::GetInstance()->GetResourceManager()->DirtyDirectory(resName); + Ship::Context::GetInstance()->GetResourceManager()->DirtyResources(resName); } // OTRTODO: There is probably a more elegant way to go about this... diff --git a/mm/2s2h/DeveloperTools/CollisionViewer.cpp b/mm/2s2h/DeveloperTools/CollisionViewer.cpp index 6c9507552..fcf666d00 100644 --- a/mm/2s2h/DeveloperTools/CollisionViewer.cpp +++ b/mm/2s2h/DeveloperTools/CollisionViewer.cpp @@ -64,7 +64,7 @@ void CollisionViewerWindow::DrawElement() { CVarClear("gCollisionViewer.ATCollisionColor"); CVarClear("gCollisionViewer.SpecialSurfaceColor"); CVarClear("gCollisionViewer.InteractableColor"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::SeparatorText("Collision Types"); diff --git a/mm/2s2h/DeveloperTools/EventLog.cpp b/mm/2s2h/DeveloperTools/EventLog.cpp index 6eacb3b03..2bca37305 100644 --- a/mm/2s2h/DeveloperTools/EventLog.cpp +++ b/mm/2s2h/DeveloperTools/EventLog.cpp @@ -313,7 +313,7 @@ void EventLogWindow::DrawElement() { CVarSetInteger("gEventLog.Filter.OpenText", 0); CVarSetInteger("gEventLog.Filter.ItemGive", 0); } - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } g->CurrentItemFlags = backup_item_flags; @@ -342,7 +342,7 @@ void EventLogWindow::DrawElement() { s32 maxEntries = CVarGetInteger("gEventLog.MaxEntries", 1000); if (ImGui::InputScalar("##maxEntriesInput", ImGuiDataType_S32, &maxEntries)) { CVarSetInteger("gEventLog.MaxEntries", MAX(0, maxEntries)); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); TrimEventLog(); } ImGui::PopItemWidth(); diff --git a/mm/2s2h/DeveloperTools/WarpPoint.cpp b/mm/2s2h/DeveloperTools/WarpPoint.cpp index 98ce5cc9d..1ae1b96d2 100644 --- a/mm/2s2h/DeveloperTools/WarpPoint.cpp +++ b/mm/2s2h/DeveloperTools/WarpPoint.cpp @@ -92,7 +92,7 @@ void RenderWarpPointSection() { CVarSetFloat(WARP_POINT_CVAR "Z", player->actor.world.pos.z); CVarSetFloat(WARP_POINT_CVAR "Rotation", player->actor.shape.rot.y); CVarSetInteger(WARP_POINT_CVAR "Saved", 1); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } if (CVarGetInteger(WARP_POINT_CVAR "Saved", 0)) { u32 sceneId = @@ -108,7 +108,7 @@ void RenderWarpPointSection() { CVarClear(WARP_POINT_CVAR "Z"); CVarClear(WARP_POINT_CVAR "Rotation"); CVarClear(WARP_POINT_CVAR "Saved"); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::SameLine(); if (UIWidgets::Button("Warp", { .size = UIWidgets::Sizes::Inline })) { From fea2bd3e920bc2c048dbbf16036def8b0d0d3c8a Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Sun, 29 Dec 2024 17:31:02 +0700 Subject: [PATCH 03/14] namespaces --- mm/2s2h/BenPort.cpp | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/mm/2s2h/BenPort.cpp b/mm/2s2h/BenPort.cpp index cd781655e..e5e761afc 100644 --- a/mm/2s2h/BenPort.cpp +++ b/mm/2s2h/BenPort.cpp @@ -182,22 +182,22 @@ OTRGlobals::OTRGlobals() { overlay->SetCurrentFont(CVarGetString(CVAR_GAME_OVERLAY_FONT, "Press Start 2P")); auto loader = context->GetResourceManager()->GetResourceLoader(); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, - "Texture", static_cast(LUS::ResourceType::Texture), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, - "Texture", static_cast(LUS::ResourceType::Texture), 1); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, - "Vertex", static_cast(LUS::ResourceType::Vertex), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "Vertex", - static_cast(LUS::ResourceType::Vertex), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, - "DisplayList", static_cast(LUS::ResourceType::DisplayList), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, - "DisplayList", static_cast(LUS::ResourceType::DisplayList), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, - "Matrix", static_cast(LUS::ResourceType::Matrix), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, - "Blob", static_cast(LUS::ResourceType::Blob), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, + "Texture", static_cast(Fast::ResourceType::Texture), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, + "Texture", static_cast(Fast::ResourceType::Texture), 1); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, + "Vertex", static_cast(Fast::ResourceType::Vertex), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "Vertex", + static_cast(Fast::ResourceType::Vertex), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, + "DisplayList", static_cast(Fast::ResourceType::DisplayList), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, + "DisplayList", static_cast(Fast::ResourceType::DisplayList), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, + "Matrix", static_cast(Fast::ResourceType::Matrix), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, + "Blob", static_cast(Ship::ResourceType::Blob), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Array", static_cast(SOH::ResourceType::SOH_Array), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, @@ -1095,8 +1095,8 @@ extern "C" uint16_t ResourceMgr_LoadTexHeightByName(char* texPath); extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) { auto res = GetResourceByName(filePath); - if (res->GetInitData()->Type == static_cast(LUS::ResourceType::DisplayList)) - return (char*)&((std::static_pointer_cast(res))->Instructions[0]); + if (res->GetInitData()->Type == static_cast(Fast::ResourceType::DisplayList)) + return (char*)&((std::static_pointer_cast(res))->Instructions[0]); else if (res->GetInitData()->Type == static_cast(SOH::ResourceType::SOH_Array)) return (char*)(std::static_pointer_cast(res))->Vertices.data(); else { @@ -1107,8 +1107,8 @@ extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) { extern "C" char* ResourceMgr_LoadIfDListByName(const char* filePath) { auto res = GetResourceByName(filePath); - if (res->GetInitData()->Type == static_cast(LUS::ResourceType::DisplayList)) - return (char*)&((std::static_pointer_cast(res))->Instructions[0]); + if (res->GetInitData()->Type == static_cast(Fast::ResourceType::DisplayList)) + return (char*)&((std::static_pointer_cast(res))->Instructions[0]); return nullptr; } @@ -1128,7 +1128,7 @@ extern "C" void ResourceMgr_PushCurrentDirectory(char* path) { } extern "C" Gfx* ResourceMgr_LoadGfxByName(const char* path) { - auto res = std::static_pointer_cast(GetResourceByName(path)); + auto res = std::static_pointer_cast(GetResourceByName(path)); return (Gfx*)&res->Instructions[0]; } @@ -1142,7 +1142,7 @@ std::unordered_map> origi // Attention! This is primarily for cosmetics & bug fixes. For things like mods and model replacement you should be // using OTRs instead (When that is available). Index can be found using the commented out section below. extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction) { - auto res = std::static_pointer_cast( + auto res = std::static_pointer_cast( Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); // Leaving this here for people attempting to find the correct Dlist index to patch @@ -1180,7 +1180,7 @@ extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchNa extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const char* patchName, int destinationIndex, int sourceIndex) { - auto res = std::static_pointer_cast( + auto res = std::static_pointer_cast( Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); // Do not patch custom assets as they most likely do not have the same instructions as authentic assets @@ -1200,7 +1200,7 @@ extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const ch extern "C" void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName) { if (originalGfx.contains(path) && originalGfx[path].contains(patchName)) { - auto res = std::static_pointer_cast( + auto res = std::static_pointer_cast( Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); Gfx* gfx = (Gfx*)&res->Instructions[originalGfx[path][patchName].index]; From d00bcf90f835f005aeca2408efc5c18790afd9e0 Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Sun, 29 Dec 2024 17:31:23 +0700 Subject: [PATCH 04/14] removed method `Gui::SetPadBtnTogglesMenu` --- mm/2s2h/BenGui/BenGui.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/2s2h/BenGui/BenGui.cpp b/mm/2s2h/BenGui/BenGui.cpp index a0a296b61..b2e587474 100644 --- a/mm/2s2h/BenGui/BenGui.cpp +++ b/mm/2s2h/BenGui/BenGui.cpp @@ -112,7 +112,6 @@ void SetupGuiElements() { mItemTrackerSettingsWindow = std::make_shared("gWindows.ItemTrackerSettings", "Item Tracker Settings", ImVec2(800, 400)); gui->AddGuiWindow(mItemTrackerSettingsWindow); - gui->SetPadBtnTogglesMenu(); mNotificationWindow = std::make_shared("gWindows.Notifications", "Notifications Window"); gui->AddGuiWindow(mNotificationWindow); From c8b9658c7d5c419189fbf9023fffafa4bd85d2c2 Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Sun, 29 Dec 2024 17:31:40 +0700 Subject: [PATCH 05/14] change args order in `LoadFont` --- mm/2s2h/BenPort.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/2s2h/BenPort.cpp b/mm/2s2h/BenPort.cpp index e5e761afc..d1eed31cc 100644 --- a/mm/2s2h/BenPort.cpp +++ b/mm/2s2h/BenPort.cpp @@ -177,8 +177,8 @@ OTRGlobals::OTRGlobals() { Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v"); auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay(); - overlay->LoadFont("Press Start 2P", "fonts/PressStart2P-Regular.ttf", 12.0f); - overlay->LoadFont("Fipps", "fonts/Fipps-Regular.otf", 32.0f); + overlay->LoadFont("Press Start 2P", 12.0f, "fonts/PressStart2P-Regular.ttf"); + overlay->LoadFont("Fipps", 32.0f, "fonts/Fipps-Regular.otf"); overlay->SetCurrentFont(CVarGetString(CVAR_GAME_OVERLAY_FONT, "Press Start 2P")); auto loader = context->GetResourceManager()->GetResourceLoader(); From 5b10739b6c56bc126096681fb881a71d8a3b668b Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Sun, 29 Dec 2024 17:36:04 +0700 Subject: [PATCH 06/14] Update OTRExporter --- OTRExporter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OTRExporter b/OTRExporter index 854685155..a27c8aaaf 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit 854685155a6addaf72ec2415ac481a08ace9f9ce +Subproject commit a27c8aaaf60e012e32bb42e155c0ea902e177922 From b92527b27deec22c2203e468b2264e17a007a9eb Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Sun, 29 Dec 2024 17:35:03 +0700 Subject: [PATCH 07/14] fix Context init Now requires to manually construct `Window` and `ControlDeck`. Both constructors depends on partially initialized `Context` object (via console variables for example). Stack: ``` std::__shared_ptr::__shared_ptr(std::__shared_ptr * const this) (/usr/include/c++/11/bits/shared_ptr_base.h:1152) std::shared_ptr::shared_ptr(std::shared_ptr * const this) (/usr/include/c++/11/bits/shared_ptr.h:150) Ship::Context::GetConsoleVariables(Ship::Context * const this) (/home/lightmanlp/git/2ship2harkinian/libultraship/src/Context.cpp:329) CVarGetInteger(const char * name, int32_t defaultValue) (/home/lightmanlp/git/2ship2harkinian/libultraship/src/public/bridge/consolevariablebridge.cpp:10) Ship::GuiWindow::GuiWindow(Ship::GuiWindow * const this, const std::string & consoleVariable, bool isVisible, const std::string & name, ImVec2 originalSize, uint32_t windowFlags) (/home/lightmanlp/git/2ship2harkinian/libultraship/src/window/gui/GuiWindow.cpp:11) Ship::GuiWindow::GuiWindow(Ship::GuiWindow * const this, const std::string & consoleVariable, const std::string & name) (/home/lightmanlp/git/2ship2harkinian/libultraship/src/window/gui/GuiWindow.cpp:34) Ship::StatsWindow::GuiWindow(Ship::StatsWindow * const this) (/home/lightmanlp/git/2ship2harkinian/libultraship/src/window/gui/StatsWindow.h:8) std::construct_at(Ship::StatsWindow * __location) (/usr/include/c++/11/bits/stl_construct.h:97) std::allocator_traits >::construct(std::allocator_traits >::allocator_type & __a, Ship::StatsWindow * __p) (/usr/include/c++/11/bits/alloc_traits.h:518) std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace(std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2> * const this, std::allocator __a) (/usr/include/c++/11/bits/shared_ptr_base.h:519) std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count, char const (&) [19], char const (&) [6]>(std::__shared_count<(__gnu_cxx::_Lock_policy)2> * const this, Ship::StatsWindow *& __p, std::_Sp_alloc_shared_tag > __a) (/usr/include/c++/11/bits/shared_ptr_base.h:650) std::__shared_ptr::__shared_ptr, char const (&) [19], char const (&) [6]>(std::__shared_ptr * const this, std::_Sp_alloc_shared_tag > __tag) (/usr/include/c++/11/bits/shared_ptr_base.h:1342) std::shared_ptr::shared_ptr, char const (&) [19], char const (&) [6]>(std::shared_ptr * const this, std::_Sp_alloc_shared_tag > __tag) (/usr/include/c++/11/bits/shared_ptr.h:409) std::allocate_shared, char const (&) [19], char const (&) [6]>(const std::allocator & __a) (/usr/include/c++/11/bits/shared_ptr.h:863) std::make_shared() (/usr/include/c++/11/bits/shared_ptr.h:879) Ship::Gui::Gui(Ship::Gui * const this, std::vector, std::allocator > > guiWindows) (/home/lightmanlp/git/2ship2harkinian/libultraship/src/window/gui/Gui.cpp:68) std::construct_at, std::allocator > >&>(Ship::Gui * __location) (/usr/include/c++/11/bits/stl_construct.h:97) std::allocator_traits >::construct, std::allocator > >&>(std::allocator_traits >::allocator_type & __a, Ship::Gui * __p) (/usr/include/c++/11/bits/alloc_traits.h:518) std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace, std::allocator > >&>(std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2> * const this, std::allocator __a) (/usr/include/c++/11/bits/shared_ptr_base.h:519) std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count, std::vector, std::allocator > >&>(std::__shared_count<(__gnu_cxx::_Lock_policy)2> * const this, Ship::Gui *& __p, std::_Sp_alloc_shared_tag > __a) (/usr/include/c++/11/bits/shared_ptr_base.h:650) std::__shared_ptr::__shared_ptr, std::vector, std::allocator > >&>(std::__shared_ptr * const this, std::_Sp_alloc_shared_tag > __tag) (/usr/include/c++/11/bits/shared_ptr_base.h:1342) std::shared_ptr::shared_ptr, std::vector, std::allocator > >&>(std::shared_ptr * const this, std::_Sp_alloc_shared_tag > __tag) (/usr/include/c++/11/bits/shared_ptr.h:409) std::allocate_shared, std::vector, std::allocator > >&>(const std::allocator & __a) (/usr/include/c++/11/bits/shared_ptr.h:863) std::make_shared, std::allocator > >&>() (/usr/include/c++/11/bits/shared_ptr.h:879) Ship::Window::Window(Ship::Window * const this, std::vector, std::allocator > > guiWindows) (/home/lightmanlp/git/2ship2harkinian/libultraship/src/window/Window.cpp:16) Fast::Fast3dWindow::Fast3dWindow(Fast::Fast3dWindow * const this, std::vector, std::allocator > > guiWindows) (/home/lightmanlp/git/2ship2harkinian/libultraship/src/graphic/Fast3D/Fast3dWindow.cpp:20) Fast::Fast3dWindow::Fast3dWindow(Fast::Fast3dWindow * const this) (/home/lightmanlp/git/2ship2harkinian/libultraship/src/graphic/Fast3D/Fast3dWindow.cpp:17) std::construct_at(Fast::Fast3dWindow * __location) (/usr/include/c++/11/bits/stl_construct.h:97) std::allocator_traits >::construct(std::allocator_traits >::allocator_type & __a, Fast::Fast3dWindow * __p) (/usr/include/c++/11/bits/alloc_traits.h:518) std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<>(std::allocator)(std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2> * const this, std::allocator __a) (/usr/include/c++/11/bits/shared_ptr_base.h:519) std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count>(Fast::Fast3dWindow*&, std::_Sp_alloc_shared_tag >)(std::__shared_count<(__gnu_cxx::_Lock_policy)2> * const this, Fast::Fast3dWindow *& __p, std::_Sp_alloc_shared_tag > __a) (/usr/include/c++/11/bits/shared_ptr_base.h:650) std::__shared_ptr::__shared_ptr>(std::_Sp_alloc_shared_tag >)(std::__shared_ptr * const this, std::_Sp_alloc_shared_tag > __tag) (/usr/include/c++/11/bits/shared_ptr_base.h:1342) std::shared_ptr::shared_ptr>(std::_Sp_alloc_shared_tag >)(std::shared_ptr * const this, std::_Sp_alloc_shared_tag > __tag) (/usr/include/c++/11/bits/shared_ptr.h:409) std::allocate_shared>(std::allocator const&)(const std::allocator & __a) (/usr/include/c++/11/bits/shared_ptr.h:863) std::make_shared() (/usr/include/c++/11/bits/shared_ptr.h:879) OTRGlobals::OTRGlobals(OTRGlobals * const this) (/home/lightmanlp/git/2ship2harkinian/mm/2s2h/BenPort.cpp:165) InitOTR() (/home/lightmanlp/git/2ship2harkinian/mm/2s2h/BenPort.cpp:656) main(int argc, char ** argv) (/home/lightmanlp/git/2ship2harkinian/mm/src/code/main.c:74) ``` --- libultraship | 2 +- mm/2s2h/BenPort.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libultraship b/libultraship index 944f0b474..3e46fe77a 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 944f0b474b5b2c0ca2605890c0b02b30b78f356a +Subproject commit 3e46fe77a4581a84f9c0edfab9c3a69a5320fe01 diff --git a/mm/2s2h/BenPort.cpp b/mm/2s2h/BenPort.cpp index d1eed31cc..6b1af5aff 100644 --- a/mm/2s2h/BenPort.cpp +++ b/mm/2s2h/BenPort.cpp @@ -162,9 +162,17 @@ OTRGlobals::OTRGlobals() { std::unordered_set validHashes = { MM_NTSC_US_10, MM_NTSC_US_GC }; // tell LUS to reserve 3 SoH specific threads (Game, Audio, Save) - context = - Ship::Context::CreateInstance("2 Ship 2 Harkinian", appShortName, "2ship2harkinian.json", archiveFiles, {}, 3, - { .SampleRate = 32000, .SampleLength = 1024, .DesiredBuffered = 1680 }); + context = Ship::Context::CreateUninitializedInstance("2 Ship 2 Harkinian", appShortName, "2ship2harkinian.json"); + context->InitLogging(); + context->InitConfiguration(); + context->InitConsoleVariables(); + context->InitResourceManager(archiveFiles, {}, 3); + context->InitControlDeck(std::make_shared()); + context->InitCrashHandler(); + context->InitConsole(); + context->InitWindow(std::make_shared()); + context->InitAudio({ .SampleRate = 32000, .SampleLength = 1024, .DesiredBuffered = 1680 }); + context->InitGfxDebugger(); SPDLOG_INFO("Starting 2 Ship 2 Harkinian version {}", (char*)gBuildVersion); From ed2a65c337a50d1b6e052bc981b75a763f0351d1 Mon Sep 17 00:00:00 2001 From: lightmanLP <50497969+lightmanLP@users.noreply.github.com> Date: Mon, 30 Dec 2024 00:12:02 +0000 Subject: [PATCH 08/14] clang-format --- mm/2s2h/BenPort.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/2s2h/BenPort.cpp b/mm/2s2h/BenPort.cpp index 6b1af5aff..35151f7a3 100644 --- a/mm/2s2h/BenPort.cpp +++ b/mm/2s2h/BenPort.cpp @@ -198,8 +198,9 @@ OTRGlobals::OTRGlobals() { "Vertex", static_cast(Fast::ResourceType::Vertex), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "Vertex", static_cast(Fast::ResourceType::Vertex), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, - "DisplayList", static_cast(Fast::ResourceType::DisplayList), 0); + loader->RegisterResourceFactory(std::make_shared(), + RESOURCE_FORMAT_BINARY, "DisplayList", + static_cast(Fast::ResourceType::DisplayList), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "DisplayList", static_cast(Fast::ResourceType::DisplayList), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, From 6d1566f7e5a88254f27e6a1d533e769d273673f9 Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Sat, 18 Jan 2025 14:02:04 +0700 Subject: [PATCH 09/14] Update libultraship --- libultraship | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship b/libultraship index 3e46fe77a..31df12cdb 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 3e46fe77a4581a84f9c0edfab9c3a69a5320fe01 +Subproject commit 31df12cdb7b877f4f0790dcc216a2c9d3823d58b From 597b712b35be82c0ee778d6b396f3e642a31d26d Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Sat, 18 Jan 2025 14:59:17 +0700 Subject: [PATCH 10/14] rename --- mm/2s2h/BenGui/CosmeticEditor.cpp | 6 +++--- mm/2s2h/BenGui/HudEditor.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/2s2h/BenGui/CosmeticEditor.cpp b/mm/2s2h/BenGui/CosmeticEditor.cpp index f783150b6..531f576eb 100644 --- a/mm/2s2h/BenGui/CosmeticEditor.cpp +++ b/mm/2s2h/BenGui/CosmeticEditor.cpp @@ -155,7 +155,7 @@ void CosmeticEditorRandomizeElement(CosmeticEditorElement element) { CVarSetColor(element.colorCvar, colorSelected); CVarSetInteger(element.colorChangedCvar, true); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } void CosmeticEditorRandomizeAllElements() { @@ -217,13 +217,13 @@ void CosmeticEditorDrawColorTab() { CVarSetColor(entry.colorCvar, colorSelected); CVarSetInteger(entry.colorChangedCvar, true); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::SameLine(); if (ImGui::Button(ICON_FA_UNDO, ImVec2(27.0f, 27.0f))) { CVarClear(entry.colorCvar); CVarClear(entry.colorChangedCvar); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::SameLine(); if (ImGui::Button(ICON_FA_RECYCLE, ImVec2(27.0f, 27.0f))) { diff --git a/mm/2s2h/BenGui/HudEditor.cpp b/mm/2s2h/BenGui/HudEditor.cpp index 2c45b183a..d49e8a409 100644 --- a/mm/2s2h/BenGui/HudEditor.cpp +++ b/mm/2s2h/BenGui/HudEditor.cpp @@ -255,14 +255,14 @@ void HudEditorWindow::DrawElement() { CVarSetColor(hudEditorElements[i].colorCvar, colorSelected); CVarSetInteger(hudEditorElements[i].colorChangedCvar, true); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::SameLine(); if (ImGui::Button(ICON_FA_REFRESH)) { float color[4] = { defaultColor[0], defaultColor[1], defaultColor[2], defaultColor[3] }; CVarClear(hudEditorElements[i].colorCvar); CVarClear(hudEditorElements[i].colorChangedCvar); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } ImGui::SameLine(); if (UIWidgets::CVarCombobox("Mode", hudEditorElements[i].modeCvar, modeNames, From d9eb6388a9690fcb035c63b48ceb180256c72761 Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Sat, 18 Jan 2025 16:36:58 +0700 Subject: [PATCH 11/14] imgui things --- mm/2s2h/BenGui/BenGui.cpp | 1 - mm/2s2h/BenGui/BenInputEditorWindow.h | 3 --- mm/2s2h/BenGui/UIWidgets.cpp | 3 +-- mm/2s2h/BenGui/UIWidgets.hpp | 1 - mm/2s2h/DeveloperTools/SaveEditor.cpp | 25 +++++++++++++++++-------- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/mm/2s2h/BenGui/BenGui.cpp b/mm/2s2h/BenGui/BenGui.cpp index b2e587474..8f7eab573 100644 --- a/mm/2s2h/BenGui/BenGui.cpp +++ b/mm/2s2h/BenGui/BenGui.cpp @@ -2,7 +2,6 @@ #include #include -#define IMGUI_DEFINE_MATH_OPERATORS #include #include #include diff --git a/mm/2s2h/BenGui/BenInputEditorWindow.h b/mm/2s2h/BenGui/BenInputEditorWindow.h index 038a53108..6a54080ac 100644 --- a/mm/2s2h/BenGui/BenInputEditorWindow.h +++ b/mm/2s2h/BenGui/BenInputEditorWindow.h @@ -2,9 +2,6 @@ #include "stdint.h" #include "window/gui/GuiWindow.h" -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif #include #include #include diff --git a/mm/2s2h/BenGui/UIWidgets.cpp b/mm/2s2h/BenGui/UIWidgets.cpp index 981e022b3..4e5c5c436 100644 --- a/mm/2s2h/BenGui/UIWidgets.cpp +++ b/mm/2s2h/BenGui/UIWidgets.cpp @@ -1,5 +1,4 @@ #include "UIWidgets.hpp" -#define IMGUI_DEFINE_MATH_OPERATORS #include #include #include @@ -247,7 +246,7 @@ bool Checkbox(const char* _label, bool* value, const CheckboxOptions& options) { : ImGuiCol_FrameBg), true, style.FrameRounding); ImU32 check_col = ImGui::GetColorU32(ImGuiCol_CheckMark); - bool mixed_value = (g.LastItemData.InFlags & ImGuiItemFlags_MixedValue) != 0; + bool mixed_value = (g.LastItemData.ItemFlags & ImGuiItemFlags_MixedValue) != 0; if (mixed_value) { // Undocumented tristate/mixed/indeterminate checkbox (#2644) // This may seem awkwardly designed because the aim is to make ImGuiItemFlags_MixedValue supported by all diff --git a/mm/2s2h/BenGui/UIWidgets.hpp b/mm/2s2h/BenGui/UIWidgets.hpp index a6b97bb9c..05f2a7e1b 100644 --- a/mm/2s2h/BenGui/UIWidgets.hpp +++ b/mm/2s2h/BenGui/UIWidgets.hpp @@ -5,7 +5,6 @@ #include #include #include -#define IMGUI_DEFINE_MATH_OPERATORS #include #include #include diff --git a/mm/2s2h/DeveloperTools/SaveEditor.cpp b/mm/2s2h/DeveloperTools/SaveEditor.cpp index dcef87ac5..1439fff57 100644 --- a/mm/2s2h/DeveloperTools/SaveEditor.cpp +++ b/mm/2s2h/DeveloperTools/SaveEditor.cpp @@ -722,16 +722,20 @@ void DrawSlot(InventorySlot slot) { } ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 2.0f); - ImTextureID textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( - (const char*)gItemIcons[safeItemsForInventorySlot[slot][0]]); + const char* textureName = (const char*)gItemIcons[safeItemsForInventorySlot[slot][0]]; + ImTextureID textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(textureName); if (currentItemId != ITEM_NONE) { + textureName = (const char*)gItemIcons[currentItemId]; textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( - (const char*)gItemIcons[currentItemId]); + textureName); } - if (ImGui::ImageButton(textureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), 0, - ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, currentItemId == ITEM_NONE ? 0.4f : 1.0f))) { + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); + auto imgBtn = ImGui::ImageButton(textureName, textureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), + ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, currentItemId == ITEM_NONE ? 0.4f : 1.0f)); + ImGui::PopStyleVar(); + if (imgBtn) { if (safeMode && safeItemsForInventorySlot[slot].size() < 2) { NextItemInSlot(slot); } else { @@ -761,9 +765,14 @@ void DrawSlot(InventorySlot slot) { } ItemId id = safeMode ? safeItemsForInventorySlot[selectedInventorySlot][pickerIndex] : static_cast(pickerIndex); - if (ImGui::ImageButton( - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName((const char*)gItemIcons[id]), - ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), 0)) { + const char* textureName = (const char*)gItemIcons[id]; + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); + auto imgBtn = ImGui::ImageButton( + textureName, + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(textureName), + ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1)); + ImGui::PopStyleVar(); + if (imgBtn) { gSaveContext.save.saveInfo.inventory.items[selectedInventorySlot] = id; ImGui::CloseCurrentPopup(); } From c39e0e3df2379d712dda831e3b70b09e4f296721 Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Sun, 19 Jan 2025 20:31:00 +0700 Subject: [PATCH 12/14] Portside window calls https://github.com/HarbourMasters/Shipwright/commit/4e8ccce002ce1503887891cabc7577678bc95c5a --- mm/2s2h/BenPort.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mm/2s2h/BenPort.cpp b/mm/2s2h/BenPort.cpp index 35151f7a3..941ac34df 100644 --- a/mm/2s2h/BenPort.cpp +++ b/mm/2s2h/BenPort.cpp @@ -848,14 +848,18 @@ extern "C" void Graph_StartFrame() { CVarClear(CVAR_NEW_FILE_DROPPED); CVarClear(CVAR_DROPPED_FILE); } - - OTRGlobals::Instance->context->GetWindow()->StartFrame(); } void RunCommands(Gfx* Commands, const std::vector>& mtx_replacements) { + auto wnd = std::dynamic_pointer_cast(OTRGlobals::Instance->context->GetWindow()); + if (wnd == nullptr) { + return; + } + // Process window events for resize, mouse, keyboard events + wnd->HandleEvents(); + for (const auto& m : mtx_replacements) { - gfx_run(Commands, m); - gfx_end_frame(); + wnd->DrawAndRunGraphicsCommands(Commands, m); } } From cdb3e0c9970d6c3953ac294867a61a1d8dd0bfad Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Sun, 19 Jan 2025 20:43:53 +0700 Subject: [PATCH 13/14] clang format --- mm/2s2h/DeveloperTools/SaveEditor.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mm/2s2h/DeveloperTools/SaveEditor.cpp b/mm/2s2h/DeveloperTools/SaveEditor.cpp index 1439fff57..5820247a5 100644 --- a/mm/2s2h/DeveloperTools/SaveEditor.cpp +++ b/mm/2s2h/DeveloperTools/SaveEditor.cpp @@ -727,13 +727,13 @@ void DrawSlot(InventorySlot slot) { if (currentItemId != ITEM_NONE) { textureName = (const char*)gItemIcons[currentItemId]; - textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( - textureName); + textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(textureName); } ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); - auto imgBtn = ImGui::ImageButton(textureName, textureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), - ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, currentItemId == ITEM_NONE ? 0.4f : 1.0f)); + auto imgBtn = + ImGui::ImageButton(textureName, textureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), + ImVec2(1, 1), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, currentItemId == ITEM_NONE ? 0.4f : 1.0f)); ImGui::PopStyleVar(); if (imgBtn) { if (safeMode && safeItemsForInventorySlot[slot].size() < 2) { @@ -768,9 +768,8 @@ void DrawSlot(InventorySlot slot) { const char* textureName = (const char*)gItemIcons[id]; ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); auto imgBtn = ImGui::ImageButton( - textureName, - Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(textureName), - ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1)); + textureName, Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(textureName), + ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1)); ImGui::PopStyleVar(); if (imgBtn) { gSaveContext.save.saveInfo.inventory.items[selectedInventorySlot] = id; From 5e06596471e81c44487446c98db0a063936f54a4 Mon Sep 17 00:00:00 2001 From: lightmanLP Date: Mon, 20 Jan 2025 19:49:22 +0700 Subject: [PATCH 14/14] TEMP imgui cache issues fix --- CMakeLists.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c39446910..df38bfd49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,12 @@ include(CMake/GlobalSettingsInclude.cmake OPTIONAL) ################################################################################ set_property(GLOBAL PROPERTY USE_FOLDERS ON) +# FIXME: temp patch to resolve imgui cache issues +execute_process( + COMMAND git reset --hard + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/_deps/imgui-src +) + ################################################################################ # Sub-projects ################################################################################ @@ -240,3 +246,17 @@ endif() set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/CMake/Packaging-2.cmake) include(CMake/Packaging.cmake) + +# FIXME: temp patch to resolve imgui cache issues +execute_process( + COMMAND git config --local user.email "author@example.com" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/_deps/imgui-src +) +execute_process( + COMMAND git config --local user.name "Noname" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/_deps/imgui-src +) +execute_process( + COMMAND git commit -a -m patch + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/_deps/imgui-src +)