Skip to content

Commit

Permalink
Remove old patches, fix patches not being saved properly when uncheck…
Browse files Browse the repository at this point in the history
…ing all of them
  • Loading branch information
Sora-yx committed Feb 27, 2025
1 parent d0e4db5 commit 8e97103
Show file tree
Hide file tree
Showing 4 changed files with 466 additions and 513 deletions.
7 changes: 0 additions & 7 deletions SA-Mod-Manager/Configuration/SA2/GameSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,6 @@ public enum SA2SettingsVersions
/// </summary>
public TestSpawnSettings TestSpawn { get; set; } = new();

/// <summary>
/// Patches for SA2.
/// </summary>
[Obsolete]
public GamePatches Patches { get; set; } = new();


public List<string> EnabledGamePatches { get; set; } = [];

/// <summary>
Expand Down
6 changes: 0 additions & 6 deletions SA-Mod-Manager/Configuration/SADX/GameSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -787,11 +787,6 @@ public enum SADXSettingsVersions
/// </summary>
public TestSpawnSettings TestSpawn { get; set; } = new();

/// <summary>
/// Patches for SADX.
/// </summary>
[Obsolete]
public GamePatches Patches { get; set; } = new();

public List<string> EnabledGamePatches { get; set; } = [];

Expand Down Expand Up @@ -832,7 +827,6 @@ public void ConvertFromV0(SADXLoaderInfo oldSettings)
Controller.ConvertFromV0(oldSettings);
Sound.ConvertFromV0(oldSettings);
TestSpawn.ConvertFromV0(oldSettings);
Patches.ConvertFromV0(oldSettings);
DebugSettings.ConvertFromV0(oldSettings);

SettingsVersion = (int)SADXSettingsVersions.v1;
Expand Down
121 changes: 52 additions & 69 deletions SA-Mod-Manager/Controls/SA2/GameConfig.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

namespace SAModManager.Controls.SA2
{
/// <summary>
/// Interaction logic for GameConfig.xaml
/// </summary>
public partial class GameConfig : UserControl
{
/// <summary>
/// Interaction logic for GameConfig.xaml
/// </summary>
public partial class GameConfig : UserControl
{
#region Variables
public GameSettings GameProfile;

Expand Down Expand Up @@ -88,17 +88,17 @@ private void HorizontalRes_Changed(object sender, RoutedEventArgs e)

private void comboScreen_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (GraphicsManager.Screens.Count > 1)
GraphicsManager.UpdateResolutionPresets(comboScreen.SelectedIndex);
}
if (GraphicsManager.Screens.Count > 1)
GraphicsManager.UpdateResolutionPresets(comboScreen.SelectedIndex);
}

private void chkRatio_Click(object sender, RoutedEventArgs e)
{
if (chkRatio.IsChecked == true)
{
txtResX.IsEnabled = false;
decimal resYDecimal = txtResY.Value;
Decimal roundedValue = Math.Round(resYDecimal * GraphicsManager.GetRatio(GraphicsManager.Ratio.ratio43));
Decimal roundedValue = Math.Round(resYDecimal * GraphicsManager.GetRatio(GraphicsManager.Ratio.ratio43));
txtResX.Value = roundedValue;
}
else if (!suppressEvent)
Expand Down Expand Up @@ -154,7 +154,7 @@ private void chkMaintainRatio_Click(object sender, RoutedEventArgs e)

#endregion


#endregion

#region Patches Tab
Expand Down Expand Up @@ -194,31 +194,14 @@ private static List<PatchesData> GetPatches(ref ListView list, GameSettings set)
list.Items.Clear();

var patches = PatchesList.Deserialize(patchesPath);
bool isListEmpty = set.EnabledGamePatches.Count == 0;

if (patches is not null)
{
var listPatch = patches.Patches;

foreach (var patch in listPatch)
{
if (isListEmpty)
{
// Convert patch name to the corresponding property name in GamePatches class
string propertyName = patch.Name.Replace(" ", ""); // Adjust the naming convention as needed
var property = typeof(GamePatches).GetProperty(propertyName);

if (property != null)
{
// Update the IsChecked property based on the GamePatches class
patch.IsChecked = (bool)property.GetValue(set.Patches);
}
}
else
{
patch.IsChecked = set.EnabledGamePatches.Contains(patch.Name);
}

patch.IsChecked = set.EnabledGamePatches.Contains(patch.Name);
string desc = "GamePatchesSA2." + patch.Name + "Desc";
patch.InternalName = patch.Name;
patch.Name = Lang.GetString("GamePatchesSA2." + patch.Name);
Expand Down Expand Up @@ -297,8 +280,8 @@ private void SetupBindings()
Source = GameProfile.Graphics,
Mode = BindingMode.TwoWay,
});
comboScreen.ItemsSource = GraphicsManager.Screens;
comboScreen.DisplayMemberPath = "Key";
comboScreen.ItemsSource = GraphicsManager.Screens;
comboScreen.DisplayMemberPath = "Key";
txtResX.MinValue = 0;
txtResY.MinValue = 0;
txtResX.SetBinding(NumberBox.ValueProperty, new Binding("HorizontalResolution")
Expand Down Expand Up @@ -380,48 +363,48 @@ private void SetupBindings()
Source = GameProfile.Graphics,
Mode = BindingMode.TwoWay
});
chkStretchToWindow.SetBinding(CheckBox.IsCheckedProperty, new Binding("StretchToWindow")
{
Source = GameProfile.Graphics,
Mode = BindingMode.TwoWay,
});
chkDisableBorderImage.SetBinding(CheckBox.IsCheckedProperty, new Binding("DisableBorderImage")
{
Source = GameProfile.Graphics,
Mode = BindingMode.TwoWay
});
chkStretchToWindow.SetBinding(CheckBox.IsCheckedProperty, new Binding("StretchToWindow")
{
Source = GameProfile.Graphics,
Mode = BindingMode.TwoWay,
});
chkDisableBorderImage.SetBinding(CheckBox.IsCheckedProperty, new Binding("DisableBorderImage")
{
Source = GameProfile.Graphics,
Mode = BindingMode.TwoWay
});
ChkSkipIntro.SetBinding(CheckBox.IsCheckedProperty, new Binding("SkipIntro")
{
Source = GameProfile.Graphics,
Mode = BindingMode.TwoWay
});
tsTextLanguage.SetBinding(ComboBox.SelectedIndexProperty, new Binding("GameTextLanguage")
{
Source = GameProfile.Graphics,
Mode = BindingMode.TwoWay
});
tsVoiceLanguage.SetBinding(ComboBox.SelectedIndexProperty, new Binding("GameVoiceLanguage")
{
Source = GameProfile.TestSpawn,
Mode = BindingMode.TwoWay
});

DebugConfig.SetBinding(DebugOptions.SettingsProperty, new Binding("DebugSettings")
{
Source = GameProfile,
Mode = BindingMode.TwoWay
});
}
#endregion

private void DownloadDXVK_Click(object sender, RoutedEventArgs e)
{
var ps = new ProcessStartInfo("https://github.com/doitsujin/dxvk/releases")
{
UseShellExecute = true,
Verb = "open"
};
Process.Start(ps);
}
}
tsTextLanguage.SetBinding(ComboBox.SelectedIndexProperty, new Binding("GameTextLanguage")
{
Source = GameProfile.Graphics,
Mode = BindingMode.TwoWay
});
tsVoiceLanguage.SetBinding(ComboBox.SelectedIndexProperty, new Binding("GameVoiceLanguage")
{
Source = GameProfile.TestSpawn,
Mode = BindingMode.TwoWay
});

DebugConfig.SetBinding(DebugOptions.SettingsProperty, new Binding("DebugSettings")
{
Source = GameProfile,
Mode = BindingMode.TwoWay
});
}
#endregion

private void DownloadDXVK_Click(object sender, RoutedEventArgs e)
{
var ps = new ProcessStartInfo("https://github.com/doitsujin/dxvk/releases")
{
UseShellExecute = true,
Verb = "open"
};
Process.Start(ps);
}
}
}
Loading

0 comments on commit 8e97103

Please sign in to comment.