Skip to content
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

Add support for ScriptHookVDotNetCore #101

Merged
merged 6 commits into from
Oct 25, 2023
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
47 changes: 47 additions & 0 deletions LemonUI.SHVDNC/LemonUI.SHVDNC.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AssemblyName>$(AssemblyName)</AssemblyName>
<DefineConstants>SHVDNC,CLIENT</DefineConstants>
<Version>1.10.0</Version>
<OutputPath>$(SolutionDir)bin\$(Configuration)\SHVDN3\</OutputPath>
<PlatformTarget>x64</PlatformTarget>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<NoAotCompile>true</NoAotCompile>
<GenerateDependencyFile>false</GenerateDependencyFile>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageIcon>logo.png</PackageIcon>
<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 ScriptHookVDotNetCore.</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="" />
<PackageReference Include="ScriptHookVDotNetCore" Version="1.2.1">
<IncludeAssets>compile</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions LemonUI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LemonUI.RagePluginHook", "L
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LemonUI.RageMP", "LemonUI.RageMP\LemonUI.RageMP.csproj", "{C526B98E-3DA1-481A-A737-27C289D960EA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LemonUI.SHVDNC", "LemonUI.SHVDNC\LemonUI.SHVDNC.csproj", "{3B49A7F9-96FF-4448-96FF-DAAA68E9B0CF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LemonUI.AltV", "LemonUI.AltV\LemonUI.AltV.csproj", "{23811603-B595-4AB2-ADC7-25F0C6920193}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LemonUI.AltV.Async", "LemonUI.AltV.Async\LemonUI.AltV.Async.csproj", "{F2761304-2B83-451F-B7BD-F7F752233A01}"
Expand All @@ -37,6 +39,10 @@ Global
{C526B98E-3DA1-481A-A737-27C289D960EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C526B98E-3DA1-481A-A737-27C289D960EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C526B98E-3DA1-481A-A737-27C289D960EA}.Release|Any CPU.Build.0 = Release|Any CPU
{3B49A7F9-96FF-4448-96FF-DAAA68E9B0CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B49A7F9-96FF-4448-96FF-DAAA68E9B0CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B49A7F9-96FF-4448-96FF-DAAA68E9B0CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B49A7F9-96FF-4448-96FF-DAAA68E9B0CF}.Release|Any CPU.Build.0 = Release|Any CPU
{23811603-B595-4AB2-ADC7-25F0C6920193}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23811603-B595-4AB2-ADC7-25F0C6920193}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23811603-B595-4AB2-ADC7-25F0C6920193}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
14 changes: 7 additions & 7 deletions LemonUI/Controls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#elif RPH
using Rage.Native;
using Control = Rage.GameControl;
#elif SHVDN3
#elif SHVDN3 || SHVDNC
using GTA;
using GTA.Native;
#endif
Expand Down Expand Up @@ -39,7 +39,7 @@ public static bool IsUsingController
return !Invoker.Invoke<bool>(Natives.IsInputDisabled, 2);
#elif RPH
return !NativeFunction.CallByHash<bool>(0xA571D46727E2B718, 2);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
return !Function.Call<bool>(Hash.IS_USING_KEYBOARD_AND_MOUSE, 2);
#endif
}
Expand All @@ -64,7 +64,7 @@ public static bool IsJustPressed(Control control)
return Invoker.Invoke<bool>(Natives.IsDisabledControlJustPressed, 0, (int)control);
#elif RPH
return NativeFunction.CallByHash<bool>(0x91AEF906BCA88877, 0, (int)control);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
return Function.Call<bool>(Hash.IS_DISABLED_CONTROL_JUST_PRESSED, 0, (int)control);
#elif ALTV
return Alt.Natives.IsControlJustPressed((uint)control);
Expand All @@ -85,7 +85,7 @@ public static bool IsPressed(Control control)
return Invoker.Invoke<bool>(Natives.IsDisabledControlJustPressed, 0, (int)control);
#elif RPH
return NativeFunction.CallByHash<bool>(0xE2587F8CBBD87B1D, 0, (int)control);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
return Function.Call<bool>(Hash.IS_DISABLED_CONTROL_PRESSED, 0, (int)control);
#endif
}
Expand All @@ -102,7 +102,7 @@ public static void DisableAll(int inputGroup = 0)
Invoker.Invoke(Natives.DisableAllControlActions, inputGroup);
#elif RPH
NativeFunction.CallByHash<int>(0x5F4B6931816E599B, inputGroup);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
Function.Call(Hash.DISABLE_ALL_CONTROL_ACTIONS, inputGroup);
#endif
}
Expand All @@ -120,7 +120,7 @@ public static void EnableThisFrame(Control control)
Invoker.Invoke(Natives.EnableControlAction, 0, (int)control, true);
#elif RPH
NativeFunction.CallByHash<int>(0x351220255D64C155, 0, (int)control);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
Function.Call(Hash.ENABLE_CONTROL_ACTION, 0, (int)control);
#endif
}
Expand Down Expand Up @@ -149,7 +149,7 @@ public static void DisableThisFrame(Control control)
Invoker.Invoke(Natives.DisableControlAction, 0, (int)control, true);
#elif RPH
NativeFunction.CallByHash<int>(0xFE99B66D079CF6BC, 0, (int)control, true);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)control, true);
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion LemonUI/Elements/IText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Font = CitizenFX.Core.UI.Font;
#elif RAGEMP
using RAGE.Game;
#elif SHVDN3
#elif SHVDN3 || SHVDNC
using Alignment = GTA.UI.Alignment;
using Font = GTA.UI.Font;
#endif
Expand Down
4 changes: 2 additions & 2 deletions LemonUI/Elements/ScaledRectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using RAGE.Game;
#elif RPH
using Rage.Native;
#elif SHVDN3
#elif SHVDN3 || SHVDNC
using GTA.Native;
#elif ALTV
using AltV.Net.Client;
Expand Down Expand Up @@ -51,7 +51,7 @@ public override void Draw()
false);
#elif RPH
NativeFunction.CallByHash<int>(0x3A618A217E5154F0, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, Color.R, Color.G, Color.B, Color.A);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
Function.Call(Hash.DRAW_RECT, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, Color.R, Color.G, Color.B, Color.A);
#endif
}
Expand Down
18 changes: 9 additions & 9 deletions LemonUI/Elements/ScaledText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
using RAGE.Game;
#elif RPH
using Rage.Native;
#elif SHVDN3
using GTA.UI;
#elif SHVDN3 || SHVDNC
using GTA.Native;
using GTA.UI;
using Font = GTA.UI.Font;
#endif
using System.Collections.Generic;
Expand Down Expand Up @@ -163,7 +163,7 @@ public float Width
NativeFunction.CallByHash<int>(0x54CE8AC98E120CAB, "CELL_EMAIL_BCON");
Add();
return NativeFunction.CallByHash<float>(0x85F061DA64ED2F67, true) * 1f.ToXAbsolute();
#elif SHVDN3
#elif SHVDN3 || SHVDNC
Function.Call(Hash.BEGIN_TEXT_COMMAND_GET_SCREEN_WIDTH_OF_DISPLAY_TEXT, "CELL_EMAIL_BCON");
Add();
return Function.Call<float>(Hash.END_TEXT_COMMAND_GET_SCREEN_WIDTH_OF_DISPLAY_TEXT, true) * 1f.ToXAbsolute();
Expand All @@ -185,7 +185,7 @@ public int LineCount
Invoker.Invoke(Natives.BeginTextCommandLineCount, "CELL_EMAIL_BCON");
#elif RPH
NativeFunction.CallByHash<int>(0x521FB041D93DD0E4, "CELL_EMAIL_BCON");
#elif SHVDN3
#elif SHVDN3 || SHVDNC
Function.Call(Hash.BEGIN_TEXT_COMMAND_GET_NUMBER_OF_LINES_FOR_STRING, "CELL_EMAIL_BCON");
#endif
Add();
Expand All @@ -197,7 +197,7 @@ public int LineCount
return Invoker.Invoke<int>(Natives.EndTextCommandGetLineCount, relativePosition.X, relativePosition.Y);
#elif RPH
return NativeFunction.CallByHash<int>(0x9040DFB09BE75706, relativePosition.X, relativePosition.Y);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
return Function.Call<int>(Hash.END_TEXT_COMMAND_GET_NUMBER_OF_LINES_FOR_STRING, relativePosition.X, relativePosition.Y);
#endif
}
Expand All @@ -218,7 +218,7 @@ public float LineHeight
return 1080 * Invoker.Invoke<float>(Natives.GetTextScaleHeight, Scale, (int)Font);
#elif RPH
return 1080 * NativeFunction.CallByHash<float>(0xDB88A37483346780, Scale, (int)Font);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
return 1080 * Function.Call<float>(Hash.GET_RENDERED_CHARACTER_HEIGHT, Scale, (int)Font);
#endif
}
Expand Down Expand Up @@ -419,7 +419,7 @@ private void Add()
{
NativeFunction.CallByHash<int>(0x63145D9C883A1A70, 0f, relativePosition.X);
}
#elif SHVDN3
#elif SHVDN3 || SHVDNC
foreach (string chunk in chunks)
{
Function.Call((Hash)0x6C188BE134E074AA, chunk); // _ADD_TEXT_COMPONENT_STRING on v2, ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME on v3
Expand Down Expand Up @@ -534,7 +534,7 @@ public void Draw()
Invoker.Invoke(Natives.BeginTextCommandDisplayText, "CELL_EMAIL_BCON");
#elif RPH
NativeFunction.CallByHash<int>(0x25FBB336DF1804CB, "CELL_EMAIL_BCON");
#elif SHVDN3
#elif SHVDN3 || SHVDNC
Function.Call((Hash)0x25FBB336DF1804CB, "CELL_EMAIL_BCON"); // _SET_TEXT_ENTRY on v2, BEGIN_TEXT_COMMAND_DISPLAY_TEXT on v3
#endif

Expand All @@ -548,7 +548,7 @@ public void Draw()
Invoker.Invoke(Natives.EndTextCommandDisplayText, relativePosition.X, relativePosition.Y);
#elif RPH
NativeFunction.CallByHash<int>(0xCD015E5BB0D96A57, relativePosition.X, relativePosition.Y);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
Function.Call((Hash)0xCD015E5BB0D96A57, relativePosition.X, relativePosition.Y); // _DRAW_TEXT on v2, END_TEXT_COMMAND_DISPLAY_TEXT on v3
#endif
}
Expand Down
8 changes: 4 additions & 4 deletions LemonUI/Elements/ScaledTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using RAGE.Game;
#elif RPH
using Rage.Native;
#elif SHVDN3
#elif SHVDN3 || SHVDNC
using GTA.Native;
#elif ALTV
using AltV.Net.Client;
Expand Down Expand Up @@ -84,7 +84,7 @@ private void Request()
{
NativeFunction.CallByHash<int>(0xDFA2EF8E04127DD5, Dictionary, true);
}
#elif SHVDN3
#elif SHVDN3 || SHVDNC
if (!Function.Call<bool>(Hash.HAS_STREAMED_TEXTURE_DICT_LOADED, Dictionary))
{
Function.Call(Hash.REQUEST_STREAMED_TEXTURE_DICT, Dictionary, true);
Expand Down Expand Up @@ -114,7 +114,7 @@ public override void Draw()
NativeFunction.CallByHash<int>(0xE7FFAE5EBF23D890, Dictionary, Texture, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, Heading, Color.R, Color.G, Color.B, Color.A);
#elif ALTV
Alt.Natives.DrawSprite(Dictionary, Texture, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, Heading, Color.R, Color.G, Color.B, Color.A, false, 0);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
Function.Call(Hash.DRAW_SPRITE, Dictionary, Texture, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, Heading, Color.R, Color.G, Color.B, Color.A);
#endif
}
Expand All @@ -136,7 +136,7 @@ public void DrawSpecific(PointF topLeft, PointF bottomRight)
NativeFunction.CallByHash<int>(0x95812F9B26074726, Dictionary, Texture, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, topLeft.X, topLeft.Y, bottomRight.X, bottomRight.Y, Heading, Color.R, Color.G, Color.B, Color.A);
#elif ALTV
Alt.Natives.DrawSpriteArxWithUv(Dictionary, Texture, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, topLeft.X, topLeft.Y, bottomRight.X, bottomRight.Y, Heading, Color.R, Color.G, Color.B, Color.A, 0);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
Function.Call((Hash)0x95812F9B26074726, Dictionary, Texture, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, topLeft.X, topLeft.Y, bottomRight.X, bottomRight.Y, Heading, Color.R, Color.G, Color.B, Color.A);
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions LemonUI/Menus/NativeColorPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using RAGE.Game;
#elif RPH
using Control = Rage.GameControl;
#elif SHVDN3
#elif SHVDN3 || SHVDNC
using GTA;
using GTA.UI;
#endif
Expand Down Expand Up @@ -619,7 +619,7 @@
}

/// <summary>
/// Removes all of the

Check warning on line 622 in LemonUI/Menus/NativeColorPanel.cs

View workflow job for this annotation

GitHub Actions / lint-and-compile (Debug)

Check warning on line 622 in LemonUI/Menus/NativeColorPanel.cs

View workflow job for this annotation

GitHub Actions / lint-and-compile (Release)

/// </summary>
/// <param name="func"></param>
public void Remove(Func<NativeColorData, bool> func)
Expand Down Expand Up @@ -690,7 +690,7 @@
#if ALTV
if (Controls.IsJustPressed(Control.FrontendLT))
#else
if (Controls.IsJustPressed(Control.FrontendLt))
if (Controls.IsJustPressed(Control.FrontendLt))
#endif
{
Previous();
Expand Down
4 changes: 2 additions & 2 deletions LemonUI/Menus/NativeGridPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Rage;
using Rage.Native;
using Control = Rage.GameControl;
#elif SHVDN3
#elif SHVDN3 || SHVDNC
using GTA;
using GTA.Native;
using GTA.UI;
Expand Down Expand Up @@ -334,7 +334,7 @@ public override void Process()
float rX = NativeFunction.CallByHash<float>(0xEC3C9B8D5327B563, 0, (int)Control.ScriptRightAxisX);
float rY = NativeFunction.CallByHash<float>(0xEC3C9B8D5327B563, 0, (int)Control.ScriptRightAxisY);
float frameTime = Game.FrameTime;
#elif SHVDN3
#elif SHVDN3 || SHVDNC
float rX = Game.GetControlValueNormalized(Control.ScriptRightAxisX);
float rY = Game.GetControlValueNormalized(Control.ScriptRightAxisY);
float frameTime = Game.LastFrameTime;
Expand Down
2 changes: 1 addition & 1 deletion LemonUI/Menus/NativeItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Font = RAGE.Game.Font;
#elif RPH
using Font = LemonUI.Elements.Font;
#elif SHVDN3
#elif SHVDN3 || SHVDNC
using Font = GTA.UI.Font;
#endif

Expand Down
14 changes: 7 additions & 7 deletions LemonUI/Menus/NativeMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using System.ComponentModel;
using Control = Rage.GameControl;
using Font = LemonUI.Elements.Font;
#elif SHVDN3
#elif SHVDN3 || SHVDNC
using GTA;
using GTA.Native;
using GTA.UI;
Expand Down Expand Up @@ -991,7 +991,7 @@ public void ResetCursor()
NativeFunction.CallByHash<int>(0xFC695459D4D0E219, pos.X, pos.Y);
#elif ALTV
Alt.Natives.SetCursorPosition(pos.X, pos.Y);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
Function.Call(Hash.SET_CURSOR_POSITION, pos.X, pos.Y);
#endif
}
Expand Down Expand Up @@ -1135,7 +1135,7 @@ private void ProcessControls()
bool isKeyboardActive = Invoker.Invoke<int>(Natives.UpdateOnscreenKeyboard) == 0;
#elif RPH
bool isKeyboardActive = NativeFunction.CallByHash<int>(0x0CF2B696BBF945AE) == 0;
#elif SHVDN3
#elif SHVDN3 || SHVDNC
bool isKeyboardActive = Function.Call<int>(Hash.UPDATE_ONSCREEN_KEYBOARD) == 0;
#endif
if (!AcceptsInput || isKeyboardActive)
Expand Down Expand Up @@ -1208,7 +1208,7 @@ private void ProcessControls()
if (UseMouse && !Controls.IsUsingController)
{
// Enable the mouse cursor
#if FIVEM || SHVDN3 || ALTV
#if FIVEM || SHVDN3 || SHVDNC || ALTV
Screen.ShowCursorThisFrame();
#elif RAGEMP
Invoker.Invoke(Natives.ShowCursorThisFrame);
Expand All @@ -1221,7 +1221,7 @@ private void ProcessControls()
{
if (Screen.IsCursorInArea(PointF.Empty, searchAreaSize))
{
#if FIVEM || SHVDN3
#if FIVEM || SHVDN3 || SHVDNC
GameplayCamera.RelativeHeading += 5;
#elif ALTV
float current = Alt.Natives.GetGameplayCamRelativeHeading();
Expand All @@ -1235,7 +1235,7 @@ private void ProcessControls()
}
else if (Screen.IsCursorInArea(searchAreaRight, searchAreaSize))
{
#if FIVEM || SHVDN3
#if FIVEM || SHVDN3 || SHVDNC
GameplayCamera.RelativeHeading -= 5;
#elif ALTV
float current = Alt.Natives.GetGameplayCamRelativeHeading();
Expand Down Expand Up @@ -1646,7 +1646,7 @@ public virtual void Process()
#elif RPH
NativeFunction.CallByHash<int>(0x351220255D64C155, 0, (int)Control.CellphoneCancel);
NativeFunction.CallByHash<int>(0x351220255D64C155, 0, (int)Control.FrontendPause);
#elif SHVDN3
#elif SHVDN3 || SHVDNC
Function.Call(Hash.SET_INPUT_EXCLUSIVE, 0, (int)Control.PhoneCancel);
Function.Call(Hash.SET_INPUT_EXCLUSIVE, 0, (int)Control.FrontendPause);
#endif
Expand Down
Loading
Loading