private void InstalledModsList_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { ErrorMessage.Text = ""; var item = e.Source as ListViewItem; if (item != null && item.IsSelected) { SelectedMod = InstalledMods.FirstOrDefault(p => p.ModGUID.Replace("-", "") == item.Name); if (SelectedMod != null) { DefaultText.Visibility = Visibility.Collapsed; SelectedModName.Text = SelectedMod.Name; SelectedModInfo.Visibility = Visibility.Visible; SelectedModNoConfig.Visibility = Visibility.Collapsed; var configable = SH2WorkshopFileHandler.IsModConfigable(SelectedMod.ModGUID); if (configable) { AddConfigFields(); ConfigFields.Visibility = Visibility.Visible; } else { SelectedModNoConfig.Visibility = Visibility.Visible; ConfigFields.Visibility = Visibility.Collapsed; } } } }
/* MANAGE MODS */ private void ManageModsSelectSetting(int type) { ManageMods_CurrentSettingType = type; if (ManageMods_CurrentSettingType == 0) { // Settings ModSettingsTitle.Text = "Mod Settings"; ModSettings_SettingsButton.Background = Shrek2Colors.GetBrushFromHex("#65a338"); ModSettings_BindsButton.Background = Shrek2Colors.GetBrushFromHex("#b7cba8"); if (SelectedMod != null) { DefaultText.Visibility = Visibility.Collapsed; SelectedModName.Text = SelectedMod.Name; SelectedModInfo.Visibility = Visibility.Visible; SelectedModNoConfig.Visibility = Visibility.Collapsed; var configable = SH2WorkshopFileHandler.IsModConfigable(SelectedMod.ModGUID); if (configable) { AddConfigFields(); ConfigFields.Visibility = Visibility.Visible; } else { SelectedModNoConfig.Visibility = Visibility.Visible; ConfigFields.Visibility = Visibility.Collapsed; } } } else if (ManageMods_CurrentSettingType == 1) { // Binds ModSettingsTitle.Text = "Mod Binds"; ModSettings_SettingsButton.Background = Shrek2Colors.GetBrushFromHex("#b7cba8"); ModSettings_BindsButton.Background = Shrek2Colors.GetBrushFromHex("#65a338"); if (SelectedMod != null) { DefaultText.Visibility = Visibility.Collapsed; SelectedModName.Text = SelectedMod.Name; SelectedModInfo.Visibility = Visibility.Visible; SelectedModNoConfig.Visibility = Visibility.Collapsed; var bindable = SH2WorkshopFileHandler.IsModBindable(SelectedMod.ModGUID); if (bindable) { AddBindFields(); ConfigFields.Visibility = Visibility.Visible; } else { SelectedModNoConfig.Visibility = Visibility.Visible; ConfigFields.Visibility = Visibility.Collapsed; } } } }
private void InstalledModsList_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { ErrorMessage.Text = ""; var item = e.Source as ListViewItem; if (item != null && item.IsSelected) { SelectedMod = InstalledMods.FirstOrDefault(p => p.ModGUID.Replace("-", "") == item.Name); ManageModsSelectSetting(0); if (SH2WorkshopFileHandler.IsModBindable(SelectedMod.ModGUID)) { ModSettings_BindsButton.Visibility = Visibility.Visible; } else { ModSettings_BindsButton.Visibility = Visibility.Collapsed; } } }
private void Button_SaveSettings_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(Settings_GameFolder.Text)) { return; } if (File.Exists(Settings_GameFolder.Text) == false) { return; } NewSettings.Language = Settings_Language.SelectedIndex == 0 ? Settings.Languages.English : Settings.Languages.Russian; NewSettings.WindowMode = Settings_WindowModes.SelectedIndex == 0 ? Settings.WindowModes.Fullscreen : Settings.WindowModes.WindowMode; var saved = SH2WorkshopFileHandler.SaveSettings(NewSettings); if (saved) { MainWindow.Settings = NewSettings; Close(); } }
private async void Overview_Button_PlayGame_MouseUp(object sender, MouseButtonEventArgs e) { try { if (string.IsNullOrWhiteSpace(Settings.GameFolderLocation)) { MessageBox.Show("You have not setup the Shrek 2 Game.exe in the Settings! You need to set it up before you can play mods directly!"); return; } if (SH2WorkshopFileHandler.IsInternalModFilesInstalled()) { Process.Start(System.IO.Path.Combine(Settings.GameFolderLocation, "Shrek 2 Modded.exe"), Settings.WindowMode == Settings.WindowModes.WindowMode ? "-windowed" : ""); } else { Overview_Button_PlayGame_Text.Text = "Downloading.."; bool downloaded = await SH2WorkshopFileHandler.DownloadInternalModFiles((ea, ex) => { }); if (downloaded) { Overview_Button_PlayGame_Text.Text = "Installing.."; bool installed = SH2WorkshopFileHandler.ExtractInternalModFiles(); if (installed) { Overview_Button_PlayGame_Text.Text = "Play Shrek 2 Modded"; return; } } Overview_Button_PlayGame_Text.Text = "Failed to install. Try again!"; } } catch { } }
private void Window_Loaded(object sender, RoutedEventArgs rea) { RM = new ResponsiveManager(this); RM.Handle(); ManageModsDialog.DialogClosing += (s, e) => { if (UnsavedChangesDialogOpened) { e.Cancel(); return; } UnsavedChangesDialogOpened = true; if (ManageMods_CurrentSettingType == 0) { var changes = ConfigChanges(); if (changes == 1 || changes == 2) { MessageBoxResult dialogResult = MessageBox.Show("You have some unsaved 'Mod Settings' changes. Would you like to save them?", "Unsaved changes", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); if (dialogResult == MessageBoxResult.Yes) { if (changes == 2) { e.Cancel(); } ConfigSaveButton_Click(null, null); } } UnsavedChangesDialogOpened = false; } else if (ManageMods_CurrentSettingType == 1) { var changes = BindChanges(); if (changes == 1 || changes == 2) { MessageBoxResult dialogResult = MessageBox.Show("You have some unsaved 'Mod Binds' changes. Would you like to save them?", "Unsaved changes", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); if (dialogResult == MessageBoxResult.Yes) { if (changes == 2) { e.Cancel(); } ConfigSaveButton_Click(null, null); } } UnsavedChangesDialogOpened = false; } else { UnsavedChangesDialogOpened = false; } }; Nav_Button_Overview.Click += (s, e) => SelectNavItem(0); Nav_Button_Mods.Click += (s, e) => SelectNavItem(1); Nav_Button_Settings.Click += Nav_Button_Settings_Click; Overview_Button_PlayGame.MouseEnter += Overview_Button_PlayGame_MouseEnter; Overview_Button_PlayGame.MouseLeave += Overview_Button_PlayGame_MouseLeave; Overview_Button_ManageMods.MouseEnter += Overview_Button_ManageMods_MouseEnter; Overview_Button_ManageMods.MouseLeave += Overview_Button_ManageMods_MouseLeave; Overview_Button_PlayGame.MouseUp += Overview_Button_PlayGame_MouseUp; Overview_Button_ManageMods.MouseUp += Overview_Button_ManageMods_MouseUp; Settings = SH2WorkshopFileHandler.GetSettings(); if (SH2WorkshopFileHandler.IsInternalModFilesInstalled()) { Overview_Button_PlayGame_Text.Text = "Play Shrek 2 Modded"; } else { Overview_Button_PlayGame_Text.Text = "Install Shrek 2 Modded"; } Mods = Mod.GetMods(); OverviewModsList.ItemsSource = Mod.VisualMod.ToVisualMods(Mods.Take(4).ToList()); }
private async void InstallButton_Click(object sender, RoutedEventArgs e) { Settings = SH2WorkshopFileHandler.GetSettings(); if (string.IsNullOrWhiteSpace(Settings.GameFolderLocation)) { MessageBox.Show("You have not setup the Shrek 2 Game.exe in the Settings! You need to set it up before you can play mods directly!"); return; } if (!SH2WorkshopFileHandler.IsInternalModFilesInstalled()) { MessageBox.Show("Before you can install a mod you need to install the Mod Framework by pressing the button 'Install Shrek 2 Modded' on the Overview Page!"); return; } Button btn = sender as Button; var dataObject = btn.DataContext as Mod.VisualMod; if (IsDownloading) { return; } var Mod = dataObject.Mod; if (SH2WorkshopFileHandler.IsModInstalled(Mod.ModGUID)) { if (dataObject.UpdateAvailable) { if (string.IsNullOrWhiteSpace(Settings.GameFolderLocation)) { MessageBox.Show("You have not setup the Shrek 2 Game.exe in the Settings! You need to set it up before you can play mods directly!"); return; } IsDownloading = true; var Downloaded = await SH2WorkshopFileHandler.UpdateMod(Mod, (s, p) => { btn.Content = $"{p.ProgressPercentage}%"; }); if (Downloaded) { SH2WorkshopFileHandler.ExtractModFile(Mod.ModGUID); if (SH2WorkshopFileHandler.IsModInstalled(Mod.ModGUID)) { Downloaded = true; } } else { MessageBox.Show($"Failed to download '{Mod.Name}'. Try again later!"); } SH2WorkshopFileHandler.HandleDefUserChanges(); RefreshMods(); IsDownloading = false; } else { if (string.IsNullOrWhiteSpace(Settings.GameFolderLocation)) { MessageBox.Show("You have not setup the Shrek 2 Game.exe in the Settings! You need to set it up before you can play mods directly!"); return; } bool uninstalled = SH2WorkshopFileHandler.UninstallMod(Mod); if (uninstalled) { SH2WorkshopFileHandler.HandleDefUserChanges(); RefreshMods(); } IsDownloading = false; } } else { // Update Mod IsDownloading = true; var Downloaded = await SH2WorkshopFileHandler.DownloadMod(Mod, (s, p) => { btn.Content = $"{p.ProgressPercentage}%"; }); if (Downloaded) { SH2WorkshopFileHandler.ExtractModFile(Mod.ModGUID); if (SH2WorkshopFileHandler.IsModInstalled(Mod.ModGUID)) { Downloaded = true; } } else { MessageBox.Show($"Failed to update '{Mod.Name}'. Try again later!"); } SH2WorkshopFileHandler.HandleDefUserChanges(); RefreshMods(); IsDownloading = false; } }