tiger_lib/
item.rs

1//! Giant enum for all the [`Item`] types in the game.
2
3use std::fmt::{Display, Formatter};
4
5use strum_macros::{EnumIter, IntoStaticStr};
6
7use crate::block::Block;
8use crate::db::Db;
9#[cfg(doc)]
10use crate::everything::Everything;
11use crate::game::{Game, GameFlags};
12use crate::pdxfile::PdxEncoding;
13use crate::report::{Confidence, Severity};
14use crate::token::Token;
15
16/// "items" are all the things that can be looked up in the game databases.
17/// Anything that can be looked up in script with a literal string key, or that's loaded into
18/// tiger's database and needs a unique key, is an `Item`.
19///
20/// There is some overlap with scopes, for example "culture" is both an `Item` and a scope type,
21/// but the difference is that scopes are runtime values while items are always strings.
22///
23/// For example if a trigger takes a culture *scope*, you could supply either `culture:german` or
24/// `scope:target_culture`, while if a trigger takes a culture *item*, you would have to supply just
25/// `german` and don't have the option of supplying something determined at runtime.
26#[derive(Copy, Clone, Debug, PartialEq, Eq, IntoStaticStr, Hash, PartialOrd, Ord, EnumIter)]
27#[strum(serialize_all = "snake_case")]
28#[non_exhaustive]
29// The item table is in several alphabetized sections. First the generic items, then items used by
30// multiple games, then a section for each game.
31//
32// Each item is marked with a cfg clause for its game. This is not strictly necessary, but it helps
33// prevent "leakage" between the games, where they accidentally use each other's item types.
34#[rustfmt::skip] // having cfg and the variant on the same line is much more readable
35pub enum Item {
36    // Generic items used by all games and assumed to be there by the validators in
37    // non-game-specific `data` modules.
38    Accessory,
39    AccessoryTag,
40    AccessoryVariation,
41    AccessoryVariationLayout,
42    AccessoryVariationTextures,
43    Achievement,
44    AchievementGroup,
45    Asset,
46    BlendShape,
47    CharacterInteraction,
48    Coa,
49    CoaColorList,
50    CoaColoredEmblemList,
51    #[cfg(feature = "ck3")]
52    CoaDesignerColorPalette,
53    CoaDesignerColoredEmblem,
54    #[cfg(feature = "ck3")]
55    CoaDesignerEmblemLayout,
56    CoaDesignerPattern,
57    CoaPatternList,
58    CoaTemplate,
59    CoaTemplateList,
60    CoaTexturedEmblemList,
61    Culture,
62    CustomLocalization,
63    Decision,
64    Define,
65    Directory,
66    Dlc,
67    DlcFeature,
68    DlcName,
69    EffectLocalization,
70    Entity,
71    Entry,
72    Ethnicity,
73    Event,
74    EventNamespace,
75    File,
76    Font,
77    Fontfiles,
78    GameConcept,
79    GameRule,
80    GameRuleSetting,
81    GeneAgePreset,
82    GeneAttribute,
83    GeneCategory,
84    GovernmentType,
85    GuiLayer,
86    GuiTemplate,
87    GuiType,
88    LawGroup,
89    Localization,
90    MapEnvironment,
91    MapMode,
92    Modifier,
93    Music,
94    MusicPlayerCategory,
95    NamedColor,
96    OnAction,
97    Pdxmesh,
98    PortraitAnimation,
99    PortraitCamera,
100    PortraitEnvironment,
101    PortraitModifierGroup,
102    PortraitModifierPack,
103    Province,
104    Religion,
105    ScriptedEffect,
106    ScriptedGui,
107    ScriptedList,
108    ScriptedModifier,
109    ScriptedRule,
110    ScriptedTrigger,
111    ScriptValue,
112    Shortcut,
113    Sound,
114    Terrain,
115    TextFormat,
116    TextIcon,
117    TextureFile,
118    TriggerLocalization,
119    WidgetName,
120
121    // Items shared by more than one game
122    #[cfg(any(feature = "ck3", feature = "imperator"))]
123    Building,
124    #[cfg(any(feature = "ck3", feature = "vic3"))]
125    CharacterTemplate,
126    #[cfg(any(feature = "vic3", feature = "imperator"))]
127    CharacterTrait,
128    #[cfg(any(feature = "vic3", feature = "imperator"))]
129    Country,
130    #[cfg(any(feature = "ck3", feature = "imperator"))]
131    DeathReason,
132    #[cfg(any(feature = "ck3", feature = "vic3"))]
133    Dna,
134    #[cfg(any(feature = "ck3", feature = "imperator"))]
135    EventTheme,
136    #[cfg(any(feature = "ck3", feature = "imperator"))]
137    Law,
138    #[cfg(any(feature = "ck3", feature = "vic3"))]
139    Message,
140    #[cfg(any(feature = "vic3", feature = "imperator"))]
141    PopType,
142    #[cfg(any(feature = "ck3", feature = "imperator"))]
143    Region,
144    #[cfg(any(feature = "vic3", feature = "imperator"))]
145    SubjectType,
146    #[cfg(any(feature = "ck3", feature = "vic3"))]
147    TutorialLesson,
148    #[cfg(any(feature = "ck3", feature = "vic3"))]
149    TutorialLessonChain,
150    #[cfg(any(feature = "ck3", feature = "vic3"))]
151    TutorialLessonStep,
152    #[cfg(any(feature = "vic3", feature = "imperator"))]
153    Wargoal,
154
155    // Items for ck3
156    #[cfg(feature = "ck3")] AccoladeCategory,
157    #[cfg(feature = "ck3")] AccoladeIcon,
158    #[cfg(feature = "ck3")] AccoladeName,
159    #[cfg(feature = "ck3")] AccoladeParameter,
160    #[cfg(feature = "ck3")] AccoladeType,
161    #[cfg(feature = "ck3")] ActivityGroupType,
162    #[cfg(feature = "ck3")] ActivityIntent,
163    #[cfg(feature = "ck3")] ActivityLocale,
164    #[cfg(feature = "ck3")] ActivityOption,
165    #[cfg(feature = "ck3")] ActivityOptionCategory,
166    #[cfg(feature = "ck3")] ActivityPhase,
167    #[cfg(feature = "ck3")] ActivityPulseAction,
168    #[cfg(feature = "ck3")] ActivityState,
169    #[cfg(feature = "ck3")] ActivityType,
170    #[cfg(feature = "ck3")] AiWarStance,
171    #[cfg(feature = "ck3")] AgentType,
172    #[cfg(feature = "ck3")] Amenity,
173    #[cfg(feature = "ck3")] AmenitySetting,
174    #[cfg(feature = "ck3")] ArtifactBlueprint,
175    #[cfg(feature = "ck3")] ArtifactFeature,
176    #[cfg(feature = "ck3")] ArtifactFeatureGroup,
177    #[cfg(feature = "ck3")] ArtifactHistory,
178    #[cfg(feature = "ck3")] ArtifactRarity,
179    #[cfg(feature = "ck3")] ArtifactSlot,
180    #[cfg(feature = "ck3")] ArtifactSlotType,
181    #[cfg(feature = "ck3")] ArtifactTemplate,
182    #[cfg(feature = "ck3")] ArtifactType,
183    #[cfg(feature = "ck3")] ArtifactVisual,
184    #[cfg(feature = "ck3")] Bookmark,
185    #[cfg(feature = "ck3")] BookmarkGroup,
186    #[cfg(feature = "ck3")] BookmarkPortrait,
187    #[cfg(feature = "ck3")] BuildingFlag,
188    #[cfg(feature = "ck3")] BuildingGfx,
189    #[cfg(feature = "ck3")] CasusBelli,
190    #[cfg(feature = "ck3")] CasusBelliGroup,
191    #[cfg(feature = "ck3")] Catalyst,
192    #[cfg(feature = "ck3")] ChallengeCharacter,
193    #[cfg(feature = "ck3")] Character,
194    #[cfg(feature = "ck3")] CharacterBackground,
195    #[cfg(feature = "ck3")] CharacterInteractionCategory,
196    #[cfg(feature = "ck3")] Climate,
197    #[cfg(feature = "ck3")] ClothingGfx,
198    #[cfg(feature = "ck3")] CoaGfx,
199    #[cfg(feature = "ck3")] CoaDynamicDefinition,
200    #[cfg(feature = "ck3")] CombatEffect,
201    #[cfg(feature = "ck3")] CombatPhaseEvent,
202    #[cfg(feature = "ck3")] CouncilPosition,
203    #[cfg(feature = "ck3")] CouncilTask,
204    #[cfg(feature = "ck3")] Countermeasure,
205    #[cfg(feature = "ck3")] CountermeasureParameter,
206    #[cfg(feature = "ck3")] CourtPosition,
207    #[cfg(feature = "ck3")] CourtPositionTask,
208    #[cfg(feature = "ck3")] CourtSceneCulture,
209    #[cfg(feature = "ck3")] CourtSceneGroup,
210    #[cfg(feature = "ck3")] CourtSceneRole,
211    #[cfg(feature = "ck3")] CourtSceneSetting,
212    #[cfg(feature = "ck3")] CourtType,
213    #[cfg(feature = "ck3")] CourtierGuestManagement,
214    #[cfg(feature = "ck3")] CultureAesthetic,
215    #[cfg(feature = "ck3")] CultureCreationName,
216    #[cfg(feature = "ck3")] CultureEra,
217    #[cfg(feature = "ck3")] CultureEthos,
218    #[cfg(feature = "ck3")] CultureHeritage,
219    #[cfg(feature = "ck3")] CultureHistory,
220    #[cfg(feature = "ck3")] CultureParameter,
221    #[cfg(feature = "ck3")] CulturePillar,
222    #[cfg(feature = "ck3")] CultureTradition,
223    #[cfg(feature = "ck3")] CultureTraditionCategory,
224    #[cfg(feature = "ck3")] DangerType,
225    #[cfg(feature = "ck3")] DecisionGroup,
226    #[cfg(feature = "ck3")] DiarchyMandate,
227    #[cfg(feature = "ck3")] DiarchyParameter,
228    #[cfg(feature = "ck3")] DiarchyType,
229    #[cfg(feature = "ck3")] Doctrine,
230    #[cfg(feature = "ck3")] DoctrineCategory,
231    #[cfg(feature = "ck3")] DoctrineParameter,
232    #[cfg(feature = "ck3")] DomicileBuilding,
233    #[cfg(feature = "ck3")] DomicileParameter,
234    #[cfg(feature = "ck3")] DomicileType,
235    #[cfg(feature = "ck3")] Dynasty,
236    #[cfg(feature = "ck3")] DynastyLegacy,
237    #[cfg(feature = "ck3")] DynastyPerk,
238    #[cfg(feature = "ck3")] EpidemicType,
239    #[cfg(feature = "ck3")] EpidemicDeathReason,
240    #[cfg(feature = "ck3")] EventBackground,
241    #[cfg(feature = "ck3")] EventEffect2d,
242    #[cfg(feature = "ck3")] EventTransition,
243    #[cfg(feature = "ck3")] Faction,
244    #[cfg(feature = "ck3")] Faith,
245    #[cfg(feature = "ck3")] FaithIcon,
246    #[cfg(feature = "ck3")] FervorModifier,
247    #[cfg(feature = "ck3")] Flavorization,
248    #[cfg(feature = "ck3")] Focus,
249    #[cfg(feature = "ck3")] GeneticConstraint,
250    #[cfg(feature = "ck3")] GovernmentFlag,
251    #[cfg(feature = "ck3")] GraphicalFaith,
252    #[cfg(feature = "ck3")] GuestInviteRule,
253    #[cfg(feature = "ck3")] GuestSubset,
254    #[cfg(feature = "ck3")] GuestSystem,
255    #[cfg(feature = "ck3")] HoldingFlag,
256    #[cfg(feature = "ck3")] HoldingType,
257    #[cfg(feature = "ck3")] HolySite,
258    #[cfg(feature = "ck3")] HolySiteFlag,
259    #[cfg(feature = "ck3")] Hook,
260    #[cfg(feature = "ck3")] House,
261    #[cfg(feature = "ck3")] HousePowerBonus,
262    #[cfg(feature = "ck3")] HouseUnity,
263    #[cfg(feature = "ck3")] HouseUnityParameter,
264    #[cfg(feature = "ck3")] HouseUnityStage,
265    #[cfg(feature = "ck3")] ImportantAction,
266    #[cfg(feature = "ck3")] Innovation,
267    #[cfg(feature = "ck3")] InnovationFlag,
268    #[cfg(feature = "ck3")] Inspiration,
269    #[cfg(feature = "ck3")] Language,
270    #[cfg(feature = "ck3")] LawFlag,
271    #[cfg(feature = "ck3")] LeaseContract,
272    #[cfg(feature = "ck3")] LegendChapter,
273    #[cfg(feature = "ck3")] LegendChronicle,
274    #[cfg(feature = "ck3")] LegendProperty,
275    #[cfg(feature = "ck3")] LegendSeed,
276    #[cfg(feature = "ck3")] LegendType,
277    #[cfg(feature = "ck3")] LegitimacyFlag,
278    #[cfg(feature = "ck3")] LegitimacyType,
279    #[cfg(feature = "ck3")] Lifestyle,
280    #[cfg(feature = "ck3")] MartialCustom,
281    #[cfg(feature = "ck3")] MemoryCategory,
282    #[cfg(feature = "ck3")] MemoryType,
283    #[cfg(feature = "ck3")] MenAtArms,
284    #[cfg(feature = "ck3")] MenAtArmsBase,
285    #[cfg(feature = "ck3")] MessageFilterType,
286    #[cfg(feature = "ck3")] MessageGroupType,
287    #[cfg(feature = "ck3")] ModifierFormat,
288    #[cfg(feature = "ck3")] MottoInsert,
289    #[cfg(feature = "ck3")] Motto,
290    #[cfg(feature = "ck3")] NameEquivalency,
291    #[cfg(feature = "ck3")] NameList,
292    #[cfg(feature = "ck3")] Nickname,
293    #[cfg(feature = "ck3")] OpinionModifier,
294    #[cfg(feature = "ck3")] Perk,
295    #[cfg(feature = "ck3")] PerkTree,
296    #[cfg(feature = "ck3")] PlayableDifficultyInfo,
297    #[cfg(feature = "ck3")] PointOfInterest,
298    #[cfg(feature = "ck3")] PoolSelector,
299    #[cfg(feature = "ck3")] PortraitType,
300    #[cfg(feature = "ck3")] PrisonType,
301    #[cfg(feature = "ck3")] ProvinceMapping,
302    #[cfg(feature = "ck3")] Relation,
303    #[cfg(feature = "ck3")] RelationFlag,
304    #[cfg(feature = "ck3")] ReligionFamily,
305    #[cfg(feature = "ck3")] RewardItem,
306    #[cfg(feature = "ck3")] Scheme,
307    #[cfg(feature = "ck3")] SchemePulseAction,
308    #[cfg(feature = "ck3")] ScriptedAnimation,
309    #[cfg(feature = "ck3")] ScriptedCost,
310    #[cfg(feature = "ck3")] ScriptedIllustration,
311    #[cfg(feature = "ck3")] Secret,
312    #[cfg(feature = "ck3")] Sexuality,
313    #[cfg(feature = "ck3")] Skill,
314    #[cfg(feature = "ck3")] SpecialBuilding,
315    #[cfg(feature = "ck3")] SpecialGuest,
316    #[cfg(feature = "ck3")] Story,
317    #[cfg(feature = "ck3")] Struggle,
318    #[cfg(feature = "ck3")] StruggleHistory,
319    #[cfg(feature = "ck3")] StrugglePhase,
320    #[cfg(feature = "ck3")] StrugglePhaseParameter,
321    #[cfg(feature = "ck3")] SuccessionAppointment,
322    #[cfg(feature = "ck3")] SuccessionElection,
323    #[cfg(feature = "ck3")] Suggestion,
324    #[cfg(feature = "ck3")] TaskContractGroup,
325    #[cfg(feature = "ck3")] TaskContractReward,
326    #[cfg(feature = "ck3")] TaskContractType,
327    #[cfg(feature = "ck3")] TaxSlotFlag,
328    #[cfg(feature = "ck3")] TaxSlotObligation,
329    #[cfg(feature = "ck3")] TaxSlotType,
330    #[cfg(feature = "ck3")] Title,
331    #[cfg(feature = "ck3")] TitleHistory,
332    #[cfg(feature = "ck3")] TitleHistoryType,
333    #[cfg(feature = "ck3")] Trait,
334    #[cfg(feature = "ck3")] TraitCategory,
335    #[cfg(feature = "ck3")] TraitFlag,
336    #[cfg(feature = "ck3")] TraitPortraitModifier,
337    #[cfg(feature = "ck3")] TraitTrack,
338    #[cfg(feature = "ck3")] TravelOption,
339    #[cfg(feature = "ck3")] UnitGfx,
340    #[cfg(feature = "ck3")] VassalContract,
341    #[cfg(feature = "ck3")] VassalContractFlag,
342    #[cfg(feature = "ck3")] VassalObligationLevel,
343    #[cfg(feature = "ck3")] VassalStance,
344
345    // Items specific to vic3
346    #[cfg(feature = "vic3")] AcceptanceStatus,
347    #[cfg(feature = "vic3")] AiStrategy,
348    #[cfg(feature = "vic3")] Alert,
349    #[cfg(feature = "vic3")] AlertGroup,
350    #[cfg(feature = "vic3")] Approval,
351    #[cfg(feature = "vic3")] Attitude,
352    #[cfg(feature = "vic3")] BattleCondition,
353    #[cfg(feature = "vic3")] BuildingGroup,
354    #[cfg(feature = "vic3")] BuildingType,
355    #[cfg(feature = "vic3")] BuyPackage,
356    #[cfg(feature = "vic3")] CanalType,
357    #[cfg(feature = "vic3")] CharacterRole,
358    #[cfg(feature = "vic3")] CombatUnit,
359    #[cfg(feature = "vic3")] CombatUnitExperienceLevel,
360    #[cfg(feature = "vic3")] CombatUnitGroup,
361    #[cfg(feature = "vic3")] CommanderOrder,
362    #[cfg(feature = "vic3")] CommanderRank,
363    #[cfg(feature = "vic3")] CompanyType,
364    #[cfg(feature = "vic3")] CohesionLevel,
365    #[cfg(feature = "vic3")] CountryCreation,
366    #[cfg(feature = "vic3")] CountryFormation,
367    #[cfg(feature = "vic3")] CountryRank,
368    #[cfg(feature = "vic3")] CountryTier,
369    #[cfg(feature = "vic3")] CountryType,
370    #[cfg(feature = "vic3")] CultureGraphics,
371    #[cfg(feature = "vic3")] Decree,
372    #[cfg(feature = "vic3")] DiplomaticAction,
373    #[cfg(feature = "vic3")] DiplomaticCatalyst,
374    #[cfg(feature = "vic3")] DiplomaticCatalystCategory,
375    #[cfg(feature = "vic3")] DiplomaticPlay,
376    #[cfg(feature = "vic3")] DiscriminationTrait,
377    #[cfg(feature = "vic3")] DynamicCompanyName,
378    #[cfg(feature = "vic3")] DynamicCountryMapColor,
379    #[cfg(feature = "vic3")] DynamicCountryName,
380    #[cfg(feature = "vic3")] EventCategory,
381    #[cfg(feature = "vic3")] FlagDefinition,
382    #[cfg(feature = "vic3")] Goods,
383    #[cfg(feature = "vic3")] GradientBorderSettings,
384    #[cfg(feature = "vic3")] HarvestConditionType,
385    #[cfg(feature = "vic3")] Ideology,
386    #[cfg(feature = "vic3")] InfamyThreshold,
387    #[cfg(feature = "vic3")] Institution,
388    #[cfg(feature = "vic3")] InterestGroup,
389    #[cfg(feature = "vic3")] InterestGroupTrait,
390    #[cfg(feature = "vic3")] JournalEntry,
391    #[cfg(feature = "vic3")] JournalEntryGroup,
392    #[cfg(feature = "vic3")] LawType,
393    #[cfg(feature = "vic3")] LegitimacyLevel,
394    #[cfg(feature = "vic3")] Level,
395    #[cfg(feature = "vic3")] LibertyDesireLevel,
396    #[cfg(feature = "vic3")] MapLayer,
397    #[cfg(feature = "vic3")] MapInteractionType,
398    #[cfg(feature = "vic3")] MapNotificationType,
399    #[cfg(feature = "vic3")] MediaAlias,
400    #[cfg(feature = "vic3")] MilitaryFormationFlag,
401    #[cfg(feature = "vic3")] MobilizationOption,
402    #[cfg(feature = "vic3")] MobilizationOptionGroup,
403    #[cfg(feature = "vic3")] ModifierTypeDefinition,
404    #[cfg(feature = "vic3")] Objective,
405    #[cfg(feature = "vic3")] ObjectiveSubgoal,
406    #[cfg(feature = "vic3")] ObjectiveSubgoalCategory,
407    #[cfg(feature = "vic3")] Party,
408    #[cfg(feature = "vic3")] PoliticalLobby,
409    #[cfg(feature = "vic3")] PoliticalLobbyAppeasement,
410    #[cfg(feature = "vic3")] PoliticalMovement,
411    #[cfg(feature = "vic3")] PoliticalMovementCategory,
412    #[cfg(feature = "vic3")] PoliticalMovementPopSupport,
413    #[cfg(feature = "vic3")] PopNeed,
414    #[cfg(feature = "vic3")] PowerBlocCoaPiece,
415    #[cfg(feature = "vic3")] PowerBlocIdentity,
416    #[cfg(feature = "vic3")] PowerBlocMapTexture,
417    #[cfg(feature = "vic3")] PowerBlocName,
418    #[cfg(feature = "vic3")] Principle,
419    #[cfg(feature = "vic3")] PrincipleGroup,
420    #[cfg(feature = "vic3")] ProductionMethod,
421    #[cfg(feature = "vic3")] ProductionMethodGroup,
422    #[cfg(feature = "vic3")] ProposalType,
423    #[cfg(feature = "vic3")] RelationsThreshold,
424    #[cfg(feature = "vic3")] ScriptedButton,
425    #[cfg(feature = "vic3")] ScriptedProgressBar,
426    #[cfg(feature = "vic3")] ScriptedTest,
427    #[cfg(feature = "vic3")] SecretGoal,
428    #[cfg(feature = "vic3")] Skin,
429    #[cfg(feature = "vic3")] SocialClass,
430    #[cfg(feature = "vic3")] SocialHierarchy,
431    #[cfg(feature = "vic3")] StateRegion,
432    #[cfg(feature = "vic3")] StateTrait,
433    #[cfg(feature = "vic3")] Strata,
434    #[cfg(feature = "vic3")] StrategicRegion,
435    #[cfg(feature = "vic3")] Technology,
436    #[cfg(feature = "vic3")] TechnologyEra,
437    #[cfg(feature = "vic3")] TerrainKey,
438    #[cfg(feature = "vic3")] TerrainLabel,
439    #[cfg(feature = "vic3")] TerrainManipulator,
440    #[cfg(feature = "vic3")] TerrainMask,
441    #[cfg(feature = "vic3")] TerrainMaterial,
442    #[cfg(feature = "vic3")] Theme,
443    #[cfg(feature = "vic3")] TransferOfPower,
444
445    // Items specific to imperator
446    #[cfg(feature = "imperator")] Ambition,
447    #[cfg(feature = "imperator")] AiPlanGoals,
448    #[cfg(feature = "imperator")] Area,
449    #[cfg(feature = "imperator")] CultureGroup,
450    #[cfg(feature = "imperator")] CombatTactic,
451    #[cfg(feature = "imperator")] Deity,
452    #[cfg(feature = "imperator")] DeityCategory,
453    #[cfg(feature = "imperator")] DiplomaticStance,
454    #[cfg(feature = "imperator")] EconomicPolicy,
455    #[cfg(feature = "imperator")] EventPicture,
456    #[cfg(feature = "imperator")] GovernorPolicy,
457    #[cfg(feature = "imperator")] GraphicalCultureType,
458    #[cfg(feature = "imperator")] GreatWorkEffectTier,
459    #[cfg(feature = "imperator")] GreatWorkEffect,
460    #[cfg(feature = "imperator")] GreatWorkCategory,
461    #[cfg(feature = "imperator")] GreatWorkMaterial,
462    #[cfg(feature = "imperator")] GreatWorkModule,
463    #[cfg(feature = "imperator")] GreatWorkTemplate,
464    #[cfg(feature = "imperator")] Heritage,
465    #[cfg(feature = "imperator")] Idea,
466    #[cfg(feature = "imperator")] Invention,
467    #[cfg(feature = "imperator")] InventionGroup,
468    #[cfg(feature = "imperator")] LegionDistinction,
469    #[cfg(feature = "imperator")] LevyTemplate,
470    #[cfg(feature = "imperator")] Loyalty,
471    #[cfg(feature = "imperator")] MilitaryTraditionTree,
472    #[cfg(feature = "imperator")] MilitaryTradition,
473    #[cfg(feature = "imperator")] Mission,
474    #[cfg(feature = "imperator")] MissionTask,
475    #[cfg(feature = "imperator")] Office,
476    #[cfg(feature = "imperator")] Opinion,
477    #[cfg(feature = "imperator")] PartyAgenda,
478    #[cfg(feature = "imperator")] PartyType,
479    #[cfg(feature = "imperator")] PostSetupCharacters,
480    #[cfg(feature = "imperator")] Price,
481    #[cfg(feature = "imperator")] ProvinceRank,
482    #[cfg(feature = "imperator")] SetupCharacters,
483    #[cfg(feature = "imperator")] SetupProvinces,
484    #[cfg(feature = "imperator")] TechnologyTable,
485    #[cfg(feature = "imperator")] TradeGood,
486    #[cfg(feature = "imperator")] Treasure,
487    #[cfg(feature = "imperator")] Unit,
488    #[cfg(feature = "imperator")] UnitAbility,
489}
490
491/// Display items in `separated word case` for maximum friendliness.
492///
493/// Unfortunately there's no option for this in `strum` so we have to roll our own
494/// by using `snake_case` and changing the `_` to a space.
495impl Display for Item {
496    fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> {
497        let s: &'static str = self.into();
498        write!(f, "{}", s.replace('_', " "))
499    }
500}
501
502impl Item {
503    /// Returns a path where items of this type are kept in the script files. Can be `""` for items
504    /// that are built in.
505    ///
506    /// These paths are used both for the user in error reports, and to find the items when loading them.
507    pub fn path(self) -> &'static str {
508        #[allow(clippy::match_same_arms)]
509        // These variants are in the same order as the Item enum declaration
510        match self {
511            Item::Accessory => "gfx/portraits/accessories/",
512            Item::AccessoryTag => "gfx/portraits/accessories/",
513            Item::AccessoryVariation => "gfx/portraits/accessory_variations/",
514            Item::AccessoryVariationLayout => "gfx/portraits/accessory_variations/",
515            Item::AccessoryVariationTextures => "gfx/portraits/accessory_variations/",
516            Item::Achievement => "common/achievements",
517            Item::AchievementGroup => "common/achievement_groups.txt",
518            Item::Asset => "gfx/models/",
519            Item::BlendShape => "gfx/models/",
520            Item::CharacterInteraction => "common/character_interactions/",
521            Item::Coa => "common/coat_of_arms/coat_of_arms/",
522            Item::CoaColorList => "common/coat_of_arms/template_lists/",
523            Item::CoaColoredEmblemList => "common/coat_of_arms/template_lists/",
524            #[cfg(feature = "ck3")]
525            Item::CoaDesignerColorPalette => "gfx/coat_of_arms/color_palettes/",
526            Item::CoaDesignerColoredEmblem => "gfx/coat_of_arms/colored_emblems/",
527            #[cfg(feature = "ck3")]
528            Item::CoaDesignerEmblemLayout => "gfx/coat_of_arms/emblem_layouts/",
529            Item::CoaDesignerPattern => "gfx/coat_of_arms/patterns/",
530            Item::CoaPatternList => "common/coat_of_arms/template_lists/",
531            Item::CoaTemplate => "common/coat_of_arms/coat_of_arms/",
532            Item::CoaTemplateList => "common/coat_of_arms/template_lists/",
533            Item::CoaTexturedEmblemList => "common/coat_of_arms/template_lists/",
534            Item::Culture => match Game::game() {
535                #[cfg(feature = "ck3")]
536                Game::Ck3 => "common/culture/cultures/",
537                #[cfg(feature = "vic3")]
538                Game::Vic3 => "common/cultures/",
539                #[cfg(feature = "imperator")]
540                Game::Imperator => "common/cultures/",
541            },
542            Item::CustomLocalization => "common/customizable_localization/",
543            Item::Decision => match Game::game() {
544                #[cfg(feature = "ck3")]
545                Game::Ck3 => "common/decisions/",
546                #[cfg(feature = "vic3")]
547                Game::Vic3 => "common/decisions/",
548                #[cfg(feature = "imperator")]
549                Game::Imperator => "decisions/",
550            },
551            Item::Define => "common/defines/",
552            Item::Dlc => "dlc_metadata/",
553            Item::DlcFeature => "",
554            Item::DlcName => "dlc_metadata/",
555            Item::Directory => "",
556            Item::EffectLocalization => "common/effect_localization/",
557            Item::Entity => "gfx/models/",
558            Item::Entry => "",
559            Item::Ethnicity => "common/ethnicities/",
560            Item::Event => "events/",
561            Item::EventNamespace => "events/",
562            Item::File => "",
563            Item::Font => "fonts/",
564            Item::Fontfiles => "fonts/",
565            Item::GameConcept => "common/game_concepts/",
566            Item::GameRule => "common/game_rules/",
567            Item::GameRuleSetting => "common/game_rules/",
568            Item::GeneAgePreset => "common/genes/",
569            Item::GeneAttribute => "gfx/models/",
570            Item::GeneCategory => "common/genes/",
571            Item::GovernmentType => match Game::game() {
572                #[cfg(feature = "ck3")]
573                Game::Ck3 => "common/governments/",
574                #[cfg(feature = "vic3")]
575                Game::Vic3 => "common/government_types/",
576                #[cfg(feature = "imperator")]
577                Game::Imperator => "common/governments/",
578            },
579            Item::GuiLayer => "gui/",
580            Item::GuiTemplate => "gui/",
581            Item::GuiType => "gui/",
582            Item::Localization => "localization/",
583            Item::MapEnvironment => "gfx/map/environment/",
584            Item::MapMode => "gfx/map/map_modes/",
585            Item::Modifier => match Game::game() {
586                #[cfg(feature = "ck3")]
587                Game::Ck3 => "common/modifiers/",
588                #[cfg(feature = "vic3")]
589                Game::Vic3 => "common/static_modifiers/",
590                #[cfg(feature = "imperator")]
591                Game::Imperator => "common/modifiers/",
592            },
593            Item::Music => "music/",
594            Item::MusicPlayerCategory => "music/music_player_categories/",
595            Item::NamedColor => "common/named_colors/",
596            Item::OnAction => match Game::game() {
597                #[cfg(feature = "ck3")]
598                Game::Ck3 => "common/on_action/",
599                #[cfg(feature = "vic3")]
600                Game::Vic3 => "common/on_actions/",
601                #[cfg(feature = "imperator")]
602                Game::Imperator => "common/on_action/",
603            },
604            Item::Pdxmesh => "gfx/models/",
605            Item::PortraitAnimation => "gfx/portraits/portrait_animations/",
606            Item::PortraitCamera => "gfx/portraits/cameras/",
607            Item::PortraitEnvironment => "gfx/portraits/environments/",
608            Item::PortraitModifierGroup => "gfx/portraits/portrait_modifiers/",
609            Item::PortraitModifierPack => "gfx/portraits/portrait_animations/",
610            Item::Province => match Game::game() {
611                #[cfg(feature = "ck3")]
612                Game::Ck3 => "map_data/definition.csv",
613                #[cfg(feature = "vic3")]
614                Game::Vic3 => "map_data/provinces.png",
615                #[cfg(feature = "imperator")]
616                Game::Imperator => "map_data/provinces.png",
617            },
618            Item::Religion => match Game::game() {
619                #[cfg(feature = "ck3")]
620                Game::Ck3 => "common/religion/religions/",
621                #[cfg(feature = "vic3")]
622                Game::Vic3 => "common/religions/",
623                #[cfg(feature = "imperator")]
624                Game::Imperator => "common/religions/",
625            },
626            Item::ScriptedEffect => "common/scripted_effects/",
627            Item::ScriptedGui => "common/scripted_guis/",
628            Item::ScriptedList => "common/scripted_lists/",
629            Item::ScriptedModifier => "common/scripted_modifiers/",
630            Item::ScriptedRule => "common/scripted_rules/",
631            Item::ScriptedTrigger => "common/scripted_triggers/",
632            Item::ScriptValue => "common/script_values/",
633            Item::Shortcut => "gui/shortcuts.shortcuts",
634            Item::Sound => "",
635            Item::Terrain => match Game::game() {
636                #[cfg(feature = "ck3")]
637                Game::Ck3 => "common/terrain_types/",
638                #[cfg(feature = "vic3")]
639                Game::Vic3 => "common/terrain/",
640                #[cfg(feature = "imperator")]
641                Game::Imperator => "common/terrain_types/",
642            },
643            Item::TextFormat => "gui/",
644            Item::TextIcon => "gui/",
645            Item::TextureFile => "gfx/models/",
646            Item::TriggerLocalization => "common/trigger_localization/",
647            Item::WidgetName => "gui/",
648
649            #[cfg(any(feature = "ck3", feature = "imperator"))]
650            Item::Building => "common/buildings/",
651            #[cfg(any(feature = "ck3", feature = "vic3"))]
652            Item::CharacterTemplate => match Game::game() {
653                #[cfg(feature = "ck3")]
654                Game::Ck3 => "common/scripted_character_templates/",
655                #[cfg(feature = "vic3")]
656                Game::Vic3 => "common/character_templates/",
657            },
658            #[cfg(any(feature = "vic3", feature = "imperator"))]
659            Item::CharacterTrait => match Game::game() {
660                #[cfg(feature = "vic3")]
661                Game::Vic3 => "common/character_traits",
662                #[cfg(feature = "imperator")]
663                Game::Imperator => "common/traits",
664            },
665            #[cfg(any(feature = "vic3", feature = "imperator"))]
666            Item::Country => match Game::game() {
667                #[cfg(feature = "vic3")]
668                Game::Vic3 => "common/country_definitions/",
669                #[cfg(feature = "imperator")]
670                Game::Imperator => "setup/countries/countries.txt",
671            },
672            #[cfg(any(feature = "ck3", feature = "imperator"))]
673            Item::DeathReason => "common/deathreasons/",
674            #[cfg(any(feature = "ck3", feature = "vic3"))]
675            Item::Dna => "common/dna_data/",
676            #[cfg(any(feature = "ck3", feature = "imperator"))]
677            Item::EventTheme => "common/event_themes/",
678            #[cfg(any(feature = "ck3", feature = "imperator"))]
679            Item::Law => "common/laws/",
680            Item::LawGroup => match Game::game() {
681                #[cfg(feature = "ck3")]
682                Game::Ck3 => "common/laws/",
683                #[cfg(feature = "imperator")]
684                Game::Imperator => "common/laws/",
685                #[cfg(feature = "vic3")]
686                Game::Vic3 => "common/law_groups/",
687            },
688            #[cfg(any(feature = "ck3", feature = "vic3"))]
689            Item::Message => "common/messages",
690            #[cfg(any(feature = "vic3", feature = "imperator"))]
691            Item::PopType => "common/pop_types/",
692            #[cfg(any(feature = "ck3", feature = "imperator"))]
693            Item::Region => match Game::game() {
694                #[cfg(feature = "ck3")]
695                Game::Ck3 => "map_data/geographical_regions/",
696                #[cfg(feature = "imperator")]
697                Game::Imperator => "map_data/regions.txt",
698            },
699            #[cfg(any(feature = "vic3", feature = "imperator"))]
700            Item::SubjectType => "common/subject_types/",
701            #[cfg(any(feature = "ck3", feature = "vic3"))]
702            Item::TutorialLesson => "common/tutorial_lessons",
703            #[cfg(any(feature = "ck3", feature = "vic3"))]
704            Item::TutorialLessonChain => "common/tutorial_lesson_chains",
705            #[cfg(any(feature = "ck3", feature = "vic3"))]
706            Item::TutorialLessonStep => "common/tutorial_lessons",
707            #[cfg(any(feature = "vic3", feature = "imperator"))]
708            Item::Wargoal => match Game::game() {
709                #[cfg(feature = "vic3")]
710                Game::Vic3 => "",
711                #[cfg(feature = "imperator")]
712                Game::Imperator => "common/wargoals",
713            },
714
715            #[cfg(feature = "ck3")]
716            Item::AccoladeCategory => "common/accolade_types/",
717            #[cfg(feature = "ck3")]
718            Item::AccoladeIcon => "common/accolade_icons/",
719            #[cfg(feature = "ck3")]
720            Item::AccoladeName => "common/accolade_names/",
721            #[cfg(feature = "ck3")]
722            Item::AccoladeParameter => "common/accolade_types/",
723            #[cfg(feature = "ck3")]
724            Item::AccoladeType => "common/accolade_types/",
725            #[cfg(feature = "ck3")]
726            Item::ActivityGroupType => "common/activities/activity_group_types/",
727            #[cfg(feature = "ck3")]
728            Item::ActivityIntent => "common/activities/intents/",
729            #[cfg(feature = "ck3")]
730            Item::ActivityLocale => "common/activities/activity_locales/",
731            #[cfg(feature = "ck3")]
732            Item::ActivityOption => "common/activities/activity_types/",
733            #[cfg(feature = "ck3")]
734            Item::ActivityOptionCategory => "common/activities/activity_types/",
735            #[cfg(feature = "ck3")]
736            Item::ActivityPhase => "common/activities/activity_types/",
737            #[cfg(feature = "ck3")]
738            Item::ActivityPulseAction => "common/activities/pulse_actions/",
739            #[cfg(feature = "ck3")]
740            Item::ActivityState => "",
741            #[cfg(feature = "ck3")]
742            Item::ActivityType => "common/activities/activity_types/",
743            #[cfg(feature = "ck3")]
744            Item::AiWarStance => "common/ai_war_stances/",
745            #[cfg(feature = "ck3")]
746            Item::AgentType => "common/schemes/agent_types/",
747            #[cfg(feature = "ck3")]
748            Item::Amenity => "common/court_amenities/",
749            #[cfg(feature = "ck3")]
750            Item::AmenitySetting => "common/court_amenities/",
751            #[cfg(feature = "ck3")]
752            Item::ArtifactBlueprint => "common/artifacts/blueprints/",
753            #[cfg(feature = "ck3")]
754            Item::ArtifactFeature => "common/artifacts/features/",
755            #[cfg(feature = "ck3")]
756            Item::ArtifactFeatureGroup => "common/artifacts/feature_groups/",
757            #[cfg(feature = "ck3")]
758            Item::ArtifactHistory => "",
759            #[cfg(feature = "ck3")]
760            Item::ArtifactRarity => "",
761            #[cfg(feature = "ck3")]
762            Item::ArtifactSlot => "common/artifacts/slots/",
763            #[cfg(feature = "ck3")]
764            Item::ArtifactSlotType => "common/artifacts/slots/",
765            #[cfg(feature = "ck3")]
766            Item::ArtifactTemplate => "common/artifacts/templates/",
767            #[cfg(feature = "ck3")]
768            Item::ArtifactType => "common/artifacts/types/",
769            #[cfg(feature = "ck3")]
770            Item::ArtifactVisual => "common/artifacts/visuals/",
771            #[cfg(feature = "ck3")]
772            Item::Bookmark => "common/bookmarks/bookmarks/",
773            #[cfg(feature = "ck3")]
774            Item::BookmarkGroup => "common/bookmarks/groups/",
775            #[cfg(feature = "ck3")]
776            Item::BookmarkPortrait => "common/bookmark_portraits/",
777            #[cfg(feature = "ck3")]
778            Item::BuildingFlag => "common/buildings/",
779            #[cfg(feature = "ck3")]
780            Item::BuildingGfx => "common/culture/cultures/",
781            #[cfg(feature = "ck3")]
782            Item::CasusBelli => "common/casus_belli_types/",
783            #[cfg(feature = "ck3")]
784            Item::CasusBelliGroup => "common/casus_belli_groups/",
785            #[cfg(feature = "ck3")]
786            Item::Catalyst => "common/struggle/catalysts/",
787            #[cfg(feature = "ck3")]
788            Item::ChallengeCharacter => "common/bookmarks/challenge_characters/",
789            #[cfg(feature = "ck3")]
790            Item::Character => "history/characters/",
791            #[cfg(feature = "ck3")]
792            Item::CharacterBackground => "common/character_backgrounds/",
793            #[cfg(feature = "ck3")]
794            Item::CharacterInteractionCategory => "common/character_interaction_categories/",
795            #[cfg(feature = "ck3")]
796            Item::Climate => "map_data/climate.txt",
797            #[cfg(feature = "ck3")]
798            Item::ClothingGfx => "common/culture/cultures/",
799            #[cfg(feature = "ck3")]
800            Item::CoaGfx => "common/culture/cultures/",
801            #[cfg(feature = "ck3")]
802            Item::CoaDynamicDefinition => "common/coat_of_arms/dynamic_definitions/",
803            #[cfg(feature = "ck3")]
804            Item::CombatEffect => "common/combat_effects/",
805            #[cfg(feature = "ck3")]
806            Item::CombatPhaseEvent => "common/combat_phase_events/",
807            #[cfg(feature = "ck3")]
808            Item::CouncilPosition => "common/council_positions/",
809            #[cfg(feature = "ck3")]
810            Item::CouncilTask => "common/council_tasks/",
811            #[cfg(feature = "ck3")]
812            Item::Countermeasure => "common/schemes/scheme_countermeasures/",
813            #[cfg(feature = "ck3")]
814            Item::CountermeasureParameter => "common/schemes/scheme_countermeasures/",
815            #[cfg(feature = "ck3")]
816            Item::CourtPosition => "common/court_positions/types/",
817            #[cfg(feature = "ck3")]
818            Item::CourtPositionTask => "common/court_positions/tasks/",
819            #[cfg(feature = "ck3")]
820            Item::CourtSceneCulture => "gfx/court_scene/scene_cultures/",
821            #[cfg(feature = "ck3")]
822            Item::CourtSceneGroup => "gfx/court_scene/character_groups/",
823            #[cfg(feature = "ck3")]
824            Item::CourtSceneRole => "gfx/court_scene/character_roles/",
825            #[cfg(feature = "ck3")]
826            Item::CourtSceneSetting => "gfx/court_scene/scene_settings/",
827            #[cfg(feature = "ck3")]
828            Item::CourtType => "common/court_types/",
829            #[cfg(feature = "ck3")]
830            Item::CourtierGuestManagement => "common/courtier_guest_management/",
831            #[cfg(feature = "ck3")]
832            Item::CultureAesthetic => "common/culture/aesthetics_bundles/",
833            #[cfg(feature = "ck3")]
834            Item::CultureCreationName => "common/culture/creation_names/",
835            #[cfg(feature = "ck3")]
836            Item::CultureEra => "common/culture/eras/",
837            #[cfg(feature = "ck3")]
838            Item::CultureEthos => "common/culture/pillars/",
839            #[cfg(feature = "ck3")]
840            Item::CultureHeritage => "common/culture/pillars/",
841            #[cfg(feature = "ck3")]
842            Item::CultureHistory => "history/cultures/",
843            #[cfg(feature = "ck3")]
844            Item::CultureParameter => "common/culture/",
845            #[cfg(feature = "ck3")]
846            Item::CulturePillar => "common/culture/pillars/",
847            #[cfg(feature = "ck3")]
848            Item::CultureTradition => "common/culture/traditions/",
849            #[cfg(feature = "ck3")]
850            Item::CultureTraditionCategory => "common/culture/traditions/",
851            #[cfg(feature = "ck3")]
852            Item::DangerType => "",
853            #[cfg(feature = "ck3")]
854            Item::DecisionGroup => "common/decision_group_types/",
855            #[cfg(feature = "ck3")]
856            Item::DiarchyMandate => "common/diarchies/diarchy_mandates/",
857            #[cfg(feature = "ck3")]
858            Item::DiarchyParameter => "common/diarchies/diarchy_types/",
859            #[cfg(feature = "ck3")]
860            Item::DiarchyType => "common/diarchies/diarchy_types/",
861            #[cfg(feature = "ck3")]
862            Item::Doctrine => "common/religion/doctrines/",
863            #[cfg(feature = "ck3")]
864            Item::DoctrineCategory => "common/religion/doctrines/",
865            #[cfg(feature = "ck3")]
866            Item::DoctrineParameter => "common/religion/doctrines/",
867            #[cfg(feature = "ck3")]
868            Item::DomicileBuilding => "common/domiciles/buildings/",
869            #[cfg(feature = "ck3")]
870            Item::DomicileParameter => "common/domiciles/buildings/",
871            #[cfg(feature = "ck3")]
872            Item::DomicileType => "common/domiciles/types/",
873            #[cfg(feature = "ck3")]
874            Item::Dynasty => "common/dynasties/",
875            #[cfg(feature = "ck3")]
876            Item::DynastyLegacy => "common/dynasty_legacies/",
877            #[cfg(feature = "ck3")]
878            Item::DynastyPerk => "common/dynasty_perks/",
879            #[cfg(feature = "ck3")]
880            Item::EpidemicType => "common/epidemics/",
881            #[cfg(feature = "ck3")]
882            Item::EpidemicDeathReason => "common/deathreasons/",
883            #[cfg(feature = "ck3")]
884            Item::EventBackground => "common/event_backgrounds/",
885            #[cfg(feature = "ck3")]
886            Item::EventEffect2d => "common/event_2d_effects/",
887            #[cfg(feature = "ck3")]
888            Item::EventTransition => "common/event_transitions/",
889            #[cfg(feature = "ck3")]
890            Item::Faith => "common/religion/religions/",
891            #[cfg(feature = "ck3")]
892            Item::FaithIcon => "common/religion/religions/",
893            #[cfg(feature = "ck3")]
894            Item::FervorModifier => "common/religion/fervor_modifiers/",
895            #[cfg(feature = "ck3")]
896            Item::Faction => "common/factions/",
897            #[cfg(feature = "ck3")]
898            Item::Flavorization => "common/flavorization/",
899            #[cfg(feature = "ck3")]
900            Item::Focus => "common/focuses/",
901            #[cfg(feature = "ck3")]
902            Item::GeneticConstraint => "common/traits/",
903            #[cfg(feature = "ck3")]
904            Item::GovernmentFlag => "common/governments/",
905            #[cfg(feature = "ck3")]
906            Item::GraphicalFaith => "common/religion/religions/",
907            #[cfg(feature = "ck3")]
908            Item::GuestInviteRule => "common/activities/guest_invite_rules/",
909            #[cfg(feature = "ck3")]
910            Item::GuestSubset => "common/activities/activity_types/",
911            #[cfg(feature = "ck3")]
912            Item::GuestSystem => "common/guest_system/",
913            #[cfg(feature = "ck3")]
914            Item::HoldingFlag => "common/holdings/",
915            #[cfg(feature = "ck3")]
916            Item::HoldingType => "common/holdings/",
917            #[cfg(feature = "ck3")]
918            Item::HolySite => "common/religion/holy_sites/",
919            #[cfg(feature = "ck3")]
920            Item::HolySiteFlag => "common/religion/holy_sites/",
921            #[cfg(feature = "ck3")]
922            Item::Hook => "common/hook_types/",
923            #[cfg(feature = "ck3")]
924            Item::House => "common/dynasty_houses/",
925            #[cfg(feature = "ck3")]
926            Item::HousePowerBonus => "common/house_power_bonus/",
927            #[cfg(feature = "ck3")]
928            Item::HouseUnity => "common/house_unities/",
929            #[cfg(feature = "ck3")]
930            Item::HouseUnityParameter => "common/house_unities",
931            #[cfg(feature = "ck3")]
932            Item::HouseUnityStage => "common/house_unities/",
933            #[cfg(feature = "ck3")]
934            Item::ImportantAction => "common/important_actions/",
935            #[cfg(feature = "ck3")]
936            Item::Innovation => "common/culture/innovations/",
937            #[cfg(feature = "ck3")]
938            Item::InnovationFlag => "common/culture/innovations/",
939            #[cfg(feature = "ck3")]
940            Item::Inspiration => "common/inspirations/",
941            #[cfg(feature = "ck3")]
942            Item::Language => "common/culture/pillars/",
943            #[cfg(feature = "ck3")]
944            Item::LawFlag => "common/laws/",
945            #[cfg(feature = "ck3")]
946            Item::LeaseContract => "common/lease_contracts/",
947            #[cfg(feature = "ck3")]
948            Item::LegendChapter => "common/legends/chronicles/",
949            #[cfg(feature = "ck3")]
950            Item::LegendChronicle => "common/legends/chronicles/",
951            #[cfg(feature = "ck3")]
952            Item::LegendProperty => "common/legends/chronicles/",
953            #[cfg(feature = "ck3")]
954            Item::LegendSeed => "common/legends/legend_seeds/",
955            #[cfg(feature = "ck3")]
956            Item::LegendType => "common/legends/legend_types/",
957            #[cfg(feature = "ck3")]
958            Item::LegitimacyFlag => "common/legitimacy/",
959            #[cfg(feature = "ck3")]
960            Item::LegitimacyType => "common/legitimacy/",
961            #[cfg(feature = "ck3")]
962            Item::Lifestyle => "common/lifestyles/",
963            #[cfg(feature = "ck3")]
964            Item::MartialCustom => "common/culture/pillars/",
965            #[cfg(feature = "ck3")]
966            Item::MemoryCategory => "common/character_memory_types/",
967            #[cfg(feature = "ck3")]
968            Item::MemoryType => "common/character_memory_types/",
969            #[cfg(feature = "ck3")]
970            Item::MenAtArms => "common/men_at_arms_types/",
971            #[cfg(feature = "ck3")]
972            Item::MenAtArmsBase => "common/men_at_arms_types/",
973            #[cfg(feature = "ck3")]
974            Item::MessageFilterType => "common/message_filter_types/",
975            #[cfg(feature = "ck3")]
976            Item::MessageGroupType => "common/message_group_types/",
977            #[cfg(feature = "ck3")]
978            Item::ModifierFormat => "common/modifier_definition_formats/",
979            #[cfg(feature = "ck3")]
980            Item::MottoInsert => "common/dynasty_house_motto_inserts/",
981            #[cfg(feature = "ck3")]
982            Item::Motto => "common/dynasty_house_mottos/",
983            #[cfg(feature = "ck3")]
984            Item::NameEquivalency => "common/culture/name_equivalency/",
985            #[cfg(feature = "ck3")]
986            Item::NameList => "common/culture/name_lists/",
987            #[cfg(feature = "ck3")]
988            Item::Nickname => "common/nicknames/",
989            #[cfg(feature = "ck3")]
990            Item::OpinionModifier => "common/opinion_modifiers/",
991            #[cfg(feature = "ck3")]
992            Item::Perk => "common/lifestyle_perks/",
993            #[cfg(feature = "ck3")]
994            Item::PerkTree => "common/lifestyle_perks/",
995            #[cfg(feature = "ck3")]
996            Item::PlayableDifficultyInfo => "common/playable_difficulty_infos/",
997            #[cfg(feature = "ck3")]
998            Item::PointOfInterest => "common/travel/point_of_interest_types/",
999            #[cfg(feature = "ck3")]
1000            Item::PoolSelector => "common/pool_character_selectors/",
1001            #[cfg(feature = "ck3")]
1002            Item::PortraitType => "common/portrait_types/",
1003            #[cfg(feature = "ck3")]
1004            Item::ProvinceMapping => "history/province_mapping/",
1005            #[cfg(feature = "ck3")]
1006            Item::PrisonType => "",
1007            #[cfg(feature = "ck3")]
1008            Item::Relation => "common/scripted_relations/",
1009            #[cfg(feature = "ck3")]
1010            Item::RelationFlag => "common/scripted_relations/",
1011            #[cfg(feature = "ck3")]
1012            Item::ReligionFamily => "common/religion/religion_families/",
1013            #[cfg(feature = "ck3")]
1014            Item::RewardItem => "",
1015            #[cfg(feature = "ck3")]
1016            Item::Scheme => "common/schemes/scheme_types",
1017            #[cfg(feature = "ck3")]
1018            Item::SchemePulseAction => "common/schemes/pulse_actions",
1019            #[cfg(feature = "ck3")]
1020            Item::ScriptedAnimation => "common/scripted_animations/",
1021            #[cfg(feature = "ck3")]
1022            Item::ScriptedCost => "common/scripted_costs/",
1023            #[cfg(feature = "ck3")]
1024            Item::ScriptedIllustration => "gfx/interface/illustrations/scripted_illustrations/",
1025            #[cfg(feature = "ck3")]
1026            Item::Secret => "common/secret_types/",
1027            #[cfg(feature = "ck3")]
1028            Item::Sexuality => "",
1029            #[cfg(feature = "ck3")]
1030            Item::Skill => "",
1031            #[cfg(feature = "ck3")]
1032            Item::SpecialBuilding => "common/buildings/",
1033            #[cfg(feature = "ck3")]
1034            Item::SpecialGuest => "common/activities/activity_types/",
1035            #[cfg(feature = "ck3")]
1036            Item::Story => "common/story_cycles/",
1037            #[cfg(feature = "ck3")]
1038            Item::Struggle => "common/struggle/struggles/",
1039            #[cfg(feature = "ck3")]
1040            Item::StruggleHistory => "history/struggles/",
1041            #[cfg(feature = "ck3")]
1042            Item::StrugglePhase => "common/struggle/struggles/",
1043            #[cfg(feature = "ck3")]
1044            Item::StrugglePhaseParameter => "common/struggle/struggles/",
1045            #[cfg(feature = "ck3")]
1046            Item::SuccessionAppointment => "common/succession_appointment/",
1047            #[cfg(feature = "ck3")]
1048            Item::SuccessionElection => "common/succession_election/",
1049            #[cfg(feature = "ck3")]
1050            Item::Suggestion => "common/suggestions/",
1051            #[cfg(feature = "ck3")]
1052            Item::TaskContractGroup => "common/task_contracts/",
1053            #[cfg(feature = "ck3")]
1054            Item::TaskContractReward => "common/task_contracts/",
1055            #[cfg(feature = "ck3")]
1056            Item::TaskContractType => "common/task_contracts/",
1057            #[cfg(feature = "ck3")]
1058            Item::TaxSlotFlag => "common/tax_slots/obligations",
1059            #[cfg(feature = "ck3")]
1060            Item::TaxSlotObligation => "common/tax_slots/obligations",
1061            #[cfg(feature = "ck3")]
1062            Item::TaxSlotType => "common/tax_slots/types",
1063            #[cfg(feature = "ck3")]
1064            Item::Title => "common/landed_titles/",
1065            #[cfg(feature = "ck3")]
1066            Item::TitleHistory => "history/titles/",
1067            #[cfg(feature = "ck3")]
1068            Item::TitleHistoryType => "",
1069            #[cfg(feature = "ck3")]
1070            Item::Trait => "common/traits/",
1071            #[cfg(feature = "ck3")]
1072            Item::TraitCategory => "",
1073            #[cfg(feature = "ck3")]
1074            Item::TraitFlag => "common/traits/",
1075            #[cfg(feature = "ck3")]
1076            Item::TraitPortraitModifier => "gfx/portraits/trait_portrait_modifiers",
1077            #[cfg(feature = "ck3")]
1078            Item::TraitTrack => "common/traits/",
1079            #[cfg(feature = "ck3")]
1080            Item::TravelOption => "common/travel/travel_options/",
1081            #[cfg(feature = "ck3")]
1082            Item::UnitGfx => "common/culture/cultures/",
1083            #[cfg(feature = "ck3")]
1084            Item::VassalContract => "common/vassal_contracts/",
1085            #[cfg(feature = "ck3")]
1086            Item::VassalContractFlag => "common/vassal_contracts/",
1087            #[cfg(feature = "ck3")]
1088            Item::VassalObligationLevel => "common/vassal_contracts/",
1089            #[cfg(feature = "ck3")]
1090            Item::VassalStance => "common/vassal_stances/",
1091
1092            #[cfg(feature = "vic3")]
1093            Item::AcceptanceStatus => "common/acceptance_statuses/",
1094            #[cfg(feature = "vic3")]
1095            Item::AiStrategy => "common/ai_strategies/",
1096            #[cfg(feature = "vic3")]
1097            Item::Alert => "common/alert_types",
1098            #[cfg(feature = "vic3")]
1099            Item::AlertGroup => "common/alert_groups",
1100            #[cfg(feature = "vic3")]
1101            Item::Approval => "",
1102            #[cfg(feature = "vic3")]
1103            Item::Attitude => "",
1104            #[cfg(feature = "vic3")]
1105            Item::BattleCondition => "common/battle_conditions/",
1106            #[cfg(feature = "vic3")]
1107            Item::BuildingGroup => "common/building_groups/",
1108            #[cfg(feature = "vic3")]
1109            Item::BuildingType => "common/buildings/",
1110            #[cfg(feature = "vic3")]
1111            Item::BuyPackage => "common/buy_packages/",
1112            #[cfg(feature = "vic3")]
1113            Item::CanalType => "common/canals/",
1114            #[cfg(feature = "vic3")]
1115            Item::CharacterRole => "",
1116            #[cfg(feature = "vic3")]
1117            Item::CombatUnit => "common/combat_unit_types/",
1118            #[cfg(feature = "vic3")]
1119            Item::CombatUnitExperienceLevel => "common/combat_unit_experience_levels/",
1120            #[cfg(feature = "vic3")]
1121            Item::CombatUnitGroup => "common/combat_unit_groups/",
1122            #[cfg(feature = "vic3")]
1123            Item::CommanderOrder => "common/commander_orders/",
1124            #[cfg(feature = "vic3")]
1125            Item::CommanderRank => "common/commander_ranks/",
1126            #[cfg(feature = "vic3")]
1127            Item::CompanyType => "common/company_types/",
1128            #[cfg(feature = "vic3")]
1129            Item::CohesionLevel => "common/cohesion_levels/",
1130            #[cfg(feature = "vic3")]
1131            Item::CountryCreation => "common/country_creation/",
1132            #[cfg(feature = "vic3")]
1133            Item::CountryFormation => "common/country_formation/",
1134            #[cfg(feature = "vic3")]
1135            Item::CountryRank => "common/country_ranks/",
1136            #[cfg(feature = "vic3")]
1137            Item::CountryTier => "",
1138            #[cfg(feature = "vic3")]
1139            Item::CountryType => "common/country_types/",
1140            #[cfg(feature = "vic3")]
1141            Item::CultureGraphics => "common/culture_graphics/",
1142            #[cfg(feature = "vic3")]
1143            Item::Decree => "common/decrees/",
1144            #[cfg(feature = "vic3")]
1145            Item::DiplomaticAction => "common/diplomatic_actions/",
1146            #[cfg(feature = "vic3")]
1147            Item::DiplomaticCatalyst => "common/diplomatic_catalysts/",
1148            #[cfg(feature = "vic3")]
1149            Item::DiplomaticCatalystCategory => "common/diplomatic_catalyst_categories/",
1150            #[cfg(feature = "vic3")]
1151            Item::DiplomaticPlay => "common/diplomatic_plays/",
1152            #[cfg(feature = "vic3")]
1153            Item::DiscriminationTrait => "common/discrimination_traits/",
1154            #[cfg(feature = "vic3")]
1155            Item::DynamicCompanyName => "common/dynamic_company_names/",
1156            #[cfg(feature = "vic3")]
1157            Item::DynamicCountryMapColor => "common/dynamic_country_map_colors/",
1158            #[cfg(feature = "vic3")]
1159            Item::DynamicCountryName => "common/dynamic_country_names/",
1160            #[cfg(feature = "vic3")]
1161            Item::EventCategory => "",
1162            #[cfg(feature = "vic3")]
1163            Item::FlagDefinition => "common/flag_definitions/",
1164            #[cfg(feature = "vic3")]
1165            Item::Goods => "common/goods/",
1166            #[cfg(feature = "vic3")]
1167            // TODO: find out if different filenames are acceptable in this dir
1168            Item::GradientBorderSettings => "gfx/map/gradient_border_settings/",
1169            #[cfg(feature = "vic3")]
1170            Item::HarvestConditionType => "common/harvest_condition_types/",
1171            #[cfg(feature = "vic3")]
1172            Item::Ideology => "common/ideologies/",
1173            #[cfg(feature = "vic3")]
1174            Item::InfamyThreshold => "",
1175            #[cfg(feature = "vic3")]
1176            Item::Institution => "common/institutions/",
1177            #[cfg(feature = "vic3")]
1178            Item::InterestGroup => "common/interest_groups/",
1179            #[cfg(feature = "vic3")]
1180            Item::InterestGroupTrait => "common/interest_group_traits/",
1181            #[cfg(feature = "vic3")]
1182            Item::JournalEntry => "common/journal_entries/",
1183            #[cfg(feature = "vic3")]
1184            Item::JournalEntryGroup => "common/journal_entry_groups/",
1185            #[cfg(feature = "vic3")]
1186            Item::LawType => "common/laws/",
1187            #[cfg(feature = "vic3")]
1188            Item::LegitimacyLevel => "common/legitimacy_levels/",
1189            #[cfg(feature = "vic3")]
1190            Item::Level => "",
1191            #[cfg(feature = "vic3")]
1192            Item::LibertyDesireLevel => "common/liberty_desire_levels/",
1193            #[cfg(feature = "vic3")]
1194            Item::MapLayer => "gfx/map/map_object_data/layers.txt",
1195            #[cfg(feature = "vic3")]
1196            Item::MapInteractionType => "common/map_interaction_types/",
1197            #[cfg(feature = "vic3")]
1198            Item::MapNotificationType => "common/map_notification_types/",
1199            #[cfg(feature = "vic3")]
1200            Item::MediaAlias => "gfx/media_aliases/",
1201            #[cfg(feature = "vic3")]
1202            Item::MilitaryFormationFlag => "common/military_formation_flags/",
1203            #[cfg(feature = "vic3")]
1204            Item::MobilizationOption => "common/mobilization_options/",
1205            #[cfg(feature = "vic3")]
1206            Item::MobilizationOptionGroup => "common/mobilization_option_groups/",
1207            #[cfg(feature = "vic3")]
1208            Item::ModifierTypeDefinition => "common/modifier_type_definitions/",
1209            #[cfg(feature = "vic3")]
1210            Item::Objective => "common/objectives/",
1211            #[cfg(feature = "vic3")]
1212            Item::ObjectiveSubgoal => "common/objective_subgoals/",
1213            #[cfg(feature = "vic3")]
1214            Item::ObjectiveSubgoalCategory => "common/objective_subgoal_categories/",
1215            #[cfg(feature = "vic3")]
1216            Item::Party => "common/parties/",
1217            #[cfg(feature = "vic3")]
1218            Item::PoliticalLobby => "common/political_lobbies/",
1219            #[cfg(feature = "vic3")]
1220            Item::PoliticalLobbyAppeasement => "common/political_lobby_appeasement/",
1221            #[cfg(feature = "vic3")]
1222            Item::PoliticalMovement => "common/political_movements",
1223            #[cfg(feature = "vic3")]
1224            Item::PoliticalMovementCategory => "common/political_movement_categories",
1225            #[cfg(feature = "vic3")]
1226            Item::PoliticalMovementPopSupport => "common/political_movement_pop_support",
1227            #[cfg(feature = "vic3")]
1228            Item::PopNeed => "common/pop_needs/",
1229            #[cfg(feature = "vic3")]
1230            Item::PowerBlocCoaPiece => "common/power_bloc_coa_pieces/",
1231            #[cfg(feature = "vic3")]
1232            Item::PowerBlocIdentity => "common/power_bloc_identities/",
1233            #[cfg(feature = "vic3")]
1234            Item::PowerBlocMapTexture => "common/power_bloc_map_textures/",
1235            #[cfg(feature = "vic3")]
1236            Item::PowerBlocName => "common/power_bloc_names/",
1237            #[cfg(feature = "vic3")]
1238            Item::Principle => "common/power_bloc_principles/",
1239            #[cfg(feature = "vic3")]
1240            Item::PrincipleGroup => "common/power_bloc_principle_groups/",
1241            #[cfg(feature = "vic3")]
1242            Item::ProductionMethod => "common/production_methods/",
1243            #[cfg(feature = "vic3")]
1244            Item::ProductionMethodGroup => "common/production_method_groups/",
1245            #[cfg(feature = "vic3")]
1246            Item::ProposalType => "common/proposal_types/",
1247            #[cfg(feature = "vic3")]
1248            Item::RelationsThreshold => "",
1249            #[cfg(feature = "vic3")]
1250            Item::ScriptedButton => "common/scripted_buttons/",
1251            #[cfg(feature = "vic3")]
1252            Item::ScriptedProgressBar => "common/scripted_progress_bars/",
1253            #[cfg(feature = "vic3")]
1254            Item::ScriptedTest => "common/scripted_tests/",
1255            #[cfg(feature = "vic3")]
1256            Item::SecretGoal => "",
1257            #[cfg(feature = "vic3")]
1258            Item::Skin => "gfx/skins/",
1259            #[cfg(feature = "vic3")]
1260            Item::SocialClass => "common/social_classes/",
1261            #[cfg(feature = "vic3")]
1262            Item::SocialHierarchy => "common/social_hierarchies/",
1263            #[cfg(feature = "vic3")]
1264            Item::StateRegion => "map_data/state_regions/",
1265            #[cfg(feature = "vic3")]
1266            Item::StateTrait => "common/state_traits/",
1267            #[cfg(feature = "vic3")]
1268            Item::Strata => "",
1269            #[cfg(feature = "vic3")]
1270            Item::StrategicRegion => "common/strategic_regions/",
1271            #[cfg(feature = "vic3")]
1272            Item::Technology => "common/technology/technologies/",
1273            #[cfg(feature = "vic3")]
1274            Item::TechnologyEra => "common/technology/eras/",
1275            #[cfg(feature = "vic3")]
1276            Item::TerrainKey => "common/labels/",
1277            #[cfg(feature = "vic3")]
1278            Item::TerrainLabel => "common/labels/",
1279            #[cfg(feature = "vic3")]
1280            Item::TerrainManipulator => "common/terrain_manipulators/",
1281            #[cfg(feature = "vic3")]
1282            Item::TerrainMask => "gfx/map/masks/",
1283            #[cfg(feature = "vic3")]
1284            Item::TerrainMaterial => "gfx/map/terrain/materials.settings",
1285            #[cfg(feature = "vic3")]
1286            Item::Theme => "common/themes/",
1287            #[cfg(feature = "vic3")]
1288            Item::TransferOfPower => "",
1289
1290            #[cfg(feature = "imperator")]
1291            Item::AiPlanGoals => "common/ai_plan_goals/",
1292            #[cfg(feature = "imperator")]
1293            Item::Ambition => "common/ambitions/",
1294            #[cfg(feature = "imperator")]
1295            Item::Area => "map_data/areas.txt",
1296            #[cfg(feature = "imperator")]
1297            Item::CombatTactic => "common/combat_tactics/",
1298            #[cfg(feature = "imperator")]
1299            Item::CultureGroup => "common/cultures/",
1300            #[cfg(feature = "imperator")]
1301            Item::Deity => "common/deities/",
1302            #[cfg(feature = "imperator")]
1303            Item::DeityCategory => "common/deity_categories/",
1304            #[cfg(feature = "imperator")]
1305            Item::DiplomaticStance => "common/diplomatic_stances/",
1306            #[cfg(feature = "imperator")]
1307            Item::EconomicPolicy => "common/economic_policies/",
1308            #[cfg(feature = "imperator")]
1309            Item::EventPicture => "common/event_pictures/",
1310            #[cfg(feature = "imperator")]
1311            Item::GovernorPolicy => "common/governor_policies/",
1312            #[cfg(feature = "imperator")]
1313            Item::GraphicalCultureType => "common/graphical_culture_types/",
1314            #[cfg(feature = "imperator")]
1315            Item::GreatWorkEffect => "common/great_work_effects/",
1316            #[cfg(feature = "imperator")]
1317            Item::GreatWorkEffectTier => "common/great_work_effect_tiers/",
1318            #[cfg(feature = "imperator")]
1319            Item::GreatWorkCategory => "common/great_work_categories/",
1320            #[cfg(feature = "imperator")]
1321            Item::GreatWorkMaterial => "common/great_work_materials/",
1322            #[cfg(feature = "imperator")]
1323            Item::GreatWorkModule => "common/great_work_modules/",
1324            #[cfg(feature = "imperator")]
1325            Item::GreatWorkTemplate => "common/great_work_templates/",
1326            #[cfg(feature = "imperator")]
1327            Item::Heritage => "common/heritage/",
1328            #[cfg(feature = "imperator")]
1329            Item::Idea => "common/ideas/",
1330            #[cfg(feature = "imperator")]
1331            Item::Invention => "common/inventions/",
1332            #[cfg(feature = "imperator")]
1333            Item::InventionGroup => "common/inventions/",
1334            #[cfg(feature = "imperator")]
1335            Item::LegionDistinction => "common/legion_distinctions/",
1336            #[cfg(feature = "imperator")]
1337            Item::LevyTemplate => "common/levy_templates/",
1338            #[cfg(feature = "imperator")]
1339            Item::Loyalty => "common/loyalty/",
1340            #[cfg(feature = "imperator")]
1341            Item::MilitaryTraditionTree => "common/military_traditions/",
1342            #[cfg(feature = "imperator")]
1343            Item::MilitaryTradition => "common/military_traditions/",
1344            #[cfg(feature = "imperator")]
1345            Item::Mission => "common/missions/",
1346            #[cfg(feature = "imperator")]
1347            Item::MissionTask => "common/missions/",
1348            #[cfg(feature = "imperator")]
1349            Item::Office => "common/offices/",
1350            #[cfg(feature = "imperator")]
1351            Item::Opinion => "common/opinions/",
1352            #[cfg(feature = "imperator")]
1353            Item::PartyAgenda => "common/party_agendas",
1354            #[cfg(feature = "imperator")]
1355            Item::PartyType => "common/party_types/",
1356            #[cfg(feature = "imperator")]
1357            Item::PostSetupCharacters => "setup/post_character/",
1358            #[cfg(feature = "imperator")]
1359            Item::Price => "common/prices/",
1360            #[cfg(feature = "imperator")]
1361            Item::ProvinceRank => "common/province_ranks/",
1362            #[cfg(feature = "imperator")]
1363            Item::TechnologyTable => "common/technology_tables/",
1364            #[cfg(feature = "imperator")]
1365            Item::SetupCharacters => "setup/characters/",
1366            #[cfg(feature = "imperator")]
1367            Item::SetupProvinces => "setup/provinces/",
1368            #[cfg(feature = "imperator")]
1369            Item::TradeGood => "common/trade_goods/",
1370            #[cfg(feature = "imperator")]
1371            Item::Treasure => "setup/main/",
1372            #[cfg(feature = "imperator")]
1373            Item::Unit => "common/units/",
1374            #[cfg(feature = "imperator")]
1375            Item::UnitAbility => "common/unit_abilities/",
1376        }
1377    }
1378
1379    /// Confidence value to use when reporting that an item is missing.
1380    /// Should be `Strong` for most, `Weak` for items that aren't defined anywhere but just used (such as gfx flags).
1381    pub fn confidence(self) -> Confidence {
1382        match self {
1383            Item::AccessoryTag
1384            // GuiType and GuiTemplate are here because referring to templates in other mods is a
1385            // common compatibility technique.
1386            | Item::GuiType
1387            | Item::GuiTemplate
1388            | Item::Sound => Confidence::Weak,
1389
1390            #[cfg(feature = "ck3")]
1391            Item::AccoladeCategory
1392            | Item::BuildingGfx
1393            | Item::ClothingGfx
1394            | Item::CoaGfx
1395            | Item::MemoryCategory
1396            | Item::UnitGfx => Confidence::Weak,
1397
1398            #[cfg(feature = "ck3")]
1399            Item::SpecialBuilding => Confidence::Reasonable,
1400
1401            _ => Confidence::Strong,
1402        }
1403    }
1404
1405    /// Severity value to use when reporting that an item is missing.
1406    /// * `Error` - most things
1407    /// * `Warning` - things that only impact visuals or presentation
1408    /// * `Untidy` - things that don't matter much at all
1409    /// * `Fatal` - things that cause crashes if they're missing
1410    ///
1411    /// This is only one piece of the severity puzzle. It can also depend on the caller who's expecting the item to exist.
1412    /// That part isn't handled yet.
1413    pub fn severity(self) -> Severity {
1414        match self {
1415            // GuiType and GuiTemplate are here because referring to templates in other mods is a
1416            // common compatibility technique.
1417            Item::GuiType | Item::GuiTemplate => Severity::Untidy,
1418
1419            Item::Accessory
1420            | Item::AccessoryTag
1421            | Item::AccessoryVariation
1422            | Item::AccessoryVariationLayout
1423            | Item::AccessoryVariationTextures
1424            | Item::Coa
1425            | Item::CoaColorList
1426            | Item::CoaColoredEmblemList
1427            | Item::CoaPatternList
1428            | Item::CoaTemplate
1429            | Item::CoaTemplateList
1430            | Item::CoaTexturedEmblemList
1431            | Item::CustomLocalization
1432            | Item::EffectLocalization
1433            | Item::Ethnicity
1434            | Item::File
1435            | Item::GameConcept
1436            | Item::Localization
1437            | Item::MapEnvironment
1438            | Item::NamedColor
1439            | Item::PortraitAnimation
1440            | Item::PortraitCamera
1441            | Item::PortraitEnvironment
1442            | Item::Sound
1443            | Item::TextFormat
1444            | Item::TextIcon
1445            | Item::TextureFile
1446            | Item::TriggerLocalization => Severity::Warning,
1447
1448            #[cfg(feature = "ck3")]
1449            Item::AccoladeIcon
1450            | Item::ArtifactVisual
1451            | Item::BuildingGfx
1452            | Item::ClothingGfx
1453            | Item::CoaDynamicDefinition
1454            | Item::CoaGfx
1455            | Item::CultureAesthetic
1456            | Item::CultureCreationName
1457            | Item::EventBackground
1458            | Item::EventTheme
1459            | Item::EventTransition
1460            | Item::Flavorization
1461            | Item::GraphicalFaith
1462            | Item::ModifierFormat
1463            | Item::MottoInsert
1464            | Item::Motto
1465            | Item::Music
1466            | Item::Nickname
1467            | Item::ScriptedIllustration
1468            | Item::UnitGfx => Severity::Warning,
1469
1470            #[cfg(feature = "vic3")]
1471            Item::MapLayer
1472            | Item::ModifierTypeDefinition
1473            | Item::TerrainManipulator
1474            | Item::TerrainMask
1475            | Item::TerrainMaterial => Severity::Warning,
1476
1477            _ => Severity::Error,
1478        }
1479    }
1480}
1481
1482/// The callback type for adding one item instance to the database.
1483pub(crate) type ItemAdder = fn(&mut Db, Token, Block);
1484
1485/// The specification for loading an [`Item`] type into the [`Db`].
1486///
1487/// An instance of this can be placed in every `data` module using the `inventory::collect!` macro.
1488/// This will register the loader so that the [`Everything`] object can load all defined items.
1489// Note that this is an enum so that users can more conveniently construct it. It used to be a
1490// struct with various constructor functions, but that didn't work because the ItemAdder type has a
1491// &mut in it, and that wasn't allowed in const functions even though the function pointer itself
1492// is const. See https://github.com/rust-lang/rust/issues/57349 for details.
1493// TODO: once that issue stabilizes, we can revisit the ItemLoader type.
1494pub(crate) enum ItemLoader {
1495    /// A convenience variant for loaders that are the most common type.
1496    ///
1497    /// * [`GameFlags`] is which games this item loader is for.
1498    /// * [`Item`] is the item type being loaded.
1499    ///
1500    /// The [`ItemAdder`] function does not have to load exclusively this type of item.
1501    /// Related items are ok. The main use of the [`Item`] field is to get the path for this item
1502    /// type, so that files are loaded from that folder.
1503    Normal(GameFlags, Item, ItemAdder),
1504    /// A variant that allows the full range of item loader behvavior.
1505    /// * [`PdxEncoding`] indicates whether to expect utf-8 and/or a BOM in the files.
1506    /// * The `&'static str` is the file extension to look for (including the dot).
1507    /// * The `bool` is whether to load the whole file as one item, or treat it as normal with a
1508    ///   series of items in one file.
1509    Full(GameFlags, Item, PdxEncoding, &'static str, bool, ItemAdder),
1510}
1511
1512inventory::collect!(ItemLoader);
1513
1514impl ItemLoader {
1515    pub fn for_game(&self, game: Game) -> bool {
1516        let game_flags = match self {
1517            ItemLoader::Normal(game_flags, _, _) | ItemLoader::Full(game_flags, _, _, _, _, _) => {
1518                game_flags
1519            }
1520        };
1521        game_flags.contains(GameFlags::from(game))
1522    }
1523
1524    pub fn itype(&self) -> Item {
1525        match self {
1526            ItemLoader::Normal(_, itype, _) | ItemLoader::Full(_, itype, _, _, _, _) => *itype,
1527        }
1528    }
1529
1530    pub fn encoding(&self) -> PdxEncoding {
1531        match self {
1532            ItemLoader::Normal(_, _, _) => PdxEncoding::Utf8Bom,
1533            ItemLoader::Full(_, _, encoding, _, _, _) => *encoding,
1534        }
1535    }
1536
1537    pub fn extension(&self) -> &'static str {
1538        match self {
1539            ItemLoader::Normal(_, _, _) => ".txt",
1540            ItemLoader::Full(_, _, _, extension, _, _) => extension,
1541        }
1542    }
1543
1544    pub fn whole_file(&self) -> bool {
1545        match self {
1546            ItemLoader::Normal(_, _, _) => false,
1547            ItemLoader::Full(_, _, _, _, whole_file, _) => *whole_file,
1548        }
1549    }
1550
1551    pub fn adder(&self) -> ItemAdder {
1552        match self {
1553            ItemLoader::Normal(_, _, adder) | ItemLoader::Full(_, _, _, _, _, adder) => *adder,
1554        }
1555    }
1556}