Esempio n. 1
0
        void resetStartupItem(DBItem startupItem)
        {
            startupEmu       = null;
            startupGame      = null;
            startupGroup     = null;
            this.startupItem = startupItem;

            if (startupItem == null)
            {
                return;
            }

            startupEmu = startupItem as Emulator;
            if (startupEmu != null)
            {
                return;
            }

            startupGame = startupItem as Game;
            if (startupGame != null)
            {
                return;
            }

            startupGroup = startupItem as RomGroup;
        }
Esempio n. 2
0
        //check if parent is an Emulator or Game and update thumbaspect
        void updateParent(DBItem parent)
        {
            if (parent is Game)
            {
                parentItemIsGame = true;
            }
            else if (!(parent is Emulator))
            {
                throw new ArgumentException("Parent must be an Emulator or Game", "parent");
            }

            parentItem = parent;
            if (parentItemIsGame)
            {
                //parent is a Game
                Game game = parent as Game;
                if (game.ParentEmulator != null)
                {
                    thumbaspect = game.ParentEmulator.CaseAspect;
                }
                else
                {
                    thumbaspect = 0;
                }
                frontCover.ThumbAspect = thumbaspect;
                backCover.ThumbAspect  = thumbaspect;
            }
            else //Emulator
            {
                thumbaspect            = 0;
                frontCover.ThumbAspect = 0;
                backCover.ThumbAspect  = 0;
            }
        }
Esempio n. 3
0
        public void Load(GUIFacadeControl facade, ImageSwapper backdrop, DBItem startupItem, bool launch, GUILabelControl showVideoPreviewControl, GUIListControl goodmergeList, GUIButtonControl detailsPlayButton)
        {
            this.facade                  = facade;
            this.goodmergeList           = goodmergeList;
            this.backdrop                = backdrop;
            this.showVideoPreviewControl = showVideoPreviewControl;
            this.detailsPlayButton       = detailsPlayButton;

            clearGUIProperties();
            currentLayout = -1;

            int prevWindow = GUIWindowManager.GetPreviousActiveWindow();

            if (GUIWindowManager.ActiveWindow == prevWindow || prevWindow == (int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO)
            {
                launchStartupItem = false;
                Refresh(true); //Catch when MP is refreshing plugin after resizing/restoring and maintain current view
            }
            else
            {
                resetStartupItem(startupItem);
                this.launchStartupItem = launch;
                SortProperty           = ListItemProperty.DEFAULT; //set skin property
                GUIPropertyManager.SetProperty("#Emulators2.sortenabled", "no");
                currentView = ViewState.Items;
                setFacadeVisibility(true);
                loadStartupItems(0);
            }
            //resume import if previously paused
            resumeImporter();
        }
Esempio n. 4
0
        void getStartupSettings(ref DBItem startupItem, ref bool launch)
        {
            //startupItem = DB.Instance.GetGame(5359);
            //launch = false;
            //return;

            if (string.IsNullOrEmpty(_loadParameter))
            {
                return;
            }

            //Check and load startup parameters
            Regex         paramReg   = new Regex(@"([A-z]+)\s*:\s*([-]?[A-z0-9]+)");
            List <string> loadParams = new List <string>(_loadParameter.Split(';'));

            foreach (string param in loadParams)
            {
                Match m = paramReg.Match(param);
                if (!m.Success)
                {
                    continue;
                }

                switch (m.Groups[1].Value.ToLower())
                {
                case "emulator":
                    int id;
                    if (int.TryParse(m.Groups[2].Value, out id))
                    {
                        startupItem = DB.Instance.GetEmulator(id);
                    }
                    break;

                case "rom":
                    //int id;
                    if (int.TryParse(m.Groups[2].Value, out id))
                    {
                        startupItem = DB.Instance.GetGame(id);
                    }
                    break;

                case "group":
                    RomGroup group;
                    if (GroupHandler.Instance.GroupNames.TryGetValue(m.Groups[2].Value.ToLower(), out group))
                    {
                        startupItem = group;
                    }
                    break;

                case "launch":
                    bool tryLaunch;
                    if (bool.TryParse(m.Groups[2].Value, out tryLaunch))
                    {
                        launch = tryLaunch;
                    }
                    break;
                }
            }
        }
Esempio n. 5
0
        protected override void OnPageLoad()
        {
            if (firstLoad)
            {
                firstLoad = false;

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

                newGUIHandler = new GUIPresenter();
                newGUIHandler.OnSortAscendingChanged      += new GUIPresenter.SortAscendingChanged(newGUIHandler_OnSortAscendingChanged);
                newGUIHandler.OnPreviewVideoStatusChanged += new GUIPresenter.PreviewVideoStatusChanged(newGUIHandler_OnPreviewVideoStatusChanged);
                GUIPropertyManager.SetProperty("#Emulators2.plugintitle", Options.Instance.GetStringOption("shownname"));

                onVideoStopped = new g_Player.StoppedHandler(g_Player_PlayBackStopped);
                onVideoEnded   = new g_Player.EndedHandler(g_Player_PlayBackEnded);
            }

            base.OnPageLoad();
            DBItem startupItem = null;
            bool   launch      = false;

            getStartupSettings(ref startupItem, ref launch);

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

            if (Options.Instance.GetBoolOption("showfanart"))
            {
                backdrop.GUIImageOne = fanartControl1;
                backdrop.GUIImageTwo = fanartControl2;
            }

            if (gameArtEnabled != null)
            {
                gameArtEnabled.Visible = Options.Instance.GetBoolOption("showgameart"); //update gameart dummy control visibility
            }
            if (Options.Instance.GetBoolOption("showvideopreview"))
            {
                if (videoPreviewEnabled != null)
                {
                    videoPreviewEnabled.Visible = true; //videoPreview dummy
                }
            }

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

            newGUIHandler.Load(facade, backdrop, startupItem, launch, showVideoPreviewControl, goodmergeList, details_play);
        }
Esempio n. 6
0
        public void SwitchView()
        {
            bool         showPC   = DB.Instance.GetGames(Emulator.GetPC()).Count > 0;
            StartupState newState = MenuPresenter.ShowViewsDialog(startupState, showPC);

            if (startupItem != null || newState != startupState)
            {
                startupState = newState;
                startupItem  = null;
                toggleDetails(null, true);
                loadStartupItems(0);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Initialises a new ThumbGroup with the thumbs of the specified parent
        /// </summary>
        /// <param name="parent">An Emulator or Game</param>
        public ThumbGroup(DBItem parent)
        {
            //init Thumbs
            frontCover  = new Thumb(ThumbType.FrontCover);
            backCover   = new Thumb(ThumbType.BackCover);
            titleScreen = new Thumb(ThumbType.TitleScreen);
            inGame      = new Thumb(ThumbType.InGameScreen);
            fanart      = new Thumb(ThumbType.Fanart);

            //set parent info and thumbaspect
            updateParent(parent);

            //load the paths/images
            loadThumbs();
        }
Esempio n. 8
0
        public ComboBoxItem(DBItem item)
        {
            Emulator emu = item as Emulator;

            if (emu != null)
            {
                ID   = emu.UID;
                Name = emu.Title;
            }
            else
            {
                Game game = (Game)item;
                ID   = game.GameID;
                Name = game.Title;
            }

            Value = item;
        }
Esempio n. 9
0
        public static void LaunchDocument(DBItem item)
        {
            string manualPath = null;

            using (ThumbGroup thumbGroup = new ThumbGroup(item))
                manualPath = thumbGroup.ManualPath;

            if (string.IsNullOrEmpty(manualPath))
            {
                return;
            }

            //Execute
            using (Process proc = new Process())
            {
                proc.StartInfo          = new ProcessStartInfo();
                proc.StartInfo.FileName = manualPath;
                proc.Start();
            }
        }
Esempio n. 10
0
        public DBItem GetRandomThumbItem(GroupItemInfo info)
        {
            DBItem thumbItem = null;

            if (!string.IsNullOrEmpty(info.Column))
            {
                return(null);
            }
            else if (info.SQL != null)
            {
                lock (artworkCacheSync)
                {
                    if (sqlRandomArtwork.ContainsKey(info.SQL))
                    {
                        return(sqlRandomArtwork[info.SQL]);
                    }
                }
                string sql          = info.SQL;
                int    orderbyIndex = orderByRegEx.Match(sql).Index;
                if (orderbyIndex > -1)
                {
                    sql = sql.Substring(0, orderbyIndex).Trim();
                }
                sql += " ORDER BY RANDOM() LIMIT 1";
                List <Game> games = DB.Instance.GetGames(sql, false);
                if (games.Count > 0)
                {
                    thumbItem = games[0];
                    lock (artworkCacheSync)
                        sqlRandomArtwork[info.SQL] = thumbItem;
                }
            }
            else if (info.Emulator)
            {
                lock (artworkCacheSync)
                    if (emuRandomArtwork.ContainsKey(info.Id))
                    {
                        return(emuRandomArtwork[info.Id]);
                    }

                if (info.Id == -2)
                {
                    List <Emulator> emus = DB.Instance.GetEmulators();
                    if (emus.Count > 0)
                    {
                        thumbItem = emus[new Random().Next(emus.Count)];
                    }
                }
                else
                {
                    thumbItem = DB.Instance.GetEmulator(info.Id);
                }
                if (thumbItem != null)
                {
                    lock (artworkCacheSync)
                        emuRandomArtwork[info.Id] = thumbItem;
                }
            }
            else
            {
                lock (artworkCacheSync)
                    if (gameRandomArtwork.ContainsKey(info.Id))
                    {
                        return(gameRandomArtwork[info.Id]);
                    }

                if (info.Id == -2)
                {
                    List <Game> games = DB.Instance.GetGames("ORDER BY RANDOM() LIMIT 1", false);
                    if (games.Count > 0)
                    {
                        thumbItem = games[0];
                    }
                }
                else
                {
                    thumbItem = DB.Instance.GetGame(info.Id);
                }
                if (thumbItem != null)
                {
                    lock (artworkCacheSync)
                        gameRandomArtwork[info.Id] = thumbItem;
                }
            }
            return(thumbItem);
        }