Exemplo n.º 1
0
 public static bool ShowContext(ExtendedGUIListItem item, GUIPresenter presenter)
 {
     if (item == null || item.AssociatedGame == null)
         return showSimpleContext(presenter);
     else
         return ShowGameDialog(item.AssociatedGame, presenter);
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        void doLoad()
        {
            MP1Options options = MP1Utils.Options;
            options.EnterReadLock();
            if (firstLoad)
            {
                firstLoad = false;

                GUIPropertyManager.SetProperty("#Emulators2.PreviewVideo.playing", "no");
                //Image Handlers
                backdrop = new ImageSwapper();
                backdrop.ImageResource.Delay = options.FanartDelay;
                backdrop.PropertyOne = "#Emulators2.CurrentItem.fanartpath";
                backdrop.PropertyTwo = "#Emulators2.CurrentItem.fanartpath2";

                guiHandler = new GUIPresenter();
                guiHandler.OnSortAscendingChanged += new GUIPresenter.SortAscendingChanged(newGUIHandler_OnSortAscendingChanged);
                guiHandler.OnPreviewVideoStatusChanged += new GUIPresenter.PreviewVideoStatusChanged(newGUIHandler_OnPreviewVideoStatusChanged);
                GUIPropertyManager.SetProperty("#Emulators2.plugintitle", options.PluginDisplayName);

                onVideoStopped = new g_Player.StoppedHandler(g_Player_PlayBackStopped);
                onVideoEnded = new g_Player.EndedHandler(g_Player_PlayBackEnded);
            }
            
            DBItem startupItem = null;
            bool launch = false;
            getStartupSettings(ref startupItem, ref launch);

            if (buttonSort != null)
            {
                buttonSort.IsAscending = guiHandler.SortAscending;
                buttonSort.SortChanged += new SortEventHandler(guiHandler.OnSort);
            }

            if (options.ShowFanart)
            {
                backdrop.GUIImageOne = fanartControl1;
                backdrop.GUIImageTwo = fanartControl2;
            }

            if (gameArtEnabled != null)
                gameArtEnabled.Visible = options.ShowVideoPreview; //update gameart dummy control visibility

            if (options.ShowVideoPreview)
            {
                if (videoPreviewEnabled != null)
                    videoPreviewEnabled.Visible = true; //videoPreview dummy
            }

            options.ExitReadLock();

            g_Player.PlayBackStopped += onVideoStopped;
            g_Player.PlayBackEnded += onVideoEnded;

            guiHandler.Load(facade, backdrop, startupItem, launch, showVideoPreviewControl, goodmergeList, details_play);
        }