From 54cfa547b7895cfa1c9a5564ae6a3d1ddb6c4038 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 27 Nov 2022 01:12:18 +0200 Subject: [PATCH 24/24] sdl2: Fix pDock assignments from helpdlg.c See osdn #46124 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/helpdlg.c | 104 ++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 55 deletions(-) diff --git a/client/gui-sdl2/helpdlg.c b/client/gui-sdl2/helpdlg.c index 364acda750..ac0a07b558 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -275,7 +275,7 @@ void popup_impr_info(Impr_type_id impr) pstr = create_utf8_str(NULL, 0, adj_font(10)); pstr->style |= (TTF_STYLE_BOLD | SF_CENTER); - /* background template for entries in scroll list */ + /* Background template for entries in scroll list */ pBackgroundTmpl = create_surf(adj_size(135), adj_size(40), SDL_SWSURFACE); SDL_FillRect(pBackgroundTmpl, NULL, map_rgba(pBackgroundTmpl->format, bg_color)); @@ -286,10 +286,10 @@ void popup_impr_info(Impr_type_id impr) impr_type_count = 0; improvement_iterate(pImprove) { - /* copy background surface */ + /* Copy background surface */ pBackground = copy_surface(pBackgroundTmpl); - /* blit improvement name */ + /* Blit improvement name */ copy_chars_to_utf8_str(pstr, improvement_name_translation(pImprove)); pText = create_text_surf_smaller_than_w(pstr, adj_size(100 - 4)); dst.x = adj_size(40) + (pBackground->w - pText->w - adj_size(40)) / 2; @@ -297,7 +297,7 @@ void popup_impr_info(Impr_type_id impr) alphablit(pText, NULL, pBackground, &dst, 255); FREESURFACE(pText); - /* blit improvement icon */ + /* Blit improvement icon */ pIcon = ResizeSurfaceBox(get_building_surface(pImprove), adj_size(36), adj_size(36), 1, TRUE, TRUE); dst.x = adj_size(5); @@ -329,7 +329,7 @@ void popup_impr_info(Impr_type_id impr) scrollbar_width = create_vertical_scrollbar(pHelpDlg, 1, 10, TRUE, TRUE); } - /* toggle techs list button */ + /* Toggle techs list button */ pListToggleButton = create_themeicon_button_from_chars(current_theme->UP_Icon, pWindow->dst, _("Improvements"), @@ -357,7 +357,7 @@ void popup_impr_info(Impr_type_id impr) area = pWindow->area; - /* delete any previous list entries */ + /* Delete any previous list entries */ if (pDock != pHelpDlg->pBeginWidgetList) { del_group_of_widgets_from_gui_list(pHelpDlg->pBeginWidgetList, pDock->prev); @@ -395,7 +395,7 @@ void popup_impr_info(Impr_type_id impr) } } - /* requirement */ + /* Requirement */ pRequirementLabel = create_iconlabel_from_chars(NULL, pWindow->dst, _("Requirement:"), adj_font(12), 0); @@ -434,7 +434,7 @@ void popup_impr_info(Impr_type_id impr) pDock = pRequirementLabel2; pStore->pRequirementButton = pRequirementLabel2; - /* obsolete by */ + /* Obsolete by */ pObsoleteByLabel = create_iconlabel_from_chars(NULL, pWindow->dst, _("Obsolete by:"), adj_font(12), 0); @@ -442,7 +442,6 @@ void popup_impr_info(Impr_type_id impr) DownAdd(pObsoleteByLabel, pDock); pDock = pObsoleteByLabel; - requirement_vector_iterate(&pImpr_type->obsolete_by, pobs) { if (pobs->source.kind == VUT_ADVANCE) { obsTech = pobs->source.value.advance; @@ -466,7 +465,7 @@ void popup_impr_info(Impr_type_id impr) pDock = pObsoleteByLabel2; pStore->pObsoleteByButton = pObsoleteByLabel2; - /* helptext */ + /* Helptext */ start_x = (area.x + 1 + scrollbar_width + pHelpDlg->pEndActiveWidgetList->size.w + adj_size(20)); buffer[0] = '\0'; @@ -478,7 +477,6 @@ void popup_impr_info(Impr_type_id impr) pHelptextLabel = create_iconlabel(NULL, pWindow->dst, bstr, 0); pHelptextLabel->ID = ID_LABEL; DownAdd(pHelptextLabel, pDock); - pDock = pHelptextLabel; text = TRUE; } @@ -486,7 +484,6 @@ void popup_impr_info(Impr_type_id impr) /* --------------------------------------------------------- */ if (created) { - pSurf = theme_get_background(theme, BACKGROUND_HELPDLG); if (resize_window(pWindow, pSurf, NULL, adj_size(640), adj_size(480))) { FREESURFACE(pSurf); @@ -498,23 +495,23 @@ void popup_impr_info(Impr_type_id impr) (main_window_width() - pWindow->size.w) / 2, (main_window_height() - pWindow->size.h) / 2); - /* exit button */ + /* Exit button */ pCloseButton = pWindow->prev; widget_set_position(pCloseButton, area.x + area.w - pCloseButton->size.w - 1, pWindow->size.y + adj_size(2)); - /* list toggle button */ + /* List toggle button */ pListToggleButton = pStore->pDock; widget_set_position(pListToggleButton, area.x, area.y); - /* list entries */ + /* List entries */ h = setup_vertical_widgets_position(1, area.x + scrollbar_width, area.y + pListToggleButton->size.h, 0, 0, pHelpDlg->pBeginActiveWidgetList, pHelpDlg->pEndActiveWidgetList); - /* scrollbar */ + /* Scrollbar */ if (pHelpDlg->pScroll) { setup_vertical_scrollbar_area(pHelpDlg->pScroll, area.x, area.y + pListToggleButton->size.h, @@ -651,11 +648,11 @@ void popup_unit_info(Unit_type_id type_id) current_help_dlg = HELP_UNIT; created = TRUE; - /* create dialog */ + /* Create dialog */ pHelpDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG)); pStore = fc_calloc(1, sizeof(struct UNITS_BUTTONS)); - /* create window */ + /* Create window */ title = create_utf8_from_char(_("Help : Units"), adj_font(12)); title->style |= TTF_STYLE_BOLD; @@ -671,7 +668,7 @@ void popup_unit_info(Unit_type_id type_id) /* ------------------ */ - /* close button */ + /* Close button */ pCloseButton = create_themeicon(current_theme->Small_CANCEL_Icon, pWindow->dst, WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND); @@ -686,12 +683,12 @@ void popup_unit_info(Unit_type_id type_id) /* ------------------ */ pDock = pCloseButton; - /* --- create scrollable unit list on the left side ---*/ + /* --- Create scrollable unit list on the left side ---*/ pstr = create_utf8_str(NULL, 0, adj_font(10)); pstr->style |= (TTF_STYLE_BOLD | SF_CENTER); - /* background template for entries in scroll list */ + /* Background template for entries in scroll list */ pBackgroundTmpl = create_surf(adj_size(135), adj_size(40), SDL_SWSURFACE); SDL_FillRect(pBackgroundTmpl, NULL, map_rgba(pBackgroundTmpl->format, bg_color)); @@ -702,10 +699,10 @@ void popup_unit_info(Unit_type_id type_id) utype_count = 0; unit_type_iterate(ut) { - /* copy background surface */ + /* Copy background surface */ pBackground = copy_surface(pBackgroundTmpl); - /* blit unit name */ + /* Blit unit name */ copy_chars_to_utf8_str(pstr, utype_name_translation(ut)); pText = create_text_surf_smaller_than_w(pstr, adj_size(100 - 4)); dst.x = adj_size(35) + (pBackground->w - pText->w - adj_size(35)) / 2; @@ -713,7 +710,7 @@ void popup_unit_info(Unit_type_id type_id) alphablit(pText, NULL, pBackground, &dst, 255); FREESURFACE(pText); - /* blit unit icon */ + /* Blit unit icon */ pIcon = ResizeSurfaceBox(get_unittype_surface(ut, direction8_invalid()), adj_size(36), adj_size(36), 1, TRUE, TRUE); dst.x = (adj_size(35) - pIcon->w) / 2; @@ -745,7 +742,7 @@ void popup_unit_info(Unit_type_id type_id) scrollbar_width = create_vertical_scrollbar(pHelpDlg, 1, 10, TRUE, TRUE); } - /* toggle techs list button */ + /* Toggle techs list button */ pListToggleButton = create_themeicon_button_from_chars(current_theme->UP_Icon, pWindow->dst, _("Units"), adj_font(10), 0); #if 0 @@ -771,7 +768,7 @@ void popup_unit_info(Unit_type_id type_id) area = pWindow->area; - /* delete any previous list entries */ + /* Delete any previous list entries */ if (pDock != pHelpDlg->pBeginWidgetList) { del_group_of_widgets_from_gui_list(pHelpDlg->pBeginWidgetList, pDock->prev); @@ -789,7 +786,6 @@ void popup_unit_info(Unit_type_id type_id) DownAdd(pUnitNameLabel, pDock); pDock = pUnitNameLabel; - { char buf[2048]; @@ -841,7 +837,7 @@ void popup_unit_info(Unit_type_id type_id) pDock = pUnitInfoLabel; } - /* requirement */ + /* Requirement */ pRequirementLabel = create_iconlabel_from_chars(NULL, pWindow->dst, _("Requirement:"), adj_font(12), 0); @@ -868,7 +864,7 @@ void popup_unit_info(Unit_type_id type_id) pDock = pRequirementLabel2; pStore->pRequirementButton = pRequirementLabel2; - /* obsolete by */ + /* Obsolete by */ pObsoleteByLabel = create_iconlabel_from_chars(NULL, pWindow->dst, _("Obsolete by:"), adj_font(12), 0); @@ -897,7 +893,7 @@ void popup_unit_info(Unit_type_id type_id) pDock = pObsoleteByLabel2; pStore->pObsoleteByButton = pObsoleteByLabel2; - /* helptext */ + /* Helptext */ start_x = (area.x + 1 + scrollbar_width + pHelpDlg->pActiveWidgetList->size.w + adj_size(20)); buffer[0] = '\0'; @@ -909,7 +905,6 @@ void popup_unit_info(Unit_type_id type_id) pHelptextLabel = create_iconlabel(NULL, pWindow->dst, ustr, 0); pHelptextLabel->ID = ID_LABEL; DownAdd(pHelptextLabel, pDock); - pDock = pHelptextLabel; text = TRUE; } @@ -929,23 +924,23 @@ void popup_unit_info(Unit_type_id type_id) (main_window_width() - pWindow->size.w) / 2, (main_window_height() - pWindow->size.h) / 2); - /* exit button */ + /* Exit button */ pCloseButton = pWindow->prev; widget_set_position(pCloseButton, area.x + area.w - pCloseButton->size.w - 1, pWindow->size.y + adj_size(2)); - /* list toggle button */ + /* List toggle button */ pListToggleButton = pStore->pDock; widget_set_position(pListToggleButton, area.x, area.y); - /* list entries */ + /* List entries */ h = setup_vertical_widgets_position(1, area.x + scrollbar_width, area.y + pListToggleButton->size.h, 0, 0, pHelpDlg->pBeginActiveWidgetList, pHelpDlg->pEndActiveWidgetList); - /* scrollbar */ + /* Scrollbar */ if (pHelpDlg->pScroll) { setup_vertical_scrollbar_area(pHelpDlg->pScroll, area.x, area.y + pListToggleButton->size.h, @@ -1116,7 +1111,7 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, start_x = (pWindow->area.x + adj_size(1) + width + pHelpDlg->pActiveWidgetList->size.w + adj_size(20)); - /* tech tree icon */ + /* Tech tree icon */ pWidget = create_icon2(current_theme->Tech_Tree_Icon, pWindow->dst, WF_RESTORE_BACKGROUND); @@ -1126,7 +1121,7 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, DownAdd(pWidget, pDock); pDock = pWidget; - /* tech name (heading) */ + /* Tech name (heading) */ pWidget = create_iconlabel_from_chars(get_tech_icon(tech), pWindow->dst, advance_name_translation(advance_by_number(tech)), @@ -1137,7 +1132,7 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, DownAdd(pWidget, pDock); pDock = pWidget; - /* target techs */ + /* Target techs */ targets_count = 0; advance_index_iterate(A_FIRST, aidx) { if ((targets_count < 6) @@ -1193,10 +1188,10 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, pStore->pSub_Targets[sub_targets_count] = NULL; } - /* fill array with iprvm. icons */ + /* Fill array with iprvm. icons */ pBudynki = pWidget; - /* target governments */ + /* Target governments */ gov_count = 0; governments_iterate(gov) { requirement_vector_iterate(&(gov->reqs), preq) { @@ -1218,7 +1213,7 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, } requirement_vector_iterate_end; } governments_iterate_end; - /* target improvements */ + /* Target improvements */ imp_count = 0; improvement_iterate(pimprove) { if (valid_improvement(pimprove)) { @@ -1281,7 +1276,6 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, pWidget = create_iconlabel(NULL, pWindow->dst, pstr, 0); pWidget->ID = ID_LABEL; DownAdd(pWidget, pDock); - pDock = pWidget; flags_count = 1; } else { flags_count = 0; @@ -1290,7 +1284,7 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, pLast = pWidget; /* --------------------------------------------- */ - /* tree button */ + /* Tree button */ pWidget = pStore->pDock->prev; pWidget->size.x = pWindow->area.x + pWindow->area.w - pWidget->size.w - adj_size(17); pWidget->size.y = pWindow->area.y + adj_size(16); @@ -1906,19 +1900,19 @@ void popup_tech_info(Tech_type_id tech) popdown_help_dialog(); } - /* create new dialog if it doesn't exist yet */ + /* Create new dialog if it doesn't exist yet */ if (!pHelpDlg) { current_help_dlg = HELP_TECH; created = TRUE; - /* create dialog */ + /* Create dialog */ pHelpDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG)); pStore = fc_calloc(1, sizeof(struct TECHS_BUTTONS)); pStore->show_tree = FALSE; pStore->show_full_tree = FALSE; - /* create window */ + /* Create window */ title = create_utf8_from_char(_("Help : Advances Tree"), adj_font(12)); title->style |= TTF_STYLE_BOLD; @@ -1935,7 +1929,7 @@ void popup_tech_info(Tech_type_id tech) /* ------------------ */ - /* close button */ + /* Close button */ pCloseButton = create_themeicon(current_theme->Small_CANCEL_Icon, pWindow->dst, WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND); @@ -1950,7 +1944,7 @@ void popup_tech_info(Tech_type_id tech) /* ------------------ */ pDock = pCloseButton; - /* --- create scrollable advance list on the left side ---*/ + /* --- Create scrollable advance list on the left side ---*/ pstr = create_utf8_str(NULL, 0, adj_font(10)); pstr->style |= (TTF_STYLE_BOLD | SF_CENTER); @@ -2010,13 +2004,13 @@ void popup_tech_info(Tech_type_id tech) area = pWindow->area; - /* delete any previous list entries */ + /* Delete any previous list entries */ if (pDock != pHelpDlg->pBeginWidgetList) { del_group_of_widgets_from_gui_list(pHelpDlg->pBeginWidgetList, pDock->prev); pHelpDlg->pBeginWidgetList = pDock; } - /* show/hide techs list */ + /* Show/hide techs list */ pListToggleButton = pDock; if (pStore->show_tree) { @@ -2026,7 +2020,7 @@ void popup_tech_info(Tech_type_id tech) } if (pStore->show_full_tree) { - /* all entries are visible without scrolling */ + /* All entries are visible without scrolling */ hide_group(pHelpDlg->pBeginActiveWidgetList, pHelpDlg->pEndActiveWidgetList); hide_scrollbar(pHelpDlg->pScroll); @@ -2057,22 +2051,22 @@ void popup_tech_info(Tech_type_id tech) (main_window_width() - pWindow->size.w) / 2, (main_window_height() - pWindow->size.h) / 2); - /* exit button */ + /* Exit button */ pCloseButton = pWindow->prev; widget_set_position(pCloseButton, area.x + area.w - pCloseButton->size.w - 1, pWindow->size.y + adj_size(2)); - /* list toggle button */ + /* List toggle button */ pListToggleButton = pStore->pDock; widget_set_position(pListToggleButton, area.x, area.y); - /* list entries */ + /* List entries */ h = setup_vertical_widgets_position(1, area.x + scrollbar_width, area.y + pListToggleButton->size.h, 0, 0, pHelpDlg->pBeginActiveWidgetList, pHelpDlg->pEndActiveWidgetList); - /* scrollbar */ + /* Scrollbar */ if (pHelpDlg->pScroll) { setup_vertical_scrollbar_area(pHelpDlg->pScroll, area.x, area.y + pListToggleButton->size.h, -- 2.35.1