mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: some more ffi communication
This commit is contained in:
1 parent
fe3d029e74
commit
a5a72f9536
12 files changed
+95
-64
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"indentSize": 2
|
||||||
|
}
|
||||||
+5
-2
@@ -119,6 +119,8 @@ _ReSharper*/
|
|||||||
_TeamCity*
|
_TeamCity*
|
||||||
*.dotCover
|
*.dotCover
|
||||||
.axoCover/*
|
.axoCover/*
|
||||||
|
|
||||||
|
|
||||||
!.axoCover/settings.json
|
!.axoCover/settings.json
|
||||||
coverage*.json
|
coverage*.json
|
||||||
coverage*.xml
|
coverage*.xml
|
||||||
@@ -137,6 +139,7 @@ DocProject/buildhelp/
|
|||||||
DocProject/Help/*.HxT
|
DocProject/Help/*.HxT
|
||||||
DocProject/Help/*.HxC
|
DocProject/Help/*.HxC
|
||||||
DocProject/Help/*.hhc
|
DocProject/Help/*.hhc
|
||||||
|
|
||||||
DocProject/Help/*.hhk
|
DocProject/Help/*.hhk
|
||||||
DocProject/Help/*.hhp
|
DocProject/Help/*.hhp
|
||||||
DocProject/Help/Html2
|
DocProject/Help/Html2
|
||||||
@@ -147,13 +150,13 @@ publish/
|
|||||||
*.pubxml
|
*.pubxml
|
||||||
*.publishproj
|
*.publishproj
|
||||||
PublishScripts/
|
PublishScripts/
|
||||||
|
|
||||||
*.nupkg
|
*.nupkg
|
||||||
*.snupkg
|
*.snupkg
|
||||||
**/[Pp]ackages/*
|
|
||||||
!**/[Pp]ackages/build/
|
|
||||||
*.nuget.props
|
*.nuget.props
|
||||||
*.nuget.targets
|
*.nuget.targets
|
||||||
csx/
|
csx/
|
||||||
|
|
||||||
*.build.csdef
|
*.build.csdef
|
||||||
ecf/
|
ecf/
|
||||||
rcf/
|
rcf/
|
||||||
|
|||||||
Vendored
+2
-1
@@ -229,5 +229,6 @@
|
|||||||
"deno.unstable": false,
|
"deno.unstable": false,
|
||||||
"cSpell.enableFiletypes": ["glsl", "proto3"],
|
"cSpell.enableFiletypes": ["glsl", "proto3"],
|
||||||
"typescript.tsdk": "node_modules\\typescript\\lib",
|
"typescript.tsdk": "node_modules\\typescript\\lib",
|
||||||
"liveServer.settings.multiRootWorkspaceName": "blitzkit"
|
"liveServer.settings.multiRootWorkspaceName": "blitzkit",
|
||||||
|
"git.ignoreLimitWarning": true
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Flex, Text } from '@radix-ui/themes';
|
||||||
|
import { ffi } from '../../core/blitzkit/ffi';
|
||||||
|
|
||||||
|
export function FFIEcho() {
|
||||||
|
return (
|
||||||
|
<Flex direction="column" align="start" gap="2">
|
||||||
|
<Text>{ffi.debug_echo(new Date().toLocaleString())}</Text>
|
||||||
|
<img src="https://i.imgflip.com/9wrr7u.gif" />
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { Code, Text } from '@radix-ui/themes';
|
||||||
|
import { ffi } from '../../core/blitzkit/ffi';
|
||||||
|
|
||||||
|
export function FFIFileCount() {
|
||||||
|
return (
|
||||||
|
<Text>
|
||||||
|
<Code>{ffi.debug_get_file_count().toLocaleString()}</Code> files loaded
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { Library, types } from 'ffi-napi';
|
||||||
|
import { assertSecret } from 'packages/core/src';
|
||||||
|
|
||||||
|
export const FFI_PATH =
|
||||||
|
'../../src/BlitzKit.FFI/bin/Release/net9.0/win-x64/publish/BlitzKit.FFI.dll';
|
||||||
|
|
||||||
|
export const ffi = Library(FFI_PATH, {
|
||||||
|
debug_echo: [types.CString, [types.CString]],
|
||||||
|
mount_game: ['void', [types.CString]],
|
||||||
|
debug_get_file_count: [types.int, []],
|
||||||
|
});
|
||||||
|
|
||||||
|
ffi.mount_game(assertSecret(import.meta.env.GAME_MOUNT_POINT));
|
||||||
@@ -1,47 +1,14 @@
|
|||||||
import { Link, Table } from '@radix-ui/themes';
|
import { Heading } from '@radix-ui/themes';
|
||||||
|
import { FFIEcho } from '../../components/Internal/FFIEcho';
|
||||||
|
import { FFIFileCount } from '../../components/Internal/FFIFileCount';
|
||||||
import { PageWrapper } from '../../components/PageWrapper';
|
import { PageWrapper } from '../../components/PageWrapper';
|
||||||
|
|
||||||
export function Page() {
|
export function Page() {
|
||||||
return (
|
return (
|
||||||
<PageWrapper>
|
<PageWrapper color="amber">
|
||||||
<Table.Root>
|
<Heading>BlitzKit FFI</Heading>
|
||||||
<Table.Header>
|
<FFIEcho />
|
||||||
<Table.Row>
|
<FFIFileCount />
|
||||||
<Table.ColumnHeaderCell>Name</Table.ColumnHeaderCell>
|
|
||||||
<Table.ColumnHeaderCell>Memo</Table.ColumnHeaderCell>
|
|
||||||
</Table.Row>
|
|
||||||
</Table.Header>
|
|
||||||
|
|
||||||
<Table.Body>
|
|
||||||
<Table.Row>
|
|
||||||
<Table.Cell>
|
|
||||||
<Link href="internal/ffi">FFI</Link>
|
|
||||||
</Table.Cell>
|
|
||||||
<Table.Cell>
|
|
||||||
Status of BlitzKit's currently mounted foreign function interface
|
|
||||||
</Table.Cell>
|
|
||||||
</Table.Row>
|
|
||||||
|
|
||||||
<Table.Row>
|
|
||||||
<Table.Cell>
|
|
||||||
<Link href="internal/ffi">Client</Link>
|
|
||||||
</Table.Cell>
|
|
||||||
<Table.Cell>
|
|
||||||
Location and information of the currently mounted client
|
|
||||||
</Table.Cell>
|
|
||||||
</Table.Row>
|
|
||||||
|
|
||||||
<Table.Row>
|
|
||||||
<Table.Cell>
|
|
||||||
<Link href="/internal/bindings">Bindings</Link>
|
|
||||||
</Table.Cell>
|
|
||||||
<Table.Cell>
|
|
||||||
Exhaustive list of all bindings and preference of currently
|
|
||||||
mounted client
|
|
||||||
</Table.Cell>
|
|
||||||
</Table.Row>
|
|
||||||
</Table.Body>
|
|
||||||
</Table.Root>
|
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { PageWrapper } from 'packages/website-ue/src/components/PageWrapper';
|
|
||||||
import { ffi } from 'packages/website-ue/src/core/blitzkit/ffi';
|
|
||||||
|
|
||||||
export function Page() {
|
|
||||||
return (
|
|
||||||
<PageWrapper align="center" justify="center">
|
|
||||||
🟢 {ffi.echo(new Date().toLocaleString())}
|
|
||||||
<img src="https://i.imgflip.com/9wrr7u.gif" />
|
|
||||||
</PageWrapper>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
---
|
|
||||||
import InternalBaseLayout from 'packages/website-ue/src/layouts/InternalBaseLayout.astro';
|
|
||||||
import { Page } from './_index';
|
|
||||||
---
|
|
||||||
|
|
||||||
<InternalBaseLayout>
|
|
||||||
<Page />
|
|
||||||
</InternalBaseLayout>
|
|
||||||
@@ -7,4 +7,8 @@
|
|||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
<InvariantGlobalization>true</InvariantGlobalization>
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="../../submodules/CUE4Parse/CUE4Parse/CUE4Parse.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
+18
-2
@@ -1,15 +1,31 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using BlitzKit.FFI.Models;
|
||||||
|
|
||||||
namespace BlitzKit.FFI;
|
namespace BlitzKit.FFI;
|
||||||
|
|
||||||
public static class FFI
|
public static class FFI
|
||||||
{
|
{
|
||||||
[UnmanagedCallersOnly(EntryPoint = "echo")]
|
static BlitzProvider provider;
|
||||||
public static IntPtr Echo(IntPtr inputPtr)
|
|
||||||
|
[UnmanagedCallersOnly(EntryPoint = "debug_echo")]
|
||||||
|
public static IntPtr DebugEcho(IntPtr inputPtr)
|
||||||
{
|
{
|
||||||
var input = Marshal.PtrToStringAnsi(inputPtr);
|
var input = Marshal.PtrToStringAnsi(inputPtr);
|
||||||
var result = $"BlitzKit FFI echo: {input}";
|
var result = $"BlitzKit FFI echo: {input}";
|
||||||
return Marshal.StringToHGlobalAnsi(result);
|
return Marshal.StringToHGlobalAnsi(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[UnmanagedCallersOnly(EntryPoint = "mount_game")]
|
||||||
|
public static void DebugGetGameMountPoint(IntPtr pointPtr)
|
||||||
|
{
|
||||||
|
var point = Marshal.PtrToStringAnsi(pointPtr);
|
||||||
|
provider = new(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedCallersOnly(EntryPoint = "debug_get_file_count")]
|
||||||
|
public static int DebugGetFileCount()
|
||||||
|
{
|
||||||
|
return provider.Files.Count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using CUE4Parse.FileProvider;
|
||||||
|
using CUE4Parse.UE4.Versions;
|
||||||
|
|
||||||
|
namespace BlitzKit.FFI.Models
|
||||||
|
{
|
||||||
|
public class BlitzProvider : DefaultFileProvider
|
||||||
|
{
|
||||||
|
public BlitzProvider(string directory)
|
||||||
|
: base(
|
||||||
|
directory: directory,
|
||||||
|
searchOption: SearchOption.AllDirectories,
|
||||||
|
versions: new(EGame.GAME_UE5_3),
|
||||||
|
pathComparer: StringComparer.OrdinalIgnoreCase
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
Mount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user