Beispiel #1
0
 void LoadGamesList()
 {
     gameList.Items.Clear();
     currentGames = ListLoader.GenerateGameList(System.IO.Path.Combine(settings.GameListLocation, consoles[consoleList.SelectedIndex].name), settings.ShowOnlyGamelistGames);
     favourites   = ListLoader.ReadFavourites(consoles[consoleList.SelectedIndex].favourites, currentGames);
     foreach (game c in favourites)
     {
         currentGames.Insert(0, c);
         //TextBlock t = new TextBlock()
         //{
         //    Text = c.name,
         //    Height = 50,
         //    FontSize = 36
         //};
         //totalHeight += t.Height;
         //gameList.Items.Add(t);
     }
     foreach (game c in currentGames)
     {
         TextBlock t = new TextBlock()
         {
             Text     = c.name,
             Height   = 50,
             FontSize = 36
         };
         //totalHeight += t.Height;
         gameList.Items.Add(t);
     }
 }
Beispiel #2
0
 void FavouriteSelectedGame()
 {
     if (favourites.Contains(currentGames[gameList.SelectedIndex]))
     {
         favourites.Remove(currentGames[gameList.SelectedIndex]);
     }
     else
     {
         favourites.Add(currentGames[gameList.SelectedIndex]);
     }
     ListLoader.WriteFavourites(favourites, consoles[consoleList.SelectedIndex].favourites);
     LoadGamesList();
 }
Beispiel #3
0
        //SolidColorBrush UnselectedColour = new SolidColorBrush((Color) ColorConverter.ConvertFromString("#FF252525"));
        public MainWindow()
        {
            InitializeComponent();
            settings = SettingsHandler.Read();
            consoles = ListLoader.GenerateConsoleList(settings.ConsoleListLocation);
            //double totalHeight = 0;
            foreach (console c in consoles)
            {
                TextBlock t = new TextBlock()
                {
                    Text     = c.name,
                    Height   = 50,
                    FontSize = 36
                };
                //totalHeight += t.Height;
                consoleList.Items.Add(t);
            }
            //consoleList.Height = totalHeight;
            connectedControllers = ListControllers();
            foreach (Joystick c in connectedControllers)
            {
                ControllerSettings cs = new ControllerSettings();
                bool settingsExist    = false;
                foreach (ControllerSettings settings in settings.Controller)
                {
                    if (c.Information.InstanceGuid == settings.ID)
                    {
                        cs            = settings;
                        settingsExist = true;
                    }
                }
                if (settingsExist == false)
                {
                    settings.Controller.Add(new ControllerSettings {
                        Name = c.Information.ProductName, ID = c.Information.InstanceGuid
                    });
                    SettingsHandler.Write(settings);
                }
                else
                {
                    //MessageBox.Show("Joystick connected : " + c.Information.ProductName + " " + c.Information.ProductGuid, "things", MessageBoxButton.OK);
                    ControllerManager con = new ControllerManager();
                    connectedControllerManagers.Add(con);
                    con.settings  = cs;
                    con.Navigate += ControlNavigate;
                    con.Init(c.Information.InstanceGuid);
                }
            }
            consoleList.SelectedIndex  = 0;
            alphabetList.SelectedIndex = 0;
            gameList.SelectedIndex     = 0;
            LoadDetails();

            DispatcherTimer timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(2)
            };

            timer.Tick += Scroll;
            timer.Start();
            GenerateAlphabet();
        }
Beispiel #4
0
        void NavigateLeftRight(bool direction)
        {
            //Console.WriteLine(gameList.SelectedIndex);
            //false goes left, true goes right
            if (ScrollTarget == 1 && direction)
            {
                gameList.SelectedIndex     = SavedSelection;
                SavedSelection             = alphabetList.SelectedIndex;
                alphabetList.SelectedIndex = -1;
            }

            /*
             * else if (ScrollTarget == 1 && !direction)
             * {
             *  alphabetList.SelectedIndex = 0;
             *  gameList.SelectedIndex = 0;
             *  SavedSelection = 0;
             * }
             */
            //Load Games list if that is the current location
            if (ScrollTarget == 0 && direction)
            {
                LoadGamesList();
                AlphabetIndices            = ListLoader.GenerateAlphabetIndices(currentGames, favourites.Count);
                alphabetList.SelectedIndex = 0;
                gameList.SelectedIndex     = 0;
                SavedSelection             = 0;
            }
            if (direction)
            {
                if (ScrollTarget < MaxScroll)
                {
                    ScrollTarget++;
                }
                else
                {
                    foreach (ControllerManager c in connectedControllerManagers)
                    {
                        c.Release();
                    }
                    string command = "/c " + consoles[consoleList.SelectedIndex].command;
                    //command.Replace("%ROMNAME%", System.IO.Path.GetFileNameWithoutExtension(currentGames[gameList.SelectedIndex].path));
                    //command.Replace("%ROMPATH%", @"""" + currentGames[gameList.SelectedIndex].path + @"""");
                    SendSignDataThreaded(System.IO.Path.GetFileNameWithoutExtension(currentGames[gameList.SelectedIndex].path));
                    command = @"/c """"" + consoles[consoleList.SelectedIndex].command + @""" """ + currentGames[gameList.SelectedIndex].path + @""" """ + System.IO.Path.GetFileNameWithoutExtension(currentGames[gameList.SelectedIndex].path) + @"""""";
                    //In batch file %1 is game path, %2 is game name
                    Console.WriteLine(command);
                    var processInfo = new ProcessStartInfo("cmd.exe", command);
                    var process     = Process.Start(processInfo);
                    process.WaitForExit();
                    SendSignDataThreaded("clear");
                    string contIds = "";
                    foreach (ControllerManager c in connectedControllerManagers)
                    {
                        contIds += (" " + c.JoystickGuid);
                        c.Init(c.JoystickGuid);
                    }
                    //MessageBox.Show("Joystick IDs: " + contIds, "stuff", MessageBoxButton.OK);
                }
            }
            else
            {
                if (ScrollTarget > 0)
                {
                    ScrollTarget--;
                }
            }
            if (ScrollTarget == 1)
            {
                alphabetList.SelectedIndex = SavedSelection;
                SavedSelection             = gameList.SelectedIndex;
                gameList.SelectedIndex     = -1;
            }
        }