From ac2668176abc9cb7181c48188c9c252d9cb1cae1 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Fri, 3 Jun 2011 23:54:45 +0200 Subject: [PATCH 01/29] Trying to clean up the loading window. --- src/StepMania-net2010.vcxproj | 10 +++---- src/arch/LoadingWindow/LoadingWindow.h | 6 ++++ .../LoadingWindow/LoadingWindow_Win32.cpp | 23 +++++++++++++++ src/arch/LoadingWindow/LoadingWindow_Win32.h | 2 ++ src/archutils/Win32/WindowsResources.h | 1 - src/archutils/Win32/WindowsResources.rc | 29 ++++++++++--------- src/archutils/Win32/arch_setup.h | 2 +- 7 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/StepMania-net2010.vcxproj b/src/StepMania-net2010.vcxproj index c1aef5d7d2..9f314df1dc 100644 --- a/src/StepMania-net2010.vcxproj +++ b/src/StepMania-net2010.vcxproj @@ -149,7 +149,7 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir) /MACHINE:I386 "$(IntDir)verstub.obj" %(AdditionalOptions) - shell32.lib;gdi32.lib;user32.lib;ole32.lib;advapi32.lib;ffmpeg/modern_working/lib/avcodec.lib;ffmpeg/modern_working/lib/avformat.lib;ffmpeg/modern_working/lib/avutil.lib;ffmpeg/modern_working/lib/swscale.lib;%(AdditionalDependencies) + shell32.lib;gdi32.lib;user32.lib;ole32.lib;advapi32.lib;Comctl32.lib;ffmpeg/modern_working/lib/avcodec.lib;ffmpeg/modern_working/lib/avformat.lib;ffmpeg/modern_working/lib/avutil.lib;ffmpeg/modern_working/lib/swscale.lib;%(AdditionalDependencies) ../Program/StepMania-debug.exe true ..\extern\libpng\lib;ffmpeg\lib;..\extern\libjpeg\;..\extern\zlib\;..\extern\mad-0.15.1b\msvc++\Release\%(AdditionalLibraryDirectories) @@ -216,7 +216,7 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir) /MACHINE:I386 "$(IntDir)verstub.obj" %(AdditionalOptions) - shell32.lib;gdi32.lib;user32.lib;ole32.lib;advapi32.lib;ffmpeg/modern_working/lib/avcodec.lib;ffmpeg/modern_working/lib/avformat.lib;ffmpeg/modern_working/lib/avutil.lib;ffmpeg/modern_working/lib/swscale.lib;%(AdditionalDependencies) + shell32.lib;gdi32.lib;user32.lib;ole32.lib;advapi32.lib;Comctl32.lib;ffmpeg/modern_working/lib/avcodec.lib;ffmpeg/modern_working/lib/avformat.lib;ffmpeg/modern_working/lib/avutil.lib;ffmpeg/modern_working/lib/swscale.lib;%(AdditionalDependencies) ../Program/StepMania.exe true ..\extern\libpng\lib;ffmpeg\lib;..\extern\libjpeg\;..\extern\zlib\;..\extern\mad-0.15.1b\msvc++\Release\%(AdditionalLibraryDirectories) @@ -280,7 +280,7 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir) /MACHINE:I386 "$(IntDir)verstub.obj" %(AdditionalOptions) - shell32.lib;gdi32.lib;user32.lib;ole32.lib;advapi32.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;%(AdditionalDependencies) + shell32.lib;gdi32.lib;user32.lib;ole32.lib;advapi32.lib;Comctl32.lib;avcodec.lib;avformat.lib;avutil.lib;swscale.lib;%(AdditionalDependencies) ../Program/StepMania-fastdebug.exe true ..\extern\libpng\lib;ffmpeg\modern_working\lib;..\extern\libjpeg\;..\extern\zlib\;..\extern\mad-0.15.1b\msvc++\Release\;%(AdditionalLibraryDirectories) @@ -349,7 +349,7 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir) /MACHINE:I386 "$(IntDir)verstub.obj" %(AdditionalOptions) - shell32.lib;gdi32.lib;user32.lib;ole32.lib;advapi32.lib;ffmpeg/modern_working/lib/avcodec.lib;ffmpeg/modern_working/lib/avformat.lib;ffmpeg/modern_working/lib/avutil.lib;ffmpeg/modern_working/lib/swscale.lib;%(AdditionalDependencies) + shell32.lib;gdi32.lib;user32.lib;ole32.lib;advapi32.lib;Comctl32.lib;ffmpeg/modern_working/lib/avcodec.lib;ffmpeg/modern_working/lib/avformat.lib;ffmpeg/modern_working/lib/avutil.lib;ffmpeg/modern_working/lib/swscale.lib;%(AdditionalDependencies) ..\Program/StepMania-SSE2.exe true ..\extern\libpng\lib;ffmpeg\lib;..\extern\libjpeg\;..\extern\zlib\;..\extern\mad-0.15.1b\msvc++\Release\%(AdditionalLibraryDirectories) @@ -2395,4 +2395,4 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir) - + \ No newline at end of file diff --git a/src/arch/LoadingWindow/LoadingWindow.h b/src/arch/LoadingWindow/LoadingWindow.h index 888a265e39..1ddfa7e110 100644 --- a/src/arch/LoadingWindow/LoadingWindow.h +++ b/src/arch/LoadingWindow/LoadingWindow.h @@ -14,6 +14,12 @@ public: virtual void Paint() { } virtual void SetText( RString str ) = 0; virtual void SetIcon( const RageSurface *pIcon ) { } + virtual void SetProgress( const int progress ) { m_progress=progress; } + virtual void SetTotalWork( const int totalWork ) { m_totalWork=totalWork; } + +protected: + int m_progress; + int m_totalWork; }; #endif diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp index 4801e0bac7..9148e15db8 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp @@ -7,6 +7,7 @@ #include "archutils/win32/WindowIcon.h" #include "archutils/win32/ErrorStrings.h" #include +#include "CommCtrl.h" #include "RageSurface_Load.h" #include "RageSurface.h" #include "RageSurfaceUtils.h" @@ -17,6 +18,9 @@ #include "RageSurfaceUtils_Zoom.h" static HBITMAP g_hBitmap = NULL; +#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") + + /* Load a RageSurface into a GDI surface. */ static HBITMAP LoadWin32Surface( RageSurface *&s ) { @@ -118,6 +122,11 @@ void LoadingWindow_Win32::SetIcon( const RageSurface *pIcon ) LoadingWindow_Win32::LoadingWindow_Win32() { + INITCOMMONCONTROLSEX cceData; + cceData.dwSize=sizeof(INITCOMMONCONTROLSEX); + cceData.dwICC=ICC_PROGRESS_CLASS; + InitCommonControlsEx(&cceData); + m_hIcon = NULL; hwnd = CreateDialog( handle.Get(), MAKEINTRESOURCE(IDD_LOADING_DIALOG), NULL, WndProc ); for( unsigned i = 0; i < 3; ++i ) @@ -168,6 +177,20 @@ void LoadingWindow_Win32::SetText( RString sText ) } } +void LoadingWindow_Win32::SetProgress(const int progress) +{ + m_progress=progress; + HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); + ::SendMessage(hwndItem,PBM_SETPOS,progress,0); +} + +void LoadingWindow_Win32::SetTotalWork(const int totalWork) +{ + m_totalWork=totalWork; + HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); + ::SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork); +} + /* * (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.h b/src/arch/LoadingWindow/LoadingWindow_Win32.h index f490392acb..365a7ee2bc 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.h +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.h @@ -16,6 +16,8 @@ public: void SetText( RString sText ); void Paint(); void SetIcon( const RageSurface *pIcon ); + void SetProgress( const int progress ); + void SetTotalWork( const int totalWork ); private: AppInstance handle; diff --git a/src/archutils/Win32/WindowsResources.h b/src/archutils/Win32/WindowsResources.h index 348f2ffdb0..be6ceda5c4 100644 --- a/src/archutils/Win32/WindowsResources.h +++ b/src/archutils/Win32/WindowsResources.h @@ -29,7 +29,6 @@ #define IDC_BUTTON_CLOSE 1011 #define IDC_VIEW_LOG 1012 #define IDC_STATIC_MESSAGE3 1013 -#define IDC_PROGRESS1 1014 #define IDC_PROGRESS 1014 #define IDC_HUSH 1016 #define IDC_MESSAGE 1017 diff --git a/src/archutils/Win32/WindowsResources.rc b/src/archutils/Win32/WindowsResources.rc index ad20d9749a..494c422801 100644 --- a/src/archutils/Win32/WindowsResources.rc +++ b/src/archutils/Win32/WindowsResources.rc @@ -7,19 +7,20 @@ // // Generated from the TEXTINCLUDE 2 resource. // + +#define _WIN32_WINNT 0x0501 #include "winres.h" +#include "CommCtrl.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources +// English (United States) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) -#endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // @@ -43,14 +44,16 @@ BEGIN CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,0,34,332,1 END -IDD_LOADING_DIALOG DIALOG 0, 0, 312, 82 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE -FONT 8, "MS Sans Serif" +IDD_LOADING_DIALOG DIALOGEX 0, 0, 317, 94 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_APPWINDOW +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - CTEXT "line1",IDC_STATIC_MESSAGE1,0,41,310,10,SS_NOPREFIX | SS_CENTERIMAGE - CTEXT "line2",IDC_STATIC_MESSAGE2,0,54,310,10,SS_NOPREFIX | SS_CENTERIMAGE - CTEXT "line3",IDC_STATIC_MESSAGE3,0,65,310,10,SS_NOPREFIX | SS_CENTERIMAGE + CTEXT "line1",IDC_STATIC_MESSAGE1,0,67,310,10,SS_NOPREFIX | SS_CENTERIMAGE + CTEXT "line2",IDC_STATIC_MESSAGE2,0,76,310,10,SS_NOPREFIX | SS_CENTERIMAGE + CTEXT "line3",IDC_STATIC_MESSAGE3,0,84,310,10,SS_NOPREFIX | SS_CENTERIMAGE CONTROL "",IDC_SPLASH,"Static",SS_BITMAP,0,0,310,25 + CONTROL "",IDC_PROGRESS,"msctls_progress32",PBS_MARQUEE,7,51,298,14 END IDD_DISASM_CRASH DIALOGEX 0, 0, 332, 114 @@ -102,14 +105,14 @@ END // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +GUIDELINES DESIGNINFO BEGIN IDD_LOADING_DIALOG, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 305 + RIGHTMARGIN, 310 TOPMARGIN, 7 - BOTTOMMARGIN, 75 + BOTTOMMARGIN, 87 END IDD_DISASM_CRASH, DIALOG @@ -212,7 +215,7 @@ BEGIN END END -#endif // English (U.S.) resources +#endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/archutils/Win32/arch_setup.h b/src/archutils/Win32/arch_setup.h index 983aa3868d..c403f26b4c 100644 --- a/src/archutils/Win32/arch_setup.h +++ b/src/archutils/Win32/arch_setup.h @@ -66,7 +66,7 @@ C4355: 'this' : used in base member initializer list /* Pull in NT-only definitions. Note that we support Win98 and WinME; you can * make NT calls, but be sure to fall back on 9x if they're not supported. */ -#define _WIN32_WINNT 0x0400 +#define _WIN32_WINNT 0x0501 #define _WIN32_IE 0x0400 // If this isn't defined to 0, VC fails to define things like stat and alloca. From 227863965c00eec3359589bbbc2bfd8a1e62774e Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Fri, 3 Jun 2011 18:09:02 -0400 Subject: [PATCH 02/29] [loading window] Don't forget VS2008. --- src/StepMania-net2008.vcproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/StepMania-net2008.vcproj b/src/StepMania-net2008.vcproj index bcc20ea4b9..8ae692a48c 100644 --- a/src/StepMania-net2008.vcproj +++ b/src/StepMania-net2008.vcproj @@ -81,7 +81,7 @@ Date: Sat, 4 Jun 2011 02:12:08 +0200 Subject: [PATCH 03/29] [loading window] Now the loading window has it's own thread. As such, the paint method is no longer needed. --- src/SongManager.cpp | 2 - src/arch/LoadingWindow/LoadingWindow.h | 1 - .../LoadingWindow/LoadingWindow_Win32.cpp | 47 +++++++++++++++---- src/arch/LoadingWindow/LoadingWindow_Win32.h | 7 ++- src/archutils/Win32/WindowsResources.rc | 8 ++-- 5 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 48a7d3c5eb..1423a13498 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -266,7 +266,6 @@ void SongManager::LoadStepManiaSongDir( RString sDir, LoadingWindow *ld ) ld->SetText( LOADING_SONGS.GetValue()+ssprintf("\n%s\n%s", Basename(sGroupDirName).c_str(), Basename(sSongDirName).c_str())); - ld->Paint(); } Song* pNewSong = new Song; if( !pNewSong->LoadFromSongDir( sSongDirName ) ) @@ -755,7 +754,6 @@ void SongManager::InitCoursesFromDisk( LoadingWindow *ld ) ld->SetText( LOADING_COURSES.GetValue()+ssprintf("\n%s\n%s", Basename(*sCourseGroup).c_str(), Basename(*sCoursePath).c_str())); - ld->Paint(); } Course* pCourse = new Course; diff --git a/src/arch/LoadingWindow/LoadingWindow.h b/src/arch/LoadingWindow/LoadingWindow.h index 1ddfa7e110..952c469ab8 100644 --- a/src/arch/LoadingWindow/LoadingWindow.h +++ b/src/arch/LoadingWindow/LoadingWindow.h @@ -11,7 +11,6 @@ public: virtual RString Init() { return RString(); } virtual ~LoadingWindow() { } - virtual void Paint() { } virtual void SetText( RString str ) = 0; virtual void SetIcon( const RageSurface *pIcon ) { } virtual void SetProgress( const int progress ) { m_progress=progress; } diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp index 9148e15db8..d776156855 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp @@ -80,8 +80,18 @@ static HBITMAP LoadWin32Surface( RString sFile, HWND hWnd ) return ret; } -BOOL CALLBACK LoadingWindow_Win32::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) +INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { + + LoadingWindow_Win32 *self; + + if(msg==WM_INITDIALOG) { + self=(LoadingWindow_Win32 *)lParam; + SetWindowLong(hWnd,DWL_USER,(LONG)self); + } else { + self=(LoadingWindow_Win32 *)GetWindowLong(hWnd,DWL_USER); + } + switch( msg ) { case WM_INITDIALOG: @@ -99,12 +109,21 @@ BOOL CALLBACK LoadingWindow_Win32::WndProc( HWND hWnd, UINT msg, WPARAM wParam, (WPARAM) IMAGE_BITMAP, (LPARAM) (HANDLE) g_hBitmap ); SetWindowTextA( hWnd, PRODUCT_ID ); + + { + HWND progressCtrl=GetDlgItem( hWnd, IDC_PROGRESS ); + SetWindowLong(progressCtrl,GWL_STYLE, PBS_MARQUEE | GetWindowLong(progressCtrl,GWL_STYLE)); + SendMessage(progressCtrl,PBM_SETMARQUEE,1,0); + } break; case WM_DESTROY: DeleteObject( g_hBitmap ); g_hBitmap = NULL; break; + + case WM_ENTERIDLE: + SetEvent(self->guiReadyEvent); } return FALSE; @@ -128,33 +147,43 @@ LoadingWindow_Win32::LoadingWindow_Win32() InitCommonControlsEx(&cceData); m_hIcon = NULL; - hwnd = CreateDialog( handle.Get(), MAKEINTRESOURCE(IDD_LOADING_DIALOG), NULL, WndProc ); + + guiReadyEvent=CreateEvent(NULL,FALSE,FALSE,NULL); + + CreateThread(NULL, NULL, MessagePump, (void *)this, 0, NULL); + + WaitForSingleObject(guiReadyEvent,0); + for( unsigned i = 0; i < 3; ++i ) text[i] = "ABC"; /* always set on first call */ SetText( "" ); - Paint(); } LoadingWindow_Win32::~LoadingWindow_Win32() { + if(guiReadyEvent) + CloseHandle(guiReadyEvent); if( hwnd ) DestroyWindow( hwnd ); if( m_hIcon != NULL ) DestroyIcon( m_hIcon ); } -void LoadingWindow_Win32::Paint() +DWORD WINAPI LoadingWindow_Win32::MessagePump(LPVOID thisAsVoidPtr) { - SendMessage( hwnd, WM_PAINT, 0, 0 ); + LoadingWindow_Win32 *self=(LoadingWindow_Win32 *)thisAsVoidPtr; - /* Process all queued messages since the last paint. This allows the window to - * come back if it loses focus during load. */ + self->hwnd = CreateDialogParam( self->handle.Get(), MAKEINTRESOURCE(IDD_LOADING_DIALOG), NULL, DlgProc, (LPARAM)thisAsVoidPtr); + + // Run the message loop in a separate thread to keep the gui responsive during the loading MSG msg; - while( PeekMessage( &msg, hwnd, 0, 0, PM_NOREMOVE ) ) + while( GetMessage(&msg, self->hwnd, 0, 0 ) ) { - GetMessage(&msg, hwnd, 0, 0 ); + if(IsDialogMessage(self->hwnd,&msg)) continue; DispatchMessage( &msg ); } + + return msg.wParam; } void LoadingWindow_Win32::SetText( RString sText ) diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.h b/src/arch/LoadingWindow/LoadingWindow_Win32.h index 365a7ee2bc..c9e0cf4bb1 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.h +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.h @@ -14,7 +14,6 @@ public: ~LoadingWindow_Win32(); void SetText( RString sText ); - void Paint(); void SetIcon( const RageSurface *pIcon ); void SetProgress( const int progress ); void SetTotalWork( const int totalWork ); @@ -24,8 +23,12 @@ private: HWND hwnd; RString text[3]; HICON m_hIcon; + HANDLE pumpThread; + HANDLE guiReadyEvent; - static BOOL CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); + static DWORD WINAPI MessagePump(LPVOID thisAsVoidPtr); + + static INT_PTR CALLBACK DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); }; #define USE_LOADING_WINDOW_WIN32 diff --git a/src/archutils/Win32/WindowsResources.rc b/src/archutils/Win32/WindowsResources.rc index 494c422801..18e8cb2d41 100644 --- a/src/archutils/Win32/WindowsResources.rc +++ b/src/archutils/Win32/WindowsResources.rc @@ -7,10 +7,7 @@ // // Generated from the TEXTINCLUDE 2 resource. // - -#define _WIN32_WINNT 0x0501 #include "winres.h" -#include "CommCtrl.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -45,15 +42,16 @@ BEGIN END IDD_LOADING_DIALOG DIALOGEX 0, 0, 317, 94 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_CENTER | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW +CAPTION "Stepmania" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN CTEXT "line1",IDC_STATIC_MESSAGE1,0,67,310,10,SS_NOPREFIX | SS_CENTERIMAGE CTEXT "line2",IDC_STATIC_MESSAGE2,0,76,310,10,SS_NOPREFIX | SS_CENTERIMAGE CTEXT "line3",IDC_STATIC_MESSAGE3,0,84,310,10,SS_NOPREFIX | SS_CENTERIMAGE CONTROL "",IDC_SPLASH,"Static",SS_BITMAP,0,0,310,25 - CONTROL "",IDC_PROGRESS,"msctls_progress32",PBS_MARQUEE,7,51,298,14 + CONTROL "",IDC_PROGRESS,"msctls_progress32",0x0,7,51,298,14 END IDD_DISASM_CRASH DIALOGEX 0, 0, 332, 114 From e0eae90f23f519906f2533dc7beed58db41f6a69 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sat, 4 Jun 2011 14:26:35 +0200 Subject: [PATCH 04/29] [loading window] Destruction now works correctly. --- .../LoadingWindow/LoadingWindow_Win32.cpp | 501 +++++++++--------- src/arch/LoadingWindow/LoadingWindow_Win32.h | 2 + src/archutils/Win32/WindowsResources.rc | 2 +- 3 files changed, 259 insertions(+), 246 deletions(-) diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp index d776156855..e8c1c1961c 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp @@ -1,246 +1,257 @@ -#include "global.h" -#include "RageUtil.h" - -#include "LoadingWindow_Win32.h" -#include "RageFileManager.h" -#include "archutils/win32/WindowsResources.h" -#include "archutils/win32/WindowIcon.h" -#include "archutils/win32/ErrorStrings.h" -#include -#include "CommCtrl.h" -#include "RageSurface_Load.h" -#include "RageSurface.h" -#include "RageSurfaceUtils.h" -#include "RageLog.h" -#include "ProductInfo.h" -#include "LocalizedString.h" - -#include "RageSurfaceUtils_Zoom.h" -static HBITMAP g_hBitmap = NULL; - +#include "global.h" +#include "RageUtil.h" + +#include "LoadingWindow_Win32.h" +#include "RageFileManager.h" +#include "archutils/win32/WindowsResources.h" +#include "archutils/win32/WindowIcon.h" +#include "archutils/win32/ErrorStrings.h" +#include +#include "CommCtrl.h" +#include "RageSurface_Load.h" +#include "RageSurface.h" +#include "RageSurfaceUtils.h" +#include "RageLog.h" +#include "ProductInfo.h" +#include "LocalizedString.h" + +#include "RageSurfaceUtils_Zoom.h" +static HBITMAP g_hBitmap = NULL; + #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") - - -/* Load a RageSurface into a GDI surface. */ -static HBITMAP LoadWin32Surface( RageSurface *&s ) -{ - RageSurfaceUtils::ConvertSurface( s, s->w, s->h, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0 ); - - HDC hScreen = GetDC(NULL); - ASSERT_M( hScreen, werr_ssprintf(GetLastError(), "hScreen") ); - - HBITMAP bitmap = CreateCompatibleBitmap( hScreen, s->w, s->h ); - ASSERT_M( bitmap, werr_ssprintf(GetLastError(), "CreateCompatibleBitmap") ); - - HDC BitmapDC = CreateCompatibleDC( hScreen ); - SelectObject( BitmapDC, bitmap ); - - /* This is silly, but simple. We only do this once, on a small image. */ - for( int y = 0; y < s->h; ++y ) - { - unsigned const char *line = ((unsigned char *) s->pixels) + (y * s->pitch); - for( int x = 0; x < s->w; ++x ) - { - unsigned const char *data = line + (x*s->format->BytesPerPixel); - - SetPixelV( BitmapDC, x, y, RGB( data[3], data[2], data[1] ) ); - } - } - - SelectObject( BitmapDC, NULL ); - DeleteObject( BitmapDC ); - - ReleaseDC( NULL, hScreen ); - - return bitmap; -} - -static HBITMAP LoadWin32Surface( RString sFile, HWND hWnd ) -{ - RString error; - RageSurface *pSurface = RageSurfaceUtils::LoadFile( sFile, error ); - if( pSurface == NULL ) - return NULL; - - /* Resize the splash image to fit the dialog. Stretch to fit horizontally, - * maintaining aspect ratio. */ - { - RECT r; - GetClientRect( hWnd, &r ); - - int iWidth = r.right; - float fRatio = (float) iWidth / pSurface->w; - int iHeight = lrintf( pSurface->h * fRatio ); - - RageSurfaceUtils::Zoom( pSurface, iWidth, iHeight ); - } - - HBITMAP ret = LoadWin32Surface( pSurface ); - delete pSurface; - return ret; -} - -INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - - LoadingWindow_Win32 *self; - - if(msg==WM_INITDIALOG) { - self=(LoadingWindow_Win32 *)lParam; - SetWindowLong(hWnd,DWL_USER,(LONG)self); - } else { - self=(LoadingWindow_Win32 *)GetWindowLong(hWnd,DWL_USER); - } - - switch( msg ) - { - case WM_INITDIALOG: - { - vector vs; - GetDirListing( "Data/splash*.png", vs, false, true ); - if( !vs.empty() ) - g_hBitmap = LoadWin32Surface( vs[0], hWnd ); - } - if( g_hBitmap == NULL ) - g_hBitmap = LoadWin32Surface( "Data/splash.bmp", hWnd ); - SendMessage( - GetDlgItem(hWnd,IDC_SPLASH), - STM_SETIMAGE, - (WPARAM) IMAGE_BITMAP, - (LPARAM) (HANDLE) g_hBitmap ); - SetWindowTextA( hWnd, PRODUCT_ID ); - - { - HWND progressCtrl=GetDlgItem( hWnd, IDC_PROGRESS ); - SetWindowLong(progressCtrl,GWL_STYLE, PBS_MARQUEE | GetWindowLong(progressCtrl,GWL_STYLE)); - SendMessage(progressCtrl,PBM_SETMARQUEE,1,0); - } - break; - - case WM_DESTROY: - DeleteObject( g_hBitmap ); - g_hBitmap = NULL; - break; - - case WM_ENTERIDLE: - SetEvent(self->guiReadyEvent); - } - - return FALSE; -} - -void LoadingWindow_Win32::SetIcon( const RageSurface *pIcon ) -{ - if( m_hIcon != NULL ) - DestroyIcon( m_hIcon ); - - m_hIcon = IconFromSurface( pIcon ); - if( m_hIcon != NULL ) - SetClassLong( hwnd, GCL_HICON, (LONG) m_hIcon ); -} - -LoadingWindow_Win32::LoadingWindow_Win32() -{ - INITCOMMONCONTROLSEX cceData; - cceData.dwSize=sizeof(INITCOMMONCONTROLSEX); - cceData.dwICC=ICC_PROGRESS_CLASS; - InitCommonControlsEx(&cceData); - - m_hIcon = NULL; - - guiReadyEvent=CreateEvent(NULL,FALSE,FALSE,NULL); - - CreateThread(NULL, NULL, MessagePump, (void *)this, 0, NULL); - - WaitForSingleObject(guiReadyEvent,0); - - for( unsigned i = 0; i < 3; ++i ) - text[i] = "ABC"; /* always set on first call */ - SetText( "" ); -} - -LoadingWindow_Win32::~LoadingWindow_Win32() -{ - if(guiReadyEvent) - CloseHandle(guiReadyEvent); - if( hwnd ) - DestroyWindow( hwnd ); - if( m_hIcon != NULL ) - DestroyIcon( m_hIcon ); -} - -DWORD WINAPI LoadingWindow_Win32::MessagePump(LPVOID thisAsVoidPtr) -{ - LoadingWindow_Win32 *self=(LoadingWindow_Win32 *)thisAsVoidPtr; - - self->hwnd = CreateDialogParam( self->handle.Get(), MAKEINTRESOURCE(IDD_LOADING_DIALOG), NULL, DlgProc, (LPARAM)thisAsVoidPtr); - - // Run the message loop in a separate thread to keep the gui responsive during the loading - MSG msg; - while( GetMessage(&msg, self->hwnd, 0, 0 ) ) - { - if(IsDialogMessage(self->hwnd,&msg)) continue; - DispatchMessage( &msg ); - } - - return msg.wParam; -} - -void LoadingWindow_Win32::SetText( RString sText ) -{ - vector asMessageLines; - split( sText, "\n", asMessageLines, false ); - while( asMessageLines.size() < 3 ) - asMessageLines.push_back( "" ); - - const int msgid[] = { IDC_STATIC_MESSAGE1, IDC_STATIC_MESSAGE2, IDC_STATIC_MESSAGE3 }; - for( unsigned i = 0; i < 3; ++i ) - { - if( text[i] == asMessageLines[i] ) - continue; - text[i] = asMessageLines[i]; - - HWND hwndItem = ::GetDlgItem( hwnd, msgid[i] ); - - ::SetWindowText( hwndItem, ConvertUTF8ToACP(asMessageLines[i]).c_str() ); - } -} - -void LoadingWindow_Win32::SetProgress(const int progress) -{ - m_progress=progress; - HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); - ::SendMessage(hwndItem,PBM_SETPOS,progress,0); -} - -void LoadingWindow_Win32::SetTotalWork(const int totalWork) -{ - m_totalWork=totalWork; - HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); - ::SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork); -} - -/* - * (c) 2001-2004 Chris Danford, Glenn Maynard - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ + + +/* Load a RageSurface into a GDI surface. */ +static HBITMAP LoadWin32Surface( RageSurface *&s ) +{ + RageSurfaceUtils::ConvertSurface( s, s->w, s->h, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0 ); + + HDC hScreen = GetDC(NULL); + ASSERT_M( hScreen, werr_ssprintf(GetLastError(), "hScreen") ); + + HBITMAP bitmap = CreateCompatibleBitmap( hScreen, s->w, s->h ); + ASSERT_M( bitmap, werr_ssprintf(GetLastError(), "CreateCompatibleBitmap") ); + + HDC BitmapDC = CreateCompatibleDC( hScreen ); + SelectObject( BitmapDC, bitmap ); + + /* This is silly, but simple. We only do this once, on a small image. */ + for( int y = 0; y < s->h; ++y ) + { + unsigned const char *line = ((unsigned char *) s->pixels) + (y * s->pitch); + for( int x = 0; x < s->w; ++x ) + { + unsigned const char *data = line + (x*s->format->BytesPerPixel); + + SetPixelV( BitmapDC, x, y, RGB( data[3], data[2], data[1] ) ); + } + } + + SelectObject( BitmapDC, NULL ); + DeleteObject( BitmapDC ); + + ReleaseDC( NULL, hScreen ); + + return bitmap; +} + +static HBITMAP LoadWin32Surface( RString sFile, HWND hWnd ) +{ + RString error; + RageSurface *pSurface = RageSurfaceUtils::LoadFile( sFile, error ); + if( pSurface == NULL ) + return NULL; + + /* Resize the splash image to fit the dialog. Stretch to fit horizontally, + * maintaining aspect ratio. */ + { + RECT r; + GetClientRect( hWnd, &r ); + + int iWidth = r.right; + float fRatio = (float) iWidth / pSurface->w; + int iHeight = lrintf( pSurface->h * fRatio ); + + RageSurfaceUtils::Zoom( pSurface, iWidth, iHeight ); + } + + HBITMAP ret = LoadWin32Surface( pSurface ); + delete pSurface; + return ret; +} + +INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) +{ + + LoadingWindow_Win32 *self; + + if(msg==WM_INITDIALOG) { + self=(LoadingWindow_Win32 *)lParam; + SetWindowLong(hWnd,DWL_USER,(LONG)self); + } else { + self=(LoadingWindow_Win32 *)GetWindowLong(hWnd,DWL_USER); + } + + switch( msg ) + { + case WM_INITDIALOG: + { + vector vs; + GetDirListing( "Data/splash*.png", vs, false, true ); + if( !vs.empty() ) + g_hBitmap = LoadWin32Surface( vs[0], hWnd ); + } + if( g_hBitmap == NULL ) + g_hBitmap = LoadWin32Surface( "Data/splash.bmp", hWnd ); + SendMessage( + GetDlgItem(hWnd,IDC_SPLASH), + STM_SETIMAGE, + (WPARAM) IMAGE_BITMAP, + (LPARAM) (HANDLE) g_hBitmap ); + SetWindowTextA( hWnd, PRODUCT_ID ); + + { + HWND progressCtrl=GetDlgItem( hWnd, IDC_PROGRESS ); + SetWindowLong(progressCtrl,GWL_STYLE, PBS_MARQUEE | GetWindowLong(progressCtrl,GWL_STYLE)); + SendMessage(progressCtrl,PBM_SETMARQUEE,1,0); + } + break; + + case WM_DESTROY: + DeleteObject( g_hBitmap ); + g_hBitmap = NULL; + self->runMessageLoop=false; + return TRUE; + break; + + case WM_APP: + DestroyWindow(hWnd); + self->runMessageLoop=false; + return TRUE; + break; + } + + return FALSE; +} + +void LoadingWindow_Win32::SetIcon( const RageSurface *pIcon ) +{ + if( m_hIcon != NULL ) + DestroyIcon( m_hIcon ); + + m_hIcon = IconFromSurface( pIcon ); + if( m_hIcon != NULL ) + SetClassLong( hwnd, GCL_HICON, (LONG) m_hIcon ); +} + +LoadingWindow_Win32::LoadingWindow_Win32() +{ + INITCOMMONCONTROLSEX cceData; + cceData.dwSize=sizeof(INITCOMMONCONTROLSEX); + cceData.dwICC=ICC_PROGRESS_CLASS; + InitCommonControlsEx(&cceData); + + m_hIcon = NULL; + + runMessageLoop=true; + + guiReadyEvent=CreateEvent(NULL,FALSE,FALSE,NULL); + + CreateThread(NULL, NULL, MessagePump, (void *)this, 0, NULL); + + WaitForSingleObject(guiReadyEvent,INFINITE); + + for( unsigned i = 0; i < 3; ++i ) + text[i] = "ABC"; /* always set on first call */ + SetText( "" ); +} + +LoadingWindow_Win32::~LoadingWindow_Win32() +{ + SendMessage(hwnd,WM_APP,0,0); + WaitForSingleObject(guiReadyEvent,INFINITE); + if(guiReadyEvent) + CloseHandle(guiReadyEvent); + if( m_hIcon != NULL ) + DestroyIcon( m_hIcon ); +} + +DWORD WINAPI LoadingWindow_Win32::MessagePump(LPVOID thisAsVoidPtr) +{ + LoadingWindow_Win32 *self=(LoadingWindow_Win32 *)thisAsVoidPtr; + + self->hwnd = CreateDialogParam( self->handle.Get(), MAKEINTRESOURCE(IDD_LOADING_DIALOG), NULL, DlgProc, (LPARAM)thisAsVoidPtr); + + SetEvent(self->guiReadyEvent); + + // Run the message loop in a separate thread to keep the gui responsive during the loading + MSG msg; + while(self->runMessageLoop && GetMessage(&msg, self->hwnd, 0, 0 ) ) + { + if(IsDialogMessage(self->hwnd,&msg)) continue; + DispatchMessage( &msg ); + } + + SetEvent(self->guiReadyEvent); + + return msg.wParam; +} + +void LoadingWindow_Win32::SetText( RString sText ) +{ + vector asMessageLines; + split( sText, "\n", asMessageLines, false ); + while( asMessageLines.size() < 3 ) + asMessageLines.push_back( "" ); + + const int msgid[] = { IDC_STATIC_MESSAGE1, IDC_STATIC_MESSAGE2, IDC_STATIC_MESSAGE3 }; + for( unsigned i = 0; i < 3; ++i ) + { + if( text[i] == asMessageLines[i] ) + continue; + text[i] = asMessageLines[i]; + + HWND hwndItem = ::GetDlgItem( hwnd, msgid[i] ); + + ::SetWindowText( hwndItem, ConvertUTF8ToACP(asMessageLines[i]).c_str() ); + } +} + +void LoadingWindow_Win32::SetProgress(const int progress) +{ + m_progress=progress; + HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); + ::SendMessage(hwndItem,PBM_SETPOS,progress,0); +} + +void LoadingWindow_Win32::SetTotalWork(const int totalWork) +{ + m_totalWork=totalWork; + HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); + ::SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork); +} + +/* + * (c) 2001-2004 Chris Danford, Glenn Maynard + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.h b/src/arch/LoadingWindow/LoadingWindow_Win32.h index c9e0cf4bb1..e19e7f0a12 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.h +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.h @@ -26,6 +26,8 @@ private: HANDLE pumpThread; HANDLE guiReadyEvent; + volatile bool runMessageLoop; + static DWORD WINAPI MessagePump(LPVOID thisAsVoidPtr); static INT_PTR CALLBACK DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); diff --git a/src/archutils/Win32/WindowsResources.rc b/src/archutils/Win32/WindowsResources.rc index 30090d15bb..94d881bd34 100644 --- a/src/archutils/Win32/WindowsResources.rc +++ b/src/archutils/Win32/WindowsResources.rc @@ -42,7 +42,7 @@ BEGIN END IDD_LOADING_DIALOG DIALOGEX 0, 0, 317, 94 -STYLE DS_SETFONT | DS_CENTER | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_CENTER | WS_MINIMIZEBOX | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW CAPTION "Stepmania" FONT 8, "MS Sans Serif", 0, 0, 0x0 From 75d595878a05f9887d075bdd5bfe9e0fdb97a4d7 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sat, 4 Jun 2011 14:55:38 +0200 Subject: [PATCH 05/29] [loading window] Reporting progress for more than just song loading. --- src/StepMania.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/StepMania.cpp b/src/StepMania.cpp index 97a897820a..46cb06a12f 100644 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -1054,19 +1054,26 @@ int main(int argc, char* argv[]) if( PREFSMAN->m_iSoundWriteAhead ) LOG->Info( "Sound writeahead has been overridden to %i", PREFSMAN->m_iSoundWriteAhead.Get() ); + + pLoadingWindow->SetText("Starting sound subsystem..."); SOUNDMAN = new RageSoundManager; SOUNDMAN->Init(); SOUNDMAN->SetMixVolume(); SOUND = new GameSoundManager; + pLoadingWindow->SetText("Initializing bookkeeper..."); BOOKKEEPER = new Bookkeeper; + pLoadingWindow->SetText("Starting lights subsystem..."); LIGHTSMAN = new LightsManager; INPUTFILTER = new InputFilter; INPUTMAPPER = new InputMapper; + pLoadingWindow->SetText("Loading game type..."); StepMania::ChangeCurrentGame( GAMESTATE->GetCurrentGame() ); INPUTQUEUE = new InputQueue; + pLoadingWindow->SetText("Building song cache index..."); SONGINDEX = new SongCacheIndex; + pLoadingWindow->SetText("Building banner cache..."); BANNERCACHE = new BannerCache; //BACKGROUNDCACHE = new BackgroundCache; @@ -1076,16 +1083,22 @@ int main(int argc, char* argv[]) CRYPTMAN = new CryptManager; // need to do this before ProfileMan if( PREFSMAN->m_bSignProfileData ) CRYPTMAN->GenerateGlobalKeys(); + pLoadingWindow->SetText("Initializing memory card system..."); MEMCARDMAN = new MemoryCardManager; + pLoadingWindow->SetText("Initializing character system..."); CHARMAN = new CharacterManager; + pLoadingWindow->SetText("Initializing profile system..."); PROFILEMAN = new ProfileManager; PROFILEMAN->Init(); // must load after SONGMAN UNLOCKMAN = new UnlockManager; + pLoadingWindow->SetText("Updating popular song list..."); SONGMAN->UpdatePopular(); SONGMAN->UpdatePreferredSort(); NSMAN = new NetworkSyncManager( pLoadingWindow ); + pLoadingWindow->SetText("Initializing message system..."); MESSAGEMAN = new MessageManager; + pLoadingWindow->SetText("Initializing statics manager..."); STATSMAN = new StatsManager; SAFE_DELETE( pLoadingWindow ); // destroy this before init'ing Display From 9956525d462179ac11556ffa818f9a8c72b7860d Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sat, 4 Jun 2011 15:37:20 +0200 Subject: [PATCH 06/29] [loading window] Die thread die! --- src/arch/LoadingWindow/LoadingWindow_Win32.cpp | 9 +++++---- src/arch/LoadingWindow/LoadingWindow_Win32.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp index e8c1c1961c..57414399a8 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp @@ -121,12 +121,14 @@ INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wPara DeleteObject( g_hBitmap ); g_hBitmap = NULL; self->runMessageLoop=false; + self->hwnd=NULL; return TRUE; break; case WM_APP: DestroyWindow(hWnd); self->runMessageLoop=false; + ExitThread(0); return TRUE; break; } @@ -157,7 +159,7 @@ LoadingWindow_Win32::LoadingWindow_Win32() guiReadyEvent=CreateEvent(NULL,FALSE,FALSE,NULL); - CreateThread(NULL, NULL, MessagePump, (void *)this, 0, NULL); + pumpThread=CreateThread(NULL, NULL, MessagePump, (void *)this, 0, &pumpThreadId); WaitForSingleObject(guiReadyEvent,INFINITE); @@ -169,7 +171,8 @@ LoadingWindow_Win32::LoadingWindow_Win32() LoadingWindow_Win32::~LoadingWindow_Win32() { SendMessage(hwnd,WM_APP,0,0); - WaitForSingleObject(guiReadyEvent,INFINITE); + //SendMessage(hwnd,WM_NULL,0,0); + WaitForSingleObject(pumpThread,INFINITE); if(guiReadyEvent) CloseHandle(guiReadyEvent); if( m_hIcon != NULL ) @@ -192,8 +195,6 @@ DWORD WINAPI LoadingWindow_Win32::MessagePump(LPVOID thisAsVoidPtr) DispatchMessage( &msg ); } - SetEvent(self->guiReadyEvent); - return msg.wParam; } diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.h b/src/arch/LoadingWindow/LoadingWindow_Win32.h index e19e7f0a12..d1adeca283 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.h +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.h @@ -24,6 +24,7 @@ private: RString text[3]; HICON m_hIcon; HANDLE pumpThread; + DWORD pumpThreadId; HANDLE guiReadyEvent; volatile bool runMessageLoop; From 813c2d8f09f344fe2bff589c09e6001c0dd67d0d Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sat, 4 Jun 2011 16:09:47 +0200 Subject: [PATCH 07/29] [loading window] Theme loading should also list itself in the loading window. --- src/StepMania.cpp | 2 +- src/ThemeManager.cpp | 3 +++ src/arch/LoadingWindow/LoadingWindow.cpp | 2 ++ src/arch/LoadingWindow/LoadingWindow.h | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/StepMania.cpp b/src/StepMania.cpp index 46cb06a12f..1be66c486d 100644 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -1011,7 +1011,7 @@ int main(int argc, char* argv[]) GAMESTATE = new GameState; // This requires PREFSMAN, for PREFSMAN->m_bShowLoadingWindow. - LoadingWindow *pLoadingWindow = LoadingWindow::Create(); + pLoadingWindow = LoadingWindow::Create(); if(pLoadingWindow == NULL) RageException::Throw("%s", COULDNT_OPEN_LOADING_WINDOW.GetValue().c_str()); diff --git a/src/ThemeManager.cpp b/src/ThemeManager.cpp index 0b3841869f..0e5764c4a6 100644 --- a/src/ThemeManager.cpp +++ b/src/ThemeManager.cpp @@ -8,6 +8,7 @@ #include "RageTimer.h" #include "FontCharAliases.h" #include "arch/ArchHooks/ArchHooks.h" +#include "arch/LoadingWindow/LoadingWindow.h" #include "arch/Dialog/Dialog.h" #include "RageFile.h" #if !defined(SMPACKAGE) @@ -397,6 +398,8 @@ void ThemeManager::SwitchThemeAndLanguage( const RString &sThemeName_, const RSt if( bNothingChanging && !bForceThemeReload ) return; + if(pLoadingWindow) pLoadingWindow->SetText("Loading theme & language..."); + m_bPseudoLocalize = bPseudoLocalize; // Load theme metrics. If only the language is changing, this is all diff --git a/src/arch/LoadingWindow/LoadingWindow.cpp b/src/arch/LoadingWindow/LoadingWindow.cpp index 2002e81f45..130d298a04 100644 --- a/src/arch/LoadingWindow/LoadingWindow.cpp +++ b/src/arch/LoadingWindow/LoadingWindow.cpp @@ -53,6 +53,8 @@ LoadingWindow *LoadingWindow::Create() return ret; } +LoadingWindow *pLoadingWindow; + /* * (c) 2002-2005 Glenn Maynard * All rights reserved. diff --git a/src/arch/LoadingWindow/LoadingWindow.h b/src/arch/LoadingWindow/LoadingWindow.h index 952c469ab8..dcd3a339c5 100644 --- a/src/arch/LoadingWindow/LoadingWindow.h +++ b/src/arch/LoadingWindow/LoadingWindow.h @@ -21,6 +21,8 @@ protected: int m_totalWork; }; +extern LoadingWindow *pLoadingWindow; + #endif /** From 9bff0653c0c3e85ef0cfdbbb19db9b969090ac73 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sat, 4 Jun 2011 23:10:07 +0200 Subject: [PATCH 08/29] [loading window]It's now a global, and it wasn't even used. --- src/CommandLineActions.cpp | 2 +- src/CommandLineActions.h | 5 ++--- src/StepMania.cpp | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/CommandLineActions.cpp b/src/CommandLineActions.cpp index ef5f26b10c..3a45380b87 100644 --- a/src/CommandLineActions.cpp +++ b/src/CommandLineActions.cpp @@ -108,7 +108,7 @@ static void Version() #endif // WIN32 } -void CommandLineActions::Handle(LoadingWindow* pLW) +void CommandLineActions::Handle() { CommandLineArgs args; for(int i=0; im_bDopefish = true; From 1dfb3a6f9a1c8e21a6299f5a2e6c353a0e968bd5 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sat, 4 Jun 2011 23:21:33 +0200 Subject: [PATCH 09/29] [loading window] More use of the global instead of as an argument. --- src/SongManager.cpp | 25 +++++++++++++------------ src/SongManager.h | 11 +++++------ src/StepMania.cpp | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 1423a13498..ddbf30d638 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -88,10 +88,11 @@ SongManager::~SongManager() FreeSongs(); } -void SongManager::InitAll( LoadingWindow *ld ) +void SongManager::InitAll() { - InitSongsFromDisk( ld ); - InitCoursesFromDisk( ld ); + InitSongsFromDisk(); + + InitCoursesFromDisk(); InitAutogenCourses(); InitRandomAttacks(); } @@ -130,14 +131,14 @@ void SongManager::Reload( bool bAllowFastLoad, LoadingWindow *ld ) UpdatePreferredSort(); } -void SongManager::InitSongsFromDisk( LoadingWindow *ld ) +void SongManager::InitSongsFromDisk() { RageTimer tm; - LoadStepManiaSongDir( SpecialFiles::SONGS_DIR, ld ); + LoadStepManiaSongDir( SpecialFiles::SONGS_DIR); const bool bOldVal = PREFSMAN->m_bFastLoad; PREFSMAN->m_bFastLoad.Set( PREFSMAN->m_bFastLoadAdditionalSongs ); - LoadStepManiaSongDir( ADDITIONAL_SONGS_DIR, ld ); + LoadStepManiaSongDir( ADDITIONAL_SONGS_DIR ); PREFSMAN->m_bFastLoad.Set( bOldVal ); LOG->Trace( "Found %d songs in %f seconds.", (int)m_pSongs.size(), tm.GetDeltaTime() ); @@ -224,7 +225,7 @@ void SongManager::AddGroup( RString sDir, RString sGroupDirName ) } static LocalizedString LOADING_SONGS ( "SongManager", "Loading songs..." ); -void SongManager::LoadStepManiaSongDir( RString sDir, LoadingWindow *ld ) +void SongManager::LoadStepManiaSongDir( RString sDir ) { // Make sure sDir has a trailing slash. if( sDir.Right(1) != "/" ) @@ -261,9 +262,9 @@ void SongManager::LoadStepManiaSongDir( RString sDir, LoadingWindow *ld ) RString sSongDirName = arraySongDirs[j]; // this is a song directory. Load a new song. - if( ld ) + if( pLoadingWindow ) { - ld->SetText( LOADING_SONGS.GetValue()+ssprintf("\n%s\n%s", + pLoadingWindow->SetText( LOADING_SONGS.GetValue()+ssprintf("\n%s\n%s", Basename(sGroupDirName).c_str(), Basename(sSongDirName).c_str())); } @@ -719,7 +720,7 @@ RString SongManager::ShortenGroupName( RString sLongGroupName ) } static LocalizedString LOADING_COURSES ( "SongManager", "Loading courses..." ); -void SongManager::InitCoursesFromDisk( LoadingWindow *ld ) +void SongManager::InitCoursesFromDisk() { LOG->Trace( "Loading courses." ); @@ -749,9 +750,9 @@ void SongManager::InitCoursesFromDisk( LoadingWindow *ld ) FOREACH_CONST( RString, vsCoursePaths, sCoursePath ) { - if( ld ) + if( pLoadingWindow ) { - ld->SetText( LOADING_COURSES.GetValue()+ssprintf("\n%s\n%s", + pLoadingWindow->SetText( LOADING_COURSES.GetValue()+ssprintf("\n%s\n%s", Basename(*sCourseGroup).c_str(), Basename(*sCoursePath).c_str())); } diff --git a/src/SongManager.h b/src/SongManager.h index 1c48792e30..4df49feae7 100644 --- a/src/SongManager.h +++ b/src/SongManager.h @@ -1,7 +1,6 @@ #ifndef SONGMANAGER_H #define SONGMANAGER_H -class LoadingWindow; class Song; class Style; class Steps; @@ -31,7 +30,7 @@ public: SongManager(); ~SongManager(); - void InitSongsFromDisk( LoadingWindow *ld ); + void InitSongsFromDisk(); void FreeSongs(); void Cleanup(); @@ -49,7 +48,7 @@ public: void LoadGroupSymLinks( RString sDir, RString sGroupFolder ); - void InitCoursesFromDisk( LoadingWindow *ld ); + void InitCoursesFromDisk(); void InitAutogenCourses(); void InitRandomAttacks(); void FreeCourses(); @@ -59,8 +58,8 @@ public: void DeleteAutogenCourses(); void InvalidateCachedTrails(); - void InitAll( LoadingWindow *ld ); // songs, courses, groups - everything. - void Reload( bool bAllowFastLoad, LoadingWindow *ld=NULL ); // songs, courses, groups - everything. + void InitAll(); // songs, courses, groups - everything. + void Reload( bool bAllowFastLoad); // songs, courses, groups - everything. void PreloadSongImages(); RString GetSongGroupBannerPath( RString sSongGroup ) const; @@ -166,7 +165,7 @@ public: void PushSelf( lua_State *L ); protected: - void LoadStepManiaSongDir( RString sDir, LoadingWindow *ld ); + void LoadStepManiaSongDir( RString sDir ); void LoadDWISongDir( RString sDir ); bool GetExtraStageInfoFromCourse( bool bExtra2, RString sPreferredGroup, Song*& pSongOut, Steps*& pStepsOut ); void SanityCheckGroupDir( RString sDir ) const; diff --git a/src/StepMania.cpp b/src/StepMania.cpp index 77ea3dd0f7..0134c68e4c 100644 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -1073,7 +1073,7 @@ int main(int argc, char* argv[]) INPUTQUEUE = new InputQueue; pLoadingWindow->SetText("Building song cache index..."); SONGINDEX = new SongCacheIndex; - pLoadingWindow->SetText("Building banner cache..."); + pLoadingWindow->SetText("Loading banner cache..."); BANNERCACHE = new BannerCache; //BACKGROUNDCACHE = new BackgroundCache; From a233c21188ca2f42bf4cb2ecf80cd1ba5d92279a Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sat, 4 Jun 2011 23:36:14 +0200 Subject: [PATCH 10/29] [loading window] Note to self: check if it compiles before commiting. --- src/ScreenReloadSongs.cpp | 6 +++--- src/ScreenReloadSongs.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ScreenReloadSongs.cpp b/src/ScreenReloadSongs.cpp index 0129f1a645..48d94907b0 100644 --- a/src/ScreenReloadSongs.cpp +++ b/src/ScreenReloadSongs.cpp @@ -56,12 +56,12 @@ void ScreenReloadSongs::Init() m_Loading.SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y ); this->AddChild( &m_Loading ); - m_LoadingWindow = new ScreenReloadSongsLoadingWindow( m_Loading ); + pLoadingWindow = new ScreenReloadSongsLoadingWindow( m_Loading ); } ScreenReloadSongs::~ScreenReloadSongs() { - delete m_LoadingWindow; + delete pLoadingWindow; } @@ -75,7 +75,7 @@ void ScreenReloadSongs::Update( float fDeltaTime ) return; ASSERT( !IsFirstUpdate() ); - SONGMAN->Reload( false, m_LoadingWindow ); + SONGMAN->Reload( false ); SCREENMAN->PostMessageToTopScreen( SM_GoToNextScreen, 0 ); } diff --git a/src/ScreenReloadSongs.h b/src/ScreenReloadSongs.h index 860bdd28f7..908f61da72 100644 --- a/src/ScreenReloadSongs.h +++ b/src/ScreenReloadSongs.h @@ -14,7 +14,6 @@ public: private: int m_iUpdates; - LoadingWindow *m_LoadingWindow; BitmapText m_Loading; }; From 6c7ebfafe82cfd1e004b0b5609cd6278685a23d3 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sat, 4 Jun 2011 23:37:36 +0200 Subject: [PATCH 11/29] [loading window] Note to self #2: Refresh the file list before commiting. --- src/ScreenInstallOverlay.cpp | 2 +- src/SongManager.cpp | 8 ++++---- src/StepMania.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ScreenInstallOverlay.cpp b/src/ScreenInstallOverlay.cpp index b1037fce23..7453d08ddc 100644 --- a/src/ScreenInstallOverlay.cpp +++ b/src/ScreenInstallOverlay.cpp @@ -360,7 +360,7 @@ void ScreenInstallOverlay::Update( float fDeltaTime ) } if( playAfterLaunchInfo.bAnySongChanged ) - SONGMAN->Reload( false, NULL ); + SONGMAN->Reload( false ); if( !playAfterLaunchInfo.sSongDir.empty() ) { diff --git a/src/SongManager.cpp b/src/SongManager.cpp index ddbf30d638..b4cfceab4e 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -98,7 +98,7 @@ void SongManager::InitAll() } static LocalizedString RELOADING ( "SongManager", "Reloading..." ); -void SongManager::Reload( bool bAllowFastLoad, LoadingWindow *ld ) +void SongManager::Reload( bool bAllowFastLoad ) { FILEMAN->FlushDirCache( SpecialFiles::SONGS_DIR ); FILEMAN->FlushDirCache( ADDITIONAL_SONGS_DIR ); @@ -106,8 +106,8 @@ void SongManager::Reload( bool bAllowFastLoad, LoadingWindow *ld ) FILEMAN->FlushDirCache( ADDITIONAL_COURSES_DIR ); FILEMAN->FlushDirCache( EDIT_SUBDIR ); - if( ld ) - ld->SetText( RELOADING ); + if( pLoadingWindow ) + pLoadingWindow->SetText( RELOADING ); // save scores before unloading songs, of the scores will be lost PROFILEMAN->SaveMachineProfile(); @@ -119,7 +119,7 @@ void SongManager::Reload( bool bAllowFastLoad, LoadingWindow *ld ) if( !bAllowFastLoad ) PREFSMAN->m_bFastLoad.Set( false ); - InitAll( ld ); + InitAll(); // reload scores and unlocks afterward PROFILEMAN->LoadMachineProfile(); diff --git a/src/StepMania.cpp b/src/StepMania.cpp index 0134c68e4c..3463d57b47 100644 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -1079,7 +1079,7 @@ int main(int argc, char* argv[]) // depends on SONGINDEX: SONGMAN = new SongManager; - SONGMAN->InitAll( pLoadingWindow ); // this takes a long time + SONGMAN->InitAll(); // this takes a long time CRYPTMAN = new CryptManager; // need to do this before ProfileMan if( PREFSMAN->m_bSignProfileData ) CRYPTMAN->GenerateGlobalKeys(); From 9721c0d66aeee19dba94d661f3ce4d3fbada8302 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sun, 5 Jun 2011 01:39:15 +0200 Subject: [PATCH 12/29] [loading window] Trying to clean up the in game song reloading. --- ... => InGameLoadingWindow LoadingText.redir} | 0 src/InGameLoadingWindow.cpp | 23 +++++++ src/InGameLoadingWindow.h | 19 ++++++ src/ScreenReloadSongs.cpp | 66 ++++++------------- src/ScreenReloadSongs.h | 11 ++-- src/StepMania-net2010.vcxproj.filters | 8 ++- 6 files changed, 76 insertions(+), 51 deletions(-) rename Themes/_fallback/Fonts/{ScreenReloadSongs LoadingText.redir => InGameLoadingWindow LoadingText.redir} (100%) create mode 100644 src/InGameLoadingWindow.cpp create mode 100644 src/InGameLoadingWindow.h diff --git a/Themes/_fallback/Fonts/ScreenReloadSongs LoadingText.redir b/Themes/_fallback/Fonts/InGameLoadingWindow LoadingText.redir similarity index 100% rename from Themes/_fallback/Fonts/ScreenReloadSongs LoadingText.redir rename to Themes/_fallback/Fonts/InGameLoadingWindow LoadingText.redir diff --git a/src/InGameLoadingWindow.cpp b/src/InGameLoadingWindow.cpp new file mode 100644 index 0000000000..381871e51b --- /dev/null +++ b/src/InGameLoadingWindow.cpp @@ -0,0 +1,23 @@ +#include "global.h" +#include "InGameLoadingWindow.h" +#include "ScreenManager.h" +#include "ThemeManager.h" +#include "ActorUtil.h" + +//REGISTER_ACTOR_CLASS( InGameLoadingWindow ); + +InGameLoadingWindow::InGameLoadingWindow() { + SetName("InGameLoadingWindow"); + m_Text.SetName("LoadingText"); + m_Text.LoadFromFont( THEME->GetPathF(m_sName, "LoadingText") ); + m_Text.SetXY(0,0); + AddChild(&m_Text); +} + +InGameLoadingWindow::~InGameLoadingWindow() { + RemoveChild(&m_Text); +} + +void InGameLoadingWindow::SetText( RString str ) { + m_Text.SetText( str ); +} diff --git a/src/InGameLoadingWindow.h b/src/InGameLoadingWindow.h new file mode 100644 index 0000000000..f9c4ae8b8b --- /dev/null +++ b/src/InGameLoadingWindow.h @@ -0,0 +1,19 @@ +#include "arch/LoadingWindow/LoadingWindow.h" +#include "BitmapText.h" +#include "RageTimer.h" +#include "global.h" +#include "ActorFrame.h" + +class InGameLoadingWindow: public LoadingWindow, public ActorFrame { + +public: + InGameLoadingWindow(); + ~InGameLoadingWindow(); + + void SetText( RString str ); + +private: + RageTimer m_LastDraw; + BitmapText m_Text; +}; + diff --git a/src/ScreenReloadSongs.cpp b/src/ScreenReloadSongs.cpp index 48d94907b0..cfa926dfba 100644 --- a/src/ScreenReloadSongs.cpp +++ b/src/ScreenReloadSongs.cpp @@ -6,38 +6,8 @@ #include "RageLog.h" #include "ThemeManager.h" #include "ScreenDimensions.h" - #include "arch/LoadingWindow/LoadingWindow.h" - -static const int DrawFrameRate = 20; -class ScreenReloadSongsLoadingWindow: public LoadingWindow -{ - RageTimer m_LastDraw; - BitmapText &m_BitmapText; - -public: - ScreenReloadSongsLoadingWindow( BitmapText &bt ): - m_BitmapText(bt) - { - } - - void SetText( RString str ) - { - m_BitmapText.SetText( str ); - Paint(); - } - - void Paint() - { - /* We load songs much faster than we draw frames. Cap the draw rate, - * so we don't slow down the reload. */ - if( m_LastDraw.PeekDeltaTime() < 1.0f/DrawFrameRate ) - return; - m_LastDraw.GetDeltaTime(); - - SCREENMAN->Draw(); - } -}; +#include "InGameLoadingWindow.h" /* This could be cleaned up: show progress, for example. Let's not use * this for the initial load, since we don't want to start up the display @@ -49,14 +19,16 @@ void ScreenReloadSongs::Init() { Screen::Init(); - m_iUpdates = 0; + loadWin=new InGameLoadingWindow( ); - m_Loading.SetName("LoadingText"); - m_Loading.LoadFromFont( THEME->GetPathF(m_sName, "LoadingText") ); - m_Loading.SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y ); - this->AddChild( &m_Loading ); + loadWin->SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y ); + + AddChild( loadWin ); - pLoadingWindow = new ScreenReloadSongsLoadingWindow( m_Loading ); + pLoadingWindow = new InGameLoadingWindow( ); + + m_loadingThread.SetName("Song reload work thread"); + m_loadingThread.Create(loadingThreadProc,this); } ScreenReloadSongs::~ScreenReloadSongs() @@ -64,20 +36,24 @@ ScreenReloadSongs::~ScreenReloadSongs() delete pLoadingWindow; } +void ScreenReloadSongs::Update( float fDeltaTime ) { + Screen::Update( fDeltaTime ); + + //SCREENMAN->Draw(); +} -void ScreenReloadSongs::Update( float fDeltaTime ) -{ - Screen::Update( fDeltaTime ); - /* Start the reload on the second update. On the first (0), SCREENMAN->Draw won't draw. */ - ++m_iUpdates; - if( m_iUpdates != 2 ) - return; - ASSERT( !IsFirstUpdate() ); + + +int ScreenReloadSongs::loadingThreadProc(void *thisAsVoidPtr) { + + ScreenReloadSongs *self=(ScreenReloadSongs *)thisAsVoidPtr; SONGMAN->Reload( false ); SCREENMAN->PostMessageToTopScreen( SM_GoToNextScreen, 0 ); + + return 0; } /* diff --git a/src/ScreenReloadSongs.h b/src/ScreenReloadSongs.h index 908f61da72..93ffa37d4f 100644 --- a/src/ScreenReloadSongs.h +++ b/src/ScreenReloadSongs.h @@ -2,8 +2,9 @@ #define SCREEN_RELOAD_SONGS_H #include "Screen.h" -#include "BitmapText.h" -class LoadingWindow; +#include "RageThreads.h" + +class InGameLoadingWindow; class ScreenReloadSongs: public Screen { @@ -11,10 +12,10 @@ public: virtual void Init(); ~ScreenReloadSongs(); void Update( float fDeltaTime ); - private: - int m_iUpdates; - BitmapText m_Loading; + InGameLoadingWindow *loadWin; + RageThread m_loadingThread; + static int loadingThreadProc(void *thisAsVoidPtr); }; #endif diff --git a/src/StepMania-net2010.vcxproj.filters b/src/StepMania-net2010.vcxproj.filters index 0d28f9a2c7..7c21d06c80 100644 --- a/src/StepMania-net2010.vcxproj.filters +++ b/src/StepMania-net2010.vcxproj.filters @@ -1629,6 +1629,9 @@ Data Structures + + Actors used in Menus + @@ -3026,6 +3029,9 @@ Data Structures + + Actors used in Menus + @@ -3154,4 +3160,4 @@ BaseClasses - + \ No newline at end of file From bce2fcbe2a769a3befb59242579a63fed5fe1721 Mon Sep 17 00:00:00 2001 From: Thai Pangsakulyanont Date: Sun, 5 Jun 2011 12:18:20 +0700 Subject: [PATCH 13/29] the progress now displays on a mac. Needs some visual adjustments though. --- Xcode/stepmania.xcodeproj/project.pbxproj | 8 ++++ src/arch/LoadingWindow/LoadingWindow_MacOSX.h | 2 + .../LoadingWindow/LoadingWindow_MacOSX.mm | 44 +++++++++++++++++-- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/Xcode/stepmania.xcodeproj/project.pbxproj b/Xcode/stepmania.xcodeproj/project.pbxproj index 83b2d2a8b7..296f1f0009 100644 --- a/Xcode/stepmania.xcodeproj/project.pbxproj +++ b/Xcode/stepmania.xcodeproj/project.pbxproj @@ -1661,6 +1661,8 @@ AAFF41A40F5BD4AD00FFDB67 /* ScreenOptionsExportPackage.h in Headers */ = {isa = PBXBuildFile; fileRef = AAFF41A20F5BD4AD00FFDB67 /* ScreenOptionsExportPackage.h */; }; AAFF41A50F5BD4AD00FFDB67 /* ScreenOptionsExportPackage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AAFF41A10F5BD4AD00FFDB67 /* ScreenOptionsExportPackage.cpp */; }; AAFF41A60F5BD4AD00FFDB67 /* ScreenOptionsExportPackage.h in Headers */ = {isa = PBXBuildFile; fileRef = AAFF41A20F5BD4AD00FFDB67 /* ScreenOptionsExportPackage.h */; }; + B71A60C0139B41DB00183A27 /* InGameLoadingWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B71A60BE139B41DB00183A27 /* InGameLoadingWindow.cpp */; }; + B71A60C1139B41DB00183A27 /* InGameLoadingWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = B71A60BF139B41DB00183A27 /* InGameLoadingWindow.h */; }; B75CE3B5137963350076A82D /* SongPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = B75CE3B3137963350076A82D /* SongPosition.h */; }; B75CE3B6137963350076A82D /* SongPosition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B75CE3B4137963350076A82D /* SongPosition.cpp */; }; EE2153A910A75BEE0074B01B /* NotesLoaderPMS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EE2153A710A75BEE0074B01B /* NotesLoaderPMS.cpp */; }; @@ -3056,6 +3058,8 @@ AAFF55220549F43A00D02EE9 /* ComboGraph.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; name = ComboGraph.h; path = ../src/ComboGraph.h; sourceTree = ""; }; AAFF5541054E736D00D02EE9 /* Attack.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; name = Attack.cpp; path = ../src/Attack.cpp; sourceTree = ""; }; AAFF5542054E736D00D02EE9 /* Attack.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; name = Attack.h; path = ../src/Attack.h; sourceTree = ""; }; + B71A60BE139B41DB00183A27 /* InGameLoadingWindow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InGameLoadingWindow.cpp; sourceTree = ""; }; + B71A60BF139B41DB00183A27 /* InGameLoadingWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InGameLoadingWindow.h; sourceTree = ""; }; B75CE3B3137963350076A82D /* SongPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SongPosition.h; path = ../src/SongPosition.h; sourceTree = SOURCE_ROOT; }; B75CE3B4137963350076A82D /* SongPosition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SongPosition.cpp; path = ../src/SongPosition.cpp; sourceTree = SOURCE_ROOT; }; EE2153A710A75BEE0074B01B /* NotesLoaderPMS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NotesLoaderPMS.cpp; path = ../src/NotesLoaderPMS.cpp; sourceTree = SOURCE_ROOT; }; @@ -3279,6 +3283,8 @@ 29B97315FDCFA39411CA2CEA /* Other Source */ = { isa = PBXGroup; children = ( + B71A60BE139B41DB00183A27 /* InGameLoadingWindow.cpp */, + B71A60BF139B41DB00183A27 /* InGameLoadingWindow.h */, AA70E3640663112800DAE1FD /* Foreach.h */, 3659B56D0F902143002B6B68 /* CommandLineActions.cpp */, 3659B56E0F902143002B6B68 /* CommandLineActions.h */, @@ -5148,6 +5154,7 @@ 2B9C2E8E137A138B004C92F3 /* NotesLoaderJson.h in Headers */, 2B9C2E90137A138B004C92F3 /* NotesWriterJson.h in Headers */, 2B43509513949F37006FA051 /* TimingSegments.h in Headers */, + B71A60C1139B41DB00183A27 /* InGameLoadingWindow.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -6489,6 +6496,7 @@ 2BD06FF2137242680018CB9F /* json_value.cpp in Sources */, 2BD06FF4137242680018CB9F /* json_writer.cpp in Sources */, 2B43509613949F37006FA051 /* TimingSegments.cpp in Sources */, + B71A60C0139B41DB00183A27 /* InGameLoadingWindow.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/arch/LoadingWindow/LoadingWindow_MacOSX.h b/src/arch/LoadingWindow/LoadingWindow_MacOSX.h index 29636eb7c0..23f45ddf1c 100644 --- a/src/arch/LoadingWindow/LoadingWindow_MacOSX.h +++ b/src/arch/LoadingWindow/LoadingWindow_MacOSX.h @@ -9,6 +9,8 @@ public: LoadingWindow_MacOSX(); ~LoadingWindow_MacOSX(); void SetText( RString str ); + void SetProgress( const int progress ); + void SetTotalWork( const int totalWork ); }; #define USE_LOADING_WINDOW_MACOSX diff --git a/src/arch/LoadingWindow/LoadingWindow_MacOSX.mm b/src/arch/LoadingWindow/LoadingWindow_MacOSX.mm index 4f26434a41..bc6a3cf9dc 100644 --- a/src/arch/LoadingWindow/LoadingWindow_MacOSX.mm +++ b/src/arch/LoadingWindow/LoadingWindow_MacOSX.mm @@ -10,8 +10,11 @@ NSWindow *m_Window; NSTextView *m_Text; NSAutoreleasePool *m_Pool; + NSProgressIndicator *m_ProgressIndicator; } - (void) setupWindow:(NSImage *)image; +- (void) setProgress:(NSNumber *)progress; +- (void) setTotalWork:(NSNumber *)totalWork; @end @implementation LoadingWindowHelper @@ -21,14 +24,25 @@ NSRect viewRect, windowRect; float height = 0.0f; + NSRect progressIndicatorRect; + progressIndicatorRect = NSMakeRect(0, 0, size.width, 0); + m_ProgressIndicator = [[NSProgressIndicator alloc] initWithFrame:progressIndicatorRect]; + [m_ProgressIndicator sizeToFit]; + [m_ProgressIndicator setIndeterminate:NO]; + [m_ProgressIndicator setMinValue:0]; + [m_ProgressIndicator setMaxValue:1]; + [m_ProgressIndicator setDoubleValue:0]; + progressIndicatorRect = [m_ProgressIndicator frame]; + float progressHeight = progressIndicatorRect.size.height; + NSFont *font = [NSFont systemFontOfSize:0.0f]; NSRect textRect; // Just give it a size until it is created. - textRect = NSMakeRect( 0, 0, size.width, size.height ); + textRect = NSMakeRect( 0, progressHeight, size.width, size.height ); m_Text = [[NSTextView alloc] initWithFrame:textRect]; [m_Text setFont:font]; height = [[m_Text layoutManager] defaultLineHeightForFont:font]*3 + 4; - textRect = NSMakeRect( 0, 0, size.width, height ); + textRect = NSMakeRect( 0, progressHeight, size.width, height ); [m_Text setFrame:textRect]; [m_Text setEditable:NO]; @@ -40,12 +54,12 @@ [m_Text setVerticallyResizable:NO]; [m_Text setString:@"Initializing Hardware..."]; - viewRect = NSMakeRect( 0, height, size.width, size.height ); + viewRect = NSMakeRect( 0, height + progressHeight, size.width, size.height ); NSImageView *iView = [[NSImageView alloc] initWithFrame:viewRect]; [iView setImage:image]; [iView setImageFrameStyle:NSImageFrameNone]; - windowRect = NSMakeRect( 0, 0, size.width, size.height + height ); + windowRect = NSMakeRect( 0, 0, size.width, size.height + height + progressHeight); m_Window = [[NSWindow alloc] initWithContentRect:windowRect styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered @@ -66,10 +80,22 @@ [view addSubview:iView]; [m_Text release]; [iView release]; + [view addSubview:m_ProgressIndicator]; // Display the window. [m_Window makeKeyAndOrderFront:nil]; } + +- (void) setProgress:(NSNumber *)progress +{ + [m_ProgressIndicator setDoubleValue:[progress doubleValue]]; +} + +- (void) setTotalWork:(NSNumber *)totalWork +{ + [m_ProgressIndicator setMaxValue:[totalWork doubleValue]]; +} + @end static LoadingWindowHelper *g_Helper = nil; @@ -124,6 +150,16 @@ void LoadingWindow_MacOSX::SetText( RString str ) [s release]; } +void LoadingWindow_MacOSX::SetProgress( const int progress ) +{ + [g_Helper performSelectorOnMainThread:@selector(setProgress:) withObject:[NSNumber numberWithDouble:(double)progress] waitUntilDone:NO]; +} + +void LoadingWindow_MacOSX::SetTotalWork( const int totalWork ) +{ + [g_Helper performSelectorOnMainThread:@selector(setTotalWork:) withObject:[NSNumber numberWithDouble:(double)totalWork] waitUntilDone:NO]; +} + /* * (c) 2003-2006, 2008 Steve Checkoway * All rights reserved. From 6f624538ce0eea95244335986b075656e9f7c4c8 Mon Sep 17 00:00:00 2001 From: Thai Pangsakulyanont Date: Sun, 5 Jun 2011 12:45:28 +0700 Subject: [PATCH 14/29] display progress for song loading --- src/SongManager.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/SongManager.cpp b/src/SongManager.cpp index b4cfceab4e..acb3926267 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -237,11 +237,16 @@ void SongManager::LoadStepManiaSongDir( RString sDir ) SortRStringArray( arrayGroupDirs ); StripCvsAndSvn( arrayGroupDirs ); StripMacResourceForks( arrayGroupDirs ); - + + vector< vector > arrayGroupSongDirs; + int groupIndex, songCount, songIndex; + + groupIndex = 0; + songCount = 0; FOREACH_CONST( RString, arrayGroupDirs, s ) // foreach dir in /Songs/ { + RString sGroupDirName = *s; - SanityCheckGroupDir(sDir+sGroupDirName); // Find all Song folders in this group directory @@ -250,6 +255,21 @@ void SongManager::LoadStepManiaSongDir( RString sDir ) StripCvsAndSvn( arraySongDirs ); StripMacResourceForks( arraySongDirs ); SortRStringArray( arraySongDirs ); + + arrayGroupSongDirs.push_back(arraySongDirs); + songCount += arraySongDirs.size(); + + } + + if( pLoadingWindow ) + pLoadingWindow->SetTotalWork( songCount ); + + groupIndex = 0; + songIndex = 0; + FOREACH_CONST( RString, arrayGroupDirs, s ) // foreach dir in /Songs/ + { + RString sGroupDirName = *s; + vector &arraySongDirs = arrayGroupSongDirs[groupIndex++]; LOG->Trace("Attempting to load %i songs from \"%s\"", int(arraySongDirs.size()), (sDir+sGroupDirName).c_str() ); @@ -264,6 +284,7 @@ void SongManager::LoadStepManiaSongDir( RString sDir ) // this is a song directory. Load a new song. if( pLoadingWindow ) { + pLoadingWindow->SetProgress(songIndex); pLoadingWindow->SetText( LOADING_SONGS.GetValue()+ssprintf("\n%s\n%s", Basename(sGroupDirName).c_str(), Basename(sSongDirName).c_str())); @@ -279,6 +300,7 @@ void SongManager::LoadStepManiaSongDir( RString sDir ) m_pSongs.push_back( pNewSong ); index_entry.push_back( pNewSong ); loaded++; + songIndex++; } LOG->Trace("Loaded %i songs from \"%s\"", loaded, (sDir+sGroupDirName).c_str() ); From af62e62b425a3adbdbda5e3e60db4fca0b780318 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sun, 5 Jun 2011 02:12:09 -0400 Subject: [PATCH 15/29] [loading window] .hgeol --- .../LoadingWindow/LoadingWindow_Win32.cpp | 516 +++++++++--------- 1 file changed, 258 insertions(+), 258 deletions(-) diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp index 57414399a8..4c3d2a9212 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp @@ -1,258 +1,258 @@ -#include "global.h" -#include "RageUtil.h" - -#include "LoadingWindow_Win32.h" -#include "RageFileManager.h" -#include "archutils/win32/WindowsResources.h" -#include "archutils/win32/WindowIcon.h" -#include "archutils/win32/ErrorStrings.h" -#include -#include "CommCtrl.h" -#include "RageSurface_Load.h" -#include "RageSurface.h" -#include "RageSurfaceUtils.h" -#include "RageLog.h" -#include "ProductInfo.h" -#include "LocalizedString.h" - -#include "RageSurfaceUtils_Zoom.h" -static HBITMAP g_hBitmap = NULL; - -#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") - - -/* Load a RageSurface into a GDI surface. */ -static HBITMAP LoadWin32Surface( RageSurface *&s ) -{ - RageSurfaceUtils::ConvertSurface( s, s->w, s->h, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0 ); - - HDC hScreen = GetDC(NULL); - ASSERT_M( hScreen, werr_ssprintf(GetLastError(), "hScreen") ); - - HBITMAP bitmap = CreateCompatibleBitmap( hScreen, s->w, s->h ); - ASSERT_M( bitmap, werr_ssprintf(GetLastError(), "CreateCompatibleBitmap") ); - - HDC BitmapDC = CreateCompatibleDC( hScreen ); - SelectObject( BitmapDC, bitmap ); - - /* This is silly, but simple. We only do this once, on a small image. */ - for( int y = 0; y < s->h; ++y ) - { - unsigned const char *line = ((unsigned char *) s->pixels) + (y * s->pitch); - for( int x = 0; x < s->w; ++x ) - { - unsigned const char *data = line + (x*s->format->BytesPerPixel); - - SetPixelV( BitmapDC, x, y, RGB( data[3], data[2], data[1] ) ); - } - } - - SelectObject( BitmapDC, NULL ); - DeleteObject( BitmapDC ); - - ReleaseDC( NULL, hScreen ); - - return bitmap; -} - -static HBITMAP LoadWin32Surface( RString sFile, HWND hWnd ) -{ - RString error; - RageSurface *pSurface = RageSurfaceUtils::LoadFile( sFile, error ); - if( pSurface == NULL ) - return NULL; - - /* Resize the splash image to fit the dialog. Stretch to fit horizontally, - * maintaining aspect ratio. */ - { - RECT r; - GetClientRect( hWnd, &r ); - - int iWidth = r.right; - float fRatio = (float) iWidth / pSurface->w; - int iHeight = lrintf( pSurface->h * fRatio ); - - RageSurfaceUtils::Zoom( pSurface, iWidth, iHeight ); - } - - HBITMAP ret = LoadWin32Surface( pSurface ); - delete pSurface; - return ret; -} - -INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - - LoadingWindow_Win32 *self; - - if(msg==WM_INITDIALOG) { - self=(LoadingWindow_Win32 *)lParam; - SetWindowLong(hWnd,DWL_USER,(LONG)self); - } else { - self=(LoadingWindow_Win32 *)GetWindowLong(hWnd,DWL_USER); - } - - switch( msg ) - { - case WM_INITDIALOG: - { - vector vs; - GetDirListing( "Data/splash*.png", vs, false, true ); - if( !vs.empty() ) - g_hBitmap = LoadWin32Surface( vs[0], hWnd ); - } - if( g_hBitmap == NULL ) - g_hBitmap = LoadWin32Surface( "Data/splash.bmp", hWnd ); - SendMessage( - GetDlgItem(hWnd,IDC_SPLASH), - STM_SETIMAGE, - (WPARAM) IMAGE_BITMAP, - (LPARAM) (HANDLE) g_hBitmap ); - SetWindowTextA( hWnd, PRODUCT_ID ); - - { - HWND progressCtrl=GetDlgItem( hWnd, IDC_PROGRESS ); - SetWindowLong(progressCtrl,GWL_STYLE, PBS_MARQUEE | GetWindowLong(progressCtrl,GWL_STYLE)); - SendMessage(progressCtrl,PBM_SETMARQUEE,1,0); - } - break; - - case WM_DESTROY: - DeleteObject( g_hBitmap ); - g_hBitmap = NULL; - self->runMessageLoop=false; - self->hwnd=NULL; - return TRUE; - break; - - case WM_APP: - DestroyWindow(hWnd); - self->runMessageLoop=false; - ExitThread(0); - return TRUE; - break; - } - - return FALSE; -} - -void LoadingWindow_Win32::SetIcon( const RageSurface *pIcon ) -{ - if( m_hIcon != NULL ) - DestroyIcon( m_hIcon ); - - m_hIcon = IconFromSurface( pIcon ); - if( m_hIcon != NULL ) - SetClassLong( hwnd, GCL_HICON, (LONG) m_hIcon ); -} - -LoadingWindow_Win32::LoadingWindow_Win32() -{ - INITCOMMONCONTROLSEX cceData; - cceData.dwSize=sizeof(INITCOMMONCONTROLSEX); - cceData.dwICC=ICC_PROGRESS_CLASS; - InitCommonControlsEx(&cceData); - - m_hIcon = NULL; - - runMessageLoop=true; - - guiReadyEvent=CreateEvent(NULL,FALSE,FALSE,NULL); - - pumpThread=CreateThread(NULL, NULL, MessagePump, (void *)this, 0, &pumpThreadId); - - WaitForSingleObject(guiReadyEvent,INFINITE); - - for( unsigned i = 0; i < 3; ++i ) - text[i] = "ABC"; /* always set on first call */ - SetText( "" ); -} - -LoadingWindow_Win32::~LoadingWindow_Win32() -{ - SendMessage(hwnd,WM_APP,0,0); - //SendMessage(hwnd,WM_NULL,0,0); - WaitForSingleObject(pumpThread,INFINITE); - if(guiReadyEvent) - CloseHandle(guiReadyEvent); - if( m_hIcon != NULL ) - DestroyIcon( m_hIcon ); -} - -DWORD WINAPI LoadingWindow_Win32::MessagePump(LPVOID thisAsVoidPtr) -{ - LoadingWindow_Win32 *self=(LoadingWindow_Win32 *)thisAsVoidPtr; - - self->hwnd = CreateDialogParam( self->handle.Get(), MAKEINTRESOURCE(IDD_LOADING_DIALOG), NULL, DlgProc, (LPARAM)thisAsVoidPtr); - - SetEvent(self->guiReadyEvent); - - // Run the message loop in a separate thread to keep the gui responsive during the loading - MSG msg; - while(self->runMessageLoop && GetMessage(&msg, self->hwnd, 0, 0 ) ) - { - if(IsDialogMessage(self->hwnd,&msg)) continue; - DispatchMessage( &msg ); - } - - return msg.wParam; -} - -void LoadingWindow_Win32::SetText( RString sText ) -{ - vector asMessageLines; - split( sText, "\n", asMessageLines, false ); - while( asMessageLines.size() < 3 ) - asMessageLines.push_back( "" ); - - const int msgid[] = { IDC_STATIC_MESSAGE1, IDC_STATIC_MESSAGE2, IDC_STATIC_MESSAGE3 }; - for( unsigned i = 0; i < 3; ++i ) - { - if( text[i] == asMessageLines[i] ) - continue; - text[i] = asMessageLines[i]; - - HWND hwndItem = ::GetDlgItem( hwnd, msgid[i] ); - - ::SetWindowText( hwndItem, ConvertUTF8ToACP(asMessageLines[i]).c_str() ); - } -} - -void LoadingWindow_Win32::SetProgress(const int progress) -{ - m_progress=progress; - HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); - ::SendMessage(hwndItem,PBM_SETPOS,progress,0); -} - -void LoadingWindow_Win32::SetTotalWork(const int totalWork) -{ - m_totalWork=totalWork; - HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); - ::SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork); -} - -/* - * (c) 2001-2004 Chris Danford, Glenn Maynard - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ +#include "global.h" +#include "RageUtil.h" + +#include "LoadingWindow_Win32.h" +#include "RageFileManager.h" +#include "archutils/win32/WindowsResources.h" +#include "archutils/win32/WindowIcon.h" +#include "archutils/win32/ErrorStrings.h" +#include +#include "CommCtrl.h" +#include "RageSurface_Load.h" +#include "RageSurface.h" +#include "RageSurfaceUtils.h" +#include "RageLog.h" +#include "ProductInfo.h" +#include "LocalizedString.h" + +#include "RageSurfaceUtils_Zoom.h" +static HBITMAP g_hBitmap = NULL; + +#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") + + +/* Load a RageSurface into a GDI surface. */ +static HBITMAP LoadWin32Surface( RageSurface *&s ) +{ + RageSurfaceUtils::ConvertSurface( s, s->w, s->h, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0 ); + + HDC hScreen = GetDC(NULL); + ASSERT_M( hScreen, werr_ssprintf(GetLastError(), "hScreen") ); + + HBITMAP bitmap = CreateCompatibleBitmap( hScreen, s->w, s->h ); + ASSERT_M( bitmap, werr_ssprintf(GetLastError(), "CreateCompatibleBitmap") ); + + HDC BitmapDC = CreateCompatibleDC( hScreen ); + SelectObject( BitmapDC, bitmap ); + + /* This is silly, but simple. We only do this once, on a small image. */ + for( int y = 0; y < s->h; ++y ) + { + unsigned const char *line = ((unsigned char *) s->pixels) + (y * s->pitch); + for( int x = 0; x < s->w; ++x ) + { + unsigned const char *data = line + (x*s->format->BytesPerPixel); + + SetPixelV( BitmapDC, x, y, RGB( data[3], data[2], data[1] ) ); + } + } + + SelectObject( BitmapDC, NULL ); + DeleteObject( BitmapDC ); + + ReleaseDC( NULL, hScreen ); + + return bitmap; +} + +static HBITMAP LoadWin32Surface( RString sFile, HWND hWnd ) +{ + RString error; + RageSurface *pSurface = RageSurfaceUtils::LoadFile( sFile, error ); + if( pSurface == NULL ) + return NULL; + + /* Resize the splash image to fit the dialog. Stretch to fit horizontally, + * maintaining aspect ratio. */ + { + RECT r; + GetClientRect( hWnd, &r ); + + int iWidth = r.right; + float fRatio = (float) iWidth / pSurface->w; + int iHeight = lrintf( pSurface->h * fRatio ); + + RageSurfaceUtils::Zoom( pSurface, iWidth, iHeight ); + } + + HBITMAP ret = LoadWin32Surface( pSurface ); + delete pSurface; + return ret; +} + +INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) +{ + + LoadingWindow_Win32 *self; + + if(msg==WM_INITDIALOG) { + self=(LoadingWindow_Win32 *)lParam; + SetWindowLong(hWnd,DWL_USER,(LONG)self); + } else { + self=(LoadingWindow_Win32 *)GetWindowLong(hWnd,DWL_USER); + } + + switch( msg ) + { + case WM_INITDIALOG: + { + vector vs; + GetDirListing( "Data/splash*.png", vs, false, true ); + if( !vs.empty() ) + g_hBitmap = LoadWin32Surface( vs[0], hWnd ); + } + if( g_hBitmap == NULL ) + g_hBitmap = LoadWin32Surface( "Data/splash.bmp", hWnd ); + SendMessage( + GetDlgItem(hWnd,IDC_SPLASH), + STM_SETIMAGE, + (WPARAM) IMAGE_BITMAP, + (LPARAM) (HANDLE) g_hBitmap ); + SetWindowTextA( hWnd, PRODUCT_ID ); + + { + HWND progressCtrl=GetDlgItem( hWnd, IDC_PROGRESS ); + SetWindowLong(progressCtrl,GWL_STYLE, PBS_MARQUEE | GetWindowLong(progressCtrl,GWL_STYLE)); + SendMessage(progressCtrl,PBM_SETMARQUEE,1,0); + } + break; + + case WM_DESTROY: + DeleteObject( g_hBitmap ); + g_hBitmap = NULL; + self->runMessageLoop=false; + self->hwnd=NULL; + return TRUE; + break; + + case WM_APP: + DestroyWindow(hWnd); + self->runMessageLoop=false; + ExitThread(0); + return TRUE; + break; + } + + return FALSE; +} + +void LoadingWindow_Win32::SetIcon( const RageSurface *pIcon ) +{ + if( m_hIcon != NULL ) + DestroyIcon( m_hIcon ); + + m_hIcon = IconFromSurface( pIcon ); + if( m_hIcon != NULL ) + SetClassLong( hwnd, GCL_HICON, (LONG) m_hIcon ); +} + +LoadingWindow_Win32::LoadingWindow_Win32() +{ + INITCOMMONCONTROLSEX cceData; + cceData.dwSize=sizeof(INITCOMMONCONTROLSEX); + cceData.dwICC=ICC_PROGRESS_CLASS; + InitCommonControlsEx(&cceData); + + m_hIcon = NULL; + + runMessageLoop=true; + + guiReadyEvent=CreateEvent(NULL,FALSE,FALSE,NULL); + + pumpThread=CreateThread(NULL, NULL, MessagePump, (void *)this, 0, &pumpThreadId); + + WaitForSingleObject(guiReadyEvent,INFINITE); + + for( unsigned i = 0; i < 3; ++i ) + text[i] = "ABC"; /* always set on first call */ + SetText( "" ); +} + +LoadingWindow_Win32::~LoadingWindow_Win32() +{ + SendMessage(hwnd,WM_APP,0,0); + //SendMessage(hwnd,WM_NULL,0,0); + WaitForSingleObject(pumpThread,INFINITE); + if(guiReadyEvent) + CloseHandle(guiReadyEvent); + if( m_hIcon != NULL ) + DestroyIcon( m_hIcon ); +} + +DWORD WINAPI LoadingWindow_Win32::MessagePump(LPVOID thisAsVoidPtr) +{ + LoadingWindow_Win32 *self=(LoadingWindow_Win32 *)thisAsVoidPtr; + + self->hwnd = CreateDialogParam( self->handle.Get(), MAKEINTRESOURCE(IDD_LOADING_DIALOG), NULL, DlgProc, (LPARAM)thisAsVoidPtr); + + SetEvent(self->guiReadyEvent); + + // Run the message loop in a separate thread to keep the gui responsive during the loading + MSG msg; + while(self->runMessageLoop && GetMessage(&msg, self->hwnd, 0, 0 ) ) + { + if(IsDialogMessage(self->hwnd,&msg)) continue; + DispatchMessage( &msg ); + } + + return msg.wParam; +} + +void LoadingWindow_Win32::SetText( RString sText ) +{ + vector asMessageLines; + split( sText, "\n", asMessageLines, false ); + while( asMessageLines.size() < 3 ) + asMessageLines.push_back( "" ); + + const int msgid[] = { IDC_STATIC_MESSAGE1, IDC_STATIC_MESSAGE2, IDC_STATIC_MESSAGE3 }; + for( unsigned i = 0; i < 3; ++i ) + { + if( text[i] == asMessageLines[i] ) + continue; + text[i] = asMessageLines[i]; + + HWND hwndItem = ::GetDlgItem( hwnd, msgid[i] ); + + ::SetWindowText( hwndItem, ConvertUTF8ToACP(asMessageLines[i]).c_str() ); + } +} + +void LoadingWindow_Win32::SetProgress(const int progress) +{ + m_progress=progress; + HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); + ::SendMessage(hwndItem,PBM_SETPOS,progress,0); +} + +void LoadingWindow_Win32::SetTotalWork(const int totalWork) +{ + m_totalWork=totalWork; + HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); + ::SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork); +} + +/* + * (c) 2001-2004 Chris Danford, Glenn Maynard + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ From 167cd9238af59155c8b3da25223ec1ddf0e6ba83 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sun, 5 Jun 2011 11:32:51 +0200 Subject: [PATCH 16/29] [loading window] Should really have included this in the initial design. Now it can be indeterminate too. --- src/SongManager.cpp | 10 +++++++- src/StepMania.cpp | 7 +++--- src/arch/LoadingWindow/LoadingWindow.cpp | 5 +++- src/arch/LoadingWindow/LoadingWindow.h | 2 ++ .../LoadingWindow/LoadingWindow_Win32.cpp | 25 ++++++++++++++----- src/arch/LoadingWindow/LoadingWindow_Win32.h | 1 + 6 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/SongManager.cpp b/src/SongManager.cpp index acb3926267..8b1ca6b2a6 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -260,9 +260,13 @@ void SongManager::LoadStepManiaSongDir( RString sDir ) songCount += arraySongDirs.size(); } + + if( songCount==0 ) return; - if( pLoadingWindow ) + if( pLoadingWindow ) { + pLoadingWindow->SetIndeterminate( false ); pLoadingWindow->SetTotalWork( songCount ); + } groupIndex = 0; songIndex = 0; @@ -318,6 +322,10 @@ void SongManager::LoadStepManiaSongDir( RString sDir ) LoadGroupSymLinks(sDir, sGroupDirName); } + if( pLoadingWindow ) { + pLoadingWindow->SetIndeterminate( true ); + } + LoadEnabledSongsFromPref(); } diff --git a/src/StepMania.cpp b/src/StepMania.cpp index 3463d57b47..e72f6f621d 100644 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -1101,6 +1101,10 @@ int main(int argc, char* argv[]) pLoadingWindow->SetText("Initializing statics manager..."); STATSMAN = new StatsManager; + // Initialize which courses are ranking courses here. + pLoadingWindow->SetText("Updating cource rankings..."); + SONGMAN->UpdateRankingCourses(); + SAFE_DELETE( pLoadingWindow ); // destroy this before init'ing Display /* If the user has tried to quit during the loading, do it before creating @@ -1140,9 +1144,6 @@ int main(int argc, char* argv[]) CodeDetector::RefreshCacheItems(); - // Initialize which courses are ranking courses here. - SONGMAN->UpdateRankingCourses(); - if( GetCommandlineArgument("netip") ) NSMAN->DisplayStartupStatus(); // If we're using networking show what happened diff --git a/src/arch/LoadingWindow/LoadingWindow.cpp b/src/arch/LoadingWindow/LoadingWindow.cpp index 130d298a04..c96afbff84 100644 --- a/src/arch/LoadingWindow/LoadingWindow.cpp +++ b/src/arch/LoadingWindow/LoadingWindow.cpp @@ -47,9 +47,12 @@ LoadingWindow *LoadingWindow::Create() } } - if( ret ) + if( ret ) { LOG->Info( "Loading window: %s", Driver.c_str() ); + ret->SetIndeterminate(true); + } + return ret; } diff --git a/src/arch/LoadingWindow/LoadingWindow.h b/src/arch/LoadingWindow/LoadingWindow.h index dcd3a339c5..4cc23cd097 100644 --- a/src/arch/LoadingWindow/LoadingWindow.h +++ b/src/arch/LoadingWindow/LoadingWindow.h @@ -15,10 +15,12 @@ public: virtual void SetIcon( const RageSurface *pIcon ) { } virtual void SetProgress( const int progress ) { m_progress=progress; } virtual void SetTotalWork( const int totalWork ) { m_totalWork=totalWork; } + virtual void SetIndeterminate( bool indeterminate ) { m_indeterminate=indeterminate; } protected: int m_progress; int m_totalWork; + bool m_indeterminate; }; extern LoadingWindow *pLoadingWindow; diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp index 4c3d2a9212..f152af9b2b 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp @@ -110,13 +110,11 @@ INT_PTR CALLBACK LoadingWindow_Win32::DlgProc( HWND hWnd, UINT msg, WPARAM wPara (LPARAM) (HANDLE) g_hBitmap ); SetWindowTextA( hWnd, PRODUCT_ID ); - { - HWND progressCtrl=GetDlgItem( hWnd, IDC_PROGRESS ); - SetWindowLong(progressCtrl,GWL_STYLE, PBS_MARQUEE | GetWindowLong(progressCtrl,GWL_STYLE)); - SendMessage(progressCtrl,PBM_SETMARQUEE,1,0); - } break; + case WM_CLOSE: + return FALSE; + case WM_DESTROY: DeleteObject( g_hBitmap ); g_hBitmap = NULL; @@ -229,7 +227,22 @@ void LoadingWindow_Win32::SetTotalWork(const int totalWork) { m_totalWork=totalWork; HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); - ::SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork); + SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork); +} + +void LoadingWindow_Win32::SetIndeterminate(bool indeterminate) { + m_indeterminate=indeterminate; + + HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); + + if(indeterminate) { + SetWindowLong(hwndItem,GWL_STYLE, PBS_MARQUEE | GetWindowLong(hwndItem,GWL_STYLE)); + SendMessage(hwndItem,PBM_SETMARQUEE,1,0); + } else { + SendMessage(hwndItem,PBM_SETMARQUEE,0,0); + SetWindowLong(hwndItem,GWL_STYLE, (~PBS_MARQUEE) & GetWindowLong(hwndItem,GWL_STYLE)); + } + } /* diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.h b/src/arch/LoadingWindow/LoadingWindow_Win32.h index d1adeca283..3c45789779 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.h +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.h @@ -17,6 +17,7 @@ public: void SetIcon( const RageSurface *pIcon ); void SetProgress( const int progress ); void SetTotalWork( const int totalWork ); + void SetIndeterminate( bool indeterminate ); private: AppInstance handle; From 16797099813c67569ad28c0ea87e7ff23a22abe5 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sun, 5 Jun 2011 12:24:04 +0200 Subject: [PATCH 17/29] [loading window] Now it uses the correct instance. I hate stupid errors like this. --- src/ScreenReloadSongs.cpp | 19 ++++++------------- src/ScreenReloadSongs.h | 1 - 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/ScreenReloadSongs.cpp b/src/ScreenReloadSongs.cpp index cfa926dfba..e5db726fdb 100644 --- a/src/ScreenReloadSongs.cpp +++ b/src/ScreenReloadSongs.cpp @@ -21,11 +21,11 @@ void ScreenReloadSongs::Init() loadWin=new InGameLoadingWindow( ); - loadWin->SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y ); - AddChild( loadWin ); - pLoadingWindow = new InGameLoadingWindow( ); + loadWin->SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y ); + + pLoadingWindow=loadWin; m_loadingThread.SetName("Song reload work thread"); m_loadingThread.Create(loadingThreadProc,this); @@ -33,18 +33,11 @@ void ScreenReloadSongs::Init() ScreenReloadSongs::~ScreenReloadSongs() { - delete pLoadingWindow; + //m_loadingThread.Halt(true); + RemoveChild(loadWin); + delete loadWin; } -void ScreenReloadSongs::Update( float fDeltaTime ) { - Screen::Update( fDeltaTime ); - - //SCREENMAN->Draw(); -} - - - - int ScreenReloadSongs::loadingThreadProc(void *thisAsVoidPtr) { ScreenReloadSongs *self=(ScreenReloadSongs *)thisAsVoidPtr; diff --git a/src/ScreenReloadSongs.h b/src/ScreenReloadSongs.h index 93ffa37d4f..5c3733aae3 100644 --- a/src/ScreenReloadSongs.h +++ b/src/ScreenReloadSongs.h @@ -11,7 +11,6 @@ class ScreenReloadSongs: public Screen public: virtual void Init(); ~ScreenReloadSongs(); - void Update( float fDeltaTime ); private: InGameLoadingWindow *loadWin; RageThread m_loadingThread; From 98204d5b56b59439e15fb42c1bcfe74067cc28ca Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sun, 5 Jun 2011 12:25:07 +0200 Subject: [PATCH 18/29] [loading window] Forgot to refresh before commiting, again. --- src/InGameLoadingWindow.cpp | 10 +++++++++- src/InGameLoadingWindow.h | 28 +++++++++++++++------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/InGameLoadingWindow.cpp b/src/InGameLoadingWindow.cpp index 381871e51b..39c06fa44c 100644 --- a/src/InGameLoadingWindow.cpp +++ b/src/InGameLoadingWindow.cpp @@ -19,5 +19,13 @@ InGameLoadingWindow::~InGameLoadingWindow() { } void InGameLoadingWindow::SetText( RString str ) { - m_Text.SetText( str ); + textChanged=true; + currentText=str; +} + +void InGameLoadingWindow::Update(float delta) { + if(textChanged) { + m_Text.SetText( currentText ); + textChanged=false; + } } diff --git a/src/InGameLoadingWindow.h b/src/InGameLoadingWindow.h index f9c4ae8b8b..52f967ed71 100644 --- a/src/InGameLoadingWindow.h +++ b/src/InGameLoadingWindow.h @@ -4,16 +4,18 @@ #include "global.h" #include "ActorFrame.h" -class InGameLoadingWindow: public LoadingWindow, public ActorFrame { - -public: - InGameLoadingWindow(); - ~InGameLoadingWindow(); - - void SetText( RString str ); - -private: - RageTimer m_LastDraw; - BitmapText m_Text; -}; - +class InGameLoadingWindow: public LoadingWindow, public ActorFrame { + +public: + InGameLoadingWindow(); + ~InGameLoadingWindow(); + + void SetText( RString str ); + void Update ( float delta ); + +private: + bool textChanged; + RString currentText; + BitmapText m_Text; +}; + From 881a6534e82b45b2e22f1449039b163a9d35bf33 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sun, 5 Jun 2011 15:37:22 +0200 Subject: [PATCH 19/29] [loading window] Unloading should be reported as well. --- Themes/_fallback/Languages/en.ini | 2 ++ src/SongManager.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/Themes/_fallback/Languages/en.ini b/Themes/_fallback/Languages/en.ini index 1884302235..81723d3615 100644 --- a/Themes/_fallback/Languages/en.ini +++ b/Themes/_fallback/Languages/en.ini @@ -1657,6 +1657,8 @@ Error adding file '%s'.=Error adding file '%s'. Loading courses...=Loading courses... Loading songs...=Loading songs... Reloading...=Reloading... +Unloading songs...=Unloading songs... +Unloading courses...=Unloading courses... The folder "%s" appears to be a song folder. All song folders must reside in a group folder. For example, "Songs/Originals/My Song".=The folder "%s" appears to be a song folder. All song folders must reside in a group folder. For example, "Songs/Originals/My Song" will contain the music file (MP3, OGG...), the steps file (.sm, .dwi, .ksf...) and other related files. [SongUtil] diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 8b1ca6b2a6..804bc2aa5b 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -98,6 +98,8 @@ void SongManager::InitAll() } static LocalizedString RELOADING ( "SongManager", "Reloading..." ); +static LocalizedString UNLOADING_SONGS ( "SongManager", "Unloading songs..." ); +static LocalizedString UNLOADING_COURSES ( "SongManager", "Unloading courses..." ); void SongManager::Reload( bool bAllowFastLoad ) { FILEMAN->FlushDirCache( SpecialFiles::SONGS_DIR ); @@ -112,7 +114,13 @@ void SongManager::Reload( bool bAllowFastLoad ) // save scores before unloading songs, of the scores will be lost PROFILEMAN->SaveMachineProfile(); + if( pLoadingWindow ) + pLoadingWindow->SetText( UNLOADING_COURSES ); + FreeCourses(); + + if( pLoadingWindow ) + pLoadingWindow->SetText( UNLOADING_SONGS ); FreeSongs(); const bool OldVal = PREFSMAN->m_bFastLoad; From 6d0f3f9db451280ae0d69c870389ed590c1cd863 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sun, 5 Jun 2011 15:40:41 +0200 Subject: [PATCH 20/29] [loading window] Might as well expose thread specific versions too. --- src/RageThreads.cpp | 11 +++++++++++ src/RageThreads.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/RageThreads.cpp b/src/RageThreads.cpp index 5b86d22999..1396fb869b 100644 --- a/src/RageThreads.cpp +++ b/src/RageThreads.cpp @@ -322,6 +322,17 @@ int RageThread::Wait() return ret; } +void RageThread::Halt(bool Kill) { + ASSERT( m_pSlot != NULL ); + ASSERT( m_pSlot->m_pImpl != NULL ); + m_pSlot->m_pImpl->Halt(Kill); +} + +void RageThread::Resume() { + ASSERT( m_pSlot != NULL ); + ASSERT( m_pSlot->m_pImpl != NULL ); + m_pSlot->m_pImpl->Resume(); +} void RageThread::HaltAllThreads( bool Kill ) { diff --git a/src/RageThreads.h b/src/RageThreads.h index 5f43ccc330..1fc7c7f49f 100644 --- a/src/RageThreads.h +++ b/src/RageThreads.h @@ -15,6 +15,9 @@ public: RString GetName() const { return m_sName; } void Create( int (*fn)(void *), void *data ); + void Halt( bool Kill=false); + void Resume(); + /* For crash handlers: kill or suspend all threads (except for * the running one) immediately. */ static void HaltAllThreads( bool Kill=false ); From 17814f36387de002d74c42292637bc8a67cd0eeb Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sun, 5 Jun 2011 15:41:20 +0200 Subject: [PATCH 21/29] [loading window] Oops, forgot to add the new files to the project. --- src/StepMania-net2010.vcxproj | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/StepMania-net2010.vcxproj b/src/StepMania-net2010.vcxproj index 9f314df1dc..2dc4b6b9ca 100644 --- a/src/StepMania-net2010.vcxproj +++ b/src/StepMania-net2010.vcxproj @@ -76,7 +76,7 @@ false $(TargetDir) $(SolutionDir)/build-$(SolutionName)/$(ProjectName)/$(Configuration)\ - false + true true $(SolutionDir)$(Configuration)\ $(Configuration)\ @@ -268,7 +268,7 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir) true ProgramDatabase 4063;4100;4127;4201;4244;4275;4355;4505;4512;4702;4786;4996;%(DisableSpecificWarnings) - true + false AnySuitable true Speed @@ -295,7 +295,7 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir) SendErrorReport - UseLinkTimeCodeGeneration + Default archutils\Win32\mapconv "$(IntDir)$(TargetName).map" "$(TargetDir)\StepMania-fastdebug.vdi" @@ -371,6 +371,7 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir) + @@ -1689,6 +1690,7 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir) + From 2f33ead363e878e2fb61821821aef09edb789aba Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sun, 5 Jun 2011 10:06:44 -0400 Subject: [PATCH 22/29] [loading window] .hgeol --- src/InGameLoadingWindow.h | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/InGameLoadingWindow.h b/src/InGameLoadingWindow.h index 52f967ed71..431be5119f 100644 --- a/src/InGameLoadingWindow.h +++ b/src/InGameLoadingWindow.h @@ -1,21 +1,21 @@ -#include "arch/LoadingWindow/LoadingWindow.h" -#include "BitmapText.h" -#include "RageTimer.h" -#include "global.h" -#include "ActorFrame.h" - -class InGameLoadingWindow: public LoadingWindow, public ActorFrame { - -public: - InGameLoadingWindow(); - ~InGameLoadingWindow(); - - void SetText( RString str ); - void Update ( float delta ); - -private: - bool textChanged; - RString currentText; - BitmapText m_Text; -}; - +#include "arch/LoadingWindow/LoadingWindow.h" +#include "BitmapText.h" +#include "RageTimer.h" +#include "global.h" +#include "ActorFrame.h" + +class InGameLoadingWindow: public LoadingWindow, public ActorFrame { + +public: + InGameLoadingWindow(); + ~InGameLoadingWindow(); + + void SetText( RString str ); + void Update ( float delta ); + +private: + bool textChanged; + RString currentText; + BitmapText m_Text; +}; + From b36733db0183376d907f60a4642eea395bcbee3b Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sun, 5 Jun 2011 10:07:09 -0400 Subject: [PATCH 23/29] [loading window] Consistent group location. --- Xcode/stepmania.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Xcode/stepmania.xcodeproj/project.pbxproj b/Xcode/stepmania.xcodeproj/project.pbxproj index 296f1f0009..63c87f3be9 100644 --- a/Xcode/stepmania.xcodeproj/project.pbxproj +++ b/Xcode/stepmania.xcodeproj/project.pbxproj @@ -3058,8 +3058,8 @@ AAFF55220549F43A00D02EE9 /* ComboGraph.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; name = ComboGraph.h; path = ../src/ComboGraph.h; sourceTree = ""; }; AAFF5541054E736D00D02EE9 /* Attack.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; name = Attack.cpp; path = ../src/Attack.cpp; sourceTree = ""; }; AAFF5542054E736D00D02EE9 /* Attack.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; name = Attack.h; path = ../src/Attack.h; sourceTree = ""; }; - B71A60BE139B41DB00183A27 /* InGameLoadingWindow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InGameLoadingWindow.cpp; sourceTree = ""; }; - B71A60BF139B41DB00183A27 /* InGameLoadingWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InGameLoadingWindow.h; sourceTree = ""; }; + B71A60BE139B41DB00183A27 /* InGameLoadingWindow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InGameLoadingWindow.cpp; path = ../src/InGameLoadingWindow.cpp; sourceTree = ""; }; + B71A60BF139B41DB00183A27 /* InGameLoadingWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InGameLoadingWindow.h; path = ../src/InGameLoadingWindow.h; sourceTree = ""; }; B75CE3B3137963350076A82D /* SongPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SongPosition.h; path = ../src/SongPosition.h; sourceTree = SOURCE_ROOT; }; B75CE3B4137963350076A82D /* SongPosition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SongPosition.cpp; path = ../src/SongPosition.cpp; sourceTree = SOURCE_ROOT; }; EE2153A710A75BEE0074B01B /* NotesLoaderPMS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NotesLoaderPMS.cpp; path = ../src/NotesLoaderPMS.cpp; sourceTree = SOURCE_ROOT; }; @@ -3283,8 +3283,6 @@ 29B97315FDCFA39411CA2CEA /* Other Source */ = { isa = PBXGroup; children = ( - B71A60BE139B41DB00183A27 /* InGameLoadingWindow.cpp */, - B71A60BF139B41DB00183A27 /* InGameLoadingWindow.h */, AA70E3640663112800DAE1FD /* Foreach.h */, 3659B56D0F902143002B6B68 /* CommandLineActions.cpp */, 3659B56E0F902143002B6B68 /* CommandLineActions.h */, @@ -4100,6 +4098,8 @@ AA6EFE9104770E7C005F316C /* GrooveRadar.h */, AA6EFE9404770E7C005F316C /* HelpDisplay.cpp */, AA6EFE9504770E7C005F316C /* HelpDisplay.h */, + B71A60BE139B41DB00183A27 /* InGameLoadingWindow.cpp */, + B71A60BF139B41DB00183A27 /* InGameLoadingWindow.h */, AA729C460599B54D00779F33 /* MemoryCardDisplay.cpp */, AA729C470599B54D00779F33 /* MemoryCardDisplay.h */, AA6EFE9A04770E7C005F316C /* MenuTimer.cpp */, From 584c2ee613572e2d0a8f80eccfad1798b04d95a1 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sun, 5 Jun 2011 10:10:45 -0400 Subject: [PATCH 24/29] [loading window] Ensure loading & building order. --- src/StepMania-net2008.vcproj | 2 ++ src/StepMania-net2010.vcxproj | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/StepMania-net2008.vcproj b/src/StepMania-net2008.vcproj index 8ae692a48c..4498df5d04 100644 --- a/src/StepMania-net2008.vcproj +++ b/src/StepMania-net2008.vcproj @@ -2810,6 +2810,8 @@ RelativePath="HelpDisplay.h" > + + diff --git a/src/StepMania-net2010.vcxproj b/src/StepMania-net2010.vcxproj index 2dc4b6b9ca..c350d25de4 100644 --- a/src/StepMania-net2010.vcxproj +++ b/src/StepMania-net2010.vcxproj @@ -371,7 +371,6 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir) - @@ -644,6 +643,7 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir) + From 4a1195298632438aa9204376da05fc5046ecd7b8 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sun, 5 Jun 2011 10:36:09 -0400 Subject: [PATCH 25/29] [loading window] Indeterminate for Mac OS X. Is there a way to use performSelector withBool? --- src/arch/LoadingWindow/LoadingWindow_MacOSX.h | 1 + src/arch/LoadingWindow/LoadingWindow_MacOSX.mm | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/arch/LoadingWindow/LoadingWindow_MacOSX.h b/src/arch/LoadingWindow/LoadingWindow_MacOSX.h index 23f45ddf1c..3a521a3170 100644 --- a/src/arch/LoadingWindow/LoadingWindow_MacOSX.h +++ b/src/arch/LoadingWindow/LoadingWindow_MacOSX.h @@ -11,6 +11,7 @@ public: void SetText( RString str ); void SetProgress( const int progress ); void SetTotalWork( const int totalWork ); + void SetIndeterminate( bool indeterminate ); }; #define USE_LOADING_WINDOW_MACOSX diff --git a/src/arch/LoadingWindow/LoadingWindow_MacOSX.mm b/src/arch/LoadingWindow/LoadingWindow_MacOSX.mm index bc6a3cf9dc..63a759113f 100644 --- a/src/arch/LoadingWindow/LoadingWindow_MacOSX.mm +++ b/src/arch/LoadingWindow/LoadingWindow_MacOSX.mm @@ -15,6 +15,7 @@ - (void) setupWindow:(NSImage *)image; - (void) setProgress:(NSNumber *)progress; - (void) setTotalWork:(NSNumber *)totalWork; +- (void) setIndeterminate:(NSNumber *)indeterminate; @end @implementation LoadingWindowHelper @@ -96,6 +97,11 @@ [m_ProgressIndicator setMaxValue:[totalWork doubleValue]]; } +- (void) setIndeterminate:(NSNumber *)indeterminate +{ + [m_ProgressIndicator setIndeterminate:(indeterminate > 0 ? YES : NO)]; +} + @end static LoadingWindowHelper *g_Helper = nil; @@ -160,6 +166,12 @@ void LoadingWindow_MacOSX::SetTotalWork( const int totalWork ) [g_Helper performSelectorOnMainThread:@selector(setTotalWork:) withObject:[NSNumber numberWithDouble:(double)totalWork] waitUntilDone:NO]; } +void LoadingWindow_MacOSX::SetIndeterminate( bool indeterminate ) +{ + double tmp = indeterminate ? 1 : 0; + [g_Helper performSelectorOnMainThread:@selector(setIndeterminate:) withObject:[NSNumber numberWithDouble:tmp] waitUntilDone:NO]; +} + /* * (c) 2003-2006, 2008 Steve Checkoway * All rights reserved. From 50e180851e07c44a08f20d66f0a95d421573792c Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sun, 5 Jun 2011 22:54:45 +0200 Subject: [PATCH 26/29] [loading window] Let's try to dodge a crash when existing while reloading songs. --- src/ScreenReloadSongs.cpp | 9 ++++++++- src/ScreenReloadSongs.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ScreenReloadSongs.cpp b/src/ScreenReloadSongs.cpp index e5db726fdb..1f2528d996 100644 --- a/src/ScreenReloadSongs.cpp +++ b/src/ScreenReloadSongs.cpp @@ -15,6 +15,8 @@ * computer while songs load. */ REGISTER_SCREEN_CLASS( ScreenReloadSongs ); +ScreenReloadSongs::ScreenReloadSongs() : loadComplete(false) {} + void ScreenReloadSongs::Init() { Screen::Init(); @@ -33,7 +35,11 @@ void ScreenReloadSongs::Init() ScreenReloadSongs::~ScreenReloadSongs() { - //m_loadingThread.Halt(true); + if(!loadComplete) { + //we where going to crash if we let this one lose, so "only" + //leaving stuff possibly corrupted isn't worse. + m_loadingThread.Halt(true); + } RemoveChild(loadWin); delete loadWin; } @@ -45,6 +51,7 @@ int ScreenReloadSongs::loadingThreadProc(void *thisAsVoidPtr) { SONGMAN->Reload( false ); SCREENMAN->PostMessageToTopScreen( SM_GoToNextScreen, 0 ); + self->loadComplete=true; return 0; } diff --git a/src/ScreenReloadSongs.h b/src/ScreenReloadSongs.h index 5c3733aae3..8c145ddfe5 100644 --- a/src/ScreenReloadSongs.h +++ b/src/ScreenReloadSongs.h @@ -9,9 +9,11 @@ class InGameLoadingWindow; class ScreenReloadSongs: public Screen { public: + ScreenReloadSongs(); virtual void Init(); ~ScreenReloadSongs(); private: + bool loadComplete; InGameLoadingWindow *loadWin; RageThread m_loadingThread; static int loadingThreadProc(void *thisAsVoidPtr); From 3df6a5e82c6e81977c26691bc25cd4290aa5aa14 Mon Sep 17 00:00:00 2001 From: Thai Pangsakulyanont Date: Mon, 6 Jun 2011 10:53:45 +0700 Subject: [PATCH 27/29] [loading window] fixes for mac os x progress bar --- src/arch/LoadingWindow/LoadingWindow_MacOSX.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arch/LoadingWindow/LoadingWindow_MacOSX.mm b/src/arch/LoadingWindow/LoadingWindow_MacOSX.mm index 63a759113f..356d3cc638 100644 --- a/src/arch/LoadingWindow/LoadingWindow_MacOSX.mm +++ b/src/arch/LoadingWindow/LoadingWindow_MacOSX.mm @@ -29,7 +29,7 @@ progressIndicatorRect = NSMakeRect(0, 0, size.width, 0); m_ProgressIndicator = [[NSProgressIndicator alloc] initWithFrame:progressIndicatorRect]; [m_ProgressIndicator sizeToFit]; - [m_ProgressIndicator setIndeterminate:NO]; + [m_ProgressIndicator setIndeterminate:YES]; [m_ProgressIndicator setMinValue:0]; [m_ProgressIndicator setMaxValue:1]; [m_ProgressIndicator setDoubleValue:0]; @@ -99,7 +99,7 @@ - (void) setIndeterminate:(NSNumber *)indeterminate { - [m_ProgressIndicator setIndeterminate:(indeterminate > 0 ? YES : NO)]; + [m_ProgressIndicator setIndeterminate:([indeterminate doubleValue] > 0 ? YES : NO)]; } @end From e249542093cf68f226d7f75d71bf7b0cfbd64b37 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 6 Jun 2011 20:49:34 +0200 Subject: [PATCH 28/29] [loading window] Might as well use this simple fallback graphic that I made in paint. --- .../Graphics/Progressbar Indeterminate.png | Bin 0 -> 480 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Themes/_fallback/Graphics/Progressbar Indeterminate.png diff --git a/Themes/_fallback/Graphics/Progressbar Indeterminate.png b/Themes/_fallback/Graphics/Progressbar Indeterminate.png new file mode 100644 index 0000000000000000000000000000000000000000..c781e5d06e6d93802435dd7bb2423ab79660fe92 GIT binary patch literal 480 zcmV<60U!Q}P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0d+}4K~#8N?b=yx z!$1rKQQiO2UJ%1h6j_>u#q+`Tz_!@^j8Kz|7Q-d=BGUR?=i}P0OcQ3 z4S@dt8Jt}J^bbdfMgh?OHUYH=fd0t?#C zBKm^?(3jF534p$!es=)$W%c_4pf9f95deJ+{nh~JE9o}{KwnS)Isp2r`WFGv*VaD^ zfWCqL*8u3-=pP3_-%S4?0Q#2t`vB-0>;DOWzP Date: Tue, 7 Jun 2011 12:25:29 +0200 Subject: [PATCH 29/29] [loading window] This is nicer than the thread termination. But now we need to find a way to end the load early. --- src/ScreenReloadSongs.cpp | 9 ++------- src/ScreenReloadSongs.h | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/ScreenReloadSongs.cpp b/src/ScreenReloadSongs.cpp index 1f2528d996..7cd7360355 100644 --- a/src/ScreenReloadSongs.cpp +++ b/src/ScreenReloadSongs.cpp @@ -15,7 +15,7 @@ * computer while songs load. */ REGISTER_SCREEN_CLASS( ScreenReloadSongs ); -ScreenReloadSongs::ScreenReloadSongs() : loadComplete(false) {} +ScreenReloadSongs::ScreenReloadSongs() {} void ScreenReloadSongs::Init() { @@ -35,11 +35,7 @@ void ScreenReloadSongs::Init() ScreenReloadSongs::~ScreenReloadSongs() { - if(!loadComplete) { - //we where going to crash if we let this one lose, so "only" - //leaving stuff possibly corrupted isn't worse. - m_loadingThread.Halt(true); - } + m_loadingThread.Wait(); RemoveChild(loadWin); delete loadWin; } @@ -51,7 +47,6 @@ int ScreenReloadSongs::loadingThreadProc(void *thisAsVoidPtr) { SONGMAN->Reload( false ); SCREENMAN->PostMessageToTopScreen( SM_GoToNextScreen, 0 ); - self->loadComplete=true; return 0; } diff --git a/src/ScreenReloadSongs.h b/src/ScreenReloadSongs.h index 8c145ddfe5..39676e8dff 100644 --- a/src/ScreenReloadSongs.h +++ b/src/ScreenReloadSongs.h @@ -13,7 +13,6 @@ public: virtual void Init(); ~ScreenReloadSongs(); private: - bool loadComplete; InGameLoadingWindow *loadWin; RageThread m_loadingThread; static int loadingThreadProc(void *thisAsVoidPtr);