Skip to main content

Overview

PathConfig is a structure that defines the directory paths for game content, user data, and updates. It is passed to the OnConfigurePaths() virtual hook in ReXApp, allowing subclasses to customize data storage locations before the Runtime is constructed.

Definition

struct PathConfig {
  std::filesystem::path game_data_root;
  std::filesystem::path user_data_root;
  std::filesystem::path update_data_root;
};

Fields

game_data_root
std::filesystem::path
Root directory for read-only game content (assets, original game files)
user_data_root
std::filesystem::path
Root directory for user-specific data (save files, settings, profiles)
update_data_root
std::filesystem::path
Root directory for game updates and downloadable content

Default Values

All paths start with sensible defaults derived from:
  • Command-line arguments
  • Console variables (cvars)
  • Platform conventions
Subclasses can override any field in the OnConfigurePaths() hook before Runtime construction.

Usage

Override OnConfigurePaths() to customize data paths:
class MyApp : public rex::ReXApp {
protected:
    void OnConfigurePaths(PathConfig& paths) override {
        // Use custom locations for user data
        paths.user_data_root = std::filesystem::path(std::getenv("HOME")) / ".mygame" / "saves";
        
        // Keep game data in a specific directory
        paths.game_data_root = "/opt/mygame/data";
        
        // Use default for updates (don't modify update_data_root)
    }
};

Accessing Configured Paths

After configuration, the resolved paths can be accessed through ReXApp accessor methods:
void MyApp::OnPostSetup() {
    auto save_dir = user_data_root() / "savefiles";
    auto assets_dir = game_data_root() / "textures";
    
    // Use the paths...
}

See Also

Build docs developers (and LLMs) love