Skip to content

Bundle 4/6: the options screen - #148

Open
MortenLyhr wants to merge 31 commits into
bssth:masterfrom
MortenLyhr:train/4-options
Open

MortenLyhr wants to merge 31 commits into
bssth:masterfrom
MortenLyhr:train/4-options

Conversation

@MortenLyhr

@MortenLyhr MortenLyhr commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Rebased on master (2026-11-23): bundles 1–3 are merged, so this branch is based on master now and shows only its own changes. Merge it before bundles 5 and 6 (#149, #150), which hold it.

Clean room (2026-11-23): #120's history is rewritten. The commits that first wrote the autosave rule from the exe's strings and the commit that re-checked it in Wine are now one commit, whose message gives only the Wine run as the source. fix/ini-options (#120's branch) is force-pushed with the same history.

This PR replaces 7 open PRs, merged here one by one with their own commits (each description stays on its PR, which links here once closed); the conflicts between them are resolved as on the branch we play daily. Merging it closes nothing automatically: each replaced PR will be closed with a link here.

PR What
#85 Minimap toggles kept in the player's profile, as in the original
#87 Options screen as the original's; player options kept in the profile
#118 Options > Other: profiles, the clock and the alarm as the original's; network greyed
#119 Options > Audio as the original's: theme sliders, speakers, own music folder; voice greyed
#120 Options: CivilizationIV.ini's settings on the OpenCiv4 tab (autosaves, tech splash, messages, field of view, frame cap)
#132 Options -> Graphics: every option as the original's, without a restart
#137 OpenCiv4 option: Quick enemy moves

Commits of this bundle's own (on top of the merges):

Checks: macOS build (Release), ctest 19/19 passed; sync checksums --turns 100 --map Fractal --size STANDARD --seed 7 at turn 100 equal master's (D7D43800). Windows: this PR's CI.

Autosaves: rule re-checked in the running game (2026-11-22, 3eab86e7)

#120 had based the autosaves after the first turn on strings from the original's exe, against CONTRIBUTING. The rule was watched in the running game under Wine instead (interval 2, 3 kept, 16 turns; see #120's added section). One difference was fixed: the initial autosave is no longer counted among the kept ones, nor deleted. Bundles 5–6 restacked on top by merges. ctest 19/19, sync checksum D7D43800, as before.

🤖 Generated with Claude Code

MortenLyhr and others added 11 commits November 20, 2026 13:39
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>
… OpenCiv4's own options on their own tab

The original keeps the player options in its player profile and sends them to the
active player at the start of every game, new or loaded (CvGame::sendPlayerOptions);
OpenCiv4 used the XML's defaults for a new game and the save's own after a load, and
never wrote them to profile.ini. Now Utility holds the profile's (profile.ini player.N),
a choice sent from the options screen goes into it and is written at once.

The options screen's check boxes get the theme's GFC_Control_StandardCheckBox_Style, as
the custom game screen's; W A S D, idle turns and edge scrolling move to an OpenCiv4 tab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rges cleanly with bssth#85)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ly with bssth#85)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…abs, GFC's box layout

Measured on the original's options screen (Wine, BUG + BULL): the standard window's title bar
with the title at the left, tabs as wide as their words from the left (the theme's tab skins,
the chosen one lighter, a baseline under them), 31 px rows (GFC's default control height),
16 px text, a box's children as wide as they need with the rest to those that expand (the
two columns of player options) or to the spacers (Language at the panel's foot), Restore
Defaults and Exit centred under the panel. Empty panels take no room. CyGTabCtrl's
setActiveTab/getActiveTab work, so a script can open a tab.

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

Before the player options were kept as choices, the options screen wrote
every player option it had shown, and it showed those the profile did not
have as off. Such a profile has Wait at End of Turn off (and advisor
pop-ups, Sid's tips) though the player never chose it; with Wait at End of
Turn off the game core ends each turn by itself once a unit has moved, so
turns seemed to end on their own.

The profile now has a version (2). One without it gets, once, the XML's
default for the options that are on by default and off there; every other
choice stays, and from then on off is the player's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ic folder

- Sliders are the theme's (GFC_Control_StandardSlider_Style): track, the light blue fill on
  the side the control flag names (CF_SLIDER_FILL_DOWN / _UP), and the grip, which follows
  the mouse while held (NOTIFY_SLIDER_NEWSTOP to the script at each new stop). They were a
  stack of little check boxes. No click sound, as the original's.
- Audio Speakers lists the original's 15 setups; the choice is kept, Mono plays both sides
  the same.
- Custom Music Folder: Browse opens the system's folder dialog; ticked, the folder's MP3 and
  WAV files play instead of the era's soundtrack, at once.
- Voice chat (the original's GameSpy voice) is shown with the system's devices but disabled,
  with a tool tip saying OpenCiv4 does not implement it.
- The path box gets the row's width as the original's; an edit box's text is kept inside it.
- --keys "<x,y:x2,y2>" drags with the left button (for scripted checks).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… network greyed

Measured in the original (Wine, BUG Mod) and made the same:
- Profiles: one file each, Profiles/<name>.ini beside profile.ini (the original's
  Profiles\<name>.pfl), the loaded one named by profile.ini's UserProfile (CivilizationIV.ini's).
  The drop-down loads one (its options to the sounds, graphics, player options, minimap toggles
  and clock), Create New Profile writes the options under the typed name and loads it, Delete
  Profile deletes a file (the loaded one: the first is loaded; the last is kept). profile.ini
  keeps OpenCiv4's own options, the same whichever is loaded; an older profile.ini becomes the
  profile "openciv4".
- Clock: setClockOn marks the clock just turned on (BUG's NJAGC starts over); getClockText in
  the user's own short time format (CoreFoundation, as the original takes Windows'), in 24
  hours with 24 Hour Clock, with a * while the alarm is set.
- Alarm: toggleAlarm sets it hours and minutes from this minute with the "Alarm will go off
  at 7:06 AM." popup; the getters as the original's (time left in the boxes, -1 when off); at
  that minute AS2D_ALARM and the "RIIIIIIIIING!" popup.
- Broadband / Modem: greyed, with a tooltip saying why (no multiplayer); clicks do nothing.
  CyGTabCtrl.setEnabled works.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original asks for a restart after Single Unit Graphics, Full-screen,
Graphics Level, High Detail Terrain and Restore Defaults; here every
option takes effect at once, so the restart popup is gone.

- Graphics Level is the original's preset (measured in Wine): Low/Medium/
  High switch the other options and qualities as the original does.
- No Enemy Glow: enemies in the active team's land get the selection ring
  in the original's red (no dots) unless the option is on.
- Show City Radius: the original's hatched area border style.
- Globe View Buildings Disabled: no city models in the globe view.
- Low Resolution Textures: textures from their half size level (the
  samplers' lowest level), at once.
- Anti-Aliasing: real MSAA 2/4/8 on the main target, resolved per pass.
- Movie Quality Low: no map drawn behind a playing movie.
- Opening Menu: the temporary menu shows the chosen menu's loading picture
  and plays its music.
- Render Quality, Globe Quality and High Detail Terrain are greyed out with
  a tool tip (no visible effect in the original either).
- The options' defaults are read again (getGraphicOptionsInfoByIndex: the
  old name did not exist, so every default read as off).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nstead of 1 s

The original has no such option (its Quick Moves speeds up only the
player's own units). With it on, the turn worker waits 150 ms between the
other civilizations' updates while one of their moves is shown, instead of
the original's 250 ms: a move every 0.6 s, the camera still on each. Off by
default, on the options' OpenCiv4 tab, kept in profile.ini as
quickEnemyMoves. The game is unchanged (checksums equal).

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

bssth commented Nov 23, 2026

Copy link
Copy Markdown
Owner
  1. Sounds.cpp:47,54: the music folder is UTF-8, but std::filesystem::path(std::string) reads it in the ANSI code page on MSVC. A non-ASCII folder silently plays nothing, and a file like 東京.mp3 makes e.path().string() throw, so the game crashes on every start, since the folder comes back from profile.ini. Use u8path or wide paths.
  2. oc4options.py:699,830: str(u'…') raises on non-ASCII profile names and paths, and the error is only printed. Encode as UTF-8.
  3. main.cpp:880,892: if the Documents folder isn't found, autosaves go to a path relative to the working directory, and autoSavesBeyond deletes AutoSave_* files there. Return early on an empty path.
  4. engine.autoSave is written from the options screen's Python and read on the game thread without a lock.
  5. Optional: README:213 is outdated (player.N= now goes to the per-profile file), profile files are written in place (a crash truncates them), turn % 25 only keeps every 25th turn when the interval divides it, and AutoSaves.h has a dated history comment.

MortenLyhr and others added 4 commits November 23, 2026 09:14
No tech splash (NoTechSplash), no event messages on the screen (NoEventMessages),
autosave every N turns and keep M (AutoSaveInterval 4, MaxAutoSaves 5) or OpenCiv4's
own autosaves, field of view (FIELD_OF_VIEW, 0: GlobalDefines.xml's), a frame cap
(SetMaxFrameRate). Kept in profile.ini; number boxes take digits only and are kept as
typed.

The autosaves as seen in the original under Wine (AutoSaveInterval 2, MaxAutoSaves 3,
Saves\single\auto listed at the start of each of 16 turns): AutoSave_Initial_<year> at
the game's start, then a save every interval's turn named AutoSave_<year>
(AutoSave_BC-3920); when one more than the number kept is written, the oldest
AutoSave_<year> goes in the same turn; the initial save is not counted and never
deleted. Only BC years were seen, so an AD year's name is our guess. The rule is in
AutoSaves.h, with a test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fore)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…reens have none)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rt getGameTurnYear)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MortenLyhr and others added 15 commits November 23, 2026 09:15
- Quick enemy moves (bssth#137) also speeds the others' walk from bssth#127 to 0.5 s, so each walk ends
  before the next shown move.
- oc4options.py: profile.ini keeps every OpenCiv4 option (bssth#120's ini settings and bssth#137's
  quickEnemyMoves in _GLOBAL); greyed controls use the node's 'disabled' (bssth#132) where bssth#118 had
  'enabled'; _GREY defined once.
- minimap_toggles_test.py: reads the loaded profile's own file (bssth#118's Profiles/<name>.ini) as well.
- player_options_test.py: the OpenCiv4 tab's options as the bundle has them (bssth#113's single-click city and bssth#130's keep-the-attacker checkboxes in the list).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BUG's options tabs (City Screen, Advisors) ran past the bottom of their window: the tab
control's scroll panel (attachScrollPanel) was laid out as high as what it held. It now
takes the height its window leaves it, as the original's, and its controls go into a
scroll panel there: clipped to it, scrolled by the wheel and the scroll bar on its right,
which shows only when they are longer (measured in Wine: the bar over the tan panel's
right edge, the panel as wide as without it). How far it is scrolled is kept when the
screen is laid out again after a click.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…no longer clips what follows

The Audio tab's volume sliders lie in a scroll panel inside the tab's: one inside another is
as high as what it holds. An edit box in a clipped panel pushed its clip twice and took one
off, so everything drawn after it was cut to the edit box (the Options screen's Other tab
showed its clock column only, the Audio tab lost Restore Defaults and Exit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The folder comes from profile.ini as UTF-8, but path(std::string) reads it in the
system's code page on Windows: a folder named in what that page can't hold played
nothing, and a file such as 東京.mp3 made path::string() throw. The folder now goes
through pathFromUtf8, the files' paths come back through utf8Path.

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

Python 2's str(u'...') raised on a profile name or a music folder that isn't ASCII
(the error only printed). They are kept as UTF-8 now, and the files are opened by
their unicode names (Windows' wide calls, not the code page). A profile file and
profile.ini are written beside themselves first and then moved over the old one, so
a crash while writing leaves the old file. Tested with such a name and folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k; one in 25 turns kept

- No Documents folder found: no autosave. Before, the path was relative to the
  working directory, and autoSavesBeyond deleted the AutoSave_ files there.
- The settings are set by the options' script and read on the game's thread: now
  through SharedAutoSaveSettings, behind a mutex.
- OpenCiv4's own autosaves kept the turn-25 save only when the interval divided 25;
  now the first save in each 25 turns is kept (openciv4KeepsForGood, tested).
- AutoSaves.h's comment without the date.

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

Copy link
Copy Markdown
Contributor Author

Thanks for the review. #148 is rebased on master (bundles 1–3 and the merged standalone PRs are gone from its diff), and each item is fixed:

  1. Music folder as UTF-8 (0b633f17). The folder goes through a new pathFromUtf8 (std::u8string → path), and the files' paths come back through utf8Path, both in the scan and when a track is opened. A non-ASCII folder or 東京.mp3 no longer goes through the ANSI code page.
  2. Profile names and paths (0a37f3f8). str(u'…') is replaced by _utf8(), so the profile keeps UTF-8. The files are opened by their unicode names, so Windows uses the wide calls. Tested with a profile 東京 and a music folder under a non-ASCII folder, in Python 3 (ctest) and by hand in Python 2.7.
  3. No Documents folder (651df8be). The autosave returns early with a message instead of using a relative path, so autoSavesBeyond never runs in the working directory.
  4. engine.autoSave lock (651df8be). It is now a SharedAutoSaveSettings (AutoSaves.h): the options' script calls set() and the game thread calls get(), both behind a mutex.
  5. Optional items, all done:
    • README: the player options are written to the profile's own file (b7aede14).
    • Profile files and profile.ini are written to a file beside them, then moved over the old one, so a crash leaves the old file (0a37f3f8).
    • OpenCiv4's own autosaves keep the first save in each 25 turns, whatever the interval (openciv4KeepsForGood, with tests) (651df8be).
    • AutoSaves.h and the other comments no longer carry dates (651df8be, c1567173).

Clean room: #120's autosave rule was first written from the exe's strings. It was later checked in the running game under Wine, so the code didn't change. Since #148 carries #120's commits, I rewrote that history too: the commits that wrote the rule are now one commit, and its message gives only the Wine run as the source.

Checked on macOS: ctest 20/20, and the 100-turn checksum is D7D43800 as before.

🤖 Generated with Claude Code

…de page

On Windows, Python 3's text-mode open() uses cp1252, so writing a profile named 東京
raised UnicodeEncodeError (windows-x64 CI, options_other). The files are now opened in
binary mode with the text encoded as UTF-8, and read back the same way, under the
game's Python 2.7 and the tests' Python 3 alike.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants