fios.h

Go to the documentation of this file.
00001 /* $Id$ */
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 
00019 
00020 typedef SmallMap<uint, CompanyProperties *> CompanyPropertiesMap;
00021 
00025 struct LoadCheckData {
00026   bool checkable;     
00027   StringID error;     
00028   char *error_data;   
00029 
00030   uint32 map_size_x, map_size_y;
00031   Date current_date;
00032 
00033   GameSettings settings;
00034 
00035   CompanyPropertiesMap companies;               
00036 
00037   GRFConfig *grfconfig;                         
00038   GRFListCompatibility grf_compatibility;       
00039 
00040   LoadCheckData() : error_data(NULL), grfconfig(NULL)
00041   {
00042     this->Clear();
00043   }
00044 
00048   ~LoadCheckData()
00049   {
00050     this->Clear();
00051   }
00052 
00057   bool HasErrors()
00058   {
00059     return this->checkable && this->error != INVALID_STRING_ID;
00060   }
00061 
00066   bool HasNewGrfs()
00067   {
00068     return this->checkable && this->error == INVALID_STRING_ID && this->grfconfig != NULL;
00069   }
00070 
00071   void Clear();
00072 };
00073 
00074 extern LoadCheckData _load_check_data;
00075 
00076 
00077 enum FileSlots {
00084   CONFIG_SLOT    =  0,
00086   SOUND_SLOT     =  1,
00088   FIRST_GRF_SLOT =  2,
00090   LAST_GRF_SLOT  = 255,
00092   MAX_FILE_SLOTS = 256,
00094   MAX_FILE_SLOTS_IN_NETWORK = 63
00095 };
00096 
00098 enum SaveLoadDialogMode {
00099   SLD_LOAD_GAME,      
00100   SLD_LOAD_SCENARIO,  
00101   SLD_SAVE_GAME,      
00102   SLD_SAVE_SCENARIO,  
00103   SLD_LOAD_HEIGHTMAP, 
00104   SLD_SAVE_HEIGHTMAP, 
00105   SLD_SAVE_TEMPLATE,
00106   SLD_LOAD_TEMPLATE,
00107   SLD_NEW_GAME,
00108 };
00109 
00111 enum FileType {
00112   FT_NONE,      
00113   FT_SAVEGAME,  
00114   FT_SCENARIO,  
00115   FT_HEIGHTMAP, 
00116 };
00117 
00118 enum FiosType {
00119   FIOS_TYPE_DRIVE,
00120   FIOS_TYPE_PARENT,
00121   FIOS_TYPE_DIR,
00122   FIOS_TYPE_FILE,
00123   FIOS_TYPE_OLDFILE,
00124   FIOS_TYPE_SCENARIO,
00125   FIOS_TYPE_OLD_SCENARIO,
00126   FIOS_TYPE_DIRECT,
00127   FIOS_TYPE_PNG,
00128   FIOS_TYPE_BMP,
00129   FIOS_TYPE_TEMPLATE,
00130   FIOS_TYPE_INVALID = 255,
00131 };
00132 
00134 struct FiosItem {
00135   FiosType type;
00136   uint64 mtime;
00137   char title[64];
00138   char name[MAX_PATH];
00139 };
00140 
00142 struct SmallFiosItem {
00143   int mode;             
00144   FileType filetype;    
00145   char name[MAX_PATH];  
00146   char title[255];      
00147 };
00148 
00149 enum SortingBits {
00150   SORT_ASCENDING  = 0,
00151   SORT_DESCENDING = 1,
00152   SORT_BY_DATE    = 0,
00153   SORT_BY_NAME    = 2
00154 };
00155 DECLARE_ENUM_AS_BIT_SET(SortingBits)
00156 
00157 /* Variables to display file lists */
00158 extern SmallVector<FiosItem, 32> _fios_items;
00159 extern SmallFiosItem _file_to_saveload;
00160 extern SaveLoadDialogMode _saveload_mode;
00161 extern SortingBits _savegame_sort_order;
00162 
00163 void ShowSaveLoadDialog(SaveLoadDialogMode mode);
00164 
00165 void FiosGetSavegameList(SaveLoadDialogMode mode);
00166 void FiosGetScenarioList(SaveLoadDialogMode mode);
00167 void FiosGetHeightmapList(SaveLoadDialogMode mode);
00168 /* Get a list of templates */
00169 void FiosGetTemplateList(SaveLoadDialogMode mode);
00170 /* Free the list of savegames */
00171 void FiosFreeSavegameList();
00172 const char *FiosBrowseTo(const FiosItem *item);
00173 
00174 StringID FiosGetDescText(const char **path, uint64 *total_free);
00175 bool FiosDelete(const char *name);
00176 void FiosMakeHeightmapName(char *buf,const char *name, size_t size);
00177 void FiosMakeSavegameName(char *buf, const char *name, size_t size);
00178 
00179 FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title, const char *last);
00180 
00181 int CDECL CompareFiosItems(const FiosItem *a, const FiosItem *b);
00182 
00183 extern const TextColour _fios_colours[];
00184 
00185 void BuildFileList();
00186 void SetFiosType(const byte fiostype);
00187 
00188 #endif /* FIOS_H */