Skip to content

Commit 2e6703e

Browse files
committed
Add new default font scaling method ResolutionFontSizeMethod_ClassicNoCeiling
1 parent f6eea97 commit 2e6703e

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

GeneralsMD/Code/GameEngine/Include/GameClient/GlobalLanguage.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ class GlobalLanguage : public SubsystemInterface
7070
enum ResolutionFontSizeMethod
7171
{
7272
ResolutionFontSizeMethod_Classic, // Uses the original scaling method. Scales poorly on wide screens and large resolutions.
73+
ResolutionFontSizeMethod_ClassicNoCeiling, // Uses the original scaling method, but without ceiling. Works ok for the original Game UI and with large resolutions. Scales poorly on very wide screens.
7374
ResolutionFontSizeMethod_Strict, // Uses a strict scaling method. Width and height are strictly bounded on upscales. Works well for accurate UI layouts and with large resolutions.
7475
ResolutionFontSizeMethod_Balanced, // Uses a balanced scaling method. Width and height are evenly weighted for upscales. Works well for the original Game UI and with large resolutions.
76+
77+
ResolutionFontSizeMethod_Default = ResolutionFontSizeMethod_ClassicNoCeiling,
7578
};
7679

7780
public:

GeneralsMD/Code/GameEngine/Source/GameClient/GlobalLanguage.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@
6464
//-----------------------------------------------------------------------------
6565
// DEFINES ////////////////////////////////////////////////////////////////////
6666
//-----------------------------------------------------------------------------
67-
GlobalLanguage *TheGlobalLanguageData = NULL; ///< The global language singalton
67+
GlobalLanguage *TheGlobalLanguageData = NULL; ///< The global language singleton
6868

6969
static const LookupListRec ResolutionFontSizeMethodNames[] =
7070
{
7171
{ "CLASSIC", GlobalLanguage::ResolutionFontSizeMethod_Classic },
72+
{ "CLASSIC_NO_CEILING", GlobalLanguage::ResolutionFontSizeMethod_ClassicNoCeiling },
7273
{ "STRICT", GlobalLanguage::ResolutionFontSizeMethod_Strict },
7374
{ "BALANCED", GlobalLanguage::ResolutionFontSizeMethod_Balanced },
7475
{ NULL, 0 }
@@ -129,7 +130,7 @@ GlobalLanguage::GlobalLanguage()
129130
m_militaryCaptionSpeed = 0;
130131
m_useHardWrap = FALSE;
131132
m_resolutionFontSizeAdjustment = 0.7f;
132-
m_resolutionFontSizeMethod = ResolutionFontSizeMethod_Balanced;
133+
m_resolutionFontSizeMethod = ResolutionFontSizeMethod_Default;
133134
m_militaryCaptionDelayMS = 750;
134135
//End Add
135136

@@ -206,6 +207,8 @@ float GlobalLanguage::getResolutionFontSizeAdjustment( void ) const
206207

207208
Int GlobalLanguage::adjustFontSize(Int theFontSize)
208209
{
210+
// TheSuperHackers @todo This function is called very often.
211+
// Therefore cache the adjustFactor on resolution change to not recompute it on every call.
209212
Real adjustFactor;
210213

211214
switch (m_resolutionFontSizeMethod)
@@ -214,13 +217,21 @@ Int GlobalLanguage::adjustFontSize(Int theFontSize)
214217
case ResolutionFontSizeMethod_Classic:
215218
{
216219
// TheSuperHackers @info The original font scaling for this game.
217-
// Can be useful for not breaking legacy Addons and Mods but scales poorly.
220+
// Useful for not breaking legacy Addons and Mods. Scales poorly with large resolutions.
218221
adjustFactor = TheDisplay->getWidth() / (Real)DEFAULT_DISPLAY_WIDTH;
219222
adjustFactor = 1.0f + (adjustFactor - 1.0f) * getResolutionFontSizeAdjustment();
220223
if (adjustFactor > 2.0f)
221224
adjustFactor = 2.0f;
222225
break;
223226
}
227+
case ResolutionFontSizeMethod_ClassicNoCeiling:
228+
{
229+
// TheSuperHackers @feature The original font scaling, but without ceiling.
230+
// Useful for not changing the original look of the game. Scales alright with large resolutions.
231+
adjustFactor = TheDisplay->getWidth() / (Real)DEFAULT_DISPLAY_WIDTH;
232+
adjustFactor = 1.0f + (adjustFactor - 1.0f) * getResolutionFontSizeAdjustment();
233+
break;
234+
}
224235
case ResolutionFontSizeMethod_Strict:
225236
{
226237
// TheSuperHackers @feature The strict method scales fonts based on the smallest screen

0 commit comments

Comments
 (0)