Skip to content

Commit

Permalink
move theme-side replaysnapshot usage to replay centric hooks
Browse files Browse the repository at this point in the history
removed bloaty hooks from eval cpp
  • Loading branch information
poco0317 committed Oct 29, 2022
1 parent 5bfb0d9 commit 3e6fe84
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 61 deletions.
26 changes: 14 additions & 12 deletions Themes/Rebirth/BGAnimations/offsetplot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ local t = Def.ActorFrame {
if isOver(bg) then
local top = SCREENMAN:GetTopScreen()
-- dont break if it will break (we can only do this from the eval screen)
if not top.GetReplaySnapshotJudgmentsForNoterow or not top.GetReplaySnapshotWifePercentForNoterow then
if not top.SetPlayerStageStatsFromReplayData then
return
end

Expand All @@ -219,18 +219,20 @@ local t = Def.ActorFrame {
local lastsec = GAMESTATE:GetCurrentSteps():GetLastSecond()
local row = td:GetBeatFromElapsedTime(percent * lastsec) * 48

local judgments = top:GetReplaySnapshotJudgmentsForNoterow(row)
local wifescore = top:GetReplaySnapshotWifePercentForNoterow(row) * 100
local replay = REPLAYS:GetActiveReplay()
local snapshot = replay:GetReplaySnapshotForNoterow(row)
local judgments = snapshot:GetJudgments()
local wifescore = snapshot:GetWifePercent() * 100
local time = SecondsToHHMMSS(td:GetElapsedTimeFromNoteRow(row))
local mean = top:GetReplaySnapshotMeanForNoterow(row)
local sd = top:GetReplaySnapshotSDForNoterow(row)

local marvCount = judgments[10]
local perfCount = judgments[9]
local greatCount = judgments[8]
local goodCount = judgments[7]
local badCount = judgments[6]
local missCount = judgments[5]
local mean = snapshot:GetMean()
local sd = snapshot:GetStandardDeviation()

local marvCount = judgments["W1"]
local perfCount = judgments["W2"]
local greatCount = judgments["W3"]
local goodCount = judgments["W4"]
local badCount = judgments["W5"]
local missCount = judgments["Miss"]

-- excessively long string format for translation support
local txt = string.format(
Expand Down
23 changes: 13 additions & 10 deletions Themes/Til Death/BGAnimations/offsetplot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,20 @@ o[#o + 1] =
bg:x(xpos)
bg:zoomto(txt:GetZoomedWidth() + 4, txt:GetZoomedHeight() + 4)
local row = convertXToRow(xpos)
local judgments = SCREENMAN:GetTopScreen():GetReplaySnapshotJudgmentsForNoterow(row)
local wifescore = SCREENMAN:GetTopScreen():GetReplaySnapshotWifePercentForNoterow(row) * 100
local mean = SCREENMAN:GetTopScreen():GetReplaySnapshotMeanForNoterow(row)
local sd = SCREENMAN:GetTopScreen():GetReplaySnapshotSDForNoterow(row)
local replay = REPLAYS:GetActiveReplay()
local snapshot = replay:GetReplaySnapshotForNoterow(row)
local judgments = snapshot:GetJudgments()
local wifescore = snapshot:GetWifePercent() * 100
local mean = snapshot:GetMean()
local sd = snapshot:GetStandardDeviation()
local timebro = td:GetElapsedTimeFromNoteRow(row) / getCurRateValue()
local marvCount = judgments[10]
local perfCount = judgments[9]
local greatCount = judgments[8]
local goodCount = judgments[7]
local badCount = judgments[6]
local missCount = judgments[5]

local marvCount = judgments["W1"]
local perfCount = judgments["W2"]
local greatCount = judgments["W3"]
local goodCount = judgments["W4"]
local badCount = judgments["W5"]
local missCount = judgments["Miss"]

--txt:settextf("x %f\nrow %f\nbeat %f\nfinalsecond %f", xpos, row, row/48, finalSecond)
-- The odd formatting here is in case we want to add translation support.
Expand Down
2 changes: 1 addition & 1 deletion src/Etterna/Models/HighScore/HighScore.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "Etterna/Models/Misc/DateTime.h"
#include "Etterna/Models/Misc/GameConstantsAndTypes.h"
#include "Etterna/Models/Misc/Grade.h"
#include "Etterna/Models/HighScore/ReplayConstantsAndTypes.h"
#include "Etterna/Models/HighScore/Replay.h"

class XNode;
struct RadarValues;
Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Models/HighScore/Replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2213,6 +2213,7 @@ class LunaReplay : public Luna<Replay>
ADD_METHOD(GetTapNoteTypeVector);
ADD_METHOD(GetHoldNoteVector);
ADD_METHOD(GetMineHitVector);
ADD_METHOD(GetReplaySnapshotForNoterow);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Models/HighScore/Replay.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
struct HighScore;
class TimingData;
class Steps;
class Style;

class Replay
{
Expand Down
38 changes: 0 additions & 38 deletions src/Etterna/Screen/Others/ScreenEvaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,40 +294,6 @@ class LunaScreenEvaluation : public Luna<ScreenEvaluation>
lua_pushboolean(L, true);
return 1;
}
static int GetReplaySnapshotJudgmentsForNoterow(T* p, lua_State* L)
{
int row = IArg(1);
auto rs = REPLAYS->GetActiveReplay()->GetReplaySnapshotForNoterow(row);
std::vector<int> toPush;

FOREACH_ENUM(TapNoteScore, tns)
toPush.emplace_back(rs->judgments[tns]);

LuaHelpers::CreateTableFromArray(toPush, L);
return 1;
}
static int GetReplaySnapshotWifePercentForNoterow(T* p, lua_State* L)
{
int row = IArg(1);
auto rs = REPLAYS->GetActiveReplay()->GetReplaySnapshotForNoterow(row);

lua_pushnumber(L, rs->curwifescore / rs->maxwifescore);
return 1;
}
static int GetReplaySnapshotSDForNoterow(T* p, lua_State* L) {
int row = IArg(1);
auto rs = REPLAYS->GetActiveReplay()->GetReplaySnapshotForNoterow(row);

lua_pushnumber(L, rs->standardDeviation);
return 1;
}
static int GetReplaySnapshotMeanForNoterow(T* p, lua_State* L) {
int row = IArg(1);
auto rs = REPLAYS->GetActiveReplay()->GetReplaySnapshotForNoterow(row);

lua_pushnumber(L, rs->mean);
return 1;
}
static int GetReplayRate(T* p, lua_State* L)
{
Locator::getLogger()->info("Getting replay rate");
Expand Down Expand Up @@ -386,10 +352,6 @@ class LunaScreenEvaluation : public Luna<ScreenEvaluation>
{
ADD_METHOD(GetStageStats);
ADD_METHOD(SetPlayerStageStatsFromReplayData);
ADD_METHOD(GetReplaySnapshotJudgmentsForNoterow);
ADD_METHOD(GetReplaySnapshotWifePercentForNoterow);
ADD_METHOD(GetReplaySnapshotSDForNoterow);
ADD_METHOD(GetReplaySnapshotMeanForNoterow);
ADD_METHOD(GetReplayRate);
ADD_METHOD(GetReplayJudge);
ADD_METHOD(ScoreUsedInvalidModifier);
Expand Down
10 changes: 10 additions & 0 deletions src/Etterna/Singletons/ReplayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,20 @@ class LunaReplayManager : public Luna<ReplayManager>
p->GetReplay(hs)->PushSelf(L);
return 1;
}
static int GetActiveReplay(T* p, lua_State* L) {
auto* r = p->GetActiveReplay();
if (r == nullptr) {
lua_pushnil(L);
} else {
r->PushSelf(L);
}
return 1;
}

LunaReplayManager()
{
ADD_METHOD(GetReplay);
ADD_METHOD(GetActiveReplay);
}
};
LUA_REGISTER_CLASS(ReplayManager)

0 comments on commit 3e6fe84

Please sign in to comment.