diff options
| -rw-r--r-- | changes.txt | 9 | ||||
| -rw-r--r-- | data/translations/en-English.mo | bin | 2859 -> 2915 bytes | |||
| -rw-r--r-- | data/translations/nl-Dutch.mo | bin | 3043 -> 3104 bytes | |||
| -rw-r--r-- | src/mo_edit.c | 720 | ||||
| -rw-r--r-- | src/project_base.h | 1 | ||||
| -rw-r--r-- | src/settings.c | 138 |
6 files changed, 444 insertions, 424 deletions
diff --git a/changes.txt b/changes.txt new file mode 100644 index 0000000..ba8d69b --- /dev/null +++ b/changes.txt @@ -0,0 +1,9 @@ + +1.1 (not released) +- show active project path in title +- decreased binary size +- fix bug where settings was being saved without clicking the save button +- lower cpu usage when idle +- small ui improvements +1.0 +- initial release
\ No newline at end of file diff --git a/data/translations/en-English.mo b/data/translations/en-English.mo Binary files differindex cf9fb0f..cf260aa 100644 --- a/data/translations/en-English.mo +++ b/data/translations/en-English.mo diff --git a/data/translations/nl-Dutch.mo b/data/translations/nl-Dutch.mo Binary files differindex 2bd5859..32bb9ca 100644 --- a/data/translations/nl-Dutch.mo +++ b/data/translations/nl-Dutch.mo diff --git a/src/mo_edit.c b/src/mo_edit.c index e7b0bb6..c8d5576 100644 --- a/src/mo_edit.c +++ b/src/mo_edit.c @@ -10,8 +10,6 @@ s32 global_language_id = 1;
char project_path[MAX_INPUT_LENGTH];
-// TODO(Aldrik): create new project button in menu
-
typedef struct t_language
{
char *name;
@@ -399,6 +397,10 @@ void load_config(settings_config *config) if (platform_directory_exists(project_path))
{
+ char title[MAX_INPUT_LENGTH];
+ snprintf(title, MAX_INPUT_LENGTH, "mo-edit > %s", project_path);
+ platform_window_set_title(main_window, title);
+
load_project_from_folder(project_path);
}
else
@@ -485,8 +487,6 @@ int main(int argc, char **argv) platform_window window = platform_open_window("mo-edit", window_w, window_h, 0, 0, 800, 600);
main_window = &window;
- //validate_license();
-
settings_page_create();
load_available_localizations();
@@ -535,8 +535,6 @@ int main(int argc, char **argv) platform_window_make_current(&window);
- //if (!license_check_status()) break;
-
static bool icon_loaded = false;
if (!icon_loaded && logo_small_img->loaded)
{
@@ -553,441 +551,457 @@ int main(int argc, char **argv) global_ui_context.keyboard = &keyboard;
global_ui_context.mouse = &mouse;
- render_clear();
- camera_apply_transformations(&window, &camera);
+ if (assets_do_post_process())
+ window.do_draw = true;
- global_ui_context.layout.width = global_ui_context.layout.active_window->width;
- // begin ui
+ if (window.has_focus)
+ window.do_draw = true;
- ui_begin(1);
+ if (window.do_draw)
{
- render_rectangle(0, 0, main_window->width, main_window->height, global_ui_context.style.background);
+ window.do_draw = false;
- ui_begin_menu_bar();
- {
- if (ui_push_menu(localize("file")))
- {
- if (ui_push_menu_item(localize("new_project"), ""))
- {
- start_new_project();
- }
- if (ui_push_menu_item(localize("load_project"), "Ctrl + O"))
- {
- load_project();
- }
- if (ui_push_menu_item(localize("save_project"), "Ctrl + S"))
- {
- if (current_project)
- {
- if (string_equals(project_path, ""))
- save_project();
- else
- save_project_to_folder(project_path);
- }
- else
- {
- platform_show_message(main_window, localize("no_project_to_save"), localize("error_saving_project"));
- }
- }
- if (ui_push_menu_item(localize("save_project_as"), "Ctrl + A"))
- {
- if (current_project)
- {
- save_project();
- }
- else
- {
- platform_show_message(main_window, localize("no_project_to_save"), localize("error_saving_project"));
- }
- }
- // TODO(Aldrik): localize
- calculate_recent_project_path_max_len();
- ui_begin_menu_submenu(&submenu_recent_projects, localize("recent_projects"));
- {
- for (s32 i = recent_projects_list.length-1; i >= 0; i--)
- {
- char *rp = array_at(&recent_projects_list, i);
- if (ui_push_menu_item(rp, ""))
- {
- load_project_from_folder(rp);
- }
- }
-
- }
- ui_end_menu_submenu();
- if (ui_push_menu_item(localize("close_project"), ""))
- {
- if (!string_equals(project_path, ""))
- {
- add_recent_project_path(project_path);
- }
-
- current_project = 0;
- project_path[0] = 0;
- }
- ui_push_menu_item_separator();
- if (ui_push_menu_item(localize("quit"), "Ctrl + Q"))
- {
- window.is_open = false;
- }
- }
- if (ui_push_menu(localize("options")))
- {
- if (ui_push_menu_item(localize("settings"), ""))
- {
- settings_page_show();
- }
- }
- }
- ui_end_menu_bar();
- ui_push_separator();
+ render_clear();
+ camera_apply_transformations(&window, &camera);
- global_ui_context.layout.width = 300;
- ui_push_vertical_dragbar();
+ global_ui_context.layout.width = global_ui_context.layout.active_window->width;
+ // begin ui
- if (current_project)
+ ui_begin(1);
{
- ui_block_begin(LAYOUT_HORIZONTAL);
- {
- if (ui_push_button_image(&btn_summary, "", list_img))
- {
- current_project->selected_term_index = -1;
- }
- ui_push_tooltip(localize("tooltip_project_overview"));
-
- ui_push_textf_width(font_medium, localize("terms"), global_ui_context.layout.width-106);
-
- if (ui_push_button_image(&btn_new_term, "", add_img))
- {
- select_term(add_term_to_project());
- }
- ui_push_tooltip(localize("tooltip_create_new_term"));
-
- //ui_push_button_image(&btn_summary, "", delete_img);
-
- }
- ui_block_end();
+ render_rectangle(0, 0, main_window->width, main_window->height, global_ui_context.style.background);
- ui_block_begin(LAYOUT_HORIZONTAL);
+ ui_begin_menu_bar();
{
- TEXTBOX_WIDTH = 280;
- ui_push_textbox(&tb_filter, localize("filter_terms"));
- }
- ui_block_end();
-
- ui_push_separator();
-
- // reset scroll if filter text changed
- if (tb_filter.state && keyboard.text_changed)
- {
- term_scroll.scroll = 0;
- }
-
- term_scroll.height = main_window->height-global_ui_context.layout.offset_y+8;
- ui_scroll_begin(&term_scroll);
- {
- for (s32 i = 0; i < current_project->terms.length; i++)
+ if (ui_push_menu(localize("file")))
{
- term *t = array_at(¤t_project->terms, i);
-
- if (!strlen(tb_filter.buffer) || string_contains(t->name, tb_filter.buffer))
- {
- bool removed = false;
- if (ui_push_button_image_with_confirmation(&t->btn_remove, "", delete_img))
+ if (ui_push_menu_item(localize("new_project"), ""))
+ {
+ start_new_project();
+ }
+ if (ui_push_menu_item(localize("load_project"), "Ctrl + O"))
+ {
+ load_project();
+ }
+ if (ui_push_menu_item(localize("save_project"), "Ctrl + S"))
+ {
+ if (current_project)
{
- removed = true;
+ if (string_equals(project_path, ""))
+ save_project();
+ else
+ save_project_to_folder(project_path);
}
- ui_push_tooltip(localize("tooltip_delete_term"));
-
- //ui_push_image(exclaim_img, 14, 14, 1, rgb(255,255,255));
-
- if (i == current_project->selected_term_index)
+ else
{
- ui_push_rect(10, global_ui_context.style.textbox_active_border);
+ platform_show_message(main_window, localize("no_project_to_save"), localize("error_saving_project"));
}
- else if (term_has_missing_translations(t))
+ }
+ if (ui_push_menu_item(localize("save_project_as"), "Ctrl + A"))
+ {
+ if (current_project)
{
- ui_push_rect(10, MISSING_TRANSLATION_COLOR);
+ save_project();
}
else
{
- ui_push_rect(10, global_ui_context.style.background);
+ platform_show_message(main_window, localize("no_project_to_save"), localize("error_saving_project"));
}
-
- if (ui_push_text_width(t->name, global_ui_context.layout.width-100, true))
+ }
+
+ calculate_recent_project_path_max_len();
+ ui_begin_menu_submenu(&submenu_recent_projects, localize("recent_projects"));
+ {
+ for (s32 i = recent_projects_list.length-1; i >= 0; i--)
{
- select_term(i);
+ char *rp = array_at(&recent_projects_list, i);
+ if (ui_push_menu_item(rp, ""))
+ {
+ load_project_from_folder(rp);
+ term_scroll.scroll = 0;
+
+ char title[MAX_INPUT_LENGTH];
+ snprintf(title, MAX_INPUT_LENGTH, "mo-edit > %s", project_path);
+ platform_window_set_title(main_window, title);
+ }
}
- ui_block_end();
-
- if (removed)
+ }
+ ui_end_menu_submenu();
+ if (ui_push_menu_item(localize("close_project"), ""))
+ {
+ if (!string_equals(project_path, ""))
{
- remove_term_from_project(i);
- --i;
- if (i >= 0) select_term(i);
+ add_recent_project_path(project_path);
}
+
+ current_project = 0;
+ project_path[0] = 0;
+ }
+ ui_push_menu_item_separator();
+ if (ui_push_menu_item(localize("quit"), "Ctrl + Q"))
+ {
+ window.is_open = false;
+ }
+ }
+ if (ui_push_menu(localize("options")))
+ {
+ if (ui_push_menu_item(localize("settings"), ""))
+ {
+ settings_page_show();
}
}
}
- ui_scroll_end();
- }
- else
- {
- if (ui_push_button(&btn_new_project, localize("create_new_project")))
- {
- start_new_project();
- }
- }
-
- global_ui_context.layout.width = main_window->width - 310;
-
- global_ui_context.layout.offset_x = 310;
- global_ui_context.layout.offset_y = MENU_BAR_HEIGHT + WIDGET_PADDING;
-
- if (current_project && current_project->selected_term_index >= 0)
- {
- if (keyboard_is_key_down(&keyboard, KEY_LEFT_CONTROL) && keyboard_is_key_pressed(&keyboard, KEY_S))
- {
- save_term_changes();
- }
+ ui_end_menu_bar();
+ ui_push_separator();
- term *t = array_at(¤t_project->terms,
- current_project->selected_term_index);
+ global_ui_context.layout.width = 300;
+ ui_push_vertical_dragbar();
- ui_block_begin(LAYOUT_HORIZONTAL);
+ if (current_project)
{
- // editor
+ ui_block_begin(LAYOUT_HORIZONTAL);
+ {
+ if (ui_push_button_image(&btn_summary, "", list_img))
+ {
+ current_project->selected_term_index = -1;
+ }
+ ui_push_tooltip(localize("tooltip_project_overview"));
+
+ ui_push_textf_width(font_medium, localize("terms"), global_ui_context.layout.width-106);
+
+ if (ui_push_button_image(&btn_new_term, "", add_img))
+ {
+ select_term(add_term_to_project());
+ }
+ ui_push_tooltip(localize("tooltip_create_new_term"));
+
+ //ui_push_button_image(&btn_summary, "", delete_img);
+
+ }
+ ui_block_end();
- if (string_equals(tb_new_term.buffer, t->name))
- ui_push_rect(10, global_ui_context.style.background);
- else
- ui_push_rect(10, UNSAVED_CHANGES_COLOR);
+ ui_block_begin(LAYOUT_HORIZONTAL);
+ {
+ TEXTBOX_WIDTH = 280;
+ ui_push_textbox(&tb_filter, localize("filter_terms"));
+ }
+ ui_block_end();
- ui_push_textbox(&tb_new_term, localize("term_name"));
+ ui_push_separator();
- if (ui_push_button_image(&btn_set_term_name, "", set_img))
+ // reset scroll if filter text changed
+ if (tb_filter.state && keyboard.text_changed)
{
- save_term_changes();
+ term_scroll.scroll = 0;
}
- ui_push_tooltip(localize("tooltip_save_term"));
- }
- ui_block_end();
-
- global_ui_context.layout.offset_x = 310;
- ui_push_separator();
-
- trans_scroll.height = main_window->height-global_ui_context.layout.offset_y+WIDGET_PADDING;
-
- ui_scroll_begin(&trans_scroll);
- {
- if (!current_project->languages.length)
+
+ term_scroll.height = main_window->height-global_ui_context.layout.offset_y+8;
+ ui_scroll_begin(&term_scroll);
{
- ui_push_text(localize("no_languages_added"));
- }
- else
- {
- for (s32 i = 0; i < t->translations.length; i++)
+ for (s32 i = 0; i < current_project->terms.length; i++)
{
- translation *tr = array_at(&t->translations, i);
-
- TEXTBOX_WIDTH = global_ui_context.layout.width - 130;
-
- textbox_state *tbs = array_at(&tb_translation_list, i);
- if (!strlen(tbs->buffer))
- {
- ui_push_rect(10, MISSING_TRANSLATION_COLOR);
- }
- else if (string_equals(tbs->buffer,
- tr->value))
- {
- ui_push_rect(10, global_ui_context.style.background);
- }
- else
- {
- ui_push_rect(10, UNSAVED_CHANGES_COLOR);
- }
+ term *t = array_at(¤t_project->terms, i);
- ui_push_textbox(tbs, "");
-
- language *l = get_language_by_id(tr->language_id);
- ui_push_text(l->name);
-
- global_ui_context.layout.offset_y += TEXTBOX_HEIGHT + WIDGET_PADDING;
- global_ui_context.layout.offset_x = 310;
-
- if (keyboard_is_key_pressed(&keyboard, KEY_TAB) && tbs->state)
+ if (!strlen(tb_filter.buffer) || string_contains(t->name, tb_filter.buffer))
{
- keyboard.input_keys[KEY_TAB] = false;
- tbs->state = false;
+ bool removed = false;
+ if (ui_push_button_image_with_confirmation(&t->btn_remove, "", delete_img))
+ {
+ removed = true;
+ }
+ ui_push_tooltip(localize("tooltip_delete_term"));
+
+ //ui_push_image(exclaim_img, 14, 14, 1, rgb(255,255,255));
- if (i+1 < t->translations.length)
+ if (i == current_project->selected_term_index)
{
- ui_set_textbox_active(array_at(&tb_translation_list, i+1));
+ ui_push_rect(10, global_ui_context.style.textbox_active_border);
+ }
+ else if (term_has_missing_translations(t))
+ {
+ ui_push_rect(10, MISSING_TRANSLATION_COLOR);
}
else
{
- ui_set_textbox_active(array_at(&tb_translation_list, 0));
+ ui_push_rect(10, global_ui_context.style.background);
+ }
+
+ if (ui_push_text_width(t->name, global_ui_context.layout.width-100, true))
+ {
+ select_term(i);
+ }
+
+ ui_block_end();
+
+ if (removed)
+ {
+ remove_term_from_project(i);
+ --i;
+ if (i >= 0) select_term(i);
}
}
}
}
+ ui_scroll_end();
}
- ui_scroll_end();
- }
- else if (current_project)
- {
- // overview
- ui_block_begin(LAYOUT_HORIZONTAL);
+ else
{
- ui_push_textf_width(font_medium, localize("overview"), 100);
-
- char info_text[60];
- sprintf(info_text, localize("info_text"), current_project->terms.length, current_project->languages.length);
-
- color c = global_ui_context.style.foreground;
- global_ui_context.style.foreground = rgb(110,110,110);
- ui_push_textf(font_small, info_text);
- global_ui_context.style.foreground = c;
+ if (ui_push_button(&btn_new_project, localize("create_new_project")))
+ {
+ start_new_project();
+ }
}
- ui_block_end();
- ui_push_separator();
+ global_ui_context.layout.width = main_window->width - 310;
+
+ global_ui_context.layout.offset_x = 310;
+ global_ui_context.layout.offset_y = MENU_BAR_HEIGHT + WIDGET_PADDING;
- ui_block_begin(LAYOUT_HORIZONTAL);
+ if (current_project && current_project->selected_term_index >= 0)
{
- bool selected = tb_new_language.state;
- ui_push_textbox(&tb_new_language, localize("add_language"));
-
- if (keyboard_is_key_pressed(&keyboard, KEY_ENTER) && selected)
+ if (keyboard_is_key_down(&keyboard, KEY_LEFT_CONTROL) && keyboard_is_key_pressed(&keyboard, KEY_S))
{
- add_language_to_project(tb_new_language.buffer);
- ui_set_textbox_text(&tb_new_language, "");
- keyboard_set_input_text(&keyboard, "");
- tb_new_language.state = true;
+ save_term_changes();
}
- if (ui_push_button(&btn_new_language, localize("add")))
+ term *t = array_at(¤t_project->terms,
+ current_project->selected_term_index);
+
+ ui_block_begin(LAYOUT_HORIZONTAL);
{
- add_language_to_project(tb_new_language.buffer);
- ui_set_textbox_text(&tb_new_language, "");
- keyboard_set_input_text(&keyboard, "");
- tb_new_language.state = true;
+ // editor
+
+ if (string_equals(tb_new_term.buffer, t->name))
+ ui_push_rect(10, global_ui_context.style.background);
+ else
+ ui_push_rect(10, UNSAVED_CHANGES_COLOR);
+
+ ui_push_textbox(&tb_new_term, localize("term_name"));
+
+ if (ui_push_button_image(&btn_set_term_name, "", set_img))
+ {
+ save_term_changes();
+ }
+ ui_push_tooltip(localize("tooltip_save_term"));
}
- ui_push_tooltip(localize("tooltip_add_language"));
+ ui_block_end();
+
+ global_ui_context.layout.offset_x = 310;
+ ui_push_separator();
+
+ trans_scroll.height = main_window->height-global_ui_context.layout.offset_y+WIDGET_PADDING;
- if (!string_equals(tb_new_language.buffer, ""))
+ ui_scroll_begin(&trans_scroll);
{
- ui_block_end();
- char filename_buffer[MAX_INPUT_LENGTH];
- filename_buffer[0] = 0;
- string_appendn(filename_buffer, localize("filename"), MAX_INPUT_LENGTH);
- string_appendn(filename_buffer, ": ", MAX_INPUT_LENGTH);
- string_appendn(filename_buffer, tb_new_language.buffer, MAX_INPUT_LENGTH);
- string_appendn(filename_buffer, ".mo", MAX_INPUT_LENGTH);
- color c = global_ui_context.style.foreground;
- global_ui_context.style.foreground = rgb(110,110,110);
- ui_push_textf(font_mini, filename_buffer);
- global_ui_context.style.foreground = c;
+ if (!current_project->languages.length)
+ {
+ ui_push_text(localize("no_languages_added"));
+ }
+ else
+ {
+ for (s32 i = 0; i < t->translations.length; i++)
+ {
+ translation *tr = array_at(&t->translations, i);
+
+ TEXTBOX_WIDTH = global_ui_context.layout.width - 130;
+
+ textbox_state *tbs = array_at(&tb_translation_list, i);
+ if (!strlen(tbs->buffer))
+ {
+ ui_push_rect(10, MISSING_TRANSLATION_COLOR);
+ }
+ else if (string_equals(tbs->buffer,
+ tr->value))
+ {
+ ui_push_rect(10, global_ui_context.style.background);
+ }
+ else
+ {
+ ui_push_rect(10, UNSAVED_CHANGES_COLOR);
+ }
+
+ ui_push_textbox(tbs, "");
+
+ language *l = get_language_by_id(tr->language_id);
+ ui_push_text(l->name);
+
+ global_ui_context.layout.offset_y += TEXTBOX_HEIGHT + WIDGET_PADDING;
+ global_ui_context.layout.offset_x = 310;
+
+ if (keyboard_is_key_pressed(&keyboard, KEY_TAB) && tbs->state)
+ {
+ keyboard.input_keys[KEY_TAB] = false;
+ tbs->state = false;
+
+ if (i+1 < t->translations.length)
+ {
+ ui_set_textbox_active(array_at(&tb_translation_list, i+1));
+ }
+ else
+ {
+ ui_set_textbox_active(array_at(&tb_translation_list, 0));
+ }
+ }
+ }
+ }
}
+ ui_scroll_end();
}
- ui_block_end();
-
- if (dd_available_countries.selected_index >= 0)
- ui_push_separator();
-
- // languages
- lang_scroll.height = main_window->height-global_ui_context.layout.offset_y+WIDGET_PADDING;
- ui_scroll_begin(&lang_scroll);
+ else if (current_project)
{
- for (s32 i = 0; i < current_project->languages.length; i++)
+ // overview
+ ui_block_begin(LAYOUT_HORIZONTAL);
{
- language *lang = array_at(¤t_project->languages, i);
-
- bool pressed = false;
- if (ui_push_button_image_with_confirmation(&lang->btn_remove, "", delete_img))
- {
- pressed = true;
- }
- ui_push_tooltip(localize("tooltip_delete_language"));
+ ui_push_textf_width(font_medium, localize("overview"), 100);
- language *l = array_at(¤t_project->languages, i);
- ui_push_text_width(l->name, global_ui_context.layout.width-200, false);
+ char info_text[60];
+ sprintf(info_text, localize("info_text"), current_project->terms.length, current_project->languages.length);
color c = global_ui_context.style.foreground;
global_ui_context.style.foreground = rgb(110,110,110);
-
- char stats[50];
- sprintf(stats, localize("translated_stats"), get_translated_count_for_language(l->id), current_project->terms.length);
- ui_push_text(stats);
-
+ ui_push_textf(font_small, info_text);
global_ui_context.style.foreground = c;
+ }
+ ui_block_end();
+
+ ui_push_separator();
+
+ ui_block_begin(LAYOUT_HORIZONTAL);
+ {
+ bool selected = tb_new_language.state;
+ ui_push_textbox(&tb_new_language, localize("add_language"));
- if (pressed)
+ if (keyboard_is_key_pressed(&keyboard, KEY_ENTER) && selected)
{
- remove_language_from_project(l->id);
- i--;
+ add_language_to_project(tb_new_language.buffer);
+ ui_set_textbox_text(&tb_new_language, "");
+ keyboard_set_input_text(&keyboard, "");
+ tb_new_language.state = true;
}
- ui_block_end();
+ if (ui_push_button(&btn_new_language, localize("add")))
+ {
+ add_language_to_project(tb_new_language.buffer);
+ ui_set_textbox_text(&tb_new_language, "");
+ keyboard_set_input_text(&keyboard, "");
+ tb_new_language.state = true;
+ }
+ ui_push_tooltip(localize("tooltip_add_language"));
+
+ if (!string_equals(tb_new_language.buffer, ""))
+ {
+ ui_block_end();
+ char filename_buffer[MAX_INPUT_LENGTH];
+ filename_buffer[0] = 0;
+ string_appendn(filename_buffer, localize("filename"), MAX_INPUT_LENGTH);
+ string_appendn(filename_buffer, ": ", MAX_INPUT_LENGTH);
+ string_appendn(filename_buffer, tb_new_language.buffer, MAX_INPUT_LENGTH);
+ string_appendn(filename_buffer, ".mo", MAX_INPUT_LENGTH);
+ color c = global_ui_context.style.foreground;
+ global_ui_context.style.foreground = rgb(110,110,110);
+ ui_push_textf(font_mini, filename_buffer);
+ global_ui_context.style.foreground = c;
+ }
+ }
+ ui_block_end();
+
+ if (dd_available_countries.selected_index >= 0)
+ ui_push_separator();
+
+ // languages
+ lang_scroll.height = main_window->height-global_ui_context.layout.offset_y+WIDGET_PADDING;
+ ui_scroll_begin(&lang_scroll);
+ {
+ for (s32 i = 0; i < current_project->languages.length; i++)
+ {
+ language *lang = array_at(¤t_project->languages, i);
+
+ bool pressed = false;
+ if (ui_push_button_image_with_confirmation(&lang->btn_remove, "", delete_img))
+ {
+ pressed = true;
+ }
+ ui_push_tooltip(localize("tooltip_delete_language"));
+
+ language *l = array_at(¤t_project->languages, i);
+ ui_push_text_width(l->name, global_ui_context.layout.width-200, false);
+
+ color c = global_ui_context.style.foreground;
+ global_ui_context.style.foreground = rgb(110,110,110);
+
+ char stats[50];
+ sprintf(stats, localize("translated_stats"), get_translated_count_for_language(l->id), current_project->terms.length);
+ ui_push_text(stats);
+
+ global_ui_context.style.foreground = c;
+
+ if (pressed)
+ {
+ remove_language_from_project(l->id);
+ i--;
+ }
+
+ ui_block_end();
+ }
}
+ ui_scroll_end();
+ }
+ else
+ {
+ render_text(font_medium, 330, 50, localize("create_a_new_project"), global_ui_context.style.foreground);
+ render_text_cutoff(font_small, 330, 70,
+ localize("no_project_loaded_info"), global_ui_context.style.foreground, 400);
+
+ render_rectangle(330, 200, 10, 25, UNSAVED_CHANGES_COLOR);
+ render_text(font_small, 350, 208, localize("unsaved_changes"), global_ui_context.style.foreground);
+
+ render_rectangle(330, 240, 10, 25, MISSING_TRANSLATION_COLOR);
+ render_text(font_small, 350, 248, localize("missing_translation"), global_ui_context.style.foreground);
}
- ui_scroll_end();
- }
- else
- {
- render_text(font_medium, 330, 50, localize("create_a_new_project"), global_ui_context.style.foreground);
- render_text_cutoff(font_small, 330, 70,
- localize("no_project_loaded_info"), global_ui_context.style.foreground, 400);
-
- render_rectangle(330, 200, 10, 25, UNSAVED_CHANGES_COLOR);
- render_text(font_small, 350, 208, localize("unsaved_changes"), global_ui_context.style.foreground);
- render_rectangle(330, 240, 10, 25, MISSING_TRANSLATION_COLOR);
- render_text(font_small, 350, 248, localize("missing_translation"), global_ui_context.style.foreground);
- }
-
- if (keyboard_is_key_down(&keyboard, KEY_LEFT_CONTROL) && keyboard_is_key_pressed(&keyboard, KEY_O))
- {
- load_project();
- }
- if (keyboard_is_key_down(&keyboard, KEY_LEFT_CONTROL) && keyboard_is_key_pressed(&keyboard, KEY_S))
- {
- if (current_project)
+ if (keyboard_is_key_down(&keyboard, KEY_LEFT_CONTROL) && keyboard_is_key_pressed(&keyboard, KEY_O))
{
- if (string_equals(project_path, ""))
- save_project();
- else
- save_project_to_folder(project_path);
+ load_project();
}
- else
+ if (keyboard_is_key_down(&keyboard, KEY_LEFT_CONTROL) && keyboard_is_key_pressed(&keyboard, KEY_S))
{
- platform_show_message(main_window, localize("no_project_to_save"), localize("error_saving_project"));
+ if (current_project)
+ {
+ if (string_equals(project_path, ""))
+ save_project();
+ else
+ save_project_to_folder(project_path);
+ }
+ else
+ {
+ platform_show_message(main_window, localize("no_project_to_save"), localize("error_saving_project"));
+ }
}
- }
- if (keyboard_is_key_down(&keyboard, KEY_LEFT_CONTROL) && keyboard_is_key_pressed(&keyboard, KEY_A))
- {
- if (current_project)
+ if (keyboard_is_key_down(&keyboard, KEY_LEFT_CONTROL) && keyboard_is_key_pressed(&keyboard, KEY_A))
{
- save_project();
+ if (current_project)
+ {
+ save_project();
+ }
+ else
+ {
+ platform_show_message(main_window, localize("no_project_to_save"), localize("error_saving_project"));
+ }
}
- else
+ if (keyboard_is_key_down(&keyboard, KEY_LEFT_CONTROL) && keyboard_is_key_pressed(&keyboard, KEY_Q))
{
- platform_show_message(main_window, localize("no_project_to_save"), localize("error_saving_project"));
+ window.is_open = false;
}
}
- if (keyboard_is_key_down(&keyboard, KEY_LEFT_CONTROL) && keyboard_is_key_pressed(&keyboard, KEY_Q))
- {
- window.is_open = false;
- }
+ ui_end();
+ // end ui
+
+ update_render_notifications();
+
+ platform_window_swap_buffers(&window);
}
- ui_end();
- // end ui
-
- update_render_notifications();
- assets_do_post_process();
- platform_window_swap_buffers(&window);
u64 current_stamp = platform_get_time(TIME_FULL, TIME_US);
u64 diff = current_stamp - last_stamp;
diff --git a/src/project_base.h b/src/project_base.h index 6369e0c..90698c4 100644 --- a/src/project_base.h +++ b/src/project_base.h @@ -65,6 +65,7 @@ #include "../../project-base/src/external/cJSON.h"
#define STB_IMAGE_IMPLEMENTATION
+#define STBI_ONLY_PNG
#include "../../project-base/src/external/stb_image.h"
#define STB_TRUETYPE_IMPLEMENTATION
diff --git a/src/settings.c b/src/settings.c index 425007f..f9249e8 100644 --- a/src/settings.c +++ b/src/settings.c @@ -46,103 +46,99 @@ void settings_page_update_render() platform_handle_events(&global_settings_page.window, &global_settings_page.mouse, &global_settings_page.keyboard); platform_set_cursor(&global_settings_page.window, CURSOR_DEFAULT); - render_clear(); - - camera_apply_transformations(&global_settings_page.window, &global_settings_page.camera); - - global_ui_context.layout.active_window = &global_settings_page.window; - global_ui_context.keyboard = &global_settings_page.keyboard; - global_ui_context.mouse = &global_settings_page.mouse; - - ui_begin(3); + if (global_settings_page.window.do_draw) { - ui_begin_menu_bar(); - { - if (ui_push_menu(localize("interface"))) - { - global_settings_page.selected_tab_index = 1; - } - } - ui_end_menu_bar(); + global_settings_page.window.do_draw = false; + + render_clear(); + + camera_apply_transformations(&global_settings_page.window, &global_settings_page.camera); - ui_push_separator(); - if (global_settings_page.selected_tab_index == 1) + global_ui_context.layout.active_window = &global_settings_page.window; + global_ui_context.keyboard = &global_settings_page.keyboard; + global_ui_context.mouse = &global_settings_page.mouse; + + ui_begin(3); { - ui_block_begin(LAYOUT_HORIZONTAL); + ui_begin_menu_bar(); { - ui_push_text(localize("language")); + if (ui_push_menu(localize("interface"))) + { + global_settings_page.selected_tab_index = 1; + } } - ui_block_end(); + ui_end_menu_bar(); - ui_block_begin(LAYOUT_HORIZONTAL); + ui_push_separator(); + if (global_settings_page.selected_tab_index == 1) { - if (ui_push_dropdown(&global_settings_page.dropdown_language, locale_get_name())) + ui_block_begin(LAYOUT_HORIZONTAL); + { + ui_push_text(localize("language")); + } + ui_block_end(); + + ui_block_begin(LAYOUT_HORIZONTAL); { - for (s32 i = 0; i < global_localization.mo_files.length; i++) + if (ui_push_dropdown(&global_settings_page.dropdown_language, locale_get_name())) { - mo_file *file = array_at(&global_localization.mo_files, i); - - if (ui_push_dropdown_item(file->icon, file->locale_full, i)) + for (s32 i = 0; i < global_localization.mo_files.length; i++) { - set_locale(file->locale_id); - //platform_window_set_title(&global_settings_page.window, - //localize("text_search_settings")); + mo_file *file = array_at(&global_localization.mo_files, i); + + if (ui_push_dropdown_item(file->icon, file->locale_full, i)) + { + set_locale(file->locale_id); + platform_window_set_title(&global_settings_page.window, + localize("mo_edit_settings")); + } } } } - } - ui_block_end(); - - ui_block_begin(LAYOUT_HORIZONTAL); - { - if (ui_push_hypertext_link(localize("copy_config_path"))) + ui_block_end(); + + ui_block_begin(LAYOUT_HORIZONTAL); { - char buffer[PATH_MAX]; - platform_set_clipboard(main_window, get_config_save_location(buffer)); + if (ui_push_hypertext_link(localize("copy_config_path"))) + { + char buffer[PATH_MAX]; + platform_set_clipboard(main_window, get_config_save_location(buffer)); + push_notification(localize("copied_to_clipboard")); + } } + ui_block_end(); } - ui_block_end(); -#if 0 + global_ui_context.layout.offset_y = global_settings_page.window.height - 33; + ui_block_begin(LAYOUT_HORIZONTAL); { - char license_text[30]; - sprintf(license_text, "%s: %s", localize("license"), license_key); - ui_push_text(license_text); + if (ui_push_button(&global_settings_page.btn_close, localize("close"))) + { + global_settings_page.active = false; + set_locale(global_settings_page.current_locale_id); + settings_page_hide_without_save(); + } + if (ui_push_button(&global_settings_page.btn_close, localize("save"))) + { + global_settings_page.active = false; + settings_page_hide(); + return; + } } ui_block_end(); -#endif } + ui_end(); - global_ui_context.layout.offset_y = global_settings_page.window.height - 33; - - ui_block_begin(LAYOUT_HORIZONTAL); + if (!global_settings_page.window.is_open) { - if (ui_push_button(&global_settings_page.btn_close, localize("close"))) - { - global_settings_page.active = false; - set_locale(global_settings_page.current_locale_id); - settings_page_hide(); - } - if (ui_push_button(&global_settings_page.btn_close, localize("save"))) - { - global_settings_page.active = false; - settings_page_hide(); - return; - } + global_settings_page.active = false; + settings_page_hide_without_save(); + return; } - ui_block_end(); - } - ui_end(); - - if (!global_settings_page.window.is_open) - { - global_settings_page.active = false; - settings_page_hide(); - return; + + platform_window_swap_buffers(&global_settings_page.window); } - - platform_window_swap_buffers(&global_settings_page.window); } } |
