Skip to content

Commit

Permalink
feat: splash log
Browse files Browse the repository at this point in the history
  • Loading branch information
apprehensions committed Oct 20, 2023
1 parent 4e5ec77 commit 522da89
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
24 changes: 21 additions & 3 deletions cmd/vinegar/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func NewBinary(bt roblox.BinaryType, cfg *config.Config, pfx *wine.Prefix) Binar
}

func (b *Binary) Run(args ...string) error {
b.Splash.Log("")

cmd, err := b.Command(args...)
if err != nil {
return err
Expand All @@ -75,6 +77,7 @@ func (b *Binary) Run(args ...string) error {
// auto kill prefix is enabled
if util.CommFound("Roblox") {
log.Println("Roblox is already running, not killing wineprefix after exit")
b.Splash.Log("Roblox is already running")
kill = false
}

Expand Down Expand Up @@ -188,7 +191,7 @@ func (b *Binary) Setup() error {
return err
}

b.Splash.Desc(fmt.Sprintf("%s %s", ver.GUID, ver.Channel))
b.Splash.Desc(ver.String())
b.Version = ver
b.Dir = filepath.Join(dirs.Versions, ver.GUID)

Expand All @@ -197,26 +200,32 @@ func (b *Binary) Setup() error {
log.Printf("Failed to retrieve stored %s version: %s", b.Name, err)
}

stateVer = ""

if stateVer != ver.GUID {
log.Printf("Installing %s (%s -> %s)", b.Name, stateVer, ver)
log.Printf("Installing %s (%s -> %s)", b.Name, stateVer, ver.GUID)

if err := b.Install(); err != nil {
return err
}
} else {
b.Splash.Log("Up to date")
log.Printf("%s is up to date (%s)", b.Name, ver.GUID)
}

b.Config.Env.Setenv()

b.Splash.Log("Setting Renderer")
if err := b.Config.FFlags.SetRenderer(b.Config.Renderer); err != nil {
return err
}

b.Splash.Log("Applying FFlags")
if err := b.Config.FFlags.Apply(b.Dir); err != nil {
return err
}

b.Splash.Log("Applying Overlay modifications")
if err := dirs.OverlayDir(b.Dir); err != nil {
return err
}
Expand All @@ -236,6 +245,7 @@ func (b *Binary) Install() error {
return err
}

b.Splash.Log("Fetching package manifest")
manifest, err := bootstrapper.FetchManifest(&b.Version)
if err != nil {
return err
Expand Down Expand Up @@ -264,6 +274,7 @@ func (b *Binary) Install() error {
}
}

b.Splash.Log("Writing AppSettings")
if err := bootstrapper.WriteAppSettings(b.Dir); err != nil {
return err
}
Expand All @@ -272,6 +283,7 @@ func (b *Binary) Install() error {
return err
}

b.Splash.Log("Cleaning up")
if err := state.CleanPackages(); err != nil {
return err
}
Expand All @@ -284,13 +296,16 @@ func (b *Binary) PerformPackages(m *bootstrapper.Manifest, fn func(bootstrapper.
pkgsLen := len(m.Packages)

return m.Packages.Perform(func(pkg bootstrapper.Package) error {
b.Splash.Log(pkg.Name)

err := fn(pkg)
if err != nil {
return err
}

donePkgs++
b.Splash.Progress(float32(donePkgs) / float32(pkgsLen))
b.Splash.Log(pkg.Name)

return nil
})
Expand Down Expand Up @@ -373,14 +388,17 @@ func (b *Binary) Command(args ...string) (*wine.Cmd, error) {
}

if b.GlobalConfig.MultipleInstances {
b.Splash.Log("Launching robloxmutexer")

mutexer := b.Prefix.Command("wine", filepath.Join(BinPrefix, "robloxmutexer.exe"))
err := mutexer.Start()
if err != nil {
return &wine.Cmd{}, err
}
}

cmd := b.Prefix.Wine(filepath.Join(b.Dir, b.Type.Executable()), args...)
exe := filepath.Join(b.Dir, b.Type.Executable())
cmd := b.Prefix.Wine(exe, args...)

launcher := strings.Fields(b.Config.Launcher)
if len(launcher) >= 1 {
Expand Down
16 changes: 16 additions & 0 deletions internal/splash/splash.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Splash struct {

logo image.Image
message string
log string
desc string
showLog string
progress float32
Expand All @@ -48,6 +49,11 @@ func (ui *Splash) Message(msg string) {
ui.Invalidate()
}

func (ui *Splash) Log(msg string) {
ui.log = msg
ui.Invalidate()
}

func (ui *Splash) Desc(desc string) {
ui.desc = desc
ui.Invalidate()
Expand Down Expand Up @@ -153,6 +159,16 @@ func (ui *Splash) Run() error {
})
}),

layout.Rigid(func(gtx C) D {
if ui.log == "" {
return D{}
}

info := material.Body2(ui.Theme, ui.log)
info.Color = ui.Theme.Palette.ContrastFg
return info.Layout(gtx)
}),

layout.Rigid(func(gtx C) D {
if ui.desc == "" {
return D{}
Expand Down
4 changes: 4 additions & 0 deletions roblox/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ type Version struct {
GUID string
}

func (v Version) String() string {
return v.Channel + " " + v.GUID
}

func ChannelPath(channel string) string {
// Ensure that the channel is lowercased, since internally in
// ClientSettings it will be lowercased, but not on the deploy mirror.
Expand Down

0 comments on commit 522da89

Please sign in to comment.