Esempio n. 1
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();
                }
            }
        }
Esempio n. 2
0
        private UIMenu buildMainMenu()
        {
            mainMenu = new UIMenu("Race Timer", "~b~by iLike2Teabag");

            // add a submenu to handle race imports
            UIMenu raceImportMenu = _menuPool.AddSubMenu(mainMenu, "Race Import Menu", "Choose races to import from file");

            buildRaceImportMenu(raceImportMenu);

            // add a submenu for race control
            UIMenu raceControlMenu = _menuPool.AddSubMenu(mainMenu, "Race Control Menu", "Modify checkpoints and race mode");

            raceControlMenu.OnMenuOpen += buildRaceControlMenu;
            //buildRaceControlMenu(raceControlMenu);

            // add a submenu for Timing Sheet
            UIMenu lapTimeMenu = _menuPool.AddSubMenu(mainMenu, "Lap Times", "Display lap times for the current race");

            lapTimeMenu.OnMenuOpen += loadLapTimeMenu;

            // add controls to enter placement & race modes
            UIMenuItem placementToggle = new UIMenuItem("Toggle Placement Mode");
            UIMenuItem raceToggle      = new UIMenuItem("Toggle Race Mode");

            placementToggle.Activated += (menu, sender) => race.togglePlacementMode();
            raceToggle.Activated      += (menu, sender) => race.toggleRaceMode();
            mainMenu.AddItem(placementToggle);
            mainMenu.AddItem(raceToggle);

            // add control to export race
            UIMenuItem exportRaceItem = new UIMenuItem("Export Race");

            exportRaceItem.Activated += (menu, sender) => race.exportRace();
            mainMenu.AddItem(exportRaceItem);

            mainMenu.RefreshIndex();
            return(mainMenu);
        }