From c5fa86c9bb69216c03c2fa52cc898919753751b5 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 16 Nov 2022 14:17:35 -0800 Subject: [PATCH] Match and link CRepeatState Former-commit-id: 6e006bdcbdc5bc13138e4d0e28fb3cfc75241ee4 --- configure.py | 2 +- include/GuiSys/CGuiTableGroup.hpp | 16 ++++++++++++++++ obj_files.mk | 2 +- src/GuiSys/CRepeatState.cpp | 24 ++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 include/GuiSys/CGuiTableGroup.hpp create mode 100644 src/GuiSys/CRepeatState.cpp diff --git a/configure.py b/configure.py index d6602157..6cc5c773 100755 --- a/configure.py +++ b/configure.py @@ -460,7 +460,7 @@ LIBS = [ "GuiSys/CGuiWidgetDrawParms", "GuiSys/CAuiEnergyBarT01", "GuiSys/CAuiImagePane", - "GuiSys/CRepeatState", + ["GuiSys/CRepeatState", True], ], }, { diff --git a/include/GuiSys/CGuiTableGroup.hpp b/include/GuiSys/CGuiTableGroup.hpp new file mode 100644 index 00000000..d654063b --- /dev/null +++ b/include/GuiSys/CGuiTableGroup.hpp @@ -0,0 +1,16 @@ +#ifndef _CGUITABLEGROUP +#define _CGUITABLEGROUP + +#include "GuiSys/CGuiObject.hpp" + +class CGuiTableGroup { +public: + class CRepeatState { + CRepeatState(); + uchar Update(float dt, bool state); + private: + float x0_timer; + }; +}; + +#endif // _CGUITABLEGROUP diff --git a/obj_files.mk b/obj_files.mk index a6b63657..0f0bc95b 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -403,7 +403,7 @@ GUISYS :=\ $(BUILD_DIR)/asm/GuiSys/CGuiWidgetDrawParms.o\ $(BUILD_DIR)/asm/GuiSys/CAuiEnergyBarT01.o\ $(BUILD_DIR)/asm/GuiSys/CAuiImagePane.o\ - $(BUILD_DIR)/asm/GuiSys/CRepeatState.o\ + $(BUILD_DIR)/src/GuiSys/CRepeatState.o\ COLLISION :=\ $(BUILD_DIR)/asm/Collision/CCollidableAABox.o\ diff --git a/src/GuiSys/CRepeatState.cpp b/src/GuiSys/CRepeatState.cpp new file mode 100644 index 00000000..e59e79a8 --- /dev/null +++ b/src/GuiSys/CRepeatState.cpp @@ -0,0 +1,24 @@ +#include "GuiSys/CGuiTableGroup.hpp" + +CGuiTableGroup::CRepeatState::CRepeatState() : x0_timer(0.f) {} + +uchar CGuiTableGroup::CRepeatState::Update(float dt, bool state) { + bool ret = false; + if (x0_timer == 0.f) { + if (state) { + x0_timer = 0.6f; + ret = true; + } + } else { + if (state) { + x0_timer -= dt; + if (x0_timer <= 0.f) { + x0_timer = 0.05f; + ret = true; + } + } else { + x0_timer = 0.f; + } + } + return ret; +}