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" />
</StackPanel>
<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="Remastered" />
</ComboBox>

View file

@ -157,20 +157,22 @@ namespace ScrapModLoader
private void ButtonRunScrapland_Click(Object sender, RoutedEventArgs e)
{
String gamePath = ScraplandVersion.SelectedIndex == 0
? modsLauncher.ScraplandPath : modsLauncher.ScraplandRemasteredPath;
modsLauncher.LoadMods(gamePath);
modsLauncher.LoadMods();
String args = "-fullscreen:1";
if (Windowed.IsChecked ?? false)
args = "-fullscreen:0";
String gamePath = modsLauncher.SelectedGameVersion == "1.0" ?
modsLauncher.ScraplandPath : modsLauncher.ScraplandRemasteredPath;
Process.Start(gamePath + @"\bin\Scrap.exe", args);
if (CloseLauncher.IsChecked ?? false)
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 String ScraplandPath { get; set; }
public String ScraplandRemasteredPath { get; set; }
public String SelectedGameVersion { get; set; }
public ModsLauncher()
{
Mods = new List<ScrapMod>();
ScraplandPath = Settings.Default.ScraplandPath;
ScraplandRemasteredPath = Settings.Default.ScraplandRemasteredPath;
SelectedGameVersion = "0.0";
}
public void ScanMods()
@ -76,10 +78,15 @@ namespace ScrapModLoader
return isFound;
}
public void LoadMods(String gamePath)
public void LoadMods()
{
String gamePath = SelectedGameVersion == "1.0" ? ScraplandPath : ScraplandRemasteredPath;
foreach (ScrapMod mod in Mods)
{
if (mod.RequiredGame != SelectedGameVersion)
continue;
if (mod.Checked)
{
if (!mod.IsEnabled(gamePath))