summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroxixes <38050447+oxixes@users.noreply.github.com>2023-01-08 00:49:25 +0100
committerGitHub <noreply@github.com>2023-01-08 00:49:25 +0100
commita7c8d40275b52656291afaa86c7589641915cf1a (patch)
treeb86c5394eae97361aa74b3f7d07bc1164631ba4f
parent050bbeab29f6175a31beb6cad1737e62ffdd6f4f (diff)
Implement FadeProgress class (#110)
-rw-r--r--data/uking_functions.csv16
-rw-r--r--src/Game/UI/CMakeLists.txt2
-rw-r--r--src/Game/UI/uiFadeProgress.cpp56
-rw-r--r--src/Game/UI/uiFadeProgress.h28
-rw-r--r--src/Game/UI/uiUtils.h4
5 files changed, 98 insertions, 8 deletions
diff --git a/data/uking_functions.csv b/data/uking_functions.csv
index e264c00b..5ec2a587 100644
--- a/data/uking_functions.csv
+++ b/data/uking_functions.csv
@@ -49384,13 +49384,13 @@ Address,Quality,Size,Name
0x00000071007cb938,U,000092,
0x00000071007cb994,U,000056,
0x00000071007cb9cc,U,000092,
-0x00000071007cba28,U,000144,FadeProgress::createInstance
-0x00000071007cbab8,U,000020,FadeProgress::init
-0x00000071007cbacc,U,000020,FadeProgress::reset
-0x00000071007cbae0,U,000180,FadeProgress::updateFadeScreen
-0x00000071007cbb94,U,000020,FadeProgress::setProgress
-0x00000071007cbba8,U,000008,FadeProgress::getGaugeValue
-0x00000071007cbbb0,U,000012,FadeProgress::setIsActive
+0x00000071007cba28,O,000144,_ZN5uking2ui12FadeProgress14createInstanceEPN4sead4HeapE
+0x00000071007cbab8,O,000020,_ZN5uking2ui12FadeProgress4initEv
+0x00000071007cbacc,O,000020,_ZN5uking2ui12FadeProgress5resetEv
+0x00000071007cbae0,O,000180,_ZN5uking2ui12FadeProgress16updateFadeScreenEv
+0x00000071007cbb94,O,000020,_ZN5uking2ui12FadeProgress11setProgressEf
+0x00000071007cbba8,O,000008,_ZNK5uking2ui12FadeProgress13getGaugeValueEv
+0x00000071007cbbb0,O,000012,_ZN5uking2ui12FadeProgress11setIsActiveEv
0x00000071007cbbbc,U,000020,StageBinder::ctor
0x00000071007cbbd0,U,000068,StageBinder::dtor
0x00000071007cbc14,U,000068,StageBinder::dtorDelete
@@ -88672,7 +88672,7 @@ Address,Quality,Size,Name
0x00000071010b62c4,U,000340,ui::isFadeDemoOrFadeScreenOpened
0x00000071010b6418,U,000320,
0x00000071010b6558,U,000024,
-0x00000071010b6570,U,000200,
+0x00000071010b6570,U,000200,applyScreenFade
0x00000071010b6638,U,000376,
0x00000071010b67b0,O,000096,_ZN4ksys7AutoDim18SingletonDisposer_D1Ev
0x00000071010b6810,O,000104,_ZN4ksys7AutoDim18SingletonDisposer_D0Ev
diff --git a/src/Game/UI/CMakeLists.txt b/src/Game/UI/CMakeLists.txt
index 61a562d6..392d89bc 100644
--- a/src/Game/UI/CMakeLists.txt
+++ b/src/Game/UI/CMakeLists.txt
@@ -1,4 +1,6 @@
target_sources(uking PRIVATE
+ uiFadeProgress.cpp
+ uiFadeProgress.h
uiPauseMenuDataMgr.cpp
uiPauseMenuDataMgr.h
uiUtils.cpp
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
diff --git a/src/Game/UI/uiFadeProgress.h b/src/Game/UI/uiFadeProgress.h
new file mode 100644
index 00000000..4669ff86
--- /dev/null
+++ b/src/Game/UI/uiFadeProgress.h
@@ -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 \ No newline at end of file
diff --git a/src/Game/UI/uiUtils.h b/src/Game/UI/uiUtils.h
index 9dc0e2e9..b68a1d58 100644
--- a/src/Game/UI/uiUtils.h
+++ b/src/Game/UI/uiUtils.h
@@ -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