Browse Source

PoC clibfj bindings with Wine support

tags/v0.0.1
NGnius (Graham) 3 years ago
parent
commit
159c07cd60
5 changed files with 66 additions and 8 deletions
  1. +3
    -0
      .gitmodules
  2. +42
    -0
      NPort/Bindings/Robocraft.cs
  3. +6
    -3
      NPort/NPort.csproj
  4. +14
    -5
      NPort/NPortPlugin.cs
  5. +1
    -0
      clibfj

+ 3
- 0
.gitmodules View File

@@ -0,0 +1,3 @@
[submodule "clibfj"]
path = clibfj
url = https://github.com/NGnius/clibfj

+ 42
- 0
NPort/Bindings/Robocraft.cs View File

@@ -0,0 +1,42 @@
using System.Runtime.InteropServices;

namespace NPort.Bindings
{
public static class Robocraft
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct FactoryRobotListInfo{
public uint item_id;
public string item_name;
public string item_description;
public string thumbnail; // url
public string added_by;
public string added_by_display_name;
public string added_date; // ISO date
public string expiry_date; // ISO date
public uint cpu;
public uint total_robot_ranking;
public uint rent_count;
public uint buy_count;
public uint buyable; // bool
public string removed_date;
public string ban_date;
public uint featured; // bool
public string banner_message;
public float combat_rating;
public float cosmetic_rating;
public string cube_amounts; // JSON as str
}
[DllImport("libfj.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void get_factory_front_page(uint size, [In,Out] FactoryRobotListInfo[] array_ptr);

public static FactoryRobotListInfo[] GetFactoryFrontPage()
{
uint size = 100;
FactoryRobotListInfo[] arr = new FactoryRobotListInfo[size];
get_factory_front_page(size, arr);
return arr;
}
}
}

+ 6
- 3
NPort/NPort.csproj View File

@@ -20,9 +20,9 @@

<!--Start Dependencies-->
<ItemGroup>
<Reference Include="GamecraftModdingAPI">
<HintPath>..\ref\Plugins\GamecraftModdingAPI.dll</HintPath>
<HintPath>..\..\ref\Plugins\GamecraftModdingAPI.dll</HintPath>
<Reference Include="TechbloxModdingAPI">
<HintPath>..\ref\Plugins\TechbloxModdingAPI.dll</HintPath>
<HintPath>..\..\ref\Plugins\TechbloxModdingAPI.dll</HintPath>
</Reference>
<Reference Include="IllusionInjector">
<HintPath>..\ref\TechbloxPreview_Data\Managed\IllusionInjector.dll</HintPath>
@@ -1081,6 +1081,9 @@
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\VisualProfiler.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Installer" />
</ItemGroup>
<!--End Dependencies-->

</Project>

+ 14
- 5
NPort/NPortPlugin.cs View File

@@ -1,7 +1,8 @@
using System.Reflection;

using IllusionPlugin;
//using GamecraftModdingAPI;
using TechbloxModdingAPI.Utility;
using TechbloxModdingAPI;

namespace NPort
{
@@ -16,22 +17,30 @@ namespace NPort
public override void OnApplicationQuit()
{
// Shutdown this mod
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has shutdown");
Logging.LogDebug($"{Name} has shutdown");

// Shutdown the Gamecraft modding API last
GamecraftModdingAPI.Main.Shutdown();
Main.Shutdown();
}

// called when Gamecraft starts up
public override void OnApplicationStart()
{
// Initialize the Gamecraft modding API first
GamecraftModdingAPI.Main.Init();
Main.Init();
// check out the modding API docs here: https://mod.exmods.org/

// Initialize this mod

GamecraftModdingAPI.Utility.Logging.MetaLog($"{Name} has started up");
Logging.MetaLog($"{Name} has started up");
#if DEBUG
// TEST
Bindings.Robocraft.FactoryRobotListInfo[] items = Bindings.Robocraft.GetFactoryFrontPage();
foreach (var item in items)
{
Logging.MetaLog($"{item.item_name} by {item.added_by_display_name} ({item.item_id})");
}
#endif
}

// unused methods


+ 1
- 0
clibfj

@@ -0,0 +1 @@
Subproject commit aa8faeb42863ae802626ccb6b2ac3291c87ed928

Loading…
Cancel
Save