fios.h

Go to the documentation of this file.
00001 /* $Id: fios.h 24491 2012-08-21 19:03:21Z rubidium $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #ifndef FIOS_H
00013 #define FIOS_H
00014 
00015 #include "gfx_type.h"
00016 #include "company_base.h"
00017 #include "newgrf_config.h"
00018 #include "network/core/tcp_content.h"
00019 
00020 
00021 typedef SmallMap<uint, CompanyProperties *> CompanyPropertiesMap;
00022 
00026 struct LoadCheckData {
00027   bool checkable;     
00028   StringID error;     
00029   char *error_data;   
00030 
00031   uint32 map_size_x, map_size_y;
00032   Date current_date;
00033 
00034   GameSettings settings;
00035 
00036   CompanyPropertiesMap companies;               
00037 
00038   GRFConfig *grfconfig;                         
00039   GRFListCompatibility grf_compatibility;       
00040 
00041   struct LoggedAction *gamelog_action;          
00042   uint gamelog_actions;                         
00043 
00044   LoadCheckData() : error_data(NULL), grfconfig(NULL), gamelog_action(NULL)
00045   {
00046     this->Clear();
00047   }
00048 
00052   ~LoadCheckData()
00053   {
00054     this->Clear();
00055   }
00056 
00061   bool HasErrors()
00062   {
00063     return this->checkable && this->error != INVALID_STRING_ID;
00064   }
00065 
00070   bool HasNewGrfs()
00071   {
00072     return this->checkable && this->error == INVALID_STRING_ID && this->grfconfig != NULL;
00073   }
00074 
00075   void Clear();
00076 };
00077 
00078 extern LoadCheckData _load_check_data;
00079 
00080 
00081 enum FileSlots {
00088   CONFIG_SLOT    =  0,
00090   SOUND_SLOT     =  1,
00092   FIRST_GRF_SLOT =  2,
00094   LAST_GRF_SLOT  = 63,
00096   MAX_FILE_SLOTS = 64
00097 };
00098 
00100 enum SaveLoadDialogMode {
00101   SLD_LOAD_GAME,      
00102   SLD_LOAD_SCENARIO,  
00103   SLD_SAVE_GAME,      
00104   SLD_SAVE_SCENARIO,  
00105   SLD_LOAD_HEIGHTMAP, 
00106   SLD_SAVE_HEIGHTMAP, 
00107 };
00108 
00110 enum FileType {
00111   FT_NONE,      
00112   FT_SAVEGAME,  
00113   FT_SCENARIO,  
00114   FT_HEIGHTMAP, 
00115 };
00116 
00117 enum FiosType {
00118   FIOS_TYPE_DRIVE,
00119   FIOS_TYPE_PARENT,
00120   FIOS_TYPE_DIR,
00121   FIOS_TYPE_FILE,
00122   FIOS_TYPE_OLDFILE,
00123   FIOS_TYPE_SCENARIO,
00124   FIOS_TYPE_OLD_SCENARIO,
00125   FIOS_TYPE_DIRECT,
00126   FIOS_TYPE_PNG,
00127   FIOS_TYPE_BMP,
00128   FIOS_TYPE_INVALID = 255,
00129 };
00130 
00132 struct FiosItem {
00133   FiosType type;
00134   uint64 mtime;
00135   char title[64];
00136   char name[MAX_PATH];
00137 };
00138 
00140 struct SmallFiosItem {
00141   int mode;             
00142   FileType filetype;    
00143   char name[MAX_PATH];  
00144   char title[255];      
00145 };
00146 
00147 enum SortingBits {
00148   SORT_ASCENDING  = 0,
00149   SORT_DESCENDING = 1,
00150   SORT_BY_DATE    = 0,
00151   SORT_BY_NAME    = 2
00152 };
00153 DECLARE_ENUM_AS_BIT_SET(SortingBits)
00154 
00155 /* Variables to display file lists */
00156 extern SmallVector<FiosItem, 32> _fios_items;
00157 extern SmallFiosItem _file_to_saveload;
00158 extern SaveLoadDialogMode _saveload_mode;
00159 extern SortingBits _savegame_sort_order;
00160 
00161 void ShowSaveLoadDialog(SaveLoadDialogMode mode);
00162 
00163 void FiosGetSavegameList(SaveLoadDialogMode mode);
00164 void FiosGetScenarioList(SaveLoadDialogMode mode);
00165 void FiosGetHeightmapList(SaveLoadDialogMode mode);
00166 
00167 void FiosFreeSavegameList();
00168 const char *FiosBrowseTo(const FiosItem *item);
00169 
00170 StringID FiosGetDescText(const char **path, uint64 *total_free);
00171 bool FiosDelete(const char *name);
00172 void FiosMakeHeightmapName(char *buf,const char *name, size_t size);
00173 void FiosMakeSavegameName(char *buf, const char *name, size_t size);
00174 
00175 FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title, const char *last);
00176 
00177 int CDECL CompareFiosItems(const FiosItem *a, const FiosItem *b);
00178 
00179 extern const TextColour _fios_colours[];
00180 
00181 void BuildFileList();
00182 void SetFiosType(const byte fiostype);
00183 
00184 #endif /* FIOS_H */