// ============================================================== // This file is part of Glest (www.glest.org) // // Copyright (C) 2011 Mark Vejvoda // // 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 MENU_STATE_MODS_H_ #define MENU_STATE_MODS_H_ #include "main_menu.h" #include "map_preview.h" #include "miniftpclient.h" #include #include #include "leak_dumper.h" namespace Glest { namespace Game { enum FTPMessageType { ftpmsg_None, ftpmsg_GetMap, ftpmsg_GetTileset, ftpmsg_GetTechtree, ftpmsg_GetScenario, ftpmsg_ReplaceMap, ftpmsg_ReplaceTileset, ftpmsg_ReplaceTechtree, ftpmsg_ReplaceScenario, ftpmsg_Quit }; enum ModMenuState { mmst_None, mmst_Loading, mmst_CalculatingCRC }; typedef vector UserButtons; typedef vector GraphicLabels; // =============================== // class MenuStateMods // =============================== class MenuStateMods: public MenuState, public FTPClientCallbackInterface, public SimpleTaskCallbackInterface { private: GraphicButton buttonReturn; GraphicLine lineHorizontal; GraphicLine lineVertical; GraphicLine lineReturn; GraphicLine lineVerticalReturn; GraphicMessageBox mainMessageBox; FTPMessageType mainMessageBoxState; int techInfoXPos; int mapInfoXPos; int tilesetInfoXPos; int scenarioInfoXPos; int labelWidth; int scrollListsYPos; int listBoxLength; GraphicButton buttonInstallTech; GraphicButton buttonRemoveTech; GraphicLabel keyTechScrollBarTitle1; GraphicLabel keyTechScrollBarTitle2; GraphicScrollBar keyTechScrollBar; UserButtons keyTechButtons; GraphicLabels labelsTech; GraphicButton buttonInstallTileset; GraphicButton buttonRemoveTileset; GraphicLabel keyTilesetScrollBarTitle1; GraphicScrollBar keyTilesetScrollBar; UserButtons keyTilesetButtons; GraphicButton buttonInstallMap; GraphicButton buttonRemoveMap; GraphicLabel keyMapScrollBarTitle1; GraphicLabel keyMapScrollBarTitle2; GraphicScrollBar keyMapScrollBar; UserButtons keyMapButtons; GraphicLabels labelsMap; GraphicButton buttonInstallScenario; GraphicButton buttonRemoveScenario; GraphicLabel keyScenarioScrollBarTitle1; GraphicLabel keyScenarioScrollBarTitle2; GraphicScrollBar keyScenarioScrollBar; UserButtons keyScenarioButtons; GraphicLabel modDescrLabel; Texture2D *modPreviewImage; ModInfo *modInfoSelected; map displayModPreviewImage; GraphicButton buttonInstalled; GraphicButton buttonAvailable; GraphicButton buttonConflict; GraphicButton buttonOnlyLocal; GraphicLabel pleaseWaitLabel; ModMenuState modMenuState; ModMenuState oldMenuState; bool enableMapPreview; bool validMapPreview; MapInfo mapInfo; MapPreview mapPreview; Texture2D *mapPreviewTexture; int keyButtonsToRender; int keyButtonsYBase; int keyButtonsXBase; int keyButtonsLineHeight; int keyButtonsHeight; int keyButtonsWidth; int keyButtonsWidthTech; int keyButtonsWidthMap; int keyButtonsWidthTil; int keyButtonsWidthScen; //Console console; bool showFullConsole; string selectedTechName; std::vector techListRemote; std::map techCacheList; vector techTreeFiles; vector techTreeFilesUserData; string selectedTilesetName; std::vector tilesetListRemote; std::map tilesetCacheList; vector tilesetFiles; vector tilesetFilesUserData; string selectedMapName; std::vector mapListRemote; std::map mapCacheList; vector mapFiles; vector mapFilesUserData; string selectedScenarioName; std::vector scenarioListRemote; std::map scenarioCacheList; vector scenarioFiles; vector scenarioFilesUserData; FTPClientThread *ftpClientThread; std::map > fileFTPProgressList; SimpleTaskThread *modHttpServerThread; void getTechsLocalList(); string refreshTechModInfo(string techInfo); void refreshTechs(); void getTilesetsLocalList(); string refreshTilesetModInfo(string tilesetInfo); void refreshTilesets(); void getMapsLocalList(); string refreshMapModInfo(string mapInfo); void refreshMaps(); string getMapCRC(string mapName); void getScenariosLocalList(); string refreshScenarioModInfo(string scenarioInfo); void refreshScenarios(); void showLocalDescription(string name); void loadMapPreview(string name); void showRemoteDesription(ModInfo *modInfo); std::map mapCRCUpdateList; public: MenuStateMods(Program *program, MainMenu *mainMenu); virtual ~MenuStateMods(); void mouseClick(int x, int y, MouseButton mouseButton); void mouseDoubleClick(int x, int y, MouseButton mouseButton){}; void mouseUp(int x, int y, const MouseButton mouseButton); void mouseMove(int x, int y, const MouseState *mouseState); void eventMouseWheel(int x, int y,int zDelta); void render(); void update(); virtual void keyDown(SDL_KeyboardEvent key); virtual void keyPress(SDL_KeyboardEvent c); virtual void keyUp(SDL_KeyboardEvent key); virtual void simpleTask(BaseThread *callingThread,void *userdata); virtual void reloadUI(); private: bool eventMouseWheel(GraphicScrollBar* scrollBar, UserButtons* buttons,int x, int y,int zDelta); void layoutButtons(GraphicScrollBar * scrollBar,UserButtons* buttons, GraphicLabels* labels); void cleanUp(); MapInfo loadMapInfo(string file); void showMessageBox(const string &text, const string &header, bool toggle); void clearUserButtons(); virtual void FTPClient_CallbackEvent(string itemName, FTP_Client_CallbackType type, pair result,void *userdata); string getPreviewImageFileForMod(const ModInfo *modInfo); void cleanupPreviewTexture(); void cleanupMapPreviewTexture(); }; }}//end namespace #endif /* MENU_STATE_MODS_H_ */