• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days. For more updates please see here.
Privus Modding API for Civilization VII

Privus Modding API for Civilization VII 1.0.0

Privus API is an add-on/library for Sid Meier's Civilization VII that aims to create a simple and unified modding API in order to signficantly ease the modding development process (especially when it comes to UI) and solve a few major problems with the traditional modding process in Civilization VII:

Compatibility

This API solves the inherent mod incompatibility by allowing mods to:
  • Implement changes to much more specific aspects of the UI
  • Be aware of any other mods (through their mod ids) that have implemented the same changes/functions
  • Use the default game functionality as desired
  • Not have to replace any original files of the base game

Complexity​

This API reduces the complexity and tediousness of mod development by allowing modders to only have to implement the exact changes they want and to not have to reimplement any of the base game functionality.

Legality​

This API avoids copyright issues by not copying nor distributing any of the base game's source code; Any default/base game functionality is re-implmeneted using original source code.

More details can be found on the README

Features​

  • Ability to easily modify both general UI components and tooltips
  • Centralized modder-customizable mod options within the game's option menu.
  • Complete control over the game's default functionality.
  • Significantly easier compatibility with other mods with similar functionality
  • Ability to see other active mods and which API functions they have implemented.
  • Standardized and well-documented functions and members
  • Simple and concise API and function definitions
  • Access to fine-grained UI functionality within the game

Installation​

Automatic​


Manual​

Download the .zip or .tar.gz source code from the github releases and extract the archive into the mods folder.
Default locations for the mods folder:
  • Windows: %localappdata%\Firaxis Games\Sid Meier's Civilization VII\Mods
  • Linux/Steam Deck: ~/My Games/Sid Meier's Civilization VII/Mods/
  • MacOS: ~/Library/Application Support/Civilization VII/Mods

Quickstart​

Add the Privus API as a dependency in your modinfo
XML:
<Dependencies>
<!-- Other dependencies... -->
<Mod id="privus-api" title="Privus API"/>
</Dependencies>


Import the category of whatever UI component you wish to modify
JavaScript:
//I want to modify the pause menu
import PauseMenuCategory from '/privus-api/ui/pause-menu/privus-pause-menu.js';
(The file to import from is listed under the component's API reference)

Create a class that implements the API your desired functionality
JavaScript:
class MyPauseMenu {
    //Other functions...
 
    //I want to change the game info in the pause menu
    renderUIGameInfo(modIds, gameInfo) {
        //...
    }
}
(You can see all the API functions you can implement in the API reference)

Register your class with the Privus API using your mod's id
JavaScript:
PrivusControls.defineModClass('my-mod', PauseMenuCategory, MyPauseMenu);

Mod options are explained under Global in the API reference
Overall usage (including using default functionality and modifying API data members) of the API for general UI components are listed under Components in the API reference
Overall usage of the API for tooltips are listed under Tooltips in the API reference
Repeat the process for any other UI components you want to modify.

Example​

This single script file changes the map seed text and game info text in the pause menu
JavaScript:
import PauseMenuCategory from '/privus-api/ui/pause-menu/privus-pause-menu.js';

class ExamplePauseMenu {
    //'root' is the ComponentRoot of this element
    constructor(root) {
        this._root = root;
    }

    //Change the map seed info text
    renderUIMapSeed(modIds, mapSeedInfo) {
        console.info(`[EXAMPLE-PAUSE-MENU] Mods that have already overriden the map seed ui: ${modIds}`);
   
        //You can also get the map seed info using `this._root.querySelector(...)`
        if (!mapSeedInfo) throw new Error('Could not find map seed element!');
        mapSeedInfo.textContent = `<Example Map Seed>`;
    }

    //Change the game info text
    renderUIGameInfo(modIds, gameInfo) {
        console.info(`[EXAMPLE-PAUSE-MENU] Mods that have already overriden the build info ui: ${modIds}`);

        if(!gameInfo) throw new Error('Could not find game info element!');
        gameInfo.textContent = `<Example Game Info>`;
    }
}

// Register our class as this mod's changes to the pause menu
PrivusControls.defineModClass('example', PauseMenuCategory, ExamplePauseMenu);
The full example mod can be seen in examples/pause-menu

API Reference​

The API is currently a work in progress and thus not fully complete. If you wish to see a part of the UI be implemented in this API, feel free to open an issue.
All current API functions and their details are laid out in the wiki

Note​

Please note that I am much better at responding to comments/concerns about this API on its channel in the Civ 7 Modding Helpline discord or on its github
Author
Arastais
Downloads
46
Views
511
First release
Last update

Ratings

0.00 star(s) 0 ratings
Back
Top Bottom