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  = 63,
00092   MAX_FILE_SLOTS = 64
00093 };
00094 
00096 enum SaveLoadDialogMode {
00097   SLD_LOAD_GAME,      
00098   SLD_LOAD_SCENARIO,  
00099   SLD_SAVE_GAME,      
00100   SLD_SAVE_SCENARIO,  
00101   SLD_LOAD_HEIGHTMAP, 
00102   SLD_SAVE_HEIGHTMAP, 
00103 };
00104 
00106 enum FileType {
00107   FT_NONE,      
00108   FT_SAVEGAME,  
00109   FT_SCENARIO,  
00110   FT_HEIGHTMAP, 
00111 };
00112 
00113 enum FiosType {
00114   FIOS_TYPE_DRIVE,
00115   FIOS_TYPE_PARENT,
00116   FIOS_TYPE_DIR,
00117   FIOS_TYPE_FILE,
00118   FIOS_TYPE_OLDFILE,
00119   FIOS_TYPE_SCENARIO,
00120   FIOS_TYPE_OLD_SCENARIO,
00121   FIOS_TYPE_DIRECT,
00122   FIOS_TYPE_PNG,
00123   FIOS_TYPE_BMP,
00124   FIOS_TYPE_INVALID = 255,
00125 };
00126 
00128 struct FiosItem {
00129   FiosType type;
00130   uint64 mtime;
00131   char title[64];
00132   char name[MAX_PATH];
00133 };
00134 
00136 struct SmallFiosItem {
00137   int mode;             
00138   FileType filetype;    
00139   char name[MAX_PATH];  
00140   char title[255];      
00141 };
00142 
00143 enum SortingBits {
00144   SORT_ASCENDING  = 0,
00145   SORT_DESCENDING = 1,
00146   SORT_BY_DATE    = 0,
00147   SORT_BY_NAME    = 2
00148 };
00149 DECLARE_ENUM_AS_BIT_SET(SortingBits)
00150 
00151 /* Variables to display file lists */
00152 extern SmallVector<FiosItem, 32> _fios_items;
00153 extern SmallFiosItem _file_to_saveload;
00154 extern SaveLoadDialogMode _saveload_mode;
00155 extern SortingBits _savegame_sort_order;
00156 
00157 void ShowSaveLoadDialog(SaveLoadDialogMode mode);
00158 
00159 void FiosGetSavegameList(SaveLoadDialogMode mode);
00160 void FiosGetScenarioList(SaveLoadDialogMode mode);
00161 void FiosGetHeightmapList(SaveLoadDialogMode mode);
00162 
00163 void FiosFreeSavegameList();
00164 const char *FiosBrowseTo(const FiosItem *item);
00165 
00166 StringID FiosGetDescText(const char **path, uint64 *total_free);
00167 bool FiosDelete(const char *name);
00168 void FiosMakeHeightmapName(char *buf,const char *name, size_t size);
00169 void FiosMakeSavegameName(char *buf, const char *name, size_t size);
00170 
00171 FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title, const char *last);
00172 
00173 int CDECL CompareFiosItems(const FiosItem *a, const FiosItem *b);
00174 
00175 extern const TextColour _fios_colours[];
00176 
00177 void BuildFileList();
00178 void SetFiosType(const byte fiostype);
00179 
00180 #endif /* FIOS_H */

Generated on Sun Jun 5 04:19:56 2011 for OpenTTD by  doxygen 1.6.1