Skip to content

Commit

Permalink
Fixes #885: Default character sheet filename doesn't change when char…
Browse files Browse the repository at this point in the history
…acter name is changed
  • Loading branch information
richardwilkes committed Oct 20, 2024
1 parent 1213010 commit f083266
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ux/sheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"time"

"github.com/richardwilkes/gcs/v5/model/gurps"
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down

0 comments on commit f083266

Please sign in to comment.