CHANGE: Maximize button no longer toggles fullscreen.
This commit is contained in:
+40
-40
@@ -54,7 +54,6 @@ HINSTANCE g_hInstance; // The Handle to Window Instance
|
|||||||
const DWORD g_dwWindowStyle = WS_VISIBLE|WS_POPUP|WS_CAPTION|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_SYSMENU;
|
const DWORD g_dwWindowStyle = WS_VISIBLE|WS_POPUP|WS_CAPTION|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_SYSMENU;
|
||||||
|
|
||||||
|
|
||||||
BOOL g_bFullscreen = FALSE; // Whether app is fullscreen (or windowed)
|
|
||||||
BOOL g_bIsActive = FALSE; // Whether the focus is on our app
|
BOOL g_bIsActive = FALSE; // Whether the focus is on our app
|
||||||
|
|
||||||
|
|
||||||
@@ -70,7 +69,6 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
|
|||||||
void Update(); // Update the game logic
|
void Update(); // Update the game logic
|
||||||
void Render(); // Render a frame
|
void Render(); // Render a frame
|
||||||
void ShowFrame(); // Display the contents of the back buffer to the screen
|
void ShowFrame(); // Display the contents of the back buffer to the screen
|
||||||
void SetFullscreen( BOOL bFullscreen ); // Switch between fullscreen and windowed modes.
|
|
||||||
|
|
||||||
// Functions that work with game objects
|
// Functions that work with game objects
|
||||||
HRESULT CreateObjects( HWND hWnd ); // allocate and initialize game objects
|
HRESULT CreateObjects( HWND hWnd ); // allocate and initialize game objects
|
||||||
@@ -78,6 +76,8 @@ HRESULT InvalidateObjects(); // invalidate game objects before a display mode
|
|||||||
HRESULT RestoreObjects(); // restore game objects after a display mode change
|
HRESULT RestoreObjects(); // restore game objects after a display mode change
|
||||||
VOID DestroyObjects(); // deallocate game objects when we're done with them
|
VOID DestroyObjects(); // deallocate game objects when we're done with them
|
||||||
|
|
||||||
|
BOOL SwitchDisplayMode( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP );
|
||||||
|
|
||||||
BOOL WeAreAlone( LPSTR szName );
|
BOOL WeAreAlone( LPSTR szName );
|
||||||
|
|
||||||
|
|
||||||
@@ -92,20 +92,21 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow )
|
|||||||
RageError( "StepMania is already running!" );
|
RageError( "StepMania is already running!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure the current directory is the root program directory
|
||||||
if( !DoesFileExist("Songs") )
|
if( !DoesFileExist("Songs") )
|
||||||
{
|
{
|
||||||
// change dir to path of the execuctable
|
// change dir to path of the execuctable
|
||||||
TCHAR szFullAppPath[MAX_PATH];
|
TCHAR szFullAppPath[MAX_PATH];
|
||||||
GetModuleFileName(NULL, szFullAppPath, MAX_PATH);
|
GetModuleFileName(NULL, szFullAppPath, MAX_PATH);
|
||||||
|
|
||||||
|
// strip off executable name
|
||||||
LPSTR pLastBackslash = strrchr(szFullAppPath, '\\');
|
LPSTR pLastBackslash = strrchr(szFullAppPath, '\\');
|
||||||
*pLastBackslash = '\0'; // terminate the string
|
*pLastBackslash = '\0'; // terminate the string
|
||||||
//MessageBox(NULL, szFullAppPath, szFullAppPath, MB_OK);
|
|
||||||
SetCurrentDirectory(szFullAppPath);
|
SetCurrentDirectory(szFullAppPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CoInitialize (NULL); // Initialize COM
|
CoInitialize (NULL); // Initialize COM
|
||||||
|
|
||||||
// Register the window class
|
// Register the window class
|
||||||
@@ -210,9 +211,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
// Check to see if we are losing our window...
|
// Check to see if we are losing our window...
|
||||||
if( SIZE_MAXIMIZED == wParam)
|
if( SIZE_MAXHIDE==wParam || SIZE_MINIMIZED==wParam )
|
||||||
MessageBeep( MB_OK );
|
|
||||||
else if( SIZE_MAXHIDE==wParam || SIZE_MINIMIZED==wParam )
|
|
||||||
g_bIsActive = FALSE;
|
g_bIsActive = FALSE;
|
||||||
else
|
else
|
||||||
g_bIsActive = TRUE;
|
g_bIsActive = TRUE;
|
||||||
@@ -220,7 +219,9 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|||||||
|
|
||||||
case WM_GETMINMAXINFO:
|
case WM_GETMINMAXINFO:
|
||||||
{
|
{
|
||||||
// don't allow the window to be resized smaller than the screen resolution
|
// Don't allow the window to be resized smaller than the screen resolution.
|
||||||
|
// This should snap to multiples of the screen size two!
|
||||||
|
|
||||||
RECT rcWnd;
|
RECT rcWnd;
|
||||||
SetRect( &rcWnd, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
|
SetRect( &rcWnd, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
|
||||||
DWORD dwWindowStyle = GetWindowLong( g_hWndMain, GWL_STYLE );
|
DWORD dwWindowStyle = GetWindowLong( g_hWndMain, GWL_STYLE );
|
||||||
@@ -233,7 +234,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|||||||
|
|
||||||
case WM_SETCURSOR:
|
case WM_SETCURSOR:
|
||||||
// Turn off Windows cursor in fullscreen mode
|
// Turn off Windows cursor in fullscreen mode
|
||||||
if( g_bFullscreen )
|
if( !SCREEN->IsWindowed() )
|
||||||
{
|
{
|
||||||
SetCursor( NULL );
|
SetCursor( NULL );
|
||||||
return TRUE; // prevent Windows from setting the cursor
|
return TRUE; // prevent Windows from setting the cursor
|
||||||
@@ -250,8 +251,8 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|||||||
case SC_MONITORPOWER:
|
case SC_MONITORPOWER:
|
||||||
return 1;
|
return 1;
|
||||||
case SC_MAXIMIZE:
|
case SC_MAXIMIZE:
|
||||||
SendMessage( g_hWndMain, WM_COMMAND, IDM_TOGGLEFULLSCREEN, 0 );
|
//SendMessage( g_hWndMain, WM_COMMAND, IDM_TOGGLEFULLSCREEN, 0 );
|
||||||
return 1;
|
//return 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -261,28 +262,18 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|||||||
switch( LOWORD(wParam) )
|
switch( LOWORD(wParam) )
|
||||||
{
|
{
|
||||||
case IDM_TOGGLEFULLSCREEN:
|
case IDM_TOGGLEFULLSCREEN:
|
||||||
SetFullscreen( !g_bFullscreen );
|
SwitchDisplayMode( !SCREEN->IsWindowed(), SCREEN_WIDTH, SCREEN_HEIGHT, 16 );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case IDM_WINDOWED:
|
|
||||||
SetFullscreen( FALSE );
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case IDM_EXIT:
|
case IDM_EXIT:
|
||||||
// Recieved key/menu command to exit app
|
// Recieved key/menu command to exit app
|
||||||
SendMessage( hWnd, WM_CLOSE, 0, 0 );
|
SendMessage( hWnd, WM_CLOSE, 0, 0 );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case IDM_PADS:
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_NCHITTEST:
|
case WM_NCHITTEST:
|
||||||
// Prevent the user from selecting the menu in fullscreen mode
|
// Prevent the user from selecting the menu in fullscreen mode
|
||||||
if( g_bFullscreen )
|
if( !SCREEN->IsWindowed() )
|
||||||
return HTCLIENT;
|
return HTCLIENT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -312,7 +303,7 @@ HRESULT CreateObjects( HWND hWnd )
|
|||||||
|
|
||||||
RageLogStart();
|
RageLogStart();
|
||||||
|
|
||||||
SCREEN = new RageScreen( hWnd );
|
SCREEN = new RageScreen( hWnd, true, SCREEN_WIDTH, SCREEN_HEIGHT, 16 );
|
||||||
TM = new RageTextureManager( SCREEN );
|
TM = new RageTextureManager( SCREEN );
|
||||||
THEME = new ThemeManager;
|
THEME = new ThemeManager;
|
||||||
WM = new WindowManager;
|
WM = new WindowManager;
|
||||||
@@ -334,8 +325,13 @@ HRESULT CreateObjects( HWND hWnd )
|
|||||||
BringWindowToTop( hWnd );
|
BringWindowToTop( hWnd );
|
||||||
SetForegroundWindow( hWnd );
|
SetForegroundWindow( hWnd );
|
||||||
|
|
||||||
bool bGoFullScreen = GAMEINFO->m_GameOptions.m_bIsFullscreen;
|
GameOptions &go = GAMEINFO->m_GameOptions;
|
||||||
SetFullscreen( GAMEINFO->m_GameOptions.m_bIsFullscreen );
|
SwitchDisplayMode(
|
||||||
|
go.m_bWindowed,
|
||||||
|
go.m_iResolution,
|
||||||
|
go.m_iResolution==640 ? 480 : 240,
|
||||||
|
go.m_iDisplayColor
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//WM->SetNewWindow( new WindowSandbox );
|
//WM->SetNewWindow( new WindowSandbox );
|
||||||
@@ -383,13 +379,15 @@ HRESULT RestoreObjects()
|
|||||||
|
|
||||||
// Set window size
|
// Set window size
|
||||||
RECT rcWnd;
|
RECT rcWnd;
|
||||||
if( g_bFullscreen )
|
if( SCREEN->IsWindowed() )
|
||||||
SetRect( &rcWnd, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) );
|
|
||||||
else // if( !g_bFullscreen )
|
|
||||||
{
|
{
|
||||||
SetRect( &rcWnd, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
|
SetRect( &rcWnd, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
|
||||||
AdjustWindowRect( &rcWnd, g_dwWindowStyle, FALSE );
|
AdjustWindowRect( &rcWnd, g_dwWindowStyle, FALSE );
|
||||||
}
|
}
|
||||||
|
else // if fullscreen
|
||||||
|
{
|
||||||
|
SetRect( &rcWnd, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) );
|
||||||
|
}
|
||||||
|
|
||||||
// Bring the window to the foreground
|
// Bring the window to the foreground
|
||||||
SetWindowPos( g_hWndMain,
|
SetWindowPos( g_hWndMain,
|
||||||
@@ -480,14 +478,16 @@ void Render()
|
|||||||
InvalidateObjects();
|
InvalidateObjects();
|
||||||
|
|
||||||
// Resize the device
|
// Resize the device
|
||||||
if( SUCCEEDED( SCREEN->Reset() ) )
|
if( SUCCEEDED( hr = SCREEN->Reset() ) )
|
||||||
{
|
{
|
||||||
// Initialize the app's device-dependent objects
|
// Initialize the app's device-dependent objects
|
||||||
RestoreObjects();
|
RestoreObjects();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
RageError( "Failed to SCREEN->Reset()" );
|
{
|
||||||
|
RageErrorHr( "Failed to SCREEN->Reset()", hr );
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case S_OK:
|
case S_OK:
|
||||||
@@ -536,24 +536,24 @@ void ShowFrame()
|
|||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Name: SetFullscreen()
|
// Name: SwitchDisplayMode()
|
||||||
// Desc:
|
// Desc:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void SetFullscreen( BOOL bFullscreen )
|
BOOL SwitchDisplayMode( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP )
|
||||||
{
|
{
|
||||||
InvalidateObjects();
|
InvalidateObjects();
|
||||||
g_bFullscreen = bFullscreen;
|
|
||||||
SCREEN->SwitchDisplayModes( g_bFullscreen,
|
BOOL bResult = SCREEN->SwitchDisplayMode( bWindowed, dwWidth, dwHeight, dwBPP );
|
||||||
SCREEN_WIDTH,
|
|
||||||
SCREEN_HEIGHT );
|
|
||||||
RestoreObjects();
|
RestoreObjects();
|
||||||
|
|
||||||
if( GAMEINFO )
|
if( GAMEINFO )
|
||||||
{
|
{
|
||||||
if (bFullscreen == 1) GAMEINFO->m_GameOptions.m_bIsFullscreen = true;
|
GAMEINFO->m_GameOptions.m_bWindowed = bWindowed;
|
||||||
else GAMEINFO->m_GameOptions.m_bIsFullscreen = false;
|
|
||||||
GAMEINFO->SaveConfigToDisk();
|
GAMEINFO->SaveConfigToDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -548,6 +548,14 @@ SOURCE=.\ActorFrame.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\Background.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\Background.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\Banner.cpp
|
SOURCE=.\Banner.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -12,10 +12,7 @@
|
|||||||
#define _STEPMANIA_H_
|
#define _STEPMANIA_H_
|
||||||
|
|
||||||
|
|
||||||
void Update(); // Update the game logic
|
BOOL SwitchDisplayMode( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP );
|
||||||
void Render(); // Render a frame
|
|
||||||
void ShowFrame(); // Display the contents of the back buffer to the screen
|
|
||||||
void SetFullscreen( BOOL bFullscreen ); // Switch between fullscreen and windowed modes.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user