2006-08-05 01:41:13 +02:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#ifndef FIOS_H
|
|
|
|
#define FIOS_H
|
|
|
|
|
2006-08-05 02:59:45 +02:00
|
|
|
/* Deals with finding savegames */
|
|
|
|
typedef struct {
|
|
|
|
byte type;
|
|
|
|
uint64 mtime;
|
|
|
|
char title[64];
|
|
|
|
char name[256 - 12 - 64];
|
|
|
|
} FiosItem;
|
|
|
|
|
|
|
|
enum {
|
2006-08-22 16:38:37 +02:00
|
|
|
FIOS_TYPE_DRIVE = 0,
|
|
|
|
FIOS_TYPE_PARENT = 1,
|
|
|
|
FIOS_TYPE_DIR = 2,
|
|
|
|
FIOS_TYPE_FILE = 3,
|
|
|
|
FIOS_TYPE_OLDFILE = 4,
|
|
|
|
FIOS_TYPE_SCENARIO = 5,
|
|
|
|
FIOS_TYPE_OLD_SCENARIO = 6,
|
|
|
|
FIOS_TYPE_DIRECT = 7,
|
|
|
|
FIOS_TYPE_PNG = 8,
|
|
|
|
FIOS_TYPE_BMP = 9,
|
|
|
|
FIOS_TYPE_INVALID = 255,
|
2006-08-05 02:59:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Variables to display file lists */
|
|
|
|
extern FiosItem *_fios_list; // defined in misc_gui.c
|
|
|
|
extern int _fios_num; // defined in fios.c, read_only version of _fios_count
|
|
|
|
extern int _saveload_mode; // defined in misc_gui.c
|
|
|
|
|
|
|
|
// Get a list of savegames
|
|
|
|
FiosItem *FiosGetSavegameList(int mode);
|
|
|
|
// Get a list of scenarios
|
|
|
|
FiosItem *FiosGetScenarioList(int mode);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
// Get a list of Heightmaps
|
|
|
|
FiosItem *FiosGetHeightmapList(int mode);
|
2006-08-05 02:59:45 +02:00
|
|
|
// Free the list of savegames
|
|
|
|
void FiosFreeSavegameList(void);
|
|
|
|
// Browse to. Returns a filename w/path if we reached a file.
|
|
|
|
char *FiosBrowseTo(const FiosItem *item);
|
|
|
|
// Return path, free space and stringID
|
|
|
|
StringID FiosGetDescText(const char **path, uint32 *total_free);
|
|
|
|
// Delete a name
|
|
|
|
bool FiosDelete(const char *name);
|
|
|
|
// Make a filename from a name
|
|
|
|
void FiosMakeSavegameName(char *buf, const char *name, size_t size);
|
|
|
|
// Allocate a new FiosItem
|
|
|
|
FiosItem *FiosAlloc(void);
|
|
|
|
|
|
|
|
int CDECL compare_FiosItems(const void *a, const void *b);
|
|
|
|
|
2006-08-05 01:41:13 +02:00
|
|
|
/* Implementation of opendir/readdir/closedir for Windows */
|
|
|
|
#if defined(WIN32)
|
|
|
|
#include <windows.h>
|
|
|
|
typedef struct DIR DIR;
|
|
|
|
|
|
|
|
typedef struct dirent { // XXX - only d_name implemented
|
(svn r9358) [0.5] -Backport from trunk (r9055, r9082, r9083, r9084, r9085, r9086):
- Codechange: Change windows unicode handling and allow a pure non-unicode build to function. (r9055)
- Codechange: [win32] Update VS2003 and VS2005 project files to build in UNICODE mode. When making a release it is probably better to make two binaries, one without UNICODE, the other with, guaranteeing full Win9x compatibility (UNICODE with MSLU also works, without it's even better). (r9082)
- Codechange: Be more lenient when trimming UTF-8 strings and don't terminate the string when an invalid encoding is encountered, but only focus on maximum length. (r9083)
- Fix: [win9x] Clipboard paste for Windows95 (doesn't have CF_UNICODETEXT) correctly converts the input to the current locale. (r9084)
- Fix: [win32] Move the initialisation of _codepage (non-UNICODE) to winMain as a dedicated server, or different video driver will not have a win32 messageloop. (r9085)
- Fix: [win32] Rewrite keyboard input and handle all keypresses in a WM_CHAR event. This saves us from doing translation (ToUnicode[Ex], ToAscii[Ex]), and we get free IME-input support as a plus. (r9086)
2007-03-20 01:02:18 +01:00
|
|
|
TCHAR *d_name; /* name of found file */
|
2006-08-05 01:41:13 +02:00
|
|
|
/* little hack which will point to parent DIR struct which will
|
|
|
|
* save us a call to GetFileAttributes if we want information
|
|
|
|
* about the file (for example in function fio_bla */
|
|
|
|
DIR *dir;
|
|
|
|
} dirent;
|
|
|
|
|
|
|
|
struct DIR {
|
|
|
|
HANDLE hFind;
|
|
|
|
/* the dirent returned by readdir.
|
|
|
|
* note: having only one global instance is not possible because
|
|
|
|
* multiple independent opendir/readdir sequences must be supported. */
|
|
|
|
dirent ent;
|
(svn r9358) [0.5] -Backport from trunk (r9055, r9082, r9083, r9084, r9085, r9086):
- Codechange: Change windows unicode handling and allow a pure non-unicode build to function. (r9055)
- Codechange: [win32] Update VS2003 and VS2005 project files to build in UNICODE mode. When making a release it is probably better to make two binaries, one without UNICODE, the other with, guaranteeing full Win9x compatibility (UNICODE with MSLU also works, without it's even better). (r9082)
- Codechange: Be more lenient when trimming UTF-8 strings and don't terminate the string when an invalid encoding is encountered, but only focus on maximum length. (r9083)
- Fix: [win9x] Clipboard paste for Windows95 (doesn't have CF_UNICODETEXT) correctly converts the input to the current locale. (r9084)
- Fix: [win32] Move the initialisation of _codepage (non-UNICODE) to winMain as a dedicated server, or different video driver will not have a win32 messageloop. (r9085)
- Fix: [win32] Rewrite keyboard input and handle all keypresses in a WM_CHAR event. This saves us from doing translation (ToUnicode[Ex], ToAscii[Ex]), and we get free IME-input support as a plus. (r9086)
2007-03-20 01:02:18 +01:00
|
|
|
WIN32_FIND_DATA fd;
|
2006-08-05 01:41:13 +02:00
|
|
|
/* since opendir calls FindFirstFile, we need a means of telling the
|
|
|
|
* first call to readdir that we already have a file.
|
|
|
|
* that's the case iff this is true */
|
|
|
|
bool at_first_entry;
|
|
|
|
};
|
|
|
|
|
(svn r9358) [0.5] -Backport from trunk (r9055, r9082, r9083, r9084, r9085, r9086):
- Codechange: Change windows unicode handling and allow a pure non-unicode build to function. (r9055)
- Codechange: [win32] Update VS2003 and VS2005 project files to build in UNICODE mode. When making a release it is probably better to make two binaries, one without UNICODE, the other with, guaranteeing full Win9x compatibility (UNICODE with MSLU also works, without it's even better). (r9082)
- Codechange: Be more lenient when trimming UTF-8 strings and don't terminate the string when an invalid encoding is encountered, but only focus on maximum length. (r9083)
- Fix: [win9x] Clipboard paste for Windows95 (doesn't have CF_UNICODETEXT) correctly converts the input to the current locale. (r9084)
- Fix: [win32] Move the initialisation of _codepage (non-UNICODE) to winMain as a dedicated server, or different video driver will not have a win32 messageloop. (r9085)
- Fix: [win32] Rewrite keyboard input and handle all keypresses in a WM_CHAR event. This saves us from doing translation (ToUnicode[Ex], ToAscii[Ex]), and we get free IME-input support as a plus. (r9086)
2007-03-20 01:02:18 +01:00
|
|
|
DIR *opendir(const TCHAR *path);
|
2006-08-05 01:41:13 +02:00
|
|
|
struct dirent *readdir(DIR *d);
|
|
|
|
int closedir(DIR *d);
|
2007-02-24 02:21:31 +01:00
|
|
|
#else
|
|
|
|
/* Use system-supplied opendir/readdir/closedir functions */
|
|
|
|
# include <sys/types.h>
|
|
|
|
# include <dirent.h>
|
2006-08-05 01:41:13 +02:00
|
|
|
#endif /* defined(WIN32) */
|
|
|
|
|
2007-02-24 02:21:31 +01:00
|
|
|
/**
|
|
|
|
* A wrapper around opendir() which will convert the string from
|
|
|
|
* OPENTTD encoding to that of the filesystem. For all purposes this
|
|
|
|
* function behaves the same as the original opendir function
|
|
|
|
* @param path string to open directory of
|
|
|
|
* @return DIR pointer
|
|
|
|
*/
|
|
|
|
static inline DIR *ttd_opendir(const char *path)
|
|
|
|
{
|
|
|
|
return opendir(OTTD2FS(path));
|
|
|
|
}
|
|
|
|
|
2006-08-05 01:41:13 +02:00
|
|
|
#endif /* FIOS_H */
|