stmm-games-doc  0.32.0
Classes | Public Member Functions | List of all members
stmg::GameDiskFiles Class Reference
Inheritance diagram for stmg::GameDiskFiles:
Inheritance graph
[legend]

Public Member Functions

 GameDiskFiles (const std::string &sAppName, bool bIncludeHomeLocal)
 Constructor. More...
 
 GameDiskFiles (const std::string &sAppName, bool bIncludeHomeLocal, std::vector< File > &&aGameFiles, bool bAddStandardLocationGameFiles, std::vector< File > &&aThemeFiles, bool bAddStandardLocationThemeFiles, const std::string &sIconFile, const std::string &sHighscoresDir, const std::string &sPreferencesFile)
 Non standard location constructor. More...
 
const std::vector< File > & getGameFiles () noexcept override
 The game files for the app. More...
 
const FilegetGameThumbnailFile (const File &oGameFile) noexcept override
 The game's thumbnail. More...
 
File getIconFile ()
 The icon file. More...
 
File getHighscoreFile (const std::string &sGameName) noexcept override
 Returns the full highscore file given the game name. More...
 
File getPreferencesFile () noexcept override
 Returns the preferences file. More...
 
const std::vector< File > & getThemeFiles ()
 The theme files for the app. More...
 
const std::vector< std::pair< std::string, File > > & getThemeImageFiles (const File &oThemeFile)
 The theme's image files. More...
 
const std::vector< std::pair< std::string, File > > & getThemeSoundFiles (const File &oThemeFile)
 The theme's sound files. More...
 
const std::vector< std::pair< std::string, File > > & getThemeFontFiles (const File &oThemeFile)
 The theme's font files. More...
 
const FilegetThemeThumbnailFile (const File &oThemeFile)
 The theme's thumbnail. More...
 
const std::vector< std::pair< std::string, File > > & getDefaultImageFiles ()
 The image files shared by all themes. More...
 
const std::vector< std::pair< std::string, File > > & getDefaultSoundFiles ()
 The sound files shared by all themes. More...
 
const std::vector< std::pair< std::string, File > > & getDefaultFontFiles ()
 The font files shared by all themes. More...
 
const std::string & getPrefsAndHighscoresBasePath () const
 The base path for preferences and highscores. More...
 
const std::vector< std::string > & getGamesAndThemesBasePaths () const
 The base paths for games and themes. More...
 
- Public Member Functions inherited from stmg::XmlGameFiles
virtual ~XmlGameFiles ()=default
 

Additional Inherited Members

- Protected Member Functions inherited from stmg::XmlGameFiles
 XmlGameFiles ()=default
 

Constructor & Destructor Documentation

◆ GameDiskFiles() [1/2]

stmg::GameDiskFiles::GameDiskFiles ( const std::string &  sAppName,
bool  bIncludeHomeLocal 
)

Constructor.

The app name is usually also the subdirectory name in the standard location paths.

Example: app name jointris

/home/user/.local/share/stmm-games/themes/jointris       # for themes
/usr/local/share/stmm-games/themes/jointris              # for themes
/home/user/.local/share/stmm-games/games/jointris        # for games
/usr/local/share/stmm-games/games/jointris               # for games
/home/user/.local/share/stmm-games/preferences/jointris  # for preferences (main.prefs)
/home/user/.local/share/stmm-games/highscores/jointris   # for highscores
/usr/local/share/stmm-games/games/jointris.png           # for the app icon (128x128 pixel)

Themes can also be non game specific and be imported by game specific themes.

Example:

/home/user/.local/share/stmm-games/themes                # for generic themes
/usr/local/share/stmm-games/themes                       # for generic themes

A theme is a folder named after the theme with suffix .thm containing files theme.xml and thumbnail.png and folders images, sounds and fonts

Example: generic theme foo

/usr/share/stmm-games/themes/foo.thm/theme.xml       # theme definition file
/usr/share/stmm-games/themes/foo.thm/thumbnail.png   # 128x128 pixel
/usr/share/stmm-games/themes/foo.thm/images
/usr/share/stmm-games/themes/foo.thm/images/mybar.jpg
/usr/share/stmm-games/themes/foo.thm/sounds
/usr/share/stmm-games/themes/foo.thm/sounds/yourbang.mp3
/usr/share/stmm-games/themes/foo.thm/fonts
/usr/share/stmm-games/themes/foo.thm/fonts/skripto.ttf

All themes also automatically have access to common images, sounds and fonts.

Example: common images, sounds and fonts

/usr/share/stmm-games/themes/common/images
/usr/share/stmm-games/themes/common/images/background.jpg
/usr/share/stmm-games/themes/common/sounds
/usr/share/stmm-games/themes/common/sounds/test.wav
/usr/share/stmm-games/themes/common/fonts
/usr/share/stmm-games/themes/common/fonts/parial.ttf

A game is defined by an xml file and a corresponding picture.

Example: app jointris can have many games

/usr/share/stmm-games/games/jointris/classic.xml       # `classic` game definition file
/usr/share/stmm-games/games/jointris/classic.png       # corresponding picture, 128x128 pixel
/usr/share/stmm-games/games/jointris/penta.xml         # `penta` game definition file
/usr/share/stmm-games/games/jointris/penta.png         # corresponding picture, 128x128 pixel
Parameters
sAppNameThe app's name. Cannot be empty. Cannot contain spaces or weird characters.
bIncludeHomeLocalWhether games and themes should also be loaded from the user's home directory.

◆ GameDiskFiles() [2/2]

stmg::GameDiskFiles::GameDiskFiles ( const std::string &  sAppName,
bool  bIncludeHomeLocal,
std::vector< File > &&  aGameFiles,
bool  bAddStandardLocationGameFiles,
std::vector< File > &&  aThemeFiles,
bool  bAddStandardLocationThemeFiles,
const std::string &  sIconFile,
const std::string &  sHighscoresDir,
const std::string &  sPreferencesFile 
)

Non standard location constructor.

The folder structure of a theme must be the same as for standard location themes.

Beware! This constructor doesn't evaluate environment variable STMM_GAMES_EXTRA_BASE_PATH and add its content as a path from which to load games and themes.

Example: /tmp/mytheme (note: the folder must not necessarily end with .thm)

/tmp/mytheme/theme.xml
/tmp/mytheme/thumbnail.png   # 128x128 pixel
/tmp/mytheme/images
/tmp/mytheme/sounds
/tmp/mytheme/fonts
Parameters
sAppNameThe app's name. Cannot be empty.
bIncludeHomeLocalWhether the user's home directory is also considered as a standard location for games and themes.
aGameFilesThe game files. Can be empty. All files must be defined and not be buffers. Example: '/tmp/mygames/pong.xml'.
bAddStandardLocationGameFilesWhether to add standard locations game files to those in aGameFiles.
aThemeFilesThe theme files. Can be empty. All files must be defined and not be buffers. Example: '/tmp/mytheme/theme.xml'.
bAddStandardLocationThemeFilesWhether to add standard locations theme files to those in aThemeFiles.
sIconFileThe icon file. If not empty must exist. Example: '/tmp/myicons/pong128x128.png'.
sHighscoresDirThe highscores directory. If not empty, must exist.
sPreferencesFileThe preferences file. Can be empty.

Member Function Documentation

◆ getDefaultFontFiles()

const std::vector< std::pair<std::string, File> >& stmg::GameDiskFiles::getDefaultFontFiles ( )

The font files shared by all themes.

Returns
The shared font files. Must all be defined.

◆ getDefaultImageFiles()

const std::vector< std::pair<std::string, File> >& stmg::GameDiskFiles::getDefaultImageFiles ( )

The image files shared by all themes.

Returns
The shared image files. Must all be defined.

◆ getDefaultSoundFiles()

const std::vector< std::pair<std::string, File> >& stmg::GameDiskFiles::getDefaultSoundFiles ( )

The sound files shared by all themes.

Returns
The shared sound files. Must all be defined.

◆ getGameFiles()

const std::vector< File >& stmg::GameDiskFiles::getGameFiles ( )
overridevirtualnoexcept

The game files for the app.

Returns
The game files. Are all defined.

Implements stmg::XmlGameFiles.

◆ getGamesAndThemesBasePaths()

const std::vector< std::string >& stmg::GameDiskFiles::getGamesAndThemesBasePaths ( ) const

The base paths for games and themes.

Returns
The paths. Cannot be empty.

◆ getGameThumbnailFile()

const File& stmg::GameDiskFiles::getGameThumbnailFile ( const File oGameFile)
overridevirtualnoexcept

The game's thumbnail.

The name of the game's thumbnail image is usually the game's xml file with the image format suffix instead of the .xml suffix.

Example: game file '/usr/local/share/stmm-games/games/jointris/classic.xml' could return thumbnail file '/usr/local/share/stmm-games/games/jointris/classic.jpg'

Parameters
oGameFileThe game file. Must be defined.
Returns
The thumbnail file or undefined if not found.

Implements stmg::XmlGameFiles.

◆ getHighscoreFile()

File stmg::GameDiskFiles::getHighscoreFile ( const std::string &  sGameName)
overridevirtualnoexcept

Returns the full highscore file given the game name.

Example: if sGameName is 'Classic' the returned file might have path '~/.local/share/stmm-games/highscores/jointris/Classic.scores'.

Parameters
sGameNameThe game name. Cannot be empty.
Returns
The highscores file or an undefined File if not supported.

Implements stmg::XmlGameFiles.

◆ getIconFile()

File stmg::GameDiskFiles::getIconFile ( )

The icon file.

Example: '/usr/local/share/stmm-games/games/jointris.png"

Returns
The icon file or undefined.

◆ getPreferencesFile()

File stmg::GameDiskFiles::getPreferencesFile ( )
overridevirtualnoexcept

Returns the preferences file.

Returns
The preferences file or an undefined File if not supported.

Implements stmg::XmlGameFiles.

◆ getPrefsAndHighscoresBasePath()

const std::string& stmg::GameDiskFiles::getPrefsAndHighscoresBasePath ( ) const

The base path for preferences and highscores.

Example: '/home/user/.local/share/stmm-games'.

Returns
The path. Can be empty.

◆ getThemeFiles()

const std::vector< File >& stmg::GameDiskFiles::getThemeFiles ( )

The theme files for the app.

Returns
The theme files. Must all be defined.

◆ getThemeFontFiles()

const std::vector< std::pair<std::string, File> >& stmg::GameDiskFiles::getThemeFontFiles ( const File oThemeFile)

The theme's font files.

Parameters
oThemeFileThe theme file. Must be defined.
Returns
The font files. Are all defined.

◆ getThemeImageFiles()

const std::vector< std::pair<std::string, File> >& stmg::GameDiskFiles::getThemeImageFiles ( const File oThemeFile)

The theme's image files.

Example: for theme file '/usr/local/share/stmm-games/themes/jointris/simple_j.thm/theme.xml' all the images in the directory '/usr/local/share/stmm-games/themes/jointris/simple_j.thm/images' are returned.

Parameters
oThemeFileThe theme file. Must be defined.
Returns
The image files. Are all defined.

◆ getThemeSoundFiles()

const std::vector< std::pair<std::string, File> >& stmg::GameDiskFiles::getThemeSoundFiles ( const File oThemeFile)

The theme's sound files.

Parameters
oThemeFileThe theme file. Must be defined.
Returns
The sound files. Are all defined.

◆ getThemeThumbnailFile()

const File& stmg::GameDiskFiles::getThemeThumbnailFile ( const File oThemeFile)

The theme's thumbnail.

Parameters
oThemeFileThe theme file. Must be defined.
Returns
The thumbnail file or undefined if not found.