mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 15:36:41 +00:00
Use one instead of five state variables to keep track of character creation progress
This commit is contained in:
parent
183ccad872
commit
67b4243a7f
2 changed files with 57 additions and 49 deletions
|
@ -33,11 +33,6 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||||
, createClassDialog(nullptr)
|
, createClassDialog(nullptr)
|
||||||
, birthSignDialog(nullptr)
|
, birthSignDialog(nullptr)
|
||||||
, reviewDialog(nullptr)
|
, reviewDialog(nullptr)
|
||||||
, nameChosen(false)
|
|
||||||
, raceChosen(false)
|
|
||||||
, classChosen(false)
|
|
||||||
, birthSignChosen(false)
|
|
||||||
, reviewNext(false)
|
|
||||||
, gui(_gui)
|
, gui(_gui)
|
||||||
, mode(GM_Game)
|
, mode(GM_Game)
|
||||||
, nextMode(GM_Game)
|
, nextMode(GM_Game)
|
||||||
|
@ -47,6 +42,8 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||||
{
|
{
|
||||||
showFPSCounter = fpsSwitch;
|
showFPSCounter = fpsSwitch;
|
||||||
|
|
||||||
|
creationStage = NotStarted;
|
||||||
|
|
||||||
//Register own widgets with MyGUI
|
//Register own widgets with MyGUI
|
||||||
MyGUI::FactoryManager::getInstance().registerFactory<DialogeHistory>("Widget");
|
MyGUI::FactoryManager::getInstance().registerFactory<DialogeHistory>("Widget");
|
||||||
|
|
||||||
|
@ -187,7 +184,7 @@ void WindowManager::updateVisible()
|
||||||
std::string sName = getGameSettingString("sName", "Name");
|
std::string sName = getGameSettingString("sName", "Name");
|
||||||
nameDialog->setTextLabel(sName);
|
nameDialog->setTextLabel(sName);
|
||||||
nameDialog->setTextInput(playerName);
|
nameDialog->setTextInput(playerName);
|
||||||
nameDialog->setNextButtonShow(nameChosen || reviewNext);
|
nameDialog->setNextButtonShow(creationStage >= NameChosen);
|
||||||
nameDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onNameDialogDone);
|
nameDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onNameDialogDone);
|
||||||
nameDialog->open();
|
nameDialog->open();
|
||||||
return;
|
return;
|
||||||
|
@ -198,7 +195,7 @@ void WindowManager::updateVisible()
|
||||||
if (raceDialog)
|
if (raceDialog)
|
||||||
removeDialog(raceDialog);
|
removeDialog(raceDialog);
|
||||||
raceDialog = new RaceDialog(environment);
|
raceDialog = new RaceDialog(environment);
|
||||||
raceDialog->setNextButtonShow(raceChosen || reviewNext);
|
raceDialog->setNextButtonShow(creationStage >= RaceChosen);
|
||||||
raceDialog->setRaceId(playerRaceId);
|
raceDialog->setRaceId(playerRaceId);
|
||||||
raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone);
|
raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone);
|
||||||
raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack);
|
raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack);
|
||||||
|
@ -232,7 +229,7 @@ void WindowManager::updateVisible()
|
||||||
if (pickClassDialog)
|
if (pickClassDialog)
|
||||||
removeDialog(pickClassDialog);
|
removeDialog(pickClassDialog);
|
||||||
pickClassDialog = new PickClassDialog(environment);
|
pickClassDialog = new PickClassDialog(environment);
|
||||||
pickClassDialog->setNextButtonShow(classChosen || reviewNext);
|
pickClassDialog->setNextButtonShow(creationStage >= ClassChosen);
|
||||||
pickClassDialog->setClassId(playerClass.name);
|
pickClassDialog->setClassId(playerClass.name);
|
||||||
pickClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogDone);
|
pickClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogDone);
|
||||||
pickClassDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogBack);
|
pickClassDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogBack);
|
||||||
|
@ -256,7 +253,7 @@ void WindowManager::updateVisible()
|
||||||
if (birthSignDialog)
|
if (birthSignDialog)
|
||||||
removeDialog(birthSignDialog);
|
removeDialog(birthSignDialog);
|
||||||
birthSignDialog = new BirthDialog(environment);
|
birthSignDialog = new BirthDialog(environment);
|
||||||
birthSignDialog->setNextButtonShow(birthSignChosen || reviewNext);
|
birthSignDialog->setNextButtonShow(creationStage >= BirthSignChosen);
|
||||||
birthSignDialog->setBirthId(playerBirthSignId);
|
birthSignDialog->setBirthId(playerBirthSignId);
|
||||||
birthSignDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogDone);
|
birthSignDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogDone);
|
||||||
birthSignDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogBack);
|
birthSignDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogBack);
|
||||||
|
@ -266,7 +263,6 @@ void WindowManager::updateVisible()
|
||||||
|
|
||||||
if (mode == GM_Review)
|
if (mode == GM_Review)
|
||||||
{
|
{
|
||||||
reviewNext = false;
|
|
||||||
if (reviewDialog)
|
if (reviewDialog)
|
||||||
removeDialog(reviewDialog);
|
removeDialog(reviewDialog);
|
||||||
reviewDialog = new ReviewDialog(environment);
|
reviewDialog = new ReviewDialog(environment);
|
||||||
|
@ -476,15 +472,16 @@ void WindowManager::onNameDialogDone()
|
||||||
removeDialog(nameDialog);
|
removeDialog(nameDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool goNext = nameChosen; // Go to next dialog if name was previously chosen
|
// Go to next dialog if name was previously chosen
|
||||||
nameChosen = true;
|
if (creationStage == ReviewNext)
|
||||||
|
|
||||||
if (reviewNext)
|
|
||||||
setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (creationStage >= NameChosen)
|
||||||
setGuiMode(GM_Race);
|
setGuiMode(GM_Race);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
creationStage = NameChosen;
|
||||||
setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onRaceDialogDone()
|
void WindowManager::onRaceDialogDone()
|
||||||
|
@ -497,15 +494,16 @@ void WindowManager::onRaceDialogDone()
|
||||||
removeDialog(raceDialog);
|
removeDialog(raceDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool goNext = raceChosen; // Go to next dialog if race was previously chosen
|
// Go to next dialog if race was previously chosen
|
||||||
raceChosen = true;
|
if (creationStage == ReviewNext)
|
||||||
|
|
||||||
if (reviewNext)
|
|
||||||
setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if(creationStage >= RaceChosen)
|
||||||
setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
creationStage = RaceChosen;
|
||||||
setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onDialogueWindowBye()
|
void WindowManager::onDialogueWindowBye()
|
||||||
|
@ -755,7 +753,8 @@ void WindowManager::onClassQuestionChosen(int _index)
|
||||||
|
|
||||||
void WindowManager::onGenerateClassBack()
|
void WindowManager::onGenerateClassBack()
|
||||||
{
|
{
|
||||||
classChosen = true;
|
if(creationStage < ClassChosen)
|
||||||
|
creationStage = ClassChosen;
|
||||||
|
|
||||||
if (generateClassResultDialog)
|
if (generateClassResultDialog)
|
||||||
removeDialog(generateClassResultDialog);
|
removeDialog(generateClassResultDialog);
|
||||||
|
@ -766,19 +765,20 @@ void WindowManager::onGenerateClassBack()
|
||||||
|
|
||||||
void WindowManager::onGenerateClassDone()
|
void WindowManager::onGenerateClassDone()
|
||||||
{
|
{
|
||||||
bool goNext = classChosen; // Go to next dialog if class was previously chosen
|
|
||||||
classChosen = true;
|
|
||||||
|
|
||||||
if (generateClassResultDialog)
|
if (generateClassResultDialog)
|
||||||
removeDialog(generateClassResultDialog);
|
removeDialog(generateClassResultDialog);
|
||||||
environment.mMechanicsManager->setPlayerClass(generateClass);
|
environment.mMechanicsManager->setPlayerClass(generateClass);
|
||||||
|
|
||||||
if (reviewNext)
|
// Go to next dialog if class was previously chosen
|
||||||
|
if (creationStage == ReviewNext)
|
||||||
setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (creationStage >= ClassChosen)
|
||||||
setGuiMode(GM_Birth);
|
setGuiMode(GM_Birth);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
creationStage = ClassChosen;
|
||||||
setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -795,15 +795,16 @@ void WindowManager::onPickClassDialogDone()
|
||||||
removeDialog(pickClassDialog);
|
removeDialog(pickClassDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool goNext = classChosen; // Go to next dialog if class was previously chosen
|
// Go to next dialog if class was previously chosen
|
||||||
classChosen = true;
|
if (creationStage == ReviewNext)
|
||||||
|
|
||||||
if (reviewNext)
|
|
||||||
setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (creationStage >= ClassChosen)
|
||||||
setGuiMode(GM_Birth);
|
setGuiMode(GM_Birth);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
creationStage = ClassChosen;
|
||||||
setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onPickClassDialogBack()
|
void WindowManager::onPickClassDialogBack()
|
||||||
|
@ -849,15 +850,16 @@ void WindowManager::onCreateClassDialogDone()
|
||||||
removeDialog(createClassDialog);
|
removeDialog(createClassDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool goNext = classChosen; // Go to next dialog if class was previously chosen
|
// Go to next dialog if class was previously chosen
|
||||||
classChosen = true;
|
if (creationStage == ReviewNext)
|
||||||
|
|
||||||
if (reviewNext)
|
|
||||||
setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (creationStage >= ClassChosen)
|
||||||
setGuiMode(GM_Birth);
|
setGuiMode(GM_Birth);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
creationStage = ClassChosen;
|
||||||
setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onCreateClassDialogBack()
|
void WindowManager::onCreateClassDialogBack()
|
||||||
|
@ -878,13 +880,14 @@ void WindowManager::onBirthSignDialogDone()
|
||||||
removeDialog(birthSignDialog);
|
removeDialog(birthSignDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool goNext = birthSignChosen; // Go to next dialog if birth sign was previously chosen
|
// Go to next dialog if birth sign was previously chosen
|
||||||
birthSignChosen = true;
|
if (creationStage >= BirthSignChosen)
|
||||||
|
|
||||||
if (reviewNext || goNext)
|
|
||||||
setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
creationStage = BirthSignChosen;
|
||||||
setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onBirthSignDialogBack()
|
void WindowManager::onBirthSignDialogBack()
|
||||||
|
@ -918,7 +921,7 @@ void WindowManager::onReviewActivateDialog(int parDialog)
|
||||||
{
|
{
|
||||||
if (reviewDialog)
|
if (reviewDialog)
|
||||||
removeDialog(reviewDialog);
|
removeDialog(reviewDialog);
|
||||||
reviewNext = true;
|
creationStage = ReviewNext;
|
||||||
|
|
||||||
switch(parDialog)
|
switch(parDialog)
|
||||||
{
|
{
|
||||||
|
|
|
@ -100,14 +100,6 @@ namespace MWGui
|
||||||
BirthDialog *birthSignDialog;
|
BirthDialog *birthSignDialog;
|
||||||
ReviewDialog *reviewDialog;
|
ReviewDialog *reviewDialog;
|
||||||
|
|
||||||
// Which dialogs have been shown, controls back/next/ok buttons
|
|
||||||
bool nameChosen;
|
|
||||||
bool raceChosen;
|
|
||||||
bool classChosen;
|
|
||||||
bool birthSignChosen;
|
|
||||||
bool reviewNext;
|
|
||||||
///< If true then any click on Next will cause the summary to be shown
|
|
||||||
|
|
||||||
// Keeps track of current step in Generate Class dialogs
|
// Keeps track of current step in Generate Class dialogs
|
||||||
unsigned generateClassStep;
|
unsigned generateClassStep;
|
||||||
// A counter for each specialization which is increased when an answer is chosen, in order: Stealth, Combat, Magic
|
// A counter for each specialization which is increased when an answer is chosen, in order: Stealth, Combat, Magic
|
||||||
|
@ -300,6 +292,19 @@ namespace MWGui
|
||||||
void onReviewDialogDone();
|
void onReviewDialogDone();
|
||||||
void onReviewDialogBack();
|
void onReviewDialogBack();
|
||||||
void onReviewActivateDialog(int parDialog);
|
void onReviewActivateDialog(int parDialog);
|
||||||
|
|
||||||
|
enum CreationStageEnum
|
||||||
|
{
|
||||||
|
NotStarted,
|
||||||
|
NameChosen,
|
||||||
|
RaceChosen,
|
||||||
|
ClassChosen,
|
||||||
|
BirthSignChosen,
|
||||||
|
ReviewNext
|
||||||
|
};
|
||||||
|
|
||||||
|
// Which state the character creating is in, controls back/next/ok buttons
|
||||||
|
CreationStageEnum creationStage;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
Loading…
Reference in a new issue