Adonthell  0.4
game Class Reference

Holds information about global settings. More...

#include <game.h>

Collaboration diagram for game:

Static Public Member Functions

static void init (string game_dir)
 Initialise the game framework. More...
 
static void set_game_data_dir (string game_dir)
 Specify an additional data directory containing game data. More...
 
static string user_data_dir ()
 Returns the absolute path to the user data directory (usually ~/.adonthell). More...
 
static string global_data_dir ()
 Returns the absolute path to the global data directory. More...
 
static string game_data_dir ()
 Returns the absolute path to the current game's directory (if any). More...
 
static string find_file (const string &fname)
 Finds a file in the directories hierarchy, starting searching from game_data_dir(), then global_data_dir() and finally user_data_dir(). More...
 
static string find_directory (const string &dirname)
 Finds a directory in the directories hierarchy, starting searching from game_data_dir(), then global_data_dir() and finally user_data_dir(). More...
 
static string get_system_dir (const sys_dir_type &type)
 Return the OS-specific directory of the given type. More...
 

Static Public Attributes

static string User_data_dir
 
static string Global_data_dir
 
static string Game_data_dir
 

Detailed Description

Holds information about global settings.

This static class should be the first to be initialised in your application, because many others depends on it's correct settings.

Definition at line 53 of file game.h.

Member Function Documentation

◆ init()

void game::init ( string  game_dir)
static

Initialise the game framework.

Parameters
game_dirGlobal data directory.

Definition at line 45 of file game.cc.

◆ set_game_data_dir()

void game::set_game_data_dir ( string  game_dir)
static

Specify an additional data directory containing game data.

Parameters
game_dirGame data directory.

Definition at line 53 of file game.cc.

◆ user_data_dir()

static string game::user_data_dir ( )
inlinestatic

Returns the absolute path to the user data directory (usually ~/.adonthell).

Returns
user data directory

Definition at line 80 of file game.h.

◆ global_data_dir()

static string game::global_data_dir ( )
inlinestatic

Returns the absolute path to the global data directory.

Returns
global data directory

Definition at line 91 of file game.h.

◆ game_data_dir()

static string game::game_data_dir ( )
inlinestatic

Returns the absolute path to the current game's directory (if any).

Returns
current game data directory, or empty string if none set.

Definition at line 102 of file game.h.

◆ find_file()

string game::find_file ( const string &  fname)
static

Finds a file in the directories hierarchy, starting searching from game_data_dir(), then global_data_dir() and finally user_data_dir().

If a matching file is found, the full absolute path is returned, else an empty string "" is returned. If the path was already absolute, it is returned immediatly.

Parameters
fnamename of the find to search for.
Returns
complete absolute path to the file if found, passed string if the given path was already absolute, or "" if the file wasn't found.

Definition at line 130 of file game.cc.

◆ find_directory()

string game::find_directory ( const string &  dirname)
static

Finds a directory in the directories hierarchy, starting searching from game_data_dir(), then global_data_dir() and finally user_data_dir().

If a matching directory is found, the full absolute path is returned, else an empty string "" is returned. If the path was already absolute, it is returned immediatly.

Parameters
fnamename of the find to search for.
Returns
complete absolute path to the directory if found, passed string if the given path was already absolute, or "" if the directory wasn't found.

Definition at line 152 of file game.cc.

◆ get_system_dir()

string game::get_system_dir ( const sys_dir_type &  type)
static

Return the OS-specific directory of the given type.

If the directory does not yet exist, it is also created.

Parameters
typeEither CONFIG or USER_DATA
Returns
appropriate system directory for the current user.

Definition at line 58 of file game.cc.


The documentation for this class was generated from the following files: