Removed unnecesarry stuff

This commit is contained in:
strongleong 2022-02-15 22:52:26 +11:00
parent 110029692d
commit 085320215a
1 changed files with 64 additions and 36 deletions

View File

@ -12,27 +12,28 @@ namespace ScrapModLoader
/// </summary> /// </summary>
public partial class SettingsWindow : Window public partial class SettingsWindow : Window
{ {
public List<String> ModsPathes { get; set; }
public String ScraplandPath { get; set; }
public String ScraplandRemasteredPath { get; set; }
public Boolean Save { get; set; } public Boolean Save { get; set; }
private ModsLauncher ModsLauncherInstance { get; set; }
public SettingsWindow() public SettingsWindow(ModsLauncher modsLauncher)
{ {
InitializeComponent(); InitializeComponent();
Save = false; Save = false;
ModsLauncherInstance = modsLauncher;
ModsPathes = Utils.StringCollectionToList(Settings.Default.ModsPathes); ModsPathesList.ItemsSource = ModsLauncherInstance.ModsPathes;
ScraplandPath = Settings.Default.ScraplandPath; ScraplandPathTextBox.Text = ModsLauncherInstance.ScraplandPath;
ScraplandRemasteredPath = Settings.Default.ScraplandRemasteredPath; ScraplandRemasteredPathTextBox.Text = ModsLauncherInstance.ScraplandRemasteredPath;
ModsPathesList.ItemsSource = ModsPathes; Boolean enable = ModsLauncherInstance.ScraplandPath != String.Empty;
ScraplandPathTextBox.Text = ScraplandPath; ButtonShowScrap.IsEnabled = enable;
ScraplandRemasteredPathTextBox.Text = ScraplandRemasteredPath; ButtonClearScrap.IsEnabled = enable;
ButtonShowScrap.IsEnabled = ScraplandPath != String.Empty; enable = ModsLauncherInstance.ScraplandRemasteredPath != String.Empty;
ButtonShowScrapRemaster.IsEnabled = ScraplandRemasteredPath != String.Empty; ButtonShowScrapRemaster.IsEnabled = enable;
ButtonClearScrapRemaster.IsEnabled = enable;
} }
// ------------------------------------------- // -------------------------------------------
@ -44,13 +45,13 @@ namespace ScrapModLoader
{ {
String folder = Utils.GetFolderDialog(); String folder = Utils.GetFolderDialog();
if (folder != String.Empty) if (folder != String.Empty)
ModsPathes.Add(folder); ModsLauncherInstance.ModsPathes.Add(folder);
ModsPathesList.Items.Refresh(); ModsPathesList.Items.Refresh();
} }
private void ButtonRemove_Click(Object sender, RoutedEventArgs e) private void ButtonRemove_Click(Object sender, RoutedEventArgs e)
{ {
ModsPathes.Remove((String)ModsPathesList.SelectedValue); ModsLauncherInstance.ModsPathes.Remove((String)ModsPathesList.SelectedValue);
ModsPathesList.Items.Refresh(); ModsPathesList.Items.Refresh();
ButtonRemove.IsEnabled = false; ButtonRemove.IsEnabled = false;
@ -64,21 +65,21 @@ namespace ScrapModLoader
if (index == 0) if (index == 0)
return; return;
String? temp = ModsPathes[index - 1]; String? temp = ModsLauncherInstance.ModsPathes[index - 1];
ModsPathes[index - 1] = ModsPathes[index]; ModsLauncherInstance.ModsPathes[index - 1] = ModsLauncherInstance.ModsPathes[index];
ModsPathes[index] = temp; ModsLauncherInstance.ModsPathes[index] = temp;
ModsPathesList.Items.Refresh(); ModsPathesList.Items.Refresh();
} }
private void ButtonDown_Click(Object sender, RoutedEventArgs e) private void ButtonDown_Click(Object sender, RoutedEventArgs e)
{ {
Int32 index = ModsPathesList.SelectedIndex; Int32 index = ModsPathesList.SelectedIndex;
if (index == ModsPathes.Count - 1) if (index == ModsLauncherInstance.ModsPathes.Count - 1)
return; return;
String? temp = ModsPathes[index + 1]; String? temp = ModsLauncherInstance.ModsPathes[index + 1];
ModsPathes[index + 1] = ModsPathes[index]; ModsLauncherInstance.ModsPathes[index + 1] = ModsLauncherInstance.ModsPathes[index];
ModsPathes[index] = temp; ModsLauncherInstance.ModsPathes[index] = temp;
ModsPathesList.Items.Refresh(); ModsPathesList.Items.Refresh();
} }
@ -108,50 +109,76 @@ namespace ScrapModLoader
private void ButtonBrowseScrap_Click(Object sender, RoutedEventArgs e) private void ButtonBrowseScrap_Click(Object sender, RoutedEventArgs e)
{ {
String scraplandPath = Utils.GetFolderDialog(); String ScraplandPath = Utils.GetFolderDialog();
if (scraplandPath != String.Empty) if (ScraplandPath != String.Empty)
{ {
ScraplandPathTextBox.Text = scraplandPath; ScraplandPathTextBox.Text = ScraplandPath + "\\";
ScraplandPath = scraplandPath; ModsLauncherInstance.ScraplandPath = ScraplandPath + "\\";
ButtonShowScrap.IsEnabled = true; ButtonShowScrap.IsEnabled = true;
} }
} }
private void ButtonBrowseScrapRemaster_Click(Object sender, RoutedEventArgs e) private void ButtonBrowseScrapRemaster_Click(Object sender, RoutedEventArgs e)
{ {
String scraplandRemasteredPath = Utils.GetFolderDialog(); String ScraplandRemasteredPath = Utils.GetFolderDialog();
if (scraplandRemasteredPath != String.Empty) if (ScraplandRemasteredPath != String.Empty)
{ {
ScraplandRemasteredPathTextBox.Text = scraplandRemasteredPath; ScraplandRemasteredPathTextBox.Text = ScraplandRemasteredPath + "\\";
ScraplandRemasteredPath = scraplandRemasteredPath; ModsLauncherInstance.ScraplandRemasteredPath = ScraplandRemasteredPath + "\\";
ButtonShowScrapRemaster.IsEnabled = true; ButtonShowScrapRemaster.IsEnabled = true;
} }
} }
private void ButtonClearScrap_Click(Object sender, RoutedEventArgs e) private void ButtonClearScrap_Click(Object sender, RoutedEventArgs e)
{ {
ScraplandPathTextBox.Text = String.Empty; ScraplandPathTextBox.Text = String.Empty;
ButtonClearScrap.IsEnabled = false;
ButtonShowScrap.IsEnabled = false; ButtonShowScrap.IsEnabled = false;
ScraplandPath = String.Empty; ModsLauncherInstance.ScraplandPath = String.Empty;
} }
private void ButtonClearScrapRemaster_Click(Object sender, RoutedEventArgs e) private void ButtonClearScrapRemaster_Click(Object sender, RoutedEventArgs e)
{ {
ScraplandRemasteredPathTextBox.Text = String.Empty; ScraplandRemasteredPathTextBox.Text = String.Empty;
ButtonClearScrapRemaster.IsEnabled = false; ButtonClearScrapRemaster.IsEnabled = false;
ScraplandRemasteredPath = String.Empty; ButtonShowScrapRemaster.IsEnabled = false;
ModsLauncherInstance.ScraplandRemasteredPath = String.Empty;
} }
private void ButtonShowScrap_Click(Object sender, RoutedEventArgs e) private void ButtonShowScrap_Click(Object sender, RoutedEventArgs e)
{ {
String? path = Path.GetDirectoryName(ScraplandPath); String? path = Path.GetDirectoryName(ModsLauncherInstance.ScraplandPath);
if (path == null) if (path == null)
throw new DirectoryNotFoundException("Cannot find direcotry for Scrapland"); throw new DirectoryNotFoundException("Cannot find direcotry for Scrapland");
Process.Start("explorer.exe", path); Process.Start("explorer.exe", path);
} }
private void ButtonShowScrapRemaster_Click(Object sender, RoutedEventArgs e) private void ButtonShowScrapRemaster_Click(Object sender, RoutedEventArgs e)
{ {
String? path = Path.GetDirectoryName(ScraplandRemasteredPath); String? path = Path.GetDirectoryName(ModsLauncherInstance.ScraplandRemasteredPath);
if (path == null) if (path == null)
throw new DirectoryNotFoundException("Cannot find direcotry for Scrapland"); throw new DirectoryNotFoundException("Cannot find direcotry for Scrapland");
Process.Start("explorer.exe", path); Process.Start("explorer.exe", path);
} }
private void ButtonAutoFind_Click(Object sender, RoutedEventArgs e)
{
try
{
Boolean isFoundScrapland = ModsLauncherInstance.SearchForScrapland();
if (!isFoundScrapland)
MessageBox.Show("Error: unable to find Scrapland instalation. Please, specify yours game installation folder in settings.");
}
catch (KeyNotFoundException ex)
{
MessageBox.Show(ex.Message);
}
ScraplandPathTextBox.Text = ModsLauncherInstance.ScraplandPath;
ScraplandRemasteredPathTextBox.Text = ModsLauncherInstance.ScraplandRemasteredPath;
Boolean enable = ModsLauncherInstance.ScraplandPath != String.Empty;
ButtonShowScrap.IsEnabled = enable;
ButtonClearScrap.IsEnabled = enable;
enable = ModsLauncherInstance.ScraplandRemasteredPath != String.Empty;
ButtonShowScrapRemaster.IsEnabled = enable;
ButtonClearScrapRemaster.IsEnabled = enable;
}
// ------------------------------------------- // -------------------------------------------
// Window contols buttons // Window contols buttons
@ -161,10 +188,11 @@ namespace ScrapModLoader
private void ButtonSave_Click(Object sender, RoutedEventArgs e) private void ButtonSave_Click(Object sender, RoutedEventArgs e)
{ {
Settings.Default.ModsPathes.Clear(); Settings.Default.ModsPathes.Clear();
Settings.Default.ModsPathes.AddRange(ModsPathes.ToArray()); Settings.Default.ModsPathes.AddRange(ModsLauncherInstance.ModsPathes.ToArray());
Settings.Default.ScraplandPath = ScraplandPath; Settings.Default.ScraplandPath = ModsLauncherInstance.ScraplandPath;
Settings.Default.ScraplandRemasteredPath = ScraplandRemasteredPath; Settings.Default.ScraplandRemasteredPath = ModsLauncherInstance.ScraplandRemasteredPath;
Settings.Default.Save(); Settings.Default.Save();
Save = true; Save = true;
Close(); Close();
} }