Change time differentials to a stack.
All checks were successful
Emscripten Build / Build_and_Deploy_Web_Build (push) Successful in 42s
All checks were successful
Emscripten Build / Build_and_Deploy_Web_Build (push) Successful in 42s
This commit is contained in:
parent
edc45fda68
commit
48c620c34e
@ -21,7 +21,7 @@ void Timer::Reset(){
|
||||
engineTime=elapsedTime=0.;
|
||||
currentSplitInd=Timer::NOT_STARTED;
|
||||
currentRunTimes.clear();
|
||||
differentialTotal=0.;
|
||||
while(!differentialTotal.empty())differentialTotal.pop();
|
||||
video.Reset();
|
||||
RecalculateSumOfBest();
|
||||
Pause();
|
||||
@ -117,7 +117,10 @@ void Timer::Draw(vf2d drawPos){
|
||||
vf2d textSize{engine.GetTextSizeProp(timerText)*timerTextScale};
|
||||
engine.DrawStringPropDecal(timerPane.pos+vf2d{timerPane.size.x-textSize.x-4.f,3.f},timerText,timerCol,timerTextScale);
|
||||
engine.DrawStringPropDecal(sumOfBestPane.pos+vf2d{1.f,1.f},"Sum of Best",WHITE);
|
||||
const std::string sumOfBestText{sumOfBest?util::timerStr(*sumOfBest+differentialTotal+differentialTime,1U):"-"};
|
||||
|
||||
double differentialAmt{};
|
||||
if(!differentialTotal.empty())differentialAmt=differentialTotal.top();
|
||||
const std::string sumOfBestText{sumOfBest?util::timerStr(*sumOfBest+differentialAmt+differentialTime,1U):"-"};
|
||||
vf2d sumOfBestTextSize{engine.GetTextSizeProp(sumOfBestText)};
|
||||
engine.DrawStringPropDecal(sumOfBestPane.pos+vf2d{sumOfBestPane.size.x-sumOfBestTextSize.x+1.f,1.f},sumOfBestText,WHITE);
|
||||
engine.DrawRectDecal(timerPane.pos,timerPane.size,GREY);
|
||||
@ -238,7 +241,8 @@ void Timer::UpdateAndSaveSplits(){
|
||||
void Timer::OnRunFinished(){
|
||||
UpdateAndSaveSplits();
|
||||
}
|
||||
const double Timer::GetTimeBetweenPreviousAndCurrentSplit()const{
|
||||
void Timer::OnAdvanceSplit(){
|
||||
currentRunTimes.emplace_back(elapsedTime);
|
||||
double timeTakenThisSplit{elapsedTime};
|
||||
size_t runTimeInd{currentRunTimes.size()-1};
|
||||
while(runTimeInd>0){
|
||||
@ -248,12 +252,9 @@ const double Timer::GetTimeBetweenPreviousAndCurrentSplit()const{
|
||||
}
|
||||
runTimeInd--;
|
||||
}
|
||||
return timeTakenThisSplit;
|
||||
}
|
||||
void Timer::OnAdvanceSplit(){
|
||||
currentRunTimes.emplace_back(elapsedTime);
|
||||
const double timeBetweenPreviousSplit{GetTimeBetweenPreviousAndCurrentSplit()};
|
||||
if(splits[currentSplitInd].bestTime)differentialTotal+=timeBetweenPreviousSplit-*splits[currentSplitInd].bestTime;
|
||||
double previousDifferential{0.};
|
||||
if(!differentialTotal.empty())previousDifferential=differentialTotal.top();
|
||||
if(splits[currentSplitInd].bestTime)differentialTotal.emplace(previousDifferential+timeTakenThisSplit-*splits[currentSplitInd].bestTime);
|
||||
}
|
||||
void Timer::OnRunReset(){
|
||||
UpdateAndSaveSplits();
|
||||
@ -266,8 +267,7 @@ void Timer::OnAdvanceSkip(){
|
||||
void Timer::OnAdvanceReverse(){
|
||||
currentRunTimes.pop_back();
|
||||
currentSplitInd--;
|
||||
const double timeBetweenPreviousSplit{GetTimeBetweenPreviousAndCurrentSplit()};
|
||||
if(splits[currentSplitInd].bestTime)differentialTotal-=timeBetweenPreviousSplit-*splits[currentSplitInd].bestTime;
|
||||
differentialTotal.pop();
|
||||
}
|
||||
void Timer::RecalculateSumOfBest(){
|
||||
sumOfBest=std::nullopt;
|
||||
|
@ -25,12 +25,11 @@ private:
|
||||
//This function will automatically increment all split attempts up to the stopped point.
|
||||
void UpdateAndSaveSplits();
|
||||
void RecalculateSumOfBest();
|
||||
const double GetTimeBetweenPreviousAndCurrentSplit()const;
|
||||
EasternStar&engine;
|
||||
bool paused{true};
|
||||
double elapsedTime{0.};
|
||||
double engineTime{0.};
|
||||
double differentialTotal{0.};
|
||||
std::stack<double>differentialTotal{};
|
||||
std::optional<double>sumOfBest{std::nullopt};
|
||||
uint32_t totalAttempts{};
|
||||
std::vector<Split>splits{};
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user