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 #902758 ยป 0044-sdl2-Rename-pI-to-adhere-with-coding-style.patch

Marko Lindqvist, 2020-12-04 01:20 AM

View differences:

client/gui-sdl2/citydlg.c
struct widget *end_city_widget_list;
/* Imprvm. vscrollbar */
struct advanced_dialog *pImprv;
struct advanced_dialog *imprv;
/* Penel group list */
struct advanced_dialog *pPanel;
......
static void del_city_dialog(void)
{
if (pcity_dlg) {
if (pcity_dlg->pImprv->end_widget_list) {
del_group_of_widgets_from_gui_list(pcity_dlg->pImprv->begin_widget_list,
pcity_dlg->pImprv->end_widget_list);
if (pcity_dlg->imprv->end_widget_list) {
del_group_of_widgets_from_gui_list(pcity_dlg->imprv->begin_widget_list,
pcity_dlg->imprv->end_widget_list);
}
FC_FREE(pcity_dlg->pImprv->scroll);
FC_FREE(pcity_dlg->pImprv);
FC_FREE(pcity_dlg->imprv->scroll);
FC_FREE(pcity_dlg->imprv);
if (pcity_dlg->pPanel) {
del_group_of_widgets_from_gui_list(pcity_dlg->pPanel->begin_widget_list,
......
i = punit->upkeep[O_SHIELD] + punit->upkeep[O_FOOD] +
punit->upkeep[O_GOLD] + happy_cost;
if (i * pIcons->pFood->w > src_rect.w / 2) {
step = (src_rect.w / 2 - pIcons->pFood->w) / (i - 1);
if (i * icons->pFood->w > src_rect.w / 2) {
step = (src_rect.w / 2 - icons->pFood->w) / (i - 1);
} else {
step = pIcons->pFood->w;
step = icons->pFood->w;
}
dest.y = tileset_unit_layout_small_offset_y(tileset);
dest.x = src_rect.x + src_rect.w / 8;
for (i = 0; i < punit->upkeep[O_SHIELD]; i++) {
alphablit(pIcons->pShield, NULL, destcanvas->surf, &dest, 255);
alphablit(icons->pShield, NULL, destcanvas->surf, &dest, 255);
dest.x += step;
}
for (i = 0; i < punit->upkeep[O_FOOD]; i++) {
alphablit(pIcons->pFood, NULL, destcanvas->surf, &dest, 255);
alphablit(icons->pFood, NULL, destcanvas->surf, &dest, 255);
dest.x += step;
}
for (i = 0; i < punit->upkeep[O_GOLD]; i++) {
alphablit(pIcons->pCoin, NULL, destcanvas->surf, &dest, 255);
alphablit(icons->pCoin, NULL, destcanvas->surf, &dest, 255);
dest.x += step;
}
for (i = 0; i < happy_cost; i++) {
alphablit(pIcons->pFace, NULL, destcanvas->surf, &dest, 255);
alphablit(icons->pFace, NULL, destcanvas->surf, &dest, 255);
dest.x += step;
}
......
pcity_dlg->end_city_menu_widget_list = NULL;
/* del imprv from widget list */
del_widget_from_vertical_scroll_widget_list(pcity_dlg->pImprv, tmp);
del_widget_from_vertical_scroll_widget_list(pcity_dlg->imprv, tmp);
enable_city_dlg_widgets();
if (pcity_dlg->pImprv->end_widget_list) {
set_group_state(pcity_dlg->pImprv->begin_active_widget_list,
pcity_dlg->pImprv->end_active_widget_list, FC_WS_DISABLED);
if (pcity_dlg->imprv->end_widget_list) {
set_group_state(pcity_dlg->imprv->begin_active_widget_list,
pcity_dlg->imprv->end_active_widget_list, FC_WS_DISABLED);
}
redraw_city_dialog(pcity_dlg->pcity);
......
/**********************************************************************//**
Popup Sell Imprvm. Dlg.
**************************************************************************/
static int sell_imprvm_dlg_callback(struct widget *pImpr)
static int sell_imprvm_dlg_callback(struct widget *impr)
{
if (PRESSED_EVENT(main_data.event)) {
utf8_str *pstr = NULL;
......
area = pwindow->area;
/* create text label */
id = MAX_ID - 3000 - pImpr->id;
id = MAX_ID - 3000 - impr->id;
price = impr_sell_gold(improvement_by_number(id));
fc_snprintf(cbuf, sizeof(cbuf), PL_("Sell %s for %d gold?",
......
ok_button = create_themeicon_button_from_chars(current_theme->Small_OK_Icon,
pwindow->dst, _("Sell"),
adj_font(10), 0);
ok_button->data.ptr = (void *)pImpr;
ok_button->data.ptr = (void *)impr;
ok_button->size.w = cancel_button->size.w;
ok_button->action = sell_imprvm_dlg_ok_callback;
ok_button->key = SDLK_RETURN;
......
set_group_state(pcity_dlg->begin_city_widget_list,
pcity_dlg->end_city_widget_list->prev, FC_WS_NORMAL);
if (pcity_dlg->pImprv->end_active_widget_list) {
if (pcity_dlg->pImprv->scroll) {
set_wstate(pcity_dlg->pImprv->scroll->pscroll_bar, FC_WS_NORMAL); /* vscroll */
set_wstate(pcity_dlg->pImprv->scroll->up_left_button, FC_WS_NORMAL); /* up */
set_wstate(pcity_dlg->pImprv->scroll->down_right_button, FC_WS_NORMAL); /* down */
if (pcity_dlg->imprv->end_active_widget_list) {
if (pcity_dlg->imprv->scroll) {
set_wstate(pcity_dlg->imprv->scroll->pscroll_bar, FC_WS_NORMAL); /* vscroll */
set_wstate(pcity_dlg->imprv->scroll->up_left_button, FC_WS_NORMAL); /* up */
set_wstate(pcity_dlg->imprv->scroll->down_right_button, FC_WS_NORMAL); /* down */
}
/* There is common function test_player_sell_building_now(),
......
* when possible */
if (pcity_dlg->pcity->did_sell
|| pcity_dlg->pcity->owner != client.conn.playing) {
set_group_state(pcity_dlg->pImprv->begin_active_widget_list,
pcity_dlg->pImprv->end_active_widget_list, FC_WS_DISABLED);
set_group_state(pcity_dlg->imprv->begin_active_widget_list,
pcity_dlg->imprv->end_active_widget_list, FC_WS_DISABLED);
} else {
struct widget *tmp_widget = pcity_dlg->pImprv->end_active_widget_list;
struct widget *tmp_widget = pcity_dlg->imprv->end_active_widget_list;
while (TRUE) {
struct impr_type *pimpr = improvement_by_number(MAX_ID - 3000 -
......
set_wstate(tmp_widget, FC_WS_NORMAL);
}
if (tmp_widget == pcity_dlg->pImprv->begin_active_widget_list) {
if (tmp_widget == pcity_dlg->imprv->begin_active_widget_list) {
break;
}
......
}
if (pcity_dlg->pImprv->end_widget_list) {
set_group_state(pcity_dlg->pImprv->begin_widget_list,
pcity_dlg->pImprv->end_widget_list, FC_WS_DISABLED);
if (pcity_dlg->imprv->end_widget_list) {
set_group_state(pcity_dlg->imprv->begin_widget_list,
pcity_dlg->imprv->end_widget_list, FC_WS_DISABLED);
}
set_group_state(pcity_dlg->begin_city_widget_list,
......
FREESURFACE(surf);
if (((pIcons->pPollution->w + 1) * pcity->pollution) > adj_size(187)) {
step = (adj_size(187) - pIcons->pPollution->w) / (pcity->pollution - 1);
if (((icons->pPollution->w + 1) * pcity->pollution) > adj_size(187)) {
step = (adj_size(187) - icons->pPollution->w) / (pcity->pollution - 1);
} else {
step = pIcons->pPollution->w + 1;
step = icons->pPollution->w + 1;
}
for (i = 0; i < pcity->pollution; i++) {
alphablit(pIcons->pPollution, NULL, city_window->dst->surface, &dest, 255);
alphablit(icons->pPollution, NULL, city_window->dst->surface, &dest, 255);
dest.x += step;
}
dest.x = city_window->size.x + adj_size(10);
dest.y += pIcons->pPollution->h + adj_size(3);
dest.y += icons->pPollution->h + adj_size(3);
} else {
fc_snprintf(cbuf, sizeof(cbuf), _("Pollution: none"));
......
/* blit trade icon */
dest.x += surf->w + adj_size(3);
dest.y += adj_size(4);
alphablit(pIcons->pTrade, NULL, city_window->dst->surface, &dest, 255);
alphablit(icons->pTrade, NULL, city_window->dst->surface, &dest, 255);
dest.x = city_window->size.x + adj_size(10);
dest.y -= adj_size(4);
......
dest.x += surf->w + adj_size(3);
dest.y += adj_size(4);
alphablit(pIcons->pTrade, NULL, city_window->dst->surface, &dest, 255);
alphablit(icons->pTrade, NULL, city_window->dst->surface, &dest, 255);
FREESURFACE(surf);
} else {
......
+ pcity->feel[CITIZEN_UNHAPPY][FEELING_FINAL] + pcity->feel[CITIZEN_ANGRY][FEELING_FINAL]
+ city_specialists(pcity));
if (count * pIcons->pMale_Happy->w > adj_size(166)) {
step = (adj_size(166) - pIcons->pMale_Happy->w) / (count - 1);
if (count * icons->pMale_Happy->w > adj_size(166)) {
step = (adj_size(166) - icons->pMale_Happy->w) / (count - 1);
} else {
step = pIcons->pMale_Happy->w;
step = icons->pMale_Happy->w;
}
for (j = 0; j < FEELING_LAST; j++) {
......
}
if (pcity->feel[CITIZEN_HAPPY][j]) {
surf = pIcons->pMale_Happy;
surf = icons->pMale_Happy;
for (i = 0; i < pcity->feel[CITIZEN_HAPPY][j]; i++) {
alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
dest.x += step;
if (surf == pIcons->pMale_Happy) {
surf = pIcons->pFemale_Happy;
if (surf == icons->pMale_Happy) {
surf = icons->pFemale_Happy;
} else {
surf = pIcons->pMale_Happy;
surf = icons->pMale_Happy;
}
}
}
if (pcity->feel[CITIZEN_CONTENT][j]) {
surf = pIcons->pMale_Content;
surf = icons->pMale_Content;
for (i = 0; i < pcity->feel[CITIZEN_CONTENT][j]; i++) {
alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
dest.x += step;
if (surf == pIcons->pMale_Content) {
surf = pIcons->pFemale_Content;
if (surf == icons->pMale_Content) {
surf = icons->pFemale_Content;
} else {
surf = pIcons->pMale_Content;
surf = icons->pMale_Content;
}
}
}
if (pcity->feel[CITIZEN_UNHAPPY][j]) {
surf = pIcons->pMale_Unhappy;
surf = icons->pMale_Unhappy;
for (i = 0; i < pcity->feel[CITIZEN_UNHAPPY][j]; i++) {
alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
dest.x += step;
if (surf == pIcons->pMale_Unhappy) {
surf = pIcons->pFemale_Unhappy;
if (surf == icons->pMale_Unhappy) {
surf = icons->pFemale_Unhappy;
} else {
surf = pIcons->pMale_Unhappy;
surf = icons->pMale_Unhappy;
}
}
}
if (pcity->feel[CITIZEN_ANGRY][j]) {
surf = pIcons->pMale_Angry;
surf = icons->pMale_Angry;
for (i = 0; i < pcity->feel[CITIZEN_ANGRY][j]; i++) {
alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
dest.x += step;
if (surf == pIcons->pMale_Angry) {
surf = pIcons->pFemale_Angry;
if (surf == icons->pMale_Angry) {
surf = icons->pFemale_Angry;
} else {
surf = pIcons->pMale_Angry;
surf = icons->pMale_Angry;
}
}
}
......
for (spe = 0 ; spe < spe_max; spe++) {
if (pcity->specialists[spe]) {
for (i = 0; i < pcity->specialists[spe]; i++) {
alphablit(pIcons->specialists[spe], NULL, city_window->dst->surface, &dest, 255);
alphablit(icons->specialists[spe], NULL, city_window->dst->surface, &dest, 255);
dest.x += step;
}
}
......
if (j == 1) { /* luxury effect */
dest.x =
city_window->size.x + adj_size(212) - pIcons->pBIG_Luxury->w - adj_size(2);
city_window->size.x + adj_size(212) - icons->pBIG_Luxury->w - adj_size(2);
count = dest.y;
dest.y += (pIcons->pMale_Happy->h -
pIcons->pBIG_Luxury->h) / 2;
alphablit(pIcons->pBIG_Luxury, NULL, city_window->dst->surface, &dest, 255);
dest.y += (icons->pMale_Happy->h -
icons->pBIG_Luxury->h) / 2;
alphablit(icons->pBIG_Luxury, NULL, city_window->dst->surface, &dest, 255);
dest.y = count;
}
......
dest.x = city_window->size.x + adj_size(187) - surf->w - adj_size(2);
i = dest.y;
dest.y += (pIcons->pMale_Happy->h - count) / 2;
dest.y += (icons->pMale_Happy->h - count) / 2;
FREESURFACE(surf);
......
dest.x = city_window->size.x + adj_size(212) - surf->w - adj_size(2);
i = dest.y;
dest.y += (pIcons->pMale_Happy->h - count) / 2;
dest.y += (icons->pMale_Happy->h - count) / 2;
if (tmp1) { /* Temple */
......
}
if (j == 3) { /* police effect */
dest.x = city_window->size.x + adj_size(187) - pIcons->pPolice->w - adj_size(5);
dest.x = city_window->size.x + adj_size(187) - icons->pPolice->w - adj_size(5);
i = dest.y;
dest.y +=
(pIcons->pMale_Happy->h - pIcons->pPolice->h) / 2;
alphablit(pIcons->pPolice, NULL, city_window->dst->surface, &dest, 255);
(icons->pMale_Happy->h - icons->pPolice->h) / 2;
alphablit(icons->pPolice, NULL, city_window->dst->surface, &dest, 255);
dest.y = i;
}
......
dest.x = city_window->size.x + adj_size(187) - surf->w - adj_size(2);
i = dest.y;
dest.y += (pIcons->pMale_Happy->h - count) / 2;
dest.y += (icons->pMale_Happy->h - count) / 2;
FREESURFACE(surf);
......
dest.x = city_window->size.x + adj_size(187) - surf->w - adj_size(2);
i = dest.y;
dest.y += (pIcons->pMale_Happy->h - count) / 2;
dest.y += (icons->pMale_Happy->h - count) / 2;
if (tmp1) { /* Cure of Cancer */
alphablit(tmp1, NULL, city_window->dst->surface, &dest, 255);
......
}
dest.x = city_window->size.x + adj_size(10);
dest.y += pIcons->pMale_Happy->h + adj_size(5);
dest.y += icons->pMale_Happy->h + adj_size(5);
}
}
......
FREESURFACE(buf);
/* draw food income */
dest.y = pwindow->size.y + adj_size(246) + (adj_size(16) - pIcons->pBIG_Food->h) / 2;
dest.y = pwindow->size.y + adj_size(246) + (adj_size(16) - icons->pBIG_Food->h) / 2;
dest.x = pwindow->size.x + adj_size(203);
if (pcity->surplus[O_FOOD] >= 0) {
......
count = pcity->prod[O_FOOD];
}
if (((pIcons->pBIG_Food->w + 1) * count) > adj_size(200)) {
step = (adj_size(200) - pIcons->pBIG_Food->w) / (count - 1);
if (((icons->pBIG_Food->w + 1) * count) > adj_size(200)) {
step = (adj_size(200) - icons->pBIG_Food->w) / (count - 1);
} else {
step = pIcons->pBIG_Food->w + 1;
step = icons->pBIG_Food->w + 1;
}
for (i = 0; i < count; i++) {
alphablit(pIcons->pBIG_Food, NULL, pwindow->dst->surface, &dest, 255);
alphablit(icons->pBIG_Food, NULL, pwindow->dst->surface, &dest, 255);
dest.x += step;
}
......
if (pcity->surplus[O_FOOD]) {
if (pcity->surplus[O_FOOD] > 0) {
count = pcity->surplus[O_FOOD];
buf = pIcons->pBIG_Food;
buf = icons->pBIG_Food;
} else {
count = -1 * pcity->surplus[O_FOOD];
buf = pIcons->pBIG_Food_Corr;
buf = icons->pBIG_Food_Corr;
}
dest.x = pwindow->size.x + adj_size(423);
......
if (pcity->surplus[O_SHIELD] > 0) {
count = pcity->surplus[O_SHIELD] + pcity->waste[O_SHIELD];
buf = pIcons->pBIG_Shield;
buf = icons->pBIG_Shield;
} else {
count = -1 * pcity->surplus[O_SHIELD];
buf = pIcons->pBIG_Shield_Corr;
buf = icons->pBIG_Shield_Corr;
}
dest.y = pwindow->size.y + adj_size(281) + (adj_size(16) - buf->h) / 2;
......
alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
dest.x += step;
if (i > pcity->surplus[O_SHIELD]) {
buf = pIcons->pBIG_Shield_Corr;
buf = icons->pBIG_Shield_Corr;
}
}
}
......
if (pcity->prod[O_SHIELD] - pcity->surplus[O_SHIELD]) {
dest.x = pwindow->size.x + adj_size(423);
dest.y =
pwindow->size.y + adj_size(281) + (adj_size(16) - pIcons->pBIG_Shield->h) / 2;
pwindow->size.y + adj_size(281) + (adj_size(16) - icons->pBIG_Shield->h) / 2;
if ((pIcons->pBIG_Shield->w + 1) * (pcity->prod[O_SHIELD] -
if ((icons->pBIG_Shield->w + 1) * (pcity->prod[O_SHIELD] -
pcity->surplus[O_SHIELD]) > adj_size(30)) {
step =
(adj_size(30) - pIcons->pBIG_Food->w) / (pcity->prod[O_SHIELD] -
(adj_size(30) - icons->pBIG_Food->w) / (pcity->prod[O_SHIELD] -
pcity->surplus[O_SHIELD] - 1);
} else {
step = pIcons->pBIG_Shield->w + 1;
step = icons->pBIG_Shield->w + 1;
}
for (i = 0; i < (pcity->prod[O_SHIELD] - pcity->surplus[O_SHIELD]); i++) {
alphablit(pIcons->pBIG_Shield, NULL, pwindow->dst->surface, &dest, 255);
alphablit(icons->pBIG_Shield, NULL, pwindow->dst->surface, &dest, 255);
dest.x -= step;
}
}
......
/* draw total (trade - corruption) */
if (pcity->surplus[O_TRADE]) {
dest.y =
pwindow->size.y + adj_size(316) + (adj_size(16) - pIcons->pBIG_Trade->h) / 2;
pwindow->size.y + adj_size(316) + (adj_size(16) - icons->pBIG_Trade->h) / 2;
dest.x = pwindow->size.x + adj_size(203);
if (((pIcons->pBIG_Trade->w + 1) * pcity->surplus[O_TRADE]) > adj_size(200)) {
step = (adj_size(200) - pIcons->pBIG_Trade->w) / (pcity->surplus[O_TRADE] - 1);
if (((icons->pBIG_Trade->w + 1) * pcity->surplus[O_TRADE]) > adj_size(200)) {
step = (adj_size(200) - icons->pBIG_Trade->w) / (pcity->surplus[O_TRADE] - 1);
} else {
step = pIcons->pBIG_Trade->w + 1;
step = icons->pBIG_Trade->w + 1;
}
for (i = 0; i < pcity->surplus[O_TRADE]; i++) {
alphablit(pIcons->pBIG_Trade, NULL, pwindow->dst->surface, &dest, 255);
alphablit(icons->pBIG_Trade, NULL, pwindow->dst->surface, &dest, 255);
dest.x += step;
}
}
......
if (pcity->waste[O_TRADE] > 0) {
dest.x = pwindow->size.x + adj_size(423);
dest.y =
pwindow->size.y + adj_size(316) + (adj_size(16) - pIcons->pBIG_Trade->h) / 2;
pwindow->size.y + adj_size(316) + (adj_size(16) - icons->pBIG_Trade->h) / 2;
if (((pIcons->pBIG_Trade_Corr->w + 1) * pcity->waste[O_TRADE]) > adj_size(30)) {
if (((icons->pBIG_Trade_Corr->w + 1) * pcity->waste[O_TRADE]) > adj_size(30)) {
step =
(adj_size(30) - pIcons->pBIG_Trade_Corr->w) / (pcity->waste[O_TRADE] - 1);
(adj_size(30) - icons->pBIG_Trade_Corr->w) / (pcity->waste[O_TRADE] - 1);
} else {
step = pIcons->pBIG_Trade_Corr->w + 1;
step = icons->pBIG_Trade_Corr->w + 1;
}
for (i = 0; i < pcity->waste[O_TRADE]; i++) {
alphablit(pIcons->pBIG_Trade_Corr, NULL, pwindow->dst->surface,
alphablit(icons->pBIG_Trade_Corr, NULL, pwindow->dst->surface,
&dest, 255);
dest.x -= step;
}
......
if (count) {
if (count > 0) {
buf = pIcons->pBIG_Coin;
buf = icons->pBIG_Coin;
} else {
count *= -1;
buf = pIcons->pBIG_Coin_Corr;
buf = icons->pBIG_Coin_Corr;
}
dest.y = pwindow->size.y + adj_size(359) + (adj_size(16) - buf->h) / 2;
......
dest.x = pwindow->size.x + adj_size(423);
dest.y = pwindow->size.y + adj_size(359)
+ (adj_size(16) - pIcons->pBIG_Coin_UpKeep->h) / 2;
+ (adj_size(16) - icons->pBIG_Coin_UpKeep->h) / 2;
if (((pIcons->pBIG_Coin_UpKeep->w + 1) *
if (((icons->pBIG_Coin_UpKeep->w + 1) *
(pcity->prod[O_GOLD] - count)) > adj_size(110)) {
step = (adj_size(110) - pIcons->pBIG_Coin_UpKeep->w) /
step = (adj_size(110) - icons->pBIG_Coin_UpKeep->w) /
(pcity->prod[O_GOLD] - count - 1);
} else {
step = pIcons->pBIG_Coin_UpKeep->w + 1;
step = icons->pBIG_Coin_UpKeep->w + 1;
}
for (i = 0; i < (pcity->prod[O_GOLD] - count); i++) {
alphablit(pIcons->pBIG_Coin_UpKeep, NULL, pwindow->dst->surface,
alphablit(icons->pBIG_Coin_UpKeep, NULL, pwindow->dst->surface,
&dest, 255);
dest.x -= step;
}
......
if (count) {
dest.y =
pwindow->size.y + adj_size(394) + (adj_size(16) - pIcons->pBIG_Colb->h) / 2;
pwindow->size.y + adj_size(394) + (adj_size(16) - icons->pBIG_Colb->h) / 2;
dest.x = pwindow->size.x + adj_size(203);
if ((pIcons->pBIG_Colb->w * count) > adj_size(235)) {
step = (adj_size(235) - pIcons->pBIG_Colb->w) / (count - 1);
if ((icons->pBIG_Colb->w * count) > adj_size(235)) {
step = (adj_size(235) - icons->pBIG_Colb->w) / (count - 1);
if (!step) {
step = 1;
count = 222;
}
} else {
step = pIcons->pBIG_Colb->w;
step = icons->pBIG_Colb->w;
}
for (i = 0; i < count; i++) {
alphablit(pIcons->pBIG_Colb, NULL, pwindow->dst->surface, &dest, 255);
alphablit(icons->pBIG_Colb, NULL, pwindow->dst->surface, &dest, 255);
dest.x += step;
}
}
......
if (pcity->prod[O_LUXURY]) {
dest.y =
pwindow->size.y + adj_size(429) + (adj_size(16) - pIcons->pBIG_Luxury->h) / 2;
pwindow->size.y + adj_size(429) + (adj_size(16) - icons->pBIG_Luxury->h) / 2;
dest.x = pwindow->size.x + adj_size(203);
if ((pIcons->pBIG_Luxury->w * pcity->prod[O_LUXURY]) > adj_size(235)) {
if ((icons->pBIG_Luxury->w * pcity->prod[O_LUXURY]) > adj_size(235)) {
step =
(adj_size(235) - pIcons->pBIG_Luxury->w) / (pcity->prod[O_LUXURY] - 1);
(adj_size(235) - icons->pBIG_Luxury->w) / (pcity->prod[O_LUXURY] - 1);
} else {
step = pIcons->pBIG_Luxury->w;
step = icons->pBIG_Luxury->w;
}
for (i = 0; i < pcity->prod[O_LUXURY]; i++) {
alphablit(pIcons->pBIG_Luxury, NULL, pwindow->dst->surface, &dest, 255);
alphablit(icons->pBIG_Luxury, NULL, pwindow->dst->surface, &dest, 255);
dest.x += step;
}
}
......
count = (city_granary_size(city_size_get(pcity))) / 10;
if (count > 12) {
step = (adj_size(168) - pIcons->pBIG_Food->h) / adj_size((11 + count - 12));
step = (adj_size(168) - icons->pBIG_Food->h) / adj_size((11 + count - 12));
i = (count - 1) * step + 14;
count = 12;
} else {
step = pIcons->pBIG_Food->h;
step = icons->pBIG_Food->h;
i = count * step;
}
......
dest.x += 2;
dest.y += 2;
i = 0;
buf = pIcons->pBIG_Food;
buf = icons->pBIG_Food;
while (count && cost) {
alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
dest.x += buf->w;
......
dest.y += step;
}
if (i > limit - 1) {
buf = pIcons->pBIG_Food_Corr;
buf = icons->pBIG_Food_Corr;
} else {
if (i > pcity->food_stock - 1) {
buf = pIcons->pBIG_Food_Surplus;
buf = icons->pBIG_Food_Surplus;
}
}
}
......
dest.y += step;
}
if (i > limit - 1) {
buf = pIcons->pBIG_Food_Corr;
buf = icons->pBIG_Food_Corr;
} else {
if (i > pcity->food_stock - 1) {
buf = pIcons->pBIG_Food_Surplus;
buf = icons->pBIG_Food_Surplus;
}
}
}
......
dest.x += adj_size(2);
dest.y += adj_size(2);
i = 0;
buf = pIcons->pBIG_Food;
buf = icons->pBIG_Food;
while (count) {
alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
dest.x += buf->w;
......
dest.y += step;
}
if (i > limit - 1) {
buf = pIcons->pBIG_Food_Corr;
buf = icons->pBIG_Food_Corr;
} else {
if (i > pcity->food_stock - 1) {
buf = pIcons->pBIG_Food_Surplus;
buf = icons->pBIG_Food_Surplus;
}
}
}
......
if (count) {
if (count > 11) {
step = (adj_size(154) - pIcons->pBIG_Shield->h) / adj_size((10 + count - 11));
step = (adj_size(154) - icons->pBIG_Shield->h) / adj_size((10 + count - 11));
if (!step) {
step = 1;
}
i = (step * (count - 1)) + pIcons->pBIG_Shield->h;
i = (step * (count - 1)) + icons->pBIG_Shield->h;
} else {
step = pIcons->pBIG_Shield->h;
step = icons->pBIG_Shield->h;
i = count * step;
}
......
dest.y = pwindow->size.y + adj_size(270) + adj_size(2);
i = 0;
buf = pIcons->pBIG_Shield;
buf = icons->pBIG_Shield;
while (count > 0) {
alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
dest.x += buf->w;
......
}
i++;
if (i > pcity->shield_stock - 1) {
buf = pIcons->pBIG_Shield_Surplus;
buf = icons->pBIG_Shield_Surplus;
}
}
}
......
struct player *owner = city_owner(pcity);
int prev_y = 0;
if (!pcity_dlg->pImprv) {
pcity_dlg->pImprv = fc_calloc(1, sizeof(struct advanced_dialog));
if (!pcity_dlg->imprv) {
pcity_dlg->imprv = fc_calloc(1, sizeof(struct advanced_dialog));
}
/* free old list */
if (pcity_dlg->pImprv->end_widget_list) {
del_group_of_widgets_from_gui_list(pcity_dlg->pImprv->begin_widget_list,
pcity_dlg->pImprv->end_widget_list);
pcity_dlg->pImprv->end_widget_list = NULL;
pcity_dlg->pImprv->begin_widget_list = NULL;
pcity_dlg->pImprv->end_active_widget_list = NULL;
pcity_dlg->pImprv->begin_active_widget_list = NULL;
pcity_dlg->pImprv->active_widget_list = NULL;
FC_FREE(pcity_dlg->pImprv->scroll);
if (pcity_dlg->imprv->end_widget_list) {
del_group_of_widgets_from_gui_list(pcity_dlg->imprv->begin_widget_list,
pcity_dlg->imprv->end_widget_list);
pcity_dlg->imprv->end_widget_list = NULL;
pcity_dlg->imprv->begin_widget_list = NULL;
pcity_dlg->imprv->end_active_widget_list = NULL;
pcity_dlg->imprv->begin_active_widget_list = NULL;
pcity_dlg->imprv->active_widget_list = NULL;
FC_FREE(pcity_dlg->imprv->scroll);
}
add_dock = pcity_dlg->pAdd_Point;
......
} city_built_iterate_end;
if (count) {
pcity_dlg->pImprv->end_widget_list = last->prev;
pcity_dlg->pImprv->end_active_widget_list = pcity_dlg->pImprv->end_widget_list;
pcity_dlg->pImprv->begin_widget_list = buf;
pcity_dlg->pImprv->begin_active_widget_list = pcity_dlg->pImprv->begin_widget_list;
pcity_dlg->imprv->end_widget_list = last->prev;
pcity_dlg->imprv->end_active_widget_list = pcity_dlg->imprv->end_widget_list;
pcity_dlg->imprv->begin_widget_list = buf;
pcity_dlg->imprv->begin_active_widget_list = pcity_dlg->imprv->begin_widget_list;
if (count > 7) {
pcity_dlg->pImprv->active_widget_list = pcity_dlg->pImprv->end_active_widget_list;
pcity_dlg->imprv->active_widget_list = pcity_dlg->imprv->end_active_widget_list;
create_vertical_scrollbar(pcity_dlg->pImprv, 1, 7, TRUE, TRUE);
create_vertical_scrollbar(pcity_dlg->imprv, 1, 7, TRUE, TRUE);
setup_vertical_scrollbar_area(pcity_dlg->pImprv->scroll,
setup_vertical_scrollbar_area(pcity_dlg->imprv->scroll,
pwindow->size.x + adj_size(635),
pwindow->size.y + adj_size(66),
adj_size(155), TRUE);
......
/* check if Citizen Icons style was loaded */
cs = style_of_city(pcity);
if (cs != pIcons->style) {
if (cs != icons->style) {
reload_citizens_icons(cs);
}
client/gui-sdl2/cityrep.c
set_wflag(pbuf, WF_HIDDEN);
}
hh = MAX(hh, pbuf->size.h);
pbuf->size.w = pIcons->pBIG_Food->w + adj_size(6);
pbuf->size.w = icons->pBIG_Food->w + adj_size(6);
add_to_gui_list(MAX_ID - pcity->id, pbuf);
/* ----------- */
......
set_wflag(pbuf, WF_HIDDEN);
}
hh = MAX(hh, pbuf->size.h);
pbuf->size.w = pIcons->pBIG_Food_Corr->w + adj_size(6);
pbuf->size.w = icons->pBIG_Food_Corr->w + adj_size(6);
add_to_gui_list(MAX_ID - pcity->id, pbuf);
/* ----------- */
......
set_wflag(pbuf, WF_HIDDEN);
}
hh = MAX(hh, pbuf->size.h);
pbuf->size.w = pIcons->pBIG_Trade->w + adj_size(6);
pbuf->size.w = icons->pBIG_Trade->w + adj_size(6);
add_to_gui_list(MAX_ID - pcity->id, pbuf);
/* ----------- */
......
set_wflag(pbuf, WF_HIDDEN);
}
hh = MAX(hh, pbuf->size.h);
pbuf->size.w = pIcons->pBIG_Trade_Corr->w + adj_size(6);
pbuf->size.w = icons->pBIG_Trade_Corr->w + adj_size(6);
add_to_gui_list(MAX_ID - pcity->id, pbuf);
/* ----------- */
......
set_wflag(pbuf, WF_HIDDEN);
}
hh = MAX(hh, pbuf->size.h);
pbuf->size.w = pIcons->pBIG_Coin->w + adj_size(6);
pbuf->size.w = icons->pBIG_Coin->w + adj_size(6);
add_to_gui_list(MAX_ID - pcity->id, pbuf);
/* ----------- */
......
set_wflag(pbuf, WF_HIDDEN);
}
hh = MAX(hh, pbuf->size.h);
pbuf->size.w = pIcons->pBIG_Colb->w + adj_size(6);
pbuf->size.w = icons->pBIG_Colb->w + adj_size(6);
add_to_gui_list(MAX_ID - pcity->id, pbuf);
/* ----------- */
......
set_wflag(pbuf, WF_HIDDEN);
}
hh = MAX(hh, pbuf->size.h);
pbuf->size.w = pIcons->pBIG_Luxury->w + adj_size(6);
pbuf->size.w = icons->pBIG_Luxury->w + adj_size(6);
add_to_gui_list(MAX_ID - pcity->id, pbuf);
/* ----------- */
......
set_wflag(pbuf, WF_HIDDEN);
}
hh = MAX(hh, pbuf->size.h);
pbuf->size.w = pIcons->pBIG_Shield->w + adj_size(6);
pbuf->size.w = icons->pBIG_Shield->w + adj_size(6);
add_to_gui_list(MAX_ID - pcity->id, pbuf);
/* ----------- */
......
set_wflag(pbuf, WF_HIDDEN);
}
hh = MAX(hh, pbuf->size.h);
pbuf->size.w = pIcons->pBIG_Shield_Corr->w + adj_size(6);
pbuf->size.w = icons->pBIG_Shield_Corr->w + adj_size(6);
add_to_gui_list(MAX_ID - pcity->id, pbuf);
/* ----------- */
......
set_wflag(pbuf, WF_HIDDEN);
}
hh = MAX(hh, pbuf->size.h);
pbuf->size.w = pIcons->pBIG_Shield_Surplus->w + adj_size(6);
pbuf->size.w = icons->pBIG_Shield_Surplus->w + adj_size(6);
add_to_gui_list(MAX_ID - pcity->id, pbuf);
/* ----------- */
......
}
if (!worklist_is_empty(&(pcity->worklist))) {
dst.x = logo->w - pIcons->pWorklist->w;
dst.x = logo->w - icons->pWorklist->w;
dst.y = 0;
alphablit(pIcons->pWorklist, NULL, logo, &dst, 255);
alphablit(icons->pWorklist, NULL, logo, &dst, 255);
fc_snprintf(cbuf, sizeof(cbuf), "%s\n(%d/%d)\n%s",
pName, pcity->shield_stock, togrow, _("worklist"));
} else {
......
city_rep->begin_widget_list = pbuf;
/* setup window width */
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)
+ (icons->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) {
......
dst.x += (ww + 1);
dst.y = area.y + 1;
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)
dst.w = (icons->pBIG_Food->w + adj_size(6)) + adj_size(10)
+ (icons->pBIG_Food_Surplus->w + adj_size(6)) + adj_size(10)
+ 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 + (text2->h - pIcons->pBIG_Food->h) / 2;
dst.y = area.y + 1 + (text2->h - icons->pBIG_Food->h) / 2;
dst.x += adj_size(5);
alphablit(pIcons->pBIG_Food, NULL, pwindow->theme, &dst, 255);
alphablit(icons->pBIG_Food, NULL, pwindow->theme, &dst, 255);
/* food surplus Icon */
w += (pIcons->pBIG_Food->w + adj_size(6)) + adj_size(10);
w += (icons->pBIG_Food->w + adj_size(6)) + adj_size(10);
dst.x = w + adj_size(3);
alphablit(pIcons->pBIG_Food_Surplus, NULL, pwindow->theme, &dst, 255);
alphablit(icons->pBIG_Food_Surplus, NULL, pwindow->theme, &dst, 255);
/* to grow label */
w += (pIcons->pBIG_Food_Surplus->w + adj_size(6)) + adj_size(10);
w += (icons->pBIG_Food_Surplus->w + adj_size(6)) + adj_size(10);
dst.x = w + adj_size(3);
dst.y = area.y + 1;
alphablit(text2, NULL, pwindow->theme, &dst, 255);
......
dst.x = w + (ww + adj_size(8));
dst.y = area.y + 1;
w = dst.x + adj_size(2);
dst.w = (pIcons->pBIG_Trade->w + adj_size(6)) + adj_size(10) +
(pIcons->pBIG_Trade_Corr->w + adj_size(6)) + adj_size(10) +
(pIcons->pBIG_Coin->w + adj_size(6)) + adj_size(10) +
(pIcons->pBIG_Colb->w + adj_size(6)) + adj_size(10) +
(pIcons->pBIG_Luxury->w + adj_size(6)) + adj_size(4);
dst.w = (icons->pBIG_Trade->w + adj_size(6)) + adj_size(10) +
(icons->pBIG_Trade_Corr->w + adj_size(6)) + adj_size(10) +
(icons->pBIG_Coin->w + adj_size(6)) + adj_size(10) +
(icons->pBIG_Colb->w + adj_size(6)) + adj_size(10) +
(icons->pBIG_Luxury->w + adj_size(6)) + adj_size(4);
dst.h = area.h - adj_size(2);
fill_rect_alpha(pwindow->theme, &dst, get_theme_color(COLOR_THEME_CITYREP_TRADE));
......
dst.x , dst.y, dst.w, dst.h - 1,
get_theme_color(COLOR_THEME_CITYREP_FRAME));
dst.y = area.y + 1 + (hh - pIcons->pBIG_Trade->h) / 2;
dst.y = area.y + 1 + (hh - icons->pBIG_Trade->h) / 2;
dst.x += adj_size(5);
alphablit(pIcons->pBIG_Trade, NULL, pwindow->theme, &dst, 255);
alphablit(icons->pBIG_Trade, NULL, pwindow->theme, &dst, 255);
w += (pIcons->pBIG_Trade->w + adj_size(6)) + adj_size(10);
w += (icons->pBIG_Trade->w + adj_size(6)) + adj_size(10);
dst.x = w + adj_size(3);
alphablit(pIcons->pBIG_Trade_Corr, NULL, pwindow->theme, &dst, 255);
alphablit(icons->pBIG_Trade_Corr, NULL, pwindow->theme, &dst, 255);
w += (pIcons->pBIG_Food_Corr->w + adj_size(6)) + adj_size(10);
w += (icons->pBIG_Food_Corr->w + adj_size(6)) + adj_size(10);
dst.x = w + adj_size(3);
alphablit(pIcons->pBIG_Coin, NULL, pwindow->theme, &dst, 255);
alphablit(icons->pBIG_Coin, NULL, pwindow->theme, &dst, 255);
w += (pIcons->pBIG_Coin->w + adj_size(6)) + adj_size(10);
w += (icons->pBIG_Coin->w + adj_size(6)) + adj_size(10);
dst.x = w + adj_size(3);
alphablit(pIcons->pBIG_Colb, NULL, pwindow->theme, &dst, 255);
alphablit(icons->pBIG_Colb, NULL, pwindow->theme, &dst, 255);
w += (pIcons->pBIG_Colb->w + adj_size(6)) + adj_size(10);
w += (icons->pBIG_Colb->w + adj_size(6)) + adj_size(10);
dst.x = w + adj_size(3);
alphablit(pIcons->pBIG_Luxury, NULL, pwindow->theme, &dst, 255);
alphablit(icons->pBIG_Luxury, NULL, pwindow->theme, &dst, 255);
/* --------------------- */
/* total productions, waste, support, shields surplus background and label */
w += (pIcons->pBIG_Luxury->w + adj_size(6)) + adj_size(4);
w += (icons->pBIG_Luxury->w + adj_size(6)) + adj_size(4);
dst.x = w;
w += adj_size(2);
dst.y = area.y + 1;
dst.w = (pIcons->pBIG_Shield->w + adj_size(6)) + adj_size(10) +
(pIcons->pBIG_Shield_Corr->w + adj_size(6)) + adj_size(10) +
dst.w = (icons->pBIG_Shield->w + adj_size(6)) + adj_size(10) +
(icons->pBIG_Shield_Corr->w + adj_size(6)) + adj_size(10) +
(units_icon->w + adj_size(6)) + adj_size(10) +
(pIcons->pBIG_Shield_Surplus->w + adj_size(6)) + adj_size(4);
(icons->pBIG_Shield_Surplus->w + adj_size(6)) + adj_size(4);
dst.h = area.h - adj_size(2);
fill_rect_alpha(pwindow->theme, &dst, get_theme_color(COLOR_THEME_CITYREP_PROD));
......
dst.x , dst.y, dst.w, dst.h - 1,
get_theme_color(COLOR_THEME_CITYREP_FRAME));
dst.y = area.y + 1 + (hh - pIcons->pBIG_Shield->h) / 2;
dst.y = area.y + 1 + (hh - icons->pBIG_Shield->h) / 2;
dst.x += adj_size(5);
alphablit(pIcons->pBIG_Shield, NULL, pwindow->theme, &dst, 255);
alphablit(icons->pBIG_Shield, NULL, pwindow->theme, &dst, 255);
w += (pIcons->pBIG_Shield->w + adj_size(6)) + adj_size(10);
w += (icons->pBIG_Shield->w + adj_size(6)) + adj_size(10);
dst.x = w + adj_size(3);
alphablit(pIcons->pBIG_Shield_Corr, NULL, pwindow->theme, &dst, 255);
alphablit(icons->pBIG_Shield_Corr, NULL, pwindow->theme, &dst, 255);
w += (pIcons->pBIG_Shield_Corr->w + adj_size(6)) + adj_size(10);
w += (icons->pBIG_Shield_Corr->w + adj_size(6)) + adj_size(10);
dst.x = w + adj_size(3);
dst.y = area.y + 1 + (hh - units_icon->h) / 2;
alphablit(units_icon, NULL, pwindow->theme, &dst, 255);
......
w += (units_icon->w + adj_size(6)) + adj_size(10);
FREESURFACE(units_icon);
dst.x = w + adj_size(3);
dst.y = area.y + 1 + (hh - pIcons->pBIG_Shield_Surplus->h) / 2;
alphablit(pIcons->pBIG_Shield_Surplus, NULL, pwindow->theme, &dst, 255);
dst.y = area.y + 1 + (hh - icons->pBIG_Shield_Surplus->h) / 2;
alphablit(icons->pBIG_Shield_Surplus, NULL, pwindow->theme, &dst, 255);
/* ------------------------------- */
w += (pIcons->pBIG_Shield_Surplus->w + adj_size(6)) + adj_size(10);
w += (icons->pBIG_Shield_Surplus->w + adj_size(6)) + adj_size(10);
dst.x = w;
w += adj_size(2);
dst.y = area.y + 1;
......
}
if (!worklist_is_empty(&(pcity->worklist))) {
dst.x = logo->w - pIcons->pWorklist->w;
dst.x = logo->w - icons->pWorklist->w;
dst.y = 0;
alphablit(pIcons->pWorklist, NULL, logo, &dst, 255);
alphablit(icons->pWorklist, NULL, logo, &dst, 255);
fc_snprintf(cbuf, sizeof(cbuf), "%s\n(%d/%d)\n%s",
pName, pcity->shield_stock, togrow, _("worklist"));
} else {
client/gui-sdl2/cma_fe.c
/* check if Citizen Icons style was loaded */
cs = style_of_city(pCma->pcity);
if (cs != pIcons->style) {
if (cs != icons->style) {
reload_citizens_icons(cs);
}
client/gui-sdl2/gui_main.c
static SDL_Event *pNet_User_Event = NULL;
static SDL_Event *pAnim_User_Event = NULL;
static SDL_Event *pInfo_User_Event = NULL;
static SDL_Event *info_user_event = NULL;
static SDL_Event *pMap_Scroll_User_Event = NULL;
static void print_usage(void);
......
}
if (widget_info_counter > 0) {
SDL_PushEvent(pInfo_User_Event);
SDL_PushEvent(info_user_event);
widget_info_counter = 0;
}
......
break;
case TRY_AUTO_CONNECT:
if (try_to_autoconnect()) {
pInfo_User_Event->user.code = SHOW_WIDGET_INFO_LABEL;
info_user_event->user.code = SHOW_WIDGET_INFO_LABEL;
autoconnect = FALSE;
}
break;
......
__Info_User_Event.user.code = SHOW_WIDGET_INFO_LABEL;
__Info_User_Event.user.data1 = NULL;
__Info_User_Event.user.data2 = NULL;
pInfo_User_Event = &__Info_User_Event;
info_user_event = &__Info_User_Event;
SDL_zero(__Flush_User_Event);
__Flush_User_Event.type = user_event_type;
client/gui-sdl2/gui_tilespec.c
#include "gui_tilespec.h"
struct Theme *current_theme = NULL;
struct City_Icon *pIcons;
struct city_icon *icons;
static SDL_Surface *city_surf;
......
load_GUI_surface(pSpr, current_theme, surf, tag)
#define load_city_icon_surface(pSpr, surf, tag) \
load_GUI_surface(pSpr, pIcons, surf, tag)
load_GUI_surface(pSpr, icons, surf, tag)
#define load_order_theme_surface(pSpr, surf, tag) \
load_GUI_surface(pSpr, current_theme, surf, tag);
......
int spe_max;
/* free info icons */
FREESURFACE(pIcons->pMale_Content);
FREESURFACE(pIcons->pFemale_Content);
FREESURFACE(pIcons->pMale_Happy);
FREESURFACE(pIcons->pFemale_Happy);
FREESURFACE(pIcons->pMale_Unhappy);
FREESURFACE(pIcons->pFemale_Unhappy);
FREESURFACE(pIcons->pMale_Angry);
FREESURFACE(pIcons->pFemale_Angry);
FREESURFACE(icons->pMale_Content);
FREESURFACE(icons->pFemale_Content);
FREESURFACE(icons->pMale_Happy);
FREESURFACE(icons->pFemale_Happy);
FREESURFACE(icons->pMale_Unhappy);
FREESURFACE(icons->pFemale_Unhappy);
FREESURFACE(icons->pMale_Angry);
FREESURFACE(icons->pFemale_Angry);
spe_max = specialist_count();
for (i = 0; i < spe_max; i++) {
FREESURFACE(pIcons->specialists[i]);
FREESURFACE(icons->specialists[i]);
}
/* allocate icons */
pIcons->pMale_Happy = adj_surf(get_citizen_surface(CITIZEN_HAPPY, 0));
pIcons->pFemale_Happy = adj_surf(get_citizen_surface(CITIZEN_HAPPY, 1));
pIcons->pMale_Content = adj_surf(get_citizen_surface(CITIZEN_CONTENT, 0));
pIcons->pFemale_Content = adj_surf(get_citizen_surface(CITIZEN_CONTENT, 1));
pIcons->pMale_Unhappy = adj_surf(get_citizen_surface(CITIZEN_UNHAPPY, 0));
pIcons->pFemale_Unhappy = adj_surf(get_citizen_surface(CITIZEN_UNHAPPY, 1));
pIcons->pMale_Angry = adj_surf(get_citizen_surface(CITIZEN_ANGRY, 0));
pIcons->pFemale_Angry = adj_surf(get_citizen_surface(CITIZEN_ANGRY, 1));
icons->pMale_Happy = adj_surf(get_citizen_surface(CITIZEN_HAPPY, 0));
icons->pFemale_Happy = adj_surf(get_citizen_surface(CITIZEN_HAPPY, 1));
icons->pMale_Content = adj_surf(get_citizen_surface(CITIZEN_CONTENT, 0));
icons->pFemale_Content = adj_surf(get_citizen_surface(CITIZEN_CONTENT, 1));
icons->pMale_Unhappy = adj_surf(get_citizen_surface(CITIZEN_UNHAPPY, 0));
icons->pFemale_Unhappy = adj_surf(get_citizen_surface(CITIZEN_UNHAPPY, 1));
icons->pMale_Angry = adj_surf(get_citizen_surface(CITIZEN_ANGRY, 0));
icons->pFemale_Angry = adj_surf(get_citizen_surface(CITIZEN_ANGRY, 1));
for (i = 0; i < spe_max; i++) {
pIcons->specialists[i] = adj_surf(get_citizen_surface(CITIZEN_SPECIALIST + i, 0));
icons->specialists[i] = adj_surf(get_citizen_surface(CITIZEN_SPECIALIST + i, 0));
}
}
......
void reload_citizens_icons(int style)
{
reload_small_citizens_icons(style);
pIcons->style = style;
icons->style = style;
}
/***************************************************************************//**
......
{
struct sprite *pSpr = NULL;
pIcons = ( struct City_Icon *)fc_calloc(1, sizeof( struct City_Icon ));
icons = (struct city_icon *)fc_calloc(1, sizeof(struct city_icon));
load_city_icon_surface(pSpr, pBIG_Food_Corr, "city.food_waste");
load_city_icon_surface(pSpr, pBIG_Shield_Corr, "city.shield_waste");
load_city_icon_surface(pSpr, pBIG_Trade_Corr, "city.trade_waste");
load_city_icon_surface(pSpr, pBIG_Food, "city.food");
pIcons->pBIG_Food_Surplus = crop_rect_from_surface(pIcons->pBIG_Food, NULL);
SDL_SetSurfaceAlphaMod(pIcons->pBIG_Food_Surplus, 128);
icons->pBIG_Food_Surplus = crop_rect_from_surface(icons->pBIG_Food, NULL);
SDL_SetSurfaceAlphaMod(icons->pBIG_Food_Surplus, 128);
load_city_icon_surface(pSpr, pBIG_Shield, "city.shield");
pIcons->pBIG_Shield_Surplus = crop_rect_from_surface(pIcons->pBIG_Shield, NULL);
SDL_SetSurfaceAlphaMod(pIcons->pBIG_Shield_Surplus, 128);
icons->pBIG_Shield_Surplus = crop_rect_from_surface(icons->pBIG_Shield, NULL);
SDL_SetSurfaceAlphaMod(icons->pBIG_Shield_Surplus, 128);
load_city_icon_surface(pSpr, pBIG_Trade, "city.trade");
load_city_icon_surface(pSpr, pBIG_Luxury, "city.lux");
......
load_city_icon_surface(pSpr, pPolice, "city.police");
/* ================================================================= */
pIcons->pWorklist = create_surf(9,9, SDL_SWSURFACE);
SDL_FillRect(pIcons->pWorklist, NULL,
SDL_MapRGB(pIcons->pWorklist->format, 255, 255,255));
icons->pWorklist = create_surf(9,9, SDL_SWSURFACE);
SDL_FillRect(icons->pWorklist, NULL,
SDL_MapRGB(icons->pWorklist->format, 255, 255,255));
create_frame(pIcons->pWorklist,
0, 0, pIcons->pWorklist->w - 1, pIcons->pWorklist->h - 1,
create_frame(icons->pWorklist,
0, 0, icons->pWorklist->w - 1, icons->pWorklist->h - 1,
get_theme_color(COLOR_THEME_CITYREP_FRAME));
create_line(pIcons->pWorklist,
create_line(icons->pWorklist,
3, 2, 5, 2,
get_theme_color(COLOR_THEME_CITYREP_FRAME));
create_line(pIcons->pWorklist,
create_line(icons->pWorklist,
3, 4, 7, 4,
get_theme_color(COLOR_THEME_CITYREP_FRAME));
create_line(pIcons->pWorklist,
create_line(icons->pWorklist,
3, 6, 6, 6,
get_theme_color(COLOR_THEME_CITYREP_FRAME));
/* ================================================================= */
/* force reload citizens icons */
pIcons->style = 999;
icons->style = 999;
}
/***************************************************************************//**
......
int i;
int spe_max;
if (!pIcons) {
if (!icons) {
return;
}
/* small citizens */
FREESURFACE(pIcons->pMale_Content);
FREESURFACE(pIcons->pFemale_Content);
FREESURFACE(pIcons->pMale_Happy);
FREESURFACE(pIcons->pFemale_Happy);
FREESURFACE(pIcons->pMale_Unhappy);
FREESURFACE(pIcons->pFemale_Unhappy);
FREESURFACE(pIcons->pMale_Angry);
FREESURFACE(pIcons->pFemale_Angry);
FREESURFACE(icons->pMale_Content);
FREESURFACE(icons->pFemale_Content);
FREESURFACE(icons->pMale_Happy);
FREESURFACE(icons->pFemale_Happy);
FREESURFACE(icons->pMale_Unhappy);
FREESURFACE(icons->pFemale_Unhappy);
FREESURFACE(icons->pMale_Angry);
FREESURFACE(icons->pFemale_Angry);
spe_max = specialist_count();
for (i = 0; i < spe_max; i++) {
FREESURFACE(pIcons->specialists[i]);
FREESURFACE(icons->specialists[i]);
}
FC_FREE(pIcons);
FC_FREE(icons);
}
/* =================================================== */
......
*******************************************************************************/
void draw_intro_gfx(void)
{
SDL_Surface *pIntro = theme_get_background(theme, BACKGROUND_MAINPAGE);
SDL_Surface *intro = theme_get_background(theme, BACKGROUND_MAINPAGE);
if (pIntro->w != main_window_width()) {
SDL_Surface *pTmp = ResizeSurface(pIntro, main_window_width(), main_window_height(), 1);
if (intro->w != main_window_width()) {
SDL_Surface *pTmp = ResizeSurface(intro, main_window_width(), main_window_height(), 1);
FREESURFACE(pIntro);
pIntro = pTmp;
FREESURFACE(intro);
intro = pTmp;
}
/* draw intro gfx center in screen */
alphablit(pIntro, NULL, main_data.map, NULL, 255);
alphablit(intro, NULL, main_data.map, NULL, 255);
FREESURFACE(pIntro);
FREESURFACE(intro);
}
client/gui-sdl2/gui_tilespec.h
SDL_Surface *OLoad_Icon;
};
struct City_Icon {
struct city_icon {
int style;
SDL_Surface *pBIG_Food_Corr;
......
};
extern struct Theme *current_theme;
extern struct City_Icon *pIcons;
extern struct city_icon *icons;
void tilespec_setup_theme(void);
void tilespec_free_theme(void);
client/gui-sdl2/helpdlg.c
struct widget *close_button = NULL;
struct widget *list_toggle_button = NULL;
struct widget *improvement_button = NULL;
struct widget *pImprNameLabel = NULL;
struct widget *impr_name_label = NULL;
struct widget *pCostLabel = NULL;
struct widget *pUpkeepLabel = NULL;
struct widget *pRequirementLabel = NULL;
......
pimpr_type = improvement_by_number(impr);
surf = get_building_surface(pimpr_type);
pImprNameLabel = create_iconlabel_from_chars(
impr_name_label = create_iconlabel_from_chars(
ResizeSurfaceBox(surf, adj_size(64), adj_size(48), 1, TRUE, TRUE),
pwindow->dst, city_improvement_name_translation(NULL, pimpr_type),
adj_font(24), WF_FREE_THEME);
pImprNameLabel->id = ID_LABEL;
widget_add_as_prev(pImprNameLabel, dock);
dock = pImprNameLabel;
impr_name_label->id = ID_LABEL;
widget_add_as_prev(impr_name_label, dock);
dock = impr_name_label;
if (!improvement_has_flag(pimpr_type, IF_GOLD)) {
sprintf(buffer, "%s %d", _("Base Cost:"),
......
}
}
pImprNameLabel = store->dock->prev;
widget_set_position(pImprNameLabel, start_x, area.y + adj_size(16));
impr_name_label = store->dock->prev;
widget_set_position(impr_name_label, start_x, area.y + adj_size(16));
start_y = pImprNameLabel->size.y + pImprNameLabel->size.h + adj_size(10);
start_y = impr_name_label->size.y + impr_name_label->size.h + adj_size(10);
if (!improvement_has_flag(pimpr_type, IF_GOLD)) {
pCostLabel = pImprNameLabel->prev;
pCostLabel = impr_name_label->prev;
widget_set_position(pCostLabel, start_x, start_y);
if (!is_wonder(pimpr_type)) {
pUpkeepLabel = pCostLabel->prev;
client/gui-sdl2/inteldlg.c
struct intel_dialog *pdialog = get_intel_dialog(p);
struct widget *pwindow = NULL, *buf = NULL, *last;
SDL_Surface *logo = NULL, *tmp_surf = NULL;
SDL_Surface *text1, *pInfo, *text2 = NULL;
SDL_Surface *text1, *info, *text2 = NULL;
utf8_str *pstr;
SDL_Rect dst;
char cbuf[256], plr_buf[4 * MAX_LEN_NAME];
......
};
copy_chars_to_utf8_str(pstr, cbuf);
pInfo = create_text_surf_from_utf8(pstr);
area.w = MAX(area.w, logo->w + adj_size(10) + pInfo->w + adj_size(20));
area.h += MAX(logo->h + adj_size(20), pInfo->h + adj_size(20));
info = create_text_surf_from_utf8(pstr);
area.w = MAX(area.w, logo->w + adj_size(10) + info->w + adj_size(20));
area.h += MAX(logo->h + adj_size(20), info->h + adj_size(20));
/* ---------- */
tmp_surf = get_tech_icon(A_FIRST);
......
/* spaceship button */
buf = buf->prev;
dst.x = area.x + (area.w - (buf->size.w + adj_size(10) + pInfo->w)) / 2;
dst.x = area.x + (area.w - (buf->size.w + adj_size(10) + info->w)) / 2;
buf->size.x = dst.x;
buf->size.y = dst.y;
dst.x += buf->size.w + adj_size(10);
alphablit(pInfo, NULL, pwindow->theme, &dst, 255);
dst.y += pInfo->h + adj_size(10);
FREESURFACE(pInfo);
alphablit(info, NULL, pwindow->theme, &dst, 255);
dst.y += info->h + adj_size(10);
FREESURFACE(info);
/* --------------------- */
client/gui-sdl2/mapctrl.c
/**********************************************************************//**
Show/Hide Units Info Window
**************************************************************************/
static int toggle_unit_info_window_callback(struct widget *pIcon_Widget)
static int toggle_unit_info_window_callback(struct widget *icon_widget)
{
if (PRESSED_EVENT(main_data.event)) {
struct widget *buf = NULL;
clear_surface(pIcon_Widget->theme, NULL);
alphablit(current_theme->MAP_Icon, NULL, pIcon_Widget->theme, NULL, 255);
clear_surface(icon_widget->theme, NULL);
alphablit(current_theme->MAP_Icon, NULL, icon_widget->theme, NULL, 255);
if (get_num_units_in_focus() > 0) {
undraw_order_widgets();
......
SDL_Surface *buf_surf;
SDL_Rect src, window_area;
set_wstate(pIcon_Widget, FC_WS_NORMAL);
set_wstate(icon_widget, FC_WS_NORMAL);
selected_widget = NULL;
if (units_info_window->private_data.adv_dlg->end_active_widget_list) {
......
widget_mark_dirty(units_info_window);
/* new button direction */
alphablit(current_theme->L_ARROW_Icon, NULL, pIcon_Widget->theme, NULL, 255);
alphablit(current_theme->L_ARROW_Icon, NULL, icon_widget->theme, NULL, 255);
copy_chars_to_utf8_str(pIcon_Widget->info_label,
copy_chars_to_utf8_str(icon_widget->info_label,
_("Show Unit Info Window"));
sdl2_client_flags &= ~CF_UNITINFO_SHOWN;
......
if (main_window_width() - units_info_window->size.w >=
minimap_window->dst->dest_rect.x + minimap_window->size.w) {
set_wstate(pIcon_Widget, FC_WS_NORMAL);
set_wstate(icon_widget, FC_WS_NORMAL);
selected_widget = NULL;
/* SHOW */
copy_chars_to_utf8_str(pIcon_Widget->info_label,
copy_chars_to_utf8_str(icon_widget->info_label,
_("Hide Unit Info Window"));
alphablit(current_theme->R_ARROW_Icon, NULL, pIcon_Widget->theme, NULL, 255);
alphablit(current_theme->R_ARROW_Icon, NULL, icon_widget->theme, NULL, 255);
sdl2_client_flags |= CF_UNITINFO_SHOWN;
......
redraw_unit_info_label(get_units_in_focus());
} else {
alphablit(current_theme->L_ARROW_Icon, NULL, pIcon_Widget->theme, NULL, 255);
widget_redraw(pIcon_Widget);
widget_mark_dirty(pIcon_Widget);
alphablit(current_theme->L_ARROW_Icon, NULL, icon_widget->theme, NULL, 255);
widget_redraw(icon_widget);
widget_mark_dirty(icon_widget);
}
}
......
void popup_unitinfo_window(void)
{
struct widget *pwidget, *pwindow;
SDL_Surface *pIcon_theme = NULL;
SDL_Surface *icon_theme = NULL;
char buf[256];
if (unit_info_dlg) {
......
unitinfo_w = pwindow->size.w;
unitinfo_h = pwindow->size.h;
pIcon_theme = ResizeSurface(current_theme->Block, pwindow->area.w,
icon_theme = ResizeSurface(current_theme->Block, pwindow->area.w,
pwindow->area.h, 1);
blit_entire_src(pIcon_theme, pwindow->theme, pwindow->area.x, pwindow->area.y);
FREESURFACE(pIcon_theme);
blit_entire_src(icon_theme, pwindow->theme, pwindow->area.x, pwindow->area.y);
FREESURFACE(icon_theme);
pwindow->action = unit_info_window_callback;
......
/* show/hide unit's window button */
/* make UNITS Icon */
pIcon_theme = create_surf(current_theme->MAP_Icon->w,
icon_theme = create_surf(current_theme->MAP_Icon->w,
current_theme->MAP_Icon->h, SDL_SWSURFACE);
alphablit(current_theme->MAP_Icon, NULL, pIcon_theme, NULL, 255);
alphablit(current_theme->R_ARROW_Icon, NULL, pIcon_theme, NULL, 255);
alphablit(current_theme->MAP_Icon, NULL, icon_theme, NULL, 255);
alphablit(current_theme->R_ARROW_Icon, NULL, icon_theme, NULL, 255);
pwidget = create_themeicon(pIcon_theme, units_info_window->dst,
pwidget = create_themeicon(icon_theme, units_info_window->dst,
WF_FREE_GFX | WF_FREE_THEME
| WF_RESTORE_BACKGROUND
| WF_WIDGET_HAS_INFO_LABEL);
......
void popup_minimap_window(void)
{
struct widget *pwidget, *pwindow;
SDL_Surface *pIcon_theme = NULL;
SDL_Surface *icon_theme = NULL;
SDL_Color black = {0, 0, 0, 255};
char buf[256];
......
draw_frame(pwindow->theme, 0, 0, pwindow->size.w, pwindow->size.h);
pIcon_theme = ResizeSurface(current_theme->Block, BLOCKM_W, pwindow->area.h, 1);
blit_entire_src(pIcon_theme, pwindow->theme,
pwindow->area.x + pwindow->area.w - pIcon_theme->w, pwindow->area.y);
FREESURFACE(pIcon_theme);
icon_theme = ResizeSurface(current_theme->Block, BLOCKM_W, pwindow->area.h, 1);
blit_entire_src(icon_theme, pwindow->theme,
pwindow->area.x + pwindow->area.w - icon_theme->w, pwindow->area.y);
FREESURFACE(icon_theme);
pwindow->action = minimap_window_callback;
......
/* show/hide minimap button */
/* make Map Icon */
pIcon_theme = create_surf(current_theme->MAP_Icon->w, current_theme->MAP_Icon->h,
icon_theme = create_surf(current_theme->MAP_Icon->w, current_theme->MAP_Icon->h,
SDL_SWSURFACE);
alphablit(current_theme->MAP_Icon, NULL, pIcon_theme, NULL, 255);
alphablit(current_theme->L_ARROW_Icon, NULL, pIcon_theme, NULL, 255);
alphablit(current_theme->MAP_Icon, NULL, icon_theme, NULL, 255);
alphablit(current_theme->L_ARROW_Icon, NULL, icon_theme, NULL, 255);
pwidget = create_themeicon(pIcon_theme, minimap_window->dst,
pwidget = create_themeicon(icon_theme, minimap_window->dst,
WF_FREE_GFX | WF_FREE_THEME |
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
......
void show_game_page(void)
{
struct widget *pwidget;
SDL_Surface *pIcon_theme = NULL;
SDL_Surface *icon_theme = NULL;
if (sdl2_client_flags & CF_MAP_UNIT_W_CREATED) {
return;
......
#endif
/* cooling icon */
pIcon_theme = adj_surf(GET_SURF(client_cooling_sprite()));
fc_assert(pIcon_theme != NULL);
pwidget = create_iconlabel(pIcon_theme, main_data.gui, NULL, WF_FREE_THEME);
icon_theme = adj_surf(GET_SURF(client_cooling_sprite()));
fc_assert(icon_theme != NULL);
pwidget = create_iconlabel(icon_theme, main_data.gui, NULL, WF_FREE_THEME);
#ifdef SMALL_SCREEN
widget_set_position(pwidget,
......
add_to_gui_list(ID_COOLING_ICON, pwidget);
/* warming icon */
pIcon_theme = adj_surf(GET_SURF(client_warming_sprite()));
fc_assert(pIcon_theme != NULL);
icon_theme = adj_surf(GET_SURF(client_warming_sprite()));
fc_assert(icon_theme != NULL);
pwidget = create_iconlabel(pIcon_theme, main_data.gui, NULL, WF_FREE_THEME);
pwidget = create_iconlabel(icon_theme, main_data.gui, NULL, WF_FREE_THEME);
#ifdef SMALL_SCREEN
widget_set_position(pwidget,
client/gui-sdl2/mapview.c
#include "mapview.h"
extern SDL_Event *flush_event;
extern SDL_Rect *pInfo_Area;
extern SDL_Rect *info_area;
int overview_start_x = 0;
int overview_start_y = 0;
......
/* restore widget info label if it overlaps with this area */
dst = main_data.rects[i];
if (pInfo_Area && !(((dst.x + dst.w) < pInfo_Area->x)
|| (dst.x > (pInfo_Area->x + pInfo_Area->w))
|| ((dst.y + dst.h) < pInfo_Area->y)
|| (dst.y > (pInfo_Area->y + pInfo_Area->h)))) {
if (info_area && !(((dst.x + dst.w) < info_area->x)
|| (dst.x > (info_area->x + info_area->w))
|| ((dst.y + dst.h) < info_area->y)
|| (dst.y > (info_area->y + info_area->h)))) {
redraw_widget_info_label(&dst);
}
}
......
widget_redraw(info_window);
if (punit) {
SDL_Surface *pName, *pVet_Name = NULL, *pInfo, *pInfo_II = NULL;
SDL_Surface *pName, *pVet_Name = NULL, *info, *info2 = NULL;
int sy, y, width, height, n;
bool right;
char buffer[512];
......
copy_chars_to_utf8_str(pstr,
get_unit_info_label_text2(punitlist,
TILE_LB_RESOURCE_POLL));
pInfo = create_text_surf_from_utf8(pstr);
info = create_text_surf_from_utf8(pstr);
if (info_window->size.h >
(DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h)) || right) {
......
copy_chars_to_utf8_str(pstr, buffer);
pInfo_II = create_text_surf_smaller_than_w(pstr, width - BLOCKU_W - adj_size(4));
info2 = create_text_surf_smaller_than_w(pstr, width - BLOCKU_W - adj_size(4));
}
FREEUTF8STR(pstr);
......
n = unit_list_size(ptile->units);
y = 0;
if (n > 1 && ((!right && pInfo_II
if (n > 1 && ((!right && info2
&& (info_window->size.h - (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h)) -
pInfo_II->h > 52))
info2->h > 52))
|| (right && info_window->size.h - (DEFAULT_UNITS_H + (info_window->size.h -
info_window->area.h)) > 52))) {
height = (info_window->size.h - info_window->area.h) + DEFAULT_UNITS_H;
......
height = info_window->size.h;
if (info_window->size.h > (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h))) {
y = (info_window->size.h - (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h)) -
(!right && pInfo_II ? pInfo_II->h : 0)) / 2;
(!right && info2 ? info2->h : 0)) / 2;
}
}
......
/* blit unit info text */
area.x = info_window->area.x + BLOCKU_W - adj_size(4) +
((width - BLOCKU_W + adj_size(4) - pInfo->w) / 2);
area.y = info_window->size.y + sy + (DEFAULT_UNITS_H - sy - pInfo->h) / 2;
((width - BLOCKU_W + adj_size(4) - info->w) / 2);
area.y = info_window->size.y + sy + (DEFAULT_UNITS_H - sy - info->h) / 2;
alphablit(pInfo, NULL, info_window->dst->surface, &area, 255);
FREESURFACE(pInfo);
alphablit(info, NULL, info_window->dst->surface, &area, 255);
FREESURFACE(info);
if (pInfo_II) {
if (info2) {
if (right) {
area.x = info_window->area.x + width + (width - pInfo_II->w) / 2;
area.y = info_window->area.y + (height - pInfo_II->h) / 2;
area.x = info_window->area.x + width + (width - info2->w) / 2;
area.y = info_window->area.y + (height - info2->h) / 2;
} else {
area.y = info_window->area.y + DEFAULT_UNITS_H + y;
area.x = info_window->area.x + BLOCKU_W +
(width - BLOCKU_W - pInfo_II->w) / 2;
(width - BLOCKU_W - info2->w) / 2;
}
/* blit unit info text */
alphablit(pInfo_II, NULL, info_window->dst->surface, &area, 255);
alphablit(info2, NULL, info_window->dst->surface, &area, 255);
if (right) {
sy = (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h));
} else {
sy = area.y - info_window->size.y + pInfo_II->h;
sy = area.y - info_window->size.y + info2->h;
}
FREESURFACE(pInfo_II);
FREESURFACE(info2);
} else {
sy = (DEFAULT_UNITS_H + (info_window->size.h - info_window->area.h));
}
client/gui-sdl2/menu.c
static void set_new_order_widget_start_pos(void)
{
struct widget *pMiniMap = get_minimap_window_widget();
struct widget *pInfoWind = get_unit_info_window_widget();
struct widget *info_wind = get_unit_info_window_widget();
struct widget *tmp_widget = begin_order_widget_list;
Sint16 sx, sy, xx, yy = 0;
int count = 0, lines = 1, w = 0, count_on_line;
xx = pMiniMap->dst->dest_rect.x + pMiniMap->size.w + adj_size(10);
w = (pInfoWind->dst->dest_rect.x - adj_size(10)) - xx;
w = (info_wind->dst->dest_rect.x - adj_size(10)) - xx;
if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
if (pMiniMap->size.h == pInfoWind->size.h) {
if (pMiniMap->size.h == info_wind->size.h) {
xx = 0;
w = main_window_width();
yy = pInfoWind->size.h;
yy = info_wind->size.h;
} else {
if (pMiniMap->size.h > pInfoWind->size.h) {
if (pMiniMap->size.h > info_wind->size.h) {
w = main_window_width() - xx - adj_size(20);
if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
xx = 0;
w = pMiniMap->size.w;
yy = pMiniMap->size.h;
} else {
yy = pInfoWind->size.h;
yy = info_wind->size.h;
}
} else {
w = pInfoWind->dst->dest_rect.x - adj_size(20);
w = info_wind->dst->dest_rect.x - adj_size(20);
if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
xx = pInfoWind->dst->dest_rect.x;
w = pInfoWind->size.w;
yy = pInfoWind->size.h;
xx = info_wind->dst->dest_rect.x;
w = info_wind->size.w;
yy = info_wind->size.h;
} else {
xx = adj_size(10);
yy = pMiniMap->size.h;
client/gui-sdl2/repodlgs.c
get_theme_color(COLOR_THEME_UNITSREP_FRAME));
dst.y = area.y + adj_size(3);
dst.x += ((ww - pIcons->pBIG_Shield->w) / 2);
alphablit(pIcons->pBIG_Shield, NULL, pwindow->theme, &dst, 255);
dst.x += ((ww - icons->pBIG_Shield->w) / 2);
alphablit(icons->pBIG_Shield, NULL, pwindow->theme, &dst, 255);
/* food cost background and label */
dst.x = w + ww + adj_size(10);
......
get_theme_color(COLOR_THEME_UNITSREP_FRAME));
dst.y = area.y + adj_size(3);
dst.x += ((ww - pIcons->pBIG_Food->w) / 2);
alphablit(pIcons->pBIG_Food, NULL, pwindow->theme, &dst, 255);
dst.x += ((ww - icons->pBIG_Food->w) / 2);
alphablit(icons->pBIG_Food, NULL, pwindow->theme, &dst, 255);
/* gold cost background and label */
dst.x = w + ww + adj_size(10);
......
get_theme_color(COLOR_THEME_UNITSREP_FRAME));
dst.y = area.y + adj_size(3);
dst.x += ((ww - pIcons->pBIG_Coin->w) / 2);
alphablit(pIcons->pBIG_Coin, NULL, pwindow->theme, &dst, 255);
dst.x += ((ww - icons->pBIG_Coin->w) / 2);
alphablit(icons->pBIG_Coin, NULL, pwindow->theme, &dst, 255);
/* building count background and label */
dst.x = w + ww + adj_size(10);
......
{
if (PRESSED_EVENT(main_data.event)) {
int imp, total_count, count = 0;
struct widget *pImpr = (struct widget *)pwidget->data.ptr;
struct widget *impr = (struct widget *)pwidget->data.ptr;
imp = pImpr->data.cont->id0;
total_count = pImpr->data.cont->id1;
imp = impr->data.cont->id0;
total_count = impr->data.cont->id1;
/* popdown sell dlg */
popdown_window_group_dialog(economy_sell_dlg->begin_widget_list,
......
} city_list_iterate_end;
if (count == total_count) {
del_widget_from_vertical_scroll_widget_list(economy_dlg, pImpr);
del_widget_from_vertical_scroll_widget_list(economy_dlg, impr);
}
}
......
pstr = create_utf8_from_char(cbuf, adj_font(12));
pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
buf = create_iconlabel(pIcons->pBIG_Coin, pwindow->dst, pstr,
buf = create_iconlabel(icons->pBIG_Coin, pwindow->dst, pstr,
(WF_RESTORE_BACKGROUND|WF_ICON_CENTER_RIGHT));
add_to_gui_list(ID_LABEL, buf);
......
pstr = create_utf8_from_char(cbuf, adj_font(11));
pstr->style |= TTF_STYLE_BOLD;
buf = create_iconlabel(pIcons->pBIG_Luxury, pwindow->dst, pstr,
buf = create_iconlabel(icons->pBIG_Luxury, pwindow->dst, pstr,
WF_RESTORE_BACKGROUND);
add_to_gui_list(ID_CHANGE_TAXRATE_DLG_LUX_LABEL, buf);
......
pstr = create_utf8_from_char(cbuf, adj_font(11));
pstr->style |= TTF_STYLE_BOLD;
buf = create_iconlabel(pIcons->pBIG_Colb, pwindow->dst, pstr,
buf = create_iconlabel(icons->pBIG_Colb, pwindow->dst, pstr,
WF_RESTORE_BACKGROUND);
add_to_gui_list(ID_CHANGE_TAXRATE_DLG_SCI_LABEL, buf);
......
dst.x = (surf->w - text_name->w)/2;
dst.y += ((surf->h - dst.y) -
(text_name->h + (pIcons->pBIG_Coin->h + 2) + text->h)) / 2;
(text_name->h + (icons->pBIG_Coin->h + 2) + text->h)) / 2;
alphablit(text_name, NULL, surf, &dst, 255);
dst.y += text_name->h;
if (p->cost) {
dst.x = (surf->w - p->cost * (pIcons->pBIG_Coin->w + 1))/2;
dst.x = (surf->w - p->cost * (icons->pBIG_Coin->w + 1))/2;
for (count = 0; count < p->cost; count++) {
alphablit(pIcons->pBIG_Coin, NULL, surf, &dst, 255);
dst.x += pIcons->pBIG_Coin->w + 1;
alphablit(icons->pBIG_Coin, NULL, surf, &dst, 255);
dst.x += icons->pBIG_Coin->w + 1;
}
} else {
......
FREESURFACE(zoomed);
}
dst.y += (pIcons->pBIG_Coin->h + adj_size(2));
dst.y += (icons->pBIG_Coin->h + adj_size(2));
dst.x = (surf->w - text->w) / 2;
alphablit(text, NULL, surf, &dst, 255);
......
char cbuf[128];
utf8_str *pStr;
SDL_Surface *msurf;
SDL_Surface *pColb_Surface = pIcons->pBIG_Colb;
SDL_Surface *pColb_Surface = icons->pBIG_Colb;
int step, i, cost;
SDL_Rect dest;
struct unit_type *punit;
client/gui-sdl2/widget.c
#include "widget_p.h"
struct widget *selected_widget;
SDL_Rect *pInfo_Area = NULL;
SDL_Rect *info_area = NULL;
extern Uint32 widget_info_counter;
......
}
widget_info_counter = 0;
if (pInfo_Area) {
dirty_sdl_rect(pInfo_Area);
FC_FREE(pInfo_Area);
if (info_area) {
dirty_sdl_rect(info_area);
FC_FREE(info_area);
FREESURFACE(info_label);
}
......
}
}
if (pInfo_Area) {
flush_rect(pInfo_Area, FALSE);
FC_FREE(pInfo_Area);
if (info_area) {
flush_rect(info_area, FALSE);
FC_FREE(info_area);
FREESURFACE(info_label);
}
......
}
if (!info_label) {
pInfo_Area = fc_calloc(1, sizeof(SDL_Rect));
info_area = fc_calloc(1, sizeof(SDL_Rect));
color = pwidget->info_label->fgcol;
pwidget->info_label->style |= TTF_STYLE_BOLD;
......
/* calculate start position */
if ((pwidget->dst->dest_rect.y + pwidget->size.y) - info_label->h - adj_size(6) < 0) {
pInfo_Area->y = (pwidget->dst->dest_rect.y + pwidget->size.y) + pwidget->size.h + adj_size(3);
info_area->y = (pwidget->dst->dest_rect.y + pwidget->size.y) + pwidget->size.h + adj_size(3);
} else {
pInfo_Area->y = (pwidget->dst->dest_rect.y + pwidget->size.y) - info_label->h - adj_size(5);
info_area->y = (pwidget->dst->dest_rect.y + pwidget->size.y) - info_label->h - adj_size(5);
}
if ((pwidget->dst->dest_rect.x + pwidget->size.x) + info_label->w + adj_size(5) > main_window_width()) {
pInfo_Area->x = (pwidget->dst->dest_rect.x + pwidget->size.x) - info_label->w - adj_size(5);
info_area->x = (pwidget->dst->dest_rect.x + pwidget->size.x) - info_label->w - adj_size(5);
} else {
pInfo_Area->x = (pwidget->dst->dest_rect.x + pwidget->size.x) + adj_size(3);
info_area->x = (pwidget->dst->dest_rect.x + pwidget->size.x) + adj_size(3);
}
pInfo_Area->w = info_label->w + adj_size(2);
pInfo_Area->h = info_label->h + adj_size(3);
info_area->w = info_label->w + adj_size(2);
info_area->h = info_label->h + adj_size(3);
/* draw text */
dstrect.x = adj_size(6);
......
}
if (rect) {
dstrect.x = MAX(rect->x, pInfo_Area->x);
dstrect.y = MAX(rect->y, pInfo_Area->y);
dstrect.x = MAX(rect->x, info_area->x);
dstrect.y = MAX(rect->y, info_area->y);
srcrect.x = dstrect.x - pInfo_Area->x;
srcrect.y = dstrect.y - pInfo_Area->y;
srcrect.w = MIN((pInfo_Area->x + pInfo_Area->w), (rect->x + rect->w)) - dstrect.x;
srcrect.h = MIN((pInfo_Area->y + pInfo_Area->h), (rect->y + rect->h)) - dstrect.y;
srcrect.x = dstrect.x - info_area->x;
srcrect.y = dstrect.y - info_area->y;
srcrect.w = MIN((info_area->x + info_area->w), (rect->x + rect->w)) - dstrect.x;
srcrect.h = MIN((info_area->y + info_area->h), (rect->y + rect->h)) - dstrect.y;
screen_blit(info_label, &srcrect, &dstrect, 255);
} else {
screen_blit(info_label, NULL, pInfo_Area, 255);
screen_blit(info_label, NULL, info_area, 255);
}
if (correct_rect_region(pInfo_Area)) {
if (correct_rect_region(info_area)) {
update_main_screen();
#if 0
SDL_UpdateRect(main_data.screen, pInfo_Area->x, pInfo_Area->y,
pInfo_Area->w, pInfo_Area->h);
SDL_UpdateRect(main_data.screen, info_area->x, info_area->y,
info_area->w, info_area->h);
#endif /* 0 */
}
}
client/gui-sdl2/widget_button.c
/**********************************************************************//**
Create ( malloc ) Theme Icon (theme)Button Widget structure.
Icon Theme graphic is taken from 'pIcon_theme' surface ( change with
Icon Theme graphic is taken from 'icon_theme' surface ( change with
button changes ); Button Theme graphic is taken from current_theme->button
surface; Text is taken from 'pstr'.
......
function return pointer to allocated Button Widget.
**************************************************************************/
struct widget *create_themeicon_button(SDL_Surface *pIcon_theme,
struct widget *create_themeicon_button(SDL_Surface *icon_theme,
struct gui_layer *pdest,
utf8_str *pstr,
Uint32 flags)
{
/* extract a single icon */
SDL_Surface *icon = create_icon_from_theme(pIcon_theme, 1);
SDL_Surface *icon = create_icon_from_theme(icon_theme, 1);
struct widget *button = create_icon_button(icon, pdest, pstr, flags);
FREESURFACE(button->theme2);
button->theme2 = pIcon_theme;
button->theme2 = icon_theme;
set_wtype(button, WT_TI_BUTTON);
button->redraw = redraw_tibutton;
client/gui-sdl2/widget_button.h
create_utf8_from_char(pCharString, iPtsize), \
flags)
#define create_themeicon_button_from_unichar(pIcon_theme, pdest, pUniChar, pUniCharSize, iPtsize, flags) \
#define create_themeicon_button_from_unichar(icon_theme, pdest, pUniChar, pUniCharSize, iPtsize, flags) \
create_themeicon_button(icon, pdest, create_utf8(pUniChar, pUniCharSize, iPtsize), \
flags)
#define create_themeicon_button_from_chars(pIcon_theme, pdest, pCharString, iPtsize, flags) \
create_themeicon_button(pIcon_theme, pdest, \
#define create_themeicon_button_from_chars(icon_theme, pdest, pCharString, iPtsize, flags) \
create_themeicon_button(icon_theme, pdest, \
create_utf8_from_char(pCharString, \
iPtsize), \
flags)
......
struct gui_layer *pdest, utf8_str *pstr,
Uint32 flags);
struct widget *create_themeicon_button(SDL_Surface *pIcon_theme,
struct widget *create_themeicon_button(SDL_Surface *icon_theme,
struct gui_layer *pdest, utf8_str *pstr,
Uint32 flags);
client/gui-sdl2/widget_edit.c
struct text_edit {
struct Utf8Char *begin_text_chain;
struct Utf8Char *end_text_chain;
struct Utf8Char *pInputChain;
struct Utf8Char *input_chain;
SDL_Surface *pBg;
struct widget *pwidget;
int ChainLen;
......
static size_t chainlen(const struct Utf8Char *pChain);
static void del_chain(struct Utf8Char *pChain);
static struct Utf8Char *text2chain(const char *text_in);
static char *chain2text(const struct Utf8Char *pInChain, size_t len, size_t *size);
static char *chain2text(const struct Utf8Char *in_chain, size_t len, size_t *size);
static int (*baseclass_redraw)(struct widget *pwidget);
......
**************************************************************************/
static int redraw_edit_chain(struct text_edit *edt)
{
struct Utf8Char *pInputChain_TMP;
struct Utf8Char *input_chain_tmp;
SDL_Rect Dest, Dest_Copy = {0, 0, 0, 0};
int iStart_Mod_X;
int ret;
......
alphablit(edt->pBg, NULL, edt->pwidget->dst->surface, &Dest, 255);
/* set start parameters */
pInputChain_TMP = edt->begin_text_chain;
input_chain_tmp = edt->begin_text_chain;
iStart_Mod_X = 0;
Dest_Copy.y += (edt->pBg->h - pInputChain_TMP->pTsurf->h) / 2;
Dest_Copy.y += (edt->pBg->h - input_chain_tmp->pTsurf->h) / 2;
Dest_Copy.x += edt->Start_X;
/* draw loop */
while (pInputChain_TMP) {
while (input_chain_tmp) {
Dest_Copy.x += iStart_Mod_X;
/* check if we draw inside of edit rect */
if (Dest_Copy.x > edt->pwidget->size.x + edt->pBg->w - 4) {
......
if (Dest_Copy.x > edt->pwidget->size.x) {
Dest = Dest_Copy;
alphablit(pInputChain_TMP->pTsurf, NULL, edt->pwidget->dst->surface, &Dest,
alphablit(input_chain_tmp->pTsurf, NULL, edt->pwidget->dst->surface, &Dest,
255);
}
iStart_Mod_X = pInputChain_TMP->pTsurf->w;
iStart_Mod_X = input_chain_tmp->pTsurf->w;
/* draw cursor */
if (pInputChain_TMP == edt->pInputChain) {
if (input_chain_tmp == edt->input_chain) {
Dest = Dest_Copy;
create_line(edt->pwidget->dst->surface,
......
edt->InputChain_X = Dest_Copy.x;
}
pInputChain_TMP = pInputChain_TMP->next;
input_chain_tmp = input_chain_tmp->next;
} /* while - draw loop */
widget_flush(edt->pwidget);
......
Convert Utf8Char structure to chars
WARNING: Do not free Utf8Char structure but allocates new char array.
**************************************************************************/
static char *chain2text(const struct Utf8Char *pInChain, size_t len,
static char *chain2text(const struct Utf8Char *in_chain, size_t len,
size_t *size)
{
int i;
......
int oi = 0;
int total_size = 0;
if (!(len && pInChain)) {
if (!(len && in_chain)) {
return pOutText;
}
......
for (i = 0; i < len; i++) {
int j;
for (j = 0; j < pInChain->bytes && i < len; j++) {
pOutText[oi++] = pInChain->chr[j];
for (j = 0; j < in_chain->bytes && i < len; j++) {
pOutText[oi++] = in_chain->chr[j];
}
total_size += pInChain->bytes;
pInChain = pInChain->next;
total_size += in_chain->bytes;
in_chain = in_chain->next;
}
*size = total_size;
......
static Uint16 edit_key_down(SDL_Keysym key, void *pData)
{
struct text_edit *edt = (struct text_edit *)pData;
struct Utf8Char *pInputChain_TMP;
struct Utf8Char *input_chain_tmp;
bool Redraw = FALSE;
/* find which key is pressed */
......
case SDLK_RIGHT:
{
/* move cursor right */
if (edt->pInputChain->next) {
if (edt->input_chain->next) {
if (edt->InputChain_X >= (edt->pwidget->size.x + edt->pBg->w - adj_size(10))) {
edt->Start_X -= edt->pInputChain->pTsurf->w -
edt->Start_X -= edt->input_chain->pTsurf->w -
(edt->pwidget->size.x + edt->pBg->w - adj_size(5) - edt->InputChain_X);
}
edt->pInputChain = edt->pInputChain->next;
edt->input_chain = edt->input_chain->next;
Redraw = TRUE;
}
}
......
case SDLK_LEFT:
{
/* move cursor left */
if (edt->pInputChain->prev) {
edt->pInputChain = edt->pInputChain->prev;
if (edt->input_chain->prev) {
edt->input_chain = edt->input_chain->prev;
if ((edt->InputChain_X <=
(edt->pwidget->size.x + adj_size(9))) && (edt->Start_X != adj_size(5))) {
if (edt->InputChain_X != (edt->pwidget->size.x + adj_size(5))) {
edt->Start_X += (edt->pwidget->size.x - edt->InputChain_X + adj_size(5));
}
edt->Start_X += (edt->pInputChain->pTsurf->w);
edt->Start_X += (edt->input_chain->pTsurf->w);
}
Redraw = TRUE;
}
......
case SDLK_HOME:
{
/* move cursor to begin of chain (and edit field) */
edt->pInputChain = edt->begin_text_chain;
edt->input_chain = edt->begin_text_chain;
Redraw = TRUE;
edt->Start_X = adj_size(5);
}
......
case SDLK_END:
{
/* move cursor to end of chain (and edit field) */
edt->pInputChain = edt->end_text_chain;
edt->input_chain = edt->end_text_chain;
Redraw = TRUE;
if (edt->pwidget->size.w - edt->Truelength < 0) {
......
case SDLK_BACKSPACE:
{
/* del element of chain (and move cursor left) */
if (edt->pInputChain->prev) {
if (edt->input_chain->prev) {
if ((edt->InputChain_X <=
(edt->pwidget->size.x + adj_size(9))) && (edt->Start_X != adj_size(5))) {
if (edt->InputChain_X != (edt->pwidget->size.x + adj_size(5))) {
edt->Start_X += (edt->pwidget->size.x - edt->InputChain_X + adj_size(5));
}
edt->Start_X += (edt->pInputChain->prev->pTsurf->w);
edt->Start_X += (edt->input_chain->prev->pTsurf->w);
}
if (edt->pInputChain->prev->prev) {
edt->pInputChain->prev->prev->next = edt->pInputChain;
pInputChain_TMP = edt->pInputChain->prev->prev;
edt->Truelength -= edt->pInputChain->prev->pTsurf->w;
FREESURFACE(edt->pInputChain->prev->pTsurf);
FC_FREE(edt->pInputChain->prev);
edt->pInputChain->prev = pInputChain_TMP;
if (edt->input_chain->prev->prev) {
edt->input_chain->prev->prev->next = edt->input_chain;
input_chain_tmp = edt->input_chain->prev->prev;
edt->Truelength -= edt->input_chain->prev->pTsurf->w;
FREESURFACE(edt->input_chain->prev->pTsurf);
FC_FREE(edt->input_chain->prev);
edt->input_chain->prev = input_chain_tmp;
} else {
edt->Truelength -= edt->pInputChain->prev->pTsurf->w;
FREESURFACE(edt->pInputChain->prev->pTsurf);
FC_FREE(edt->pInputChain->prev);
edt->begin_text_chain = edt->pInputChain;
edt->Truelength -= edt->input_chain->prev->pTsurf->w;
FREESURFACE(edt->input_chain->prev->pTsurf);
FC_FREE(edt->input_chain->prev);
edt->begin_text_chain = edt->input_chain;
}
edt->ChainLen--;
......
case SDLK_DELETE:
{
/* del element of chain */
if (edt->pInputChain->next && edt->pInputChain->prev) {
edt->pInputChain->prev->next = edt->pInputChain->next;
edt->pInputChain->next->prev = edt->pInputChain->prev;
pInputChain_TMP = edt->pInputChain->next;
edt->Truelength -= edt->pInputChain->pTsurf->w;
FREESURFACE(edt->pInputChain->pTsurf);
FC_FREE(edt->pInputChain);
edt->pInputChain = pInputChain_TMP;
if (edt->input_chain->next && edt->input_chain->prev) {
edt->input_chain->prev->next = edt->input_chain->next;
edt->input_chain->next->prev = edt->input_chain->prev;
input_chain_tmp = edt->input_chain->next;
edt->Truelength -= edt->input_chain->pTsurf->w;
FREESURFACE(edt->input_chain->pTsurf);
FC_FREE(edt->input_chain);
edt->input_chain = input_chain_tmp;
edt->ChainLen--;
Redraw = TRUE;
}
if (edt->pInputChain->next && !edt->pInputChain->prev) {
edt->pInputChain = edt->pInputChain->next;
edt->Truelength -= edt->pInputChain->prev->pTsurf->w;
FREESURFACE(edt->pInputChain->prev->pTsurf);
FC_FREE(edt->pInputChain->prev);
edt->begin_text_chain = edt->pInputChain;
if (edt->input_chain->next && !edt->input_chain->prev) {
edt->input_chain = edt->input_chain->next;
edt->Truelength -= edt->input_chain->prev->pTsurf->w;
FREESURFACE(edt->input_chain->prev->pTsurf);
FC_FREE(edt->input_chain->prev);
edt->begin_text_chain = edt->input_chain;
edt->ChainLen--;
Redraw = TRUE;
}
......
static Uint16 edit_textinput(char *text, void *pData)
{
struct text_edit *edt = (struct text_edit *)pData;
struct Utf8Char *pInputChain_TMP;
struct Utf8Char *input_chain_tmp;
int i;
for (i = 0; text[i] != '\0';) {
......
int addition = 32;
/* add new element of chain (and move cursor right) */
if (edt->pInputChain != edt->begin_text_chain) {
pInputChain_TMP = edt->pInputChain->prev;
edt->pInputChain->prev = fc_calloc(1, sizeof(struct Utf8Char));
edt->pInputChain->prev->next = edt->pInputChain;
edt->pInputChain->prev->prev = pInputChain_TMP;
pInputChain_TMP->next = edt->pInputChain->prev;
if (edt->input_chain != edt->begin_text_chain) {
input_chain_tmp = edt->input_chain->prev;
edt->input_chain->prev = fc_calloc(1, sizeof(struct Utf8Char));
edt->input_chain->prev->next = edt->input_chain;
edt->input_chain->prev->prev = input_chain_tmp;
input_chain_tmp->next = edt->input_chain->prev;
} else {
edt->pInputChain->prev = fc_calloc(1, sizeof(struct Utf8Char));
edt->pInputChain->prev->next = edt->pInputChain;
edt->begin_text_chain = edt->pInputChain->prev;
edt->input_chain->prev = fc_calloc(1, sizeof(struct Utf8Char));
edt->input_chain->prev->next = edt->input_chain;
edt->begin_text_chain = edt->input_chain->prev;
}
edt->pInputChain->prev->chr[0] = leading;
edt->input_chain->prev->chr[0] = leading;
/* UTF-8 multibyte handling */
while (leading >= sum) {
edt->pInputChain->prev->chr[charlen++] = text[i++];
edt->input_chain->prev->chr[charlen++] = text[i++];
sum += addition;
addition /= 2;
}
edt->pInputChain->prev->chr[charlen] = '\0';
edt->pInputChain->prev->bytes = charlen;
edt->input_chain->prev->chr[charlen] = '\0';
edt->input_chain->prev->bytes = charlen;
if (get_wflags(edt->pwidget) & WF_PASSWD_EDIT) {
char passwd_chr[2] = {'*', '\0'};
edt->pInputChain->prev->pTsurf =
edt->input_chain->prev->pTsurf =
TTF_RenderUTF8_Blended(edt->pwidget->string_utf8->font,
passwd_chr,
edt->pwidget->string_utf8->fgcol);
} else {
edt->pInputChain->prev->pTsurf =
edt->input_chain->prev->pTsurf =
TTF_RenderUTF8_Blended(edt->pwidget->string_utf8->font,
edt->pInputChain->prev->chr,
edt->input_chain->prev->chr,
edt->pwidget->string_utf8->fgcol);
}
edt->Truelength += edt->pInputChain->prev->pTsurf->w;
edt->Truelength += edt->input_chain->prev->pTsurf->w;
if (edt->InputChain_X >= edt->pwidget->size.x + edt->pBg->w - adj_size(10)) {
if (edt->pInputChain == edt->end_text_chain) {
if (edt->input_chain == edt->end_text_chain) {
edt->Start_X = edt->pBg->w - adj_size(5) - edt->Truelength;
} else {
edt->Start_X -= edt->pInputChain->prev->pTsurf->w -
edt->Start_X -= edt->input_chain->prev->pTsurf->w -
(edt->pwidget->size.x + edt->pBg->w - adj_size(5) - edt->InputChain_X);
}
}
......
{
struct text_edit edt;
struct Utf8Char ___last;
struct Utf8Char *pInputChain_TMP = NULL;
struct Utf8Char *input_chain_tmp = NULL;
enum edit_return_codes ret;
void *backup = edit_widget->data.ptr;
......
edt.begin_text_chain = text2chain(edit_widget->string_utf8->text);
/* Creating Empty (Last) pice of Chain */
edt.pInputChain = &___last;
edt.end_text_chain = edt.pInputChain;
edt.input_chain = &___last;
edt.end_text_chain = edt.input_chain;
edt.end_text_chain->chr[0] = 32; /* spacebar */
edt.end_text_chain->chr[1] = 0; /* spacebar */
edt.end_text_chain->next = NULL;
......
/* create surface for each font in chain and find chain length */
if (edt.begin_text_chain) {
pInputChain_TMP = edt.begin_text_chain;
input_chain_tmp = edt.begin_text_chain;
while (TRUE) {
edt.ChainLen++;
......
if (get_wflags(edit_widget) & WF_PASSWD_EDIT) {
const char passwd_chr[2] = {'*', '\0'};
pInputChain_TMP->pTsurf =
input_chain_tmp->pTsurf =
TTF_RenderUTF8_Blended(edit_widget->string_utf8->font,
passwd_chr,
edit_widget->string_utf8->fgcol);
} else {
pInputChain_TMP->pTsurf =
input_chain_tmp->pTsurf =
TTF_RenderUTF8_Blended(edit_widget->string_utf8->font,
pInputChain_TMP->chr,
input_chain_tmp->chr,
edit_widget->string_utf8->fgcol);
}
edt.Truelength += pInputChain_TMP->pTsurf->w;
edt.Truelength += input_chain_tmp->pTsurf->w;
if (pInputChain_TMP->next == NULL) {
if (input_chain_tmp->next == NULL) {
break;
}
pInputChain_TMP = pInputChain_TMP->next;
input_chain_tmp = input_chain_tmp->next;
}
/* set terminator of list */
pInputChain_TMP->next = edt.pInputChain;
edt.pInputChain->prev = pInputChain_TMP;
pInputChain_TMP = NULL;
input_chain_tmp->next = edt.input_chain;
edt.input_chain->prev = input_chain_tmp;
input_chain_tmp = NULL;
} else {
edt.begin_text_chain = edt.pInputChain;
edt.begin_text_chain = edt.input_chain;
}
redraw_edit_chain(&edt);
client/gui-sdl2/widget_icon.c
/**********************************************************************//**
Set new theme and callculate new size.
**************************************************************************/
void set_new_icon_theme(struct widget *pIcon_Widget, SDL_Surface *pNew_Theme)
void set_new_icon_theme(struct widget *icon_widget, SDL_Surface *pNew_Theme)
{
if ((pNew_Theme) && (pIcon_Widget)) {
FREESURFACE(pIcon_Widget->theme);
pIcon_Widget->theme = pNew_Theme;
pIcon_Widget->size.w = pNew_Theme->w / 4;
pIcon_Widget->size.h = pNew_Theme->h;
if ((pNew_Theme) && (icon_widget)) {
FREESURFACE(icon_widget->theme);
icon_widget->theme = pNew_Theme;
icon_widget->size.w = pNew_Theme->w / 4;
icon_widget->size.h = pNew_Theme->h;
}
}
......
/**********************************************************************//**
Create ( malloc ) Icon Widget ( flat Button )
**************************************************************************/
struct widget *create_themeicon(SDL_Surface *pIcon_theme,
struct widget *create_themeicon(SDL_Surface *icon_theme,
struct gui_layer *pdest,
Uint32 flags)
{
struct widget *pIcon_Widget = widget_new();
struct widget *icon_widget = widget_new();
pIcon_Widget->theme = pIcon_theme;
icon_widget->theme = icon_theme;
set_wflag(pIcon_Widget, (WF_FREE_STRING | WF_FREE_GFX | flags));
set_wstate(pIcon_Widget, FC_WS_DISABLED);
set_wtype(pIcon_Widget, WT_ICON);
pIcon_Widget->mod = KMOD_NONE;
pIcon_Widget->dst = pdest;
set_wflag(icon_widget, (WF_FREE_STRING | WF_FREE_GFX | flags));
set_wstate(icon_widget, FC_WS_DISABLED);
set_wtype(icon_widget, WT_ICON);
icon_widget->mod = KMOD_NONE;
icon_widget->dst = pdest;
baseclass_redraw = pIcon_Widget->redraw;
pIcon_Widget->redraw = redraw_icon;
baseclass_redraw = icon_widget->redraw;
icon_widget->redraw = redraw_icon;
if (pIcon_theme) {
pIcon_Widget->size.w = pIcon_theme->w / 4;
pIcon_Widget->size.h = pIcon_theme->h;
if (icon_theme) {
icon_widget->size.w = icon_theme->w / 4;
icon_widget->size.h = icon_theme->h;
}
return pIcon_Widget;
return icon_widget;
}
/**********************************************************************//**
......
Blit Icon image to pdest(ination) on position
start_x, start_y. WARNING: pdest must exist.
Graphic is taken from pIcon_theme surface.
Graphic is taken from icon_theme surface.
Type of Icon depend of "state" parameter.
state = 0 - normal
......
state = 2 - pressed
state = 3 - disabled
Function return: -3 if pIcon_theme is NULL.
Function return: -3 if icon_theme is NULL.
std return of alphablit(...) function.
**************************************************************************/
int draw_icon_from_theme(SDL_Surface *pIcon_theme, Uint8 state,
int draw_icon_from_theme(SDL_Surface *icon_theme, Uint8 state,
struct gui_layer *pdest, Sint16 start_x, Sint16 start_y)
{
SDL_Rect src, des = {start_x, start_y, 0, 0};
if (!pIcon_theme) {
if (!icon_theme) {
return -3;
}
src.x = 0 + (pIcon_theme->w / 4) * state;
src.x = 0 + (icon_theme->w / 4) * state;
src.y = 0;
src.w = pIcon_theme->w / 4;
src.h = pIcon_theme->h;
src.w = icon_theme->w / 4;
src.h = icon_theme->h;
return alphablit(pIcon_theme, &src, pdest->surface, &des, 255);
return alphablit(icon_theme, &src, pdest->surface, &des, 255);
}
/**********************************************************************//**
Create Icon image then return pointer to this image.
Graphic is take from pIcon_theme surface and blit to new created image.
Graphic is take from icon_theme surface and blit to new created image.
Type of Icon depend of "state" parameter.
state = 0 - normal
......
state = 2 - pressed
state = 3 - disabled
Function return NULL if pIcon_theme is NULL or blit fail.
Function return NULL if icon_theme is NULL or blit fail.
**************************************************************************/
SDL_Surface *create_icon_from_theme(SDL_Surface *pIcon_theme, Uint8 state)
SDL_Surface *create_icon_from_theme(SDL_Surface *icon_theme, Uint8 state)
{
SDL_Rect src;
if (!pIcon_theme) {
if (!icon_theme) {
return NULL;
}
src.w = pIcon_theme->w / 4;
src.w = icon_theme->w / 4;
src.x = src.w * state;
src.y = 0;
src.h = pIcon_theme->h;
src.h = icon_theme->h;
return crop_rect_from_surface(pIcon_theme, &src);
return crop_rect_from_surface(icon_theme, &src);
}
/* =================================================== */
......
/**********************************************************************//**
Set new theme and calculate new size.
**************************************************************************/
void set_new_icon2_theme(struct widget *pIcon_Widget, SDL_Surface *pNew_Theme,
void set_new_icon2_theme(struct widget *icon_widget, SDL_Surface *pNew_Theme,
bool free_old_theme)
{
if ((pNew_Theme) && (pIcon_Widget)) {
if ((pNew_Theme) && (icon_widget)) {
if (free_old_theme) {
FREESURFACE(pIcon_Widget->theme);
FREESURFACE(icon_widget->theme);
}
pIcon_Widget->theme = pNew_Theme;
pIcon_Widget->size.w = pNew_Theme->w + adj_size(4);
pIcon_Widget->size.h = pNew_Theme->h + adj_size(4);
icon_widget->theme = pNew_Theme;
icon_widget->size.w = pNew_Theme->w + adj_size(4);
icon_widget->size.h = pNew_Theme->h + adj_size(4);
}
}
......
struct widget *create_icon2(SDL_Surface *icon, struct gui_layer *pdest,
Uint32 flags)
{
struct widget *pIcon_Widget = widget_new();
struct widget *icon_widget = widget_new();
pIcon_Widget->theme = icon;
icon_widget->theme = icon;
set_wflag(pIcon_Widget, (WF_FREE_STRING | WF_FREE_GFX | flags));
set_wstate(pIcon_Widget, FC_WS_DISABLED);
set_wtype(pIcon_Widget, WT_ICON2);
pIcon_Widget->mod = KMOD_NONE;
pIcon_Widget->dst = pdest;
set_wflag(icon_widget, (WF_FREE_STRING | WF_FREE_GFX | flags));
set_wstate(icon_widget, FC_WS_DISABLED);
set_wtype(icon_widget, WT_ICON2);
icon_widget->mod = KMOD_NONE;
icon_widget->dst = pdest;
baseclass_redraw = pIcon_Widget->redraw;
pIcon_Widget->redraw = redraw_icon2;
baseclass_redraw = icon_widget->redraw;
icon_widget->redraw = redraw_icon2;
if (icon) {
pIcon_Widget->size.w = icon->w + adj_size(4);
pIcon_Widget->size.h = icon->h + adj_size(4);
icon_widget->size.w = icon->w + adj_size(4);
icon_widget->size.h = icon->h + adj_size(4);
}
return pIcon_Widget;
return icon_widget;
}
client/gui-sdl2/widget_icon.h
#define FC__WIDGET_ICON_H
/* ICON */
void set_new_icon_theme(struct widget *pIcon_Widget,
void set_new_icon_theme(struct widget *icon_widget,
SDL_Surface *pNew_Theme);
SDL_Surface *create_icon_theme_surf(SDL_Surface *icon);
struct widget *create_themeicon(SDL_Surface *pIcon_theme,
struct widget *create_themeicon(SDL_Surface *icon_theme,
struct gui_layer *pdest, Uint32 flags);
SDL_Surface *create_icon_from_theme(SDL_Surface *pIcon_theme,
SDL_Surface *create_icon_from_theme(SDL_Surface *icon_theme,
Uint8 state);
int draw_icon_from_theme(SDL_Surface *pIcon_theme, Uint8 state,
int draw_icon_from_theme(SDL_Surface *icon_theme, Uint8 state,
struct gui_layer *pdest, Sint16 start_x,
Sint16 start_y);
int draw_icon(struct widget *icon, Sint16 start_x, Sint16 start_y);
/* ICON2 */
void set_new_icon2_theme(struct widget *pIcon_Widget, SDL_Surface *pNew_Theme,
void set_new_icon2_theme(struct widget *icon_widget, SDL_Surface *pNew_Theme,
bool free_old_theme);
struct widget *create_icon2(SDL_Surface *icon, struct gui_layer *pdest,
Uint32 flags);
client/gui-sdl2/widget_label.c
pLabel->theme = icon;
pLabel->string_utf8 = pstr;
set_wflag(pLabel,
(WF_ICON_CENTER | WF_FREE_STRING | WF_FREE_GFX |
WF_RESTORE_BACKGROUND | flags));
(WF_ICON_CENTER | WF_FREE_STRING | WF_FREE_GFX |
WF_RESTORE_BACKGROUND | flags));
set_wstate(pLabel, FC_WS_DISABLED);
set_wtype(pLabel, WT_T_LABEL);
pLabel->mod = KMOD_NONE;
......
struct widget *create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest,
utf8_str *pstr, Uint32 flags)
{
struct widget *pILabel = NULL;
struct widget *icon_label = NULL;
pILabel = widget_new();
icon_label = widget_new();
pILabel->theme = icon;
pILabel->string_utf8 = pstr;
set_wflag(pILabel, WF_FREE_STRING | WF_FREE_GFX | flags);
set_wstate(pILabel, FC_WS_DISABLED);
set_wtype(pILabel, WT_I_LABEL);
pILabel->mod = KMOD_NONE;
pILabel->dst = pdest;
icon_label->theme = icon;
icon_label->string_utf8 = pstr;
set_wflag(icon_label, WF_FREE_STRING | WF_FREE_GFX | flags);
set_wstate(icon_label, FC_WS_DISABLED);
set_wtype(icon_label, WT_I_LABEL);
icon_label->mod = KMOD_NONE;
icon_label->dst = pdest;
baseclass_redraw = pILabel->redraw;
pILabel->redraw = redraw_label;
baseclass_redraw = icon_label->redraw;
icon_label->redraw = redraw_label;
remake_label_size(pILabel);
remake_label_size(icon_label);
return pILabel;
return icon_label;
}
/**********************************************************************//**
......
/**********************************************************************//**
Make themeiconlabel2 widget out of iconlabel widget.
**************************************************************************/
struct widget *convert_iconlabel_to_themeiconlabel2(struct widget *pIconLabel)
struct widget *convert_iconlabel_to_themeiconlabel2(struct widget *icon_label)
{
SDL_Rect start, area;
SDL_Color store = {0, 0, 0, 0};
SDL_Color bg_color = *get_theme_color(COLOR_THEME_THEMELABEL2_BG);
Uint32 colorkey, flags = get_wflags(pIconLabel);
Uint32 colorkey, flags = get_wflags(icon_label);
SDL_Surface *pdest;
SDL_Surface *ptheme = create_surf(pIconLabel->size.w,
pIconLabel->size.h * 2, SDL_SWSURFACE);
SDL_Surface *ptheme = create_surf(icon_label->size.w,
icon_label->size.h * 2, SDL_SWSURFACE);
colorkey = SDL_MapRGBA(ptheme->format,
pIconLabel->string_utf8->bgcol.r,
pIconLabel->string_utf8->bgcol.g,
pIconLabel->string_utf8->bgcol.b,
pIconLabel->string_utf8->bgcol.a);
icon_label->string_utf8->bgcol.r,
icon_label->string_utf8->bgcol.g,
icon_label->string_utf8->bgcol.b,
icon_label->string_utf8->bgcol.a);
SDL_FillRect(ptheme, NULL, colorkey);
start = pIconLabel->size;
pIconLabel->size.x = 0;
pIconLabel->size.y = 0;
start = icon_label->size;
icon_label->size.x = 0;
icon_label->size.y = 0;
area = start;
pdest = pIconLabel->dst->surface;
pIconLabel->dst->surface = ptheme;
pdest = icon_label->dst->surface;
icon_label->dst->surface = ptheme;
/* normal */
redraw_iconlabel(pIconLabel);
redraw_iconlabel(icon_label);
/* selected */
area.x = 0;
area.y = pIconLabel->size.h;
area.y = icon_label->size.h;
if (flags & WF_RESTORE_BACKGROUND) {
SDL_FillRect(ptheme, &area, map_rgba(ptheme->format, bg_color));
store = pIconLabel->string_utf8->bgcol;
store = icon_label->string_utf8->bgcol;
SDL_GetRGBA(getpixel(ptheme, area.x , area.y), ptheme->format,
&pIconLabel->string_utf8->bgcol.r,
&pIconLabel->string_utf8->bgcol.g,
&pIconLabel->string_utf8->bgcol.b,
&pIconLabel->string_utf8->bgcol.a);
&icon_label->string_utf8->bgcol.r,
&icon_label->string_utf8->bgcol.g,
&icon_label->string_utf8->bgcol.b,
&icon_label->string_utf8->bgcol.a);
} else {
fill_rect_alpha(ptheme, &area, &bg_color);
}
pIconLabel->size.y = pIconLabel->size.h;
redraw_iconlabel(pIconLabel);
icon_label->size.y = icon_label->size.h;
redraw_iconlabel(icon_label);
if (flags & WF_RESTORE_BACKGROUND) {
pIconLabel->string_utf8->bgcol = store;
icon_label->string_utf8->bgcol = store;
}
pIconLabel->size = start;
icon_label->size = start;
if (flags & WF_FREE_THEME) {
FREESURFACE(pIconLabel->theme);
FREESURFACE(icon_label->theme);
}
pIconLabel->theme = ptheme;
icon_label->theme = ptheme;
if (flags & WF_FREE_STRING) {
FREEUTF8STR(pIconLabel->string_utf8);
FREEUTF8STR(icon_label->string_utf8);
}
pIconLabel->dst->surface = pdest;
set_wtype(pIconLabel, WT_T2_LABEL);
icon_label->dst->surface = pdest;
set_wtype(icon_label, WT_T2_LABEL);
pIconLabel->redraw = redraw_label;
icon_label->redraw = redraw_label;
return pIconLabel;
return icon_label;
}
#if 0
client/gui-sdl2/widget_label.h
utf8_str *pstr, Uint16 w, Uint16 h, Uint32 flags);
struct widget *create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest,
utf8_str *text, Uint32 flags);
struct widget *convert_iconlabel_to_themeiconlabel2(struct widget *pIconLabel);
struct widget *convert_iconlabel_to_themeiconlabel2(struct widget *icon_label);
int draw_label(struct widget *pLabel, Sint16 start_x, Sint16 start_y);
int redraw_iconlabel(struct widget *pLabel);
client/gui-sdl2/wldlg.c
remove currently building imprv/unit and change production to first worklist
element (or Capitalizations if worklist is empty)
**************************************************************************/
static void remove_item_from_worklist(struct widget *pItem)
static void remove_item_from_worklist(struct widget *item)
{
/* only one item (production) is left */
if (worklist_is_empty(&editor->worklist_copy)) {
return;
}
if (pItem->data.ptr) {
if (item->data.ptr) {
/* correct "data" widget fiels */
struct widget *buf = pItem;
struct widget *buf = item;
if (buf != editor->pWork->begin_active_widget_list) {
do {
......
}
/* remove element from worklist */
worklist_remove(&editor->worklist_copy, *((int *)pItem->data.ptr));
worklist_remove(&editor->worklist_copy, *((int *)item->data.ptr));
/* remove widget from widget list */
del_widget_from_vertical_scroll_widget_list(editor->pWork, pItem);
del_widget_from_vertical_scroll_widget_list(editor->pWork, item);
} else {
/* change productions to first worklist element */
struct widget *buf = pItem->prev;
struct widget *buf = item->prev;
change_production(&editor->worklist_copy.entries[0]);
worklist_advance(&editor->worklist_copy);
del_widget_from_vertical_scroll_widget_list(editor->pWork, pItem);
del_widget_from_vertical_scroll_widget_list(editor->pWork, item);
FC_FREE(buf->data.ptr);
if (buf != editor->pWork->begin_active_widget_list) {
do {
......
Swap worklist entries DOWN.
Fuction swap current element with next element of worklist.
If pItem is last widget or there is only one widget on widgets list
If item is last widget or there is only one widget on widgets list
fuction remove this widget from widget list and target from worklist
In City mode, when pItem is first worklist element, function make
In City mode, when item is first worklist element, function make
change production (currently building is moved to first element of worklist
and first element of worklist is build).
**************************************************************************/
static void swap_item_down_from_worklist(struct widget *pItem)
static void swap_item_down_from_worklist(struct widget *item)
{
char *text;
Uint16 id;
bool changed = FALSE;
struct universal tmp;
if (pItem == editor->pWork->begin_active_widget_list) {
remove_item_from_worklist(pItem);
if (item == editor->pWork->begin_active_widget_list) {
remove_item_from_worklist(item);
return;
}
text = pItem->string_utf8->text;
id = pItem->id;
text = item->string_utf8->text;
id = item->id;
/* second item or higher was clicked */
if (pItem->data.ptr) {
if (item->data.ptr) {
/* worklist operations -> swap down */
int row = *((int *)pItem->data.ptr);
int row = *((int *)item->data.ptr);
tmp = editor->worklist_copy.entries[row];
editor->worklist_copy.entries[row] = editor->worklist_copy.entries[row + 1];
......
}
if (changed) {
pItem->string_utf8->text = pItem->prev->string_utf8->text;
pItem->id = pItem->prev->id;
item->string_utf8->text = item->prev->string_utf8->text;
item->id = item->prev->id;
pItem->prev->string_utf8->text = text;
pItem->prev->id = id;
item->prev->string_utf8->text = text;
item->prev->id = id;
redraw_group(editor->pWork->begin_widget_list,
editor->pWork->end_widget_list, TRUE);
......
Swap worklist entries UP.
Fuction swap current element with prev. element of worklist.
If pItem is first widget on widgets list fuction remove this widget
If item is first widget on widgets list fuction remove this widget
from widget list and target from worklist (global mode)
or from production (city mode)
In City mode, when pItem is first worklist element, function make
In City mode, when item is first worklist element, function make
change production (currently building is moved to first element of worklist
and first element of worklist is build).
**************************************************************************/
static void swap_item_up_from_worklist(struct widget *pItem)
static void swap_item_up_from_worklist(struct widget *item)
{
char *text = pItem->string_utf8->text;
Uint16 id = pItem->id;
char *text = item->string_utf8->text;
Uint16 id = item->id;
bool changed = FALSE;
struct universal tmp;
/* first item was clicked -> remove */
if (pItem == editor->pWork->end_active_widget_list) {
remove_item_from_worklist(pItem);
if (item == editor->pWork->end_active_widget_list) {
remove_item_from_worklist(item);
return;
}
/* third item or higher was clicked */
if (pItem->data.ptr && *((int *)pItem->data.ptr) > 0) {
if (item->data.ptr && *((int *)item->data.ptr) > 0) {
/* worklist operations -> swap up */
int row = *((int *)pItem->data.ptr);
int row = *((int *)item->data.ptr);
tmp = editor->worklist_copy.entries[row];
editor->worklist_copy.entries[row] = editor->worklist_copy.entries[row - 1];
......
}
if (changed) {
pItem->string_utf8->text = pItem->next->string_utf8->text;
pItem->id = pItem->next->id;
item->string_utf8->text = item->next->string_utf8->text;
item->id = item->next->id;
pItem->next->string_utf8->text = text;
pItem->next->id = id;
item->next->string_utf8->text = text;
item->next->id = id;
redraw_group(editor->pWork->begin_widget_list,
editor->pWork->end_widget_list, TRUE);
    (1-1/1)