support theme-specific program icon and window title (useful for non-SM products)

This commit is contained in:
Chris Danford
2003-05-25 20:19:01 +00:00
parent a75cd6e7b1
commit 6b63ef50f9
11 changed files with 89 additions and 66 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 967 B

+1
View File
@@ -17,6 +17,7 @@
ColorP1=0.4,1.0,0.8,1 // sea green
ColorP2=1.0,0.5,0.2,1 // orange
InitialScreen=ScreenCompany
WindowTitle=StepMania
[Notes]
DefaultScrollDirection=0
+2 -2
View File
@@ -69,13 +69,13 @@ class RageDisplay
friend class RageTexture;
public:
RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync );
RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile );
~RageDisplay();
void Update(float fDeltaTime);
bool IsSoftwareRenderer();
bool SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync );
bool SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile );
/* Call this when the resolution has been changed externally: */
void ResolutionChanged();
+26 -13
View File
@@ -28,6 +28,8 @@
#include "SDL_video.h" // for SDL_Surface
#include "SDL_utils.h"
#include "Dxerr8.h"
#include "SDL_image.h" // for setting icon
#include "SDL_rotozoom.h" // for setting icon
#include "arch/arch.h"
@@ -166,7 +168,7 @@ const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = {
};
RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync )
RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
{
LOG->Trace( "RageDisplay::RageDisplay()" );
@@ -242,7 +244,7 @@ RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rat
}
SetVideoMode( windowed, width, height, bpp, rate, vsync );
SetVideoMode( windowed, width, height, bpp, rate, vsync, sWindowTitle, sIconFile );
}
void RageDisplay::Update(float fDeltaTime)
@@ -350,17 +352,29 @@ HWND GetHwnd()
}
#endif
bool IsWin98()
{
OSVERSIONINFO version;
version.dwOSVersionInfoSize=sizeof(version);
GetVersionEx(&version);
return version.dwMajorVersion == 4;
}
/* Set the video mode. */
bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync )
bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
{
/* Set SDL window title and icon -before- creating the window */
SDL_WM_SetCaption(sWindowTitle, "");
SDL_Surface *srf = IMG_Load(sIconFile);
SDL_SetColorKey( srf, SDL_SRCCOLORKEY, SDL_MapRGB(srf->format, 0xFF, 0, 0xFF));
/* Windows icons are 32x32 and SDL can't resize them for us, which
* causes mask corruption. (Actually, the above icon *is* 32x32;
* this is here just in case it changes.) */
ConvertSDLSurface(srf, srf->w, srf->h,
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
zoomSurface(srf, 32, 32);
SDL_SetAlpha( srf, SDL_SRCALPHA, SDL_ALPHA_OPAQUE );
SDL_WM_SetIcon(srf, NULL /* derive from alpha */);
SDL_FreeSurface(srf);
// HACK: On Windows 98, we can't call SDL_SetVideoMode while D3D is full screen.
// It will result in "SDL_SetVideoMode failed: DirectDraw2::CreateSurface(PRIMARY):
// Not in exclusive access mode". So, we'll Reset the D3D device, then resize the
@@ -486,7 +500,7 @@ int RageDisplay::GetMaxTextureSize() const
void RageDisplay::BeginFrame()
{
if( g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET )
SetVideoMode( g_Windowed, g_CurrentWidth, g_CurrentHeight, g_CurrentBPP, 0, 0 );
SetVideoMode( g_Windowed, g_CurrentWidth, g_CurrentHeight, g_CurrentBPP, 0, 0, "", "" ); // FIXME: preserve prefs
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 );
@@ -907,7 +921,6 @@ void RageDisplay::SetAlphaTest( bool b )
g_pd3dDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATER );
}
RageMatrix RageDisplay::GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf )
{
// D3DXMatrixOrthoOffCenterRH
@@ -917,4 +930,4 @@ RageMatrix RageDisplay::GetOrthoMatrix( float l, float r, float b, float t, floa
0, 0, 1/(zn-zf), 0,
(l+r)/(l-r), (t+b)/(b-t), zn/(zn-zf), 1 );
return m;
}
}
+4 -4
View File
@@ -106,13 +106,13 @@ void GetGLExtensions(set<string> &ext)
ext.insert(lst[i]);
}
RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync )
RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
{
LOG->Trace( "RageDisplay::RageDisplay()" );
wind = MakeLowLevelWindow();
SetVideoMode( windowed, width, height, bpp, rate, vsync );
SetVideoMode( windowed, width, height, bpp, rate, vsync, sWindowTitle, sIconFile );
// Log driver details
LOG->Info("OGL Vendor: %s", glGetString(GL_VENDOR));
@@ -258,10 +258,10 @@ void RageDisplay::ResolutionChanged()
/* Set the video mode. In some cases, changing the video mode will reset
* the rendering context; returns true if we need to reload textures. */
bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync )
bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
{
// LOG->Trace( "RageDisplay::SetVideoMode( %d, %d, %d, %d, %d, %d )", windowed, width, height, bpp, rate, vsync );
bool NewOpenGLContext = wind->SetVideoMode( windowed, width, height, bpp, rate, vsync );
bool NewOpenGLContext = wind->SetVideoMode( windowed, width, height, bpp, rate, vsync, sWindowTitle, sIconFile );
if(NewOpenGLContext)
{
+6 -36
View File
@@ -95,8 +95,9 @@ void ApplyGraphicOptions()
PREFSMAN->m_iDisplayHeight,
PREFSMAN->m_iDisplayColorDepth,
PREFSMAN->m_iRefreshRate,
PREFSMAN->m_bVsync );
PREFSMAN->m_bVsync,
THEME->GetMetric("Common","WindowTitle"),
THEME->GetPathToG("Common window icon") );
bNeedReload |= TEXTUREMAN->SetPrefs(
PREFSMAN->m_iTextureColorDepth,
PREFSMAN->m_bDelayedTextureDelete,
@@ -145,30 +146,6 @@ void ResetGame()
}
static void GameLoop();
#include "SDL_utils.h"
#include "SDL_image.h"
#include "SDL_rotozoom.h"
#include "StepMania.xpm" /* icon */
static void SetIcon()
{
if(!SDL_WasInit(SDL_INIT_VIDEO))
return;
SDL_Surface *srf = IMG_ReadXPMFromArray(icon);
SDL_SetColorKey( srf, SDL_SRCCOLORKEY, SDL_MapRGB(srf->format, 0xFF, 0, 0xFF));
/* Windows icons are 32x32 and SDL can't resize them for us, which
* causes mask corruption. (Actually, the above icon *is* 32x32;
* this is here just in case it changes.) */
ConvertSDLSurface(srf, srf->w, srf->h,
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
zoomSurface(srf, 32, 32);
SDL_SetAlpha( srf, SDL_SRCALPHA, SDL_ALPHA_OPAQUE );
SDL_WM_SetIcon(srf, NULL /* derive from alpha */);
SDL_FreeSurface(srf);
}
static bool ChangeAppPri()
{
@@ -259,11 +236,6 @@ int main(int argc, char* argv[])
LoadingWindow *loading_window = MakeLoadingWindow();
/* We might be using SDL, so set generic window properties (icon and caption).
* Be careful; we might not have an SDL window at all. */
SDL_WM_SetCaption("StepMania", "StepMania");
SetIcon();
loading_window->Paint();
// changed to use time. GetTimeSinceStart is silly because it always return 0! -Chris
@@ -299,7 +271,9 @@ int main(int argc, char* argv[])
PREFSMAN->m_iDisplayHeight,
PREFSMAN->m_iDisplayColorDepth,
PREFSMAN->m_iRefreshRate,
PREFSMAN->m_bVsync );
PREFSMAN->m_bVsync,
THEME->GetMetric("Common","WindowTitle"),
THEME->GetPathToG("Common window icon") );
TEXTUREMAN = new RageTextureManager();
TEXTUREMAN->SetPrefs(
PREFSMAN->m_iTextureColorDepth,
@@ -310,10 +284,6 @@ int main(int argc, char* argv[])
SDL_EventState(SDL_QUIT, SDL_ENABLE);
SDL_EventState(SDL_ACTIVEEVENT, SDL_ENABLE);
/* We might have a new window, so let's make sure window properties are still set. */
SDL_WM_SetCaption("StepMania", "StepMania");
SetIcon();
/* Grab the window manager specific information */
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
@@ -2,8 +2,10 @@
#include "SDL_utils.h"
#include "SDL_image.h"
#include "SDL_rotozoom.h"
#include "LoadingWindow_SDL.h"
#include "loading.xpm"
#include "StepMania.xpm" /* icon */
LoadingWindow_SDL::LoadingWindow_SDL()
{
@@ -11,23 +13,37 @@ LoadingWindow_SDL::LoadingWindow_SDL()
if( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 )
RageException::Throw( "Couldn't initialize SDL: %s\n", SDL_GetError() );
/* Load the BMP file into a surface */
/* Set window title and icon */
SDL_WM_SetCaption("StepMania", "StepMania");
SDL_Surface *srf = IMG_ReadXPMFromArray(icon);
SDL_SetColorKey( srf, SDL_SRCCOLORKEY, SDL_MapRGB(srf->format, 0xFF, 0, 0xFF));
/* Windows icons are 32x32 and SDL can't resize them for us, which
* causes mask corruption. (Actually, the above icon *is* 32x32;
* this is here just in case it changes.) */
ConvertSDLSurface(srf, srf->w, srf->h,
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
zoomSurface(srf, 32, 32);
SDL_SetAlpha( srf, SDL_SRCALPHA, SDL_ALPHA_OPAQUE );
SDL_WM_SetIcon(srf, NULL /* derive from alpha */);
SDL_FreeSurface(srf);
/* Load the BMP - we need it's dimensions */
SDL_Surface *image = IMG_ReadXPMFromArray(loading);
if( image == NULL )
RageException::Throw("Couldn't load loading.bmp: %s\n",SDL_GetError());
/* Initialize the display in a 640x480 16-bit mode */
/* Initialize the window */
loading_screen = SDL_SetVideoMode(image->w, image->h, 16, SDL_SWSURFACE|SDL_ANYFORMAT|SDL_NOFRAME);
if( loading_screen == NULL )
RageException::Throw( "Couldn't initialize loading window: %s\n", SDL_GetError() );
/* Blit onto the screen surface */
SDL_BlitSurface(image, NULL, loading_screen, NULL);
/* Free the allocated BMP surface */
SDL_FreeSurface(image);
}
LoadingWindow_SDL::~LoadingWindow_SDL()
@@ -13,7 +13,7 @@ public:
/* Set the video mode as close to the requested settings as possible. They're
* hints only; it's better to get the wrong mode than to bail out. */
virtual bool SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync ) = 0;
virtual bool SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile ) = 0;
virtual void SwapBuffers() = 0;
virtual void Update(float fDeltaTime) { }
@@ -1,6 +1,7 @@
#include "global.h"
#include "LowLevelWindow_SDL.h"
#include "SDL_image.h" // for setting icon
#include "SDL_rotozoom.h" // for setting icon
#include "RageLog.h"
#include "RageDisplay.h" // for REFRESH_DEFAULT
@@ -23,7 +24,7 @@ void *LowLevelWindow_SDL::GetProcAddress(CString s)
return SDL_GL_GetProcAddress(s);
}
bool LowLevelWindow_SDL::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync )
bool LowLevelWindow_SDL::SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
{
SDL_QuitSubSystem(SDL_INIT_VIDEO);
@@ -40,6 +41,26 @@ bool LowLevelWindow_SDL::SetVideoMode( bool windowed, int width, int height, int
SDL_InitSubSystem(SDL_INIT_VIDEO);
/* Set SDL window title and icon -before- creating the window */
SDL_WM_SetCaption(sWindowTitle, "");
SDL_Surface *srf = IMG_Load(sIconFile);
SDL_SetColorKey( srf, SDL_SRCCOLORKEY, SDL_MapRGB(srf->format, 0xFF, 0, 0xFF));
/* Windows icons are 32x32 and SDL can't resize them for us, which
* causes mask corruption. (Actually, the above icon *is* 32x32;
* this is here just in case it changes.) */
ConvertSDLSurface(srf, srf->w, srf->h,
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
zoomSurface(srf, 32, 32);
SDL_SetAlpha( srf, SDL_SRCALPHA, SDL_ALPHA_OPAQUE );
SDL_WM_SetIcon(srf, NULL /* derive from alpha */);
SDL_FreeSurface(srf);
Windowed = false;
int flags = SDL_RESIZABLE | SDL_OPENGL; // | SDL_DOUBLEBUF; // no need for DirectDraw to be double-buffered
@@ -152,7 +173,9 @@ void LowLevelWindow_SDL::Update(float fDeltaTime)
DISPLAY->GetHeight(),
DISPLAY->GetBPP(),
0,
0 );
0,
"",
"" ); // FIXME: preserve prefs
}
break;
}
@@ -12,7 +12,7 @@ public:
LowLevelWindow_SDL();
~LowLevelWindow_SDL();
void *GetProcAddress(CString s);
bool SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync );
bool SetVideoMode( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile );
void SwapBuffers();
void Update(float fDeltaTime);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB