Skip to content

Commit

Permalink
Fix eo favs
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Jul 24, 2018
1 parent 0d9e251 commit 708a543
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
27 changes: 15 additions & 12 deletions src/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,29 +585,31 @@ 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)
{
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;
Expand Down Expand Up @@ -846,14 +848,15 @@ OnlineTopScore DownloadManager::GetTopSkillsetScore(unsigned int rank, Skillset
return OnlineTopScore();
}

void DownloadManager::SendRequest(string requestName, vector<pair<string, string>> params, function<void(HTTPRequest&, CURLMsg *)> done, bool requireLogin, bool post, bool async)
HTTPRequest* DownloadManager::SendRequest(string requestName, vector<pair<string, string>> params, function<void(HTTPRequest&, CURLMsg *)> 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<pair<string, string>> params, function<void(HTTPRequest&, CURLMsg *)> afterDone, bool requireLogin, bool post, bool async)

HTTPRequest* DownloadManager::SendRequestToURL(string url, vector<pair<string, string>> params, function<void(HTTPRequest&, CURLMsg *)> afterDone, bool requireLogin, bool post, bool async)
{
if (requireLogin && !LoggedIn())
return;
return nullptr;
if (!post && !params.empty()) {
url += "?";
for (auto& param : params)
Expand Down Expand Up @@ -911,7 +914,7 @@ void DownloadManager::SendRequestToURL(string url, vector<pair<string, string>>
done(*req, nullptr);
delete req;
}
return;
return req;
}

float mythicalmathymathsProbablyUnderratedness(string chartkey) {
Expand Down
4 changes: 2 additions & 2 deletions src/DownloadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<pair<string, string>> params, function<void(HTTPRequest&, CURLMsg *)> done, bool requireLogin = true, bool post = false, bool async = true);
void SendRequestToURL(string url, vector<pair<string, string>> params, function<void(HTTPRequest&, CURLMsg *)> done, bool requireLogin, bool post, bool async);
HTTPRequest* SendRequest(string requestName, vector<pair<string, string>> params, function<void(HTTPRequest&, CURLMsg *)> done, bool requireLogin = true, bool post = false, bool async = true);
HTTPRequest* SendRequestToURL(string url, vector<pair<string, string>> params, function<void(HTTPRequest&, CURLMsg *)> done, bool requireLogin, bool post, bool async);
void RefreshLastVersion();
void RefreshRegisterPage();
void RequestChartLeaderBoard(string chartkey);
Expand Down
12 changes: 6 additions & 6 deletions src/SongManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<RString> &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))
Expand Down
16 changes: 11 additions & 5 deletions src/arch/LoadingWindow/LoadingWindow_Win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <windows.h>
#include <Commdlg.h>
#include <tchar.h>
#include "Dwmapi.h"
#include "CommCtrl.h"
#include "RageSurface_Load.h"
#include "RageSurface.h"
Expand All @@ -20,6 +21,8 @@
#include "LocalizedString.h"

#include "RageSurfaceUtils_Zoom.h"
#pragma comment(lib,"Dwmapi.lib")

static HBITMAP g_hBitmap = NULL;

RString text[3];
Expand All @@ -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. */
Expand Down Expand Up @@ -244,7 +253,6 @@ void LoadingWindow_Win32::SetText(const RString &sText)
{
lastText = sText;
SetTextInternal();
Paint();
}

void LoadingWindow_Win32::SetTextInternal()
Expand Down Expand Up @@ -274,6 +282,7 @@ void LoadingWindow_Win32::SetTextInternal()
text[i] += progress;
break;
}
Paint();
}

void LoadingWindow_Win32::SetProgress(const int progress)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -310,7 +317,6 @@ void LoadingWindow_Win32::SetIndeterminate(bool indeterminate)
SetWindowLong(hwndItem,GWL_STYLE, (~PBS_MARQUEE) & GetWindowLong(hwndItem,GWL_STYLE));
}
*/
Paint();
}

/*
Expand Down

0 comments on commit 708a543

Please sign in to comment.