From 763c742788769407125a819d03971d4ac55779e3 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 23 Jun 2023 16:25:40 +0300 Subject: [PATCH 07/12] sdl2: Make size 14 fonts to adjust to theme font size See osdn #48271 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/connectdlg.c | 60 +++++++++++++++++++++++------------- client/gui-sdl2/dialogs.c | 14 ++++++--- client/gui-sdl2/diplodlg.c | 14 +++++---- client/gui-sdl2/gui_string.c | 3 ++ client/gui-sdl2/gui_string.h | 3 +- client/gui-sdl2/helpdlg.c | 20 ++++++------ client/gui-sdl2/inteldlg.c | 2 +- client/gui-sdl2/mapview.c | 4 +-- client/gui-sdl2/pages.c | 49 ++++++++++++++++------------- 9 files changed, 101 insertions(+), 68 deletions(-) diff --git a/client/gui-sdl2/connectdlg.c b/client/gui-sdl2/connectdlg.c index eed34b354d..b1821189be 100644 --- a/client/gui-sdl2/connectdlg.c +++ b/client/gui-sdl2/connectdlg.c @@ -317,9 +317,10 @@ void popup_connection_dialog(bool lan_scan) pMeta_Server->pEndWidgetList = pWindow; /* Cancel button */ - pNewWidget = create_themeicon_button_from_chars(current_theme->CANCEL_Icon, - pWindow->dst, _("Cancel"), - adj_font(14), 0); + pNewWidget + = create_themeicon_button_from_chars_fonto(current_theme->CANCEL_Icon, + pWindow->dst, _("Cancel"), + FONTO_HEADING, 0); pNewWidget->action = exit_meta_server_dlg_callback; set_wstate(pNewWidget, FC_WS_NORMAL); add_to_gui_list(ID_BUTTON, pNewWidget); @@ -327,7 +328,7 @@ void popup_connection_dialog(bool lan_scan) /* Servers */ server_list_iterate(pServer_list, pServer) { - /* TRANS: "host.example.com Port 5556 Ver: 2.6.0 Running Players 3\n + /* TRANS: "host.example.com Port 5556 Ver: 3.1.0 Running Players 3\n * [server message]" */ fc_snprintf(cBuf, sizeof(cBuf), _("%s Port %d Ver: %s %s %s %d\n%s"), pServer->host, pServer->port, pServer->version, _(pServer->state), @@ -576,8 +577,9 @@ void popup_join_game_dialog(void) area.h += pBuf->size.h + adj_size(20); /* Player name edit */ - pBuf = create_edit_from_chars(NULL, pWindow->dst, user_name, adj_font(14), adj_size(210), - (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); + pBuf = create_edit_from_chars_fonto(NULL, pWindow->dst, user_name, + FONTO_HEADING, adj_size(210), + (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); pBuf->action = convert_playername_callback; set_wstate(pBuf, FC_WS_NORMAL); add_to_gui_list(ID_PLAYER_NAME_EDIT, pBuf); @@ -592,8 +594,9 @@ void popup_join_game_dialog(void) area.h += pBuf->size.h + adj_size(5); /* Server name edit */ - pBuf = create_edit_from_chars(NULL, pWindow->dst, server_host, adj_font(14), adj_size(210), - WF_RESTORE_BACKGROUND); + pBuf = create_edit_from_chars_fonto(NULL, pWindow->dst, server_host, + FONTO_HEADING, adj_size(210), + WF_RESTORE_BACKGROUND); pBuf->action = convert_servername_callback; set_wstate(pBuf, FC_WS_NORMAL); @@ -611,8 +614,9 @@ void popup_join_game_dialog(void) /* Port edit */ fc_snprintf(pCharPort, sizeof(pCharPort), "%d", server_port); - pBuf = create_edit_from_chars(NULL, pWindow->dst, pCharPort, adj_font(14), adj_size(210), - WF_RESTORE_BACKGROUND); + pBuf = create_edit_from_chars_fonto(NULL, pWindow->dst, pCharPort, + FONTO_HEADING, adj_size(210), + WF_RESTORE_BACKGROUND); pBuf->action = convert_portnr_callback; set_wstate(pBuf, FC_WS_NORMAL); @@ -620,16 +624,20 @@ void popup_join_game_dialog(void) area.h += pBuf->size.h + adj_size(20); /* Connect button */ - pBuf = create_themeicon_button_from_chars(current_theme->OK_Icon, pWindow->dst, - _("Connect"), adj_font(14), 0); + pBuf = create_themeicon_button_from_chars_fonto(current_theme->OK_Icon, + pWindow->dst, + _("Connect"), + FONTO_HEADING, 0); pBuf->action = connect_callback; set_wstate(pBuf, FC_WS_NORMAL); pBuf->key = SDLK_RETURN; add_to_gui_list(ID_CONNECT_BUTTON, pBuf); /* Cancel button */ - pBuf = create_themeicon_button_from_chars(current_theme->CANCEL_Icon, pWindow->dst, - _("Cancel"), adj_font(14), 0); + pBuf = create_themeicon_button_from_chars_fonto(current_theme->CANCEL_Icon, + pWindow->dst, + _("Cancel"), + FONTO_HEADING, 0); pBuf->action = cancel_connect_dlg_callback; set_wstate(pBuf, FC_WS_NORMAL); pBuf->key = SDLK_ESCAPE; @@ -814,16 +822,20 @@ static void popup_user_passwd_dialog(const char *pMessage) area.h += pBuf->size.h + adj_size(10); /* Next button */ - pBuf = create_themeicon_button_from_chars(current_theme->OK_Icon, pWindow->dst, - _("Next"), adj_font(14), 0); + pBuf = create_themeicon_button_from_chars_fonto(current_theme->OK_Icon, + pWindow->dst, + _("Next"), + FONTO_HEADING, 0); pBuf->action = send_passwd_callback; set_wstate(pBuf, FC_WS_NORMAL); pBuf->key = SDLK_RETURN; add_to_gui_list(ID_BUTTON, pBuf); /* Cancel button */ - pBuf = create_themeicon_button_from_chars(current_theme->CANCEL_Icon, pWindow->dst, - _("Cancel"), adj_font(14), 0); + pBuf = create_themeicon_button_from_chars_fonto(current_theme->CANCEL_Icon, + pWindow->dst, + _("Cancel"), + FONTO_HEADING, 0); pBuf->action = cancel_passwd_callback; set_wstate(pBuf, FC_WS_NORMAL); pBuf->key = SDLK_ESCAPE; @@ -985,15 +997,19 @@ static void popup_new_user_passwd_dialog(const char *pMessage) area.h += pBuf->size.h + adj_size(10); /* Next button */ - pBuf = create_themeicon_button_from_chars(current_theme->OK_Icon, pWindow->dst, - _("Next"), adj_font(14), 0); + pBuf = create_themeicon_button_from_chars_fonto(current_theme->OK_Icon, + pWindow->dst, + _("Next"), + FONTO_HEADING, 0); pBuf->action = send_passwd_callback; pBuf->key = SDLK_RETURN; add_to_gui_list(ID_BUTTON, pBuf); /* Cancel button */ - pBuf = create_themeicon_button_from_chars(current_theme->CANCEL_Icon, pWindow->dst, - _("Cancel"), adj_font(14), 0); + pBuf = create_themeicon_button_from_chars_fonto(current_theme->CANCEL_Icon, + pWindow->dst, + _("Cancel"), + FONTO_HEADING, 0); pBuf->action = cancel_passwd_callback; set_wstate(pBuf, FC_WS_NORMAL); pBuf->key = SDLK_ESCAPE; diff --git a/client/gui-sdl2/dialogs.c b/client/gui-sdl2/dialogs.c index 789dc59ea9..a965ed059f 100644 --- a/client/gui-sdl2/dialogs.c +++ b/client/gui-sdl2/dialogs.c @@ -2884,8 +2884,10 @@ static int nation_button_callback(struct widget *pNationButton) pHelpDlg->pEndWidgetList = pWindow; add_to_gui_list(ID_WINDOW, pWindow); - pOK_Button = create_themeicon_button_from_chars(current_theme->OK_Icon, - pWindow->dst, _("OK"), adj_font(14), 0); + pOK_Button + = create_themeicon_button_from_chars_fonto(current_theme->OK_Icon, + pWindow->dst, _("OK"), + FONTO_HEADING, 0); pOK_Button->action = cancel_help_dlg_callback; set_wstate(pOK_Button, FC_WS_NORMAL); pOK_Button->key = SDLK_ESCAPE; @@ -2894,7 +2896,8 @@ static int nation_button_callback(struct widget *pNationButton) } else { pWindow = pHelpDlg->pEndWidgetList; pOK_Button = pHelpDlg->pBeginWidgetList; - /* undraw window */ + + /* Undraw window */ widget_undraw(pWindow); widget_mark_dirty(pWindow); } @@ -3272,8 +3275,9 @@ void popup_races_dialog(struct player *pplayer) pSetup->pName_Prev = pWidget; /* Change sex button */ - pWidget = create_icon_button_from_chars(NULL, pWindow->dst, - _("Male"), adj_font(14), 0); + pWidget = create_icon_button_from_chars_fonto(NULL, pWindow->dst, + _("Male"), + FONTO_HEADING, 0); pWidget->action = change_sex_callback; pWidget->size.w = adj_size(100); pWidget->size.h = adj_size(22); diff --git a/client/gui-sdl2/diplodlg.c b/client/gui-sdl2/diplodlg.c index 859dbc643b..4a3577f6b2 100644 --- a/client/gui-sdl2/diplodlg.c +++ b/client/gui-sdl2/diplodlg.c @@ -1412,7 +1412,7 @@ static void popup_war_dialog(struct player *pPlayer) /* Label */ fc_snprintf(cBuf, sizeof(cBuf), _("Shall we declare WAR on them?")); - pstr = create_utf8_from_char(cBuf, adj_font(14)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_HEADING); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pstr->fgcol = *get_theme_color(COLOR_THEME_WARDLG_TEXT); @@ -1544,16 +1544,18 @@ void popup_diplomacy_dialog(struct player *pPlayer) /* ============================================================= */ /* Label */ if (client.conn.playing == NULL || client.conn.playing->is_male) { - fc_snprintf(cBuf, sizeof(cBuf), _("Sir!, the %s ambassador has arrived\n" - "What are your wishes?"), + fc_snprintf(cBuf, sizeof(cBuf), + _("Sir!, the %s ambassador has arrived\n" + "What are your wishes?"), nation_adjective_for_player(pPlayer)); } else { - fc_snprintf(cBuf, sizeof(cBuf), _("Ma'am!, the %s ambassador has arrived\n" - "What are your wishes?"), + fc_snprintf(cBuf, sizeof(cBuf), + _("Ma'am!, the %s ambassador has arrived\n" + "What are your wishes?"), nation_adjective_for_player(pPlayer)); } - pstr = create_utf8_from_char(cBuf, adj_font(14)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_HEADING); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pstr->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_TEXT); diff --git a/client/gui-sdl2/gui_string.c b/client/gui-sdl2/gui_string.c index bd48bbf137..f75fea4748 100644 --- a/client/gui-sdl2/gui_string.c +++ b/client/gui-sdl2/gui_string.c @@ -168,6 +168,9 @@ static Uint16 fonto_ptsize(enum font_origin origin) case FONTO_ATTENTION: def = ptsize_default(); return adj_font(MAX(def + 1, def * 1.2)); + case FONTO_HEADING: + def = ptsize_default(); + return adj_font(MAX(def + 2, def * 1.4)); } return 0; diff --git a/client/gui-sdl2/gui_string.h b/client/gui-sdl2/gui_string.h index 54f9f65d0b..92b613635f 100644 --- a/client/gui-sdl2/gui_string.h +++ b/client/gui-sdl2/gui_string.h @@ -62,7 +62,8 @@ typedef struct utf8_str { enum font_origin { FONTO_DEFAULT, - FONTO_ATTENTION + FONTO_ATTENTION, + FONTO_HEADING }; utf8_str *create_utf8_str_fonto(char *in_text, size_t n_alloc, diff --git a/client/gui-sdl2/helpdlg.c b/client/gui-sdl2/helpdlg.c index 40adec66ff..b18f3fb16d 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -1067,7 +1067,7 @@ static void redraw_tech_info_dlg(void) get_theme_color(COLOR_THEME_HELPDLG_FRAME)); /* -------------------------- */ - pstr = create_utf8_from_char(_("Allows"), adj_font(14)); + pstr = create_utf8_from_char_fonto(_("Allows"), FONTO_HEADING); pstr->style |= TTF_STYLE_BOLD; pText0 = create_text_surf_from_utf8(pstr); @@ -1220,10 +1220,11 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, if (VUT_ADVANCE == preq->source.kind && advance_number(preq->source.value.advance) == tech) { - pWidget = create_iconlabel_from_chars(adj_surf(get_government_surface(gov)), + pWidget + = create_iconlabel_from_chars_fonto(adj_surf(get_government_surface(gov)), pWindow->dst, government_name_translation(gov), - adj_font(14), + FONTO_HEADING, WF_RESTORE_BACKGROUND | WF_SELECT_WITHOUT_BAR | WF_FREE_THEME); set_wstate(pWidget, FC_WS_NORMAL); pWidget->action = change_gov_callback; @@ -1246,11 +1247,12 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, if (VUT_ADVANCE == preq->source.kind && advance_number(preq->source.value.advance) == tech) { pSurf = get_building_surface(pimprove); - pWidget = create_iconlabel_from_chars( + pWidget + = create_iconlabel_from_chars_fonto( ResizeSurfaceBox(pSurf, adj_size(48), adj_size(48), 1, TRUE, TRUE), pWindow->dst, improvement_name_translation(pimprove), - adj_font(14), + FONTO_HEADING, WF_RESTORE_BACKGROUND | WF_SELECT_WITHOUT_BAR); set_wstate(pWidget, FC_WS_NORMAL); if (is_wonder(pimprove)) { @@ -1270,13 +1272,11 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, unit_count = 0; unit_type_iterate(un) { - struct unit_type *pUnitType = un; - - if (advance_number(pUnitType->require_advance) == tech) { - pWidget = create_iconlabel_from_chars( + if (advance_number(un->require_advance) == tech) { + pWidget = create_iconlabel_from_chars_fonto( ResizeSurfaceBox(get_unittype_surface(un, direction8_invalid()), adj_size(48), adj_size(48), 1, TRUE, TRUE), - pWindow->dst, utype_name_translation(pUnitType), adj_font(14), + pWindow->dst, utype_name_translation(un), FONTO_HEADING, (WF_FREE_THEME | WF_RESTORE_BACKGROUND | WF_SELECT_WITHOUT_BAR)); set_wstate(pWidget, FC_WS_NORMAL); pWidget->action = change_unit_callback; diff --git a/client/gui-sdl2/inteldlg.c b/client/gui-sdl2/inteldlg.c index 6ff16b976f..84a2702606 100644 --- a/client/gui-sdl2/inteldlg.c +++ b/client/gui-sdl2/inteldlg.c @@ -307,7 +307,7 @@ void update_intel_dialog(struct player *p) _("Intelligence Information for the %s Empire"), nation_adjective_for_player(p)); - pstr = create_utf8_from_char(cBuf, adj_font(14)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_HEADING); pstr->style |= TTF_STYLE_BOLD; pstr->bgcol = (SDL_Color) {0, 0, 0, 0}; diff --git a/client/gui-sdl2/mapview.c b/client/gui-sdl2/mapview.c index 9dc6ffd024..795fe75904 100644 --- a/client/gui-sdl2/mapview.c +++ b/client/gui-sdl2/mapview.c @@ -941,7 +941,7 @@ void redraw_unit_info_label(struct unit_list *punitlist) fc_snprintf(buf, sizeof(buf), "%s\n%s\n%s", _("End of Turn"), _("Press"), _("Shift+Return")); - pstr = create_utf8_from_char(buf, adj_font(14)); + pstr = create_utf8_from_char_fonto(buf, FONTO_HEADING); pstr->style = SF_CENTER; pstr->bgcol = (SDL_Color) {0, 0, 0, 0}; buf_surf = create_text_surf_from_utf8(pstr); @@ -951,7 +951,7 @@ void redraw_unit_info_label(struct unit_list *punitlist) alphablit(buf_surf, NULL, pInfo_Window->dst->surface, &area, 255); FREESURFACE(buf_surf); FREEUTF8STR(pstr); - /* fix the bug of child dialogues not showing up when player's turn ends */ + /* Fix the bug of child dialogues not showing up when player's turn ends */ flush_all(); } } diff --git a/client/gui-sdl2/pages.c b/client/gui-sdl2/pages.c index e1ac6b2fb9..462fd85c9a 100644 --- a/client/gui-sdl2/pages.c +++ b/client/gui-sdl2/pages.c @@ -189,9 +189,10 @@ static void show_main_page(void) add_to_gui_list(ID_LABEL, pWidget); /* Start New Game */ - pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Start New Game"), - adj_font(14), - (WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND|WF_FREE_DATA)); + pWidget = create_iconlabel_from_chars_fonto(NULL, pWindow->dst, + _("Start New Game"), + FONTO_HEADING, + (WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND|WF_FREE_DATA)); pWidget->action = start_new_game_callback; pWidget->string_utf8->style |= SF_CENTER; @@ -204,9 +205,10 @@ static void show_main_page(void) add_to_gui_list(ID_START_NEW_GAME, pWidget); /* Load Game */ - pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Load Game"), - adj_font(14), - (WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND)); + pWidget = create_iconlabel_from_chars_fonto(NULL, pWindow->dst, + _("Load Game"), + FONTO_HEADING, + (WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND)); pWidget->action = load_game_callback; pWidget->string_utf8->style |= SF_CENTER; @@ -219,9 +221,10 @@ static void show_main_page(void) count++; /* Join Game */ - pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Join Game"), - adj_font(14), - WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); + pWidget = create_iconlabel_from_chars_fonto(NULL, pWindow->dst, + _("Join Game"), + FONTO_HEADING, + WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); pWidget->action = join_game_callback; pWidget->string_utf8->style |= SF_CENTER; @@ -234,9 +237,10 @@ static void show_main_page(void) count++; /* Join Pubserver */ - pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Join Pubserver"), - adj_font(14), - WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); + pWidget = create_iconlabel_from_chars_fonto(NULL, pWindow->dst, + _("Join Pubserver"), + FONTO_HEADING, + WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); pWidget->action = servers_callback; pWidget->string_utf8->style |= SF_CENTER; @@ -249,9 +253,10 @@ static void show_main_page(void) count++; /* Join LAN Server */ - pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Join LAN Server"), - adj_font(14), - WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); + pWidget = create_iconlabel_from_chars_fonto(NULL, pWindow->dst, + _("Join LAN Server"), + FONTO_HEADING, + WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); pWidget->action = servers_callback; pWidget->string_utf8->style |= SF_CENTER; @@ -264,9 +269,10 @@ static void show_main_page(void) count++; /* Options */ - pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Options"), - adj_font(14), - WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); + pWidget = create_iconlabel_from_chars_fonto(NULL, pWindow->dst, + _("Options"), + FONTO_HEADING, + WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); pWidget->action = options_callback; pWidget->string_utf8->style |= SF_CENTER; @@ -279,9 +285,10 @@ static void show_main_page(void) count++; /* Quit */ - pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Quit"), - adj_font(14), - WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); + pWidget = create_iconlabel_from_chars_fonto(NULL, pWindow->dst, + _("Quit"), + FONTO_HEADING, + WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND); pWidget->action = quit_callback; pWidget->string_utf8->style |= SF_CENTER; -- 2.40.1