Refactored CMainDialog

master
krzys-h 2015-08-06 16:02:59 +02:00
parent f29a826ad2
commit 711643b454
14 changed files with 257 additions and 313 deletions

View File

@ -137,24 +137,12 @@ msgstr ""
msgid "Strip color:"
msgstr ""
msgid "Do you want to quit Colobot: Gold Edition?"
msgstr ""
msgid "Quit\\Quit Colobot: Gold Edition"
msgstr ""
msgid "Quit the mission?"
msgstr ""
msgid "Abort\\Abort the current mission"
msgstr ""
msgid "Continue\\Continue the current mission"
msgstr ""
msgid "Continue\\Continue the game"
msgstr ""
msgid "Do you really want to destroy the selected building?"
msgstr ""
@ -162,10 +150,10 @@ msgstr ""
msgid "Do you want to delete %s's saved games? "
msgstr ""
msgid "Delete"
msgid "Yes"
msgstr ""
msgid "Cancel"
msgid "No"
msgstr ""
msgid "LOADING"
@ -255,6 +243,9 @@ msgstr ""
msgid "OK"
msgstr ""
msgid "Cancel"
msgstr ""
msgid "Next"
msgstr ""
@ -294,6 +285,9 @@ msgstr ""
msgid "\\Return to Colobot: Gold Edition"
msgstr ""
msgid "Quit\\Quit Colobot: Gold Edition"
msgstr ""
msgid "<< Back \\Back to the previous screen"
msgstr ""

View File

@ -436,9 +436,6 @@ msgstr "Weitermachen"
msgid "Continue\\Continue the current mission"
msgstr "Weitermachen\\Mission weitermachen"
msgid "Continue\\Continue the game"
msgstr "Weitermachen\\Weitermachen"
msgid "Controls\\Keyboard, joystick and mouse settings"
msgstr "Steuerung\\Auswahl der Tasten"
@ -463,9 +460,6 @@ msgstr "Ausschneiden (Ctrl+x)"
msgid "Defense tower"
msgstr "Geschützturm"
msgid "Delete"
msgstr "Zerstören"
#, fuzzy
msgid "Delete mark"
msgstr "Zerstören"
@ -510,10 +504,6 @@ msgstr "Wollen Sie das angewählte Gebäude wirklich zerstören ?"
msgid "Do you want to delete %s's saved games? "
msgstr "Wollen Sie die gespeicherten Missionen von %s löschen ?"
#, fuzzy
msgid "Do you want to quit Colobot: Gold Edition?"
msgstr "Wollen Sie COLOBOT schließen ?"
msgid "Doors blocked by a robot or another object "
msgstr "Die Türen werden von einem Gegenstand blockiert"
@ -902,6 +892,9 @@ msgstr "Nächster"
msgid "Next object\\Selects the next object"
msgstr "Nächstes auswählen\\Nächstes Objekt auswählen"
msgid "No"
msgstr ""
msgid "No energy in the subsoil"
msgstr "Kein unterirdisches Energievorkommen"
@ -1182,9 +1175,6 @@ msgstr "Öffentlich\\Gemeinsamer Ordner für alle Spieler"
msgid "Quake at explosions\\The screen shakes at explosions"
msgstr "Beben bei Explosionen\\Die Kamera bebt bei Explosionen"
msgid "Quit the mission?"
msgstr "Mission abbrechen ?"
msgid "Quit\\Quit Colobot: Gold Edition"
msgstr ""
@ -1708,6 +1698,9 @@ msgstr "Der Ausdruck ergibt einen falschen Typ für die Zuweisung"
msgid "Yellow flag"
msgstr "Gelbe Fahne"
msgid "Yes"
msgstr ""
msgid "You can fly with the keys (\\key gup;) and (\\key gdown;)"
msgstr "Sie können jetzt mit den Tasten \\key gup; und \\key gdown; fliegen"
@ -1855,15 +1848,28 @@ msgstr "www.epsitec.com"
#~ msgid "COLOBOT"
#~ msgstr "COLOBOT"
#~ msgid "Continue\\Continue the game"
#~ msgstr "Weitermachen\\Weitermachen"
#~ msgid "Delete"
#~ msgstr "Zerstören"
#~ msgid "Developed by :"
#~ msgstr "Entwickelt von:"
#, fuzzy
#~ msgid "Do you want to quit Colobot: Gold Edition?"
#~ msgstr "Wollen Sie COLOBOT schließen ?"
#~ msgid "Key word help\\More detailed help about key words"
#~ msgstr "Hilfe über Begriff\\Hilfe über einen Begriff"
#~ msgid "Mouse shadow\\Gives the mouse a shadow"
#~ msgstr "Schatten unter der Maus\\Ein Schatten erscheint unter der Maus"
#~ msgid "Quit the mission?"
#~ msgstr "Mission abbrechen ?"
#~ msgid "Quit\\Quit COLOBOT"
#~ msgstr "Schließen\\COLOBOT schließen"

View File

@ -431,9 +431,6 @@ msgstr "Continuer"
msgid "Continue\\Continue the current mission"
msgstr "Continuer\\Continuer la mission en cours"
msgid "Continue\\Continue the game"
msgstr "Continuer\\Continuer de jouer"
msgid "Controls\\Keyboard, joystick and mouse settings"
msgstr "Commandes\\Touches du clavier"
@ -458,9 +455,6 @@ msgstr "Couper (Ctrl+x)"
msgid "Defense tower"
msgstr "Tour de défense"
msgid "Delete"
msgstr "Détruire"
#, fuzzy
msgid "Delete mark"
msgstr "Détruire"
@ -505,10 +499,6 @@ msgstr "Voulez-vous vraiment détruire le bâtiment sélectionné ?"
msgid "Do you want to delete %s's saved games? "
msgstr "Voulez-vous détruire les sauvegardes de %s ?"
#, fuzzy
msgid "Do you want to quit Colobot: Gold Edition?"
msgstr "Voulez-vous quitter COLOBOT ?"
msgid "Doors blocked by a robot or another object "
msgstr "Portes bloquées par un robot ou un objet"
@ -898,6 +888,9 @@ msgstr "Suivant"
msgid "Next object\\Selects the next object"
msgstr "Sélectionner l'objet suivant\\Sélectionner l'objet suivant"
msgid "No"
msgstr ""
msgid "No energy in the subsoil"
msgstr "Pas d'énergie en sous-sol"
@ -1178,9 +1171,6 @@ msgstr "Public\\Dossier commun à tous les joueurs"
msgid "Quake at explosions\\The screen shakes at explosions"
msgstr "Secousses lors d'explosions\\L'écran vibre lors d'une explosion"
msgid "Quit the mission?"
msgstr "Quitter la mission ?"
msgid "Quit\\Quit Colobot: Gold Edition"
msgstr ""
@ -1703,6 +1693,9 @@ msgstr "Mauvais type de résultat pour l'assignation"
msgid "Yellow flag"
msgstr "Drapeau jaune"
msgid "Yes"
msgstr ""
msgid "You can fly with the keys (\\key gup;) and (\\key gdown;)"
msgstr ""
"Il est possible de voler avec les touches (\\key gup;) et (\\key gdown;)"
@ -1851,15 +1844,28 @@ msgstr "www.epsitec.com"
#~ msgid "COLOBOT"
#~ msgstr "COLOBOT"
#~ msgid "Continue\\Continue the game"
#~ msgstr "Continuer\\Continuer de jouer"
#~ msgid "Delete"
#~ msgstr "Détruire"
#~ msgid "Developed by :"
#~ msgstr "Développé par :"
#, fuzzy
#~ msgid "Do you want to quit Colobot: Gold Edition?"
#~ msgstr "Voulez-vous quitter COLOBOT ?"
#~ msgid "Key word help\\More detailed help about key words"
#~ msgstr "Instructions mot-clé\\Explication sur le mot-clé"
#~ msgid "Mouse shadow\\Gives the mouse a shadow"
#~ msgstr "Souris ombrée\\Jolie souris avec une ombre"
#~ msgid "Quit the mission?"
#~ msgstr "Quitter la mission ?"
#~ msgid "Quit\\Quit COLOBOT"
#~ msgstr "Quitter\\Quitter COLOBOT"

View File

@ -439,9 +439,6 @@ msgstr "Kontynuuj"
msgid "Continue\\Continue the current mission"
msgstr "Kontynuuj\\Kontynuuje bieżącą misję"
msgid "Continue\\Continue the game"
msgstr "Kontynuuj\\Kontynuuje grę"
msgid "Controls\\Keyboard, joystick and mouse settings"
msgstr "Sterowanie\\Ustawienia klawiatury, joysticka i myszy"
@ -466,9 +463,6 @@ msgstr "Wytnij (Ctrl+X)"
msgid "Defense tower"
msgstr "Wieża obronna"
msgid "Delete"
msgstr "Usuń"
msgid "Delete mark"
msgstr "Usuń znacznik"
@ -512,9 +506,6 @@ msgstr "Czy na pewno chcesz zniszczyć zaznaczony budynek?"
msgid "Do you want to delete %s's saved games? "
msgstr "Czy na pewno chcesz skasować zapisane gry gracza %s? "
msgid "Do you want to quit Colobot: Gold Edition?"
msgstr "Czy na pewno chcesz opuścić grę Colobot: Gold Edition?"
msgid "Doors blocked by a robot or another object "
msgstr "Drzwi zablokowane przez robota lub inny obiekt "
@ -902,6 +893,9 @@ msgstr "Następny"
msgid "Next object\\Selects the next object"
msgstr "Następny obiekt\\Zaznacza następny obiekt"
msgid "No"
msgstr "Nie"
msgid "No energy in the subsoil"
msgstr "Brak energii w ziemi"
@ -1183,9 +1177,6 @@ msgstr "Publiczny\\Folder ogólnodostępny"
msgid "Quake at explosions\\The screen shakes at explosions"
msgstr "Wstrząsy przy wybuchach\\Ekran trzęsie się podczas wybuchów"
msgid "Quit the mission?"
msgstr "Opuścić misję?"
msgid "Quit\\Quit Colobot: Gold Edition"
msgstr "Wyjdź\\Kończy grę Colobot: Gold Edition"
@ -1704,6 +1695,9 @@ msgstr "Zły typ dla przypisania"
msgid "Yellow flag"
msgstr "Żółta flaga"
msgid "Yes"
msgstr "Tak"
msgid "You can fly with the keys (\\key gup;) and (\\key gdown;)"
msgstr "Możesz latać używając klawiszy (\\key gup;) oraz (\\key gdown;)"
@ -1845,6 +1839,15 @@ msgstr "www.epsitec.com"
#~ msgid "3D sound\\3D positioning of the sound"
#~ msgstr "Dźwięk 3D\\Przestrzenne pozycjonowanie dźwięków"
#~ msgid "Continue\\Continue the game"
#~ msgstr "Kontynuuj\\Kontynuuje grę"
#~ msgid "Delete"
#~ msgstr "Usuń"
#~ msgid "Do you want to quit Colobot: Gold Edition?"
#~ msgstr "Czy na pewno chcesz opuścić grę Colobot: Gold Edition?"
#~ msgid "Key word help\\More detailed help about key words"
#~ msgstr ""
#~ "Pomoc dot. słów kluczowych\\Dokładniejsza pomoc na temat słów kluczowych"
@ -1852,5 +1855,8 @@ msgstr "www.epsitec.com"
#~ msgid "Mouse shadow\\Gives the mouse a shadow"
#~ msgstr "Cień kursora myszy\\Dodaje cień kursorowi myszy"
#~ msgid "Quit the mission?"
#~ msgstr "Opuścić misję?"
#~ msgid "Textures\\Quality of textures "
#~ msgstr "Tekstury\\Jakość tekstur "

View File

@ -430,9 +430,6 @@ msgstr "Продолжить"
msgid "Continue\\Continue the current mission"
msgstr "Продолжить\\Продолжить текущую миссию"
msgid "Continue\\Continue the game"
msgstr "Продолжить\\Продолжить игру"
msgid "Controls\\Keyboard, joystick and mouse settings"
msgstr "Управление\\Настройки клавиатуры, джойстика и мыши"
@ -457,9 +454,6 @@ msgstr "Вырезать (Ctrl+X)"
msgid "Defense tower"
msgstr "Защитная башня"
msgid "Delete"
msgstr "Удалить"
#, fuzzy
msgid "Delete mark"
msgstr "Удалить"
@ -504,10 +498,6 @@ msgstr "Вы действительно хотите уничтожить выб
msgid "Do you want to delete %s's saved games? "
msgstr "Вы действительно хотите удалить сохраненные игры игрока %s?"
#, fuzzy
msgid "Do you want to quit Colobot: Gold Edition?"
msgstr "Вы хотите закрыть COLOBOT?"
msgid "Doors blocked by a robot or another object "
msgstr "Двери заблокированы роботом или другим объектом"
@ -895,6 +885,9 @@ msgstr "Следующий"
msgid "Next object\\Selects the next object"
msgstr "Следующий объект\\Выбор следующего объекта"
msgid "No"
msgstr ""
msgid "No energy in the subsoil"
msgstr "Под землей нет запасов энергии"
@ -1178,9 +1171,6 @@ msgstr "Общее\\Общая папка"
msgid "Quake at explosions\\The screen shakes at explosions"
msgstr "Землетряс. при взрывах\\Тряска экрана при взрывах"
msgid "Quit the mission?"
msgstr "Завершить миссию?"
msgid "Quit\\Quit Colobot: Gold Edition"
msgstr ""
@ -1700,6 +1690,9 @@ msgstr "Неверный тип для назначения"
msgid "Yellow flag"
msgstr "Желтый флаг"
msgid "Yes"
msgstr ""
msgid "You can fly with the keys (\\key gup;) and (\\key gdown;)"
msgstr "Вы можете лететь с помощью клавиш (\\key gup;) и (\\key gdown;)"
@ -1847,15 +1840,28 @@ msgstr "www.epsitec.com"
#~ msgid "COLOBOT"
#~ msgstr "КОЛОБОТ"
#~ msgid "Continue\\Continue the game"
#~ msgstr "Продолжить\\Продолжить игру"
#~ msgid "Delete"
#~ msgstr "Удалить"
#~ msgid "Developed by :"
#~ msgstr "Разработка :"
#, fuzzy
#~ msgid "Do you want to quit Colobot: Gold Edition?"
#~ msgstr "Вы хотите закрыть COLOBOT?"
#~ msgid "Key word help\\More detailed help about key words"
#~ msgstr "Помощь по командам\\Более подробная справку по командам"
#~ msgid "Mouse shadow\\Gives the mouse a shadow"
#~ msgstr "Тень мыши\\Мышь отбрасывает тень"
#~ msgid "Quit the mission?"
#~ msgstr "Завершить миссию?"
#~ msgid "Quit\\Quit COLOBOT"
#~ msgstr "Выход\\Выход из COLOBOT"

View File

@ -103,17 +103,12 @@ void InitializeRestext()
stringsText[RT_PERSO_COMBI] = TR("Suit color:");
stringsText[RT_PERSO_BAND] = TR("Strip color:");
stringsText[RT_DIALOG_QUIT] = TR("Do you want to quit Colobot: Gold Edition?");
stringsText[RT_DIALOG_TITLE] = TR("Colobot: Gold Edition");
stringsText[RT_DIALOG_YESQUIT] = TR("Quit\\Quit Colobot: Gold Edition");
stringsText[RT_DIALOG_ABORT] = TR("Quit the mission?");
stringsText[RT_DIALOG_YES] = TR("Abort\\Abort the current mission");
stringsText[RT_DIALOG_NO] = TR("Continue\\Continue the current mission");
stringsText[RT_DIALOG_NOQUIT] = TR("Continue\\Continue the game");
stringsText[RT_DIALOG_ABORT] = TR("Abort\\Abort the current mission");
stringsText[RT_DIALOG_CONTINUE] = TR("Continue\\Continue the current mission");
stringsText[RT_DIALOG_DELOBJ] = TR("Do you really want to destroy the selected building?");
stringsText[RT_DIALOG_DELGAME] = TR("Do you want to delete %s's saved games? ");
stringsText[RT_DIALOG_YESDEL] = TR("Delete");
stringsText[RT_DIALOG_NODEL] = TR("Cancel");
stringsText[RT_DIALOG_YES] = TR("Yes");
stringsText[RT_DIALOG_NO] = TR("No");
stringsText[RT_DIALOG_LOADING] = TR("LOADING");
stringsText[RT_STUDIO_LISTTT] = TR("Keyword help(\\key cbot;)");

View File

@ -99,18 +99,13 @@ enum ResTextType
RT_PERSO_COMBI = 93,
RT_PERSO_BAND = 94,
RT_DIALOG_TITLE = 100,
RT_DIALOG_ABORT = 101,
RT_DIALOG_QUIT = 102,
RT_DIALOG_YES = 103,
RT_DIALOG_NO = 104,
RT_DIALOG_ABORT = 103,
RT_DIALOG_CONTINUE = 104,
RT_DIALOG_DELOBJ = 105,
RT_DIALOG_DELGAME = 106,
RT_DIALOG_YESDEL = 107,
RT_DIALOG_NODEL = 108,
RT_DIALOG_YES = 107,
RT_DIALOG_NO = 108,
RT_DIALOG_LOADING = 109,
RT_DIALOG_YESQUIT = 110,
RT_DIALOG_NOQUIT = 111,
RT_STUDIO_LISTTT = 120,
RT_STUDIO_COMPOK = 121,
@ -158,4 +153,3 @@ void InitializeRestext();
void SetGlobalGamerName(std::string name);
bool GetResource(ResType type, unsigned int num, std::string& text);

View File

@ -805,7 +805,7 @@ bool CRobotMain::ProcessEvent(Event &event)
else if (m_lostDelay > 0.0f)
ChangePhase(PHASE_LOST);
else if (!m_cmdEdit)
m_ui->GetDialog()->StartAbort(); // do you want to leave?
m_ui->GetDialog()->StartPauseMenu(); // do you want to leave?
}
if (event.key.slot == INPUT_SLOT_PAUSE)
{
@ -963,7 +963,9 @@ bool CRobotMain::ProcessEvent(Event &event)
break;
case EVENT_OBJECT_DELETE:
m_ui->GetDialog()->StartDeleteObject(); // do you want to destroy it?
m_ui->GetDialog()->StartQuestion(RT_DIALOG_DELOBJ, true, false, [&]() {
DeleteObject();
});
break;
case EVENT_OBJECT_BHELP:

View File

@ -28,7 +28,6 @@
#include "common/logger.h"
#include "common/make_unique.h"
#include "common/settings.h"
#include "common/stringutils.h"
#include "object/player_profile.h"
#include "object/robotmain.h"
@ -37,7 +36,6 @@
#include "ui/controls/button.h"
#include "ui/controls/interface.h"
#include "ui/mainui.h"
#include "ui/controls/window.h"
#include "ui/screen/screen_setup.h"
@ -58,7 +56,7 @@ CMainDialog::CMainDialog()
m_phase = PHASE_PLAYER_SELECT;
m_bDialog = false;
m_dialogOpen = false;
}
// Destructor of robot application.
@ -77,7 +75,7 @@ void CMainDialog::ChangePhase(Phase phase)
bool CMainDialog::EventProcess(const Event &event)
{
if ( m_bDialog ) // this dialogue?
if ( m_dialogOpen ) // this dialogue?
{
if ( event.type == EVENT_FRAME )
{
@ -85,32 +83,24 @@ bool CMainDialog::EventProcess(const Event &event)
return true;
}
if ( event.type == EVENT_DIALOG_OK ||
(event.type == EVENT_KEY_DOWN && event.key.key == KEY(RETURN) ) )
EventType pressedButton = event.type;
if (event.type == EVENT_KEY_DOWN && event.key.key == KEY(RETURN) )
{
StopDialog();
if ( m_phase == PHASE_PLAYER_SELECT )
pressedButton = EVENT_DIALOG_OK;
}
if (event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE) )
{
CMainUserInterface::GetInstancePointer()->NameDelete(); // TODO: Clean this up
pressedButton = EVENT_DIALOG_CANCEL;
}
if ( m_phase == PHASE_SIMUL )
if ( m_dialogType == DialogType::PauseMenu )
{
if ( m_bDialogDelete )
{
m_main->DeleteObject();
}
else
{
m_main->ChangePhase(PHASE_LEVEL_LIST);
}
}
}
if ( event.type == EVENT_DIALOG_CANCEL ||
(event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE) ) )
if ( pressedButton == EVENT_DIALOG_CANCEL )
{
StopDialog();
}
if ( event.type == EVENT_INTERFACE_SETUP )
if ( pressedButton == EVENT_INTERFACE_SETUP )
{
StopDialog();
m_main->StartSuspend();
@ -124,24 +114,55 @@ bool CMainDialog::EventProcess(const Event &event)
if ( CScreenSetup::GetTab() == PHASE_SETUPc ) m_main->ChangePhase(PHASE_SETUPcs);
if ( CScreenSetup::GetTab() == PHASE_SETUPs ) m_main->ChangePhase(PHASE_SETUPss);
}
if ( event.type == EVENT_INTERFACE_AGAIN )
{
StopDialog();
m_main->ChangePhase(PHASE_LOADING);
}
if ( event.type == EVENT_INTERFACE_WRITE )
if ( pressedButton == EVENT_INTERFACE_WRITE )
{
StopDialog();
m_main->StartSuspend();
m_main->ChangePhase(PHASE_WRITEs);
}
if ( event.type == EVENT_INTERFACE_READ )
if ( pressedButton == EVENT_INTERFACE_READ )
{
StopDialog();
m_main->StartSuspend();
m_main->ChangePhase(PHASE_READs);
}
if ( pressedButton == EVENT_INTERFACE_AGAIN )
{
StopDialog();
m_main->ChangePhase(PHASE_LOADING);
}
if ( pressedButton == EVENT_DIALOG_OK )
{
StopDialog();
m_main->ChangePhase(PHASE_LEVEL_LIST);
}
}
if ( m_dialogType == DialogType::Question )
{
if ( pressedButton == EVENT_DIALOG_OK )
{
StopDialog();
if (m_callbackYes != nullptr)
{
m_callbackYes();
}
}
if ( pressedButton == EVENT_DIALOG_CANCEL )
{
StopDialog();
if (m_callbackNo != nullptr)
{
m_callbackNo();
}
}
}
return false;
}
@ -150,15 +171,15 @@ bool CMainDialog::EventProcess(const Event &event)
// Do you want to quit the current mission?
void CMainDialog::StartAbort()
void CMainDialog::StartPauseMenu()
{
CWindow* pw;
CButton* pb;
Math::Point pos, dim;
std::string name;
StartDialog(Math::Point(0.3f, 0.8f), true, false, false);
m_bDialogDelete = false;
StartDialog(Math::Point(0.3f, 0.8f), true);
m_dialogType = DialogType::PauseMenu;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == 0 ) return;
@ -181,7 +202,7 @@ void CMainDialog::StartAbort()
pos.y = 0.74f;
pb = pw->CreateButton(pos, dim, -1, EVENT_DIALOG_CANCEL);
pb->SetState(STATE_SHADOW);
GetResource(RES_TEXT, RT_DIALOG_NO, name);
GetResource(RES_TEXT, RT_DIALOG_CONTINUE, name);
pb->SetName(name);
if ( m_main->GetLevelCategory() == LevelCategory::Missions || // missions ?
@ -219,122 +240,73 @@ void CMainDialog::StartAbort()
pb = pw->CreateButton(pos, dim, -1, EVENT_DIALOG_OK);
pb->SetState(STATE_SHADOW);
pb->SetState(STATE_WARNING);
GetResource(RES_TEXT, RT_DIALOG_YES, name);
GetResource(RES_TEXT, RT_DIALOG_ABORT, name);
pb->SetName(name);
}
// Do you want to destroy the building?
void CMainDialog::StartDeleteObject()
void CMainDialog::StartQuestion(const std::string& text, bool warningYes, bool warningNo, DialogCallback yes, DialogCallback no)
{
CWindow* pw;
CButton* pb;
Math::Point pos, dim;
Math::Point pos, dim, ddim;
std::string name;
StartDialog(Math::Point(0.7f, 0.3f), false, true, true);
m_bDialogDelete = true;
dim.x = 0.7f;
dim.y = 0.3f;
StartDialog(dim, false);
m_dialogType = DialogType::Question;
m_callbackYes = yes;
m_callbackNo = no;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == 0 ) return;
pos.x = 0.00f;
pos.y = 0.50f;
dim.x = 1.00f;
dim.y = 0.05f;
GetResource(RES_TEXT, RT_DIALOG_DELOBJ, name);
pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, name);
ddim.x = 1.00f;
ddim.y = 0.05f;
pw->CreateLabel(pos, ddim, -1, EVENT_DIALOG_LABEL, text);
pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK));
if ( pb == 0 ) return;
GetResource(RES_TEXT, RT_DIALOG_YESDEL, name);
pos.x = 0.50f-0.15f-0.02f;
pos.y = 0.50f-dim.y/2.0f+0.03f;
ddim.x = 0.15f;
ddim.y = 0.06f;
pb = pw->CreateButton(pos, ddim, -1, EVENT_DIALOG_OK);
pb->SetState(STATE_SHADOW);
GetResource(RES_TEXT, RT_DIALOG_YES, name);
pb->SetName(name);
if (warningYes)
{
pb->SetState(STATE_WARNING);
}
pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_CANCEL));
if ( pb == 0 ) return;
GetResource(RES_TEXT, RT_DIALOG_NODEL, name);
pos.x = 0.50f+0.02f;
pos.y = 0.50f-dim.y/2.0f+0.03f;
ddim.x = 0.15f;
ddim.y = 0.06f;
pb = pw->CreateButton(pos, ddim, -1, EVENT_DIALOG_CANCEL);
pb->SetState(STATE_SHADOW);
GetResource(RES_TEXT, RT_DIALOG_NO, name);
pb->SetName(name);
if (warningNo)
{
pb->SetState(STATE_WARNING);
}
}
// Do you want to delete the player?
void CMainDialog::StartDeleteGame(char *gamer)
void CMainDialog::StartQuestion(ResTextType text, bool warningYes, bool warningNo, DialogCallback yes, DialogCallback no)
{
CWindow* pw;
CButton* pb;
Math::Point pos, dim;
StartDialog(Math::Point(0.7f, 0.3f), false, true, true);
m_bDialogDelete = true;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9));
if (pw == nullptr)
return;
std::string name;
pos.x = 0.00f;
pos.y = 0.50f;
dim.x = 1.00f;
dim.y = 0.05f;
GetResource(RES_TEXT, RT_DIALOG_DELGAME, name);
std::string text = StrUtils::Format(name.c_str(), gamer);
pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, text);
pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK));
if ( pb == 0 ) return;
GetResource(RES_TEXT, RT_DIALOG_YESDEL, name);
pb->SetName(name);
pb->SetState(STATE_WARNING);
pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_CANCEL));
if ( pb == 0 ) return;
GetResource(RES_TEXT, RT_DIALOG_NODEL, name);
pb->SetName(name);
}
// Would you quit the game?
void CMainDialog::StartQuit()
{
CWindow* pw;
CButton* pb;
Math::Point pos, dim;
StartDialog(Math::Point(0.6f, 0.3f), false, true, true);
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9));
if (pw == nullptr)
return;
std::string name;
pos.x = 0.00f;
pos.y = 0.50f;
dim.x = 1.00f;
dim.y = 0.05f;
GetResource(RES_TEXT, RT_DIALOG_QUIT, name);
pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, name);
pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK));
if ( pb == 0 ) return;
GetResource(RES_TEXT, RT_DIALOG_YESQUIT, name);
pb->SetName(name);
pb->SetState(STATE_WARNING);
pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_CANCEL));
if ( pb == 0 ) return;
GetResource(RES_TEXT, RT_DIALOG_NOQUIT, name);
pb->SetName(name);
GetResource(RES_TEXT, text, name);
StartQuestion(name, warningYes, warningNo, yes, no);
}
// Beginning of displaying a dialog.
void CMainDialog::StartDialog(Math::Point dim, bool bFire, bool bOK, bool bCancel)
void CMainDialog::StartDialog(Math::Point dim, bool fireParticles)
{
CWindow* pw;
CButton* pb;
Math::Point pos, ddim;
m_main->StartSuspend();
@ -366,14 +338,13 @@ void CMainDialog::StartDialog(Math::Point dim, bool bFire, bool bOK, bool bCance
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW8));
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
m_bDialogFire = bFire;
std::string name;
m_dialogFireParticles = fireParticles;
pos.x = (1.0f-dim.x)/2.0f;
pos.y = (1.0f-dim.y)/2.0f;
pw = m_interface->CreateWindows(pos, dim, bFire?12:8, EVENT_WINDOW9);
pw = m_interface->CreateWindows(pos, dim, m_dialogFireParticles ? 12 : 8, EVENT_WINDOW9);
pw->SetState(STATE_SHADOW);
std::string name;
GetResource(RES_TEXT, RT_TITLE_BASE, name);
pw->SetName(name);
@ -382,32 +353,8 @@ void CMainDialog::StartDialog(Math::Point dim, bool bFire, bool bOK, bool bCance
m_dialogTime = 0.0f;
m_dialogParti = 999.0f;
if ( bOK )
{
pos.x = 0.50f-0.15f-0.02f;
pos.y = 0.50f-dim.y/2.0f+0.03f;
ddim.x = 0.15f;
ddim.y = 0.06f;
pb = pw->CreateButton(pos, ddim, -1, EVENT_DIALOG_OK);
pb->SetState(STATE_SHADOW);
GetResource(RES_EVENT, EVENT_DIALOG_OK, name);
pb->SetName(name);
}
if ( bCancel )
{
pos.x = 0.50f+0.02f;
pos.y = 0.50f-dim.y/2.0f+0.03f;
ddim.x = 0.15f;
ddim.y = 0.06f;
pb = pw->CreateButton(pos, ddim, -1, EVENT_DIALOG_CANCEL);
pb->SetState(STATE_SHADOW);
GetResource(RES_EVENT, EVENT_DIALOG_CANCEL, name);
pb->SetName(name);
}
m_sound->Play(SOUND_TZOING);
m_bDialog = true;
m_dialogOpen = true;
}
// Animation of a dialog.
@ -458,7 +405,7 @@ void CMainDialog::FrameDialog(float rTime)
if ( m_dialogParti < m_engine->ParticleAdapt(0.05f) ) return;
m_dialogParti = 0.0f;
if ( !m_bDialogFire ) return;
if ( !m_dialogFireParticles ) return;
dpos = m_dialogPos;
ddim = m_dialogDim;
@ -549,7 +496,7 @@ void CMainDialog::StopDialog()
m_main->StopSuspend();
m_interface->DeleteControl(EVENT_WINDOW9);
m_bDialog = false;
m_dialogOpen = false;
}
@ -557,7 +504,7 @@ void CMainDialog::StopDialog()
bool CMainDialog::IsDialog()
{
return m_bDialog;
return m_dialogOpen;
}
} // namespace Ui

View File

@ -19,6 +19,7 @@
#pragma once
#include "common/event.h"
#include "common/restext.h"
#include "object/robotmain.h"
@ -39,25 +40,6 @@ namespace Ui
class CInterface;
class CScreen;
class CScreenApperance;
class CScreenIORead;
class CScreenIOWrite;
class CScreenLevelList;
class CScreenLoading;
class CScreenMainMenu;
class CScreenPlayerSelect;
class CScreenQuit;
class CScreenSetup;
class CScreenSetupControls;
class CScreenSetupDisplay;
class CScreenSetupGame;
class CScreenSetupGraphics;
class CScreenSetupSound;
class CScreenWelcome;
class CMainDialog
{
public:
@ -67,15 +49,22 @@ public:
bool EventProcess(const Event &event);
void ChangePhase(Phase phase);
void StartAbort();
void StartDeleteObject();
void StartDeleteGame(char *gamer);
void StartQuit();
void StartDialog(Math::Point dim, bool bFire, bool bOK, bool bCancel);
void FrameDialog(float rTime);
typedef std::function<void()> DialogCallback;
void StartQuestion(const std::string& text,
bool warningYes, bool warningNo,
DialogCallback yes = nullptr, DialogCallback no = nullptr);
void StartQuestion(ResTextType text,
bool warningYes, bool warningNo,
DialogCallback yes = nullptr, DialogCallback no = nullptr);
void StartPauseMenu();
void StopDialog();
bool IsDialog();
protected:
void StartDialog(Math::Point dim, bool fireParticles);
void FrameDialog(float rTime);
protected:
CRobotMain* m_main;
Gfx::CEngine* m_engine;
@ -86,13 +75,21 @@ protected:
Phase m_phase; // copy of CRobotMain
bool m_bDialog; // this dialogue?
bool m_bDialogFire; // setting on fire?
bool m_bDialogDelete;
enum class DialogType {
Question,
PauseMenu
};
bool m_dialogOpen;
DialogType m_dialogType;
bool m_dialogFireParticles;
Math::Point m_dialogPos;
Math::Point m_dialogDim;
float m_dialogParti;
float m_dialogTime;
float m_dialogParti;
DialogCallback m_callbackYes;
DialogCallback m_callbackNo;
};
} // namespace Ui

View File

@ -56,8 +56,6 @@
#include "ui/maindialog.h"
#include "ui/controls/window.h"
template<> Ui::CMainUserInterface* CSingleton<Ui::CMainUserInterface>::m_instance = nullptr;
namespace Ui
{
@ -803,15 +801,6 @@ void CMainUserInterface::ShowSoluceUpdate()
}
}
// TODO: Clean this up
void CMainUserInterface::NameDelete()
{
if ( m_phase == PHASE_PLAYER_SELECT )
{
m_screenPlayerSelect->NameDelete();
}
}
// Whether to show the solution.
bool CMainUserInterface::GetSceneSoluce()

View File

@ -18,8 +18,6 @@
*/
#pragma once
#include "common/singleton.h"
#include "object/robotmain.h"
#include <vector>
@ -57,8 +55,7 @@ class CScreenSetupSound;
class CScreenWelcome;
class CMainUserInterface : public CSingleton<CMainUserInterface>
class CMainUserInterface
{
public:
CMainUserInterface();
@ -67,7 +64,6 @@ public:
CMainDialog* GetDialog();
bool EventProcess(const Event &event);
void ChangePhase(Phase phase);
@ -82,8 +78,6 @@ public:
void AllMissionUpdate();
void ShowSoluceUpdate();
void NameDelete();
void UpdateCustomLevelList();
std::string GetCustomLevelName(int id);
const std::vector<std::string>& GetCustomLevelList();

View File

@ -22,6 +22,7 @@
#include "app/app.h"
#include "common/logger.h"
#include "common/stringutils.h"
#include "object/player_profile.h"
@ -37,7 +38,7 @@ namespace Ui
{
CScreenPlayerSelect::CScreenPlayerSelect(CMainDialog* mainDialog)
: m_mainDialog(mainDialog)
: m_dialog(mainDialog)
{
}
@ -151,6 +152,8 @@ bool CScreenPlayerSelect::EventProcess(const Event &event)
CWindow* pw;
CButton* pb;
CList* pl;
std::string name;
char* gamer;
switch( event.type )
{
@ -199,7 +202,12 @@ bool CScreenPlayerSelect::EventProcess(const Event &event)
if ( pw == 0 ) break;
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
if ( pl == 0 ) break;
m_mainDialog->StartDeleteGame(pl->GetItemName(pl->GetSelect()));
GetResource(RES_TEXT, RT_DIALOG_DELGAME, name);
gamer = pl->GetItemName(pl->GetSelect());
m_dialog->StartQuestion(StrUtils::Format(name.c_str(), gamer), true, false, [&]() {
NameDelete();
});
break;
default:

View File

@ -45,7 +45,7 @@ protected:
bool NameCreate();
private:
CMainDialog* m_mainDialog;
CMainDialog* m_dialog;
};
} // namespace Ui