From f0832660b8f4e8577de8381e09935a85f62d8d4c Mon Sep 17 00:00:00 2001 From: Richard Wilkes Date: Sun, 20 Oct 2024 12:58:35 -0700 Subject: [PATCH] Fixes #885: Default character sheet filename doesn't change when character name is changed --- ux/sheet.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ux/sheet.go b/ux/sheet.go index 5df36223a..156090890 100644 --- a/ux/sheet.go +++ b/ux/sheet.go @@ -15,6 +15,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "time" "github.com/richardwilkes/gcs/v5/model/gurps" @@ -412,7 +413,7 @@ func (s *Sheet) TitleIcon(suggestedSize unison.Size) unison.Drawable { // Title implements workspace.FileBackedDockable func (s *Sheet) Title() string { - return fs.BaseName(s.path) + return fs.BaseName(s.BackingFilePath()) } func (s *Sheet) String() string { @@ -421,11 +422,18 @@ func (s *Sheet) String() string { // Tooltip implements workspace.FileBackedDockable func (s *Sheet) Tooltip() string { - return s.path + return s.BackingFilePath() } // BackingFilePath implements workspace.FileBackedDockable func (s *Sheet) BackingFilePath() string { + if s.needsSaveAsPrompt { + name := strings.TrimSpace(s.entity.Profile.Name) + if name == "" { + name = i18n.Text("Unnamed Character") + } + return name + gurps.SheetExt + } return s.path }