4jcraft/Minecraft.Client/Platform/Common/UI/UIScene_DeathMenu.cpp
MatthewBeshay a0fdc643d1 Merge branch 'upstream-dev' into cleanup/nullptr-replacement
# Conflicts:
#	Minecraft.Client/Network/PlayerChunkMap.cpp
#	Minecraft.Client/Network/PlayerList.cpp
#	Minecraft.Client/Network/ServerChunkCache.cpp
#	Minecraft.Client/Platform/Common/Consoles_App.cpp
#	Minecraft.Client/Platform/Common/DLC/DLCManager.cpp
#	Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp
#	Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp
#	Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp
#	Minecraft.Client/Platform/Common/Tutorial/TutorialTask.cpp
#	Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp
#	Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp
#	Minecraft.Client/Platform/Common/UI/UIController.cpp
#	Minecraft.Client/Platform/Common/UI/UIController.h
#	Minecraft.Client/Platform/Extrax64Stubs.cpp
#	Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h
#	Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Storage.h
#	Minecraft.Client/Player/EntityTracker.cpp
#	Minecraft.Client/Player/ServerPlayer.cpp
#	Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp
#	Minecraft.Client/Textures/Packs/DLCTexturePack.cpp
#	Minecraft.Client/Textures/Stitching/StitchedTexture.cpp
#	Minecraft.Client/Textures/Stitching/TextureMap.cpp
#	Minecraft.Client/Textures/Textures.cpp
#	Minecraft.World/Blocks/NotGateTile.cpp
#	Minecraft.World/Blocks/PressurePlateTile.cpp
#	Minecraft.World/Blocks/TileEntities/PotionBrewing.cpp
#	Minecraft.World/Enchantments/EnchantmentHelper.cpp
#	Minecraft.World/Entities/HangingEntity.cpp
#	Minecraft.World/Entities/LeashFenceKnotEntity.cpp
#	Minecraft.World/Entities/LivingEntity.cpp
#	Minecraft.World/Entities/Mobs/Boat.cpp
#	Minecraft.World/Entities/Mobs/Minecart.cpp
#	Minecraft.World/Entities/Mobs/Witch.cpp
#	Minecraft.World/Entities/SyncedEntityData.cpp
#	Minecraft.World/Items/LeashItem.cpp
#	Minecraft.World/Items/PotionItem.cpp
#	Minecraft.World/Level/BaseMobSpawner.cpp
#	Minecraft.World/Level/CustomLevelSource.cpp
#	Minecraft.World/Level/Level.cpp
#	Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp
#	Minecraft.World/Level/Storage/McRegionLevelStorage.cpp
#	Minecraft.World/Level/Storage/RegionFileCache.cpp
#	Minecraft.World/Player/Player.cpp
#	Minecraft.World/WorldGen/Biomes/BiomeCache.cpp
#	Minecraft.World/WorldGen/Features/RandomScatteredLargeFeature.cpp
#	Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp
2026-03-30 16:28:40 +11:00

163 lines
6.3 KiB
C++

#include "../../Minecraft.World/Platform/stdafx.h"
#include "UI.h"
#include "UIScene_DeathMenu.h"
#include "IUIScene_PauseMenu.h"
#include "../../Minecraft.Client/Minecraft.h"
#include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h"
UIScene_DeathMenu::UIScene_DeathMenu(int iPad, void* initData,
UILayer* parentLayer)
: UIScene(iPad, parentLayer) {
// Setup all the Iggy references we need for this scene
initialiseMovie();
m_buttonRespawn.init(app.GetString(IDS_RESPAWN), eControl_Respawn);
m_buttonExitGame.init(app.GetString(IDS_EXIT_GAME), eControl_ExitGame);
m_labelTitle.setLabel(app.GetString(IDS_YOU_DIED));
m_bIgnoreInput = false;
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft != nullptr && pMinecraft->localgameModes[iPad] != nullptr) {
TutorialMode* gameMode =
(TutorialMode*)pMinecraft->localgameModes[iPad];
// This just allows it to be shown
gameMode->getTutorial()->showTutorialPopup(false);
}
}
UIScene_DeathMenu::~UIScene_DeathMenu() {
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft != nullptr && pMinecraft->localgameModes[m_iPad] != nullptr) {
TutorialMode* gameMode =
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
// This just allows it to be shown
gameMode->getTutorial()->showTutorialPopup(true);
}
}
std::wstring UIScene_DeathMenu::getMoviePath() {
if (app.GetLocalPlayerCount() > 1) {
return L"DeathMenuSplit";
} else {
return L"DeathMenu";
}
}
void UIScene_DeathMenu::updateTooltips() {
ui.SetTooltips(m_iPad, IDS_TOOLTIPS_SELECT);
}
void UIScene_DeathMenu::handleInput(int iPad, int key, bool repeat,
bool pressed, bool released,
bool& handled) {
if (m_bIgnoreInput) return;
ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released);
switch (key) {
case ACTION_MENU_CANCEL:
handled = true;
break;
case ACTION_MENU_OK:
case ACTION_MENU_UP:
case ACTION_MENU_DOWN:
sendInputToMovie(key, repeat, pressed, released);
handled = true;
break;
}
}
void UIScene_DeathMenu::handlePress(F64 controlId, F64 childId) {
switch ((int)controlId) {
case eControl_Respawn:
m_bIgnoreInput = true;
app.SetAction(m_iPad, eAppAction_Respawn);
break;
case eControl_ExitGame: {
Minecraft* pMinecraft = Minecraft::GetInstance();
// 4J-PB - fix for #8333 - BLOCKER: If player decides to exit game,
// then cancels the exit player becomes stuck at game over screen
// m_bIgnoreInput = true;
// Check if it's the trial version
if (ProfileManager.IsFullVersion()) {
// is it the primary player exiting?
if (m_iPad == ProfileManager.GetPrimaryPad()) {
unsigned int uiIDA[3];
int playTime = -1;
if (pMinecraft->localplayers[m_iPad] != nullptr) {
playTime = (int)pMinecraft->localplayers[m_iPad]
->getSessionTimer();
}
TelemetryManager->RecordLevelExit(
m_iPad, eSen_LevelExitStatus_Failed);
if (StorageManager.GetSaveDisabled()) {
uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK;
ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST,
uiIDA, 2, m_iPad,
&IUIScene_PauseMenu::ExitGameDialogReturned,
(void*)GetCallbackUniqueId());
} else {
if (g_NetworkManager.IsHost()) {
uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_EXIT_GAME_SAVE;
uiIDA[2] = IDS_EXIT_GAME_NO_SAVE;
ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3,
m_iPad,
&IUIScene_PauseMenu::ExitGameSaveDialogReturned,
(void*)GetCallbackUniqueId());
} else {
uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK;
ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2,
m_iPad,
&IUIScene_PauseMenu::ExitGameDialogReturned,
(void*)GetCallbackUniqueId());
}
}
} else {
TelemetryManager->RecordLevelExit(
m_iPad, eSen_LevelExitStatus_Failed);
// just exit the player
app.SetAction(m_iPad, eAppAction_ExitPlayer);
}
} else {
// is it the primary player exiting?
if (m_iPad == ProfileManager.GetPrimaryPad()) {
TelemetryManager->RecordLevelExit(
m_iPad, eSen_LevelExitStatus_Failed);
// adjust the trial time played
ui.ReduceTrialTimerValue();
// exit the level
unsigned int uiIDA[2];
uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK;
ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST,
uiIDA, 2, m_iPad,
&IUIScene_PauseMenu::ExitGameDialogReturned,
(void*)GetCallbackUniqueId());
} else {
TelemetryManager->RecordLevelExit(
m_iPad, eSen_LevelExitStatus_Failed);
// just exit the player
app.SetAction(m_iPad, eAppAction_ExitPlayer);
}
}
} break;
}
}