Unciv Documentation

repository·master·Indexed 27 days ago

https://github.com/yairm210/unciv

An open-source, moddability-focused 4X strategy game remake of Civilization V, developed using LibGDX for Android and Desktop platforms. The documentation covers installation across multiple OSs, Docker deployment, contribution guides for programmers and modders, detailed Croatian translation guidelines, and technical API details for city statistics and production logic.

Tokens
62.3K
Snippets
71
Records
289
Agent score
94%

What's inside Unciv

  1. Understand LibGDX image rendering and texture binding

    master

    Unciv uses LibGDX for rendering. Images are displayed via a SpriteBatch which binds textures to memory.

    Key Performance Concept:

    • Texture Binding: The process of loading textures into memory is slow, while the actual rendering is fast.
    • Optimization Strategy: To minimize performance hits, the game minimizes texture rebinds (swapping between different categories). This is achieved by compiling images into large PNGs using ImagePacker.packImages().
    • Texture Limits: Due to chipset limitations, textures are capped at 2048*2048 pixels. Images are therefore categorized (e.g., Images.Flags, Images.Tech) and compiled into separate PNG files in the android/assets folder to balance proximity and size.
  2. Understand the Unciv Project Structure

    master

    Unciv is built using LibGDX for multi-platform support. The project is organized into several key directories:

    • core: Contains 99% of the code, representing all platform-independent logic.
    • desktop: Contains platform-specific code for desktop environments.
    • android: Contains platform-specific code for Android, as well as the game Images and Assets (required for both Android and Desktop).
    • server: Contains the source for UncivServer, which enables communication between multiplayer game instances.
    • tests: Contains tests that can be executed via Gradle.
  3. Understand the three types of Unciv mods

    master

    Unciv mods are categorized based on how they interact with the game rules:

    • Extension mods: Add new nations, units, buildings, or resources to an existing ruleset (either the default or another mod's ruleset).
    • Base Ruleset mods: Replace the entire existing ruleset (tech tree, units, policies, etc.) to provide a completely different experience. These require setting "isBaseRuleset": true in the ModOptions.json file.
    • Ruleset-agnostic mods: Do not contain ruleset JSONs. These focus on audiovisual changes (tilesets, unitsets, UI skins) or map mods.
  4. Manually add translation templates to template.properties

    master

    If you add text directly in code (e.g., popup.add("Hello world".toLabel())) that is not contained in a JSON file or the UniqueType system, you must manually add it to template.properties to make it translatable.

    Formatting Rules:

    • Add the text followed by an equals sign and a space: Hello world = .
    • Crucial: The space after the = is absolutely required. Ensure your editor does not strip trailing whitespace.
    • Avoid leading spaces or multiple spaces between the text and the = unless those spaces are a required part of the string, as translators may overlook them.
    Hello world = 
  5. Translate overridden base game terms

    master

    When translating, check if the base game uses an override in English.properties. If a term is overridden in English, you must translate it relative to that override, not the original base game key.

    Example: If English.properties contains gold = credits, and you are translating into your language:

    • Correct: gold = [your translation for credits]
    • Incorrect: gold = gold (This ignores the English override and will result in incorrect terminology).

    Always ensure exact case sensitivity for both the translation keys (left of the =) and the filenames.

  6. Play multiplayer in Unciv

    master

    To play multiplayer, all players must be connected to the same multiplayer server. Follow these steps:

    1. Sync Server: Ensure everyone is using the same server via Main Menu -> Options -> Multiplayer.
    2. Exchange User IDs: Have all players provide their user ID via Main Menu -> Multiplayer -> Copy user ID. (Optional: Add these to your Friends list via Main Menu -> Multiplayer -> Friends list).
    3. Host the Game:
      • Go to Main Menu -> Start new game.
      • Check Online multiplayer on the left.
      • On the right, add human players by inputting their user IDs.
      • Press Start game!.
    4. Share Game ID: The game ID is automatically copied to your clipboard. If lost, retrieve it via Main Menu -> Multiplayer -> Copy game ID. Send this ID to other players.
    5. Join the Game: Other players must go to Main Menu -> Multiplayer -> Add multiplayer game, enter the provided game ID, and join from that screen.
  7. Optimize rendering performance with multiple texture atlases

    master

    To avoid performance degradation caused by large textures spilling into multiple files (e.g., game2.png), you can group images into multiple atlases.

    Implementation:

    • Create multiple image folders named Images.xyz (where xyz is a unique identifier).
    • Warning: Do not use Images.game as it will clash with the default.
    • Atlases.json: If using multiple atlases, you must manually maintain an Atlases.json file in the mod root. This file is a JSON array of strings containing the filenames (without the .atlas extension) of the atlases to load. It must be saved as UTF-8 without a BOM.

    Icon Optimization:

    • Aim for icon sizes around 100x100 pixels.
    • To enable faster rendering for specific icon categories, copy OtherIcons/circle.png to the corresponding category folder (e.g., ImprovementIcons/Circle.png, ResourceIcons/Circle.png, TechIcons/Circle.png, ConstructionIcons/Circle.png, or StatIcons/Circle.png). Only do this if your mod's icons constitute the majority of that category.
  8. Format and structure translation files

    master

    Unciv uses .properties files for translations, with one file per language. This avoids merge conflicts and human error common in JSON.

    Format Rules:

    • Use the format Source Text = Translated Text to make it easy for translators to see the context.
    • Use = as the delimiter.
    • Use lines starting with # for comments to provide guidance to translators.
    • Do not use JSON for translation files as it is prone to syntax errors.
  9. Add edge images for specific tile adjacencies

    master

    Edge images are drawn when a tile is adjacent to another tile in a specific direction.

    Location: Images/Tilesets/<tileset name>/Edges/

    Naming Convention: <tile name>-<origin tile filter>-<destination tile filter>-<neighbor direction>.png

    Components:

    • Directions: Bottom, BottomLeft, BottomRight, Top, TopLeft, TopRight.
    • Filters: Terrain name, Feature name, or Terrain type (Land/Water).

    Example: Cliff-Hills-Coast-Top.png will be drawn on a Hills tile if a Coast tile is at its Top position.