diff --git a/armorforge/sources/tab_scene.ts b/armorforge/sources/tab_scene.ts index c44f88b0..ee157c95 100644 --- a/armorforge/sources/tab_scene.ts +++ b/armorforge/sources/tab_scene.ts @@ -56,16 +56,16 @@ function tab_scene_draw_list(ui: ui_t, list_handle: ui_handle_t, current_object: // Highlight every other line if (tab_scene_line_counter % 2 == 0) { - g2_set_color(ui.ops.theme.SEPARATOR_COL); + draw_set_color(ui.ops.theme.SEPARATOR_COL); g2_fill_rect(0, ui._y, ui._window_w, ui_ELEMENT_H(ui)); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); } // Highlight selected line if (current_object == context_raw.selected_object) { - g2_set_color(0xff205d9c); + draw_set_color(0xff205d9c); g2_fill_rect(0, ui._y, ui._window_w, ui_ELEMENT_H(ui)); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); } if (current_object.children.length > 0) { @@ -82,9 +82,9 @@ function tab_scene_draw_list(ui: ui_t, list_handle: ui_handle_t, current_object: ui._x += 18; // Sign offset // Draw line that shows parent relations - g2_set_color(ui.ops.theme.BUTTON_COL); + draw_set_color(ui.ops.theme.BUTTON_COL); g2_draw_line(ui._x - 10, ui._y + ui_ELEMENT_H(ui) / 2, ui._x, ui._y + ui_ELEMENT_H(ui) / 2); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); ui_text(current_object.name); ui._x -= 18; @@ -121,9 +121,9 @@ function tab_scene_draw_list(ui: ui_t, list_handle: ui_handle_t, current_object: } // Draw line that shows parent relations - g2_set_color(ui.ops.theme.BUTTON_COL); + draw_set_color(ui.ops.theme.BUTTON_COL); g2_draw_line(ui._x + 14, current_y, ui._x + 14, ui._y - ui_ELEMENT_H(ui) / 2); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); } } diff --git a/armorpaint/sources/layers_ext.ts b/armorpaint/sources/layers_ext.ts index 9acbce0f..a9876bb9 100644 --- a/armorpaint/sources/layers_ext.ts +++ b/armorpaint/sources/layers_ext.ts @@ -36,7 +36,7 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t if (l1masks.length > 1) { layers_make_temp_mask_img(); g2_begin(pipes_temp_mask_image); - g2_clear(0x00000000); + g4_clear(0x00000000); g2_end(); let l1: slot_layer_t = { texpaint: pipes_temp_mask_image }; for (let i: i32 = 0; i < l1masks.length; ++i) { diff --git a/armorpaint/sources/ui_header_ext.ts b/armorpaint/sources/ui_header_ext.ts index acd8c98c..553e410a 100644 --- a/armorpaint/sources/ui_header_ext.ts +++ b/armorpaint/sources/ui_header_ext.ts @@ -241,11 +241,11 @@ function ui_header_draw_tool_properties(ui: ui_t) { let progress: f32 = render_path_raytrace_bake_current_sample / context_raw.bake_samples; if (progress > 1.0) progress = 1.0; // Progress bar - g2_set_color(ui.ops.theme.SEPARATOR_COL); + draw_set_color(ui.ops.theme.SEPARATOR_COL); ui_draw_rect(true, ui._x + 1, ui._y, ui._w - 2, ui_ELEMENT_H(ui)); - g2_set_color(ui.ops.theme.HIGHLIGHT_COL); + draw_set_color(ui.ops.theme.HIGHLIGHT_COL); ui_draw_rect(true, ui._x + 1, ui._y, (ui._w - 2) * progress, ui_ELEMENT_H(ui)); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); ui_text(tr("Samples") + ": " + render_path_raytrace_bake_current_sample); ui_text(tr("Rays/pixel") + ": " + render_path_raytrace_bake_rays_pix); ui_text(tr("Rays/second") + ": " + render_path_raytrace_bake_rays_sec); diff --git a/base/sources/backends/android_system.c b/base/sources/backends/android_system.c index 1831a78b..385918c9 100644 --- a/base/sources/backends/android_system.c +++ b/base/sources/backends/android_system.c @@ -1202,7 +1202,7 @@ void android_main(struct android_app *application) { (*activity->vm)->DetachCurrentThread(activity->vm); } -void kinc_init(const char *name, int width, int height, struct kinc_window_options *win, struct kinc_framebuffer_options *frame) { +void kinc_init(const char *name, int width, int height, struct kinc_window_options *win) { kinc_mutex_init(&unicode_mutex); kinc_window_options_t default_win; @@ -1213,14 +1213,8 @@ void kinc_init(const char *name, int width, int height, struct kinc_window_optio win->width = width; win->height = height; - kinc_framebuffer_options_t default_frame; - if (frame == NULL) { - kinc_framebuffer_options_set_defaults(&default_frame); - frame = &default_frame; - } - kinc_g5_internal_init(); - kinc_g4_internal_init_window(frame->depth_bits, true); + kinc_g4_internal_init_window(win->depth_bits, true); kinc_internal_gamepad_trigger_connect(0); } @@ -1350,9 +1344,7 @@ void kinc_window_hide() {} void kinc_window_set_title(const char *title) {} -void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) { - -} +void kinc_window_create(kinc_window_options_t *win) {} void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { resizeCallback = callback; diff --git a/base/sources/backends/ios_system.m b/base/sources/backends/ios_system.m index 7f51a76a..ce45ec16 100644 --- a/base/sources/backends/ios_system.m +++ b/base/sources/backends/ios_system.m @@ -614,19 +614,14 @@ void KoreUpdateKeyboard(void) { void kinc_internal_shutdown(void) {} -void kinc_init(const char *name, int width, int height, struct kinc_window_options *win, struct kinc_framebuffer_options *frame) { +void kinc_init(const char *name, int width, int height, struct kinc_window_options *win) { kinc_window_options_t defaultWin; if (win == NULL) { kinc_window_options_set_defaults(&defaultWin); win = &defaultWin; } - kinc_framebuffer_options_t defaultFrame; - if (frame == NULL) { - kinc_framebuffer_options_set_defaults(&defaultFrame); - frame = &defaultFrame; - } kinc_g5_internal_init(); - kinc_g4_internal_init_window(frame->depth_bits, true); + kinc_g4_internal_init_window(win->depth_bits, true); } void endGL(void); @@ -732,9 +727,7 @@ void kinc_window_hide() {} void kinc_window_set_title(const char *title) {} -void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) { - -} +void kinc_window_create(kinc_window_options_t *win) {} void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { resizeCallback = callback; diff --git a/base/sources/backends/linux_system.c b/base/sources/backends/linux_system.c index b104316f..41ca2955 100644 --- a/base/sources/backends/linux_system.c +++ b/base/sources/backends/linux_system.c @@ -373,7 +373,7 @@ void kinc_window_set_title(const char *_title) { xlib.XFlush(x11_ctx.display); } -void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) { +void kinc_window_create(kinc_window_options_t *win) { struct kinc_x11_window *window = &x11_ctx.windows[0]; window->width = win->width; window->height = win->height; @@ -424,7 +424,7 @@ void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t * xlib.XSelectExtensionEvent(x11_ctx.display, window->window, &x11_ctx.eraser.motionClass, 1); } - kinc_g4_internal_init_window(frame->depth_bits, frame->vertical_sync); + kinc_g4_internal_init_window(win->depth_bits, win->vsync); } static struct { @@ -1434,7 +1434,7 @@ kinc_ticks_t kinc_timestamp(void) { return (kinc_ticks_t)now.tv_sec * 1000000 + (kinc_ticks_t)now.tv_usec; } -void kinc_init(const char *name, int width, int height, kinc_window_options_t *win, kinc_framebuffer_options_t *frame) { +void kinc_init(const char *name, int width, int height, kinc_window_options_t *win) { kinc_linux_initHIDGamepads(); gettimeofday(&start, NULL); @@ -1450,18 +1450,13 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w kinc_window_options_set_defaults(&defaultWin); win = &defaultWin; } - kinc_framebuffer_options_t defaultFrame; - if (frame == NULL) { - kinc_framebuffer_options_set_defaults(&defaultFrame); - frame = &defaultFrame; - } win->width = width; win->height = height; if (win->title == NULL) { win->title = name; } - kinc_window_create(win, frame); + kinc_window_create(win); } void kinc_internal_shutdown() { diff --git a/base/sources/backends/macos_system.m b/base/sources/backends/macos_system.m index e490aa4c..dbaf9587 100644 --- a/base/sources/backends/macos_system.m +++ b/base/sources/backends/macos_system.m @@ -1139,10 +1139,10 @@ static void createWindow(kinc_window_options_t *options) { int width = options->width / [[NSScreen mainScreen] backingScaleFactor]; int height = options->height / [[NSScreen mainScreen] backingScaleFactor]; int styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable; - if ((options->window_features & KINC_WINDOW_FEATURE_RESIZEABLE) || (options->window_features & KINC_WINDOW_FEATURE_MAXIMIZABLE)) { + if ((options->features & KINC_WINDOW_FEATURE_RESIZEABLE) || (options->features & KINC_WINDOW_FEATURE_MAXIMIZABLE)) { styleMask |= NSWindowStyleMaskResizable; } - if (options->window_features & KINC_WINDOW_FEATURE_MINIMIZABLE) { + if (options->features & KINC_WINDOW_FEATURE_MINIMIZABLE) { styleMask |= NSWindowStyleMaskMiniaturizable; } @@ -1205,7 +1205,7 @@ static void addMenubar(void) { [NSApp setMainMenu:menubar]; } -void kinc_init(const char *name, int width, int height, kinc_window_options_t *win, kinc_framebuffer_options_t *frame) { +void kinc_init(const char *name, int width, int height, kinc_window_options_t *win) { @autoreleasepool { myapp = [KincApplication sharedApplication]; [myapp finishLaunching]; @@ -1223,12 +1223,6 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w win = &defaultWindowOptions; } - kinc_framebuffer_options_t defaultFramebufferOptions; - if (frame == NULL) { - kinc_framebuffer_options_set_defaults(&defaultFramebufferOptions); - frame = &defaultFramebufferOptions; - } - win->width = width; win->height = height; if (win->title == NULL) { @@ -1237,7 +1231,7 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w createWindow(win); kinc_g5_internal_init(); - kinc_g4_internal_init_window(frame->depth_bits, true); + kinc_g4_internal_init_window(win->depth_bits, true); } int kinc_window_width() { @@ -1374,7 +1368,7 @@ void kinc_window_hide() {} void kinc_window_set_title(const char *title) {} -void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) { +void kinc_window_create(kinc_window_options_t *win) { } void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { diff --git a/base/sources/backends/wasm_system.c b/base/sources/backends/wasm_system.c index f8f5246c..e4b71de0 100644 --- a/base/sources/backends/wasm_system.c +++ b/base/sources/backends/wasm_system.c @@ -73,17 +73,12 @@ __attribute__((import_module("imports"), import_name("js_time"))) int js_time(); extern int kinc_internal_window_width; extern int kinc_internal_window_height; -void kinc_init(const char *name, int width, int height, kinc_window_options_t *win, kinc_framebuffer_options_t *frame) { +void kinc_init(const char *name, int width, int height, kinc_window_options_t *win) { kinc_window_options_t defaultWin; if (win == NULL) { kinc_window_options_set_defaults(&defaultWin); win = &defaultWin; } - kinc_framebuffer_options_t defaultFrame; - if (frame == NULL) { - kinc_framebuffer_options_set_defaults(&defaultFrame); - frame = &defaultFrame; - } win->width = width; win->height = height; @@ -91,7 +86,7 @@ void kinc_init(const char *name, int width, int height, kinc_window_options_t *w kinc_internal_window_height = height; kinc_g5_internal_init(); - kinc_g4_internal_init_window(frame->depth_bits, true); + kinc_g4_internal_init_window(win->depth_bits, true); } bool kinc_internal_handle_messages() { @@ -211,9 +206,7 @@ void kinc_window_hide() {} // TODO: change browser title. void kinc_window_set_title(const char *title) {} -void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) { - -} +void kinc_window_create(kinc_window_options_t *win) {} void kinc_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {} diff --git a/base/sources/backends/windows_system.c b/base/sources/backends/windows_system.c index 4bb8a51e..a9da8946 100644 --- a/base/sources/backends/windows_system.c +++ b/base/sources/backends/windows_system.c @@ -1671,7 +1671,7 @@ static void init_crash_handler() { } } -void kinc_init(const char *name, int width, int height, kinc_window_options_t *win, kinc_framebuffer_options_t *frame) { +void kinc_init(const char *name, int width, int height, kinc_window_options_t *win) { init_crash_handler(); // Pen functions are only in Windows 8 and later, so load them dynamically @@ -2082,20 +2082,14 @@ void kinc_window_set_title(const char *title) { SetWindowTextW(windows[0].handle, buffer); } -void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) { +void kinc_window_create(kinc_window_options_t *win) { kinc_window_options_t defaultWin; - kinc_framebuffer_options_t defaultFrame; if (win == NULL) { kinc_window_options_set_defaults(&defaultWin); win = &defaultWin; } - if (frame == NULL) { - kinc_framebuffer_options_set_defaults(&defaultFrame); - frame = &defaultFrame; - } - if (win->title == NULL) { win->title = ""; } @@ -2103,12 +2097,12 @@ void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t * wchar_t wbuffer[1024]; MultiByteToWideChar(CP_UTF8, 0, win->title, -1, wbuffer, 1024); - createWindow(wbuffer, win->x, win->y, win->width, win->height, frame->color_bits, frame->frequency, win->window_features, win->mode, + createWindow(wbuffer, win->x, win->y, win->width, win->height, win->color_bits, win->frequency, win->features, win->mode, win->display_index); - bool vsync = frame->vertical_sync; + bool vsync = win->vsync; - kinc_g4_internal_init_window(frame->depth_bits, vsync); + kinc_g4_internal_init_window(win->depth_bits, vsync); if (win->visible) { kinc_window_show(); diff --git a/base/sources/iron.h b/base/sources/iron.h index 2fa0f0ff..b7d51132 100644 --- a/base/sources/iron.h +++ b/base/sources/iron.h @@ -784,30 +784,18 @@ i32 color_set_ab(i32 c, u8 i) { return (i << 24) | (color_get_rb(c) << 16) | (color_get_gb(c) << 8) | color_get_bb(c); } -void iron_init(string_t *title, i32 width, i32 height, bool vsync, i32 window_mode, i32 window_features, i32 x, i32 y, i32 frequency, bool use_depth) { - kinc_window_options_t win; - kinc_framebuffer_options_t frame; - win.title = title; - win.width = width; - win.height = height; - frame.vertical_sync = vsync; - win.mode = (kinc_window_mode_t)window_mode; - win.window_features = window_features; - win.x = x; - win.y = y; - frame.frequency = frequency; - - win.display_index = -1; - win.visible = enable_window; - frame.color_bits = 32; - frame.depth_bits = use_depth ? 24 : 0; - kinc_init(title, win.width, win.height, &win, &frame); +void iron_init(kinc_window_options_t *ops) { + ops->display_index = -1; + ops->visible = enable_window; + ops->color_bits = 32; + ops->depth_bits = ops->use_depth ? 24 : 0; + kinc_init(ops->title, ops->width, ops->height, ops); kinc_random_init((int)(kinc_time() * 1000)); #ifdef KINC_WINDOWS // Maximized window has x < -1, prevent window centering done by kinc - if (win.x < -1 && win.y < -1) { - kinc_window_move(win.x, win.y); + if (ops->x < -1 && ops->y < -1) { + kinc_window_move(ops->x, ops->y); } #endif diff --git a/base/sources/iron_draw.c b/base/sources/iron_draw.c index b61b6f2a..cc661d54 100644 --- a/base/sources/iron_draw.c +++ b/base/sources/iron_draw.c @@ -946,7 +946,7 @@ void draw_font_default_glyphs() { draw_font_glyph_blocks[1] = 126; } -void _draw_font_init(draw_font_t *font, void *blob, int font_index) { +void draw_font_init(draw_font_t *font, void *blob, int font_index) { if (draw_font_glyphs == NULL) { draw_font_default_glyphs(); } @@ -961,13 +961,7 @@ void _draw_font_init(draw_font_t *font, void *blob, int font_index) { } } -draw_font_t *draw_font_init(buffer_t *blob, int font_index) { - draw_font_t *font = (draw_font_t *)malloc(sizeof(draw_font_t)); - _draw_font_init(font, blob->buffer, font_index); - return font; -} - -void _draw_font_13(draw_font_t *font, void *blob) { +void draw_font_13(draw_font_t *font, void *blob) { if (draw_font_glyphs == NULL) { draw_font_default_glyphs(); } @@ -1004,12 +998,6 @@ void _draw_font_13(draw_font_t *font, void *blob) { img->chars = baked; } -draw_font_t *draw_font_13(buffer_t *blob) { - draw_font_t *font = (draw_font_t *)malloc(sizeof(draw_font_t)); - _draw_font_13(font, blob->buffer); - return font; -} - bool draw_font_has_glyph(int glyph) { for (int i = 0; i < draw_font_num_glyphs; ++i) { if (draw_font_glyphs[i] == glyph) { diff --git a/base/sources/iron_draw.h b/base/sources/iron_draw.h index f33f7079..c45179b2 100644 --- a/base/sources/iron_draw.h +++ b/base/sources/iron_draw.h @@ -30,14 +30,11 @@ typedef struct draw_font { size_t m_capacity; size_t m_images_len; int offset; -} draw_font_t; -typedef struct g2_font { - draw_font_t *font_; - void *blob; // buffer_t + buffer_t *buf; void *glyphs; // i32_array_t int index; -} g2_font_t; +} draw_font_t; void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *colored_vert, buffer_t *colored_frag, buffer_t *text_vert, buffer_t *text_frag); void draw_begin(void); @@ -65,8 +62,8 @@ uint32_t draw_get_color(); void draw_set_pipeline(kinc_g5_pipeline_t *pipeline); void draw_set_transform(buffer_t *matrix); bool draw_set_font(draw_font_t *font, int size); -draw_font_t *draw_font_init(buffer_t *blob, int font_index); -draw_font_t *draw_font_13(buffer_t *blob); +void draw_font_init(draw_font_t *font, void *blob, int font_index); +void draw_font_13(draw_font_t *font, void *blob); bool draw_font_has_glyph(int glyph); void draw_font_set_glyphs(i32_array_t *glyphs); void draw_font_add_glyph(int glyph); diff --git a/base/sources/iron_system.c b/base/sources/iron_system.c index 52313b5d..2c730801 100644 --- a/base/sources/iron_system.c +++ b/base/sources/iron_system.c @@ -87,14 +87,12 @@ void kinc_window_options_set_defaults(kinc_window_options_t *win) { win->width = 800; win->height = 600; win->visible = true; - win->window_features = KINC_WINDOW_FEATURE_RESIZEABLE | KINC_WINDOW_FEATURE_MINIMIZABLE | KINC_WINDOW_FEATURE_MAXIMIZABLE; -} + win->features = KINC_WINDOW_FEATURE_RESIZEABLE | KINC_WINDOW_FEATURE_MINIMIZABLE | KINC_WINDOW_FEATURE_MAXIMIZABLE; -void kinc_framebuffer_options_set_defaults(kinc_framebuffer_options_t *frame) { - frame->frequency = 60; - frame->vertical_sync = true; - frame->color_bits = 32; - frame->depth_bits = 16; + win->frequency = 60; + win->vsync = true; + win->color_bits = 32; + win->depth_bits = 16; } #if !defined(KINC_WASM) && !defined(KINC_ANDROID) && !defined(KINC_WINDOWS) diff --git a/base/sources/iron_system.h b/base/sources/iron_system.h index 6d3e6784..87bb0b6e 100644 --- a/base/sources/iron_system.h +++ b/base/sources/iron_system.h @@ -28,13 +28,6 @@ kinc_display_mode_t kinc_display_current_mode(int display_index); int kinc_display_count_available_modes(int display_index); kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_index); -typedef struct kinc_framebuffer_options { - int frequency; - bool vertical_sync; - int color_bits; - int depth_bits; -} kinc_framebuffer_options_t; - typedef enum { KINC_WINDOW_MODE_WINDOW, KINC_WINDOW_MODE_FULLSCREEN @@ -52,16 +45,23 @@ typedef struct kinc_window_options { int y; int width; int height; + int features; + kinc_window_mode_t mode; + int frequency; + bool vsync; + + bool use_depth; + int display_index; bool visible; - int window_features; - kinc_window_mode_t mode; + int color_bits; + int depth_bits; + } kinc_window_options_t; -void kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame); +void kinc_window_create(kinc_window_options_t *win); void kinc_window_destroy(); void kinc_window_options_set_defaults(kinc_window_options_t *win); -void kinc_framebuffer_options_set_defaults(kinc_framebuffer_options_t *frame); void kinc_window_resize(int width, int height); void kinc_window_move(int x, int y); void kinc_window_change_mode(kinc_window_mode_t mode); @@ -82,9 +82,8 @@ void kinc_internal_call_resize_callback(int width, int height); bool kinc_internal_call_close_callback(); struct kinc_window_options; -struct kinc_framebuffer_options; -void kinc_init(const char *name, int width, int height, struct kinc_window_options *win, struct kinc_framebuffer_options *frame); +void kinc_init(const char *name, int width, int height, struct kinc_window_options *win); const char *kinc_application_name(void); void kinc_set_app_name(const char *name); int kinc_width(void); diff --git a/base/sources/iron_ui.c b/base/sources/iron_ui.c index 37df1774..720979e7 100644 --- a/base/sources/iron_ui.c +++ b/base/sources/iron_ui.c @@ -314,13 +314,13 @@ void ui_draw_string(char *text, float x_offset, float y_offset, int align, bool char *full_text = text; strcpy(truncated, text); text = &truncated[0]; - while (strlen(text) > 0 && draw_string_width(current->ops->font->font_, current->font_size, text) > current->_w - 6.0 * UI_SCALE()) { + while (strlen(text) > 0 && draw_string_width(current->ops->font, current->font_size, text) > current->_w - 6.0 * UI_SCALE()) { text[strlen(text) - 1] = 0; } if (strlen(text) < strlen(full_text)) { strcat(text, ".."); // Strip more to fit ".." - while (strlen(text) > 2 && draw_string_width(current->ops->font->font_, current->font_size, text) > current->_w - 10.0 * UI_SCALE()) { + while (strlen(text) > 2 && draw_string_width(current->ops->font, current->font_size, text) > current->_w - 10.0 * UI_SCALE()) { text[strlen(text) - 3] = 0; strcat(text, ".."); } @@ -344,12 +344,12 @@ void ui_draw_string(char *text, float x_offset, float y_offset, int align, bool x_offset = theme->TEXT_OFFSET; } x_offset *= UI_SCALE(); - draw_set_font(current->ops->font->font_, current->font_size); + draw_set_font(current->ops->font, current->font_size); if (align == UI_ALIGN_CENTER) { - x_offset = current->_w / 2.0 - draw_string_width(current->ops->font->font_, current->font_size, text) / 2.0; + x_offset = current->_w / 2.0 - draw_string_width(current->ops->font, current->font_size, text) / 2.0; } else if (align == UI_ALIGN_RIGHT) { - x_offset = current->_w - draw_string_width(current->ops->font->font_, current->font_size, text) - UI_TEXT_OFFSET(); + x_offset = current->_w - draw_string_width(current->ops->font, current->font_size, text) - UI_TEXT_OFFSET(); } if (!current->enabled) { @@ -576,14 +576,14 @@ void ui_draw_tooltip_text(bool bind_global_g) { int line_count = ui_line_count(current->tooltip_text); float tooltip_w = 0.0; for (int i = 0; i < line_count; ++i) { - float line_tooltip_w = draw_string_width(current->ops->font->font_, current->font_size, ui_extract_line(current->tooltip_text, i)); + float line_tooltip_w = draw_string_width(current->ops->font, current->font_size, ui_extract_line(current->tooltip_text, i)); if (line_tooltip_w > tooltip_w) { tooltip_w = line_tooltip_w; } } current->tooltip_x = fmin(current->tooltip_x, kinc_window_width() - tooltip_w - 20); if (bind_global_g) draw_restore_render_target(); - float font_height = draw_font_height(current->ops->font->font_, current->font_size); + float font_height = draw_font_height(current->ops->font, current->font_size); float off = 0; if (current->tooltip_img != NULL) { float w = current->tooltip_img->width; @@ -608,7 +608,7 @@ void ui_draw_tooltip_text(bool bind_global_g) { draw_set_color(theme->SEPARATOR_COL); draw_filled_rect(x, y, w, h); - draw_set_font(current->ops->font->font_, current->font_size); + draw_set_font(current->ops->font, current->font_size); draw_set_color(theme->TEXT_COL); for (int i = 0; i < line_count; ++i) { draw_string(ui_extract_line(current->tooltip_text, i), current->tooltip_x + 5, current->tooltip_y + off + i * current->font_size); @@ -659,12 +659,12 @@ void ui_draw_tooltip(bool bind_global_g) { if (bind_global_g) { draw_restore_render_target(); } - draw_set_font(current->ops->font->font_, current->font_size * 2); + draw_set_font(current->ops->font, current->font_size * 2); sprintf(temp, "%f", round(current->scroll_handle->value * 100.0) / 100.0); string_strip_trailing_zeros(temp); char *text = temp; - float x_off = draw_string_width(current->ops->font->font_, current->font_size * 2.0, text) / 2.0; - float y_off = draw_font_height(current->ops->font->font_, current->font_size * 2.0); + float x_off = draw_string_width(current->ops->font, current->font_size * 2.0, text) / 2.0; + float y_off = draw_font_height(current->ops->font, current->font_size * 2.0); float x = fmin(fmax(current->slider_tooltip_x, current->input_x), current->slider_tooltip_x + current->slider_tooltip_w); draw_set_color(theme->BUTTON_COL); draw_filled_rect(x - x_off, current->slider_tooltip_y - y_off, x_off * 2.0, y_off); @@ -675,9 +675,9 @@ void ui_draw_tooltip(bool bind_global_g) { if (bind_global_g) { draw_restore_render_target(); } - draw_set_font(current->ops->font->font_, current->font_size * 2.0); - float x_off = draw_string_width(current->ops->font->font_, current->font_size * 2.0, current->text_selected) / 2.0; - float y_off = draw_font_height(current->ops->font->font_, current->font_size * 2.0) / 2.0; + draw_set_font(current->ops->font, current->font_size * 2.0); + float x_off = draw_string_width(current->ops->font, current->font_size * 2.0, current->text_selected) / 2.0; + float y_off = draw_font_height(current->ops->font, current->font_size * 2.0) / 2.0; float x = kinc_window_width() / 2.0; float y = kinc_window_height() / 3.0; draw_set_color(theme->BUTTON_COL); @@ -985,10 +985,10 @@ void ui_end_region(bool last) { } void ui_set_cursor_to_input(int align) { - float off = align == UI_ALIGN_LEFT ? UI_TEXT_OFFSET() : current->_w - draw_string_width(current->ops->font->font_, current->font_size, current->text_selected); + float off = align == UI_ALIGN_LEFT ? UI_TEXT_OFFSET() : current->_w - draw_string_width(current->ops->font, current->font_size, current->text_selected); float x = current->input_x - (current->_window_x + current->_x + off); current->cursor_x = 0; - while (current->cursor_x < strlen(current->text_selected) && draw_sub_string_width(current->ops->font->font_, current->font_size, current->text_selected, 0, current->cursor_x) < x) { + while (current->cursor_x < strlen(current->text_selected) && draw_sub_string_width(current->ops->font, current->font_size, current->text_selected, 0, current->cursor_x) < x) { current->cursor_x++; } current->highlight_anchor = current->cursor_x; @@ -1201,11 +1201,11 @@ void ui_update_text_edit(int align, bool editable, bool live_update) { iend = current->cursor_x; } - float hlstrw = draw_sub_string_width(current->ops->font->font_, current->font_size, text, istart, iend); - float start_off = draw_sub_string_width(current->ops->font->font_, current->font_size, text, 0, istart); + float hlstrw = draw_sub_string_width(current->ops->font, current->font_size, text, istart, iend); + float start_off = draw_sub_string_width(current->ops->font, current->font_size, text, 0, istart); float hl_start = align == UI_ALIGN_LEFT ? current->_x + start_off + off : current->_x + current->_w - hlstrw - off; if (align == UI_ALIGN_RIGHT) { - hl_start -= draw_sub_string_width(current->ops->font->font_, current->font_size, text, iend, strlen(text)); + hl_start -= draw_sub_string_width(current->ops->font, current->font_size, text, iend, strlen(text)); } draw_set_color(theme->ACCENT_COL); draw_filled_rect(hl_start, current->_y + current->button_offset_y * 1.5, hlstrw, cursor_height); @@ -1214,7 +1214,7 @@ void ui_update_text_edit(int align, bool editable, bool live_update) { // Draw cursor int str_start = align == UI_ALIGN_LEFT ? 0 : current->cursor_x; int str_length = align == UI_ALIGN_LEFT ? current->cursor_x : (strlen(text) - current->cursor_x); - float strw = draw_sub_string_width(current->ops->font->font_, current->font_size, text, str_start, str_length); + float strw = draw_sub_string_width(current->ops->font, current->font_size, text, str_start, str_length); float cursor_x = align == UI_ALIGN_LEFT ? current->_x + strw + off : current->_x + current->_w - strw - off; draw_set_color(theme->TEXT_COL); // Cursor draw_filled_rect(cursor_x, current->_y + current->button_offset_y * 1.5, 1.0 * UI_SCALE(), cursor_height); @@ -1289,7 +1289,7 @@ void ui_draw_tabs() { current->_y = base_y + tab_y; current->_w = current->tab_vertical ? (UI_ELEMENT_W() - 1 * UI_SCALE()) : theme->FULL_TABS ? (current->_window_w / current->tab_count) : - (draw_string_width(current->ops->font->font_, current->font_size, current->tab_names[i]) + current->button_offset_y * 2.0 + 18.0 * UI_SCALE()); + (draw_string_width(current->ops->font, current->font_size, current->tab_names[i]) + current->button_offset_y * 2.0 + 18.0 * UI_SCALE()); bool released = ui_get_released(tab_h); bool started = ui_get_started(tab_h); bool pushed = ui_get_pushed(tab_h); @@ -1467,7 +1467,7 @@ void ui_draw_slider(float value, float from, float to, bool filled, bool hover) void ui_set_scale(float factor) { current->ops->scale_factor = factor; current->font_size = UI_FONT_SIZE(); - float font_height = draw_font_height(current->ops->font->font_, current->font_size); + float font_height = draw_font_height(current->ops->font, current->font_size); current->font_offset_y = (UI_ELEMENT_H() - font_height) / 2.0; // Precalculate offsets current->arrow_offset_y = (UI_ELEMENT_H() - UI_ARROW_SIZE()) / 2.0; current->arrow_offset_x = current->arrow_offset_y; @@ -1797,7 +1797,7 @@ int ui_text(char *text, int align, int bg) { ui_split_text(text, align, bg); return UI_STATE_IDLE; } - float h = fmax(UI_ELEMENT_H(), draw_font_height(current->ops->font->font_, current->font_size)); + float h = fmax(UI_ELEMENT_H(), draw_font_height(current->ops->font, current->font_size)); if (!ui_is_visible(h)) { ui_end_element_of_size(h + UI_ELEMENT_OFFSET()); return UI_STATE_IDLE; @@ -2112,7 +2112,7 @@ int ui_combo(ui_handle_t *handle, char_ptr_array_t *texts, char *label, bool sho current->combo_selected_w = current->_w; current->combo_search_bar = search_bar; for (int i = 0; i < texts->length; ++i) { // Adapt combo list width to combo item width - int w = (int)draw_string_width(current->ops->font->font_, current->font_size, texts->buffer[i]) + 10; + int w = (int)draw_string_width(current->ops->font, current->font_size, texts->buffer[i]) + 10; if (current->combo_selected_w < w) { current->combo_selected_w = w; } @@ -3141,9 +3141,9 @@ char *ui_text_area(ui_handle_t *handle, int align, bool editable, char *label, b new_lines[0] = '\0'; for (int i = 0; i < word_count; ++i) { char *w = ui_extract_word(lines, i); - float spacew = draw_string_width(current->ops->font->font_, current->font_size, " "); - float wordw = spacew + draw_string_width(current->ops->font->font_, current->font_size, w); - float linew = wordw + draw_string_width(current->ops->font->font_, current->font_size, line); + float spacew = draw_string_width(current->ops->font, current->font_size, " "); + float wordw = spacew + draw_string_width(current->ops->font, current->font_size, w); + float linew = wordw + draw_string_width(current->ops->font, current->font_size, line); if (linew > current->_w - 10 && linew > wordw) { if (new_lines[0] != '\0') { strcat(new_lines, "\n"); @@ -3243,7 +3243,7 @@ char *ui_text_area(ui_handle_t *handle, int align, bool editable, char *label, b (i <= text_area_selection_start && i > handle->position)) { int line_height = UI_ELEMENT_H(); int cursor_height = line_height - current->button_offset_y * 3.0; - int linew = draw_string_width(current->ops->font->font_, current->font_size, line); + int linew = draw_string_width(current->ops->font, current->font_size, line); draw_set_color(current->ops->theme->ACCENT_COL); draw_filled_rect(current->_x + UI_ELEMENT_OFFSET() * 2.0, current->_y + current->button_offset_y * 1.5, linew, cursor_height); } @@ -3318,6 +3318,6 @@ void ui_end_menu() { bool _ui_menu_button(char *text) { ui_t *current = ui_get_current(); - current->_w = draw_string_width(current->ops->font->font_, current->font_size, text) + 25.0 * UI_SCALE(); + current->_w = draw_string_width(current->ops->font, current->font_size, text) + 25.0 * UI_SCALE(); return ui_button(text, UI_ALIGN_CENTER, ""); } diff --git a/base/sources/iron_ui.h b/base/sources/iron_ui.h index 4b43a087..158eb647 100644 --- a/base/sources/iron_ui.h +++ b/base/sources/iron_ui.h @@ -53,7 +53,7 @@ typedef struct ui_theme { } ui_theme_t; typedef struct ui_options { - g2_font_t *font; + draw_font_t *font; ui_theme_t *theme; float scale_factor; kinc_g5_texture_t *color_wheel; diff --git a/base/sources/iron_ui_nodes.c b/base/sources/iron_ui_nodes.c index cd2a67a6..93816b74 100644 --- a/base/sources/iron_ui_nodes.c +++ b/base/sources/iron_ui_nodes.c @@ -443,7 +443,7 @@ void ui_draw_node(ui_node_t *node, ui_node_canvas_t *canvas) { // Title draw_set_color(current->ops->theme->TEXT_COL); - float textw = draw_string_width(current->ops->font->font_, current->font_size, text); + float textw = draw_string_width(current->ops->font, current->font_size, text); draw_string(text, nx + ui_p(10), ny + ui_p(6)); ny += lineh * 0.5; @@ -459,7 +459,7 @@ void ui_draw_node(ui_node_t *node, ui_node_canvas_t *canvas) { for (int i = 0; i < node->outputs->length; ++i) { ui_node_socket_t *out = node->outputs->buffer[i]; ny += lineh; - float strw = draw_string_width(current->ops->font->font_, current->font_size, ui_tr(out->name)); + float strw = draw_string_width(current->ops->font, current->font_size, ui_tr(out->name)); draw_string(ui_tr(out->name), nx + w - strw - ui_p(12), ny - ui_p(3)); if (ui_nodes_on_socket_released != NULL && current->input_enabled && (current->input_released || current->input_released_r)) { @@ -804,7 +804,7 @@ void ui_node_canvas(ui_nodes_t *nodes, ui_node_canvas_t *canvas) { current_nodes->ELEMENT_H = current->ops->theme->ELEMENT_H + 2; ui_set_scale(UI_NODES_SCALE()); // Apply zoomed scale current->elements_baked = true; - draw_set_font(current->ops->font->font_, current->font_size); + draw_set_font(current->ops->font, current->font_size); for (int i = 0; i < canvas->links->length; ++i) { ui_node_link_t *link = canvas->links->buffer[i]; diff --git a/base/sources/ts/args.ts b/base/sources/ts/args.ts index 0d127fa2..2f6fba13 100644 --- a/base/sources/ts/args.ts +++ b/base/sources/ts/args.ts @@ -153,7 +153,7 @@ function args_run() { } if (args_background) { - sys_stop(); + kinc_stop(); } }); } diff --git a/base/sources/ts/base.ts b/base/sources/ts/base.ts index 16b42a86..0e1a38a4 100644 --- a/base/sources/ts/base.ts +++ b/base/sources/ts/base.ts @@ -14,7 +14,7 @@ let base_drag_off_y: f32 = 0.0; let base_drag_start: f32 = 0.0; let base_drop_x: f32 = 0.0; let base_drop_y: f32 = 0.0; -let base_font: g2_font_t = null; +let base_font: draw_font_t = null; let base_theme: ui_theme_t; let base_color_wheel: image_t; let base_color_wheel_gradient: image_t; @@ -36,8 +36,8 @@ let base_default_fov: f32 = 0.69; let _base_material_count: i32; function base_init() { - base_last_window_width = sys_width(); - base_last_window_height = sys_height(); + base_last_window_width = kinc_window_width(); + base_last_window_height = kinc_window_height(); sys_notify_on_drop_files(function (drop_path: string) { ///if arm_linux @@ -69,7 +69,7 @@ function base_init() { iron_set_save_and_quit_callback(base_save_and_quit_callback); - let font: g2_font_t = data_get_font("font.ttf"); + let font: draw_font_t = data_get_font("font.ttf"); let image_color_wheel: image_t = data_get_image("color_wheel.k"); let image_color_wheel_gradient: image_t = data_get_image("color_wheel_gradient.k"); @@ -86,7 +86,7 @@ function base_init() { // Baked font for fast startup if (config_raw.locale == "en") { - base_font.font_ = draw_font_13(base_font.blob); + draw_font_13(base_font, base_font.buf.buffer); base_font.glyphs = _g2_font_glyphs; } else { @@ -156,7 +156,7 @@ function base_save_and_quit_callback(save: bool) { project_save(true); } else { - sys_stop(); + kinc_stop(); } } @@ -174,16 +174,16 @@ function base_w(): i32 { let res: i32 = 0; if (config_raw.layout == null) { let sidebarw: i32 = ui_base_default_sidebar_w; - res = sys_width() - sidebarw - ui_toolbar_default_w; + res = kinc_window_width() - sidebarw - ui_toolbar_default_w; } else if (ui_nodes_show || ui_view2d_show) { - res = sys_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - config_raw.layout[layout_size_t.NODES_W] - ui_toolbar_w; + res = kinc_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - config_raw.layout[layout_size_t.NODES_W] - ui_toolbar_w; } else if (ui_base_show) { - res = sys_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - ui_toolbar_w; + res = kinc_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - ui_toolbar_w; } else { // Distract free - res = sys_width(); + res = kinc_window_width(); } if (context_raw.view_index > -1) { res = math_floor(res / 2); @@ -206,7 +206,7 @@ function base_h(): i32 { return util_render_decal_preview_size; } - let res: i32 = sys_height(); + let res: i32 = kinc_window_height(); if (config_raw.layout == null) { res -= ui_header_default_h * 2 + ui_status_default_status_h; @@ -235,33 +235,33 @@ function base_y(): i32 { } function base_on_resize() { - if (sys_width() == 0 || sys_height() == 0) { + if (kinc_window_width() == 0 || kinc_window_height() == 0) { return; } - let ratio_w: f32 = sys_width() / base_last_window_width; - base_last_window_width = sys_width(); - let ratio_h: f32 = sys_height() / base_last_window_height; - base_last_window_height = sys_height(); + let ratio_w: f32 = kinc_window_width() / base_last_window_width; + base_last_window_width = kinc_window_width(); + let ratio_h: f32 = kinc_window_height() / base_last_window_height; + base_last_window_height = kinc_window_height(); config_raw.layout[layout_size_t.NODES_W] = math_floor(config_raw.layout[layout_size_t.NODES_W] * ratio_w); config_raw.layout[layout_size_t.SIDEBAR_H0] = math_floor(config_raw.layout[layout_size_t.SIDEBAR_H0] * ratio_h); - config_raw.layout[layout_size_t.SIDEBAR_H1] = sys_height() - config_raw.layout[layout_size_t.SIDEBAR_H0]; + config_raw.layout[layout_size_t.SIDEBAR_H1] = kinc_window_height() - config_raw.layout[layout_size_t.SIDEBAR_H0]; base_resize(); base_save_window_rect(); } function base_save_window_rect() { - config_raw.window_w = sys_width(); - config_raw.window_h = sys_height(); - config_raw.window_x = sys_x(); - config_raw.window_y = sys_y(); + config_raw.window_w = kinc_window_width(); + config_raw.window_h = kinc_window_height(); + config_raw.window_x = kinc_window_x(); + config_raw.window_y = kinc_window_y(); config_save(); } function base_resize() { - if (sys_width() == 0 || sys_height() == 0) { + if (kinc_window_width() == 0 || kinc_window_height() == 0) { return; } @@ -556,7 +556,7 @@ function base_get_drag_image(): image_t { } function base_render() { - if (sys_width() == 0 || sys_height() == 0) { + if (kinc_window_width() == 0 || kinc_window_height() == 0) { return; } @@ -592,7 +592,7 @@ function base_render() { let h: f32 = img.height * ratio; let inv: i32 = 0; - g2_set_color(base_drag_tint); + draw_set_color(base_drag_tint); let bg_rect: rect_t = base_get_drag_background(); if (bg_rect != null) { @@ -602,7 +602,7 @@ function base_render() { base_drag_rect == null ? draw_scaled_image(img, mouse_x + base_drag_off_x, mouse_y + base_drag_off_y + inv, size, h - inv * 2) : draw_scaled_sub_image(img, base_drag_rect.x, base_drag_rect.y, base_drag_rect.w, base_drag_rect.h, mouse_x + base_drag_off_x, mouse_y + base_drag_off_y + inv, size, h - inv * 2); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); } let using_menu: bool = ui_menu_show && mouse_y > ui_header_h; @@ -675,17 +675,17 @@ function base_get_asset_index(file_name: string): i32 { } function base_toggle_fullscreen() { - if (sys_mode() == window_mode_t.WINDOWED) { - config_raw.window_w = sys_width(); - config_raw.window_h = sys_height(); - config_raw.window_x = sys_x(); - config_raw.window_y = sys_y(); - sys_mode_set(window_mode_t.FULLSCREEN); + if (kinc_window_get_mode() == window_mode_t.WINDOWED) { + config_raw.window_w = kinc_window_width(); + config_raw.window_h = kinc_window_height(); + config_raw.window_x = kinc_window_x(); + config_raw.window_y = kinc_window_y(); + iron_set_window_mode(window_mode_t.FULLSCREEN); } else { - sys_mode_set(window_mode_t.WINDOWED); - sys_resize(config_raw.window_w, config_raw.window_h); - sys_move(config_raw.window_x, config_raw.window_y); + iron_set_window_mode(window_mode_t.WINDOWED); + kinc_window_resize(config_raw.window_w, config_raw.window_h); + kinc_window_move(config_raw.window_x, config_raw.window_y); } } @@ -752,8 +752,8 @@ function base_init_layout() { let new_layout: i32[] = []; array_push(new_layout, math_floor(ui_base_default_sidebar_w * raw.window_scale)); // LayoutSidebarW - array_push(new_layout, math_floor(sys_height() / 2)); // LayoutSidebarH0 - array_push(new_layout, math_floor(sys_height() / 2)); // LayoutSidebarH1 + array_push(new_layout, math_floor(kinc_window_height() / 2)); // LayoutSidebarH0 + array_push(new_layout, math_floor(kinc_window_height() / 2)); // LayoutSidebarH1 ///if arm_ios array_push(new_layout, show2d ? math_floor((app_w() + raw.layout[layout_size_t.NODES_W]) * 0.473) : math_floor(app_w() * 0.473)); // LayoutNodesW diff --git a/base/sources/ts/box_projects.ts b/base/sources/ts/box_projects.ts index cb47b59d..7e1419c0 100644 --- a/base/sources/ts/box_projects.ts +++ b/base/sources/ts/box_projects.ts @@ -69,7 +69,7 @@ function box_projects_tab(ui: ui_t) { ui_separator(3, false); let slotw: i32 = math_floor(150 * ui_SCALE(ui)); - let num: i32 = math_floor(sys_width() / slotw); + let num: i32 = math_floor(kinc_window_width() / slotw); if (num == 0) { return; } @@ -261,10 +261,10 @@ function box_projects_get_started_tab(ui: ui_t) { } function box_projects_align_to_fullscreen() { - ui_box_modalw = math_floor(sys_width() / ui_SCALE(base_ui_box)); - ui_box_modalh = math_floor(sys_height() / ui_SCALE(base_ui_box)); - let appw: i32 = sys_width(); - let apph: i32 = sys_height(); + ui_box_modalw = math_floor(kinc_window_width() / ui_SCALE(base_ui_box)); + ui_box_modalh = math_floor(kinc_window_height() / ui_SCALE(base_ui_box)); + let appw: i32 = kinc_window_width(); + let apph: i32 = kinc_window_height(); let mw: i32 = appw; let mh: i32 = apph; ui_box_hwnd.drag_x = math_floor(-appw / 2 + mw / 2); diff --git a/base/sources/ts/config.ts b/base/sources/ts/config.ts index 34cb863e..a3f2c5e8 100644 --- a/base/sources/ts/config.ts +++ b/base/sources/ts/config.ts @@ -191,27 +191,27 @@ function config_get_date(): string { return v.date; } -function config_get_options(): kinc_sys_ops_t { +function config_get_options(): kinc_window_options_t { let window_mode: window_mode_t = config_raw.window_mode == 0 ? window_mode_t.WINDOWED : window_mode_t.FULLSCREEN; - let window_features: window_features_t = window_features_t.NONE; + let features: window_features_t = window_features_t.NONE; if (config_raw.window_resizable) { - window_features |= window_features_t.RESIZABLE; + features |= window_features_t.RESIZABLE; } if (config_raw.window_maximizable) { - window_features |= window_features_t.MAXIMIZABLE; + features |= window_features_t.MAXIMIZABLE; } if (config_raw.window_minimizable) { - window_features |= window_features_t.MINIMIZABLE; + features |= window_features_t.MINIMIZABLE; } let title: string = "untitled - " + manifest_title; - let ops: kinc_sys_ops_t = { + let ops: kinc_window_options_t = { title: title, width: config_raw.window_w, height: config_raw.window_h, x: config_raw.window_x, y: config_raw.window_y, mode: window_mode, - features: window_features, + features: features, vsync: config_raw.window_vsync, frequency: config_raw.window_frequency, use_depth: false diff --git a/base/sources/ts/console.ts b/base/sources/ts/console.ts index 8166d2b7..79cf8ad8 100644 --- a/base/sources/ts/console.ts +++ b/base/sources/ts/console.ts @@ -6,15 +6,15 @@ let console_last_traces: string[] = [""]; let console_progress_text: string = null; function console_draw_toast(s: string) { - g2_set_color(0x55000000); - draw_filled_rect(0, 0, sys_width(), sys_height()); + draw_set_color(0x55000000); + draw_filled_rect(0, 0, kinc_window_width(), kinc_window_height()); let scale: f32 = ui_SCALE(base_get_uis()[0]); - let x: f32 = sys_width() / 2; - let y: f32 = sys_height() - 200 * scale; + let x: f32 = kinc_window_width() / 2; + let y: f32 = kinc_window_height() - 200 * scale; draw_filled_rect(x - 200 * scale, y, 400 * scale, 80 * scale); g2_set_font(base_font); g2_set_font_size(math_floor(22 * scale)); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); draw_string(s, x - g2_font_width(_g2_font, _g2_font_size, s) / 2, y + 40 * scale - g2_font_height(_g2_font, _g2_font_size) / 2); } diff --git a/base/sources/ts/export_texture.ts b/base/sources/ts/export_texture.ts index 614e7cd0..fe44a5bf 100644 --- a/base/sources/ts/export_texture.ts +++ b/base/sources/ts/export_texture.ts @@ -226,7 +226,7 @@ function export_texture_run_layers(path: string, layers: slot_layer_t[], object_ if (l1masks.length > 1) { layers_make_temp_mask_img(); g2_begin(pipes_temp_mask_image); - g2_clear(0x00000000); + g4_clear(0x00000000); g2_end(); let l1: slot_layer_t = { texpaint: pipes_temp_mask_image diff --git a/base/sources/ts/import_font.ts b/base/sources/ts/import_font.ts index 488c27ea..0ae8fc6e 100644 --- a/base/sources/ts/import_font.ts +++ b/base/sources/ts/import_font.ts @@ -8,19 +8,19 @@ function import_font_run(path: string) { } } - let font: g2_font_t = data_get_font(path); + let font: draw_font_t = data_get_font(path); g2_font_init(font); // Make sure font_ is ready - let count: i32 = draw_font_count(font.font_); + let count: i32 = draw_font_count(font); let font_slots: slot_font_t[] = []; for (let i: i32 = 0; i < count; ++i) { let ar: string[] = string_split(path, path_sep); let name: string = ar[ar.length - 1]; - let f: g2_font_t = g2_font_clone(font); + let f: draw_font_t = g2_font_clone(font); g2_font_set_font_index(f, i); g2_font_init(f); - if (!draw_set_font(f.font_, util_render_font_preview_size)) { + if (!draw_set_font(f, util_render_font_preview_size)) { console_error(tr("Error: Failed to read font data")); continue; } diff --git a/base/sources/ts/iron/app.ts b/base/sources/ts/iron/app.ts index ad152513..01b36289 100644 --- a/base/sources/ts/iron/app.ts +++ b/base/sources/ts/iron/app.ts @@ -24,14 +24,14 @@ function app_w(): i32 { if (app_on_w != null) { return app_on_w(); } - return sys_width(); + return kinc_window_width(); } function app_h(): i32 { if (app_on_h != null) { return app_on_h(); } - return sys_height(); + return kinc_window_height(); } function app_x(): i32 { diff --git a/base/sources/ts/iron/data.ts b/base/sources/ts/iron/data.ts index 840cffec..84b88bce 100644 --- a/base/sources/ts/iron/data.ts +++ b/base/sources/ts/iron/data.ts @@ -10,7 +10,7 @@ let data_cached_shaders: map_t = map_create(); let data_cached_blobs: map_t = map_create(); let data_cached_images: map_t = map_create(); let data_cached_videos: map_t = map_create(); -let data_cached_fonts: map_t = map_create(); +let data_cached_fonts: map_t = map_create(); ///if arm_audio let data_cached_sounds: map_t = map_create(); ///end @@ -140,14 +140,14 @@ function data_get_video(file: string): video_t { return null; } -function data_get_font(file: string): g2_font_t { - let cached: g2_font_t = map_get(data_cached_fonts, file); +function data_get_font(file: string): draw_font_t { + let cached: draw_font_t = map_get(data_cached_fonts, file); if (cached != null) { return cached; } let blob: buffer_t = iron_load_blob(data_resolve_path(file)); - let b: g2_font_t = g2_font_create(blob); + let b: draw_font_t = g2_font_create(blob); map_set(data_cached_fonts, file, b); data_assets_loaded++; return b; @@ -203,7 +203,7 @@ function data_delete_video(handle: string) { } function data_delete_font(handle: string) { - let font: g2_font_t = map_get(data_cached_fonts, handle); + let font: draw_font_t = map_get(data_cached_fonts, handle); if (font == null) { return; } @@ -269,7 +269,7 @@ function data_delete_all() { let cached_fonts_keys: string[] = map_keys(data_cached_fonts); for (let i: i32 = 0; i < cached_fonts_keys.length; ++i) { - let c: g2_font_t = map_get(data_cached_fonts, cached_fonts_keys[i]); + let c: draw_font_t = map_get(data_cached_fonts, cached_fonts_keys[i]); g2_font_unload(c); } data_cached_fonts = map_create(); diff --git a/base/sources/ts/iron/g2.ts b/base/sources/ts/iron/g2.ts index ef207b0d..daad022c 100644 --- a/base/sources/ts/iron/g2.ts +++ b/base/sources/ts/iron/g2.ts @@ -1,17 +1,18 @@ -declare type g2_font_t = { - font_?: any; // draw_font_t - blob?: buffer_t; +declare type draw_font_t = { + blob?: any; // unsigned char * + images: any; // draw_font_image_t * + m_capacity?: i32; + m_images_len?: i32; + offset?: 32; + + buf?: buffer_t; glyphs?: i32[]; index?: i32; }; -let _g2_color: color_t; -let _g2_font: g2_font_t; +let _g2_font: draw_font_t; let _g2_font_size: i32 = 0; -let _g2_pipeline: pipeline_t; -let _g2_transformation: mat3_t = mat3_nan(); -let _g2_render_target: image_t; let _g2_current: image_t = null; let _g2_in_use: bool = false; @@ -21,17 +22,12 @@ let _g2_thrown: bool = false; let _g2_mat: f32_array_t = f32_array_create(9); let _g2_initialized: bool = false; -function g2_set_color(c: color_t) { - draw_set_color(c); - _g2_color = c; -} - -function g2_set_font_and_size(font: g2_font_t, font_size: i32) { +function g2_set_font_and_size(font: draw_font_t, font_size: i32) { g2_font_init(font); - draw_set_font(font.font_, font_size); + draw_set_font(font, font_size); } -function g2_set_font(f: g2_font_t) { +function g2_set_font(f: draw_font_t) { if (_g2_font_size != 0) { g2_set_font_and_size(f, _g2_font_size); } @@ -39,7 +35,7 @@ function g2_set_font(f: g2_font_t) { } function g2_set_font_size(i: i32) { - if (_g2_font.font_ != null) { + if (_g2_font != null) { g2_set_font_and_size(_g2_font, i); } _g2_font_size = i; @@ -47,7 +43,6 @@ function g2_set_font_size(i: i32) { function g2_set_pipeline(p: pipeline_t) { draw_set_pipeline(p == null ? null : p.pipeline_); - _g2_pipeline = p; } function g2_set_transformation(m: mat3_t) { @@ -90,16 +85,6 @@ function g2_init() { } } -function g2_scissor(x: i32, y: i32, width: i32, height: i32) { - draw_end(); // flush - g4_scissor(x, y, width, height); -} - -function g2_disable_scissor() { - draw_end(); // flush - g4_disable_scissor(); -} - function g2_begin(render_target: image_t = null) { if (_g2_in_use && !_g2_thrown) { _g2_thrown = true; @@ -129,47 +114,43 @@ function g2_end() { draw_end(); } -function g2_clear(color: color_t = 0x00000000) { - g4_clear(color); -} - -function g2_font_init(raw: g2_font_t) { +function g2_font_init(raw: draw_font_t) { if (_g2_font_glyphs_last != _g2_font_glyphs) { _g2_font_glyphs_last = _g2_font_glyphs; draw_font_set_glyphs(_g2_font_glyphs); } if (raw.glyphs != _g2_font_glyphs) { raw.glyphs = _g2_font_glyphs; - raw.font_ = draw_font_init(raw.blob, raw.index); + draw_font_init(raw, raw.buf.buffer, raw.index); } } -function g2_font_create(blob: buffer_t, index: i32 = 0): g2_font_t { - let raw: g2_font_t = {}; - raw.blob = blob; +function g2_font_create(buf: buffer_t, index: i32 = 0): draw_font_t { + let raw: draw_font_t = {}; + raw.buf = buf; raw.index = index; return raw; } -function g2_font_height(raw: g2_font_t, size: i32): f32 { +function g2_font_height(raw: draw_font_t, size: i32): f32 { g2_font_init(raw); - return draw_font_height(raw.font_, size); + return draw_font_height(raw, size); } -function g2_font_width(raw: g2_font_t, size: i32, str: string): f32 { +function g2_font_width(raw: draw_font_t, size: i32, str: string): f32 { g2_font_init(raw); - return draw_string_width(raw.font_, size, str); + return draw_string_width(raw, size, str); } -function g2_font_unload(raw: g2_font_t) { - raw.blob = null; +function g2_font_unload(raw: draw_font_t) { + raw.buf = null; } -function g2_font_set_font_index(raw: g2_font_t, index: i32) { +function g2_font_set_font_index(raw: draw_font_t, index: i32) { raw.index = index; _g2_font_glyphs = array_slice(_g2_font_glyphs, 0, _g2_font_glyphs.length); // Trigger atlas update } -function g2_font_clone(raw: g2_font_t): g2_font_t { - return g2_font_create(raw.blob, raw.index); +function g2_font_clone(raw: draw_font_t): draw_font_t { + return g2_font_create(raw.buf, raw.index); } diff --git a/base/sources/ts/iron/g4.ts b/base/sources/ts/iron/g4.ts index 363f1158..281ca48b 100644 --- a/base/sources/ts/iron/g4.ts +++ b/base/sources/ts/iron/g4.ts @@ -460,6 +460,32 @@ declare type image_t = { height?: i32; }; +declare type kinc_g5_pipeline_t = { + input_layout?: any; + vertex_shader?: any; + fragment_shader?: any; + + cull_mode?: cull_mode_t; + depth_write?: bool; + depth_mode?: compare_mode_t; + + blend_source?: blend_factor_t; + blend_destination?: blend_factor_t; + alpha_blend_source?: blend_factor_t; + alpha_blend_destination?: blend_factor_t; + + color_write_mask_red?: any; + color_write_mask_green?: any; + color_write_mask_blue?: any; + color_write_mask_alpha?: any; + + color_attachment?: any; + color_attachment_count?: i32; + depth_attachment_bits?: i32; + + impl?: any; +}; + type pipeline_t = { pipeline_?: kinc_g5_pipeline_t; input_layout?: vertex_struct_t; @@ -506,32 +532,6 @@ declare type kinc_vertex_elem_t = { type kinc_const_loc_t = any; type kinc_tex_unit_t = any; -declare type kinc_g5_pipeline_t = { - input_layout?: any; - vertex_shader?: any; - fragment_shader?: any; - - cull_mode?: cull_mode_t; - depth_write?: bool; - depth_mode?: compare_mode_t; - - blend_source?: blend_factor_t; - blend_destination?: blend_factor_t; - alpha_blend_source?: blend_factor_t; - alpha_blend_destination?: blend_factor_t; - - color_write_mask_red?: any; - color_write_mask_green?: any; - color_write_mask_blue?: any; - color_write_mask_alpha?: any; - - color_attachment?: any; - color_attachment_count?: i32; - depth_attachment_bits?: i32; - - impl?: any; -}; - type iron_texture_t = { width?: i32; height?: i32; diff --git a/base/sources/ts/iron/input.ts b/base/sources/ts/iron/input.ts index f25132af..fe45f6ba 100644 --- a/base/sources/ts/iron/input.ts +++ b/base/sources/ts/iron/input.ts @@ -94,7 +94,7 @@ function mouse_released(button: string = "left"): bool { } function mouse_lock() { - if (sys_can_lock_mouse()) { + if (kinc_mouse_can_lock()) { sys_lock_mouse(); mouse_locked = true; mouse_hidden = true; @@ -102,7 +102,7 @@ function mouse_lock() { } function mouse_unlock() { - if (sys_can_lock_mouse()) { + if (kinc_mouse_can_lock()) { sys_unlock_mouse(); mouse_locked = false; mouse_hidden = false; diff --git a/base/sources/ts/iron/iron.ts b/base/sources/ts/iron/iron.ts index 633c6104..beb7397a 100644 --- a/base/sources/ts/iron/iron.ts +++ b/base/sources/ts/iron/iron.ts @@ -180,7 +180,7 @@ declare function color_set_gb(c: i32, i: u8): i32; declare function color_set_bb(c: i32, i: u8): i32; declare function color_set_ab(c: i32, i: u8): i32; -declare function iron_init(title: string, width: i32, height: i32, vsync: bool, window_mode: i32, window_features: i32, x: i32, y: i32, frequency: i32, use_depth: bool): void; +declare function iron_init(ops: kinc_window_options_t): void; declare function kinc_set_app_name(name: string): void; declare function kinc_log(v: any): void; declare function kinc_g5_clear(flags: i32, color: i32, depth: f32): void; @@ -316,8 +316,8 @@ declare function draw_line(x0: f32, y0: f32, x1: f32, y1: f32, strength: f32 = 1 declare function draw_line_aa(x0: f32, y0: f32, x1: f32, y1: f32, strength: f32 = 1.0): void; declare function draw_string(text: string, x: f32, y: f32): void; declare function draw_set_font(font: any, size: i32): bool; -declare function draw_font_init(blob: buffer_t, font_index: i32): any; -declare function draw_font_13(blob: buffer_t): any; +declare function draw_font_init(font: any, buf: any, font_index: i32): void; +declare function draw_font_13(font: any, buf: any): any; declare function draw_font_set_glyphs(glyphs: i32[]): void; declare function draw_font_count(font: any): i32; declare function draw_font_height(font: any, size: i32): i32; diff --git a/base/sources/ts/iron/render_path.ts b/base/sources/ts/iron/render_path.ts index 9d98ef5b..4cdbeb34 100644 --- a/base/sources/ts/iron/render_path.ts +++ b/base/sources/ts/iron/render_path.ts @@ -290,7 +290,7 @@ function _render_path_resize_on_init(_image: image_t) { } function render_path_resize() { - if (sys_width() == 0 || sys_height() == 0) { + if (kinc_window_width() == 0 || kinc_window_height() == 0) { return; } diff --git a/base/sources/ts/iron/sys.ts b/base/sources/ts/iron/sys.ts index 77c4d0e7..61af0092 100644 --- a/base/sources/ts/iron/sys.ts +++ b/base/sources/ts/iron/sys.ts @@ -22,8 +22,27 @@ let _sys_start_time: f32; let _sys_window_title: string; let _sys_shaders: map_t = map_create(); -function sys_start(ops: kinc_sys_ops_t) { - iron_init(ops.title, ops.width, ops.height, ops.vsync, ops.mode, ops.features, ops.x, ops.y, ops.frequency, ops.use_depth); +declare type kinc_window_options_t = { + title?: string; + x?: i32; + y?: i32; + width?: i32; + height?: i32; + features?: window_features_t; + mode?: window_mode_t; + frequency?: i32; + vsync?: bool; + + use_depth?: bool; + + display_index?: i32; + visible?: bool; + color_bits?: i32; + depth_bits?: i32; +}; + +function sys_start(ops: kinc_window_options_t) { + iron_init(ops); _sys_start_time = kinc_time(); g2_init(); @@ -129,22 +148,6 @@ function sys_time(): f32 { return kinc_time() - _sys_start_time; } -function sys_system_id(): string { - return kinc_system_id(); -} - -function sys_language(): string { - return kinc_language(); -} - -function sys_stop() { - kinc_stop(); -} - -function sys_load_url(url: string) { - kinc_load_url(url); -} - function sys_render_callback() { for (let i: i32 = 0; i < _sys_render_listeners.length; ++i) { _sys_render_listeners[i].f(); @@ -262,25 +265,17 @@ function sys_gamepad_button_callback(gamepad: i32, button: i32, value: f32) { } function sys_lock_mouse() { - if (!sys_is_mouse_locked()) { + if (!kinc_mouse_is_locked()) { kinc_mouse_lock(); } } function sys_unlock_mouse() { - if (sys_is_mouse_locked()) { + if (kinc_mouse_is_locked()) { kinc_mouse_unlock(); } } -function sys_can_lock_mouse(): bool { - return kinc_mouse_can_lock(); -} - -function sys_is_mouse_locked(): bool { - return kinc_mouse_is_locked(); -} - function sys_hide_system_cursor() { iron_show_mouse(false); } @@ -289,38 +284,6 @@ function sys_show_system_cursor() { iron_show_mouse(true); } -function sys_resize(width: i32, height: i32) { - kinc_window_resize(width, height); -} - -function sys_move(x: i32, y: i32) { - kinc_window_move(x, y); -} - -function sys_x(): i32 { - return kinc_window_x(); -} - -function sys_y(): i32 { - return kinc_window_y(); -} - -function sys_width(): i32 { - return kinc_window_width(); -} - -function sys_height(): i32 { - return kinc_window_height(); -} - -function sys_mode(): window_mode_t { - return kinc_window_get_mode(); -} - -function sys_mode_set(mode: window_mode_t) { - iron_set_window_mode(mode); -} - function sys_title(): string { return _sys_window_title; } @@ -409,19 +372,6 @@ type sound_t = { sound_?: any; }; -type kinc_sys_ops_t = { - title?: string; - x?: i32; - y?: i32; - width?: i32; - height?: i32; - features?: window_features_t; - mode?: window_mode_t; - frequency?: i32; - vsync?: bool; - use_depth?: bool; -}; - enum window_features_t { NONE = 0, RESIZABLE = 1, diff --git a/base/sources/ts/iron/ui.ts b/base/sources/ts/iron/ui.ts index 8ef58114..a7b7abad 100644 --- a/base/sources/ts/iron/ui.ts +++ b/base/sources/ts/iron/ui.ts @@ -237,7 +237,7 @@ function ui_get_socket(nodes: ui_node_t[], id: i32): ui_node_socket_t { return null; } -function ui_set_font(raw: ui_t, font: g2_font_t) { +function ui_set_font(raw: ui_t, font: draw_font_t) { g2_font_init(font); // Make sure font_ is ready raw.ops.font = font; } @@ -397,7 +397,7 @@ declare type ui_handle_t = { }; declare type ui_options_t = { - font?: g2_font_t; + font?: draw_font_t; theme?: ui_theme_t; scale_factor?: f32; color_wheel?: kinc_g5_texture_t; diff --git a/base/sources/ts/project.ts b/base/sources/ts/project.ts index 8433b1bf..44da3163 100644 --- a/base/sources/ts/project.ts +++ b/base/sources/ts/project.ts @@ -79,7 +79,7 @@ function project_save(save_and_quit: bool = false) { app_notify_on_init(function () { export_arm_run_project(); if (_project_save_and_quit) { - sys_stop(); + kinc_stop(); } }); } diff --git a/base/sources/ts/render_path_base.ts b/base/sources/ts/render_path_base.ts index da35bc52..71b697d6 100644 --- a/base/sources/ts/render_path_base.ts +++ b/base/sources/ts/render_path_base.ts @@ -95,7 +95,7 @@ function render_path_base_ssaa4(): bool { } function render_path_base_is_cached(): bool { - if (sys_width() == 0 || sys_height() == 0) { + if (kinc_window_width() == 0 || kinc_window_height() == 0) { return true; } diff --git a/base/sources/ts/slot_font.ts b/base/sources/ts/slot_font.ts index 89e93ab9..706a0830 100644 --- a/base/sources/ts/slot_font.ts +++ b/base/sources/ts/slot_font.ts @@ -3,12 +3,12 @@ type slot_font_t = { image?: image_t; // 200px preview_ready?: bool; id?: i32; - font?: g2_font_t; + font?: draw_font_t; name?: string; file?: string; }; -function slot_font_create(name: string, font: g2_font_t, file: string = ""): slot_font_t { +function slot_font_create(name: string, font: draw_font_t, file: string = ""): slot_font_t { let raw: slot_font_t = {}; raw.preview_ready = false; raw.id = 0; diff --git a/base/sources/ts/slot_layer.ts b/base/sources/ts/slot_layer.ts index 9ea5905a..b5daca8e 100644 --- a/base/sources/ts/slot_layer.ts +++ b/base/sources/ts/slot_layer.ts @@ -338,7 +338,7 @@ function slot_layer_duplicate(raw: slot_layer_t): slot_layer_t { if (l.texpaint_preview != null) { g2_begin(l.texpaint_preview); - g2_clear(0x00000000); + g4_clear(0x00000000); g2_set_pipeline(pipes_copy); draw_scaled_image(raw.texpaint_preview, 0, 0, raw.texpaint_preview.width, raw.texpaint_preview.height); g2_set_pipeline(null); diff --git a/base/sources/ts/tab_console.ts b/base/sources/ts/tab_console.ts index 21bce003..88237cb8 100644 --- a/base/sources/ts/tab_console.ts +++ b/base/sources/ts/tab_console.ts @@ -55,9 +55,9 @@ function tab_console_draw(htab: ui_handle_t) { ui_end_sticky(); - let _font: g2_font_t = ui.ops.font; + let _font: draw_font_t = ui.ops.font; let _font_size: i32 = ui.font_size; - let f: g2_font_t = data_get_font("font_mono.ttf"); + let f: draw_font_t = data_get_font("font_mono.ttf"); ui_set_font(ui, f); ui.font_size = math_floor(15 * ui_SCALE(ui)); for (let i: i32 = 0; i < console_last_traces.length; ++i) { diff --git a/base/sources/ts/tab_fonts.ts b/base/sources/ts/tab_fonts.ts index a09fdbd8..9e08de47 100644 --- a/base/sources/ts/tab_fonts.ts +++ b/base/sources/ts/tab_fonts.ts @@ -29,7 +29,7 @@ function tab_fonts_draw(htab: ui_handle_t) { ui_end_sticky(); ui_separator(3, false); - let statusw: i32 = sys_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W]; + let statusw: i32 = kinc_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W]; let slotw: i32 = math_floor(51 * ui_SCALE(ui)); let num: i32 = math_floor(statusw / slotw); if (num == 0) { diff --git a/base/sources/ts/tab_layers.ts b/base/sources/ts/tab_layers.ts index 5d5847d9..c7c2a9e0 100644 --- a/base/sources/ts/tab_layers.ts +++ b/base/sources/ts/tab_layers.ts @@ -670,9 +670,9 @@ function tab_layers_draw_layer_icon(l: slot_layer_t, i: i32, uix: f32, uiy: f32, let number: string = i32_to_string(i + 1) ; let width: i32 = g2_font_width(ui.ops.font, ui.font_size, number) + 10; let height: i32 = g2_font_height(ui.ops.font, ui.font_size); - g2_set_color(ui.ops.theme.TEXT_COL); + draw_set_color(ui.ops.theme.TEXT_COL); draw_filled_rect(uix, uiy, width, height); - g2_set_color(ui.ops.theme.BUTTON_COL); + draw_set_color(ui.ops.theme.BUTTON_COL); draw_string(number, uix + 5, uiy); } } diff --git a/base/sources/ts/tab_materials.ts b/base/sources/ts/tab_materials.ts index 7786a7aa..e7e7b1b1 100644 --- a/base/sources/ts/tab_materials.ts +++ b/base/sources/ts/tab_materials.ts @@ -118,9 +118,9 @@ function tab_materials_draw_slots(mini: bool) { let number: string = i32_to_string(i + 1); let width: i32 = g2_font_width(ui.ops.font, ui.font_size, number) + 10; let height: i32 = g2_font_height(ui.ops.font, ui.font_size); - g2_set_color(ui.ops.theme.TEXT_COL); + draw_set_color(ui.ops.theme.TEXT_COL); draw_filled_rect(uix, uiy, width, height); - g2_set_color(ui.ops.theme.BUTTON_COL); + draw_set_color(ui.ops.theme.BUTTON_COL); draw_string(number, uix + 5, uiy); } } diff --git a/base/sources/ts/tab_script.ts b/base/sources/ts/tab_script.ts index b28d8695..e3abc4ed 100644 --- a/base/sources/ts/tab_script.ts +++ b/base/sources/ts/tab_script.ts @@ -44,9 +44,9 @@ function tab_script_draw(htab: ui_handle_t) { } ui_end_sticky(); - let _font: g2_font_t = ui.ops.font; + let _font: draw_font_t = ui.ops.font; let _font_size: i32 = ui.font_size; - let f: g2_font_t = data_get_font("font_mono.ttf"); + let f: draw_font_t = data_get_font("font_mono.ttf"); ui_set_font(ui, f); ui.font_size = math_floor(15 * ui_SCALE(ui)); ui_text_area_line_numbers = true; diff --git a/base/sources/ts/tab_textures.ts b/base/sources/ts/tab_textures.ts index d970d919..7e5157d4 100644 --- a/base/sources/ts/tab_textures.ts +++ b/base/sources/ts/tab_textures.ts @@ -40,10 +40,10 @@ function tab_textures_draw(htab: ui_handle_t) { if (project_assets.length > 0) { ///if (is_paint || is_sculpt) - let statusw: i32 = sys_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W]; + let statusw: i32 = kinc_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W]; ///end ///if is_lab - let statusw: i32 = sys_width(); + let statusw: i32 = kinc_window_width(); ///end let slotw: i32 = math_floor(52 * ui_SCALE(ui)); diff --git a/base/sources/ts/translator.ts b/base/sources/ts/translator.ts index 42e7423c..95ab8b22 100644 --- a/base/sources/ts/translator.ts +++ b/base/sources/ts/translator.ts @@ -159,7 +159,7 @@ function translator_init_font(cjk: bool, font_path: string, font_scale: f32) { let font_path: string = _translator_init_font_font_path; let font_scale: f32 = _translator_init_font_font_scale; - let f: g2_font_t = data_get_font(font_path); + let f: draw_font_t = data_get_font(font_path); if (cjk) { let font_index: i32 = map_get(translator_cjk_font_indices, config_raw.locale) != -1 ? map_get(translator_cjk_font_indices, config_raw.locale) : 0; g2_font_set_font_index(f, font_index); diff --git a/base/sources/ts/ui_base.ts b/base/sources/ts/ui_base.ts index 23526574..79710d7d 100644 --- a/base/sources/ts/ui_base.ts +++ b/base/sources/ts/ui_base.ts @@ -659,8 +659,8 @@ function ui_base_update() { if (config_raw.layout[layout_size_t.NODES_W] < 32) { config_raw.layout[layout_size_t.NODES_W] = 32; } - else if (config_raw.layout[layout_size_t.NODES_W] > sys_width() * 0.7) { - config_raw.layout[layout_size_t.NODES_W] = math_floor(sys_width() * 0.7); + else if (config_raw.layout[layout_size_t.NODES_W] > kinc_window_width() * 0.7) { + config_raw.layout[layout_size_t.NODES_W] = math_floor(kinc_window_width() * 0.7); } } else { // UINodes / UIView2D ratio @@ -675,7 +675,7 @@ function ui_base_update() { } else if (ui_base_border_handle == ui_base_hwnds[tab_area_t.STATUS]) { let my: i32 = math_floor(mouse_movement_y); - if (config_raw.layout[layout_size_t.STATUS_H] - my >= ui_status_default_status_h * config_raw.window_scale && config_raw.layout[layout_size_t.STATUS_H] - my < sys_height() * 0.7) { + if (config_raw.layout[layout_size_t.STATUS_H] - my >= ui_status_default_status_h * config_raw.window_scale && config_raw.layout[layout_size_t.STATUS_H] - my < kinc_window_height() * 0.7) { config_raw.layout[layout_size_t.STATUS_H] -= my; } } @@ -685,8 +685,8 @@ function ui_base_update() { if (config_raw.layout[layout_size_t.SIDEBAR_W] < ui_base_sidebar_mini_w) { config_raw.layout[layout_size_t.SIDEBAR_W] = ui_base_sidebar_mini_w; } - else if (config_raw.layout[layout_size_t.SIDEBAR_W] > sys_width() - ui_base_sidebar_mini_w) { - config_raw.layout[layout_size_t.SIDEBAR_W] = sys_width() - ui_base_sidebar_mini_w; + else if (config_raw.layout[layout_size_t.SIDEBAR_W] > kinc_window_width() - ui_base_sidebar_mini_w) { + config_raw.layout[layout_size_t.SIDEBAR_W] = kinc_window_width() - ui_base_sidebar_mini_w; } } else { @@ -1089,7 +1089,7 @@ function ui_base_update_ui() { let source: image_t = l.texpaint; g2_begin(target); - g2_clear(0x00000000); + g4_clear(0x00000000); // g2_set_pipeline(l.is_mask() ? pipes_copy8 : pipes_copy); g2_set_pipeline(pipes_copy); // texpaint_preview is always RGBA32 for now draw_scaled_image(source, 0, 0, target.width, target.height); @@ -1109,7 +1109,7 @@ function ui_base_update_ui() { let source: image_t = l.texpaint; g2_begin(target); - g2_clear(0x00000000); + g4_clear(0x00000000); // g2_set_pipeline(raw.layer.is_mask() ? pipes_copy8 : pipes_copy); g2_set_pipeline(pipes_copy); // texpaint_preview is always RGBA32 for now draw_scaled_image(source, 0, 0, target.width, target.height); @@ -1167,7 +1167,7 @@ function ui_base_render() { g2_begin(null); } - if (!ui_base_show || sys_width() == 0 || sys_height() == 0) { + if (!ui_base_show || kinc_window_width() == 0 || kinc_window_height() == 0) { return; } @@ -1208,7 +1208,7 @@ function ui_base_draw_sidebar() { // Tabs let mini: bool = config_raw.layout[layout_size_t.SIDEBAR_W] <= ui_base_sidebar_mini_w; let expand_button_offset: i32 = config_raw.touch_ui ? math_floor(ui_ELEMENT_H(ui_base_ui) + ui_ELEMENT_OFFSET(ui_base_ui)) : 0; - ui_base_tabx = sys_width() - config_raw.layout[layout_size_t.SIDEBAR_W]; + ui_base_tabx = kinc_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W]; let _SCROLL_W: i32 = ui_base_ui.ops.theme.SCROLL_W; if (mini) { @@ -1235,7 +1235,7 @@ function ui_base_draw_sidebar() { if (config_raw.touch_ui) { let width: i32 = config_raw.layout[layout_size_t.SIDEBAR_W]; let height: i32 = math_floor(ui_ELEMENT_H(ui_base_ui) + ui_ELEMENT_OFFSET(ui_base_ui)); - if (ui_window(ui_handle(__ID__), sys_width() - width, sys_height() - height, width, height + 1)) { + if (ui_window(ui_handle(__ID__), kinc_window_width() - width, kinc_window_height() - height, width, height + 1)) { ui_base_ui._w = width; let _BUTTON_H: i32 = ui_base_ui.ops.theme.BUTTON_H; let _BUTTON_COL: i32 = ui_base_ui.ops.theme.BUTTON_COL; @@ -1253,7 +1253,7 @@ function ui_base_draw_sidebar() { // Expand button if (config_raw.layout[layout_size_t.SIDEBAR_W] == 0) { let width: i32 = math_floor(g2_font_width(ui_base_ui.ops.font, ui_base_ui.font_size, "<<") + 25 * ui_SCALE(ui_base_ui)); - if (ui_window(ui_base_hminimized, sys_width() - width, 0, width, math_floor(ui_ELEMENT_H(ui_base_ui) + ui_ELEMENT_OFFSET(ui_base_ui) + 1))) { + if (ui_window(ui_base_hminimized, kinc_window_width() - width, 0, width, math_floor(ui_ELEMENT_H(ui_base_ui) + ui_ELEMENT_OFFSET(ui_base_ui) + 1))) { ui_base_ui._w = width; let _BUTTON_H: i32 = ui_base_ui.ops.theme.BUTTON_H; let _BUTTON_COL: i32 = ui_base_ui.ops.theme.BUTTON_COL; @@ -1286,7 +1286,7 @@ function ui_base_render_cursor() { return; } - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); context_raw.view_index = context_raw.view_index_last; let mx: i32 = base_x() + context_raw.paint_vec.x * base_w(); @@ -1295,8 +1295,8 @@ function ui_base_render_cursor() { // Radius being scaled if (context_raw.brush_locked) { - mx += context_raw.lock_started_x - sys_width() / 2; - my += context_raw.lock_started_y - sys_height() / 2; + mx += context_raw.lock_started_x - kinc_window_width() / 2; + my += context_raw.lock_started_y - kinc_window_height() / 2; } if (context_raw.brush_stencil_image != null && @@ -1308,14 +1308,14 @@ function ui_base_render_cursor() { context_raw.tool != workspace_tool_t.COLORID) { let r: rect_t = ui_base_get_brush_stencil_rect(); if (!operator_shortcut(map_get(config_keymap, "stencil_hide"), shortcut_type_t.DOWN)) { - g2_set_color(0x88ffffff); + draw_set_color(0x88ffffff); let angle: f32 = context_raw.brush_stencil_angle; let cx: f32 = r.x + r.w / 2; let cy: f32 = r.y + r.h / 2; g2_set_transformation(mat3_multmat(mat3_multmat(mat3_translation(cx, cy), mat3_rotation(-angle)), mat3_translation(-cx, -cy))); draw_scaled_image(context_raw.brush_stencil_image, r.x, r.y, r.w, r.h); g2_set_transformation(mat3_nan()); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); } let transform: bool = operator_shortcut(map_get(config_keymap, "stencil_transform"), shortcut_type_t.DOWN); if (transform) { @@ -1352,9 +1352,9 @@ function ui_base_render_cursor() { // Clone source cursor if (context_raw.tool == workspace_tool_t.CLONE && !keyboard_down("alt") && (mouse_down() || pen_down())) { - g2_set_color(0x66ffffff); + draw_set_color(0x66ffffff); draw_scaled_image(cursor_img, mx + context_raw.clone_delta_x * app_w() - psize / 2, my + context_raw.clone_delta_y * app_h() - psize / 2, psize, psize); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); } let decal: bool = context_is_decal(); @@ -1370,8 +1370,8 @@ function ui_base_render_cursor() { // Radius being scaled if (context_raw.brush_locked) { - context_raw.decal_x += (context_raw.lock_started_x - sys_width() / 2) / base_w(); - context_raw.decal_y += (context_raw.lock_started_y - sys_height() / 2) / base_h(); + context_raw.decal_x += (context_raw.lock_started_x - kinc_window_width() / 2) / base_w(); + context_raw.decal_y += (context_raw.lock_started_y - kinc_window_height() / 2) / base_h(); } } @@ -1384,14 +1384,14 @@ function ui_base_render_cursor() { let decaly: f32 = base_y() + context_raw.decal_y * base_h() - psizey / 2; context_raw.view_index = -1; - g2_set_color(color_from_floats(1, 1, 1, decal_alpha)); + draw_set_color(color_from_floats(1, 1, 1, decal_alpha)); let angle: f32 = (context_raw.brush_angle + context_raw.brush_nodes_angle) * (math_pi() / 180); let cx: f32 = decalx + psizex / 2; let cy: f32 = decaly + psizey / 2; g2_set_transformation(mat3_multmat(mat3_multmat(mat3_translation(cx, cy), mat3_rotation(angle)), mat3_translation(-cx, -cy))); draw_scaled_image(context_raw.decal_image, decalx, decaly, psizex, psizey); g2_set_transformation(mat3_nan()); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); } } if (context_raw.tool == workspace_tool_t.BRUSH || @@ -1425,9 +1425,9 @@ function ui_base_render_cursor() { mx = context_raw.brush_lazy_x * base_w() + base_x(); my = context_raw.brush_lazy_y * base_h() + base_y(); let radius: f32 = context_raw.brush_lazy_radius * 180; - g2_set_color(0xff666666); + draw_set_color(0xff666666); draw_scaled_image(cursor_img, mx - radius / 2, my - radius / 2, radius, radius); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); } } diff --git a/base/sources/ts/ui_box.ts b/base/sources/ts/ui_box.ts index 6683f1e8..657a4841 100644 --- a/base/sources/ts/ui_box.ts +++ b/base/sources/ts/ui_box.ts @@ -28,8 +28,8 @@ function ui_box_render() { let in_use: bool = ui.combo_selected_handle != null; let is_escape: bool = keyboard_started("escape"); if (ui_box_draws > 2 && (ui.input_released || is_escape) && !in_use && !ui.is_typing) { - let appw: i32 = sys_width(); - let apph: i32 = sys_height(); + let appw: i32 = kinc_window_width(); + let apph: i32 = kinc_window_height(); let mw: i32 = math_floor(ui_box_modalw * ui_SCALE(ui)); let mh: i32 = math_floor(ui_box_modalh * ui_SCALE(ui)); let left: f32 = (appw / 2 - mw / 2) + ui_box_hwnd.drag_x; @@ -46,18 +46,18 @@ function ui_box_render() { if (config_raw.touch_ui) { // Darken bg ///if (arm_android || arm_ios) - g2_set_color(color_from_floats(0, 0, 0, ui_box_tween_alpha)); + draw_set_color(color_from_floats(0, 0, 0, ui_box_tween_alpha)); ///else - g2_set_color(color_from_floats(0, 0, 0, 0.5)); + draw_set_color(color_from_floats(0, 0, 0, 0.5)); ///end - draw_filled_rect(0, 0, sys_width(), sys_height()); + draw_filled_rect(0, 0, kinc_window_width(), kinc_window_height()); } g2_end(); let ui: ui_t = base_ui_box; - let appw: i32 = sys_width(); - let apph: i32 = sys_height(); + let appw: i32 = kinc_window_width(); + let apph: i32 = kinc_window_height(); let mw: i32 = math_floor(ui_box_modalw * ui_SCALE(ui)); let mh: i32 = math_floor(ui_box_modalh * ui_SCALE(ui)); if (mw > appw) { @@ -176,7 +176,7 @@ function ui_box_tween_in() { let a: tween_anim_t = { target: ADDRESS(ui_box_tween_alpha), to: 0.5, duration: 0.2, ease: ease_t.EXPO_OUT }; tween_to(a); - ui_box_hwnd.drag_y = math_floor(sys_height() / 2); + ui_box_hwnd.drag_y = math_floor(kinc_window_height() / 2); a = { target: ADDRESS(ui_box_hwnd.drag_y), to: 0.0, duration: 0.2, ease: ease_t.EXPO_OUT, tick: ui_box_tween_tick }; tween_to(a); } @@ -185,7 +185,7 @@ function ui_box_tween_out() { let a: tween_anim_t = { target: ADDRESS(ui_box_tween_alpha), to: 0.0, duration: 0.2, ease: ease_t.EXPO_IN, done: ui_box_hide_internal }; tween_to(a); - a = { target: ADDRESS(ui_box_hwnd.drag_y), to: sys_height() / 2, duration: 0.2, ease: ease_t.EXPO_IN }; + a = { target: ADDRESS(ui_box_hwnd.drag_y), to: kinc_window_height() / 2, duration: 0.2, ease: ease_t.EXPO_IN }; tween_to(a); } @@ -196,10 +196,10 @@ function ui_box_tween_tick() { function ui_box_window_border(ui: ui_t) { if (ui.scissor) { ui.scissor = false; - g2_disable_scissor(); + g4_disable_scissor(); } // Border - g2_set_color(ui.ops.theme.SEPARATOR_COL); + draw_set_color(ui.ops.theme.SEPARATOR_COL); draw_filled_rect(0, 0, 1, ui._window_h); draw_filled_rect(0 + ui._window_w - 1, 0, 1, ui._window_h); draw_filled_rect(0, 0 + ui._window_h - 1, ui._window_w, 1); diff --git a/base/sources/ts/ui_files.ts b/base/sources/ts/ui_files.ts index 92122116..3f42cbf4 100644 --- a/base/sources/ts/ui_files.ts +++ b/base/sources/ts/ui_files.ts @@ -215,7 +215,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool = } else { g2_begin(icon); - g2_clear(0xffffffff); + g4_clear(0xffffffff); } g2_set_pipeline(pipes_copy_rgb); draw_image(data.image, 0, 0); @@ -433,7 +433,7 @@ function ui_files_make_icon (args: ui_files_make_icon_t) { let sh: i32 = image.width > image.height ? math_floor(1.0 * image.height / image.width * w) : w; let icon: image_t = image_create_render_target(sw, sh); g2_begin(icon); - g2_clear(0xffffffff); + g4_clear(0xffffffff); g2_set_pipeline(pipes_copy_rgb); draw_scaled_image(image, 0, 0, sw, sh); g2_set_pipeline(null); diff --git a/base/sources/ts/ui_header.ts b/base/sources/ts/ui_header.ts index dbebb4d3..2c316af4 100644 --- a/base/sources/ts/ui_header.ts +++ b/base/sources/ts/ui_header.ts @@ -24,9 +24,9 @@ function ui_header_render_ui() { let nodesw: i32 = (ui_nodes_show || ui_view2d_show) ? config_raw.layout[layout_size_t.NODES_W] : 0; ///if is_lab - let ww: i32 = sys_width() - nodesw; + let ww: i32 = kinc_window_width() - nodesw; ///else - let ww: i32 = sys_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W] - nodesw; + let ww: i32 = kinc_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W] - nodesw; ///end if (ui_window(ui_header_handle, app_x(), ui_header_h, ww, ui_header_h)) { diff --git a/base/sources/ts/ui_menu.ts b/base/sources/ts/ui_menu.ts index 9ff0a9d7..bf5ccc5f 100644 --- a/base/sources/ts/ui_menu.ts +++ b/base/sources/ts/ui_menu.ts @@ -32,8 +32,8 @@ function ui_menu_render() { // First draw out of screen, then align the menu based on menu height if (ui_menu_show_first) { - ui_menu_x -= sys_width() * 2; - ui_menu_y -= sys_height() * 2; + ui_menu_x -= kinc_window_width() * 2; + ui_menu_y -= kinc_window_height() * 2; } ui_begin_region(ui, ui_menu_x, ui_menu_y, menu_w); @@ -122,7 +122,7 @@ function ui_menu_render() { ui_menu_separator(ui); if (ui_menu_button(tr("Exit"))) { - sys_stop(); + kinc_stop(); } } else if (ui_menu_category == menu_category_t.EDIT) { @@ -437,16 +437,16 @@ function ui_menu_render() { } if (ui_menu_button(tr("Report Bug"))) { ///if (arm_macos || arm_ios) // Limited url length - file_load_url("https://github.com/armory3d/armortools/issues/new?labels=bug&template=bug_report.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + sys_system_id()); + file_load_url("https://github.com/armory3d/armortools/issues/new?labels=bug&template=bug_report.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + kinc_system_id()); ///else - file_load_url("https://github.com/armory3d/armortools/issues/new?labels=bug&template=bug_report.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + sys_system_id() + "*%0A%0A**Issue description:**%0A%0A**Steps to reproduce:**%0A%0A"); + file_load_url("https://github.com/armory3d/armortools/issues/new?labels=bug&template=bug_report.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + kinc_system_id() + "*%0A%0A**Issue description:**%0A%0A**Steps to reproduce:**%0A%0A"); ///end } if (ui_menu_button(tr("Request Feature"))) { ///if (arm_macos || arm_ios) // Limited url length - file_load_url("https://github.com/armory3d/armortools/issues/new?labels=feature%20request&template=feature_request.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + sys_system_id()); + file_load_url("https://github.com/armory3d/armortools/issues/new?labels=feature%20request&template=feature_request.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + kinc_system_id()); ///else - file_load_url("https://github.com/armory3d/armortools/issues/new?labels=feature%20request&template=feature_request.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + sys_system_id() + "*%0A%0A**Feature description:**%0A%0A"); + file_load_url("https://github.com/armory3d/armortools/issues/new?labels=feature%20request&template=feature_request.md&body=*" + manifest_title + "%20" + manifest_version + "-" + config_get_sha() + ",%20" + kinc_system_id() + "*%0A%0A**Feature description:**%0A%0A"); ///end } ui_menu_separator(ui); @@ -489,7 +489,7 @@ function ui_menu_render() { if (ui_menu_button(tr("About..."))) { let msg: string = manifest_title + ".org - v" + manifest_version + " (" + config_get_date() + ") - " + config_get_sha() + "\n"; - msg += sys_system_id() + " - " + strings_graphics_api(); + msg += kinc_system_id() + " - " + strings_graphics_api(); ///if arm_windows let save: string; @@ -572,8 +572,8 @@ function ui_menu_render() { if (ui_menu_show_first) { ui_menu_show_first = false; ui_menu_h = ui._y - ui_menu_y; - ui_menu_x += sys_width() * 2; - ui_menu_y += sys_height() * 2; + ui_menu_x += kinc_window_width() * 2; + ui_menu_y += kinc_window_height() * 2; ui_menu_fit_to_screen(); ui_menu_render(); // Render at correct position now } @@ -602,20 +602,20 @@ function ui_menu_draw(commands: (ui: ui_t)=>void = null, x: i32 = -1, y: i32 = - function ui_menu_fit_to_screen() { // Prevent the menu going out of screen let menu_w: f32 = base_default_element_w * ui_SCALE(base_ui_menu) * 2.3; - if (ui_menu_x + menu_w > sys_width()) { + if (ui_menu_x + menu_w > kinc_window_width()) { if (ui_menu_x - menu_w > 0) { ui_menu_x = math_floor(ui_menu_x - menu_w); } else { - ui_menu_x = math_floor(sys_width() - menu_w); + ui_menu_x = math_floor(kinc_window_width() - menu_w); } } - if (ui_menu_y + ui_menu_h > sys_height()) { + if (ui_menu_y + ui_menu_h > kinc_window_height()) { if (ui_menu_y - ui_menu_h > 0) { ui_menu_y = math_floor(ui_menu_y - ui_menu_h); } else { - ui_menu_y = sys_height() - ui_menu_h; + ui_menu_y = kinc_window_height() - ui_menu_h; } ui_menu_x += 1; // Move out of mouse focus } @@ -649,9 +649,9 @@ function ui_menu_align(ui: ui_t) { function ui_menu_start(ui: ui_t) { ui_draw_shadow(ui._x, ui._y, ui._w, ui_menu_h); - g2_set_color(ui.ops.theme.SEPARATOR_COL); + draw_set_color(ui.ops.theme.SEPARATOR_COL); ui_draw_rect(true, ui._x, ui._y, ui._w, ui_menu_h); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); } function ui_menu_end(ui: ui_t) { diff --git a/base/sources/ts/ui_menubar.ts b/base/sources/ts/ui_menubar.ts index 7907c7e1..501a9391 100644 --- a/base/sources/ts/ui_menubar.ts +++ b/base/sources/ts/ui_menubar.ts @@ -125,10 +125,10 @@ function ui_menubar_draw_tab_header() { let nodesw: i32 = (ui_nodes_show || ui_view2d_show) ? config_raw.layout[layout_size_t.NODES_W] : 0; ///if (is_paint || is_sculpt) - let ww: i32 = sys_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - ui_menubar_w - nodesw; + let ww: i32 = kinc_window_width() - config_raw.layout[layout_size_t.SIDEBAR_W] - ui_menubar_w - nodesw; panel_x = (app_x() - item_w) + ui_menubar_w; ///else - let ww: i32 = sys_width() - ui_menubar_w - nodesw; + let ww: i32 = kinc_window_width() - ui_menubar_w - nodesw; panel_x = (app_x()) + ui_menubar_w; ///end diff --git a/base/sources/ts/ui_nodes.ts b/base/sources/ts/ui_nodes.ts index 7917de56..26d718b5 100644 --- a/base/sources/ts/ui_nodes.ts +++ b/base/sources/ts/ui_nodes.ts @@ -738,7 +738,7 @@ function ui_nodes_draw_grid(zoom: f32): image_t { let grid: image_t = image_create_render_target(w, h); g2_begin(grid); - g2_clear(ui_nodes_ui.ops.theme.SEPARATOR_COL); + g4_clear(ui_nodes_ui.ops.theme.SEPARATOR_COL); let sep_col: i32 = ui_nodes_ui.ops.theme.SEPARATOR_COL; let line_primary: i32 = sep_col - 0x00050505; @@ -751,7 +751,7 @@ function ui_nodes_draw_grid(zoom: f32): image_t { line_secondary = sep_col + 0x00090909; } - g2_set_color(line_primary); + draw_set_color(line_primary); step = ui_nodes_grid_small_cell_w * zoom; for (let i: i32 = 0; i < math_floor(h / step) + 1; ++i) { draw_line(0, i * step, w, i * step); @@ -760,7 +760,7 @@ function ui_nodes_draw_grid(zoom: f32): image_t { draw_line(i * step, 0, i * step, h); } - g2_set_color(line_secondary); + draw_set_color(line_secondary); step = ui_nodes_grid_cell_w * zoom; for (let i: i32 = 0; i < math_floor(h / step) + 1; ++i) { draw_line(0, i * step, w, i * step); @@ -858,7 +858,7 @@ function ui_nodes_render() { } ui_nodes_release_link = ui_nodes_ui.input_released; - if (!ui_nodes_show || sys_width() == 0 || sys_height() == 0) { + if (!ui_nodes_show || kinc_window_width() == 0 || kinc_window_height() == 0) { return; } @@ -946,7 +946,7 @@ function ui_nodes_render() { } // Grid - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); let step: f32 = ui_nodes_grid_cell_w * nodes.zoom; let x: f32 = math_fmod(ui_nodes_PAN_X(), step) - step; let y: f32 = math_fmod(ui_nodes_PAN_Y(), step) - step; @@ -1110,7 +1110,7 @@ function ui_nodes_render() { } ///end - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); invert_y ? draw_scaled_image(img, tx, ty + th, tw, -th) : draw_scaled_image(img, tx, ty, tw, th); @@ -1124,9 +1124,9 @@ function ui_nodes_render() { } // Menu - g2_set_color(ui_nodes_ui.ops.theme.SEPARATOR_COL); + draw_set_color(ui_nodes_ui.ops.theme.SEPARATOR_COL); draw_filled_rect(0, ui_ELEMENT_H(ui_nodes_ui), ui_nodes_ww, ui_ELEMENT_H(ui_nodes_ui) + ui_ELEMENT_OFFSET(ui_nodes_ui) * 2); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); let start_y: i32 = ui_ELEMENT_H(ui_nodes_ui) + ui_ELEMENT_OFFSET(ui_nodes_ui); ui_nodes_ui._x = 0; diff --git a/base/sources/ts/ui_status.ts b/base/sources/ts/ui_status.ts index f9eab756..fda4f767 100644 --- a/base/sources/ts/ui_status.ts +++ b/base/sources/ts/ui_status.ts @@ -6,10 +6,10 @@ function ui_status_init() { function ui_status_width(): i32 { ///if (is_paint || is_sculpt) - return sys_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W]; + return kinc_window_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W]; ///end ///if is_lab - return sys_width(); + return kinc_window_width(); ///end } @@ -18,11 +18,11 @@ function ui_status_render_ui() { let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; - if (ui_window(ui_base_hwnds[tab_area_t.STATUS], app_x(), sys_height() - statush, ui_status_width(), statush)) { + if (ui_window(ui_base_hwnds[tab_area_t.STATUS], app_x(), kinc_window_height() - statush, ui_status_width(), statush)) { ui._y += 2; // Border - g2_set_color(ui.ops.theme.SEPARATOR_COL); + draw_set_color(ui.ops.theme.SEPARATOR_COL); draw_filled_rect(0, 0, 1, ui._window_h); draw_filled_rect(ui._window_w - 1, 0, 1, ui._window_h); diff --git a/base/sources/ts/ui_toolbar.ts b/base/sources/ts/ui_toolbar.ts index 2636db4d..9b878624 100644 --- a/base/sources/ts/ui_toolbar.ts +++ b/base/sources/ts/ui_toolbar.ts @@ -94,7 +94,7 @@ function ui_toolbar_render_ui() { let x: i32 = 0; let y: i32 = ui_header_h; - let h: i32 = sys_height() - ui_header_h; + let h: i32 = kinc_window_height() - ui_header_h; let _WINDOW_BG_COL: i32 = ui.ops.theme.WINDOW_BG_COL; if (context_is_floating_toolbar()) { @@ -246,6 +246,6 @@ function ui_toolbar_tool_properties_menu() { function ui_toolbar_draw_highlight() { let ui: ui_t = ui_base_ui; let size: i32 = ui_toolbar_w - 4; - g2_set_color(ui.ops.theme.HIGHLIGHT_COL); + draw_set_color(ui.ops.theme.HIGHLIGHT_COL); ui_draw_rect(true, ui._x + -1, ui._y + 2, size + 2, size + 2); } diff --git a/base/sources/ts/ui_view2d.ts b/base/sources/ts/ui_view2d.ts index f2937615..23bdf7ab 100644 --- a/base/sources/ts/ui_view2d.ts +++ b/base/sources/ts/ui_view2d.ts @@ -81,7 +81,7 @@ function ui_view2d_render() { if (!ui_view2d_show) { return; } - if (sys_width() == 0 || sys_height() == 0) { + if (kinc_window_width() == 0 || kinc_window_height() == 0) { return; } @@ -117,8 +117,8 @@ function ui_view2d_render() { ui_begin(ui_view2d_ui); let headerh: i32 = config_raw.layout[layout_size_t.HEADER] == 1 ? ui_header_h * 2 : ui_header_h; - let apph: i32 = sys_height() - config_raw.layout[layout_size_t.STATUS_H] + headerh; - ui_view2d_wh = sys_height() - config_raw.layout[layout_size_t.STATUS_H]; + let apph: i32 = kinc_window_height() - config_raw.layout[layout_size_t.STATUS_H] + headerh; + ui_view2d_wh = kinc_window_height() - config_raw.layout[layout_size_t.STATUS_H]; if (ui_nodes_show) { ui_view2d_wh -= config_raw.layout[layout_size_t.NODES_H]; @@ -132,7 +132,7 @@ function ui_view2d_render() { ui_tab(ui_handle(__ID__), tr("2D View")); // Grid - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); let step: f32 = ui_nodes_grid_cell_w * ui_view2d_pan_scale; let x: f32 = math_fmod(ui_view2d_pan_x, step) - step; let y: f32 = math_fmod(ui_view2d_pan_y, step) - step; @@ -291,9 +291,9 @@ function ui_view2d_render() { // Menu let ew: i32 = math_floor(ui_ELEMENT_W(ui_view2d_ui)); - g2_set_color(ui_view2d_ui.ops.theme.SEPARATOR_COL); + draw_set_color(ui_view2d_ui.ops.theme.SEPARATOR_COL); draw_filled_rect(0, ui_ELEMENT_H(ui_view2d_ui), ui_view2d_ww, ui_ELEMENT_H(ui_view2d_ui) + ui_ELEMENT_OFFSET(ui_view2d_ui) * 2); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); let start_y: f32 = ui_ELEMENT_H(ui_view2d_ui) + ui_ELEMENT_OFFSET(ui_view2d_ui); ui_view2d_ui._x = 2; diff --git a/base/sources/ts/util_render.ts b/base/sources/ts/util_render.ts index e3a4abe6..f0ec8e84 100644 --- a/base/sources/ts/util_render.ts +++ b/base/sources/ts/util_render.ts @@ -148,7 +148,7 @@ function util_render_make_text_preview() { if (g2_in_use) g2_end(); let text: string = context_raw.text_tool_text; - let font: g2_font_t = context_raw.font.font; + let font: draw_font_t = context_raw.font.font; let font_size: i32 = util_render_font_preview_size; let text_w: i32 = math_floor(g2_font_width(font, font_size, text)); let text_h: i32 = math_floor(g2_font_height(font, font_size)); @@ -168,10 +168,10 @@ function util_render_make_text_preview() { ///end } g2_begin(context_raw.text_tool_image); - g2_clear(0xff000000); + g4_clear(0xff000000); g2_set_font(font); g2_set_font_size(font_size); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); draw_string(text, tex_w / 2 - text_w / 2, tex_w / 2 - text_h / 2); g2_end(); @@ -184,7 +184,7 @@ function util_render_make_font_preview() { if (g2_in_use) g2_end(); let text: string = "Abg"; - let font: g2_font_t = context_raw.font.font; + let font: draw_font_t = context_raw.font.font; let font_size: i32 = util_render_font_preview_size; let text_w: i32 = math_floor(g2_font_width(font, font_size, text)) + 8; let text_h: i32 = math_floor(g2_font_height(font, font_size)) + 8; @@ -193,10 +193,10 @@ function util_render_make_font_preview() { context_raw.font.image = image_create_render_target(tex_w, tex_w, tex_format_t.RGBA32); } g2_begin(context_raw.font.image); - g2_clear(0x00000000); + g4_clear(0x00000000); g2_set_font(font); g2_set_font_size(font_size); - g2_set_color(0xffffffff); + draw_set_color(0xffffffff); draw_string(text, tex_w / 2 - text_w / 2, tex_w / 2 - text_h / 2); g2_end(); context_raw.font.preview_ready = true; @@ -369,7 +369,7 @@ function util_render_make_brush_preview() { l = render_path_paint_live_layer; let target: image_t = context_raw.brush.image; g2_begin(target); - g2_clear(0x00000000); + g4_clear(0x00000000); g2_set_pipeline(pipes_copy); draw_scaled_image(l.texpaint, 0, 0, target.width, target.height); g2_set_pipeline(null); diff --git a/base/sources/ts/util_uv.ts b/base/sources/ts/util_uv.ts index 1f9c46e1..5af66513 100644 --- a/base/sources/ts/util_uv.ts +++ b/base/sources/ts/util_uv.ts @@ -35,8 +35,8 @@ function util_uv_cache_uv_map() { let texa: i16_array_t = mesh.vertex_arrays[2].values; let inda: u32_array_t = mesh.index_arrays[0].values; g2_begin(util_uv_uvmap); - g2_clear(0x00000000); - g2_set_color(0xffffffff); + g4_clear(0x00000000); + draw_set_color(0xffffffff); let strength: f32 = res_x > 2048 ? 2.0 : 1.0; let f: f32 = (1 / 32767) * util_uv_uvmap.width; for (let i: i32 = 0; i < math_floor(inda.length / 3); ++i) { @@ -74,13 +74,13 @@ function util_uv_cache_triangle_map() { let texa: i16_array_t = mesh.vertex_arrays[2].values; let inda: u32_array_t = mesh.index_arrays[0].values; g2_begin(util_uv_trianglemap); - g2_clear(0xff000000); + g4_clear(0xff000000); let f: f32 = (1 / 32767) * util_uv_trianglemap.width; let color: i32 = 0xff000001; for (let i: i32 = 0; i < math_floor(inda.length / 3); ++i) { if (color == 0xffffffff) color = 0xff000001; color++; - g2_set_color(color); + draw_set_color(color); let x1: f32 = (texa[inda[i * 3 ] * 2 ]) * f; let x2: f32 = (texa[inda[i * 3 + 1] * 2 ]) * f; let x3: f32 = (texa[inda[i * 3 + 2] * 2 ]) * f; diff --git a/base/tests/cube/sources/main.ts b/base/tests/cube/sources/main.ts index dae93aba..cc1e397d 100644 --- a/base/tests/cube/sources/main.ts +++ b/base/tests/cube/sources/main.ts @@ -1,7 +1,7 @@ // ../../../make --graphics vulkan --run function main() { - let ops: kinc_sys_ops_t = { + let ops: kinc_window_options_t = { title: "Empty", width: 1280, height: 720, diff --git a/base/tests/fall/sources/main.ts b/base/tests/fall/sources/main.ts index f2879a54..5711dcad 100644 --- a/base/tests/fall/sources/main.ts +++ b/base/tests/fall/sources/main.ts @@ -3,7 +3,7 @@ ///include "../../sources/libs/asim/asim.h" function main() { - let ops: kinc_sys_ops_t = { + let ops: kinc_window_options_t = { title: "Empty", width: 1280, height: 720, diff --git a/base/tools/pad/sources/main.ts b/base/tools/pad/sources/main.ts index 6e907de5..d8dddc90 100644 --- a/base/tools/pad/sources/main.ts +++ b/base/tools/pad/sources/main.ts @@ -76,7 +76,7 @@ function main() { text_handle.text = storage.text; - let ops: kinc_sys_ops_t = { + let ops: kinc_window_options_t = { title: "ArmorPad", x: storage.window_x, y: storage.window_y, @@ -180,8 +180,8 @@ function list_folder(path: string) { } function render() { - storage.window_w = sys_width(); - storage.window_h = sys_height(); + storage.window_w = kinc_window_width(); + storage.window_h = kinc_window_height(); storage.window_x = kinc_window_x(); storage.window_y = kinc_window_y(); if (ui.input_dx != 0 || ui.input_dy != 0) { @@ -190,7 +190,7 @@ function render() { ui_begin(ui); - if (ui_window(sidebar_handle, 0, 0, storage.sidebar_w, sys_height(), false)) { + if (ui_window(sidebar_handle, 0, 0, storage.sidebar_w, kinc_window_height(), false)) { if (storage.project != "") { list_folder(storage.project); } @@ -199,12 +199,12 @@ function render() { } } - ui_fill(sys_width() - minimap_w, 0, minimap_w, UI_ELEMENT_H() + UI_ELEMENT_OFFSET() + 1, theme.SEPARATOR_COL); - ui_fill(storage.sidebar_w, 0, 1, sys_height(), theme.SEPARATOR_COL); + ui_fill(kinc_window_width() - minimap_w, 0, minimap_w, UI_ELEMENT_H() + UI_ELEMENT_OFFSET() + 1, theme.SEPARATOR_COL); + ui_fill(storage.sidebar_w, 0, 1, kinc_window_height(), theme.SEPARATOR_COL); let editor_updated: bool = false; - if (ui_window(editor_handle, storage.sidebar_w + 1, 0, sys_width() - storage.sidebar_w - minimap_w, sys_height(), false)) { + if (ui_window(editor_handle, storage.sidebar_w + 1, 0, kinc_window_width() - storage.sidebar_w - minimap_w, kinc_window_height(), false)) { editor_updated = true; let htab: ui_handle_t = ui_handle(__ID__); let file_name: string = substring(storage.file, string_last_index_of(storage.file, "/") + 1, storage.file.length); @@ -241,7 +241,7 @@ function render() { } // Minimap controls - let minimap_x: i32 = sys_width() - minimap_w; + let minimap_x: i32 = kinc_window_width() - minimap_w; let minimap_y: i32 = window_header_h + 1; let redraw: bool = false; if (ui.input_started && hit_test(ui.input_x, ui.input_y, minimap_x + 5, minimap_y, minimap_w, minimap_h)) { @@ -312,8 +312,8 @@ function build_project() { } function draw_minimap() { - if (minimap_h != sys_height()) { - minimap_h = sys_height(); + if (minimap_h != kinc_window_height()) { + minimap_h = kinc_window_height(); if (minimap != null) { image_unload(minimap); } @@ -321,8 +321,8 @@ function draw_minimap() { } g2_begin(minimap); - g2_clear(theme.SEPARATOR_COL); - g2_set_color(0xff333333); + g4_clear(theme.SEPARATOR_COL); + draw_set_color(0xff333333); let lines: string[] = string_split(storage.text, "\n"); let minimap_full_h: i32 = lines.length * 2; let scroll_progress: f32 = -editor_handle.scroll_offset / (lines.length * UI_ELEMENT_H()); @@ -348,8 +348,8 @@ function draw_minimap() { // Current position let visible_area: i32 = out_of_screen > 0 ? minimap_h : minimap_full_h; - g2_set_color(0x11ffffff); - minimap_box_h = math_floor((sys_height() - window_header_h) / UI_ELEMENT_H() * 2); + draw_set_color(0x11ffffff); + minimap_box_h = math_floor((kinc_window_height() - window_header_h) / UI_ELEMENT_H() * 2); g2_fill_rect(0, scroll_progress * visible_area, minimap_w, minimap_box_h); g2_end(); }