00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef MAINMENU_H
00019 #define MAINMENU_H
00020
00021 #include "constants.h"
00022 #include "sdlhandler.h"
00023 #include "sdleventhandler.h"
00024 #include "sdlscreenview.h"
00025 #include "scourge.h"
00026 #include "text.h"
00027 #include "partyeditor.h"
00028 #include "gui/window.h"
00029 #include "gui/label.h"
00030 #include "gui/button.h"
00031 #include "gui/scrollinglabel.h"
00032 #include <vector>
00033
00038 class Scourge;
00039 class PartyEditor;
00040
00041 using namespace std;
00042
00043 typedef struct _MenuItemParticle {
00044 int life;
00045 float x, y;
00046 int r, g, b;
00047 float dir, step;
00048 float zoom;
00049 } MenuItemParticle;
00050
00051 typedef struct _MenuItem {
00052 char text[80];
00053 GLuint texture[1];
00054 unsigned char *textureInMemory;
00055 int x;
00056 int y;
00057 bool active;
00058 int value;
00059 MenuItemParticle particle[100];
00060 } MenuItem;
00061
00062 class MainMenu : public SDLEventHandler,SDLScreenView {
00063 private:
00064 Scourge *scourge;
00065 int value;
00066 float logoRot, logoRotDelta;
00067 GLint logoTicks;
00068 GLint logoTicksDelta;
00069 int top, openingTop;
00070 Uint32 lastTick, lastTickMenu;
00071 int candleFlameX, candleFlameY;
00072 PartyEditor *partyEditor;
00073 bool initTextures;
00074 Window *aboutDialog;
00075 ScrollingLabel *aboutText;
00076 Button *aboutOK;
00077
00078 #define MAX_LOGOS 100
00079 typedef struct _LogoSprite {
00080 float x, y, angle, rot;
00081 int quadrant, steps;
00082 } LogoSprite;
00083 int logoSpriteCount;
00084 LogoSprite logoSprite[MAX_LOGOS];
00085
00086
00087 typedef struct _Cloud {
00088 int x, y, w, h, speed;
00089 } Cloud;
00090 Cloud cloud[100];
00091 int cloudCount;
00092 int starCount;
00093 typedef struct _Star {
00094 int x, y;
00095 } Star;
00096 Star star[100];
00097
00098 Window *mainWin;
00099 Button *newGameButton;
00100 Button *continueButton;
00101 Button *multiplayer;
00102 Button *optionsButton;
00103 Button *aboutButton;
00104 Button *quitButton;
00105
00106 Window *newGameConfirm;
00107 Button *newGameConfirmOK, *newGameConfirmCancel;
00108
00109 static const char *menuText[];
00110 static const int values[];
00111 vector< MenuItem* > menuItemList;
00112
00113 public:
00114 #define NEW_GAME 1
00115 #define CONTINUE_GAME 2
00116 #define OPTIONS 3
00117 #define ABOUT 4
00118 #define QUIT 5
00119 #define MULTIPLAYER 6
00120 #define MULTIPLAYER_START 7
00121 #define NEW_GAME_START 8
00122
00123 MainMenu(Scourge *scourge);
00124 ~MainMenu();
00125
00126 void drawView();
00127 void drawAfter();
00128 bool handleEvent(SDL_Event *event);
00129 bool handleEvent(Widget *widget, SDL_Event *event);
00130 int getValue();
00131 void showNewGameConfirmationDialog();
00132
00133 void show();
00134 void hide();
00135 inline bool isVisible() { return mainWin->isVisible(); }
00136 void showPartyEditor();
00137 void createParty( Creature **pc, int *partySize );
00138
00139 protected:
00140 void drawClouds(bool moveClouds, bool flipped);
00141 void drawWater();
00142 void drawLogo();
00143 void drawMenu();
00144 void drawActiveMenuItem( float divisor, int count );
00145 void buildTextures();
00146 void addLogoSprite();
00147 void drawLogoSprites();
00148 void moveLogoSprites();
00149 void drawParticles();
00150 void drawStars();
00151 };
00152
00153 #endif