mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 15:40:29 +01:00
RNUIMouseInputHandler now utilizes InputManager.dll to simulate key presses on mouse click.
This commit is contained in:
parent
cd1bce8c2c
commit
c7a24a1c0a
1 changed files with 13 additions and 136 deletions
|
|
@ -1,7 +1,7 @@
|
|||
using Rage;
|
||||
using InputManager;
|
||||
using Rage;
|
||||
using RAGENativeUI;
|
||||
using RAGENativeUI.Elements;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
|
@ -12,7 +12,7 @@ namespace SceneManager
|
|||
{
|
||||
internal delegate void Function();
|
||||
|
||||
internal static void Initialize(UIMenu menu, List<UIMenuScrollerItem> scrollerItems, Dictionary<UIMenuCheckboxItem, Function> checkboxItems, Dictionary<UIMenuItem, Function> selectItems)
|
||||
internal static void Initialize(UIMenu menu, List<UIMenuScrollerItem> scrollerItems)
|
||||
{
|
||||
GameFiber.StartNew(() =>
|
||||
{
|
||||
|
|
@ -24,27 +24,11 @@ namespace SceneManager
|
|||
OnWheelScroll(menu, selectedScroller, scrollerItems);
|
||||
}
|
||||
|
||||
if (Game.IsKeyDown(Keys.LButton))
|
||||
if (Game.IsKeyDown(Keys.LButton) && Rage.Native.NativeFunction.Natives.UPDATE_ONSCREEN_KEYBOARD<int>() != 0)
|
||||
{
|
||||
var selectedItem = menu.MenuItems.Where(x => x.Enabled && x.Selected).FirstOrDefault();
|
||||
if (selectedItem != null)
|
||||
{
|
||||
//Game.LogTrivial($"selectedItem: {selectedItem.Text}");
|
||||
//Game.LogTrivial($"scrollerItems contains: {scrollerItems.Contains(selectedItem)}");
|
||||
if (selectItems.ContainsKey(selectedItem))
|
||||
{
|
||||
OnMenuItemClicked(selectItems);
|
||||
}
|
||||
else if (!scrollerItems.Contains(selectedItem) && checkboxItems.ContainsKey((UIMenuCheckboxItem)selectedItem))
|
||||
{
|
||||
OnCheckboxItemClicked(checkboxItems);
|
||||
}
|
||||
}
|
||||
|
||||
if(menu.SubtitleText == "~o~Main Menu")
|
||||
{
|
||||
menu.Visible = false;
|
||||
}
|
||||
Keyboard.KeyDown(Keys.Enter);
|
||||
GameFiber.Wait(1);
|
||||
Keyboard.KeyUp(Keys.Enter);
|
||||
}
|
||||
|
||||
if (menu.SubtitleText.Contains("Path Creation Menu"))
|
||||
|
|
@ -56,32 +40,6 @@ namespace SceneManager
|
|||
});
|
||||
}
|
||||
|
||||
internal static void OnCheckboxItemClicked(Dictionary<UIMenuCheckboxItem, Function> checkboxItems)
|
||||
{
|
||||
var checkedItem = checkboxItems.Keys.Where(x => x.Selected && x.Enabled).FirstOrDefault();
|
||||
if(checkedItem != null)
|
||||
{
|
||||
checkedItem.Checked = !checkedItem.Checked;
|
||||
if(checkboxItems.TryGetValue(checkedItem, out Function func))
|
||||
{
|
||||
func?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void OnMenuItemClicked(Dictionary<UIMenuItem, Function> selectItems)
|
||||
{
|
||||
var selectedItem = selectItems.Keys.Where(x => x.Selected && x.Enabled).FirstOrDefault();
|
||||
//Game.LogTrivial($"selectedItem: {selectedItem?.Text}");
|
||||
if (selectedItem != null)
|
||||
{
|
||||
if (selectItems.TryGetValue(selectedItem, out Function func))
|
||||
{
|
||||
func?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void OnWheelScroll(UIMenu menu, UIMenuItem selectedScroller, List<UIMenuScrollerItem> scrollerItems)
|
||||
{
|
||||
var menuScrollingDisabled = false;
|
||||
|
|
@ -115,98 +73,17 @@ namespace SceneManager
|
|||
|
||||
void ScrollMenuItem()
|
||||
{
|
||||
//Game.LogTrivial($"Selected scroller: {selectedScroller.Text}");
|
||||
if (Game.GetMouseWheelDelta() > 0)
|
||||
{
|
||||
foreach (var item in scrollerItems)
|
||||
{
|
||||
if (item == selectedScroller)
|
||||
{
|
||||
//Game.LogTrivial($"item text: {item.Text}");
|
||||
item.ScrollToNextOption();
|
||||
if (menu.SubtitleText.ToLower().Contains("barrier"))
|
||||
{
|
||||
HandleBarrierMenuItems(item);
|
||||
}
|
||||
if(item.Text == "Edit Waypoint")
|
||||
{
|
||||
UpdateEditWaypointMenuItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
Keyboard.KeyDown(Keys.Right);
|
||||
GameFiber.Wait(1);
|
||||
Keyboard.KeyUp(Keys.Right);
|
||||
}
|
||||
else if (Game.GetMouseWheelDelta() < 0)
|
||||
{
|
||||
foreach (var item in scrollerItems)
|
||||
{
|
||||
if (item == selectedScroller)
|
||||
{
|
||||
item.ScrollToPreviousOption();
|
||||
if (menu.SubtitleText.ToLower().Contains("barrier"))
|
||||
{
|
||||
HandleBarrierMenuItems(item);
|
||||
}
|
||||
if (item.Text == "Edit Waypoint")
|
||||
{
|
||||
UpdateEditWaypointMenuItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HandleBarrierMenuItems(UIMenuItem item)
|
||||
{
|
||||
if (item.Text == "Spawn Barrier")
|
||||
{
|
||||
if (BarrierMenu.shadowBarrier)
|
||||
{
|
||||
BarrierMenu.shadowBarrier.Delete();
|
||||
}
|
||||
var changeTextureItem = scrollerItems.Where(x => x.Text == "Change Texture").FirstOrDefault().Index = 0;
|
||||
var listScrollerItem = (UIMenuListScrollerItem<string>)item;
|
||||
if (listScrollerItem.SelectedItem == "Flare")
|
||||
{
|
||||
scrollerItems.Where(x => x.Text == "Rotate Barrier").FirstOrDefault().Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollerItems.Where(x => x.Text == "Rotate Barrier").FirstOrDefault().Enabled = true;
|
||||
}
|
||||
menu.Width = BarrierMenu.SetMenuWidth();
|
||||
}
|
||||
else if (item.Text == "Rotate Barrier")
|
||||
{
|
||||
BarrierMenu.RotateBarrier();
|
||||
}
|
||||
else if(item.Text == "Change Texture")
|
||||
{
|
||||
var numericScrollerItem = (UIMenuNumericScrollerItem<int>)item;
|
||||
Rage.Native.NativeFunction.Natives.x971DA0055324D033(BarrierMenu.shadowBarrier, numericScrollerItem.Value);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateEditWaypointMenuItems()
|
||||
{
|
||||
var currentPath = PathMainMenu.paths[PathMainMenu.editPath.Index];
|
||||
var editWaypoint = (UIMenuNumericScrollerItem<int>)menu.MenuItems.Where(x => x.Text == "Edit Waypoint").FirstOrDefault();
|
||||
var collectorWaypoint = (UIMenuCheckboxItem)menu.MenuItems.Where(x => x.Text == "Collector").FirstOrDefault();
|
||||
var changeCollectorRadius = (UIMenuNumericScrollerItem<int>)menu.MenuItems.Where(x => x.Text == "Collection Radius").FirstOrDefault();
|
||||
var changeSpeedZoneRadius = (UIMenuNumericScrollerItem<int>)menu.MenuItems.Where(x => x.Text == "Speed Zone Radius").FirstOrDefault();
|
||||
var stopWaypointType = (UIMenuCheckboxItem)menu.MenuItems.Where(x => x.Text == "Is this a Stop waypoint?").FirstOrDefault();
|
||||
var directWaypointBehavior = (UIMenuCheckboxItem)menu.MenuItems.Where(x => x.Text == "Drive directly to waypoint?").FirstOrDefault();
|
||||
var changeWaypointSpeed = (UIMenuNumericScrollerItem<int>)menu.MenuItems.Where(x => x.Text == "Waypoint Speed").FirstOrDefault();
|
||||
var updateWaypointPosition = (UIMenuCheckboxItem)menu.MenuItems.Where(x => x.Text == "Update Waypoint Position").FirstOrDefault();
|
||||
var currentWaypoint = currentPath.Waypoints[editWaypoint.Value - 1];
|
||||
|
||||
changeWaypointSpeed.Value = (int)MathHelper.ConvertMetersPerSecondToMilesPerHour(currentWaypoint.Speed);
|
||||
stopWaypointType.Checked = currentWaypoint.IsStopWaypoint;
|
||||
directWaypointBehavior.Checked = currentWaypoint.DrivingFlagType == DrivingFlagType.Direct ? true : false;
|
||||
collectorWaypoint.Checked = currentWaypoint.IsCollector;
|
||||
changeCollectorRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
changeCollectorRadius.Value = (int)currentWaypoint.CollectorRadius;
|
||||
changeSpeedZoneRadius.Enabled = collectorWaypoint.Checked ? true : false;
|
||||
changeSpeedZoneRadius.Value = (int)currentWaypoint.SpeedZoneRadius;
|
||||
updateWaypointPosition.Checked = false;
|
||||
Keyboard.KeyDown(Keys.Left);
|
||||
GameFiber.Wait(1);
|
||||
Keyboard.KeyUp(Keys.Left);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue