move ScreenDimensions into a namespace
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "ScreenDimensions.h"
|
#include "ScreenDimensions.h"
|
||||||
#include "PrefsManager.h"
|
#include "PrefsManager.h"
|
||||||
|
#include "LuaManager.h"
|
||||||
|
|
||||||
ThemeMetric<float> THEME_SCREEN_WIDTH("Common","ScreenWidth");
|
static ThemeMetric<float> THEME_SCREEN_WIDTH("Common","ScreenWidth");
|
||||||
ThemeMetric<float> THEME_SCREEN_HEIGHT("Common","ScreenHeight");
|
static ThemeMetric<float> THEME_SCREEN_HEIGHT("Common","ScreenHeight");
|
||||||
|
|
||||||
//
|
//
|
||||||
// The theme's logical resolution specifies the minimum screen width
|
// The theme's logical resolution specifies the minimum screen width
|
||||||
@@ -21,7 +22,7 @@ ThemeMetric<float> THEME_SCREEN_HEIGHT("Common","ScreenHeight");
|
|||||||
*/
|
*/
|
||||||
#define THEME_NATIVE_ASPECT (THEME_SCREEN_WIDTH/THEME_SCREEN_HEIGHT)
|
#define THEME_NATIVE_ASPECT (THEME_SCREEN_WIDTH/THEME_SCREEN_HEIGHT)
|
||||||
|
|
||||||
float ScreenAspectRatio()
|
float ScreenDimensions::GetScreenAspectRatio()
|
||||||
{
|
{
|
||||||
float fAspect = PREFSMAN->m_fDisplayAspectRatio;
|
float fAspect = PREFSMAN->m_fDisplayAspectRatio;
|
||||||
if( fAspect == ASPECT_AUTO )
|
if( fAspect == ASPECT_AUTO )
|
||||||
@@ -37,14 +38,14 @@ float ScreenAspectRatio()
|
|||||||
return fAspect;
|
return fAspect;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ThemeAspectRatio()
|
float ScreenDimensions::GetThemeAspectRatio()
|
||||||
{
|
{
|
||||||
return THEME_NATIVE_ASPECT;
|
return THEME_NATIVE_ASPECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ScreenWidth()
|
float ScreenDimensions::GetScreenWidth()
|
||||||
{
|
{
|
||||||
float fAspect = ScreenAspectRatio();
|
float fAspect = GetScreenAspectRatio();
|
||||||
float fScale = 1;
|
float fScale = 1;
|
||||||
if( fAspect > THEME_NATIVE_ASPECT )
|
if( fAspect > THEME_NATIVE_ASPECT )
|
||||||
fScale = fAspect / THEME_NATIVE_ASPECT;
|
fScale = fAspect / THEME_NATIVE_ASPECT;
|
||||||
@@ -52,9 +53,9 @@ float ScreenWidth()
|
|||||||
return THEME_SCREEN_WIDTH * fScale;
|
return THEME_SCREEN_WIDTH * fScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ScreenHeight()
|
float ScreenDimensions::GetScreenHeight()
|
||||||
{
|
{
|
||||||
float fAspect = ScreenAspectRatio();
|
float fAspect = GetScreenAspectRatio();
|
||||||
float fScale = 1;
|
float fScale = 1;
|
||||||
if( fAspect < THEME_NATIVE_ASPECT )
|
if( fAspect < THEME_NATIVE_ASPECT )
|
||||||
fScale = THEME_NATIVE_ASPECT / fAspect;
|
fScale = THEME_NATIVE_ASPECT / fAspect;
|
||||||
@@ -62,6 +63,21 @@ float ScreenHeight()
|
|||||||
return THEME_SCREEN_HEIGHT * fScale;
|
return THEME_SCREEN_HEIGHT * fScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenDimensions::ReloadMetricsAndUpdateLua()
|
||||||
|
{
|
||||||
|
/* Important: explicitly refresh cached metrics that we use. */
|
||||||
|
THEME_SCREEN_WIDTH.Read();
|
||||||
|
THEME_SCREEN_HEIGHT.Read();
|
||||||
|
|
||||||
|
LUA->SetGlobal( "SCREEN_WIDTH", (int) SCREEN_WIDTH );
|
||||||
|
LUA->SetGlobal( "SCREEN_HEIGHT", (int) SCREEN_HEIGHT );
|
||||||
|
LUA->SetGlobal( "SCREEN_LEFT", (int) SCREEN_LEFT );
|
||||||
|
LUA->SetGlobal( "SCREEN_RIGHT", (int) SCREEN_RIGHT );
|
||||||
|
LUA->SetGlobal( "SCREEN_TOP", (int) SCREEN_TOP );
|
||||||
|
LUA->SetGlobal( "SCREEN_BOTTOM", (int) SCREEN_BOTTOM );
|
||||||
|
LUA->SetGlobal( "SCREEN_CENTER_X", (int) SCREEN_CENTER_X );
|
||||||
|
LUA->SetGlobal( "SCREEN_CENTER_Y", (int) SCREEN_CENTER_Y );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2001-2002 Chris Danford
|
* (c) 2001-2002 Chris Danford
|
||||||
|
|||||||
@@ -6,15 +6,17 @@
|
|||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
#include "ThemeMetric.h"
|
#include "ThemeMetric.h"
|
||||||
|
|
||||||
#define SCREEN_WIDTH ScreenWidth()
|
namespace ScreenDimensions
|
||||||
#define SCREEN_HEIGHT ScreenHeight()
|
{
|
||||||
float ScreenAspectRatio();
|
float GetScreenAspectRatio();
|
||||||
float ThemeAspectRatio();
|
float GetThemeAspectRatio();
|
||||||
float ScreenWidth();
|
float GetScreenWidth();
|
||||||
float ScreenHeight();
|
float GetScreenHeight();
|
||||||
|
void ReloadMetricsAndUpdateLua();
|
||||||
|
};
|
||||||
|
|
||||||
extern ThemeMetric<float> THEME_SCREEN_WIDTH;
|
#define SCREEN_WIDTH ScreenDimensions::GetScreenWidth()
|
||||||
extern ThemeMetric<float> THEME_SCREEN_HEIGHT;
|
#define SCREEN_HEIGHT ScreenDimensions::GetScreenHeight()
|
||||||
|
|
||||||
#define SCREEN_LEFT (0)
|
#define SCREEN_LEFT (0)
|
||||||
#define SCREEN_RIGHT (SCREEN_WIDTH)
|
#define SCREEN_RIGHT (SCREEN_WIDTH)
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ void StepMania::GetPreferredVideoModeParams( VideoModeParams ¶msOut )
|
|||||||
CommonMetrics::WINDOW_TITLE,
|
CommonMetrics::WINDOW_TITLE,
|
||||||
THEME->GetPathG("Common","window icon"),
|
THEME->GetPathG("Common","window icon"),
|
||||||
PREFSMAN->m_bPAL,
|
PREFSMAN->m_bPAL,
|
||||||
ScreenAspectRatio()
|
ScreenDimensions::GetScreenAspectRatio()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -349,17 +349,7 @@ void ThemeManager::UpdateLuaGlobals()
|
|||||||
LUA->ResetState();
|
LUA->ResetState();
|
||||||
|
|
||||||
/* Important: explicitly refresh cached metrics that we use. */
|
/* Important: explicitly refresh cached metrics that we use. */
|
||||||
THEME_SCREEN_WIDTH.Read();
|
ScreenDimensions::ReloadMetricsAndUpdateLua();
|
||||||
THEME_SCREEN_HEIGHT.Read();
|
|
||||||
|
|
||||||
LUA->SetGlobal( "SCREEN_WIDTH", (int) SCREEN_WIDTH );
|
|
||||||
LUA->SetGlobal( "SCREEN_HEIGHT", (int) SCREEN_HEIGHT );
|
|
||||||
LUA->SetGlobal( "SCREEN_LEFT", (int) SCREEN_LEFT );
|
|
||||||
LUA->SetGlobal( "SCREEN_RIGHT", (int) SCREEN_RIGHT );
|
|
||||||
LUA->SetGlobal( "SCREEN_TOP", (int) SCREEN_TOP );
|
|
||||||
LUA->SetGlobal( "SCREEN_BOTTOM", (int) SCREEN_BOTTOM );
|
|
||||||
LUA->SetGlobal( "SCREEN_CENTER_X", (int) SCREEN_CENTER_X );
|
|
||||||
LUA->SetGlobal( "SCREEN_CENTER_Y", (int) SCREEN_CENTER_Y );
|
|
||||||
|
|
||||||
RunLuaScripts( "*.lua" );
|
RunLuaScripts( "*.lua" );
|
||||||
}
|
}
|
||||||
@@ -952,8 +942,8 @@ public:
|
|||||||
static int GetPathG( T* p, lua_State *L ) { lua_pushstring(L, p->GetPathG(SArg(1),SArg(2)) ); return 1; }
|
static int GetPathG( T* p, lua_State *L ) { lua_pushstring(L, p->GetPathG(SArg(1),SArg(2)) ); return 1; }
|
||||||
static int GetPathB( T* p, lua_State *L ) { lua_pushstring(L, p->GetPathB(SArg(1),SArg(2)) ); return 1; }
|
static int GetPathB( T* p, lua_State *L ) { lua_pushstring(L, p->GetPathB(SArg(1),SArg(2)) ); return 1; }
|
||||||
static int GetPathS( T* p, lua_State *L ) { lua_pushstring(L, p->GetPathS(SArg(1),SArg(2)) ); return 1; }
|
static int GetPathS( T* p, lua_State *L ) { lua_pushstring(L, p->GetPathS(SArg(1),SArg(2)) ); return 1; }
|
||||||
static int GetScreenAspectRatio( T* p, lua_State *L ) { lua_pushnumber( L, ScreenAspectRatio() ); return 1; }
|
static int GetScreenAspectRatio( T* p, lua_State *L ) { lua_pushnumber( L, ScreenDimensions::GetScreenAspectRatio() ); return 1; }
|
||||||
static int GetThemeAspectRatio( T* p, lua_State *L ) { lua_pushnumber( L, ThemeAspectRatio() ); return 1; }
|
static int GetThemeAspectRatio( T* p, lua_State *L ) { lua_pushnumber( L, ScreenDimensions::GetThemeAspectRatio() ); return 1; }
|
||||||
|
|
||||||
static void Register(lua_State *L)
|
static void Register(lua_State *L)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user