summaryrefslogtreecommitdiff
path: root/src/koopatlas/starcoin.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-10-18 01:35:08 +0200
committerTreeki <treeki@gmail.com>2012-10-18 01:35:08 +0200
commit9af56ee115dea9cbb9ee5b8317fefdb396a0e744 (patch)
treee444fa91e0455984de0b7d53996695eea2c7e1db /src/koopatlas/starcoin.cpp
parent3ef1114c2bebd29b55fc53986b3c942a55b8b642 (diff)
downloadkamek-9af56ee115dea9cbb9ee5b8317fefdb396a0e744.tar.gz
kamek-9af56ee115dea9cbb9ee5b8317fefdb396a0e744.zip
working on star coin screen
Diffstat (limited to '')
-rw-r--r--src/koopatlas/starcoin.cpp168
1 files changed, 156 insertions, 12 deletions
diff --git a/src/koopatlas/starcoin.cpp b/src/koopatlas/starcoin.cpp
index 7b7db51..3b8372e 100644
--- a/src/koopatlas/starcoin.cpp
+++ b/src/koopatlas/starcoin.cpp
@@ -11,11 +11,19 @@ dWMStarCoin_c *dWMStarCoin_c::build() {
return c;
}
-dWMStarCoin_c::dWMStarCoin_c() {
+dWMStarCoin_c::dWMStarCoin_c() : state(this) {
layoutLoaded = false;
visible = false;
+ state.setState(&StateID_Hidden);
}
+CREATE_STATE(dWMStarCoin_c, Hidden);
+CREATE_STATE(dWMStarCoin_c, ShowWait);
+CREATE_STATE(dWMStarCoin_c, ShowSectionWait);
+CREATE_STATE(dWMStarCoin_c, Wait);
+CREATE_STATE(dWMStarCoin_c, HideSectionWait);
+CREATE_STATE(dWMStarCoin_c, HideWait);
+
int dWMStarCoin_c::onCreate() {
if (!layoutLoaded) {
@@ -100,24 +108,17 @@ int dWMStarCoin_c::onDelete() {
void dWMStarCoin_c::show() {
- visible = true;
- layout.enableNonLoopAnim(SHOW_ALL);
+ if (state.getCurrentState() == &StateID_Hidden)
+ state.setState(&StateID_ShowWait);
}
int dWMStarCoin_c::onExecute() {
+ state.execute();
+
if (visible) {
layout.execAnimations();
layout.update();
-
- int nowPressed = Remocon_GetPressed(GetActiveRemocon());
-
- if (!layout.isAnyAnimOn()) {
- if (nowPressed & WPAD_B) {
- MapSoundPlayer(SoundRelatedClass, SE_SYS_DIALOGUE_OUT_AUTO, 1);
- layout.enableNonLoopAnim(1);
- }
- }
}
return true;
@@ -130,3 +131,146 @@ int dWMStarCoin_c::onDraw() {
return true;
}
+
+void dWMStarCoin_c::showLeftArrow() {
+ if (!isLeftArrowVisible) {
+ isLeftArrowVisible = true;
+ layout.enableNonLoopAnim(SHOW_LEFT_ARROW);
+ }
+}
+
+void dWMStarCoin_c::showRightArrow() {
+ if (!isRightArrowVisible) {
+ isRightArrowVisible = true;
+ layout.enableNonLoopAnim(SHOW_RIGHT_ARROW);
+ }
+}
+
+void dWMStarCoin_c::hideLeftArrow() {
+ if (isLeftArrowVisible) {
+ isLeftArrowVisible = false;
+ layout.enableNonLoopAnim(HIDE_LEFT_ARROW);
+ }
+}
+
+void dWMStarCoin_c::hideRightArrow() {
+ if (isRightArrowVisible) {
+ isRightArrowVisible = false;
+ layout.enableNonLoopAnim(HIDE_RIGHT_ARROW);
+ }
+}
+
+void dWMStarCoin_c::setLeftArrowVisible(bool value) {
+ if (value)
+ showLeftArrow();
+ else
+ hideLeftArrow();
+}
+
+void dWMStarCoin_c::setRightArrowVisible(bool value) {
+ if (value)
+ showRightArrow();
+ else
+ hideRightArrow();
+}
+
+
+bool dWMStarCoin_c::canScrollLeft() const {
+ return (currentSection > 0);
+}
+bool dWMStarCoin_c::canScrollRight() const {
+ // TODO
+ return false;
+}
+
+void dWMStarCoin_c::loadInfo() {
+ // TODO
+}
+
+void dWMStarCoin_c::loadSectionInfo() {
+ // TODO
+}
+
+
+void dWMStarCoin_c::beginState_Hidden() { }
+void dWMStarCoin_c::executeState_Hidden() { }
+void dWMStarCoin_c::endState_Hidden() { }
+
+void dWMStarCoin_c::beginState_ShowWait() {
+ visible = true;
+ loadInfo();
+ layout.enableNonLoopAnim(SHOW_ALL);
+}
+void dWMStarCoin_c::executeState_ShowWait() {
+ if (!layout.isAnimOn(SHOW_ALL))
+ state.setState(&StateID_ShowSectionWait);
+}
+void dWMStarCoin_c::endState_ShowWait() { }
+
+void dWMStarCoin_c::beginState_ShowSectionWait() {
+ loadSectionInfo();
+ layout.enableNonLoopAnim(SHOW_SECTION);
+
+ if (canScrollLeft())
+ showLeftArrow();
+ if (canScrollRight())
+ showRightArrow();
+}
+void dWMStarCoin_c::executeState_ShowSectionWait() {
+ if (!layout.isAnimOn(SHOW_SECTION))
+ state.setState(&StateID_Wait);
+}
+void dWMStarCoin_c::endState_ShowSectionWait() { }
+
+void dWMStarCoin_c::beginState_Wait() { }
+void dWMStarCoin_c::executeState_Wait() {
+ int nowPressed = Remocon_GetPressed(GetActiveRemocon());
+
+ if (nowPressed & WPAD_ONE) {
+ MapSoundPlayer(SoundRelatedClass, SE_SYS_DIALOGUE_OUT_AUTO, 1);
+ willExit = true;
+ state.setState(&StateID_HideSectionWait);
+ } else if ((nowPressed & WPAD_LEFT) && canScrollLeft()) {
+ currentSection--;
+ willExit = false;
+ state.setState(&StateID_HideSectionWait);
+ } else if ((nowPressed & WPAD_RIGHT) && canScrollRight()) {
+ currentSection++;
+ willExit = false;
+ state.setState(&StateID_HideSectionWait);
+ }
+}
+void dWMStarCoin_c::endState_Wait() { }
+
+void dWMStarCoin_c::beginState_HideSectionWait() {
+ layout.enableNonLoopAnim(HIDE_SECTION);
+ if (willExit) {
+ hideLeftArrow();
+ hideRightArrow();
+ } else {
+ setLeftArrowVisible(canScrollLeft());
+ setRightArrowVisible(canScrollRight());
+ }
+}
+void dWMStarCoin_c::executeState_HideSectionWait() {
+ if (!layout.isAnimOn(HIDE_SECTION)) {
+ if (willExit)
+ state.setState(&StateID_HideWait);
+ else
+ state.setState(&StateID_ShowSectionWait);
+ }
+}
+void dWMStarCoin_c::endState_HideSectionWait() { }
+
+void dWMStarCoin_c::beginState_HideWait() {
+ layout.enableNonLoopAnim(SHOW_ALL);
+ layout.grpHandlers[SHOW_ALL].frameCtrl.flags = 3; // NO_LOOP | REVERSE
+}
+void dWMStarCoin_c::executeState_HideWait() {
+ if (!layout.isAnimOn(SHOW_ALL))
+ state.setState(&StateID_Wait);
+}
+void dWMStarCoin_c::endState_HideWait() {
+ visible = false;
+}
+