diff options
| author | oxixes <38050447+oxixes@users.noreply.github.com> | 2023-01-08 00:49:25 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-08 00:49:25 +0100 |
| commit | a7c8d40275b52656291afaa86c7589641915cf1a (patch) | |
| tree | b86c5394eae97361aa74b3f7d07bc1164631ba4f /src/Game/UI/uiFadeProgress.cpp | |
| parent | 050bbeab29f6175a31beb6cad1737e62ffdd6f4f (diff) | |
Implement FadeProgress class (#110)
Diffstat (limited to 'src/Game/UI/uiFadeProgress.cpp')
| -rw-r--r-- | src/Game/UI/uiFadeProgress.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/Game/UI/uiFadeProgress.cpp b/src/Game/UI/uiFadeProgress.cpp new file mode 100644 index 00000000..87ded166 --- /dev/null +++ b/src/Game/UI/uiFadeProgress.cpp @@ -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
\ No newline at end of file |
