Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. *Read more...*

Feature #900047 ยป 0044-sdl2-Rename-pText-to-adhere-with-coding-style.patch

Marko Lindqvist, 2020-11-26 03:50 AM

View differences:

client/gui-sdl2/citydlg.c
char tBuf[512], cBuf[512];
struct widget *buf = NULL, *pwindow;
utf8_str *pstr;
SDL_Surface *pText;
SDL_Surface *text;
SDL_Rect dst;
int window_x = 0, window_y = 0;
SDL_Rect area;
......
pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_BUY);
pText = create_text_surf_from_utf8(pstr);
text = create_text_surf_from_utf8(pstr);
FREEUTF8STR(pstr);
area.w = MAX(area.w , pText->w);
area.h += pText->h + adj_size(5);
area.w = MAX(area.w , text->w);
area.h += text->h + adj_size(5);
buf = create_themeicon_button_from_chars(current_theme->CANCEL_Icon,
pwindow->dst, _("No"), adj_font(12), 0);
......
/* setup rest of widgets */
/* label */
dst.x = area.x + (area.w - pText->w) / 2;
dst.x = area.x + (area.w - text->w) / 2;
dst.y = area.y + 1;
alphablit(pText, NULL, pwindow->theme, &dst, 255);
dst.y += pText->h + adj_size(5);
FREESURFACE(pText);
alphablit(text, NULL, pwindow->theme, &dst, 255);
dst.y += text->h + adj_size(5);
FREESURFACE(text);
/* no */
buf = pwindow->prev;
client/gui-sdl2/cityrep.c
struct widget *pbuf = NULL;
struct widget *pwindow, *pLast;
utf8_str *pstr;
SDL_Surface *pText1, *pText2, *pText3, *units_icon, *pCMA_Icon, *pText4;
SDL_Surface *text1, *text2, *text3, *units_icon, *pCMA_Icon, *text4;
SDL_Surface *logo;
int togrow, w = 0 , count, ww = 0, hh = 0, name_w = 0, prod_w = 0, H;
char cbuf[128];
......
fc_snprintf(cbuf, sizeof(cbuf), _("size"));
pstr = create_utf8_from_char(cbuf, adj_font(10));
pstr->style |= SF_CENTER;
pText1 = create_text_surf_from_utf8(pstr);
text1 = create_text_surf_from_utf8(pstr);
fc_snprintf(cbuf, sizeof(cbuf), _("time\nto grow"));
copy_chars_to_utf8_str(pstr, cbuf);
pText2 = create_text_surf_from_utf8(pstr);
text2 = create_text_surf_from_utf8(pstr);
fc_snprintf(cbuf, sizeof(cbuf), _("City Name"));
copy_chars_to_utf8_str(pstr, cbuf);
pText3 = create_text_surf_from_utf8(pstr);
name_w = pText3->w + adj_size(6);
text3 = create_text_surf_from_utf8(pstr);
name_w = text3->w + adj_size(6);
fc_snprintf(cbuf, sizeof(cbuf), _("Production"));
copy_chars_to_utf8_str(pstr, cbuf);
pstr->fgcol = *get_theme_color(COLOR_THEME_CITYREP_TEXT);
pText4 = create_text_surf_from_utf8(pstr);
prod_w = pText4->w;
text4 = create_text_surf_from_utf8(pstr);
prod_w = text4->w;
FREEUTF8STR(pstr);
units_icon = create_icon_from_theme(current_theme->UNITS_Icon, 0);
......
set_wflag(pbuf, WF_HIDDEN);
}
hh = MAX(hh, pbuf->size.h);
pbuf->size.w = pText1->w + adj_size(8);
pbuf->size.w = text1->w + adj_size(8);
add_to_gui_list(MAX_ID - pcity->id, pbuf);
/* ----------- */
......
set_wflag(pbuf, WF_HIDDEN);
}
hh = MAX(hh, pbuf->size.h);
pbuf->size.w = pText2->w + adj_size(6);
pbuf->size.w = text2->w + adj_size(6);
add_to_gui_list(MAX_ID - pcity->id, pbuf);
/* ----------- */
......
H = hh;
city_rep->begin_widget_list = pbuf;
/* setup window width */
area.w = name_w + adj_size(6) + pText1->w + adj_size(8) + pCMA_Icon->w
+ (pIcons->pBIG_Food->w + adj_size(6)) * 10 + pText2->w + adj_size(6)
area.w = name_w + adj_size(6) + text1->w + adj_size(8) + pCMA_Icon->w
+ (pIcons->pBIG_Food->w + adj_size(6)) * 10 + text2->w + adj_size(6)
+ units_icon->w + adj_size(6) + prod_w + adj_size(170);
if (count) {
......
}
}
area.h += pText2->h + adj_size(6);
area.h += text2->h + adj_size(6);
area.w += adj_size(2);
logo = theme_get_background(theme, BACKGROUND_CITYREP);
......
/* cities background and labels */
dst.x = area.x + adj_size(2);
dst.y = area.y + 1;
dst.w = (name_w + adj_size(6)) + (pText1->w + adj_size(8)) + adj_size(5);
dst.w = (name_w + adj_size(6)) + (text1->w + adj_size(8)) + adj_size(5);
dst.h = area.h - adj_size(2);
fill_rect_alpha(pwindow->theme, &dst, &bg_color);
......
dst.x , dst.y, dst.w, dst.h - 1,
get_theme_color(COLOR_THEME_CITYREP_FRAME));
dst.y += (pText2->h - pText3->h) / 2;
dst.x += ((name_w + adj_size(6)) - pText3->w) / 2;
alphablit(pText3, NULL, pwindow->theme, &dst, 255);
FREESURFACE(pText3);
dst.y += (text2->h - text3->h) / 2;
dst.x += ((name_w + adj_size(6)) - text3->w) / 2;
alphablit(text3, NULL, pwindow->theme, &dst, 255);
FREESURFACE(text3);
/* city size background and label */
dst.x = area.x + adj_size(5) + name_w + adj_size(5 + 4);
alphablit(pText1, NULL, pwindow->theme, &dst, 255);
ww = pText1->w;
FREESURFACE(pText1);
alphablit(text1, NULL, pwindow->theme, &dst, 255);
ww = text1->w;
FREESURFACE(text1);
/* cma icon */
dst.x += (ww + adj_size(9));
dst.y = area.y + 1 + (pText2->h - pCMA_Icon->h) / 2;
dst.y = area.y + 1 + (text2->h - pCMA_Icon->h) / 2;
alphablit(pCMA_Icon, NULL, pwindow->theme, &dst, 255);
ww = pCMA_Icon->w;
FREESURFACE(pCMA_Icon);
......
w = dst.x + adj_size(2);
dst.w = (pIcons->pBIG_Food->w + adj_size(6)) + adj_size(10)
+ (pIcons->pBIG_Food_Surplus->w + adj_size(6)) + adj_size(10)
+ pText2->w + adj_size(6 + 2);
+ text2->w + adj_size(6 + 2);
dst.h = area.h - adj_size(2);
fill_rect_alpha(pwindow->theme, &dst, get_theme_color(COLOR_THEME_CITYREP_FOODSTOCK));
......
dst.x, dst.y, dst.w, dst.h - 1,
get_theme_color(COLOR_THEME_CITYREP_FRAME));
dst.y = area.y + 1 + (pText2->h - pIcons->pBIG_Food->h) / 2;
dst.y = area.y + 1 + (text2->h - pIcons->pBIG_Food->h) / 2;
dst.x += adj_size(5);
alphablit(pIcons->pBIG_Food, NULL, pwindow->theme, &dst, 255);
......
w += (pIcons->pBIG_Food_Surplus->w + adj_size(6)) + adj_size(10);
dst.x = w + adj_size(3);
dst.y = area.y + 1;
alphablit(pText2, NULL, pwindow->theme, &dst, 255);
hh = pText2->h;
ww = pText2->w;
FREESURFACE(pText2);
alphablit(text2, NULL, pwindow->theme, &dst, 255);
hh = text2->h;
ww = text2->w;
FREESURFACE(text2);
/* -------------- */
/* trade, corruptions, gold, science, luxury income background and label */
......
dst.x , dst.y, dst.w, dst.h - 1,
get_theme_color(COLOR_THEME_CITYREP_FRAME));
dst.y = area.y + 1 + (hh - pText4->h) / 2;
dst.x += (dst.w - pText4->w) / 2;
alphablit(pText4, NULL, pwindow->theme, &dst, 255);
FREESURFACE(pText4);
dst.y = area.y + 1 + (hh - text4->h) / 2;
dst.x += (dst.w - text4->w) / 2;
alphablit(text4, NULL, pwindow->theme, &dst, 255);
FREESURFACE(text4);
if (count) {
int start_x = area.x + adj_size(5);
client/gui-sdl2/cma_fe.c
if (PRESSED_EVENT(main_data.event)) {
struct widget *buf, *pwindow;
utf8_str *pstr;
SDL_Surface *pText;
SDL_Surface *text;
SDL_Rect dst;
SDL_Rect area;
......
pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pstr->fgcol = *get_theme_color(COLOR_THEME_CMA_TEXT);
pText = create_text_surf_from_utf8(pstr);
text = create_text_surf_from_utf8(pstr);
FREEUTF8STR(pstr);
area.w = MAX(area.w, pText->w);
area.h += pText->h + adj_size(5);
area.w = MAX(area.w, text->w);
area.h += text->h + adj_size(5);
/* ============================================================= */
buf = create_edit(NULL, pwindow->dst,
......
/* setup rest of widgets */
/* label */
dst.x = area.x + (area.w - pText->w) / 2;
dst.x = area.x + (area.w - text->w) / 2;
dst.y = area.y + 1;
alphablit(pText, NULL, pwindow->theme, &dst, 255);
dst.y += pText->h + adj_size(5);
FREESURFACE(pText);
alphablit(text, NULL, pwindow->theme, &dst, 255);
dst.y += text->h + adj_size(5);
FREESURFACE(text);
/* edit */
buf = pwindow->prev;
......
SDL_Color bg_color = {255, 255, 255, 136};
int count, step, i;
struct widget *buf = pCma->pDlg->end_widget_list; /* pwindow */
SDL_Surface *pText;
SDL_Surface *text;
utf8_str *pstr;
SDL_Rect dst;
bool cma_presets_exist = cmafec_preset_num() > 0;
......
/* redraw Citizens */
count = city_size_get(pCma->pcity);
pText = get_tax_surface(O_LUXURY);
step = (buf->size.w - adj_size(20)) / pText->w;
text = get_tax_surface(O_LUXURY);
step = (buf->size.w - adj_size(20)) / text->w;
if (count > step) {
step = (buf->size.w - adj_size(20) - pText->w) / (count - 1);
step = (buf->size.w - adj_size(20) - text->w) / (count - 1);
} else {
step = pText->w;
step = text->w;
}
dst.y = buf->area.y + adj_size(4);
......
i < count - (result->specialists[SP_ELVIS]
+ result->specialists[SP_SCIENTIST]
+ result->specialists[SP_TAXMAN]); i++) {
pText = adj_surf(get_citizen_surface(CITIZEN_CONTENT, i));
alphablit(pText, NULL, buf->dst->surface, &dst, 255);
text = adj_surf(get_citizen_surface(CITIZEN_CONTENT, i));
alphablit(text, NULL, buf->dst->surface, &dst, 255);
dst.x += step;
}
pText = get_tax_surface(O_LUXURY);
text = get_tax_surface(O_LUXURY);
for (i = 0; i < result->specialists[SP_ELVIS]; i++) {
alphablit(pText, NULL, buf->dst->surface, &dst, 255);
alphablit(text, NULL, buf->dst->surface, &dst, 255);
dst.x += step;
}
pText = get_tax_surface(O_GOLD);
text = get_tax_surface(O_GOLD);
for (i = 0; i < result->specialists[SP_TAXMAN]; i++) {
alphablit(pText, NULL, buf->dst->surface, &dst, 255);
alphablit(text, NULL, buf->dst->surface, &dst, 255);
dst.x += step;
}
pText = get_tax_surface(O_SCIENCE);
text = get_tax_surface(O_SCIENCE);
for (i = 0; i < result->specialists[SP_SCIENTIST]; i++) {
alphablit(pText, NULL, buf->dst->surface, &dst, 255);
alphablit(text, NULL, buf->dst->surface, &dst, 255);
dst.x += step;
}
}
......
&pCma->edited_cm_parm),
adj_font(12));
pText = create_text_surf_from_utf8(pstr);
text = create_text_surf_from_utf8(pstr);
FREEUTF8STR(pstr);
/* fill result text background */
dst.x = buf->area.x + adj_size(7);
dst.y = buf->area.y + adj_size(186);
dst.w = pText->w + adj_size(10);
dst.h = pText->h + adj_size(10);
dst.w = text->w + adj_size(10);
dst.h = text->h + adj_size(10);
fill_rect_alpha(buf->dst->surface, &dst, &bg_color);
create_frame(buf->dst->surface,
......
dst.x += adj_size(5);
dst.y += adj_size(5);
alphablit(pText, NULL, buf->dst->surface, &dst, 255);
FREESURFACE(pText);
alphablit(text, NULL, buf->dst->surface, &dst, 255);
FREESURFACE(text);
/* happy factor scrollbar */
buf = pCma->pDlg->begin_widget_list->next->next->next->next->next->next->next;
......
SDL_Color bg_color = {255, 255, 255, 136};
struct widget *pwindow, *buf;
SDL_Surface *logo, *pText[O_LAST + 1], *pMinimal, *pFactor;
SDL_Surface *logo, *text[O_LAST + 1], *pMinimal, *pFactor;
SDL_Surface *pcity_map;
utf8_str *pstr;
char cBuf[128];
......
/* ---------- */
output_type_iterate(i) {
copy_chars_to_utf8_str(pstr, get_output_name(i));
pText[i] = create_text_surf_from_utf8(pstr);
text_w = MAX(text_w, pText[i]->w);
text[i] = create_text_surf_from_utf8(pstr);
text_w = MAX(text_w, text[i]->w);
/* minimal label */
buf = create_iconlabel(NULL, pwindow->dst,
......
} output_type_iterate_end;
copy_chars_to_utf8_str(pstr, _("Celebrate"));
pText[O_LAST] = create_text_surf_from_utf8(pstr);
text[O_LAST] = create_text_surf_from_utf8(pstr);
FREEUTF8STR(pstr);
/* happy factor label */
......
area.y = dst.y - adj_size(20);
w = area.w = adj_size(10) + text_w + adj_size(10) + pwindow->prev->prev->size.w + adj_size(5 + 70 + 5)
+ pwindow->prev->prev->size.w + adj_size(5 + 55 + 10);
area.h = (O_LAST + 1) * (pText[0]->h + adj_size(6)) + adj_size(20);
area.h = (O_LAST + 1) * (text[0]->h + adj_size(6)) + adj_size(20);
fill_rect_alpha(pwindow->theme, &area, &bg_color);
create_frame(pwindow->theme,
......
/* min label */
buf = buf->prev;
buf->size.x = pwindow->size.x + dst.x + text_w + adj_size(10);
buf->size.y = pwindow->size.y + dst.y + (pText[i]->h - buf->size.h) / 2;
buf->size.y = pwindow->size.y + dst.y + (text[i]->h - buf->size.h) / 2;
/* min sb */
buf = buf->prev;
buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(5);
buf->size.y = pwindow->size.y + dst.y + (pText[i]->h - buf->size.h) / 2;
buf->size.y = pwindow->size.y + dst.y + (text[i]->h - buf->size.h) / 2;
area.x = buf->size.x - pwindow->size.x - adj_size(2);
area.y = buf->size.y - pwindow->size.y;
......
/* factor label */
buf = buf->prev;
buf->size.x = buf->next->size.x + adj_size(75);
buf->size.y = pwindow->size.y + dst.y + (pText[i]->h - buf->size.h) / 2;
buf->size.y = pwindow->size.y + dst.y + (text[i]->h - buf->size.h) / 2;
/* factor sb */
buf = buf->prev;
buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(5);
buf->size.y = pwindow->size.y + dst.y + (pText[i]->h - buf->size.h) / 2;
buf->size.y = pwindow->size.y + dst.y + (text[i]->h - buf->size.h) / 2;
area.x = buf->size.x - pwindow->size.x - adj_size(2);
area.y = buf->size.y - pwindow->size.y;
......
area.x, area.y, area.w - 1, area.h - 1,
get_theme_color(COLOR_THEME_CMA_FRAME));
alphablit(pText[i], NULL, pwindow->theme, &dst, 255);
dst.y += pText[i]->h + adj_size(6);
FREESURFACE(pText[i]);
alphablit(text[i], NULL, pwindow->theme, &dst, 255);
dst.y += text[i]->h + adj_size(6);
FREESURFACE(text[i]);
} output_type_iterate_end;
/* happy factor label */
buf = buf->prev;
buf->size.x = buf->next->next->size.x;
buf->size.y = pwindow->size.y + dst.y + (pText[O_LAST]->h - buf->size.h) / 2;
buf->size.y = pwindow->size.y + dst.y + (text[O_LAST]->h - buf->size.h) / 2;
/* happy factor sb */
buf = buf->prev;
buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(5);
buf->size.y = pwindow->size.y + dst.y + (pText[O_LAST]->h - buf->size.h) / 2;
buf->size.y = pwindow->size.y + dst.y + (text[O_LAST]->h - buf->size.h) / 2;
area.x = buf->size.x - pwindow->size.x - adj_size(2);
area.y = buf->size.y - pwindow->size.y;
......
/* celebrate static text */
dst.x += (adj_size(10) + buf->size.w + adj_size(5));
dst.y += (buf->size.h - pText[O_LAST]->h) / 2;
alphablit(pText[O_LAST], NULL, pwindow->theme, &dst, 255);
FREESURFACE(pText[O_LAST]);
dst.y += (buf->size.h - text[O_LAST]->h) / 2;
alphablit(text[O_LAST], NULL, pwindow->theme, &dst, 255);
FREESURFACE(text[O_LAST]);
/* ------------------------ */
/* save as */
client/gui-sdl2/dialogs.c
char cBuf[128];
struct widget *buf = NULL, *pwindow;
utf8_str *pstr;
SDL_Surface *pText;
SDL_Surface *text;
SDL_Rect dst;
int window_x = 0, window_y = 0;
enum unit_upgrade_result unit_upgrade_result;
......
pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pstr->fgcol = *get_theme_color(COLOR_THEME_UNITUPGRADE_TEXT);
pText = create_text_surf_from_utf8(pstr);
text = create_text_surf_from_utf8(pstr);
FREEUTF8STR(pstr);
area.w = MAX(area.w, pText->w + adj_size(20));
area.h += (pText->h + adj_size(10));
area.w = MAX(area.w, text->w + adj_size(20));
area.h += (text->h + adj_size(10));
/* cancel button */
buf = create_themeicon_button_from_chars(current_theme->CANCEL_Icon,
......
/* setup rest of widgets */
/* label */
dst.x = area.x + (area.w - pText->w) / 2;
dst.x = area.x + (area.w - text->w) / 2;
dst.y = area.y + adj_size(10);
alphablit(pText, NULL, pwindow->theme, &dst, 255);
FREESURFACE(pText);
alphablit(text, NULL, pwindow->theme, &dst, 255);
FREESURFACE(text);
/* cancel button */
buf = pwindow->prev;
......
char cBuf[128];
struct widget *buf = NULL, *pwindow;
utf8_str *pstr;
SDL_Surface *pText;
SDL_Surface *text;
SDL_Rect dst;
int window_x = 0, window_y = 0;
bool unit_disband_result;
......
pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pstr->fgcol = *get_theme_color(COLOR_THEME_UNITDISBAND_TEXT);
pText = create_text_surf_from_utf8(pstr);
text = create_text_surf_from_utf8(pstr);
FREEUTF8STR(pstr);
area.w = MAX(area.w, pText->w + adj_size(20));
area.h += (pText->h + adj_size(10));
area.w = MAX(area.w, text->w + adj_size(20));
area.h += (text->h + adj_size(10));
/* cancel button */
buf = create_themeicon_button_from_chars(current_theme->CANCEL_Icon,
......
/* setup rest of widgets */
/* label */
dst.x = area.x + (area.w - pText->w) / 2;
dst.x = area.x + (area.w - text->w) / 2;
dst.y = area.y + adj_size(10);
alphablit(pText, NULL, pwindow->theme, &dst, 255);
FREESURFACE(pText);
alphablit(text, NULL, pwindow->theme, &dst, 255);
FREESURFACE(text);
/* cancel button */
buf = pwindow->prev;
......
/* pop up nation description */
struct widget *pwindow, *ok_button;
utf8_str *pstr;
SDL_Surface *pText;
SDL_Surface *text;
SDL_Rect area, area2;
struct nation_type *pNation = nation_by_number(MAX_ID - pNationButton->ID);
......
}
pstr->fgcol = *get_theme_color(COLOR_THEME_NATIONDLG_LEGEND);
pText = create_text_surf_smaller_than_w(pstr, main_window_width() - adj_size(20));
text = create_text_surf_smaller_than_w(pstr, main_window_width() - adj_size(20));
FREEUTF8STR(pstr);
/* create window background */
area.w = MAX(area.w, pText->w + adj_size(20));
area.w = MAX(area.w, text->w + adj_size(20));
area.w = MAX(area.w, ok_button->size.w + adj_size(20));
area.h = MAX(area.h, adj_size(9) + pText->h
area.h = MAX(area.h, adj_size(9) + text->h
+ adj_size(10) + ok_button->size.h + adj_size(10));
resize_window(pwindow, NULL, get_theme_color(COLOR_THEME_BACKGROUND),
......
area2.x = area.x + adj_size(7);
area2.y = area.y + adj_size(6);
alphablit(pText, NULL, pwindow->theme, &area2, 255);
FREESURFACE(pText);
alphablit(text, NULL, pwindow->theme, &area2, 255);
FREESURFACE(text);
ok_button->size.x = area.x + (area.w - ok_button->size.w) / 2;
ok_button->size.y = area.y + area.h - ok_button->size.h - adj_size(10);
......
int len = 0;
int w = adj_size(10), h = adj_size(10);
SDL_Surface *pTmp_Surf, *pTmp_Surf_zoomed = NULL;
SDL_Surface *pMain_Bg, *pText_Name;
SDL_Surface *pMain_Bg, *text_name;
SDL_Rect dst;
float zoom;
struct NAT *pSetup;
......
copy_chars_to_utf8_str(pstr, nation_plural_translation(pNation));
change_ptsize_utf8(pstr, adj_font(12));
pText_Name = create_text_surf_smaller_than_w(pstr, pTmp_Surf->w - adj_size(4));
text_name = create_text_surf_smaller_than_w(pstr, pTmp_Surf->w - adj_size(4));
dst.x = (pTmp_Surf->w - pTmp_Surf_zoomed->w) / 2;
len = pTmp_Surf_zoomed->h +
adj_size(10) + pText_Name->h;
adj_size(10) + text_name->h;
dst.y = (pTmp_Surf->h - len) / 2;
alphablit(pTmp_Surf_zoomed, NULL, pTmp_Surf, &dst, 255);
dst.y += (pTmp_Surf_zoomed->h + adj_size(10));
dst.x = (pTmp_Surf->w - pText_Name->w) / 2;
alphablit(pText_Name, NULL, pTmp_Surf, &dst, 255);
dst.y += pText_Name->h;
FREESURFACE(pText_Name);
dst.x = (pTmp_Surf->w - text_name->w) / 2;
alphablit(text_name, NULL, pTmp_Surf, &dst, 255);
dst.y += text_name->h;
FREESURFACE(text_name);
pwidget = create_icon2(pTmp_Surf, pwindow->dst,
(WF_RESTORE_BACKGROUND|WF_FREE_THEME));
client/gui-sdl2/diplodlg.c
char cBuf[128];
struct widget *buf = NULL, *pwindow;
utf8_str *pstr;
SDL_Surface *pText;
SDL_Surface *text;
SDL_Rect dst;
SDL_Rect area;
......
pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pstr->fgcol = *get_theme_color(COLOR_THEME_WARDLG_TEXT);
pText = create_text_surf_from_utf8(pstr);
text = create_text_surf_from_utf8(pstr);
FREEUTF8STR(pstr);
area.w = MAX(area.w, pText->w);
area.h += pText->h + adj_size(10);
area.w = MAX(area.w, text->w);
area.h += text->h + adj_size(10);
buf = create_themeicon_button_from_chars(current_theme->CANCEL_Icon,
pwindow->dst, _("No"),
......
/* setup rest of widgets */
/* label */
dst.x = area.x + (area.w - pText->w) / 2;
dst.x = area.x + (area.w - text->w) / 2;
dst.y = area.y + 1;
alphablit(pText, NULL, pwindow->theme, &dst, 255);
dst.y += pText->h + adj_size(5);
FREESURFACE(pText);
alphablit(text, NULL, pwindow->theme, &dst, 255);
dst.y += text->h + adj_size(5);
FREESURFACE(text);
/* no */
buf = pwindow->prev;
......
char cBuf[128];
struct widget *buf = NULL, *pwindow;
utf8_str *pstr;
SDL_Surface *pText;
SDL_Surface *text;
SDL_Rect dst;
bool shared;
SDL_Rect area;
......
pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pstr->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_TEXT);
pText = create_text_surf_from_utf8(pstr);
text = create_text_surf_from_utf8(pstr);
FREEUTF8STR(pstr);
area.w = MAX(area.w , pText->w);
area.h += pText->h + adj_size(15);
area.w = MAX(area.w , text->w);
area.h += text->h + adj_size(15);
can_toward_war = can_client_issue_orders()
&& pplayer_can_cancel_treaty(client_player(), pplayer) == DIPL_OK;
......
/* setup rest of widgets */
/* label */
dst.x = area.x + (area.w - pText->w) / 2;
dst.x = area.x + (area.w - text->w) / 2;
dst.y = area.y + 1;
alphablit(pText, NULL, pwindow->theme, &dst, 255);
dst.y += pText->h + adj_size(15);
FREESURFACE(pText);
alphablit(text, NULL, pwindow->theme, &dst, 255);
dst.y += text->h + adj_size(15);
FREESURFACE(text);
buf = pwindow;
client/gui-sdl2/helpdlg.c
}
if (!help_dlg) {
SDL_Surface *background_tmpl, *background, *pText, *icon;
SDL_Surface *background_tmpl, *background, *impr_name, *icon;
SDL_Rect dst;
current_help_dlg = HELP_IMPROVEMENT;
......
/* 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) + (background->w - pText->w - adj_size(40)) / 2;
dst.y = (background->h - pText->h) / 2;
alphablit(pText, NULL, background, &dst, 255);
FREESURFACE(pText);
impr_name = create_text_surf_smaller_than_w(pstr, adj_size(100 - 4));
dst.x = adj_size(40) + (background->w - impr_name->w - adj_size(40)) / 2;
dst.y = (background->h - impr_name->h) / 2;
alphablit(impr_name, NULL, background, &dst, 255);
FREESURFACE(impr_name);
/* blit improvement icon */
icon = ResizeSurfaceBox(get_building_surface(pimprove),
......
/* create new dialog if it doesn't exist yet */
if (!help_dlg) {
SDL_Surface *background_tmpl, *background, *pText, *icon;
SDL_Surface *background_tmpl, *background, *unit_name, *icon;
SDL_Rect dst;
current_help_dlg = HELP_UNIT;
......
/* 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) + (background->w - pText->w - adj_size(35)) / 2;
dst.y = (background->h - pText->h) / 2;
alphablit(pText, NULL, background, &dst, 255);
FREESURFACE(pText);
unit_name = create_text_surf_smaller_than_w(pstr, adj_size(100 - 4));
dst.x = adj_size(35) + (background->w - unit_name->w - adj_size(35)) / 2;
dst.y = (background->h - unit_name->h) / 2;
alphablit(unit_name, NULL, background, &dst, 255);
FREESURFACE(unit_name);
/* blit unit icon */
icon = ResizeSurfaceBox(get_unittype_surface(ut, direction8_invalid()),
......
SDL_Color bg_color = {255, 255, 255, 64};
struct widget *pwindow = help_dlg->end_widget_list;
struct techs_buttons *store = (struct techs_buttons *)pwindow->data.ptr;
SDL_Surface *pText0, *pText1 = NULL;
SDL_Surface *text0, *text1 = NULL;
utf8_str *pstr;
SDL_Rect dst;
......
pstr = create_utf8_from_char(_("Allows"), adj_font(14));
pstr->style |= TTF_STYLE_BOLD;
pText0 = create_text_surf_from_utf8(pstr);
text0 = create_text_surf_from_utf8(pstr);
dst.x = store->dock->prev->prev->size.x;
if (store->pTargets[0]) {
dst.y = store->pTargets[0]->size.y - pText0->h;
dst.y = store->pTargets[0]->size.y - text0->h;
} else {
dst.y = store->dock->prev->prev->size.y
+ store->dock->prev->prev->size.h + adj_size(10);
}
alphablit(pText0, NULL, pwindow->dst->surface, &dst, 255);
FREESURFACE(pText0);
alphablit(text0, NULL, pwindow->dst->surface, &dst, 255);
FREESURFACE(text0);
if (store->pSub_Targets[0]) {
int i;
......
change_ptsize_utf8(pstr, adj_font(12));
copy_chars_to_utf8_str(pstr, _("( with "));
pText0 = create_text_surf_from_utf8(pstr);
text0 = create_text_surf_from_utf8(pstr);
copy_chars_to_utf8_str(pstr, _(" )"));
pText1 = create_text_surf_from_utf8(pstr);
text1 = create_text_surf_from_utf8(pstr);
i = 0;
while (i < 6 && store->pSub_Targets[i]) {
dst.x = store->pSub_Targets[i]->size.x - pText0->w;
dst.x = store->pSub_Targets[i]->size.x - text0->w;
dst.y = store->pSub_Targets[i]->size.y;
alphablit(pText0, NULL, pwindow->dst->surface, &dst, 255);
alphablit(text0, NULL, pwindow->dst->surface, &dst, 255);
dst.x = store->pSub_Targets[i]->size.x + store->pSub_Targets[i]->size.w;
dst.y = store->pSub_Targets[i]->size.y;
alphablit(pText1, NULL, pwindow->dst->surface, &dst, 255);
alphablit(text1, NULL, pwindow->dst->surface, &dst, 255);
i++;
}
FREESURFACE(pText0);
FREESURFACE(pText1);
FREESURFACE(text0);
FREESURFACE(text1);
}
FREEUTF8STR(pstr);
client/gui-sdl2/inteldlg.c
struct intel_dialog *pdialog = get_intel_dialog(p);
struct widget *pwindow = NULL, *buf = NULL, *pLast;
SDL_Surface *logo = NULL, *tmp_surf = NULL;
SDL_Surface *pText1, *pInfo, *pText2 = NULL;
SDL_Surface *text1, *pInfo, *text2 = NULL;
utf8_str *pstr;
SDL_Rect dst;
char cBuf[256], plr_buf[4 * MAX_LEN_NAME];
......
{
double zoom = DEFAULT_ZOOM * 60.0 / logo->h;
pText1 = zoomSurface(logo, zoom, zoom, 1);
text1 = zoomSurface(logo, zoom, zoom, 1);
}
logo = pText1;
logo = text1;
buf = create_icon2(logo, pwindow->dst,
WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL
......
pstr->style |= TTF_STYLE_BOLD;
pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
pText1 = create_text_surf_from_utf8(pstr);
area.w = MAX(area.w, pText1->w + adj_size(20));
area.h += pText1->h + adj_size(20);
text1 = create_text_surf_from_utf8(pstr);
area.w = MAX(area.w, text1->w + adj_size(20));
area.h += text1->h + adj_size(20);
/* ---------- */
......
fc_snprintf(cBuf, sizeof(cBuf), _("Their techs that we don't have :"));
copy_chars_to_utf8_str(pstr, cBuf);
pstr->style |= TTF_STYLE_BOLD;
pText2 = create_text_surf_from_utf8(pstr);
text2 = create_text_surf_from_utf8(pstr);
}
FREEUTF8STR(pstr);
......
buf->size.x = area.x + area.w - buf->size.w - 1;
buf->size.y = pwindow->size.y + adj_size(2);
dst.x = area.x + (area.w - pText1->w) / 2;
dst.x = area.x + (area.w - text1->w) / 2;
dst.y = area.y + adj_size(8);
alphablit(pText1, NULL, pwindow->theme, &dst, 255);
dst.y += pText1->h + adj_size(10);
FREESURFACE(pText1);
alphablit(text1, NULL, pwindow->theme, &dst, 255);
dst.y += text1->h + adj_size(10);
FREESURFACE(text1);
/* spaceship button */
buf = buf->prev;
......
if (n) {
dst.x = area.x + adj_size(5);
alphablit(pText2, NULL, pwindow->theme, &dst, 255);
dst.y += pText2->h + adj_size(2);
FREESURFACE(pText2);
alphablit(text2, NULL, pwindow->theme, &dst, 255);
dst.y += text2->h + adj_size(2);
FREESURFACE(text2);
setup_vertical_widgets_position(col, area.x, dst.y, 0, 0,
pdialog->pdialog->begin_active_widget_list,
client/gui-sdl2/mapctrl.c
**************************************************************************/
static void popup_minimap_scale_dialog(void)
{
SDL_Surface *pText1, *pText2;
SDL_Surface *text1, *text2;
utf8_str *pstr = NULL;
struct widget *pwindow = NULL;
struct widget *buf = NULL;
......
/* ----------------- */
pstr = create_utf8_from_char(_("Single Tile Width"), adj_font(12));
pText1 = create_text_surf_from_utf8(pstr);
area.w = MAX(area.w, pText1->w + adj_size(30));
text1 = create_text_surf_from_utf8(pstr);
area.w = MAX(area.w, text1->w + adj_size(30));
copy_chars_to_utf8_str(pstr, _("Single Tile Height"));
pText2 = create_text_surf_from_utf8(pstr);
area.w = MAX(area.w, pText2->w + adj_size(30));
text2 = create_text_surf_from_utf8(pstr);
area.w = MAX(area.w, text2->w + adj_size(30));
FREEUTF8_STR(pstr);
buf = create_themeicon_button(current_theme->L_ARROW_Icon, pwindow->dst, NULL, 0);
......
widget_set_position(pwindow, window_x, window_y);
blit_entire_src(pText1, pwindow->theme, 15, area.y + 1);
FREESURFACE(pText1);
blit_entire_src(text1, pwindow->theme, 15, area.y + 1);
FREESURFACE(text1);
/* width label */
buf = pwindow->prev->prev;
......
buf->size.y = buf->next->next->next->size.y + buf->next->next->next->size.h + adj_size(20);
buf->size.x = area.x + (area.w - buf->size.w) / 2;
blit_entire_src(pText2, pwindow->theme, adj_size(15), buf->size.y - pText2->h - adj_size(2));
FREESURFACE(pText2);
blit_entire_src(text2, pwindow->theme, adj_size(15), buf->size.y - text2->h - adj_size(2));
FREESURFACE(text2);
/* height left button */
buf->next->size.y = buf->size.y + buf->size.h - buf->next->size.h;
......
return;
#endif /* SCALE_UNITINFO */
SDL_Surface *pText1, *pText2;
SDL_Surface *text1, *text2;
utf8_str *pstr = NULL;
struct widget *pwindow = NULL;
struct widget *buf = NULL;
......
area = pwindow->area;
pstr = create_utf8_from_char(_("Width"), adj_font(12));
pText1 = create_text_surf_from_utf8(pstr);
area.w = MAX(area.w, pText1->w + adj_size(30));
area.h += MAX(adj_size(20), pText1->h + adj_size(4));
text1 = create_text_surf_from_utf8(pstr);
area.w = MAX(area.w, text1->w + adj_size(30));
area.h += MAX(adj_size(20), text1->h + adj_size(4));
copy_chars_to_utf8_str(pstr, _("Height"));
pText2 = create_text_surf_from_utf8(pstr);
area.w = MAX(area.w, pText2->w + adj_size(30));
area.h += MAX(adj_size(20), pText2->h + adj_size(4));
text2 = create_text_surf_from_utf8(pstr);
area.w = MAX(area.w, text2->w + adj_size(30));
area.h += MAX(adj_size(20), text2->h + adj_size(4));
FREEUTF8STR(pstr);
/* ----------------- */
......
/* width left button */
buf = pwindow->prev;
buf->size.y = area.y + MAX(adj_size(20), pText1->h + adj_size(4));
buf->size.y = area.y + MAX(adj_size(20), text1->h + adj_size(4));
buf->size.x = area.x + (area.w - buf->size.w * 2) / 2;
blit_entire_src(pText1, pwindow->theme, adj_size(15), buf->size.y
- area.y - pText1->h - adj_size(2));
FREESURFACE(pText1);
blit_entire_src(text1, pwindow->theme, adj_size(15), buf->size.y
- area.y - text1->h - adj_size(2));
FREESURFACE(text1);
/* width right button */
buf->prev->size.y = buf->size.y;
......
/* height left button */
buf = buf->prev->prev;
buf->size.y = buf->next->next->size.y +
buf->next->next->size.h + MAX(adj_size(20), pText2->h + adj_size(4));
buf->next->next->size.h + MAX(adj_size(20), text2->h + adj_size(4));
buf->size.x = area.x + (area.w - buf->size.w * 2) / 2;
blit_entire_src(pText2, pwindow->theme, adj_size(15), buf->size.y - area.y - pText2->h - adj_size(2));
FREESURFACE(pText2);
blit_entire_src(text2, pwindow->theme, adj_size(15), buf->size.y - area.y - text2->h - adj_size(2));
FREESURFACE(text2);
/* height right button */
buf->prev->size.y = buf->size.y;
client/gui-sdl2/repodlgs.c
char tBuf[128], cBuf[128];
struct widget *buf = NULL, *pwindow;
utf8_str *pstr;
SDL_Surface *pText;
SDL_Surface *text;
SDL_Rect dst;
SDL_Rect area;
......
pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pstr->fgcol = *get_theme_color(COLOR_THEME_UNITUPGRADE_TEXT);
pText = create_text_surf_from_utf8(pstr);
text = create_text_surf_from_utf8(pstr);
FREEUTF8STR(pstr);
area.h += (pText->h + adj_size(10));
area.w = MAX(area.w, pText->w + adj_size(20));
area.h += (text->h + adj_size(10));
area.w = MAX(area.w, text->w + adj_size(20));
/* cancel button */
buf = create_themeicon_button_from_chars(current_theme->CANCEL_Icon,
......
/* setup rest of widgets */
/* label */
dst.x = area.x + (area.w - pText->w) / 2;
dst.x = area.x + (area.w - text->w) / 2;
dst.y = area.y + adj_size(10);
alphablit(pText, NULL, pwindow->theme, &dst, 255);
FREESURFACE(pText);
alphablit(text, NULL, pwindow->theme, &dst, 255);
FREESURFACE(text);
/* cancel button */
buf = pwindow->prev;
......
struct widget *buf = NULL;
struct widget *pwindow, *pLast;
utf8_str *pstr;
SDL_Surface *pText1, *pText2, *pText3 , *pText4, *pText5, *logo;
SDL_Surface *text1, *text2, *text3 , *text4, *text5, *logo;
int w = 0 , count, ww, hh = 0, name_w = 0;
char cbuf[64];
SDL_Rect dst;
......
fc_snprintf(cbuf, sizeof(cbuf), _("active"));
pstr = create_utf8_from_char(cbuf, adj_font(10));
pstr->style |= SF_CENTER;
pText1 = create_text_surf_from_utf8(pstr);
text1 = create_text_surf_from_utf8(pstr);
fc_snprintf(cbuf, sizeof(cbuf), _("under\nconstruction"));
copy_chars_to_utf8_str(pstr, cbuf);
pText2 = create_text_surf_from_utf8(pstr);
text2 = create_text_surf_from_utf8(pstr);
fc_snprintf(cbuf, sizeof(cbuf), _("soonest\ncompletion"));
copy_chars_to_utf8_str(pstr, cbuf);
pText5 = create_text_surf_from_utf8(pstr);
text5 = create_text_surf_from_utf8(pstr);
fc_snprintf(cbuf, sizeof(cbuf), _("Total"));
copy_chars_to_utf8_str(pstr, cbuf);
pText3 = create_text_surf_from_utf8(pstr);
text3 = create_text_surf_from_utf8(pstr);
fc_snprintf(cbuf, sizeof(cbuf), _("Units"));
copy_chars_to_utf8_str(pstr, cbuf);
pText4 = create_text_surf_from_utf8(pstr);
name_w = pText4->w;
text4 = create_text_surf_from_utf8(pstr);
name_w = text4->w;
FREEUTF8STR(pstr);
/* --------------- */
......
WF_RESTORE_BACKGROUND);
area.h += buf->size.h;
buf->size.w = pText1->w + adj_size(6);
buf->size.w = text1->w + adj_size(6);
add_to_gui_list(ID_LABEL, buf);
/* ---------------------------------------------- */
fc_snprintf(cbuf, sizeof(cbuf), "%d", total->upkeep[O_SHIELD]);
......
buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
buf->size.w = pText1->w;
buf->size.w = text1->w;
add_to_gui_list(ID_LABEL, buf);
/* ---------------------------------------------- */
fc_snprintf(cbuf, sizeof(cbuf), "%d", total->upkeep[O_FOOD]);
......
buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
buf->size.w = pText1->w;
buf->size.w = text1->w;
add_to_gui_list(ID_LABEL, buf);
/* ---------------------------------------------- */
fc_snprintf(cbuf, sizeof(cbuf), "%d", total->upkeep[O_GOLD]);
......
buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
buf->size.w = pText1->w;
buf->size.w = text1->w;
add_to_gui_list(ID_LABEL, buf);
/* ---------------------------------------------- */
fc_snprintf(cbuf, sizeof(cbuf), "%d", total->building_count);
......
buf = create_iconlabel(NULL, pwindow->dst, pstr,
WF_RESTORE_BACKGROUND);
buf->size.w = pText2->w + adj_size(6);
buf->size.w = text2->w + adj_size(6);
add_to_gui_list(ID_LABEL, buf);
/* ------------------------- */
......
set_wflag(buf, WF_HIDDEN);
}
hh = MAX(hh, buf->size.h);
buf->size.w = pText1->w + adj_size(6);
buf->size.w = text1->w + adj_size(6);
add_to_gui_list(MAX_ID - utype_number(i), buf);
/* shield upkeep */
......
set_wflag(buf, WF_HIDDEN);
}
hh = MAX(hh, buf->size.h);
buf->size.w = pText1->w;
buf->size.w = text1->w;
add_to_gui_list(MAX_ID - utype_number(i), buf);
/* food upkeep */
......
}
hh = MAX(hh, buf->size.h);
buf->size.w = pText1->w;
buf->size.w = text1->w;
add_to_gui_list(MAX_ID - utype_number(i), buf);
/* gold upkeep */
......
}
hh = MAX(hh, buf->size.h);
buf->size.w = pText1->w;
buf->size.w = text1->w;
add_to_gui_list(MAX_ID - utype_number(i), buf);
/* building */
......
set_wflag(buf, WF_HIDDEN);
}
hh = MAX(hh, buf->size.h);
buf->size.w = pText2->w + adj_size(6);
buf->size.w = text2->w + adj_size(6);
add_to_gui_list(MAX_ID - utype_number(i), buf);
/* soonest completion */
......
set_wflag(buf, WF_HIDDEN);
}
hh = MAX(hh, buf->size.h);
buf->size.w = pText5->w + adj_size(6);
buf->size.w = text5->w + adj_size(6);
add_to_gui_list(MAX_ID - utype_number(i), buf);
count += adj_size(8);
......
units_dlg->begin_widget_list = buf;
area.w = MAX(area.w, (tileset_full_tile_width(tileset) * 2 + name_w + adj_size(15))
+ (adj_size(4) * pText1->w + adj_size(46)) + (pText2->w + adj_size(16))
+ (pText5->w + adj_size(6)) + adj_size(2));
+ (adj_size(4) * text1->w + adj_size(46)) + (text2->w + adj_size(16))
+ (text5->w + adj_size(6)) + adj_size(2));
if (count > 0) {
units_dlg->end_active_widget_list = pLast->prev;
units_dlg->begin_active_widget_list = units_dlg->begin_widget_list;
......
area.h = adj_size(50);
}
area.h += pText1->h + adj_size(10);
area.h += text1->h + adj_size(10);
area.w += adj_size(2);
logo = theme_get_background(theme, BACKGROUND_UNITSREP);
......
/* totals background and label */
dst.x = area.x + adj_size(2);
dst.y = area.y + area.h - (pText3->h + adj_size(2)) - adj_size(2);
dst.y = area.y + area.h - (text3->h + adj_size(2)) - adj_size(2);
dst.w = name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5);
dst.h = pText3->h + adj_size(2);
dst.h = text3->h + adj_size(2);
fill_rect_alpha(pwindow->theme, &dst, &bg_color);
create_frame(pwindow->theme,
......
get_theme_color(COLOR_THEME_UNITSREP_FRAME));
dst.y += 1;
dst.x += ((name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5)) - pText3->w) / 2;
alphablit(pText3, NULL, pwindow->theme, &dst, 255);
FREESURFACE(pText3);
dst.x += ((name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5)) - text3->w) / 2;
alphablit(text3, NULL, pwindow->theme, &dst, 255);
FREESURFACE(text3);
/* total active widget */
buf = buf->prev;
......
dst.x = area.x + adj_size(2);
dst.y = area.y + 1;
dst.w = name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5);
dst.h = pText4->h + adj_size(2);
dst.h = text4->h + adj_size(2);
fill_rect_alpha(pwindow->theme, &dst, &bg_color);
create_frame(pwindow->theme,
......
get_theme_color(COLOR_THEME_UNITSREP_FRAME));
dst.y += 1;
dst.x += ((name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5))- pText4->w) / 2;
alphablit(pText4, NULL, pwindow->theme, &dst, 255);
FREESURFACE(pText4);
dst.x += ((name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5))- text4->w) / 2;
alphablit(text4, NULL, pwindow->theme, &dst, 255);
FREESURFACE(text4);
/* active count background and label */
dst.x = area.x + adj_size(2) + name_w + tileset_full_tile_width(tileset) * 2 + adj_size(15);
dst.y = area.y + 1;
dst.w = pText1->w + adj_size(6);
dst.w = text1->w + adj_size(6);
dst.h = area.h - adj_size(3);
fill_rect_alpha(pwindow->theme, &dst, &bg_color);
......
get_theme_color(COLOR_THEME_UNITSREP_FRAME));
dst.x += adj_size(3);
alphablit(pText1, NULL, pwindow->theme, &dst, 255);
ww = pText1->w;
hh = pText1->h;
FREESURFACE(pText1);
alphablit(text1, NULL, pwindow->theme, &dst, 255);
ww = text1->w;
hh = text1->h;
FREESURFACE(text1);
/* shields cost background and label */
dst.x += (ww + adj_size(13));
......
/* building count background and label */
dst.x = w + ww + adj_size(10);
dst.y = area.y + 1;
dst.w = pText2->w + adj_size(6);
ww = pText2->w + adj_size(6);
dst.w = text2->w + adj_size(6);
ww = text2->w + adj_size(6);
w = dst.x;
dst.h = area.h - adj_size(3);
fill_rect_alpha(pwindow->theme, &dst, &bg_color);
......
get_theme_color(COLOR_THEME_UNITSREP_FRAME));
dst.x += adj_size(3);
alphablit(pText2, NULL, pwindow->theme, &dst, 255);
FREESURFACE(pText2);
alphablit(text2, NULL, pwindow->theme, &dst, 255);
FREESURFACE(text2);
/* building count background and label */
dst.x = w + ww + adj_size(10);
dst.y = area.y + 1;
dst.w = pText5->w + adj_size(6);
dst.w = text5->w + adj_size(6);
dst.h = area.h - adj_size(3);
fill_rect_alpha(pwindow->theme, &dst, &bg_color);
......
get_theme_color(COLOR_THEME_UNITSREP_FRAME));
dst.x += adj_size(3);
alphablit(pText5, NULL, pwindow->theme, &dst, 255);
FREESURFACE(pText5);
alphablit(text5, NULL, pwindow->theme, &dst, 255);
FREESURFACE(text5);
if (count) {
int start_x = area.x + adj_size(2);
......
char cBuf[128];
struct widget *buf = NULL, *pwindow;
utf8_str *pstr;
SDL_Surface *pText;
SDL_Surface *text;
SDL_Rect dst;
SDL_Rect area;
......
pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pstr->fgcol = *get_theme_color(COLOR_THEME_SELLIMPR_TEXT);
pText = create_text_surf_from_utf8(pstr);
text = create_text_surf_from_utf8(pstr);
FREEUTF8STR(pstr);
area.w = MAX(area.w, pText->w + adj_size(20));
area.h += (pText->h + adj_size(10));
area.w = MAX(area.w, text->w + adj_size(20));
area.h += (text->h + adj_size(10));
/* cancel button */
buf = create_themeicon_button_from_chars(current_theme->CANCEL_Icon,
......
/* setup rest of widgets */
/* label */
dst.x = area.x + (area.w - pText->w) / 2;
dst.x = area.x + (area.w - text->w) / 2;
dst.y = area.y + adj_size(10);
alphablit(pText, NULL, pwindow->theme, &dst, 255);
FREESURFACE(pText);
alphablit(text, NULL, pwindow->theme, &dst, 255);
FREESURFACE(text);
/* cancel button */
buf = pwindow->prev;
......
struct widget *buf;
struct widget *pwindow , *pLast;
utf8_str *pstr, *pstr2;
SDL_Surface *surf, *pText_Name, *pText, *zoomed;
SDL_Surface *surf, *text_name, *text, *zoomed;
SDL_Surface *background;
int i, count , h = 0;
int w = 0; /* left column values */
......
copy_chars_to_utf8_str(pstr, cbuf);
pstr->style |= TTF_STYLE_BOLD;
pText_Name = create_text_surf_smaller_than_w(pstr, surf->w - adj_size(4));
text_name = create_text_surf_smaller_than_w(pstr, surf->w - adj_size(4));
fc_snprintf(cbuf, sizeof(cbuf), "%s %d\n%s %d",
_("Built"), p->count, _("U Total"),p->total_cost);
copy_chars_to_utf8_str(pstr, cbuf);
pstr->style &= ~TTF_STYLE_BOLD;
pText = create_text_surf_from_utf8(pstr);
text = create_text_surf_from_utf8(pstr);
/*-----------------*/
......
dst.y += zoomed->h;
FREESURFACE(zoomed);
dst.x = (surf->w - pText_Name->w)/2;
dst.x = (surf->w - text_name->w)/2;
dst.y += ((surf->h - dst.y) -
(pText_Name->h + (pIcons->pBIG_Coin->h + 2) + pText->h)) / 2;
alphablit(pText_Name, NULL, surf, &dst, 255);
(text_name->h + (pIcons->pBIG_Coin->h + 2) + text->h)) / 2;
alphablit(text_name, NULL, surf, &dst, 255);
dst.y += pText_Name->h;
dst.y += text_name->h;
if (p->cost) {
dst.x = (surf->w - p->cost * (pIcons->pBIG_Coin->w + 1))/2;
for (count = 0; count < p->cost; count++) {
......
}
dst.y += (pIcons->pBIG_Coin->h + adj_size(2));
dst.x = (surf->w - pText->w) / 2;
alphablit(pText, NULL, surf, &dst, 255);
dst.x = (surf->w - text->w) / 2;
alphablit(text, NULL, surf, &dst, 255);
FREESURFACE(pText);
FREESURFACE(pText_Name);
FREESURFACE(text);
FREESURFACE(text_name);
buf = create_icon2(surf, pwindow->dst,
(WF_RESTORE_BACKGROUND|WF_FREE_THEME|WF_FREE_DATA));
......
enum tech_info_mode mode)
{
struct unit_type *punit = NULL;
SDL_Surface *surf, *pText, *pTmp, *pTmp2;
SDL_Surface *surf, *text, *pTmp, *pTmp2;
SDL_Surface *Surf_Array[10], **buf_array;
SDL_Rect dst;
SDL_Color color;
......
break;
}
pText = create_text_surf_smaller_than_w(pstr, adj_size(100 - 4));
text = create_text_surf_smaller_than_w(pstr, adj_size(100 - 4));
/* create label surface */
surf = create_surf(w, h, SDL_SWSURFACE);
......
if (mode == SMALL_MODE) {
/* draw name tech text */
dst.x = adj_size(35) + (surf->w - pText->w - adj_size(35)) / 2;
dst.y = (surf->h - pText->h) / 2;
alphablit(pText, NULL, surf, &dst, 255);
FREESURFACE(pText);
dst.x = adj_size(35) + (surf->w - text->w - adj_size(35)) / 2;
dst.y = (surf->h - text->h) / 2;
alphablit(text, NULL, surf, &dst, 255);
FREESURFACE(text);
/* draw tech icon */
pText = ResizeSurface(pTmp, adj_size(25), adj_size(25), 1);
dst.x = (adj_size(35) - pText->w) / 2;
dst.y = (surf->h - pText->h) / 2;
alphablit(pText, NULL, surf, &dst, 255);
FREESURFACE(pText);
text = ResizeSurface(pTmp, adj_size(25), adj_size(25), 1);
dst.x = (adj_size(35) - text->w) / 2;
dst.y = (surf->h - text->h) / 2;
alphablit(text, NULL, surf, &dst, 255);
FREESURFACE(text);
} else {
/* draw name tech text */
dst.x = (surf->w - pText->w) / 2;
dst.x = (surf->w - text->w) / 2;
dst.y = adj_size(20);
alphablit(pText, NULL, surf, &dst, 255);
dst.y += pText->h + adj_size(10);
FREESURFACE(pText);
alphablit(text, NULL, surf, &dst, 255);
dst.y += text->h + adj_size(10);
FREESURFACE(text);
/* draw tech icon */
dst.x = (surf->w - pTmp->w) / 2;
client/gui-sdl2/widget.c
**************************************************************************/
void redraw_widget_info_label(SDL_Rect *rect)
{
SDL_Surface *pText;
SDL_Surface *text;
SDL_Rect srcrect, dstrect;
SDL_Color color;
struct widget *pwidget = selected_widget;
......
pwidget->info_label->fgcol = *get_theme_color(COLOR_THEME_QUICK_INFO_TEXT);
/* create string and bcgd theme */
pText = create_text_surf_from_utf8(pwidget->info_label);
text = create_text_surf_from_utf8(pwidget->info_label);
pwidget->info_label->fgcol = color;
info_label = create_filled_surface(pText->w + adj_size(10), pText->h + adj_size(6),
info_label = create_filled_surface(text->w + adj_size(10), text->h + adj_size(6),
SDL_SWSURFACE, get_theme_color(COLOR_THEME_QUICK_INFO_BG));
/* calculate start position */
......
dstrect.x = adj_size(6);
dstrect.y = adj_size(3);
alphablit(pText, NULL, info_label, &dstrect, 255);
alphablit(text, NULL, info_label, &dstrect, 255);
FREESURFACE(pText);
FREESURFACE(text);
/* draw frame */
create_frame(info_label,
client/gui-sdl2/widget_button.c
{
SDL_Rect dest = { 0, 0, 0, 0 };
utf8_str TMPString;
SDL_Surface *button = NULL, *pText = NULL, *icon = icon_button->theme2;
SDL_Surface *button = NULL, *text = NULL, *icon = icon_button->theme2;
Uint16 Ix, Iy, x;
Uint16 y = 0; /* FIXME: possibly uninitialized */
int ret;
......
TMPString.fgcol = *get_theme_color(COLOR_THEME_WIDGET_DISABLED_TEXT);
}
pText = create_text_surf_from_utf8(&TMPString);
text = create_text_surf_from_utf8(&TMPString);
}
if (!pText && !icon) {
if (!text && !icon) {
return -1;
}
......
FREESURFACE(button);
if (icon) { /* Icon */
if (pText) {
if (text) {
if (get_wflags(icon_button) & WF_ICON_CENTER_RIGHT) {
Ix = icon_button->size.w - icon->w - 5;
} else {
......
if (get_wflags(icon_button) & WF_ICON_ABOVE_TEXT) {
Iy = 3;
y = 3 + icon->h + 3 + (icon_button->size.h -
(icon->h + 6) - pText->h) / 2;
(icon->h + 6) - text->h) / 2;
} else {
if (get_wflags(icon_button) & WF_ICON_UNDER_TEXT) {
y = 3 + (icon_button->size.h - (icon->h + 3) - pText->h) / 2;
Iy = y + pText->h + 3;
y = 3 + (icon_button->size.h - (icon->h + 3) - text->h) / 2;
Iy = y + text->h + 3;
} else { /* center */
Iy = (icon_button->size.h - icon->h) / 2;
y = (icon_button->size.h - pText->h) / 2;
y = (icon_button->size.h - text->h) / 2;
}
}
} else { /* no text */
......
ret = alphablit(icon, NULL, icon_button->dst->surface, &dest, 255);
if (ret) {
FREESURFACE(pText);
FREESURFACE(text);
return ret - 10;
}
}
if (pText) {
if (text) {
if (icon) {
if (!(get_wflags(icon_button) & WF_ICON_ABOVE_TEXT)
&& !(get_wflags(icon_button) & WF_ICON_UNDER_TEXT)) {
if (get_wflags(icon_button) & WF_ICON_CENTER_RIGHT) {
if (icon_button->string_utf8->style & SF_CENTER) {
x = (icon_button->size.w - (icon->w + 5) - pText->w) / 2;
x = (icon_button->size.w - (icon->w + 5) - text->w) / 2;
} else {
if (icon_button->string_utf8->style & SF_CENTER_RIGHT) {
x = icon_button->size.w - (icon->w + 7) - pText->w;
x = icon_button->size.w - (icon->w + 7) - text->w;
} else {
x = 5;
}
......
} else { /* icon center left - default */
if (icon_button->string_utf8->style & SF_CENTER) {
x = 5 + icon->w + ((icon_button->size.w -
(icon->w + 5) - pText->w) / 2);
(icon->w + 5) - text->w) / 2);
} else {
if (icon_button->string_utf8->style & SF_CENTER_RIGHT) {
x = icon_button->size.w - pText->w - 5;
x = icon_button->size.w - text->w - 5;
} else { /* text center left */
x = 5 + icon->w + 3;
}
......
}
} else {
/* !icon */
y = (icon_button->size.h - pText->h) / 2;
y = (icon_button->size.h - text->h) / 2;
Alone:
if (icon_button->string_utf8->style & SF_CENTER) {
x = (icon_button->size.w - pText->w) / 2;
x = (icon_button->size.w - text->w) / 2;
} else {
if (icon_button->string_utf8->style & SF_CENTER_RIGHT) {
x = icon_button->size.w - pText->w - 5;
x = icon_button->size.w - text->w - 5;
} else {
x = 5;
}
......
dest.x = icon_button->size.x + x;
dest.y = icon_button->size.y + y;
ret = alphablit(pText, NULL, icon_button->dst->surface, &dest, 255);
ret = alphablit(text, NULL, icon_button->dst->surface, &dest, 255);
}
FREESURFACE(pText);
FREESURFACE(text);
return 0;
}
client/gui-sdl2/widget_edit.c
int iRet = 0;
SDL_Rect rDest = {edit_widget->size.x, edit_widget->size.y, 0, 0};
SDL_Surface *pedit = NULL;
SDL_Surface *pText;
SDL_Surface *text;
ret = (*baseclass_redraw)(edit_widget);
if (ret != 0) {
......
memset(cbuf, '*', len - 1);
cbuf[len - 1] = '\0';
edit_widget->string_utf8->text = cbuf;
pText = create_text_surf_from_utf8(edit_widget->string_utf8);
text = create_text_surf_from_utf8(edit_widget->string_utf8);
FC_FREE(cbuf);
edit_widget->string_utf8->text = backup;
} else {
pText = create_text_surf_from_utf8(edit_widget->string_utf8);
text = create_text_surf_from_utf8(edit_widget->string_utf8);
}
pedit = create_bcgnd_surf(edit_widget->theme, get_wstate(edit_widget),
......
alphablit(pedit, NULL, edit_widget->dst->surface, &rDest, 255);
/* set position and blit text */
if (pText) {
rDest.y += (pedit->h - pText->h) / 2;
if (text) {
rDest.y += (pedit->h - text->h) / 2;
/* blit centred text to botton */
if (edit_widget->string_utf8->style & SF_CENTER) {
rDest.x += (pedit->w - pText->w) / 2;
rDest.x += (pedit->w - text->w) / 2;
} else {
if (edit_widget->string_utf8->style & SF_CENTER_RIGHT) {
rDest.x += pedit->w - pText->w - adj_size(5);
rDest.x += pedit->w - text->w - adj_size(5);
} else {
rDest.x += adj_size(5); /* center left */
}
}
alphablit(pText, NULL, edit_widget->dst->surface, &rDest, 255);
alphablit(text, NULL, edit_widget->dst->surface, &rDest, 255);
}
/* pText */
/* text */
iRet = pedit->h;
/* Free memory */
FREESURFACE(pText);
FREESURFACE(text);
FREESURFACE(pedit);
return iRet;
client/gui-sdl2/widget_label.c
{
int ret;
Sint16 x, y;
SDL_Surface *pText = NULL;
SDL_Surface *text = NULL;
if (!pLabel) {
return -3;
}
if ((pText = create_text_surf_from_utf8(pLabel->string_utf8)) == NULL) {
if ((text = create_text_surf_from_utf8(pLabel->string_utf8)) == NULL) {
return (-4);
}
if (pLabel->string_utf8->style & SF_CENTER) {
x = (pLabel->size.w - pText->w) / 2;
x = (pLabel->size.w - text->w) / 2;
} else {
if (pLabel->string_utf8->style & SF_CENTER_RIGHT) {
x = pLabel->size.w - pText->w - adj_size(5);
x = pLabel->size.w - text->w - adj_size(5);
} else {
x = adj_size(5);
}
}
y = (pLabel->size.h - pText->h) / 2;
y = (pLabel->size.h - text->h) / 2;
/* redraw theme */
if (pLabel->theme) {
......
}
}
ret = blit_entire_src(pText, pLabel->dst->surface, pLabel->size.x + x, pLabel->size.y + y);
ret = blit_entire_src(text, pLabel->dst->surface, pLabel->size.x + x, pLabel->size.y + y);
FREESURFACE(pText);
FREESURFACE(text);
return ret;
}
......
int space, ret = 0; /* FIXME: possibly uninitialized */
Sint16 x, xI, yI;
Sint16 y = 0; /* FIXME: possibly uninitialized */
SDL_Surface *pText;
SDL_Surface *text;
SDL_Rect dst;
Uint32 flags;
......
space = 0;
}
pText = create_text_surf_from_utf8(pLabel->string_utf8);
text = create_text_surf_from_utf8(pLabel->string_utf8);
if (pLabel->theme) { /* Icon */
if (pText) {
if (text) {
if (flags & WF_ICON_CENTER_RIGHT) {
xI = pLabel->size.w - pLabel->theme->w - space;
} else {
......
if (flags & WF_ICON_ABOVE_TEXT) {
yI = 0;
y = pLabel->theme->h + adj_size(3)
+ (pLabel->size.h - (pLabel->theme->h + adj_size(3)) - pText->h) / 2;
+ (pLabel->size.h - (pLabel->theme->h + adj_size(3)) - text->h) / 2;
} else {
if (flags & WF_ICON_UNDER_TEXT) {
y = (pLabel->size.h - (pLabel->theme->h + adj_size(3)) - pText->h) / 2;
yI = y + pText->h + adj_size(3);
y = (pLabel->size.h - (pLabel->theme->h + adj_size(3)) - text->h) / 2;
yI = y + text->h + adj_size(3);
} else {
yI = (pLabel->size.h - pLabel->theme->h) / 2;
y = (pLabel->size.h - pText->h) / 2;
y = (pLabel->size.h - text->h) / 2;
}
}
/* pText */
/* text */
} else {
#if 0
yI = (pLabel->size.h - pLabel->theme->h) / 2;
......
}
}
if (pText) {
if (text) {
if (pLabel->theme) { /* Icon */
if (!(flags & WF_ICON_ABOVE_TEXT) && !(flags & WF_ICON_UNDER_TEXT)) {
if (flags & WF_ICON_CENTER_RIGHT) {
if (pLabel->string_utf8->style & SF_CENTER) {
x = (pLabel->size.w - (pLabel->theme->w + 5 + space) -
pText->w) / 2;
text->w) / 2;
} else {
if (pLabel->string_utf8->style & SF_CENTER_RIGHT) {
x = pLabel->size.w - (pLabel->theme->w + 5 + space) - pText->w;
x = pLabel->size.w - (pLabel->theme->w + 5 + space) - text->w;
} else {
x = space;
}
......
x = space + pLabel->theme->w + adj_size(5) + ((pLabel->size.w -
(space +
pLabel->theme->w + adj_size(5)) -
pText->w) / 2);
text->w) / 2);
} else {
if (pLabel->string_utf8->style & SF_CENTER_RIGHT) {
x = pLabel->size.w - pText->w - space;
x = pLabel->size.w - text->w - space;
} else {
x = space + pLabel->theme->w + adj_size(5);
}
......
}
/* pLabel->theme == Icon */
} else {
y = (pLabel->size.h - pText->h) / 2;
y = (pLabel->size.h - text->h) / 2;
Alone:
if (pLabel->string_utf8->style & SF_CENTER) {
x = (pLabel->size.w - pText->w) / 2;
x = (pLabel->size.w - text->w) / 2;
} else {
if (pLabel->string_utf8->style & SF_CENTER_RIGHT) {
x = pLabel->size.w - pText->w - space;
x = pLabel->size.w - text->w - space;
} else {
x = space;
}
......
dst.x = pLabel->size.x + x;
dst.y = pLabel->size.y + y;
ret = alphablit(pText, NULL, pLabel->dst->surface, &dst, 255);
FREESURFACE(pText);
ret = alphablit(text, NULL, pLabel->dst->surface, &dst, 255);
FREESURFACE(text);
}
SDL_SetClipRect(pLabel->dst->surface, NULL);
client/gui-sdl2/wldlg.c
int widget_w = 0, widget_h = 0;
utf8_str *pstr = NULL;
struct widget *buf = NULL, *pwindow, *pLast;
SDL_Surface *pText = NULL, *pText_Name = NULL, *zoomed = NULL;
SDL_Surface *text = NULL, *text_name = NULL, *zoomed = NULL;
SDL_Surface *pMain;
SDL_Surface *icon;
SDL_Rect dst;
......
pstr->style |= TTF_STYLE_STRIKETHROUGH;
}
pText_Name = create_text_surf_smaller_than_w(pstr, icon->w - 4);
text_name = create_text_surf_smaller_than_w(pstr, icon->w - 4);
if (is_wonder(pimprove)) {
if (improvement_obsolete(client.conn.playing, pimprove, pcity)) {
......
pstr->style &= ~TTF_STYLE_BOLD;
pstr->style &= ~TTF_STYLE_STRIKETHROUGH;
pText = create_text_surf_from_utf8(pstr);
text = create_text_surf_from_utf8(pstr);
/*-----------------*/
......
dst.y += zoomed->h;
FREESURFACE(zoomed);
dst.x = (icon->w - pText_Name->w) / 2;
dst.y += ((icon->h - dst.y) - (pText_Name->h + pText->h)) / 2;
alphablit(pText_Name, NULL, icon, &dst, 255);
dst.x = (icon->w - text_name->w) / 2;
dst.y += ((icon->h - dst.y) - (text_name->h + text->h)) / 2;
alphablit(text_name, NULL, icon, &dst, 255);
dst.x = (icon->w - pText->w) / 2;
dst.y += pText_Name->h;
alphablit(pText, NULL, icon, &dst, 255);
dst.x = (icon->w - text->w) / 2;
dst.y += text_name->h;
alphablit(text, NULL, icon, &dst, 255);
FREESURFACE(pText);
FREESURFACE(pText_Name);
FREESURFACE(text);
FREESURFACE(text_name);
buf = create_icon2(icon, pwindow->dst,
WF_RESTORE_BACKGROUND|WF_FREE_THEME);
......
copy_chars_to_utf8_str(pstr, cbuf);
pstr->style |= TTF_STYLE_BOLD;
pText_Name = create_text_surf_smaller_than_w(pstr, icon->w - 4);
text_name = create_text_surf_smaller_than_w(pstr, icon->w - 4);
if (pcity) {
struct universal univ = cid_production(cid_encode_unit(un));
......
copy_chars_to_utf8_str(pstr, cbuf);
pstr->style &= ~TTF_STYLE_BOLD;
pText = create_text_surf_from_utf8(pstr);
text = create_text_surf_from_utf8(pstr);
zoomed = adj_surf(get_unittype_surface(un, direction8_invalid()));
dst.x = (icon->w - zoomed->w) / 2;
......
alphablit(zoomed, NULL, icon, &dst, 255);
FREESURFACE(zoomed);
dst.x = (icon->w - pText_Name->w) / 2;
dst.y = icon->h / 2 + (icon->h / 2 - (pText_Name->h + pText->h)) / 2;
alphablit(pText_Name, NULL, icon, &dst, 255);
dst.x = (icon->w - text_name->w) / 2;
dst.y = icon->h / 2 + (icon->h / 2 - (text_name->h + text->h)) / 2;
alphablit(text_name, NULL, icon, &dst, 255);
dst.x = (icon->w - pText->w) / 2;
dst.y += pText_Name->h;
alphablit(pText, NULL, icon, &dst, 255);
dst.x = (icon->w - text->w) / 2;
dst.y += text_name->h;
alphablit(text, NULL, icon, &dst, 255);
FREESURFACE(pText);
FREESURFACE(pText_Name);
FREESURFACE(text);
FREESURFACE(text_name);
buf = create_icon2(icon, pwindow->dst,
WF_RESTORE_BACKGROUND|WF_FREE_THEME);
    (1-1/1)