Skip to content

Commit

Permalink
add manual batch upload buttons to scoretab (wip on ui)
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Apr 17, 2020
1 parent 1df8e31 commit 1c49f7f
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,48 @@ l[#l + 1] =
end
end
}
l[#l + 1] =
LoadFont("Common Normal") ..
{
Name = "TheDootButtonTWO",
InitCommand = function(self)
self:xy(frameWidth - offsetX - frameX, frameHeight - headeroffY - 90 - offsetY):zoom(0.5):halign(1):settext("")
end,
DisplayCommand = function(self)
self:settext("Upload all scores for this chart")
end,
HighlightCommand = function(self)
highlightIfOver(self)
end,
MouseLeftClickMessageCommand = function(self)
if nestedTab == 1 then
if getTabIndex() == 2 and isOver(self) then
DLMAN:UploadScoresForChart(score:GetChartKey())
end
end
end
}
l[#l + 1] =
LoadFont("Common Normal") ..
{
Name = "TheDootButtonTHREEEEEEEE",
InitCommand = function(self)
self:xy(frameWidth - offsetX - frameX, frameHeight - headeroffY - 110 - offsetY):zoom(0.5):halign(1):settext("")
end,
DisplayCommand = function(self)
self:settext("Upload all scores for charts in this pack")
end,
HighlightCommand = function(self)
highlightIfOver(self)
end,
MouseLeftClickMessageCommand = function(self)
if nestedTab == 1 then
if getTabIndex() == 2 and isOver(self) then
DLMAN:UploadScoresForPack(GAMESTATE:GetCurrentSong():GetGroupName())
end
end
end
}
t[#t + 1] = l

t[#t + 1] =
Expand Down
41 changes: 41 additions & 0 deletions src/Etterna/Singletons/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,35 @@ DownloadManager::UploadScores()
uploadSequentially(toUpload);
return true;
}

// manual upload function that will upload all scores for a chart
// that skips some of the constraints of the auto uploaders
void
DownloadManager::ForceUploadScoresForChart(std::string ck)
{
deque<HighScore*> toUpload;
for (auto& s : SCOREMAN->GetScoresForChart(ck)->GetAllScores())
toUpload.push_back(s);
uploadSequentially(toUpload);
}

// dont wrap the chart function so we can see progress as a whole (todo)
void
DownloadManager::ForceUploadScoresForPack(std::string pack)
{
deque<HighScore*> toUpload;
auto songs = SONGMAN->GetSongs(pack);
for (auto so : songs)
for (auto c : so->GetAllSteps()) {
auto cs = SCOREMAN->GetScoresForChart(c->GetChartKey());
if (cs)
for (auto s : cs->GetAllScores()) {
toUpload.push_back(s);
}
}

uploadSequentially(toUpload);
}
void
DownloadManager::EndSessionIfExists()
{
Expand Down Expand Up @@ -2865,6 +2894,16 @@ class LunaDownloadManager : public Luna<DownloadManager>
DLMAN->UploadScoreWithReplayDataFromDisk(SArg(1));
return 0;
}
static int UploadScoresForChart(T* p, lua_State* L)
{
DLMAN->ForceUploadScoresForChart(SArg(1));
return 0;
}
static int UploadScoresForPack(T* p, lua_State* L)
{
DLMAN->ForceUploadScoresForPack(SArg(1));
return 0;
}
LunaDownloadManager()
{
ADD_METHOD(GetCountryCodes);
Expand Down Expand Up @@ -2900,6 +2939,8 @@ class LunaDownloadManager : public Luna<DownloadManager>
ADD_METHOD(ToggleCCFilter);
ADD_METHOD(GetCCFilter);
ADD_METHOD(SendReplayDataForOldScore);
ADD_METHOD(UploadScoresForChart);
ADD_METHOD(UploadScoresForPack);
ADD_METHOD(Logout);
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/Etterna/Singletons/DownloadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ class DownloadManager
done); // Sends login request if not already logging in
void OnLogin();
bool UploadScores(); // Uploads all scores not yet uploaded to current
void ForceUploadScoresForChart(std::string ck); // forced upload wrapper for charts
void ForceUploadScoresForPack(std::string pack);// forced upload wrapper for packs
bool UpdateOnlineScoreReplayData(); // attempts updates existing replaydata
// server (Async, 1 request per score)
void RefreshPackList(const string& url);
Expand Down

0 comments on commit 1c49f7f

Please sign in to comment.