Exemple #1
0
        protected override void OnInit()
        {
            base.OnInit();

            // Add GUI elements
            Game.Screen.Elements.Add(m_backPrompt);
            Game.Screen.Elements.Add(m_diskSelectPrompt);

            Game.Screen.Elements.Add(m_aPrompt);
            Game.Screen.Elements.Add(m_bPrompt);

            // Start audio
            m_speakerOutput = Game.Audio.Audio.PlayCustom(m_devices, 1, SPEAKER_SAMPLE_RATE);

            // Choose a disk
            var         allDisks         = ArcadeUtils.GetAllDisks();
            var         lastPlayedDiskID = Game.User.Progress.GetLastPlayedArcadeGame();
            DiskWithMod lastPlayedDisk   = null;

            if (lastPlayedDiskID != 0)
            {
                for (int i = 0; i < allDisks.Count; ++i)
                {
                    var disk = allDisks[i];
                    if (ArcadeUtils.IsDiskUnlocked(disk.Disk, disk.Mod, Game.User.Progress) &&
                        disk.Disk.ID == lastPlayedDiskID)
                    {
                        lastPlayedDisk = disk;
                        break;
                    }
                }
            }
            if (lastPlayedDisk == null)
            {
                lastPlayedDisk = allDisks.FirstOrDefault(
                    disk => ArcadeUtils.IsDiskUnlocked(disk.Disk, disk.Mod, Game.User.Progress)
                    );
            }
            if (lastPlayedDisk != null)
            {
                SelectDisk(lastPlayedDisk.Disk, lastPlayedDisk.Mod);
            }

            // Turn on the computer
            m_computer.TurnOn();
            UpdateDisplay();
        }
Exemple #2
0
        public DiskSelector(Screen screen, string initialDiskPath, Mod initialDiskMod, Progress progress)
        {
            m_geometry      = new Geometry(Primitive.Triangles);
            m_disks         = ArcadeUtils.GetAllDisks().ToArray();
            m_disksUnlocked = m_disks.Select(disk => ArcadeUtils.IsDiskUnlocked(disk.Disk, disk.Mod, progress)).ToArray();

            m_page = 0;
            if (m_disks.Length <= COLUMNS_PER_PAGE)
            {
                m_numColumns = m_disks.Length;
                m_numRows    = 1;
            }
            else if (m_disks.Length < NUM_PER_PAGE)
            {
                m_numColumns = (m_disks.Length + ROWS_PER_PAGE - 1) / ROWS_PER_PAGE;
                m_numRows    = ROWS_PER_PAGE;
            }
            else
            {
                m_numColumns = COLUMNS_PER_PAGE;
                m_numRows    = ROWS_PER_PAGE;
            }
            m_highlight = -1;

            m_backPrompt                       = new InputPrompt(UIFonts.Smaller, screen.Language.Translate("menus.close"), TextAlignment.Right);
            m_backPrompt.Key                   = Key.Escape;
            m_backPrompt.MouseButton           = MouseButton.Left;
            m_backPrompt.GamepadButton         = GamepadButton.B;
            m_backPrompt.SteamControllerButton = SteamControllerButton.MenuBack;
            m_backPrompt.Anchor                = Anchor.BottomRight;
            m_backPrompt.LocalPosition         = new Vector2(-16.0f, -16.0f - m_backPrompt.Height);
            m_backPrompt.Parent                = this;
            m_backPrompt.OnClick              += delegate(object o, EventArgs args)
            {
                m_closeNextFrame = true;
            };

            m_selectPrompt                       = new InputPrompt(UIFonts.Smaller, screen.Language.Translate("menus.select"), TextAlignment.Left);
            m_selectPrompt.Key                   = Key.Return;
            m_selectPrompt.GamepadButton         = GamepadButton.A;
            m_selectPrompt.SteamControllerButton = SteamControllerButton.MenuSelect;
            m_selectPrompt.Anchor                = Anchor.BottomLeft;
            m_selectPrompt.LocalPosition         = new Vector2(16.0f, -16.0f - m_selectPrompt.Height);
            m_selectPrompt.Parent                = this;

            m_browseWorkshopPrompt                       = new InputPrompt(UIFonts.Smaller, screen.Language.Translate("menus.arcade.browse_workshop"), TextAlignment.Right);
            m_browseWorkshopPrompt.Key                   = Key.LeftCtrl;
            m_browseWorkshopPrompt.GamepadButton         = GamepadButton.Y;
            m_browseWorkshopPrompt.SteamControllerButton = SteamControllerButton.MenuAltSelect;
            m_browseWorkshopPrompt.Anchor                = Anchor.BottomRight;
            m_browseWorkshopPrompt.LocalPosition         = new Vector2(-16.0f, -16.0f - m_selectPrompt.Height - m_browseWorkshopPrompt.Height);
            m_browseWorkshopPrompt.Parent                = this;

            m_previousPageButton                               = new Button(Texture.Get("gui/arrows.png", true), 32.0f, 32.0f);
            m_previousPageButton.Region                        = new Quad(0.0f, 0.5f, 0.5f, 0.5f);
            m_previousPageButton.HighlightRegion               = m_previousPageButton.Region;
            m_previousPageButton.DisabledRegion                = m_previousPageButton.Region;
            m_previousPageButton.ShortcutButton                = GamepadButton.LeftBumper;
            m_previousPageButton.AltShortcutButton             = GamepadButton.LeftTrigger;
            m_previousPageButton.ShortcutSteamControllerButton = SteamControllerButton.MenuPreviousPage;
            m_previousPageButton.Colour                        = UIColours.Title;
            m_previousPageButton.HighlightColour               = UIColours.White;
            m_previousPageButton.DisabledColour                = m_previousPageButton.Colour;
            m_previousPageButton.Anchor                        = Anchor.CentreMiddle;
            m_previousPageButton.LocalPosition                 = new Vector2(
                -0.5f * (float)COLUMNS_PER_PAGE * (DISK_SIZE + DISK_PADDING) - m_previousPageButton.Width,
                -0.5f * m_previousPageButton.Height
                );
            m_previousPageButton.Parent     = this;
            m_previousPageButton.OnClicked += delegate(object o, EventArgs e)
            {
                PreviousPage();
            };

            m_nextPageButton                               = new Button(Texture.Get("gui/arrows.png", true), 32.0f, 32.0f);
            m_nextPageButton.Region                        = new Quad(0.0f, 0.0f, 0.5f, 0.5f);
            m_nextPageButton.HighlightRegion               = m_nextPageButton.Region;
            m_nextPageButton.DisabledRegion                = m_nextPageButton.Region;
            m_nextPageButton.ShortcutButton                = GamepadButton.RightBumper;
            m_nextPageButton.AltShortcutButton             = GamepadButton.RightTrigger;
            m_nextPageButton.ShortcutSteamControllerButton = SteamControllerButton.MenuNextPage;
            m_nextPageButton.Colour                        = UIColours.Title;
            m_nextPageButton.HighlightColour               = UIColours.White;
            m_nextPageButton.DisabledColour                = m_nextPageButton.Colour;
            m_nextPageButton.Anchor                        = Anchor.CentreMiddle;
            m_nextPageButton.LocalPosition                 = new Vector2(
                0.5f * (float)COLUMNS_PER_PAGE * (DISK_SIZE + DISK_PADDING),
                -0.5f * m_previousPageButton.Height
                );
            m_nextPageButton.Parent     = this;
            m_nextPageButton.OnClicked += delegate(object o, EventArgs e)
            {
                NextPage();
            };

            // Load labels
            m_diskLabels = new Texture[m_disks.Length];
            for (int i = 0; i < m_disks.Length; ++i)
            {
                var disk      = m_disks[i];
                var labelPath = AssetPath.ChangeExtension(disk.Disk.Path, "png");
                if (disk.Mod != null)
                {
                    if (disk.Mod.Assets.CanLoad(labelPath))
                    {
                        m_diskLabels[i]        = disk.Mod.Assets.Load <Texture>(labelPath);
                        m_diskLabels[i].Filter = false;
                    }
                }
                else
                {
                    m_diskLabels[i] = Texture.Get(labelPath, false);
                }
            }

            m_framesOpen     = 0;
            m_closeNextFrame = false;

            // Determine initial disk index
            m_initialDisk = -1;
            if (initialDiskPath != null && m_disks.Length > 0)
            {
                for (int i = 0; i < m_disks.Length; ++i)
                {
                    var disk = m_disks[i];
                    if (disk.Disk.Path == initialDiskPath &&
                        disk.Mod == initialDiskMod &&
                        m_disksUnlocked[i])
                    {
                        m_initialDisk = i;
                        break;
                    }
                }
            }
        }