Skip to content

Add Fivem Mono v2 implementation #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
56 changes: 56 additions & 0 deletions LemonUI.FiveM.V2/LemonUI.FiveM.V2.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net452</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AssemblyName>LemonUI.FiveM.V2</AssemblyName>
<RootNamespace>LemonUI</RootNamespace>
<DefineConstants>FIVEMV2,CLIENT</DefineConstants>
<Version>1.10.0</Version>
<OutputPath>$(SolutionDir)bin\$(Configuration)\FiveM.V2\</OutputPath>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>embedded</DebugType>
<DebugSymbols>true</DebugSymbols>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<CheckEolTargetFramework>false</CheckEolTargetFramework>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageIcon>logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageId>$(ProjectName)</PackageId>
<Authors>Hannele "Lemon" Ruiz</Authors>
<Company>Hannele "Lemon" Ruiz</Company>
<Product>LemonUI</Product>
<Description>UI system for Grand Theft Auto V. This package is for FiveM Client using Mono V2.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/justalemon/LemonUI</PackageProjectUrl>
<RepositoryUrl>https://github.com/justalemon/LemonUI.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<NeutralLanguage>en-US</NeutralLanguage>
<PackageOutputPath>$(SolutionDir)bin\$(Configuration)\FOR DEVELOPERS</PackageOutputPath>
</PropertyGroup>

<ItemGroup>
<Compile Include="$(ProjectDir)../LemonUI/**/*.cs" />
<None Include="$(ProjectDir)../README.md" Pack="true" Visible="false" PackagePath="\" />
<None Include="$(ProjectDir)../logo.png" Pack="true" Visible="false" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<Reference Include="CitizenFX.Core">
<HintPath>lib\CitizenFX.Core.dll</HintPath>
</Reference>
<Reference Include="CitizenFX.FiveM">
<HintPath>lib\CitizenFX.FiveM.dll</HintPath>
</Reference>
<Reference Include="CitizenFX.FiveM.Native">
<HintPath>lib\CitizenFX.FiveM.Native.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
Binary file added LemonUI.FiveM.V2/lib/CitizenFX.Core.dll
Binary file not shown.
Binary file added LemonUI.FiveM.V2/lib/CitizenFX.FiveM.Native.dll
Binary file not shown.
Binary file added LemonUI.FiveM.V2/lib/CitizenFX.FiveM.dll
Binary file not shown.
6 changes: 6 additions & 0 deletions LemonUI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LemonUI.AltV", "LemonUI.Alt
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LemonUI.AltV.Async", "LemonUI.AltV.Async\LemonUI.AltV.Async.csproj", "{F2761304-2B83-451F-B7BD-F7F752233A01}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LemonUI.FiveM.V2", "LemonUI.FiveM.V2\LemonUI.FiveM.V2.csproj", "{D2040C87-3A02-4EA3-AAA3-68FB6F5754D1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -51,6 +53,10 @@ Global
{F2761304-2B83-451F-B7BD-F7F752233A01}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2761304-2B83-451F-B7BD-F7F752233A01}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2761304-2B83-451F-B7BD-F7F752233A01}.Release|Any CPU.Build.0 = Release|Any CPU
{D2040C87-3A02-4EA3-AAA3-68FB6F5754D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2040C87-3A02-4EA3-AAA3-68FB6F5754D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2040C87-3A02-4EA3-AAA3-68FB6F5754D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2040C87-3A02-4EA3-AAA3-68FB6F5754D1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion LemonUI/CancelEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (c) .NET Foundation and Contributors
// Under the MIT License

#if FIVEM || RAGEMP
#if FIVEM || RAGEMP || FIVEMV2
using System;

namespace LemonUI // Previously System.ComponentModel
Expand All @@ -16,7 +16,7 @@
#region Properties

/// <summary>
/// Gets or sets a value indicating whether we should cancel the operation or not

Check warning on line 19 in LemonUI/CancelEventArgs.cs

View workflow job for this annotation

GitHub Actions / lint-and-compile (Debug)

/// </summary>
public bool Cancel { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion LemonUI/CancelEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (c) .NET Foundation and Contributors
// Under the MIT License

#if FIVEM || RAGEMP
#if FIVEM || RAGEMP || FIVEMV2
namespace LemonUI // Previously System.ComponentModel
{
/// <summary>
Expand Down
31 changes: 23 additions & 8 deletions LemonUI/Controls.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#if FIVEM
#if FIVEMV2
using CitizenFX.FiveM;
using CitizenFX.FiveM.Native;
#elif FIVEM
using CitizenFX.Core;
using CitizenFX.Core.Native;
#elif ALTV
Expand Down Expand Up @@ -31,8 +34,10 @@ public static bool IsUsingController
{
get
{
#if FIVEM
return !API.IsInputDisabled(2);
#if FIVEMV2
return !Natives.IsInputDisabled(2);
#elif FIVEM
return !API.IsInputDisabled(2);
#elif ALTV
return !Alt.Natives.IsUsingKeyboardAndMouse(2);
#elif RAGEMP
Expand All @@ -56,7 +61,9 @@ public static bool IsUsingController
/// <returns>true if the control was pressed, false otherwise.</returns>
public static bool IsJustPressed(Control control)
{
#if FIVEM
#if FIVEMV2
return Natives.IsDisabledControlJustPressed(0, (int)control);
#elif FIVEM
return API.IsDisabledControlJustPressed(0, (int)control);
#elif ALTV
return Alt.Natives.IsDisabledControlJustPressed(0, (int)control);
Expand All @@ -77,7 +84,9 @@ public static bool IsJustPressed(Control control)
/// <returns>true if the control is pressed, false otherwise.</returns>
public static bool IsPressed(Control control)
{
#if FIVEM
#if FIVEMV2
return Natives.IsDisabledControlPressed(0, (int)control);
#elif FIVEM
return API.IsDisabledControlPressed(0, (int)control);
#elif ALTV
return Alt.Natives.IsDisabledControlPressed(0, (int)control);
Expand All @@ -94,7 +103,9 @@ public static bool IsPressed(Control control)
/// </summary>
public static void DisableAll(int inputGroup = 0)
{
#if FIVEM
#if FIVEMV2
Natives.DisableAllControlActions(inputGroup);
#elif FIVEM
API.DisableAllControlActions(inputGroup);
#elif ALTV
Alt.Natives.DisableAllControlActions(inputGroup);
Expand All @@ -112,7 +123,9 @@ public static void DisableAll(int inputGroup = 0)
/// <param name="control">The control to enable.</param>
public static void EnableThisFrame(Control control)
{
#if FIVEM
#if FIVEMV2
Natives.EnableControlAction(0, (int)control, true);
#elif FIVEM
API.EnableControlAction(0, (int)control, true);
#elif ALTV
Alt.Natives.EnableControlAction(0, (int)control, true);
Expand Down Expand Up @@ -141,7 +154,9 @@ public static void EnableThisFrame(IEnumerable<Control> controls)
/// <param name="control">The control to disable.</param>
public static void DisableThisFrame(Control control)
{
#if FIVEM
#if FIVEMV2
Natives.DisableControlAction(0, (int)control, true);
#elif FIVEM
API.DisableControlAction(0, (int)control, true);
#elif ALTV
Alt.Natives.DisableControlAction(0, (int)control, true);
Expand Down
5 changes: 4 additions & 1 deletion LemonUI/Elements/IText.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#if FIVEM
#if FIVEMV2
using Alignment = CitizenFX.FiveM.GUI.Alignment;
using Font = CitizenFX.FiveM.GUI.Font;
#elif FIVEM
using Alignment = CitizenFX.Core.UI.Alignment;
using Font = CitizenFX.Core.UI.Font;
#elif RAGEMP
Expand Down
6 changes: 4 additions & 2 deletions LemonUI/Elements/ScaledAnim.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if ALTV
#if FIVEMV2
using Game = CitizenFX.FiveM.Game;
#elif ALTV
using AltV.Net.Client;
#elif FIVEM
using CitizenFX.Core;
Expand Down Expand Up @@ -107,7 +109,7 @@ private void UpdateTexture()
long time = Alt.Natives.GetGameTimer();
#elif RAGEMP
long time = Misc.GetGameTimer();
#elif FIVEM || RPH || SHVDN3 || SHVDNC
#elif FIVEM || RPH || SHVDN3 || SHVDNC || FIVEMV2
long time = Game.GameTime;
#endif

Expand Down
25 changes: 16 additions & 9 deletions LemonUI/Elements/ScaledBink.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if ALTV
#if FIVEMV2
using CitizenFX.FiveM.Native;
#elif ALTV
using AltV.Net.Client;
#elif FIVEM
using CitizenFX.Core.Native;
Expand Down Expand Up @@ -40,8 +42,9 @@ public string Name
set
{
name = value ?? throw new ArgumentNullException(nameof(value));

#if ALTV
#if FIVEMV2
Id = Natives.SetBinkMovie(name);
#elif ALTV
Id = Alt.Natives.SetBinkMovie(name);
#elif FIVEM
Id = API.SetBinkMovie(name);
Expand Down Expand Up @@ -107,8 +110,10 @@ public override void Draw()
{
return;
}

#if ALTV
#if FIVEMV2
Natives.PlayBinkMovie(Id);
Natives.DrawBinkMovie(Id, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, 0.0f, 255, 255, 255, 255);
#elif ALTV
Alt.Natives.PlayBinkMovie(Id);
Alt.Natives.DrawBinkMovie(Id, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, 0.0f, 255, 255, 255, 255);
#elif FIVEM
Expand Down Expand Up @@ -137,8 +142,9 @@ public void Stop()
{
return;
}

#if ALTV
#if FIVEMV2
Natives.StopBinkMovie(Id);
#elif ALTV
Alt.Natives.StopBinkMovie(Id);
#elif FIVEM
API.StopBinkMovie(Id);
Expand All @@ -159,8 +165,9 @@ public void Dispose()
{
return;
}

#if ALTV
#if FIVEMV2
Natives.ReleaseBinkMovie(Id);
#elif ALTV
Alt.Natives.ReleaseBinkMovie(Id);
#elif FIVEM
API.ReleaseBinkMovie(Id);
Expand Down
9 changes: 7 additions & 2 deletions LemonUI/Elements/ScaledRectangle.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#if FIVEM
#if FIVEMV2
using CitizenFX.Core;
using CitizenFX.FiveM.Native;
#elif FIVEM
using CitizenFX.Core.Native;
#elif RAGEMP
using RAGE.Game;
Expand Down Expand Up @@ -42,7 +45,9 @@ public override void Draw()
{
return;
}
#if FIVEM
#if FIVEMV2
Natives.DrawRect(relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, Color.R, Color.G, Color.B, Color.A);
#elif FIVEM
API.DrawRect(relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, Color.R, Color.G, Color.B, Color.A);
#elif RAGEMP
Invoker.Invoke(Natives.DrawRect, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, Color.R, Color.G, Color.B, Color.A);
Expand Down
71 changes: 62 additions & 9 deletions LemonUI/Elements/ScaledText.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#if FIVEM
#if FIVEMV2
using CitizenFX.FiveM.GUI;
using CitizenFX.FiveM.Native;
using Font = CitizenFX.FiveM.GUI.Font;
#elif FIVEM
using CitizenFX.Core.Native;
using CitizenFX.Core.UI;
using Font = CitizenFX.Core.UI.Font;
Expand Down Expand Up @@ -148,7 +152,11 @@ public float Width
{
get
{
#if FIVEM
#if FIVEMV2
Natives.BeginTextCommandWidth("CELL_EMAIL_BCON");
Add();
return Natives.EndTextCommandGetWidth(true) * 1f.ToXScaled();
#elif FIVEM
API.BeginTextCommandWidth("CELL_EMAIL_BCON");
Add();
return API.EndTextCommandGetWidth(true) * 1f.ToXScaled();
Expand Down Expand Up @@ -178,7 +186,9 @@ public int LineCount
{
get
{
#if FIVEM
#if FIVEMV2
Natives.BeginTextCommandLineCount("CELL_EMAIL_BCON");
#elif FIVEM
API.BeginTextCommandLineCount("CELL_EMAIL_BCON");
#elif ALTV
Alt.Natives.BeginTextCommandGetNumberOfLinesForString("CELL_EMAIL_BCON");
Expand All @@ -190,7 +200,9 @@ public int LineCount
Function.Call(Hash.BEGIN_TEXT_COMMAND_GET_NUMBER_OF_LINES_FOR_STRING, "CELL_EMAIL_BCON");
#endif
Add();
#if FIVEM
#if FIVEMV2
return Natives.EndTextCommandGetLineCount(relativePosition.X, relativePosition.Y);
#elif FIVEM
return API.EndTextCommandGetLineCount(relativePosition.X, relativePosition.Y);
#elif ALTV
return Alt.Natives.EndTextCommandGetNumberOfLinesForString(relativePosition.X, relativePosition.Y);
Expand All @@ -211,7 +223,9 @@ public float LineHeight
get
{
// Height will always be 1080
#if FIVEM
#if FIVEMV2
return 1080 * Natives.GetTextScaleHeight(Scale, (int)Font);
#elif FIVEM
return 1080 * API.GetTextScaleHeight(Scale, (int)Font);
#elif ALTV
return 1080 * Alt.Natives.GetRenderedCharacterHeight(Scale, (int)Font);
Expand Down Expand Up @@ -274,7 +288,43 @@ private void Add()
{
return;
}
#if FIVEM
#if FIVEMV2
foreach (string chunk in chunks)
{
Natives.AddTextComponentString(chunk);
}
Natives.SetTextFont((int)Font);
Natives.SetTextScale(1f, Scale);
Natives.SetTextColour(Color.R, Color.G, Color.B, Color.A);
Natives.SetTextJustification((int)Alignment);
if (Shadow)
{
Natives.SetTextDropShadow();
}
if (Outline)
{
Natives.SetTextOutline();
}
if (WordWrap > 0)
{
switch (Alignment)
{
case Alignment.Center:
Natives.SetTextWrap(relativePosition.X - (realWrap * 0.5f), relativePosition.X + (realWrap * 0.5f));
break;
case Alignment.Left:
Natives.SetTextWrap(relativePosition.X, relativePosition.X + realWrap);
break;
case Alignment.Right:
Natives.SetTextWrap(relativePosition.X - realWrap, relativePosition.X);
break;
}
}
else if (Alignment == Alignment.Right)
{
Natives.SetTextWrap(0f, relativePosition.X);
}
#elif FIVEM
foreach (string chunk in chunks)
{
API.AddTextComponentString(chunk);
Expand Down Expand Up @@ -525,7 +575,9 @@ public void Recalculate()
/// </summary>
public void Draw()
{
#if FIVEM
#if FIVEMV2
Natives.SetTextEntry("CELL_EMAIL_BCON");
#elif FIVEM
API.SetTextEntry("CELL_EMAIL_BCON");
#elif ALTV
Alt.Natives.BeginTextCommandDisplayText("CELL_EMAIL_BCON");
Expand All @@ -538,8 +590,9 @@ public void Draw()
#endif

Add();

#if FIVEM
#if FIVEMV2
Natives.DrawText(relativePosition.X, relativePosition.Y);
#elif FIVEM
API.DrawText(relativePosition.X, relativePosition.Y);
#elif ALTV
Alt.Natives.EndTextCommandDisplayText(relativePosition.X, relativePosition.Y, 0);
Expand Down
Loading
Loading