Skip to content

Commit b3e7544

Browse files
committed
bugfix(gui): fix resolution and zoom scaling of unit information
1 parent 06c6b3b commit b3e7544

File tree

6 files changed

+237
-329
lines changed

6 files changed

+237
-329
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ class Display : public SubsystemInterface
9696
virtual void dumpAssetUsage(const char* mapname) = 0;
9797
#endif
9898

99+
//---------------------------------------------------------------------------------------
100+
// Display scaling methods
101+
virtual Real getWidthScale( void );
102+
virtual Real getHeightScale( void );
103+
virtual Real getAspectRatioScale( void );
104+
99105
//---------------------------------------------------------------------------------------
100106
// View management
101107
virtual void attachView( View *view ); ///< Attach the given view to the world

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
#define DEFAULT_VIEW_ORIGIN_X 0
4444
#define DEFAULT_VIEW_ORIGIN_Y 0
4545

46+
#define DEFAULT_VIEW_MAX_ZOOM 1.3f
47+
#define DEFAULT_VIEW_MIN_ZOOM 0.2f
48+
4649
// FORWARD DECLARATIONS ///////////////////////////////////////////////////////////////////////////
4750
class Drawable;
4851
class ViewLocation;

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,32 @@ void Display::setHeight( UnsignedInt height )
202202

203203
}
204204

205+
// Display::getWidthScale =========================================================
206+
/** Return the ratio of the current display width relative to the default resolution */
207+
//=============================================================================
208+
Real Display::getWidthScale(void)
209+
{
210+
return INT_TO_REAL(m_width) / DEFAULT_DISPLAY_WIDTH;
211+
}
212+
213+
// Display::getHeightScale =========================================================
214+
/** Return the ratio of the current display height relative to the default resolution */
215+
//=============================================================================
216+
Real Display::getHeightScale(void)
217+
{
218+
return INT_TO_REAL(m_height) / DEFAULT_DISPLAY_HEIGHT;
219+
}
220+
221+
// Display::getAspectRatioScale =========================================================
222+
/** Return the ratio of the current display aspect ratio relative to the default aspect ratio */
223+
//=============================================================================
224+
Real Display::getAspectRatioScale(void)
225+
{
226+
Real baseAspectRatio = INT_TO_REAL(DEFAULT_DISPLAY_WIDTH) / DEFAULT_DISPLAY_HEIGHT;
227+
Real currentAspectRatio = INT_TO_REAL(m_width) / m_height;
228+
return currentAspectRatio / baseAspectRatio;
229+
}
230+
205231
//============================================================================
206232
// Display::playLogoMovie
207233
// minMovieLength is in milliseconds

0 commit comments

Comments
 (0)