/// <summary> /// Process the select & go back/cancel buttons. /// </summary> /// <returns></returns> private async Task ProcessMainButtons() { UIMenu currentMenu = Cf.GetOpenMenu(); if (currentMenu != null && !DontOpenMenus && Mp.IsAnyMenuOpen() && !NoClipEnabled) { if (currentMenu.Visible && !DisableControls) { // Select / Enter if (Game.IsDisabledControlJustReleased(0, Control.FrontendAccept) || Game.IsControlJustReleased(0, Control.FrontendAccept)) { if (currentMenu.MenuItems.Count() > 0) { currentMenu.SelectItem(); } } // Cancel / Go Back else if (Game.IsDisabledControlJustReleased(0, Control.PhoneCancel)) { // Wait for the next frame to make sure the "cinematic camera" button doesn't get "re-enabled" before the menu gets closed. await Delay(0); currentMenu.GoBack(); } } } else { await Delay(0); } }
/// <summary> /// Process the select & go back/cancel buttons. /// </summary> /// <returns></returns> private async Task ProcessMainButtons() { UIMenu currentMenu = Cf.GetOpenMenu(); if (currentMenu != null) { // Select / Enter if (Game.IsDisabledControlJustReleased(0, Control.FrontendAccept) || Game.IsControlJustReleased(0, Control.FrontendAccept)) { currentMenu.SelectItem(); if (DebugMode) { Subtitle.Custom("select"); } } // Cancel / Go Back else if (Game.IsDisabledControlJustReleased(0, Control.PhoneCancel)) { // Wait for the next frame to make sure the "cinematic camera" button doesn't get "re-enabled" before the menu gets closed. await Delay(0); currentMenu.GoBack(); if (DebugMode) { Subtitle.Custom("cancel"); } } } else { await Delay(0); } }
/// <summary> /// Process left/right/up/down buttons (also holding down buttons will speed up after 3 iterations) /// </summary> /// <returns></returns> private async Task ProcessDirectionalButtons() { // Get the currently open menu. UIMenu currentMenu = Cf.GetOpenMenu(); // If it exists. if (currentMenu != null) { // Check if the Go Up controls are pressed. if (Game.IsDisabledControlJustPressed(0, Control.Phone) || Game.IsControlJustPressed(0, Control.SniperZoomInSecondary)) { // Update the currently selected item to the new one. currentMenu.GoUp(); currentMenu.GoUpOverflow(); // Get the current game time. var time = GetGameTimer(); var times = 0; var delay = 200; // Do the following as long as the controls are being pressed. while (Game.IsDisabledControlPressed(0, Control.Phone) && Cf.GetOpenMenu() != null) { // Update the current menu. currentMenu = Cf.GetOpenMenu(); // Check if the game time has changed by "delay" amount. if (GetGameTimer() - time > delay) { // Increment the "changed indexes" counter times++; // If the controls are still being held down after moving 3 indexes, reduce the delay between index changes. if (times > 2) { delay = 150; } // Update the currently selected item to the new one. currentMenu.GoUp(); currentMenu.GoUpOverflow(); // Reset the time to the current game timer. time = GetGameTimer(); } // Wait for the next game tick. await Delay(0); } // If debugging is enabled, a subtitle will be shown when this control is pressed. if (DebugMode) { Subtitle.Custom("up"); } } // Check if the Go Left controls are pressed. else if (Game.IsDisabledControlJustPressed(0, Control.PhoneLeft)) { currentMenu.GoLeft(); var time = GetGameTimer(); var times = 0; var delay = 200; while (Game.IsDisabledControlPressed(0, Control.PhoneLeft) && Cf.GetOpenMenu() != null) { currentMenu = Cf.GetOpenMenu(); if (GetGameTimer() - time > delay) { times++; if (times > 2) { delay = 150; } currentMenu.GoLeft(); time = GetGameTimer(); } await Delay(0); } if (DebugMode) { Subtitle.Custom("left"); } } // Check if the Go Right controls are pressed. else if (Game.IsDisabledControlJustPressed(0, Control.PhoneRight)) { currentMenu.GoRight(); var time = GetGameTimer(); var times = 0; var delay = 200; while (Game.IsDisabledControlPressed(0, Control.PhoneRight) && Cf.GetOpenMenu() != null) { currentMenu = Cf.GetOpenMenu(); if (GetGameTimer() - time > delay) { times++; if (times > 2) { delay = 150; } currentMenu.GoRight(); time = GetGameTimer(); } await Delay(0); } if (DebugMode) { Subtitle.Custom("right"); } } // Check if the Go Down controls are pressed. else if (Game.IsDisabledControlJustPressed(0, Control.PhoneDown) || Game.IsControlJustPressed(0, Control.SniperZoomOutSecondary)) { currentMenu.GoDown(); currentMenu.GoDownOverflow(); var time = GetGameTimer(); var times = 0; var delay = 200; while (Game.IsDisabledControlPressed(0, Control.PhoneDown) && Cf.GetOpenMenu() != null) { currentMenu = Cf.GetOpenMenu(); if (GetGameTimer() - time > delay) { times++; if (times > 2) { delay = 150; } currentMenu.GoDown(); currentMenu.GoDownOverflow(); time = GetGameTimer(); } await Delay(0); } if (DebugMode) { Subtitle.Custom("down"); } } } }
/// <summary> /// Process left/right/up/down buttons (also holding down buttons will speed up after 3 iterations) /// </summary> /// <returns></returns> private async Task ProcessDirectionalButtons() { // Get the currently open menu. UIMenu currentMenu = Cf.GetOpenMenu(); // If it exists. if (currentMenu != null && !DontOpenMenus && Mp.IsAnyMenuOpen() && !NoClipEnabled) { if (currentMenu.Visible && !DisableControls) { // Check if the Go Up controls are pressed. if (Game.IsDisabledControlJustPressed(0, (Control)188) || Game.IsControlJustPressed(0, (Control)188) || Game.IsControlJustPressed(0, (Control)181) || Game.IsDisabledControlJustPressed(0, (Control)181)) { // Update the currently selected item to the new one. currentMenu.GoUp(); currentMenu.GoUpOverflow(); // Get the current game time. var time = GetGameTimer(); var times = 0; var delay = 200; // Do the following as long as the controls are being pressed. while ((Game.IsDisabledControlPressed(0, (Control)188) || Game.IsControlPressed(0, (Control)188)) && Cf.GetOpenMenu() != null) { // Update the current menu. currentMenu = Cf.GetOpenMenu(); // Check if the game time has changed by "delay" amount. if (GetGameTimer() - time > delay) { // Increment the "changed indexes" counter times++; // If the controls are still being held down after moving 3 indexes, reduce the delay between index changes. if (times > 2) { delay = 150; } // Update the currently selected item to the new one. currentMenu.GoUp(); currentMenu.GoUpOverflow(); // Reset the time to the current game timer. time = GetGameTimer(); } // Wait for the next game tick. await Delay(0); } } // Check if the Go Left controls are pressed. else if (Game.IsDisabledControlJustPressed(0, Control.PhoneLeft)) { currentMenu.GoLeft(); var time = GetGameTimer(); var times = 0; var delay = 200; while (Game.IsDisabledControlPressed(0, Control.PhoneLeft) && Cf.GetOpenMenu() != null) { currentMenu = Cf.GetOpenMenu(); if (GetGameTimer() - time > delay) { times++; if (times > 2) { delay = 150; } currentMenu.GoLeft(); time = GetGameTimer(); } await Delay(0); } } // Check if the Go Right controls are pressed. else if (Game.IsDisabledControlJustPressed(0, Control.PhoneRight)) { currentMenu.GoRight(); var time = GetGameTimer(); var times = 0; var delay = 200; while ((Game.IsDisabledControlPressed(0, Control.PhoneRight) || Game.IsControlPressed(0, Control.PhoneRight)) && Cf.GetOpenMenu() != null) { currentMenu = Cf.GetOpenMenu(); if (GetGameTimer() - time > delay) { times++; if (times > 2) { delay = 150; } currentMenu.GoRight(); time = GetGameTimer(); } await Delay(0); } } // Check if the Go Down controls are pressed. else if (Game.IsDisabledControlJustPressed(0, (Control)187) || Game.IsControlJustPressed(0, (Control)187) || Game.IsControlJustPressed(0, (Control)180) || Game.IsDisabledControlJustPressed(0, (Control)180)) { currentMenu.GoDown(); currentMenu.GoDownOverflow(); var time = GetGameTimer(); var times = 0; var delay = 200; while ((Game.IsDisabledControlPressed(0, (Control)187) || Game.IsControlPressed(0, (Control)187) || Game.IsControlPressed(0, (Control)180) || Game.IsDisabledControlPressed(0, (Control)180)) && Cf.GetOpenMenu() != null) { currentMenu = Cf.GetOpenMenu(); if (GetGameTimer() - time > delay) { times++; if (times > 2) { delay = 150; } currentMenu.GoDown(); currentMenu.GoDownOverflow(); time = GetGameTimer(); } await Delay(0); } } } else { await Delay(0); } } else { await Delay(0); } }