Re: Re: [AD] set_config_file jumping around on OS X bundles

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


On Mon, 2005-08-22 at 14:43 +0000, peter.hull90@xxxxxxxxxx wrote:
> > I would prefer to have set_config_file do different things on
> > different platforms if necessary, in such a way that user code
> > only makes that one call and doesn't bother if the "brains" behind
> > Allegro decided that it stores the config file here or there,
> > as long as it is sensible for that platform.
> 
> I agree with this, can we make these changes for 4.2? I think that might be difficult.
> 
> > Now back to the OSX platform, any nice ideas on what to do with
> > configuration files?
> > 
> The correct locations for storing data and system-/game-/user-specific settings, _are_ well known on all the platforms; it's just a case of us writing them down. For example, on Mac I'd make use of the API function NSSearchPathForDirectoriesInDomains to get the user's settings directory.
> 
> The current config code is not right, it is based on DOS-era (e.g single user, no file permissions) thinking where it was OK to write files in the app's directory. I suggest that it should be redesigned from scratch for 4.3.
> 
> The problem that Matthew raised is just a bug - the location shouldn't jump around like that under any circumstances. The true problem is where the settings should be going - on Unix, if your game was called /usr/local/bin/mygame, settings certainly shouldn't be going in /usr/local/bin, nor should they go in some directory underneath c:\program files\ for Windows.
> 
> I'll see if I can make a Mac patch that does something sensible when I get home. 
> 
> Also, don't forget the 'magic chdir' on OSX - when run from a bundle, Allegro will automatically set the current directory to a directory within the bundle that has the same name as the binary, if one exists. This makes it easy to port a DOS/Win game that assumes that game resources will be in the same directory as the .exe. Maybe Linux could do the same, cd to /usr/local/share/exename or something similar?
> 

Can we still add an entry to the system driver? Then we could solve this
properly instead of adding another hack.

char *system_driver.get_path(int type, int name)

name would be the name of my game, type would be one of (and what it
would return in linux):
AL_ALLEGRO_CONFIG "/etc/allegro.cfg"
AL_USER_SETTINGS_PATH "~/.name"
AL_GLOBAL_SETTINGS_PATH "/etc/name"
AL_DATA_PATH "/usr/local/share/name" (or whatever prefix it was compiled with)

Now, to look for the graphics driver to set, I would look, and override,
in this order:

AL_ALLEGRO_CONFIG
AL_GLOBAL_SETTINGS_PATH/allegro.cfg
AL_USER_SETTINGS_PATH/allegro.cfg

To load my image and other data, I would load e.g. AL_DATA_PATH/game.dat

Possibly we could later add more type constants, but these 4 are the
ones I would use right now.

-- 
Elias Pschernig





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