Added checks for game version

This commit is contained in:
strongleong 2022-02-06 23:20:05 +11:00
parent e3eacc4ab4
commit 22421b502c
3 changed files with 16 additions and 7 deletions

View file

@ -69,7 +69,7 @@
<Button Name="ButtonSettings" Content=" Settings " Click="ButtonSettings_Click" /> <Button Name="ButtonSettings" Content=" Settings " Click="ButtonSettings_Click" />
</StackPanel> </StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Left"> <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Left">
<ComboBox Name="ScraplandVersion" Margin="0,0,10,0"> <ComboBox Name="ScraplandVersion" Margin="0,0,10,0" SelectionChanged="ScraplandVersion_SelectionChanged">
<ComboBoxItem Content="Original" IsEnabled="False" /> <ComboBoxItem Content="Original" IsEnabled="False" />
<ComboBoxItem Content="Remastered" /> <ComboBoxItem Content="Remastered" />
</ComboBox> </ComboBox>

View file

@ -157,20 +157,22 @@ namespace ScrapModLoader
private void ButtonRunScrapland_Click(Object sender, RoutedEventArgs e) private void ButtonRunScrapland_Click(Object sender, RoutedEventArgs e)
{ {
modsLauncher.LoadMods();
String gamePath = ScraplandVersion.SelectedIndex == 0
? modsLauncher.ScraplandPath : modsLauncher.ScraplandRemasteredPath;
modsLauncher.LoadMods(gamePath);
String args = "-fullscreen:1"; String args = "-fullscreen:1";
if (Windowed.IsChecked ?? false) if (Windowed.IsChecked ?? false)
args = "-fullscreen:0"; args = "-fullscreen:0";
String gamePath = modsLauncher.SelectedGameVersion == "1.0" ?
modsLauncher.ScraplandPath : modsLauncher.ScraplandRemasteredPath;
Process.Start(gamePath + @"\bin\Scrap.exe", args); Process.Start(gamePath + @"\bin\Scrap.exe", args);
if (CloseLauncher.IsChecked ?? false) if (CloseLauncher.IsChecked ?? false)
Close(); Close();
} }
private void ScraplandVersion_SelectionChanged(Object sender, SelectionChangedEventArgs e) =>
modsLauncher.SelectedGameVersion = ScraplandVersion.SelectedIndex == 0 ? "1.0" : "1.1";
} }
} }

View file

@ -11,12 +11,14 @@ namespace ScrapModLoader
public List<ScrapMod> Mods { get; private set; } public List<ScrapMod> Mods { get; private set; }
public String ScraplandPath { get; set; } public String ScraplandPath { get; set; }
public String ScraplandRemasteredPath { get; set; } public String ScraplandRemasteredPath { get; set; }
public String SelectedGameVersion { get; set; }
public ModsLauncher() public ModsLauncher()
{ {
Mods = new List<ScrapMod>(); Mods = new List<ScrapMod>();
ScraplandPath = Settings.Default.ScraplandPath; ScraplandPath = Settings.Default.ScraplandPath;
ScraplandRemasteredPath = Settings.Default.ScraplandRemasteredPath; ScraplandRemasteredPath = Settings.Default.ScraplandRemasteredPath;
SelectedGameVersion = "0.0";
} }
public void ScanMods() public void ScanMods()
@ -76,10 +78,15 @@ namespace ScrapModLoader
return isFound; return isFound;
} }
public void LoadMods(String gamePath) public void LoadMods()
{ {
String gamePath = SelectedGameVersion == "1.0" ? ScraplandPath : ScraplandRemasteredPath;
foreach (ScrapMod mod in Mods) foreach (ScrapMod mod in Mods)
{ {
if (mod.RequiredGame != SelectedGameVersion)
continue;
if (mod.Checked) if (mod.Checked)
{ {
if (!mod.IsEnabled(gamePath)) if (!mod.IsEnabled(gamePath))