C:/DevKitPro/!MDuel/source/menuBottom.h

Go to the documentation of this file.
00001 /*
00002  * Marshmallow Duel DS v2
00003  * Copyright © 2007 Sam Pospischil http://pospi.spadgos.com
00004  * 
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00018  */
00019 
00020 #ifndef _MENUBOTTOM_H
00021 #define _MENUBOTTOM_H
00022 
00023 #include <PA9.h>
00024 #include <string>
00025 #include <vector>
00026         using namespace std;
00027 #include "spriteManager.h"
00028 #include "macros.h"
00029 #ifndef _ALLGRAPHICS_
00030 #define _ALLGRAPHICS_
00031 #include "../data/all_gfx_ed.c"
00032 #endif
00033 
00034 //forward declaration
00035 class gameManager;
00036 
00050 class menuBottom : public spriteManager
00051 {
00052         public:
00053                 menuBottom(u8 newScreen = 0);
00054                 virtual ~menuBottom();
00055                 
00056                 void loadBackground();
00057                 
00058                 virtual void clearOutSprites(bool keepSound = false);
00059                 
00060                 virtual void gameTick();
00061                 
00065                 virtual void activate()
00066                 {
00067                         spriteManager::activate(); 
00068                         resetText();                    
00069                         loadBackground();
00070                         mainMenu();     //initially jump to main menu
00071                         /*#ifdef __WITHSOUND
00072                         #ifdef __WITHMENUTRACK
00073                         playSound(titleMusic.data, titleMusic.size, true);
00074                         #endif
00075                         #endif*/
00076                         loadSRAM(true);
00077                 }
00078                 virtual void deactivate() {spriteManager::deactivate(); unloadBackground();}
00079                 
00081                 spriteManager *menuTop;
00083                 spriteManager *gameBottom;
00085                 gameManager* gameTop;
00086                 
00087                 void loadCursorSpriteSet(const unsigned short *p, const unsigned char *s);
00088                 void loadPickupSpriteSet(const unsigned short *p, const unsigned char *s);
00089                 void loadMenuSpriteSet(const unsigned short *p, const unsigned char *s);
00090                 
00091                 //player character selections, needed by the gameManager
00092                 u8 player1id, player2id;
00093                 //character pallete and sprite data
00094                 const unsigned short *playerPallete1, *playerPallete2, *playerPallete3, *playerPallete4;
00095                 const unsigned char *playerSprite1, *playerSprite2, *playerSprite3;
00096                 
00098                 string playerNames;
00100                 u8 numPickups;
00101                 bool dieWhileDancing, showPickups;
00102                 
00103                 void scoreKill(u8 player, u8 weaponID = 18);            //weaponID == Pickup::pickupType. default to FIDs.
00104                 void scoreDeath(u8 player, u8 weaponID = 18);
00105                 void scoreTime(u8 player, u8 weaponID, u16 timeSecs);
00106                 void scoreRound(u8 winner, u8 loser, bool tied);
00107                 
00108                 void saveStats();       //silently save statistics so SRAM (or not, if not yet formatted)
00109                 
00110                 #ifdef __WITHSOUND
00111                         soundData menuMove, menuOk, menuCancel;
00112                 #endif
00113 private:
00115                 void (menuBottom::*navFunction)();
00117                 void (menuBottom::*renderFunction)(u8);
00119                 void (menuBottom::*actionFunction)(bool, bool);
00120 
00121                 //different menu behaviours to assign to navFunction, renderFunction & actionFunction
00122                 void normalNav();
00123                 void statsNav();
00124                 void miscNav();
00125                 void charNav();
00126                 void charNameNav();
00127                 void roundsNav();
00128                 void normalRender(u8 i);
00129                 void statsRender(u8 i);
00130                 void pickupsRender(u8 i);
00131                 void charRender(u8 i);
00132                 void charNameRender(u8 i);
00133                 void mainAction(bool stylusTouched = false, bool stylusActivated = false);
00134                 void charAction(bool stylusTouched = false, bool stylusActivated = false);
00135                 void pickupsAction(bool stylusTouched = false, bool stylusActivated = false);
00136                 void roundsAction(bool stylusTouched = false, bool stylusActivated = false);
00137                 void sramAction(bool stylusTouched = false, bool stylusActivated = false);
00138                 void controlsAction(bool stylusTouched = false, bool stylusActivated = false);
00139                 void charNameAction(bool stylusTouched = false, bool stylusActivated = false);
00140                 void creditsAction(bool stylusTouched = false, bool stylusActivated = false);
00141                 void miscAction(bool stylusTouched = false, bool stylusActivated = false);
00142                 void statsAction(bool stylusTouched = false, bool stylusActivated = false);
00143                 
00144                 u8 playerPal1, playerPal2, playerPal3, playerPal4;
00145                 
00146                 spriteSet cursorSprite, pickupSprite, menuSprite;
00147                 
00148                 /*#ifdef __WITHSOUND
00149                 #ifdef __WITHMENUTRACK
00150                 soundData titleMusic;
00151                 #endif
00152                 #endif*/
00153                 
00154                 //menu resettings
00155                 void clearMenus();
00156                 void makeCursor();
00157                 
00158                 void autoMenuClickRegions();
00159                 s8 touchingWhichItem(u16 x, u16 y);
00160                 
00161                 //menu changings
00162                 void mainMenu(u8 prevScreen = 0);
00163                 void characterMenu();
00164                 void pickupMenu();
00165                 void roundsMenu();
00166                 void saveWarningMenu();
00167                 void controlsMenu();
00168                 void playerRenameMenu(u8 playerID);
00169                 void creditsMenu();
00170                 void miscMenu();
00171                 void statsMenu();
00172                 
00173                 void alterPlayerName(u8 playerID, u8 letterID, s8 modBy);
00175                 u8 editingName;
00176                 
00177                 bool isSRAMSaved();
00178                 
00184                 struct menuItem
00185                 {
00186                         u8 cursorx, cursory;
00187                         u8 textx, texty;
00188                         string text;
00189                         u8 objx, objy;
00190                         spriteObject *obj;
00192                         spriteObject *obj2;
00193                         u16 x1, x2, y1, y2;
00194                 };
00196                 s8 selectedItem;
00198                 u8 menuColSize;
00200                 vector<menuItem> menuItems;
00202                 spriteObject* cursor;
00203                 
00205                 s8 selectedItem2;
00206                 u8 settingsPlayer, settingsPage;
00207                 void drawStatsFor(u8 player, u8 page);
00208                 
00209                 //SRAM variables
00210                 string prevPlayerNames;
00211                 u8 roundNum, prevRoundNum;
00212                 u32 pickupMask, prevPickupMask;
00213                 u8 prevPlayer1id, prevPlayer2id;        //1 indexed
00214                 u8 playerSprs[6], prevPlayerSprs[6];
00215                 u8 playerPals[6], prevPlayerPals[6];
00216                 bool prevDieWhileDancing, prevShowPickups;
00217                 u8 prevNumPickups;
00218                 
00242                 u8 statistics[798];
00243                 void writeStatValueAt(u16 offset, u16 value);
00244                 u16 readStatValueAt(u16 offset) const;
00245                 void erasePlayer(u8 player);
00246                 //for these:
00247                 // if player == -1 then get stat for all players
00248                 // if weaponID == -1, get stat for all weapons
00249                 u16 getKillsForPlayer(s8 player, s8 weaponID) const;
00250                 u16 getDeathsForPlayer(s8 player, s8 weaponID) const;
00251                 u16 getTimeForPlayer(s8 player, s8 weaponID) const;
00252                 u16 getWins(s8 player) const;
00253                 u16 getLosses(s8 player) const;
00254                 u16 getTies(s8 player) const;
00256                 static const u8 PLAYERSLOTSIZE = 120;
00258                 static const u8 GLOBALSLOTSIZE = 78;
00260                 static const u8 WEAPONBLOCKSIZE = 38;
00261 
00263                 u8 menuRepeater;
00264                 
00265                 void loadSRAM(bool firstLoad = false);
00266                 void saveSRAM(bool dontCheck = false, u8 menuNumber = 0);
00267                 
00268                 void sramSavePrevVars();
00269                 void sramLoadPrevVars();
00270                 void sramLoadDefaults();
00271                 
00272                 bool pickupSelected(u8 pickupID);
00273                 void makePickupIcon(string text, u8 num, u16 curx, u16 cury);
00274                 void makeInstructions(u8 frame, u8 xpos);
00275                 const unsigned char *getPlayerSpriteData(u8 idNum);
00276                 const unsigned short *getPlayerPalleteData(u8 idNum);
00277                 u8 getPlayerPalleteID(u8 idNum);
00278                 void updatePlayerIcon(u8 i);
00279                 
00280                 void loadPlayerGFX(u8 dataNum, u8 playerNum);
00281                 void pickupToggle(u8 i);
00282                 void selectPlayer(u8 i, u8 playerNum);
00283                 void playerColorCycle(u8 i);
00284                 void playerGFXCycle(u8 i);
00285                 
00287                 static const u8 _SRAMIDOFFSET = 0;
00289                 static const u8 _ROUNDSOFFSET = 7;
00291                 static const u8 _PICKUPOFFSET = 8;
00293                 static const u8 _PLAYER1IDOFFSET = 12;
00295                 static const u8 _PLAYER2IDOFFSET = 13;
00297                 static const u8 _PLAYERSPRSOFFSET = 14;
00299                 static const u8 _PLAYERPALSOFFSET = 20;
00301                 static const u8 _NAMESOFFSET = 26;
00303                 static const u8 _SETTINGSOFFSET = 76;
00305                 static const u8 _STATSOFFSET = 78;
00307                 static const u16 _STATSLEN = 798;
00308                 
00310                 static const char *_SRAMID;
00312                 static const u8 _NUMPICKUPS = 18;
00314                 static const u8 MAXPICKUPSONSCREEN = 10;
00316                 static const u32 _ALLPICKUPS = 262143;
00318                 static const u8 _NUMSAVESLOTS = 6;
00320                 static const u8 menuRepeatDelay = 10;
00321 };
00322 
00323 #endif

Generated on Tue Mar 13 23:27:53 2007 for MDuel DS by  doxygen 1.5.1-p1