mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-29 22:20:33 +00:00
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:
parent
a59a53882f
commit
de554dffd2
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
RaceDialog::RaceDialog(MWWorld::Environment& environment)
|
RaceDialog::RaceDialog(MWWorld::Environment& environment, bool showNext)
|
||||||
: Layout("openmw_chargen_race_layout.xml")
|
: Layout("openmw_chargen_race_layout.xml")
|
||||||
, environment(environment)
|
, environment(environment)
|
||||||
, genderIndex(0)
|
, genderIndex(0)
|
||||||
@ -63,14 +63,21 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment)
|
|||||||
getWidget(skillList, "SkillList");
|
getWidget(skillList, "SkillList");
|
||||||
getWidget(spellPowerList, "SpellPowerList");
|
getWidget(spellPowerList, "SpellPowerList");
|
||||||
|
|
||||||
MyGUI::ButtonPtr okButton;
|
// TODO: These buttons should be managed by a Dialog class
|
||||||
getWidget(okButton, "OKButton");
|
|
||||||
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onOkClicked);
|
|
||||||
|
|
||||||
MyGUI::ButtonPtr backButton;
|
MyGUI::ButtonPtr backButton;
|
||||||
getWidget(backButton, "BackButton");
|
getWidget(backButton, "BackButton");
|
||||||
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onBackClicked);
|
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onBackClicked);
|
||||||
|
|
||||||
|
if (showNext)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MyGUI::ButtonPtr okButton;
|
||||||
|
getWidget(okButton, "OKButton");
|
||||||
|
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onOkClicked);
|
||||||
|
}
|
||||||
|
|
||||||
updateRaces();
|
updateRaces();
|
||||||
updateSkills();
|
updateSkills();
|
||||||
updateSpellPowers();
|
updateSpellPowers();
|
||||||
|
@ -34,9 +34,23 @@ namespace MWGui
|
|||||||
class RaceDialog : public OEngine::GUI::Layout
|
class RaceDialog : public OEngine::GUI::Layout
|
||||||
{
|
{
|
||||||
public:
|
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 setRace(const std::string &race);
|
||||||
|
void setGender(Gender gender) { genderIndex = gender == GM_Male ? 0 : 1; }
|
||||||
|
// setFace()
|
||||||
|
// setHair()
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
|
|
||||||
@ -84,7 +98,7 @@ namespace MWGui
|
|||||||
MyGUI::WidgetPtr spellPowerList;
|
MyGUI::WidgetPtr spellPowerList;
|
||||||
std::vector<MyGUI::WidgetPtr> spellPowerItems;
|
std::vector<MyGUI::WidgetPtr> spellPowerItems;
|
||||||
|
|
||||||
int genderIndex, faceIndex, hairIndex;
|
int genderIndex, faceIndex, hairIndex;
|
||||||
int faceCount, hairCount;
|
int faceCount, hairCount;
|
||||||
|
|
||||||
std::string currentRace;
|
std::string currentRace;
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include "mw_layouts.hpp"
|
#include "mw_layouts.hpp"
|
||||||
#include "mw_chargen.hpp"
|
#include "mw_chargen.hpp"
|
||||||
|
|
||||||
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||||
|
|
||||||
#include "console.hpp"
|
#include "console.hpp"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -12,7 +14,17 @@ using namespace MWGui;
|
|||||||
|
|
||||||
WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
||||||
const Compiler::Extensions& extensions, bool newGame)
|
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
|
// Get size info from the Gui object
|
||||||
assert(gui);
|
assert(gui);
|
||||||
@ -26,10 +38,6 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
|||||||
inventory = new InventoryWindow ();
|
inventory = new InventoryWindow ();
|
||||||
console = new Console(w,h, environment, extensions);
|
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
|
// The HUD is always on
|
||||||
hud->setVisible(true);
|
hud->setVisible(true);
|
||||||
|
|
||||||
@ -57,7 +65,6 @@ void WindowManager::updateVisible()
|
|||||||
stats->setVisible(false);
|
stats->setVisible(false);
|
||||||
inventory->setVisible(false);
|
inventory->setVisible(false);
|
||||||
console->disable();
|
console->disable();
|
||||||
raceDialog->setVisible(false);
|
|
||||||
|
|
||||||
// Mouse is visible whenever we're not in game mode
|
// Mouse is visible whenever we're not in game mode
|
||||||
gui->setVisiblePointer(isGuiMode());
|
gui->setVisiblePointer(isGuiMode());
|
||||||
@ -81,6 +88,16 @@ void WindowManager::updateVisible()
|
|||||||
return;
|
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)
|
if(mode == GM_Inventory)
|
||||||
{
|
{
|
||||||
// Ah, inventory mode. First, compute the effective set of
|
// 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()
|
void WindowManager::onRaceDialogDone()
|
||||||
{
|
{
|
||||||
raceDialog->setVisible(false);
|
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()
|
void WindowManager::onRaceDialogBack()
|
||||||
{
|
{
|
||||||
raceDialog->setVisible(false);
|
if (raceDialog)
|
||||||
|
{
|
||||||
|
raceDialog->setVisible(false);
|
||||||
|
environment.mMechanicsManager->setPlayerRace(raceDialog->getRace(), raceDialog->getGender() == RaceDialog::GM_Male);
|
||||||
|
}
|
||||||
|
delete raceDialog;
|
||||||
|
raceDialog = nullptr;
|
||||||
|
|
||||||
|
updateCharacterGeneration();
|
||||||
|
|
||||||
|
setMode(GM_Name);
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,7 @@ namespace MWGui
|
|||||||
|
|
||||||
class WindowManager
|
class WindowManager
|
||||||
{
|
{
|
||||||
|
MWWorld::Environment& environment;
|
||||||
HUD *hud;
|
HUD *hud;
|
||||||
MapWindow *map;
|
MapWindow *map;
|
||||||
MainMenu *menu;
|
MainMenu *menu;
|
||||||
@ -86,8 +87,17 @@ namespace MWGui
|
|||||||
InventoryWindow *inventory;
|
InventoryWindow *inventory;
|
||||||
Console *console;
|
Console *console;
|
||||||
|
|
||||||
|
// Character creation
|
||||||
RaceDialog *raceDialog;
|
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;
|
MyGUI::Gui *gui;
|
||||||
|
|
||||||
// Current gui mode
|
// Current gui mode
|
||||||
@ -155,6 +165,9 @@ namespace MWGui
|
|||||||
void messageBox (const std::string& message, const std::vector<std::string>& buttons);
|
void messageBox (const std::string& message, const std::vector<std::string>& buttons);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateCharacterGeneration();
|
||||||
|
void checkCharacterGeneration(GuiMode mode);
|
||||||
|
|
||||||
void onRaceDialogDone();
|
void onRaceDialogDone();
|
||||||
void onRaceDialogBack();
|
void onRaceDialogBack();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user