diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..051bb81 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "clibfj"] + path = clibfj + url = https://github.com/NGnius/clibfj diff --git a/NPort/Bindings/Robocraft.cs b/NPort/Bindings/Robocraft.cs new file mode 100644 index 0000000..e486f53 --- /dev/null +++ b/NPort/Bindings/Robocraft.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/NPort/NPort.csproj b/NPort/NPort.csproj index 8b7e004..0e95e7a 100644 --- a/NPort/NPort.csproj +++ b/NPort/NPort.csproj @@ -20,9 +20,9 @@ - - ..\ref\Plugins\GamecraftModdingAPI.dll - ..\..\ref\Plugins\GamecraftModdingAPI.dll + + ..\ref\Plugins\TechbloxModdingAPI.dll + ..\..\ref\Plugins\TechbloxModdingAPI.dll ..\ref\TechbloxPreview_Data\Managed\IllusionInjector.dll @@ -1081,6 +1081,9 @@ ..\..\ref\TechbloxPreview_Data\Managed\VisualProfiler.dll + + + diff --git a/NPort/NPortPlugin.cs b/NPort/NPortPlugin.cs index 6a863b0..cca6374 100644 --- a/NPort/NPortPlugin.cs +++ b/NPort/NPortPlugin.cs @@ -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 diff --git a/clibfj b/clibfj new file mode 160000 index 0000000..aa8faeb --- /dev/null +++ b/clibfj @@ -0,0 +1 @@ +Subproject commit aa8faeb42863ae802626ccb6b2ac3291c87ed928