Implement FadeProgress class (#110)

This commit is contained in:
oxixes
2023-01-08 00:49:25 +01:00
committed by GitHub
parent 050bbeab29
commit a7c8d40275
5 changed files with 98 additions and 8 deletions
+2
View File
@@ -1,4 +1,6 @@
target_sources(uking PRIVATE
uiFadeProgress.cpp
uiFadeProgress.h
uiPauseMenuDataMgr.cpp
uiPauseMenuDataMgr.h
uiUtils.cpp
+56
View File
@@ -0,0 +1,56 @@
#include "Game/UI/uiFadeProgress.h"
#include "Game/UI/uiUtils.h"
namespace uking::ui {
SEAD_SINGLETON_DISPOSER_IMPL(FadeProgress)
void FadeProgress::init() {
mActive = false;
mProgress = 0.0;
mGaugeValue = 0.0;
mSteps = 1.0;
}
void FadeProgress::reset() {
init();
}
void FadeProgress::updateFadeScreen() {
if (!mActive)
return;
float progress = mProgress;
float difference = progress - mGaugeValue;
if (difference > 0.1f)
mSteps = 1.1;
if (difference > 0.2f)
mSteps = 1.2;
if (progress > 0.94f)
mSteps = 10.0;
if (difference <= 0.0001f && difference >= -0.0001f)
mSteps = 1.0;
float new_progress = mGaugeValue + (mProgressPerStep * mSteps);
if (new_progress < progress)
progress = new_progress;
mGaugeValue = progress;
applyScreenFade(progress);
}
void FadeProgress::setProgress(float value) {
if (mProgress < value)
mProgress = value;
}
float FadeProgress::getGaugeValue() const {
return mGaugeValue;
}
void FadeProgress::setIsActive() {
mActive = true;
}
} // namespace uking::ui
+28
View File
@@ -0,0 +1,28 @@
#pragma once
#include <heap/seadDisposer.h>
namespace uking::ui {
class FadeProgress {
SEAD_SINGLETON_DISPOSER(FadeProgress)
FadeProgress() = default;
~FadeProgress() = default;
public:
void init();
void reset();
void updateFadeScreen();
void setProgress(float value);
float getGaugeValue() const;
void setIsActive();
private:
bool mActive = false;
float mProgress = 0.0;
float mGaugeValue = 0.0;
float mProgressPerStep = 0.002;
float mSteps = 1.0;
};
} // namespace uking::ui
+4
View File
@@ -43,4 +43,8 @@ int countCookResultsCheck(const sead::SafeString& name, s32 effect_type);
int countCookResultsAllOk(const sead::SafeString& name);
int getItemValue(const sead::SafeString& name);
// TODO: move these to another translation unit (TBD)
// Do not implement until the location is figured out
void applyScreenFade(float progress);
} // namespace uking::ui