diff --git a/example/example.gui b/example/example.gui index 859d8de..f6cd70a 100644 --- a/example/example.gui +++ b/example/example.gui @@ -52,6 +52,7 @@ nodes { template: "/dirtylarry/button.gui" template_node_child: false custom_type: 0 + enabled: true } nodes { position { @@ -108,6 +109,9 @@ nodes { template_node_child: true size_mode: SIZE_MODE_MANUAL custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -173,11 +177,14 @@ nodes { text_leading: 1.0 text_tracking: 0.0 custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { x: 176.0 - y: 270.0 + y: 294.0 z: 0.0 w: 1.0 } @@ -213,6 +220,7 @@ nodes { template: "/dirtylarry/button.gui" template_node_child: false custom_type: 0 + enabled: true } nodes { position { @@ -269,6 +277,9 @@ nodes { template_node_child: true size_mode: SIZE_MODE_MANUAL custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -334,6 +345,9 @@ nodes { text_leading: 1.0 text_tracking: 0.0 custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -374,6 +388,7 @@ nodes { template: "/dirtylarry/button.gui" template_node_child: false custom_type: 0 + enabled: true } nodes { position { @@ -430,6 +445,9 @@ nodes { template_node_child: true size_mode: SIZE_MODE_MANUAL custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -495,11 +513,14 @@ nodes { text_leading: 1.0 text_tracking: 0.0 custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { x: 490.0 - y: 265.0 + y: 289.0 z: 0.0 w: 1.0 } @@ -535,6 +556,7 @@ nodes { template: "/dirtylarry/button.gui" template_node_child: false custom_type: 0 + enabled: true } nodes { position { @@ -591,6 +613,9 @@ nodes { template_node_child: true size_mode: SIZE_MODE_MANUAL custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -656,6 +681,9 @@ nodes { text_leading: 1.0 text_tracking: 0.0 custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -719,6 +747,9 @@ nodes { text_leading: 1.0 text_tracking: 0.0 custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -782,6 +813,9 @@ nodes { text_leading: 1.0 text_tracking: 0.0 custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -804,7 +838,7 @@ nodes { } size { x: 200.0 - y: 236.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -837,6 +871,9 @@ nodes { template_node_child: false size_mode: SIZE_MODE_AUTO custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -900,6 +937,9 @@ nodes { text_leading: 1.0 text_tracking: 0.0 custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -940,6 +980,7 @@ nodes { template: "/dirtylarry/button.gui" template_node_child: false custom_type: 0 + enabled: true } nodes { position { @@ -996,6 +1037,9 @@ nodes { template_node_child: true size_mode: SIZE_MODE_MANUAL custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -1061,6 +1105,9 @@ nodes { text_leading: 1.0 text_tracking: 0.0 custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -1124,11 +1171,14 @@ nodes { text_leading: 1.0 text_tracking: 0.0 custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { x: 801.0 - y: 265.0 + y: 289.0 z: 0.0 w: 1.0 } @@ -1164,6 +1214,7 @@ nodes { template: "/dirtylarry/button.gui" template_node_child: false custom_type: 0 + enabled: true } nodes { position { @@ -1220,6 +1271,9 @@ nodes { template_node_child: true size_mode: SIZE_MODE_MANUAL custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -1286,6 +1340,9 @@ nodes { text_leading: 1.0 text_tracking: 0.0 custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -1349,11 +1406,14 @@ nodes { text_leading: 1.0 text_tracking: 0.0 custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { x: 176.0 - y: 143.0 + y: 179.0 z: 0.0 w: 1.0 } @@ -1389,6 +1449,7 @@ nodes { template: "/dirtylarry/button.gui" template_node_child: false custom_type: 0 + enabled: true } nodes { position { @@ -1445,6 +1506,9 @@ nodes { template_node_child: true size_mode: SIZE_MODE_MANUAL custom_type: 0 + enabled: true + visible: true + material: "" } nodes { position { @@ -1510,7 +1574,178 @@ nodes { text_leading: 1.0 text_tracking: 0.0 custom_type: 0 + enabled: true + visible: true + material: "" +} +nodes { + position { + x: 176.0 + y: 67.0 + z: 0.0 + w: 1.0 + } + rotation { + x: 0.0 + y: 0.0 + z: 0.0 + w: 1.0 + } + scale { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + size { + x: 200.0 + y: 100.0 + z: 0.0 + w: 1.0 + } + color { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + type: TYPE_TEMPLATE + id: "engine-error" + layer: "" + inherit_alpha: true + alpha: 1.0 + template: "/dirtylarry/button.gui" + template_node_child: false + custom_type: 0 + enabled: true +} +nodes { + position { + x: 0.0 + y: 0.0 + z: 0.0 + w: 1.0 + } + rotation { + x: 0.0 + y: 0.0 + z: 0.0 + w: 1.0 + } + scale { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + size { + x: 300.0 + y: 88.0 + z: 0.0 + w: 1.0 + } + color { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + type: TYPE_BOX + blend_mode: BLEND_MODE_ALPHA + texture: "button/button_normal" + id: "engine-error/larrybutton" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "engine-error" + layer: "" + inherit_alpha: true + slice9 { + x: 32.0 + y: 32.0 + z: 32.0 + w: 32.0 + } + clipping_mode: CLIPPING_MODE_NONE + clipping_visible: true + clipping_inverted: false + alpha: 1.0 + template_node_child: true + size_mode: SIZE_MODE_MANUAL + custom_type: 0 + enabled: true + visible: true + material: "" +} +nodes { + position { + x: 0.0 + y: 0.0 + z: 0.0 + w: 1.0 + } + rotation { + x: 0.0 + y: 0.0 + z: 0.0 + w: 1.0 + } + scale { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + size { + x: 200.0 + y: 100.0 + z: 0.0 + w: 1.0 + } + color { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + type: TYPE_TEXT + blend_mode: BLEND_MODE_ALPHA + text: "engine-error" + font: "larryfont" + id: "engine-error/larrylabel" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + outline { + x: 0.0 + y: 0.0 + z: 0.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "engine-error/larrybutton" + layer: "" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 1.0 + shadow_alpha: 1.0 + overridden_fields: 8 + template_node_child: true + text_leading: 1.0 + text_tracking: 0.0 + custom_type: 0 + enabled: true + visible: true + material: "" } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 +max_nodes: 32 diff --git a/example/poki-sdk.gui_script b/example/poki-sdk.gui_script index db94183..0d14306 100644 --- a/example/poki-sdk.gui_script +++ b/example/poki-sdk.gui_script @@ -85,6 +85,13 @@ function on_input(self, action_id, action) print("Click lua-error") print(dsf.frt) end) + + dirtylarry:button("engine-error", action_id, action, function() + print("Click engine-error") + for i = 1, 12 do + gui.new_box_node(vmath.vector3(-1), vmath.vector3(1)) + end + end) end end diff --git a/poki-sdk/lib/web/lib_pokisdk.js b/poki-sdk/lib/web/lib_pokisdk.js index b219342..e8b1c54 100644 --- a/poki-sdk/lib/web/lib_pokisdk.js +++ b/poki-sdk/lib/web/lib_pokisdk.js @@ -51,6 +51,12 @@ var LibPokiSdk = { PokiSDK.captureError(UTF8ToString(error)); }, + PokiSdkJs_InternalCaptureError: function(formatted_string) { + var js_formatted_string = UTF8ToString(formatted_string); + var final_message = "DEFOLD:" + js_formatted_string; + PokiSDK.captureError(final_message); + }, + PokiSdkJs_IsAdBlocked: function() { return PokiSDK.isAdBlocked(); }, diff --git a/poki-sdk/src/pokisdk.cpp b/poki-sdk/src/pokisdk.cpp index 6e8913f..94df47b 100644 --- a/poki-sdk/src/pokisdk.cpp +++ b/poki-sdk/src/pokisdk.cpp @@ -22,6 +22,7 @@ extern "C" { void PokiSdkJs_GameplayStop(); void PokiSdkJs_SetDebug(bool value); void PokiSdkJs_CaptureError(const char* error); + void PokiSdkJs_InternalCaptureError(const char* formatted_string); void PokiSdkJs_CommercialBreak(CommercialBreakCallback callback); void PokiSdkJs_RewardedBreak(RewardedBreakCallback callback); @@ -243,29 +244,71 @@ static void LuaInit(lua_State* L) assert(top == lua_gettop(L)); } -dmExtension::Result InitializePokiSdk(dmExtension::Params* params) +static dmExtension::Result InitializePokiSdk(dmExtension::Params* params) { LuaInit(params->m_L); return dmExtension::RESULT_OK; } -dmExtension::Result FinalizePokiSdk(dmExtension::Params* params) +static dmExtension::Result FinalizePokiSdk(dmExtension::Params* params) { return dmExtension::RESULT_OK; } +static void LogListener(LogSeverity severity, const char* domain, const char* formatted_string) +{ + switch (severity) + { + case LOG_SEVERITY_WARNING: + case LOG_SEVERITY_ERROR: + case LOG_SEVERITY_FATAL: + PokiSdkJs_InternalCaptureError(formatted_string); + break; + case LOG_SEVERITY_DEBUG: + case LOG_SEVERITY_USER_DEBUG: + case LOG_SEVERITY_INFO: + // do nothing + break; + default: + // do nothing + break; + } +} + +static dmExtension::Result AppInitializePokiSdk(dmExtension::AppParams *params) +{ + dmLogRegisterListener(&LogListener); + return dmExtension::RESULT_OK; +} + +static dmExtension::Result AppFinalizePokiSdk(dmExtension::AppParams *params) +{ + dmLogUnregisterListener(&LogListener); + return dmExtension::RESULT_OK; +} + #else // unsupported platforms -dmExtension::Result InitializePokiSdk(dmExtension::Params* params) +static dmExtension::Result InitializePokiSdk(dmExtension::Params* params) +{ + return dmExtension::RESULT_OK; +} + +static dmExtension::Result FinalizePokiSdk(dmExtension::Params* params) +{ + return dmExtension::RESULT_OK; +} + +static dmExtension::Result AppInitializePokiSdk(dmExtension::AppParams *params) { return dmExtension::RESULT_OK; } -dmExtension::Result FinalizePokiSdk(dmExtension::Params* params) +static dmExtension::Result AppFinalizePokiSdk(dmExtension::AppParams *params) { return dmExtension::RESULT_OK; } #endif -DM_DECLARE_EXTENSION(EXTENSION_NAME, LIB_NAME, 0, 0, InitializePokiSdk, 0, 0, FinalizePokiSdk) +DM_DECLARE_EXTENSION(EXTENSION_NAME, LIB_NAME, AppInitializePokiSdk, AppFinalizePokiSdk, InitializePokiSdk, 0, 0, FinalizePokiSdk)