diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp index e8c8d6f0ae..09f5babc93 100644 --- a/src/DownloadManager.cpp +++ b/src/DownloadManager.cpp @@ -585,12 +585,12 @@ bool DownloadManager::LoggedIn() void DownloadManager::AddFavorite(string chartkey) { - string req = "users/" + DLMAN->sessionUser + "/favorites"; + string req = "user/" + DLMAN->sessionUser + "/favorites"; DLMAN->favorites.emplace_back(chartkey); - auto done = [](HTTPRequest& req, CURLMsg *) { - + auto done = [req](HTTPRequest& requ, CURLMsg *) { + LOG->Warn((requ.result+req+DLMAN->sessionUser).c_str()); }; - SendRequest(req, {make_pair("chartkey", chartkey)}, done); + SendRequest(req, {make_pair("chartkey", chartkey)}, done, true, true); } void DownloadManager::RemoveFavorite(string chartkey) @@ -598,16 +598,18 @@ void DownloadManager::RemoveFavorite(string chartkey) auto it = std::find(DLMAN->favorites.begin(), DLMAN->favorites.end(), chartkey); if (it != DLMAN->favorites.end()) DLMAN->favorites.erase(it); - string req = "users/" + DLMAN->sessionUser + "/favorites/"+chartkey; + string req = "user/" + DLMAN->sessionUser + "/favorites/"+chartkey; auto done = [](HTTPRequest& req, CURLMsg *) { }; - SendRequest(req, {}, done); + auto r = SendRequest(req, {}, done); + if(r) + curl_easy_setopt(r->handle, CURLOPT_CUSTOMREQUEST, "DELETE"); } void DownloadManager::RefreshFavourites() { - string req = "users/" + DLMAN->sessionUser + "/favorites"; + string req = "user/" + DLMAN->sessionUser + "/favorites"; auto done = [](HTTPRequest& req, CURLMsg *) { json j; bool parsed = true; @@ -846,14 +848,15 @@ OnlineTopScore DownloadManager::GetTopSkillsetScore(unsigned int rank, Skillset return OnlineTopScore(); } -void DownloadManager::SendRequest(string requestName, vector> params, function done, bool requireLogin, bool post, bool async) +HTTPRequest* DownloadManager::SendRequest(string requestName, vector> params, function done, bool requireLogin, bool post, bool async) { - SendRequestToURL(serverURL.Get() + "/" + requestName, params, done, requireLogin, post, async); + return SendRequestToURL(serverURL.Get() + "/" + requestName, params, done, requireLogin, post, async); } -void DownloadManager::SendRequestToURL(string url, vector> params, function afterDone, bool requireLogin, bool post, bool async) + +HTTPRequest* DownloadManager::SendRequestToURL(string url, vector> params, function afterDone, bool requireLogin, bool post, bool async) { if (requireLogin && !LoggedIn()) - return; + return nullptr; if (!post && !params.empty()) { url += "?"; for (auto& param : params) @@ -911,7 +914,7 @@ void DownloadManager::SendRequestToURL(string url, vector> done(*req, nullptr); delete req; } - return; + return req; } float mythicalmathymathsProbablyUnderratedness(string chartkey) { diff --git a/src/DownloadManager.h b/src/DownloadManager.h index 120c4c5bf5..a2e9cff618 100644 --- a/src/DownloadManager.h +++ b/src/DownloadManager.h @@ -202,8 +202,8 @@ class DownloadManager inline void SetCURLPostToURL(CURL *curlHandle, string url); inline void SetCURLURL(CURL *curlHandle, string url); - void SendRequest(string requestName, vector> params, function done, bool requireLogin = true, bool post = false, bool async = true); - void SendRequestToURL(string url, vector> params, function done, bool requireLogin, bool post, bool async); + HTTPRequest* SendRequest(string requestName, vector> params, function done, bool requireLogin = true, bool post = false, bool async = true); + HTTPRequest* SendRequestToURL(string url, vector> params, function done, bool requireLogin, bool post, bool async); void RefreshLastVersion(); void RefreshRegisterPage(); void RequestChartLeaderBoard(string chartkey); diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 2493b9fb86..91c08fdb88 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -214,7 +214,7 @@ void SongManager::InitSongsFromDisk( LoadingWindow *ld ) int cacheIndex = 0; for (auto& pair : cache) { cacheIndex++; - if(ld) + if(ld && cacheIndex%4 ==0) ld->SetProgress(cacheIndex); auto& pNewSong = pair.second; const RString& dir = pNewSong->GetSongDir(); @@ -605,23 +605,23 @@ void SongManager::LoadStepManiaSongDir( RString sDir, LoadingWindow *ld ) if( ld != nullptr ) { ld->SetIndeterminate(false); - ld->SetTotalWork(songCount); + ld->SetTotalWork(arrayGroupDirs.size()); } int groupIndex = 0; int songIndex = 0; FOREACH_CONST(RString, arrayGroupDirs, s) { RString sGroupDirName = *s; vector &arraySongDirs = arrayGroupSongDirs[groupIndex++]; + if (ld) { + ld->SetProgress(groupIndex); + ld->SetText("Loading Songs From Disk\n" + sGroupDirName); + } int loaded = 0; SongPointerVector& index_entry = m_mapSongGroupIndex[sGroupDirName]; RString group_base_name = Basename(sGroupDirName); for (size_t j = 0; j < arraySongDirs.size(); ++j) { songIndex++; RString sSongDirName = arraySongDirs[j]; - if (ld) { - ld->SetProgress(songIndex); - ld->SetText("Loading Songs From Disk\n" + sSongDirName); - } RString hur = sSongDirName + "/"; hur.MakeLower(); if (m_SongsByDir.count(hur)) diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp index 106a30314c..a83a6b41c8 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "Dwmapi.h" #include "CommCtrl.h" #include "RageSurface_Load.h" #include "RageSurface.h" @@ -20,6 +21,8 @@ #include "LocalizedString.h" #include "RageSurfaceUtils_Zoom.h" +#pragma comment(lib,"Dwmapi.lib") + static HBITMAP g_hBitmap = NULL; RString text[3]; @@ -37,9 +40,15 @@ 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 wrect; + DwmGetWindowAttribute(hWnd, DWMWA_EXTENDED_FRAME_BOUNDS, &wrect, sizeof(wrect)); RECT rOld; GetClientRect(hWnd, &rOld); - SetWindowPos(hWnd, 0, rOld.left, rOld.top, s->w, s->h, SWP_NOMOVE); + rOld.left = (rOld.right / 2) - (pSplash->w / 2); + rOld.top = (rOld.bottom / 2) - (pSplash->h / 2); + wrect.left += ((wrect.right - wrect.left) - s->w) / 2; + wrect.top += ((wrect.bottom - wrect.top) - s->h) / 2; + SetWindowPos(hWnd, 0, wrect.left, wrect.top, s->w, s->h, 0); /* Resize the splash image to fit the dialog. Stretch to fit horizontally, * maintaining aspect ratio. */ @@ -244,7 +253,6 @@ void LoadingWindow_Win32::SetText(const RString &sText) { lastText = sText; SetTextInternal(); - Paint(); } void LoadingWindow_Win32::SetTextInternal() @@ -274,6 +282,7 @@ void LoadingWindow_Win32::SetTextInternal() text[i] += progress; break; } + Paint(); } void LoadingWindow_Win32::SetProgress(const int progress) @@ -282,7 +291,6 @@ void LoadingWindow_Win32::SetProgress(const int progress) //HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); //::SendMessage(hwndItem,PBM_SETPOS,progress,0); SetTextInternal(); - Paint(); } void LoadingWindow_Win32::SetTotalWork(const int totalWork) @@ -291,7 +299,6 @@ void LoadingWindow_Win32::SetTotalWork(const int totalWork) //HWND hwndItem = ::GetDlgItem( hwnd, IDC_PROGRESS ); //SendMessage(hwndItem,PBM_SETRANGE32,0,totalWork); SetTextInternal(); - Paint(); } void LoadingWindow_Win32::SetIndeterminate(bool indeterminate) @@ -310,7 +317,6 @@ void LoadingWindow_Win32::SetIndeterminate(bool indeterminate) SetWindowLong(hwndItem,GWL_STYLE, (~PBS_MARQUEE) & GetWindowLong(hwndItem,GWL_STYLE)); } */ - Paint(); } /*