orbit high score fix

This commit is contained in:
2026-04-09 14:38:00 -04:00
parent eeefdcf2d9
commit 83f5ab13f9
2 changed files with 11 additions and 14 deletions

View File

@@ -262,6 +262,7 @@ namespace game::state::play::menu::arcade
cursorPosition = {}; cursorPosition = {};
centerPosition = {}; centerPosition = {};
level = 0; level = 0;
highScoreAtRunStart = highScore;
score = 0; score = 0;
isHighScoreAchievedThisRun = false; isHighScoreAchievedThisRun = false;
itemEffectManager = {}; itemEffectManager = {};
@@ -311,7 +312,8 @@ namespace game::state::play::menu::arcade
auto padding = ImGui::GetTextLineHeightWithSpacing(); auto padding = ImGui::GetTextLineHeightWithSpacing();
auto contentRegionAvail = ImGui::GetContentRegionAvail(); auto contentRegionAvail = ImGui::GetContentRegionAvail();
auto contentRegionPosition = ImGui::GetCursorScreenPos(); auto contentRegionPosition = ImGui::GetCursorScreenPos();
auto contentBounds = ImVec4(contentRegionPosition.x, contentRegionPosition.y, contentRegionAvail.x, contentRegionAvail.y); auto contentBounds =
ImVec4(contentRegionPosition.x, contentRegionPosition.y, contentRegionAvail.x, contentRegionAvail.y);
auto available = auto available =
imgui::to_vec2(contentRegionAvail) - vec2(0.0f, ImGui::GetFrameHeightWithSpacing() + style.WindowPadding.y); imgui::to_vec2(contentRegionAvail) - vec2(0.0f, ImGui::GetFrameHeightWithSpacing() + style.WindowPadding.y);
auto canvasSize = glm::max(vec2(1.0f), available - vec2(padding * 2.0f)); auto canvasSize = glm::max(vec2(1.0f), available - vec2(padding * 2.0f));
@@ -502,22 +504,17 @@ namespace game::state::play::menu::arcade
rewardChance, rewardRollCount, menu::ItemEffectManager::SHOOT_UP); rewardChance, rewardRollCount, menu::ItemEffectManager::SHOOT_UP);
if (score > highScore) if (score > highScore)
{ {
auto previousHighScore = highScore;
highScore = score; highScore = score;
if (!isHighScoreAchievedThisRun) if (!isHighScoreAchievedThisRun && highScoreAtRunStart > 0)
{ {
isHighScoreAchievedThisRun = true; isHighScoreAchievedThisRun = true;
schema.sounds.highScore.play(); schema.sounds.highScore.play();
auto toastText = strings.get(Strings::ArcadeHighScoreToast);
if (previousHighScore > 0) auto toastPosition = imgui::to_imvec2(
{ canvasScreenPosition + player->position -
auto toastText = strings.get(Strings::ArcadeHighScoreToast); vec2(ImGui::CalcTextSize(toastText.c_str()).x * 0.5f, ImGui::GetTextLineHeightWithSpacing() * 2.0f));
auto toastPosition = imgui::to_imvec2( toasts.spawn(toastText, toastPosition, 60);
canvasScreenPosition + player->position -
vec2(ImGui::CalcTextSize(toastText.c_str()).x * 0.5f, ImGui::GetTextLineHeightWithSpacing() * 2.0f));
toasts.spawn(toastText, toastPosition, 60);
}
} }
} }
} }
@@ -602,8 +599,7 @@ namespace game::state::play::menu::arcade
toasts.update(drawList); toasts.update(drawList);
auto isMenuPressed = WIDGET_FX(ImGui::Button(strings.get(Strings::ArcadeMenuBackButton).c_str())); auto isMenuPressed = WIDGET_FX(ImGui::Button(strings.get(Strings::ArcadeMenuBackButton).c_str()));
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered()) ImGui::SetItemTooltip("%s", strings.get(Strings::ArcadeMenuBackButtonTooltip).c_str());
ImGui::SetItemTooltip("%s", strings.get(Strings::ArcadeMenuBackButtonTooltip).c_str());
return isMenuPressed; return isMenuPressed;
} }
} }

View File

@@ -51,6 +51,7 @@ namespace game::state::play::menu::arcade
int level{1}; int level{1};
int score{}; int score{};
int highScore{}; int highScore{};
int highScoreAtRunStart{};
bool isHighScoreAchievedThisRun{}; bool isHighScoreAchievedThisRun{};
menu::ItemEffectManager itemEffectManager{}; menu::ItemEffectManager itemEffectManager{};
game::state::play::item::Reward itemRewards{}; game::state::play::item::Reward itemRewards{};