Add native

This commit is contained in:
Jackzie 2024-05-07 12:15:58 -05:00
parent b6cee78ab0
commit 959b9d9db5
2 changed files with 20 additions and 2 deletions

View file

@ -22,8 +22,9 @@ methodmap UIElement < JSONObject {
public UIElement(const char[] elemNamespace, const char[] elemId) {
JSONObject obj = new JSONObject();
obj.SetString("namespace", elemNamespace);
obj.SetString("id", elemId);
obj.SetString("elem_id", elemId);
obj.SetBool("visibility", false);
obj.Set("variables", new JSONObject());
return view_as<UIElement>(obj);
}
@ -80,5 +81,9 @@ methodmap UIElement < JSONObject {
view_as<JSONObject>(this).Remove("steamids");
}
public void Clear() {
view_as<JSONObject>(this).Clear();
}
public native bool Send();
}

View file

@ -51,7 +51,10 @@ char OUT_EVENT_IDS[view_as<int>(Event_Invalid)][] = {
};
char steamidCache[MAXPLAYERS+1][32];
// TODO: add natives
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) {
CreateNative("UIElement.Send", Native_UpdateUI);
return APLRes_Success;
}
public void OnPluginStart() {
EngineVersion g_Game = GetEngineVersion();
@ -330,6 +333,16 @@ bool Native_PlayAudio(Handle plugin, int numParams) {
return true;
}
bool Native_UpdateUI(Handle plugin, int numParams) {
if(!isManagerReady()) return false;
UIElement elem = view_as<UIElement>(GetNativeCell(1));
g_ws.Write(view_as<JSON>(elem));
return true;
}
//IsOverlayConnected();
bool Native_IsOverlayConnected(Handle plugin, int numParams) {
return isManagerReady();