Skip to content

Add "civ styles" GUI - #1603

Open
Snowstar38 wants to merge 2 commits into
DFHack:masterfrom
Snowstar38:civ-styles
Open

Snowstar38 wants to merge 2 commits into
DFHack:masterfrom
Snowstar38:civ-styles

Conversation

@Snowstar38

@Snowstar38 Snowstar38 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Adds gui/civ-styles, letting people edit the item styles a civilization knows how to make.

"add-recipe" can only add; there's no way to see what your civ already knows or remove any styles. This lists every style per category, marks which ones came from the civ's raws [helpful for modded civs/races], and lets you take styles away as well as grant them.

It also flags duplicate styles and can clear them (in case add-recipe was accidentally called 2x, lets users fix duplicate entries in menus). There are toggles to show known, unknown, etc.

Covers: armor, helms, gloves, shoes, pants, shields, weapons, diggers, training weapons, ammo, siege ammo, trap components, tools, toys, and instruments.

20260812211703_1

@chdoc

chdoc commented Aug 21, 2026

Copy link
Copy Markdown
Member

First of, thank you for contributing, this is a significant piece of work. At first glance, this looks to be in reasonably good shape. But the devil is usually in the detail. I'm still expecting this to require multiple rounds of code review before it can get merged. Given our currently limited reviewing capacity, this may take weeks or even months.

Please indicate the level of AI-support that was used in the development of this tool (if any) and your willingness to iterate on this for several weeks? I would like to avoid spending hours on an in-depth code review, just for another pull request to get abandoned.

@chdoc chdoc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are some general remarks for the first round. I will do a more in-depth review once these are taken care of.

Comment thread docs/gui/civ-styles.rst Outdated
@@ -0,0 +1,30 @@
gui/civ-styles

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why call is tool civ-styles? the concept is already known as recipes. I would think the tool would be better named gui/recipes.

Comment thread docs/gui/civ-styles.rst Outdated
Comment on lines +21 to +23
it did not, ``gen`` for procedurally generated items, and ``xN`` if the style is
listed more than once, which repeated `add-recipe` runs will do.
:kbd:`Ctrl`:kbd:`D` removes duplicates.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of fixing this behavior after the fact, please file a bug report against add-recipe.

Comment thread gui/civ-styles.lua Outdated
Comment on lines +46 to +47
local civ_id = df.global.plotinfo.civ_id
if not civ_id or civ_id < 0 then return nil end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

civ_id is an integer that is always defined when plotinfo is defined (basically always). So it is fine to directly call find with it.

Comment thread gui/civ-styles.lua Outdated
local cat = self.by_key[cat_key]
local vec = cat and self:get_vec(cat)
if not vec then return end
if count_in(vec, subtype) == 0 then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all you need is a membership test, please use utils.linear_index(vector,key[,field]) and remove count_in.

@Snowstar38

Copy link
Copy Markdown
Contributor Author

Thanks for looking at it - sorry, I've had a lot going on and missed the notification email for this.

The tool was written with AI assistance. The design is mine, I wanted to see and remove civ style types, not just add them, since add-recipe only appends and doesn't show what your civ already knows. An AI agent implemented it, and we tested it in-game against a new and old world. I reviewed it before submitting.

On iterating: yes, I'm definitely willing to. Will be getting time this week to be able to rename it and polish anything that needs it.

Snowstar38 added a commit to Snowstar38/scripts that referenced this pull request Oct 21, 2026
Review feedback from chdoc on DFHack#1603:

- Rename the tool to gui/recipes, since "recipes" is the established name
  for the concept (add-recipe). Renames the script, the docs file, the
  changelog entry, the classes and the focus path, and switches the
  user-facing strings from "style" to "recipe".
- get_civ(): plotinfo.civ_id is always a defined integer, so call
  df.historical_entity.find with it directly.
- Use utils.linear_index for the membership test in Recipes:add and
  remove count_in.

Also narrows one docs claim: duplicate entries come from
"add-recipe single", which inserts without a duplicate check; the
"all"/"exotic" path already guards with checkKnown.
Review feedback from chdoc on DFHack#1603:

- Rename the tool to gui/recipes, since "recipes" is the established name
  for the concept (add-recipe). Renames the script, the docs file, the
  changelog entry, the classes and the focus path, and switches the
  user-facing strings from "style" to "recipe".
- get_civ(): plotinfo.civ_id is always a defined integer, so call
  df.historical_entity.find with it directly.
- Use utils.linear_index for the membership test in Recipes:add and
  remove count_in.

Also narrows one docs claim: duplicate entries come from
"add-recipe single", which inserts without a duplicate check; the
"all"/"exotic" path already guards with checkKnown.
@Snowstar38

Copy link
Copy Markdown
Contributor Author

Thanks for the review. All four are done, but I did have a question about the last one.

  1. Renamed to gui/recipes. That covers the script, the docs file, the changelog entry, the classes and the focus path, and the user-facing strings now say "recipe" instead of "style".
  2. get_civ calls df.historical_entity.find(df.global.plotinfo.civ_id) directly.
  3. count_in is gone, replaced with utils.linear_index.
  4. Filed the duplicates bug as add-recipe single inserts a duplicate when the civ already knows the recipe dfhack#6022. It turned out to be specific to add-recipe single, which inserts without checking checkKnown. The all/native paths already guard.

On dropping the dedupe feature - I think it could make sense to leave it, though I'd like to hear your thoughts? After add-recipe is fixed, duplicates ideally won't happen anymore, but some people might end up with saves that do have them. If you think it's better off without I'll remove it tho

I loaded the renamed version in game and checked it: the window opens, categories populate, toggling works, and Ctrl-D correctly removed a duplicate I made on purpose with add-recipe single SHOES:ITEM_SHOES_BOOTS.

Also rebased onto current master, so the branch isn't 126 commits behind anymore.

Disclosure: I used AI assistance (Claude) for this round of changes and for the write-up in #6022. The testing above is mine.

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