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 
00095 enum SaveLoadDialogMode {
00096   SLD_LOAD_GAME,
00097   SLD_LOAD_SCENARIO,
00098   SLD_SAVE_GAME,
00099   SLD_SAVE_SCENARIO,
00100   SLD_LOAD_HEIGHTMAP,
00101   SLD_NEW_GAME,
00102 };
00103 
00104 /* The different types of files been handled by the system */
00105 enum FileType {
00106   FT_NONE,      
00107   FT_SAVEGAME,  
00108   FT_SCENARIO,  
00109   FT_HEIGHTMAP, 
00110 };
00111 
00112 enum FiosType {
00113   FIOS_TYPE_DRIVE,
00114   FIOS_TYPE_PARENT,
00115   FIOS_TYPE_DIR,
00116   FIOS_TYPE_FILE,
00117   FIOS_TYPE_OLDFILE,
00118   FIOS_TYPE_SCENARIO,
00119   FIOS_TYPE_OLD_SCENARIO,
00120   FIOS_TYPE_DIRECT,
00121   FIOS_TYPE_PNG,
00122   FIOS_TYPE_BMP,
00123   FIOS_TYPE_INVALID = 255,
00124 };
00125 
00126 /* Deals with finding savegames */
00127 struct FiosItem {
00128   FiosType type;
00129   uint64 mtime;
00130   char title[64];
00131   char name[MAX_PATH];
00132 };
00133 
00134 /* Deals with the type of the savegame, independent of extension */
00135 struct SmallFiosItem {
00136   int mode;             
00137   FileType filetype;    
00138   char name[MAX_PATH];  
00139   char title[255];      
00140 };
00141 
00142 enum SortingBits {
00143   SORT_ASCENDING  = 0,
00144   SORT_DESCENDING = 1,
00145   SORT_BY_DATE    = 0,
00146   SORT_BY_NAME    = 2
00147 };
00148 DECLARE_ENUM_AS_BIT_SET(SortingBits)
00149 
00150 /* Variables to display file lists */
00151 extern SmallVector<FiosItem, 32> _fios_items;
00152 extern SmallFiosItem _file_to_saveload;
00153 extern SaveLoadDialogMode _saveload_mode;
00154 extern SortingBits _savegame_sort_order;
00155 
00156 /* Launch save/load dialog */
00157 void ShowSaveLoadDialog(SaveLoadDialogMode mode);
00158 
00159 /* Get a list of savegames */
00160 void FiosGetSavegameList(SaveLoadDialogMode mode);
00161 /* Get a list of scenarios */
00162 void FiosGetScenarioList(SaveLoadDialogMode mode);
00163 /* Get a list of Heightmaps */
00164 void FiosGetHeightmapList(SaveLoadDialogMode mode);
00165 /* Free the list of savegames */
00166 void FiosFreeSavegameList();
00167 /* Browse to. Returns a filename w/path if we reached a file. */
00168 const char *FiosBrowseTo(const FiosItem *item);
00169 /* Return path, free space and stringID */
00170 StringID FiosGetDescText(const char **path, uint64 *total_free);
00171 /* Delete a name */
00172 bool FiosDelete(const char *name);
00173 /* Make a filename from a name */
00174 void FiosMakeSavegameName(char *buf, const char *name, size_t size);
00175 /* Determines type of savegame (or tells it is not a savegame) */
00176 FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title, const char *last);
00177 
00178 int CDECL CompareFiosItems(const FiosItem *a, const FiosItem *b);
00179 
00180 /* FIOS_TYPE_FILE, FIOS_TYPE_OLDFILE etc. different colours */
00181 extern const TextColour _fios_colours[];
00182 
00183 void BuildFileList();
00184 void SetFiosType(const byte fiostype);
00185 
00186 #endif /* FIOS_H */

Generated on Sun Jan 23 01:49:02 2011 for OpenTTD by  doxygen 1.6.1