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   struct LoggedAction *gamelog_action;          
00041   uint gamelog_actions;                         
00042 
00043   LoadCheckData() : error_data(NULL), grfconfig(NULL), gamelog_action(NULL)
00044   {
00045     this->Clear();
00046   }
00047 
00051   ~LoadCheckData()
00052   {
00053     this->Clear();
00054   }
00055 
00060   bool HasErrors()
00061   {
00062     return this->checkable && this->error != INVALID_STRING_ID;
00063   }
00064 
00069   bool HasNewGrfs()
00070   {
00071     return this->checkable && this->error == INVALID_STRING_ID && this->grfconfig != NULL;
00072   }
00073 
00074   void Clear();
00075 };
00076 
00077 extern LoadCheckData _load_check_data;
00078 
00079 
00080 enum FileSlots {
00087   CONFIG_SLOT    =  0,
00089   SOUND_SLOT     =  1,
00091   FIRST_GRF_SLOT =  2,
00093   LAST_GRF_SLOT  = 63,
00095   MAX_FILE_SLOTS = 64
00096 };
00097 
00099 enum SaveLoadDialogMode {
00100   SLD_LOAD_GAME,      
00101   SLD_LOAD_SCENARIO,  
00102   SLD_SAVE_GAME,      
00103   SLD_SAVE_SCENARIO,  
00104   SLD_LOAD_HEIGHTMAP, 
00105   SLD_SAVE_HEIGHTMAP, 
00106 };
00107 
00109 enum FileType {
00110   FT_NONE,      
00111   FT_SAVEGAME,  
00112   FT_SCENARIO,  
00113   FT_HEIGHTMAP, 
00114 };
00115 
00116 enum FiosType {
00117   FIOS_TYPE_DRIVE,
00118   FIOS_TYPE_PARENT,
00119   FIOS_TYPE_DIR,
00120   FIOS_TYPE_FILE,
00121   FIOS_TYPE_OLDFILE,
00122   FIOS_TYPE_SCENARIO,
00123   FIOS_TYPE_OLD_SCENARIO,
00124   FIOS_TYPE_DIRECT,
00125   FIOS_TYPE_PNG,
00126   FIOS_TYPE_BMP,
00127   FIOS_TYPE_INVALID = 255,
00128 };
00129 
00131 struct FiosItem {
00132   FiosType type;
00133   uint64 mtime;
00134   char title[64];
00135   char name[MAX_PATH];
00136 };
00137 
00139 struct SmallFiosItem {
00140   int mode;             
00141   FileType filetype;    
00142   char name[MAX_PATH];  
00143   char title[255];      
00144 };
00145 
00146 enum SortingBits {
00147   SORT_ASCENDING  = 0,
00148   SORT_DESCENDING = 1,
00149   SORT_BY_DATE    = 0,
00150   SORT_BY_NAME    = 2
00151 };
00152 DECLARE_ENUM_AS_BIT_SET(SortingBits)
00153 
00154 /* Variables to display file lists */
00155 extern SmallVector<FiosItem, 32> _fios_items;
00156 extern SmallFiosItem _file_to_saveload;
00157 extern SaveLoadDialogMode _saveload_mode;
00158 extern SortingBits _savegame_sort_order;
00159 
00160 void ShowSaveLoadDialog(SaveLoadDialogMode mode);
00161 
00162 void FiosGetSavegameList(SaveLoadDialogMode mode);
00163 void FiosGetScenarioList(SaveLoadDialogMode mode);
00164 void FiosGetHeightmapList(SaveLoadDialogMode mode);
00165 
00166 void FiosFreeSavegameList();
00167 const char *FiosBrowseTo(const FiosItem *item);
00168 
00169 StringID FiosGetDescText(const char **path, uint64 *total_free);
00170 bool FiosDelete(const char *name);
00171 void FiosMakeHeightmapName(char *buf,const char *name, size_t size);
00172 void FiosMakeSavegameName(char *buf, const char *name, size_t size);
00173 
00174 FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title, const char *last);
00175 
00176 int CDECL CompareFiosItems(const FiosItem *a, const FiosItem *b);
00177 
00178 extern const TextColour _fios_colours[];
00179 
00180 void BuildFileList();
00181 void SetFiosType(const byte fiostype);
00182 
00183 #endif /* FIOS_H */