Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Generals/Code/GameEngine/Include/Common/UserPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class OptionPreferences : public UserPreferences

Int getSystemTimeFontSize(void);
Int getGameTimeFontSize(void);

Real getResolutionFontAdjustment(void);
};

//-----------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions Generals/Code/GameEngine/Include/GameClient/GlobalLanguage.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ class GlobalLanguage : public SubsystemInterface
FontDesc m_creditsNormalFont;

Real m_resolutionFontSizeAdjustment;
Real m_userResolutionFontSizeAdjustment;

//UnicodeString m_unicodeFontNameUStr;

float getResolutionFontSizeAdjustment() const;
Int adjustFontSize(Int theFontSize); // Adjusts font size for resolution. jba.

typedef std::list<AsciiString> StringList; // Used for our font file names that we want to load
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include "GameClient/IMEManager.h"
#include "GameClient/ShellHooks.h"
#include "GameClient/GUICallbacks.h"
#include "GameClient/GlobalLanguage.h"
#include "GameNetwork/FirewallHelper.h"
#include "GameNetwork/IPEnumeration.h"
#include "GameNetwork/GameSpyOverlay.h"
Expand Down Expand Up @@ -784,6 +785,20 @@ Int OptionPreferences::getGameTimeFontSize(void)
return fontSize;
}

Real OptionPreferences::getResolutionFontAdjustment(void)
{
OptionPreferences::const_iterator it = find("ResolutionFontAdjustment");
if (it == end())
return -1.0f;

Real fontScale = (Real)atof(it->second.str()) / 100.0f;
if (fontScale < 0.0f)
{
fontScale = -1.0f;
}
return fontScale;
}

static OptionPreferences *pref = NULL;

static void setDefaults( void )
Expand Down Expand Up @@ -1294,6 +1309,17 @@ static void saveOptions( void )
TheInGameUI->refreshGameTimeResources();
}

//-------------------------------------------------------------------------------------------------
// Set User Font Scaling Percentage
val = pref->getResolutionFontAdjustment() * 100.0f; // TheSuperHackers @todo replace with options input when applicable
if (val >= 0 || val == -100)
{
AsciiString prefString;
prefString.format("%d", REAL_TO_INT( val ) );
(*pref)["ResolutionFontAdjustment"] = prefString;
TheGlobalLanguageData->m_userResolutionFontSizeAdjustment = (Real)val / 100.0f;
}

//-------------------------------------------------------------------------------------------------
// Resolution
//
Expand Down
19 changes: 17 additions & 2 deletions Generals/Code/GameEngine/Source/GameClient/GlobalLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@

#include "Common/INI.h"
#include "Common/Registry.h"
#include "GameClient/GlobalLanguage.h"
#include "Common/FileSystem.h"
#include "Common/UserPreferences.h"

#include "GameClient/GlobalLanguage.h"

//-----------------------------------------------------------------------------
// DEFINES ////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -117,6 +119,8 @@ GlobalLanguage::GlobalLanguage()
m_useHardWrap = FALSE;
m_resolutionFontSizeAdjustment = 0.7f;
//End Add

m_userResolutionFontSizeAdjustment = -1.0f;
}

GlobalLanguage::~GlobalLanguage()
Expand Down Expand Up @@ -165,6 +169,9 @@ void GlobalLanguage::init( void )
++it;
}

// override values with user preferences
OptionPreferences optionPref;
m_userResolutionFontSizeAdjustment = optionPref.getResolutionFontAdjustment();

}
void GlobalLanguage::reset( void ) {}
Expand All @@ -185,10 +192,18 @@ void GlobalLanguage::parseFontFileName( INI *ini, void * instance, void *store,
monkey->m_localFonts.push_front(asciiString);
}

float GlobalLanguage::getResolutionFontSizeAdjustment( void ) const
{
if (m_userResolutionFontSizeAdjustment >= 0.0f)
return m_userResolutionFontSizeAdjustment;
else
return m_resolutionFontSizeAdjustment;
}

Int GlobalLanguage::adjustFontSize(Int theFontSize)
{
Real adjustFactor = TheGlobalData->m_xResolution / (Real)DEFAULT_DISPLAY_WIDTH;
adjustFactor = 1.0f + (adjustFactor-1.0f) * m_resolutionFontSizeAdjustment;
adjustFactor = 1.0f + (adjustFactor-1.0f) * getResolutionFontSizeAdjustment();
if (adjustFactor<1.0f) adjustFactor = 1.0f;
if (adjustFactor>2.0f) adjustFactor = 2.0f;
Int pointSize = REAL_TO_INT_FLOOR(theFontSize*adjustFactor);
Expand Down
2 changes: 2 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class OptionPreferences : public UserPreferences

Int getSystemTimeFontSize(void);
Int getGameTimeFontSize(void);

Real getResolutionFontAdjustment(void);
};

//-----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ class GlobalLanguage : public SubsystemInterface
FontDesc m_creditsNormalFont;

Real m_resolutionFontSizeAdjustment;
Real m_userResolutionFontSizeAdjustment;

//UnicodeString m_unicodeFontNameUStr;

float getResolutionFontSizeAdjustment() const;
Int adjustFontSize(Int theFontSize); // Adjusts font size for resolution. jba.

typedef std::list<AsciiString> StringList; // Used for our font file names that we want to load
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include "GameClient/IMEManager.h"
#include "GameClient/ShellHooks.h"
#include "GameClient/GUICallbacks.h"
#include "GameClient/GlobalLanguage.h"
#include "GameNetwork/FirewallHelper.h"
#include "GameNetwork/IPEnumeration.h"
#include "GameNetwork/GameSpyOverlay.h"
Expand Down Expand Up @@ -828,6 +829,20 @@ Int OptionPreferences::getGameTimeFontSize(void)
return fontSize;
}

Real OptionPreferences::getResolutionFontAdjustment(void)
{
OptionPreferences::const_iterator it = find("ResolutionFontAdjustment");
if (it == end())
return -1.0f;

Real fontScale = (Real)atof(it->second.str()) / 100.0f;
if (fontScale < 0.0f)
{
fontScale = -1.0f;
}
return fontScale;
}

static OptionPreferences *pref = NULL;

static void setDefaults( void )
Expand Down Expand Up @@ -1354,6 +1369,17 @@ static void saveOptions( void )
TheInGameUI->refreshGameTimeResources();
}

//-------------------------------------------------------------------------------------------------
// Set User Font Scaling Percentage
val = pref->getResolutionFontAdjustment() * 100.0f; // TheSuperHackers @todo replace with options input when applicable
if (val >= 0 || val == -100)
{
AsciiString prefString;
prefString.format("%d", REAL_TO_INT( val ) );
(*pref)["ResolutionFontAdjustment"] = prefString;
TheGlobalLanguageData->m_userResolutionFontSizeAdjustment = (Real)val / 100.0f;
}

//-------------------------------------------------------------------------------------------------
// Resolution
//
Expand Down
19 changes: 17 additions & 2 deletions GeneralsMD/Code/GameEngine/Source/GameClient/GlobalLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@

#include "Common/INI.h"
#include "Common/Registry.h"
#include "GameClient/GlobalLanguage.h"
#include "Common/FileSystem.h"
#include "Common/UserPreferences.h"

#include "GameClient/GlobalLanguage.h"

//-----------------------------------------------------------------------------
// DEFINES ////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -119,6 +121,8 @@ GlobalLanguage::GlobalLanguage()
m_resolutionFontSizeAdjustment = 0.7f;
m_militaryCaptionDelayMS = 750;
//End Add

m_userResolutionFontSizeAdjustment = -1.0f;
}

GlobalLanguage::~GlobalLanguage()
Expand Down Expand Up @@ -169,6 +173,9 @@ void GlobalLanguage::init( void )
++it;
}

// override values with user preferences
OptionPreferences optionPref;
m_userResolutionFontSizeAdjustment = optionPref.getResolutionFontAdjustment();

}
void GlobalLanguage::reset( void ) {}
Expand All @@ -189,10 +196,18 @@ void GlobalLanguage::parseFontFileName( INI *ini, void * instance, void *store,
monkey->m_localFonts.push_front(asciiString);
}

float GlobalLanguage::getResolutionFontSizeAdjustment( void ) const
{
if (m_userResolutionFontSizeAdjustment >= 0.0f)
return m_userResolutionFontSizeAdjustment;
else
return m_resolutionFontSizeAdjustment;
}

Int GlobalLanguage::adjustFontSize(Int theFontSize)
{
Real adjustFactor = TheGlobalData->m_xResolution / (Real)DEFAULT_DISPLAY_WIDTH;
adjustFactor = 1.0f + (adjustFactor-1.0f) * m_resolutionFontSizeAdjustment;
adjustFactor = 1.0f + (adjustFactor-1.0f) * getResolutionFontSizeAdjustment();
if (adjustFactor<1.0f) adjustFactor = 1.0f;
if (adjustFactor>2.0f) adjustFactor = 2.0f;
Int pointSize = REAL_TO_INT_FLOOR(theFontSize*adjustFactor);
Expand Down
Loading