Implemented choosing Scrapland version

This commit is contained in:
strongleong 2022-02-06 20:38:13 +11:00
parent e0c1beb5f1
commit b168b7403a
4 changed files with 21 additions and 20 deletions

View file

@ -66,9 +66,13 @@
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content=" Settings " Click="Button_Click" />
<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">
<ComboBoxItem Content="Original" IsEnabled="False" />
<ComboBoxItem Content="Remastered" />
</ComboBox>
<CheckBox Content=" Windowed " Margin="0,0,10,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
<CheckBox Content=" Close launcher " Margin="0,0,10,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Button Content=" Run Scrapland " Name="ButtonRunScrapland" />

View file

@ -34,12 +34,21 @@ namespace ScrapModLoader
}
// TODO: Refactor it to separate window with pretty loading animation
if (!modsLauncher.SearchForScrapland())
if (modsLauncher.ScraplandPath == String.Empty && modsLauncher.ScraplandRemasteredPath == String.Empty)
{
ButtonRunScrapland.IsEnabled = false;
MessageBox.Show("Error: unable to find Scrapland instalation. Please, specify yours game installation folder in settings.");
Boolean isFoundScrapland = modsLauncher.SearchForScrapland();
if (!isFoundScrapland)
{
ButtonRunScrapland.IsEnabled = false;
MessageBox.Show("Error: unable to find Scrapland instalation. Please, specify yours game installation folder in settings.");
}
}
((ComboBoxItem)ScraplandVersion.Items[0]).IsEnabled = modsLauncher.ScraplandPath != String.Empty;
((ComboBoxItem)ScraplandVersion.Items[1]).IsEnabled = modsLauncher.ScraplandRemasteredPath != String.Empty;
ScraplandVersion.SelectedIndex = modsLauncher.ScraplandRemasteredPath != String.Empty ? 1 : 0;
modsLauncher.ScanMods();
}
@ -136,9 +145,9 @@ namespace ScrapModLoader
mod.Checked = (Boolean)isChecked;
}
private void Button_Click(Object sender, RoutedEventArgs e)
private void ButtonSettings_Click(Object sender, RoutedEventArgs e)
{
SettingsWindow settingsWindow = new SettingsWindow(modsLauncher);
SettingsWindow settingsWindow = new SettingsWindow();
settingsWindow.ShowDialog();
if (settingsWindow.Save)
modsLauncher.ScanMods();

View file

@ -17,7 +17,7 @@ namespace ScrapModLoader
public String ScraplandRemasteredPath { get; set; }
public Boolean Save { get; set; }
public SettingsWindow(ModsLauncher modsLauncher)
public SettingsWindow()
{
InitializeComponent();
@ -118,7 +118,7 @@ namespace ScrapModLoader
}
private void ButtonBrowseScrapRemaster_Click(Object sender, RoutedEventArgs e)
{
String scraplandRemasteredPath = Utils.GetFilePath();
String scraplandRemasteredPath = Utils.GetFolderDialog();
if (scraplandRemasteredPath != String.Empty)
{
ScraplandRemasteredPathTextBox.Text = scraplandRemasteredPath;

View file

@ -9,18 +9,6 @@ namespace ScrapModLoader
{
internal static class Utils
{
public static String GetFilePath()
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog
{
DefaultExt = ".exe",
Filter = "Scrapland Executable File (*.exe)|*.exe"
};
Nullable<Boolean> result = dlg.ShowDialog();
return dlg.FileName;
}
public static String GetFolderDialog()
{
using System.Windows.Forms.FolderBrowserDialog? dialog = new System.Windows.Forms.FolderBrowserDialog();