Update 07.12.2022
This commit is contained in:
28
C#/FiveM/Framework/Framework.Client/Client.cs
Normal file
28
C#/FiveM/Framework/Framework.Client/Client.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma warning disable CS1998
|
||||
|
||||
using System;
|
||||
using CitizenFX.Core;
|
||||
using Framework.Client.Handler;
|
||||
using NativeUI;
|
||||
|
||||
namespace Framework.Client {
|
||||
public class Client : ClientScript {
|
||||
public static Client Instance;
|
||||
public static MenuPool Menus;
|
||||
|
||||
public Client() {
|
||||
Instance = this;
|
||||
Menus = new MenuPool();
|
||||
|
||||
JoinHandler.Init();
|
||||
|
||||
EventHandlers["client:spawn:register"] += new Action(JoinHandler.Register);
|
||||
EventHandlers["client:spawn:choose"] += new Action<dynamic[]>(JoinHandler.ChooseChar);
|
||||
|
||||
Tick += async () => {
|
||||
Menus.ProcessMenus();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
74
C#/FiveM/Framework/Framework.Client/Framework.Client.csproj
Normal file
74
C#/FiveM/Framework/Framework.Client/Framework.Client.csproj
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{4E52F164-32BF-40C6-978E-E91BB595C5B6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Framework.Client</RootNamespace>
|
||||
<AssemblyName>Framework.Client.net</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugType>embedded</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>../Build</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>del Newtonsoft.Json.xml</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="CitizenFX.Core.Client, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\CitizenFX.Core.Client.1.0.6086\lib\net45\CitizenFX.Core.Client.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="NativeUI">
|
||||
<HintPath>..\Librarys\NativeUI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Client.cs" />
|
||||
<Compile Include="Handler\JoinHandler.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utils\UI.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Framework.Shared\Framework.Shared.csproj">
|
||||
<Project>{7130f249-1c23-438c-a077-76a2867f8c5e}</Project>
|
||||
<Name>Framework.Shared</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
|
||||
</Project>
|
||||
93
C#/FiveM/Framework/Framework.Client/Handler/JoinHandler.cs
Normal file
93
C#/FiveM/Framework/Framework.Client/Handler/JoinHandler.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using CitizenFX.Core;
|
||||
using CitizenFX.Core.UI;
|
||||
using Framework.Client.Utils;
|
||||
using Framework.Shared.Models;
|
||||
using NativeUI;
|
||||
|
||||
namespace Framework.Client.Handler {
|
||||
public static class JoinHandler {
|
||||
private static UIMenu _registerMenu;
|
||||
private static PlayerData _data;
|
||||
|
||||
public static void Init() {
|
||||
_registerMenu = new UIMenu("PrincepRP", "Registrierung");
|
||||
Client.Menus.Add(_registerMenu);
|
||||
|
||||
var sex = new UIMenuItem("Geschlecht setzen", "0 -> Männlich, 1 -> Weiblich");
|
||||
var height = new UIMenuItem("Größe setzen", "Wert in cm");
|
||||
var firstName = new UIMenuItem("Vornamen setzen");
|
||||
var lastName = new UIMenuItem("Nachnamen setzen");
|
||||
var birth = new UIMenuItem("Geburtsdatum setzen", "DD.MM.JJJJ, min. 18 Jahre");
|
||||
var skin = new UIMenuItem("Skin erstellen");
|
||||
var done = new UIMenuItem("Charackter erstellen");
|
||||
|
||||
_registerMenu.AddItem(sex);
|
||||
_registerMenu.AddItem(height);
|
||||
_registerMenu.AddItem(firstName);
|
||||
_registerMenu.AddItem(lastName);
|
||||
_registerMenu.AddItem(birth);
|
||||
_registerMenu.AddItem(skin);
|
||||
_registerMenu.AddItem(done);
|
||||
|
||||
sex.Activated += async (sender, item) => {
|
||||
var input = await UI.DisplayTextInput("Geschlecht setzen", 1);
|
||||
if (int.TryParse(input, out var result)) {
|
||||
_data.sex = result == 0;
|
||||
|
||||
if (_data.sex) sex.Description = "Männlich";
|
||||
else sex.Description = "Weiblich";
|
||||
}
|
||||
else {
|
||||
Screen.ShowNotification("~r~Geschlecht setzen: 0 -> Männlich, 1 -> Weiblich");
|
||||
}
|
||||
};
|
||||
|
||||
height.Activated += async (sender, item) => {
|
||||
var input = await UI.DisplayTextInput("Größe setzen", 3);
|
||||
if (int.TryParse(input, out var result)) {
|
||||
_data.height = result;
|
||||
|
||||
height.Description = _data.height + "cm";
|
||||
}
|
||||
else {
|
||||
Screen.ShowNotification("~r~Größe setzen: Wert in cm");
|
||||
}
|
||||
};
|
||||
|
||||
firstName.Activated += async (sender, item) => {
|
||||
var input = await UI.DisplayTextInput("Vornamen setzen", 60);
|
||||
_data.firstName = input;
|
||||
firstName.Description = _data.firstName;
|
||||
};
|
||||
|
||||
lastName.Activated += async (sender, item) => {
|
||||
var input = await UI.DisplayTextInput("Nachnamen setzen", 60);
|
||||
_data.lastName = input;
|
||||
lastName.Description = _data.lastName;
|
||||
};
|
||||
|
||||
birth.Activated += async (sender, item) => {
|
||||
var input = await UI.DisplayTextInput("Geburtsdatum setzen", 10);
|
||||
_data.birth = input;
|
||||
birth.Description = _data.birth;
|
||||
};
|
||||
|
||||
done.Activated += (sender, item) => {
|
||||
// TODO: Checks
|
||||
_registerMenu.Visible = false;
|
||||
BaseScript.TriggerServerEvent("server:spawn:register", _data);
|
||||
};
|
||||
}
|
||||
|
||||
public static void Register() {
|
||||
_data = new PlayerData();
|
||||
_registerMenu.Visible = true;
|
||||
}
|
||||
|
||||
public static void ChooseChar(dynamic[] chars) {
|
||||
Debug.WriteLine("ChooseChar");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Framework.Client")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Framework.Client")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("4E52F164-32BF-40C6-978E-E91BB595C5B6")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
27
C#/FiveM/Framework/Framework.Client/Utils/UI.cs
Normal file
27
C#/FiveM/Framework/Framework.Client/Utils/UI.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Threading.Tasks;
|
||||
using CitizenFX.Core;
|
||||
using CitizenFX.Core.Native;
|
||||
|
||||
namespace Framework.Client.Utils {
|
||||
public static class UI {
|
||||
|
||||
public static async Task<string> DisplayTextInput(string title, int maxLength) {
|
||||
API.AddTextEntry("CH_INPUT", title);
|
||||
API.DisplayOnscreenKeyboard(1, "CH_INPUT", "", "", "", "", "", maxLength);
|
||||
|
||||
while (API.UpdateOnscreenKeyboard() == 0) {
|
||||
await BaseScript.Delay(0);
|
||||
}
|
||||
|
||||
if (API.UpdateOnscreenKeyboard() != 2) {
|
||||
var result = API.GetOnscreenKeyboardResult();
|
||||
await BaseScript.Delay(0);
|
||||
return result;
|
||||
}
|
||||
|
||||
await BaseScript.Delay(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
34591d24053ea89eea29dc22e89a3ebad14609bf
|
||||
@@ -0,0 +1,7 @@
|
||||
D:\Programmierstuff\C#\FiveM\Framework\Framework.Client\obj\Release\Framework.Client.csproj.AssemblyReference.cache
|
||||
D:\Programmierstuff\C#\FiveM\Framework\Framework.Client\obj\Release\Framework.Client.csproj.CoreCompileInputs.cache
|
||||
D:\Programmierstuff\C#\FiveM\Framework\Framework.Client\obj\Release\Framework.Client.csproj.CopyComplete
|
||||
D:\Programmierstuff\C#\FiveM\Framework\Build\fxmanifest.lua
|
||||
D:\Programmierstuff\C#\FiveM\Framework\Build\stream\NativeUI.ytd
|
||||
D:\Programmierstuff\C#\FiveM\Framework\Build\Framework.Client.net.dll
|
||||
D:\Programmierstuff\C#\FiveM\Framework\Framework.Client\obj\Release\Framework.Client.net.dll
|
||||
Binary file not shown.
4
C#/FiveM/Framework/Framework.Client/packages.config
Normal file
4
C#/FiveM/Framework/Framework.Client/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="CitizenFX.Core.Client" version="1.0.6086" targetFramework="net481" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user