@ -12,528 +12,531 @@
# include "console.hpp"
# include "spellicons.hpp"
using namespace MWGui ;
HUD : : HUD ( int width , int height , int fpsLevel , DragAndDrop * dragAndDrop )
: Layout ( " openmw_hud.layout " )
, mHealth ( NULL )
, mMagicka ( NULL )
, mStamina ( NULL )
, mWeapImage ( NULL )
, mSpellImage ( NULL )
, mWeapStatus ( NULL )
, mSpellStatus ( NULL )
, mEffectBox ( NULL )
, mMinimap ( NULL )
, mCompass ( NULL )
, mCrosshair ( NULL )
, mFpsBox ( NULL )
, mFpsCounter ( NULL )
, mTriangleCounter ( NULL )
, mBatchCounter ( NULL )
, mHealthManaStaminaBaseLeft ( 0 )
, mWeapBoxBaseLeft ( 0 )
, mSpellBoxBaseLeft ( 0 )
, mEffectBoxBaseRight ( 0 )
, mMinimapBoxBaseRight ( 0 )
, mDragAndDrop ( dragAndDrop )
, mCellNameTimer ( 0.0f )
, mCellNameBox ( NULL )
, mMapVisible ( true )
, mWeaponVisible ( true )
, mSpellVisible ( true )
, mWorldMouseOver ( false )
namespace MWGui
{
setCoord ( 0 , 0 , width , height ) ;
// Energy bars
getWidget ( mHealthFrame , " HealthFrame " ) ;
getWidget ( mHealth , " Health " ) ;
getWidget ( mMagicka , " Magicka " ) ;
getWidget ( mStamina , " Stamina " ) ;
mHealthManaStaminaBaseLeft = mHealthFrame - > getLeft ( ) ;
MyGUI : : Widget * healthFrame , * magickaFrame , * fatigueFrame ;
getWidget ( healthFrame , " HealthFrame " ) ;
getWidget ( magickaFrame , " MagickaFrame " ) ;
getWidget ( fatigueFrame , " FatigueFrame " ) ;
healthFrame - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onHMSClicked ) ;
magickaFrame - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onHMSClicked ) ;
fatigueFrame - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onHMSClicked ) ;
HUD : : HUD ( int width , int height , int fpsLevel , DragAndDrop * dragAndDrop )
: Layout ( " openmw_hud.layout " )
, mHealth ( NULL )
, mMagicka ( NULL )
, mStamina ( NULL )
, mWeapImage ( NULL )
, mSpellImage ( NULL )
, mWeapStatus ( NULL )
, mSpellStatus ( NULL )
, mEffectBox ( NULL )
, mMinimap ( NULL )
, mCompass ( NULL )
, mCrosshair ( NULL )
, mFpsBox ( NULL )
, mFpsCounter ( NULL )
, mTriangleCounter ( NULL )
, mBatchCounter ( NULL )
, mHealthManaStaminaBaseLeft ( 0 )
, mWeapBoxBaseLeft ( 0 )
, mSpellBoxBaseLeft ( 0 )
, mEffectBoxBaseRight ( 0 )
, mMinimapBoxBaseRight ( 0 )
, mDragAndDrop ( dragAndDrop )
, mCellNameTimer ( 0.0f )
, mCellNameBox ( NULL )
, mMapVisible ( true )
, mWeaponVisible ( true )
, mSpellVisible ( true )
, mWorldMouseOver ( false )
{
setCoord ( 0 , 0 , width , height ) ;
const MyGUI : : IntSize & viewSize = MyGUI : : RenderManager : : getInstance ( ) . getViewSize ( ) ;
// Energy bars
getWidget ( mHealthFrame , " HealthFrame " ) ;
getWidget ( mHealth , " Health " ) ;
getWidget ( mMagicka , " Magicka " ) ;
getWidget ( mStamina , " Stamina " ) ;
mHealthManaStaminaBaseLeft = mHealthFrame - > getLeft ( ) ;
// Item and spell images and status bars
getWidget ( mWeapBox , " WeapBox " ) ;
getWidget ( mWeapImage , " WeapImage " ) ;
getWidget ( mWeapStatus , " WeapStatus " ) ;
mWeapBoxBaseLeft = mWeapBox - > getLeft ( ) ;
mWeapBox - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onWeaponClicked ) ;
MyGUI : : Widget * healthFrame , * magickaFrame , * fatigueFrame ;
getWidget ( healthFrame , " HealthFrame " ) ;
getWidget ( magickaFrame , " MagickaFrame " ) ;
getWidget ( fatigueFrame , " FatigueFrame " ) ;
healthFrame - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onHMSClicked ) ;
magickaFrame - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onHMSClicked ) ;
fatigueFrame - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onHMSClicked ) ;
getWidget ( mSpellBox , " SpellBox " ) ;
getWidget ( mSpellImage , " SpellImage " ) ;
getWidget ( mSpellStatus , " SpellStatus " ) ;
mSpellBoxBaseLeft = mSpellBox - > getLeft ( ) ;
mSpellBox - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onMagicClicked ) ;
const MyGUI : : IntSize & viewSize = MyGUI : : RenderManager : : getInstance ( ) . getViewSize ( ) ;
getWidget ( mEffectBox , " EffectBox " ) ;
mEffectBoxBaseRight = viewSize . width - mEffectBox - > getRight ( ) ;
// Item and spell images and status bars
getWidget ( mWeapBox , " WeapBox " ) ;
getWidget ( mWeapImage , " WeapImage " ) ;
getWidget ( mWeapStatus , " WeapStatus " ) ;
mWeapBoxBaseLeft = mWeapBox - > getLeft ( ) ;
mWeapBox - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onWeaponClicked ) ;
getWidget ( mMinimapBox , " MiniMapBox " ) ;
mMinimapBoxBaseRight = viewSize . width - mMinimapBox - > getRight ( ) ;
getWidget ( mMinimap , " MiniMap " ) ;
getWidget ( mCompass , " Compass " ) ;
getWidget ( mMinimapButton , " MiniMapButton " ) ;
mMinimapButton - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onMapClicked ) ;
getWidget ( mSpellBox , " SpellBox " ) ;
getWidget ( mSpellImage , " SpellImage " ) ;
getWidget ( mSpellStatus , " SpellStatus " ) ;
mSpellBoxBaseLeft = mSpellBox - > getLeft ( ) ;
mSpellBox - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onMagicClicked ) ;
getWidget ( mCellNameBox , " CellName " ) ;
getWidget ( mWeaponSpellBox , " WeaponSpellName " ) ;
getWidget ( mEffectBox , " EffectBox " ) ;
mEffectBoxBaseRight = viewSize . width - mEffectBox - > getRight ( ) ;
getWidget ( mCrosshair , " Crosshair " ) ;
getWidget ( mMinimapBox , " MiniMapBox " ) ;
mMinimapBoxBaseRight = viewSize . width - mMinimapBox - > getRight ( ) ;
getWidget ( mMinimap , " MiniMap " ) ;
getWidget ( mCompass , " Compass " ) ;
getWidget ( mMinimapButton , " MiniMapButton " ) ;
mMinimapButton - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onMapClicked ) ;
setFpsLevel ( fpsLevel ) ;
getWidget ( mCellNameBox , " CellName " ) ;
getWidget ( mWeaponSpellBox , " WeaponSpellName " ) ;
getWidget ( mTriangleCounter , " TriangleCounter " ) ;
getWidget ( mBatchCounter , " BatchCounter " ) ;
getWidget ( mCrosshair , " Crosshair " ) ;
LocalMapBase : : init ( mMinimap , mCompass , this ) ;
setFpsLevel ( fpsLevel ) ;
mMainWidget - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onWorldClicked ) ;
mMainWidget - > eventMouseMove + = MyGUI : : newDelegate ( this , & HUD : : onWorldMouseOver ) ;
mMainWidget - > eventMouseLostFocus + = MyGUI : : newDelegate ( this , & HUD : : onWorldMouseLostFocus ) ;
getWidget ( mTriangleCounter , " TriangleCounter " ) ;
getWidget ( mBatchCounter , " BatchCounter " ) ;
mSpellIcons = new SpellIcons ( ) ;
}
LocalMapBase : : init ( mMinimap , mCompass , this ) ;
HUD : : ~ HUD ( )
{
delete mSpellIcons ;
}
mMainWidget - > eventMouseButtonClick + = MyGUI : : newDelegate ( this , & HUD : : onWorldClicked ) ;
mMainWidget - > eventMouseMove + = MyGUI : : newDelegate ( this , & HUD : : onWorldMouseOver ) ;
mMainWidget - > eventMouseLostFocus + = MyGUI : : newDelegate ( this , & HUD : : onWorldMouseLostFocus ) ;
void HUD : : setFpsLevel ( int level )
{
mFpsCounter = 0 ;
MyGUI : : Widget * fps ;
getWidget ( fps , " FPSBoxAdv " ) ;
fps - > setVisible ( false ) ;
getWidget ( fps , " FPSBox " ) ;
fps - > setVisible ( false ) ;
mSpellIcons = new SpellIcons ( ) ;
}
if ( level = = 2 )
HUD : : ~ HUD ( )
{
getWidget ( mFpsBox , " FPSBoxAdv " ) ;
mFpsBox - > setVisible ( true ) ;
getWidget ( mFpsCounter , " FPSCounterAdv " ) ;
delete mSpellIcons ;
}
else if ( level = = 1 )
void HUD : : setFpsLevel ( int level )
{
getWidget ( mFpsBox , " FPSBox " ) ;
mFpsBox - > setVisible ( true ) ;
getWidget ( mFpsCounter , " FPSCounter " ) ;
}
}
mFpsCounter = 0 ;
void HUD : : setFPS ( float fps )
{
if ( mFpsCounter )
mFpsCounter- > setCaption ( boost : : lexical_cast < std : : string > ( ( int ) fps ) ) ;
}
MyGUI : : Widget * fps ;
getWidget ( fps , " FPSBoxAdv " ) ;
fps - > setVisible ( false ) ;
getWidget( fps , " FPSBox " ) ;
fps - > setVisible ( false ) ;
void HUD : : setTriangleCount ( unsigned int count )
{
mTriangleCounter - > setCaption ( boost : : lexical_cast < std : : string > ( count ) ) ;
}
if ( level = = 2 )
{
getWidget ( mFpsBox , " FPSBoxAdv " ) ;
mFpsBox - > setVisible ( true ) ;
getWidget ( mFpsCounter , " FPSCounterAdv " ) ;
}
else if ( level = = 1 )
{
getWidget ( mFpsBox , " FPSBox " ) ;
mFpsBox - > setVisible ( true ) ;
getWidget ( mFpsCounter , " FPSCounter " ) ;
}
}
void HUD : : setBatchCount ( unsigned int count )
{
mBatchCounter - > setCaption ( boost : : lexical_cast < std : : string > ( count ) ) ;
}
void HUD : : setFPS ( float fps )
{
if ( mFpsCounter )
mFpsCounter - > setCaption ( boost : : lexical_cast < std : : string > ( ( int ) fps ) ) ;
}
void HUD : : setValue ( const std : : string & id , const MWMechanics : : DynamicStat < float > & value )
{
static const char * ids [ ] =
void HUD : : setTriangleCount ( unsigned int count )
{
" HBar " , " MBar " , " FBar " , 0
} ;
mTriangleCounter - > setCaption ( boost : : lexical_cast < std : : string > ( count ) ) ;
}
for ( int i = 0 ; ids [ i ] ; + + i )
if ( ids [ i ] = = id )
void HUD : : setBatchCount ( unsigned int count )
{
mBatchCounter - > setCaption ( boost : : lexical_cast < std : : string > ( count ) ) ;
}
void HUD : : setValue ( const std : : string & id , const MWMechanics : : DynamicStat < float > & value )
{
static const char * ids [ ] =
{
MyGUI : : Widget * w ;
std : : string valStr = boost : : lexical_cast < std : : string > ( value . getCurrent ( ) ) + " / " + boost : : lexical_cast < std : : string > ( value . getModified ( ) ) ;
switch ( i )
" HBar " , " MBar " , " FBar " , 0
} ;
for ( int i = 0 ; ids [ i ] ; + + i )
if ( ids [ i ] = = id )
{
case 0 :
mHealth - > setProgressRange ( value . getModified ( ) ) ;
mHealth - > setProgressPosition ( value . getCurrent ( ) ) ;
getWidget ( w , " HealthFrame " ) ;
w - > setUserString ( " Caption_HealthDescription " , " #{sHealthDesc} \n " + valStr ) ;
break ;
case 1 :
mMagicka - > setProgressRange ( value . getModified ( ) ) ;
mMagicka - > setProgressPosition ( value . getCurrent ( ) ) ;
getWidget ( w , " MagickaFrame " ) ;
w - > setUserString ( " Caption_HealthDescription " , " #{sIntDesc} \n " + valStr ) ;
break ;
case 2 :
mStamina - > setProgressRange ( value . getModified ( ) ) ;
mStamina - > setProgressPosition ( value . getCurrent ( ) ) ;
getWidget ( w , " FatigueFrame " ) ;
w - > setUserString ( " Caption_HealthDescription " , " #{sFatDesc} \n " + valStr ) ;
break ;
MyGUI : : Widget * w ;
std : : string valStr = boost : : lexical_cast < std : : string > ( value . getCurrent ( ) ) + " / " + boost : : lexical_cast < std : : string > ( value . getModified ( ) ) ;
switch ( i )
{
case 0 :
mHealth - > setProgressRange ( value . getModified ( ) ) ;
mHealth - > setProgressPosition ( value . getCurrent ( ) ) ;
getWidget ( w , " HealthFrame " ) ;
w - > setUserString ( " Caption_HealthDescription " , " #{sHealthDesc} \n " + valStr ) ;
break ;
case 1 :
mMagicka - > setProgressRange ( value . getModified ( ) ) ;
mMagicka - > setProgressPosition ( value . getCurrent ( ) ) ;
getWidget ( w , " MagickaFrame " ) ;
w - > setUserString ( " Caption_HealthDescription " , " #{sIntDesc} \n " + valStr ) ;
break ;
case 2 :
mStamina - > setProgressRange ( value . getModified ( ) ) ;
mStamina - > setProgressPosition ( value . getCurrent ( ) ) ;
getWidget ( w , " FatigueFrame " ) ;
w - > setUserString ( " Caption_HealthDescription " , " #{sFatDesc} \n " + valStr ) ;
break ;
}
}
}
}
void HUD : : onWorldClicked ( MyGUI : : Widget * _sender )
{
if ( ! MWBase : : Environment : : get ( ) . getWindowManager ( ) - > isGuiMode ( ) )
return ;
}
if ( mDragAndDrop - > mIsOnDragAndDrop )
void HUD : : onWorldClicked ( MyGUI : : Widget * _sender )
{
// drop item into the gameworld
MWWorld : : Ptr object = * mDragAndDrop - > mDraggedWidget - > getUserData < MWWorld : : Ptr > ( ) ;
if ( ! MWBase : : Environment : : get ( ) . getWindowManager ( ) - > isGuiMode ( ) )
return ;
MWBase : : World * world = MWBase : : Environment : : get ( ) . getWorld ( ) ;
if ( mDragAndDrop - > mIsOnDragAndDrop )
{
// drop item into the gameworld
MWWorld : : Ptr object = * mDragAndDrop - > mDraggedWidget - > getUserData < MWWorld : : Ptr > ( ) ;
MyGUI : : IntSize viewSize = MyGUI : : RenderManager : : getInstance ( ) . getViewSize ( ) ;
MyGUI : : IntPoint cursorPosition = MyGUI : : InputManager : : getInstance ( ) . getMousePosition ( ) ;
float mouseX = cursorPosition . left / float ( viewSize . width ) ;
float mouseY = cursorPosition . top / float ( viewSize . height ) ;
MWBase : : World * world = MWBase : : Environment : : get ( ) . getWorld ( ) ;
int origCount = object . getRefData ( ) . getCount ( ) ;
object . getRefData ( ) . setCount ( mDragAndDrop - > mDraggedCount ) ;
MyGUI : : IntSize viewSize = MyGUI : : RenderManager : : getInstance ( ) . getViewSize ( ) ;
MyGUI : : IntPoint cursorPosition = MyGUI : : InputManager : : getInstance ( ) . getMousePosition ( ) ;
float mouseX = cursorPosition . left / float ( viewSize . width ) ;
float mouseY = cursorPosition . top / float ( viewSize . height ) ;
if ( world - > canPlaceObject ( mouseX , mouseY ) )
world - > placeObject ( object , mouseX , mouseY ) ;
else
world - > dropObjectOnGround ( world - > getPlayer ( ) . getPlayer ( ) , object ) ;
int origCount = object . getRefData ( ) . getCount ( ) ;
object . getRefData ( ) . setCount ( mDragAndDrop - > mDraggedCount ) ;
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > changePointer ( " arrow " ) ;
if ( world - > canPlaceObject ( mouseX , mouseY ) )
world - > placeObject ( object , mouseX , mouseY ) ;
else
world - > dropObjectOnGround ( world - > getPlayer ( ) . getPlayer ( ) , object ) ;
std : : string sound = MWWorld : : Class : : get ( object ) . getDownSoundId ( object ) ;
MWBase : : Environment : : get ( ) . getSoundManager ( ) - > playSound ( sound , 1.0 , 1.0 ) ;
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > changePointer ( " arrow " ) ;
// remove object from the container it was coming from
object . getRefData ( ) . setCount ( origCount - mDragAndDrop - > mDraggedCount ) ;
std : : string sound = MWWorld : : Class : : get ( object ) . getDownSoundId ( object ) ;
MWBase : : Environment : : get ( ) . getSoundManager ( ) - > playSound ( sound , 1.0 , 1.0 ) ;
mDragAndDrop - > mIsOnDragAndDrop = false ;
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( mDragAndDrop - > mDraggedWidget ) ;
mDragAndDrop - > mDraggedWidget = 0 ;
// remove object from the container it was coming from
object . getRefData ( ) . setCount ( origCount - mDragAndDrop - > mDraggedCount ) ;
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > setDragDrop ( false ) ;
mDragAndDrop - > mDraggedFrom - > drawItems ( ) ;
mDragAndDrop - > mDraggedFrom - > notifyItemDragged ( object , - mDragAndDrop - > mDraggedCount ) ;
}
else
{
GuiMode mode = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getMode ( ) ;
mDragAndDrop - > mIsOnDragAndDrop = false ;
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( mDragAndDrop - > mDraggedWidget ) ;
mDragAndDrop - > mDraggedWidget = 0 ;
if ( ( mode ! = GM_Console ) & & ( mode ! = GM_Container ) & & ( mode ! = GM_Inventory ) )
return ;
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > setDragDrop ( false ) ;
mDragAndDrop - > mDraggedFrom - > drawItems ( ) ;
mDragAndDrop - > mDraggedFrom - > notifyItemDragged ( object , - mDragAndDrop - > mDraggedCount ) ;
}
else
{
GuiMode mode = MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getMode ( ) ;
MWWorld : : Ptr object = MWBase : : Environment : : get ( ) . getWorld ( ) - > getFacedObject ( ) ;
if ( ( mode ! = GM_Console ) & & ( mode ! = GM_Container ) & & ( mode ! = GM_Inventory ) )
return ;
if ( mode = = GM_Console )
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getConsole ( ) - > setSelectedObject ( object ) ;
else if ( ( mode = = GM_Container ) | | ( mode = = GM_Inventory ) )
{
// pick up object
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getInventoryWindow ( ) - > pickUpObject ( object ) ;
MWWorld : : Ptr object = MWBase : : Environment : : get ( ) . getWorld ( ) - > getFacedObject ( ) ;
if ( mode = = GM_Console )
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getConsole ( ) - > setSelectedObject ( object ) ;
else if ( ( mode = = GM_Container ) | | ( mode = = GM_Inventory ) )
{
// pick up object
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > getInventoryWindow ( ) - > pickUpObject ( object ) ;
}
}
}
}
void HUD : : onWorldMouseOver ( MyGUI : : Widget * _sender , int x , int y )
{
if ( mDragAndDrop - > mIsOnDragAndDrop )
void HUD : : onWorldMouseOver ( MyGUI : : Widget * _sender , int x , int y )
{
mWorldMouseOver = false ;
if ( mDragAndDrop - > mIsOnDragAndDrop )
{
mWorldMouseOver = false ;
MyGUI : : IntSize viewSize = MyGUI : : RenderManager : : getInstance ( ) . getViewSize ( ) ;
MyGUI : : IntPoint cursorPosition = MyGUI : : InputManager : : getInstance ( ) . getMousePosition ( ) ;
float mouseX = cursorPosition . left / float ( viewSize . width ) ;
float mouseY = cursorPosition . top / float ( viewSize . height ) ;
MyGUI : : IntSize viewSize = MyGUI : : RenderManager : : getInstance ( ) . getViewSize ( ) ;
MyGUI : : IntPoint cursorPosition = MyGUI : : InputManager : : getInstance ( ) . getMousePosition ( ) ;
float mouseX = cursorPosition . left / float ( viewSize . width ) ;
float mouseY = cursorPosition . top / float ( viewSize . height ) ;
MWBase : : World * world = MWBase : : Environment : : get ( ) . getWorld ( ) ;
MWBase : : World * world = MWBase : : Environment : : get ( ) . getWorld ( ) ;
// if we can't drop the object at the wanted position, show the "drop on ground" cursor.
bool canDrop = world - > canPlaceObject ( mouseX , mouseY ) ;
// if we can't drop the object at the wanted position, show the "drop on ground" cursor.
bool canDrop = world - > canPlaceObject ( mouseX , mouseY ) ;
if ( ! canDrop )
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > changePointer ( " drop_ground " ) ;
else
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > changePointer ( " arrow " ) ;
if ( ! canDrop )
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > changePointer ( " drop_ground " ) ;
}
else
{
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > changePointer ( " arrow " ) ;
mWorldMouseOver = true ;
}
}
else
void HUD : : onWorldMouseLostFocus ( MyGUI : : Widget * _sender , MyGUI : : Widget * _new )
{
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > changePointer ( " arrow " ) ;
mWorldMouseOver = tru e;
mWorldMouseOver = fals e;
}
}
void HUD : : onWorldMouseLostFocus ( MyGUI : : Widget * _sender , MyGUI : : Widget * _new )
{
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > changePointer ( " arrow " ) ;
mWorldMouseOver = false ;
}
void HUD : : onHMSClicked ( MyGUI : : Widget * _sender )
{
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > toggleVisible ( GW_Stats ) ;
}
void HUD : : onMapClicked ( MyGUI : : Widget * _sender )
{
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > toggleVisible ( GW_Map ) ;
}
void HUD : : onWeaponClicked ( MyGUI : : Widget * _sender )
{
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > toggleVisible ( GW_Inventory ) ;
}
void HUD : : onHMSClicked ( MyGUI : : Widget * _sender )
{
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > toggleVisible ( GW_Stats ) ;
}
void HUD : : onMa gic Clicked( MyGUI : : Widget * _sender )
{
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > toggleVisible ( GW_Ma gic ) ;
}
void HUD : : onMapClicked ( MyGUI : : Widget * _sender )
{
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > toggleVisible ( GW_Map ) ;
}
void HUD : : setCellName ( const std : : string & cellName )
{
if ( mCellName ! = cellName )
void HUD : : onWeaponClicked ( MyGUI : : Widget * _sender )
{
mCellNameTimer = 5.0f ;
mCellName = cellName ;
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > toggleVisible ( GW_Inventory ) ;
}
mCellNameBox - > setCaptionWithReplacing ( " #{sCell= " + mCellName + " } " ) ;
mCellNameBox - > setVisible ( mMapVisible ) ;
void HUD : : onMagicClicked ( MyGUI : : Widget * _sender )
{
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > toggleVisible ( GW_Magic ) ;
}
}
void HUD : : onFrame ( float dt )
{
mCellNameTimer - = dt ;
mWeaponSpellTimer - = dt ;
if ( mCellNameTimer < 0 )
mCellNameBox - > setVisible ( false ) ;
if ( mWeaponSpellTimer < 0 )
mWeaponSpellBox - > setVisible ( false ) ;
}
void HUD : : setCellName ( const std : : string & cellName )
{
if ( mCellName ! = cellName )
{
mCellNameTimer = 5.0f ;
mCellName = cellName ;
void HUD : : onResChange ( int width , int height )
{
setCoord ( 0 , 0 , width , height ) ;
}
mCellNameBox - > setCaptionWithReplacing ( " #{sCell= " + mCellName + " } " ) ;
mCellNameBox - > setVisible ( mMapVisible ) ;
}
}
void HUD : : setSelectedSpell ( const std : : string & spellId , int successChancePercent )
{
const ESM : : Spell * spell =
MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . get < ESM : : Spell > ( ) . find ( spellId ) ;
void HUD : : onFrame ( float dt )
{
mCellNameTimer - = dt ;
mWeaponSpellTimer - = dt ;
if ( mCellNameTimer < 0 )
mCellNameBox - > setVisible ( false ) ;
if ( mWeaponSpellTimer < 0 )
mWeaponSpellBox - > setVisible ( false ) ;
}
std : : string spellName = spell - > mName ;
if ( spellName ! = mSpellName & & mSpellVisible )
void HUD : : onResChange ( int width , int height )
{
mWeaponSpellTimer = 5.0f ;
mSpellName = spellName ;
mWeaponSpellBox - > setCaption ( mSpellName ) ;
mWeaponSpellBox - > setVisible ( true ) ;
setCoord ( 0 , 0 , width , height ) ;
}
mSpellStatus - > setProgressRange ( 100 ) ;
mSpellStatus - > setProgressPosition ( successChancePercent ) ;
void HUD : : setSelectedSpell ( const std : : string & spellId , int successChancePercent )
{
const ESM : : Spell * spell =
MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . get < ESM : : Spell > ( ) . find ( spellId ) ;
if ( mSpellImage - > getChildCount ( ) )
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( mSpellImage - > getChildAt ( 0 ) ) ;
std : : string spellName = spell - > mName ;
if ( spellName ! = mSpellName & & mSpellVisible )
{
mWeaponSpellTimer = 5.0f ;
mSpellName = spellName ;
mWeaponSpellBox - > setCaption ( mSpellName ) ;
mWeaponSpellBox - > setVisible ( true ) ;
}
mSpellBox - > setUserString ( " ToolTipType " , " Spell " ) ;
mSpellBox - > setUserString ( " Spell " , spellId ) ;
mSpellStatus - > setProgressRange ( 100 ) ;
mSpellStatus - > setProgressPosition ( successChancePercent ) ;
// use the icon of the first effect
const ESM : : MagicEffect * effect =
MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . get < ESM : : MagicEffect > ( ) . find ( spell - > mEffects . mList . front ( ) . mEffectID ) ;
if ( mSpellImage - > getChildCount ( ) )
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( mSpellImage - > getChildAt ( 0 ) ) ;
std : : string icon = effect - > mIcon ;
int slashPos = icon . find ( " \\ " ) ;
icon . insert ( slashPos + 1 , " b_ " ) ;
icon = std : : string ( " icons \\ " ) + icon ;
Widgets : : fixTexturePath ( icon ) ;
mSpellImage - > setImageTexture ( icon ) ;
}
mSpellBox - > setUserString ( " ToolTipType " , " Spell " ) ;
mSpellBox - > setUserString ( " Spell " , spellId ) ;
void HUD : : setSelectedEnchantItem ( const MWWorld : : Ptr & item , int chargePercent )
{
std : : string itemName = MWWorld : : Class : : get ( item ) . getName ( item ) ;
if ( itemName ! = mSpellName & & mSpellVisible )
{
mWeaponSpellTimer = 5.0f ;
mSpellName = itemName ;
mWeaponSpellBox - > setCaption ( mSpellName ) ;
mWeaponSpellBox - > setVisible ( true ) ;
// use the icon of the first effect
const ESM : : MagicEffect * effect =
MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . get < ESM : : MagicEffect > ( ) . find ( spell - > mEffects . mList . front ( ) . mEffectID ) ;
std : : string icon = effect - > mIcon ;
int slashPos = icon . find ( " \\ " ) ;
icon . insert ( slashPos + 1 , " b_ " ) ;
icon = std : : string ( " icons \\ " ) + icon ;
Widgets : : fixTexturePath ( icon ) ;
mSpellImage - > setImageTexture ( icon ) ;
}
mSpellStatus - > setProgressRange ( 100 ) ;
mSpellStatus - > setProgressPosition ( chargePercent ) ;
void HUD : : setSelectedEnchantItem ( const MWWorld : : Ptr & item , int chargePercent )
{
std : : string itemName = MWWorld : : Class : : get ( item ) . getName ( item ) ;
if ( itemName ! = mSpellName & & mSpellVisible )
{
mWeaponSpellTimer = 5.0f ;
mSpellName = itemName ;
mWeaponSpellBox - > setCaption ( mSpellName ) ;
mWeaponSpellBox - > setVisible ( true ) ;
}
if ( mSpellImage - > getChildCount ( ) )
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( mSpellImage - > getChildAt ( 0 ) ) ;
mSpellStatus - > setProgressRange ( 100 ) ;
mSpellStatus- > setProgressPosition ( chargePercent ) ;
mSpellBox - > setUserString ( " ToolTipType " , " ItemPtr " ) ;
mSpellBox - > setUserData ( item ) ;
if ( mSpellImage - > getChildCount ( ) )
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( mSpellImage - > getChildAt ( 0 ) ) ;
mSpellImage - > setImageTexture ( " textures \\ menu_icon_magic_mini.dds " ) ;
MyGUI : : ImageBox * itemBox = mSpellImage - > createWidgetReal < MyGUI : : ImageBox > ( " ImageBox " , MyGUI : : FloatCoord ( 0 , 0 , 1 , 1 )
, MyGUI : : Align : : Stretch ) ;
mSpellBox - > setUserString ( " ToolTipType " , " ItemPtr " ) ;
mSpellBox - > setUserData ( item ) ;
std : : string path = std : : string ( " icons \\ " ) ;
path + = MWWorld : : Class : : get ( item ) . getInventoryIcon ( item ) ;
Widgets : : fixTexturePath ( path ) ;
itemBox - > setImageTexture ( path ) ;
itemBox - > setNeedMouseFocus ( false ) ;
}
mSpellImage - > setImageTexture ( " textures \\ menu_icon_magic_mini.dds " ) ;
MyGUI : : ImageBox * itemBox = mSpellImage - > createWidgetReal < MyGUI : : ImageBox > ( " ImageBox " , MyGUI : : FloatCoord ( 0 , 0 , 1 , 1 )
, MyGUI : : Align : : Stretch ) ;
void HUD : : setSelectedWeapon ( const MWWorld : : Ptr & item , int durabilityPercent )
{
std : : string itemName = MWWorld : : Class : : get ( item ) . getName ( item ) ;
if ( itemName ! = mWeaponName & & mWeaponVisible )
{
mWeaponSpellTimer = 5.0f ;
mWeaponName = itemName ;
mWeaponSpellBox - > setCaption ( mWeaponName ) ;
mWeaponSpellBox - > setVisible ( true ) ;
std : : string path = std : : string ( " icons \\ " ) ;
path + = MWWorld : : Class : : get ( item ) . getInventoryIcon ( item ) ;
Widgets : : fixTexturePath ( path ) ;
itemBox - > setImageTexture ( path ) ;
itemBox - > setNeedMouseFocus ( false ) ;
}
mWeapBox - > setUserString ( " ToolTipType " , " ItemPtr " ) ;
mWeapBox - > setUserData ( item ) ;
void HUD : : setSelectedWeapon ( const MWWorld : : Ptr & item , int durabilityPercent )
{
std : : string itemName = MWWorld : : Class : : get ( item ) . getName ( item ) ;
if ( itemName ! = mWeaponName & & mWeaponVisible )
{
mWeaponSpellTimer = 5.0f ;
mWeaponName = itemName ;
mWeaponSpellBox - > setCaption ( mWeaponName ) ;
mWeaponSpellBox - > setVisible ( true ) ;
}
mWeapBox - > setUserString ( " ToolTipType " , " ItemPtr " ) ;
mWeapBox - > setUserData ( item ) ;
mWeapStatus - > setProgressRange ( 100 ) ;
mWeapStatus - > setProgressPosition ( durabilityPercent ) ;
mWeapStatus - > setProgressRange ( 100 ) ;
mWeapStatus - > setProgressPosition ( durabilityPercent ) ;
if ( mWeapImage - > getChildCount ( ) )
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( mWeapImage - > getChildAt ( 0 ) ) ;
if ( mWeapImage - > getChildCount ( ) )
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( mWeapImage - > getChildAt ( 0 ) ) ;
std : : string path = std : : string ( " icons \\ " ) ;
path + = MWWorld : : Class : : get ( item ) . getInventoryIcon ( item ) ;
Widgets : : fixTexturePath ( path ) ;
std : : string path = std : : string ( " icons \\ " ) ;
path + = MWWorld : : Class : : get ( item ) . getInventoryIcon ( item ) ;
Widgets : : fixTexturePath ( path ) ;
if ( MWWorld : : Class : : get ( item ) . getEnchantment ( item ) ! = " " )
{
mWeapImage - > setImageTexture ( " textures \\ menu_icon_magic_mini.dds " ) ;
MyGUI : : ImageBox * itemBox = mWeapImage - > createWidgetReal < MyGUI : : ImageBox > ( " ImageBox " , MyGUI : : FloatCoord ( 0 , 0 , 1 , 1 )
, MyGUI : : Align : : Stretch ) ;
itemBox - > setImageTexture ( path ) ;
itemBox - > setNeedMouseFocus ( false ) ;
if ( MWWorld : : Class : : get ( item ) . getEnchantment ( item ) ! = " " )
{
mWeapImage - > setImageTexture ( " textures \\ menu_icon_magic_mini.dds " ) ;
MyGUI : : ImageBox * itemBox = mWeapImage - > createWidgetReal < MyGUI : : ImageBox > ( " ImageBox " , MyGUI : : FloatCoord ( 0 , 0 , 1 , 1 )
, MyGUI : : Align : : Stretch ) ;
itemBox - > setImageTexture ( path ) ;
itemBox - > setNeedMouseFocus ( false ) ;
}
else
mWeapImage - > setImageTexture ( path ) ;
}
else
mWeapImage - > setImageTexture ( path ) ;
}
void HUD : : unsetSelectedSpell ( )
{
std : : string spellName = " #{sNone} " ;
if ( spellName ! = mSpellName & & mSpellVisible )
void HUD : : unsetSelectedSpell ( )
{
mWeaponSpellTimer = 5.0f ;
mSpellName = spellName ;
mWeaponSpellBox - > setCaptionWithReplacing ( mSpellName ) ;
mWeaponSpellBox - > setVisible ( true ) ;
}
std : : string spellName = " #{sNone} " ;
if ( spellName ! = mSpellName & & mSpellVisible )
{
mWeaponSpellTimer = 5.0f ;
mSpellName = spellName ;
mWeaponSpellBox - > setCaptionWithReplacing ( mSpellName ) ;
mWeaponSpellBox - > setVisible ( true ) ;
}
if ( mSpellImage - > getChildCount ( ) )
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( mSpellImage - > getChildAt ( 0 ) ) ;
mSpellStatus - > setProgressRange ( 100 ) ;
mSpellStatus - > setProgressPosition ( 0 ) ;
mSpellImage - > setImageTexture ( " " ) ;
mSpellBox - > clearUserStrings ( ) ;
}
if ( mSpellImage - > getChildCount ( ) )
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( mSpellImage - > getChildAt ( 0 ) ) ;
mSpellStatus - > setProgressRange ( 100 ) ;
mSpellStatus - > setProgressPosition ( 0 ) ;
mSpellImage - > setImageTexture ( " " ) ;
mSpellBox - > clearUserStrings ( ) ;
}
void HUD : : unsetSelectedWeapon ( )
{
std : : string itemName = " #{sSkillHandtohand} " ;
if ( itemName ! = mWeaponName & & mWeaponVisible )
void HUD : : unsetSelectedWeapon ( )
{
mWeaponSpellTimer = 5.0f ;
mWeaponName = itemName ;
mWeaponSpellBox - > setCaptionWithReplacing ( mWeaponName ) ;
mWeaponSpellBox - > setVisible ( true ) ;
std : : string itemName = " #{sSkillHandtohand} " ;
if ( itemName ! = mWeaponName & & mWeaponVisible )
{
mWeaponSpellTimer = 5.0f ;
mWeaponName = itemName ;
mWeaponSpellBox - > setCaptionWithReplacing ( mWeaponName ) ;
mWeaponSpellBox - > setVisible ( true ) ;
}
if ( mWeapImage - > getChildCount ( ) )
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( mWeapImage - > getChildAt ( 0 ) ) ;
mWeapStatus - > setProgressRange ( 100 ) ;
mWeapStatus - > setProgressPosition ( 0 ) ;
mWeapImage - > setImageTexture ( " icons \\ k \\ stealth_handtohand.dds " ) ;
mWeapBox - > clearUserStrings ( ) ;
}
if ( mWeapImage - > getChildCount ( ) )
MyGUI : : Gui : : getInstance ( ) . destroyWidget ( mWeapImage - > getChildAt ( 0 ) ) ;
mWeapStatus - > setProgressRange ( 100 ) ;
mWeapStatus - > setProgressPosition ( 0 ) ;
mWeapImage - > setImageTexture ( " icons \\ k \\ stealth_handtohand.dds " ) ;
mWeapBox - > clearUserStrings ( ) ;
}
void HUD : : setCrosshairVisible ( bool visible )
{
mCrosshair - > setVisible ( visible ) ;
}
void HUD : : setCrosshairVisible ( bool visible )
{
mCrosshair - > setVisible ( visible ) ;
}
void HUD : : setHmsVisible ( bool visible )
{
mHealth - > setVisible ( visible ) ;
mMagicka - > setVisible ( visible ) ;
mStamina - > setVisible ( visible ) ;
updatePositions ( ) ;
}
void HUD : : setHmsVisible ( bool visible )
{
mHealth - > setVisible ( visible ) ;
mMagicka - > setVisible ( visible ) ;
mStamina - > setVisible ( visible ) ;
updatePositions ( ) ;
}
void HUD : : setWeapVisible ( bool visible )
{
mWeapBox - > setVisible ( visible ) ;
updatePositions ( ) ;
}
void HUD : : setWeap Visible( bool visible )
{
mWeap Box- > setVisible ( visible ) ;
updatePositions ( ) ;
}
void HUD : : setSpellVisible ( bool visible )
{
mSpell Box- > setVisible ( visible ) ;
updatePositions ( ) ;
}
void HUD : : setSpell Visible( bool visible )
{
mSpellBox - > setVisible ( visible ) ;
updatePositions ( ) ;
}
void HUD : : setEffect Visible( bool visible )
{
mEffectBox - > setVisible ( visible ) ;
updatePositions ( ) ;
}
void HUD : : setEffect Visible( bool visible )
{
mEffect Box- > setVisible ( visible ) ;
updatePositions ( ) ;
}
void HUD : : setMinimap Visible( bool visible )
{
mMinimap Box- > setVisible ( visible ) ;
updatePositions ( ) ;
}
void HUD : : setMinimapVisible ( bool visible )
{
mMinimapBox - > setVisible ( visible ) ;
updatePositions ( ) ;
}
void HUD : : updatePositions ( )
{
int weapDx = 0 , spellDx = 0 ;
if ( ! mHealth - > getVisible ( ) )
spellDx = weapDx = mWeapBoxBaseLeft - mHealthManaStaminaBaseLeft ;
void HUD : : updatePositions ( )
{
int weapDx = 0 , spellDx = 0 ;
if ( ! mHealth - > getVisible ( ) )
spellDx = weapDx = mWeapBoxBaseLeft - mHealthManaStaminaBaseLeft ;
if ( ! mWeapBox - > getVisible ( ) )
spellDx + = mSpellBoxBaseLeft - mWeapBoxBaseLeft ;
if ( ! mWeapBox - > getVisible ( ) )
spellDx + = mSpellBoxBaseLeft - mWeapBoxBaseLeft ;
mWeaponVisible = mWeapBox - > getVisible ( ) ;
mSpellVisible = mSpellBox - > getVisible ( ) ;
if ( ! mWeaponVisible & & ! mSpellVisible )
mWeaponSpellBox - > setVisible ( false ) ;
mWeaponVisible = mWeapBox - > getVisible ( ) ;
mSpellVisible = mSpellBox - > getVisible ( ) ;
if ( ! mWeaponVisible & & ! mSpellVisible )
mWeaponSpellBox - > setVisible ( false ) ;
mWeapBox - > setPosition ( mWeapBoxBaseLeft - weapDx , mWeapBox - > getTop ( ) ) ;
mSpellBox - > setPosition ( mSpellBoxBaseLeft - spellDx , mSpellBox - > getTop ( ) ) ;
mWeapBox - > setPosition ( mWeapBoxBaseLeft - weapDx , mWeapBox - > getTop ( ) ) ;
mSpellBox - > setPosition ( mSpellBoxBaseLeft - spellDx , mSpellBox - > getTop ( ) ) ;
const MyGUI : : IntSize & viewSize = MyGUI : : RenderManager : : getInstance ( ) . getViewSize ( ) ;
const MyGUI : : IntSize & viewSize = MyGUI : : RenderManager : : getInstance ( ) . getViewSize ( ) ;
// effect box can have variable width -> variable left coordinate
int effectsDx = 0 ;
if ( ! mMinimapBox - > getVisible ( ) )
effectsDx = ( viewSize . width - mMinimapBoxBaseRight ) - ( viewSize . width - mEffectBoxBaseRight ) ;
// effect box can have variable width -> variable left coordinate
int effectsDx = 0 ;
if ( ! mMinimapBox - > getVisible ( ) )
effectsDx = ( viewSize . width - mMinimapBoxBaseRight ) - ( viewSize . width - mEffectBoxBaseRight ) ;
mMapVisible = mMinimapBox - > getVisible ( ) ;
mEffectBox - > setPosition ( ( viewSize . width - mEffectBoxBaseRight ) - mEffectBox - > getWidth ( ) + effectsDx , mEffectBox - > getTop ( ) ) ;
}
mMapVisible = mMinimapBox - > getVisible ( ) ;
mEffectBox - > setPosition ( ( viewSize . width - mEffectBoxBaseRight ) - mEffectBox - > getWidth ( ) + effectsDx , mEffectBox - > getTop ( ) ) ;
}
void HUD : : update ( )
{
mSpellIcons - > updateWidgets ( mEffectBox , true ) ;
}
void HUD : : update ( )
{
mSpellIcons - > updateWidgets ( mEffectBox , true ) ;
}