summaryrefslogtreecommitdiff
path: root/src/koopatlas
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2013-01-17 09:23:55 +0100
committerTreeki <treeki@gmail.com>2013-01-17 09:23:55 +0100
commit1e2fe2181af8215e6da3f55d0350385d0af2f7e0 (patch)
tree697f2105ceedd031f901c896d2747ccdfc2b43bb /src/koopatlas
parent4a51200b922d2ed0896562d95d1d9e390a014db3 (diff)
downloadkamek-1e2fe2181af8215e6da3f55d0350385d0af2f7e0.tar.gz
kamek-1e2fe2181af8215e6da3f55d0350385d0af2f7e0.zip
myriad updates and fixes to EVERYTHING
Diffstat (limited to '')
-rw-r--r--src/koopatlas/core.cpp42
-rw-r--r--src/koopatlas/core.h4
-rw-r--r--src/koopatlas/hud.cpp27
-rw-r--r--src/koopatlas/hud.h3
-rw-r--r--src/koopatlas/pathmanager.cpp1
-rw-r--r--src/koopatlas/shop.cpp70
-rw-r--r--src/koopatlas/shop.h4
7 files changed, 89 insertions, 62 deletions
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp
index e9ae989..f0a57af 100644
--- a/src/koopatlas/core.cpp
+++ b/src/koopatlas/core.cpp
@@ -109,14 +109,6 @@ dScKoopatlas_c::dScKoopatlas_c() : state(this) {
#define NPCHG_CCI(npc,idx) (((void**)(((u32)(npc))+0xA4))[(idx)])
#define NPCHG_2DPLAYER(npc,idx) (((void**)(((u32)(npc))+0x64C))[(idx)])
-#define STKI_SETUP_DONE(si) (*((bool*)(((u32)(si))+0x310)))
-#define STKI_SHADOW(si) (*((void**)(((u32)(si))+0x310)))
-#define STKI_2DPLAYER(si,idx) (((void**)(((u32)(si))+0x2E4))[(idx)])
-#define STKI_ITEM(si,idx) (((void**)(((u32)(si))+0x2F4))[(idx)])
-#define STKI_SHOW(si) (*((bool*)(((u32)(si))+0x8DD)))
-
-#define SIS_SETUP_DONE(sis) (*((bool*)(((u32)(sis))+0x260)))
-
#define CCSB_ACTIVE(ccsb) (*((bool*)(((u32)(ccsb))+0x29C)))
#define CCSC_ACTIVE(ccsc) (*((bool*)(((u32)(ccsc))+0x2A1)))
@@ -218,8 +210,8 @@ bool WMInit_SetupWait(void *ptr) {
success &= NPCHG_SETUP_DONE(wm->numPeopleChange);
success &= YESNO_SETUP_DONE(wm->yesNoWindow);
success &= CONT_SETUP_DONE(wm->continueObj);
- success &= STKI_SETUP_DONE(wm->stockItem);
- success &= SIS_SETUP_DONE(wm->stockItemShadow);
+ success &= wm->stockItem->layoutLoaded;
+ success &= wm->stockItemShadow->layoutLoaded;
success &= EASYP_SETUP_DONE(wm->easyPairing);
return success;
@@ -243,14 +235,14 @@ bool WMInit_SetupExtra(void *ptr) {
// first up: player models for Stocked Items
for (int i = 0; i < 4; i++) {
void *obj = CreateChildObject(WM_2D_PLAYER, wm, i, 0, 0);
- STKI_2DPLAYER(wm->stockItem,i) = obj;
+ wm->stockItem->player2d[i] = obj;
NPCHG_2DPLAYER(wm->numPeopleChange,i) = obj;
}
// next: items for the Powerup screen
- for (int i = 0; i < 7; i++) {
- void *obj = CreateChildObject(WM_ITEM, wm, i, 0, 0);
- STKI_ITEM(wm->stockItem,i) = obj;
+ for (int i = 0; i < 8; i++) {
+ void *obj = CreateChildObject(WM_ITEM, wm, i==7?6:i, 0, 0);
+ wm->stockItem->newItemPtr[i] = obj;
}
// need Player before we can set up paths
@@ -398,10 +390,10 @@ int dScKoopatlas_c::onCreate() {
this->continueObj = CreateParentedObject(CONTINUE, this, 0, 0);
SpammyReport("stock item\n");
- this->stockItem = CreateParentedObject(STOCK_ITEM, this, 0, 0);
+ this->stockItem = (dStockItem_c*)CreateParentedObject(STOCK_ITEM, this, 0, 0);
SpammyReport("stock item shadow\n");
- this->stockItemShadow = CreateParentedObject(STOCK_ITEM_SHADOW, this, 0, 0);
- STKI_SHADOW(this->stockItem) = this->stockItemShadow;
+ this->stockItemShadow = (dStockItemShadow_c*)CreateParentedObject(STOCK_ITEM_SHADOW, this, 0, 0);
+ stockItem->shadow = stockItemShadow;
SpammyReport("easy pairing\n");
this->easyPairing = CreateParentedObject(EASY_PAIRING, this, 0, 0);
@@ -516,11 +508,13 @@ void dScKoopatlas_c::executeState_Normal() {
// Nothing related to the menu is going on
if (nowPressed & WPAD_ONE) {
- STKI_SHOW(this->stockItem) = true;
+ stockItem->show = true;
state.setState(&StateID_PowerupsWait);
+ hud->hideAll();
} else if (nowPressed & WPAD_PLUS) {
CSMENU_ACTIVE(this->csMenu) = true;
state.setState(&StateID_CSMenu);
+ hud->hideAll();
} else if (nowPressed & WPAD_MINUS) {
pathManager.unlockAllPaths(2);
} else if (nowPressed & WPAD_A) {
@@ -582,6 +576,7 @@ void dScKoopatlas_c::executeState_CSMenu() {
} else {
// Ok, change back to STATE_Normal
+ hud->unhideAll();
state.setState(&StateID_Normal);
}
}
@@ -637,6 +632,7 @@ void dScKoopatlas_c::executeState_TitleConfirmHitWait() {
if (!YESNO_OPENING(this->yesNoWindow)) {
if (YESNO_CURRENT(this->yesNoWindow) == 1) {
state.setState(&StateID_Normal);
+ hud->unhideAll();
} else {
state.setState(&StateID_Limbo);
StartTitleScreenStage(false, 0);
@@ -680,6 +676,7 @@ void dScKoopatlas_c::executeState_PlayerChangeWait() {
}
state.setState(&StateID_Normal);
+ hud->unhideAll();
}
}
@@ -712,10 +709,11 @@ void dScKoopatlas_c::executeState_EasyPairingWait() {
// STATE_PowerupsWait : Wait for the user to exit the Powerups screen.
void dScKoopatlas_c::executeState_PowerupsWait() {
- if (!STKI_SHOW(this->stockItem)) {
+ if (!stockItem->show) {
player->modelHandler->mdlClass->setPowerup(Player_Powerup[0]);
state.setState(&StateID_Normal);
+ hud->unhideAll();
}
}
@@ -727,6 +725,7 @@ void dScKoopatlas_c::executeState_ShopWait() {
if (!shop->visible) {
state.setState(&StateID_Normal);
+ hud->unhideAll();
}
}
@@ -738,6 +737,7 @@ void dScKoopatlas_c::executeState_CoinsWait() {
if (!coins->visible) {
state.setState(&StateID_Normal);
+ hud->unhideAll();
}
}
@@ -793,6 +793,7 @@ void dScKoopatlas_c::executeState_SaveWindowClose() {
if (!YESNO_VISIBLE(this->yesNoWindow)) {
if (YESNO_CURRENT(this->yesNoWindow) == 1) {
state.setState(&StateID_Normal);
+ hud->unhideAll();
} else {
state.setState(&StateID_SaveDo);
SaveGame(0, false);
@@ -836,6 +837,7 @@ void dScKoopatlas_c::executeState_SaveEndCloseWait() {
if (!YESNO_OPENING(this->yesNoWindow)) {
state.setState(&StateID_Normal);
+ hud->unhideAll();
}
}
@@ -891,6 +893,7 @@ void dScKoopatlas_c::executeState_QuickSaveWindowClose() {
if (!YESNO_VISIBLE(this->yesNoWindow)) {
if (YESNO_CURRENT(this->yesNoWindow) == 1) {
state.setState(&StateID_Normal);
+ hud->unhideAll();
} else {
state.setState(&StateID_QuickSaveDo);
SaveGame(0, true);
@@ -934,6 +937,7 @@ void dScKoopatlas_c::executeState_QuickSaveEndCloseWait() {
if (!YESNO_OPENING(this->yesNoWindow)) {
if (YESNO_CURRENT(this->yesNoWindow) == 1) {
state.setState(&StateID_Normal);
+ hud->unhideAll();
} else {
state.setState(&StateID_Limbo);
StartTitleScreenStage(false, 0);
diff --git a/src/koopatlas/core.h b/src/koopatlas/core.h
index 93cc257..788ad62 100644
--- a/src/koopatlas/core.h
+++ b/src/koopatlas/core.h
@@ -86,8 +86,8 @@ class dScKoopatlas_c : public dScene_c {
void *numPeopleChange;
void *yesNoWindow;
void *continueObj;
- void *stockItem;
- void *stockItemShadow;
+ dStockItem_c *stockItem;
+ dStockItemShadow_c *stockItemShadow;
void *easyPairing;
diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp
index 4d678c6..1032512 100644
--- a/src/koopatlas/hud.cpp
+++ b/src/koopatlas/hud.cpp
@@ -24,7 +24,9 @@ dWMHud_c::dWMHud_c() {
enum WMHudAnimation {
SHOW_LIVES = 0,
SHOW_HEADER,
- SHOW_FOOTER
+ SHOW_FOOTER,
+ HIDE_ALL,
+ UNHIDE_ALL,
};
@@ -46,16 +48,23 @@ int dWMHud_c::onCreate() {
layout.layout.rootPane->scale.y = 0.7711f;
}
- static const char *brlanNames[2] = {"MapHUD_ShowMain.brlan", "MapHUD_ShowHeader.brlan"};
- static const char *groupNames[3] = {"G_Lives", "G_Header", "G_Footer"};
+ static const char *brlanNames[] = {
+ "MapHUD_ShowMain.brlan", "MapHUD_ShowHeader.brlan",
+ "MapHUD_HideAll.brlan", "MapHUD_UnhideAll.brlan",
+ };
+ static const char *groupNames[] = {
+ "G_Lives", "G_Header", "G_Footer",
+ "G_Hideables", "G_Hideables",
+ };
- layout.loadAnimations(brlanNames, 2);
- layout.loadGroups(groupNames, (int[3]){0, 1, 0}, 3);
+ layout.loadAnimations(brlanNames, 4);
+ layout.loadGroups(groupNames, (int[5]){0, 1, 0, 2, 3}, 5);
layout.disableAllAnimations();
layout.enableNonLoopAnim(SHOW_LIVES);
layout.resetAnim(SHOW_FOOTER);
layout.resetAnim(SHOW_HEADER);
+ layout.resetAnim(HIDE_ALL);
static const char *tbNames[2] = {"MenuButtonInfo", "ItemsButtonInfo"};
layout.setLangStrings(tbNames, (int[2]){12, 15}, 4, 2);
@@ -162,6 +171,14 @@ int dWMHud_c::onDraw() {
}
+void dWMHud_c::hideAll() {
+ layout.enableNonLoopAnim(HIDE_ALL);
+}
+void dWMHud_c::unhideAll() {
+ layout.enableNonLoopAnim(UNHIDE_ALL);
+}
+
+
void dWMHud_c::playShowAnim(int id) {
diff --git a/src/koopatlas/hud.h b/src/koopatlas/hud.h
index 32a09be..982b38a 100644
--- a/src/koopatlas/hud.h
+++ b/src/koopatlas/hud.h
@@ -27,6 +27,9 @@ class dWMHud_c : public dBase_c {
void setupLives();
+ void hideAll();
+ void unhideAll();
+
private:
void playShowAnim(int id);
void playHideAnim(int id);
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp
index 6cff759..7f4b754 100644
--- a/src/koopatlas/pathmanager.cpp
+++ b/src/koopatlas/pathmanager.cpp
@@ -861,6 +861,7 @@ void dWMPathManager_c::activatePoint() {
if (l == 98) {
dWMShop_c::instance->show(w);
+ dWMHud_c::instance->hideAll();
dScKoopatlas_c::instance->state.setState(&dScKoopatlas_c::instance->StateID_ShopWait);
return;
}
diff --git a/src/koopatlas/shop.cpp b/src/koopatlas/shop.cpp
index 025a7d9..63d23e2 100644
--- a/src/koopatlas/shop.cpp
+++ b/src/koopatlas/shop.cpp
@@ -17,7 +17,6 @@ void dWMShop_c::ShopModel_c::setupItem(float x, float y, ItemTypes type) {
{ "I_star", "g3d/I_star.brres", "I_star", "wait2" },
{ "I_hammer", "g3d/I_fireflower.brres", "I_fireflower", "wait2" },
{ "I_kinoko_bundle","g3d/I_life_kinoko.brres", "I_life_kinoko", "wait2" },
- { "obj_coin", "g3d/obj_coin.brres", "obj_coin", "wait2" }
};
this->x = x;
@@ -33,12 +32,7 @@ void dWMShop_c::ShopModel_c::setupItem(float x, float y, ItemTypes type) {
nw4r::g3d::ResMdl mdlRes = res.GetResMdl(Produce[id][2]);
model.setup(mdlRes, &allocator, 0x224, 1, 0);
- if (type == COINS) {
- SetupTextures_MapObj(&model, 1);
- this->y += 20.0f;
- scaleFactor = 2.7f;
- } else
- SetupTextures_Item(&model, 1);
+ SetupTextures_Item(&model, 1);
nw4r::g3d::ResAnmChr anmChr = res.GetResAnmChr(Produce[id][3]);
animation.setup(mdlRes, anmChr, &allocator, 0);
@@ -194,6 +188,11 @@ int dWMShop_c::onCreate() {
name[8] = crap[i*2];
name[9] = crap[i*2+1];
BtnRight[i] = layout.findPictureByName(name);
+
+ strcpy(name, "BtnXX");
+ name[3] = crap[i*2];
+ name[4] = crap[i*2+1];
+ Buttons[i] = layout.findPaneByName(name);
}
leftCol.setTexMap(BtnLeft[0]->material->texMaps);
@@ -206,6 +205,8 @@ int dWMShop_c::onCreate() {
rightCol.applyAlso(BtnRight[i]->material->texMaps);
}
+ Buttons[5]->size.x = 252.0f; // don't feel like editing rlyt
+
layoutLoaded = true;
}
@@ -301,7 +302,9 @@ void dWMShop_c::executeState_ButtonActivateWait() {
if (!layout.isAnyAnimOn())
state.setState(&StateID_Wait);
}
-void dWMShop_c::endState_ButtonActivateWait() { OSReport("Wait"); }
+void dWMShop_c::endState_ButtonActivateWait() {
+ UpdateSelectCursor(Buttons[0], 0, false);
+}
// Wait
void dWMShop_c::beginState_Wait() { timer = 1; MapSoundPlayer(SoundRelatedClass, SE_OBJ_CLOUD_BLOCK_TO_JUGEM, 1); }
@@ -352,6 +355,7 @@ void dWMShop_c::executeState_Wait() {
layout.enableNonLoopAnim(DEACTIVATE_BUTTON+selected);
layout.enableNonLoopAnim(ACTIVATE_BUTTON+newSelection);
+ UpdateSelectCursor(Buttons[newSelection], 0, false);
selected = newSelection;
if (newSelection <= 3)
@@ -368,6 +372,8 @@ void dWMShop_c::beginState_HideWait() {
timer = 26;
MapSoundPlayer(SoundRelatedClass, SE_OBJ_CS_KINOHOUSE_DISAPP, 1);
+
+ HideSelectCursor(SelectCursorPointer, 0);
}
void dWMShop_c::executeState_HideWait() {
if (timer > 0) {
@@ -394,7 +400,6 @@ void dWMShop_c::endState_HideWait() {
// 6 = Starman - 2
// 7 = Hammer - 3
// 8 = 1-ups - 2
-// 9 = Coins - 1
//
// Format: 1coin, 1coin, 2coins, 3coins, 5coins[3] (Value 6-9), 8coins[5] (Value 10-15)
//
@@ -403,37 +408,37 @@ void dWMShop_c::endState_HideWait() {
const dWMShop_c::ItemTypes dWMShop_c::Inventory[10][12] = {
{ // Yoshi's Island
- COINS, MUSHROOM, FIRE_FLOWER, PROPELLER,
+ MUSHROOM, FIRE_FLOWER, ICE_FLOWER, PROPELLER,
FIRE_FLOWER, ICE_FLOWER, FIRE_FLOWER,
MUSHROOM, MUSHROOM, ONE_UP, PROPELLER, PROPELLER
},
{ // Desert
- COINS, MUSHROOM, FIRE_FLOWER, PROPELLER,
+ MUSHROOM, FIRE_FLOWER, ICE_FLOWER, PROPELLER,
FIRE_FLOWER, STARMAN, FIRE_FLOWER,
MUSHROOM, FIRE_FLOWER, FIRE_FLOWER, PROPELLER, PROPELLER
},
{ // Mountain
- COINS, MUSHROOM, MINI_SHROOM, PROPELLER,
+ MUSHROOM, FIRE_FLOWER, MINI_SHROOM, PROPELLER,
MUSHROOM, MINI_SHROOM, PROPELLER,
MUSHROOM, MINI_SHROOM, PROPELLER, PROPELLER, HAMMER
},
{ // Japan
- COINS, MUSHROOM, ONE_UP, HAMMER,
+ MUSHROOM, FIRE_FLOWER, ONE_UP, HAMMER,
ONE_UP, ONE_UP, ONE_UP,
PROPELLER, ICE_FLOWER, ONE_UP, FIRE_FLOWER, PROPELLER
},
{ // FreezeFlame
- COINS, MUSHROOM, ICE_FLOWER, PENGUIN,
+ MUSHROOM, FIRE_FLOWER, ICE_FLOWER, PENGUIN,
ICE_FLOWER, PENGUIN, ICE_FLOWER,
ICE_FLOWER, PENGUIN, PENGUIN, PENGUIN, ICE_FLOWER
},
{ // Ghost
- COINS, MUSHROOM, STARMAN, PROPELLER,
+ MUSHROOM, FIRE_FLOWER, STARMAN, PROPELLER,
MINI_SHROOM, PROPELLER, MINI_SHROOM,
- PROPELLER, PROPELLER, COINS, PROPELLER, PROPELLER
+ PROPELLER, PROPELLER, MUSHROOM, PROPELLER, PROPELLER
},
{ // Space
- COINS, MUSHROOM, STARMAN, HAMMER,
+ MUSHROOM, STARMAN, ONE_UP, HAMMER,
STARMAN, STARMAN, STARMAN,
HAMMER, HAMMER, ONE_UP, HAMMER, HAMMER
},
@@ -443,12 +448,12 @@ const dWMShop_c::ItemTypes dWMShop_c::Inventory[10][12] = {
PROPELLER, HAMMER, PROPELLER, HAMMER, PROPELLER
},
{ // Unknown
- COINS, MUSHROOM, FIRE_FLOWER, PENGUIN,
+ MUSHROOM, MUSHROOM, MUSHROOM, MUSHROOM,
MUSHROOM, MUSHROOM, MUSHROOM,
MUSHROOM, MUSHROOM, MUSHROOM, MUSHROOM, MUSHROOM
},
{ // Goldwood
- MUSHROOM, ONE_UP, FIRE_FLOWER, MINI_SHROOM,
+ MUSHROOM, FIRE_FLOWER, ONE_UP, PENGUIN,
FIRE_FLOWER, PROPELLER, FIRE_FLOWER,
FIRE_FLOWER, FIRE_FLOWER, STARMAN, FIRE_FLOWER, FIRE_FLOWER
}
@@ -528,7 +533,7 @@ void dWMShop_c::loadInfo() {
void dWMShop_c::buyItem(int item) {
static int itemDefs[6][3] = {
// Cost, Start Index, Count
- {1, 0, 1}, {1, 1, 1}, {2, 2, 1}, {3, 3, 1},
+ {1, 0, 1}, {2, 1, 1}, {2, 2, 1}, {3, 3, 1},
{5, 4, 3}, {8, 7, 5}
};
@@ -542,7 +547,6 @@ void dWMShop_c::buyItem(int item) {
MapSoundPlayer(SoundRelatedClass, SE_SYS_DECIDE, 1);
-
SaveFile *file = GetSaveFile();
SaveBlock *block = file->GetBlock(file->header.current_file);
@@ -558,32 +562,28 @@ void dWMShop_c::buyItem(int item) {
appliedItems[(int)Inventory[shopKind][invStartIndex]]++;
// TODO: Make this work with hammers
- for (int i = 0; i < 7; i++) {
+ for (int i = 0; i < 8; i++) {
block->powerups_available[i] += appliedItems[i];
if (block->powerups_available[i] > 99)
block->powerups_available[i] = 99;
+
+ dScKoopatlas_c::instance->stockItem->counts[i] = block->powerups_available[i];
}
- // Apply coins and lives to everyone
+ // Apply lives to everyone
for (int i = 0; i < 4; i++) {
- block->player_coins[i] += (appliedItems[(int)COINS] * 50);
-
- while (block->player_coins[i] >= 100) {
- block->player_coins[i] -= 100;
- block->player_lives[i]++;
- }
-
- block->player_lives[i] += appliedItems[(int)ONE_UP];
- if (block->player_lives[i] > 99)
- block->player_lives[i] = 99;
+ Player_Lives[i] += appliedItems[(int)ONE_UP];
+ if (Player_Lives[i] > 99)
+ Player_Lives[i] = 99;
}
+ if (appliedItems[(int)ONE_UP] > 0)
+ MapSoundPlayer(SoundRelatedClass, SE_SYS_100COIN_ONE_UP, 1);
+
// load the coin count
int scCount = getUnspentStarCoinCount();
WriteNumberToTextBox(&scCount, CoinCount, false);
WriteNumberToTextBox(&scCount, CoinCountShadow, false);
-
- state.setState(&StateID_HideWait);
}
diff --git a/src/koopatlas/shop.h b/src/koopatlas/shop.h
index fb948a9..4a79861 100644
--- a/src/koopatlas/shop.h
+++ b/src/koopatlas/shop.h
@@ -44,7 +44,6 @@ class dWMShop_c : public dActor_c {
STARMAN,
HAMMER,
ONE_UP,
- COINS,
ITEM_TYPE_COUNT
};
@@ -62,6 +61,9 @@ class dWMShop_c : public dActor_c {
nw4r::lyt::Picture
*BtnLeft[6], *BtnMid[6], *BtnRight[6];
+ nw4r::lyt::Pane
+ *Buttons[6];
+
dTexMapColouriser_c leftCol, midCol, rightCol;
class ShopModel_c {