@ -1,6 +1,5 @@
# include "class.hpp"
# include <assert.h>
# include <iterator>
# include <boost/algorithm/string.hpp>
@ -26,8 +25,8 @@ GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowMan
setText ( " ReflectT " , mWindowManager . getGameSettingString ( " sMessageQuestionAnswer1 " , " " ) ) ;
getWidget ( c lassImage, " ClassImage " ) ;
getWidget ( c lassName, " ClassName " ) ;
getWidget ( mC lassImage, " ClassImage " ) ;
getWidget ( mC lassName, " ClassName " ) ;
MyGUI : : ButtonPtr backButton ;
getWidget ( backButton , " BackButton " ) ;
@ -51,15 +50,15 @@ void GenerateClassResultDialog::open()
std : : string GenerateClassResultDialog : : getClassId ( ) const
{
return c lassName- > getCaption ( ) ;
return mC lassName- > getCaption ( ) ;
}
void GenerateClassResultDialog : : setClassId ( const std : : string & classId )
{
c urrentClassId = classId ;
c lassImage- > setImageTexture ( std : : string ( " textures \\ levelup \\ " ) + c urrentClassId + " .dds " ) ;
mC urrentClassId = classId ;
mC lassImage- > setImageTexture ( std : : string ( " textures \\ levelup \\ " ) + mC urrentClassId + " .dds " ) ;
const ESMS : : ESMStore & store = mWindowManager . getStore ( ) ;
c lassName- > setCaption ( store . classes . find ( c urrentClassId) - > name ) ;
mC lassName- > setCaption ( store . classes . find ( mC urrentClassId) - > name ) ;
}
// widget controls
@ -82,29 +81,29 @@ PickClassDialog::PickClassDialog(WindowManager& parWindowManager)
// Centre dialog
center ( ) ;
getWidget ( s pecializationName, " SpecializationName " ) ;
getWidget ( mS pecializationName, " SpecializationName " ) ;
getWidget ( f avoriteAttribute[ 0 ] , " FavoriteAttribute0 " ) ;
getWidget ( f avoriteAttribute[ 1 ] , " FavoriteAttribute1 " ) ;
f avoriteAttribute[ 0 ] - > setWindowManager ( & mWindowManager ) ;
f avoriteAttribute[ 1 ] - > setWindowManager ( & mWindowManager ) ;
getWidget ( mF avoriteAttribute[ 0 ] , " FavoriteAttribute0 " ) ;
getWidget ( mF avoriteAttribute[ 1 ] , " FavoriteAttribute1 " ) ;
mF avoriteAttribute[ 0 ] - > setWindowManager ( & mWindowManager ) ;
mF avoriteAttribute[ 1 ] - > setWindowManager ( & mWindowManager ) ;
for ( int i = 0 ; i < 5 ; i + + )
{
char theIndex = ' 0 ' + i ;
getWidget ( m ajorSkill[ i ] , std : : string ( " MajorSkill " ) . append ( 1 , theIndex ) ) ;
getWidget ( m inorSkill[ i ] , std : : string ( " MinorSkill " ) . append ( 1 , theIndex ) ) ;
m ajorSkill[ i ] - > setWindowManager ( & mWindowManager ) ;
m inorSkill[ i ] - > setWindowManager ( & mWindowManager ) ;
getWidget ( m M ajorSkill[ i ] , std : : string ( " MajorSkill " ) . append ( 1 , theIndex ) ) ;
getWidget ( m M inorSkill[ i ] , std : : string ( " MinorSkill " ) . append ( 1 , theIndex ) ) ;
m M ajorSkill[ i ] - > setWindowManager ( & mWindowManager ) ;
m M inorSkill[ i ] - > setWindowManager ( & mWindowManager ) ;
}
getWidget ( c lassList, " ClassList " ) ;
c lassList- > setScrollVisible ( true ) ;
c lassList- > eventListSelectAccept + = MyGUI : : newDelegate ( this , & PickClassDialog : : onSelectClass ) ;
c lassList- > eventListMouseItemActivate + = MyGUI : : newDelegate ( this , & PickClassDialog : : onSelectClass ) ;
c lassList- > eventListChangePosition + = MyGUI : : newDelegate ( this , & PickClassDialog : : onSelectClass ) ;
getWidget ( mC lassList, " ClassList " ) ;
mC lassList- > setScrollVisible ( true ) ;
mC lassList- > eventListSelectAccept + = MyGUI : : newDelegate ( this , & PickClassDialog : : onSelectClass ) ;
mC lassList- > eventListMouseItemActivate + = MyGUI : : newDelegate ( this , & PickClassDialog : : onSelectClass ) ;
mC lassList- > eventListChangePosition + = MyGUI : : newDelegate ( this , & PickClassDialog : : onSelectClass ) ;
getWidget ( c lassImage, " ClassImage " ) ;
getWidget ( mC lassImage, " ClassImage " ) ;
MyGUI : : ButtonPtr backButton ;
getWidget ( backButton , " BackButton " ) ;
@ -148,14 +147,14 @@ void PickClassDialog::open()
void PickClassDialog : : setClassId ( const std : : string & classId )
{
c urrentClassId = classId ;
c lassList- > setIndexSelected ( MyGUI : : ITEM_NONE ) ;
size_t count = c lassList- > getItemCount ( ) ;
mC urrentClassId = classId ;
mC lassList- > setIndexSelected ( MyGUI : : ITEM_NONE ) ;
size_t count = mC lassList- > getItemCount ( ) ;
for ( size_t i = 0 ; i < count ; + + i )
{
if ( boost : : iequals ( * c lassList- > getItemDataAt < std : : string > ( i ) , classId ) )
if ( boost : : iequals ( * mC lassList- > getItemDataAt < std : : string > ( i ) , classId ) )
{
c lassList- > setIndexSelected ( i ) ;
mC lassList- > setIndexSelected ( i ) ;
break ;
}
}
@ -180,11 +179,11 @@ void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index)
if ( _index = = MyGUI : : ITEM_NONE )
return ;
const std : : string * classId = c lassList- > getItemDataAt < std : : string > ( _index ) ;
if ( boost : : iequals ( c urrentClassId, * classId ) )
const std : : string * classId = mC lassList- > getItemDataAt < std : : string > ( _index ) ;
if ( boost : : iequals ( mC urrentClassId, * classId ) )
return ;
c urrentClassId = * classId ;
mC urrentClassId = * classId ;
updateStats ( ) ;
}
@ -192,7 +191,7 @@ void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index)
void PickClassDialog : : updateClasses ( )
{
c lassList- > removeAllItems ( ) ;
mC lassList- > removeAllItems ( ) ;
const ESMS : : ESMStore & store = mWindowManager . getStore ( ) ;
@ -207,19 +206,19 @@ void PickClassDialog::updateClasses()
continue ;
const std : : string & id = it - > first ;
c lassList- > addItem ( klass . name , id ) ;
if ( boost : : iequals ( id , c urrentClassId) )
c lassList- > setIndexSelected ( index ) ;
mC lassList- > addItem ( klass . name , id ) ;
if ( boost : : iequals ( id , mC urrentClassId) )
mC lassList- > setIndexSelected ( index ) ;
+ + index ;
}
}
void PickClassDialog : : updateStats ( )
{
if ( c urrentClassId. empty ( ) )
if ( mC urrentClassId. empty ( ) )
return ;
const ESMS : : ESMStore & store = mWindowManager . getStore ( ) ;
const ESM : : Class * klass = store . classes . search ( c urrentClassId) ;
const ESM : : Class * klass = store . classes . search ( mC urrentClassId) ;
if ( ! klass )
return ;
@ -231,23 +230,23 @@ void PickClassDialog::updateStats()
" sSpecializationStealth "
} ;
std : : string specName = mWindowManager . getGameSettingString ( specIds [ specialization ] , specIds [ specialization ] ) ;
s pecializationName- > setCaption ( specName ) ;
ToolTips : : createSpecializationToolTip ( s pecializationName, specName , specialization ) ;
mS pecializationName- > setCaption ( specName ) ;
ToolTips : : createSpecializationToolTip ( mS pecializationName, specName , specialization ) ;
f avoriteAttribute[ 0 ] - > setAttributeId ( klass - > data . attribute [ 0 ] ) ;
f avoriteAttribute[ 1 ] - > setAttributeId ( klass - > data . attribute [ 1 ] ) ;
ToolTips : : createAttributeToolTip ( favoriteAttribute[ 0 ] , f avoriteAttribute[ 0 ] - > getAttributeId ( ) ) ;
ToolTips : : createAttributeToolTip ( favoriteAttribute[ 1 ] , f avoriteAttribute[ 1 ] - > getAttributeId ( ) ) ;
mF avoriteAttribute[ 0 ] - > setAttributeId ( klass - > data . attribute [ 0 ] ) ;
mF avoriteAttribute[ 1 ] - > setAttributeId ( klass - > data . attribute [ 1 ] ) ;
ToolTips : : createAttributeToolTip ( mFavoriteAttribute[ 0 ] , mF avoriteAttribute[ 0 ] - > getAttributeId ( ) ) ;
ToolTips : : createAttributeToolTip ( mFavoriteAttribute[ 1 ] , mF avoriteAttribute[ 1 ] - > getAttributeId ( ) ) ;
for ( int i = 0 ; i < 5 ; + + i )
{
m inorSkill[ i ] - > setSkillNumber ( klass - > data . skills [ i ] [ 0 ] ) ;
m ajorSkill[ i ] - > setSkillNumber ( klass - > data . skills [ i ] [ 1 ] ) ;
ToolTips : : createSkillToolTip ( m inorSkill[ i ] , klass - > data . skills [ i ] [ 0 ] ) ;
ToolTips : : createSkillToolTip ( m ajorSkill[ i ] , klass - > data . skills [ i ] [ 1 ] ) ;
m M inorSkill[ i ] - > setSkillNumber ( klass - > data . skills [ i ] [ 0 ] ) ;
m M ajorSkill[ i ] - > setSkillNumber ( klass - > data . skills [ i ] [ 1 ] ) ;
ToolTips : : createSkillToolTip ( m M inorSkill[ i ] , klass - > data . skills [ i ] [ 0 ] ) ;
ToolTips : : createSkillToolTip ( m M ajorSkill[ i ] , klass - > data . skills [ i ] [ 1 ] ) ;
}
c lassImage- > setImageTexture ( std : : string ( " textures \\ levelup \\ " ) + c urrentClassId + " .dds " ) ;
mC lassImage- > setImageTexture ( std : : string ( " textures \\ levelup \\ " ) + mC urrentClassId + " .dds " ) ;
}
/* InfoBoxDialog */
@ -284,59 +283,59 @@ void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin)
InfoBoxDialog : : InfoBoxDialog ( WindowManager & parWindowManager )
: WindowBase ( " openmw_infobox.layout " , parWindowManager )
, c urrentButton( - 1 )
, mC urrentButton( - 1 )
{
getWidget ( t extBox, " TextBox " ) ;
getWidget ( t ext, " Text " ) ;
t ext- > getSubWidgetText ( ) - > setWordWrap ( true ) ;
getWidget ( b uttonBar, " ButtonBar " ) ;
getWidget ( mT extBox, " TextBox " ) ;
getWidget ( mT ext, " Text " ) ;
mT ext- > getSubWidgetText ( ) - > setWordWrap ( true ) ;
getWidget ( mB uttonBar, " ButtonBar " ) ;
center ( ) ;
}
void InfoBoxDialog : : setText ( const std : : string & str )
{
t ext- > setCaption ( str ) ;
t extBox- > setVisible ( ! str . empty ( ) ) ;
fitToText ( t ext) ;
mT ext- > setCaption ( str ) ;
mT extBox- > setVisible ( ! str . empty ( ) ) ;
fitToText ( mT ext) ;
}
std : : string InfoBoxDialog : : getText ( ) const
{
return t ext- > getCaption ( ) ;
return mT ext- > getCaption ( ) ;
}
void InfoBoxDialog : : setButtons ( ButtonList & buttons )
{
for ( std : : vector < MyGUI : : ButtonPtr > : : iterator it = this - > b uttons. begin ( ) ; it ! = this - > b uttons. end ( ) ; + + it )
for ( std : : vector < MyGUI : : ButtonPtr > : : iterator it = this - > mB uttons. begin ( ) ; it ! = this - > mB uttons. end ( ) ; + + it )
{
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( * it ) ;
}
this - > b uttons. clear ( ) ;
c urrentButton = - 1 ;
this - > mB uttons. clear ( ) ;
mC urrentButton = - 1 ;
// TODO: The buttons should be generated from a template in the layout file, ie. cloning an existing widget
MyGUI : : ButtonPtr button ;
MyGUI : : IntCoord coord = MyGUI : : IntCoord ( 0 , 0 , b uttonBar- > getWidth ( ) , 10 ) ;
MyGUI : : IntCoord coord = MyGUI : : IntCoord ( 0 , 0 , mB uttonBar- > getWidth ( ) , 10 ) ;
ButtonList : : const_iterator end = buttons . end ( ) ;
for ( ButtonList : : const_iterator it = buttons . begin ( ) ; it ! = end ; + + it )
{
const std : : string & text = * it ;
button = b uttonBar- > createWidget < MyGUI : : Button > ( " MW_Button " , coord , MyGUI : : Align : : Top | MyGUI : : Align : : HCenter , " " ) ;
button = mB uttonBar- > createWidget < MyGUI : : Button > ( " MW_Button " , coord , MyGUI : : Align : : Top | MyGUI : : Align : : HCenter , " " ) ;
button - > getSubWidgetText ( ) - > setWordWrap ( true ) ;
button - > setCaption ( text ) ;
fitToText ( button ) ;
button - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & InfoBoxDialog : : onButtonClicked ) ;
coord . top + = button - > getHeight ( ) ;
this - > b uttons. push_back ( button ) ;
this - > mB uttons. push_back ( button ) ;
}
}
void InfoBoxDialog : : open ( )
{
// Fix layout
layoutVertically ( t extBox, 4 ) ;
layoutVertically ( b uttonBar, 6 ) ;
layoutVertically ( mT extBox, 4 ) ;
layoutVertically ( mB uttonBar, 6 ) ;
layoutVertically ( mMainWidget , 4 + 6 ) ;
center ( ) ;
@ -345,18 +344,18 @@ void InfoBoxDialog::open()
int InfoBoxDialog : : getChosenButton ( ) const
{
return c urrentButton;
return mC urrentButton;
}
void InfoBoxDialog : : onButtonClicked ( MyGUI : : WidgetPtr _sender )
{
std : : vector < MyGUI : : ButtonPtr > : : const_iterator end = b uttons. end ( ) ;
std : : vector < MyGUI : : ButtonPtr > : : const_iterator end = mB uttons. end ( ) ;
int i = 0 ;
for ( std : : vector < MyGUI : : ButtonPtr > : : const_iterator it = b uttons. begin ( ) ; it ! = end ; + + it )
for ( std : : vector < MyGUI : : ButtonPtr > : : const_iterator it = mB uttons. begin ( ) ; it ! = end ; + + it )
{
if ( * it = = _sender )
{
c urrentButton = i ;
mC urrentButton = i ;
eventButtonSelected ( i ) ;
return ;
}
@ -382,49 +381,49 @@ ClassChoiceDialog::ClassChoiceDialog(WindowManager& parWindowManager)
CreateClassDialog : : CreateClassDialog ( WindowManager & parWindowManager )
: WindowBase ( " openmw_chargen_create_class.layout " , parWindowManager )
, s pecDialog( nullptr )
, a ttribDialog( nullptr )
, s killDialog( nullptr )
, d escDialog( nullptr )
, mS pecDialog( nullptr )
, mA ttribDialog( nullptr )
, mS killDialog( nullptr )
, mD escDialog( nullptr )
{
// Centre dialog
center ( ) ;
setText ( " SpecializationT " , mWindowManager . getGameSettingString ( " sChooseClassMenu1 " , " Specialization " ) ) ;
getWidget ( s pecializationName, " SpecializationName " ) ;
s pecializationName- > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onSpecializationClicked ) ;
getWidget ( mS pecializationName, " SpecializationName " ) ;
mS pecializationName- > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onSpecializationClicked ) ;
setText ( " FavoriteAttributesT " , mWindowManager . getGameSettingString ( " sChooseClassMenu2 " , " Favorite Attributes: " ) ) ;
getWidget ( f avoriteAttribute0, " FavoriteAttribute0 " ) ;
getWidget ( f avoriteAttribute1, " FavoriteAttribute1 " ) ;
f avoriteAttribute0- > setWindowManager ( & mWindowManager ) ;
f avoriteAttribute1- > setWindowManager ( & mWindowManager ) ;
f avoriteAttribute0- > eventClicked + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onAttributeClicked ) ;
f avoriteAttribute1- > eventClicked + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onAttributeClicked ) ;
getWidget ( mF avoriteAttribute0, " FavoriteAttribute0 " ) ;
getWidget ( mF avoriteAttribute1, " FavoriteAttribute1 " ) ;
mF avoriteAttribute0- > setWindowManager ( & mWindowManager ) ;
mF avoriteAttribute1- > setWindowManager ( & mWindowManager ) ;
mF avoriteAttribute0- > eventClicked + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onAttributeClicked ) ;
mF avoriteAttribute1- > eventClicked + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onAttributeClicked ) ;
setText ( " MajorSkillT " , mWindowManager . getGameSettingString ( " sSkillClassMajor " , " " ) ) ;
setText ( " MinorSkillT " , mWindowManager . getGameSettingString ( " sSkillClassMinor " , " " ) ) ;
for ( int i = 0 ; i < 5 ; i + + )
{
char theIndex = ' 0 ' + i ;
getWidget ( m ajorSkill[ i ] , std : : string ( " MajorSkill " ) . append ( 1 , theIndex ) ) ;
getWidget ( m inorSkill[ i ] , std : : string ( " MinorSkill " ) . append ( 1 , theIndex ) ) ;
skills. push_back ( m ajorSkill[ i ] ) ;
skills. push_back ( m inorSkill[ i ] ) ;
getWidget ( m M ajorSkill[ i ] , std : : string ( " MajorSkill " ) . append ( 1 , theIndex ) ) ;
getWidget ( m M inorSkill[ i ] , std : : string ( " MinorSkill " ) . append ( 1 , theIndex ) ) ;
mSkills. push_back ( mM ajorSkill[ i ] ) ;
mSkills. push_back ( mM inorSkill[ i ] ) ;
}
std : : vector < Widgets : : MWSkillPtr > : : const_iterator end = s kills. end ( ) ;
for ( std : : vector < Widgets : : MWSkillPtr > : : const_iterator it = s kills. begin ( ) ; it ! = end ; + + it )
std : : vector < Widgets : : MWSkillPtr > : : const_iterator end = mS kills. end ( ) ;
for ( std : : vector < Widgets : : MWSkillPtr > : : const_iterator it = mS kills. begin ( ) ; it ! = end ; + + it )
{
( * it ) - > setWindowManager ( & mWindowManager ) ;
( * it ) - > eventClicked + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onSkillClicked ) ;
}
setText ( " LabelT " , mWindowManager . getGameSettingString ( " sName " , " " ) ) ;
getWidget ( e ditName, " EditName " ) ;
getWidget ( mE ditName, " EditName " ) ;
// Make sure the edit box has focus
MyGUI : : InputManager : : getInstance ( ) . setKeyFocusWidget ( e ditName) ;
MyGUI : : InputManager : : getInstance ( ) . setKeyFocusWidget ( mE ditName) ;
MyGUI : : ButtonPtr descriptionButton ;
getWidget ( descriptionButton , " DescriptionButton " ) ;
@ -441,20 +440,20 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
// Set default skills, attributes
f avoriteAttribute0- > setAttributeId ( ESM : : Attribute : : Strength ) ;
f avoriteAttribute1- > setAttributeId ( ESM : : Attribute : : Agility ) ;
mF avoriteAttribute0- > setAttributeId ( ESM : : Attribute : : Strength ) ;
mF avoriteAttribute1- > setAttributeId ( ESM : : Attribute : : Agility ) ;
m ajorSkill[ 0 ] - > setSkillId ( ESM : : Skill : : Block ) ;
m ajorSkill[ 1 ] - > setSkillId ( ESM : : Skill : : Armorer ) ;
m ajorSkill[ 2 ] - > setSkillId ( ESM : : Skill : : MediumArmor ) ;
m ajorSkill[ 3 ] - > setSkillId ( ESM : : Skill : : HeavyArmor ) ;
m ajorSkill[ 4 ] - > setSkillId ( ESM : : Skill : : BluntWeapon ) ;
m M ajorSkill[ 0 ] - > setSkillId ( ESM : : Skill : : Block ) ;
m M ajorSkill[ 1 ] - > setSkillId ( ESM : : Skill : : Armorer ) ;
m M ajorSkill[ 2 ] - > setSkillId ( ESM : : Skill : : MediumArmor ) ;
m M ajorSkill[ 3 ] - > setSkillId ( ESM : : Skill : : HeavyArmor ) ;
m M ajorSkill[ 4 ] - > setSkillId ( ESM : : Skill : : BluntWeapon ) ;
m inorSkill[ 0 ] - > setSkillId ( ESM : : Skill : : LongBlade ) ;
m inorSkill[ 1 ] - > setSkillId ( ESM : : Skill : : Axe ) ;
m inorSkill[ 2 ] - > setSkillId ( ESM : : Skill : : Spear ) ;
m inorSkill[ 3 ] - > setSkillId ( ESM : : Skill : : Athletics ) ;
m inorSkill[ 4 ] - > setSkillId ( ESM : : Skill : : Enchant ) ;
m M inorSkill[ 0 ] - > setSkillId ( ESM : : Skill : : LongBlade ) ;
m M inorSkill[ 1 ] - > setSkillId ( ESM : : Skill : : Axe ) ;
m M inorSkill[ 2 ] - > setSkillId ( ESM : : Skill : : Spear ) ;
m M inorSkill[ 3 ] - > setSkillId ( ESM : : Skill : : Athletics ) ;
m M inorSkill[ 4 ] - > setSkillId ( ESM : : Skill : : Enchant ) ;
setSpecialization ( 0 ) ;
update ( ) ;
@ -462,44 +461,44 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
CreateClassDialog : : ~ CreateClassDialog ( )
{
delete s pecDialog;
delete a ttribDialog;
delete s killDialog;
delete d escDialog;
delete mS pecDialog;
delete mA ttribDialog;
delete mS killDialog;
delete mD escDialog;
}
void CreateClassDialog : : update ( )
{
for ( int i = 0 ; i < 5 ; + + i )
{
ToolTips : : createSkillToolTip ( m ajorSkill[ i ] , m ajorSkill[ i ] - > getSkillId ( ) ) ;
ToolTips : : createSkillToolTip ( m inorSkill[ i ] , m inorSkill[ i ] - > getSkillId ( ) ) ;
ToolTips : : createSkillToolTip ( m M ajorSkill[ i ] , m M ajorSkill[ i ] - > getSkillId ( ) ) ;
ToolTips : : createSkillToolTip ( m M inorSkill[ i ] , m M inorSkill[ i ] - > getSkillId ( ) ) ;
}
ToolTips : : createAttributeToolTip ( favoriteAttribute0, f avoriteAttribute0- > getAttributeId ( ) ) ;
ToolTips : : createAttributeToolTip ( favoriteAttribute1, f avoriteAttribute1- > getAttributeId ( ) ) ;
ToolTips : : createAttributeToolTip ( mFavoriteAttribute0, mF avoriteAttribute0- > getAttributeId ( ) ) ;
ToolTips : : createAttributeToolTip ( mFavoriteAttribute1, mF avoriteAttribute1- > getAttributeId ( ) ) ;
}
std : : string CreateClassDialog : : getName ( ) const
{
return e ditName- > getOnlyText ( ) ;
return mE ditName- > getOnlyText ( ) ;
}
std : : string CreateClassDialog : : getDescription ( ) const
{
return d escription;
return mD escription;
}
ESM : : Class : : Specialization CreateClassDialog : : getSpecializationId ( ) const
{
return s pecializationId;
return mS pecializationId;
}
std : : vector < int > CreateClassDialog : : getFavoriteAttributes ( ) const
{
std : : vector < int > v ;
v . push_back ( f avoriteAttribute0- > getAttributeId ( ) ) ;
v . push_back ( f avoriteAttribute1- > getAttributeId ( ) ) ;
v . push_back ( mF avoriteAttribute0- > getAttributeId ( ) ) ;
v . push_back ( mF avoriteAttribute1- > getAttributeId ( ) ) ;
return v ;
}
@ -508,7 +507,7 @@ std::vector<ESM::Skill::SkillEnum> CreateClassDialog::getMajorSkills() const
std : : vector < ESM : : Skill : : SkillEnum > v ;
for ( int i = 0 ; i < 5 ; i + + )
{
v . push_back ( m ajorSkill[ i ] - > getSkillId ( ) ) ;
v . push_back ( m M ajorSkill[ i ] - > getSkillId ( ) ) ;
}
return v ;
}
@ -518,7 +517,7 @@ std::vector<ESM::Skill::SkillEnum> CreateClassDialog::getMinorSkills() const
std : : vector < ESM : : Skill : : SkillEnum > v ;
for ( int i = 0 ; i < 5 ; i + + )
{
v . push_back ( m inorSkill[ i ] - > getSkillId ( ) ) ;
v . push_back ( m M inorSkill[ i ] - > getSkillId ( ) ) ;
}
return v ;
}
@ -557,108 +556,108 @@ void CreateClassDialog::open()
void CreateClassDialog : : onDialogCancel ( )
{
if ( s pecDialog)
if ( mS pecDialog)
{
mWindowManager . removeDialog ( s pecDialog) ;
s pecDialog = 0 ;
mWindowManager . removeDialog ( mS pecDialog) ;
mS pecDialog = 0 ;
}
if ( a ttribDialog)
if ( mA ttribDialog)
{
mWindowManager . removeDialog ( a ttribDialog) ;
a ttribDialog = 0 ;
mWindowManager . removeDialog ( mA ttribDialog) ;
mA ttribDialog = 0 ;
}
if ( s killDialog)
if ( mS killDialog)
{
mWindowManager . removeDialog ( s killDialog) ;
s killDialog = 0 ;
mWindowManager . removeDialog ( mS killDialog) ;
mS killDialog = 0 ;
}
if ( d escDialog)
if ( mD escDialog)
{
mWindowManager . removeDialog ( d escDialog) ;
d escDialog = 0 ;
mWindowManager . removeDialog ( mD escDialog) ;
mD escDialog = 0 ;
}
}
void CreateClassDialog : : onSpecializationClicked ( MyGUI : : WidgetPtr _sender )
{
delete s pecDialog;
s pecDialog = new SelectSpecializationDialog ( mWindowManager ) ;
s pecDialog- > eventCancel + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onDialogCancel ) ;
s pecDialog- > eventItemSelected + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onSpecializationSelected ) ;
s pecDialog- > setVisible ( true ) ;
delete mS pecDialog;
mS pecDialog = new SelectSpecializationDialog ( mWindowManager ) ;
mS pecDialog- > eventCancel + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onDialogCancel ) ;
mS pecDialog- > eventItemSelected + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onSpecializationSelected ) ;
mS pecDialog- > setVisible ( true ) ;
}
void CreateClassDialog : : onSpecializationSelected ( )
{
specializationId = s pecDialog- > getSpecializationId ( ) ;
setSpecialization ( s pecializationId) ;
mSpecializationId = mS pecDialog- > getSpecializationId ( ) ;
setSpecialization ( mS pecializationId) ;
mWindowManager . removeDialog ( s pecDialog) ;
s pecDialog = 0 ;
mWindowManager . removeDialog ( mS pecDialog) ;
mS pecDialog = 0 ;
}
void CreateClassDialog : : setSpecialization ( int id )
{
s pecializationId = ( ESM : : Class : : Specialization ) id ;
mS pecializationId = ( ESM : : Class : : Specialization ) id ;
static const char * specIds [ 3 ] = {
" sSpecializationCombat " ,
" sSpecializationMagic " ,
" sSpecializationStealth "
} ;
std : : string specName = mWindowManager . getGameSettingString ( specIds [ specializationId] , specIds [ s pecializationId] ) ;
s pecializationName- > setCaption ( specName ) ;
ToolTips : : createSpecializationToolTip ( specializationName, specName , s pecializationId) ;
std : : string specName = mWindowManager . getGameSettingString ( specIds [ mSpecializationId] , specIds [ mS pecializationId] ) ;
mS pecializationName- > setCaption ( specName ) ;
ToolTips : : createSpecializationToolTip ( mSpecializationName, specName , mS pecializationId) ;
}
void CreateClassDialog : : onAttributeClicked ( Widgets : : MWAttributePtr _sender )
{
delete a ttribDialog;
a ttribDialog = new SelectAttributeDialog ( mWindowManager ) ;
a ttribDialog- > setAffectedWidget ( _sender ) ;
a ttribDialog- > eventCancel + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onDialogCancel ) ;
a ttribDialog- > eventItemSelected + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onAttributeSelected ) ;
a ttribDialog- > setVisible ( true ) ;
delete mA ttribDialog;
mA ttribDialog = new SelectAttributeDialog ( mWindowManager ) ;
mA ttribDialog- > setAffectedWidget ( _sender ) ;
mA ttribDialog- > eventCancel + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onDialogCancel ) ;
mA ttribDialog- > eventItemSelected + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onAttributeSelected ) ;
mA ttribDialog- > setVisible ( true ) ;
}
void CreateClassDialog : : onAttributeSelected ( )
{
ESM : : Attribute : : AttributeID id = a ttribDialog- > getAttributeId ( ) ;
Widgets : : MWAttributePtr attribute = a ttribDialog- > getAffectedWidget ( ) ;
if ( attribute = = f avoriteAttribute0)
ESM : : Attribute : : AttributeID id = mA ttribDialog- > getAttributeId ( ) ;
Widgets : : MWAttributePtr attribute = mA ttribDialog- > getAffectedWidget ( ) ;
if ( attribute = = mF avoriteAttribute0)
{
if ( f avoriteAttribute1- > getAttributeId ( ) = = id )
favoriteAttribute1- > setAttributeId ( f avoriteAttribute0- > getAttributeId ( ) ) ;
if ( mF avoriteAttribute1- > getAttributeId ( ) = = id )
mFavoriteAttribute1- > setAttributeId ( mF avoriteAttribute0- > getAttributeId ( ) ) ;
}
else if ( attribute = = f avoriteAttribute1)
else if ( attribute = = mF avoriteAttribute1)
{
if ( f avoriteAttribute0- > getAttributeId ( ) = = id )
favoriteAttribute0- > setAttributeId ( f avoriteAttribute1- > getAttributeId ( ) ) ;
if ( mF avoriteAttribute0- > getAttributeId ( ) = = id )
mFavoriteAttribute0- > setAttributeId ( mF avoriteAttribute1- > getAttributeId ( ) ) ;
}
attribute - > setAttributeId ( id ) ;
mWindowManager . removeDialog ( a ttribDialog) ;
a ttribDialog = 0 ;
mWindowManager . removeDialog ( mA ttribDialog) ;
mA ttribDialog = 0 ;
update ( ) ;
}
void CreateClassDialog : : onSkillClicked ( Widgets : : MWSkillPtr _sender )
{
delete s killDialog;
s killDialog = new SelectSkillDialog ( mWindowManager ) ;
s killDialog- > setAffectedWidget ( _sender ) ;
s killDialog- > eventCancel + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onDialogCancel ) ;
s killDialog- > eventItemSelected + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onSkillSelected ) ;
s killDialog- > setVisible ( true ) ;
delete mS killDialog;
mS killDialog = new SelectSkillDialog ( mWindowManager ) ;
mS killDialog- > setAffectedWidget ( _sender ) ;
mS killDialog- > eventCancel + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onDialogCancel ) ;
mS killDialog- > eventItemSelected + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onSkillSelected ) ;
mS killDialog- > setVisible ( true ) ;
}
void CreateClassDialog : : onSkillSelected ( )
{
ESM : : Skill : : SkillEnum id = s killDialog- > getSkillId ( ) ;
Widgets : : MWSkillPtr skill = s killDialog- > getAffectedWidget ( ) ;
ESM : : Skill : : SkillEnum id = mS killDialog- > getSkillId ( ) ;
Widgets : : MWSkillPtr skill = mS killDialog- > getAffectedWidget ( ) ;
// Avoid duplicate skills by swapping any skill field that matches the selected one
std : : vector < Widgets : : MWSkillPtr > : : const_iterator end = s kills. end ( ) ;
for ( std : : vector < Widgets : : MWSkillPtr > : : const_iterator it = s kills. begin ( ) ; it ! = end ; + + it )
std : : vector < Widgets : : MWSkillPtr > : : const_iterator end = mS kills. end ( ) ;
for ( std : : vector < Widgets : : MWSkillPtr > : : const_iterator it = mS kills. begin ( ) ; it ! = end ; + + it )
{
if ( * it = = skill )
continue ;
@ -669,25 +668,25 @@ void CreateClassDialog::onSkillSelected()
}
}
skill - > setSkillId ( s killDialog- > getSkillId ( ) ) ;
mWindowManager . removeDialog ( s killDialog) ;
s killDialog = 0 ;
skill - > setSkillId ( mS killDialog- > getSkillId ( ) ) ;
mWindowManager . removeDialog ( mS killDialog) ;
mS killDialog = 0 ;
update ( ) ;
}
void CreateClassDialog : : onDescriptionClicked ( MyGUI : : Widget * _sender )
{
d escDialog = new DescriptionDialog ( mWindowManager ) ;
descDialog- > setTextInput ( d escription) ;
d escDialog- > eventDone + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onDescriptionEntered ) ;
d escDialog- > setVisible ( true ) ;
mD escDialog = new DescriptionDialog ( mWindowManager ) ;
mDescDialog- > setTextInput ( mD escription) ;
mD escDialog- > eventDone + = MyGUI : : newDelegate ( this , & CreateClassDialog : : onDescriptionEntered ) ;
mD escDialog- > setVisible ( true ) ;
}
void CreateClassDialog : : onDescriptionEntered ( WindowBase * parWindow )
{
description = d escDialog- > getTextInput ( ) ;
mWindowManager . removeDialog ( d escDialog) ;
d escDialog = 0 ;
mDescription = mD escDialog- > getTextInput ( ) ;
mWindowManager . removeDialog ( mD escDialog) ;
mD escDialog = 0 ;
}
void CreateClassDialog : : onOkClicked ( MyGUI : : Widget * _sender )
@ -710,24 +709,24 @@ SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowM
setText ( " LabelT " , mWindowManager . getGameSettingString ( " sSpecializationMenu1 " , " " ) ) ;
getWidget ( s pecialization0, " Specialization0 " ) ;
getWidget ( s pecialization1, " Specialization1 " ) ;
getWidget ( s pecialization2, " Specialization2 " ) ;
getWidget ( mS pecialization0, " Specialization0 " ) ;
getWidget ( mS pecialization1, " Specialization1 " ) ;
getWidget ( mS pecialization2, " Specialization2 " ) ;
std : : string combat = mWindowManager . getGameSettingString ( ESM : : Class : : gmstSpecializationIds [ ESM : : Class : : Combat ] , " " ) ;
std : : string magic = mWindowManager . getGameSettingString ( ESM : : Class : : gmstSpecializationIds [ ESM : : Class : : Magic ] , " " ) ;
std : : string stealth = mWindowManager . getGameSettingString ( ESM : : Class : : gmstSpecializationIds [ ESM : : Class : : Stealth ] , " " ) ;
s pecialization0- > setCaption ( combat ) ;
s pecialization0- > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & SelectSpecializationDialog : : onSpecializationClicked ) ;
s pecialization1- > setCaption ( magic ) ;
s pecialization1- > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & SelectSpecializationDialog : : onSpecializationClicked ) ;
s pecialization2- > setCaption ( stealth ) ;
s pecialization2- > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & SelectSpecializationDialog : : onSpecializationClicked ) ;
s pecializationId = ESM : : Class : : Combat ;
mS pecialization0- > setCaption ( combat ) ;
mS pecialization0- > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & SelectSpecializationDialog : : onSpecializationClicked ) ;
mS pecialization1- > setCaption ( magic ) ;
mS pecialization1- > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & SelectSpecializationDialog : : onSpecializationClicked ) ;
mS pecialization2- > setCaption ( stealth ) ;
mS pecialization2- > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & SelectSpecializationDialog : : onSpecializationClicked ) ;
mS pecializationId = ESM : : Class : : Combat ;
ToolTips : : createSpecializationToolTip ( s pecialization0, combat , ESM : : Class : : Combat ) ;
ToolTips : : createSpecializationToolTip ( s pecialization1, magic , ESM : : Class : : Magic ) ;
ToolTips : : createSpecializationToolTip ( s pecialization2, stealth , ESM : : Class : : Stealth ) ;
ToolTips : : createSpecializationToolTip ( mS pecialization0, combat , ESM : : Class : : Combat ) ;
ToolTips : : createSpecializationToolTip ( mS pecialization1, magic , ESM : : Class : : Magic ) ;
ToolTips : : createSpecializationToolTip ( mS pecialization2, stealth , ESM : : Class : : Stealth ) ;
MyGUI : : ButtonPtr cancelButton ;
getWidget ( cancelButton , " CancelButton " ) ;
@ -748,12 +747,12 @@ SelectSpecializationDialog::~SelectSpecializationDialog()
void SelectSpecializationDialog : : onSpecializationClicked ( MyGUI : : WidgetPtr _sender )
{
if ( _sender = = s pecialization0)
s pecializationId = ESM : : Class : : Combat ;
else if ( _sender = = s pecialization1)
s pecializationId = ESM : : Class : : Magic ;
else if ( _sender = = s pecialization2)
s pecializationId = ESM : : Class : : Stealth ;
if ( _sender = = mS pecialization0)
mS pecializationId = ESM : : Class : : Combat ;
else if ( _sender = = mS pecialization1)
mS pecializationId = ESM : : Class : : Magic ;
else if ( _sender = = mS pecialization2)
mS pecializationId = ESM : : Class : : Stealth ;
else
return ;
@ -807,7 +806,7 @@ SelectAttributeDialog::~SelectAttributeDialog()
void SelectAttributeDialog : : onAttributeClicked ( Widgets : : MWAttributePtr _sender )
{
// TODO: Change MWAttribute to set and get AttributeID enum instead of int
a ttributeId = static_cast < ESM : : Attribute : : AttributeID > ( _sender - > getAttributeId ( ) ) ;
mA ttributeId = static_cast < ESM : : Attribute : : AttributeID > ( _sender - > getAttributeId ( ) ) ;
eventItemSelected ( ) ;
}
@ -833,44 +832,44 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager)
for ( int i = 0 ; i < 9 ; i + + )
{
char theIndex = ' 0 ' + i ;
getWidget ( c ombatSkill[ i ] , std : : string ( " CombatSkill " ) . append ( 1 , theIndex ) ) ;
getWidget ( m agicSkill[ i ] , std : : string ( " MagicSkill " ) . append ( 1 , theIndex ) ) ;
getWidget ( s tealthSkill[ i ] , std : : string ( " StealthSkill " ) . append ( 1 , theIndex ) ) ;
getWidget ( mC ombatSkill[ i ] , std : : string ( " CombatSkill " ) . append ( 1 , theIndex ) ) ;
getWidget ( m M agicSkill[ i ] , std : : string ( " MagicSkill " ) . append ( 1 , theIndex ) ) ;
getWidget ( mS tealthSkill[ i ] , std : : string ( " StealthSkill " ) . append ( 1 , theIndex ) ) ;
}
struct { Widgets : : MWSkillPtr widget ; ESM : : Skill : : SkillEnum skillId ; } s kills[ 3 ] [ 9 ] = {
struct { Widgets : : MWSkillPtr widget ; ESM : : Skill : : SkillEnum skillId ; } mS kills[ 3 ] [ 9 ] = {
{
{ c ombatSkill[ 0 ] , ESM : : Skill : : Block } ,
{ c ombatSkill[ 1 ] , ESM : : Skill : : Armorer } ,
{ c ombatSkill[ 2 ] , ESM : : Skill : : MediumArmor } ,
{ c ombatSkill[ 3 ] , ESM : : Skill : : HeavyArmor } ,
{ c ombatSkill[ 4 ] , ESM : : Skill : : BluntWeapon } ,
{ c ombatSkill[ 5 ] , ESM : : Skill : : LongBlade } ,
{ c ombatSkill[ 6 ] , ESM : : Skill : : Axe } ,
{ c ombatSkill[ 7 ] , ESM : : Skill : : Spear } ,
{ c ombatSkill[ 8 ] , ESM : : Skill : : Athletics }
{ mC ombatSkill[ 0 ] , ESM : : Skill : : Block } ,
{ mC ombatSkill[ 1 ] , ESM : : Skill : : Armorer } ,
{ mC ombatSkill[ 2 ] , ESM : : Skill : : MediumArmor } ,
{ mC ombatSkill[ 3 ] , ESM : : Skill : : HeavyArmor } ,
{ mC ombatSkill[ 4 ] , ESM : : Skill : : BluntWeapon } ,
{ mC ombatSkill[ 5 ] , ESM : : Skill : : LongBlade } ,
{ mC ombatSkill[ 6 ] , ESM : : Skill : : Axe } ,
{ mC ombatSkill[ 7 ] , ESM : : Skill : : Spear } ,
{ mC ombatSkill[ 8 ] , ESM : : Skill : : Athletics }
} ,
{
{ m agicSkill[ 0 ] , ESM : : Skill : : Enchant } ,
{ m agicSkill[ 1 ] , ESM : : Skill : : Destruction } ,
{ m agicSkill[ 2 ] , ESM : : Skill : : Alteration } ,
{ m agicSkill[ 3 ] , ESM : : Skill : : Illusion } ,
{ m agicSkill[ 4 ] , ESM : : Skill : : Conjuration } ,
{ m agicSkill[ 5 ] , ESM : : Skill : : Mysticism } ,
{ m agicSkill[ 6 ] , ESM : : Skill : : Restoration } ,
{ m agicSkill[ 7 ] , ESM : : Skill : : Alchemy } ,
{ m agicSkill[ 8 ] , ESM : : Skill : : Unarmored }
{ m M agicSkill[ 0 ] , ESM : : Skill : : Enchant } ,
{ m M agicSkill[ 1 ] , ESM : : Skill : : Destruction } ,
{ m M agicSkill[ 2 ] , ESM : : Skill : : Alteration } ,
{ m M agicSkill[ 3 ] , ESM : : Skill : : Illusion } ,
{ m M agicSkill[ 4 ] , ESM : : Skill : : Conjuration } ,
{ m M agicSkill[ 5 ] , ESM : : Skill : : Mysticism } ,
{ m M agicSkill[ 6 ] , ESM : : Skill : : Restoration } ,
{ m M agicSkill[ 7 ] , ESM : : Skill : : Alchemy } ,
{ m M agicSkill[ 8 ] , ESM : : Skill : : Unarmored }
} ,
{
{ s tealthSkill[ 0 ] , ESM : : Skill : : Security } ,
{ s tealthSkill[ 1 ] , ESM : : Skill : : Sneak } ,
{ s tealthSkill[ 2 ] , ESM : : Skill : : Acrobatics } ,
{ s tealthSkill[ 3 ] , ESM : : Skill : : LightArmor } ,
{ s tealthSkill[ 4 ] , ESM : : Skill : : ShortBlade } ,
{ s tealthSkill[ 5 ] , ESM : : Skill : : Marksman } ,
{ s tealthSkill[ 6 ] , ESM : : Skill : : Mercantile } ,
{ s tealthSkill[ 7 ] , ESM : : Skill : : Speechcraft } ,
{ s tealthSkill[ 8 ] , ESM : : Skill : : HandToHand }
{ mS tealthSkill[ 0 ] , ESM : : Skill : : Security } ,
{ mS tealthSkill[ 1 ] , ESM : : Skill : : Sneak } ,
{ mS tealthSkill[ 2 ] , ESM : : Skill : : Acrobatics } ,
{ mS tealthSkill[ 3 ] , ESM : : Skill : : LightArmor } ,
{ mS tealthSkill[ 4 ] , ESM : : Skill : : ShortBlade } ,
{ mS tealthSkill[ 5 ] , ESM : : Skill : : Marksman } ,
{ mS tealthSkill[ 6 ] , ESM : : Skill : : Mercantile } ,
{ mS tealthSkill[ 7 ] , ESM : : Skill : : Speechcraft } ,
{ mS tealthSkill[ 8 ] , ESM : : Skill : : HandToHand }
}
} ;
@ -878,10 +877,10 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager)
{
for ( int i = 0 ; i < 9 ; + + i )
{
s kills[ spec ] [ i ] . widget - > setWindowManager ( & mWindowManager ) ;
s kills[ spec ] [ i ] . widget - > setSkillId ( s kills[ spec ] [ i ] . skillId ) ;
s kills[ spec ] [ i ] . widget - > eventClicked + = MyGUI : : newDelegate ( this , & SelectSkillDialog : : onSkillClicked ) ;
ToolTips : : createSkillToolTip ( s kills[ spec ] [ i ] . widget , s kills[ spec ] [ i ] . widget - > getSkillId ( ) ) ;
mS kills[ spec ] [ i ] . widget - > setWindowManager ( & mWindowManager ) ;
mS kills[ spec ] [ i ] . widget - > setSkillId ( mS kills[ spec ] [ i ] . skillId ) ;
mS kills[ spec ] [ i ] . widget - > eventClicked + = MyGUI : : newDelegate ( this , & SelectSkillDialog : : onSkillClicked ) ;
ToolTips : : createSkillToolTip ( mS kills[ spec ] [ i ] . widget , mS kills[ spec ] [ i ] . widget - > getSkillId ( ) ) ;
}
}
@ -904,7 +903,7 @@ SelectSkillDialog::~SelectSkillDialog()
void SelectSkillDialog : : onSkillClicked ( Widgets : : MWSkillPtr _sender )
{
s killId = _sender - > getSkillId ( ) ;
mS killId = _sender - > getSkillId ( ) ;
eventItemSelected ( ) ;
}
@ -921,7 +920,7 @@ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager)
// Centre dialog
center ( ) ;
getWidget ( t extEdit, " TextEdit " ) ;
getWidget ( mT extEdit, " TextEdit " ) ;
MyGUI : : ButtonPtr okButton ;
getWidget ( okButton , " OKButton " ) ;
@ -931,7 +930,7 @@ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager)
okButton - > setCoord ( 234 - buttonWidth , 214 , buttonWidth , 24 ) ;
// Make sure the edit box has focus
MyGUI : : InputManager : : getInstance ( ) . setKeyFocusWidget ( t extEdit) ;
MyGUI : : InputManager : : getInstance ( ) . setKeyFocusWidget ( mT extEdit) ;
MyGUI : : InputManager : : getInstance ( ) . addWidgetModal ( mMainWidget ) ;
}