Example #1
0
		bool ScreenGameplay::Run(double Delta)
		{
			if (Next)
				return RunNested(Delta);

			if (!DoPlay)
				return false;

			if (ForceActivation)
			{
				Activate();
				ForceActivation = false;
			}

			if (Active)
			{
				Time.Game += Delta;
				Time.Miss -= Delta;
				Time.Failure -= Delta;
				Time.Success -= Delta;

				if (Time.Game >= Time.Waiting)
				{
					UpdateSongTime(Delta);

					// PlayerContext::Update(Time.Stream)
					CheckShouldEndScreen();
				}
				else
				{
					Time.InterpolatedStream = -(Time.Waiting - Time.Game);
					Time.Stream = Time.InterpolatedStream;
				}
			}

			RunAutoEvents();
			for (auto &p : Players)
				p->Update(Time.InterpolatedStream);

			Animations->UpdateTargets(Delta);
			BGA->Update(Delta);
			Render();

			if (Delta > 0.1)
				Log::Logf("ScreenGameplay7K: Delay@[ST%.03f/RST:%.03f] = %f\n", GetScreenTime(), Time.Game, Delta);

			return Running;
		}
Example #2
0
bool ScreenLoading::Run(double TimeDelta)
{
    if (!LoadThread && !ThreadInterrupted)
        return (Running = RunNested(TimeDelta));

    if (!Animations) return false;

    Animations->DrawTargets(TimeDelta);

    if (FinishedLoading)
    {
        LoadThread->join();
        LoadThread = nullptr;
        Next->InitializeResources();
        ChangeState(StateExit);
    }

    std::this_thread::sleep_for(std::chrono::milliseconds(16));
    return Running;
}
Example #3
0
/* TODO: Use measure ratios instead of song time for the barline. */
bool ScreenGameplay::Run(double TimeDelta)
{
    if (Music && LeadInTime <= 0)
    {
        SongDelta = Music->GetStreamedTime() - SongTime;

        SongTime += SongDelta;
    }

    float ScreenTime = Screen::GetScreenTime();
    if (ScreenTime > ScreenPauseTime || !ShouldChangeScreenAtEnd) // we're over the pause?
    {
        if (SongTime <= 0)
        {
            if (LeadInTime > 0)
            {
                LeadInTime -= TimeDelta;
                SongTime = -LeadInTime;
            }
            else
                startMusic();
        }

        if (Next) // We have a pending screen?
            return RunNested(TimeDelta); // use that instead.

        RunMeasure(SongDelta);

        if (LeadInTime)
            Barline.Run(TimeDelta, MeasureRatio);
        else
            Barline.Run(SongDelta, MeasureRatio);

        if (SongTime > CurrentDiff->Offset)
        {
            while (BarlineRatios.size() && BarlineRatios.at(0).Time <= SongTime)
            {
                RatioPerSecond = BarlineRatios.front().Value;
                BarlineRatios.erase(BarlineRatios.begin());
            }

            MeasureRatio += RatioPerSecond * SongDelta;

            if (SongDelta == 0 && !IsPaused)
            {
                if ((!Music || !Music->IsPlaying()))
                    MeasureRatio += RatioPerSecond * TimeDelta;
            }

            if (MeasureRatio > 1.0f)
            {
                MeasureRatio -= 1.0f;
                Measure += 1;
            }
            Lifebar.Run(SongDelta);
            aJudgment.Run(TimeDelta);
        }
    }

    if (ShouldChangeScreenAtEnd)
    {
        float TotalTime = (CurrentDiff->Offset + MySong->LeadInTime + ScreenPauseTime);
        float X = GetScreenTime() / TotalTime;
        float xPos;

        if (X < 0.5)
            xPos = ((-2)*X*X + 2 * X) * ScreenWidth;
        else
            xPos = ScreenWidth - ((-2)*X*X + 2 * X) * ScreenWidth;

        ReadySign.SetPosition(xPos, ScreenHeight / 2);
        ReadySign.Alpha = 2 * ((-2)*X*X + 2 * X);

        // Lights
        float LightProgress = GetScreenTime() / 1.5;
        if (LightProgress <= 1)
            WindowFrame.SetLightMultiplier(LightProgress * 1.2);
    }
    else
        ReadySign.Alpha = 0;

    RenderObjects(TimeDelta);

    if (ShouldChangeScreenAtEnd && Measure >= CurrentDiff->Measures.size())
    {
        auto Eval = std::make_shared<ScreenEvaluation>();
        Eval->Init(Evaluation, MySong->SongAuthor, MySong->SongName);
        Next = Eval;
        Music->Stop();
    }

    // You died? Not editing? Failing is enabled?
    if (Lifebar.Health <= 0 && !EditMode && FailEnabled)
        Running = false; // It's over.

    return Running;
}