2026-03-06 12:56:38 +01:00
|
|
|
void console_draw_toast(string_t *s) {
|
|
|
|
|
draw_begin(null, false, 0);
|
2025-03-02 21:07:17 +01:00
|
|
|
draw_set_color(0x55000000);
|
2025-03-09 17:02:12 +01:00
|
|
|
draw_filled_rect(0, 0, iron_window_width(), iron_window_height());
|
2026-03-06 12:56:38 +01:00
|
|
|
f32 scale = UI_SCALE();
|
|
|
|
|
f32 x = iron_window_width() / (float)2;
|
|
|
|
|
f32 y = iron_window_height() - 200 * scale;
|
2025-03-02 19:44:26 +01:00
|
|
|
draw_filled_rect(x - 200 * scale, y, 400 * scale, 80 * scale);
|
2025-03-10 20:26:45 +01:00
|
|
|
draw_set_font(base_font, math_floor(22 * scale));
|
2025-03-02 21:07:17 +01:00
|
|
|
draw_set_color(0xffffffff);
|
2026-03-06 12:56:38 +01:00
|
|
|
draw_string(s, x - draw_string_width(draw_font, draw_font_size, s) / (float)2, y + 40 * scale - draw_font_height(draw_font, draw_font_size) / (float)2);
|
2025-06-21 16:49:53 +02:00
|
|
|
draw_end();
|
2024-03-09 14:52:33 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-06 12:56:38 +01:00
|
|
|
void console_toast(string_t *s) {
|
2024-03-09 14:52:33 +01:00
|
|
|
// Show a popup message
|
2026-03-06 12:56:38 +01:00
|
|
|
gpu_texture_t *current = _draw_current;
|
|
|
|
|
bool in_use = gpu_in_use;
|
2026-01-10 13:50:53 +01:00
|
|
|
if (in_use)
|
2025-10-15 18:39:55 +02:00
|
|
|
draw_end();
|
2024-03-09 14:52:33 +01:00
|
|
|
console_trace(s);
|
2025-08-05 22:53:56 +02:00
|
|
|
console_draw_toast(s);
|
2026-01-10 13:50:53 +01:00
|
|
|
if (in_use)
|
2026-03-06 12:56:38 +01:00
|
|
|
draw_begin(current, false, 0);
|
2024-03-09 14:52:33 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-06 12:56:38 +01:00
|
|
|
void console_draw_progress(any _) {
|
2024-03-09 14:52:33 +01:00
|
|
|
console_draw_toast(console_progress_text);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-06 12:56:38 +01:00
|
|
|
void console_progress(string_t *s) {
|
2024-03-09 14:52:33 +01:00
|
|
|
// Keep popup message displayed until s == null
|
|
|
|
|
if (s == null) {
|
2025-08-16 20:43:45 +02:00
|
|
|
sys_remove_render(console_draw_progress);
|
2024-03-09 14:52:33 +01:00
|
|
|
}
|
|
|
|
|
else if (console_progress_text == null) {
|
2026-03-06 12:56:38 +01:00
|
|
|
sys_notify_on_render(console_draw_progress, null);
|
2024-03-09 14:52:33 +01:00
|
|
|
}
|
2024-03-20 16:13:54 +01:00
|
|
|
if (s != null) {
|
|
|
|
|
console_trace(s);
|
|
|
|
|
}
|
2026-03-06 12:56:38 +01:00
|
|
|
gc_unroot(console_progress_text);
|
|
|
|
|
console_progress_text = string_copy(s);
|
|
|
|
|
gc_root(console_progress_text);
|
2024-10-25 18:58:10 +02:00
|
|
|
|
|
|
|
|
// Pass one frame to immediately show the message
|
2025-03-10 20:26:45 +01:00
|
|
|
draw_end();
|
2025-03-11 19:49:42 +01:00
|
|
|
sys_render();
|
2026-03-06 12:56:38 +01:00
|
|
|
draw_begin(null, false, 0);
|
2025-06-19 19:55:16 +02:00
|
|
|
gpu_present();
|
2025-08-15 22:04:07 +02:00
|
|
|
ui_end_input();
|
2024-03-09 14:52:33 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-06 12:56:38 +01:00
|
|
|
void console_info(string_t *s) {
|
2024-03-09 14:52:33 +01:00
|
|
|
console_message_timer = 5.0;
|
2026-03-06 12:56:38 +01:00
|
|
|
gc_unroot(console_message);
|
|
|
|
|
console_message = string_copy(s);
|
|
|
|
|
gc_root(console_message);
|
2024-03-09 14:52:33 +01:00
|
|
|
console_message_color = 0x00000000;
|
|
|
|
|
base_redraw_status();
|
|
|
|
|
console_trace(s);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-06 12:56:38 +01:00
|
|
|
void console_error(string_t *s) {
|
2024-03-09 14:52:33 +01:00
|
|
|
console_message_timer = 8.0;
|
2026-03-06 12:56:38 +01:00
|
|
|
gc_unroot(console_message);
|
|
|
|
|
console_message = string_copy(s);
|
|
|
|
|
gc_root(console_message);
|
2024-03-09 14:52:33 +01:00
|
|
|
console_message_color = 0xffaa0000;
|
|
|
|
|
base_redraw_status();
|
|
|
|
|
console_trace(s);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-06 12:56:38 +01:00
|
|
|
void console_log(string_t *s) {
|
2024-03-09 14:52:33 +01:00
|
|
|
console_trace(s);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-06 12:56:38 +01:00
|
|
|
void console_trace(string_t *s) {
|
2025-03-09 17:02:12 +01:00
|
|
|
iron_log(s);
|
2024-03-09 14:52:33 +01:00
|
|
|
base_redraw_console();
|
2024-05-03 21:29:39 +02:00
|
|
|
array_insert(console_last_traces, 0, s);
|
2026-03-06 12:56:38 +01:00
|
|
|
if (console_last_traces->length > 100) {
|
2024-05-03 21:29:39 +02:00
|
|
|
array_pop(console_last_traces);
|
2024-03-20 16:13:54 +01:00
|
|
|
}
|
2024-03-09 14:52:33 +01:00
|
|
|
}
|