1 /*
2    File:        Menu.h
3   Description: Menu management
4   Program:     BlockOut
5   Author:      Jean-Luc PONS
6 
7   This program is free software; you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation; either version 2 of the License, or
10   (at your option) any later version.
11 
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16 */
17 
18 #include "MenuPage.h"
19 #include "PolyCube.h"
20 #include "MenuGrid.h"
21 #include "SetupManager.h"
22 #include "SoundManager.h"
23 #include "Http.h"
24 
25 #define BLLETTER_NB 9
26 #define ANIMTIME    1.5f
27 
28 class Menu {
29 
30   public:
31     Menu();
32     ~Menu();
33 
34     // Initialise device objects
35     int Create(int width,int height);
36 
37     // Set/Grt view matrix
38     void SetViewMatrix(GLfloat *mView);
39     GLfloat *GetViewMatrix();
40 
41     // Render the menu
42     void Render();
43 
44     // Release device objects
45     void InvalidateDeviceObjects();
46 
47     // Process menu
48     int Process(BYTE *keys,float fTime);
49 
50     // Set manager
51     void SetSetupManager(SetupManager *manager);
52     SetupManager *GetSetup();
53     void SetSoundManager(SoundManager *manager);
54     SoundManager *GetSound();
55     void SetHttp(Http *h);
56     Http *GetHttp();
57 
58     // Ask full repaint
59     void FullRepaint();
60 
61     // Menu page
62     void ToPage(MenuPage *page);
63     void ToPage(MenuPage *page,int iParam,void *wParam);
64     void RenderText(int x,int y,BOOL selected,char *text);
65     void RenderTitle(char *title);
66 
67     PageMainMenu mainMenuPage;
68     PageStartGame startGamePage;
69     PageChooseSetup chooseSetupPage;
70     PageChangeSetup changeSetupPage;
71     PageHallOfFame hallOfFamePage;
72     PageHallOfFameOnLine hallOfFamePageOnLine;
73     PageOptions optionsPage;
74     PageGSOptions gsOptionsPage;
75     PageScoreDetails scoreDetailsPage;
76     PageControls controlsPage;
77     PageHttp httpPage;
78     PageCredits creditsPage;
79 
80     // On-Line Logo
81     Sprite2D onlineLogo;
82 
83   private:
84 
CreatePage()85     void CreatePage() {
86       mainMenuPage.SetParent(this);
87       startGamePage.SetParent(this);
88       chooseSetupPage.SetParent(this);
89       changeSetupPage.SetParent(this);
90       hallOfFamePage.SetParent(this);
91       optionsPage.SetParent(this);
92       gsOptionsPage.SetParent(this);
93       scoreDetailsPage.SetParent(this);
94       controlsPage.SetParent(this);
95       httpPage.SetParent(this);
96       hallOfFamePageOnLine.SetParent(this);
97       creditsPage.SetParent(this);
98     };
99 
100     void InitGraphics();
101     void ProcessAnim(float fTime);
102     int  InitBlLetters();
103     void ResetAnim(float fTime);
104     void RenderChar(int x,int y,int w,int h,BOOL selected,char c);
105 
106     // Viewport and transformation matrix
107     GLVIEWPORT menuView;
108     GLfloat    matProj[16];
109     GLfloat    matView[16];
110 
111     // Menu grid
112     MenuGrid theGrid;
113 
114     // Menu background and font
115     Sprite2D background;
116     Sprite2D background2;
117     Sprite2D font;
118     Sprite2D font2;
119     int wFont;
120     int hFont;
121     int scrWidth;
122     int scrHeight;
123     int fullRepaint;
124 
125     // Menu selection
126     MenuPage *selPage;
127 
128     // Setup
129     SetupManager *setupManager;
130     SoundManager *soundManager;
131     Http         *http;
132 
133     // Big Cube letters "BLOCKOUT"
134     PolyCube  *blLetters[BLLETTER_NB];
135     GLMatrix   blOrgMatrix;
136     GLMatrix   blMatrix[BLLETTER_NB];
137     VERTEX     startPos[BLLETTER_NB];
138     VERTEX     endPos[BLLETTER_NB];
139     BOOL       isAdded[BLLETTER_NB];
140     BOOL       isStarted[BLLETTER_NB];
141     BOOL       animEnded;
142     BOOL       menuEscaped;
143 
144     // Time stamps
145     float startMenuTime;
146 
147 };
148