1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
/*
File: Menu.h
Description: Contains menu pages.
Program: BlockOut
Author: Jean-Luc PONS
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#ifndef MENUPAGEH
#define MENUPAGEH
#include <math.h>
#include "GLApp/GLSprite.h"
#include "GLApp/GLMatrix.h"
#include "PolyCube.h"
class Menu;
#include "EditControl.h"
#define DECLARE(className,exts) class className: public MenuPage { \
public: \
className() {}; \
void Prepare(int iParam,void *pParam); \
void Render(); \
int Process(BYTE *keys,float fTime); \
private: \
exts \
}
// Super Class
class MenuPage {
public:
// Init parent
void SetParent(Menu *parent) {mParent=parent;};
// Overrides
virtual void Prepare(int iParam,void *pParam) {};
virtual void Render() {};
virtual int Process(BYTE *keys,float fTime) { return 0; };
protected:
void ProcessDefault(BYTE *keys,float fTime) {
if(keys[SDLK_DOWN]) {
selItem++;
if(selItem>=nbItem) selItem=0;
keys[SDLK_DOWN] = 0;
}
if(keys[SDLK_UP]) {
selItem--;
if(selItem<0) selItem=nbItem-1;
keys[SDLK_UP] = 0;
}
}
int selItem;
int nbItem;
Menu *mParent;
};
// Sub classes
DECLARE(PageMainMenu,
float startWriteTime;
);
DECLARE(PageStartGame,);
DECLARE(PageChooseSetup,);
DECLARE(PageChangeSetup,
void ProcessKey(int keyCode);
);
DECLARE(PageHallOfFame,
SCOREREC allScore[10];
BOOL editMode;
char editText[11];
int editPos;
BOOL editCursor;
SCOREREC *editScore;
float startEditTime;
PLAYER_INFO pInfo;
void ProcessEdit(BYTE *keys,float fTime);
public:
PLAYER_INFO *GetPlayer();
);
DECLARE(PageOptions,);
DECLARE(PageGSOptions,
int ProcessKey(int keyCode);
);
DECLARE(PageScoreDetails,
SCOREREC *score;
int rank;
int pageState;
float startTime;
char errMsg[512];
);
DECLARE(PageControls,
GLVIEWPORT blockView;
GLfloat blockProj[16];
Sprite2D pitBack;
GLfloat matBlock[3][16];
PolyCube block[3];
float startTime;
float cubeSide;
int rotPos;
BOOL rotMode;
BOOL editMode;
float startEditTime;
BOOL cursorVisible;
void ProcessMenuDis(BYTE *keys);
void ProcessEdit(BYTE *keys);
void ProcessAnimation(float fTime);
void Place(PolyCube *obj,GLfloat *mat,GLMatrix *matR,float x,float y,float z);
void RenderKey(int x,int y,char k,int pos);
public:
int Create(int width,int height);
void InvalidateDeviceObjects();
);
DECLARE(PageHttp,
EditControl edit;
char *Wrap(char *str);
);
DECLARE(PageHallOfFameOnLine,
SCOREREC allScore[100];
int startPos;
int downloadState;
char errMsg[512];
char *pPos;
PLAYER_INFO pInfo;
void FetchNextLine();
char *FetchNextField();
void ParseScore(SCOREREC *s);
void DownloadScore();
public:
PLAYER_INFO *GetPlayer();
);
DECLARE(PageCredits,
GLVIEWPORT blockView;
GLfloat blockProj[16];
GLfloat matBlock[16];
PolyCube block;
float startTime;
public:
int Create(int width,int height);
void InvalidateDeviceObjects();
);
#endif /* MENUPAGEH */
|