#include "koopatlas/starcoin.h" #include dWMStarCoin_c *dWMStarCoin_c::instance = 0; dWMStarCoin_c *dWMStarCoin_c::build() { void *buffer = AllocFromGameHeap1(sizeof(dWMStarCoin_c)); dWMStarCoin_c *c = new(buffer) dWMStarCoin_c; instance = c; return 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) { bool gotFile = layout.loadArc("StarCoins.arc", false); if (!gotFile) return false; bool output = layout.build("StarCoins.brlyt"); layout.layout.rootPane->trans.x = -112.0f; if (IsWideScreen()) { layout.layout.rootPane->scale.x = 0.735f; } else { layout.clippingEnabled = true; layout.clipX = 0; layout.clipY = 52; layout.clipWidth = 640; layout.clipHeight = 352; layout.layout.rootPane->scale.x = 0.7711f; layout.layout.rootPane->scale.y = 0.7711f; } static const char *brlanNames[] = { "StarCoins_Show.brlan", "StarCoins_ShowSection.brlan", "StarCoins_HideSection.brlan", "StarCoins_ShowArrow.brlan", "StarCoins_HideArrow.brlan", }; static const char *groupNames[] = { "base", "section", "section", "leftArrow", "leftArrow", "rightArrow", "rightArrow" }; layout.loadAnimations(brlanNames, 5); layout.loadGroups(groupNames, (int[7]){0, 1, 2, 3, 4, 3, 4}, 7); layout.disableAllAnimations(); layout.drawOrder = 1; for (int col = 0; col < COLUMN_COUNT; col++) { for (int shine = 0; shine < SHINE_COUNT; shine++) { char name[8]; sprintf(name, "Shine%d%d", col, shine); Shine[col][shine] = layout.findPictureByName(name); } for (int row = 0; row < ROW_COUNT; row++) { char lname[12]; sprintf(lname, "LevelName%d%d", col, row); LevelName[col][row] = layout.findTextBoxByName(lname); char coname[16], cname[8]; for (int i = 0; i < 3; i++) { sprintf(coname, "CoinOutline%d%d%d", col, row, i); CoinOutline[col][row][i] = layout.findPictureByName(coname); sprintf(cname, "Coin%d%d%d", col, row, i); Coin[col][row][i] = layout.findPictureByName(cname); } } } static const char *tbNames[] = { "LeftTitle", "RightTitle", "TotalCoinCount", "UnspentCoinCount", "EarnedCoinCount", "EarnedCoinMax", "BtnWorldSelText", "BtnBackText", }; layout.getTextBoxes(tbNames, &LeftTitle, 8); WriteBMGToTextBox(BtnBackText, GetBMG(), 3, 1, 0); WriteBMGToTextBox(BtnWorldSelText, GetBMG(), 4, 11, 0); layoutLoaded = true; } return true; } int dWMStarCoin_c::onDelete() { return layout.free(); } void dWMStarCoin_c::show() { if (state.getCurrentState() == &StateID_Hidden) state.setState(&StateID_ShowWait); } int dWMStarCoin_c::onExecute() { state.execute(); if (visible) { layout.execAnimations(); layout.update(); } return true; } int dWMStarCoin_c::onDraw() { if (visible) layout.scheduleForDrawing(); 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; }