From ea9aab0a2cd6bc0050ea250868eb24abd791e021 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 17 Aug 2024 16:29:41 +0100 Subject: [PATCH] library: "setcallback.." -> "on.." --- src/library/gl.c | 4 ++-- src/library/plugin/plugin.c | 26 +++++++++++++------------- src/library/plugin/plugin.h | 4 ++-- src/library/plugin/plugin_api.h | 18 +++++++++--------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/library/gl.c b/src/library/gl.c index d025f14..4547921 100644 --- a/src/library/gl.c +++ b/src/library/gl.c @@ -1336,7 +1336,7 @@ void _bolt_gl_onDrawElements(GLenum mode, GLsizei count, GLenum type, const void batch.texture_functions.compare = _bolt_gl_plugin_texture_compare; batch.texture_functions.data = _bolt_gl_plugin_texture_data; - _bolt_plugin_handle_2d(&batch); + _bolt_plugin_handle_render2d(&batch); } } if (type == GL_UNSIGNED_SHORT && mode == GL_TRIANGLES && c->bound_program->is_3d) { @@ -1390,7 +1390,7 @@ void _bolt_gl_onDrawElements(GLenum mode, GLsizei count, GLenum type, const void render.matrix_functions.to_screen_space = _bolt_gl_plugin_matrix3d_toscreenspace; render.matrix_functions.world_pos = _bolt_gl_plugin_matrix3d_worldpos; - _bolt_plugin_handle_3d(&render); + _bolt_plugin_handle_render3d(&render); } } } diff --git a/src/library/plugin/plugin.c b/src/library/plugin/plugin.c index 8f9df5d..73a17ef 100644 --- a/src/library/plugin/plugin.c +++ b/src/library/plugin/plugin.c @@ -133,7 +133,7 @@ static uint64_t _bolt_plugin_map_hash(const void* item, uint64_t seed0, uint64_t static struct hashmap* plugins; -// macro for defining callback functions "_bolt_plugin_handle_*" and "api_setcallback*" +// macro for defining callback functions "_bolt_plugin_handle_*" and "api_on*" // e.g. DEFINE_CALLBACK(swapbuffers, SWAPBUFFERS, SwapBuffersEvent) #define DEFINE_CALLBACK(APINAME, REGNAME, STRUCTNAME) \ void _bolt_plugin_handle_##APINAME(struct STRUCTNAME* e) { \ @@ -163,8 +163,8 @@ void _bolt_plugin_handle_##APINAME(struct STRUCTNAME* e) { \ } \ } \ } \ -static int api_setcallback##APINAME(lua_State* state) { \ - _bolt_check_argc(state, 1, "setcallback" #APINAME); \ +static int api_on##APINAME(lua_State* state) { \ + _bolt_check_argc(state, 1, "on" #APINAME); \ PUSHSTRING(state, REGNAME##_CB_REGISTRYNAME); \ if (lua_isfunction(state, 1)) { \ lua_pushvalue(state, 1); \ @@ -282,14 +282,14 @@ static int _bolt_api_init(lua_State* state) { API_ADD(time) API_ADD(datetime) API_ADD(weekday) - API_ADD(setcallback2d) - API_ADD(setcallback3d) - API_ADD(setcallbackminimap) - API_ADD(setcallbackswapbuffers) - API_ADD(setcallbackmousemotion) - API_ADD(setcallbackmousebutton) - API_ADD(setcallbackmousebuttonup) - API_ADD(setcallbackscroll) + API_ADD(onrender2d) + API_ADD(onrender3d) + API_ADD(onminimap) + API_ADD(onswapbuffers) + API_ADD(onmousemotion) + API_ADD(onmousebutton) + API_ADD(onmousebuttonup) + API_ADD(onscroll) API_ADD(createsurface) API_ADD(createsurfacefromrgba) API_ADD(createsurfacefrompng) @@ -743,8 +743,8 @@ static void _bolt_check_argc(lua_State* state, int expected_argc, const char* fu } DEFINE_CALLBACK(swapbuffers, SWAPBUFFERS, SwapBuffersEvent) -DEFINE_CALLBACK(2d, BATCH2D, RenderBatch2D) -DEFINE_CALLBACK(3d, RENDER3D, Render3D) +DEFINE_CALLBACK(render2d, BATCH2D, RenderBatch2D) +DEFINE_CALLBACK(render3d, RENDER3D, Render3D) DEFINE_CALLBACK(minimap, MINIMAP, RenderMinimapEvent) DEFINE_CALLBACK(mousemotion, MOUSEMOTION, MouseMotionEvent) DEFINE_CALLBACK(mousebutton, MOUSEBUTTON, MouseButtonEvent) diff --git a/src/library/plugin/plugin.h b/src/library/plugin/plugin.h index 5f34295..6f7d132 100644 --- a/src/library/plugin/plugin.h +++ b/src/library/plugin/plugin.h @@ -271,10 +271,10 @@ void _bolt_plugin_stop(char* id, uint32_t id_length); void _bolt_plugin_handle_swapbuffers(struct SwapBuffersEvent*); /// Sends a RenderBatch2D to all plugins. -void _bolt_plugin_handle_2d(struct RenderBatch2D*); +void _bolt_plugin_handle_render2d(struct RenderBatch2D*); /// Sends a Render3D to all plugins. -void _bolt_plugin_handle_3d(struct Render3D*); +void _bolt_plugin_handle_render3d(struct Render3D*); /// Sends a RenderMinimap to all plugins. void _bolt_plugin_handle_minimap(struct RenderMinimapEvent*); diff --git a/src/library/plugin/plugin_api.h b/src/library/plugin/plugin_api.h index 05178d8..c774d93 100644 --- a/src/library/plugin/plugin_api.h +++ b/src/library/plugin/plugin_api.h @@ -17,7 +17,7 @@ * --... * ``` * - * After that, pass Lua functions to the `bolt.setcallback...` functions to set event callbacks. + * After that, pass Lua functions to the `bolt.on...` functions to set event callbacks. * * The 2D rendering pipeline is fairly simple. Images are drawn in large batches of vertices, * usually 6 vertices per icon (three per triangle, two triangles.) Plugins should call the @@ -146,7 +146,7 @@ static int api_createwindow(lua_State*); /// /// The callback will be called every frame - that's anywhere from 5 to 150+ times per second - so /// avoid using it for anything time-consuming. -static int api_setcallbackswapbuffers(lua_State*); +static int api_onswapbuffers(lua_State*); /// [-1, +0, -] /// Sets a callback function for rendering of 2D images, overwriting the previous callback, if any. @@ -161,7 +161,7 @@ static int api_setcallbackswapbuffers(lua_State*); /// The callback will be called an extremely high amount of times per second, so great care should /// be taken to determine as quickly as possible whether any image is of interest or not, such as /// by checking each image's width and height. -static int api_setcallback2d(lua_State*); +static int api_onrender2d(lua_State*); /// [-1, +0, -] /// Sets a callback function for rendering of 3D models, overwriting the previous callback, if any. @@ -176,7 +176,7 @@ static int api_setcallback2d(lua_State*); /// The callback will be called an extremely high amount of times per second, so great care should /// be taken to determine as quickly as possible whether any image is of interest or not, such as /// by checking the model's vertex count. -static int api_setcallback3d(lua_State*); +static int api_onrender3d(lua_State*); /// [-1, +0, -] /// Sets a callback function for rendering of a minimap background image, overwriting the previous @@ -193,7 +193,7 @@ static int api_setcallback3d(lua_State*); /// /// The pixel contents cannot be examined directly, however it's possible to query the image angle, /// image scale (zoom level), and a rough estimate of the tile position it's centered on. -static int api_setcallbackminimap(lua_State*); +static int api_onminimap(lua_State*); /// [-1, +0, -] /// Sets a callback function for mouse motion events, overwriting the previous callback, if any. @@ -208,7 +208,7 @@ static int api_setcallbackminimap(lua_State*); /// /// The callback will be called with one param, that being a mouse motion object. All of the member /// functions of that object can be found in this file, prefixed with "api_mouseevent_". -static int api_setcallbackmousemotion(lua_State*); +static int api_onmousemotion(lua_State*); /// [-1, +0, -] /// Sets a callback function for mouse button events, overwriting the previous callback, if any. @@ -221,7 +221,7 @@ static int api_setcallbackmousemotion(lua_State*); /// The callback will be called with one param, that being a mouse-button object. All of the member /// functions of that object can be found in this file, prefixed with "api_mouseevent_" and /// "api_mousebutton_". -static int api_setcallbackmousebutton(lua_State*); +static int api_onmousebutton(lua_State*); /// [-1, +0, -] /// Sets a callback function for mouse button release events, overwriting the previous callback, if @@ -235,7 +235,7 @@ static int api_setcallbackmousebutton(lua_State*); /// The callback will be called with one param, that being a mouse-button object. All of the member /// functions of that object can be found in this file, prefixed with "api_mouseevent_" and /// "api_mousebutton_". -static int api_setcallbackmousebuttonup(lua_State*); +static int api_onmousebuttonup(lua_State*); /// [-1, +0, -] /// Sets a callback function for mouse scroll events, overwriting the previous callback, if any. @@ -248,7 +248,7 @@ static int api_setcallbackmousebuttonup(lua_State*); /// The callback will be called with one param, that being a mouse-scroll object. All of the member /// functions of that object can be found in this file, prefixed with "api_mouseevent_" and /// "api_scroll_". -static int api_setcallbackscroll(lua_State*); +static int api_onscroll(lua_State*); /// [-1, +1, -] /// Returns the number of vertices in a 2D batch object.