Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/etternagame/etterna into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
nico-abram committed Sep 14, 2018
2 parents fd46634 + 900aaca commit 7f7e7da
Show file tree
Hide file tree
Showing 15 changed files with 200 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ function scoreBoard(pn,position)
self:queuecommand("Set")
end,
SetCommand=function(self)
self:settextf("%03d/%03d",score:GetRadarValues():GetValue("RadarCategory_"..fart[i]),pss:GetRadarPossible():GetValue("RadarCategory_"..fart[i]))
self:settextf("%03d/%03d",pss:GetRadarActual():GetValue("RadarCategory_"..fart[i]),pss:GetRadarPossible():GetValue("RadarCategory_"..fart[i]))
end,
ScoreChangedMessageCommand = function(self) self:queuecommand("Set"); end,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ t[#t+1] = LoadFont("Common Normal")..{
t[#t+1] = LoadFont("Common Normal")..{
Name="ReplayViewer",
InitCommand=function(self)
self:y(frameHeight-headeroffY - 30 - offsetY):zoom(0.5):halign(-2):settext("")
self:xy((frameWidth-offsetX- frameX)/2 + 25,frameHeight-headeroffY - 30 - offsetY):zoom(0.5):halign(1):settext("")
end,
DisplayCommand=function(self)
if score:HasReplayData() then
Expand All @@ -530,7 +530,7 @@ t[#t+1] = LoadFont("Common Normal")..{
t[#t+1] = LoadFont("Common Normal")..{
Name="EvalViewer",
InitCommand=function(self)
self:y(frameHeight-headeroffY - 30 - offsetY):zoom(0.5):halign(-3):settext("")
self:xy(frameWidth-offsetX- frameX,frameHeight-headeroffY - 30 - offsetY):zoom(0.5):halign(1):settext("")
end,
DisplayCommand=function(self)
if score:HasReplayData() then
Expand Down Expand Up @@ -565,7 +565,7 @@ function nestedTabButton(i)
return
Def.ActorFrame{
InitCommand=function(self)
self:xy(frameX + offsetX + (i-1)*(nestedTabButtonWidth), frameY + headeroffY)
self:xy(frameX + offsetX + (i-1)*(nestedTabButtonWidth-80), frameY + headeroffY)
self:SetUpdateFunction(highlight)
end,
CollapseCommand=function(self)
Expand All @@ -576,7 +576,7 @@ function nestedTabButton(i)
end,
LoadFont("Common normal") .. {
InitCommand=function(self)
self:diffuse(getMainColor('positive')):maxwidth(nestedTabButtonWidth):maxheight(40):zoom(0.75):settext(nestedTabs[i]):halign(0)
self:diffuse(getMainColor('positive')):maxwidth(nestedTabButtonWidth-80):maxheight(40):zoom(0.75):settext(nestedTabs[i]):halign(0)
end,
HighlightCommand=function(self)
if isOver(self) and nestedTab ~= i then
Expand Down Expand Up @@ -612,4 +612,4 @@ for i=1,#nestedTabs do
end


return ret
return ret
6 changes: 5 additions & 1 deletion src/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,12 @@ void DownloadManager::UpdatePacks(float fDeltaSeconds)
}
}
}
if(finishedADownload)
if (finishedADownload)
{
UpdateDLSpeed();
if (downloads.empty())
MESSAGEMAN->Broadcast("AllDownloadsCompleted");
}
if (installedPacks) {
auto screen = SCREENMAN->GetScreen(0);
if (screen && screen->GetName() == "ScreenSelectMusic")
Expand Down
3 changes: 3 additions & 0 deletions src/GameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2746,6 +2746,9 @@ static const Game *g_Games[] =

GameManager::GameManager()
{
m_bResetModifiers = false;
m_fPreviousRate = 1.f;
m_sModsToReset;
// Register with Lua.
{
Lua *L = LUA->Get();
Expand Down
4 changes: 4 additions & 0 deletions src/GameManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class GameManager
const Style* GameAndStringToStyle( const Game* pGame, const RString &sStyle );
RString StyleToLocalizedString( const Style* s );

bool m_bResetModifiers;
float m_fPreviousRate;
RString m_sModsToReset;


// Lua
void PushSelf( lua_State *L );
Expand Down
7 changes: 4 additions & 3 deletions src/HighScore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,14 +748,15 @@ bool HighScore::LoadReplayDataFull() {

if (tokens[0] == "H") {
HoldReplayResult hrr;
hrr.row = std::stoi(tokens[0]);
hrr.track = std::stoi(tokens[1]);
tmp = tokens.size() > 2 ? ::stoi(tokens[2]) : TapNoteSubType_Hold;
hrr.row = std::stoi(tokens[1]);
hrr.track = std::stoi(tokens[2]);
tmp = tokens.size() > 3 ? ::stoi(tokens[3]) : TapNoteSubType_Hold;
if (tmp < 0 || tmp >= NUM_TapNoteSubType || !(typeid(tmp) == typeid(int))) {
LOG->Warn("Failed to load replay data at %s (\"Tapnotesubtype value is not of type TapNoteSubType\")", path.c_str());
}
hrr.subType = static_cast<TapNoteSubType>(tmp);
vHoldReplayDataVector.emplace_back(hrr);
tokens.clear();
continue;
}
noteRow = std::stoi(tokens[0]);
Expand Down
71 changes: 49 additions & 22 deletions src/NoteDataWithScoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "PlayerStageStats.h"
#include "ThemeMetric.h"
#include "TimingData.h"
#include "GamePreferences.h"

namespace
{
Expand All @@ -21,36 +22,62 @@ int LastTapNoteScoreTrack( const NoteData &in, unsigned iRow, PlayerNumber pn )
{
float scoretime = -9999;
int best_track = -1;
for( int t=0; t<in.GetNumTracks(); t++ )
if (GamePreferences::m_AutoPlay == PC_REPLAY)
{
/* Skip empty tracks and mines */
const TapNote &tn = in.GetTapNote( t, iRow );
if (tn.type == TapNoteType_Empty ||
tn.type == TapNoteType_Mine ||
tn.type == TapNoteType_Fake ||
tn.type == TapNoteType_AutoKeysound)
continue;
if( tn.pn != PLAYER_INVALID && tn.pn != pn && pn != PLAYER_INVALID )
continue;

TapNoteScore tns = tn.result.tns;

if ( tns == TNS_Miss || (!GAMESTATE->CountNotesSeparately() && tns == TNS_None) )
// In replay mode, judging misses as the "last" tap of every single row breaks judge counting.
// Since we judge left to right in Replay, we just check to see which track was last judged.
for (int t = in.GetNumTracks() - 1; t >= 0; t--)
{
const TapNote &tn = in.GetTapNote(t, iRow);
if (tn.type == TapNoteType_Empty ||
tn.type == TapNoteType_Mine ||
tn.type == TapNoteType_Fake ||
tn.type == TapNoteType_AutoKeysound)
continue;
if (tn.pn != PLAYER_INVALID && tn.pn != pn && pn != PLAYER_INVALID)
continue;

TapNoteScore tns = tn.result.tns;
if (tns == TNS_None)
continue;
best_track = t;
return t;
}
if ( tns == TNS_None )
continue;
return best_track;
}
else
{
for( int t=0; t<in.GetNumTracks(); t++ )
{
/* Skip empty tracks and mines */
const TapNote &tn = in.GetTapNote( t, iRow );
if (tn.type == TapNoteType_Empty ||
tn.type == TapNoteType_Mine ||
tn.type == TapNoteType_Fake ||
tn.type == TapNoteType_AutoKeysound)
continue;
if( tn.pn != PLAYER_INVALID && tn.pn != pn && pn != PLAYER_INVALID )
continue;

TapNoteScore tns = tn.result.tns;

if ( tns == TNS_Miss || (!GAMESTATE->CountNotesSeparately() && tns == TNS_None) )
{
return t;
}
if ( tns == TNS_None )
continue;


float tm = tn.result.fTapNoteOffset;
if(tm < scoretime) continue;
float tm = tn.result.fTapNoteOffset;
if(tm < scoretime) continue;

scoretime = tm;
best_track = t;
}
scoretime = tm;
best_track = t;
}

return best_track;
return best_track;
}
}

/* Return the minimum tap score of a row: the lowest grade of the tap in the row.
Expand Down
2 changes: 1 addition & 1 deletion src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2195,7 +2195,7 @@ void Player::Step( int col, int row, const std::chrono::steady_clock::time_point
}
else // every other case
{
if (pTN->IsNote())
if (pTN->IsNote() || pTN->type == TapNoteType_Lift)
score = PlayerAI::GetTapNoteScoreForReplay(m_pPlayerState, fNoteOffset);
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/PlayerAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ float PlayerAI::GetTapNoteOffsetForReplay(TapNote* pTN, int noteRow, int col)
{
if (trr.type == TapNoteType_Mine) // hack for mines
return -2.f;
if (pTN->type == TapNoteType_Lift)
{
if (trr.type != TapNoteType_Lift)
continue;
}
return -trr.offset;
}
}
Expand Down
27 changes: 25 additions & 2 deletions src/ScreenEvaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,14 @@ void ScreenEvaluation::Init()
}

// update persistent statistics
if( SUMMARY && GamePreferences::m_AutoPlay != PC_REPLAY)
m_pStageStats->FinalizeScores( true );
if (SUMMARY && GamePreferences::m_AutoPlay == PC_REPLAY)
{
m_pStageStats->m_player[PLAYER_1].m_HighScore.SetRadarValues(m_pStageStats->m_player[PLAYER_1].m_radarActual);
}
else if (SUMMARY && GamePreferences::m_AutoPlay != PC_REPLAY)
{
m_pStageStats->FinalizeScores(true);
}

// Run this here, so STATSMAN->m_CurStageStats is available to overlays.
ScreenWithMenuElements::Init();
Expand Down Expand Up @@ -748,6 +754,23 @@ void ScreenEvaluation::HandleMenuStart()
stepsid.FromSteps(GAMESTATE->m_pCurSteps[PLAYER_1]);
SongID songid;
songid.FromSong(GAMESTATE->m_pCurSong);
if (GAMEMAN->m_bResetModifiers)
{
float oldRate = GAMEMAN->m_fPreviousRate;
const RString mods = GAMEMAN->m_sModsToReset;
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetSong().FromString("clearall");
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetCurrent().FromString("clearall");
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetPreferred().FromString("clearall");
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetSong().FromString(mods);
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetCurrent().FromString(mods);
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetPreferred().FromString(mods);
GAMESTATE->m_SongOptions.GetSong().m_fMusicRate = oldRate;
GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate = oldRate;
GAMESTATE->m_SongOptions.GetPreferred().m_fMusicRate = oldRate;
GAMEMAN->m_bResetModifiers = false;
GAMEMAN->m_sModsToReset = "";
MESSAGEMAN->Broadcast("RateChanged");
}
StartTransitioningScreen( SM_GoToNextScreen );
}

Expand Down
39 changes: 39 additions & 0 deletions src/ScreenGameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Foreground.h"
#include "Game.h"
#include "GameConstantsAndTypes.h"
#include "GameManager.h"
#include "GamePreferences.h"
#include "GameSoundManager.h"
#include "GameState.h"
Expand Down Expand Up @@ -1583,7 +1584,26 @@ void ScreenGameplay::Update( float fDeltaTime )
if(GIVING_UP_GOES_TO_PREV_SCREEN && !m_skipped_song)
{
if (GamePreferences::m_AutoPlay == PC_REPLAY)
{
if (GAMEMAN->m_bResetModifiers)
{
float oldRate = GAMEMAN->m_fPreviousRate;
const RString mods = GAMEMAN->m_sModsToReset;
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetSong().FromString("clearall");
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetCurrent().FromString("clearall");
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetPreferred().FromString("clearall");
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetSong().FromString(mods);
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetCurrent().FromString(mods);
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetPreferred().FromString(mods);
GAMESTATE->m_SongOptions.GetSong().m_fMusicRate = oldRate;
GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate = oldRate;
GAMESTATE->m_SongOptions.GetPreferred().m_fMusicRate = oldRate;
GAMEMAN->m_bResetModifiers = false;
GAMEMAN->m_sModsToReset = "";
MESSAGEMAN->Broadcast("RateChanged");
}
GamePreferences::m_AutoPlay.Set(PC_HUMAN);
}
BeginBackingOutFromGameplay();
}
else
Expand Down Expand Up @@ -1876,7 +1896,26 @@ bool ScreenGameplay::Input( const InputEventPlus &input )
{
LOG->Trace("Player %i went back", input.pn+1);
if (GamePreferences::m_AutoPlay == PC_REPLAY)
{
if (GAMEMAN->m_bResetModifiers)
{
float oldRate = GAMEMAN->m_fPreviousRate;
const RString mods = GAMEMAN->m_sModsToReset;
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetSong().FromString("clearall");
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetCurrent().FromString("clearall");
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetPreferred().FromString("clearall");
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetSong().FromString(mods);
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetCurrent().FromString(mods);
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.GetPreferred().FromString(mods);
GAMESTATE->m_SongOptions.GetSong().m_fMusicRate = oldRate;
GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate = oldRate;
GAMESTATE->m_SongOptions.GetPreferred().m_fMusicRate = oldRate;
GAMEMAN->m_bResetModifiers = false;
GAMEMAN->m_sModsToReset = "";
MESSAGEMAN->Broadcast("RateChanged");
}
GamePreferences::m_AutoPlay.Set(PC_HUMAN);
}
BeginBackingOutFromGameplay();
}
else if( PREFSMAN->m_bDelayedBack && input.type==IET_FIRST_PRESS )
Expand Down
3 changes: 1 addition & 2 deletions src/ScreenInstallOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ void ScreenInstallOverlay::Update(float fDeltaTime)
msg.SetParam("queuedpacks", RString(""));
}
MESSAGEMAN->Broadcast(msg);
} else
MESSAGEMAN->Broadcast("AllDownloadsCompleted"); // silly to handle this through updates but im not sure where is better atm -mina
}
#endif
}

Expand Down
Loading

0 comments on commit 7f7e7da

Please sign in to comment.