comparison nuklear_ui/blastem_nuklear.c @ 2379:9e6cb50d0639

Fix accidental search and replace in UI code
author Michael Pavone <pavone@retrodev.com>
date Sat, 18 Nov 2023 22:00:45 -0800
parents 1c09f5be285b
children ee0cc07dc406
comparison
equal deleted inserted replaced
2378:af3075c1e421 2379:9e6cb50d0639
1059 options[IDENTICAL_CONTROLLERS].title = "Use for identical controllers"; 1059 options[IDENTICAL_CONTROLLERS].title = "Use for identical controllers";
1060 options[DEFAULT].title = "Use as default"; 1060 options[DEFAULT].title = "Use as default";
1061 options[BY_INDEX].title = by_index_names[selected_controller]; 1061 options[BY_INDEX].title = by_index_names[selected_controller];
1062 options[SIMILAR_CONTROLLERS].title = make_human_readable_type_name(&selected_controller_info); 1062 options[SIMILAR_CONTROLLERS].title = make_human_readable_type_name(&selected_controller_info);
1063 1063
1064 if ((context, "Select Binding Dest", nk_rect(0, 0, render_width(), render_height()), NK_WINDOW_NO_SCROLLBAR)) { 1064 if (nk_begin(context, "Select Binding Dest", nk_rect(0, 0, render_width(), render_height()), NK_WINDOW_NO_SCROLLBAR)) {
1065 menu(context, NUM_DEST_TYPES, options, handle_dest_clicked); 1065 menu(context, NUM_DEST_TYPES, options, handle_dest_clicked);
1066 nk_end(context); 1066 nk_end(context);
1067 } 1067 }
1068 free((char *)options[SIMILAR_CONTROLLERS].title); 1068 free((char *)options[SIMILAR_CONTROLLERS].title);
1069 } 1069 }
1085 } 1085 }
1086 } 1086 }
1087 1087
1088 void view_controller_bindings(struct nk_context *context) 1088 void view_controller_bindings(struct nk_context *context)
1089 { 1089 {
1090 if ((context, "Controller Bindings", nk_rect(0, 0, render_width(), render_height()), NK_WINDOW_NO_SCROLLBAR)) { 1090 if (nk_begin(context, "Controller Bindings", nk_rect(0, 0, render_width(), render_height()), NK_WINDOW_NO_SCROLLBAR)) {
1091 if (!bindings) { 1091 if (!bindings) {
1092 bindings = calloc(1, sizeof(*bindings)); 1092 bindings = calloc(1, sizeof(*bindings));
1093 tern_node *pad = get_binding_node_for_pad(selected_controller, &selected_controller_info); 1093 tern_node *pad = get_binding_node_for_pad(selected_controller, &selected_controller_info);
1094 if (pad) { 1094 if (pad) {
1095 tern_foreach(tern_find_node(pad, "buttons"), button_iter, bindings); 1095 tern_foreach(tern_find_node(pad, "buttons"), button_iter, bindings);
1280 static void view_controller_mappings(struct nk_context *context) 1280 static void view_controller_mappings(struct nk_context *context)
1281 { 1281 {
1282 char buffer[512]; 1282 char buffer[512];
1283 static int quiet, button_a = -1, button_a_axis = -1; 1283 static int quiet, button_a = -1, button_a_axis = -1;
1284 uint8_t added_mapping = 0; 1284 uint8_t added_mapping = 0;
1285 if ((context, "Controllers", nk_rect(0, 0, render_width(), render_height()), NK_WINDOW_NO_SCROLLBAR)) { 1285 if (nk_begin(context, "Controllers", nk_rect(0, 0, render_width(), render_height()), NK_WINDOW_NO_SCROLLBAR)) {
1286 1286
1287 nk_layout_space_begin(context, NK_STATIC, render_height() - context->style.font->height, 3); 1287 nk_layout_space_begin(context, NK_STATIC, render_height() - context->style.font->height, 3);
1288 1288
1289 if (current_button < SDL_CONTROLLER_BUTTON_MAX) { 1289 if (current_button < SDL_CONTROLLER_BUTTON_MAX) {
1290 snprintf(buffer, sizeof(buffer), "Press Button %s", get_button_label(&selected_controller_info, current_button)); 1290 snprintf(buffer, sizeof(buffer), "Press Button %s", get_button_label(&selected_controller_info, current_button));
1421 } 1421 }
1422 1422
1423 static void view_controller_variant(struct nk_context *context) 1423 static void view_controller_variant(struct nk_context *context)
1424 { 1424 {
1425 uint8_t selected = 0; 1425 uint8_t selected = 0;
1426 if ((context, "Controller Type", nk_rect(0, 0, render_width(), render_height()), 0)) { 1426 if (nk_begin(context, "Controller Type", nk_rect(0, 0, render_width(), render_height()), 0)) {
1427 nk_layout_row_static(context, context->style.font->height*1.25, render_width() - context->style.font->height * 2, 1); 1427 nk_layout_row_static(context, context->style.font->height*1.25, render_width() - context->style.font->height * 2, 1);
1428 nk_label(context, "", NK_TEXT_CENTERED); 1428 nk_label(context, "", NK_TEXT_CENTERED);
1429 nk_label(context, "Select the layout that", NK_TEXT_CENTERED); 1429 nk_label(context, "Select the layout that", NK_TEXT_CENTERED);
1430 nk_label(context, "best matches your controller", NK_TEXT_CENTERED); 1430 nk_label(context, "best matches your controller", NK_TEXT_CENTERED);
1431 nk_label(context, "", NK_TEXT_CENTERED); 1431 nk_label(context, "", NK_TEXT_CENTERED);
1516 } 1516 }
1517 } 1517 }
1518 1518
1519 void view_controller_type(struct nk_context *context) 1519 void view_controller_type(struct nk_context *context)
1520 { 1520 {
1521 if ((context, "Controller Type", nk_rect(0, 0, render_width(), render_height()), 0)) { 1521 if (nk_begin(context, "Controller Type", nk_rect(0, 0, render_width(), render_height()), 0)) {
1522 controller_type_group(context, "Xbox", TYPE_XBOX, SUBTYPE_XBOX, (const char *[]){ 1522 controller_type_group(context, "Xbox", TYPE_XBOX, SUBTYPE_XBOX, (const char *[]){
1523 "Original", "Xbox 360", "Xbox One/Series", "Xbox Elite" 1523 "Original", "Xbox 360", "Xbox One/Series", "Xbox Elite"
1524 }, 4); 1524 }, 4);
1525 controller_type_group(context, "Playstation", TYPE_PSX, SUBTYPE_PS3, (const char *[]){ 1525 controller_type_group(context, "Playstation", TYPE_PSX, SUBTYPE_PS3, (const char *[]){
1526 "PS3", "PS4", "PS5" 1526 "PS3", "PS4", "PS5"
1602 nk_draw_symbol(&context->current->buffer, NK_SYMBOL_X, nk_rect(left + x, top + 0.25f * crosshair_size, crosshair_size, crosshair_size), nk_rgb(0, 0, 0), nk_rgb(255, 255, 255), 1, context->style.font); 1602 nk_draw_symbol(&context->current->buffer, NK_SYMBOL_X, nk_rect(left + x, top + 0.25f * crosshair_size, crosshair_size, crosshair_size), nk_rgb(0, 0, 0), nk_rgb(255, 255, 255), 1, context->style.font);
1603 } 1603 }
1604 1604
1605 void view_deadzones(struct nk_context *context) 1605 void view_deadzones(struct nk_context *context)
1606 { 1606 {
1607 if ((context, "Deadzones", nk_rect(0, 0, render_width(), render_height()), NK_WINDOW_NO_SCROLLBAR)) { 1607 if (nk_begin(context, "Deadzones", nk_rect(0, 0, render_width(), render_height()), NK_WINDOW_NO_SCROLLBAR)) {
1608 nk_layout_space_begin(context, NK_STATIC, render_height() - 3 * context->style.font->height, 4); 1608 nk_layout_space_begin(context, NK_STATIC, render_height() - 3 * context->style.font->height, 4);
1609 1609
1610 float left = render_width() / 8.0f, top = render_height() / 8.0f; 1610 float left = render_width() / 8.0f, top = render_height() / 8.0f;
1611 float size = render_height() / 3.0f; 1611 float size = render_height() / 3.0f;
1612 stick_deadzone_widget(left, top, size, SDL_CONTROLLER_AXIS_LEFTX); 1612 stick_deadzone_widget(left, top, size, SDL_CONTROLLER_AXIS_LEFTX);
1652 } 1652 }
1653 } 1653 }
1654 1654
1655 void view_controllers(struct nk_context *context) 1655 void view_controllers(struct nk_context *context)
1656 { 1656 {
1657 if ((context, "Controllers", nk_rect(0, 0, render_width(), render_height()), NK_WINDOW_NO_SCROLLBAR)) { 1657 if (nk_begin(context, "Controllers", nk_rect(0, 0, render_width(), render_height()), NK_WINDOW_NO_SCROLLBAR)) {
1658 int height = (render_height() - 2*context->style.font->height) / 5; 1658 int height = (render_height() - 2*context->style.font->height) / 5;
1659 int inner_height = height - context->style.window.spacing.y; 1659 int inner_height = height - context->style.window.spacing.y;
1660 const struct nk_user_font *font = context->style.font; 1660 const struct nk_user_font *font = context->style.font;
1661 int bindings_width = font->width(font->userdata, font->height, "Bindings", strlen("Bindings")) + context->style.button.padding.x * 2; 1661 int bindings_width = font->width(font->userdata, font->height, "Bindings", strlen("Bindings")) + context->style.button.padding.x * 2;
1662 int remap_width = font->width(font->userdata, font->height, "Remap", strlen("Remap")) + context->style.button.padding.x * 2; 1662 int remap_width = font->width(font->userdata, font->height, "Remap", strlen("Remap")) + context->style.button.padding.x * 2;
2032 uint32_t height = render_height(); 2032 uint32_t height = render_height();
2033 uint32_t desired_width = context->style.font->height * 10; 2033 uint32_t desired_width = context->style.font->height * 10;
2034 if (desired_width > width) { 2034 if (desired_width > width) {
2035 desired_width = width; 2035 desired_width = width;
2036 } 2036 }
2037 if ((context, "Video Settings", nk_rect(0, 0, width, height), 0)) { 2037 if (nk_begin(context, "Video Settings", nk_rect(0, 0, width, height), 0)) {
2038 nk_layout_row_static(context, context->style.font->height, desired_width, 2); 2038 nk_layout_row_static(context, context->style.font->height, desired_width, 2);
2039 settings_toggle(context, "Fullscreen", "video\0fullscreen\0", 0); 2039 settings_toggle(context, "Fullscreen", "video\0fullscreen\0", 0);
2040 settings_toggle(context, "Open GL", "video\0gl\0", 1); 2040 settings_toggle(context, "Open GL", "video\0gl\0", 1);
2041 settings_toggle(context, "Scanlines", "video\0scanlines\0", 0); 2041 settings_toggle(context, "Scanlines", "video\0scanlines\0", 0);
2042 selected_vsync = settings_dropdown_ex(context, "VSync", vsync_opts, vsync_opt_names, num_vsync_opts, selected_vsync, "video\0vsync\0"); 2042 selected_vsync = settings_dropdown_ex(context, "VSync", vsync_opts, vsync_opt_names, num_vsync_opts, selected_vsync, "video\0vsync\0");