2010-03-27 08:09:34 +01:00
|
|
|
|
// ==============================================================
|
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
|
//
|
2010-05-13 00:58:00 +02:00
|
|
|
|
// Copyright (C) 2001-2005 Marti<74>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
|
|
|
|
|
2010-09-14 02:43:09 +02:00
|
|
|
|
namespace Glest { namespace Game {
|
2010-09-12 07:05:08 +02:00
|
|
|
|
|
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;
|
2010-05-31 12:20:18 +02:00
|
|
|
|
GraphicLabel labelEnableObserverMode;
|
2010-10-26 23:52:00 +02:00
|
|
|
|
//GraphicLabel labelEnableServerControlledAI;
|
2010-07-10 08:14:31 +02:00
|
|
|
|
GraphicLabel labelLocalIP;
|
2010-12-19 09:36:59 +01:00
|
|
|
|
|
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-05-31 12:20:18 +02:00
|
|
|
|
GraphicListBox listBoxEnableObserverMode;
|
2010-10-26 23:52:00 +02:00
|
|
|
|
//GraphicListBox listBoxEnableServerControlledAI;
|
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;
|
|
|
|
|
GraphicListBox listBoxPublishServer;
|
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-10-26 23:52:00 +02:00
|
|
|
|
//GraphicListBox listBoxNetworkFramePeriod;
|
|
|
|
|
//GraphicLabel labelNetworkFramePeriod;
|
2010-12-19 09:36:59 +01:00
|
|
|
|
|
2010-07-16 18:53:19 +02:00
|
|
|
|
GraphicLabel labelNetworkPauseGameForLaggedClients;
|
|
|
|
|
GraphicListBox listBoxNetworkPauseGameForLaggedClients;
|
|
|
|
|
|
2010-07-21 20:21:40 +02:00
|
|
|
|
GraphicLabel labelPathFinderType;
|
|
|
|
|
GraphicListBox listBoxPathFinderType;
|
2010-12-19 09:36:59 +01: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;
|
|
|
|
|
GraphicListBox listBoxAdvanced;
|
2010-03-27 08:09:34 +01:00
|
|
|
|
|
2010-09-04 03:24:17 +02:00
|
|
|
|
GraphicLabel labelAllowObservers;
|
|
|
|
|
GraphicListBox listBoxAllowObservers;
|
|
|
|
|
|
2010-08-21 09:41:26 +02:00
|
|
|
|
GraphicLabel *activeInputLabel;
|
|
|
|
|
|
2011-03-11 12:11:46 +01:00
|
|
|
|
GraphicLabel labelPlayerStatus[GameConstants::maxPlayers];
|
|
|
|
|
GraphicListBox listBoxPlayerStatus;
|
|
|
|
|
|
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;
|
2010-12-19 09:36:59 +01:00
|
|
|
|
|
2010-05-16 18:40:21 +02:00
|
|
|
|
bool parentMenuIsMs;
|
2010-05-21 02:25:18 +02:00
|
|
|
|
int soundConnectionCount;
|
2010-12-19 09:36:59 +01:00
|
|
|
|
|
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;
|
|
|
|
|
|
2010-09-12 07:05:08 +02:00
|
|
|
|
MapPreview mapPreview;
|
2010-11-01 17:44:05 +01:00
|
|
|
|
Texture2D *mapPreviewTexture;
|
|
|
|
|
|
2010-10-02 04:17:50 +02:00
|
|
|
|
bool autostart;
|
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;
|
|
|
|
|
int32 lastCheckedCRCTilesetValue;
|
|
|
|
|
int32 lastCheckedCRCTechtreeValue;
|
|
|
|
|
int32 lastCheckedCRCMapValue;
|
2011-03-19 13:04:18 +01:00
|
|
|
|
vector<pair<string,int32> > factionCRCList;
|
2011-03-19 06:11:36 +01:00
|
|
|
|
|
2011-03-28 23:04:47 +02:00
|
|
|
|
bool forceWaitForShutdown;
|
|
|
|
|
|
2010-03-27 08:09:34 +01:00
|
|
|
|
public:
|
2010-10-02 04:17:50 +02:00
|
|
|
|
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,bool openNetworkSlots= false, bool parentMenuIsMasterserver=false, bool autostart=false);
|
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
|
|
|
|
|
2011-01-02 07:46:48 +01:00
|
|
|
|
virtual void simpleTask(BaseThread *callingThread);
|
2011-04-20 18:25:16 +02:00
|
|
|
|
virtual bool isInSpecialKeyCaptureEvent();
|
2010-05-13 08:43:56 +02:00
|
|
|
|
|
2010-03-27 08:09:34 +01:00
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
bool hasNetworkGameSettings();
|
|
|
|
|
void loadGameSettings(GameSettings *gameSettings);
|
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-10-15 01:22:09 +02:00
|
|
|
|
void reloadFactions(bool keepExistingSelectedItem);
|
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-05-31 21:57:10 +02:00
|
|
|
|
GameSettings loadGameSettingsFromFile(std::string fileName);
|
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
|
|
|
|
|
|
|
|
|
void RestoreLastGameSettings();
|
|
|
|
|
void PlayNow();
|
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);
|
2010-03-27 08:09:34 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
|
|
#endif
|