1 /*************************************************************************** 2 gamegui.h - The Game menu interface 3 ------------------- 4 begin : do okt 14 2004 5 copyright : (C) 2004 by CJP 6 email : cornware-cjp@users.sourceforge.net 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 ***************************************************************************/ 17 18 #ifndef GAMEGUI_H 19 #define GAMEGUI_H 20 21 #include "gamewinsystem.h" 22 #include "gui.h" 23 #include "guipage.h" 24 #include "carviewer.h" 25 26 #include "uscore.h" 27 #include "player.h" 28 29 #include "usserver.h" 30 31 32 /** 33 *@author CJP 34 */ 35 36 class CGameGUI : public CGUI { 37 public: 38 CGameGUI(CGameWinSystem *winsys); 39 virtual ~CGameGUI(); 40 41 virtual void start(); //returns when an exit command is given 42 43 virtual bool reloadConfiguration(); 44 45 virtual int onKeyPress(int key); 46 virtual int onIdle(); 47 48 protected: 49 virtual CString key2name(int key) const; 50 virtual int name2key(const CString &name) const; 51 52 //Core things that are to be managed 53 CUSCore *m_GameCore; 54 CSound *m_SoundSystem; 55 vector<CPlayer *> m_Players; 56 CUSServer *m_Server; 57 58 //all data of the last times the menus were passed 59 enum eGameType 60 { 61 LocalGame=1, 62 NewNetwork, 63 JoinNetwork, 64 ViewReplay 65 } m_GameType; 66 void initGameType(bool keepServerAlive=false, bool keepReplayFile=false); 67 68 CString m_HostName; 69 int m_HostPort; 70 int m_MinPlayers; 71 CString m_ServerName; 72 bool m_OnlineServer; 73 vector<CClientNet::SBroadcastResult> m_ServerList; 74 CString m_TrackFile; 75 CString m_ReplayFile; 76 77 struct SPlayerDescr 78 { 79 CString name; 80 bool isHuman; 81 unsigned int carIndex; //refers to m_CarFile 82 CVector carColor; 83 bool automaticGearbox; 84 }; 85 vector<SPlayerDescr> m_PlayerDescr; 86 unsigned int m_SelectedPlayer; //for player menus 87 88 CString m_SelectedOptionsSection; //for options menus 89 bool m_OptionsAreChanged; 90 91 //A cache for names of the cars, loaded by constructor 92 struct SCarFile 93 { 94 CString filename; 95 CString fullname; 96 CVector defaultColor; 97 }; 98 vector<SCarFile> m_CarFiles; 99 100 void updateMenuTexts(); 101 102 //The menu starters: 103 CString viewMainMenu(); 104 CString playGame(); 105 bool load(); 106 void unload(); 107 CString viewGameTypeMenu(); 108 CString viewSelectServerMenu(); 109 CString viewTrackMenu(); 110 CString editTrack(); 111 CString viewLoadTrackMenu(); 112 CString viewReplayMenu(); 113 CString viewReplay(); 114 CString viewPlayersMenu(); 115 CString viewPlayerMenu(); 116 CString viewCarMenu(); 117 CString viewOptionsMenu(); 118 CString viewCreditsMenu(); 119 CString viewHiscore(); 120 121 //The menu pages: 122 CGUIPage m_MainPage; 123 CGUIPage m_GameTypePage; 124 CGUIPage m_SelectServerPage; 125 CGUIPage m_TrackPage; 126 CGUIPage m_LoadTrackPage; 127 CGUIPage m_ReplayPage; 128 CGUIPage m_PlayersPage; 129 CGUIPage m_PlayerPage; 130 CGUIPage m_CarPage; 131 CGUIPage m_OptionsPage; 132 CGUIPage m_CreditsPage; 133 CGUIPage m_LoadingPage; 134 CGUIPage m_HiscorePage; 135 136 CCarViewer *m_CarViewer; 137 }; 138 139 #endif 140