From 522da890cbefaffc25d7461663af6a2f27d69ef0 Mon Sep 17 00:00:00 2001 From: sewn Date: Fri, 20 Oct 2023 14:41:54 +0300 Subject: [PATCH] feat: splash log --- cmd/vinegar/binary.go | 24 +++++++++++++++++++++--- internal/splash/splash.go | 16 ++++++++++++++++ roblox/version.go | 4 ++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index 3392624f..68eba0bf 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -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 @@ -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 } @@ -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) @@ -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 } @@ -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 @@ -264,6 +274,7 @@ func (b *Binary) Install() error { } } + b.Splash.Log("Writing AppSettings") if err := bootstrapper.WriteAppSettings(b.Dir); err != nil { return err } @@ -272,6 +283,7 @@ func (b *Binary) Install() error { return err } + b.Splash.Log("Cleaning up") if err := state.CleanPackages(); err != nil { return err } @@ -284,6 +296,8 @@ 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 @@ -291,6 +305,7 @@ func (b *Binary) PerformPackages(m *bootstrapper.Manifest, fn func(bootstrapper. donePkgs++ b.Splash.Progress(float32(donePkgs) / float32(pkgsLen)) + b.Splash.Log(pkg.Name) return nil }) @@ -373,6 +388,8 @@ 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 { @@ -380,7 +397,8 @@ func (b *Binary) Command(args ...string) (*wine.Cmd, error) { } } - 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 { diff --git a/internal/splash/splash.go b/internal/splash/splash.go index 5515656e..4b3ddcc5 100644 --- a/internal/splash/splash.go +++ b/internal/splash/splash.go @@ -37,6 +37,7 @@ type Splash struct { logo image.Image message string + log string desc string showLog string progress float32 @@ -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() @@ -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{} diff --git a/roblox/version.go b/roblox/version.go index 7c66d9a1..fdef6cea 100644 --- a/roblox/version.go +++ b/roblox/version.go @@ -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.