Gbx Tool API (powered by GBX.NET)
This project will be transformed into GBX.NET.Tool with a fairly similar API.
Gbx Tool API library integrates tools into Gbx Web Tools in both serverside and clientside ways.
That way it is possible to make conventions that allow easier Gbx tool development, while also not completely rely on the Gbx Web Tools project.
It is important to note that Gbx Tool API can still introduce major breaking changes without notice due to its early development stage.
Features of this library set are split in this way:
- GbxToolAPI
- GbxToolAPI.Client
- GbxToolAPI.Server
- GbxToolAPI.CLI
- GbxToolAPI.Lua (coming soon)
This is the base library, used by all the other sub-libraries above (except GbxToolAPI.Server, temporarily). It has the tool skeleton logic, and other features suitable for most tool scenarios.
Reference this library in your Gbx tool library project, if it is supposed to run in both wbe browser and CLI.
This has everything from GbxToolAPI + Razor web features on top.
If you want to enhance web UI of your tool that is also supposed to work on CLI, create a [YourTool].Client
Razor library and reference GbxToolAPI.Client
there (don't reference it in your main tool library project). If your tool is only supposed to work in web browser, directly reference GbxToolAPI.Client
and don't bother about the base GbxToolAPI
library.
This allows your tool to communicate with databases and websocket connections. In the future, this will also allow serversided executions of the tools, like Discord bot or REST API endpoints for example.
To build a Gbx tool utilizing Gbx Tool API:
-
Create a library project that will be the base of everything
-
Reference GbxToolAPI in that project
exact commands soon
- Create a class called
[YourToolName]Tool.cs
:
using GBX.NET.Engines.Game;
using GbxToolAPI;
namespace [YourToolNamespace];
[ToolName("[Your Tool Name]")]
public class [YourToolName]Tool : ITool
{
private readonly CGameCtnChallenge map;
public [YourToolName]Tool(CGameCtnChallenge map)
{
this.map = map;
}
}
-
This on its own cannot do anything, but you can add "extensions" to the tool via interfaces.
-
For example, add
IHasOutput<T>
, which will implementProduces()
method returningT
as the produced result. Currently I only recommend usingNode
orNodeFile<T> where T : Node
classes in there.
using GBX.NET.Engines.Game;
using GbxToolAPI;
namespace [YourToolNamespace];
[ToolName("[Your Tool Name]")]
public class [YourToolName]Tool : ITool, IHasOutput<CGameCtnMediaClip>
{
private readonly CGameCtnChallenge map;
public [YourToolName]Tool(CGameCtnChallenge map)
{
this.map = map;
}
public CGameCtnMediaClip Produce()
{
return map.ClipIntro; // Some advanced conversion
}
}
- For example, add configuration of the tool via
IConfigurable<TConfig> where TConfig : Config
. You should create your own configuration class (standard name is[YourToolName]Config
).