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 #892728 ยป 0036-sdl2-Rename-pPlayer-as-pplayer.patch

Marko Lindqvist, 2020-10-25 01:26 PM

View differences:

client/gui-sdl2/diplodlg.c
/**********************************************************************//**
Create treaty widgets. Pact (that will always be both ways) related
widgets are created only when pPlayer0 is client user.
widgets are created only when pplayer0 is client user.
**************************************************************************/
static struct ADVANCED_DLG *popup_diplomatic_objects(struct player *pPlayer0,
struct player *pPlayer1,
static struct ADVANCED_DLG *popup_diplomatic_objects(struct player *pplayer0,
struct player *pplayer1,
struct widget *pMainWindow,
bool L_R)
{
......
int window_x = 0, window_y = 0;
SDL_Rect area;
enum diplstate_type type
= player_diplstate_get(pPlayer0, pPlayer1)->type;
= player_diplstate_get(pplayer0, pplayer1)->type;
pCont->id0 = player_number(pPlayer0);
pCont->id1 = player_number(pPlayer1);
pCont->id0 = player_number(pplayer0);
pCont->id1 = player_number(pplayer1);
pstr = create_utf8_from_char(nation_adjective_for_player(pPlayer0), adj_font(12));
pstr = create_utf8_from_char(nation_adjective_for_player(pplayer0), adj_font(12));
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, WF_FREE_DATA);
......
height = 0;
/* Pacts. */
if (pPlayer0 == client.conn.playing && DS_ALLIANCE != type) {
if (pplayer0 == client.conn.playing && DS_ALLIANCE != type) {
pBuf = create_iconlabel_from_chars(NULL, pwindow->dst,
_("Pacts"), adj_font(12), WF_RESTORE_BACKGROUND);
pBuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_MEETING_HEADING_TEXT);
......
count++;
}
if (pplayer_can_make_treaty(pPlayer0, pPlayer1, DS_ALLIANCE)) {
if (pplayer_can_make_treaty(pplayer0, pplayer1, DS_ALLIANCE)) {
fc_snprintf(cBuf, sizeof(cBuf), " %s", Q_("?diplomatic_state:Alliance"));
pBuf = create_iconlabel_from_chars(NULL, pwindow->dst,
......
}
/* ---------------------------- */
if (!gives_shared_vision(pPlayer0, pPlayer1)) {
if (!gives_shared_vision(pplayer0, pplayer1)) {
pBuf = create_iconlabel_from_chars(NULL, pwindow->dst,
_("Give shared vision"), adj_font(12),
(WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
......
}
/* Don't take in account the embassy effects. */
if (!player_has_real_embassy(pPlayer1, pPlayer0)) {
if (!player_has_real_embassy(pplayer1, pplayer0)) {
pBuf = create_iconlabel_from_chars(NULL, pwindow->dst,
_("Give embassy"), adj_font(12),
(WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
......
}
/* ---------------------------- */
if (game.info.trading_gold && pPlayer0->economic.gold > 0) {
pCont->value = pPlayer0->economic.gold;
if (game.info.trading_gold && pplayer0->economic.gold > 0) {
pCont->value = pplayer0->economic.gold;
fc_snprintf(cBuf, sizeof(cBuf), _("Gold(max %d)"), pPlayer0->economic.gold);
fc_snprintf(cBuf, sizeof(cBuf), _("Gold(max %d)"), pplayer0->economic.gold);
pBuf = create_iconlabel_from_chars(NULL, pwindow->dst,
cBuf, adj_font(12), WF_RESTORE_BACKGROUND);
pBuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_MEETING_HEADING_TEXT);
......
/* Trading: advances */
if (game.info.trading_tech) {
const struct research *presearch0 = research_get(pPlayer0);
const struct research *presearch1 = research_get(pPlayer1);
const struct research *presearch0 = research_get(pplayer0);
const struct research *presearch1 = research_get(pplayer1);
int flag = A_NONE;
advance_index_iterate(A_FIRST, i) {
......
/* Trading: cities */
/****************************************************************
Creates a sorted list of pPlayer0's cities, excluding the capital and
any cities not visible to pPlayer1. This means that you can only trade
Creates a sorted list of pplayer0's cities, excluding the capital and
any cities not visible to pplayer1. This means that you can only trade
cities visible to requesting player.
- Kris Bubendorfer
*****************************************************************/
if (game.info.trading_city) {
int i = 0, j = 0, n = city_list_size(pPlayer0->cities);
int i = 0, j = 0, n = city_list_size(pplayer0->cities);
struct city **city_list_ptrs;
if (n > 0) {
city_list_ptrs = fc_calloc(1, sizeof(struct city *) * n);
city_list_iterate(pPlayer0->cities, pCity) {
city_list_iterate(pplayer0->cities, pCity) {
if (!is_capital(pCity)) {
city_list_ptrs[i] = pCity;
i++;
......
static void update_diplomacy_dialog(struct diplomacy_dialog *pdialog)
{
SDL_Color bg_color = {255, 255, 255, 136};
struct player *pPlayer0, *pPlayer1;
struct player *pplayer0, *pplayer1;
struct CONTAINER *pCont = fc_calloc(1, sizeof(struct CONTAINER));
char cBuf[128];
struct widget *pBuf = NULL, *pwindow;
......
pdialog->pdialog->pEndWidgetList);
}
pPlayer0 = pdialog->treaty.plr0;
pPlayer1 = pdialog->treaty.plr1;
pplayer0 = pdialog->treaty.plr0;
pplayer1 = pdialog->treaty.plr1;
pCont->id0 = player_number(pPlayer0);
pCont->id1 = player_number(pPlayer1);
pCont->id0 = player_number(pplayer0);
pCont->id1 = player_number(pplayer1);
fc_snprintf(cBuf, sizeof(cBuf), _("Diplomacy meeting"));
......
/* ============================================================= */
pstr = create_utf8_from_char(nation_adjective_for_player(pPlayer0), adj_font(12));
pstr = create_utf8_from_char(nation_adjective_for_player(pplayer0), adj_font(12));
pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pstr->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_MEETING_TEXT);
......
add_to_gui_list(ID_ICON, pBuf);
pstr = create_utf8_from_char(nation_adjective_for_player(pPlayer1), adj_font(12));
pstr = create_utf8_from_char(nation_adjective_for_player(pplayer1), adj_font(12));
pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pstr->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_MEETING_TEXT);
......
dst.y,
dst.h, TRUE);
/* ============================================================= */
pdialog->poffers = popup_diplomatic_objects(pPlayer0, pPlayer1, pwindow, FALSE);
pdialog->poffers = popup_diplomatic_objects(pplayer0, pplayer1, pwindow, FALSE);
pdialog->pwants = popup_diplomatic_objects(pPlayer1, pPlayer0, pwindow, TRUE);
pdialog->pwants = popup_diplomatic_objects(pplayer1, pplayer0, pwindow, TRUE);
/* ============================================================= */
/* redraw */
redraw_group(pdialog->pdialog->pBeginWidgetList, pwindow, 0);
......
}
/**********************************************************************//**
Open war declaring dialog after some incident caused by pPlayer.
Open war declaring dialog after some incident caused by pplayer.
**************************************************************************/
static void popup_war_dialog(struct player *pPlayer)
static void popup_war_dialog(struct player *pplayer)
{
char cBuf[128];
struct widget *pBuf = NULL, *pwindow;
......
fc_snprintf(cBuf, sizeof(cBuf),
/* TRANS: "Polish incident !" FIXME!!! */
_("%s incident !"),
nation_adjective_for_player(pPlayer));
nation_adjective_for_player(pplayer));
pstr = create_utf8_from_char(cBuf, adj_font(12));
pstr->style |= TTF_STYLE_BOLD;
......
pBuf->action = cancel_pact_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->data.player = pPlayer;
pBuf->data.player = pplayer;
pBuf->key = SDLK_RETURN;
add_to_gui_list(ID_BUTTON, pBuf);
pBuf->size.w = MAX(pBuf->next->size.w, pBuf->size.w);
......
/**********************************************************************//**
Open diplomacy dialog between client user and given player.
**************************************************************************/
void popup_diplomacy_dialog(struct player *pPlayer)
void popup_diplomacy_dialog(struct player *pplayer)
{
enum diplstate_type type =
player_diplstate_get(client.conn.playing, pPlayer)->type;
player_diplstate_get(client.conn.playing, pplayer)->type;
if (!can_meet_with_player(pPlayer)) {
if (DS_WAR == type || pPlayer == client.conn.playing) {
if (!can_meet_with_player(pplayer)) {
if (DS_WAR == type || pplayer == client.conn.playing) {
flush_dirty();
return;
} else {
popup_war_dialog(pPlayer);
popup_war_dialog(pplayer);
return;
}
......
if (client.conn.playing == NULL || client.conn.playing->is_male) {
fc_snprintf(cBuf, sizeof(cBuf), _("Sir!, the %s ambassador has arrived\n"
"What are your wishes?"),
nation_adjective_for_player(pPlayer));
nation_adjective_for_player(pplayer));
} else {
fc_snprintf(cBuf, sizeof(cBuf), _("Ma'am!, the %s ambassador has arrived\n"
"What are your wishes?"),
nation_adjective_for_player(pPlayer));
nation_adjective_for_player(pplayer));
}
pstr = create_utf8_from_char(cBuf, adj_font(14));
......
area.h += pText->h + adj_size(15);
can_toward_war = can_client_issue_orders()
&& pplayer_can_cancel_treaty(client_player(), pPlayer) == DIPL_OK;
&& pplayer_can_cancel_treaty(client_player(), pplayer) == DIPL_OK;
if (can_toward_war) {
if (type == DS_ARMISTICE) {
......
pBuf->action = cancel_pact_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_MEETING_TEXT);
pBuf->data.player = pPlayer;
pBuf->data.player = pplayer;
pBuf->key = SDLK_c;
add_to_gui_list(ID_BUTTON, pBuf);
pBuf->size.w = MAX(pBuf->next->size.w, pBuf->size.w);
......
buttons++;
}
shared = gives_shared_vision(client.conn.playing, pPlayer);
shared = gives_shared_vision(client.conn.playing, pplayer);
if (shared) {
/* shared vision */
......
pBuf->action = withdraw_vision_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->data.player = pPlayer;
pBuf->data.player = pplayer;
pBuf->key = SDLK_w;
pBuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_MEETING_TEXT);
add_to_gui_list(ID_BUTTON, pBuf);
......
pBuf->action = call_meeting_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->data.player = pPlayer;
pBuf->data.player = pplayer;
pBuf->key = SDLK_m;
pBuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_DIPLODLG_MEETING_TEXT);
add_to_gui_list(ID_BUTTON, pBuf);
client/gui-sdl2/diplodlg.h
/**********************************************************************
/***********************************************************************
Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
void diplomacy_dialog_init(void);
void diplomacy_dialog_done(void);
void popup_diplomacy_dialog(struct player *pPlayer);
void popup_diplomacy_dialog(struct player *pplayer);
#endif /* FC__DIPLODLG_H */
client/gui-sdl2/finddlg.c
add_to_gui_list(ID_TERRAIN_ADV_DLG_EXIT_BUTTON, pBuf);
/* ---------- */
players_iterate(pPlayer) {
city_list_iterate(pPlayer->cities, pCity) {
players_iterate(pplayer) {
city_list_iterate(pplayer->cities, pCity) {
fc_snprintf(cBuf , sizeof(cBuf), "%s (%d)", city_name_get(pCity),
city_size_get(pCity));
client/gui-sdl2/gotodlg.c
pLast = pAdd_Dock;
players_iterate(pPlayer) {
if (!BV_ISSET(all_players, player_index(pPlayer))) {
players_iterate(pplayer) {
if (!BV_ISSET(all_players, player_index(pplayer))) {
continue;
}
city_list_iterate(pPlayer->cities, pCity) {
city_list_iterate(pplayer->cities, pCity) {
/* FIXME: should use unit_can_airlift_to(). */
if (!GOTO && !pCity->airlift) {
......
col = 0;
/* --------------------------------------------- */
players_iterate(pPlayer) {
if (pPlayer != client.conn.playing
&& DS_NO_CONTACT == player_diplstate_get(client.conn.playing, pPlayer)->type) {
players_iterate(pplayer) {
if (pplayer != client.conn.playing
&& DS_NO_CONTACT == player_diplstate_get(client.conn.playing, pplayer)->type) {
continue;
}
pFlag = ResizeSurfaceBox(get_nation_flag_surface(pPlayer->nation),
pFlag = ResizeSurfaceBox(get_nation_flag_surface(pplayer->nation),
adj_size(30), adj_size(30), 1, TRUE, FALSE);
pEnabled = create_icon_theme_surf(pFlag);
......
FREESURFACE(pFlag);
pBuf = create_checkbox(pwindow->dst,
BV_ISSET(all_players, player_index(pPlayer)),
BV_ISSET(all_players, player_index(pplayer)),
WF_FREE_THEME | WF_RESTORE_BACKGROUND
| WF_WIDGET_HAS_INFO_LABEL);
set_new_checkbox_theme(pBuf, pEnabled, pDisabled);
pBuf->info_label =
create_utf8_from_char(nation_adjective_for_player(pPlayer),
adj_font(12));
create_utf8_from_char(nation_adjective_for_player(pplayer),
adj_font(12));
pBuf->info_label->style &= ~SF_CENTER;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = toggle_goto_nations_cities_dialog_callback;
add_to_gui_list(MAX_ID - player_number(pPlayer), pBuf);
add_to_gui_list(MAX_ID - player_number(pplayer), pBuf);
col++;
} players_iterate_end;
client/gui-sdl2/inteldlg.c
static int spaceship_callback(struct widget *pWidget)
{
if (PRESSED_EVENT(Main.event)) {
struct player *pPlayer = pWidget->data.player;
struct player *pplayer = pWidget->data.player;
popdown_intel_dialog(pPlayer);
popup_spaceship_dialog(pPlayer);
popdown_intel_dialog(pplayer);
popup_spaceship_dialog(pplayer);
}
return -1;
......
/**********************************************************************//**
Create an intelligence dialog towards given player.
**************************************************************************/
static struct intel_dialog *create_intel_dialog(struct player *pPlayer)
static struct intel_dialog *create_intel_dialog(struct player *pplayer)
{
struct intel_dialog *pdialog = fc_calloc(1, sizeof(struct intel_dialog));
pdialog->pplayer = pPlayer;
pdialog->pplayer = pplayer;
pdialog->pdialog = fc_calloc(1, sizeof(struct ADVANCED_DLG));
client/gui-sdl2/plrdlg.c
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#endif
static struct SMALL_DLG *pPlayers_Dlg = NULL;
static struct SMALL_DLG *pplayers_dlg = NULL;
/**********************************************************************//**
User interacted with player dialog close button.
......
**************************************************************************/
static int player_callback(struct widget *pWidget)
{
struct player *pPlayer = pWidget->data.player;
struct player *pplayer = pWidget->data.player;
if (Main.event.type == SDL_MOUSEBUTTONDOWN) {
switch (Main.event.button.button) {
......
break;
#endif /* 0 */
case SDL_BUTTON_RIGHT:
if (can_intel_with_player(pPlayer)) {
if (can_intel_with_player(pplayer)) {
popdown_players_dialog();
popup_intel_dialog(pPlayer);
popup_intel_dialog(pplayer);
return -1;
}
break;
default:
popdown_players_dialog();
popup_diplomacy_dialog(pPlayer);
popup_diplomacy_dialog(pplayer);
return -1;
break;
}
} else if (PRESSED_EVENT(Main.event)) {
popdown_players_dialog();
popup_diplomacy_dialog(pPlayer);
popup_diplomacy_dialog(pplayer);
}
return -1;
......
static int players_window_dlg_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(Main.event)) {
if (move_window_group_dialog(pPlayers_Dlg->pBeginWidgetList, pwindow)) {
select_window_group_dialog(pPlayers_Dlg->pBeginWidgetList, pwindow);
if (move_window_group_dialog(pplayers_dlg->pBeginWidgetList, pwindow)) {
select_window_group_dialog(pplayers_dlg->pBeginWidgetList, pwindow);
players_dialog_update();
} else {
if (select_window_group_dialog(pPlayers_Dlg->pBeginWidgetList, pwindow)) {
if (select_window_group_dialog(pplayers_dlg->pBeginWidgetList, pwindow)) {
widget_flush(pwindow);
}
}
......
{
if (PRESSED_EVENT(Main.event)) {
/* exit button -> neutral -> war -> casefire -> peace -> alliance */
struct widget *pPlayer = pPlayers_Dlg->pEndWidgetList->prev->prev->prev->prev->prev->prev;
struct widget *pplayer = pplayers_dlg->pEndWidgetList->prev->prev->prev->prev->prev->prev;
SDL_Client_Flags ^= CF_DRAW_PLAYERS_WAR_STATUS;
do {
pPlayer = pPlayer->prev;
FREESURFACE(pPlayer->gfx);
} while (pPlayer != pPlayers_Dlg->pBeginWidgetList);
pplayer = pplayer->prev;
FREESURFACE(pplayer->gfx);
} while (pplayer != pplayers_dlg->pBeginWidgetList);
players_dialog_update();
}
......
{
if (PRESSED_EVENT(Main.event)) {
/* exit button -> neutral -> war -> casefire -> peace -> alliance */
struct widget *pPlayer = pPlayers_Dlg->pEndWidgetList->prev->prev->prev->prev->prev->prev;
struct widget *pplayer = pplayers_dlg->pEndWidgetList->prev->prev->prev->prev->prev->prev;
SDL_Client_Flags ^= CF_DRAW_PLAYERS_CEASEFIRE_STATUS;
do {
pPlayer = pPlayer->prev;
FREESURFACE(pPlayer->gfx);
} while (pPlayer != pPlayers_Dlg->pBeginWidgetList);
pplayer = pplayer->prev;
FREESURFACE(pplayer->gfx);
} while (pplayer != pplayers_dlg->pBeginWidgetList);
players_dialog_update();
}
......
{
if (PRESSED_EVENT(Main.event)) {
/* exit button -> neutral -> war -> casefire -> peace -> alliance */
struct widget *pPlayer = pPlayers_Dlg->pEndWidgetList->prev->prev->prev->prev->prev->prev;
struct widget *pplayer = pplayers_dlg->pEndWidgetList->prev->prev->prev->prev->prev->prev;
SDL_Client_Flags ^= CF_DRAW_PLAYERS_PEACE_STATUS;
do {
pPlayer = pPlayer->prev;
FREESURFACE(pPlayer->gfx);
} while (pPlayer != pPlayers_Dlg->pBeginWidgetList);
pplayer = pplayer->prev;
FREESURFACE(pplayer->gfx);
} while (pplayer != pplayers_dlg->pBeginWidgetList);
players_dialog_update();
}
......
{
if (PRESSED_EVENT(Main.event)) {
/* exit button -> neutral -> war -> casefire -> peace -> alliance */
struct widget *pPlayer = pPlayers_Dlg->pEndWidgetList->prev->prev->prev->prev->prev->prev;
struct widget *pplayer = pplayers_dlg->pEndWidgetList->prev->prev->prev->prev->prev->prev;
SDL_Client_Flags ^= CF_DRAW_PLAYERS_ALLIANCE_STATUS;
do {
pPlayer = pPlayer->prev;
FREESURFACE(pPlayer->gfx);
} while (pPlayer != pPlayers_Dlg->pBeginWidgetList);
pplayer = pplayer->prev;
FREESURFACE(pplayer->gfx);
} while (pplayer != pplayers_dlg->pBeginWidgetList);
players_dialog_update();
}
......
{
if (PRESSED_EVENT(Main.event)) {
/* exit button -> neutral -> war -> casefire -> peace -> alliance */
struct widget *pPlayer = pPlayers_Dlg->pEndWidgetList->prev->prev->prev->prev->prev->prev;
struct widget *pplayer = pplayers_dlg->pEndWidgetList->prev->prev->prev->prev->prev->prev;
SDL_Client_Flags ^= CF_DRAW_PLAYERS_NEUTRAL_STATUS;
do {
pPlayer = pPlayer->prev;
FREESURFACE(pPlayer->gfx);
} while (pPlayer != pPlayers_Dlg->pBeginWidgetList);
pplayer = pplayer->prev;
FREESURFACE(pplayer->gfx);
} while (pplayer != pplayers_dlg->pBeginWidgetList);
players_dialog_update();
}
......
**************************************************************************/
void real_players_dialog_update(void *unused)
{
if (pPlayers_Dlg) {
struct widget *pPlayer0, *pPlayer1;
struct player *pPlayer;
if (pplayers_dlg) {
struct widget *pplayer0, *pplayer1;
struct player *pplayer;
int i;
struct astring astr = ASTRING_INIT;
/* redraw window */
widget_redraw(pPlayers_Dlg->pEndWidgetList);
widget_redraw(pplayers_dlg->pEndWidgetList);
/* exit button -> neutral -> war -> casefire -> peace -> alliance */
pPlayer0 = pPlayers_Dlg->pEndWidgetList->prev->prev->prev->prev->prev->prev;
pplayer0 = pplayers_dlg->pEndWidgetList->prev->prev->prev->prev->prev->prev;
do {
pPlayer0 = pPlayer0->prev;
pPlayer1 = pPlayer0;
pPlayer = pPlayer0->data.player;
pplayer0 = pplayer0->prev;
pplayer1 = pplayer0;
pplayer = pplayer0->data.player;
for (i = 0; i < num_player_dlg_columns; i++) {
if (player_dlg_columns[i].show) {
......
case COL_TEXT:
case COL_RIGHT_TEXT:
astr_add_line(&astr, "%s: %s", player_dlg_columns[i].title,
player_dlg_columns[i].func(pPlayer));
player_dlg_columns[i].func(pplayer));
break;
case COL_BOOLEAN:
astr_add_line(&astr, "%s: %s", player_dlg_columns[i].title,
player_dlg_columns[i].bool_func(pPlayer) ?
player_dlg_columns[i].bool_func(pplayer) ?
_("Yes") : _("No"));
break;
default:
......
}
}
copy_chars_to_utf8_str(pPlayer0->info_label, astr_str(&astr));
copy_chars_to_utf8_str(pplayer0->info_label, astr_str(&astr));
astr_free(&astr);
/* now add some eye candy ... */
if (pPlayer1 != pPlayers_Dlg->pBeginWidgetList) {
if (pplayer1 != pplayers_dlg->pBeginWidgetList) {
SDL_Rect dst0, dst1;
dst0.x = pPlayer0->size.x + pPlayer0->size.w / 2;
dst0.y = pPlayer0->size.y + pPlayer0->size.h / 2;
dst0.x = pplayer0->size.x + pplayer0->size.w / 2;
dst0.y = pplayer0->size.y + pplayer0->size.h / 2;
do {
pPlayer1 = pPlayer1->prev;
if (have_diplomat_info_about(pPlayer)
|| have_diplomat_info_about(pPlayer1->data.player)) {
pplayer1 = pplayer1->prev;
if (have_diplomat_info_about(pplayer)
|| have_diplomat_info_about(pplayer1->data.player)) {
dst1.x = pPlayer1->size.x + pPlayer1->size.w / 2;
dst1.y = pPlayer1->size.y + pPlayer1->size.h / 2;
dst1.x = pplayer1->size.x + pplayer1->size.w / 2;
dst1.y = pplayer1->size.y + pplayer1->size.h / 2;
switch (player_diplstate_get(pPlayer,
pPlayer1->data.player)->type) {
switch (player_diplstate_get(pplayer,
pplayer1->data.player)->type) {
case DS_ARMISTICE:
if (SDL_Client_Flags & CF_DRAW_PLAYERS_NEUTRAL_STATUS) {
create_line(pPlayer1->dst->surface,
create_line(pplayer1->dst->surface,
dst0.x, dst0.y, dst1.x, dst1.y,
get_theme_color(COLOR_THEME_PLRDLG_ARMISTICE));
}
break;
case DS_WAR:
if (SDL_Client_Flags & CF_DRAW_PLAYERS_WAR_STATUS) {
create_line(pPlayer1->dst->surface,
create_line(pplayer1->dst->surface,
dst0.x, dst0.y, dst1.x, dst1.y,
get_theme_color(COLOR_THEME_PLRDLG_WAR));
}
break;
case DS_CEASEFIRE:
if (SDL_Client_Flags & CF_DRAW_PLAYERS_CEASEFIRE_STATUS) {
create_line(pPlayer1->dst->surface,
create_line(pplayer1->dst->surface,
dst0.x, dst0.y, dst1.x, dst1.y,
get_theme_color(COLOR_THEME_PLRDLG_CEASEFIRE));
}
break;
case DS_PEACE:
if (SDL_Client_Flags & CF_DRAW_PLAYERS_PEACE_STATUS) {
create_line(pPlayer1->dst->surface,
create_line(pplayer1->dst->surface,
dst0.x, dst0.y, dst1.x, dst1.y,
get_theme_color(COLOR_THEME_PLRDLG_PEACE));
}
break;
case DS_ALLIANCE:
if (SDL_Client_Flags & CF_DRAW_PLAYERS_ALLIANCE_STATUS) {
create_line(pPlayer1->dst->surface,
create_line(pplayer1->dst->surface,
dst0.x, dst0.y, dst1.x, dst1.y,
get_theme_color(COLOR_THEME_PLRDLG_ALLIANCE));
}
......
break;
}
}
} while (pPlayer1 != pPlayers_Dlg->pBeginWidgetList);
} while (pplayer1 != pplayers_dlg->pBeginWidgetList);
}
} while (pPlayer0 != pPlayers_Dlg->pBeginWidgetList);
} while (pplayer0 != pplayers_dlg->pBeginWidgetList);
/* -------------------- */
/* redraw */
redraw_group(pPlayers_Dlg->pBeginWidgetList,
pPlayers_Dlg->pEndWidgetList->prev, 0);
widget_mark_dirty(pPlayers_Dlg->pEndWidgetList);
redraw_group(pplayers_dlg->pBeginWidgetList,
pplayers_dlg->pEndWidgetList->prev, 0);
widget_mark_dirty(pplayers_dlg->pEndWidgetList);
flush_dirty();
}
......
double a, b, r;
SDL_Rect area;
if (pPlayers_Dlg) {
if (pplayers_dlg) {
return;
}
n = 0;
players_iterate(pPlayer) {
if (is_barbarian(pPlayer)) {
players_iterate(pplayer) {
if (is_barbarian(pplayer)) {
continue;
}
n++;
......
return;
}
pPlayers_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
pplayers_dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
pstr = create_utf8_from_char(Q_("?header:Players"), adj_font(12));
pstr->style |= TTF_STYLE_BOLD;
......
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_WINDOW, pwindow);
pPlayers_Dlg->pEndWidgetList = pwindow;
pplayers_dlg->pEndWidgetList = pwindow;
/* ---------- */
/* exit button */
pBuf = create_themeicon(current_theme->Small_CANCEL_Icon, pwindow->dst,
......
}
/* ---------- */
players_iterate(pPlayer) {
if (is_barbarian(pPlayer)) {
players_iterate(pplayer) {
if (is_barbarian(pplayer)) {
continue;
}
pstr = create_utf8_str(NULL, 0, adj_font(10));
pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pLogo = get_nation_flag_surface(nation_of_player(pPlayer));
pLogo = get_nation_flag_surface(nation_of_player(pplayer));
{
/* Aim for a flag height of 60 pixels, but draw smaller flags if there
* are more players */
......
| WF_FREE_THEME);
pBuf->info_label = pstr;
if (!pPlayer->is_alive) {
if (!pplayer->is_alive) {
pstr = create_utf8_from_char(_("R.I.P.") , adj_font(10));
pstr->style |= TTF_STYLE_BOLD;
pstr->fgcol = *get_theme_color(COLOR_THEME_PLRDLG_TEXT);
......
FREESURFACE(pLogo);
}
if (pPlayer->is_alive) {
if (pplayer->is_alive) {
set_wstate(pBuf, FC_WS_NORMAL);
}
pBuf->data.player = pPlayer;
pBuf->data.player = pplayer;
pBuf->action = player_callback;
......
} players_iterate_end;
pPlayers_Dlg->pBeginWidgetList = pBuf;
pplayers_dlg->pBeginWidgetList = pBuf;
resize_window(pwindow, NULL, NULL, adj_size(500), adj_size(400));
......
pBuf->size.y = area.y + area.h / 2 - r - pBuf->size.h / 2;
n = 1;
if (pBuf != pPlayers_Dlg->pBeginWidgetList) {
if (pBuf != pplayers_dlg->pBeginWidgetList) {
do {
pBuf = pBuf->prev;
b = M_PI_2 + n * a;
pBuf->size.x = area.x + area.w / 2 - r * cos(b) - pBuf->size.w / 2;
pBuf->size.y = area.y + area.h / 2 - r * sin(b) - pBuf->size.h / 2;
n++;
} while (pBuf != pPlayers_Dlg->pBeginWidgetList);
} while (pBuf != pplayers_dlg->pBeginWidgetList);
}
players_dialog_update();
......
**************************************************************************/
void popdown_players_dialog(void)
{
if (pPlayers_Dlg) {
popdown_window_group_dialog(pPlayers_Dlg->pBeginWidgetList,
pPlayers_Dlg->pEndWidgetList);
FC_FREE(pPlayers_Dlg);
if (pplayers_dlg) {
popdown_window_group_dialog(pplayers_dlg->pBeginWidgetList,
pplayers_dlg->pEndWidgetList);
FC_FREE(pplayers_dlg);
}
}
......
**************************************************************************/
static int player_nation_callback(struct widget *pWidget)
{
struct player *pPlayer = pWidget->data.player;
struct player *pplayer = pWidget->data.player;
popdown_players_nations_dialog();
if (Main.event.type == SDL_MOUSEBUTTONDOWN) {
......
break;
#endif /* 0 */
case SDL_BUTTON_RIGHT:
if (can_intel_with_player(pPlayer)) {
popup_intel_dialog(pPlayer);
if (can_intel_with_player(pplayer)) {
popup_intel_dialog(pplayer);
} else {
flush_dirty();
}
break;
default:
if (pPlayer != client.conn.playing) {
popup_diplomacy_dialog(pPlayer);
if (pplayer != client.conn.playing) {
popup_diplomacy_dialog(pplayer);
}
break;
}
} else if (PRESSED_EVENT(Main.event)) {
if (pPlayer != client.conn.playing) {
popup_diplomacy_dialog(pPlayer);
if (pplayer != client.conn.playing) {
popup_diplomacy_dialog(pplayer);
}
}
......
add_to_gui_list(ID_BUTTON, pBuf);
/* ---------- */
players_iterate(pPlayer) {
if (pPlayer != client.conn.playing) {
if (!pPlayer->is_alive || is_barbarian(pPlayer)) {
players_iterate(pplayer) {
if (pplayer != client.conn.playing) {
if (!pplayer->is_alive || is_barbarian(pplayer)) {
continue;
}
pDS = player_diplstate_get(client.conn.playing, pPlayer);
pDS = player_diplstate_get(client.conn.playing, pplayer);
if (is_ai(pPlayer)) {
if (is_ai(pplayer)) {
state = _("AI");
} else {
if (pPlayer->is_connected) {
if (pPlayer->phase_done) {
if (pplayer->is_connected) {
if (pplayer->phase_done) {
state = _("done");
} else {
state = _("moving");
......
if (pDS->type == DS_CEASEFIRE) {
fc_snprintf(cBuf, sizeof(cBuf), "%s(%s) - %d %s",
nation_adjective_for_player(pPlayer),
nation_adjective_for_player(pplayer),
state,
pDS->turns_left, PL_("turn", "turns", pDS->turns_left));
} else {
fc_snprintf(cBuf, sizeof(cBuf), "%s(%s)",
nation_adjective_for_player(pPlayer),
nation_adjective_for_player(pplayer),
state);
}
pstr = create_utf8_from_char(cBuf, adj_font(10));
pstr->style |= TTF_STYLE_BOLD;
pLogo = get_nation_flag_surface(nation_of_player(pPlayer));
pLogo = get_nation_flag_surface(nation_of_player(pplayer));
pBuf = create_iconlabel(pLogo, pwindow->dst, pstr,
(WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
......
set_wstate(pBuf, FC_WS_NORMAL);
break;
case DS_WAR:
if (can_meet_with_player(pPlayer) || can_intel_with_player(pPlayer)) {
if (can_meet_with_player(pplayer) || can_intel_with_player(pplayer)) {
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_PLRDLG_WAR);
} else {
......
pBuf->string_utf8->bgcol = (SDL_Color) {0, 0, 0, 0};
pBuf->data.player = pPlayer;
pBuf->data.player = pplayer;
pBuf->action = player_nation_callback;
client/gui-sdl2/spaceshipdlg.c
/**********************************************************************//**
Refresh (update) the spaceship dialog for the given player.
**************************************************************************/
void refresh_spaceship_dialog(struct player *pPlayer)
void refresh_spaceship_dialog(struct player *pplayer)
{
struct SMALL_DLG *pSpaceShp;
struct widget *pbuf;
if (!(pSpaceShp = get_spaceship_dialog(pPlayer))) {
if (!(pSpaceShp = get_spaceship_dialog(pplayer))) {
return;
}
/* launch button */
pbuf = pSpaceShp->pEndWidgetList->prev->prev;
if (victory_enabled(VC_SPACERACE)
&& pPlayer == client.conn.playing
&& pPlayer->spaceship.state == SSHIP_STARTED
&& pPlayer->spaceship.success_rate > 0.0) {
&& pplayer == client.conn.playing
&& pplayer->spaceship.state == SSHIP_STARTED
&& pplayer->spaceship.success_rate > 0.0) {
set_wstate(pbuf, FC_WS_NORMAL);
}
/* update text info */
pbuf = pbuf->prev;
copy_chars_to_utf8_str(pbuf->string_utf8,
get_spaceship_descr(&pPlayer->spaceship));
get_spaceship_descr(&pplayer->spaceship));
/* ------------------------------------------ */
/* redraw */
......
/**********************************************************************//**
Popup (or raise) the spaceship dialog for the given player.
**************************************************************************/
void popup_spaceship_dialog(struct player *pPlayer)
void popup_spaceship_dialog(struct player *pplayer)
{
struct SMALL_DLG *pSpaceShp;
if (!(pSpaceShp = get_spaceship_dialog(pPlayer))) {
if (!(pSpaceShp = get_spaceship_dialog(pplayer))) {
struct widget *pBuf, *pwindow;
utf8_str *pstr;
char cbuf[128];
......
pSpaceShp = fc_calloc(1, sizeof(struct SMALL_DLG));
fc_snprintf(cbuf, sizeof(cbuf), _("The %s Spaceship"),
nation_adjective_for_player(pPlayer));
nation_adjective_for_player(pplayer));
pstr = create_utf8_from_char(cbuf, adj_font(12));
pstr->style |= TTF_STYLE_BOLD;
......
pwindow->action = space_dialog_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
pwindow->data.player = pPlayer;
pwindow->data.player = pplayer;
pwindow->private_data.small_dlg = pSpaceShp;
add_to_gui_list(ID_WINDOW, pwindow);
pSpaceShp->pEndWidgetList = pwindow;
......
| WF_RESTORE_BACKGROUND);
pBuf->info_label = create_utf8_from_char(_("Close Dialog (Esc)"),
adj_font(12));
pBuf->data.player = pPlayer;
pBuf->data.player = pplayer;
pBuf->action = exit_space_dialog_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
......
dialog_list_prepend(dialog_list, pSpaceShp);
refresh_spaceship_dialog(pPlayer);
refresh_spaceship_dialog(pplayer);
} else {
if (select_window_group_dialog(pSpaceShp->pBeginWidgetList,
pSpaceShp->pEndWidgetList)) {
......
/**********************************************************************//**
Close the spaceship dialog for the given player.
**************************************************************************/
void popdown_spaceship_dialog(struct player *pPlayer)
void popdown_spaceship_dialog(struct player *pplayer)
{
struct SMALL_DLG *pSpaceShp;
if ((pSpaceShp = get_spaceship_dialog(pPlayer))) {
if ((pSpaceShp = get_spaceship_dialog(pplayer))) {
popdown_window_group_dialog(pSpaceShp->pBeginWidgetList,
pSpaceShp->pEndWidgetList);
dialog_list_remove(dialog_list, pSpaceShp);
    (1-1/1)