This commit is contained in:
sardelka9515
2022-11-16 17:40:07 +08:00
parent 50153d860a
commit 745b212b42
18 changed files with 152 additions and 176 deletions

View File

@ -39,9 +39,9 @@ namespace RageCoop.Client.CefHost
private ChromiumWebBrowser _browser;
private MemoryMappedFile _mmf;
private string _mmfName;
private CefProcessor _processor;
private SafeMemoryMappedViewHandle _mmfView;
private BufferMode _mode;
private CefProcessor _processor;
public IntPtr PtrBuffer { get; private set; }
public int FrameRate
@ -172,11 +172,13 @@ namespace RageCoop.Client.CefHost
{
_browser.LoadUrl(url);
}
public void Resize(Size size)
{
_browser.Size = size;
_processor.Size = size;
}
public void SendMouseClick(int x, int y, int modifiers, MouseButton button, bool mouseUp, int clicks)
{
var e = new MouseEvent(x, y, (CefEventFlags)modifiers);
@ -184,11 +186,11 @@ namespace RageCoop.Client.CefHost
?.SendMouseClickEvent(e, (MouseButtonType)button, mouseUp, clicks);
}
public void SendMouseMove(int x, int y,bool leave=false)
public void SendMouseMove(int x, int y, bool leave = false)
{
var e = new MouseEvent(x, y, 0);
_browser.GetBrowserHost()?.SendMouseMoveEvent(e,leave);
_browser.GetBrowserHost()?.SendMouseMoveEvent(e, leave);
}
public DateTime Ping()
@ -217,13 +219,14 @@ namespace RageCoop.Client.CefHost
private MemoryMappedFile _mmf;
private SafeMemoryMappedViewHandle _mmfView;
public int Id;
public Size Size { get; private set; }
public CefAdapter()
{
Console.WriteLine("Adapter created");
}
public Size Size { get; private set; }
public IntPtr PtrBuffer { get; private set; }
/// <summary>

View File

@ -12,6 +12,7 @@ namespace RageCoop.Client.GUI
private static DXHookD3D11 _hook;
public static Overlay DefaultOverlay = new Overlay();
public static bool Hooked => _hook != null;
public static void GetOverlays()
{
new List<IOverlay>(_hook.Overlays);

View File

@ -17,11 +17,11 @@ using RageCoop.Client.Menus;
using RageCoop.Client.Scripting;
using RageCoop.Core;
using SHVDN;
using static RageCoop.Client.Shared;
using Console = GTA.Console;
using Control = GTA.Control;
using Screen = System.Windows.Forms.Screen;
using Script = GTA.Script;
using static RageCoop.Client.Shared;
namespace RageCoop.Client
{
@ -58,7 +58,7 @@ namespace RageCoop.Client
/// </summary>
public Main()
{
Util.StartUpCheck();
Util.StartUpCheck();
Directory.CreateDirectory(DataPath);
Console.Info(
@ -248,13 +248,13 @@ namespace RageCoop.Client
{
new ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 0),
$"L: {Networking.Latency * 1000:N0}ms", 0.5f)
{ Alignment = Alignment.Center }.Draw();
{ Alignment = Alignment.Center }.Draw();
new ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 30),
$"R: {NetUtility.ToHumanReadable(Statistics.BytesDownPerSecond)}/s", 0.5f)
{ Alignment = Alignment.Center }.Draw();
{ Alignment = Alignment.Center }.Draw();
new ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 60),
$"S: {NetUtility.ToHumanReadable(Statistics.BytesUpPerSecond)}/s", 0.5f)
{ Alignment = Alignment.Center }.Draw();
{ Alignment = Alignment.Center }.Draw();
}
MainChat.Tick();
@ -472,6 +472,7 @@ namespace RageCoop.Client
{
CefManager.CleanUp();
}
HookManager.CleanUp();
DownloadManager.Cleanup();
Voice.ClearAll();

View File

@ -105,6 +105,7 @@ namespace RageCoop.Client
{
CefManager.DestroyClient(_testCef);
}
DxHookTest.Checked = HookManager.Hooked;
}

View File

@ -7,15 +7,13 @@ using GTA.UI;
using LemonUI.Menus;
using Newtonsoft.Json;
using RageCoop.Core;
using Console = GTA.Console;
using static RageCoop.Client.Shared;
using Console = GTA.Console;
namespace RageCoop.Client
{
internal static class DevToolMenu
{
public static NativeMenu Menu = new NativeMenu("RAGECOOP", "DevTool", "Internal testing tools")
{
UseMouse = false,

View File

@ -1,7 +1,4 @@

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Resources;
// General Information
@ -18,5 +15,4 @@ using System.Resources;
// Version informationr(
[assembly: AssemblyVersion("1.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
[assembly: NeutralResourcesLanguageAttribute("en-US")]

View File

@ -3,7 +3,6 @@ using System;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Windows.Forms;
using GTA;
using Lidgren.Network;
using Newtonsoft.Json;
@ -150,7 +149,7 @@ namespace RageCoop.Client.Scripting
{
OnPlayerDied?.Invoke();
}
internal static void InvokeCustomEventReceived(Packets.CustomEvent p)
{
var args = new CustomEventReceivedArgs { Hash = p.Hash, Args = p.Args };

View File

@ -73,7 +73,7 @@ namespace RageCoop.Client
/// The game won't spawn more NPC traffic if the limit is exceeded. -1 for unlimited (not recommended).
/// </summary>
public int WorldPedSoftLimit { get; set; } = 30;
/// <summary>
/// Show the owner name of the entity you're aiming at

View File

@ -1,18 +1,13 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace RageCoop.Client
{
internal static partial class Shared
internal static class Shared
{
public static string BasePath = "RageCoop";
public static string DataPath = Path.Combine(BasePath, "Data");
public static string LogPath = Path.Combine(DataPath, "RageCoop.Client.log");
public static string SettingsPath = Path.Combine(DataPath,"Setting.json");
public static string SettingsPath = Path.Combine(DataPath, "Setting.json");
public static string VehicleWeaponDataPath = Path.Combine(DataPath, "VehicleWeapons.json");
public static string WeaponFixDataPath = Path.Combine(DataPath, "WeaponFixes.json");
@ -21,4 +16,4 @@ namespace RageCoop.Client
public static string CefSubProcessPath = Path.Combine(BasePath, "SubProcess", "RageCoop.Client.CefHost.exe");
}
}
}

View File

@ -10,8 +10,8 @@ using GTA.UI;
using LemonUI.Elements;
using Newtonsoft.Json;
using RageCoop.Core;
using Font = GTA.UI.Font;
using static RageCoop.Client.Shared;
using Font = GTA.UI.Font;
[assembly: InternalsVisibleTo("RageCoop.Client.Installer")]
@ -19,7 +19,6 @@ namespace RageCoop.Client
{
internal static class Util
{
/// <summary>
/// The location of the cursor on screen between 0 and 1.
/// </summary>

View File

@ -1,21 +1,15 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using GTA;
using GTA.Math;
using GTA.Native;
using Newtonsoft.Json;
using RageCoop.Client.Scripting;
using RageCoop.Core;
using Console = GTA.Console;
using static RageCoop.Client.Shared;
namespace RageCoop.Client
{
internal class WeaponFix
{
public Dictionary<uint, string> Bullet = new Dictionary<uint, string>();
@ -39,14 +33,11 @@ namespace RageCoop.Client
File.ReadAllText(WeaponInfoDataPath));
if (File.Exists(WeaponFixDataPath))
{
WeaponFix = JsonConvert.DeserializeObject<WeaponFix>(File.ReadAllText(WeaponFixDataPath));
}
else
{
API.Logger.Warning("Weapon fix data not found");
}
}
public static void DumpWeaponFix(string path)
{
var P = Game.Player.Character;
@ -65,7 +56,6 @@ namespace RageCoop.Client
if (!Function.Call<bool>(Hash.IS_BULLET_IN_AREA, pos.X, pos.Y, pos.Z, 10f, true) &&
!Function.Call<bool>(Hash.IS_PROJECTILE_IN_AREA, pos.X - 10, pos.Y - 10, pos.Z - 10, pos.X + 10,
pos.Y + 10, pos.Z + 10, true))
{
switch (w.Value.DamageType)
{
case "BULLET":
@ -78,7 +68,7 @@ namespace RageCoop.Client
fix.Others.Add(w.Key, w.Value.Name);
break;
}
}
foreach (var p in World.GetAllProjectiles()) p.Delete();
Script.Wait(50);
}
@ -88,9 +78,9 @@ namespace RageCoop.Client
P.IsInvincible = false;
}
public static uint GetWeaponFix(uint hash)
{
if (WeaponFix.Bullet.TryGetValue(hash, out _)) return 0x461DDDB0;
if (WeaponFix.Lazer.TryGetValue(hash, out _)) return 0xE2822A29;
@ -146,10 +136,11 @@ namespace RageCoop.Client
public static bool IsUsingProjectileWeapon(this Ped p)
{
var vp = p.VehicleWeapon;
return Weapons.TryGetValue(vp != VehicleWeaponHash.Invalid ?
(uint)vp : (uint)p.Weapons.Current.Hash, out var info)
return Weapons.TryGetValue(vp != VehicleWeaponHash.Invalid ? (uint)vp : (uint)p.Weapons.Current.Hash,
out var info)
&& info.FireType == "PROJECTILE";
}
public static string GetFlashFX(this WeaponHash w, bool veh)
{
if (veh)

View File

@ -1,68 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Extensions.ObjectPool" version="6.0.8" targetFramework="net48" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net48" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net48" />
<package id="Microsoft.Win32.Registry" version="4.7.0" targetFramework="net481" />
<package id="NAudio" version="2.1.0" targetFramework="net48" />
<package id="NAudio.Asio" version="2.1.0" targetFramework="net48" />
<package id="NAudio.Core" version="2.1.0" targetFramework="net48" />
<package id="NAudio.Midi" version="2.1.0" targetFramework="net48" />
<package id="NAudio.Wasapi" version="2.1.0" targetFramework="net48" />
<package id="NAudio.WinForms" version="2.1.0" targetFramework="net48" />
<package id="NAudio.WinMM" version="2.1.0" targetFramework="net48" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
<package id="SharpZipLib" version="1.4.0" targetFramework="net48" />
<package id="System.AppContext" version="4.3.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Collections" version="4.3.0" targetFramework="net48" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net48" />
<package id="System.Console" version="4.3.0" targetFramework="net48" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net48" />
<package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net48" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net48" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net48" />
<package id="System.Drawing.Common" version="4.5.0" targetFramework="net48" />
<package id="System.Globalization" version="4.3.0" targetFramework="net48" />
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net48" />
<package id="System.IO" version="4.3.0" targetFramework="net48" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net48" />
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net48" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net48" />
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net48" />
<package id="System.Linq" version="4.3.0" targetFramework="net48" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Net.Http" version="4.3.0" targetFramework="net48" />
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net48" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="net48" />
<package id="System.Reflection" version="4.3.0" targetFramework="net48" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net48" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net48" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net48" />
<package id="System.Security.AccessControl" version="4.7.0" targetFramework="net481" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Principal.Windows" version="4.7.0" targetFramework="net481" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net48" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net48" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net48" />
<package id="System.Threading" version="4.3.0" targetFramework="net48" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net48" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net48" />
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net48" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net48" />
<package id="Microsoft.Extensions.ObjectPool" version="6.0.8" targetFramework="net48" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net48" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net48" />
<package id="Microsoft.Win32.Registry" version="4.7.0" targetFramework="net481" />
<package id="NAudio" version="2.1.0" targetFramework="net48" />
<package id="NAudio.Asio" version="2.1.0" targetFramework="net48" />
<package id="NAudio.Core" version="2.1.0" targetFramework="net48" />
<package id="NAudio.Midi" version="2.1.0" targetFramework="net48" />
<package id="NAudio.Wasapi" version="2.1.0" targetFramework="net48" />
<package id="NAudio.WinForms" version="2.1.0" targetFramework="net48" />
<package id="NAudio.WinMM" version="2.1.0" targetFramework="net48" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
<package id="SharpZipLib" version="1.4.0" targetFramework="net48" />
<package id="System.AppContext" version="4.3.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Collections" version="4.3.0" targetFramework="net48" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net48" />
<package id="System.Console" version="4.3.0" targetFramework="net48" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net48" />
<package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net48" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net48" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net48" />
<package id="System.Drawing.Common" version="4.5.0" targetFramework="net48" />
<package id="System.Globalization" version="4.3.0" targetFramework="net48" />
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net48" />
<package id="System.IO" version="4.3.0" targetFramework="net48" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net48" />
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net48" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net48" />
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net48" />
<package id="System.Linq" version="4.3.0" targetFramework="net48" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Net.Http" version="4.3.0" targetFramework="net48" />
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net48" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="net48" />
<package id="System.Reflection" version="4.3.0" targetFramework="net48" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net48" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net48" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net48" />
<package id="System.Security.AccessControl" version="4.7.0" targetFramework="net481" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Principal.Windows" version="4.7.0" targetFramework="net481" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net48" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net48" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net48" />
<package id="System.Threading" version="4.3.0" targetFramework="net48" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net48" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net48" />
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net48" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net48" />
</packages>

View File

@ -363,7 +363,7 @@ namespace RageCoop.Core
}
/// <summary>
/// Generate jenkins one-at-a-time hash from specified string (lower)
/// Generate jenkins one-at-a-time hash from specified string (lower)
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
@ -383,7 +383,6 @@ namespace RageCoop.Core
hash += hash << 15;
return hash;
}
}
internal class IpInfo

View File

@ -1,15 +1,13 @@
using Newtonsoft.Json;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Console = System.Console;
using System.Xml;
using Newtonsoft.Json;
using Formatting = Newtonsoft.Json.Formatting;
namespace RageCoop.Core
{
internal class AnimDic
{
public string[] Animations;
@ -17,7 +15,6 @@ namespace RageCoop.Core
public static AnimDic[] Dump(string input, string output)
{
Console.WriteLine("Generating " + output);
if (!File.Exists(input))
{
@ -33,6 +30,7 @@ namespace RageCoop.Core
return anims;
}
}
internal class WeaponInfo
{
public string Audio;
@ -42,7 +40,11 @@ namespace RageCoop.Core
public bool IsVehicleWeapon;
public string Name;
public float Speed;
public WeaponInfo() { }
public WeaponInfo()
{
}
public WeaponInfo(XmlNode node)
{
if (node.Attributes["type"].Value != "CWeaponInfo") throw new Exception("Not a CWeaponInfo node");
@ -72,6 +74,7 @@ namespace RageCoop.Core
IsVehicleWeapon = Name.StartsWith("VEHICLE_WEAPON");
}
}
internal class VehicleInfo
{
public VehicleBone[] Bones;
@ -92,6 +95,7 @@ namespace RageCoop.Core
public VehicleBone[] Bones;
public string Name;
}
internal class VehicleWeaponInfo
{
public uint Hash;
@ -132,5 +136,4 @@ namespace RageCoop.Core
return result;
}
}
}
}

View File

@ -1,7 +1,4 @@

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Resources;
// General Information
@ -17,5 +14,4 @@ using System.Resources;
// Version information
[assembly: AssemblyVersion("1.6.0.3")]
[assembly: AssemblyFileVersion("1.6.0.3")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
[assembly: NeutralResourcesLanguageAttribute("en-US")]

View File

@ -1,19 +1,16 @@
using System;
using System.Windows.Forms;
using SharpD2D.Drawing;
using SharpD2D.Windows;
using System.Windows.Forms;
using SharpDX.Direct2D1;
using Image = SharpD2D.Drawing.Image;
namespace CefTest
{
public class D2DMedia:Control
public class D2DMedia : Control
{
private Canvas _canvas;
private Image _img;
public D2DMedia()
{
}
protected override void OnHandleCreated(EventArgs e)
{
@ -28,15 +25,16 @@ namespace CefTest
private void _canvas_DrawGraphics(object sender, DrawGraphicsEventArgs e)
{
e.Graphics.BeginScene();
e.Graphics.DrawImage(_img,default(PointF));
e.Graphics.DrawImage(_img, default(PointF));
e.Graphics.EndScene();
}
public void UpdateAndPaint(int width,int height,int pitch,IntPtr scan0,PixelFormat format)
public void UpdateAndPaint(int width, int height, int pitch, IntPtr scan0, PixelFormat format)
{
_img.Update(width,height,pitch,scan0,format);
_img.Update(width, height, pitch, scan0, format);
_canvas.SafeDraw();
}
private void _canvas_SetupGraphics(object sender, SetupGraphicsEventArgs e)
{
_img = e.Graphics.CreateImage();

View File

@ -1,15 +1,14 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Security.Permissions;
using System.Threading;
using System.Windows.Forms;
using RageCoop.Client.CefHost;
using SharpDX.DXGI;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using AlphaMode = SharpDX.Direct2D1.AlphaMode;
using SharpD2D;
using SharpD2D.Windows;
using SharpDX.Direct2D1;
using SharpDX.DXGI;
using AlphaMode = SharpDX.Direct2D1.AlphaMode;
using Bitmap = System.Drawing.Bitmap;
namespace CefTest
{
@ -20,17 +19,18 @@ namespace CefTest
{
WindowHelper.DisableScalingGlobal();
TimerService.EnableHighPrecisionTimers();
CefController.Initialize(@"M:\SandBox-Shared\repos\RAGECOOP\RAGECOOP-V\bin\Debug\Client\SubProcess\RageCoop.Client.CefHost.exe");
CefController.Initialize(
@"M:\SandBox-Shared\repos\RAGECOOP\RAGECOOP-V\bin\Debug\Client\SubProcess\RageCoop.Client.CefHost.exe");
CefController.OnCefMessage += s => Console.WriteLine(s);
Test2();
}
static void Test1()
private static void Test1()
{
var controller2 = CefController.Create(1, new Size(1920, 1080), out var adapter2, BufferMode.Dirty);
Application.Run(new Test(adapter2, controller2));
}
private static void Test2()
{
var controller = CefController.Create(0, new Size(1920, 1080), out var adapter, BufferMode.Full);
@ -41,35 +41,36 @@ namespace CefTest
internal class Test2 : Test
{
private D2DMedia _con;
private readonly D2DMedia _con;
public Test2(CefAdapter adapter, CefController controller) : base(adapter, controller)
{
Text = "test2: d2d";
_con = new D2DMedia { Size = Size };
Controls.Add(_con);
SizeChanged += (s, e) =>
{
_con.Size = Size;
};
SizeChanged += (s, e) => { _con.Size = Size; };
_con.KeyDown += CefKeyDown;
_con.MouseDown += (s, e) => MouseKey(e, false);
_con.MouseUp += (s, e) => MouseKey(e, true);
_con.MouseMove += (s, e) => controller?.SendMouseMove(Cursor.Position.X, Cursor.Position.Y - (Height - ClientRectangle.Height));
_con.MouseMove += (s, e) =>
controller?.SendMouseMove(Cursor.Position.X, Cursor.Position.Y - (Height - ClientRectangle.Height));
}
protected override void CefPaint(int bufferSize, Rectangle dirtyRect)
{
try
{
lock (_adapter)
{
var size = _adapter.Size;
_con.UpdateAndPaint(size.Width, size.Height, size.Width * 4, _adapter.PtrBuffer, new SharpDX.Direct2D1.PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied));
_con.UpdateAndPaint(size.Width, size.Height, size.Width * 4, _adapter.PtrBuffer,
new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied));
}
}
catch (Exception ex) { Console.WriteLine(ex); }
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
@ -90,7 +91,8 @@ namespace CefTest
KeyDown += CefKeyDown;
MouseDown += (s, e) => MouseKey(e, false);
MouseUp += (s, e) => MouseKey(e, true);
MouseMove += (s, e) => controller?.SendMouseMove(Cursor.Position.X, Cursor.Position.Y - (Height - ClientRectangle.Height));
MouseMove += (s, e) =>
controller?.SendMouseMove(Cursor.Position.X, Cursor.Position.Y - (Height - ClientRectangle.Height));
BackColor = Color.AliceBlue;
_graphics = CreateGraphics();
AutoScaleMode = AutoScaleMode.None;
@ -116,7 +118,10 @@ namespace CefTest
public void CefKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.R) _controller.LoadUrl("https://www.youtube.com/watch?v=x53lfkuP044/");
if (e.KeyCode == Keys.R)
{
_controller.LoadUrl("https://www.youtube.com/watch?v=x53lfkuP044/");
}
else if (e.KeyCode == Keys.F11)
{
if (WindowState != FormWindowState.Maximized)
@ -129,7 +134,6 @@ namespace CefTest
FormBorderStyle = FormBorderStyle.Sizable;
WindowState = FormWindowState.Normal;
}
}
}
@ -138,10 +142,10 @@ namespace CefTest
lock (_adapter)
{
var draw = new Bitmap(dirtyRect.Width, dirtyRect.Height, dirtyRect.Width * 4,
PixelFormat.Format32bppArgb, _adapter.PtrBuffer);
System.Drawing.Imaging.PixelFormat.Format32bppArgb, _adapter.PtrBuffer);
_graphics.DrawImage(draw, dirtyRect.Location);
draw.Dispose();
}
}
}
}
}

View File

@ -6,7 +6,6 @@ using Formatting = Newtonsoft.Json.Formatting;
namespace DataDumper;
[Flags]
public enum GenFlags
{
@ -16,18 +15,18 @@ public enum GenFlags
Animations = 8,
All = ~0
}
public static class Program
{
public static GenFlags ToGenerate = GenFlags.All;
public static void Main(string[] args)
{
if (args.Length > 0 && Enum.TryParse<GenFlags>(args[0], true, out var flags))
{
ToGenerate = flags;
}
if (args.Length > 0 && Enum.TryParse<GenFlags>(args[0], true, out var flags)) ToGenerate = flags;
Directory.CreateDirectory("out");
#region META
// Dumps from the game's xml documents, needs to have all *.meta file extracted to "meta" directory. OpenIV is recommended
if (ToGenerate.HasFlag(GenFlags.WeaponInfo))
@ -35,28 +34,21 @@ public static class Program
Dictionary<uint, WeaponInfo> weapons = new();
foreach (var f in Directory.GetFiles("meta", "*.meta")) Parse(f, weapons);
File.WriteAllText("out/Weapons.json", JsonConvert.SerializeObject(weapons, Formatting.Indented));
if (ToGenerate.HasFlag(GenFlags.WeaponHash))
{
DumpWeaponHash(weapons, true);
}
if (ToGenerate.HasFlag(GenFlags.WeaponHash)) DumpWeaponHash(weapons, true);
}
#endregion
#region EXTERNAL
// External data from DurtyFree's data dumps: https://github.com/DurtyFree/gta-v-data-dumps
Directory.CreateDirectory("ext");
if (ToGenerate.HasFlag(GenFlags.VehicleWeaponInfo))
{
VehicleWeaponInfo.Dump("ext/vehicles.json", "out/VehicleWeapons.json");
}
if (ToGenerate.HasFlag(GenFlags.Animations))
{
AnimDic.Dump("ext/animDictsCompact.json", "out/Animations.json");
}
if (ToGenerate.HasFlag(GenFlags.Animations)) AnimDic.Dump("ext/animDictsCompact.json", "out/Animations.json");
#endregion
}
@ -123,5 +115,4 @@ public static class Program
foreach (XmlNode n in l) nodes.Add(n);
return nodes;
}
}