2010-04-22 01:13:39 +02: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-04-22 01:13:39 +02: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_MENUSTATECONNECTEDGAME_H_
|
|
|
|
#define _GLEST_GAME_MENUSTATECONNECTEDGAME_H_
|
|
|
|
|
2012-04-20 03:04:05 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
#endif
|
|
|
|
|
2010-04-22 01:13:39 +02:00
|
|
|
#include "main_menu.h"
|
|
|
|
#include "chat_manager.h"
|
2010-09-14 08:10:48 +02:00
|
|
|
#include "map_preview.h"
|
2010-12-29 02:10:53 +01:00
|
|
|
#include "miniftpclient.h"
|
2010-09-07 07:25:40 +02:00
|
|
|
#include "leak_dumper.h"
|
2010-04-22 01:13:39 +02:00
|
|
|
|
2012-05-26 01:00:36 +02:00
|
|
|
namespace Shared { namespace Graphics {
|
|
|
|
class VideoPlayer;
|
|
|
|
}}
|
|
|
|
|
2010-09-14 08:10:48 +02:00
|
|
|
namespace Glest { namespace Game {
|
2010-04-22 01:13:39 +02:00
|
|
|
|
2010-09-14 08:10:48 +02:00
|
|
|
enum JoinMenu {
|
2010-05-09 23:23:13 +02:00
|
|
|
jmSimple,
|
|
|
|
jmMasterserver,
|
|
|
|
|
|
|
|
jmCount
|
|
|
|
};
|
|
|
|
|
2011-01-01 01:50:10 +01:00
|
|
|
enum FTPMessageType {
|
|
|
|
ftpmsg_MissingNone,
|
|
|
|
ftpmsg_MissingMap,
|
2011-03-10 00:09:32 +01:00
|
|
|
ftpmsg_MissingTileset,
|
|
|
|
ftpmsg_MissingTechtree
|
2011-01-01 01:50:10 +01:00
|
|
|
};
|
2010-05-09 23:23:13 +02:00
|
|
|
|
2010-04-22 01:13:39 +02:00
|
|
|
// ===============================
|
|
|
|
// class MenuStateConnectedGame
|
|
|
|
// ===============================
|
|
|
|
|
2012-10-16 00:19:22 +02:00
|
|
|
class MenuStateConnectedGame: public MenuState, public FTPClientCallbackInterface, public SimpleTaskCallbackInterface {
|
2010-04-22 01:13:39 +02:00
|
|
|
private:
|
|
|
|
GraphicButton buttonDisconnect;
|
|
|
|
GraphicLabel labelControl;
|
2010-11-09 00:15:50 +01:00
|
|
|
GraphicLabel labelRMultiplier;
|
2010-04-22 01:13:39 +02:00
|
|
|
GraphicLabel labelFaction;
|
|
|
|
GraphicLabel labelTeam;
|
|
|
|
GraphicLabel labelMap;
|
|
|
|
GraphicLabel labelFogOfWar;
|
|
|
|
GraphicLabel labelTechTree;
|
|
|
|
GraphicLabel labelTileset;
|
|
|
|
GraphicLabel labelMapInfo;
|
|
|
|
GraphicLabel labelStatus;
|
|
|
|
GraphicLabel labelInfo;
|
2011-12-03 09:17:49 +01:00
|
|
|
GraphicButton buttonRestoreLastSettings;
|
2010-08-05 01:39:12 +02:00
|
|
|
|
2012-09-22 23:44:30 +02:00
|
|
|
//GraphicLabel labelPathFinderType;
|
|
|
|
//GraphicListBox listBoxPathFinderType;
|
2010-12-29 02:10:53 +01:00
|
|
|
|
2010-08-28 01:08:35 +02:00
|
|
|
GraphicLabel labelMapPlayerCount;
|
|
|
|
GraphicListBox listBoxMapPlayerCount;
|
2010-12-29 02:10:53 +01:00
|
|
|
|
2010-08-28 01:08:35 +02:00
|
|
|
GraphicLabel labelAdvanced;
|
|
|
|
GraphicListBox listBoxAdvanced;
|
2010-12-29 02:10:53 +01:00
|
|
|
|
2010-04-22 01:13:39 +02:00
|
|
|
GraphicListBox listBoxMap;
|
|
|
|
GraphicListBox listBoxFogOfWar;
|
|
|
|
GraphicListBox listBoxTechTree;
|
|
|
|
GraphicListBox listBoxTileset;
|
|
|
|
GraphicLabel labelPlayers[GameConstants::maxPlayers];
|
2010-08-21 15:04:52 +02:00
|
|
|
GraphicLabel labelPlayerNames[GameConstants::maxPlayers];
|
2010-04-22 01:13:39 +02:00
|
|
|
GraphicListBox listBoxControls[GameConstants::maxPlayers];
|
2010-11-09 00:15:50 +01:00
|
|
|
GraphicListBox listBoxRMultiplier[GameConstants::maxPlayers];
|
2010-04-22 01:13:39 +02:00
|
|
|
GraphicListBox listBoxFactions[GameConstants::maxPlayers];
|
|
|
|
GraphicListBox listBoxTeams[GameConstants::maxPlayers];
|
|
|
|
GraphicLabel labelNetStatus[GameConstants::maxPlayers];
|
2010-04-29 01:59:37 +02:00
|
|
|
GraphicButton grabSlotButton[GameConstants::maxPlayers];
|
2010-08-21 15:04:52 +02:00
|
|
|
|
2011-03-11 12:11:46 +01:00
|
|
|
GraphicListBox listBoxPlayerStatus;
|
|
|
|
GraphicLabel labelPlayerStatus[GameConstants::maxPlayers];
|
|
|
|
|
2010-09-04 03:24:17 +02:00
|
|
|
GraphicLabel labelAllowObservers;
|
2012-10-22 19:53:48 +02:00
|
|
|
//GraphicListBox listBoxAllowObservers;
|
|
|
|
GraphicCheckBox checkBoxAllowObservers;
|
2010-09-04 03:24:17 +02:00
|
|
|
|
2010-08-21 15:04:52 +02:00
|
|
|
GraphicLabel *activeInputLabel;
|
|
|
|
|
2011-01-09 05:49:21 +01:00
|
|
|
time_t timerLabelFlash;
|
|
|
|
GraphicLabel labelDataSynchInfo;
|
|
|
|
|
2010-04-22 01:13:39 +02:00
|
|
|
MapInfo mapInfo;
|
2011-04-13 03:11:23 +02:00
|
|
|
Texture2D *mapPreviewTexture;
|
2010-04-22 01:13:39 +02:00
|
|
|
|
|
|
|
bool needToSetChangedGameSettings;
|
|
|
|
time_t lastSetChangedGameSettings;
|
2010-08-22 10:00:05 +02:00
|
|
|
bool updateDataSynchDetailText;
|
2010-04-22 01:13:39 +02:00
|
|
|
|
2012-06-14 01:01:10 +02:00
|
|
|
int soundConnectionCount;
|
|
|
|
|
2011-04-15 03:05:36 +02:00
|
|
|
//Console console;
|
2010-04-22 01:13:39 +02:00
|
|
|
ChatManager chatManager;
|
2010-06-09 00:50:37 +02:00
|
|
|
bool showFullConsole;
|
2010-12-29 02:10:53 +01:00
|
|
|
|
2010-04-23 01:18:04 +02:00
|
|
|
string currentFactionName;
|
|
|
|
string currentMap;
|
2010-05-09 23:23:13 +02:00
|
|
|
JoinMenu returnMenuInfo;
|
2010-04-23 01:18:04 +02:00
|
|
|
bool settingsReceivedFromServer;
|
2010-07-09 19:12:57 +02:00
|
|
|
time_t lastNetworkSendPing;
|
2010-07-09 20:49:01 +02:00
|
|
|
int pingCount;
|
2010-08-05 02:48:46 +02:00
|
|
|
bool initialSettingsReceivedFromServer;
|
2010-12-29 02:10:53 +01:00
|
|
|
|
2010-08-22 10:00:05 +02:00
|
|
|
string lastMapDataSynchError;
|
|
|
|
string lastTileDataSynchError;
|
|
|
|
string lastTechtreeDataSynchError;
|
2010-12-29 02:10:53 +01:00
|
|
|
|
2010-08-23 06:33:21 +02:00
|
|
|
int8 switchSetupRequestFlagType;
|
|
|
|
string defaultPlayerName;
|
|
|
|
|
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;
|
2012-05-26 01:00:36 +02: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-14 08:10:48 +02:00
|
|
|
MapPreview mapPreview;
|
|
|
|
|
2010-09-17 08:37:08 +02:00
|
|
|
GraphicMessageBox mainMessageBox;
|
|
|
|
|
2010-09-17 10:26:22 +02:00
|
|
|
std::string lastMissingMap;
|
2010-09-17 10:46:34 +02:00
|
|
|
std::string lastMissingTechtree;
|
|
|
|
std::string lastMissingTileSet;
|
2010-12-29 02:10:53 +01:00
|
|
|
|
2011-03-10 00:09:32 +01:00
|
|
|
vector<string> mapFiles;
|
|
|
|
vector<string> techTreeFiles;
|
|
|
|
vector<string> tilesetFiles;
|
|
|
|
vector<string> factionFiles;
|
2010-09-17 10:26:22 +02:00
|
|
|
|
2011-09-24 09:46:56 +02:00
|
|
|
vector<string> playerSortedMaps[GameConstants::maxPlayers+1];
|
|
|
|
vector<string> formattedPlayerSortedMaps[GameConstants::maxPlayers+1];
|
|
|
|
vector<string> formattedMapFiles;
|
|
|
|
|
2010-12-29 20:31:51 +01:00
|
|
|
GraphicMessageBox ftpMessageBox;
|
2010-12-29 02:10:53 +01:00
|
|
|
FTPClientThread *ftpClientThread;
|
2011-01-01 01:50:10 +01:00
|
|
|
FTPMessageType ftpMissingDataType;
|
|
|
|
|
2012-10-16 00:19:22 +02:00
|
|
|
SimpleTaskThread *modHttpServerThread;
|
|
|
|
std::vector<std::string> tilesetListRemote;
|
|
|
|
std::map<string, ModInfo> tilesetCacheList;
|
|
|
|
std::vector<std::string> techListRemote;
|
|
|
|
std::map<string, ModInfo> techCacheList;
|
|
|
|
std::vector<std::string> mapListRemote;
|
|
|
|
std::map<string, ModInfo> mapCacheList;
|
|
|
|
|
|
|
|
std::map<string,uint32> mapCRCUpdateList;
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-29 07:11:06 +01:00
|
|
|
string getMissingMapFromFTPServer;
|
2010-12-29 09:10:22 +01:00
|
|
|
bool getMissingMapFromFTPServerInProgress;
|
2010-12-29 02:10:53 +01:00
|
|
|
|
2011-01-01 01:50:10 +01:00
|
|
|
string getMissingTilesetFromFTPServer;
|
|
|
|
bool getMissingTilesetFromFTPServerInProgress;
|
|
|
|
|
2011-03-10 00:09:32 +01:00
|
|
|
string getMissingTechtreeFromFTPServer;
|
|
|
|
bool getMissingTechtreeFromFTPServerInProgress;
|
|
|
|
|
2013-02-15 19:25:10 +01:00
|
|
|
string getInProgressSavedGameFromFTPServer;
|
|
|
|
bool getInProgressSavedGameFromFTPServerInProgress;
|
|
|
|
bool readyToJoinInProgressGame;
|
|
|
|
|
2011-03-19 06:11:36 +01:00
|
|
|
string lastCheckedCRCTilesetName;
|
|
|
|
string lastCheckedCRCTechtreeName;
|
|
|
|
string lastCheckedCRCMapName;
|
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-01-04 09:44:00 +01:00
|
|
|
std::map<string,pair<int,string> > fileFTPProgressList;
|
2011-04-15 02:09:38 +02:00
|
|
|
GraphicButton buttonCancelDownloads;
|
2011-01-04 09:44:00 +01:00
|
|
|
|
2011-09-21 08:51:28 +02:00
|
|
|
GraphicLabel labelEnableSwitchTeamMode;
|
2012-10-22 19:53:48 +02:00
|
|
|
//GraphicListBox listBoxEnableSwitchTeamMode;
|
|
|
|
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
|
|
|
|
2011-09-24 09:46:56 +02:00
|
|
|
GraphicButton buttonPlayNow;
|
|
|
|
|
2011-12-26 07:29:14 +01:00
|
|
|
GraphicCheckBox checkBoxScenario;
|
|
|
|
GraphicLabel labelScenario;
|
|
|
|
GraphicListBox listBoxScenario;
|
|
|
|
vector<string> scenarioFiles;
|
|
|
|
ScenarioInfo scenarioInfo;
|
|
|
|
vector<string> dirList;
|
|
|
|
string autoloadScenarioName;
|
|
|
|
time_t previewLoadDelayTimer;
|
|
|
|
bool needToLoadTextures;
|
|
|
|
bool enableScenarioTexturePreview;
|
|
|
|
Texture2D *scenarioLogoTexture;
|
|
|
|
|
2011-10-22 02:19:38 +02:00
|
|
|
bool needToBroadcastServerSettings;
|
|
|
|
time_t broadcastServerSettingsDelayTimer;
|
|
|
|
int lastGameSettingsReceivedCount;
|
|
|
|
|
2010-04-22 01:13:39 +02:00
|
|
|
public:
|
2010-09-14 08:10:48 +02:00
|
|
|
|
2010-05-09 23:23:13 +02:00
|
|
|
MenuStateConnectedGame(Program *program, MainMenu *mainMenu, JoinMenu joinMenuInfo=jmSimple, bool openNetworkSlots= false);
|
2010-08-31 08:38:27 +02:00
|
|
|
~MenuStateConnectedGame();
|
2010-04-22 01:13:39 +02: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-04-22 01:13:39 +02:00
|
|
|
|
2011-04-20 18:25:16 +02:00
|
|
|
virtual bool isInSpecialKeyCaptureEvent();
|
2010-07-29 07:24:51 +02:00
|
|
|
|
2011-10-25 20:39:11 +02:00
|
|
|
virtual void reloadUI();
|
|
|
|
|
2012-06-09 04:59:46 +02:00
|
|
|
virtual bool isVideoPlaying();
|
|
|
|
|
2010-04-22 01:13:39 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
bool hasNetworkGameSettings();
|
2010-06-03 08:03:41 +02:00
|
|
|
bool loadFactions(const GameSettings *gameSettings,bool errorOnNoFactions);
|
2010-05-09 23:23:13 +02:00
|
|
|
void returnToJoinMenu();
|
2010-08-21 15:04:52 +02:00
|
|
|
string getHumanPlayerName();
|
|
|
|
void setActiveInputLabel(GraphicLabel *newLable);
|
2010-08-31 08:38:27 +02:00
|
|
|
|
|
|
|
void loadFactionTexture(string filepath);
|
2010-09-17 10:26:22 +02:00
|
|
|
bool loadMapInfo(string file, MapInfo *mapInfo, bool loadMapPreview);
|
2010-09-17 08:37:08 +02:00
|
|
|
void showMessageBox(const string &text, const string &header, bool toggle);
|
2010-08-31 08:38:27 +02:00
|
|
|
|
2010-12-29 20:31:51 +01:00
|
|
|
void showFTPMessageBox(const string &text, const string &header, bool toggle);
|
2011-03-25 11:11:16 +01:00
|
|
|
virtual void FTPClient_CallbackEvent(string itemName,
|
|
|
|
FTP_Client_CallbackType type, pair<FTP_Client_ResultType,string> result,void *userdata);
|
2011-03-11 12:11:46 +01:00
|
|
|
|
|
|
|
int32 getNetworkPlayerStatus();
|
2011-04-13 03:11:23 +02:00
|
|
|
void cleanupMapPreviewTexture();
|
2011-09-24 09:46:56 +02:00
|
|
|
|
2012-11-17 02:04:04 +01:00
|
|
|
void mouseClickAdmin(int x, int y, MouseButton mouseButton,string advanceToItemStartingWith);
|
2011-09-24 09:46:56 +02:00
|
|
|
string getCurrentMapFile();
|
|
|
|
void loadGameSettings(GameSettings *gameSettings);
|
2011-12-28 05:46:36 +01:00
|
|
|
void reloadFactions(bool keepExistingSelectedItem,string scenario);
|
2011-09-24 09:46:56 +02:00
|
|
|
void PlayNow(bool saveGame);
|
2012-07-06 00:03:15 +02:00
|
|
|
bool isHeadlessAdmin();
|
|
|
|
void broadCastGameSettingsToHeadlessServer(bool forceNow);
|
2011-09-27 03:11:11 +02:00
|
|
|
void updateResourceMultiplier(const int index);
|
2011-12-03 09:17:49 +01:00
|
|
|
|
|
|
|
void RestoreLastGameSettings();
|
2011-12-26 07:29:14 +01:00
|
|
|
void setupUIFromGameSettings(GameSettings *gameSettings, bool errorOnMissingData);
|
2011-12-28 05:46:36 +01:00
|
|
|
|
|
|
|
int setupMapList(string scenario);
|
|
|
|
int setupTechList(string scenario);
|
|
|
|
void setupTilesetList(string scenario);
|
|
|
|
|
|
|
|
void loadScenarioInfo(string file, ScenarioInfo *scenarioInfo);
|
2012-09-26 00:52:07 +02:00
|
|
|
void initFactionPreview(const GameSettings *gameSettings);
|
2012-10-16 00:19:22 +02:00
|
|
|
|
|
|
|
virtual void simpleTask(BaseThread *callingThread);
|
|
|
|
string refreshTilesetModInfo(string tilesetInfo);
|
|
|
|
string refreshTechModInfo(string techInfo);
|
|
|
|
string refreshMapModInfo(string mapInfo);
|
|
|
|
string getMapCRC(string mapName);
|
2010-04-22 01:13:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
#endif
|