mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 12:35:46 +00:00
Created a class for char gen, and starting moving code to it
This commit is contained in:
parent
a17c193f56
commit
4b758376be
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ Docs/mainpage.hpp
|
||||
CMakeFiles
|
||||
*/CMakeFiles
|
||||
CMakeCache.txt
|
||||
data
|
||||
|
@ -23,7 +23,7 @@ add_openmw_dir (mwinput
|
||||
|
||||
add_openmw_dir (mwgui
|
||||
layouts text_input widgets race class birth review window_manager console dialogue
|
||||
dialogue_history window_base stats_window messagebox journalwindow
|
||||
dialogue_history window_base stats_window messagebox journalwindow character_creation
|
||||
)
|
||||
|
||||
add_openmw_dir (mwdialogue
|
||||
|
@ -45,6 +45,15 @@ namespace MWGui
|
||||
|
||||
GW_ALL = 0xFF
|
||||
};
|
||||
|
||||
// Character creation dialogs
|
||||
enum CharGen
|
||||
{
|
||||
GEN_Name,
|
||||
GEN_Race,
|
||||
GEN_Class,
|
||||
GEN_Sign
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "window_manager.hpp"
|
||||
#include "layouts.hpp"
|
||||
#include "text_input.hpp"
|
||||
#include "race.hpp"
|
||||
#include "class.hpp"
|
||||
#include "birth.hpp"
|
||||
#include "review.hpp"
|
||||
@ -15,6 +14,7 @@
|
||||
|
||||
#include "console.hpp"
|
||||
#include "journalwindow.hpp"
|
||||
#include "character_creation.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
@ -25,13 +25,10 @@ using namespace MWGui;
|
||||
WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
||||
const Compiler::Extensions& extensions, int fpsLevel, bool newGame)
|
||||
: environment(environment)
|
||||
, nameDialog(nullptr)
|
||||
, raceDialog(nullptr)
|
||||
, dialogueWindow(nullptr)
|
||||
, classChoiceDialog(nullptr)
|
||||
, generateClassQuestionDialog(nullptr)
|
||||
, generateClassResultDialog(nullptr)
|
||||
, pickClassDialog(nullptr)
|
||||
, createClassDialog(nullptr)
|
||||
, birthSignDialog(nullptr)
|
||||
, reviewDialog(nullptr)
|
||||
@ -44,6 +41,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||
{
|
||||
showFPSLevel = fpsLevel;
|
||||
|
||||
/// REMOVE
|
||||
creationStage = NotStarted;
|
||||
|
||||
//Register own widgets with MyGUI
|
||||
@ -68,6 +66,8 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||
// The HUD is always on
|
||||
hud->setVisible(true);
|
||||
|
||||
mCharGen = new CharacterCreation(this);
|
||||
|
||||
// Setup player stats
|
||||
for (int i = 0; i < ESM::Attribute::Length; ++i)
|
||||
{
|
||||
@ -102,13 +102,10 @@ WindowManager::~WindowManager()
|
||||
delete inventory;
|
||||
#endif
|
||||
|
||||
delete nameDialog;
|
||||
delete raceDialog;
|
||||
delete dialogueWindow;
|
||||
delete classChoiceDialog;
|
||||
delete generateClassQuestionDialog;
|
||||
delete generateClassResultDialog;
|
||||
delete pickClassDialog;
|
||||
delete createClassDialog;
|
||||
delete birthSignDialog;
|
||||
delete reviewDialog;
|
||||
@ -129,6 +126,11 @@ void WindowManager::cleanupGarbage()
|
||||
}
|
||||
}
|
||||
|
||||
MWMechanics::MechanicsManager* WindowManager::getMechanicsManager()
|
||||
{
|
||||
return environment.mMechanicsManager;
|
||||
}
|
||||
|
||||
void WindowManager::update()
|
||||
{
|
||||
cleanupGarbage();
|
||||
@ -178,7 +180,7 @@ void WindowManager::updateVisible()
|
||||
gui->setVisiblePointer(isGuiMode());
|
||||
|
||||
// If in game mode, don't show anything.
|
||||
if(mode == GM_Game)
|
||||
if(mode == GM_Game) //Use a switch/case structure
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -196,40 +198,21 @@ void WindowManager::updateVisible()
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == GM_Name)
|
||||
if (mode == GM_Name) //Combine this with all char-gen related if statements
|
||||
{
|
||||
if (nameDialog)
|
||||
removeDialog(nameDialog);
|
||||
nameDialog = new TextInputDialog(*this);
|
||||
std::string sName = getGameSettingString("sName", "Name");
|
||||
nameDialog->setTextLabel(sName);
|
||||
nameDialog->setTextInput(playerName);
|
||||
nameDialog->setNextButtonShow(creationStage >= NameChosen);
|
||||
nameDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onNameDialogDone);
|
||||
nameDialog->open();
|
||||
mCharGen->spawnDialog(GM_Name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == GM_Race)
|
||||
if (mode == GM_Race) //Combine this with all char-gen related if statements
|
||||
{
|
||||
if (raceDialog)
|
||||
removeDialog(raceDialog);
|
||||
raceDialog = new RaceDialog(*this);
|
||||
raceDialog->setNextButtonShow(creationStage >= RaceChosen);
|
||||
raceDialog->setRaceId(playerRaceId);
|
||||
raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone);
|
||||
raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack);
|
||||
raceDialog->open();
|
||||
mCharGen->spawnDialog(GM_Race);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == GM_Class)
|
||||
{
|
||||
if (classChoiceDialog)
|
||||
removeDialog(classChoiceDialog);
|
||||
classChoiceDialog = new ClassChoiceDialog(*this);
|
||||
classChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &WindowManager::onClassChoice);
|
||||
classChoiceDialog->open();
|
||||
mCharGen->spawnDialog(GM_Class);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -246,14 +229,7 @@ void WindowManager::updateVisible()
|
||||
|
||||
if (mode == GM_ClassPick)
|
||||
{
|
||||
if (pickClassDialog)
|
||||
removeDialog(pickClassDialog);
|
||||
pickClassDialog = new PickClassDialog(*this);
|
||||
pickClassDialog->setNextButtonShow(creationStage >= ClassChosen);
|
||||
pickClassDialog->setClassId(playerClass.name);
|
||||
pickClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogDone);
|
||||
pickClassDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogBack);
|
||||
pickClassDialog->open();
|
||||
mCharGen->spawnDialog(GM_ClassPick);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -286,7 +262,7 @@ void WindowManager::updateVisible()
|
||||
if (reviewDialog)
|
||||
removeDialog(reviewDialog);
|
||||
reviewDialog = new ReviewDialog(*this);
|
||||
reviewDialog->setPlayerName(playerName);
|
||||
//reviewDialog->setPlayerName(playerName); //Move this to Chargen as part of refactoring
|
||||
reviewDialog->setRace(playerRaceId);
|
||||
reviewDialog->setClass(playerClass);
|
||||
reviewDialog->setBirthSign(playerBirthSignId);
|
||||
@ -420,10 +396,10 @@ void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicS
|
||||
void WindowManager::setValue (const std::string& id, const std::string& value)
|
||||
{
|
||||
stats->setValue (id, value);
|
||||
if (id=="name")
|
||||
/*if (id=="name")
|
||||
playerName = value;
|
||||
else if (id=="race")
|
||||
playerRaceId = value;
|
||||
playerRaceId = value;*/ //Move this to chargen
|
||||
}
|
||||
|
||||
void WindowManager::setValue (const std::string& id, int value)
|
||||
@ -505,49 +481,6 @@ const std::string &WindowManager::getGameSettingString(const std::string &id, co
|
||||
return default_;
|
||||
}
|
||||
|
||||
void WindowManager::onNameDialogDone(WindowBase* parWindow)
|
||||
{
|
||||
if (nameDialog)
|
||||
{
|
||||
playerName = nameDialog->getTextInput();
|
||||
environment.mMechanicsManager->setPlayerName(playerName);
|
||||
removeDialog(nameDialog);
|
||||
}
|
||||
|
||||
// Go to next dialog if name was previously chosen
|
||||
if (creationStage == ReviewNext)
|
||||
setGuiMode(GM_Review);
|
||||
else if (creationStage >= NameChosen)
|
||||
setGuiMode(GM_Race);
|
||||
else
|
||||
{
|
||||
creationStage = NameChosen;
|
||||
setGuiMode(GM_Game);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManager::onRaceDialogDone(WindowBase* parWindow)
|
||||
{
|
||||
if (raceDialog)
|
||||
{
|
||||
playerRaceId = raceDialog->getRaceId();
|
||||
if (!playerRaceId.empty())
|
||||
environment.mMechanicsManager->setPlayerRace(playerRaceId, raceDialog->getGender() == RaceDialog::GM_Male);
|
||||
removeDialog(raceDialog);
|
||||
}
|
||||
|
||||
// Go to next dialog if race was previously chosen
|
||||
if (creationStage == ReviewNext)
|
||||
setGuiMode(GM_Review);
|
||||
else if(creationStage >= RaceChosen)
|
||||
setGuiMode(GM_Class);
|
||||
else
|
||||
{
|
||||
creationStage = RaceChosen;
|
||||
setGuiMode(GM_Game);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManager::onDialogueWindowBye()
|
||||
{
|
||||
if (dialogueWindow)
|
||||
@ -558,44 +491,6 @@ void WindowManager::onDialogueWindowBye()
|
||||
setGuiMode(GM_Game);
|
||||
}
|
||||
|
||||
void WindowManager::onRaceDialogBack()
|
||||
{
|
||||
if (raceDialog)
|
||||
{
|
||||
playerRaceId = raceDialog->getRaceId();
|
||||
if (!playerRaceId.empty())
|
||||
environment.mMechanicsManager->setPlayerRace(playerRaceId, raceDialog->getGender() == RaceDialog::GM_Male);
|
||||
removeDialog(raceDialog);
|
||||
}
|
||||
|
||||
setGuiMode(GM_Name);
|
||||
}
|
||||
|
||||
void WindowManager::onClassChoice(int _index)
|
||||
{
|
||||
if (classChoiceDialog)
|
||||
{
|
||||
removeDialog(classChoiceDialog);
|
||||
}
|
||||
|
||||
switch(_index)
|
||||
{
|
||||
case ClassChoiceDialog::Class_Generate:
|
||||
setGuiMode(GM_ClassGenerate);
|
||||
break;
|
||||
case ClassChoiceDialog::Class_Pick:
|
||||
setGuiMode(GM_ClassPick);
|
||||
break;
|
||||
case ClassChoiceDialog::Class_Create:
|
||||
setGuiMode(GM_ClassCreate);
|
||||
break;
|
||||
case ClassChoiceDialog::Class_Back:
|
||||
setGuiMode(GM_Race);
|
||||
break;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
void WindowManager::onFrame (float frameDuration)
|
||||
{
|
||||
mMessageBoxManager->onFrame(frameDuration);
|
||||
@ -828,43 +723,9 @@ void WindowManager::onGenerateClassDone(WindowBase* parWindow)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WindowManager::onPickClassDialogDone(WindowBase* parWindow)
|
||||
MWWorld::World* WindowManager::getWorld()
|
||||
{
|
||||
if (pickClassDialog)
|
||||
{
|
||||
const std::string &classId = pickClassDialog->getClassId();
|
||||
if (!classId.empty())
|
||||
environment.mMechanicsManager->setPlayerClass(classId);
|
||||
const ESM::Class *klass = environment.mWorld->getStore().classes.find(classId);
|
||||
if (klass)
|
||||
playerClass = *klass;
|
||||
removeDialog(pickClassDialog);
|
||||
}
|
||||
|
||||
// Go to next dialog if class was previously chosen
|
||||
if (creationStage == ReviewNext)
|
||||
setGuiMode(GM_Review);
|
||||
else if (creationStage >= ClassChosen)
|
||||
setGuiMode(GM_Birth);
|
||||
else
|
||||
{
|
||||
creationStage = ClassChosen;
|
||||
setGuiMode(GM_Game);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManager::onPickClassDialogBack()
|
||||
{
|
||||
if (pickClassDialog)
|
||||
{
|
||||
const std::string classId = pickClassDialog->getClassId();
|
||||
if (!classId.empty())
|
||||
environment.mMechanicsManager->setPlayerClass(classId);
|
||||
removeDialog(pickClassDialog);
|
||||
}
|
||||
|
||||
setGuiMode(GM_Class);
|
||||
return environment.mWorld;
|
||||
}
|
||||
|
||||
void WindowManager::onCreateClassDialogDone(WindowBase* parWindow)
|
||||
|
@ -32,6 +32,12 @@ namespace Compiler
|
||||
namespace MWWorld
|
||||
{
|
||||
class Environment;
|
||||
class World;
|
||||
}
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
class MechanicsManager;
|
||||
}
|
||||
|
||||
namespace OEngine
|
||||
@ -52,14 +58,13 @@ namespace MWGui
|
||||
class InventoryWindow;
|
||||
class Console;
|
||||
class JournalWindow;
|
||||
class CharacterCreation;
|
||||
|
||||
class TextInputDialog;
|
||||
class InfoBoxDialog;
|
||||
class RaceDialog;
|
||||
class DialogueWindow;
|
||||
class ClassChoiceDialog;
|
||||
class GenerateClassResultDialog;
|
||||
class PickClassDialog;
|
||||
class CreateClassDialog;
|
||||
class BirthDialog;
|
||||
class ReviewDialog;
|
||||
@ -94,13 +99,12 @@ namespace MWGui
|
||||
JournalWindow* mJournal;
|
||||
|
||||
// Character creation
|
||||
TextInputDialog *nameDialog;
|
||||
RaceDialog *raceDialog;
|
||||
CharacterCreation* mCharGen;
|
||||
|
||||
DialogueWindow *dialogueWindow;
|
||||
ClassChoiceDialog *classChoiceDialog;
|
||||
InfoBoxDialog *generateClassQuestionDialog;
|
||||
GenerateClassResultDialog *generateClassResultDialog;
|
||||
PickClassDialog *pickClassDialog;
|
||||
CreateClassDialog *createClassDialog;
|
||||
BirthDialog *birthSignDialog;
|
||||
ReviewDialog *reviewDialog;
|
||||
@ -112,9 +116,9 @@ namespace MWGui
|
||||
std::string generateClass;
|
||||
|
||||
// Various stats about player as needed by window manager
|
||||
std::string playerName;
|
||||
ESM::Class playerClass;
|
||||
std::string playerRaceId, playerBirthSignId;
|
||||
std::string playerRaceId; ///REMOVE
|
||||
std::string playerBirthSignId;
|
||||
std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > playerAttributes;
|
||||
SkillList playerMajorSkills, playerMinorSkills;
|
||||
std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > playerSkillValues;
|
||||
@ -156,8 +160,6 @@ namespace MWGui
|
||||
// allowed settings.
|
||||
void updateVisible();
|
||||
|
||||
void setGuiMode(GuiMode newMode);
|
||||
|
||||
int showFPSLevel;
|
||||
float mFPS;
|
||||
size_t mTriangleCount;
|
||||
@ -169,6 +171,10 @@ namespace MWGui
|
||||
const Compiler::Extensions& extensions, int fpsLevel, bool newGame);
|
||||
virtual ~WindowManager();
|
||||
|
||||
void setGuiMode(GuiMode newMode);
|
||||
MWMechanics::MechanicsManager* getMechanicsManager();
|
||||
MWWorld::World* getWorld();
|
||||
|
||||
/**
|
||||
* Should be called each frame to update windows/gui elements.
|
||||
* This could mean updating sizes of gui elements or opening
|
||||
@ -280,27 +286,13 @@ namespace MWGui
|
||||
private:
|
||||
|
||||
void onDialogueWindowBye();
|
||||
|
||||
// Character generation: Name dialog
|
||||
void onNameDialogDone(WindowBase* parWindow);
|
||||
|
||||
// Character generation: Race dialog
|
||||
void onRaceDialogDone(WindowBase* parWindow);
|
||||
void onRaceDialogBack();
|
||||
|
||||
// Character generation: Choose class process
|
||||
void onClassChoice(int _index);
|
||||
|
||||
|
||||
// Character generation: Generate Class
|
||||
void showClassQuestionDialog();
|
||||
void onClassQuestionChosen(int _index);
|
||||
void onGenerateClassBack();
|
||||
void onGenerateClassDone(WindowBase* parWindow);
|
||||
|
||||
// Character generation: Pick Class dialog
|
||||
void onPickClassDialogDone(WindowBase* parWindow);
|
||||
void onPickClassDialogBack();
|
||||
|
||||
// Character generation: Create Class dialog
|
||||
void onCreateClassDialogDone(WindowBase* parWindow);
|
||||
void onCreateClassDialogBack();
|
||||
@ -314,6 +306,7 @@ namespace MWGui
|
||||
void onReviewDialogBack();
|
||||
void onReviewActivateDialog(int parDialog);
|
||||
|
||||
/// REMOVE
|
||||
enum CreationStageEnum
|
||||
{
|
||||
NotStarted,
|
||||
@ -326,6 +319,7 @@ namespace MWGui
|
||||
|
||||
// Which state the character creating is in, controls back/next/ok buttons
|
||||
CreationStageEnum creationStage;
|
||||
/// /REMOVE
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
Loading…
x
Reference in New Issue
Block a user