Skip to content

Commit

Permalink
Loading screen changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Jul 24, 2018
1 parent 92237b3 commit 5de14f1
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 37 deletions.
Binary file added Data/Roboto-Light.ttf
Binary file not shown.
Binary file modified Data/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Themes/_fallback/Graphics/Common splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/NetworkSyncManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ NetworkSyncManager::NetworkSyncManager(LoadingWindow *ld)
loggedIn = false;
m_startupStatus = 0; //By default, connection not tried.
m_ActivePlayers = 0;
ld->SetText("Connecting to multiplayer server");
ld->SetIndeterminate(true);
ld->SetText("\nConnecting to multiplayer server");
StartUp();
// Register with Lua.
{
Expand Down
5 changes: 3 additions & 2 deletions src/ScoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,18 @@ void ScoreManager::RecalculateSSRs(LoadingWindow *ld, const string& profileID) {
RageTimer ld_timer;
auto& scores = AllProfileScores[profileID];
if (ld != nullptr) {
ld->SetProgress(0);
ld_timer.Touch();
ld->SetIndeterminate(false);
ld->SetTotalWork(scores.size());
ld->SetText("Updating SSR Calculations for Scores...");
ld->SetText("\nUpdating Ratings");
}

int scoreindex = 0;
for(size_t i = 0; i < scores.size(); ++i) {
if (ld && ld_timer.Ago() > ld_update) {
ld_timer.Touch();
ld->SetProgress(scoreindex);
ld->SetProgress(i);
}
++scoreindex;

Expand Down
91 changes: 81 additions & 10 deletions src/arch/LoadingWindow/LoadingWindow_Win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,37 @@
#include "archutils/win32/ErrorStrings.h"
#include "arch/ArchHooks/ArchHooks.h"
#include <windows.h>
#include <Commdlg.h>
#include <tchar.h>
#include "CommCtrl.h"
#include "RageSurface_Load.h"
#include "RageSurface.h"
#include "RageSurfaceUtils.h"
#include "RageLog.h"
#include <wchar.h>
#include "ProductInfo.h"
#include "LocalizedString.h"

#include "RageSurfaceUtils_Zoom.h"
static HBITMAP g_hBitmap = NULL;

RString text[3];
const float FONT_HEIGHT = 12;
const string FONT_FILE = "Data/Roboto-Light.ttf";
const string FONT_NAME = "Roboto Light";
const auto FONT_COLOR = RGB(240, 240, 240);
const int FONT_Y = 98;
const int FONT_X = 20;

/* Load a RageSurface into a GDI surface. */
static HBITMAP LoadWin32Surface( const RageSurface *pSplash, HWND hWnd )
{
RageSurface *s = CreateSurface( pSplash->w, pSplash->h, 32,
0xFF000000, 0x00FF0000, 0x0000FF00, 0 );
RageSurfaceUtils::Blit( pSplash, s , -1, -1 );
RECT rOld;
GetClientRect(hWnd, &rOld);
SetWindowPos(hWnd, 0, rOld.left, rOld.top, s->w, s->h, SWP_NOMOVE);

/* Resize the splash image to fit the dialog. Stretch to fit horizontally,
* maintaining aspect ratio. */
Expand Down Expand Up @@ -81,7 +95,7 @@ static HBITMAP LoadWin32Surface( RString sFile, HWND hWnd )
return ret;
}

BOOL CALLBACK LoadingWindow_Win32::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
BOOL CALLBACK LoadingWindow_Win32::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch( msg )
{
Expand All @@ -106,6 +120,30 @@ BOOL CALLBACK LoadingWindow_Win32::WndProc( HWND hWnd, UINT msg, WPARAM wParam,
DeleteObject( g_hBitmap );
g_hBitmap = NULL;
break;
case WM_PAINT:
for (unsigned i = 0; i < 3; ++i)
{
//Do graphical paint
RECT rect;
HDC wdc = GetWindowDC(hWnd);
GetClientRect(hWnd, &rect);
SetTextColor(wdc, FONT_COLOR);
SetBkMode(wdc, TRANSPARENT);
rect.left = FONT_X;
rect.top = FONT_Y + (FONT_HEIGHT+3) * i;

LOGFONT lf;
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -MulDiv(FONT_HEIGHT, GetDeviceCaps(wdc, LOGPIXELSY), 72);
_tcscpy(lf.lfFaceName, FONT_NAME.c_str()); //we must include tchar.h
auto f = CreateFontIndirect(&lf);
SendMessage(hWnd, WM_SETFONT, (WPARAM)f, MAKELPARAM(FALSE, 0));
SelectObject(wdc, f);

DrawText(wdc, text[i].c_str(), -1, &rect, DT_SINGLELINE | DT_NOCLIP);
DeleteDC(wdc);
//::SetWindowText( hwndItem, ConvertUTF8ToACP(asMessageLines[i]).c_str() );
}
}

return FALSE;
Expand Down Expand Up @@ -144,6 +182,13 @@ void LoadingWindow_Win32::SetSplash( const RageSurface *pSplash )

LoadingWindow_Win32::LoadingWindow_Win32()
{
string szFontFile = RageFileManagerUtil::sDirOfExecutable.substr(0, RageFileManagerUtil::sDirOfExecutable.length()-7) + FONT_FILE;

int nResults = AddFontResourceEx(
szFontFile.c_str(), // font file name
FR_PRIVATE, // font characteristics
NULL);

m_hIcon = NULL;
hwnd = CreateDialog( handle.Get(), MAKEINTRESOURCE(IDD_LOADING_DIALOG), NULL, WndProc );
ASSERT( hwnd != NULL );
Expand All @@ -163,7 +208,9 @@ LoadingWindow_Win32::~LoadingWindow_Win32()

void LoadingWindow_Win32::Paint()
{
SendMessage( hwnd, WM_PAINT, 0, 0 );
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
SendMessage(hwnd, WM_PAINT, 0, 0);

/* Process all queued messages since the last paint. This allows the window to
* come back if it loses focus during load. */
Expand All @@ -175,8 +222,23 @@ void LoadingWindow_Win32::Paint()
}
}

void LoadingWindow_Win32::SetText( const RString &sText )
void LoadingWindow_Win32::SetText(const RString &sText)
{
lastText = sText;
SetTextInternal();
Paint();
}

void LoadingWindow_Win32::SetTextInternal()
{
if (m_indeterminate)
progress = "";
else {
int percent = m_totalWork != 0 ? ((float)m_progress) / ((float)m_totalWork) * 100 : m_progress;
progress = " ("+to_string(percent) + "%)";
}
RString& sText = lastText;

vector<RString> asMessageLines;
split( sText, "\n", asMessageLines, false );
while( asMessageLines.size() < 3 )
Expand All @@ -188,31 +250,38 @@ void LoadingWindow_Win32::SetText( const RString &sText )
if( text[i] == asMessageLines[i] )
continue;
text[i] = asMessageLines[i];

HWND hwndItem = ::GetDlgItem( hwnd, msgid[i] );
::SetWindowText( hwndItem, ConvertUTF8ToACP(asMessageLines[i]).c_str() );
}
for (unsigned i = 0; i < 3; ++i)
if (text[i] != "") {
text[i] += progress;
break;
}
}

void LoadingWindow_Win32::SetProgress(const int progress)
{
m_progress=progress;
HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS );
::SendMessage(hwndItem,PBM_SETPOS,progress,0);
//HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS );
//::SendMessage(hwndItem,PBM_SETPOS,progress,0);
SetTextInternal();
Paint();
}

void LoadingWindow_Win32::SetTotalWork(const int totalWork)
{
m_totalWork=totalWork;
HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS );
SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork);
//HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS );
//SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork);
SetTextInternal();
Paint();
}

void LoadingWindow_Win32::SetIndeterminate(bool indeterminate)
{
m_indeterminate=indeterminate;
SetTextInternal();

/*
HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS );
if(indeterminate) {
Expand All @@ -222,6 +291,8 @@ void LoadingWindow_Win32::SetIndeterminate(bool indeterminate)
SendMessage(hwndItem,PBM_SETMARQUEE,0,0);
SetWindowLong(hwndItem,GWL_STYLE, (~PBS_MARQUEE) & GetWindowLong(hwndItem,GWL_STYLE));
}
*/
Paint();
}

/*
Expand Down
4 changes: 3 additions & 1 deletion src/arch/LoadingWindow/LoadingWindow_Win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class LoadingWindow_Win32: public LoadingWindow

void Paint();
void SetText( const RString &sText );
void SetTextInternal();
void SetIcon( const RageSurface *pIcon );
void SetSplash( const RageSurface *pSplash );
void SetProgress( const int progress );
Expand All @@ -24,8 +25,9 @@ class LoadingWindow_Win32: public LoadingWindow
private:
AppInstance handle;
HWND hwnd;
RString text[3];
HICON m_hIcon;
string progress;
RString lastText;

static BOOL CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
};
Expand Down
Binary file added src/archutils/Win32/Etterna.ico
Binary file not shown.
Binary file added src/archutils/Win32/WindowsResources.aps
Binary file not shown.
53 changes: 30 additions & 23 deletions src/archutils/Win32/WindowsResources.rc
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
#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(65001)
#endif //_WIN32
#pragma code_page(1252)

/////////////////////////////////////////////////////////////////////////////
//
Expand All @@ -43,16 +41,12 @@ BEGIN
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,0,34,332,1
END

IDD_LOADING_DIALOG DIALOGEX 0, 0, 320, 94
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE
IDD_LOADING_DIALOG DIALOGEX 0, 0, 512, 143
STYLE DS_SETFONT | DS_CENTER | WS_POPUP | WS_VISIBLE
EXSTYLE WS_EX_APPWINDOW
FONT 8, "MS Sans Serif", 0, 0, 0x0
FONT 1, "MS Sans Serif", 0, 0, 0x0
BEGIN
CTEXT "line1",IDC_STATIC_MESSAGE1,7,43,303,10,SS_NOPREFIX | SS_CENTERIMAGE
CTEXT "line2",IDC_STATIC_MESSAGE2,7,52,303,10,SS_NOPREFIX | SS_CENTERIMAGE
CTEXT "line3",IDC_STATIC_MESSAGE3,7,61,303,10,SS_NOPREFIX | SS_CENTERIMAGE
CONTROL "",IDC_SPLASH,"Static",SS_BITMAP,0,0,316,25
CONTROL "",IDC_PROGRESS,"msctls_progress32",0x0,7,73,303,14
CONTROL "",IDC_SPLASH,"Static",SS_BITMAP,0,0,512,143
END

IDD_DISASM_CRASH DIALOGEX 0, 0, 332, 114
Expand Down Expand Up @@ -104,7 +98,7 @@ END
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
GUIDELINES DESIGNINFO
BEGIN
IDD_LOADING_DIALOG, DIALOG
BEGIN
Expand Down Expand Up @@ -173,9 +167,11 @@ END

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON ICON "StepMania.ICO"
IDI_ICON ICON "Etterna.ICO"

IDI_ICON1 ICON "smzip.ico"


/////////////////////////////////////////////////////////////////////////////
//
// Version
Expand All @@ -198,14 +194,14 @@ BEGIN
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "StepMania Team \n http://www.stepmania.com/"
VALUE "FileDescription", "StepMania"
VALUE "FileVersion", "5, 0, 0, 0"
VALUE "InternalName", "StepMania - Etterna"
VALUE "LegalCopyright", "Copyright � 2001-2014"
VALUE "OriginalFilename", "StepMania.exe"
VALUE "ProductName", "StepMania"
VALUE "ProductVersion", "5, 0, 0, 0"
VALUE "CompanyName", "Etterna Team \n http://etternaonline.com/"
VALUE "FileDescription", "Etterna"
VALUE "FileVersion", "0, 0, 6, 0"
VALUE "InternalName", "Etterna"
VALUE "LegalCopyright", "Copyright ? 2016-2018"
VALUE "OriginalFilename", "Etterna.exe"
VALUE "ProductName", "Etterna"
VALUE "ProductVersion", "0, 0, 6, 0"
END
END
BLOCK "VarFileInfo"
Expand All @@ -214,7 +210,18 @@ BEGIN
END
END

#endif // English (U.S.) resources

/////////////////////////////////////////////////////////////////////////////
//
// AFX_DIALOG_LAYOUT
//

IDD_LOADING_DIALOG AFX_DIALOG_LAYOUT
BEGIN
0
END

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////


Expand Down

0 comments on commit 5de14f1

Please sign in to comment.