added graphics settings section with more control (shadowLOD and libSilicon can be turned off)

This commit is contained in:
aomizu
2025-07-10 13:36:21 +09:00
parent 2766aee96f
commit 9fd6ca731c
8 changed files with 726 additions and 34 deletions

View File

@@ -73,7 +73,7 @@ func createOptionsComponents() {
debug.Printf("Successfully applied recommended settings")
// Show success dialog if we have a window reference
if currentWindow != nil {
dialog.ShowInformation("Success", "Recommended graphics settings have been applied to Config.wtf", currentWindow)
dialog.ShowInformation("Success", "Recommended graphics settings have been applied", currentWindow)
}
// Update button state
updateRecommendedSettingsButton()
@@ -92,6 +92,9 @@ func createOptionsComponents() {
// Create Wine registry Option-as-Alt buttons and status
createWineRegistryComponents()
// Create graphics settings components
createGraphicsSettingsComponents()
// Load environment variables from preferences
if prefs.EnvironmentVariables != "" {
launcher.CustomEnvVars = prefs.EnvironmentVariables
@@ -476,3 +479,187 @@ func showRecommendedSettingsHelpPopup() {
helpPopup.Show()
}
// createGraphicsSettingsComponents creates all graphics settings checkboxes and buttons
func createGraphicsSettingsComponents() {
// Load preferences for initial values
prefs, _ := utils.LoadPrefs()
// Create Reduce Terrain Distance setting with help button
reduceTerrainDistanceCheckbox = widget.NewCheck("", func(checked bool) {
prefs, _ := utils.LoadPrefs()
prefs.ReduceTerrainDistance = checked
utils.SavePrefs(prefs)
debug.Printf("Reduce terrain distance: %v", checked)
updateApplyGraphicsSettingsButton()
})
reduceTerrainDistanceCheckbox.SetChecked(prefs.ReduceTerrainDistance)
reduceTerrainDistanceHelpButton = widget.NewButton("?", func() {
showGraphicsSettingHelpPopup("Reduce Terrain Distance", "Sets the draw distance to the lowest setting. This will drastically increase your FPS", "High Performance Impact")
})
reduceTerrainDistanceHelpButton.Importance = widget.MediumImportance
// Create Set Multisample to 2x setting with help button
setMultisampleTo2xCheckbox = widget.NewCheck("", func(checked bool) {
prefs, _ := utils.LoadPrefs()
prefs.SetMultisampleTo2x = checked
utils.SavePrefs(prefs)
debug.Printf("Set multisample to 2x: %v", checked)
updateApplyGraphicsSettingsButton()
})
setMultisampleTo2xCheckbox.SetChecked(prefs.SetMultisampleTo2x)
setMultisampleTo2xHelpButton = widget.NewButton("?", func() {
showGraphicsSettingHelpPopup("Set Multisample to 2x", "Might reduce your FPS slightly on lower end machines, but makes sure the portraits load properly.", "Medium Performance Impact")
})
setMultisampleTo2xHelpButton.Importance = widget.MediumImportance
// Create Set Shadow LOD to 0 setting with help button
setShadowLOD0Checkbox = widget.NewCheck("", func(checked bool) {
prefs, _ := utils.LoadPrefs()
prefs.SetShadowLOD0 = checked
// Track if user manually disabled this setting
if !checked {
prefs.UserDisabledShadowLOD = true
} else {
prefs.UserDisabledShadowLOD = false
}
utils.SavePrefs(prefs)
debug.Printf("Set shadow LOD to 0: %v (user manually changed)", checked)
updateApplyGraphicsSettingsButton()
})
setShadowLOD0Checkbox.SetChecked(prefs.SetShadowLOD0)
setShadowLOD0HelpButton = widget.NewButton("?", func() {
showGraphicsSettingHelpPopup("Set Shadow LOD to 0", "Turns off all shadows. This will give you ~10% more FPS.", "High Performance Impact")
})
setShadowLOD0HelpButton.Importance = widget.MediumImportance
// Create Enable libSiliconPatch setting with help button
libSiliconPatchCheckbox = widget.NewCheck("", func(checked bool) {
prefs, _ := utils.LoadPrefs()
prefs.EnableLibSiliconPatch = checked
// Track if user manually disabled this setting
if !checked {
prefs.UserDisabledLibSiliconPatch = true
} else {
prefs.UserDisabledLibSiliconPatch = false
}
utils.SavePrefs(prefs)
debug.Printf("Enable libSiliconPatch: %v (user manually changed)", checked)
updateApplyGraphicsSettingsButton()
})
libSiliconPatchCheckbox.SetChecked(prefs.EnableLibSiliconPatch)
libSiliconPatchHelpButton = widget.NewButton("?", func() {
showGraphicsSettingHelpPopup("Enable libSiliconPatch", "Hooks into the WoW process and replaces slow X87 instructions with SSE2 instructions that Rosetta can translate much quicker, resulting in an increase in FPS (2x or more). May potentially cause graphical bugs.", "Very High Performance Impact")
})
libSiliconPatchHelpButton.Importance = widget.MediumImportance
applyGraphicsSettingsButton = widget.NewButton("Apply Graphics Settings", func() {
err := patching.ApplyGraphicsSettings(currentWindow)
if err != nil {
debug.Printf("Failed to apply graphics settings: %v", err)
if currentWindow != nil {
dialog.ShowError(fmt.Errorf("failed to apply graphics settings: %v", err), currentWindow)
}
} else {
debug.Printf("Successfully applied graphics settings")
if currentWindow != nil {
dialog.ShowInformation("Success", "Graphics settings have been applied", currentWindow)
}
// Refresh checkboxes to reflect current state
refreshGraphicsSettingsCheckboxes()
}
})
applyGraphicsSettingsButton.Importance = widget.MediumImportance
// Initialize button state
updateApplyGraphicsSettingsButton()
}
// updateApplyGraphicsSettingsButton updates the state of the apply graphics settings button
func updateApplyGraphicsSettingsButton() {
if applyGraphicsSettingsButton == nil {
return
}
// Always enable the button since we need to handle both adding and removing settings
applyGraphicsSettingsButton.Enable()
applyGraphicsSettingsButton.SetText("Apply Changes")
}
// refreshGraphicsSettingsCheckboxes updates the checkbox states from current preferences
func refreshGraphicsSettingsCheckboxes() {
prefs, _ := utils.LoadPrefs()
if reduceTerrainDistanceCheckbox != nil {
reduceTerrainDistanceCheckbox.SetChecked(prefs.ReduceTerrainDistance)
}
if setMultisampleTo2xCheckbox != nil {
setMultisampleTo2xCheckbox.SetChecked(prefs.SetMultisampleTo2x)
}
if setShadowLOD0Checkbox != nil {
setShadowLOD0Checkbox.SetChecked(prefs.SetShadowLOD0)
}
if libSiliconPatchCheckbox != nil {
libSiliconPatchCheckbox.SetChecked(prefs.EnableLibSiliconPatch)
}
// Update the apply button state
updateApplyGraphicsSettingsButton()
}
// showGraphicsSettingHelpPopup shows a help popup for a specific graphics setting
func showGraphicsSettingHelpPopup(title, description, impact string) {
if currentWindow == nil {
return
}
// Create help content
helpTitle := widget.NewRichTextFromMarkdown("# " + title)
descriptionLabel := widget.NewLabel(description)
descriptionLabel.Wrapping = fyne.TextWrapWord
impactLabel := widget.NewLabel(impact)
impactLabel.TextStyle = fyne.TextStyle{Bold: true}
// Create OK button
okButton := widget.NewButton("OK", func() {
// This will be set when the popup is created
})
okButton.Importance = widget.MediumImportance
// Create help content container
helpContentContainer := container.NewVBox(
container.NewCenter(helpTitle),
widget.NewSeparator(),
descriptionLabel,
widget.NewSeparator(),
impactLabel,
widget.NewSeparator(),
container.NewCenter(okButton),
)
// Calculate popup size
windowSize := currentWindow.Content().Size()
popupWidth := windowSize.Width * 2 / 3
popupHeight := windowSize.Height / 2
// Create the help popup
helpPopup := widget.NewModalPopUp(container.NewPadded(helpContentContainer), currentWindow.Canvas())
helpPopup.Resize(fyne.NewSize(popupWidth, popupHeight))
// Set the OK button action to hide the help popup
okButton.OnTapped = func() {
helpPopup.Hide()
}
helpPopup.Show()
}

View File

@@ -13,6 +13,8 @@ import (
"howett.net/plist"
"turtlesilicon/pkg/debug"
"turtlesilicon/pkg/patching"
"turtlesilicon/pkg/paths"
"turtlesilicon/pkg/utils"
)
@@ -23,25 +25,84 @@ func showOptionsPopup() {
return
}
// Create options content with better organization and smaller titles
optionsTitle := widget.NewLabel("Options")
optionsTitle.TextStyle = fyne.TextStyle{Bold: true}
// Create label for recommended settings
recommendedSettingsLabel := widget.NewLabel("Graphics settings:")
// Check graphics settings presence and update preferences before showing UI
patching.CheckGraphicsSettingsPresence()
gameOptionsContainer := container.NewVBox(
optionsTitle,
// Load graphics settings from Config.wtf and update preferences
if err := patching.LoadGraphicsSettingsFromConfig(); err != nil {
debug.Printf("Warning: failed to load graphics settings from Config.wtf: %v", err)
}
// Refresh checkbox states to reflect current settings
refreshGraphicsSettingsCheckboxes()
// Create General tab content
generalTitle := widget.NewLabel("General Settings")
generalTitle.TextStyle = fyne.TextStyle{Bold: true}
generalContainer := container.NewVBox(
generalTitle,
widget.NewSeparator(),
metalHudCheckbox,
showTerminalCheckbox,
vanillaTweaksCheckbox,
autoDeleteWdbCheckbox,
widget.NewSeparator(),
container.NewBorder(nil, nil, recommendedSettingsLabel, container.NewHBox(applyRecommendedSettingsButton, recommendedSettingsHelpButton), nil),
widget.NewSeparator(),
container.NewBorder(nil, nil, nil, container.NewHBox(enableOptionAsAltButton, disableOptionAsAltButton), optionAsAltStatusLabel),
)
// Create Graphics tab content
graphicsTitle := widget.NewLabel("Graphics Settings")
graphicsTitle.TextStyle = fyne.TextStyle{Bold: true}
graphicsDescription := widget.NewLabel("Select graphics settings to apply to Config.wtf:")
graphicsDescription.TextStyle = fyne.TextStyle{Italic: true}
// Create bold text labels for each setting
terrainLabel := widget.NewLabel("Reduce Terrain Distance")
terrainLabel.TextStyle = fyne.TextStyle{Bold: true}
multisampleLabel := widget.NewLabel("Set Multisample to 2x")
multisampleLabel.TextStyle = fyne.TextStyle{Bold: true}
shadowLabel := widget.NewLabel("Set Shadow LOD to 0")
shadowLabel.TextStyle = fyne.TextStyle{Bold: true}
libSiliconPatchLabel := widget.NewLabel("Enable libSiliconPatch")
libSiliconPatchLabel.TextStyle = fyne.TextStyle{Bold: true}
// Create setting rows with help buttons between checkbox and label
terrainRow := container.NewHBox(
reduceTerrainDistanceCheckbox,
reduceTerrainDistanceHelpButton,
terrainLabel)
multisampleRow := container.NewHBox(
setMultisampleTo2xCheckbox,
setMultisampleTo2xHelpButton,
multisampleLabel)
shadowRow := container.NewHBox(
setShadowLOD0Checkbox,
setShadowLOD0HelpButton,
shadowLabel)
libSiliconPatchRow := container.NewHBox(
libSiliconPatchCheckbox,
libSiliconPatchHelpButton,
libSiliconPatchLabel)
graphicsContainer := container.NewVBox(
graphicsTitle,
widget.NewSeparator(),
graphicsDescription,
widget.NewSeparator(),
terrainRow,
multisampleRow,
shadowRow,
libSiliconPatchRow,
widget.NewSeparator(),
container.NewCenter(applyGraphicsSettingsButton),
)
// Create Environment Variables tab content
envVarsTitle := widget.NewLabel("Environment Variables")
envVarsTitle.TextStyle = fyne.TextStyle{Bold: true}
envVarsContainer := container.NewVBox(
@@ -50,13 +111,15 @@ func showOptionsPopup() {
envVarsEntry,
)
// Create a scrollable container for all options
optionsContent := container.NewVBox(
gameOptionsContainer,
envVarsContainer,
// Create tabs
tabs := container.NewAppTabs(
container.NewTabItem("General", container.NewScroll(generalContainer)),
container.NewTabItem("Graphics", container.NewScroll(graphicsContainer)),
container.NewTabItem("Environment", container.NewScroll(envVarsContainer)),
)
scrollContainer := container.NewScroll(optionsContent)
// Set tab location to top
tabs.SetTabLocation(container.TabLocationTop)
// Create close button
closeButton := widget.NewButton("Close", func() {
@@ -65,11 +128,11 @@ func showOptionsPopup() {
// Create the popup content with close button
popupContent := container.NewBorder(
nil, // top
container.NewCenter(closeButton), // bottom
nil, // left
nil, // right
container.NewPadded(scrollContainer), // center
nil, // top
container.NewCenter(closeButton), // bottom
nil, // left
nil, // right
container.NewPadded(tabs), // center
)
// Get the window size and calculate 2/3 size

View File

@@ -97,7 +97,15 @@ func updateTurtleWoWStatus() {
if utils.PathExists(dllsTextFile) {
if fileContent, err := os.ReadFile(dllsTextFile); err == nil {
contentStr := string(fileContent)
if strings.Contains(contentStr, "winerosetta.dll") && strings.Contains(contentStr, "libSiliconPatch.dll") {
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) {
dllsFileValid = true
}
}
@@ -110,14 +118,18 @@ func updateTurtleWoWStatus() {
rosettaX87CorrectSize := utils.CompareFileWithBundledResource(rosettaX87ExePath, "rosettax87/rosettax87")
libRuntimeRosettaX87CorrectSize := utils.CompareFileWithBundledResource(libRuntimeRosettaX87Path, "rosettax87/libRuntimeRosettax87")
// Check if shadowLOD setting is applied
shadowLODApplied := patching.CheckShadowLODSetting()
// 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) &&
utils.DirExists(rosettaX87DirPath) && utils.PathExists(rosettaX87ExePath) &&
utils.PathExists(libRuntimeRosettaX87Path) && dllsFileValid &&
winerosettaDllCorrectSize && d3d9DllCorrectSize && libSiliconPatchCorrectSize &&
rosettaX87CorrectSize && libRuntimeRosettaX87CorrectSize && shadowLODApplied {
rosettaX87CorrectSize && libRuntimeRosettaX87CorrectSize && shadowLODRequiredAndApplied {
paths.PatchesAppliedTurtleWoW = true
}
}

View File

@@ -1,7 +1,9 @@
package ui
import (
"turtlesilicon/pkg/debug"
"turtlesilicon/pkg/paths"
"turtlesilicon/pkg/patching"
"turtlesilicon/pkg/utils"
"fyne.io/fyne/v2"
@@ -35,6 +37,18 @@ func CreateUI(myWindow fyne.Window) fyne.CanvasObject {
// Check default CrossOver path
paths.CheckDefaultCrossOverPath()
// Check graphics settings presence and set default state
patching.CheckGraphicsSettingsPresence()
// Load graphics settings from Config.wtf and update UI
if err := patching.LoadGraphicsSettingsFromConfig(); err != nil {
// Log error but continue - this is not critical for app startup
debug.Printf("Warning: failed to load graphics settings from Config.wtf: %v", err)
} else {
// Refresh checkbox states to reflect loaded settings
refreshGraphicsSettingsCheckboxes()
}
// Create header, main content and bottom bar
headerContent := createHeaderContainer()
mainContent := createMainContent(myWindow)

View File

@@ -45,6 +45,19 @@ var (
// Environment variables entry
envVarsEntry *widget.Entry
// Graphics settings checkboxes
reduceTerrainDistanceCheckbox *widget.Check
setMultisampleTo2xCheckbox *widget.Check
setShadowLOD0Checkbox *widget.Check
libSiliconPatchCheckbox *widget.Check
applyGraphicsSettingsButton *widget.Button
// Graphics settings help buttons
reduceTerrainDistanceHelpButton *widget.Button
setMultisampleTo2xHelpButton *widget.Button
setShadowLOD0HelpButton *widget.Button
libSiliconPatchHelpButton *widget.Button
// Window reference for popup functionality
currentWindow fyne.Window