Esempio n. 1
0
        private void buildRaceControlMenu(UIMenu submenu)
        {
            submenu.Clear();

            // add checkbox to toggle lap mode
            string             lapModeDescription = "If checked, race is a circuit, and automatically restarts. If unchecked, race is point-to-point";
            UIMenuCheckboxItem lapModeItem        = new UIMenuCheckboxItem("Lap Mode", race.lapRace, lapModeDescription);

            lapModeItem.CheckboxEvent += (sender, status) => race.lapRace = status;
            submenu.AddItem(lapModeItem);

            // add button to place checkpoint
            UIMenuItem addCheckpointBtn = new UIMenuItem("Place checkpoint", "Place a checkpoint at the player's current location");

            addCheckpointBtn.Activated += (m, i) => race.createSectorCheckpoint();
            submenu.AddItem(addCheckpointBtn);

            // undo last placed checkpoint
            UIMenuItem undoCheckpointBtn = new UIMenuItem("Undo last checkpoint", "Remove the last checkpoint");

            undoCheckpointBtn.Activated += (m, i) => race.deleteLastSectorCheckpoint();
            submenu.AddItem(undoCheckpointBtn);

            // delete all checkpoints
            UIMenuItem deleteAllCheckpointsBtn = new UIMenuItem("Delete all checkpoints");

            deleteAllCheckpointsBtn.Activated += (m, i) => race.clearAllSectorCheckpoints();
            submenu.AddItem(deleteAllCheckpointsBtn);

            //return submenu;
        }
Esempio n. 2
0
        // ------------- EVENT LISTENERS/HANDLERS -----------------
        #region eventHandlers
        private void onKeyDown(object sender, KeyEventArgs e)
        {
            // open menu
            if (e.Modifiers == Keys.Control && e.KeyCode == menuKey)
            {
                menu.toggleMenu();
            }

            // enter/exit placement mode with F5
            else if (e.KeyCode == placementActivateKey)
            {
                race.togglePlacementMode();
            }

            // if placement mode is enabled, and the control key was used:
            else if (race.placementMode && e.Modifiers == Keys.Control)
            {
                // Ctrl+X: add a checkpoint
                if (e.KeyCode == addCheckpointKey)
                {
                    race.createSectorCheckpoint();
                }

                // Ctrl+Z: delete (undo) last SectorCheckpoint
                else if (e.KeyCode == undoCheckpointKey)
                {
                    race.deleteLastSectorCheckpoint();
                }

                // Ctrl+D: clear all SectorCheckpoints, and delete any blips & checkpoints from World
                else if (e.KeyCode == clearCheckpointsKey)
                {
                    race.clearAllSectorCheckpoints();
                }
            }

            // enter/exit race mode with F6
            else if (e.KeyCode == raceActivateKey)
            {
                race.toggleRaceMode();
            }

            // if race mode is enabled, and the control key was used:
            else if (race.raceMode && e.Modifiers == Keys.Control)
            {
                // Ctrl+R: restart race
                if (e.KeyCode == restartRaceKey)
                {
                    race.enterRaceMode();
                }
            }
        }