Re: [AD] Magic main in Windows

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]



On Mon, 2 Aug 2004, Daniel Schlyder wrote:

Stepan Roh:
What about adding these two functions:

get_data_path()
- returns path where datafiles are located (path with executable on Win,
/usr/share/XY on *nix)

According to FHS, that should be /usr/share/games/XY, and wouldn't it also need
to support /usr/local hierarchy? And what if a user installed the game to his
home dir?

get_state_path()
- returns path where game state files (= saves, modifiable config files,
etc.) should be stored (again path with executable on Win, ~/.XY on *nix)

Of course that brings the problem what XY is/should be :-)

Yeah, I think functions like these should be left for users to implement.

I think get_executable_name() should be dropped w/o replacement or with something like your find_file() (which I removed from this post :-) ) as a replacement.

Could be (in the spirit of find_allegro_resource(), but smaller):

int find_user_resource(char *dest, const char *resource, int type, int size);

where type is either DATA or STATE or whatever you like

Places where such resource is located in are configured with:

add_user_resource_dir(const char *dir, int type);

Default resource dirs (last ones to be searched) are program dir for Windows and current dir for *nix.

In main() programmers write:

#ifdef DATA_DIR
add_user_resource_dir(DATA_DIR, DATA);
#endif
#ifdef STATE_DIR
add_user_resource_dir(STATE_DIR, STATE);
#endif

Values of *_DIR are supplied by some config.h created during build process on *nix and undefined on Windows.

Have a nice day.

Stepan Roh




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/