# fios.h

Go to the documentation of this file.

    00001 /* $Id: fios.h 26057 2013-11-23 13:12:19Z 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),
    00045       grf_compatibility(GLC_NOT_FOUND), gamelog_action(NULL), gamelog_actions(0)
    00046   {
    00047     this->Clear();
    00048   }
    00049
    00053   ~LoadCheckData()
    00054   {
    00055     this->Clear();
    00056   }
    00057
    00062   bool HasErrors()
    00063   {
    00064     return this->checkable && this->error != INVALID_STRING_ID;
    00065   }
    00066
    00071   bool HasNewGrfs()
    00072   {
    00073     return this->checkable && this->error == INVALID_STRING_ID && this->grfconfig != NULL;
    00074   }
    00075
    00076   void Clear();
    00077 };
    00078
    00079 extern LoadCheckData _load_check_data;
    00080
    00081
    00082 enum FileSlots {
    00089   CONFIG_SLOT    =  0,
    00091   SOUND_SLOT     =  1,
    00093   FIRST_GRF_SLOT =  2,
    00095   LAST_GRF_SLOT  = 63,
    00097   MAX_FILE_SLOTS = 64
    00098 };
    00099
    00101 enum SaveLoadDialogMode {
    00102   SLD_LOAD_GAME,
    00103   SLD_LOAD_SCENARIO,
    00104   SLD_SAVE_GAME,
    00105   SLD_SAVE_SCENARIO,
    00106   SLD_LOAD_HEIGHTMAP,
    00107   SLD_SAVE_HEIGHTMAP,
    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_INVALID = 255,
    00130 };
    00131
    00133 struct FiosItem {
    00134   FiosType type;
    00135   uint64 mtime;
    00136   char title[64];
    00137   char name[MAX_PATH];
    00138 };
    00139
    00141 struct SmallFiosItem {
    00142   int mode;
    00143   FileType filetype;
    00144   char name[MAX_PATH];
    00145   char title[255];
    00146 };
    00147
    00148 enum SortingBits {
    00149   SORT_ASCENDING  = 0,
    00150   SORT_DESCENDING = 1,
    00151   SORT_BY_DATE    = 0,
    00152   SORT_BY_NAME    = 2
    00153 };
    00154 DECLARE_ENUM_AS_BIT_SET(SortingBits)
    00155
    00156 /* Variables to display file lists */
    00157 extern SmallVector<FiosItem, 32> _fios_items;
    00158 extern SmallFiosItem _file_to_saveload;
    00159 extern SaveLoadDialogMode _saveload_mode;
    00160 extern SortingBits _savegame_sort_order;
    00161
    00162 void ShowSaveLoadDialog(SaveLoadDialogMode mode);
    00163
    00164 void FiosGetSavegameList(SaveLoadDialogMode mode);
    00165 void FiosGetScenarioList(SaveLoadDialogMode mode);
    00166 void FiosGetHeightmapList(SaveLoadDialogMode mode);
    00167
    00168 void FiosFreeSavegameList();
    00169 const char *FiosBrowseTo(const FiosItem *item);
    00170
    00171 StringID FiosGetDescText(const char **path, uint64 *total_free);
    00172 bool FiosDelete(const char *name);
    00173 void FiosMakeHeightmapName(char *buf, const char *name, size_t size);
    00174 void FiosMakeSavegameName(char *buf, const char *name, size_t size);
    00175
    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 extern const TextColour _fios_colours[];
    00181
    00182 void BuildFileList();
    00183 void SetFiosType(const byte fiostype);
    00184
    00185 #endif /* FIOS_H */