2010-07-17 12:01:47 +00:00
# include "window_manager.hpp"
2010-09-14 20:10:15 +00:00
# include "layouts.hpp"
2010-09-14 21:17:08 +00:00
# include "text_input.hpp"
2010-09-14 20:01:45 +00:00
# include "race.hpp"
2010-09-19 02:29:22 +00:00
# include "class.hpp"
2010-09-21 10:34:47 +00:00
# include "birth.hpp"
2010-07-17 12:01:47 +00:00
2010-09-14 19:27:40 +00:00
# include "../mwmechanics/mechanicsmanager.hpp"
2010-09-15 12:48:19 +00:00
# include "../mwinput/inputmanager.hpp"
2010-09-14 19:27:40 +00:00
2010-07-20 19:10:51 +00:00
# include "console.hpp"
2010-07-17 12:01:47 +00:00
# include <assert.h>
2010-08-22 09:22:10 +00:00
# include <iostream>
2010-08-22 10:56:35 +00:00
# include <iterator>
2010-07-17 12:01:47 +00:00
using namespace MWGui ;
2010-07-20 21:21:48 +00:00
WindowManager : : WindowManager ( MyGUI : : Gui * _gui , MWWorld : : Environment & environment ,
2010-07-21 08:28:58 +00:00
const Compiler : : Extensions & extensions , bool newGame )
2010-09-14 19:27:40 +00:00
: environment ( environment )
2010-09-14 21:17:08 +00:00
, nameDialog ( nullptr )
2010-09-14 19:27:40 +00:00
, raceDialog ( nullptr )
2010-10-09 22:42:56 +00:00
, classChoiceDialog ( nullptr )
, generateClassQuestionDialog ( nullptr )
2010-10-09 23:52:08 +00:00
, generateClassResultDialog ( nullptr )
2010-09-19 02:29:22 +00:00
, pickClassDialog ( nullptr )
2010-10-10 00:43:44 +00:00
, createClassDialog ( nullptr )
2010-09-21 10:34:47 +00:00
, birthSignDialog ( nullptr )
2010-09-14 19:27:40 +00:00
, nameChosen ( false )
, raceChosen ( false )
, classChosen ( false )
2010-09-21 10:34:47 +00:00
, birthSignChosen ( false )
2010-09-14 19:27:40 +00:00
, reviewNext ( false )
, gui ( _gui )
, mode ( GM_Game )
, shown ( GW_ALL )
, allowed ( newGame ? GW_None : GW_ALL )
2010-07-17 12:01:47 +00:00
{
// Get size info from the Gui object
assert ( gui ) ;
2010-08-30 10:19:45 +00:00
int w = gui - > getViewSize ( ) . width ;
int h = gui - > getViewSize ( ) . height ;
2010-07-17 12:01:47 +00:00
hud = new HUD ( w , h ) ;
menu = new MainMenu ( w , h ) ;
map = new MapWindow ( ) ;
2010-09-17 23:30:23 +00:00
stats = new StatsWindow ( environment ) ;
2010-09-15 11:15:58 +00:00
#if 0
2010-09-10 01:29:29 +00:00
inventory = new InventoryWindow ( ) ;
2010-09-15 11:15:58 +00:00
# endif
2010-07-20 21:21:48 +00:00
console = new Console ( w , h , environment , extensions ) ;
2010-07-17 12:01:47 +00:00
// The HUD is always on
hud - > setVisible ( true ) ;
// Set up visibility
updateVisible ( ) ;
}
WindowManager : : ~ WindowManager ( )
{
2010-07-20 19:10:51 +00:00
delete console ;
2010-07-17 12:01:47 +00:00
delete hud ;
delete map ;
delete menu ;
delete stats ;
2010-09-15 11:15:58 +00:00
#if 0
2010-09-10 01:29:29 +00:00
delete inventory ;
2010-09-15 11:15:58 +00:00
# endif
2010-09-12 12:06:10 +00:00
2010-09-14 21:17:08 +00:00
delete nameDialog ;
2010-09-12 12:06:10 +00:00
delete raceDialog ;
2010-10-09 22:42:56 +00:00
delete classChoiceDialog ;
delete generateClassQuestionDialog ;
2010-10-09 23:52:08 +00:00
delete generateClassResultDialog ;
2010-09-19 02:29:22 +00:00
delete pickClassDialog ;
2010-10-10 00:43:44 +00:00
delete createClassDialog ;
2010-09-21 10:34:47 +00:00
delete birthSignDialog ;
2010-07-17 12:01:47 +00:00
}
void WindowManager : : updateVisible ( )
{
// Start out by hiding everything except the HUD
map - > setVisible ( false ) ;
menu - > setVisible ( false ) ;
stats - > setVisible ( false ) ;
2010-09-15 11:15:58 +00:00
#if 0
2010-09-10 01:29:29 +00:00
inventory - > setVisible ( false ) ;
2010-09-15 11:15:58 +00:00
# endif
2010-07-20 19:10:51 +00:00
console - > disable ( ) ;
2010-07-17 12:01:47 +00:00
// Mouse is visible whenever we're not in game mode
gui - > setVisiblePointer ( isGuiMode ( ) ) ;
// If in game mode, don't show anything.
if ( mode = = GM_Game )
{
return ;
}
if ( mode = = GM_MainMenu )
{
// Enable the main menu
menu - > setVisible ( true ) ;
return ;
}
2010-07-20 19:10:51 +00:00
if ( mode = = GM_Console )
{
console - > enable ( ) ;
return ;
}
2010-09-14 21:17:08 +00:00
if ( mode = = GM_Name )
{
if ( ! nameDialog )
2010-09-15 17:37:06 +00:00
nameDialog = new TextInputDialog ( environment , gui - > getViewSize ( ) ) ;
std : : string sName = getGameSettingString ( " sName " , " Name " ) ;
nameDialog - > setTextLabel ( sName ) ;
nameDialog - > setNextButtonShow ( nameChosen ) ;
2010-09-14 21:17:08 +00:00
nameDialog - > eventDone = MyGUI : : newDelegate ( this , & WindowManager : : onNameDialogDone ) ;
2010-09-15 17:48:37 +00:00
nameDialog - > open ( ) ;
2010-09-14 21:17:08 +00:00
return ;
}
2010-09-14 19:27:40 +00:00
if ( mode = = GM_Race )
{
if ( ! raceDialog )
2010-09-15 19:48:10 +00:00
raceDialog = new RaceDialog ( environment , gui - > getViewSize ( ) ) ;
2010-09-15 17:44:53 +00:00
raceDialog - > setNextButtonShow ( raceChosen ) ;
2010-09-14 19:27:40 +00:00
raceDialog - > eventDone = MyGUI : : newDelegate ( this , & WindowManager : : onRaceDialogDone ) ;
raceDialog - > eventBack = MyGUI : : newDelegate ( this , & WindowManager : : onRaceDialogBack ) ;
2010-09-15 19:36:32 +00:00
raceDialog - > open ( ) ;
2010-09-14 19:27:40 +00:00
return ;
}
2010-09-19 02:29:22 +00:00
if ( mode = = GM_Class )
2010-10-09 22:42:56 +00:00
{
if ( classChoiceDialog )
delete classChoiceDialog ;
classChoiceDialog = new ClassChoiceDialog ( environment ) ;
classChoiceDialog - > eventButtonSelected = MyGUI : : newDelegate ( this , & WindowManager : : onClassChoice ) ;
return ;
}
if ( mode = = GM_ClassGenerate )
{
generateClassStep = 0 ;
showClassQuestionDialog ( ) ;
return ;
}
if ( mode = = GM_ClassPick )
2010-09-19 02:29:22 +00:00
{
if ( ! pickClassDialog )
pickClassDialog = new PickClassDialog ( environment , gui - > getViewSize ( ) ) ;
pickClassDialog - > setNextButtonShow ( classChosen ) ;
pickClassDialog - > eventDone = MyGUI : : newDelegate ( this , & WindowManager : : onPickClassDialogDone ) ;
pickClassDialog - > eventBack = MyGUI : : newDelegate ( this , & WindowManager : : onPickClassDialogBack ) ;
pickClassDialog - > open ( ) ;
return ;
}
2010-10-09 22:42:56 +00:00
if ( mode = = GM_ClassCreate )
{
2010-10-10 00:43:44 +00:00
if ( createClassDialog )
delete createClassDialog ;
createClassDialog = new CreateClassDialog ( environment , gui - > getViewSize ( ) ) ;
createClassDialog - > eventDone = MyGUI : : newDelegate ( this , & WindowManager : : onCreateClassDialogDone ) ;
createClassDialog - > eventBack = MyGUI : : newDelegate ( this , & WindowManager : : onCreateClassDialogBack ) ;
createClassDialog - > open ( ) ;
2010-10-09 22:42:56 +00:00
return ;
}
2010-09-21 10:34:47 +00:00
if ( mode = = GM_Birth )
{
if ( ! birthSignDialog )
birthSignDialog = new BirthDialog ( environment , gui - > getViewSize ( ) ) ;
birthSignDialog - > setNextButtonShow ( birthSignChosen ) ;
birthSignDialog - > eventDone = MyGUI : : newDelegate ( this , & WindowManager : : onBirthSignDialogDone ) ;
birthSignDialog - > eventBack = MyGUI : : newDelegate ( this , & WindowManager : : onBirthSignDialogBack ) ;
birthSignDialog - > open ( ) ;
return ;
}
2010-07-17 12:01:47 +00:00
if ( mode = = GM_Inventory )
{
// Ah, inventory mode. First, compute the effective set of
// windows to show. This is controlled both by what windows the
// user has opened/closed (the 'shown' variable) and by what
// windows we are allowed to show (the 'allowed' var.)
int eff = shown & allowed ;
// Show the windows we want
2010-09-15 11:16:54 +00:00
map - > setVisible ( ( eff & GW_Map ) ! = 0 ) ;
stats - > setVisible ( ( eff & GW_Stats ) ! = 0 ) ;
2010-09-15 11:15:58 +00:00
#if 0
2010-09-12 12:06:10 +00:00
// inventory -> setVisible( eff & GW_Inventory );
2010-09-15 11:15:58 +00:00
# endif
2010-09-14 19:55:41 +00:00
return ;
2010-07-17 12:01:47 +00:00
}
2010-09-15 12:48:19 +00:00
// Unsupported mode, switch back to game
// Note: The call will eventually end up this method again but
// will stop at the check if(mode == GM_Game) above.
environment . mInputManager - > setGuiMode ( GM_Game ) ;
2010-07-17 12:01:47 +00:00
}
2010-07-26 09:15:38 +00:00
2010-07-27 13:59:41 +00:00
void WindowManager : : setValue ( const std : : string & id , const MWMechanics : : Stat < int > & value )
{
stats - > setValue ( id , value ) ;
}
2010-09-18 16:04:53 +00:00
void WindowManager : : setValue ( const std : : string & id , const MWMechanics : : Stat < float > & value )
{
stats - > setValue ( id , value ) ;
}
2010-07-28 16:48:01 +00:00
void WindowManager : : setValue ( const std : : string & id , const MWMechanics : : DynamicStat < int > & value )
{
stats - > setValue ( id , value ) ;
hud - > setValue ( id , value ) ;
}
2010-08-22 09:22:10 +00:00
2010-09-15 10:22:06 +00:00
void WindowManager : : setValue ( const std : : string & id , const std : : string & value )
{
stats - > setValue ( id , value ) ;
}
2010-09-15 13:32:35 +00:00
void WindowManager : : setValue ( const std : : string & id , int value )
{
stats - > setValue ( id , value ) ;
}
2010-09-18 17:26:45 +00:00
void WindowManager : : configureSkills ( const SkillList & major , const SkillList & minor )
2010-09-17 23:30:23 +00:00
{
2010-09-18 17:26:45 +00:00
stats - > configureSkills ( major , minor ) ;
2010-09-17 23:30:23 +00:00
}
2010-09-18 16:21:37 +00:00
void WindowManager : : setFactions ( const FactionList & factions )
2010-09-18 00:24:42 +00:00
{
2010-09-18 16:21:37 +00:00
stats - > setFactions ( factions ) ;
2010-09-18 00:24:42 +00:00
}
2010-09-18 16:44:20 +00:00
void WindowManager : : setBirthSign ( const std : : string & signId )
2010-09-18 00:24:42 +00:00
{
2010-09-18 16:44:20 +00:00
stats - > setBirthSign ( signId ) ;
2010-09-18 00:24:42 +00:00
}
void WindowManager : : setReputation ( int reputation )
{
stats - > setReputation ( reputation ) ;
}
void WindowManager : : setBounty ( int bounty )
{
stats - > setBounty ( bounty ) ;
}
void WindowManager : : updateSkillArea ( )
{
stats - > updateSkillArea ( ) ;
}
2010-08-22 09:22:10 +00:00
void WindowManager : : messageBox ( const std : : string & message , const std : : vector < std : : string > & buttons )
{
std : : cout < < " message box: " < < message < < std : : endl ;
if ( ! buttons . empty ( ) )
2010-08-22 10:56:35 +00:00
{
std : : cout < < " buttons: " ;
std : : copy ( buttons . begin ( ) , buttons . end ( ) , std : : ostream_iterator < std : : string > ( std : : cout , " , " ) ) ;
std : : cout < < std : : endl ;
}
2010-08-22 09:22:10 +00:00
}
2010-09-14 17:33:40 +00:00
2010-09-15 20:22:27 +00:00
const std : : string & WindowManager : : getGameSettingString ( const std : : string & id , const std : : string & default_ )
2010-09-15 10:41:53 +00:00
{
const ESM : : GameSetting * setting = environment . mWorld - > getStore ( ) . gameSettings . search ( id ) ;
if ( setting & & setting - > type = = ESM : : VT_String )
return setting - > str ;
2010-09-15 20:22:27 +00:00
return default_ ;
2010-09-15 10:41:53 +00:00
}
2010-09-14 19:27:40 +00:00
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
}
}
2010-09-14 21:17:08 +00:00
void WindowManager : : onNameDialogDone ( )
{
2010-09-15 17:44:53 +00:00
nameDialog - > eventDone = MWGui : : TextInputDialog : : EventHandle_Void ( ) ;
2010-09-15 10:44:43 +00:00
bool goNext = nameChosen ; // Go to next dialog if name was previously chosen
2010-09-14 21:17:08 +00:00
nameChosen = true ;
if ( nameDialog )
{
nameDialog - > setVisible ( false ) ;
environment . mMechanicsManager - > setPlayerName ( nameDialog - > getTextInput ( ) ) ;
}
updateCharacterGeneration ( ) ;
if ( reviewNext )
2010-09-15 12:48:19 +00:00
environment . mInputManager - > setGuiMode ( GM_Review ) ;
2010-09-15 10:44:43 +00:00
else if ( goNext )
2010-09-15 12:48:19 +00:00
environment . mInputManager - > setGuiMode ( GM_Race ) ;
2010-09-15 11:10:47 +00:00
else
2010-09-15 12:48:19 +00:00
environment . mInputManager - > setGuiMode ( GM_Game ) ;
2010-09-14 21:17:08 +00:00
}
2010-09-14 17:33:40 +00:00
void WindowManager : : onRaceDialogDone ( )
{
2010-09-15 17:44:53 +00:00
raceDialog - > eventDone = MWGui : : RaceDialog : : EventHandle_Void ( ) ;
bool goNext = raceChosen ; // Go to next dialog if race was previously chosen
2010-09-14 19:27:40 +00:00
raceChosen = true ;
if ( raceDialog )
{
raceDialog - > setVisible ( false ) ;
2010-09-15 11:04:57 +00:00
environment . mMechanicsManager - > setPlayerRace ( raceDialog - > getRaceId ( ) , raceDialog - > getGender ( ) = = RaceDialog : : GM_Male ) ;
2010-09-14 19:27:40 +00:00
}
updateCharacterGeneration ( ) ;
if ( reviewNext )
2010-09-15 12:48:19 +00:00
environment . mInputManager - > setGuiMode ( GM_Review ) ;
2010-09-15 10:44:43 +00:00
else if ( goNext )
2010-09-15 12:48:19 +00:00
environment . mInputManager - > setGuiMode ( GM_Class ) ;
2010-09-15 11:10:47 +00:00
else
2010-09-15 12:48:19 +00:00
environment . mInputManager - > setGuiMode ( GM_Game ) ;
2010-09-14 17:33:40 +00:00
}
void WindowManager : : onRaceDialogBack ( )
{
2010-09-14 19:27:40 +00:00
if ( raceDialog )
{
raceDialog - > setVisible ( false ) ;
2010-09-15 11:04:57 +00:00
environment . mMechanicsManager - > setPlayerRace ( raceDialog - > getRaceId ( ) , raceDialog - > getGender ( ) = = RaceDialog : : GM_Male ) ;
2010-09-14 19:27:40 +00:00
}
updateCharacterGeneration ( ) ;
2010-09-15 12:48:19 +00:00
environment . mInputManager - > setGuiMode ( GM_Name ) ;
2010-09-14 17:33:40 +00:00
}
2010-09-19 02:29:22 +00:00
2010-10-09 22:42:56 +00:00
void WindowManager : : onClassChoice ( MyGUI : : WidgetPtr , int _index )
{
classChoiceDialog - > setVisible ( false ) ;
// classChoiceDialog = nullptr;
if ( _index = = ClassChoiceDialog : : Class_Generate )
{
environment . mInputManager - > setGuiMode ( GM_ClassGenerate ) ;
}
else if ( _index = = ClassChoiceDialog : : Class_Pick )
{
environment . mInputManager - > setGuiMode ( GM_ClassPick ) ;
}
else if ( _index = = ClassChoiceDialog : : Class_Create )
{
environment . mInputManager - > setGuiMode ( GM_ClassCreate ) ;
}
else if ( _index = = ClassChoiceDialog : : Class_Back )
{
environment . mInputManager - > setGuiMode ( GM_Race ) ;
}
}
void WindowManager : : showClassQuestionDialog ( )
{
struct Step
{
const char * text ;
const char * buttons [ 3 ] ;
} ;
static boost : : array < Step , 2 > steps = { {
{ " On a clear day you chance upon a strange animal, its legs trapped in a hunter's clawsnare. Judging from the bleeding, it will not survive long. " ,
{ " Use herbs from your pack to put it to sleep? " ,
" Do not interfere in the natural evolution of events, but rather take the opportunity to learn more about a strange animal that you have never seen before? " ,
" Draw your dagger, mercifully endings its life with a single thrust? " }
} ,
{ " Your mother sends you to the market with a list of goods to buy. After you finish you find that by mistake a shopkeeper has given you too much money back in exchange for one of the items. " ,
{ " Return to the store and give the shopkeeper his hard-earned money, explaining to him the mistake? " ,
" Pocket the extra money, knowing that shopkeepers in general tend to overcharge customers anyway? " ,
" Decide to put the extra money to good use and purchase items that would help your family? " }
} ,
} } ;
2010-10-09 23:52:08 +00:00
if ( generateClassStep = = steps . size ( ) )
2010-10-09 22:42:56 +00:00
{
2010-10-09 23:52:08 +00:00
// TODO: Calculate this in mechanics manager
generateClass = " acrobat " ;
if ( generateClassResultDialog )
delete generateClassResultDialog ;
generateClassResultDialog = new GenerateClassResultDialog ( environment ) ;
generateClassResultDialog - > setClassId ( generateClass ) ;
generateClassResultDialog - > eventBack = MyGUI : : newDelegate ( this , & WindowManager : : onGenerateClassBack ) ;
generateClassResultDialog - > eventDone = MyGUI : : newDelegate ( this , & WindowManager : : onGenerateClassDone ) ;
generateClassResultDialog - > setVisible ( true ) ;
2010-10-09 22:42:56 +00:00
return ;
}
2010-10-09 23:52:08 +00:00
if ( generateClassStep > steps . size ( ) )
2010-10-09 22:42:56 +00:00
{
2010-10-09 23:52:08 +00:00
environment . mInputManager - > setGuiMode ( GM_Class ) ;
2010-10-09 22:42:56 +00:00
return ;
}
2010-10-09 23:52:08 +00:00
if ( ! generateClassQuestionDialog )
generateClassQuestionDialog = new InfoBoxDialog ( environment ) ;
2010-10-09 22:42:56 +00:00
InfoBoxDialog : : ButtonList buttons ;
generateClassQuestionDialog - > setText ( steps [ generateClassStep ] . text ) ;
buttons . push_back ( steps [ generateClassStep ] . buttons [ 0 ] ) ;
buttons . push_back ( steps [ generateClassStep ] . buttons [ 1 ] ) ;
buttons . push_back ( steps [ generateClassStep ] . buttons [ 2 ] ) ;
generateClassQuestionDialog - > setButtons ( buttons ) ;
generateClassQuestionDialog - > update ( ) ;
generateClassQuestionDialog - > eventButtonSelected = MyGUI : : newDelegate ( this , & WindowManager : : onClassQuestionChosen ) ;
generateClassQuestionDialog - > setVisible ( true ) ;
}
void WindowManager : : onClassQuestionChosen ( MyGUI : : Widget * _sender , int _index )
{
generateClassQuestionDialog - > setVisible ( false ) ;
if ( _index < 0 | | _index > = 3 )
{
environment . mInputManager - > setGuiMode ( GM_Class ) ;
return ;
}
+ + generateClassStep ;
showClassQuestionDialog ( ) ;
}
2010-10-09 23:52:08 +00:00
void WindowManager : : onGenerateClassBack ( )
{
2010-10-10 00:43:44 +00:00
bool goNext = classChosen ; // Go to next dialog if class was previously chosen
classChosen = true ;
2010-10-09 23:52:08 +00:00
if ( generateClassResultDialog )
{
generateClassResultDialog - > setVisible ( false ) ;
}
environment . mMechanicsManager - > setPlayerClass ( generateClass ) ;
updateCharacterGeneration ( ) ;
environment . mInputManager - > setGuiMode ( GM_Class ) ;
}
void WindowManager : : onGenerateClassDone ( )
{
2010-10-10 00:43:44 +00:00
bool goNext = classChosen ; // Go to next dialog if class was previously chosen
classChosen = true ;
2010-10-09 23:52:08 +00:00
if ( generateClassResultDialog )
{
generateClassResultDialog - > setVisible ( false ) ;
}
environment . mMechanicsManager - > setPlayerClass ( generateClass ) ;
updateCharacterGeneration ( ) ;
2010-10-10 00:43:44 +00:00
if ( reviewNext )
environment . mInputManager - > setGuiMode ( GM_Review ) ;
else if ( goNext )
environment . mInputManager - > setGuiMode ( GM_Birth ) ;
else
environment . mInputManager - > setGuiMode ( GM_Game ) ;
2010-10-09 23:52:08 +00:00
}
2010-09-19 02:29:22 +00:00
void WindowManager : : onPickClassDialogDone ( )
{
pickClassDialog - > eventDone = MWGui : : PickClassDialog : : EventHandle_Void ( ) ;
bool goNext = classChosen ; // Go to next dialog if class was previously chosen
classChosen = true ;
if ( pickClassDialog )
{
pickClassDialog - > setVisible ( false ) ;
2010-09-21 13:44:48 +00:00
environment . mMechanicsManager - > setPlayerClass ( pickClassDialog - > getClassId ( ) ) ;
2010-09-19 02:29:22 +00:00
}
updateCharacterGeneration ( ) ;
if ( reviewNext )
environment . mInputManager - > setGuiMode ( GM_Review ) ;
else if ( goNext )
environment . mInputManager - > setGuiMode ( GM_Birth ) ;
else
environment . mInputManager - > setGuiMode ( GM_Game ) ;
}
void WindowManager : : onPickClassDialogBack ( )
2010-10-10 00:43:44 +00:00
{
if ( pickClassDialog )
{
pickClassDialog - > setVisible ( false ) ;
environment . mMechanicsManager - > setPlayerClass ( pickClassDialog - > getClassId ( ) ) ;
}
updateCharacterGeneration ( ) ;
environment . mInputManager - > setGuiMode ( GM_Class ) ;
}
void WindowManager : : onCreateClassDialogDone ( )
{
createClassDialog - > eventDone = MWGui : : CreateClassDialog : : EventHandle_Void ( ) ;
bool goNext = classChosen ; // Go to next dialog if class was previously chosen
classChosen = true ;
if ( createClassDialog )
{
createClassDialog - > setVisible ( false ) ;
// TODO: The ESM::Class should have methods to set these values to ensure correct data is assigned
ESM : : Class klass ;
klass . name = createClassDialog - > getName ( ) ;
klass . description = createClassDialog - > getDescription ( ) ;
klass . data . specialization = createClassDialog - > getSpecializationId ( ) ;
klass . data . isPlayable = 0x1 ;
std : : vector < int > attributes = createClassDialog - > getFavoriteAttributes ( ) ;
assert ( attributes . size ( ) = = 2 ) ;
klass . data . attribute [ 0 ] = attributes [ 0 ] ;
klass . data . attribute [ 1 ] = attributes [ 1 ] ;
std : : vector < ESM : : Skill : : SkillEnum > majorSkills = createClassDialog - > getMajorSkills ( ) ;
std : : vector < ESM : : Skill : : SkillEnum > minorSkills = createClassDialog - > getMinorSkills ( ) ;
assert ( majorSkills . size ( ) > = sizeof ( klass . data . skills ) / sizeof ( klass . data . skills [ 0 ] ) ) ;
assert ( minorSkills . size ( ) > = sizeof ( klass . data . skills ) / sizeof ( klass . data . skills [ 0 ] ) ) ;
for ( size_t i = 0 ; i < sizeof ( klass . data . skills ) / sizeof ( klass . data . skills [ 0 ] ) ; + + i )
{
klass . data . skills [ i ] [ 1 ] = majorSkills [ i ] ;
klass . data . skills [ i ] [ 0 ] = minorSkills [ i ] ;
}
environment . mMechanicsManager - > setPlayerClass ( klass ) ;
}
updateCharacterGeneration ( ) ;
if ( reviewNext )
environment . mInputManager - > setGuiMode ( GM_Review ) ;
else if ( goNext )
environment . mInputManager - > setGuiMode ( GM_Birth ) ;
else
environment . mInputManager - > setGuiMode ( GM_Game ) ;
}
void WindowManager : : onCreateClassDialogBack ( )
2010-09-19 02:29:22 +00:00
{
if ( pickClassDialog )
{
pickClassDialog - > setVisible ( false ) ;
2010-09-21 13:44:48 +00:00
environment . mMechanicsManager - > setPlayerClass ( pickClassDialog - > getClassId ( ) ) ;
2010-09-19 02:29:22 +00:00
}
updateCharacterGeneration ( ) ;
2010-10-09 22:42:56 +00:00
environment . mInputManager - > setGuiMode ( GM_Class ) ;
2010-09-19 02:29:22 +00:00
}
2010-09-21 10:34:47 +00:00
void WindowManager : : onBirthSignDialogDone ( )
{
birthSignDialog - > eventDone = MWGui : : BirthDialog : : EventHandle_Void ( ) ;
bool goNext = birthSignChosen ; // Go to next dialog if birth sign was previously chosen
birthSignChosen = true ;
if ( birthSignDialog )
{
birthSignDialog - > setVisible ( false ) ;
environment . mMechanicsManager - > setPlayerBirthsign ( birthSignDialog - > getBirthId ( ) ) ;
}
updateCharacterGeneration ( ) ;
if ( reviewNext | | goNext )
environment . mInputManager - > setGuiMode ( GM_Review ) ;
else
environment . mInputManager - > setGuiMode ( GM_Game ) ;
}
void WindowManager : : onBirthSignDialogBack ( )
{
if ( birthSignDialog )
{
birthSignDialog - > setVisible ( false ) ;
environment . mMechanicsManager - > setPlayerBirthsign ( birthSignDialog - > getBirthId ( ) ) ;
}
updateCharacterGeneration ( ) ;
environment . mInputManager - > setGuiMode ( GM_Class ) ;
}