From 4753be45fcf14595954c0aec26bf0fd53a88394f Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Sat, 19 May 2012 08:44:58 +0000 Subject: [PATCH] - The SBarInfo AspectRatio command should treat 17:10 ratios as 16:10 for better compatibility with existing status bars unless the statusbar explicitly checks for it. SVN r3663 (trunk) --- src/g_shared/sbarinfo_commands.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index c044f0525..aafa228d5 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -1748,13 +1748,19 @@ class CommandAspectRatio : public SBarInfoCommandFlowControl ratio = ASPECTRATIO_5_4; else sc.ScriptError("Unkown aspect ratio: %s", sc.String); + + // Make this ratio known and map to itself + // In the future, should another aspect ratio get added, you'd want + // to also make any wider ratio remap to this one if suitable. + ratioMap[ratio] = ratio; + SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets); } void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) { SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); - SetTruth(CheckRatio(screen->GetWidth(), screen->GetHeight()) == ratio, block, statusBar); + SetTruth(ratioMap[CheckRatio(screen->GetWidth(), screen->GetHeight())] == ratio, block, statusBar); } protected: enum Ratio @@ -1765,9 +1771,14 @@ class CommandAspectRatio : public SBarInfoCommandFlowControl ASPECTRATIO_17_10 = 3, ASPECTRATIO_5_4 = 4 }; + // Since the number of aspect ratios may change at any time, we should + // track what aspect ratios the statusbar supports and use the widest + // or tallest available ratio. + static Ratio ratioMap[5]; - Ratio ratio; + Ratio ratio; }; +CommandAspectRatio::Ratio CommandAspectRatio::ratioMap[5] = {ASPECTRATIO_4_3,ASPECTRATIO_16_9,ASPECTRATIO_16_10,ASPECTRATIO_16_10,ASPECTRATIO_5_4}; ////////////////////////////////////////////////////////////////////////////////