mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-07-10 19:28:39 +00:00
RMLUI Menu Updates.
* LoadCreateJoin Menu: Adjusted size (Is not 100% accurate but works fine), fix X Padding (Y Padding still need fixes), * Settings Menu: Added Message Box to "Reset Defaults Settings" * Pause Menu: Added Message Box for Save Game and Exit.
This commit is contained in:
@@ -25,8 +25,6 @@ UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void *initData, UILayer *parentLa
|
||||
: UIScene(iPad, parentLayer)
|
||||
, m_document(nullptr)
|
||||
, m_bIgnoreInput(false)
|
||||
, m_bExitDialog(false)
|
||||
, m_bSaveDialog(false)
|
||||
{
|
||||
Rml::Context* ctx = RmlManager::Get().GetContext();
|
||||
if (!ctx)
|
||||
@@ -47,11 +45,6 @@ UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void *initData, UILayer *parentLa
|
||||
m_document->GetElementById("achievements")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("save_game")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("exit_game")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("exit_save")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("exit_nosave")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("exit_cancel")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("save_cancel")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("save_confirm")->AddEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("resume")->Focus();
|
||||
}
|
||||
else
|
||||
@@ -77,11 +70,6 @@ UIScene_PauseMenu::~UIScene_PauseMenu()
|
||||
m_document->GetElementById("achievements")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("save_game")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("exit_game")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("exit_save")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("exit_nosave")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("exit_cancel")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("save_cancel")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->GetElementById("save_confirm")->RemoveEventListener(Rml::EventId::Click, this);
|
||||
m_document->Close();
|
||||
m_document = nullptr;
|
||||
}
|
||||
@@ -184,42 +172,25 @@ void UIScene_PauseMenu::handleInput(int iPad, int key, bool repeat, bool pressed
|
||||
{
|
||||
case ACTION_MENU_UP:
|
||||
ctx->ProcessKeyDown(Rml::Input::KI_UP, 0);
|
||||
handled = true;
|
||||
break;
|
||||
case ACTION_MENU_DOWN:
|
||||
ctx->ProcessKeyDown(Rml::Input::KI_DOWN, 0);
|
||||
handled = true;
|
||||
break;
|
||||
case ACTION_MENU_OK:
|
||||
// Only forward as keyboard Enter if actually coming from keyboard,
|
||||
// not from mouse click (mouse is handled in tick()).
|
||||
if (g_KBMInput.IsKeyPressed(VK_RETURN))
|
||||
{
|
||||
ctx->ProcessKeyDown(Rml::Input::KI_RETURN, 0);
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
case ACTION_MENU_CANCEL:
|
||||
case ACTION_MENU_PAUSEMENU:
|
||||
if (m_bExitDialog)
|
||||
{
|
||||
OnExitCancel();
|
||||
handled = true;
|
||||
}
|
||||
else if (m_bSaveDialog)
|
||||
{
|
||||
OnSaveCancel();
|
||||
handled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
navigateBack();
|
||||
handled = true;
|
||||
}
|
||||
navigateBack();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
handled = true;
|
||||
}
|
||||
|
||||
void UIScene_PauseMenu::ProcessEvent(Rml::Event& event)
|
||||
@@ -236,11 +207,6 @@ void UIScene_PauseMenu::ProcessEvent(Rml::Event& event)
|
||||
else if (id == "achievements") OnAchievements();
|
||||
else if (id == "save_game") OnSaveGame();
|
||||
else if (id == "exit_game") OnExitGame();
|
||||
else if (id == "exit_save") OnExitSave();
|
||||
else if (id == "exit_nosave") OnExitNoSave();
|
||||
else if (id == "exit_cancel") OnExitCancel();
|
||||
else if (id == "save_confirm") OnSaveConfirm();
|
||||
else if (id == "save_cancel") OnSaveCancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,114 +246,27 @@ void UIScene_PauseMenu::OnAchievements()
|
||||
ui.NavigateToScene(m_iPad, eUIScene_AchievementsMenu);
|
||||
}
|
||||
|
||||
void UIScene_PauseMenu::ShowSaveDialog(bool show)
|
||||
{
|
||||
if (!m_document)
|
||||
return;
|
||||
|
||||
auto* saveDialog = m_document->GetElementById("save_dialog");
|
||||
auto* buttons = m_document->GetElementById("buttons");
|
||||
|
||||
if (show)
|
||||
{
|
||||
if (buttons) buttons->SetProperty("display", "none");
|
||||
if (saveDialog) saveDialog->SetProperty("display", "block");
|
||||
|
||||
auto* saveText = m_document->GetElementById("save_text");
|
||||
|
||||
if (saveText)
|
||||
saveText->SetInnerRML("[IDS_CONFIRM_SAVE_GAME]");
|
||||
|
||||
m_document->GetElementById("save_cancel")->Focus();
|
||||
m_bSaveDialog = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (saveDialog) saveDialog->SetProperty("display", "none");
|
||||
if (buttons) buttons->SetProperty("display", "block");
|
||||
|
||||
m_document->GetElementById("save_game")->Focus();
|
||||
m_bSaveDialog = false;
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_PauseMenu::OnSaveGame()
|
||||
{
|
||||
if (m_iPad != ProfileManager.GetPrimaryPad())
|
||||
return;
|
||||
|
||||
// Does the save exist?
|
||||
bool bSaveExists;
|
||||
StorageManager.DoesSaveExist(&bSaveExists);
|
||||
|
||||
// We need to ask if they are sure they want to overwrite the existing game
|
||||
if (bSaveExists)
|
||||
ShowSaveDialog(true);
|
||||
else
|
||||
app.SetAction(m_iPad, eAppAction_SaveGame);
|
||||
}
|
||||
|
||||
void UIScene_PauseMenu::OnSaveConfirm()
|
||||
{
|
||||
ShowSaveDialog(false);
|
||||
app.SetAction(m_iPad, eAppAction_SaveGame);
|
||||
}
|
||||
|
||||
void UIScene_PauseMenu::OnSaveCancel()
|
||||
{
|
||||
ShowSaveDialog(false);
|
||||
}
|
||||
|
||||
void UIScene_PauseMenu::ShowExitDialog(bool show)
|
||||
{
|
||||
if (!m_document)
|
||||
return;
|
||||
|
||||
auto* exitDialog = m_document->GetElementById("exit_dialog");
|
||||
auto* buttons = m_document->GetElementById("buttons");
|
||||
|
||||
if (show)
|
||||
{
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (buttons) buttons->SetProperty("display", "none");
|
||||
if (exitDialog) exitDialog->SetProperty("display", "block");
|
||||
|
||||
// Configure dialog for current state
|
||||
auto* exitSave = m_document->GetElementById("exit_save");
|
||||
auto* exitNosave = m_document->GetElementById("exit_nosave");
|
||||
auto* exitCancel = m_document->GetElementById("exit_cancel");
|
||||
auto* exitText = m_document->GetElementById("exit_text");
|
||||
|
||||
if (m_iPad == ProfileManager.GetPrimaryPad())
|
||||
{
|
||||
if (exitSave)
|
||||
exitSave->SetProperty("display", "inline-block");
|
||||
if (exitNosave)
|
||||
exitNosave->SetProperty("display", "inline-block");
|
||||
|
||||
if (g_NetworkManager.GetPlayerCount() > 1)
|
||||
if (exitText) exitText->SetInnerRML("[IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE]");
|
||||
else
|
||||
if (exitText) exitText->SetInnerRML("[IDS_CONFIRM_EXIT_GAME]");
|
||||
|
||||
if (exitCancel) exitCancel->Focus();
|
||||
}
|
||||
|
||||
m_bExitDialog = true;
|
||||
UINT uiIDA[2];
|
||||
uiIDA[0] = IDS_CONFIRM_CANCEL;
|
||||
uiIDA[1] = IDS_CONFIRM_OK;
|
||||
ui.RequestAlertMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, m_iPad, &IUIScene_PauseMenu::SaveGameDialogReturned, (LPVOID)GetCallbackUniqueId());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (exitDialog) exitDialog->SetProperty("display", "none");
|
||||
if (buttons) buttons->SetProperty("display", "block");
|
||||
|
||||
// Restore default button state
|
||||
auto* exitSave = m_document->GetElementById("exit_save");
|
||||
auto* exitNosave = m_document->GetElementById("exit_nosave");
|
||||
if (exitSave) exitSave->SetProperty("display", "inline-block");
|
||||
if (exitNosave) exitNosave->SetInnerRML("[IDS_EXIT_GAME_NO_SAVE]");
|
||||
if (exitNosave) exitNosave->SetProperty("display", "inline-block");
|
||||
|
||||
m_document->GetElementById("exit_game")->Focus();
|
||||
m_bExitDialog = false;
|
||||
// Flag a app action of save game
|
||||
app.SetAction(m_iPad, eAppAction_SaveGame);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,51 +274,53 @@ void UIScene_PauseMenu::OnExitGame()
|
||||
{
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
// Non-primary pad: exit directly without dialog
|
||||
if (m_iPad != ProfileManager.GetPrimaryPad())
|
||||
UINT uiIDA[3];
|
||||
|
||||
// Is it the primary player exiting?
|
||||
if (m_iPad == ProfileManager.GetPrimaryPad())
|
||||
{
|
||||
int playTime = -1;
|
||||
if (pMinecraft->localplayers[m_iPad] != NULL)
|
||||
playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer();
|
||||
|
||||
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, (LPVOID)GetCallbackUniqueId());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_NetworkManager.IsHost())
|
||||
{
|
||||
uiIDA[0] = IDS_CONFIRM_CANCEL;
|
||||
uiIDA[1] = IDS_EXIT_GAME_SAVE;
|
||||
uiIDA[2] = IDS_EXIT_GAME_NO_SAVE;
|
||||
|
||||
if (g_NetworkManager.GetPlayerCount() > 1)
|
||||
ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, uiIDA, 3, m_iPad, &UIScene_PauseMenu::ExitGameSaveDialogReturned, (LPVOID)GetCallbackUniqueId());
|
||||
else
|
||||
ui.RequestAlertMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, m_iPad, &UIScene_PauseMenu::ExitGameSaveDialogReturned, (LPVOID)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, (LPVOID)GetCallbackUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Non-primary pad: exit directly without dialog
|
||||
{
|
||||
int playTime = -1;
|
||||
if (pMinecraft->localplayers[m_iPad] != NULL)
|
||||
playTime = (int)pMinecraft->localplayers[m_iPad]->getSessionTimer();
|
||||
|
||||
if (pMinecraft->localplayers[m_iPad] != nullptr)
|
||||
TelemetryManager->RecordLevelExit(m_iPad, eSen_LevelExitStatus_Exited);
|
||||
|
||||
app.SetAction(m_iPad, eAppAction_ExitPlayer);
|
||||
return;
|
||||
}
|
||||
|
||||
// Primary pad: show inline confirmation dialog (no Iggy MessageBox)
|
||||
ShowExitDialog(true);
|
||||
}
|
||||
|
||||
void UIScene_PauseMenu::OnExitSave()
|
||||
{
|
||||
ShowExitDialog(false);
|
||||
SetIgnoreInput(true);
|
||||
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft->localplayers[m_iPad] != nullptr)
|
||||
{
|
||||
int playTime = static_cast<int>(pMinecraft->localplayers[m_iPad]->getSessionTimer());
|
||||
TelemetryManager->RecordLevelExit(m_iPad, eSen_LevelExitStatus_Exited);
|
||||
}
|
||||
|
||||
MinecraftServer::getInstance()->setSaveOnExit(true);
|
||||
app.SetAction(m_iPad, eAppAction_ExitWorld);
|
||||
}
|
||||
|
||||
void UIScene_PauseMenu::OnExitNoSave()
|
||||
{
|
||||
ShowExitDialog(false);
|
||||
SetIgnoreInput(true);
|
||||
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft->localplayers[m_iPad] != nullptr)
|
||||
{
|
||||
int playTime = static_cast<int>(pMinecraft->localplayers[m_iPad]->getSessionTimer());
|
||||
TelemetryManager->RecordLevelExit(m_iPad, eSen_LevelExitStatus_Exited);
|
||||
}
|
||||
|
||||
app.SetAction(m_iPad, eAppAction_ExitWorld);
|
||||
}
|
||||
|
||||
void UIScene_PauseMenu::OnExitCancel()
|
||||
{
|
||||
ShowExitDialog(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user