static bool showSimpleContext(GUIPresenter presenter, int selectedLabel = 0) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(MP1Utils.Options.ReadOption(o => o.PluginDisplayName)); dlg.Add(new GUIListItem(Translator.Instance.switchview)); dlg.Add(new GUIListItem(Translator.Instance.runimport)); dlg.Add(new GUIListItem(Translator.Instance.options)); dlg.SelectedLabel = selectedLabel; dlg.DoModal(Plugin.WINDOW_ID); selectedLabel = dlg.SelectedLabel; switch (dlg.SelectedId) { case 1: presenter.SwitchView(); break; case 2: presenter.RestartImporter(); break; case 3: if (ShowSettingsDialog()) presenter.ReloadOptions(); showSimpleContext(presenter, selectedLabel); break; } } return false; }
public static bool ShowGameDialog(Game game, GUIPresenter presenter, int selectedLabel = 0) { if (game == null) return false; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { int windowID = Plugin.WINDOW_ID; dlg.Reset(); dlg.SetHeading(MP1Utils.Options.ReadOption(o => o.PluginDisplayName)); GUIListItem playItem = new GUIListItem("Play"); dlg.Add(playItem); GUIListItem profileItem = new GUIListItem(Translator.Instance.profile) { Label2 = game.CurrentProfile != null ? game.CurrentProfile.Title : "" }; dlg.Add(profileItem); GUIListItem favouriteItem = new GUIListItem(Translator.Instance.favourite) { Label2 = game.Favourite.ToString() }; dlg.Add(favouriteItem); GUIListItem gradeItem = new GUIListItem(Translator.Instance.grade) { Label2 = game.Grade.ToString() }; dlg.Add(gradeItem); GUIListItem discItem = new GUIListItem(Translator.Instance.disc); if (game.Discs.Count > 1) { discItem.Label2 = game.CurrentDisc != null ? game.CurrentDisc.Number.ToString() : ""; dlg.Add(discItem); } GUIListItem goodmergeItem = new GUIListItem(Translator.Instance.goodmerge); if (game.IsGoodmerge) { goodmergeItem.Label2 = string.IsNullOrEmpty(game.CurrentDisc.LaunchFile) ? "" : game.CurrentDisc.LaunchFile.Replace(game.CurrentDisc.Filename, "").Trim(); dlg.Add(goodmergeItem); } GUIListItem viewItem = new GUIListItem(Translator.Instance.switchview); dlg.Add(viewItem); GUIListItem importItem = new GUIListItem(Translator.Instance.retrieveonlineinfo); dlg.Add(importItem); GUIListItem runImportItem = new GUIListItem(Translator.Instance.runimport); dlg.Add(runImportItem); GUIListItem settingsItem = new GUIListItem(Translator.Instance.options); dlg.Add(settingsItem); dlg.SelectedLabel = selectedLabel; dlg.DoModal(windowID); selectedLabel = dlg.SelectedLabel; int id = dlg.SelectedId; bool result = false; bool reload = true; if (id < 1) return false; if (id == playItem.ItemId) { presenter.LaunchGame(game); reload = false; } else if (id == profileItem.ItemId) { if (game.EmulatorProfiles.Count > 0) { EmulatorProfile currentProfile = game.CurrentProfile; if (showProfileDialog(ref currentProfile, game.EmulatorProfiles, windowID)) { game.CurrentProfile = currentProfile; game.SaveGamePlayInfo(); result = true; } } } else if (id == favouriteItem.ItemId) { bool favourite = game.Favourite; if (ShowBoolDialog(ref favourite, windowID)) { game.Favourite = favourite; game.SaveGamePlayInfo(); result = true; } } else if (id == gradeItem.ItemId) { int grade = game.Grade; if (showGradeDialog(ref grade, windowID)) { game.Grade = grade; game.SaveGamePlayInfo(); result = true; } } else if (id == discItem.ItemId) { if (game.Discs.Count > 0) { GameDisc disc = game.CurrentDisc; if (showDiscSelect(ref disc, game.Discs, windowID)) { game.CurrentDisc = disc; game.SaveGamePlayInfo(); result = true; } } } else if (id == goodmergeItem.ItemId) { List<string> games; if (game.CurrentDisc.GoodmergeFiles != null) { games = game.CurrentDisc.GoodmergeFiles; } else { games = SharpCompressExtractor.ViewFiles(game.CurrentDisc.Path); game.CurrentDisc.GoodmergeFiles = games; } if (games != null) { int selectedGoodmergeIndex = GoodmergeHandler.GetFileIndex(game.CurrentDisc.LaunchFile, games, game.CurrentProfile.GetGoodmergeTags()); string launchFile = selectedGoodmergeIndex > -1 ? games[selectedGoodmergeIndex] : null; if (ShowGoodmergeSelect(ref launchFile, games, game.CurrentDisc.Filename, windowID)) { game.CurrentDisc.LaunchFile = launchFile; game.CurrentDisc.Commit(); result = true; } } } else if (id == viewItem.ItemId) { presenter.SwitchView(); reload = false; } else if (id == importItem.ItemId) { presenter.AddToImporter(game); reload = false; } else if (id == runImportItem.ItemId) { presenter.RestartImporter(); reload = false; } else if (id == settingsItem.ItemId) { if (ShowSettingsDialog()) { presenter.ReloadOptions(); result = true; } } if (reload) result = ShowGameDialog(game, presenter, selectedLabel) || result; return result; } return false; }