Match and link CRepeatState

Former-commit-id: 6e006bdcbd
This commit is contained in:
Phillip Stephens 2022-11-16 14:17:35 -08:00
parent 8e96fba1fb
commit c5fa86c9bb
4 changed files with 42 additions and 2 deletions

View File

@ -460,7 +460,7 @@ LIBS = [
"GuiSys/CGuiWidgetDrawParms", "GuiSys/CGuiWidgetDrawParms",
"GuiSys/CAuiEnergyBarT01", "GuiSys/CAuiEnergyBarT01",
"GuiSys/CAuiImagePane", "GuiSys/CAuiImagePane",
"GuiSys/CRepeatState", ["GuiSys/CRepeatState", True],
], ],
}, },
{ {

View File

@ -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

View File

@ -403,7 +403,7 @@ GUISYS :=\
$(BUILD_DIR)/asm/GuiSys/CGuiWidgetDrawParms.o\ $(BUILD_DIR)/asm/GuiSys/CGuiWidgetDrawParms.o\
$(BUILD_DIR)/asm/GuiSys/CAuiEnergyBarT01.o\ $(BUILD_DIR)/asm/GuiSys/CAuiEnergyBarT01.o\
$(BUILD_DIR)/asm/GuiSys/CAuiImagePane.o\ $(BUILD_DIR)/asm/GuiSys/CAuiImagePane.o\
$(BUILD_DIR)/asm/GuiSys/CRepeatState.o\ $(BUILD_DIR)/src/GuiSys/CRepeatState.o\
COLLISION :=\ COLLISION :=\
$(BUILD_DIR)/asm/Collision/CCollidableAABox.o\ $(BUILD_DIR)/asm/Collision/CCollidableAABox.o\

View File

@ -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;
}