Exemplo n.º 1
0
        /// <inheritdoc/>
        public override void Show(int x = -1, int y = -1)
        {
            _scroller = new ScrollView();

            AddChild(_scroller);

            _userIcon     = new PictureBox();
            _userFullName = new Label();
            _userHostname = new Label();

            AddChild(_userIcon);
            AddChild(_userFullName);
            AddChild(_userHostname);

            _userFullName.AutoSize  = true;
            _userHostname.AutoSize  = true;
            _userFullName.FontStyle = Plex.Engine.Themes.TextFontStyle.Header3;

            _userIcon.Width  = 72;
            _userIcon.Height = 72;

            _userIcon.Texture = _plexgate.Content.Load <Texture2D>("MainMenu/MenuButtons/SinglePlayer");

            _userFullName.Text = (_itch.LoggedIn) ? _itch.User.display_name : "Peacegate OS User";
            if (string.IsNullOrWhiteSpace(_userFullName.Text))
            {
                _userFullName.Text = "Peacegate OS User";
            }
            string itchUsername = (_itch.LoggedIn) ? _itch.User.username : "******";
            string osEdition    = _server.IsMultiplayer ? "Peacegate OS for Sentient Programs" : "Peacegate OS for Peacenet Uplink Kiosks - Pre-deployment Mode";

            _userHostname.Text = $"{itchUsername}@{_os.Hostname} ({osEdition})";

            _apps     = new AppLauncherSectionButton();
            _computer = new AppLauncherSectionButton();
            _settings = new AppLauncherSectionButton();
            _history  = new AppLauncherSectionButton();
            _leave    = new AppLauncherSectionButton();

            AddChild(_apps);
            AddChild(_computer);
            AddChild(_settings);
            AddChild(_history);
            AddChild(_leave);

            _apps.Name     = "Apps";
            _computer.Name = "Computer";
            _settings.Name = "Settings";
            _history.Name  = "History";
            _leave.Name    = "Leave";

            _apps.Activated += () =>
            {
                _page = 0;
                ResetUI();
            };
            _computer.Activated += () =>
            {
                _page = 2;
                ResetUI();
            };
            _settings.Activated += () =>
            {
                _page = 3;
                ResetUI();
            };
            _history.Activated += () =>
            {
                _page = 4;
                ResetUI();
            };
            _leave.Activated += () =>
            {
                _page = 5;
                ResetUI();
            };


            _appsStacker         = new Stacker();
            _appsCategoryStacker = new Stacker();
            _computerStacker     = new Stacker();
            _settingsStacker     = new Stacker();

            _leaveStacker = new Stacker();

            _appsStacker.AutoSize         = true;
            _appsCategoryStacker.AutoSize = true;
            _computerStacker.AutoSize     = true;
            _settingsStacker.AutoSize     = true;

            _leaveStacker.AutoSize = true;

            var systemSettings = new AppLauncherItem();

            systemSettings.Name        = "System Settings";
            systemSettings.Description = "Adjust core settings of the Peacegate OS, such as screen resolution, audio volume, and user interface effects.";
            systemSettings.Activated  += () =>
            {
                var gameSettings = new GameSettings(WindowSystem);
                gameSettings.Show();
            };
            _settingsStacker.AddChild(systemSettings);

            var leavePeacegate = new AppLauncherItem();

            leavePeacegate.Name        = "Exit Peacegate";
            leavePeacegate.Description = "Exit your Peacegate OS session, closing all your open programs and terminating your connection to The Peacenet.";
            leavePeacegate.Activated  += () =>
            {
                foreach (var window in WindowSystem.WindowList)
                {
                    window.Border.Enabled = false;
                }
                _infobox.ShowYesNo("Exit Peacegate", "Are you sure you want to exit Peacegate OS?", (answer) =>
                {
                    foreach (var window in WindowSystem.WindowList)
                    {
                        window.Border.Enabled = true;
                    }
                    if (answer)
                    {
                        foreach (var window in WindowSystem.WindowList)
                        {
                            if (window.Border != _desktop.Parent)
                            {
                                WindowSystem.Close(window.WindowID);
                            }
                        }
                        _desktop.Shutdown();
                    }
                });
            };
            _leaveStacker.AddChild(leavePeacegate);

            foreach (var cat in _al.GetAllCategories())
            {
                var item = new AppLauncherItem();
                item.Name       = cat;
                item.Activated += () =>
                {
                    _page = 1;
                    SetupCategory(cat);
                    ResetUI();
                };
                _appsStacker.AddChild(item);
            }

            var runCommand = new AppLauncherItem();

            runCommand.Name        = "Run command...";
            runCommand.Description = "Run a Terminal Command.";
            runCommand.Activated  += () =>
            {
                _infobox.PromptText("Run Command", "Enter a command to run.", (command) =>
                {
                    var terminal = new RunCommandTerminal(WindowSystem, command);
                    terminal.Show();
                });
            };
            _computerStacker.AddChild(runCommand);

            foreach (var dir in _os.GetShellDirs())
            {
                var shellItem = new AppLauncherItem();
                shellItem.Icon        = dir.Texture;
                shellItem.Name        = dir.FriendlyName;
                shellItem.Description = dir.Path;
                shellItem.Activated  += () =>
                {
                    var fm = new FileManager(WindowSystem);
                    fm.SetCurrentDirectory(dir.Path);
                    fm.Show();
                };
                _computerStacker.AddChild(shellItem);
            }

            ResetUI();

            base.Show(x, y);
        }