Nuclide
Software Development Kit for id Tech
gamelibrary.h File Reference

Game library parsing and querying of metadata. More...

Go to the source code of this file.

Enumerations

enum  gameInfo_t {
  GAMEINFO_TITLE , GAMEINFO_GAMEDIR , GAMEINFO_FALLBACKDIR , GAMEINFO_BASEDIR ,
  GAMEINFO_WEBSITE , GAMEINFO_VERSION , GAMEINFO_SIZE , GAMEINFO_TYPE ,
  GAMEINFO_NOPLAYERMODELS , GAMEINFO_NOSPRAYS , GAMEINFO_STARTMAP , GAMEINFO_TRAININGMAP ,
  GAMEINFO_MINVERSION , GAMEINFO_CHATROOM , GAMEINFO_READMEFILE , GAMEINFO_INTROVIDEO ,
  GAMEINFO_MENUMAP , GAMEINFO_AUTHOR , GAMEINFO_AUTHORSITE , GAMEINFO_PACKAGELIST ,
  GAMEINFO_INSTALLED
}
 
enum  gi_type {
  GAMEINFO_NONE , GAMEINFO_MANIFEST , GAMEINFO_GITXT , GAMEINFO_LIBLIST ,
  GAMEINFO_PACKAGE
}
 

Functions

void GameLibrary_Init (void)
 Called when initializing the current game. More...
 
void GameLibrary_InitCustom (void)
 Called when you want to initialize custom games/mods. More...
 
void GameLibrary_Install (int)
 Install the specified game. More...
 
void GameLibrary_Activate (int)
 Activate the specified game. More...
 
void GameLibrary_Deactivate (void)
 Deactivate the currently running mod. More...
 
bool GameLibrary_IsInstalling (void)
 Returns true/false depending on if a Game installation is in progress. More...
 
float GameLibrary_InstallProgress (void)
 Returns a 0-100% value of game install progress, tracking across multiple packages. More...
 
int GameLibrary_GetGameCount (void)
 Returns the total amount of games currently available. More...
 
int GameLibrary_GetCurrentGame (void)
 Return the ID for the currently active game. More...
 
__variant GameLibrary_GetGameInfo (int, gameInfo_t)
 Retrieves fields for a given game. More...
 
__variant GameLibrary_GetInfo (gameInfo_t)
 Retrieves fields for the currently running game. More...
 
void GameLibrary_DebugList (void)
 Prints debug info about the currently cached games to the console. More...
 

Detailed Description

Game library parsing and querying of metadata.

The GameLibrary concerns itself with everything around what a game is, how to install, activate and deactivate it. Mods are included in this, so we'll proceed calling them 'games' or 'custom games'.

A game can be installed through two primary means:

  • Manual install, like from a .zip or some installer or archive
  • Engine package manager install, through our own user interface

And between these, they can come with different metadata/manifests.

It assumed that every game has either a FTE Manifest description, a gameinfo.txt (Source Engine format) or liblist.gam (GoldSrc format) that describes various aspects of the game. Like which version it is, what map will be loaded when you press 'New Game' and so on.

If that info is not available, some placeholder data will be used instead. However, games installed via the package manager will at least for the custom game menus not use the on-disk manifest file, but information provided by the package manager. Once you switch into said game everything within will be pulled from a file on disk, such as a liblist.gam or gameinfo.txt.

The menu needs to call GameLibrary_Init() once for parsing the currently running game its own metadata. If you want to index custom games, aka mods, you need to do so with GameLibrary_InitCustom() afterwards.

Because indexing mods can take a very long time depending on the amount that is stored on disk, you may want to call GameLibrary_InitCustom() at a later time.

Enumeration Type Documentation

◆ gameInfo_t

enum gameInfo_t
Enumerator
GAMEINFO_TITLE 

(string) The title of the game.

E.g. "Action Game"

GAMEINFO_GAMEDIR 

(string) The game directory name.

E.g. "data"

GAMEINFO_FALLBACKDIR 

(string) The directory to be loaded before the game directory.

GAMEINFO_BASEDIR 

(string) The first game directory to be loaded.

GAMEINFO_WEBSITE 

(string) The game its official website.

GAMEINFO_VERSION 

(string) Version number string.

GAMEINFO_SIZE 

(int) The size of the game, in bytes.

GAMEINFO_TYPE 

(string) The game type.

E.g. "Singleplayer"

GAMEINFO_NOPLAYERMODELS 

(bool) If the game allows player model selection.

GAMEINFO_NOSPRAYS 

(bool) If the game allows custom spray logos.

GAMEINFO_STARTMAP 

(string) The command for starting a new game.

GAMEINFO_TRAININGMAP 

(string) The command for starting the training.

GAMEINFO_MINVERSION 

(string) The minimum base game version.

GAMEINFO_CHATROOM 

(string) The chatroom for this game.

E.g. #action

GAMEINFO_READMEFILE 

(string) File name of the readme documentation.

GAMEINFO_INTROVIDEO 

(string) File name of the intro video to play.

GAMEINFO_MENUMAP 

(string) Name of the map to be used as a background.

GAMEINFO_AUTHOR 

(string) Name of the author.

GAMEINFO_AUTHORSITE 

(string) The author their website.

GAMEINFO_PACKAGELIST 

(string) List of packages, separated by white-space.

GAMEINFO_INSTALLED 

(bool) Whether the game is installed.

◆ gi_type

enum gi_type
Enumerator
GAMEINFO_NONE 

No gameinfo available.

This is probably the engine making assumptions.

GAMEINFO_MANIFEST 

Game info was read from a manifest within the path.

GAMEINFO_GITXT 

Game info stems from a Source Engine style gameinfo.txt file.

GAMEINFO_LIBLIST 

Game info stems from a GoldSrc style liblist.gam file.

GAMEINFO_PACKAGE 

Function Documentation

◆ GameLibrary_Activate()

void GameLibrary_Activate ( int  gameID)

Activate the specified game.

◆ GameLibrary_Deactivate()

void GameLibrary_Deactivate ( void  )

Deactivate the currently running mod.

Switching back to the base game.

◆ GameLibrary_DebugList()

void GameLibrary_DebugList ( void  )

Prints debug info about the currently cached games to the console.

◆ GameLibrary_GetCurrentGame()

int GameLibrary_GetCurrentGame ( void  )

Return the ID for the currently active game.

◆ GameLibrary_GetGameCount()

int GameLibrary_GetGameCount ( void  )

Returns the total amount of games currently available.

◆ GameLibrary_GetGameInfo()

__variant GameLibrary_GetGameInfo ( int  gameID,
gameInfo_t  infoType 
)

Retrieves fields for a given game.

See gameInfo_t for a list of fields you can query.

◆ GameLibrary_GetInfo()

__variant GameLibrary_GetInfo ( gameInfo_t  infoType)

Retrieves fields for the currently running game.

See gameInfo_t for a list of fields you can query.

◆ GameLibrary_Init()

void GameLibrary_Init ( void  )

Called when initializing the current game.

Does not cache custom game/mod info.

◆ GameLibrary_InitCustom()

void GameLibrary_InitCustom ( void  )

Called when you want to initialize custom games/mods.

Might want to call this later if the amount of locally installed mods is overwhelming.

◆ GameLibrary_Install()

void GameLibrary_Install ( int  gameID)

Install the specified game.

◆ GameLibrary_InstallProgress()

float GameLibrary_InstallProgress ( void  )

Returns a 0-100% value of game install progress, tracking across multiple packages.

◆ GameLibrary_IsInstalling()

bool GameLibrary_IsInstalling ( void  )

Returns true/false depending on if a Game installation is in progress.