Repository navigation
Add Codex popup UI (phase 2) - #1040
Billytifft wants to merge 7 commits into
Conversation
Add a Civilopedia popup opened from the top-left nav button: section list
with index, icon/stats panel, and a markdown article with Body/Description
paging. Convert Civ3 [..]/{..} markup to italics/bold (whole-line braces
become headings), look up Codex entries case-insensitively, and keep
leading body lines that lack a caret. Add civilopediaEntry keys for units,
buildings, and civilizations to the ruleset, with tests for the parser and
the ruleset keys.
|
BTW we do want to support importing any graphics we need, but that doesn't mean we have to use all the graphics. If you look in the files you'll see there are several variants of this background with different internal sections in the main content area, corresponding to different types/formats of articles (eg. look at a unit vs government vs civ). I wouldn't say we necessarily need to use all of those in the same cases if as long as we have a background that works for us. Which is just to say, we don't need to go as far as copying the exact section breakdown within the articles, just keep it in that main area. |
Align the popup to the measured regions of civilopediaBackground.pcx and load full-size Civilopedia icons from PediaIcons.txt instead of the small in-game art: - PediaIcons now exposes the large civilopedia icon for buildings, resources, and techs, threaded through GameData/SaveGame, with a lazy fallback. - Codex icons use the pedia art where available, falling back to the TextureLoader crops; add a default placeholder and a black backdrop for circular leader heads. - Lay the popup out on the art's regions (title cut-out, body column, side column, close area) instead of generic margins.
|
Yeah, exactly. That background should be fine at least for a first pass. That UI looks good to me but I'll let others weigh in. I haven't had a chance to look at any code yet. |
|
I haven't looked at the code, but I want to weigh in on the visuals. I don't mind having a completely new redesigned UI for the civilopedia (or anything really) for the standalone mode, but I would like us to keep the old look for the one that we use the old graphics for, even if it's super hard to navigate, old fashioned, etc. For me it's part of the appeal/nostalgia. We could add to it, like the search bar for example that I see here, keep it in the original style, but not do it half way like this, and half way like that. That's my take.. |
|
Im good with faithfully reproducing the Civilopedia design for the civ3 graphics, but I think we can expand on it. I can also do the faithful reproduction for when using civ3 graphics, and then a different/better design when using the standalone graphics (similar to the my first try on this PR). |
|
I'm not a huge fan of the original's UI, but I agree that it would be nice if we can support the old shapes, as all kinds of mods may have worked with those texture sets. I think we want different "modes" for engaging with the pedia (and a switch in the INI/Lua/settings):
I'd once again split out the efforts a bit. There are generally useful bits in this PR, needed for every mode, and we should try and get those in first. If the new, proposed UI goes into its own branch, we can continue designing the modern version independently of the Classic one (and Classic+). So, how about pushing all the new UI bits out of this PR into something new? Or, alternatively, a new PR with all the non-UI parts from this one? |
- Rebuild the popup from the Civ3 pedia art: title bar, history arrows, colored name bar, description toggle, A-Z index, and section menu. - Use PediaIcons large and small icons with the classic section order. - Add a standalone fallback panel at the Civ3 pedia screen's rect. - Make icon lookups case-insensitive and tolerate PediaIcons blocks without an era row number. - Enable the Civilopedia toolbar button.
Escape was closed locally by the popup before Game.ProcessAction ran, so the same key press fell through to the quit handling. Let the central popup check close it instead.
|
Looks great, works great! Using the general background texture as the overall body works wonderfully. Ideally, we'd have placeholder texture assets in the Assets repo for all the codex/pedia assets fro standalone, but a flat box texture and just not drawing the embellishments works fine. One thing I would change is to push all the If you look at the other entries in var backButton = MakeArrowButton(BackSheet, 37, 69, 101, 1, 15, 24, new Vector2(BackLeft, ArrowTop), "Back", GoBack);You can have in textures.codex = {
back_button = {
normal = {
path = CODEX .. "fwdBackarrows.pcx",
crop_region = { 0, 37, 15, 24 },
},
hover = {
path = CODEX .. "fwdBackarrows.pcx",
crop_region = { 0, 69, 15, 24 },
},
pressed = {
path = CODEX .. "fwdBackarrows.pcx",
crop_region = { 0, 85, 15, 24 },
},
},
}And then all you need in the TextureLoader.SetButtonTextures(backButton, "codex.back_button");This makes life easier for whoever wants to have a go at replacing the Codex textures with custom |
Use textures.codex for the background, name bars, icons, and buttons. Define button sprite crops with crop_region so custom texture sets can replace the Civ3 art without editing C#.





Phase 2 of the Codex feature (#997): a working in-game Civilopedia popup backed by the phase-1 data parser. UI/data only — no navigation, search, or content pipeline yet (see "Deferred"). Opening as a draft to get early feedback on the tab-alignment approach (see "Outstanding").
Screenshots
What's included
Popup UI (
C7/UIElements/Codex/CodexPopup.cs)ui.exitclose button; closes on the button and onEsc.automatic_links=false) with a plainRichTextLabelfallback; body font size pinned to 13 across all RichTextLabel style keys.Catalog (
C7/UIElements/Codex/CodexCatalog.cs)TextureLoader.Load(failures fall back to no icon).gameData.Codex; alphabetical except Game Concepts (authored order).Parser/data fixes (
C7Engine/C7GameData/Codex.cs)Entrieslookup (fixesPRTO_NUKEvsPRTO_Nuke).contentStartedguard so entries whose first line lacks a^still parse (e.g. Apollo Project).[..]-> italics,{..}-> bold, a whole-line{Title}(no tabs) ->## heading;$LINK->[label](key:target).Ruleset + wiring
C7/Lua/civ3/ruleset.json:civilopediaEntryadded to 124 units, 82 buildings, 32 civilizations (from the BIQ).C7/Game.cs: load Civilopedia text when the Codex is empty (native JSON rulesets don't carry it).C7/UIElements/UpperLeftNav/CivilopediaButton.cs+C7/C7Game.tscn: open the popup viaPopupOverlay.GameData.cs:Civilizationsread-only accessor (GameData.cs:57).Testing
dotnet build C7/C7.sln— 0 errors.dotnet format C7/C7.sln whitespace --verify-no-changes— clean.dotnet testwithCIV3_HOMEset — 171 passed / 2 failed (both pre-existing, see below).BaseRulesetPediaKeysTest(all units/buildings/civs have non-emptyPRTO_/BLDG_/RACE_keys) and CodexTest additions covering italics/bold/heading conversion, case-insensitive lookup, body/desc merge, and caret-less leading lines.Outstanding / known issues
TabSize = 5(CodexPopup.cs:252) as the best fit across all 49 tab tables for the current font — but it's a heuristic, some rows remain ragged, and the correct value changes with the font.ruleset.jsonhas a large generated diff (+238 lines). It may be better generated from the BIQ at build time rather than committed. Needs a maintainer call.GameDataTest.SeedInGameData_JSONandUnitPrototypeConquestsTest.UnitAvailability_JSON(a Dropbox-hosted save fails$.buildings[6].flags[1]->SaveBuilding+Flagconversion).Deferred (later phases)
automatic_links=false).