implement our own gui module, drop microui
This commit is contained in:
parent
2555bec8eb
commit
8baf5f06ea
25 changed files with 495 additions and 507 deletions
53
src/pxl8.c
53
src/pxl8.c
|
|
@ -16,7 +16,6 @@
|
|||
#include "pxl8_script.h"
|
||||
#include "pxl8_sys.h"
|
||||
#include "pxl8_types.h"
|
||||
#include "pxl8_ui.h"
|
||||
|
||||
struct pxl8 {
|
||||
pxl8_cart* cart;
|
||||
|
|
@ -127,12 +126,6 @@ pxl8_result pxl8_init(pxl8* sys, i32 argc, char* argv[]) {
|
|||
return PXL8_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
|
||||
game->ui = pxl8_ui_create(game->gfx);
|
||||
if (!game->ui) {
|
||||
pxl8_error("Failed to create UI");
|
||||
return PXL8_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
|
||||
game->script = pxl8_script_create();
|
||||
if (!game->script) {
|
||||
pxl8_error("Failed to initialize scripting: %s", pxl8_script_get_last_error(game->script));
|
||||
|
|
@ -170,7 +163,6 @@ pxl8_result pxl8_init(pxl8* sys, i32 argc, char* argv[]) {
|
|||
pxl8_script_set_gfx(game->script, game->gfx);
|
||||
pxl8_script_set_input(game->script, &game->input);
|
||||
pxl8_script_set_sys(game->script, sys);
|
||||
pxl8_script_set_ui(game->script, game->ui);
|
||||
|
||||
if (game->script_path[0] != '\0') {
|
||||
pxl8_result result = pxl8_script_load_main(game->script, game->script_path);
|
||||
|
|
@ -252,34 +244,6 @@ pxl8_result pxl8_update(pxl8* sys) {
|
|||
}
|
||||
}
|
||||
|
||||
if (game->ui) {
|
||||
pxl8_ui_input_mousemove(game->ui, game->input.mouse_x, game->input.mouse_y);
|
||||
|
||||
if (game->input.mouse_wheel_x != 0 || game->input.mouse_wheel_y != 0) {
|
||||
pxl8_ui_input_scroll(game->ui, game->input.mouse_wheel_x * 10, -game->input.mouse_wheel_y * 10);
|
||||
}
|
||||
|
||||
for (i32 i = 0; i < 3; i++) {
|
||||
if (game->input.mouse_buttons_pressed[i]) {
|
||||
pxl8_ui_input_mousedown(game->ui, game->input.mouse_x, game->input.mouse_y, i + 1);
|
||||
}
|
||||
if (game->input.mouse_buttons_released[i]) {
|
||||
pxl8_ui_input_mouseup(game->ui, game->input.mouse_x, game->input.mouse_y, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (i32 key = 0; key < 256; key++) {
|
||||
if (game->input.keys_pressed[key]) {
|
||||
pxl8_ui_input_keydown(game->ui, key);
|
||||
}
|
||||
if (!game->input.keys_down[key] && game->input.keys_pressed[key]) {
|
||||
pxl8_ui_input_keyup(game->ui, key);
|
||||
}
|
||||
}
|
||||
|
||||
pxl8_ui_frame_begin(game->ui);
|
||||
}
|
||||
|
||||
if (game->script_loaded) {
|
||||
pxl8_script_call_function_f32(game->script, "update", dt);
|
||||
}
|
||||
|
|
@ -315,10 +279,6 @@ pxl8_result pxl8_frame(pxl8* sys) {
|
|||
|
||||
pxl8_size render_size = pxl8_get_resolution_dimensions(game->resolution);
|
||||
|
||||
if (game->ui) {
|
||||
pxl8_ui_frame_end(game->ui);
|
||||
}
|
||||
|
||||
pxl8_gfx_set_viewport(game->gfx, pxl8_gfx_viewport(bounds, render_size.w, render_size.h));
|
||||
pxl8_gfx_upload_framebuffer(game->gfx);
|
||||
pxl8_gfx_upload_atlas(game->gfx);
|
||||
|
|
@ -332,8 +292,6 @@ pxl8_result pxl8_frame(pxl8* sys) {
|
|||
game->input.mouse_dy = 0;
|
||||
game->input.mouse_wheel_x = 0;
|
||||
game->input.mouse_wheel_y = 0;
|
||||
game->input.mouse_x = 0;
|
||||
game->input.mouse_y = 0;
|
||||
|
||||
game->frame_count++;
|
||||
|
||||
|
|
@ -360,7 +318,6 @@ void pxl8_quit(pxl8* sys) {
|
|||
|
||||
pxl8_gfx_destroy(game->gfx);
|
||||
pxl8_script_destroy(game->script);
|
||||
if (game->ui) pxl8_ui_destroy(game->ui);
|
||||
}
|
||||
|
||||
bool pxl8_is_running(const pxl8* sys) {
|
||||
|
|
@ -389,6 +346,16 @@ pxl8_resolution pxl8_get_resolution(const pxl8* sys) {
|
|||
return (sys && sys->game) ? sys->game->resolution : PXL8_RESOLUTION_640x360;
|
||||
}
|
||||
|
||||
void pxl8_center_cursor(pxl8* sys) {
|
||||
if (!sys || !sys->hal || !sys->hal->center_cursor) return;
|
||||
sys->hal->center_cursor(sys->platform_data);
|
||||
}
|
||||
|
||||
void pxl8_set_cursor(pxl8* sys, pxl8_cursor cursor) {
|
||||
if (!sys || !sys->hal || !sys->hal->set_cursor) return;
|
||||
sys->hal->set_cursor(sys->platform_data, cursor);
|
||||
}
|
||||
|
||||
void pxl8_set_relative_mouse_mode(pxl8* sys, bool enabled) {
|
||||
if (!sys || !sys->hal || !sys->hal->set_relative_mouse_mode) return;
|
||||
sys->hal->set_relative_mouse_mode(sys->platform_data, enabled);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue