diff --git a/model/gurps/sheet_settings.go b/model/gurps/sheet_settings.go index beb02a18..b63f8c66 100644 --- a/model/gurps/sheet_settings.go +++ b/model/gurps/sheet_settings.go @@ -47,6 +47,7 @@ type SheetSettingsData struct { ShowTraitModifierAdj bool `json:"show_trait_modifier_adj,alt=show_advantage_modifier_adj,omitempty"` ShowEquipmentModifierAdj bool `json:"show_equipment_modifier_adj,omitempty"` ShowSpellAdj bool `json:"show_spell_adj,omitempty"` + HideSourceMismatch bool `json:"hide_source_mismatch,omitempty"` UseTitleInFooter bool `json:"use_title_in_footer,omitempty"` ExcludeUnspentPointsFromTotal bool `json:"exclude_unspent_points_from_total"` } diff --git a/ux/equipment_provider.go b/ux/equipment_provider.go index c5ee1e1c..0a3e8876 100644 --- a/ux/equipment_provider.go +++ b/ux/equipment_provider.go @@ -202,7 +202,9 @@ func (p *equipmentProvider) ColumnIDs() []int { } columnIDs = append(columnIDs, gurps.EquipmentReferenceColumn) if p.forPage { - columnIDs = append(columnIDs, gurps.EquipmentLibSrcColumn) + if entity := p.DataOwner().OwningEntity(); entity != nil && !entity.SheetSettings.HideSourceMismatch { + columnIDs = append(columnIDs, gurps.EquipmentLibSrcColumn) + } } return columnIDs } diff --git a/ux/notes_provider.go b/ux/notes_provider.go index aa70c57d..7a62c5ed 100644 --- a/ux/notes_provider.go +++ b/ux/notes_provider.go @@ -117,7 +117,9 @@ func (p *notesProvider) ColumnIDs() []int { gurps.NoteReferenceColumn, } if p.forPage { - columnIDs = append(columnIDs, gurps.NoteLibSrcColumn) + if entity := p.DataOwner().OwningEntity(); entity != nil && !entity.SheetSettings.HideSourceMismatch { + columnIDs = append(columnIDs, gurps.NoteLibSrcColumn) + } } return columnIDs } diff --git a/ux/page_list.go b/ux/page_list.go index f72b00c9..0982ebb5 100644 --- a/ux/page_list.go +++ b/ux/page_list.go @@ -155,6 +155,22 @@ func newPageList[T gurps.NodeTypes](owner Rebuildable, provider TableProvider[T] return p } +func (p *PageList[T]) needReconstruction() bool { + if p == nil { + return true + } + ids := p.provider.ColumnIDs() + if len(ids) != len(p.Table.Columns) { + return true + } + for i, col := range p.Table.Columns { + if col.ID != ids[i] { + return true + } + } + return false +} + func (p *PageList[T]) installMoveToCarriedEquipmentHandler(owner Rebuildable) { if sheet, ok := owner.AsPanel().Self.(*Sheet); ok { var t *unison.Table[*Node[*gurps.Equipment]] diff --git a/ux/sheet.go b/ux/sheet.go index dceb43f9..cbbec024 100644 --- a/ux/sheet.go +++ b/ux/sheet.go @@ -634,42 +634,42 @@ func (s *Sheet) createLists() { rowPanel.AddChild(s.RangedWeapons) } case gurps.BlockLayoutTraitsKey: - if s.Traits == nil { + if s.Traits.needReconstruction() { s.Traits = NewTraitsPageList(s, s.entity) } else { s.Traits.Sync() } rowPanel.AddChild(s.Traits) case gurps.BlockLayoutSkillsKey: - if s.Skills == nil { + if s.Skills.needReconstruction() { s.Skills = NewSkillsPageList(s, s.entity) } else { s.Skills.Sync() } rowPanel.AddChild(s.Skills) case gurps.BlockLayoutSpellsKey: - if s.Spells == nil { + if s.Spells.needReconstruction() { s.Spells = NewSpellsPageList(s, s.entity) } else { s.Spells.Sync() } rowPanel.AddChild(s.Spells) case gurps.BlockLayoutEquipmentKey: - if s.CarriedEquipment == nil { + if s.CarriedEquipment.needReconstruction() { s.CarriedEquipment = NewCarriedEquipmentPageList(s, s.entity) } else { s.CarriedEquipment.Sync() } rowPanel.AddChild(s.CarriedEquipment) case gurps.BlockLayoutOtherEquipmentKey: - if s.OtherEquipment == nil { + if s.OtherEquipment.needReconstruction() { s.OtherEquipment = NewOtherEquipmentPageList(s, s.entity) } else { s.OtherEquipment.Sync() } rowPanel.AddChild(s.OtherEquipment) case gurps.BlockLayoutNotesKey: - if s.Notes == nil { + if s.Notes.needReconstruction() { s.Notes = NewNotesPageList(s, s.entity) } else { s.Notes.Sync() diff --git a/ux/sheet_settings_dockable.go b/ux/sheet_settings_dockable.go index defd9ee7..685f7737 100644 --- a/ux/sheet_settings_dockable.go +++ b/ux/sheet_settings_dockable.go @@ -40,6 +40,7 @@ type sheetSettingsDockable struct { showTraitModifier *unison.CheckBox showEquipmentModifier *unison.CheckBox showSpellAdjustments *unison.CheckBox + hideSourceMismatch *unison.CheckBox showTitleInsteadOfNameInPageFooter *unison.CheckBox useMultiplicativeModifiers *unison.CheckBox useModifyDicePlusAdds *unison.CheckBox @@ -149,6 +150,11 @@ func (d *sheetSettingsDockable) createOptions(content *unison.Panel) { HSpacing: unison.StdHSpacing, VSpacing: unison.StdVSpacing, }) + d.hideSourceMismatch = d.addCheckBox(panel, i18n.Text("Show library source column"), + !s.HideSourceMismatch, func() { + d.settings().HideSourceMismatch = d.hideSourceMismatch.State != check.On + d.syncSheet(true) + }) d.showTraitModifier = d.addCheckBox(panel, i18n.Text("Show trait modifier cost adjustments"), s.ShowTraitModifierAdj, func() { d.settings().ShowTraitModifierAdj = d.showTraitModifier.State == check.On @@ -397,6 +403,7 @@ func (d *sheetSettingsDockable) reset() { func (d *sheetSettingsDockable) sync() { s := d.settings() d.damageProgressionPopup.Select(s.DamageProgression) + d.hideSourceMismatch.State = check.FromBool(!s.HideSourceMismatch) d.showTraitModifier.State = check.FromBool(s.ShowTraitModifierAdj) d.showEquipmentModifier.State = check.FromBool(s.ShowEquipmentModifierAdj) d.showSpellAdjustments.State = check.FromBool(s.ShowSpellAdj) diff --git a/ux/skills_provider.go b/ux/skills_provider.go index 54a96637..1d0572db 100644 --- a/ux/skills_provider.go +++ b/ux/skills_provider.go @@ -157,7 +157,9 @@ func (p *skillsProvider) ColumnIDs() []int { } columnIDs = append(columnIDs, gurps.SkillReferenceColumn) if p.forPage { - columnIDs = append(columnIDs, gurps.SkillLibSrcColumn) + if entity := p.DataOwner().OwningEntity(); entity != nil && !entity.SheetSettings.HideSourceMismatch { + columnIDs = append(columnIDs, gurps.SkillLibSrcColumn) + } } return columnIDs } diff --git a/ux/spells_provider.go b/ux/spells_provider.go index bd28058f..f036a211 100644 --- a/ux/spells_provider.go +++ b/ux/spells_provider.go @@ -171,7 +171,9 @@ func (p *spellsProvider) ColumnIDs() []int { } columnIDs = append(columnIDs, gurps.SpellReferenceColumn) if p.forPage { - columnIDs = append(columnIDs, gurps.SpellLibSrcColumn) + if entity := p.DataOwner().OwningEntity(); entity != nil && !entity.SheetSettings.HideSourceMismatch { + columnIDs = append(columnIDs, gurps.SpellLibSrcColumn) + } } return columnIDs } diff --git a/ux/traits_provider.go b/ux/traits_provider.go index dcb35759..1e626884 100644 --- a/ux/traits_provider.go +++ b/ux/traits_provider.go @@ -157,7 +157,9 @@ func (p *traitsProvider) ColumnIDs() []int { } columnIDs = append(columnIDs, gurps.TraitReferenceColumn) if p.forPage { - columnIDs = append(columnIDs, gurps.TraitLibSrcColumn) + if entity := p.DataOwner().OwningEntity(); entity != nil && !entity.SheetSettings.HideSourceMismatch { + columnIDs = append(columnIDs, gurps.TraitLibSrcColumn) + } } return columnIDs }