Exemple #1
0
        private MainWindow(Builder builder) : base(builder.GetObject("_mainWin").Handle)
        {
            builder.Autoconnect(this);

            // Apply custom theme if needed.
            ThemeHelper.ApplyTheme();

            // Sets overridden fields.
            int monitorWidth  = Display.PrimaryMonitor.Geometry.Width * Display.PrimaryMonitor.ScaleFactor;
            int monitorHeight = Display.PrimaryMonitor.Geometry.Height * Display.PrimaryMonitor.ScaleFactor;

            DefaultWidth  = monitorWidth < 1280 ? monitorWidth  : 1280;
            DefaultHeight = monitorHeight < 760  ? monitorHeight : 760;

            Icon  = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.Resources.Logo_Ryujinx.png");
            Title = $"Ryujinx {Program.Version}";

            // Hide emulation context status bar.
            _statusBar.Hide();

            // Instanciate HLE objects.
            _virtualFileSystem      = VirtualFileSystem.CreateInstance();
            _contentManager         = new ContentManager(_virtualFileSystem);
            _userChannelPersistence = new UserChannelPersistence();

            // Instanciate GUI objects.
            _applicationLibrary = new ApplicationLibrary(_virtualFileSystem);
            _uiHandler          = new GtkHostUiHandler(this);
            _deviceExitStatus   = new AutoResetEvent(false);

            WindowStateEvent += WindowStateEvent_Changed;
            DeleteEvent      += Window_Close;

            _applicationLibrary.ApplicationAdded        += Application_Added;
            _applicationLibrary.ApplicationCountUpdated += ApplicationCount_Updated;

            _gameTable.ButtonReleaseEvent += Row_Clicked;
            _fullScreen.Activated         += FullScreen_Toggled;

            GlRenderer.StatusUpdatedEvent += Update_StatusBar;

            if (ConfigurationState.Instance.Ui.StartFullscreen)
            {
                _startFullScreen.Active = true;
            }

            _stopEmulation.Sensitive         = false;
            _simulateWakeUpMessage.Sensitive = false;

            if (ConfigurationState.Instance.Ui.GuiColumns.FavColumn)
            {
                _favToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.IconColumn)
            {
                _iconToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.AppColumn)
            {
                _appToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.DevColumn)
            {
                _developerToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.VersionColumn)
            {
                _versionToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.TimePlayedColumn)
            {
                _timePlayedToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.LastPlayedColumn)
            {
                _lastPlayedToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.FileExtColumn)
            {
                _fileExtToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.FileSizeColumn)
            {
                _fileSizeToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.PathColumn)
            {
                _pathToggle.Active = true;
            }

            _favToggle.Toggled        += Fav_Toggled;
            _iconToggle.Toggled       += Icon_Toggled;
            _appToggle.Toggled        += App_Toggled;
            _developerToggle.Toggled  += Developer_Toggled;
            _versionToggle.Toggled    += Version_Toggled;
            _timePlayedToggle.Toggled += TimePlayed_Toggled;
            _lastPlayedToggle.Toggled += LastPlayed_Toggled;
            _fileExtToggle.Toggled    += FileExt_Toggled;
            _fileSizeToggle.Toggled   += FileSize_Toggled;
            _pathToggle.Toggled       += Path_Toggled;

            _gameTable.Model = _tableStore = new ListStore(
                typeof(bool),
                typeof(Gdk.Pixbuf),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(BlitStruct <ApplicationControlProperty>));

            _tableStore.SetSortFunc(5, SortHelper.TimePlayedSort);
            _tableStore.SetSortFunc(6, SortHelper.LastPlayedSort);
            _tableStore.SetSortFunc(8, SortHelper.FileSizeSort);

            int  columnId  = ConfigurationState.Instance.Ui.ColumnSort.SortColumnId;
            bool ascending = ConfigurationState.Instance.Ui.ColumnSort.SortAscending;

            _tableStore.SetSortColumnId(columnId, ascending ? SortType.Ascending : SortType.Descending);

            _gameTable.EnableSearch = true;
            _gameTable.SearchColumn = 2;

            UpdateColumns();
            UpdateGameTable();

            ConfigurationState.Instance.Ui.GameDirs.Event += (sender, args) =>
            {
                if (args.OldValue != args.NewValue)
                {
                    UpdateGameTable();
                }
            };

            Task.Run(RefreshFirmwareLabel);
        }
Exemple #2
0
        private MainWindow(Builder builder) : base(builder.GetObject("_mainWin").Handle)
        {
            builder.Autoconnect(this);

            int monitorWidth  = Display.PrimaryMonitor.Geometry.Width * Display.PrimaryMonitor.ScaleFactor;
            int monitorHeight = Display.PrimaryMonitor.Geometry.Height * Display.PrimaryMonitor.ScaleFactor;

            this.DefaultWidth  = monitorWidth < 1280 ? monitorWidth : 1280;
            this.DefaultHeight = monitorHeight < 760 ? monitorHeight : 760;

            this.WindowStateEvent += MainWindow_WindowStateEvent;
            this.DeleteEvent      += Window_Close;
            _fullScreen.Activated += FullScreen_Toggled;

            this.Icon  = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png");
            this.Title = $"Ryujinx {Program.Version}";

            ApplicationLibrary.ApplicationAdded        += Application_Added;
            ApplicationLibrary.ApplicationCountUpdated += ApplicationCount_Updated;
            GlRenderer.StatusUpdatedEvent += Update_StatusBar;

            _gameTable.ButtonReleaseEvent += Row_Clicked;

            // First we check that a migration isn't needed. (because VirtualFileSystem will create the new directory otherwise)
            bool continueWithStartup = Migration.PromptIfMigrationNeededForStartup(this, out bool migrationNeeded);

            if (!continueWithStartup)
            {
                End(null);
            }

            _virtualFileSystem = VirtualFileSystem.CreateInstance();
            _contentManager    = new ContentManager(_virtualFileSystem);

            if (migrationNeeded)
            {
                bool migrationSuccessful = Migration.DoMigrationForStartup(this, _virtualFileSystem);

                if (!migrationSuccessful)
                {
                    End(null);
                }
            }

            // Make sure that everything is loaded.
            _virtualFileSystem.Reload();

            ApplyTheme();

            _stopEmulation.Sensitive = false;

            if (ConfigurationState.Instance.Ui.GuiColumns.FavColumn)
            {
                _favToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.IconColumn)
            {
                _iconToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.AppColumn)
            {
                _appToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.DevColumn)
            {
                _developerToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.VersionColumn)
            {
                _versionToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.TimePlayedColumn)
            {
                _timePlayedToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.LastPlayedColumn)
            {
                _lastPlayedToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.FileExtColumn)
            {
                _fileExtToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.FileSizeColumn)
            {
                _fileSizeToggle.Active = true;
            }
            if (ConfigurationState.Instance.Ui.GuiColumns.PathColumn)
            {
                _pathToggle.Active = true;
            }

#if USE_DEBUGGING
            _debugger = new Debugger.Debugger();
            _openDebugger.Activated += _openDebugger_Opened;
#else
            _openDebugger.Hide();
#endif

            _gameTable.Model = _tableStore = new ListStore(
                typeof(bool),
                typeof(Gdk.Pixbuf),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(string),
                typeof(BlitStruct <ApplicationControlProperty>));

            _tableStore.SetSortFunc(5, TimePlayedSort);
            _tableStore.SetSortFunc(6, LastPlayedSort);
            _tableStore.SetSortFunc(8, FileSizeSort);

            int  columnId  = ConfigurationState.Instance.Ui.ColumnSort.SortColumnId;
            bool ascending = ConfigurationState.Instance.Ui.ColumnSort.SortAscending;

            _tableStore.SetSortColumnId(columnId, ascending ? SortType.Ascending : SortType.Descending);

            _gameTable.EnableSearch = true;
            _gameTable.SearchColumn = 2;

            UpdateColumns();
            UpdateGameTable();

            ConfigurationState.Instance.Ui.GameDirs.Event += (sender, args) =>
            {
                if (args.OldValue != args.NewValue)
                {
                    UpdateGameTable();
                }
            };

            Task.Run(RefreshFirmwareLabel);

            _statusBar.Hide();

            _uiHandler = new GtkHostUiHandler(this);
        }