115
pkg/ui/status.go
115
pkg/ui/status.go
@@ -1,15 +1,16 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"epochsilicon/pkg/debug"
|
||||
"git.burkey.co/eburk/epochcli/pkg/epoch"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"turtlesilicon/pkg/patching"
|
||||
"turtlesilicon/pkg/paths"
|
||||
"turtlesilicon/pkg/service"
|
||||
"turtlesilicon/pkg/utils"
|
||||
"epochsilicon/pkg/paths"
|
||||
"epochsilicon/pkg/service"
|
||||
"epochsilicon/pkg/utils"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
@@ -23,7 +24,7 @@ var (
|
||||
// UpdateAllStatuses updates all UI components based on current application state
|
||||
func UpdateAllStatuses() {
|
||||
updateCrossoverStatus()
|
||||
updateTurtleWoWStatus()
|
||||
updateEpochStatus()
|
||||
updatePlayButtonState()
|
||||
updateServiceStatus()
|
||||
|
||||
@@ -76,20 +77,19 @@ func updateCrossoverStatus() {
|
||||
crossoverStatusLabel.Refresh()
|
||||
}
|
||||
|
||||
// updateTurtleWoWStatus updates TurtleWoW path and patch status
|
||||
func updateTurtleWoWStatus() {
|
||||
if paths.TurtlewowPath == "" {
|
||||
turtlewowPathLabel.Segments = []widget.RichTextSegment{&widget.TextSegment{Text: "Not set", Style: widget.RichTextStyle{ColorName: theme.ColorNameError}}}
|
||||
paths.PatchesAppliedTurtleWoW = false // Reset if path is cleared
|
||||
// updateEpochStatus updates Epoch path and patch status
|
||||
func updateEpochStatus() {
|
||||
if paths.EpochPath == "" {
|
||||
epochPathLabel.Segments = []widget.RichTextSegment{&widget.TextSegment{Text: "Not set", Style: widget.RichTextStyle{ColorName: theme.ColorNameError}}}
|
||||
paths.PatchesAppliedEpoch = false // Reset if path is cleared
|
||||
} else {
|
||||
turtlewowPathLabel.Segments = []widget.RichTextSegment{&widget.TextSegment{Text: paths.TurtlewowPath, Style: widget.RichTextStyle{ColorName: theme.ColorNameSuccess}}}
|
||||
epochPathLabel.Segments = []widget.RichTextSegment{&widget.TextSegment{Text: paths.EpochPath, Style: widget.RichTextStyle{ColorName: theme.ColorNameSuccess}}}
|
||||
|
||||
// Check if all required files exist
|
||||
winerosettaDllPath := filepath.Join(paths.TurtlewowPath, "winerosetta.dll")
|
||||
d3d9DllPath := filepath.Join(paths.TurtlewowPath, "d3d9.dll")
|
||||
libSiliconPatchDllPath := filepath.Join(paths.TurtlewowPath, "libSiliconPatch.dll")
|
||||
rosettaX87DirPath := filepath.Join(paths.TurtlewowPath, "rosettax87")
|
||||
dllsTextFile := filepath.Join(paths.TurtlewowPath, "dlls.txt")
|
||||
winerosettaDllPath := filepath.Join(paths.EpochPath, "winerosetta.dll")
|
||||
d3d9DllPath := filepath.Join(paths.EpochPath, "d3d9.dll")
|
||||
rosettaX87DirPath := filepath.Join(paths.EpochPath, "rosettax87")
|
||||
dllsTextFile := filepath.Join(paths.EpochPath, "dlls.txt")
|
||||
rosettaX87ExePath := filepath.Join(rosettaX87DirPath, "rosettax87")
|
||||
libRuntimeRosettaX87Path := filepath.Join(rosettaX87DirPath, "libRuntimeRosettax87")
|
||||
|
||||
@@ -99,70 +99,77 @@ func updateTurtleWoWStatus() {
|
||||
contentStr := string(fileContent)
|
||||
winerosettaPresent := strings.Contains(contentStr, "winerosetta.dll")
|
||||
|
||||
// Check if libSiliconPatch should be present based on user preference
|
||||
prefs, _ := utils.LoadPrefs()
|
||||
libSiliconPatchRequired := prefs.EnableLibSiliconPatch
|
||||
libSiliconPatchPresent := strings.Contains(contentStr, "libSiliconPatch.dll")
|
||||
|
||||
// Validate dlls.txt: winerosetta must be present, libSiliconPatch based on setting
|
||||
if winerosettaPresent && (!libSiliconPatchRequired || libSiliconPatchPresent) {
|
||||
// Validate dlls.txt: winerosetta must be present
|
||||
if winerosettaPresent {
|
||||
dllsFileValid = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for Epoch-specific files
|
||||
epochPatchesApplied := false
|
||||
stats, err := epoch.Update(paths.EpochPath, false, true, true)
|
||||
if err != nil {
|
||||
debug.Printf("Failed to get download Epoch patches: %v", err)
|
||||
}
|
||||
if stats.Outdated == 0 {
|
||||
debug.Println("Nothing is outdated")
|
||||
epochPatchesApplied = true
|
||||
}
|
||||
|
||||
// Check if patched files have the correct size (matches bundled versions)
|
||||
winerosettaDllCorrectSize := utils.CompareFileWithBundledResource(winerosettaDllPath, "winerosetta/winerosetta.dll")
|
||||
d3d9DllCorrectSize := utils.CompareFileWithBundledResource(d3d9DllPath, "winerosetta/d3d9.dll")
|
||||
libSiliconPatchCorrectSize := utils.CompareFileWithBundledResource(libSiliconPatchDllPath, "winerosetta/libSiliconPatch.dll")
|
||||
rosettaX87CorrectSize := utils.CompareFileWithBundledResource(rosettaX87ExePath, "rosettax87/rosettax87")
|
||||
libRuntimeRosettaX87CorrectSize := utils.CompareFileWithBundledResource(libRuntimeRosettaX87Path, "rosettax87/libRuntimeRosettax87")
|
||||
|
||||
// Check if shadowLOD setting is applied (only if user has enabled it in graphics settings)
|
||||
prefs, _ := utils.LoadPrefs()
|
||||
shadowLODRequiredAndApplied := true // Default to true if not required
|
||||
if prefs.SetShadowLOD0 {
|
||||
shadowLODRequiredAndApplied = patching.CheckShadowLODSetting()
|
||||
}
|
||||
|
||||
if utils.PathExists(winerosettaDllPath) && utils.PathExists(d3d9DllPath) && utils.PathExists(libSiliconPatchDllPath) &&
|
||||
if utils.PathExists(winerosettaDllPath) && utils.PathExists(d3d9DllPath) &&
|
||||
utils.DirExists(rosettaX87DirPath) && utils.PathExists(rosettaX87ExePath) &&
|
||||
utils.PathExists(libRuntimeRosettaX87Path) && dllsFileValid &&
|
||||
winerosettaDllCorrectSize && d3d9DllCorrectSize && libSiliconPatchCorrectSize &&
|
||||
rosettaX87CorrectSize && libRuntimeRosettaX87CorrectSize && shadowLODRequiredAndApplied {
|
||||
paths.PatchesAppliedTurtleWoW = true
|
||||
winerosettaDllCorrectSize && d3d9DllCorrectSize &&
|
||||
rosettaX87CorrectSize && libRuntimeRosettaX87CorrectSize && epochPatchesApplied {
|
||||
paths.PatchesAppliedEpoch = true
|
||||
}
|
||||
}
|
||||
turtlewowPathLabel.Refresh()
|
||||
|
||||
if paths.PatchesAppliedTurtleWoW {
|
||||
turtlewowStatusLabel.Segments = []widget.RichTextSegment{&widget.TextSegment{Text: "Patched", Style: widget.RichTextStyle{ColorName: theme.ColorNameSuccess}}}
|
||||
if patchTurtleWoWButton != nil {
|
||||
patchTurtleWoWButton.Disable()
|
||||
}
|
||||
|
||||
epochPathLabel.Refresh()
|
||||
if paths.DownloadingPatches {
|
||||
epochStatusLabel.Segments = []widget.RichTextSegment{&widget.TextSegment{Text: "Downloading...", Style: widget.RichTextStyle{ColorName: theme.ColorNamePrimary}}}
|
||||
if patchEpochButton != nil {
|
||||
patchEpochButton.Disable()
|
||||
}
|
||||
if unpatchTurtleWoWButton != nil {
|
||||
unpatchTurtleWoWButton.Enable()
|
||||
if unpatchEpochButton != nil {
|
||||
unpatchEpochButton.Disable()
|
||||
}
|
||||
} else if paths.PatchesAppliedEpoch {
|
||||
epochStatusLabel.Segments = []widget.RichTextSegment{&widget.TextSegment{Text: "Patched", Style: widget.RichTextStyle{ColorName: theme.ColorNameSuccess}}}
|
||||
if patchEpochButton != nil {
|
||||
patchEpochButton.Disable()
|
||||
}
|
||||
if unpatchEpochButton != nil {
|
||||
unpatchEpochButton.Enable()
|
||||
}
|
||||
} else {
|
||||
turtlewowStatusLabel.Segments = []widget.RichTextSegment{&widget.TextSegment{Text: "Not patched", Style: widget.RichTextStyle{ColorName: theme.ColorNameError}}}
|
||||
if patchTurtleWoWButton != nil {
|
||||
if paths.TurtlewowPath != "" {
|
||||
patchTurtleWoWButton.Enable()
|
||||
epochStatusLabel.Segments = []widget.RichTextSegment{&widget.TextSegment{Text: "Not patched", Style: widget.RichTextStyle{ColorName: theme.ColorNameError}}}
|
||||
if patchEpochButton != nil {
|
||||
if paths.EpochPath != "" {
|
||||
patchEpochButton.Enable()
|
||||
} else {
|
||||
patchTurtleWoWButton.Disable()
|
||||
patchEpochButton.Disable()
|
||||
}
|
||||
}
|
||||
if unpatchTurtleWoWButton != nil {
|
||||
unpatchTurtleWoWButton.Disable()
|
||||
if unpatchEpochButton != nil {
|
||||
unpatchEpochButton.Disable()
|
||||
}
|
||||
}
|
||||
turtlewowStatusLabel.Refresh()
|
||||
epochStatusLabel.Refresh()
|
||||
}
|
||||
|
||||
// updatePlayButtonState enables/disables play and launch buttons based on current state
|
||||
func updatePlayButtonState() {
|
||||
launchEnabled := paths.PatchesAppliedTurtleWoW && paths.PatchesAppliedCrossOver &&
|
||||
paths.TurtlewowPath != "" && paths.CrossoverPath != "" && service.IsServiceRunning()
|
||||
launchEnabled := paths.PatchesAppliedEpoch && paths.PatchesAppliedCrossOver &&
|
||||
paths.EpochPath != "" && paths.CrossoverPath != "" && service.IsServiceRunning()
|
||||
|
||||
if launchButton != nil {
|
||||
if launchEnabled {
|
||||
@@ -239,7 +246,7 @@ func updateServiceStatus() {
|
||||
serviceStatusLabel.Refresh()
|
||||
}
|
||||
if startServiceButton != nil {
|
||||
if paths.TurtlewowPath != "" && paths.PatchesAppliedTurtleWoW {
|
||||
if paths.EpochPath != "" && paths.PatchesAppliedEpoch {
|
||||
startServiceButton.Enable()
|
||||
} else {
|
||||
startServiceButton.Disable()
|
||||
|
Reference in New Issue
Block a user