Skip to content

Minimap toggles kept in the player's profile, as in the original - #85

Closed
MortenLyhr wants to merge 1 commit into
bssth:masterfrom
MortenLyhr:fix/minimap-toggles
Closed

MortenLyhr wants to merge 1 commit into
bssth:masterfrom
MortenLyhr:fix/minimap-toggles

Conversation

@MortenLyhr

Copy link
Copy Markdown
Contributor

What it changes

The buttons by the minimap switch the plot grid, the bare map, the tile yields and the scores (and the unit and resource icon layers). In OpenCiv4 they started off in every game, and the scores button did nothing.

The original keeps four of them in the player's profile: Profiles/<name>.pfl in the user's My Games/Beyond the Sword (a binary file, named by UserProfile = ... in CivilizationIV.ini). The Python reads them back through CyUserProfile().getGrid(), getMap(), getYields() and getScores(), as CvMainInterface.updateGlobeLayers does for the buttons' states. Watched under Wine:

  • The .pfl is written at each click, not when the game exits.
  • After a restart and in a new game, the toggles are as last left.
  • A save does not carry them. A game saved with the grid, bare map, yields and resource layer on, then loaded after they were turned off, loads with them off.
  • The unit and resource icon layers are not in the profile.

OpenCiv4 now does the same in the profile it already has (Documents/My Games/openciv4/profile.ini, beside the graphic options and volumes), as grid=, map=, yields= and scores=. Defaults are the original's: everything off except the scores.

  • oc4options gives them to the host when the profile is read (oc4host.load_map_toggles).
  • Screens::frame notices when one has been switched, by its button or its key (Ctrl+T, Ctrl+B, Ctrl+Y), and has oc4options write the file at once.
  • CONTROL_SCORES now hides and shows the scores (Interface::toggleScoresVisible was a stub, isScoresVisible always false).
  • CyUserProfile and CyInterface (isScoresVisible, isYieldVisibleMode, the toggle... calls) read the toggles as they are.

How it was checked

  • ctest passes: 14/14 (macOS, Release), with the new minimap_toggles (oc4options.py with a stand-in host, run by Python 3 when CMake finds it). It checks that a switched toggle is in profile.ini at once, comes back after a restart and with readFromFile, and that an older profile without the keys gives the defaults. It fails on master.
  • Game results unchanged: --turns 100 --map Fractal --size STANDARD --seed 7 gives the same checksum as master on every turn, ending at D7D43800 (interface only).
  • In the game (TestMap scenario, its own Documents folder via OC4_DOCUMENTS):
    1. A new game with Ctrl+T, Ctrl+Y and the scores button gives grid=1 yields=1 scores=0.
    2. The program again, with a new game: grid and yields drawn, scores hidden.
    3. Ctrl+T there turns the grid off, and the save from step 1 (made with the grid on) loads with the grid off and the yields on.
  • Original saves still load: not affected (nothing is added to saves).

🤖 Generated with Claude Code

The original keeps four of the toggles by the minimap in its player
profile (Profiles/<name>.pfl, named by CivilizationIV.ini's UserProfile):
the plot grid, the bare map, the yields and the scores, as CyUserProfile's
getGrid, getMap, getYields and getScores. It writes the file at each click,
and every game takes them from there: after a restart, a new game, and a
loaded save (a save made with the grid on loads with the profile's grid).
The unit and resource icon layers are not kept. (Watched in Wine.)

OpenCiv4 now keeps them in its own profile (Documents/My Games/openciv4/
profile.ini) as grid=, map=, yields=, scores=: oc4options gives them to the
host when the profile is read, and Screens::frame tells it when one is
switched, by its button or its key. The scores toggle works (it did
nothing, and the scores showed always), and CyUserProfile / CyInterface
read the toggles as they are.

New test minimap_toggles (oc4options with a stand-in host): a switched
toggle is in profile.ini at once and comes back after a restart and with
readFromFile; an older profile gives the defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MortenLyhr

MortenLyhr commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Included in bundle 4/6, #148, merged there with its own commits and with its conflicts with the other open PRs resolved (the bundle PR lists them). Closing in favour of #148.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant