2010-09-20 11:17:02 +00:00
# include "widgets.hpp"
2013-10-07 00:46:04 +00:00
# include <sstream>
# include <iomanip>
2013-03-03 12:11:02 +00:00
# include <MyGUI_ProgressBar.h>
# include <MyGUI_ImageBox.h>
2013-07-05 17:17:00 +00:00
# include <MyGUI_ControllerManager.h>
2013-03-03 12:11:02 +00:00
2012-08-12 12:36:46 +00:00
# include "../mwbase/environment.hpp"
# include "../mwbase/world.hpp"
2012-08-12 16:11:09 +00:00
# include "../mwbase/windowmanager.hpp"
2012-08-12 12:36:46 +00:00
2015-01-10 01:50:43 +00:00
# include "../mwworld/esmstore.hpp"
# include "controllers.hpp"
2013-04-17 22:56:48 +00:00
namespace MWGui
2010-09-21 10:34:47 +00:00
{
2013-04-17 22:56:48 +00:00
namespace Widgets
{
/* MWSkill */
2010-09-20 11:17:02 +00:00
2013-04-17 22:56:48 +00:00
MWSkill : : MWSkill ( )
: mSkillId ( ESM : : Skill : : Length )
2018-10-09 06:21:12 +00:00
, mSkillNameWidget ( nullptr )
, mSkillValueWidget ( nullptr )
2010-09-20 11:17:02 +00:00
{
}
2013-04-17 22:56:48 +00:00
void MWSkill : : setSkillId ( ESM : : Skill : : SkillEnum skill )
2010-09-20 11:17:02 +00:00
{
2013-04-17 22:56:48 +00:00
mSkillId = skill ;
updateWidgets ( ) ;
2010-09-20 11:17:02 +00:00
}
2013-04-17 22:56:48 +00:00
void MWSkill : : setSkillNumber ( int skill )
{
if ( skill < 0 )
setSkillId ( ESM : : Skill : : Length ) ;
else if ( skill < ESM : : Skill : : Length )
setSkillId ( static_cast < ESM : : Skill : : SkillEnum > ( skill ) ) ;
else
2019-02-17 06:24:25 +00:00
throw std : : runtime_error ( " Skill number out of range " ) ;
2013-04-17 22:56:48 +00:00
}
2010-09-24 13:28:14 +00:00
2013-04-17 22:56:48 +00:00
void MWSkill : : setSkillValue ( const SkillValue & value )
{
mValue = value ;
updateWidgets ( ) ;
}
2010-09-20 11:17:02 +00:00
2013-04-17 22:56:48 +00:00
void MWSkill : : updateWidgets ( )
{
if ( mSkillNameWidget )
{
if ( mSkillId = = ESM : : Skill : : Length )
{
2014-09-13 02:07:40 +00:00
mSkillNameWidget - > setCaption ( " " ) ;
2013-04-17 22:56:48 +00:00
}
else
{
const std : : string & name = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( ESM : : Skill : : sSkillNameIds [ mSkillId ] , " " ) ;
2014-09-13 02:07:40 +00:00
mSkillNameWidget - > setCaption ( name ) ;
2013-04-17 22:56:48 +00:00
}
}
if ( mSkillValueWidget )
{
SkillValue : : Type modified = mValue . getModified ( ) , base = mValue . getBase ( ) ;
2015-01-10 02:01:01 +00:00
mSkillValueWidget - > setCaption ( MyGUI : : utility : : toString ( modified ) ) ;
2013-04-17 22:56:48 +00:00
if ( modified > base )
mSkillValueWidget - > _setWidgetState ( " increased " ) ;
else if ( modified < base )
mSkillValueWidget - > _setWidgetState ( " decreased " ) ;
else
mSkillValueWidget - > _setWidgetState ( " normal " ) ;
}
}
2010-09-20 11:17:02 +00:00
2013-04-17 22:56:48 +00:00
void MWSkill : : onClicked ( MyGUI : : Widget * _sender )
{
eventClicked ( this ) ;
}
2010-09-20 11:17:02 +00:00
2013-04-17 22:56:48 +00:00
MWSkill : : ~ MWSkill ( )
{
}
2012-03-20 19:24:36 +00:00
2013-04-17 22:56:48 +00:00
void MWSkill : : initialiseOverride ( )
{
Base : : initialiseOverride ( ) ;
2010-09-20 11:17:02 +00:00
2013-04-17 22:56:48 +00:00
assignWidget ( mSkillNameWidget , " StatName " ) ;
assignWidget ( mSkillValueWidget , " StatValue " ) ;
2010-09-20 11:17:02 +00:00
2013-04-17 22:56:48 +00:00
MyGUI : : Button * button ;
assignWidget ( button , " StatNameButton " ) ;
if ( button )
{
mSkillNameWidget = button ;
button - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & MWSkill : : onClicked ) ;
}
2010-09-20 11:17:02 +00:00
2020-11-13 07:39:47 +00:00
button = nullptr ;
2013-04-17 22:56:48 +00:00
assignWidget ( button , " StatValueButton " ) ;
if ( button )
{
2017-09-27 10:12:16 +00:00
mSkillValueWidget = button ;
2013-04-17 22:56:48 +00:00
button - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & MWSkill : : onClicked ) ;
}
}
2010-09-20 11:17:02 +00:00
2013-04-17 22:56:48 +00:00
/* MWAttribute */
2010-09-24 13:28:14 +00:00
2013-04-17 22:56:48 +00:00
MWAttribute : : MWAttribute ( )
: mId ( - 1 )
2018-10-09 06:21:12 +00:00
, mAttributeNameWidget ( nullptr )
, mAttributeValueWidget ( nullptr )
2010-09-20 11:17:02 +00:00
{
}
2013-04-17 22:56:48 +00:00
void MWAttribute : : setAttributeId ( int attributeId )
2010-09-20 11:17:02 +00:00
{
2013-04-17 22:56:48 +00:00
mId = attributeId ;
updateWidgets ( ) ;
2010-09-20 11:17:02 +00:00
}
2013-04-17 22:56:48 +00:00
void MWAttribute : : setAttributeValue ( const AttributeValue & value )
{
mValue = value ;
updateWidgets ( ) ;
}
2010-09-20 11:17:02 +00:00
2013-04-17 22:56:48 +00:00
void MWAttribute : : onClicked ( MyGUI : : Widget * _sender )
{
eventClicked ( this ) ;
}
2012-08-12 12:36:46 +00:00
2013-04-17 22:56:48 +00:00
void MWAttribute : : updateWidgets ( )
{
if ( mAttributeNameWidget )
{
if ( mId < 0 | | mId > = 8 )
{
2014-09-13 02:07:40 +00:00
mAttributeNameWidget - > setCaption ( " " ) ;
2013-04-17 22:56:48 +00:00
}
else
{
static const char * attributes [ 8 ] = {
" sAttributeStrength " ,
" sAttributeIntelligence " ,
" sAttributeWillpower " ,
" sAttributeAgility " ,
" sAttributeSpeed " ,
" sAttributeEndurance " ,
" sAttributePersonality " ,
" sAttributeLuck "
} ;
const std : : string & name = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( attributes [ mId ] , " " ) ;
2014-09-13 02:07:40 +00:00
mAttributeNameWidget - > setCaption ( name ) ;
2013-04-17 22:56:48 +00:00
}
}
if ( mAttributeValueWidget )
{
2014-01-03 02:46:30 +00:00
int modified = mValue . getModified ( ) , base = mValue . getBase ( ) ;
2015-01-10 02:01:01 +00:00
mAttributeValueWidget - > setCaption ( MyGUI : : utility : : toString ( modified ) ) ;
2013-04-17 22:56:48 +00:00
if ( modified > base )
mAttributeValueWidget - > _setWidgetState ( " increased " ) ;
else if ( modified < base )
mAttributeValueWidget - > _setWidgetState ( " decreased " ) ;
else
mAttributeValueWidget - > _setWidgetState ( " normal " ) ;
}
}
2010-09-20 11:17:02 +00:00
2013-04-17 22:56:48 +00:00
MWAttribute : : ~ MWAttribute ( )
{
}
2010-09-20 11:36:55 +00:00
2013-04-17 22:56:48 +00:00
void MWAttribute : : initialiseOverride ( )
{
Base : : initialiseOverride ( ) ;
2010-09-20 11:36:55 +00:00
2013-04-17 22:56:48 +00:00
assignWidget ( mAttributeNameWidget , " StatName " ) ;
assignWidget ( mAttributeValueWidget , " StatValue " ) ;
2010-09-20 11:36:55 +00:00
2013-04-17 22:56:48 +00:00
MyGUI : : Button * button ;
assignWidget ( button , " StatNameButton " ) ;
if ( button )
{
mAttributeNameWidget = button ;
button - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & MWAttribute : : onClicked ) ;
}
2010-09-20 11:36:55 +00:00
2020-11-13 07:39:47 +00:00
button = nullptr ;
2013-04-17 22:56:48 +00:00
assignWidget ( button , " StatValueButton " ) ;
if ( button )
{
mAttributeValueWidget = button ;
button - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & MWAttribute : : onClicked ) ;
}
}
2012-11-05 20:34:11 +00:00
2013-04-17 22:56:48 +00:00
/* MWSpell */
2010-09-21 10:34:47 +00:00
2013-04-17 22:56:48 +00:00
MWSpell : : MWSpell ( )
2018-10-09 06:21:12 +00:00
: mSpellNameWidget ( nullptr )
2013-04-17 22:56:48 +00:00
{
}
2010-09-21 10:34:47 +00:00
2013-04-17 22:56:48 +00:00
void MWSpell : : setSpellId ( const std : : string & spellId )
{
mId = spellId ;
updateWidgets ( ) ;
}
2010-09-20 11:36:55 +00:00
2013-04-17 22:56:48 +00:00
void MWSpell : : createEffectWidgets ( std : : vector < MyGUI : : Widget * > & effects , MyGUI : : Widget * creator , MyGUI : : IntCoord & coord , int flags )
{
const MWWorld : : ESMStore & store =
MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) ;
2010-09-20 11:36:55 +00:00
2013-04-17 22:56:48 +00:00
const ESM : : Spell * spell = store . get < ESM : : Spell > ( ) . search ( mId ) ;
MYGUI_ASSERT ( spell , " spell with id ' " < < mId < < " ' not found " ) ;
2010-09-20 11:36:55 +00:00
2019-03-02 09:27:59 +00:00
for ( const ESM : : ENAMstruct & effectInfo : spell - > mEffects . mList )
2013-04-17 22:56:48 +00:00
{
2014-09-26 15:12:48 +00:00
MWSpellEffectPtr effect = creator - > createWidget < MWSpellEffect > ( " MW_EffectImage " , coord , MyGUI : : Align : : Default ) ;
2013-04-17 22:56:48 +00:00
SpellEffectParams params ;
2019-03-02 09:27:59 +00:00
params . mEffectID = effectInfo . mEffectID ;
params . mSkill = effectInfo . mSkill ;
params . mAttribute = effectInfo . mAttribute ;
params . mDuration = effectInfo . mDuration ;
params . mMagnMin = effectInfo . mMagnMin ;
params . mMagnMax = effectInfo . mMagnMax ;
params . mRange = effectInfo . mRange ;
2015-03-06 10:19:57 +00:00
params . mIsConstant = ( flags & MWEffectList : : EF_Constant ) ! = 0 ;
2013-04-17 22:56:48 +00:00
params . mNoTarget = ( flags & MWEffectList : : EF_NoTarget ) ;
2019-05-06 23:48:13 +00:00
params . mNoMagnitude = ( flags & MWEffectList : : EF_NoMagnitude ) ;
2013-04-17 22:56:48 +00:00
effect - > setSpellEffect ( params ) ;
effects . push_back ( effect ) ;
coord . top + = effect - > getHeight ( ) ;
coord . width = std : : max ( coord . width , effect - > getRequestedWidth ( ) ) ;
}
}
2010-09-21 10:34:47 +00:00
2013-04-17 22:56:48 +00:00
void MWSpell : : updateWidgets ( )
{
if ( mSpellNameWidget & & MWBase : : Environment : : get ( ) . getWindowManager ( ) )
{
const MWWorld : : ESMStore & store =
MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) ;
const ESM : : Spell * spell = store . get < ESM : : Spell > ( ) . search ( mId ) ;
if ( spell )
2014-09-13 02:07:40 +00:00
mSpellNameWidget - > setCaption ( spell - > mName ) ;
2013-04-17 22:56:48 +00:00
else
2014-09-13 02:07:40 +00:00
mSpellNameWidget - > setCaption ( " " ) ;
2013-04-17 22:56:48 +00:00
}
}
2012-04-18 16:09:30 +00:00
2013-04-17 22:56:48 +00:00
void MWSpell : : initialiseOverride ( )
{
Base : : initialiseOverride ( ) ;
2012-04-18 16:09:30 +00:00
2013-04-17 22:56:48 +00:00
assignWidget ( mSpellNameWidget , " StatName " ) ;
}
2012-04-18 16:09:30 +00:00
2013-04-17 22:56:48 +00:00
MWSpell : : ~ MWSpell ( )
{
}
2012-05-24 12:47:57 +00:00
2013-04-17 22:56:48 +00:00
/* MWEffectList */
2012-04-29 22:57:41 +00:00
2013-04-17 22:56:48 +00:00
MWEffectList : : MWEffectList ( )
: mEffectList ( 0 )
2012-04-29 22:57:41 +00:00
{
}
2013-04-17 22:56:48 +00:00
void MWEffectList : : setEffectList ( const SpellEffectList & list )
2012-04-29 22:57:41 +00:00
{
2013-04-17 22:56:48 +00:00
mEffectList = list ;
updateWidgets ( ) ;
2012-04-29 22:57:41 +00:00
}
2012-04-18 16:09:30 +00:00
2013-04-17 22:56:48 +00:00
void MWEffectList : : createEffectWidgets ( std : : vector < MyGUI : : Widget * > & effects , MyGUI : : Widget * creator , MyGUI : : IntCoord & coord , bool center , int flags )
{
// We don't know the width of all the elements beforehand, so we do it in
// 2 steps: first, create all widgets and check their width....
2018-10-09 06:21:12 +00:00
MWSpellEffectPtr effect = nullptr ;
2013-04-17 22:56:48 +00:00
int maxwidth = coord . width ;
2012-11-05 20:34:11 +00:00
2019-03-02 09:27:59 +00:00
for ( auto & effectInfo : mEffectList )
2013-04-17 22:56:48 +00:00
{
effect = creator - > createWidget < MWSpellEffect > ( " MW_EffectImage " , coord , MyGUI : : Align : : Default ) ;
2019-03-02 09:27:59 +00:00
effectInfo . mIsConstant = ( flags & EF_Constant ) | | effectInfo . mIsConstant ;
effectInfo . mNoTarget = ( flags & EF_NoTarget ) | | effectInfo . mNoTarget ;
2019-05-06 23:48:13 +00:00
effectInfo . mNoMagnitude = ( flags & EF_NoMagnitude ) | | effectInfo . mNoMagnitude ;
2019-03-02 09:27:59 +00:00
effect - > setSpellEffect ( effectInfo ) ;
2013-04-17 22:56:48 +00:00
effects . push_back ( effect ) ;
if ( effect - > getRequestedWidth ( ) > maxwidth )
maxwidth = effect - > getRequestedWidth ( ) ;
coord . top + = effect - > getHeight ( ) ;
}
2012-10-03 13:06:54 +00:00
2013-04-17 22:56:48 +00:00
// ... then adjust the size for all widgets
2019-03-02 09:27:59 +00:00
for ( MyGUI : : Widget * effectWidget : effects )
2013-04-17 22:56:48 +00:00
{
2019-03-02 09:27:59 +00:00
effect = effectWidget - > castType < MWSpellEffect > ( ) ;
2013-04-17 22:56:48 +00:00
bool needcenter = center & & ( maxwidth > effect - > getRequestedWidth ( ) ) ;
int diff = maxwidth - effect - > getRequestedWidth ( ) ;
if ( needcenter )
{
effect - > setCoord ( diff / 2 , effect - > getCoord ( ) . top , effect - > getRequestedWidth ( ) , effect - > getCoord ( ) . height ) ;
}
else
{
effect - > setCoord ( 0 , effect - > getCoord ( ) . top , effect - > getRequestedWidth ( ) , effect - > getCoord ( ) . height ) ;
}
}
2012-10-03 13:06:54 +00:00
2013-04-17 22:56:48 +00:00
// inform the parent about width
coord . width = maxwidth ;
}
2012-10-03 13:06:54 +00:00
2013-04-17 22:56:48 +00:00
void MWEffectList : : updateWidgets ( )
{
}
2012-10-03 13:06:54 +00:00
2013-04-17 22:56:48 +00:00
void MWEffectList : : initialiseOverride ( )
{
Base : : initialiseOverride ( ) ;
}
2012-10-03 13:06:54 +00:00
2013-04-17 22:56:48 +00:00
MWEffectList : : ~ MWEffectList ( )
2012-05-24 12:47:57 +00:00
{
}
2013-04-17 22:56:48 +00:00
SpellEffectList MWEffectList : : effectListFromESM ( const ESM : : EffectList * effects )
2012-05-24 12:47:57 +00:00
{
2013-04-17 22:56:48 +00:00
SpellEffectList result ;
2019-03-02 09:27:59 +00:00
for ( const ESM : : ENAMstruct & effectInfo : effects - > mList )
2013-04-17 22:56:48 +00:00
{
SpellEffectParams params ;
2019-03-02 09:27:59 +00:00
params . mEffectID = effectInfo . mEffectID ;
params . mSkill = effectInfo . mSkill ;
params . mAttribute = effectInfo . mAttribute ;
params . mDuration = effectInfo . mDuration ;
params . mMagnMin = effectInfo . mMagnMin ;
params . mMagnMax = effectInfo . mMagnMax ;
params . mRange = effectInfo . mRange ;
params . mArea = effectInfo . mArea ;
2013-04-17 22:56:48 +00:00
result . push_back ( params ) ;
}
return result ;
2012-05-24 12:47:57 +00:00
}
2012-04-29 23:53:22 +00:00
2013-04-17 22:56:48 +00:00
/* MWSpellEffect */
MWSpellEffect : : MWSpellEffect ( )
2018-10-09 06:21:12 +00:00
: mImageWidget ( nullptr )
, mTextWidget ( nullptr )
2013-04-17 22:56:48 +00:00
, mRequestedWidth ( 0 )
2012-10-11 16:26:29 +00:00
{
}
2013-04-17 22:56:48 +00:00
void MWSpellEffect : : setSpellEffect ( const SpellEffectParams & params )
2012-05-24 12:47:57 +00:00
{
2013-04-17 22:56:48 +00:00
mEffectParams = params ;
updateWidgets ( ) ;
2010-09-21 10:34:47 +00:00
}
2012-10-03 13:06:54 +00:00
2013-04-17 22:56:48 +00:00
void MWSpellEffect : : updateWidgets ( )
{
if ( ! mEffectParams . mKnown )
{
mTextWidget - > setCaption ( " ? " ) ;
2019-09-02 17:13:56 +00:00
mTextWidget - > setCoord ( sIconOffset / 2 , mTextWidget - > getCoord ( ) . top , mTextWidget - > getCoord ( ) . width , mTextWidget - > getCoord ( ) . height ) ; // Compensates for the missing image when effect is not known
mRequestedWidth = mTextWidget - > getTextSize ( ) . width + sIconOffset ;
2013-04-17 22:56:48 +00:00
mImageWidget - > setImageTexture ( " " ) ;
return ;
}
2012-10-03 13:06:54 +00:00
2013-04-17 22:56:48 +00:00
const MWWorld : : ESMStore & store =
MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) ;
2010-09-21 10:34:47 +00:00
2013-04-17 22:56:48 +00:00
const ESM : : MagicEffect * magicEffect =
store . get < ESM : : MagicEffect > ( ) . search ( mEffectParams . mEffectID ) ;
2010-09-21 10:34:47 +00:00
2013-04-17 22:56:48 +00:00
assert ( magicEffect ) ;
2010-09-21 10:34:47 +00:00
2013-04-17 22:56:48 +00:00
std : : string pt = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " spoint " , " " ) ;
std : : string pts = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " spoints " , " " ) ;
2013-10-07 00:32:40 +00:00
std : : string pct = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " spercent " , " " ) ;
2013-10-09 05:08:11 +00:00
std : : string ft = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " sfeet " , " " ) ;
std : : string lvl = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " sLevel " , " " ) ;
std : : string lvls = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " sLevels " , " " ) ;
2013-04-17 22:56:48 +00:00
std : : string to = " " + MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " sTo " , " " ) + " " ;
std : : string sec = " " + MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " ssecond " , " " ) ;
std : : string secs = " " + MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " sseconds " , " " ) ;
2010-09-21 10:34:47 +00:00
2013-04-17 22:56:48 +00:00
std : : string effectIDStr = ESM : : MagicEffect : : effectIdToString ( mEffectParams . mEffectID ) ;
std : : string spellLine = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( effectIDStr , " " ) ;
2010-10-20 19:39:18 +00:00
2014-06-29 15:02:29 +00:00
if ( magicEffect - > mData . mFlags & ESM : : MagicEffect : : TargetSkill & & mEffectParams . mSkill ! = - 1 )
2013-04-17 22:56:48 +00:00
{
spellLine + = " " + MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( ESM : : Skill : : sSkillNameIds [ mEffectParams . mSkill ] , " " ) ;
}
2014-06-29 15:02:29 +00:00
if ( magicEffect - > mData . mFlags & ESM : : MagicEffect : : TargetAttribute & & mEffectParams . mAttribute ! = - 1 )
2013-04-17 22:56:48 +00:00
{
spellLine + = " " + MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( ESM : : Attribute : : sGmstAttributeIds [ mEffectParams . mAttribute ] , " " ) ;
}
2010-10-20 19:39:18 +00:00
2019-05-05 18:27:48 +00:00
if ( mEffectParams . mMagnMin | | mEffectParams . mMagnMax ) {
2013-10-09 05:08:11 +00:00
ESM : : MagicEffect : : MagnitudeDisplayType displayType = magicEffect - > getMagnitudeDisplayType ( ) ;
2013-10-08 03:28:55 +00:00
if ( displayType = = ESM : : MagicEffect : : MDT_TimesInt ) {
2013-10-07 00:32:40 +00:00
std : : string timesInt = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " sXTimesINT " , " " ) ;
2013-10-07 00:46:04 +00:00
std : : stringstream formatter ;
formatter < < std : : fixed < < std : : setprecision ( 1 ) < < " " < < ( mEffectParams . mMagnMin / 10.0f ) ;
if ( mEffectParams . mMagnMin ! = mEffectParams . mMagnMax )
2013-10-09 05:08:11 +00:00
formatter < < to < < ( mEffectParams . mMagnMax / 10.0f ) ;
2013-10-07 00:46:04 +00:00
formatter < < timesInt ;
spellLine + = formatter . str ( ) ;
2013-10-07 00:32:40 +00:00
}
2019-05-06 23:48:13 +00:00
else if ( displayType ! = ESM : : MagicEffect : : MDT_None & & ! mEffectParams . mNoMagnitude ) {
2015-01-10 02:01:01 +00:00
spellLine + = " " + MyGUI : : utility : : toString ( mEffectParams . mMagnMin ) ;
2013-10-08 03:28:55 +00:00
if ( mEffectParams . mMagnMin ! = mEffectParams . mMagnMax )
2015-01-10 02:01:01 +00:00
spellLine + = to + MyGUI : : utility : : toString ( mEffectParams . mMagnMax ) ;
2013-10-08 03:28:55 +00:00
if ( displayType = = ESM : : MagicEffect : : MDT_Percentage )
2013-10-07 00:32:40 +00:00
spellLine + = pct ;
2013-10-09 05:08:11 +00:00
else if ( displayType = = ESM : : MagicEffect : : MDT_Feet )
spellLine + = " " + ft ;
else if ( displayType = = ESM : : MagicEffect : : MDT_Level )
2019-05-05 18:27:48 +00:00
spellLine + = " " + ( ( mEffectParams . mMagnMin = = mEffectParams . mMagnMax & & std : : abs ( mEffectParams . mMagnMin ) = = 1 ) ? lvl : lvls ) ;
2013-10-08 03:28:55 +00:00
else // ESM::MagicEffect::MDT_Points
2019-05-05 18:27:48 +00:00
spellLine + = " " + ( ( mEffectParams . mMagnMin = = mEffectParams . mMagnMax & & std : : abs ( mEffectParams . mMagnMin ) = = 1 ) ? pt : pts ) ;
2013-04-17 22:56:48 +00:00
}
}
2010-10-20 19:39:18 +00:00
2013-04-17 22:56:48 +00:00
// constant effects have no duration and no target
if ( ! mEffectParams . mIsConstant )
{
2020-05-23 20:12:56 +00:00
if ( ! ( magicEffect - > mData . mFlags & ESM : : MagicEffect : : AppliedOnce ) )
mEffectParams . mDuration = std : : max ( 1 , mEffectParams . mDuration ) ;
2014-11-04 11:46:33 +00:00
if ( mEffectParams . mDuration > 0 & & ! ( magicEffect - > mData . mFlags & ESM : : MagicEffect : : NoDuration ) )
2013-04-17 22:56:48 +00:00
{
2015-01-10 02:01:01 +00:00
spellLine + = " " + MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " sfor " , " " ) + " " + MyGUI : : utility : : toString ( mEffectParams . mDuration ) + ( ( mEffectParams . mDuration = = 1 ) ? sec : secs ) ;
2013-04-17 22:56:48 +00:00
}
if ( mEffectParams . mArea > 0 )
{
2015-01-10 02:01:01 +00:00
spellLine + = " #{sin} " + MyGUI : : utility : : toString ( mEffectParams . mArea ) + " #{sfootarea} " ;
2013-04-17 22:56:48 +00:00
}
// potions have no target
if ( ! mEffectParams . mNoTarget )
{
std : : string on = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " sonword " , " " ) ;
if ( mEffectParams . mRange = = ESM : : RT_Self )
spellLine + = " " + on + " " + MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " sRangeSelf " , " " ) ;
else if ( mEffectParams . mRange = = ESM : : RT_Touch )
spellLine + = " " + on + " " + MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " sRangeTouch " , " " ) ;
else if ( mEffectParams . mRange = = ESM : : RT_Target )
spellLine + = " " + on + " " + MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getGameSettingString ( " sRangeTarget " , " " ) ;
}
}
2010-10-20 19:39:18 +00:00
2014-09-13 02:07:40 +00:00
mTextWidget - > setCaptionWithReplacing ( spellLine ) ;
2019-09-02 17:13:56 +00:00
mRequestedWidth = mTextWidget - > getTextSize ( ) . width + sIconOffset ;
2010-10-20 19:39:18 +00:00
2015-05-01 16:37:24 +00:00
mImageWidget - > setImageTexture ( MWBase : : Environment : : get ( ) . getWindowManager ( ) - > correctIconPath ( magicEffect - > mIcon ) ) ;
2013-04-17 22:56:48 +00:00
}
MWSpellEffect : : ~ MWSpellEffect ( )
2010-10-20 19:39:18 +00:00
{
}
2013-04-17 22:56:48 +00:00
void MWSpellEffect : : initialiseOverride ( )
{
Base : : initialiseOverride ( ) ;
2010-10-20 19:39:18 +00:00
2013-04-17 22:56:48 +00:00
assignWidget ( mTextWidget , " Text " ) ;
assignWidget ( mImageWidget , " Image " ) ;
}
2010-10-20 19:39:18 +00:00
2013-04-17 22:56:48 +00:00
/* MWDynamicStat */
2012-09-10 09:20:27 +00:00
2013-04-17 22:56:48 +00:00
MWDynamicStat : : MWDynamicStat ( )
: mValue ( 0 )
, mMax ( 1 )
2018-10-09 06:21:12 +00:00
, mTextWidget ( nullptr )
, mBarWidget ( nullptr )
, mBarTextWidget ( nullptr )
2013-04-17 22:56:48 +00:00
{
}
2012-09-10 09:20:27 +00:00
2013-04-17 22:56:48 +00:00
void MWDynamicStat : : setValue ( int cur , int max )
{
mValue = cur ;
mMax = max ;
2012-09-10 09:20:27 +00:00
2013-04-17 22:56:48 +00:00
if ( mBarWidget )
{
2017-08-29 14:04:31 +00:00
mBarWidget - > setProgressRange ( std : : max ( 0 , mMax ) ) ;
mBarWidget - > setProgressPosition ( std : : max ( 0 , mValue ) ) ;
2013-04-17 22:56:48 +00:00
}
2012-09-10 09:20:27 +00:00
2013-04-17 22:56:48 +00:00
if ( mBarTextWidget )
2012-09-10 11:39:22 +00:00
{
2014-01-02 20:48:33 +00:00
std : : stringstream out ;
out < < mValue < < " / " < < mMax ;
2014-09-13 02:07:40 +00:00
mBarTextWidget - > setCaption ( out . str ( ) . c_str ( ) ) ;
2012-09-10 11:39:22 +00:00
}
}
2013-04-17 22:56:48 +00:00
void MWDynamicStat : : setTitle ( const std : : string & text )
{
if ( mTextWidget )
2014-09-13 02:07:40 +00:00
mTextWidget - > setCaption ( text ) ;
2013-04-17 22:56:48 +00:00
}
2012-09-10 09:20:27 +00:00
2013-04-17 22:56:48 +00:00
MWDynamicStat : : ~ MWDynamicStat ( )
{
}
2012-09-10 09:20:27 +00:00
2013-04-17 22:56:48 +00:00
void MWDynamicStat : : initialiseOverride ( )
{
Base : : initialiseOverride ( ) ;
2012-09-10 09:20:27 +00:00
2013-04-17 22:56:48 +00:00
assignWidget ( mTextWidget , " Text " ) ;
assignWidget ( mBarWidget , " Bar " ) ;
assignWidget ( mBarTextWidget , " BarText " ) ;
}
2012-09-10 09:20:27 +00:00
}
2012-09-18 16:29:03 +00:00
}