diff --git a/soh/include/z64save.h b/soh/include/z64save.h index 4095f665fc6..4ee0a848194 100644 --- a/soh/include/z64save.h +++ b/soh/include/z64save.h @@ -182,6 +182,10 @@ typedef struct { u8 damageValue; s16 playerHealth; s16 playerHealthCapacity; + s16 playerMagic; + s16 playerMagicCapacity; + s16 isPlayerMagicAcquired; + s16 isDoubleMagicAcquired; s32 strengthValue; f32 yOffset; u8 currentMask; diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Anchor.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Anchor.cpp index a70a66d1fb3..14221d49f1d 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Anchor.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Anchor.cpp @@ -53,6 +53,10 @@ void from_json(const json& j, PlayerData& playerData) { j.at("damageValue").get_to(playerData.damageValue); j.at("playerHealth").get_to(playerData.playerHealth); j.at("playerHealthCapacity").get_to(playerData.playerHealthCapacity); + j.at("playerMagic").get_to(playerData.playerMagic); + j.at("playerMagicCapacity").get_to(playerData.playerMagicCapacity); + j.at("isPlayerMagicAcquired").get_to(playerData.isPlayerMagicAcquired); + j.at("isDoubleMagicAcquired").get_to(playerData.isDoubleMagicAcquired); j.at("strengthValue").get_to(playerData.strengthValue); j.at("yOffset").get_to(playerData.yOffset); j.at("currentMask").get_to(playerData.currentMask); @@ -90,6 +94,10 @@ void to_json(json& j, const PlayerData& playerData) { { "damageValue", playerData.damageValue }, { "playerHealth", playerData.playerHealth }, { "playerHealthCapacity", playerData.playerHealthCapacity }, + { "playerMagic", playerData.playerMagic }, + { "playerMagicCapacity", playerData.playerMagicCapacity }, + { "isPlayerMagicAcquired", playerData.isPlayerMagicAcquired }, + { "isDoubleMagicAcquired", playerData.isDoubleMagicAcquired }, { "strengthValue", playerData.strengthValue }, { "yOffset", playerData.yOffset }, { "currentMask", playerData.currentMask }, @@ -810,6 +818,10 @@ void Anchor_RegisterHooks() { gSaveContext.playerData.playerAge = gSaveContext.linkAge; gSaveContext.playerData.playerHealth = gSaveContext.health; gSaveContext.playerData.playerHealthCapacity = gSaveContext.healthCapacity; + gSaveContext.playerData.playerMagic = gSaveContext.magic; + gSaveContext.playerData.playerMagicCapacity = gSaveContext.magicCapacity; + gSaveContext.playerData.isPlayerMagicAcquired = gSaveContext.isMagicAcquired; + gSaveContext.playerData.isDoubleMagicAcquired = gSaveContext.isDoubleMagicAcquired; gSaveContext.playerData.strengthValue = CUR_UPG_VALUE(UPG_STRENGTH); gSaveContext.playerData.yOffset = player->actor.shape.yOffset; gSaveContext.playerData.currentMask = player->currentMask; @@ -940,15 +952,14 @@ const char* heartTextureNames[16] = { void DisplayLifeMeter(AnchorClient& client) { int currentHealth = client.playerData.playerHealth; int maxHealth = client.playerData.playerHealthCapacity; + int currentMagic = client.playerData.playerMagic; + int maxMagic = client.playerData.playerMagicCapacity; int fullHearts = currentHealth / 16; int partialHealth = currentHealth % 16; const ImVec4 normalHeartsColor = ImVec4(1, 0.275f, 0.118f, 1); - // const ImVec4 doubleDefenseHeartsColor = ImVec4(1, 1, 1, 1); - // ImVec4 heartsColor = gSaveContext.isDoubleDefenseAcquired ? doubleDefenseHeartsColor : normalHeartsColor; - int numMaxHearts = maxHealth / 16; int numLines = (numMaxHearts / 10) + 1; @@ -966,9 +977,18 @@ void DisplayLifeMeter(AnchorClient& client) { "Heart_Empty", "textures/parameter_static/gHeartEmptyTex", normalHeartsColor); heartTexturesLoaded = true; } + if (CVarGetInteger("gAnchorPlayerHealth", 0) == 1 || CVarGetInteger("gAnchorPlayerHealth", 0) == 3) { std::string healthInfo = "Life: " + std::to_string(currentHealth) + " / " + std::to_string(maxHealth); ImGui::Text(healthInfo.c_str()); + if (client.playerData.isPlayerMagicAcquired || client.playerData.isDoubleMagicAcquired) { + std::string magichInfo = " | Magic: " + std::to_string(currentMagic) + " / " + std::to_string(maxMagic); + ImGui::SameLine(); + ImGui::Text(magichInfo.c_str()); + } + if (CVarGetInteger("gAnchorPlayerHealth", 0) == 1) { + ImGui::Separator(); + } } if (CVarGetInteger("gAnchorPlayerHealth", 0) == 2 || CVarGetInteger("gAnchorPlayerHealth", 0) == 3) { @@ -989,28 +1009,46 @@ void DisplayLifeMeter(AnchorClient& client) { } if (heartIndex < fullHearts) { - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Heart_Full"), - imageSize); + ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Heart_Full"), imageSize); } else if (heartIndex == fullHearts) { - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( - heartTextureNames[partialHealth]), - imageSize); + if (currentHealth == 0) { + ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Heart_Empty"), imageSize); + } else { + ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(heartTextureNames[partialHealth]), imageSize); + } } else { - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Heart_Empty"), - imageSize); + ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Heart_Empty"), imageSize); } } if (line < numLines - 1) { ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 2)); } + } - if (line < numLines - 1) { - ImGui::PopStyleVar(); + if (client.playerData.isPlayerMagicAcquired) { + ImGui::Spacing(); + ImVec4 magicBarColor = ImVec4(0, 1, 0, 1); + float magicBarItemWidth = 168.0f; + float magicBarItemHeight = 6.0f; + const char* label = ""; + + if (!client.playerData.isDoubleMagicAcquired) { + magicBarItemWidth /= 2; } + + float currentMagicRatio = static_cast(currentMagic) / maxMagic; + + ImGui::BeginGroup(); + + ImGui::PushStyleColor(ImGuiCol_PlotHistogram, magicBarColor); + ImGui::ProgressBar(currentMagicRatio, ImVec2(magicBarItemWidth, magicBarItemHeight), label); + ImGui::PopStyleColor(); + ImGui::EndGroup(); } ImGui::PopStyleVar(); + ImGui::Separator(); } } diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index b538ac9d8e2..9ce2b0121a8 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1421,7 +1421,7 @@ bool isStringEmpty(std::string str) { } #ifdef ENABLE_REMOTE_CONTROL -static const char* anchorPlayerHealth[4] = { "Disabled", "Numeric", "Hearts", "Numeric + Hearts" }; +static const char* anchorPlayerHealth[4] = { "Disabled", "Numeric", "Hearts and Magic", "Numeric + Hearts and Magic" }; void DrawRemoteControlMenu() { if (ImGui::BeginMenu("Network")) {