Пример #1
0
 private bool SetGameFolder(string?path)
 {
     if (path != null)
     {
         var gameModes = GameFolders.GetGameModes(path);
         foreach (var gameMode in gameModes)
         {
             _isGameFolderSet       = true;
             gbGameInfo.Visible     = true;
             gbButtonMenu.Visible   = true;
             cbGameModes.Visible    = true;
             tbGamePath.Text        = path.ToUpper();
             tbGamePath.TextAlign   = HorizontalAlignment.Left;
             cbGameModes.DataSource = gameModes;
             _gameModes             = gameModes.Select(i => i.Mode).ToList();
             SetGameModeInfo(gameMode);
             Program.RunRepositoryMonitors(gameModes);
             return(true);
         }
     }
     _isGameFolderSet       = false;
     gbGameInfo.Visible     = false;
     gbButtonMenu.Visible   = false;
     cbGameModes.Visible    = false;
     tbGamePath.Text        = Resources.GamePath_Hint;
     tbGamePath.TextAlign   = HorizontalAlignment.Center;
     cbGameModes.DataSource = null;
     _gameModes             = null;
     Program.CurrentGame    = null;
     Program.StopRepositoryMonitors();
     return(false);
 }
Пример #2
0
 private void btnGamePath_Click(object sender, EventArgs e)
 {
     using var dlg = new FolderBrowserDialog
           {
               Description         = Resources.GamePath_Description,
               RootFolder          = Environment.SpecialFolder.MyComputer,
               ShowNewFolderButton = false,
               SelectedPath        = _lastBrowsePath ?? (_isGameFolderSet ? tbGamePath.Text : string.Empty)
           };
     if (dlg.ShowDialog(this) == DialogResult.OK)
     {
         _lastBrowsePath = dlg.SelectedPath;
         string?gamePath = GameFolders.SearchGameFolder(_lastBrowsePath);
         if (!SetGameFolder(gamePath))
         {
             MessageBox.Show(this, Resources.GamePath_Error_Text, Resources.GamePath_Error_Title,
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (string.Compare(Program.Settings.GameFolder, gamePath, StringComparison.OrdinalIgnoreCase) != 0)
         {
             Program.Settings.GameFolder = gamePath;
             Program.SaveAppSettings();
         }
     }
 }
Пример #3
0
        private void ItemContextStrip_Opening(object sender, CancelEventArgs e)
        {
            Point p = GameFolders.PointToClient(Cursor.Position);

            _currentItem                   = GameFolders.GetItemAt(p.X, p.Y);
            PlayGameItem.Visible           = LoadMenuItem.Visible =
                RenameProjectItem.Visible  = SetIconItem.Visible =
                    OpenFolderItem.Visible = (_currentItem != null);
        }
Пример #4
0
 private void GameFolders_MouseClick(object sender, MouseEventArgs e)
 {
     _currentItem = GameFolders.GetItemAt(e.X, e.Y);
     if (_currentItem == null)
     {
         return;
     }
     _proj = Project.Open((string)_currentItem.Tag);
     SetProjData();
 }
Пример #5
0
        public override void OnActivateGui()
        {
            _Style = LazyLoader.LoadVehicle.Get();
            BlueprintFolder combinedBlueprintFolder = GameFolders.GetCombinedBlueprintFolder();

            sectionsNorthSouth = WorldSpecification.i.BoardLayout.NorthSouthBoardSectionCount - 1;
            sectionsEastWest   = WorldSpecification.i.BoardLayout.EastWestBoardSectionCount - 1;
            _treeSelector      = FtdGuiUtils.GetFileBrowserFor(combinedBlueprintFolder);
            _treeSelector.Refresh();
            _focus.ResetCam();
            GameEvents.UpdateEvent += _focus.UpdateBoardSectionPreview;
        }
Пример #6
0
        public override void OnActivateGui()
        {
            //_Style = LazyLoader.LoadVehicle.Get();
            BlueprintFolder val = GameFolders.GetCombinedBlueprintFolder(false);

            sectionsNorthSouth = WorldSpecification.i.BoardLayout.NorthSouthBoardSectionCount - 1;
            sectionsEastWest   = WorldSpecification.i.BoardLayout.EastWestBoardSectionCount - 1;
            if (t.eastWestBoard > sectionsEastWest)
            {
                t.eastWestBoard = t.eastWestBoardD;
            }
            if (t.northSouthBoard > sectionsNorthSouth)
            {
                t.northSouthBoard = t.northSouthBoardD;
            }
            _treeSelector = FtdGuiUtils.GetFileBrowserFor(val);
            _treeSelector.Refresh();
            t.ResetCam();
            GameEvents.UpdateEvent += t.UpdateBoardSectionPreview;
        }
    private static void ChangeInstallationDir()
    {
        var gameFolders   = new GameFolders();
        var configManager = new GameConfigManager(gameFolders);

        var currentFolder = configManager.Config.InstallationFolder;

        ValidationReport validationReport = null;
        string           selectedFolder;

        do
        {
            if (!InstallationDirSelector.Select(validationReport, currentFolder, out selectedFolder))
            {
                return;
            }

            validationReport = ToEEInstallationValidator.Validate(selectedFolder);
        } while (selectedFolder == null || !validationReport.IsValid);

        configManager.Config.InstallationFolder = selectedFolder;
        configManager.Save();
    }
Пример #8
0
        // Constructor
        public SettingsVisualHandler()
        {
            // get an instance of the MainWindow
            MWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            // get 'show all settings' button and click it
            RadioButton btnAllSettings = (RadioButton)MWindow.FindName("btnAllSettings");
            //btnAllSettings.IsChecked = true;

            // get settings grid
            WrapPanel wpSettingsLeftPane = (WrapPanel)MWindow.FindName("wpSettingsLeftPane");

            // get all filter buttons from the settings page
            List <RadioButton> _filterButtons = UIHandler.GetLogicalChildCollection <RadioButton>(wpSettingsLeftPane);//.Where(r => r.GroupName == "grpSettings").ToList();

            FilterButtons = _filterButtons;

            // setting grid containing right hand content
            Grid SettingGrid = (Grid)MWindow.FindName("SettingGrid");

            // get all settings panels
            //AllSettingPanels = UIHandler.GetLogicalChildCollection<Border>("SettingGrid").ToList();

            AllSettingPanels = UIHandler.GetLogicalChildCollection <Border>(SettingGrid).ToList();


            // iterate through each panel and match the border x:name to the class property name
            foreach (Border b in AllSettingPanels)
            {
                // remove any trailing numerals from the control name
                string name = StripTrailingNumerals(b.Name);

                // if the control name matches a property name in this class, add it to that list
                PropertyInfo property = typeof(SettingsVisualHandler).GetProperty(name);
                if (property == null)
                {
                    // no property matched
                    continue;
                }

                // add the border control to the correct List
                switch (property.Name)
                {
                case "MednafenPaths":
                    MednafenPaths.Add(b);
                    break;

                case "GameFolders":
                    GameFolders.Add(b);
                    break;

                case "SystemBios":
                    SystemBios.Add(b);
                    break;

                case "Netplay":
                    Netplay.Add(b);
                    break;

                case "Emulator":
                    Emulator.Add(b);
                    break;

                case "MedLaunch":
                    MedLaunch.Add(b);
                    break;

                case "Library":
                    Library.Add(b);
                    break;

                case "ScrapingSettings":
                    ScrapingSettings.Add(b);
                    break;

                default:
                    // do nothing
                    break;
                }
            }
        }
Пример #9
0
 private void Awake()
 {
     UI.UIFolders.Load();
     StatDisplay.Load();
     GameFolders.Load();
 }
    private static void OpenSaveGameFolder()
    {
        var gameFolders = new GameFolders();

        NativePlatform.OpenFolder(gameFolders.SaveFolder);
    }
Пример #11
0
        /// <summary>
        /// Adds Sphere games to the games panel for start-up use.
        /// </summary>
        public void PopulateGameList()
        {
            GameFolders.Items.Clear();
            GameFolders.BeginUpdate();
            if (_listIcons.Images.Count == 0)
            {
                return;
            }
            Image holdOnToMe = _listIcons.Images[0]; // keep this sucker alive.

            _listIcons.Images.Clear();
            _listIcons.Images.Add(holdOnToMe);

            // Search through a list of supplied directories.
            string sphereDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Sphere Studio");
            var    paths     = new List <string>(Core.Settings.ProjectPaths);

            paths.Insert(0, Path.Combine(sphereDir, "Projects"));
            foreach (string path in paths)
            {
                if (string.IsNullOrWhiteSpace(path) || !Directory.Exists(path))
                {
                    continue;
                }
                var baseDir    = new DirectoryInfo(path);
                var fileInfos  = baseDir.GetFiles("*.ssproj", SearchOption.AllDirectories);
                var ssprojDirs = from fi in fileInfos
                                 select fi.DirectoryName + @"\";
                foreach (var fileInfo in fileInfos)
                {
                    var          dirPath = Path.GetDirectoryName(fileInfo.FullName);
                    int          img     = CheckForIcon(dirPath);
                    Project      proj    = Project.Open(fileInfo.FullName);
                    ListViewItem item    = new ListViewItem(proj.Name, img)
                    {
                        Tag = fileInfo.FullName
                    };
                    item.SubItems.Add(proj.Author);
                    item.SubItems.Add(fileInfo.FullName);
                    GameFolders.Items.Add(item);
                }
                var sgmFileInfos = from fi in baseDir.GetFiles("game.sgm", SearchOption.AllDirectories)
                                   where !ssprojDirs.Any(x => fi.FullName.StartsWith(x))
                                   select fi;
                foreach (var fileInfo in sgmFileInfos)
                {
                    var          dirPath = Path.GetDirectoryName(fileInfo.FullName);
                    int          img     = CheckForIcon(dirPath);
                    Project      proj    = Project.Open(fileInfo.FullName);
                    ListViewItem item    = new ListViewItem(proj.Name, img)
                    {
                        Tag = fileInfo.FullName
                    };
                    item.SubItems.Add(proj.Author);
                    item.SubItems.Add(fileInfo.FullName);
                    GameFolders.Items.Add(item);
                }
            }
            GameFolders.EndUpdate();
            GameFolders.Invalidate();
        }