@ -122,19 +122,8 @@
# include "../mwvr/vrgui.hpp"
# endif
namespace
{
MyGUI : : Colour getTextColour ( const std : : string & type )
{
return MyGUI : : Colour : : parse ( MyGUI : : LanguageManager : : getInstance ( ) . replaceTags ( " #{fontcolour= " + type + " } " ) ) ;
}
}
namespace MWGui
{
WindowManager : : WindowManager (
SDL_Window * window , osgViewer : : Viewer * viewer , osg : : Group * guiRoot , Resource : : ResourceSystem * resourceSystem , SceneUtil : : WorkQueue * workQueue ,
const std : : string & logpath , const std : : string & resourcePath , bool consoleOnlyScripts , Translation : : Storage & translationDataStorage ,
@ -188,12 +177,6 @@ namespace MWGui
, mCursorActive ( false )
, mVideoEnabled ( false )
, mPlayerBounty ( - 1 )
, mPlayerName ( )
, mPlayerRaceId ( )
, mPlayerAttributes ( )
, mPlayerMajorSkills ( )
, mPlayerMinorSkills ( )
, mPlayerSkillValues ( )
, mGui ( nullptr )
, mGuiModes ( )
, mCursorManager ( nullptr )
@ -204,7 +187,6 @@ namespace MWGui
, mRestAllowed ( true )
, mShowOwned ( 0 )
, mEncoding ( encoding )
, mFontHeight ( 16 )
, mVersionDescription ( versionDescription )
, mWindowVisible ( true )
{
@ -246,13 +228,6 @@ namespace MWGui
SpellView : : registerComponents ( ) ;
Gui : : registerAllWidgets ( ) ;
int fontSize = Settings : : Manager : : getInt ( " font size " , " GUI " ) ;
fontSize = std : : min ( std : : max ( 12 , fontSize ) , 20 ) ;
mFontHeight = fontSize ;
MyGUI : : ResourceManager : : getInstance ( ) . unregisterLoadXmlDelegate ( " Resource " ) ;
MyGUI : : ResourceManager : : getInstance ( ) . registerLoadXmlDelegate ( " Resource " ) = newDelegate ( this , & WindowManager : : loadFontDelegate ) ;
MyGUI : : FactoryManager : : getInstance ( ) . registerFactory < MWGui : : Controllers : : ControllerFollowMouse > ( " Controller " ) ;
MyGUI : : FactoryManager : : getInstance ( ) . registerFactory < ResourceImageSetPointerFix > ( " Resource " , " ResourceImageSetPointer " ) ;
@ -269,7 +244,7 @@ namespace MWGui
mKeyboardNavigation - > setEnabled ( keyboardNav ) ;
Gui : : ImageButton : : setDefaultNeedKeyFocus ( keyboardNav ) ;
mLoadingScreen = new LoadingScreen ( mResourceSystem - > getVFS ( ) , mViewer ) ;
mLoadingScreen = new LoadingScreen ( mResourceSystem , mViewer ) ;
mWindows . push_back ( mLoadingScreen ) ;
//set up the hardware cursor manager
@ -313,94 +288,6 @@ namespace MWGui
Settings : : Manager : : getFloat ( " contrast " , " Video " ) ) ;
}
void WindowManager : : loadFontDelegate ( MyGUI : : xml : : ElementPtr _node , const std : : string & _file , MyGUI : : Version _version )
{
MyGUI : : xml : : ElementEnumerator resourceNode = _node - > getElementEnumerator ( ) ;
bool createCopy = false ;
while ( resourceNode . next ( " Resource " ) )
{
std : : string type , name ;
resourceNode - > findAttribute ( " type " , type ) ;
resourceNode - > findAttribute ( " name " , name ) ;
if ( name . empty ( ) )
continue ;
if ( Misc : : StringUtils : : ciEqual ( type , " ResourceTrueTypeFont " ) )
{
createCopy = true ;
// For TrueType fonts we should override Size and Resolution properties
// to allow to configure font size via config file, without need to edit XML files.
// Also we should take UI scaling factor in account.
int resolution = Settings : : Manager : : getInt ( " ttf resolution " , " GUI " ) ;
resolution = std : : min ( 960 , std : : max ( 48 , resolution ) ) ;
float uiScale = Settings : : Manager : : getFloat ( " scaling factor " , " GUI " ) ;
resolution * = uiScale ;
MyGUI : : xml : : ElementPtr resolutionNode = resourceNode - > createChild ( " Property " ) ;
resolutionNode - > addAttribute ( " key " , " Resolution " ) ;
resolutionNode - > addAttribute ( " value " , std : : to_string ( resolution ) ) ;
MyGUI : : xml : : ElementPtr sizeNode = resourceNode - > createChild ( " Property " ) ;
sizeNode - > addAttribute ( " key " , " Size " ) ;
sizeNode - > addAttribute ( " value " , std : : to_string ( mFontHeight ) ) ;
}
else if ( Misc : : StringUtils : : ciEqual ( type , " ResourceSkin " ) | |
Misc : : StringUtils : : ciEqual ( type , " AutoSizedResourceSkin " ) )
{
// We should adjust line height for MyGUI widgets depending on font size
MyGUI : : xml : : ElementPtr heightNode = resourceNode - > createChild ( " Property " ) ;
heightNode - > addAttribute ( " key " , " HeightLine " ) ;
heightNode - > addAttribute ( " value " , std : : to_string ( mFontHeight + 2 ) ) ;
}
}
MyGUI : : ResourceManager : : getInstance ( ) . loadFromXmlNode ( _node , _file , _version ) ;
if ( createCopy )
{
MyGUI : : xml : : ElementPtr copy = _node - > createCopy ( ) ;
MyGUI : : xml : : ElementEnumerator copyFont = copy - > getElementEnumerator ( ) ;
while ( copyFont . next ( " Resource " ) )
{
std : : string type , name ;
copyFont - > findAttribute ( " type " , type ) ;
copyFont - > findAttribute ( " name " , name ) ;
if ( name . empty ( ) )
continue ;
if ( Misc : : StringUtils : : ciEqual ( type , " ResourceTrueTypeFont " ) )
{
// Since the journal and books use the custom scaling factor depending on resolution,
// setup separate fonts with different Resolution to fit these windows.
// These fonts have an internal prefix.
int resolution = Settings : : Manager : : getInt ( " ttf resolution " , " GUI " ) ;
resolution = std : : min ( 960 , std : : max ( 48 , resolution ) ) ;
float currentX = Settings : : Manager : : getInt ( " resolution x " , " Video " ) ;
float currentY = Settings : : Manager : : getInt ( " resolution y " , " Video " ) ;
// TODO: read size from openmw_layout.xml
float heightScale = ( currentY / 520 ) ;
float widthScale = ( currentX / 600 ) ;
float uiScale = std : : min ( widthScale , heightScale ) ;
resolution * = uiScale ;
MyGUI : : xml : : ElementPtr resolutionNode = copyFont - > createChild ( " Property " ) ;
resolutionNode - > addAttribute ( " key " , " Resolution " ) ;
resolutionNode - > addAttribute ( " value " , std : : to_string ( resolution ) ) ;
copyFont - > setAttribute ( " name " , " Journalbook " + name ) ;
}
}
MyGUI : : ResourceManager : : getInstance ( ) . loadFromXmlNode ( copy , _file , _version ) ;
}
}
void WindowManager : : loadUserFonts ( )
{
mFontLoader - > loadTrueTypeFonts ( ) ;
@ -412,26 +299,7 @@ namespace MWGui
int w = MyGUI : : RenderManager : : getInstance ( ) . getViewSize ( ) . width ;
int h = MyGUI : : RenderManager : : getInstance ( ) . getViewSize ( ) . height ;
mTextColours . header = getTextColour ( " header " ) ;
mTextColours . normal = getTextColour ( " normal " ) ;
mTextColours . notify = getTextColour ( " notify " ) ;
mTextColours . link = getTextColour ( " link " ) ;
mTextColours . linkOver = getTextColour ( " link_over " ) ;
mTextColours . linkPressed = getTextColour ( " link_pressed " ) ;
mTextColours . answer = getTextColour ( " answer " ) ;
mTextColours . answerOver = getTextColour ( " answer_over " ) ;
mTextColours . answerPressed = getTextColour ( " answer_pressed " ) ;
mTextColours . journalLink = getTextColour ( " journal_link " ) ;
mTextColours . journalLinkOver = getTextColour ( " journal_link_over " ) ;
mTextColours . journalLinkPressed = getTextColour ( " journal_link_pressed " ) ;
mTextColours . journalTopic = getTextColour ( " journal_topic " ) ;
mTextColours . journalTopicOver = getTextColour ( " journal_topic_over " ) ;
mTextColours . journalTopicPressed = getTextColour ( " journal_topic_pressed " ) ;
mTextColours . loadColours ( ) ;
mDragAndDrop = new DragAndDrop ( ) ;
@ -608,17 +476,6 @@ namespace MWGui
mCharGen = new CharacterCreation ( mViewer - > getSceneData ( ) - > asGroup ( ) , mResourceSystem ) ;
// Setup player stats
for ( int i = 0 ; i < ESM : : Attribute : : Length ; + + i )
{
mPlayerAttributes . insert ( std : : make_pair ( ESM : : Attribute : : sAttributeIds [ i ] , MWMechanics : : AttributeValue ( ) ) ) ;
}
for ( int i = 0 ; i < ESM : : Skill : : Length ; + + i )
{
mPlayerSkillValues . insert ( std : : make_pair ( ESM : : Skill : : sSkillIds [ i ] , MWMechanics : : SkillValue ( ) ) ) ;
}
updatePinnedWindows ( ) ;
// Set up visibility
@ -627,7 +484,7 @@ namespace MWGui
int WindowManager : : getFontHeight ( ) const
{
return mFont Height;
return mFont Loader- > getFont Height( ) ;
}
void WindowManager : : setNewGame ( bool newgame )
@ -648,7 +505,6 @@ namespace MWGui
{
mKeyboardNavigation . reset ( ) ;
MyGUI : : ResourceManager : : getInstance ( ) . unregisterLoadXmlDelegate ( " Resource " ) ;
MyGUI : : LanguageManager : : getInstance ( ) . eventRequestTag . clear ( ) ;
MyGUI : : PointerManager : : getInstance ( ) . eventChangeMousePointer . clear ( ) ;
MyGUI : : InputManager : : getInstance ( ) . eventChangeKeyFocus . clear ( ) ;
@ -811,32 +667,7 @@ namespace MWGui
{
mStatsWindow - > setValue ( id , value ) ;
mCharGen - > setValue ( id , value ) ;
static const char * ids [ ] =
{
" AttribVal1 " , " AttribVal2 " , " AttribVal3 " , " AttribVal4 " , " AttribVal5 " ,
" AttribVal6 " , " AttribVal7 " , " AttribVal8 "
} ;
static ESM : : Attribute : : AttributeID attributes [ ] =
{
ESM : : Attribute : : Strength ,
ESM : : Attribute : : Intelligence ,
ESM : : Attribute : : Willpower ,
ESM : : Attribute : : Agility ,
ESM : : Attribute : : Speed ,
ESM : : Attribute : : Endurance ,
ESM : : Attribute : : Personality ,
ESM : : Attribute : : Luck
} ;
for ( size_t i = 0 ; i < sizeof ( ids ) / sizeof ( ids [ 0 ] ) ; + + i )
{
if ( id ! = ids [ i ] )
continue ;
mPlayerAttributes [ attributes [ i ] ] = value ;
break ;
}
}
void WindowManager : : setValue ( int parSkill , const MWMechanics : : SkillValue & value )
{
@ -844,7 +675,6 @@ namespace MWGui
/// allow custom skills.
mStatsWindow - > setValue ( static_cast < ESM : : Skill : : SkillEnum > ( parSkill ) , value ) ;
mCharGen - > setValue ( static_cast < ESM : : Skill : : SkillEnum > ( parSkill ) , value ) ;
mPlayerSkillValues [ parSkill ] = value ;
}
void WindowManager : : setValue ( const std : : string & id , const MWMechanics : : DynamicStat < float > & value )
@ -857,10 +687,6 @@ namespace MWGui
void WindowManager : : setValue ( const std : : string & id , const std : : string & value )
{
mStatsWindow - > setValue ( id , value ) ;
if ( id = = " name " )
mPlayerName = value ;
else if ( id = = " race " )
mPlayerRaceId = value ;
}
void WindowManager : : setValue ( const std : : string & id , int value )
@ -882,8 +708,6 @@ namespace MWGui
{
mStatsWindow - > configureSkills ( major , minor ) ;
mCharGen - > configureSkills ( major , minor ) ;
mPlayerMajorSkills = major ;
mPlayerMinorSkills = minor ;
}
void WindowManager : : updateSkillArea ( )
@ -1021,7 +845,7 @@ namespace MWGui
mHud - > setPlayerPos ( x , y , u , v ) ;
}
void WindowManager : : onFram e ( float frameDuration )
void WindowManager : : updat e ( float frameDuration )
{
bool gameRunning = MWBase : : Environment : : get ( ) . getStateManager ( ) - > getState ( ) ! =
MWBase : : StateManager : : State_NoGame ;
@ -1663,26 +1487,6 @@ namespace MWGui
return mGuiModes . back ( ) ;
}
std : : map < int , MWMechanics : : SkillValue > WindowManager : : getPlayerSkillValues ( )
{
return mPlayerSkillValues ;
}
std : : map < int , MWMechanics : : AttributeValue > WindowManager : : getPlayerAttributeValues ( )
{
return mPlayerAttributes ;
}
WindowManager : : SkillList WindowManager : : getPlayerMinorSkills ( )
{
return mPlayerMinorSkills ;
}
WindowManager : : SkillList WindowManager : : getPlayerMajorSkills ( )
{
return mPlayerMajorSkills ;
}
void WindowManager : : disallowMouse ( )
{
mInputBlocker - > setVisible ( true ) ;