Mercurial > repos > blastem
comparison nuklear_ui/blastem_nuklear.c @ 1578:aaa28c9bf67d
Basic interface scaling for rest of settings UI
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 01 May 2018 19:27:17 -0700 |
parents | 69d624271cf8 |
children | f66290afae65 |
comparison
equal
deleted
inserted
replaced
1577:69d624271cf8 | 1578:aaa28c9bf67d |
---|---|
296 static int32_t keycode; | 296 static int32_t keycode; |
297 static const char *set_binding; | 297 static const char *set_binding; |
298 char *set_label; | 298 char *set_label; |
299 void binding_group(struct nk_context *context, char *name, const char **binds, const char **bind_names, uint32_t num_binds, tern_node *binding_lookup) | 299 void binding_group(struct nk_context *context, char *name, const char **binds, const char **bind_names, uint32_t num_binds, tern_node *binding_lookup) |
300 { | 300 { |
301 nk_layout_row_static(context, 34*num_binds+60, render_width() - 80, 1); | 301 nk_layout_row_static(context, (context->style.font->height + 4)*num_binds+context->style.font->height+30, render_width() - 80, 1); |
302 if (nk_group_begin(context, name, NK_WINDOW_TITLE)) { | 302 if (nk_group_begin(context, name, NK_WINDOW_TITLE)) { |
303 nk_layout_row_static(context, 30, render_width()/2 - 80, 2); | 303 nk_layout_row_static(context, context->style.font->height, render_width()/2 - 80, 2); |
304 | 304 |
305 for (int i = 0; i < num_binds; i++) | 305 for (int i = 0; i < num_binds; i++) |
306 { | 306 { |
307 char *label_alloc = bind_names ? NULL : path_extension(binds[i]); | 307 char *label_alloc = bind_names ? NULL : path_extension(binds[i]); |
308 const char *label = label_alloc; | 308 const char *label = label_alloc; |
450 binding_group(context, "Controller 1", controller1_binds, NULL, NUM_C1_BINDS, binding_lookup); | 450 binding_group(context, "Controller 1", controller1_binds, NULL, NUM_C1_BINDS, binding_lookup); |
451 binding_group(context, "Controller 2", controller2_binds, NULL, NUM_C2_BINDS, binding_lookup); | 451 binding_group(context, "Controller 2", controller2_binds, NULL, NUM_C2_BINDS, binding_lookup); |
452 binding_group(context, "General", general_binds, general_names, NUM_GEN_BINDS, binding_lookup); | 452 binding_group(context, "General", general_binds, general_names, NUM_GEN_BINDS, binding_lookup); |
453 binding_group(context, "Speed Control", speed_binds, speed_names, NUM_SPEED_BINDS, binding_lookup); | 453 binding_group(context, "Speed Control", speed_binds, speed_names, NUM_SPEED_BINDS, binding_lookup); |
454 binding_group(context, "Debug", debug_binds, debug_names, NUM_DBG_BINDS, binding_lookup); | 454 binding_group(context, "Debug", debug_binds, debug_names, NUM_DBG_BINDS, binding_lookup); |
455 nk_layout_row_static(context, 34, (render_width() - 80) / 2, 1); | 455 nk_layout_row_static(context, context->style.font->height * 1.1333, (render_width() - 80) / 2, 1); |
456 if (nk_button_label(context, "Back")) { | 456 if (nk_button_label(context, "Back")) { |
457 pop_view(); | 457 pop_view(); |
458 } | 458 } |
459 nk_end(context); | 459 nk_end(context); |
460 } | 460 } |
858 selected_rate = find_match(rates, num_rates, "autio\0rate\0", "48000"); | 858 selected_rate = find_match(rates, num_rates, "autio\0rate\0", "48000"); |
859 selected_size = find_match(sizes, num_sizes, "audio\0buffer\0", "512"); | 859 selected_size = find_match(sizes, num_sizes, "audio\0buffer\0", "512"); |
860 } | 860 } |
861 uint32_t width = render_width(); | 861 uint32_t width = render_width(); |
862 uint32_t height = render_height(); | 862 uint32_t height = render_height(); |
863 uint32_t desired_width = context->style.font->height * 10; | |
864 if (desired_width > width) { | |
865 desired_width = width; | |
866 } | |
863 if (nk_begin(context, "Audio Settings", nk_rect(0, 0, width, height), 0)) { | 867 if (nk_begin(context, "Audio Settings", nk_rect(0, 0, width, height), 0)) { |
864 nk_layout_row_static(context, 30, width > 300 ? 300 : width, 2); | 868 nk_layout_row_static(context, context->style.font->height , desired_width, 2); |
865 selected_rate = settings_dropdown(context, "Rate in Hz", rates, num_rates, selected_rate, "audio\0rate\0"); | 869 selected_rate = settings_dropdown(context, "Rate in Hz", rates, num_rates, selected_rate, "audio\0rate\0"); |
866 selected_size = settings_dropdown(context, "Buffer Samples", sizes, num_sizes, selected_size, "audio\0buffer\0"); | 870 selected_size = settings_dropdown(context, "Buffer Samples", sizes, num_sizes, selected_size, "audio\0buffer\0"); |
867 settings_int_input(context, "Lowpass Cutoff Hz", "audio\0lowpass_cutoff\0", "3390"); | 871 settings_int_input(context, "Lowpass Cutoff Hz", "audio\0lowpass_cutoff\0", "3390"); |
868 if (nk_button_label(context, "Back")) { | 872 if (nk_button_label(context, "Back")) { |
869 pop_view(); | 873 pop_view(); |
935 selected_io_2 = find_match(io_opts_2, num_io, "io\0devices\0""2\0", "gamepad6.2"); | 939 selected_io_2 = find_match(io_opts_2, num_io, "io\0devices\0""2\0", "gamepad6.2"); |
936 } | 940 } |
937 | 941 |
938 uint32_t width = render_width(); | 942 uint32_t width = render_width(); |
939 uint32_t height = render_height(); | 943 uint32_t height = render_height(); |
944 uint32_t desired_width = context->style.font->height * 10; | |
940 if (nk_begin(context, "System Settings", nk_rect(0, 0, width, height), 0)) { | 945 if (nk_begin(context, "System Settings", nk_rect(0, 0, width, height), 0)) { |
941 nk_layout_row_static(context, 30, width > 300 ? 300 : width, 2); | 946 nk_layout_row_static(context, context->style.font->height, desired_width, 2); |
942 selected_sync = settings_dropdown(context, "Sync Source", sync_opts, num_sync_opts, selected_sync, "system\0sync_source\0"); | 947 selected_sync = settings_dropdown(context, "Sync Source", sync_opts, num_sync_opts, selected_sync, "system\0sync_source\0"); |
943 settings_int_property(context, "68000 Clock Divider", "", "clocks\0m68k_divider\0", 7, 1, 53); | 948 settings_int_property(context, "68000 Clock Divider", "", "clocks\0m68k_divider\0", 7, 1, 53); |
944 settings_toggle(context, "Remember ROM Path", "ui\0remember_path\0", 1); | 949 settings_toggle(context, "Remember ROM Path", "ui\0remember_path\0", 1); |
945 selected_region = settings_dropdown_ex(context, "Default Region", region_codes, regions, num_regions, selected_region, "system\0default_region\0"); | 950 selected_region = settings_dropdown_ex(context, "Default Region", region_codes, regions, num_regions, selected_region, "system\0default_region\0"); |
946 selected_format = settings_dropdown(context, "Save State Format", formats, num_formats, selected_format, "ui\0state_format\0"); | 951 selected_format = settings_dropdown(context, "Save State Format", formats, num_formats, selected_format, "ui\0state_format\0"); |
970 {"Audio", view_audio_settings}, | 975 {"Audio", view_audio_settings}, |
971 {"System", view_system_settings}, | 976 {"System", view_system_settings}, |
972 {"Back", view_back} | 977 {"Back", view_back} |
973 }; | 978 }; |
974 | 979 |
975 const uint32_t num_buttons = 6; | |
976 if (nk_begin(context, "Settings Menu", nk_rect(0, 0, render_width(), render_height()), 0)) { | 980 if (nk_begin(context, "Settings Menu", nk_rect(0, 0, render_width(), render_height()), 0)) { |
977 menu(context, sizeof(items)/sizeof(*items), items); | 981 menu(context, sizeof(items)/sizeof(*items), items); |
978 nk_end(context); | 982 nk_end(context); |
979 } | 983 } |
980 } | 984 } |
989 {"Load State", view_load_state}, | 993 {"Load State", view_load_state}, |
990 {"Settings", view_settings}, | 994 {"Settings", view_settings}, |
991 {"Exit", NULL} | 995 {"Exit", NULL} |
992 }; | 996 }; |
993 | 997 |
994 const uint32_t num_buttons = 3; | |
995 if (nk_begin(context, "Main Menu", nk_rect(0, 0, render_width(), render_height()), 0)) { | 998 if (nk_begin(context, "Main Menu", nk_rect(0, 0, render_width(), render_height()), 0)) { |
996 menu(context, sizeof(items)/sizeof(*items), items); | 999 menu(context, sizeof(items)/sizeof(*items), items); |
997 nk_end(context); | 1000 nk_end(context); |
998 } | 1001 } |
999 } | 1002 } |
1005 {"Settings", view_settings}, | 1008 {"Settings", view_settings}, |
1006 {"About", view_about}, | 1009 {"About", view_about}, |
1007 {"Exit", NULL} | 1010 {"Exit", NULL} |
1008 }; | 1011 }; |
1009 | 1012 |
1010 const uint32_t num_buttons = 3; | |
1011 if (nk_begin(context, "Main Menu", nk_rect(0, 0, render_width(), render_height()), 0)) { | 1013 if (nk_begin(context, "Main Menu", nk_rect(0, 0, render_width(), render_height()), 0)) { |
1012 menu(context, sizeof(items)/sizeof(*items), items); | 1014 menu(context, sizeof(items)/sizeof(*items), items); |
1013 nk_end(context); | 1015 nk_end(context); |
1014 } | 1016 } |
1015 } | 1017 } |