Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();

            //Initialize The Colorscheme
            var materialSkinManager = MaterialSkinManager.Instance;

            materialSkinManager.AddFormToManage(this);

            //Loads colorscheme
            if (Properties.Settings.Default.nightMode == true)
            {
                materialSkinManager.Theme = MaterialSkinManager.Themes.DARK;
            }
            else
            {
                materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT;
            }

            //Load saved colorscheme
            if (Properties.Settings.Default.colorscheme == "bluegrey")
            {
                materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
            }
            else if (Properties.Settings.Default.colorscheme == "pink")
            {
                materialSkinManager.ColorScheme = new ColorScheme(Primary.Pink800, Primary.Pink900, Primary.Pink500, Accent.Pink200, TextShade.WHITE);
            }

            //Loads saved settings
            emuDir      = Properties.Settings.Default.EmuDir;
            addgamesDir = Properties.Settings.Default.gamesDir;

            //Initilization
            isoPanel.AutoScroll = true;
            isoPanel.AllowDrop  = true;
            UpdateUiEvent      += new UpdateUiDelegate(addIso);
            artScrapper.WorkerSupportsCancellation = true;

            QueueThread.WorkerSupportsCancellation = true;
            QueueThread.WorkerReportsProgress      = true;
            QueueThread.DoWork += QueueThread_DoWork;
            //QueueThread.RunWorkerCompleted += QueueThread_DoWork;

            //Loads last window size
            if ((Properties.Settings.Default.lastSize == "null") == false)
            {
                string _size = Properties.Settings.Default.lastSize;
                _size       = _size.Replace("{Width=", String.Empty);
                _size       = _size.Replace("}", String.Empty);
                _size       = _size.Replace(" Height=", String.Empty);
                this.Width  = Convert.ToInt32(_size.Split(',')[0]);
                this.Height = Convert.ToInt32(_size.Split(',')[1]);
            }


            //Creates required directories
            Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\");
            Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\resources\logs\");

            //If blacklist file doesn't exist, create one
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\resources\logs\blacklist.txt") == false)
            {
                FileStream newblacklist = null;
                newblacklist = File.Create(AppDomain.CurrentDomain.BaseDirectory + @"\resources\logs\blacklist.txt");
                newblacklist.Close();
            }

            //Adds items to region list
            regionList.Add("SLUS");
            regionList.Add("SCUS");
            regionList.Add("SCES");
            regionList.Add("SLES");
            regionList.Add("SCPS");
            regionList.Add("SLPS");
            regionList.Add("SLPM");
            regionList.Add("PSRM");
            regionList.Add("SCED");
            regionList.Add("SLPM");
            regionList.Add("SIPS");

            //Integrity Checks
            if (emuDir == "null")
            {
                FirstTimeSetup(true);
            }
            else
            {
                copyDLL();

                //Searches game folders in resources directory
                string[] gamesDir = Directory.GetDirectories(AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\");
                foreach (string dir in gamesDir)
                {
                    //Removes symbols from game title
                    string _title = dir;
                    string _name  = dir.Remove(0, dir.LastIndexOf(System.IO.Path.DirectorySeparatorChar) + 1);
                    _name = _name.Trim(new Char[] { ' ', '*', '.', '\\', '/' });
                    //_name = _name.Remove(0, dir.LastIndexOf(System.IO.Path.DirectorySeparatorChar) + 1);

                    if (File.Exists(_title + @"\art.jpg"))
                    {
                        var gameIni = new IniFile(_title + @"\spectabis.ini");
                        var _isoDir = gameIni.Read("isoDirectory", "Spectabis");

                        if (File.Exists(_isoDir))
                        {
                            //Creates a group for game tile
                            FlowLayoutPanel gameGroupBox = new FlowLayoutPanel();
                            gameGroupBox.FlowDirection = FlowDirection.TopDown;
                            gameGroupBox.AutoSize      = true;
                            gameGroupBox.WrapContents  = true;
                            gameGroupBox.Name          = _name;
                            //Adds file to game file list
                            gamelist.Add(_isoDir);

                            //Creates a game picture
                            PictureBox gameBox = new PictureBox();

                            gameBox.Height        = 200;
                            gameBox.Width         = 150;
                            gameBox.SizeMode      = PictureBoxSizeMode.StretchImage;
                            gameBox.ImageLocation = _title + @"\art.jpg";
                            //isoPanel.Controls.Add(gameBox);
                            gameBox.MouseDown += gameBox_Click;
                            gameBox.Tag        = _isoDir;
                            gameBox.Name       = _name;
                            gameGroupBox.Controls.Add(gameBox);

                            //If showtitle is selected, create a label object
                            if (Properties.Settings.Default.showtitle == true)
                            {
                                MaterialLabel gamelabel = new MaterialLabel();
                                gamelabel.Text  = _name;
                                gamelabel.Width = 180;
                                gameGroupBox.Controls.Add(gamelabel);
                            }

                            isoPanel.Controls.Add(gameGroupBox);

                            Debug.WriteLine(_name + " has been added");
                        }
                    }
                }
            }

            //Empty list cannot be foreached
            gamelist.Add("null");

            //Every startup look for new .iso files
            if (addgamesDir != "null")
            {
                scanDir();
            }
        }
Exemple #2
0
        //Clicking on game
        private void gameBox_Click(object sender, MouseEventArgs e)
        {
            PictureBox clickedPictureBox = (PictureBox)sender;

            Debug.WriteLine(clickedPictureBox.Name + " - clicked");

            //Saves last picturebox to a variable
            lastGame = (PictureBox)sender;

            //Refresh the image
            clickedPictureBox.ImageLocation = AppDomain.CurrentDomain.BaseDirectory + @"resources\configs\" + clickedPictureBox.Name + @"\art.jpg";

            //Refresh isoDirectory
            string _cfgDir  = AppDomain.CurrentDomain.BaseDirectory + @"resources\configs\" + clickedPictureBox.Name;
            var    _gameIni = new IniFile(_cfgDir + @"\spectabis.ini");
            var    _isoDir  = _gameIni.Read("isoDirectory", "Spectabis");

            clickedPictureBox.Tag = _isoDir;



            //Check, if click was left mouse
            if (e.Button == MouseButtons.Left)
            {
                //Checks, if double click
                if (e.Clicks == 2)
                {
                    //If doubleclick setting is false, then stop
                    //This prevents launching multiple instances of game
                    if (Properties.Settings.Default.doubleclick == false)
                    {
                        return;
                    }
                }

                //If single click, with doubleclick setting, then stop
                if (e.Clicks == 1)
                {
                    if (Properties.Settings.Default.doubleclick == true)
                    {
                        return;
                    }
                }

                //Checks, if game file still exists
                if (File.Exists((string)clickedPictureBox.Tag))
                {
                    //Starts the game, if exists
                    string isoDir = (string)clickedPictureBox.Tag;
                    string cfgDir = AppDomain.CurrentDomain.BaseDirectory + @"resources\configs\" + clickedPictureBox.Name;

                    var gameIni     = new IniFile(cfgDir + @"\spectabis.ini");
                    var _nogui      = gameIni.Read("nogui", "Spectabis");
                    var _fullscreen = gameIni.Read("fullscreen", "Spectabis");
                    var _fullboot   = gameIni.Read("fullboot", "Spectabis");
                    var _nohacks    = gameIni.Read("nohacks", "Spectabis");


                    string _launchargs = "";

                    if (_nogui == "1")
                    {
                        _launchargs = "--nogui ";
                    }

                    if (_fullscreen == "1")
                    {
                        _launchargs = _launchargs + "--fullscreen ";
                    }

                    if (_fullboot == "1")
                    {
                        _launchargs = _launchargs + "--fullboot ";
                    }

                    if (_nohacks == "1")
                    {
                        _launchargs = _launchargs + "--nohacks ";
                    }

                    Debug.WriteLine(clickedPictureBox.Name + " launched with commandlines:  " + _launchargs);
                    Debug.WriteLine(clickedPictureBox.Name + " launched from: " + isoDir);
                    Debug.WriteLine(emuDir + @"\pcsx2.exe", "" + _launchargs + "\"" + isoDir + "\" --cfgpath \"" + cfgDir + "\"");

                    Process.Start(emuDir + @"\pcsx2.exe", "" + _launchargs + "\"" + isoDir + "\" --cfgpath \"" + cfgDir + "\"");
                    return;
                }
                else
                {
                    MessageBox.Show("Huh, the game doesn't exist", ":(");
                }
            }

            //Check, if click was right mouse
            if (e.Button == MouseButtons.Right)
            {
                //Displays context menu
                contextMenu.Show(Cursor.Position.X, Cursor.Position.Y);
            }
        }
Exemple #3
0
        //Add Iso function
        public void addIso(string _img, string _isoDir, string _title)
        {
            //Item properties
            FlowLayoutPanel gameGroupBox = new FlowLayoutPanel();

            gameGroupBox.FlowDirection = FlowDirection.TopDown;
            gameGroupBox.AutoSize      = true;
            gameGroupBox.WrapContents  = true;
            gameGroupBox.Name          = _title;

            PictureBox gameBox = new PictureBox();

            gameBox.Height   = 200;
            gameBox.Width    = 150;
            gameBox.SizeMode = PictureBoxSizeMode.StretchImage;

            _title = _title.Replace(@"/", string.Empty);
            _title = _title.Replace(@"\", string.Empty);
            _title = _title.Replace(@":", string.Empty);

            //Path to iso from mainForm
            string selfPath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]);


            //If boxart exists in folder, then set it in isoPanel
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\" + _title + @"\art.jpg"))
            {
                gameBox.ImageLocation = AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\" + _title + @"\art.jpg";
            }
            else
            {
                gameBox.ImageLocation = _img;
            }

            Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\" + _title);

            //copies pcsx2 inis to added game

            //looks for inis in pcsx2 directory
            if (Directory.Exists(emuDir + @"\inis\"))
            {
                string[] inisDir = Directory.GetFiles(emuDir + @"\inis\");
                foreach (string inifile in inisDir)
                {
                    Debug.WriteLine(inifile + " found!");
                    if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\" + _title + @"\" + Path.GetFileName(inifile)) == false)
                    {
                        string _destinationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\" + _title + @"\" + Path.GetFileName(inifile));
                        File.Copy(inifile, _destinationPath);
                    }
                }
            }
            else
            {
                //looks for pcsx2 inis in documents folder
                if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\PCSX2\inis"))
                {
                    string[] inisDirDoc = Directory.GetFiles((Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\PCSX2\inis"));
                    foreach (string inifile in inisDirDoc)
                    {
                        if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\" + _title + @"\" + Path.GetFileName(inifile)) == false)
                        {
                            string _destinationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\" + _title + @"\" + Path.GetFileName(inifile));
                            File.Copy(inifile, _destinationPath);
                        }
                    }
                }

                //if no inis are found, warning is shown
                else
                {
                    MessageBox.Show("Cannot find default PCSX2 configuration at " + emuDir + @"\inis\");
                    MessageBox.Show("Neither in " + Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\PCSX2\inis");
                }
            }



            gameBox.Name       = _title;
            gameBox.MouseDown += gameBox_Click;
            gameBox.Tag        = _isoDir;
            gamelist.Add(_isoDir);
            gameGroupBox.Controls.Add(gameBox);

            //If showtitle is selected, create a label object
            if (Properties.Settings.Default.showtitle == true)
            {
                MaterialLabel gamelabel = new MaterialLabel();
                gamelabel.Text  = _title;
                gamelabel.Width = 180;
                gameGroupBox.Controls.Add(gamelabel);
            }

            isoPanel.Controls.Add(gameGroupBox);



            Debug.WriteLine("creating a folder at - " + AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\" + _title);


            using (WebClient client = new WebClient())
            {
                try
                {
                    client.DownloadFile(_img, AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\" + _title + @"\art.jpg");
                }
                catch
                {
                    //throw;
                    MessageBox.Show("Image not available, none set.");
                }
            }

            var gameIni = new IniFile(AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\" + _title + @"\spectabis.ini");

            gameIni.Write("isoDirectory", _isoDir, "Spectabis");
            gameIni.Write("nogui", "0", "Spectabis");
            gameIni.Write("fullscreen", "0", "Spectabis");
            gameIni.Write("fullboot", "0", "Spectabis");

            //MessageBox.Show("Please, configure the game");
            //string cfgDir = AppDomain.CurrentDomain.BaseDirectory + @"\resources\configs\" + _title;
            //Process.Start(emuDir + @"\pcsx2.exe", "--cfgpath \"" + cfgDir + "\"");
        }