From e0efffa57af90ffc81a7def158ef1599794be857 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 23 Jun 2023 16:13:27 +0300 Subject: [PATCH 10/10] sdl2: Make size 14 fonts to adjust to theme font size See osdn #48271 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/connectdlg.c | 64 +++++++++++++++++++++--------------- client/gui-sdl2/dialogs.c | 14 +++++--- client/gui-sdl2/diplodlg.c | 4 +-- client/gui-sdl2/gui_string.c | 3 ++ client/gui-sdl2/gui_string.h | 3 +- client/gui-sdl2/helpdlg.c | 19 +++++------ client/gui-sdl2/inteldlg.c | 2 +- client/gui-sdl2/mapview.c | 4 +-- client/gui-sdl2/pages.c | 49 +++++++++++++++------------ 9 files changed, 94 insertions(+), 68 deletions(-) diff --git a/client/gui-sdl2/connectdlg.c b/client/gui-sdl2/connectdlg.c index 57583cdc19..56d8a038ce 100644 --- a/client/gui-sdl2/connectdlg.c +++ b/client/gui-sdl2/connectdlg.c @@ -309,9 +309,10 @@ void popup_connection_dialog(bool lan_scan) meta_server->end_widget_list = pwindow; /* Cancel button */ - new_widget = create_themeicon_button_from_chars(current_theme->cancel_icon, - pwindow->dst, _("Cancel"), - adj_font(14), 0); + new_widget + = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon, + pwindow->dst, _("Cancel"), + FONTO_HEADING, 0); new_widget->action = exit_meta_server_dlg_callback; set_wstate(new_widget, FC_WS_NORMAL); add_to_gui_list(ID_BUTTON, new_widget); @@ -319,7 +320,7 @@ void popup_connection_dialog(bool lan_scan) /* Servers */ server_list_iterate(server_list, server) { - /* 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"), server->host, server->port, server->version, _(server->state), @@ -569,9 +570,10 @@ void popup_join_game_dialog(void) area.h += buf->size.h + adj_size(20); /* Player name edit */ - buf = create_edit_from_chars(NULL, pwindow->dst, user_name, adj_font(14), - adj_size(210), - (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); + buf = create_edit_from_chars_fonto(NULL, pwindow->dst, user_name, + FONTO_HEADING, + adj_size(210), + (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); buf->action = convert_playername_callback; set_wstate(buf, FC_WS_NORMAL); add_to_gui_list(ID_PLAYER_NAME_EDIT, buf); @@ -586,8 +588,9 @@ void popup_join_game_dialog(void) area.h += buf->size.h + adj_size(5); /* Server name edit */ - buf = create_edit_from_chars(NULL, pwindow->dst, server_host, adj_font(14), - adj_size(210), WF_RESTORE_BACKGROUND); + buf = create_edit_from_chars_fonto(NULL, pwindow->dst, server_host, + FONTO_HEADING, + adj_size(210), WF_RESTORE_BACKGROUND); buf->action = convert_servername_callback; set_wstate(buf, FC_WS_NORMAL); @@ -605,9 +608,10 @@ void popup_join_game_dialog(void) /* Port edit */ fc_snprintf(port_str, sizeof(port_str), "%d", server_port); - buf = create_edit_from_chars(NULL, pwindow->dst, port_str, adj_font(14), - adj_size(210), - WF_RESTORE_BACKGROUND); + buf = create_edit_from_chars_fonto(NULL, pwindow->dst, port_str, + FONTO_HEADING, + adj_size(210), + WF_RESTORE_BACKGROUND); buf->action = convert_portnr_callback; set_wstate(buf, FC_WS_NORMAL); @@ -615,17 +619,19 @@ void popup_join_game_dialog(void) area.h += buf->size.h + adj_size(20); /* Connect button */ - buf = create_themeicon_button_from_chars(current_theme->ok_icon, pwindow->dst, - _("Connect"), adj_font(14), 0); + buf = create_themeicon_button_from_chars_fonto(current_theme->ok_icon, + pwindow->dst, + _("Connect"), + FONTO_HEADING, 0); buf->action = connect_callback; set_wstate(buf, FC_WS_NORMAL); buf->key = SDLK_RETURN; add_to_gui_list(ID_CONNECT_BUTTON, buf); /* Cancel button */ - buf = create_themeicon_button_from_chars(current_theme->cancel_icon, - pwindow->dst, _("Cancel"), - adj_font(14), 0); + buf = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon, + pwindow->dst, _("Cancel"), + FONTO_HEADING, 0); buf->action = cancel_connect_dlg_callback; set_wstate(buf, FC_WS_NORMAL); buf->key = SDLK_ESCAPE; @@ -811,16 +817,20 @@ static void popup_user_passwd_dialog(const char *message) area.h += buf->size.h + adj_size(10); /* Next button */ - buf = create_themeicon_button_from_chars(current_theme->ok_icon, pwindow->dst, - _("Next"), adj_font(14), 0); + buf = create_themeicon_button_from_chars_fonto(current_theme->ok_icon, + pwindow->dst, + _("Next"), + FONTO_HEADING, 0); buf->action = send_passwd_callback; set_wstate(buf, FC_WS_NORMAL); buf->key = SDLK_RETURN; add_to_gui_list(ID_BUTTON, buf); /* Cancel button */ - buf = create_themeicon_button_from_chars(current_theme->cancel_icon, pwindow->dst, - _("Cancel"), adj_font(14), 0); + buf = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon, + pwindow->dst, + _("Cancel"), + FONTO_HEADING, 0); buf->action = cancel_passwd_callback; set_wstate(buf, FC_WS_NORMAL); buf->key = SDLK_ESCAPE; @@ -983,16 +993,18 @@ static void popup_new_user_passwd_dialog(const char *message) area.h += buf->size.h + adj_size(10); /* Next button */ - buf = create_themeicon_button_from_chars(current_theme->ok_icon, pwindow->dst, - _("Next"), adj_font(14), 0); + buf = create_themeicon_button_from_chars_fonto(current_theme->ok_icon, + pwindow->dst, + _("Next"), + FONTO_HEADING, 0); buf->action = send_passwd_callback; buf->key = SDLK_RETURN; add_to_gui_list(ID_BUTTON, buf); /* Cancel button */ - buf = create_themeicon_button_from_chars(current_theme->cancel_icon, - pwindow->dst, _("Cancel"), - adj_font(14), 0); + buf = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon, + pwindow->dst, _("Cancel"), + FONTO_HEADING, 0); buf->action = cancel_passwd_callback; set_wstate(buf, FC_WS_NORMAL); buf->key = SDLK_ESCAPE; diff --git a/client/gui-sdl2/dialogs.c b/client/gui-sdl2/dialogs.c index b3779621f7..57cdf7bc0a 100644 --- a/client/gui-sdl2/dialogs.c +++ b/client/gui-sdl2/dialogs.c @@ -2926,8 +2926,10 @@ static int nation_button_callback(struct widget *nation_button) help_dlg->end_widget_list = pwindow; add_to_gui_list(ID_WINDOW, pwindow); - ok_button = create_themeicon_button_from_chars(current_theme->ok_icon, - pwindow->dst, _("OK"), adj_font(14), 0); + ok_button + = create_themeicon_button_from_chars_fonto(current_theme->ok_icon, + pwindow->dst, _("OK"), + FONTO_HEADING, 0); ok_button->action = cancel_help_dlg_callback; set_wstate(ok_button, FC_WS_NORMAL); ok_button->key = SDLK_ESCAPE; @@ -2936,7 +2938,8 @@ static int nation_button_callback(struct widget *nation_button) } else { pwindow = help_dlg->end_widget_list; ok_button = help_dlg->begin_widget_list; - /* undraw window */ + + /* Undraw window */ widget_undraw(pwindow); widget_mark_dirty(pwindow); } @@ -3315,8 +3318,9 @@ void popup_races_dialog(struct player *pplayer) setup->name_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 4103349f86..e1c8a80c8d 100644 --- a/client/gui-sdl2/diplodlg.c +++ b/client/gui-sdl2/diplodlg.c @@ -1437,7 +1437,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); @@ -1578,7 +1578,7 @@ void popup_diplomacy_dialog(struct player *pplayer) 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 2b543d5130..5bc0dd0c48 100644 --- a/client/gui-sdl2/gui_string.c +++ b/client/gui-sdl2/gui_string.c @@ -169,6 +169,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 2c795172a3..0e8fc7fc1a 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 31bbfe7476..91f50b3b1e 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -1071,7 +1071,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; text0 = create_text_surf_from_utf8(pstr); @@ -1224,10 +1224,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; @@ -1250,12 +1251,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) { surf = get_building_surface(pimprove); - pwidget = create_iconlabel_from_chars( + pwidget = create_iconlabel_from_chars_fonto( resize_surface_box(surf, 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)) { @@ -1275,13 +1276,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( resize_surface_box(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 5b6a6f89e1..3870f906e0 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 6193c416e4..52e339e778 100644 --- a/client/gui-sdl2/mapview.c +++ b/client/gui-sdl2/mapview.c @@ -949,7 +949,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); @@ -959,7 +959,7 @@ void redraw_unit_info_label(struct unit_list *punitlist) alphablit(buf_surf, NULL, info_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 2158833280..c7f17fcd84 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