Race dialog is now triggered by setMode(GM_Race) and not part of the inventory mode anymore. Initial implementation of the dialog management of back/ok/next buttons.

This commit is contained in:
Jan Borsodi 2010-09-14 21:27:40 +02:00
parent a59a53882f
commit de554dffd2
4 changed files with 101 additions and 15 deletions

View file

@ -12,7 +12,7 @@
using namespace MWGui;
RaceDialog::RaceDialog(MWWorld::Environment& environment)
RaceDialog::RaceDialog(MWWorld::Environment& environment, bool showNext)
: Layout("openmw_chargen_race_layout.xml")
, environment(environment)
, genderIndex(0)
@ -63,14 +63,21 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment)
getWidget(skillList, "SkillList");
getWidget(spellPowerList, "SpellPowerList");
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onOkClicked);
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton");
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onBackClicked);
if (showNext)
{
}
else
{
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onOkClicked);
}
updateRaces();
updateSkills();
updateSpellPowers();

View file

@ -34,9 +34,23 @@ namespace MWGui
class RaceDialog : public OEngine::GUI::Layout
{
public:
RaceDialog(MWWorld::Environment& environment);
RaceDialog(MWWorld::Environment& environment, bool showNext);
enum Gender
{
GM_Male,
GM_Female
};
const std::string &getRace() const { return currentRace; }
Gender getGender() const { return genderIndex == 0 ? GM_Male : GM_Female; }
// getFace()
// getHair()
void setRace(const std::string &race);
void setGender(Gender gender) { genderIndex = gender == GM_Male ? 0 : 1; }
// setFace()
// setHair()
// Events

View file

@ -2,6 +2,8 @@
#include "mw_layouts.hpp"
#include "mw_chargen.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "console.hpp"
#include <assert.h>
@ -12,7 +14,17 @@ using namespace MWGui;
WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
const Compiler::Extensions& extensions, bool newGame)
: gui(_gui), mode(GM_Game), shown(GW_ALL), allowed(newGame ? GW_None : GW_ALL)
: environment(environment)
, raceDialog(nullptr)
, nameChosen(false)
, raceChosen(false)
, classChosen(false)
, birthChosen(false)
, reviewNext(false)
, gui(_gui)
, mode(GM_Game)
, shown(GW_ALL)
, allowed(newGame ? GW_None : GW_ALL)
{
// Get size info from the Gui object
assert(gui);
@ -26,10 +38,6 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
inventory = new InventoryWindow ();
console = new Console(w,h, environment, extensions);
raceDialog = new RaceDialog (environment);
raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone);
raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack);
// The HUD is always on
hud->setVisible(true);
@ -57,7 +65,6 @@ void WindowManager::updateVisible()
stats->setVisible(false);
inventory->setVisible(false);
console->disable();
raceDialog->setVisible(false);
// Mouse is visible whenever we're not in game mode
gui->setVisiblePointer(isGuiMode());
@ -81,6 +88,16 @@ void WindowManager::updateVisible()
return;
}
if (mode == GM_Race)
{
if (!raceDialog)
raceDialog = new RaceDialog (environment, raceChosen);
raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone);
raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack);
raceDialog->setVisible(true);
return;
}
if(mode == GM_Inventory)
{
// Ah, inventory mode. First, compute the effective set of
@ -125,12 +142,47 @@ void WindowManager::messageBox (const std::string& message, const std::vector<st
}
}
void WindowManager::updateCharacterGeneration()
{
if (raceDialog)
{
// TOOD: Uncomment when methods in mechanics manager is implemented
//raceDialog->setRace(environment.mMechanicsManager->getPlayerRace());
//raceDialog->setGender(environment.mMechanicsManager->getPlayerMale() ? RaceDialog::GM_Male : RaceDialog::GM_Female);
// TODO: Face/Hair
}
}
void WindowManager::onRaceDialogDone()
{
raceChosen = true;
if (raceDialog)
{
raceDialog->setVisible(false);
environment.mMechanicsManager->setPlayerRace(raceDialog->getRace(), raceDialog->getGender() == RaceDialog::GM_Male);
}
delete raceDialog;
raceDialog = nullptr;
updateCharacterGeneration();
if (reviewNext)
setMode(GM_Review);
else if (classChosen)
setMode(GM_Class);
}
void WindowManager::onRaceDialogBack()
{
if (raceDialog)
{
raceDialog->setVisible(false);
environment.mMechanicsManager->setPlayerRace(raceDialog->getRace(), raceDialog->getGender() == RaceDialog::GM_Male);
}
delete raceDialog;
raceDialog = nullptr;
updateCharacterGeneration();
setMode(GM_Name);
}

View file

@ -79,6 +79,7 @@ namespace MWGui
class WindowManager
{
MWWorld::Environment& environment;
HUD *hud;
MapWindow *map;
MainMenu *menu;
@ -86,8 +87,17 @@ namespace MWGui
InventoryWindow *inventory;
Console *console;
// Character creation
RaceDialog *raceDialog;
// Which dialogs have been shown, controls back/next/ok buttons
bool nameChosen;
bool raceChosen;
bool classChosen;
bool birthChosen;
bool reviewNext;
///< If true then any click on Next will cause the summary to be shown
MyGUI::Gui *gui;
// Current gui mode
@ -155,6 +165,9 @@ namespace MWGui
void messageBox (const std::string& message, const std::vector<std::string>& buttons);
private:
void updateCharacterGeneration();
void checkCharacterGeneration(GuiMode mode);
void onRaceDialogDone();
void onRaceDialogBack();
};