Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions MenuAPI.sln

This file was deleted.

4 changes: 4 additions & 0 deletions MenuAPI.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Solution>
<Project Path="MenuAPI/MenuAPI.csproj" />
<Project Path="TestMenu/TestMenu.csproj" />
</Solution>
4 changes: 0 additions & 4 deletions MenuAPI/MenuAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
<Compile Include="..\shared\Controls.cs" Link="Controls.cs" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CitizenFX.FiveM.Client" Version="0.0.2-alpha" />
</ItemGroup>
Expand Down
73 changes: 61 additions & 12 deletions MenuAPI/MenuController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CitizenFX.Core;

Expand Down Expand Up @@ -103,14 +104,62 @@ public enum MenuAlignmentOption
/// </summary>
public void Initialize()
{
API.SetInterval(ProcessMenus, 3, 0);
API.SetInterval(DrawInstructionalButtons, 3, 0);
API.SetInterval(ProcessMainButtons, 3, 0);
API.SetInterval(ProcessDirectionalButtons, 100l, 0);
API.SetInterval(ProcessToggleMenuButton, 3, 0);
API.SetInterval(MenuButtonsDisableChecks, 3, 0);
LoopProcessMenus();
LoopDrawInstructionalButtons();
LoopProcessMainButtons();
LoopProcessDirectionalButtons();
LoopProcessToggleMenuButton();
LoopMenuButtonsDisableChecks();
}

async void LoopProcessMenus()
{
while (true)
{
await ProcessMenus();
await API.Yield();
}
}
async void LoopDrawInstructionalButtons()
{
while (true)
{
await DrawInstructionalButtons();
await API.Yield();
}
}
async void LoopProcessMainButtons()
{
while (true)
{
await ProcessMainButtons();
await API.Yield();
}
}
async void LoopProcessDirectionalButtons()
{
while (true)
{
await ProcessDirectionalButtons();
await API.Yield();
}
}
async void LoopProcessToggleMenuButton()
{
while (true)
{
await ProcessToggleMenuButton();
await API.Yield();
}
}
async void LoopMenuButtonsDisableChecks()
{
while (true)
{
await MenuButtonsDisableChecks();
await API.Yield();
}
}
/// <summary>
/// This binds the <paramref name="childMenu"/> menu to the <paramref name="menuItem"/> and sets the menu's parent to <paramref name="parentMenu"/>.
/// </summary>
Expand Down Expand Up @@ -220,7 +269,7 @@ public static Menu GetCurrentMenu()
/// Process the select & go back/cancel buttons.
/// </summary>
/// <returns></returns>
private async void ProcessMainButtons()
private async Task ProcessMainButtons()
{
if (!IsAnyMenuOpen())
{
Expand Down Expand Up @@ -362,7 +411,7 @@ private bool IsDownPressed()
/// Processes the menu toggle button to check if the menu should open or close.
/// </summary>
/// <returns></returns>
private async void ProcessToggleMenuButton()
private async Task ProcessToggleMenuButton()
{
if (!MenuToggleKeyIsValid)
{
Expand Down Expand Up @@ -401,7 +450,7 @@ private async Task ProcessToggleMenuButtonFiveM()
/// Process left/right/up/down buttons (also holding down buttons will speed up after 3 iterations)
/// </summary>
/// <returns></returns>
private async void ProcessDirectionalButtons()
private async Task ProcessDirectionalButtons()
{
// Return if the buttons are not currently enabled.
if (!AreMenuButtonsEnabled)
Expand Down Expand Up @@ -692,7 +741,7 @@ private async Task HandleUpNavigation(Menu currentMenu)
}
}

private async void MenuButtonsDisableChecks()
private async Task MenuButtonsDisableChecks()
{
bool isInputVisible() => UpdateOnscreenKeyboard() == 0;
if (isInputVisible())
Expand Down Expand Up @@ -847,7 +896,7 @@ private static void DisableRadioInputs()
/// Draws all the menus that are visible on the screen.
/// </summary>
/// <returns></returns>
private static async void ProcessMenus()
private static async Task ProcessMenus()
{
if (!(
Menus.Any() &&
Expand Down Expand Up @@ -901,7 +950,7 @@ private static async Task DrawMenus()
}
}

internal static async void DrawInstructionalButtons()
internal static async Task DrawInstructionalButtons()
{
if (
IsPlayerSwitchInProgress() ||
Expand Down
5 changes: 0 additions & 5 deletions TestMenu/TestMenu.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
<LangVersion>default</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug FiveM' Or '$(Configuration)' == 'Release FiveM'">
<DefineConstants>FIVEM</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Reference Include="Microsoft.CSharp" />

<ProjectReference Include="..\MenuAPI\MenuAPI.csproj" />
</ItemGroup>
Expand Down
Loading