2010-03-27 08:09:34 +01:00
|
|
|
// ==============================================================
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
//
|
2012-10-30 07:48:12 +01:00
|
|
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
2010-03-27 08:09:34 +01:00
|
|
|
//
|
|
|
|
// You can redistribute this code 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
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
#ifndef _GLEST_GAME_MENUSTATECUSTOMGAME_H_
|
|
|
|
#define _GLEST_GAME_MENUSTATECUSTOMGAME_H_
|
|
|
|
|
|
|
|
#include "main_menu.h"
|
|
|
|
#include "chat_manager.h"
|
2010-05-13 08:43:56 +02:00
|
|
|
#include "simple_threads.h"
|
2010-09-14 02:43:09 +02:00
|
|
|
#include "map_preview.h"
|
2010-09-07 07:25:40 +02:00
|
|
|
#include "leak_dumper.h"
|
2010-03-27 08:09:34 +01:00
|
|
|
|
2010-09-14 02:43:09 +02:00
|
|
|
using namespace Shared::Map;
|
2010-09-12 07:05:08 +02:00
|
|
|
|
2012-05-26 01:00:36 +02:00
|
|
|
namespace Shared { namespace Graphics {
|
|
|
|
class VideoPlayer;
|
|
|
|
}}
|
|
|
|
|
2010-09-14 02:43:09 +02:00
|
|
|
namespace Glest { namespace Game {
|
2010-09-12 07:05:08 +02:00
|
|
|
|
2011-09-01 23:54:31 +02:00
|
|
|
class SwitchSetupRequest;
|
|
|
|
class ServerInterface;
|
2013-06-13 03:37:15 +02:00
|
|
|
class TechTree;
|
2011-09-01 23:54:31 +02:00
|
|
|
|
2011-10-30 23:23:57 +01:00
|
|
|
enum ParentMenuState {
|
|
|
|
pNewGame,
|
|
|
|
pMasterServer,
|
|
|
|
pLanGame
|
|
|
|
};
|
|
|
|
|
2010-03-27 08:09:34 +01:00
|
|
|
// ===============================
|
|
|
|
// class MenuStateCustomGame
|
|
|
|
// ===============================
|
|
|
|
|
2010-05-13 08:43:56 +02:00
|
|
|
class MenuStateCustomGame : public MenuState, public SimpleTaskCallbackInterface {
|
2010-03-27 08:09:34 +01:00
|
|
|
private:
|
|
|
|
GraphicButton buttonReturn;
|
|
|
|
GraphicButton buttonPlayNow;
|
2010-06-01 02:32:24 +02:00
|
|
|
GraphicButton buttonRestoreLastSettings;
|
2010-03-27 08:09:34 +01:00
|
|
|
GraphicLabel labelControl;
|
2010-11-09 00:15:50 +01:00
|
|
|
GraphicLabel labelRMultiplier;
|
2010-03-27 08:09:34 +01:00
|
|
|
GraphicLabel labelFaction;
|
|
|
|
GraphicLabel labelTeam;
|
|
|
|
GraphicLabel labelMap;
|
|
|
|
GraphicLabel labelFogOfWar;
|
|
|
|
GraphicLabel labelTechTree;
|
|
|
|
GraphicLabel labelTileset;
|
|
|
|
GraphicLabel labelMapInfo;
|
2012-05-12 04:21:21 +02:00
|
|
|
GraphicLabel labelLocalGameVersion;
|
2010-07-10 08:14:31 +02:00
|
|
|
GraphicLabel labelLocalIP;
|
2011-10-21 00:30:09 +02:00
|
|
|
GraphicLabel labelGameName;
|
2010-06-03 03:10:40 +02:00
|
|
|
|
2010-03-27 08:09:34 +01:00
|
|
|
GraphicListBox listBoxMap;
|
|
|
|
GraphicListBox listBoxFogOfWar;
|
|
|
|
GraphicListBox listBoxTechTree;
|
|
|
|
GraphicListBox listBoxTileset;
|
2010-06-03 03:10:40 +02:00
|
|
|
|
2010-03-27 08:09:34 +01:00
|
|
|
vector<string> mapFiles;
|
2010-08-30 22:02:58 +02:00
|
|
|
vector<string> playerSortedMaps[GameConstants::maxPlayers+1];
|
|
|
|
vector<string> formattedPlayerSortedMaps[GameConstants::maxPlayers+1];
|
2010-03-27 08:09:34 +01:00
|
|
|
vector<string> techTreeFiles;
|
|
|
|
vector<string> tilesetFiles;
|
|
|
|
vector<string> factionFiles;
|
|
|
|
GraphicLabel labelPlayers[GameConstants::maxPlayers];
|
2010-08-21 09:41:26 +02:00
|
|
|
GraphicLabel labelPlayerNames[GameConstants::maxPlayers];
|
2010-03-27 08:09:34 +01:00
|
|
|
GraphicListBox listBoxControls[GameConstants::maxPlayers];
|
2011-04-13 06:04:08 +02:00
|
|
|
GraphicButton buttonBlockPlayers[GameConstants::maxPlayers];
|
2010-11-09 00:15:50 +01:00
|
|
|
GraphicListBox listBoxRMultiplier[GameConstants::maxPlayers];
|
2010-03-27 08:09:34 +01:00
|
|
|
GraphicListBox listBoxFactions[GameConstants::maxPlayers];
|
|
|
|
GraphicListBox listBoxTeams[GameConstants::maxPlayers];
|
|
|
|
GraphicLabel labelNetStatus[GameConstants::maxPlayers];
|
|
|
|
MapInfo mapInfo;
|
2010-12-19 09:36:59 +01:00
|
|
|
|
2011-04-13 06:04:08 +02:00
|
|
|
GraphicButton buttonClearBlockedPlayers;
|
|
|
|
|
2010-05-13 00:58:00 +02:00
|
|
|
GraphicLabel labelPublishServer;
|
2012-10-22 17:52:08 +02:00
|
|
|
GraphicCheckBox checkBoxPublishServer;
|
2010-12-19 09:36:59 +01:00
|
|
|
|
2010-05-17 01:03:22 +02:00
|
|
|
GraphicMessageBox mainMessageBox;
|
|
|
|
int mainMessageBoxState;
|
2010-12-19 09:36:59 +01:00
|
|
|
|
2010-07-16 18:53:19 +02:00
|
|
|
GraphicLabel labelNetworkPauseGameForLaggedClients;
|
2012-10-22 17:52:08 +02:00
|
|
|
GraphicCheckBox checkBoxNetworkPauseGameForLaggedClients;
|
2010-07-16 18:53:19 +02:00
|
|
|
|
2010-08-28 01:08:35 +02:00
|
|
|
GraphicLabel labelMapFilter;
|
|
|
|
GraphicListBox listBoxMapFilter;
|
2010-12-19 09:36:59 +01:00
|
|
|
|
2010-08-28 01:08:35 +02:00
|
|
|
GraphicLabel labelAdvanced;
|
2012-10-22 17:52:08 +02:00
|
|
|
GraphicCheckBox checkBoxAdvanced;
|
2010-03-27 08:09:34 +01:00
|
|
|
|
2010-09-04 03:24:17 +02:00
|
|
|
GraphicLabel labelAllowObservers;
|
2012-10-22 17:52:08 +02:00
|
|
|
GraphicCheckBox checkBoxAllowObservers;
|
2010-09-04 03:24:17 +02:00
|
|
|
|
2010-08-21 09:41:26 +02:00
|
|
|
GraphicLabel *activeInputLabel;
|
|
|
|
|
2011-03-11 12:11:46 +01:00
|
|
|
GraphicLabel labelPlayerStatus[GameConstants::maxPlayers];
|
|
|
|
GraphicListBox listBoxPlayerStatus;
|
|
|
|
|
2011-09-21 08:51:28 +02:00
|
|
|
GraphicLabel labelEnableSwitchTeamMode;
|
2012-10-22 17:52:08 +02:00
|
|
|
GraphicCheckBox checkBoxEnableSwitchTeamMode;
|
|
|
|
|
2011-09-21 08:51:28 +02:00
|
|
|
GraphicLabel labelAISwitchTeamAcceptPercent;
|
|
|
|
GraphicListBox listBoxAISwitchTeamAcceptPercent;
|
2012-09-17 01:42:56 +02:00
|
|
|
GraphicLabel labelFallbackCpuMultiplier;
|
|
|
|
GraphicListBox listBoxFallbackCpuMultiplier;
|
2011-09-21 08:51:28 +02:00
|
|
|
|
2013-02-15 19:25:10 +01:00
|
|
|
GraphicLabel labelAllowInGameJoinPlayer;
|
|
|
|
GraphicCheckBox checkBoxAllowInGameJoinPlayer;
|
|
|
|
|
2014-01-27 23:15:05 +01:00
|
|
|
GraphicLabel labelAllowTeamUnitSharing;
|
|
|
|
GraphicCheckBox checkBoxAllowTeamUnitSharing;
|
|
|
|
|
|
|
|
GraphicLabel labelAllowTeamResourceSharing;
|
|
|
|
GraphicCheckBox checkBoxAllowTeamResourceSharing;
|
|
|
|
|
|
|
|
|
2013-06-13 03:37:15 +02:00
|
|
|
GraphicLabel labelAllowNativeLanguageTechtree;
|
|
|
|
GraphicCheckBox checkBoxAllowNativeLanguageTechtree;
|
|
|
|
|
2011-12-26 07:29:14 +01:00
|
|
|
GraphicCheckBox checkBoxScenario;
|
|
|
|
GraphicLabel labelScenario;
|
|
|
|
GraphicListBox listBoxScenario;
|
2014-01-27 23:15:05 +01:00
|
|
|
|
2011-12-26 07:29:14 +01:00
|
|
|
vector<string> scenarioFiles;
|
|
|
|
ScenarioInfo scenarioInfo;
|
|
|
|
vector<string> dirList;
|
|
|
|
string autoloadScenarioName;
|
|
|
|
time_t previewLoadDelayTimer;
|
|
|
|
bool needToLoadTextures;
|
|
|
|
bool enableScenarioTexturePreview;
|
|
|
|
Texture2D *scenarioLogoTexture;
|
|
|
|
|
2010-03-27 08:09:34 +01:00
|
|
|
bool needToSetChangedGameSettings;
|
|
|
|
time_t lastSetChangedGameSettings;
|
2010-05-13 00:58:00 +02:00
|
|
|
time_t lastMasterserverPublishing;
|
2010-07-09 19:12:57 +02:00
|
|
|
time_t lastNetworkPing;
|
2011-01-29 21:13:29 +01:00
|
|
|
time_t mapPublishingDelayTimer;
|
2011-01-31 00:01:55 +01:00
|
|
|
bool needToPublishDelayed;
|
2010-07-09 19:12:57 +02:00
|
|
|
|
2010-05-13 08:43:56 +02:00
|
|
|
bool needToRepublishToMasterserver;
|
2010-05-13 13:19:10 +02:00
|
|
|
bool needToBroadcastServerSettings;
|
2010-06-23 16:49:20 +02:00
|
|
|
std::map<string,string> publishToServerInfo;
|
2010-05-13 08:43:56 +02:00
|
|
|
SimpleTaskThread *publishToMasterserverThread;
|
2013-11-07 19:39:08 +01:00
|
|
|
SimpleTaskThread *publishToClientsThread;
|
2010-12-19 09:36:59 +01:00
|
|
|
|
2011-10-30 23:23:57 +01:00
|
|
|
ParentMenuState parentMenuState;
|
2010-05-21 02:25:18 +02:00
|
|
|
int soundConnectionCount;
|
2010-12-19 09:36:59 +01:00
|
|
|
|
2012-03-03 09:28:15 +01:00
|
|
|
time_t tMasterserverErrorElapsed;
|
2010-05-17 01:03:22 +02:00
|
|
|
bool showMasterserverError;
|
|
|
|
string masterServererErrorToShow;
|
2010-06-11 06:55:49 +02:00
|
|
|
|
|
|
|
bool showGeneralError;
|
|
|
|
string generalErrorToShow;
|
|
|
|
bool serverInitError;
|
2010-12-19 09:36:59 +01:00
|
|
|
|
2011-04-15 03:05:36 +02:00
|
|
|
//Console console;
|
2010-03-27 08:09:34 +01:00
|
|
|
ChatManager chatManager;
|
2010-06-09 00:50:37 +02:00
|
|
|
bool showFullConsole;
|
2010-03-27 08:09:34 +01:00
|
|
|
|
2010-08-22 10:00:05 +02:00
|
|
|
string lastMapDataSynchError;
|
|
|
|
string lastTileDataSynchError;
|
|
|
|
string lastTechtreeDataSynchError;
|
|
|
|
|
2010-08-23 06:33:21 +02:00
|
|
|
string defaultPlayerName;
|
|
|
|
int8 switchSetupRequestFlagType;
|
|
|
|
|
2010-08-31 22:31:20 +02:00
|
|
|
bool enableFactionTexturePreview;
|
2010-09-26 23:34:00 +02:00
|
|
|
bool enableMapPreview;
|
2010-10-30 05:29:29 +02:00
|
|
|
|
|
|
|
string currentTechName_factionPreview;
|
|
|
|
string currentFactionName_factionPreview;
|
2010-08-31 08:38:27 +02:00
|
|
|
string currentFactionLogo;
|
|
|
|
Texture2D *factionTexture;
|
2013-11-19 22:57:28 +01:00
|
|
|
::Shared::Graphics::VideoPlayer *factionVideo;
|
2012-07-15 21:45:55 +02:00
|
|
|
bool factionVideoSwitchedOffVolume;
|
2010-08-31 08:38:27 +02:00
|
|
|
|
2010-09-12 07:05:08 +02:00
|
|
|
MapPreview mapPreview;
|
2010-11-01 17:44:05 +01:00
|
|
|
Texture2D *mapPreviewTexture;
|
2014-01-03 19:19:10 +01:00
|
|
|
bool zoomedMap;
|
2013-12-31 08:32:06 +01:00
|
|
|
int render_mapPreviewTexture_X;
|
|
|
|
int render_mapPreviewTexture_Y;
|
|
|
|
int render_mapPreviewTexture_W;
|
|
|
|
int render_mapPreviewTexture_H;
|
2010-11-01 17:44:05 +01:00
|
|
|
|
2010-10-02 04:17:50 +02:00
|
|
|
bool autostart;
|
2011-09-16 02:34:14 +02:00
|
|
|
GameSettings *autoStartSettings;
|
|
|
|
|
2010-10-22 19:20:55 +02:00
|
|
|
std::map<int,int> lastSelectedTeamIndex;
|
2010-11-09 00:15:50 +01:00
|
|
|
float rMultiplierOffset;
|
2010-12-21 06:07:10 +01:00
|
|
|
bool hasCheckedForUPNP;
|
2010-09-12 07:05:08 +02:00
|
|
|
|
2011-03-19 06:11:36 +01:00
|
|
|
string lastCheckedCRCTilesetName;
|
|
|
|
string lastCheckedCRCTechtreeName;
|
|
|
|
string lastCheckedCRCMapName;
|
2013-06-23 07:23:02 +02:00
|
|
|
|
|
|
|
string last_Forced_CheckedCRCTilesetName;
|
|
|
|
string last_Forced_CheckedCRCTechtreeName;
|
|
|
|
string last_Forced_CheckedCRCMapName;
|
|
|
|
|
2012-07-07 04:46:57 +02:00
|
|
|
uint32 lastCheckedCRCTilesetValue;
|
|
|
|
uint32 lastCheckedCRCTechtreeValue;
|
|
|
|
uint32 lastCheckedCRCMapValue;
|
|
|
|
vector<pair<string,uint32> > factionCRCList;
|
2011-03-19 06:11:36 +01:00
|
|
|
|
2011-03-28 23:04:47 +02:00
|
|
|
bool forceWaitForShutdown;
|
2012-07-06 00:03:15 +02:00
|
|
|
bool headlessServerMode;
|
2011-09-24 09:46:56 +02:00
|
|
|
bool masterserverModeMinimalResources;
|
|
|
|
int lastMasterServerSettingsUpdateCount;
|
2011-03-28 23:04:47 +02:00
|
|
|
|
2013-06-13 03:37:15 +02:00
|
|
|
std::auto_ptr<TechTree> techTree;
|
|
|
|
|
2013-10-31 01:57:36 +01:00
|
|
|
string gameUUID;
|
2014-01-27 23:15:05 +01:00
|
|
|
|
2010-03-27 08:09:34 +01:00
|
|
|
public:
|
2011-09-24 09:46:56 +02:00
|
|
|
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,
|
2011-10-30 23:23:57 +01:00
|
|
|
bool openNetworkSlots= false, ParentMenuState parentMenuState=pNewGame,
|
2011-12-26 07:29:14 +01:00
|
|
|
bool autostart=false,GameSettings *settings=NULL,bool masterserverMode=false,
|
|
|
|
string autoloadScenarioName="");
|
2011-01-02 10:33:37 +01:00
|
|
|
virtual ~MenuStateCustomGame();
|
2010-03-27 08:09:34 +01:00
|
|
|
|
|
|
|
void mouseClick(int x, int y, MouseButton mouseButton);
|
|
|
|
void mouseMove(int x, int y, const MouseState *mouseState);
|
|
|
|
void render();
|
|
|
|
void update();
|
|
|
|
|
2011-06-26 03:55:08 +02:00
|
|
|
virtual void keyDown(SDL_KeyboardEvent key);
|
|
|
|
virtual void keyPress(SDL_KeyboardEvent c);
|
|
|
|
virtual void keyUp(SDL_KeyboardEvent key);
|
2010-12-19 09:36:59 +01:00
|
|
|
|
2010-03-27 08:09:34 +01:00
|
|
|
|
2013-11-07 19:39:08 +01:00
|
|
|
virtual void simpleTask(BaseThread *callingThread,void *userdata);
|
|
|
|
virtual void setupTask(BaseThread *callingThread,void *userdata);
|
|
|
|
virtual void shutdownTask(BaseThread *callingThread,void *userdata);
|
2012-03-05 23:53:03 +01:00
|
|
|
static void setupTaskStatic(BaseThread *callingThread);
|
|
|
|
static void shutdownTaskStatic(BaseThread *callingThread);
|
2011-11-23 09:00:09 +01:00
|
|
|
|
2011-04-20 18:25:16 +02:00
|
|
|
virtual bool isInSpecialKeyCaptureEvent();
|
2011-09-24 09:46:56 +02:00
|
|
|
virtual bool isMasterserverMode() const;
|
2010-05-13 08:43:56 +02:00
|
|
|
|
2012-06-09 04:59:46 +02:00
|
|
|
virtual bool isVideoPlaying();
|
2010-03-27 08:09:34 +01:00
|
|
|
private:
|
|
|
|
|
|
|
|
bool hasNetworkGameSettings();
|
2011-09-10 03:45:34 +02:00
|
|
|
void loadGameSettings(GameSettings *gameSettings, bool forceCloseUnusedSlots=false);
|
2010-09-12 07:05:08 +02:00
|
|
|
void loadMapInfo(string file, MapInfo *mapInfo,bool loadMapPreview);
|
2010-11-01 17:44:05 +01:00
|
|
|
void cleanupMapPreviewTexture();
|
|
|
|
|
2010-03-27 08:09:34 +01:00
|
|
|
void updateControlers();
|
|
|
|
void closeUnusedSlots();
|
|
|
|
void updateNetworkSlots();
|
2010-05-13 00:58:00 +02:00
|
|
|
void publishToMasterserver();
|
2010-05-16 18:40:21 +02:00
|
|
|
void returnToParentMenu();
|
2010-05-17 01:03:22 +02:00
|
|
|
void showMessageBox(const string &text, const string &header, bool toggle);
|
2010-05-31 21:57:10 +02:00
|
|
|
|
|
|
|
void saveGameSettingsToFile(std::string fileName);
|
2010-08-30 22:02:58 +02:00
|
|
|
void switchToNextMapGroup(const int direction);
|
2010-11-11 02:24:48 +01:00
|
|
|
void updateAllResourceMultiplier();
|
|
|
|
void updateResourceMultiplier(const int index);
|
2010-08-30 22:02:58 +02:00
|
|
|
string getCurrentMapFile();
|
2010-08-21 09:41:26 +02:00
|
|
|
void setActiveInputLabel(GraphicLabel *newLable);
|
2010-08-21 15:04:52 +02:00
|
|
|
string getHumanPlayerName(int index=-1);
|
2010-08-31 08:38:27 +02:00
|
|
|
|
|
|
|
void loadFactionTexture(string filepath);
|
2010-10-02 04:17:50 +02:00
|
|
|
|
2012-09-20 23:57:00 +02:00
|
|
|
GameSettings loadGameSettingsFromFile(std::string fileName);
|
|
|
|
void loadGameSettings(std::string fileName);
|
2010-10-02 04:17:50 +02:00
|
|
|
void RestoreLastGameSettings();
|
2011-09-16 02:34:14 +02:00
|
|
|
void PlayNow(bool saveGame);
|
2010-10-08 03:41:53 +02:00
|
|
|
|
|
|
|
void SetActivePlayerNameEditor();
|
2011-01-02 10:33:37 +01:00
|
|
|
void cleanup();
|
2011-03-11 12:11:46 +01:00
|
|
|
|
|
|
|
int32 getNetworkPlayerStatus();
|
2011-04-20 00:53:37 +02:00
|
|
|
void setupUIFromGameSettings(const GameSettings &gameSettings);
|
2011-09-01 23:54:31 +02:00
|
|
|
|
|
|
|
void switchSetupForSlots(SwitchSetupRequest **switchSetupRequests,
|
|
|
|
ServerInterface *& serverInterface, int startIndex, int endIndex,
|
|
|
|
bool onlyNetworkUnassigned);
|
|
|
|
|
2011-10-25 20:39:11 +02:00
|
|
|
void reloadUI();
|
2011-12-26 07:29:14 +01:00
|
|
|
void loadScenarioInfo(string file, ScenarioInfo *scenarioInfo);
|
|
|
|
void processScenario();
|
2011-12-26 23:51:48 +01:00
|
|
|
void SetupUIForScenarios();
|
2011-12-28 05:46:36 +01:00
|
|
|
int setupMapList(string scenario);
|
2013-06-13 03:37:15 +02:00
|
|
|
int setupTechList(string scenario, bool forceLoad=false);
|
2011-12-28 05:46:36 +01:00
|
|
|
void reloadFactions(bool keepExistingSelectedItem, string scenario);
|
|
|
|
void setupTilesetList(string scenario);
|
2013-10-25 21:35:10 +02:00
|
|
|
void setSlotHuman(int i);
|
2012-09-26 00:52:07 +02:00
|
|
|
|
|
|
|
void initFactionPreview(const GameSettings *gameSettings);
|
2013-06-23 07:23:02 +02:00
|
|
|
|
|
|
|
bool checkNetworkPlayerDataSynch(bool checkMapCRC,bool checkTileSetCRC, bool checkTechTreeCRC);
|
|
|
|
|
2013-11-07 19:39:08 +01:00
|
|
|
void cleanupThread(SimpleTaskThread **thread);
|
|
|
|
void simpleTaskForMasterServer(BaseThread *callingThread);
|
|
|
|
void simpleTaskForClients(BaseThread *callingThread);
|
2014-01-25 19:07:15 +01:00
|
|
|
void KeepCurrentHumanPlayerSlots(GameSettings &gameSettings);
|
2010-03-27 08:09:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
#endif
|