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 #901113 ยป 0041-sdl2-Rename-p-Dlg-to-adhere-with-coding-style.patch

Marko Lindqvist, 2020-11-29 03:53 AM

View differences:

client/gui-sdl2/action_dialog.c
void popdown_bribe_dialog(void);
static struct diplomat_dialog *pDiplomat_Dlg = NULL;
static struct diplomat_dialog *diplomat_dlg = NULL;
static bool is_more_user_input_needed = FALSE;
static bool did_not_decide = FALSE;
......
static int diplomat_dlg_window_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pDiplomat_Dlg->pdialog->begin_widget_list, pwindow);
move_window_group(diplomat_dlg->pdialog->begin_widget_list, pwindow);
}
return -1;
......
**************************************************************************/
static int spy_strike_bld_request(struct widget *pwidget)
{
if (NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
pDiplomat_Dlg->target_ids[ATK_CITY])) {
diplomat_dlg->target_ids[ATK_CITY])) {
request_action_details(ACTION_STRIKE_BUILDING,
pDiplomat_Dlg->actor_unit_id,
pDiplomat_Dlg->target_ids[ATK_CITY]);
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
is_more_user_input_needed = TRUE;
popdown_diplomat_dialog();
} else {
......
**************************************************************************/
static int spy_sabotage_request(struct widget *pwidget)
{
if (NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
pDiplomat_Dlg->target_ids[ATK_CITY])) {
diplomat_dlg->target_ids[ATK_CITY])) {
request_action_details(ACTION_SPY_TARGETED_SABOTAGE_CITY,
pDiplomat_Dlg->actor_unit_id,
pDiplomat_Dlg->target_ids[ATK_CITY]);
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
is_more_user_input_needed = TRUE;
popdown_diplomat_dialog();
} else {
......
**************************************************************************/
static int spy_sabotage_esc_request(struct widget *pwidget)
{
if (NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
pDiplomat_Dlg->target_ids[ATK_CITY])) {
diplomat_dlg->target_ids[ATK_CITY])) {
request_action_details(ACTION_SPY_TARGETED_SABOTAGE_CITY_ESC,
pDiplomat_Dlg->actor_unit_id,
pDiplomat_Dlg->target_ids[ATK_CITY]);
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
is_more_user_input_needed = TRUE;
popdown_diplomat_dialog();
} else {
......
static int spy_steal_dlg_window_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pDiplomat_Dlg->pdialog->begin_widget_list, pwindow);
move_window_group(diplomat_dlg->pdialog->begin_widget_list, pwindow);
}
return -1;
......
static int exit_spy_tgt_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int actor_id = pDiplomat_Dlg->actor_unit_id;
int actor_id = diplomat_dlg->actor_unit_id;
fc_assert(is_more_user_input_needed);
popdown_diplomat_dialog();
......
{
if (PRESSED_EVENT(main_data.event)) {
int steal_advance = MAX_ID - pwidget->ID;
int actor_id = pDiplomat_Dlg->actor_unit_id;
int actor_id = diplomat_dlg->actor_unit_id;
if (NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
pDiplomat_Dlg->target_ids[ATK_CITY])) {
diplomat_dlg->target_ids[ATK_CITY])) {
if (steal_advance == A_UNSET) {
/* This is the untargeted version. */
request_do_action(get_non_targeted_action_id(
pDiplomat_Dlg->act_id),
pDiplomat_Dlg->actor_unit_id,
pDiplomat_Dlg->target_ids[ATK_CITY],
diplomat_dlg->act_id),
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY],
steal_advance, "");
} else {
/* This is the targeted version. */
request_do_action(pDiplomat_Dlg->act_id,
pDiplomat_Dlg->actor_unit_id,
pDiplomat_Dlg->target_ids[ATK_CITY],
request_do_action(diplomat_dlg->act_id,
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY],
steal_advance, "");
}
}
......
{
const struct research *presearch, *vresearch;
struct city *pVcity = pwidget->data.city;
int id = pDiplomat_Dlg->actor_unit_id;
int id = diplomat_dlg->actor_unit_id;
struct player *pVictim = NULL;
struct container *pCont;
struct widget *buf = NULL;
......
SDL_Rect area;
struct unit *actor_unit = game_unit_by_number(id);
action_id act_id = pDiplomat_Dlg->act_id;
action_id act_id = diplomat_dlg->act_id;
is_more_user_input_needed = TRUE;
popdown_diplomat_dialog();
......
pVictim = city_owner(pVcity);
}
fc_assert_ret_val_msg(!pDiplomat_Dlg, 1, "Diplomat dialog already open");
fc_assert_ret_val_msg(!diplomat_dlg, 1, "Diplomat dialog already open");
if (!pVictim) {
act_sel_done_secondary(id);
......
pCont->id0 = pVcity->id;
pCont->id1 = id;/* spy id */
pDiplomat_Dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
pDiplomat_Dlg->act_id = act_id;
pDiplomat_Dlg->actor_unit_id = id;
pDiplomat_Dlg->target_ids[ATK_CITY] = pVcity->id;
pDiplomat_Dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
diplomat_dlg->act_id = act_id;
diplomat_dlg->actor_unit_id = id;
diplomat_dlg->target_ids[ATK_CITY] = pVcity->id;
diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
pstr = create_utf8_from_char(_("Select Advance to Steal"), adj_font(12));
pstr->style |= TTF_STYLE_BOLD;
......
set_wstate(pwindow , FC_WS_NORMAL);
add_to_gui_list(ID_DIPLOMAT_DLG_WINDOW, pwindow);
pDiplomat_Dlg->pdialog->end_widget_list = pwindow;
diplomat_dlg->pdialog->end_widget_list = pwindow;
area = pwindow->area;
area.w = MAX(area.w, adj_size(8));
......
/* --------------------------------------------------------- */
FREEUTF8STR(pstr);
pDiplomat_Dlg->pdialog->begin_widget_list = buf;
pDiplomat_Dlg->pdialog->begin_active_widget_list = pDiplomat_Dlg->pdialog->begin_widget_list;
pDiplomat_Dlg->pdialog->end_active_widget_list = pDiplomat_Dlg->pdialog->end_widget_list->prev->prev;
diplomat_dlg->pdialog->begin_widget_list = buf;
diplomat_dlg->pdialog->begin_active_widget_list = diplomat_dlg->pdialog->begin_widget_list;
diplomat_dlg->pdialog->end_active_widget_list = diplomat_dlg->pdialog->end_widget_list->prev->prev;
/* -------------------------------------------------------------- */
......
if (count > col) {
count = (count + (col - 1)) / col;
if (count > max_row) {
pDiplomat_Dlg->pdialog->active_widget_list = pDiplomat_Dlg->pdialog->end_active_widget_list;
diplomat_dlg->pdialog->active_widget_list = diplomat_dlg->pdialog->end_active_widget_list;
count = max_row;
idx = create_vertical_scrollbar(pDiplomat_Dlg->pdialog, col, count, TRUE, TRUE);
idx = create_vertical_scrollbar(diplomat_dlg->pdialog, col, count, TRUE, TRUE);
}
} else {
count = 1;
......
setup_vertical_widgets_position(col, area.x + 1,
area.y, 0, 0,
pDiplomat_Dlg->pdialog->begin_active_widget_list,
pDiplomat_Dlg->pdialog->end_active_widget_list);
diplomat_dlg->pdialog->begin_active_widget_list,
diplomat_dlg->pdialog->end_active_widget_list);
if (pDiplomat_Dlg->pdialog->scroll) {
setup_vertical_scrollbar_area(pDiplomat_Dlg->pdialog->scroll,
if (diplomat_dlg->pdialog->scroll) {
setup_vertical_scrollbar_area(diplomat_dlg->pdialog->scroll,
area.x + area.w, area.y,
area.h, TRUE);
}
redraw_group(pDiplomat_Dlg->pdialog->begin_widget_list, pwindow, FALSE);
redraw_group(diplomat_dlg->pdialog->begin_widget_list, pwindow, FALSE);
widget_mark_dirty(pwindow);
return -1;
......
**************************************************************************/
static int spy_steal_popup(struct widget *pwidget)
{
pDiplomat_Dlg->act_id = ACTION_SPY_TARGETED_STEAL_TECH;
diplomat_dlg->act_id = ACTION_SPY_TARGETED_STEAL_TECH;
return spy_steal_popup_shared(pwidget);
}
......
**************************************************************************/
static int spy_steal_esc_popup(struct widget *pwidget)
{
pDiplomat_Dlg->act_id = ACTION_SPY_TARGETED_STEAL_TECH_ESC;
diplomat_dlg->act_id = ACTION_SPY_TARGETED_STEAL_TECH_ESC;
return spy_steal_popup_shared(pwidget);
}
......
static int diplomat_incite_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
pDiplomat_Dlg->target_ids[ATK_CITY])) {
diplomat_dlg->target_ids[ATK_CITY])) {
request_action_details(ACTION_SPY_INCITE_CITY,
pDiplomat_Dlg->actor_unit_id,
pDiplomat_Dlg->target_ids[ATK_CITY]);
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
is_more_user_input_needed = TRUE;
popdown_diplomat_dialog();
} else {
......
static int spy_incite_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL != game_city_by_number(
pDiplomat_Dlg->target_ids[ATK_CITY])) {
diplomat_dlg->target_ids[ATK_CITY])) {
request_action_details(ACTION_SPY_INCITE_CITY_ESC,
pDiplomat_Dlg->actor_unit_id,
pDiplomat_Dlg->target_ids[ATK_CITY]);
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_CITY]);
is_more_user_input_needed = TRUE;
popdown_diplomat_dialog();
} else {
......
if (PRESSED_EVENT(main_data.event)) {
struct unit *punit;
if ((punit = game_unit_by_number(pDiplomat_Dlg->actor_unit_id))
if ((punit = game_unit_by_number(diplomat_dlg->actor_unit_id))
&& !same_pos(unit_tile(punit), pwidget->data.tile)) {
request_unit_non_action_move(punit, pwidget->data.tile);
}
......
static int diplomat_bribe_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)
if (NULL != game_unit_by_number(diplomat_dlg->actor_unit_id)
&& NULL !=
game_unit_by_number(pDiplomat_Dlg->target_ids[ATK_UNIT])) {
game_unit_by_number(diplomat_dlg->target_ids[ATK_UNIT])) {
request_action_details(ACTION_SPY_BRIBE_UNIT,
pDiplomat_Dlg->actor_unit_id,
pDiplomat_Dlg->target_ids[ATK_UNIT]);
diplomat_dlg->actor_unit_id,
diplomat_dlg->target_ids[ATK_UNIT]);
is_more_user_input_needed = TRUE;
popdown_diplomat_dialog();
} else {
......
static int found_city_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int actor_id = pDiplomat_Dlg->actor_unit_id;
int actor_id = diplomat_dlg->actor_unit_id;
popdown_diplomat_dialog();
dsend_packet_city_name_suggestion_req(&client.conn,
......
struct unit *punit;
struct city *pcity;
if ((pcity = game_city_by_number(pDiplomat_Dlg->target_ids[ATK_CITY]))
&& (punit = game_unit_by_number(pDiplomat_Dlg->actor_unit_id))) {
if ((pcity = game_city_by_number(diplomat_dlg->target_ids[ATK_CITY]))
&& (punit = game_unit_by_number(diplomat_dlg->actor_unit_id))) {
popup_unit_upgrade_dlg(punit, FALSE);
}
......
/* Actor */
fc_assert(action_get_actor_kind(paction) == AAK_UNIT);
actor_id = pDiplomat_Dlg->actor_unit_id;
actor_id = diplomat_dlg->actor_unit_id;
if (NULL == game_unit_by_number(actor_id)) {
/* Probably dead. */
failed = TRUE;
......
target_id = IDENTITY_NUMBER_ZERO;
switch (action_get_target_kind(paction)) {
case ATK_CITY:
target_id = pDiplomat_Dlg->target_ids[ATK_CITY];
target_id = diplomat_dlg->target_ids[ATK_CITY];
if (NULL == game_city_by_number(target_id)) {
/* Probably destroyed. */
failed = TRUE;
}
break;
case ATK_UNIT:
target_id = pDiplomat_Dlg->target_ids[ATK_UNIT];
target_id = diplomat_dlg->target_ids[ATK_UNIT];
if (NULL == game_unit_by_number(target_id)) {
/* Probably dead. */
failed = TRUE;
......
break;
case ATK_UNITS:
case ATK_TILE:
target_id = pDiplomat_Dlg->target_ids[ATK_TILE];
target_id = diplomat_dlg->target_ids[ATK_TILE];
if (NULL == index_to_tile(&(wld.map), target_id)) {
/* TODO: Should this be possible at all? If not: add assertion. */
failed = TRUE;
......
if (paction->target_complexity != ACT_TGT_COMPL_SIMPLE) {
switch (action_get_sub_target_kind(paction)) {
case ASTK_BUILDING:
sub_target = pDiplomat_Dlg->sub_target_id[ASTK_BUILDING];
sub_target = diplomat_dlg->sub_target_id[ASTK_BUILDING];
if (NULL == improvement_by_number(sub_target)) {
/* Did the ruleset change? */
failed = TRUE;
}
break;
case ASTK_TECH:
sub_target = pDiplomat_Dlg->sub_target_id[ASTK_TECH];
sub_target = diplomat_dlg->sub_target_id[ASTK_TECH];
if (NULL == valid_advance_by_number(sub_target)) {
/* Did the ruleset change? */
failed = TRUE;
......
case ASTK_EXTRA:
case ASTK_EXTRA_NOT_THERE:
/* TODO: validate if the extra is there? */
sub_target = pDiplomat_Dlg->sub_target_id[ASTK_EXTRA];
sub_target = diplomat_dlg->sub_target_id[ASTK_EXTRA];
if (NULL == extra_by_number(sub_target)) {
/* Did the ruleset change? */
failed = TRUE;
......
**************************************************************************/
void popdown_diplomat_dialog(void)
{
if (pDiplomat_Dlg) {
act_sel_done_primary(pDiplomat_Dlg->actor_unit_id);
if (diplomat_dlg) {
act_sel_done_primary(diplomat_dlg->actor_unit_id);
is_unit_move_blocked = FALSE;
popdown_window_group_dialog(pDiplomat_Dlg->pdialog->begin_widget_list,
pDiplomat_Dlg->pdialog->end_widget_list);
FC_FREE(pDiplomat_Dlg->pdialog->scroll);
FC_FREE(pDiplomat_Dlg->pdialog);
FC_FREE(pDiplomat_Dlg);
popdown_window_group_dialog(diplomat_dlg->pdialog->begin_widget_list,
diplomat_dlg->pdialog->end_widget_list);
FC_FREE(diplomat_dlg->pdialog->scroll);
FC_FREE(diplomat_dlg->pdialog);
FC_FREE(diplomat_dlg);
queue_flush();
}
}
......
utf8_str *pstr;
SDL_Rect area;
fc_assert_ret_msg(!pDiplomat_Dlg, "Diplomat dialog already open");
fc_assert_ret_msg(!diplomat_dlg, "Diplomat dialog already open");
/* Could be caused by the server failing to reply to a request for more
* information or a bug in the client code. */
......
is_unit_move_blocked = TRUE;
pDiplomat_Dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
pDiplomat_Dlg->actor_unit_id = actor_unit->id;
pDiplomat_Dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
diplomat_dlg->actor_unit_id = actor_unit->id;
diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
/* window */
if (target_city) {
......
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_CARAVAN_DLG_WINDOW, pwindow);
pDiplomat_Dlg->pdialog->end_widget_list = pwindow;
diplomat_dlg->pdialog->end_widget_list = pwindow;
area = pwindow->area;
area.w = MAX(area.w, adj_size(8));
area.h = MAX(area.h, adj_size(2));
if (target_city) {
pDiplomat_Dlg->target_ids[ATK_CITY] = target_city->id;
diplomat_dlg->target_ids[ATK_CITY] = target_city->id;
} else {
pDiplomat_Dlg->target_ids[ATK_CITY] = IDENTITY_NUMBER_ZERO;
diplomat_dlg->target_ids[ATK_CITY] = IDENTITY_NUMBER_ZERO;
}
if (target_unit) {
pDiplomat_Dlg->target_ids[ATK_UNIT] = target_unit->id;
diplomat_dlg->target_ids[ATK_UNIT] = target_unit->id;
} else {
pDiplomat_Dlg->target_ids[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
diplomat_dlg->target_ids[ATK_UNIT] = IDENTITY_NUMBER_ZERO;
}
pDiplomat_Dlg->target_ids[ATK_UNITS] = tile_index(target_tile);
pDiplomat_Dlg->target_ids[ATK_TILE] = tile_index(target_tile);
diplomat_dlg->target_ids[ATK_UNITS] = tile_index(target_tile);
diplomat_dlg->target_ids[ATK_TILE] = tile_index(target_tile);
/* No target building or target tech supplied. (Feb 2020) */
pDiplomat_Dlg->sub_target_id[ASTK_BUILDING] = B_LAST;
pDiplomat_Dlg->sub_target_id[ASTK_TECH] = A_UNSET;
diplomat_dlg->sub_target_id[ASTK_BUILDING] = B_LAST;
diplomat_dlg->sub_target_id[ASTK_TECH] = A_UNSET;
if (target_extra) {
pDiplomat_Dlg->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
pDiplomat_Dlg->sub_target_id[ASTK_EXTRA_NOT_THERE]
diplomat_dlg->sub_target_id[ASTK_EXTRA] = extra_number(target_extra);
diplomat_dlg->sub_target_id[ASTK_EXTRA_NOT_THERE]
= extra_number(target_extra);
} else {
pDiplomat_Dlg->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
pDiplomat_Dlg->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
diplomat_dlg->sub_target_id[ASTK_EXTRA] = EXTRA_NONE;
diplomat_dlg->sub_target_id[ASTK_EXTRA_NOT_THERE] = EXTRA_NONE;
}
pDiplomat_Dlg->target_ids[ATK_SELF] = actor_unit->id;
diplomat_dlg->target_ids[ATK_SELF] = actor_unit->id;
/* ---------- */
/* Unit acting against a city */
......
area.w = MAX(area.w, buf->size.w);
area.h += buf->size.h;
/* ---------- */
pDiplomat_Dlg->pdialog->begin_widget_list = buf;
diplomat_dlg->pdialog->begin_widget_list = buf;
/* setup window size and start position */
......
setup_vertical_widgets_position(1,
area.x,
area.y + 1, area.w, 0,
pDiplomat_Dlg->pdialog->begin_widget_list, buf);
diplomat_dlg->pdialog->begin_widget_list, buf);
/* --------------------- */
/* redraw */
redraw_group(pDiplomat_Dlg->pdialog->begin_widget_list, pwindow, 0);
redraw_group(diplomat_dlg->pdialog->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
......
**************************************************************************/
int action_selection_actor_unit(void)
{
if (!pDiplomat_Dlg) {
if (!diplomat_dlg) {
return IDENTITY_NUMBER_ZERO;
}
return pDiplomat_Dlg->actor_unit_id;
return diplomat_dlg->actor_unit_id;
}
/**********************************************************************//**
......
**************************************************************************/
int action_selection_target_city(void)
{
if (!pDiplomat_Dlg) {
if (!diplomat_dlg) {
return IDENTITY_NUMBER_ZERO;
}
return pDiplomat_Dlg->target_ids[ATK_CITY];
return diplomat_dlg->target_ids[ATK_CITY];
}
/**********************************************************************//**
......
**************************************************************************/
int action_selection_target_unit(void)
{
if (!pDiplomat_Dlg) {
if (!diplomat_dlg) {
return IDENTITY_NUMBER_ZERO;
}
return pDiplomat_Dlg->target_ids[ATK_UNIT];
return diplomat_dlg->target_ids[ATK_UNIT];
}
/**********************************************************************//**
......
**************************************************************************/
int action_selection_target_tile(void)
{
if (!pDiplomat_Dlg) {
if (!diplomat_dlg) {
return TILE_INDEX_NONE;
}
return pDiplomat_Dlg->target_ids[ATK_TILE];
return diplomat_dlg->target_ids[ATK_TILE];
}
/**********************************************************************//**
......
**************************************************************************/
int action_selection_target_extra(void)
{
if (!pDiplomat_Dlg) {
if (!diplomat_dlg) {
return EXTRA_NONE;
}
return pDiplomat_Dlg->sub_target_id[ASTK_EXTRA];
return diplomat_dlg->sub_target_id[ASTK_EXTRA];
}
/**********************************************************************//**
......
SDL_Rect area, area2;
int n, w = 0, h, imp_h = 0, y;
fc_assert_ret_msg(!pDiplomat_Dlg, "Diplomat dialog already open");
fc_assert_ret_msg(!diplomat_dlg, "Diplomat dialog already open");
/* Should be set before sending request to the server. */
fc_assert(is_more_user_input_needed);
......
is_unit_move_blocked = TRUE;
pDiplomat_Dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
pDiplomat_Dlg->actor_unit_id = actor->id;
pDiplomat_Dlg->target_ids[ATK_CITY] = pcity->id;
pDiplomat_Dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
diplomat_dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
diplomat_dlg->actor_unit_id = actor->id;
diplomat_dlg->target_ids[ATK_CITY] = pcity->id;
diplomat_dlg->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
pCont = fc_calloc(1, sizeof(struct container));
pCont->id0 = pcity->id;
......
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_TERRAIN_ADV_DLG_WINDOW, pwindow);
pDiplomat_Dlg->pdialog->end_widget_list = pwindow;
diplomat_dlg->pdialog->end_widget_list = pwindow;
area = pwindow->area;
area.h = MAX(area.h, adj_size(2));
......
add_to_gui_list(ID_SEPARATOR, buf);
area.h += buf->next->size.h;
pDiplomat_Dlg->pdialog->end_active_widget_list = buf;
diplomat_dlg->pdialog->end_active_widget_list = buf;
}
/* ------------------ */
......
}
} city_built_iterate_end;
pDiplomat_Dlg->pdialog->begin_active_widget_list = buf;
diplomat_dlg->pdialog->begin_active_widget_list = buf;
if (n > 0
&& action_prob_possible(actor->client.act_prob_cache[
......
/* ----------- */
pLast = buf;
pDiplomat_Dlg->pdialog->begin_widget_list = pLast;
pDiplomat_Dlg->pdialog->active_widget_list = pDiplomat_Dlg->pdialog->end_active_widget_list;
diplomat_dlg->pdialog->begin_widget_list = pLast;
diplomat_dlg->pdialog->active_widget_list = diplomat_dlg->pdialog->end_active_widget_list;
/* ---------- */
if (n > 10) {
imp_h = 10 * buf->size.h;
n = create_vertical_scrollbar(pDiplomat_Dlg->pdialog,
n = create_vertical_scrollbar(diplomat_dlg->pdialog,
1, 10, TRUE, TRUE);
area.w += n;
} else {
......
buf = buf->prev;
while (buf) {
if (buf == pDiplomat_Dlg->pdialog->end_active_widget_list) {
if (buf == diplomat_dlg->pdialog->end_active_widget_list) {
w -= n;
}
......
break;
}
if (buf == pDiplomat_Dlg->pdialog->begin_active_widget_list) {
if (buf == diplomat_dlg->pdialog->begin_active_widget_list) {
/* Reset to end of scrolling area */
y = MIN(y, pDiplomat_Dlg->pdialog->end_active_widget_list->size.y
y = MIN(y, diplomat_dlg->pdialog->end_active_widget_list->size.y
+ 9 * buf->size.h);
w += n;
}
buf = buf->prev;
}
if (pDiplomat_Dlg->pdialog->scroll) {
setup_vertical_scrollbar_area(pDiplomat_Dlg->pdialog->scroll,
if (diplomat_dlg->pdialog->scroll) {
setup_vertical_scrollbar_area(diplomat_dlg->pdialog->scroll,
area.x + area.w,
pDiplomat_Dlg->pdialog->end_active_widget_list->size.y,
pDiplomat_Dlg->pdialog->begin_active_widget_list->prev->size.y
- pDiplomat_Dlg->pdialog->end_active_widget_list->size.y,
diplomat_dlg->pdialog->end_active_widget_list->size.y,
diplomat_dlg->pdialog->begin_active_widget_list->prev->size.y
- diplomat_dlg->pdialog->end_active_widget_list->size.y,
TRUE);
}
/* -------------------- */
/* redraw */
redraw_group(pDiplomat_Dlg->pdialog->begin_widget_list, pwindow, 0);
redraw_group(diplomat_dlg->pdialog->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
}
......
/* ====================================================================== */
/* ============================== INCITE DIALOG ========================= */
/* ====================================================================== */
static struct small_diplomat_dialog *pIncite_Dlg = NULL;
static struct small_diplomat_dialog *incite_dlg = NULL;
/**********************************************************************//**
User interacted with Incite Revolt dialog window.
......
static int incite_dlg_window_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pIncite_Dlg->pdialog->begin_widget_list, pwindow);
move_window_group(incite_dlg->pdialog->begin_widget_list, pwindow);
}
return -1;
......
static int diplomat_incite_yes_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(pIncite_Dlg->actor_unit_id)
&& NULL != game_city_by_number(pIncite_Dlg->target_id)) {
request_do_action(pIncite_Dlg->act_id, pIncite_Dlg->actor_unit_id,
pIncite_Dlg->target_id, 0, "");
if (NULL != game_unit_by_number(incite_dlg->actor_unit_id)
&& NULL != game_city_by_number(incite_dlg->target_id)) {
request_do_action(incite_dlg->act_id, incite_dlg->actor_unit_id,
incite_dlg->target_id, 0, "");
}
popdown_incite_dialog();
......
**************************************************************************/
void popdown_incite_dialog(void)
{
if (pIncite_Dlg) {
act_sel_done_secondary(pIncite_Dlg->actor_unit_id);
if (incite_dlg) {
act_sel_done_secondary(incite_dlg->actor_unit_id);
is_unit_move_blocked = FALSE;
popdown_window_group_dialog(pIncite_Dlg->pdialog->begin_widget_list,
pIncite_Dlg->pdialog->end_widget_list);
FC_FREE(pIncite_Dlg->pdialog);
FC_FREE(pIncite_Dlg);
popdown_window_group_dialog(incite_dlg->pdialog->begin_widget_list,
incite_dlg->pdialog->end_widget_list);
FC_FREE(incite_dlg->pdialog);
FC_FREE(incite_dlg);
flush_dirty();
}
}
......
bool exit = FALSE;
SDL_Rect area;
if (pIncite_Dlg) {
if (incite_dlg) {
return;
}
......
is_unit_move_blocked = TRUE;
pIncite_Dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
pIncite_Dlg->actor_unit_id = actor->id;
pIncite_Dlg->target_id = pcity->id;
pIncite_Dlg->act_id = paction->id;
pIncite_Dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
incite_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
incite_dlg->actor_unit_id = actor->id;
incite_dlg->target_id = pcity->id;
incite_dlg->act_id = paction->id;
incite_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
"Treasury contains %d gold.",
......
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_INCITE_DLG_WINDOW, pwindow);
pIncite_Dlg->pdialog->end_widget_list = pwindow;
incite_dlg->pdialog->end_widget_list = pwindow;
area = pwindow->area;
area.w =MAX(area.w, adj_size(8));
......
area.w = MAX(area.w, buf->size.w);
area.h += buf->size.h;
}
pIncite_Dlg->pdialog->begin_widget_list = buf;
incite_dlg->pdialog->begin_widget_list = buf;
/* setup window size and start position */
......
setup_vertical_widgets_position(1,
area.x,
area.y + 1, area.w, 0,
pIncite_Dlg->pdialog->begin_widget_list, buf);
incite_dlg->pdialog->begin_widget_list, buf);
/* --------------------- */
/* redraw */
redraw_group(pIncite_Dlg->pdialog->begin_widget_list, pwindow, 0);
redraw_group(incite_dlg->pdialog->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
}
......
/* ====================================================================== */
/* ============================ BRIBE DIALOG ========================== */
/* ====================================================================== */
static struct small_diplomat_dialog *pBribe_Dlg = NULL;
static struct small_diplomat_dialog *bribe_dlg = NULL;
/**********************************************************************//**
User interacted with bribe dialog window.
......
static int bribe_dlg_window_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pBribe_Dlg->pdialog->begin_widget_list, pwindow);
move_window_group(bribe_dlg->pdialog->begin_widget_list, pwindow);
}
return -1;
......
static int diplomat_bribe_yes_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (NULL != game_unit_by_number(pBribe_Dlg->actor_unit_id)
&& NULL != game_unit_by_number(pBribe_Dlg->target_id)) {
request_do_action(pBribe_Dlg->act_id, pBribe_Dlg->actor_unit_id,
pBribe_Dlg->target_id, 0, "");
if (NULL != game_unit_by_number(bribe_dlg->actor_unit_id)
&& NULL != game_unit_by_number(bribe_dlg->target_id)) {
request_do_action(bribe_dlg->act_id, bribe_dlg->actor_unit_id,
bribe_dlg->target_id, 0, "");
}
popdown_bribe_dialog();
}
......
**************************************************************************/
void popdown_bribe_dialog(void)
{
if (pBribe_Dlg) {
act_sel_done_secondary(pBribe_Dlg->actor_unit_id);
if (bribe_dlg) {
act_sel_done_secondary(bribe_dlg->actor_unit_id);
is_unit_move_blocked = FALSE;
popdown_window_group_dialog(pBribe_Dlg->pdialog->begin_widget_list,
pBribe_Dlg->pdialog->end_widget_list);
FC_FREE(pBribe_Dlg->pdialog);
FC_FREE(pBribe_Dlg);
popdown_window_group_dialog(bribe_dlg->pdialog->begin_widget_list,
bribe_dlg->pdialog->end_widget_list);
FC_FREE(bribe_dlg->pdialog);
FC_FREE(bribe_dlg);
flush_dirty();
}
}
......
bool exit = FALSE;
SDL_Rect area;
if (pBribe_Dlg) {
if (bribe_dlg) {
return;
}
......
is_unit_move_blocked = TRUE;
pBribe_Dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
pBribe_Dlg->act_id = paction->id;
pBribe_Dlg->actor_unit_id = actor->id;
pBribe_Dlg->target_id = punit->id;
pBribe_Dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
bribe_dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
bribe_dlg->act_id = paction->id;
bribe_dlg->actor_unit_id = actor->id;
bribe_dlg->target_id = punit->id;
bribe_dlg->pdialog = fc_calloc(1, sizeof(struct small_dialog));
fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
"Treasury contains %d gold.",
......
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_BRIBE_DLG_WINDOW, pwindow);
pBribe_Dlg->pdialog->end_widget_list = pwindow;
bribe_dlg->pdialog->end_widget_list = pwindow;
area = pwindow->area;
area.w = MAX(area.w, adj_size(8));
......
area.w = MAX(area.w, buf->size.w);
area.h += buf->size.h;
}
pBribe_Dlg->pdialog->begin_widget_list = buf;
bribe_dlg->pdialog->begin_widget_list = buf;
/* setup window size and start position */
......
setup_vertical_widgets_position(1,
area.x,
area.y + 1, area.w, 0,
pBribe_Dlg->pdialog->begin_widget_list, buf);
bribe_dlg->pdialog->begin_widget_list, buf);
/* --------------------- */
/* redraw */
redraw_group(pBribe_Dlg->pdialog->begin_widget_list, pwindow, 0);
redraw_group(bribe_dlg->pdialog->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
}
client/gui-sdl2/chatline.c
#define PTSIZE_LOG_FONT adj_font(10)
struct CONNLIST {
struct advanced_dialog *pUsers_Dlg;
struct advanced_dialog *pChat_Dlg;
struct advanced_dialog *users_dlg;
struct advanced_dialog *chat_dlg;
struct widget *begin_widget_list;
struct widget *end_widget_list;
struct widget *start_button;
......
struct widget *pedit;
int text_width;
int active;
} *pConnDlg = NULL;
} *conn_dlg = NULL;
static void popup_conn_list_dialog(void);
static void add_to_chat_list(char *msg, size_t n_alloc);
......
FC_FREE(pLoadDialog);
/* enable buttons */
set_wstate(pConnDlg->pBackButton, FC_WS_NORMAL);
widget_redraw(pConnDlg->pBackButton);
widget_mark_dirty(pConnDlg->pBackButton);
set_wstate(pConnDlg->pLoadGameButton, FC_WS_NORMAL);
widget_redraw(pConnDlg->pLoadGameButton);
widget_mark_dirty(pConnDlg->pLoadGameButton);
set_wstate(pConnDlg->start_button, FC_WS_NORMAL);
widget_redraw(pConnDlg->start_button);
widget_mark_dirty(pConnDlg->start_button);
set_wstate(conn_dlg->pBackButton, FC_WS_NORMAL);
widget_redraw(conn_dlg->pBackButton);
widget_mark_dirty(conn_dlg->pBackButton);
set_wstate(conn_dlg->pLoadGameButton, FC_WS_NORMAL);
widget_redraw(conn_dlg->pLoadGameButton);
widget_mark_dirty(conn_dlg->pLoadGameButton);
set_wstate(conn_dlg->start_button, FC_WS_NORMAL);
widget_redraw(conn_dlg->start_button);
widget_mark_dirty(conn_dlg->start_button);
flush_dirty();
}
......
}
/* disable buttons */
set_wstate(pConnDlg->pBackButton, FC_WS_DISABLED);
widget_redraw(pConnDlg->pBackButton);
widget_mark_dirty(pConnDlg->pBackButton);
set_wstate(pConnDlg->pLoadGameButton, FC_WS_DISABLED);
widget_redraw(pConnDlg->pLoadGameButton);
widget_mark_dirty(pConnDlg->pLoadGameButton);
set_wstate(pConnDlg->pSelectNationButton, FC_WS_DISABLED);
widget_redraw(pConnDlg->pSelectNationButton);
widget_mark_dirty(pConnDlg->pSelectNationButton);
set_wstate(pConnDlg->start_button, FC_WS_DISABLED);
widget_redraw(pConnDlg->start_button);
widget_mark_dirty(pConnDlg->start_button);
set_wstate(conn_dlg->pBackButton, FC_WS_DISABLED);
widget_redraw(conn_dlg->pBackButton);
widget_mark_dirty(conn_dlg->pBackButton);
set_wstate(conn_dlg->pLoadGameButton, FC_WS_DISABLED);
widget_redraw(conn_dlg->pLoadGameButton);
widget_mark_dirty(conn_dlg->pLoadGameButton);
set_wstate(conn_dlg->pSelectNationButton, FC_WS_DISABLED);
widget_redraw(conn_dlg->pSelectNationButton);
widget_mark_dirty(conn_dlg->pSelectNationButton);
set_wstate(conn_dlg->start_button, FC_WS_DISABLED);
widget_redraw(conn_dlg->start_button);
widget_mark_dirty(conn_dlg->start_button);
/* create dialog */
pLoadDialog = fc_calloc(1, sizeof(struct advanced_dialog));
......
int conn_id)
{
/* Currently this is a wrapper to the message subsystem. */
if (pConnDlg) {
if (conn_dlg) {
size_t n = strlen(astring);
char *buffer = fc_strdup(astring);
......
static void add_to_chat_list(char *msg, size_t n_alloc)
{
utf8_str *pstr;
struct widget *buf, *pwindow = pConnDlg->end_widget_list;
struct widget *buf, *pwindow = conn_dlg->end_widget_list;
fc_assert_ret(msg != NULL);
fc_assert_ret(n_alloc != 0);
pstr = create_utf8_str(msg, n_alloc, adj_font(12));
if (convert_utf8_str_to_const_surface_width(pstr, pConnDlg->text_width - adj_size(5))) {
if (convert_utf8_str_to_const_surface_width(pstr, conn_dlg->text_width - adj_size(5))) {
utf8_str *pstr2;
int count = 0;
char **utf8_texts = create_new_line_utf8strs(pstr->text);
......
strlen(utf8_texts[count]) + 1, adj_font(12));
pstr2->bgcol = (SDL_Color) {0, 0, 0, 0};
buf = create_themelabel2(NULL, pwindow->dst,
pstr2, pConnDlg->text_width, 0,
pstr2, conn_dlg->text_width, 0,
(WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
buf->size.w = pConnDlg->text_width;
add_widget_to_vertical_scroll_widget_list(pConnDlg->pChat_Dlg, buf,
pConnDlg->pChat_Dlg->begin_active_widget_list, FALSE,
buf->size.w = conn_dlg->text_width;
add_widget_to_vertical_scroll_widget_list(conn_dlg->chat_dlg, buf,
conn_dlg->chat_dlg->begin_active_widget_list, FALSE,
pwindow->size.x + adj_size(10 + 60 + 10),
pwindow->size.y + adj_size(14));
count++;
}
redraw_group(pConnDlg->pChat_Dlg->begin_widget_list,
pConnDlg->pChat_Dlg->end_widget_list, TRUE);
redraw_group(conn_dlg->chat_dlg->begin_widget_list,
conn_dlg->chat_dlg->end_widget_list, TRUE);
FREEUTF8STR(pstr);
} else {
pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
buf = create_themelabel2(NULL, pwindow->dst,
pstr, pConnDlg->text_width, 0,
pstr, conn_dlg->text_width, 0,
(WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
buf->size.w = pConnDlg->text_width;
buf->size.w = conn_dlg->text_width;
if (add_widget_to_vertical_scroll_widget_list(pConnDlg->pChat_Dlg, buf,
pConnDlg->pChat_Dlg->begin_active_widget_list, FALSE,
if (add_widget_to_vertical_scroll_widget_list(conn_dlg->chat_dlg, buf,
conn_dlg->chat_dlg->begin_active_widget_list, FALSE,
pwindow->size.x + adj_size(10 + 60 + 10),
pwindow->size.y + adj_size(14))) {
redraw_group(pConnDlg->pChat_Dlg->begin_widget_list,
pConnDlg->pChat_Dlg->end_widget_list, TRUE);
redraw_group(conn_dlg->chat_dlg->begin_widget_list,
conn_dlg->chat_dlg->end_widget_list, TRUE);
} else {
widget_redraw(buf);
widget_mark_dirty(buf);
......
static int load_game_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
/* set_wstate(pConnDlg->pLoadGameButton, FC_WS_NORMAL);
* widget_redraw(pConnDlg->pLoadGameButton);
/* set_wstate(conn_dlg->pLoadGameButton, FC_WS_NORMAL);
* widget_redraw(conn_dlg->pLoadGameButton);
* flush_dirty(); */
popup_load_game_dialog();
}
......
void real_conn_list_dialog_update(void *unused)
{
if (C_S_PREPARING == client_state()) {
if (pConnDlg) {
struct widget *buf = NULL, *pwindow = pConnDlg->end_widget_list;
if (conn_dlg) {
struct widget *buf = NULL, *pwindow = conn_dlg->end_widget_list;
utf8_str *pstr = create_utf8_str(NULL, 0, adj_font(12));
bool create;
pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
if (pConnDlg->pUsers_Dlg) {
del_group(pConnDlg->pUsers_Dlg->begin_active_widget_list,
pConnDlg->pUsers_Dlg->end_active_widget_list);
pConnDlg->pUsers_Dlg->active_widget_list = NULL;
pConnDlg->pUsers_Dlg->begin_widget_list =
pConnDlg->pUsers_Dlg->scroll->pscroll_bar;
pConnDlg->pUsers_Dlg->scroll->count = 0;
if (conn_dlg->users_dlg) {
del_group(conn_dlg->users_dlg->begin_active_widget_list,
conn_dlg->users_dlg->end_active_widget_list);
conn_dlg->users_dlg->active_widget_list = NULL;
conn_dlg->users_dlg->begin_widget_list =
conn_dlg->users_dlg->scroll->pscroll_bar;
conn_dlg->users_dlg->scroll->count = 0;
} else {
pConnDlg->pUsers_Dlg = fc_calloc(1, sizeof(struct advanced_dialog));
pConnDlg->pUsers_Dlg->end_widget_list = pConnDlg->begin_widget_list;
pConnDlg->pUsers_Dlg->begin_widget_list = pConnDlg->begin_widget_list;
create_vertical_scrollbar(pConnDlg->pUsers_Dlg, 1,
pConnDlg->active, TRUE, TRUE);
pConnDlg->pUsers_Dlg->end_widget_list =
pConnDlg->pUsers_Dlg->end_widget_list->prev;
setup_vertical_scrollbar_area(pConnDlg->pUsers_Dlg->scroll,
conn_dlg->users_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
conn_dlg->users_dlg->end_widget_list = conn_dlg->begin_widget_list;
conn_dlg->users_dlg->begin_widget_list = conn_dlg->begin_widget_list;
create_vertical_scrollbar(conn_dlg->users_dlg, 1,
conn_dlg->active, TRUE, TRUE);
conn_dlg->users_dlg->end_widget_list =
conn_dlg->users_dlg->end_widget_list->prev;
setup_vertical_scrollbar_area(conn_dlg->users_dlg->scroll,
pwindow->size.x + pwindow->size.w - adj_size(30),
pwindow->size.y + adj_size(14), pwindow->size.h - adj_size(44) - adj_size(40), FALSE);
}
hide_scrollbar(pConnDlg->pUsers_Dlg->scroll);
hide_scrollbar(conn_dlg->users_dlg->scroll);
create = TRUE;
conn_list_iterate(game.est_connections, pconn) {
copy_chars_to_utf8_str(pstr, pconn->username);
......
/* add to widget list */
if (create) {
add_widget_to_vertical_scroll_widget_list(pConnDlg->pUsers_Dlg,
buf, pConnDlg->pUsers_Dlg->begin_widget_list, FALSE,
add_widget_to_vertical_scroll_widget_list(conn_dlg->users_dlg,
buf, conn_dlg->users_dlg->begin_widget_list, FALSE,
pwindow->area.x + pwindow->area.w - adj_size(130),
pwindow->size.y + adj_size(14));
create = FALSE;
} else {
add_widget_to_vertical_scroll_widget_list(pConnDlg->pUsers_Dlg,
buf, pConnDlg->pUsers_Dlg->begin_active_widget_list, FALSE,
add_widget_to_vertical_scroll_widget_list(conn_dlg->users_dlg,
buf, conn_dlg->users_dlg->begin_active_widget_list, FALSE,
pwindow->area.x + pwindow->area.w - adj_size(130),
pwindow->size.y + adj_size(14));
}
} conn_list_iterate_end;
pConnDlg->begin_widget_list = pConnDlg->pUsers_Dlg->begin_widget_list;
conn_dlg->begin_widget_list = conn_dlg->users_dlg->begin_widget_list;
FREEUTF8STR(pstr);
/* FIXME: implement the server settings dialog and then reactivate this part */
#if 0
if (ALLOW_CTRL == client.conn.access_level
|| ALLOW_HACK == client.conn.access_level) {
set_wstate(pConnDlg->pConfigure, FC_WS_NORMAL);
set_wstate(conn_dlg->pConfigure, FC_WS_NORMAL);
} else {
set_wstate(pConnDlg->pConfigure, FC_WS_DISABLED);
set_wstate(conn_dlg->pConfigure, FC_WS_DISABLED);
}
#endif
/* redraw */
redraw_group(pConnDlg->begin_widget_list, pConnDlg->end_widget_list, 0);
redraw_group(conn_dlg->begin_widget_list, conn_dlg->end_widget_list, 0);
widget_flush(pConnDlg->end_widget_list);
widget_flush(conn_dlg->end_widget_list);
} else {
popup_conn_list_dialog();
}
......
SDL_Rect area;
SDL_Surface *surf;
if (pConnDlg || !client.conn.established) {
if (conn_dlg || !client.conn.established) {
return;
}
meswin_dialog_popdown();
pConnDlg = fc_calloc(1, sizeof(struct CONNLIST));
conn_dlg = fc_calloc(1, sizeof(struct CONNLIST));
pwindow = create_window_skeleton(NULL, NULL, 0);
pwindow->action = conn_dlg_callback;
set_wstate(pwindow, FC_WS_NORMAL);
clear_wflag(pwindow, WF_DRAW_FRAME_AROUND_WIDGET);
pConnDlg->end_widget_list = pwindow;
conn_dlg->end_widget_list = pwindow;
add_to_gui_list(ID_WINDOW, pwindow);
widget_set_position(pwindow, 0, 0);
......
FREESURFACE(surf);
}
pConnDlg->text_width = pwindow->size.w - adj_size(130) - adj_size(20) - adj_size(20);
conn_dlg->text_width = pwindow->size.w - adj_size(130) - adj_size(20) - adj_size(20);
/* chat area background */
area.x = adj_size(10);
area.y = adj_size(14);
area.w = pConnDlg->text_width + adj_size(20);
area.w = conn_dlg->text_width + adj_size(20);
area.h = pwindow->size.h - adj_size(44) - adj_size(40);
fill_rect_alpha(pwindow->theme, &area, &window_bg_color);
......
/* chat area */
pConnDlg->pChat_Dlg = fc_calloc(1, sizeof(struct advanced_dialog));
conn_dlg->chat_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
n = conn_list_size(game.est_connections);
......
pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
pLabel = create_themelabel2(NULL, pwindow->dst,
pstr, pConnDlg->text_width, 0,
pstr, conn_dlg->text_width, 0,
(WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
widget_set_position(pLabel, adj_size(10), adj_size(14));
add_to_gui_list(ID_LABEL, pLabel);
pConnDlg->pChat_Dlg->begin_widget_list = pLabel;
pConnDlg->pChat_Dlg->end_widget_list = pLabel;
pConnDlg->pChat_Dlg->begin_active_widget_list = pConnDlg->pChat_Dlg->begin_widget_list;
pConnDlg->pChat_Dlg->end_active_widget_list = pConnDlg->pChat_Dlg->end_widget_list;
conn_dlg->chat_dlg->begin_widget_list = pLabel;
conn_dlg->chat_dlg->end_widget_list = pLabel;
conn_dlg->chat_dlg->begin_active_widget_list = conn_dlg->chat_dlg->begin_widget_list;
conn_dlg->chat_dlg->end_active_widget_list = conn_dlg->chat_dlg->end_widget_list;
n = (pwindow->size.h - adj_size(44) - adj_size(40)) / pLabel->size.h;
pConnDlg->active = n;
conn_dlg->active = n;
create_vertical_scrollbar(pConnDlg->pChat_Dlg, 1,
pConnDlg->active, TRUE, TRUE);
create_vertical_scrollbar(conn_dlg->chat_dlg, 1,
conn_dlg->active, TRUE, TRUE);
setup_vertical_scrollbar_area(pConnDlg->pChat_Dlg->scroll,
adj_size(10) + pConnDlg->text_width + 1,
setup_vertical_scrollbar_area(conn_dlg->chat_dlg->scroll,
adj_size(10) + conn_dlg->text_width + 1,
adj_size(14), pwindow->size.h - adj_size(44) - adj_size(40), FALSE);
hide_scrollbar(pConnDlg->pChat_Dlg->scroll);
hide_scrollbar(conn_dlg->chat_dlg->scroll);
/* -------------------------------- */
......
buf->size.y = pwindow->size.h - adj_size(40) - adj_size(5) - buf->size.h;
buf->action = input_edit_conn_callback;
set_wstate(buf, FC_WS_NORMAL);
pConnDlg->pedit = buf;
conn_dlg->pedit = buf;
add_to_gui_list(ID_EDIT, buf);
/* buttons */
......
_("Back"), adj_font(12), 0);
buf->size.x = adj_size(10);
buf->size.y = pwindow->size.h - adj_size(10) - buf->size.h;
pConnDlg->pBackButton = buf;
conn_dlg->pBackButton = buf;
buf->action = disconnect_conn_callback;
set_wstate(buf, FC_WS_NORMAL);
buf->key = SDLK_ESCAPE;
......
_("Start"), adj_font(12), 0);
buf->size.x = pwindow->size.w - adj_size(10) - buf->size.w;
buf->size.y = pBackButton->size.y;
pConnDlg->start_button = buf;
conn_dlg->start_button = buf;
buf->action = start_game_callback;
set_wstate(buf, FC_WS_NORMAL);
add_to_gui_list(ID_BUTTON, buf);
......
buf->size.h = start_game_button->size.h;
buf->size.x = start_game_button->size.x - adj_size(10) - buf->size.w;
buf->size.y = start_game_button->size.y;
pConnDlg->pSelectNationButton = buf;
conn_dlg->pSelectNationButton = buf;
buf->action = select_nation_callback;
set_wstate(buf, FC_WS_NORMAL);
add_to_gui_list(ID_BUTTON, buf);
......
buf->size.h = pSelectNationButton->size.h;
buf->size.x = pSelectNationButton->size.x - adj_size(10) - buf->size.w;
buf->size.y = pSelectNationButton->size.y;
pConnDlg->pLoadGameButton = buf;
conn_dlg->pLoadGameButton = buf;
buf->action = load_game_callback;
set_wstate(buf, FC_WS_NORMAL);
add_to_gui_list(ID_BUTTON, buf);
......
buf->size.h = pSelectNationButton->size.h;
buf->size.x = pSelectNationButton->size.x - adj_size(10) - buf->size.w;
buf->size.y = pSelectNationButton->size.y;
pConnDlg->pConfigure = buf;
conn_dlg->pConfigure = buf;
buf->action = server_config_callback;
set_wstate(buf, FC_WS_DISABLED);
add_to_gui_list(ID_BUTTON, buf);
......
add_to_gui_list(ID_BUTTON, buf);
#endif
pConnDlg->begin_widget_list = buf;
conn_dlg->begin_widget_list = buf;
/* ------------------------------------------------------------ */
conn_list_dialog_update();
......
**************************************************************************/
bool popdown_conn_list_dialog(void)
{
if (pConnDlg) {
if (get_wstate(pConnDlg->pedit) == FC_WS_PRESSED) {
if (conn_dlg) {
if (get_wstate(conn_dlg->pedit) == FC_WS_PRESSED) {
force_exit_from_event_loop();
}
popdown_window_group_dialog(pConnDlg->begin_widget_list,
pConnDlg->end_widget_list);
if (pConnDlg->pUsers_Dlg) {
FC_FREE(pConnDlg->pUsers_Dlg->scroll);
FC_FREE(pConnDlg->pUsers_Dlg);
popdown_window_group_dialog(conn_dlg->begin_widget_list,
conn_dlg->end_widget_list);
if (conn_dlg->users_dlg) {
FC_FREE(conn_dlg->users_dlg->scroll);
FC_FREE(conn_dlg->users_dlg);
}
if (pConnDlg->pChat_Dlg) {
FC_FREE(pConnDlg->pChat_Dlg->scroll);
FC_FREE(pConnDlg->pChat_Dlg);
if (conn_dlg->chat_dlg) {
FC_FREE(conn_dlg->chat_dlg->scroll);
FC_FREE(conn_dlg->chat_dlg);
}
FC_FREE(pConnDlg);
FC_FREE(conn_dlg);
return TRUE;
}
client/gui-sdl2/citydlg.c
static float city_map_zoom = 1;
static struct small_dialog *pHurry_Prod_Dlg = NULL;
static struct small_dialog *hurry_prog_dlg = NULL;
static void popdown_hurry_production_dialog(void);
static void disable_city_dlg_widgets(void);
......
FC_FREE(pcity_dlg->pPanel);
}
if (pHurry_Prod_Dlg) {
del_group_of_widgets_from_gui_list(pHurry_Prod_Dlg->begin_widget_list,
pHurry_Prod_Dlg->end_widget_list);
if (hurry_prog_dlg) {
del_group_of_widgets_from_gui_list(hurry_prog_dlg->begin_widget_list,
hurry_prog_dlg->end_widget_list);
FC_FREE(pHurry_Prod_Dlg);
FC_FREE(hurry_prog_dlg);
}
free_city_units_lists();
......
**************************************************************************/
static void popdown_hurry_production_dialog(void)
{
if (pHurry_Prod_Dlg) {
popdown_window_group_dialog(pHurry_Prod_Dlg->begin_widget_list,
pHurry_Prod_Dlg->end_widget_list);
FC_FREE(pHurry_Prod_Dlg);
if (hurry_prog_dlg) {
popdown_window_group_dialog(hurry_prog_dlg->begin_widget_list,
hurry_prog_dlg->end_widget_list);
FC_FREE(hurry_prog_dlg);
flush_dirty();
}
}
......
static int hurry_production_window_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pHurry_Prod_Dlg->begin_widget_list, pwindow);
move_window_group(hurry_prog_dlg->begin_widget_list, pwindow);
}
return -1;
}
......
const char *name = city_production_name_translation(pcity);
int value = pcity->client.buy_cost;
if (pHurry_Prod_Dlg) {
if (hurry_prog_dlg) {
return;
}
......
client_player()->economic.gold),
client_player()->economic.gold);
pHurry_Prod_Dlg = fc_calloc(1, sizeof(struct small_dialog));
hurry_prog_dlg = fc_calloc(1, sizeof(struct small_dialog));
if (city_can_buy(pcity)) {
if (value <= client_player()->economic.gold) {
......
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_WINDOW, pwindow);
pHurry_Prod_Dlg->end_widget_list = pwindow;
hurry_prog_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
area.w = MAX(area.w , 2 * buf->size.w + adj_size(20));
}
pHurry_Prod_Dlg->begin_widget_list = buf;
hurry_prog_dlg->begin_widget_list = buf;
/* setup window size and start position */
area.w += adj_size(10);
......
}
/* ================================================== */
/* redraw */
redraw_group(pHurry_Prod_Dlg->begin_widget_list, pwindow, 0);
redraw_group(hurry_prog_dlg->begin_widget_list, pwindow, 0);
widget_mark_dirty(pwindow);
flush_dirty();
}
client/gui-sdl2/cma_fe.c
static struct cma_dialog {
struct city *pcity;
struct small_dialog *pDlg;
struct small_dialog *dlg;
struct advanced_dialog *pAdv;
struct cm_parameter edited_cm_parm;
} *pCma = NULL;
......
}
/* exit button */
pbuf = pCma->pDlg->end_widget_list->prev;
pbuf = pCma->dlg->end_widget_list->prev;
output_type_iterate(i) {
/* min label */
pbuf = pbuf->prev;
......
{
SDL_Color bg_color = {255, 255, 255, 136};
int count, step, i;
struct widget *buf = pCma->pDlg->end_widget_list; /* pwindow */
struct widget *buf = pCma->dlg->end_widget_list; /* pwindow */
SDL_Surface *text;
utf8_str *pstr;
SDL_Rect dst;
......
FREESURFACE(text);
/* happy factor scrollbar */
buf = pCma->pDlg->begin_widget_list->next->next->next->next->next->next->next;
buf = pCma->dlg->begin_widget_list->next->next->next->next->next->next->next;
if (client_under_control && get_checkbox_state(buf->prev)) {
set_wstate(buf, FC_WS_NORMAL);
} else {
......
}
/* redraw rest widgets */
redraw_group(pCma->pDlg->begin_widget_list,
pCma->pDlg->end_widget_list->prev->prev, 0);
redraw_group(pCma->dlg->begin_widget_list,
pCma->dlg->end_widget_list->prev->prev, 0);
widget_flush(pCma->pDlg->end_widget_list);
widget_flush(pCma->dlg->end_widget_list);
cm_result_destroy(result);
}
......
pCma = fc_calloc(1, sizeof(struct cma_dialog));
pCma->pcity = pcity;
pCma->pDlg = fc_calloc(1, sizeof(struct small_dialog));
pCma->dlg = fc_calloc(1, sizeof(struct small_dialog));
pCma->pAdv = NULL;
pcity_map = get_scaled_city_map(pcity);
......
pwindow->action = cma_dlg_callback;
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_WINDOW, pwindow);
pCma->pDlg->end_widget_list = pwindow;
pCma->dlg->end_widget_list = pwindow;
area = pwindow->area;
......
add_to_gui_list(ID_ICON, buf);
/* -------------------------------- */
pCma->pDlg->begin_widget_list = buf;
pCma->dlg->begin_widget_list = buf;
#ifdef SMALL_SCREEN
area.w = MAX(pcity_map->w + adj_size(220) + text_w + adj_size(10) +
......
void popdown_city_cma_dialog(void)
{
if (pCma) {
popdown_window_group_dialog(pCma->pDlg->begin_widget_list,
pCma->pDlg->end_widget_list);
FC_FREE(pCma->pDlg);
popdown_window_group_dialog(pCma->dlg->begin_widget_list,
pCma->dlg->end_widget_list);
FC_FREE(pCma->dlg);
if (pCma->pAdv) {
del_group_of_widgets_from_gui_list(pCma->pAdv->begin_widget_list,
pCma->pAdv->end_widget_list);
client/gui-sdl2/connectdlg.c
static struct server_scan *pServer_scan = NULL;
static struct advanced_dialog *pMeta_Server = NULL;
static struct small_dialog *pConnectDlg = NULL;
static struct small_dialog *connect_dlg = NULL;
static int connect_callback(struct widget *pwidget);
static int convert_portnr_callback(struct widget *pwidget);
......
queue_flush();
close_connection_dialog();
pConnectDlg = fc_calloc(1, sizeof(struct small_dialog));
connect_dlg = fc_calloc(1, sizeof(struct small_dialog));
/* window */
pwindow = create_window_skeleton(NULL, NULL, 0);
add_to_gui_list(ID_WINDOW, pwindow);
pConnectDlg->end_widget_list = pwindow;
connect_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
area.h += buf->size.h + adj_size(10);
/* ------------------------------ */
pConnectDlg->begin_widget_list = buf;
connect_dlg->begin_widget_list = buf;
dialog_w = MAX(adj_size(40) + buf->size.w * 2, adj_size(210)) + adj_size(80);
......
(main_window_height() - pwindow->size.h) / 2 + adj_size(40));
/* player name label */
buf = pConnectDlg->end_widget_list->prev;
buf = connect_dlg->end_widget_list->prev;
start_x = area.x + (area.w - buf->prev->size.w) / 2;
pos_y = area.y + adj_size(20);
......
buf->size.x = buf->next->size.x + buf->size.w + adj_size(40);
buf->size.y = pos_y;
redraw_group(pConnectDlg->begin_widget_list, pConnectDlg->end_widget_list, FALSE);
redraw_group(connect_dlg->begin_widget_list, connect_dlg->end_widget_list, FALSE);
flush_all();
}
......
queue_flush();
close_connection_dialog();
pConnectDlg = fc_calloc(1, sizeof(struct small_dialog));
connect_dlg = fc_calloc(1, sizeof(struct small_dialog));
pwindow = create_window_skeleton(NULL, NULL, 0);
add_to_gui_list(ID_WINDOW, pwindow);
pConnectDlg->end_widget_list = pwindow;
connect_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
/* ------------------------------ */
pConnectDlg->begin_widget_list = buf;
connect_dlg->begin_widget_list = buf;
area.w = MAX(area.w, buf->size.w * 2 + adj_size(40));
area.w = MAX(area.w, adj_size(210) - (pwindow->size.w - pwindow->area.w));
......
(main_window_height() - pwindow->size.h) / 2);
/* text label */
buf = pConnectDlg->end_widget_list->prev;
buf = connect_dlg->end_widget_list->prev;
start_x = area.x + (area.w - buf->size.w) / 2;
start_y = area.y + adj_size(10);
......
buf->next->size.x + buf->size.w + adj_size(40),
start_button_y);
redraw_group(pConnectDlg->begin_widget_list, pConnectDlg->end_widget_list, FALSE);
redraw_group(connect_dlg->begin_widget_list, connect_dlg->end_widget_list, FALSE);
flush_all();
}
......
queue_flush();
close_connection_dialog();
pConnectDlg = fc_calloc(1, sizeof(struct small_dialog));
connect_dlg = fc_calloc(1, sizeof(struct small_dialog));
pwindow = create_window_skeleton(NULL, NULL, 0);
add_to_gui_list(ID_WINDOW, pwindow);
pConnectDlg->end_widget_list = pwindow;
connect_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
/* ------------------------------ */
pConnectDlg->begin_widget_list = buf;
connect_dlg->begin_widget_list = buf;
area.w = buf->size.w * 2 + adj_size(40);
area.w = MAX(area.w, adj_size(210) - (pwindow->size.w - pwindow->area.w));
......
(main_window_height() - pwindow->size.h) / 2);
/* text label */
buf = pConnectDlg->end_widget_list->prev;
buf = connect_dlg->end_widget_list->prev;
start_x = area.x + (area.w - buf->size.w) / 2;
start_y = area.y + adj_size(10);
......
buf->next->size.x + buf->size.w + adj_size(40),
start_button_y);
redraw_group(pConnectDlg->begin_widget_list, pConnectDlg->end_widget_list, FALSE);
redraw_group(connect_dlg->begin_widget_list, connect_dlg->end_widget_list, FALSE);
flush_all();
}
......
**************************************************************************/
void close_connection_dialog(void)
{
if (pConnectDlg) {
popdown_window_group_dialog(pConnectDlg->begin_widget_list,
pConnectDlg->end_widget_list);
FC_FREE(pConnectDlg);
if (connect_dlg) {
popdown_window_group_dialog(connect_dlg->begin_widget_list,
connect_dlg->end_widget_list);
FC_FREE(connect_dlg);
}
if (pMeta_Server) {
popdown_window_group_dialog(pMeta_Server->begin_widget_list,
client/gui-sdl2/dialogs.c
}
/* ----------------------------------------------------------------------- */
struct advanced_dialog *pNotifyDlg = NULL;
struct advanced_dialog *notify_dlg = NULL;
/**********************************************************************//**
User interacted with generic notify dialog.
......
static int notify_dialog_window_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pNotifyDlg->begin_widget_list, pwindow);
move_window_group(notify_dlg->begin_widget_list, pwindow);
}
return -1;
......
static int exit_notify_dialog_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pNotifyDlg) {
popdown_window_group_dialog(pNotifyDlg->begin_widget_list,
pNotifyDlg->end_widget_list);
FC_FREE(pNotifyDlg->scroll);
FC_FREE(pNotifyDlg);
if (notify_dlg) {
popdown_window_group_dialog(notify_dlg->begin_widget_list,
notify_dlg->end_widget_list);
FC_FREE(notify_dlg->scroll);
FC_FREE(notify_dlg);
flush_dirty();
}
}
......
SDL_Rect dst;
SDL_Rect area;
if (pNotifyDlg) {
if (notify_dlg) {
return;
}
pNotifyDlg = fc_calloc(1, sizeof(struct advanced_dialog));
notify_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
pstr = create_utf8_from_char(caption, adj_font(12));
pstr->style |= TTF_STYLE_BOLD;
......
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_WINDOW, pwindow);
pNotifyDlg->end_widget_list = pwindow;
notify_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
area.w += (buf->size.w + adj_size(10));
add_to_gui_list(ID_BUTTON, buf);
pNotifyDlg->begin_widget_list = buf;
notify_dlg->begin_widget_list = buf;
pstr = create_utf8_from_char(headline, adj_font(16));
pstr->style |= TTF_STYLE_BOLD;
......
buf->size.y = pwindow->size.y + adj_size(2);
/* redraw */
redraw_group(pNotifyDlg->begin_widget_list, pwindow, 0);
redraw_group(notify_dlg->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
}
......
/* ====================================================================== */
/* ========================= ADVANCED_TERRAIN_MENU ====================== */
/* ====================================================================== */
struct advanced_dialog *pAdvanced_Terrain_Dlg = NULL;
struct advanced_dialog *advanced_terrain_dlg = NULL;
/**********************************************************************//**
Popdown a generic dialog to display some generic information about
......
**************************************************************************/
void popdown_advanced_terrain_dialog(void)
{
if (pAdvanced_Terrain_Dlg) {
if (advanced_terrain_dlg) {
is_unit_move_blocked = FALSE;
popdown_window_group_dialog(pAdvanced_Terrain_Dlg->begin_widget_list,
pAdvanced_Terrain_Dlg->end_widget_list);
popdown_window_group_dialog(advanced_terrain_dlg->begin_widget_list,
advanced_terrain_dlg->end_widget_list);
FC_FREE(pAdvanced_Terrain_Dlg->scroll);
FC_FREE(pAdvanced_Terrain_Dlg);
FC_FREE(advanced_terrain_dlg->scroll);
FC_FREE(advanced_terrain_dlg);
}
}
......
int advanced_terrain_window_dlg_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pAdvanced_Terrain_Dlg->begin_widget_list, pwindow);
move_window_group(advanced_terrain_dlg->begin_widget_list, pwindow);
}
return -1;
}
......
int n, w = 0, h, units_h = 0;
SDL_Rect area;
if (pAdvanced_Terrain_Dlg) {
if (advanced_terrain_dlg) {
return;
}
......
area.h = adj_size(2);
is_unit_move_blocked = TRUE;
pAdvanced_Terrain_Dlg = fc_calloc(1, sizeof(struct advanced_dialog));
advanced_terrain_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
pCont = fc_calloc(1, sizeof(struct container));
pCont->id0 = index_to_map_pos_x(tile_index(ptile));
......
set_wstate(pwindow , FC_WS_NORMAL);
add_to_gui_list(ID_TERRAIN_ADV_DLG_WINDOW, pwindow);
pAdvanced_Terrain_Dlg->end_widget_list = pwindow;
advanced_terrain_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
}
}
pAdvanced_Terrain_Dlg->begin_widget_list = buf;
advanced_terrain_dlg->begin_widget_list = buf;
/* ---------- */
if (n) {
......
}
}
pAdvanced_Terrain_Dlg->end_active_widget_list = pLast->prev;
pAdvanced_Terrain_Dlg->active_widget_list = pAdvanced_Terrain_Dlg->end_active_widget_list;
pAdvanced_Terrain_Dlg->begin_widget_list = buf;
pAdvanced_Terrain_Dlg->begin_active_widget_list = pAdvanced_Terrain_Dlg->begin_widget_list;
advanced_terrain_dlg->end_active_widget_list = pLast->prev;
advanced_terrain_dlg->active_widget_list = advanced_terrain_dlg->end_active_widget_list;
advanced_terrain_dlg->begin_widget_list = buf;
advanced_terrain_dlg->begin_active_widget_list = advanced_terrain_dlg->begin_widget_list;
if (n > ADV_NUM_SEEN) {
units_h = ADV_NUM_SEEN * buf->size.h;
n = create_vertical_scrollbar(pAdvanced_Terrain_Dlg,
n = create_vertical_scrollbar(advanced_terrain_dlg,
1, ADV_NUM_SEEN, TRUE, TRUE);
area.w += n;
}
......
fc_snprintf(cBuf, sizeof(cBuf), "%s (%d)", _("Ready all"), my_units);
create_active_iconlabel(buf, pwindow->dst, pstr,
cBuf, adv_unit_select_all_callback);
buf->data.unit = pAdvanced_Terrain_Dlg->end_active_widget_list->data.unit;
buf->data.unit = advanced_terrain_dlg->end_active_widget_list->data.unit;
set_wstate(buf, FC_WS_NORMAL);
buf->ID = ID_LABEL;
widget_add_as_prev(buf, pLast);
......
fc_snprintf(cBuf, sizeof(cBuf), "%s (%d)", _("Sentry idle"), my_units);
create_active_iconlabel(buf, pwindow->dst, pstr,
cBuf, adv_unit_sentry_idle_callback);
buf->data.unit = pAdvanced_Terrain_Dlg->end_active_widget_list->data.unit;
buf->data.unit = advanced_terrain_dlg->end_active_widget_list->data.unit;
set_wstate(buf, FC_WS_NORMAL);
buf->ID = ID_LABEL;
widget_add_as_prev(buf, pLast->prev);
......
area.w = MAX(area.w, buf->size.w);
units_h += buf->size.h;
/* ---------------- */
pAdvanced_Terrain_Dlg->begin_widget_list = buf;
advanced_terrain_dlg->begin_widget_list = buf;
}
}
......
w = area.w - adj_size(2);
if (pAdvanced_Terrain_Dlg->scroll) {
if (advanced_terrain_dlg->scroll) {
units_h = n;
} else {
units_h = 0;
......
buf = buf->prev;
while (buf) {
if (buf == pAdvanced_Terrain_Dlg->end_active_widget_list) {
if (buf == advanced_terrain_dlg->end_active_widget_list) {
w -= units_h;
}
......
*get_theme_color(COLOR_THEME_ADVANCEDTERRAINDLG_TEXT)));
}
if (buf == pAdvanced_Terrain_Dlg->begin_widget_list
|| buf == pAdvanced_Terrain_Dlg->begin_active_widget_list) {
if (buf == advanced_terrain_dlg->begin_widget_list
|| buf == advanced_terrain_dlg->begin_active_widget_list) {
break;
}
buf = buf->prev;
}
if (pAdvanced_Terrain_Dlg->scroll) {
setup_vertical_scrollbar_area(pAdvanced_Terrain_Dlg->scroll,
if (advanced_terrain_dlg->scroll) {
setup_vertical_scrollbar_area(advanced_terrain_dlg->scroll,
area.x + area.w,
pAdvanced_Terrain_Dlg->end_active_widget_list->size.y,
area.y - pAdvanced_Terrain_Dlg->end_active_widget_list->size.y + area.h,
advanced_terrain_dlg->end_active_widget_list->size.y,
area.y - advanced_terrain_dlg->end_active_widget_list->size.y + area.h,
TRUE);
}
/* -------------------- */
/* redraw */
redraw_group(pAdvanced_Terrain_Dlg->begin_widget_list, pwindow, 0);
redraw_group(advanced_terrain_dlg->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
}
......
/* ====================================================================== */
/* ============================ PILLAGE DIALOG ========================== */
/* ====================================================================== */
static struct small_dialog *pPillage_Dlg = NULL;
static struct small_dialog *pillage_dlg = NULL;
/**********************************************************************//**
User interacted with pillage dialog.
......
static int pillage_window_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pPillage_Dlg->begin_widget_list, pwindow);
move_window_group(pillage_dlg->begin_widget_list, pwindow);
}
return -1;
}
......
**************************************************************************/
static void popdown_pillage_dialog(void)
{
if (pPillage_Dlg) {
if (pillage_dlg) {
is_unit_move_blocked = FALSE;
popdown_window_group_dialog(pPillage_Dlg->begin_widget_list,
pPillage_Dlg->end_widget_list);
FC_FREE(pPillage_Dlg);
popdown_window_group_dialog(pillage_dlg->begin_widget_list,
pillage_dlg->end_widget_list);
FC_FREE(pillage_dlg);
flush_dirty();
}
}
......
SDL_Rect area;
struct extra_type *tgt;
if (pPillage_Dlg) {
if (pillage_dlg) {
return;
}
is_unit_move_blocked = TRUE;
pPillage_Dlg = fc_calloc(1, sizeof(struct small_dialog));
pillage_dlg = fc_calloc(1, sizeof(struct small_dialog));
/* window */
pstr = create_utf8_from_char(_("What To Pillage") , adj_font(12));
......
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_PILLAGE_DLG_WINDOW, pwindow);
pPillage_Dlg->end_widget_list = pwindow;
pillage_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
area.w = MAX(area.w, buf->size.w);
area.h += buf->size.h;
}
pPillage_Dlg->begin_widget_list = buf;
pillage_dlg->begin_widget_list = buf;
/* setup window size and start position */
......
buf = buf->prev;
setup_vertical_widgets_position(1,
area.x, area.y + 1, area.w, 0,
pPillage_Dlg->begin_widget_list, buf);
pillage_dlg->begin_widget_list, buf);
/* --------------------- */
/* redraw */
redraw_group(pPillage_Dlg->begin_widget_list, pwindow, 0);
redraw_group(pillage_dlg->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
}
......
/* ======================================================================= */
/* =========================== CONNECT DIALOG ============================ */
/* ======================================================================= */
static struct small_dialog *pConnect_Dlg = NULL;
static struct small_dialog *connect_dlg = NULL;
/**********************************************************************//**
Popdown a dialog asking the unit how they want to "connect" their
......
**************************************************************************/
static void popdown_connect_dialog(void)
{
if (pConnect_Dlg) {
if (connect_dlg) {
is_unit_move_blocked = FALSE;
popdown_window_group_dialog(pConnect_Dlg->begin_widget_list,
pConnect_Dlg->end_widget_list);
FC_FREE(pConnect_Dlg);
popdown_window_group_dialog(connect_dlg->begin_widget_list,
connect_dlg->end_widget_list);
FC_FREE(connect_dlg);
}
}
......
/**************************************************************************
Select Goverment Type
**************************************************************************/
static struct small_dialog *pGov_Dlg = NULL;
static struct small_dialog *gov_dlg = NULL;
/**********************************************************************//**
Close the government dialog.
**************************************************************************/
static void popdown_government_dialog(void)
{
if (pGov_Dlg) {
popdown_window_group_dialog(pGov_Dlg->begin_widget_list,
pGov_Dlg->end_widget_list);
FC_FREE(pGov_Dlg);
if (gov_dlg) {
popdown_window_group_dialog(gov_dlg->begin_widget_list,
gov_dlg->end_widget_list);
FC_FREE(gov_dlg);
enable_and_redraw_revolution_button();
}
}
......
static int move_government_dlg_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pGov_Dlg->begin_widget_list, pwindow);
move_window_group(gov_dlg->begin_widget_list, pwindow);
}
return -1;
}
......
Uint16 max_w = 0, max_h = 0;
SDL_Rect area;
if (pGov_Dlg) {
if (gov_dlg) {
return;
}
pGov_Dlg = fc_calloc(1, sizeof(struct small_dialog));
gov_dlg = fc_calloc(1, sizeof(struct small_dialog));
/* create window */
pstr = create_utf8_from_char(_("Choose Your New Government"), adj_font(12));
......
pwindow->action = move_government_dlg_callback;
add_to_gui_list(ID_GOVERNMENT_DLG_WINDOW, pwindow);
pGov_Dlg->end_widget_list = pwindow;
gov_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
}
} governments_iterate_end;
pGov_Dlg->begin_widget_list = gov_button;
gov_dlg->begin_widget_list = gov_button;
max_w += adj_size(10);
max_h += adj_size(4);
......
/* set buttons start positions and size */
j = 1;
while (gov_button != pGov_Dlg->end_widget_list) {
while (gov_button != gov_dlg->end_widget_list) {
gov_button->size.w = max_w;
gov_button->size.h = max_h;
gov_button->size.x = area.x + adj_size(10);
......
set_wstate(pwindow, FC_WS_NORMAL);
/* redraw */
redraw_group(pGov_Dlg->begin_widget_list, pwindow, 0);
redraw_group(gov_dlg->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
}
......
/**************************************************************************
Nation Wizard
**************************************************************************/
static struct advanced_dialog *pNationDlg = NULL;
static struct advanced_dialog *nation_dlg = NULL;
static struct small_dialog *help_dlg = NULL;
struct NAT {
......
static int nations_dialog_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
if (select_window_group_dialog(pNationDlg->begin_widget_list, pwindow)) {
if (select_window_group_dialog(nation_dlg->begin_widget_list, pwindow)) {
widget_flush(pwindow);
}
}
......
static int races_dialog_ok_callback(struct widget *start_button)
{
if (PRESSED_EVENT(main_data.event)) {
struct NAT *pSetup = (struct NAT *)(pNationDlg->end_widget_list->data.ptr);
struct NAT *pSetup = (struct NAT *)(nation_dlg->end_widget_list->data.ptr);
char *pstr = pSetup->name_edit->string_utf8->text;
/* perform a minimum of sanity test on the name */
......
static int change_sex_callback(struct widget *pSex)
{
if (PRESSED_EVENT(main_data.event)) {
struct NAT *pSetup = (struct NAT *)(pNationDlg->end_widget_list->data.ptr);
struct NAT *pSetup = (struct NAT *)(nation_dlg->end_widget_list->data.ptr);
if (pSetup->leader_sex) {
copy_chars_to_utf8_str(pSetup->pChange_Sex->string_utf8, _("Female"));
......
static int next_name_callback(struct widget *pNext)
{
if (PRESSED_EVENT(main_data.event)) {
struct NAT *pSetup = (struct NAT *)(pNationDlg->end_widget_list->data.ptr);
struct NAT *pSetup = (struct NAT *)(nation_dlg->end_widget_list->data.ptr);
const struct nation_leader_list *leaders =
nation_leaders(nation_by_number(pSetup->nation));
const struct nation_leader *pleader;
......
static int prev_name_callback(struct widget *pPrev)
{
if (PRESSED_EVENT(main_data.event)) {
struct NAT *pSetup = (struct NAT *)(pNationDlg->end_widget_list->data.ptr);
struct NAT *pSetup = (struct NAT *)(nation_dlg->end_widget_list->data.ptr);
const struct nation_leader_list *leaders =
nation_leaders(nation_by_number(pSetup->nation));
const struct nation_leader *pleader;
......
static int next_set_callback(struct widget *next_button)
{
if (PRESSED_EVENT(main_data.event)) {
struct NAT *pSetup = (struct NAT *)(pNationDlg->end_widget_list->data.ptr);
struct NAT *pSetup = (struct NAT *)(nation_dlg->end_widget_list->data.ptr);
struct option *poption = optset_option_by_name(server_optset, "nationset");
fc_assert(pSetup->set != NULL
......
static int prev_set_callback(struct widget *prev_button)
{
if (PRESSED_EVENT(main_data.event)) {
struct NAT *pSetup = (struct NAT *)(pNationDlg->end_widget_list->data.ptr);
struct NAT *pSetup = (struct NAT *)(nation_dlg->end_widget_list->data.ptr);
struct option *poption = optset_option_by_name(server_optset, "nationset");
fc_assert(pSetup->set != NULL && nation_set_index(pSetup->set) > 0);
......
static int style_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct NAT *pSetup = (struct NAT *)(pNationDlg->end_widget_list->data.ptr);
struct NAT *pSetup = (struct NAT *)(nation_dlg->end_widget_list->data.ptr);
struct widget *pGUI = get_widget_pointer_form_main_list(MAX_ID - 1000 -
pSetup->nation_style);
......
selected_widget = pNationButton;
if (PRESSED_EVENT(main_data.event)) {
struct NAT *pSetup = (struct NAT *)(pNationDlg->end_widget_list->data.ptr);
struct NAT *pSetup = (struct NAT *)(nation_dlg->end_widget_list->data.ptr);
if (pSetup->nation == MAX_ID - pNationButton->ID) {
widget_redraw(pNationButton);
......
select_random_leader(pSetup->nation);
redraw_group(pNationDlg->begin_widget_list, pNationDlg->end_widget_list, 0);
widget_flush(pNationDlg->end_widget_list);
redraw_group(nation_dlg->begin_widget_list, nation_dlg->end_widget_list, 0);
widget_flush(nation_dlg->end_widget_list);
} else {
/* pop up nation description */
struct widget *pwindow, *ok_button;
......
static void change_nation_label(void)
{
SDL_Surface *pTmp_Surf, *pTmp_Surf_zoomed;
struct widget *pwindow = pNationDlg->end_widget_list;
struct widget *pwindow = nation_dlg->end_widget_list;
struct NAT *pSetup = (struct NAT *)(pwindow->data.ptr);
struct widget *pLabel = pSetup->name_edit->next;
struct nation_type *pNation = nation_by_number(pSetup->nation);
......
**************************************************************************/
static void select_random_leader(Nation_type_id nation)
{
struct NAT *pSetup = (struct NAT *)(pNationDlg->end_widget_list->data.ptr);
struct NAT *pSetup = (struct NAT *)(nation_dlg->end_widget_list->data.ptr);
const struct nation_leader_list *leaders =
nation_leaders(nation_by_number(pSetup->nation));
const struct nation_leader *pleader;
......
#define TARGETS_ROW 5
#define TARGETS_COL 1
if (pNationDlg) {
if (nation_dlg) {
return;
}
races_player = pplayer;
pNationDlg = fc_calloc(1, sizeof(struct advanced_dialog));
nation_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
/* create window widget */
pstr = create_utf8_from_char(_("What nation will you be?"), adj_font(12));
......
pSetup = fc_calloc(1, sizeof(struct NAT));
pwindow->data.ptr = (void *)pSetup;
pNationDlg->end_widget_list = pwindow;
nation_dlg->end_widget_list = pwindow;
add_to_gui_list(ID_NATION_WIZARD_WINDOW, pwindow);
/* --------------------------------------------------------- */
/* create nations list */
......
FREESURFACE(pMain_Bg);
pNationDlg->end_active_widget_list = pwindow->prev;
pNationDlg->begin_widget_list = pwidget;
pNationDlg->begin_active_widget_list = pNationDlg->begin_widget_list;
nation_dlg->end_active_widget_list = pwindow->prev;
nation_dlg->begin_widget_list = pwidget;
nation_dlg->begin_active_widget_list = nation_dlg->begin_widget_list;
if (get_playable_nation_count() > TARGETS_ROW * TARGETS_COL) {
pNationDlg->active_widget_list = pNationDlg->end_active_widget_list;
create_vertical_scrollbar(pNationDlg,
nation_dlg->active_widget_list = nation_dlg->end_active_widget_list;
create_vertical_scrollbar(nation_dlg,
TARGETS_COL, TARGETS_ROW, TRUE, TRUE);
}
......
pwidget->size.w = MAX(pwidget->size.w, pwidget->next->size.w);
pwidget->next->size.w = pwidget->size.w;
pNationDlg->begin_widget_list = pwidget;
nation_dlg->begin_widget_list = pwidget;
/* ---------------------------------------------------------- */
pMain_Bg = theme_get_background(theme, BACKGROUND_NATIONDLG);
......
/* nations */
h = pNationDlg->end_active_widget_list->size.h * TARGETS_ROW;
h = nation_dlg->end_active_widget_list->size.h * TARGETS_ROW;
i = (area.h - adj_size(43) - h) / 2;
setup_vertical_widgets_position(TARGETS_COL,
area.x + adj_size(10),
area.y + i - adj_size(4),
0, 0, pNationDlg->begin_active_widget_list,
pNationDlg->end_active_widget_list);
0, 0, nation_dlg->begin_active_widget_list,
nation_dlg->end_active_widget_list);
if (pNationDlg->scroll) {
if (nation_dlg->scroll) {
SDL_Rect area2;
w = pNationDlg->end_active_widget_list->size.w * TARGETS_COL;
setup_vertical_scrollbar_area(pNationDlg->scroll,
w = nation_dlg->end_active_widget_list->size.w * TARGETS_COL;
setup_vertical_scrollbar_area(nation_dlg->scroll,
area.x + w + adj_size(12),
area.y + i - adj_size(4), h, FALSE);
area2.x = area.x + w + adj_size(11);
area2.y = area.y + i - adj_size(4);
area2.w = pNationDlg->scroll->up_left_button->size.w + adj_size(2);
area2.w = nation_dlg->scroll->up_left_button->size.w + adj_size(2);
area2.h = h;
fill_rect_alpha(pwindow->theme, &area2, &bg_color);
......
select_random_leader(pSetup->nation);
redraw_group(pNationDlg->begin_widget_list, pwindow, 0);
redraw_group(nation_dlg->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
}
......
**************************************************************************/
void popdown_races_dialog(void)
{
if (pNationDlg) {
popdown_window_group_dialog(pNationDlg->begin_widget_list,
pNationDlg->end_widget_list);
if (nation_dlg) {
popdown_window_group_dialog(nation_dlg->begin_widget_list,
nation_dlg->end_widget_list);
cancel_help_dlg_callback(NULL);
FC_FREE(pLeaderName);
FC_FREE(pNationDlg->scroll);
FC_FREE(pNationDlg);
FC_FREE(nation_dlg->scroll);
FC_FREE(nation_dlg);
}
}
......
{
/* If this is because of nationset change, update will take
* place later when the new option value is received */
if (pNationDlg != NULL && !nationset_change) {
if (nation_dlg != NULL && !nationset_change) {
popdown_races_dialog();
popup_races_dialog(client.conn.playing);
}
......
**************************************************************************/
void nationset_changed(void)
{
if (pNationDlg != NULL) {
if (nation_dlg != NULL) {
popdown_races_dialog();
popup_races_dialog(client.conn.playing);
}
......
bool change = FALSE;
struct widget *pNat;
if (!pNationDlg) {
if (!nation_dlg) {
return;
}
pSetup = (struct NAT *)(pNationDlg->end_widget_list->data.ptr);
pSetup = (struct NAT *)(nation_dlg->end_widget_list->data.ptr);
nations_iterate(nation) {
if (!is_nation_pickable(nation) || nation->player) {
......
disable(MAX_ID - 1000 - pSetup->nation_style);
select_random_leader(pSetup->nation);
}
redraw_group(pNationDlg->begin_widget_list, pNationDlg->end_widget_list, 0);
widget_flush(pNationDlg->end_widget_list);
redraw_group(nation_dlg->begin_widget_list, nation_dlg->end_widget_list, 0);
widget_flush(nation_dlg->end_widget_list);
}
/**********************************************************************//**
client/gui-sdl2/diplodlg.c
struct widget *main_window,
bool L_R)
{
struct advanced_dialog *pDlg = fc_calloc(1, sizeof(struct advanced_dialog));
struct advanced_dialog *dlg = fc_calloc(1, sizeof(struct advanced_dialog));
struct container *pCont = fc_calloc(1, sizeof(struct container));
int width, height, count = 0, scroll_w = 0;
char cBuf[128];
......
pwindow->action = dipomatic_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
pDlg->end_widget_list = pwindow;
dlg->end_widget_list = pwindow;
pwindow->data.cont = pCont;
add_to_gui_list(ID_WINDOW, pwindow);
......
FC_FREE(city_list_ptrs);
} /* Cities */
pDlg->begin_widget_list = buf;
pDlg->begin_active_widget_list = pDlg->begin_widget_list;
pDlg->end_active_widget_list = pDlg->end_widget_list->prev;
pDlg->scroll = NULL;
dlg->begin_widget_list = buf;
dlg->begin_active_widget_list = dlg->begin_widget_list;
dlg->end_active_widget_list = dlg->end_widget_list->prev;
dlg->scroll = NULL;
area.h = (main_window_height() - adj_size(100) - (pwindow->size.h - pwindow->area.h));
if (area.h < (count * height)) {
pDlg->active_widget_list = pDlg->end_active_widget_list;
dlg->active_widget_list = dlg->end_active_widget_list;
count = area.h / height;
scroll_w = create_vertical_scrollbar(pDlg, 1, count, TRUE, TRUE);
scroll_w = create_vertical_scrollbar(dlg, 1, count, TRUE, TRUE);
buf = pwindow;
/* hide not seen widgets */
do {
......
} else {
set_wflag(buf, WF_HIDDEN);
}
} while (buf != pDlg->begin_active_widget_list);
} while (buf != dlg->begin_active_widget_list);
}
area.w = MAX(width + adj_size(4) + scroll_w, adj_size(150) - (pwindow->size.w - pwindow->area.w));
......
setup_vertical_widgets_position(1,
area.x + adj_size(2), area.y + 1,
width, height, pDlg->begin_active_widget_list,
pDlg->end_active_widget_list);
width, height, dlg->begin_active_widget_list,
dlg->end_active_widget_list);
if (pDlg->scroll) {
setup_vertical_scrollbar_area(pDlg->scroll,
if (dlg->scroll) {
setup_vertical_scrollbar_area(dlg->scroll,
area.x + area.w,
area.y,
area.h, TRUE);
}
return pDlg;
return dlg;
}
/**********************************************************************//**
......
/* ================================================================= */
/* ========================== Small Diplomat Dialog ================ */
/* ================================================================= */
static struct small_dialog *pSDip_Dlg = NULL;
static struct small_dialog *spy_dlg = NULL;
/**********************************************************************//**
Close small diplomacy dialog.
**************************************************************************/
static void popdown_sdip_dialog(void)
{
if (pSDip_Dlg) {
popdown_window_group_dialog(pSDip_Dlg->begin_widget_list,
pSDip_Dlg->end_widget_list);
FC_FREE(pSDip_Dlg);
if (spy_dlg) {
popdown_window_group_dialog(spy_dlg->begin_widget_list,
spy_dlg->end_widget_list);
FC_FREE(spy_dlg);
}
}
......
static int sdip_window_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pSDip_Dlg->begin_widget_list, pwindow);
move_window_group(spy_dlg->begin_widget_list, pwindow);
}
return -1;
......
SDL_Rect dst;
SDL_Rect area;
if (pSDip_Dlg) {
if (spy_dlg) {
return;
}
pSDip_Dlg = fc_calloc(1, sizeof(struct small_dialog));
spy_dlg = fc_calloc(1, sizeof(struct small_dialog));
fc_snprintf(cBuf, sizeof(cBuf),
/* TRANS: "Polish incident !" FIXME!!! */
......
add_to_gui_list(ID_WINDOW, pwindow);
pSDip_Dlg->end_widget_list = pwindow;
spy_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
buf->next->size.w = buf->size.w;
area.w = MAX(area.w , 2 * buf->size.w + adj_size(20));
pSDip_Dlg->begin_widget_list = buf;
spy_dlg->begin_widget_list = buf;
/* setup window size and start position */
area.w += adj_size(10);
......
/* ================================================== */
/* redraw */
redraw_group(pSDip_Dlg->begin_widget_list, pwindow, 0);
redraw_group(spy_dlg->begin_widget_list, pwindow, 0);
widget_mark_dirty(pwindow);
flush_dirty();
}
......
int buttons = 0;
bool can_toward_war;
if (pSDip_Dlg) {
if (spy_dlg) {
return;
}
pSDip_Dlg = fc_calloc(1, sizeof(struct small_dialog));
spy_dlg = fc_calloc(1, sizeof(struct small_dialog));
fc_snprintf(cBuf, sizeof(cBuf), _("Foreign Minister"));
pstr = create_utf8_from_char(cBuf, adj_font(12));
......
pwindow->action = sdip_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
pSDip_Dlg->end_widget_list = pwindow;
spy_dlg->end_widget_list = pwindow;
add_to_gui_list(ID_WINDOW, pwindow);
......
add_to_gui_list(ID_BUTTON, buf);
pSDip_Dlg->begin_widget_list = buf;
spy_dlg->begin_widget_list = buf;
/* setup window size and start position */
area.w += adj_size(10);
......
/* ================================================== */
/* redraw */
redraw_group(pSDip_Dlg->begin_widget_list, pwindow, 0);
redraw_group(spy_dlg->begin_widget_list, pwindow, 0);
widget_mark_dirty(pwindow);
flush_dirty();
client/gui-sdl2/finddlg.c
/* ====================================================================== */
/* ============================= FIND CITY MENU ========================= */
/* ====================================================================== */
static struct advanced_dialog *pFind_City_Dlg = NULL;
static struct advanced_dialog *find_city_dlg = NULL;
/**********************************************************************//**
User interacted with find city dialog window.
......
static int find_city_window_dlg_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pFind_City_Dlg->begin_widget_list, pwindow);
move_window_group(find_city_dlg->begin_widget_list, pwindow);
}
return -1;
......
**************************************************************************/
void popdown_find_dialog(void)
{
if (pFind_City_Dlg) {
popdown_window_group_dialog(pFind_City_Dlg->begin_widget_list,
pFind_City_Dlg->end_widget_list);
FC_FREE(pFind_City_Dlg->scroll);
FC_FREE(pFind_City_Dlg);
if (find_city_dlg) {
popdown_window_group_dialog(find_city_dlg->begin_widget_list,
find_city_dlg->end_widget_list);
FC_FREE(find_city_dlg->scroll);
FC_FREE(find_city_dlg);
enable_and_redraw_find_city_button();
}
}
......
}
} players_iterate_end;
if (pFind_City_Dlg && !h) {
if (find_city_dlg && !h) {
return;
}
original = canvas_pos_to_tile(main_data.map->w / 2, main_data.map->h / 2);
pFind_City_Dlg = fc_calloc(1, sizeof(struct advanced_dialog));
find_city_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
pstr = create_utf8_from_char(_("Find City") , adj_font(12));
pstr->style |= TTF_STYLE_BOLD;
......
set_wstate(pwindow , FC_WS_NORMAL);
add_to_gui_list(ID_TERRAIN_ADV_DLG_WINDOW, pwindow);
pFind_City_Dlg->end_widget_list = pwindow;
find_city_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
} city_list_iterate_end;
} players_iterate_end;
pFind_City_Dlg->begin_widget_list = buf;
pFind_City_Dlg->begin_active_widget_list = pFind_City_Dlg->begin_widget_list;
pFind_City_Dlg->end_active_widget_list = pwindow->prev->prev;
pFind_City_Dlg->active_widget_list = pFind_City_Dlg->end_active_widget_list;
find_city_dlg->begin_widget_list = buf;
find_city_dlg->begin_active_widget_list = find_city_dlg->begin_widget_list;
find_city_dlg->end_active_widget_list = pwindow->prev->prev;
find_city_dlg->active_widget_list = find_city_dlg->end_active_widget_list;
/* ---------- */
if (n > 20) {
units_h = create_vertical_scrollbar(pFind_City_Dlg, 1, 20, TRUE, TRUE);
pFind_City_Dlg->scroll->count = n;
units_h = create_vertical_scrollbar(find_city_dlg, 1, 20, TRUE, TRUE);
find_city_dlg->scroll->count = n;
n = units_h;
area.w += n;
......
w = area.w;
if (pFind_City_Dlg->scroll) {
if (find_city_dlg->scroll) {
w -= n;
}
......
/* cities */
buf = buf->prev;
setup_vertical_widgets_position(1, area.x, area.y, w, 0,
pFind_City_Dlg->begin_active_widget_list,
find_city_dlg->begin_active_widget_list,
buf);
if (pFind_City_Dlg->scroll) {
setup_vertical_scrollbar_area(pFind_City_Dlg->scroll,
if (find_city_dlg->scroll) {
setup_vertical_scrollbar_area(find_city_dlg->scroll,
area.x + area.w, area.y,
area.h, TRUE);
}
/* -------------------- */
/* redraw */
redraw_group(pFind_City_Dlg->begin_widget_list, pwindow, 0);
redraw_group(find_city_dlg->begin_widget_list, pwindow, 0);
widget_mark_dirty(pwindow);
flush_dirty();
client/gui-sdl2/gotodlg.c
#include "gotodlg.h"
static struct advanced_dialog *pGotoDlg = NULL;
static struct advanced_dialog *goto_dlg = NULL;
bv_player all_players;
static bool GOTO = TRUE;
......
static int goto_dialog_window_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pGotoDlg->begin_widget_list, pwindow);
move_window_group(goto_dlg->begin_widget_list, pwindow);
}
return -1;
......
int n = 0;
struct player *owner = NULL;
if (pGotoDlg->end_active_widget_list) {
add_dock = pGotoDlg->end_active_widget_list->next;
pGotoDlg->begin_widget_list = add_dock;
del_group(pGotoDlg->begin_active_widget_list, pGotoDlg->end_active_widget_list);
pGotoDlg->active_widget_list = NULL;
if (goto_dlg->end_active_widget_list) {
add_dock = goto_dlg->end_active_widget_list->next;
goto_dlg->begin_widget_list = add_dock;
del_group(goto_dlg->begin_active_widget_list, goto_dlg->end_active_widget_list);
goto_dlg->active_widget_list = NULL;
} else {
add_dock = pGotoDlg->begin_widget_list;
add_dock = goto_dlg->begin_widget_list;
}
pLast = add_dock;
......
logo = crop_visible_part_from_surface(logo);
}
buf = create_iconlabel(logo, pGotoDlg->end_widget_list->dst, pstr,
buf = create_iconlabel(logo, goto_dlg->end_widget_list->dst, pstr,
(WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
if (!player_owns_city(owner, pcity)) {
......
widget_add_as_prev(buf, add_dock);
add_dock = buf;
if (n > (pGotoDlg->scroll->active - 1)) {
if (n > (goto_dlg->scroll->active - 1)) {
set_wflag(buf, WF_HIDDEN);
}
......
} players_iterate_end;
if (n > 0) {
pGotoDlg->begin_widget_list = buf;
pGotoDlg->begin_active_widget_list = pGotoDlg->begin_widget_list;
pGotoDlg->end_active_widget_list = pLast->prev;
pGotoDlg->active_widget_list = pGotoDlg->end_active_widget_list;
pGotoDlg->scroll->count = n;
if (n > pGotoDlg->scroll->active) {
show_scrollbar(pGotoDlg->scroll);
pGotoDlg->scroll->pscroll_bar->size.y = pGotoDlg->end_widget_list->area.y +
pGotoDlg->scroll->up_left_button->size.h;
pGotoDlg->scroll->pscroll_bar->size.h = scrollbar_size(pGotoDlg->scroll);
goto_dlg->begin_widget_list = buf;
goto_dlg->begin_active_widget_list = goto_dlg->begin_widget_list;
goto_dlg->end_active_widget_list = pLast->prev;
goto_dlg->active_widget_list = goto_dlg->end_active_widget_list;
goto_dlg->scroll->count = n;
if (n > goto_dlg->scroll->active) {
show_scrollbar(goto_dlg->scroll);
goto_dlg->scroll->pscroll_bar->size.y = goto_dlg->end_widget_list->area.y +
goto_dlg->scroll->up_left_button->size.h;
goto_dlg->scroll->pscroll_bar->size.h = scrollbar_size(goto_dlg->scroll);
} else {
hide_scrollbar(pGotoDlg->scroll);
hide_scrollbar(goto_dlg->scroll);
}
setup_vertical_widgets_position(1,
pGotoDlg->end_widget_list->area.x,
pGotoDlg->end_widget_list->area.y,
pGotoDlg->scroll->up_left_button->size.x -
pGotoDlg->end_widget_list->area.x - adj_size(2),
0, pGotoDlg->begin_active_widget_list,
pGotoDlg->end_active_widget_list);
goto_dlg->end_widget_list->area.x,
goto_dlg->end_widget_list->area.y,
goto_dlg->scroll->up_left_button->size.x -
goto_dlg->end_widget_list->area.x - adj_size(2),
0, goto_dlg->begin_active_widget_list,
goto_dlg->end_active_widget_list);
} else {
hide_scrollbar(pGotoDlg->scroll);
hide_scrollbar(goto_dlg->scroll);
}
/* redraw */
redraw_group(pGotoDlg->begin_widget_list, pGotoDlg->end_widget_list, 0);
widget_flush(pGotoDlg->end_widget_list);
redraw_group(goto_dlg->begin_widget_list, goto_dlg->end_widget_list, 0);
widget_flush(goto_dlg->end_widget_list);
}
/**********************************************************************//**
......
int i, col, block_x, x, y;
SDL_Rect area;
if (pGotoDlg) {
if (goto_dlg) {
return;
}
pGotoDlg = fc_calloc(1, sizeof(struct advanced_dialog));
goto_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
pstr = create_utf8_from_char(_("Select destination"), adj_font(12));
pstr->style |= TTF_STYLE_BOLD;
......
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_WINDOW, pwindow);
pGotoDlg->end_widget_list = pwindow;
goto_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
col++;
} players_iterate_end;
pGotoDlg->begin_widget_list = buf;
goto_dlg->begin_widget_list = buf;
create_vertical_scrollbar(pGotoDlg, 1, adj_size(320) / adj_size(30), TRUE, TRUE);
hide_scrollbar(pGotoDlg->scroll);
create_vertical_scrollbar(goto_dlg, 1, adj_size(320) / adj_size(30), TRUE, TRUE);
hide_scrollbar(goto_dlg->scroll);
area.w = MAX(area.w, adj_size(300));
area.h = adj_size(320);
......
x += buf->size.w + adj_size(5);
}
if (buf == pGotoDlg->begin_widget_list) {
if (buf == goto_dlg->begin_widget_list) {
break;
}
......
buf = buf->prev;
}
setup_vertical_scrollbar_area(pGotoDlg->scroll,
setup_vertical_scrollbar_area(goto_dlg->scroll,
block_x, area.y,
area.h, TRUE);
......
**************************************************************************/
void popdown_goto_airlift_dialog(void)
{
if (pGotoDlg) {
popdown_window_group_dialog(pGotoDlg->begin_widget_list,
pGotoDlg->end_widget_list);
FC_FREE(pGotoDlg->scroll);
FC_FREE(pGotoDlg);
if (goto_dlg) {
popdown_window_group_dialog(goto_dlg->begin_widget_list,
goto_dlg->end_widget_list);
FC_FREE(goto_dlg->scroll);
FC_FREE(goto_dlg);
}
GOTO = TRUE;
}
client/gui-sdl2/mapctrl.c
extern bool is_unit_move_blocked;
static char *pSuggestedCityName = NULL;
static struct small_dialog *pNewCity_Dlg = NULL;
static struct small_dialog *new_city_dlg = NULL;
extern struct widget *options_button;
#ifdef SCALE_MINIMAP
static struct small_dialog *pScale_MiniMap_Dlg = NULL;
static struct small_dialog *scale_minimap_dlg = NULL;
static int popdown_scale_minmap_dlg_callback(struct widget *pwidget);
#endif /* SCALE_MINIMAP */
#ifdef SCALE_UNITINFO
static struct small_dialog *pScale_UnitInfo_Dlg = NULL;
static struct small_dialog *scale_unit_info_dlg = NULL;
static int INFO_WIDTH, INFO_HEIGHT = 0, INFO_WIDTH_MIN, INFO_HEIGHT_MIN;
static int popdown_scale_unitinfo_dlg_callback(struct widget *pwidget);
static void remake_unitinfo(int w, int h);
#endif /* SCALE_UNITINFO */
static struct advanced_dialog *pMiniMap_Dlg = NULL;
static struct advanced_dialog *minimap_dlg = NULL;
static struct advanced_dialog *unit_info_dlg = NULL;
int overview_w = 0;
......
static int move_scale_minimap_dlg_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pScale_MiniMap_Dlg->begin_widget_list, pwindow);
move_window_group(scale_minimap_dlg->begin_widget_list, pwindow);
}
return -1;
......
static int popdown_scale_minimap_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pScale_MiniMap_Dlg) {
popdown_window_group_dialog(pScale_MiniMap_Dlg->begin_widget_list,
pScale_MiniMap_Dlg->end_widget_list);
FC_FREE(pScale_MiniMap_Dlg);
if (scale_minimap_dlg) {
popdown_window_group_dialog(scale_minimap_dlg->begin_widget_list,
scale_minimap_dlg->end_widget_list);
FC_FREE(scale_minimap_dlg);
if (pwidget) {
flush_dirty();
}
......
int window_x = 0, window_y = 0;
SDL_Rect area;
if (pScale_MiniMap_Dlg || !(sdl2_client_flags & CF_OVERVIEW_SHOWN)) {
if (scale_minimap_dlg || !(sdl2_client_flags & CF_OVERVIEW_SHOWN)) {
return;
}
pScale_MiniMap_Dlg = fc_calloc(1, sizeof(struct small_dialog));
scale_minimap_dlg = fc_calloc(1, sizeof(struct small_dialog));
/* create window */
pstr = create_utf8_from_char(_("Scale Mini Map"), adj_font(12));
......
pwindow->action = move_scale_minimap_dlg_callback;
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_WINDOW, pwindow);
pScale_MiniMap_Dlg->end_widget_list = pwindow;
scale_minimap_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
buf = create_themeicon_button(current_theme->CANCEL_Icon, pwindow->dst, pstr, 0);
buf->action = popdown_scale_minimap_dlg_callback;
set_wstate(buf, FC_WS_NORMAL);
pScale_MiniMap_Dlg->begin_widget_list = buf;
scale_minimap_dlg->begin_widget_list = buf;
add_to_gui_list(ID_BUTTON, buf);
area.h += buf->size.h + adj_size(10);
area.w = MAX(area.w, buf->size.w + adj_size(20));
......
buf->size.y = area.y + area.h - buf->size.h - adj_size(7);
/* -------------------- */
redraw_group(pScale_MiniMap_Dlg->begin_widget_list, pwindow, 0);
redraw_group(scale_minimap_dlg->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
}
#endif /* SCALE_MINIMAP */
......
static int move_scale_unitinfo_dlg_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pScale_UnitInfo_Dlg->begin_widget_list, pwindow);
move_window_group(scale_unit_info_dlg->begin_widget_list, pwindow);
}
return -1;
......
static int popdown_scale_unitinfo_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pScale_UnitInfo_Dlg) {
popdown_window_group_dialog(pScale_UnitInfo_Dlg->begin_widget_list,
pScale_UnitInfo_Dlg->end_widget_list);
FC_FREE(pScale_UnitInfo_Dlg);
if (scale_unit_info_dlg) {
popdown_window_group_dialog(scale_unit_info_dlg->begin_widget_list,
scale_unit_info_dlg->end_widget_list);
FC_FREE(scale_unit_info_dlg);
if (pwidget) {
flush_dirty();
}
......
int window_x = 0, window_y = 0;
SDL_Rect area;
if (pScale_UnitInfo_Dlg || !(sdl2_client_flags & CF_UNITINFO_SHOWN)) {
if (scale_unit_info_dlg || !(sdl2_client_flags & CF_UNITINFO_SHOWN)) {
return;
}
pScale_UnitInfo_Dlg = fc_calloc(1, sizeof(struct small_dialog));
scale_unit_info_dlg = fc_calloc(1, sizeof(struct small_dialog));
/* create window */
pstr = create_utf8_from_char(_("Scale Unit Info"), adj_font(12));
......
pwindow->action = move_scale_unitinfo_dlg_callback;
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_WINDOW, pwindow);
pScale_UnitInfo_Dlg->end_widget_list = pwindow;
scale_unit_info_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
pwindow->dst, pstr, 0);
buf->action = popdown_scale_unitinfo_dlg_callback;
set_wstate(buf, FC_WS_NORMAL);
pScale_UnitInfo_Dlg->begin_widget_list = buf;
scale_unit_info_dlg->begin_widget_list = buf;
add_to_gui_list(ID_BUTTON, buf);
area.h += buf->size.h + adj_size(10);
area.w = MAX(area.w, buf->size.w + adj_size(20));
......
}
/* -------------------- */
redraw_group(pScale_UnitInfo_Dlg->begin_widget_list, pwindow, 0);
redraw_group(scale_unit_info_dlg->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
}
#endif /* SCALE_UNITINFO */
......
SDL_Color black = {0, 0, 0, 255};
char buf[256];
if (pMiniMap_Dlg) {
if (minimap_dlg) {
return;
}
pMiniMap_Dlg = fc_calloc(1, sizeof(struct advanced_dialog));
minimap_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
/* minimap_window */
pwindow = create_window_skeleton(NULL, NULL, 0);
......
add_to_gui_list(ID_MINI_MAP_WINDOW, pwindow);
minimap_window = pwindow;
pMiniMap_Dlg->end_widget_list = minimap_window;
minimap_dlg->end_widget_list = minimap_window;
/* new turn button */
pwidget = create_themeicon(current_theme->NEW_TURN_Icon, minimap_window->dst,
......
add_to_gui_list(ID_TOGGLE_MAP_WINDOW_BUTTON, pwidget);
pMiniMap_Dlg->begin_widget_list = pwidget;
minimap_dlg->begin_widget_list = pwidget;
sdl2_client_flags |= CF_OVERVIEW_SHOWN;
......
**************************************************************************/
void popdown_minimap_window(void)
{
if (pMiniMap_Dlg) {
popdown_window_group_dialog(pMiniMap_Dlg->begin_widget_list, pMiniMap_Dlg->end_widget_list);
FC_FREE(pMiniMap_Dlg);
if (minimap_dlg) {
popdown_window_group_dialog(minimap_dlg->begin_widget_list, minimap_dlg->end_widget_list);
FC_FREE(minimap_dlg);
sdl2_client_flags &= ~CF_OVERVIEW_SHOWN;
}
}
......
static int newcity_name_edit_callback(struct widget *pedit)
{
if (PRESSED_EVENT(main_data.event)) {
if (pNewCity_Dlg->begin_widget_list->string_utf8->text == NULL) {
if (new_city_dlg->begin_widget_list->string_utf8->text == NULL) {
/* empty input -> restore previous content */
copy_chars_to_utf8_str(pedit->string_utf8, pSuggestedCityName);
widget_redraw(pedit);
......
{
if (PRESSED_EVENT(main_data.event)) {
finish_city(ok_button->data.tile, pNewCity_Dlg->begin_widget_list->string_utf8->text);
finish_city(ok_button->data.tile, new_city_dlg->begin_widget_list->string_utf8->text);
popdown_window_group_dialog(pNewCity_Dlg->begin_widget_list,
pNewCity_Dlg->end_widget_list);
FC_FREE(pNewCity_Dlg);
popdown_window_group_dialog(new_city_dlg->begin_widget_list,
new_city_dlg->end_widget_list);
FC_FREE(new_city_dlg);
FC_FREE(pSuggestedCityName);
......
static int newcity_cancel_callback(struct widget *cancel_button)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_window_group_dialog(pNewCity_Dlg->begin_widget_list,
pNewCity_Dlg->end_widget_list);
popdown_window_group_dialog(new_city_dlg->begin_widget_list,
new_city_dlg->end_widget_list);
cancel_city(cancel_button->data.tile);
FC_FREE(pNewCity_Dlg);
FC_FREE(new_city_dlg);
FC_FREE(pSuggestedCityName);
......
static int move_new_city_dlg_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pNewCity_Dlg->begin_widget_list, pwindow);
move_window_group(new_city_dlg->begin_widget_list, pwindow);
}
return -1;
......
SDL_Rect area;
int suggestlen;
if (pNewCity_Dlg) {
if (new_city_dlg) {
return;
}
......
pSuggestedCityName = fc_calloc(1, suggestlen);
fc_strlcpy(pSuggestedCityName, pSuggestname, suggestlen);
pNewCity_Dlg = fc_calloc(1, sizeof(struct small_dialog));
new_city_dlg = fc_calloc(1, sizeof(struct small_dialog));
/* create window */
pstr = create_utf8_from_char(action_id_name_translation(ACTION_FOUND_CITY),
......
set_wstate(pwindow, FC_WS_NORMAL);
/* add widgets to main list */
pNewCity_Dlg->end_widget_list = pwindow;
new_city_dlg->end_widget_list = pwindow;
add_to_gui_list(ID_NEWCITY_NAME_WINDOW, pwindow);
add_to_gui_list(ID_NEWCITY_NAME_LABEL, pLabel);
add_to_gui_list(ID_NEWCITY_NAME_CANCEL_BUTTON, cancel_button);
add_to_gui_list(ID_NEWCITY_NAME_OK_BUTTON, ok_button);
add_to_gui_list(ID_NEWCITY_NAME_EDIT, pedit);
pNewCity_Dlg->begin_widget_list = pedit;
new_city_dlg->begin_widget_list = pedit;
/* redraw */
redraw_group(pedit, pwindow, 0);
......
**************************************************************************/
void popdown_newcity_dialog(void)
{
if (pNewCity_Dlg) {
popdown_window_group_dialog(pNewCity_Dlg->begin_widget_list,
pNewCity_Dlg->end_widget_list);
FC_FREE(pNewCity_Dlg);
if (new_city_dlg) {
popdown_window_group_dialog(new_city_dlg->begin_widget_list,
new_city_dlg->end_widget_list);
FC_FREE(new_city_dlg);
flush_dirty();
}
}
client/gui-sdl2/mapview.c
}
if (n > 1 && (info_window->size.h - sy > 52)) {
struct advanced_dialog *pDlg = info_window->private_data.adv_dlg;
struct advanced_dialog *dlg = info_window->private_data.adv_dlg;
struct widget *buf = NULL, *end = NULL, *dock;
struct city *pHome_City;
const struct unit_type *putype;
int num_w, num_h;
if (pDlg->end_active_widget_list && pDlg->begin_active_widget_list) {
del_group(pDlg->begin_active_widget_list, pDlg->end_active_widget_list);
if (dlg->end_active_widget_list && dlg->begin_active_widget_list) {
del_group(dlg->begin_active_widget_list, dlg->end_active_widget_list);
}
num_w = (info_window->area.w - BLOCKU_W) / 68;
num_h = (info_window->area.h - sy) / 52;
......
} unit_list_iterate_end;
pDlg->begin_active_widget_list = buf;
pDlg->end_active_widget_list = end;
pDlg->active_widget_list = pDlg->end_active_widget_list;
dlg->begin_active_widget_list = buf;
dlg->end_active_widget_list = end;
dlg->active_widget_list = dlg->end_active_widget_list;
if (n > num_w * num_h) {
if (!pDlg->scroll) {
create_vertical_scrollbar(pDlg, num_w, num_h, FALSE, TRUE);
if (!dlg->scroll) {
create_vertical_scrollbar(dlg, num_w, num_h, FALSE, TRUE);
} else {
pDlg->scroll->active = num_h;
pDlg->scroll->step = num_w;
pDlg->scroll->count = n;
show_scrollbar(pDlg->scroll);
dlg->scroll->active = num_h;
dlg->scroll->step = num_w;
dlg->scroll->count = n;
show_scrollbar(dlg->scroll);
}
/* create up button */
buf = pDlg->scroll->up_left_button;
buf = dlg->scroll->up_left_button;
buf->size.x = info_window->area.x + info_window->area.w - buf->size.w;
buf->size.y = info_window->area.y + sy +
(info_window->size.h - sy - num_h * 52) / 2;
buf->size.h = (num_h * 52) / 2;
/* create down button */
buf = pDlg->scroll->down_right_button;
buf->size.x = pDlg->scroll->up_left_button->size.x;
buf->size.y = pDlg->scroll->up_left_button->size.y +
pDlg->scroll->up_left_button->size.h;
buf->size.h = pDlg->scroll->up_left_button->size.h;
buf = dlg->scroll->down_right_button;
buf->size.x = dlg->scroll->up_left_button->size.x;
buf->size.y = dlg->scroll->up_left_button->size.y +
dlg->scroll->up_left_button->size.h;
buf->size.h = dlg->scroll->up_left_button->size.h;
} else {
if (pDlg->scroll) {
hide_scrollbar(pDlg->scroll);
if (dlg->scroll) {
hide_scrollbar(dlg->scroll);
}
num_h = (n + num_w - 1) / num_w;
}
......
info_window->area.x + BLOCKU_W + adj_size(2),
info_window->size.y + sy +
(info_window->size.h - sy - num_h * 52) / 2,
0, 0, pDlg->begin_active_widget_list,
pDlg->end_active_widget_list);
0, 0, dlg->begin_active_widget_list,
dlg->end_active_widget_list);
} else {
if (info_window->private_data.adv_dlg->end_active_widget_list) {
del_group(info_window->private_data.adv_dlg->begin_active_widget_list,
client/gui-sdl2/messagewin.c
#define PTSIZE_LOG_FONT adj_font(10)
static struct advanced_dialog *pMsg_Dlg = NULL;
static struct advanced_dialog *msg_dlg = NULL;
/**********************************************************************//**
Called from default clicks on a message.
......
static int move_msg_window_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pMsg_Dlg->begin_widget_list, pwindow);
move_window_group(msg_dlg->begin_widget_list, pwindow);
}
return -1;
......
bool create;
int label_width;
if (pMsg_Dlg == NULL) {
if (msg_dlg == NULL) {
meswin_dialog_popup(TRUE);
}
msg_count = meswin_get_num_messages();
current_count = pMsg_Dlg->scroll->count;
current_count = msg_dlg->scroll->count;
if (current_count > 0) {
undraw_group(pMsg_Dlg->begin_active_widget_list, pMsg_Dlg->end_active_widget_list);
del_group_of_widgets_from_gui_list(pMsg_Dlg->begin_active_widget_list,
pMsg_Dlg->end_active_widget_list);
pMsg_Dlg->begin_active_widget_list = NULL;
pMsg_Dlg->end_active_widget_list = NULL;
pMsg_Dlg->active_widget_list = NULL;
undraw_group(msg_dlg->begin_active_widget_list, msg_dlg->end_active_widget_list);
del_group_of_widgets_from_gui_list(msg_dlg->begin_active_widget_list,
msg_dlg->end_active_widget_list);
msg_dlg->begin_active_widget_list = NULL;
msg_dlg->end_active_widget_list = NULL;
msg_dlg->active_widget_list = NULL;
/* hide scrollbar */
hide_scrollbar(pMsg_Dlg->scroll);
pMsg_Dlg->scroll->count = 0;
hide_scrollbar(msg_dlg->scroll);
msg_dlg->scroll->count = 0;
current_count = 0;
}
create = (current_count == 0);
pwindow = pMsg_Dlg->end_widget_list;
pwindow = msg_dlg->end_widget_list;
area = pwindow->area;
label_width = area.w - pMsg_Dlg->scroll->up_left_button->size.w - adj_size(3);
label_width = area.w - msg_dlg->scroll->up_left_button->size.w - adj_size(3);
if (msg_count > 0) {
for (; current_count < msg_count; current_count++) {
......
/* add to widget list */
if (create) {
add_widget_to_vertical_scroll_widget_list(pMsg_Dlg, buf, pwindow, FALSE,
add_widget_to_vertical_scroll_widget_list(msg_dlg, buf, pwindow, FALSE,
area.x, area.y);
create = FALSE;
} else {
add_widget_to_vertical_scroll_widget_list(pMsg_Dlg, buf,
pMsg_Dlg->begin_active_widget_list,
add_widget_to_vertical_scroll_widget_list(msg_dlg, buf,
msg_dlg->begin_active_widget_list,
FALSE, area.x, area.y);
}
}
......
/* add to widget list */
if (create) {
add_widget_to_vertical_scroll_widget_list(pMsg_Dlg, buf,
add_widget_to_vertical_scroll_widget_list(msg_dlg, buf,
pwindow, FALSE,
area.x, area.y);
create = FALSE;
} else {
add_widget_to_vertical_scroll_widget_list(pMsg_Dlg, buf,
pMsg_Dlg->begin_active_widget_list,
add_widget_to_vertical_scroll_widget_list(msg_dlg, buf,
msg_dlg->begin_active_widget_list,
FALSE, area.x, area.y);
}
}
......
} /* for */
} /* if */
redraw_group(pMsg_Dlg->begin_widget_list, pwindow, 0);
redraw_group(msg_dlg->begin_widget_list, pwindow, 0);
widget_flush(pwindow);
}
......
SDL_Rect area;
SDL_Rect size;
if (pMsg_Dlg) {
if (msg_dlg) {
return;
}
pMsg_Dlg = fc_calloc(1, sizeof(struct advanced_dialog));
msg_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
/* create window */
pstr = create_utf8_from_char(_("Messages"), adj_font(12));
......
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_CHATLINE_WINDOW, pwindow);
pMsg_Dlg->end_widget_list = pwindow;
pMsg_Dlg->begin_widget_list = pwindow;
msg_dlg->end_widget_list = pwindow;
msg_dlg->begin_widget_list = pwindow;
/* create scrollbar */
create_vertical_scrollbar(pMsg_Dlg, 1, N_MSG_VIEW, TRUE, TRUE);
create_vertical_scrollbar(msg_dlg, 1, N_MSG_VIEW, TRUE, TRUE);
pstr = create_utf8_from_char("sample text", PTSIZE_LOG_FONT);
......
area = pwindow->area;
setup_vertical_scrollbar_area(pMsg_Dlg->scroll,
setup_vertical_scrollbar_area(msg_dlg->scroll,
area.x + area.w, area.y,
area.h, TRUE);
hide_scrollbar(pMsg_Dlg->scroll);
hide_scrollbar(msg_dlg->scroll);
widget_set_position(pwindow, (main_window_width() - pwindow->size.w)/2, adj_size(25));
......
**************************************************************************/
void meswin_dialog_popdown(void)
{
if (pMsg_Dlg) {
popdown_window_group_dialog(pMsg_Dlg->begin_widget_list,
pMsg_Dlg->end_widget_list);
FC_FREE(pMsg_Dlg->scroll);
FC_FREE(pMsg_Dlg);
if (msg_dlg) {
popdown_window_group_dialog(msg_dlg->begin_widget_list,
msg_dlg->end_widget_list);
FC_FREE(msg_dlg->scroll);
FC_FREE(msg_dlg);
}
}
......
**************************************************************************/
bool meswin_dialog_is_open(void)
{
return (pMsg_Dlg != NULL);
return (msg_dlg != NULL);
}
client/gui-sdl2/plrdlg.c
/* ============================== SHORT =============================== */
static struct advanced_dialog *pShort_Players_Dlg = NULL;
static struct advanced_dialog *short_players_dlg = NULL;
/**********************************************************************//**
User interacted with nations window.
......
const struct player_diplstate *pDS;
SDL_Rect area;
if (pShort_Players_Dlg) {
if (short_players_dlg) {
return;
}
pShort_Players_Dlg = fc_calloc(1, sizeof(struct advanced_dialog));
short_players_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
/* TRANS: Nations report title */
pstr = create_utf8_from_char(_("Nations") , adj_font(12));
......
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_WINDOW, pwindow);
pShort_Players_Dlg->end_widget_list = pwindow;
short_players_dlg->end_widget_list = pwindow;
area = pwindow->area;
......
n++;
}
} players_iterate_end;
pShort_Players_Dlg->begin_widget_list = buf;
pShort_Players_Dlg->begin_active_widget_list = pShort_Players_Dlg->begin_widget_list;
pShort_Players_Dlg->end_active_widget_list = pwindow->prev->prev;
pShort_Players_Dlg->active_widget_list = pShort_Players_Dlg->end_active_widget_list;
short_players_dlg->begin_widget_list = buf;
short_players_dlg->begin_active_widget_list = short_players_dlg->begin_widget_list;
short_players_dlg->end_active_widget_list = pwindow->prev->prev;
short_players_dlg->active_widget_list = short_players_dlg->end_active_widget_list;
/* ---------- */
if (n > 20) {
units_h = create_vertical_scrollbar(pShort_Players_Dlg, 1, 20, TRUE, TRUE);
pShort_Players_Dlg->scroll->count = n;
units_h = create_vertical_scrollbar(short_players_dlg, 1, 20, TRUE, TRUE);
short_players_dlg->scroll->count = n;
n = units_h;
area.w += n;
......
w = area.w;
if (pShort_Players_Dlg->scroll) {
if (short_players_dlg->scroll) {
w -= n;
}
......
/* cities */
buf = buf->prev;
setup_vertical_widgets_position(1, area.x, area.y, w, 0,
pShort_Players_Dlg->begin_active_widget_list,
short_players_dlg->begin_active_widget_list,
buf);
if (pShort_Players_Dlg->scroll) {
setup_vertical_scrollbar_area(pShort_Players_Dlg->scroll,
if (short_players_dlg->scroll) {
setup_vertical_scrollbar_area(short_players_dlg->scroll,
area.x + area.w, area.y,
area.h, TRUE);
}
/* -------------------- */
/* redraw */
redraw_group(pShort_Players_Dlg->begin_widget_list, pwindow, 0);
redraw_group(short_players_dlg->begin_widget_list, pwindow, 0);
widget_mark_dirty(pwindow);
flush_dirty();
......
**************************************************************************/
void popdown_players_nations_dialog(void)
{
if (pShort_Players_Dlg) {
popdown_window_group_dialog(pShort_Players_Dlg->begin_widget_list,
pShort_Players_Dlg->end_widget_list);
FC_FREE(pShort_Players_Dlg->scroll);
FC_FREE(pShort_Players_Dlg);
if (short_players_dlg) {
popdown_window_group_dialog(short_players_dlg->begin_widget_list,
short_players_dlg->end_widget_list);
FC_FREE(short_players_dlg->scroll);
FC_FREE(short_players_dlg);
}
}
client/gui-sdl2/repodlgs.c
/* ===================================================================== */
/* ======================== Economy Report ============================= */
/* ===================================================================== */
static struct advanced_dialog *pEconomyDlg = NULL;
static struct small_dialog *pEconomy_Sell_Dlg = NULL;
static struct advanced_dialog *economy_dlg = NULL;
static struct small_dialog *economy_sell_dlg = NULL;
struct rates_move {
int min, max, tax, x, gov_max;
......
static int economy_dialog_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pEconomyDlg->begin_widget_list, pwindow);
move_window_group(economy_dlg->begin_widget_list, pwindow);
}
return -1;
......
static int exit_economy_dialog_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pEconomyDlg) {
if (pEconomy_Sell_Dlg) {
del_group_of_widgets_from_gui_list(pEconomy_Sell_Dlg->begin_widget_list,
pEconomy_Sell_Dlg->end_widget_list);
FC_FREE(pEconomy_Sell_Dlg);
if (economy_dlg) {
if (economy_sell_dlg) {
del_group_of_widgets_from_gui_list(economy_sell_dlg->begin_widget_list,
economy_sell_dlg->end_widget_list);
FC_FREE(economy_sell_dlg);
}
popdown_window_group_dialog(pEconomyDlg->begin_widget_list,
pEconomyDlg->end_widget_list);
FC_FREE(pEconomyDlg->scroll);
FC_FREE(pEconomyDlg);
popdown_window_group_dialog(economy_dlg->begin_widget_list,
economy_dlg->end_widget_list);
FC_FREE(economy_dlg->scroll);
FC_FREE(economy_dlg);
set_wstate(get_tax_rates_widget(), FC_WS_NORMAL);
widget_redraw(get_tax_rates_widget());
widget_mark_dirty(get_tax_rates_widget());
......
void *pData)
{
struct rates_move *pMotion = (struct rates_move *)pData;
struct widget *pTax_Label = pEconomyDlg->end_widget_list->prev->prev;
struct widget *pTax_Label = economy_dlg->end_widget_list->prev->prev;
struct widget *pbuf = NULL;
char cbuf[8];
int dir, inc, x, *buf_rate = NULL;
......
pMotion.pLabel_Dst = pMotion.pHoriz_Dst->prev;
} else {
/* tax label */
pMotion.pLabel_Dst = pEconomyDlg->end_widget_list->prev->prev;
pMotion.pLabel_Dst = economy_dlg->end_widget_list->prev->prev;
}
pMotion.min = pHoriz_Src->next->size.x + pHoriz_Src->next->size.w + adj_size(2);
......
static void enable_economy_dlg(void)
{
/* lux lock */
struct widget *buf = pEconomyDlg->end_widget_list->prev->prev->prev->prev->prev->prev;
struct widget *buf = economy_dlg->end_widget_list->prev->prev->prev->prev->prev->prev;
set_wstate(buf, FC_WS_NORMAL);
......
buf = buf->prev;
set_wstate(buf, FC_WS_NORMAL);
set_group_state(pEconomyDlg->begin_active_widget_list,
pEconomyDlg->end_active_widget_list, FC_WS_NORMAL);
if (pEconomyDlg->scroll && pEconomyDlg->active_widget_list) {
set_wstate(pEconomyDlg->scroll->up_left_button, FC_WS_NORMAL);
set_wstate(pEconomyDlg->scroll->down_right_button, FC_WS_NORMAL);
set_wstate(pEconomyDlg->scroll->pscroll_bar, FC_WS_NORMAL);
set_group_state(economy_dlg->begin_active_widget_list,
economy_dlg->end_active_widget_list, FC_WS_NORMAL);
if (economy_dlg->scroll && economy_dlg->active_widget_list) {
set_wstate(economy_dlg->scroll->up_left_button, FC_WS_NORMAL);
set_wstate(economy_dlg->scroll->down_right_button, FC_WS_NORMAL);
set_wstate(economy_dlg->scroll->pscroll_bar, FC_WS_NORMAL);
}
}
......
static void disable_economy_dlg(void)
{
/* lux lock */
struct widget *buf = pEconomyDlg->end_widget_list->prev->prev->prev->prev->prev->prev;
struct widget *buf = economy_dlg->end_widget_list->prev->prev->prev->prev->prev->prev;
set_wstate(buf, FC_WS_DISABLED);
......
buf = buf->prev;
set_wstate(buf, FC_WS_DISABLED);
set_group_state(pEconomyDlg->begin_active_widget_list,
pEconomyDlg->end_active_widget_list, FC_WS_DISABLED);
if (pEconomyDlg->scroll && pEconomyDlg->active_widget_list) {
set_wstate(pEconomyDlg->scroll->up_left_button, FC_WS_DISABLED);
set_wstate(pEconomyDlg->scroll->down_right_button, FC_WS_DISABLED);
set_wstate(pEconomyDlg->scroll->pscroll_bar, FC_WS_DISABLED);
set_group_state(economy_dlg->begin_active_widget_list,
economy_dlg->end_active_widget_list, FC_WS_DISABLED);
if (economy_dlg->scroll && economy_dlg->active_widget_list) {
set_wstate(economy_dlg->scroll->up_left_button, FC_WS_DISABLED);
set_wstate(economy_dlg->scroll->down_right_button, FC_WS_DISABLED);
set_wstate(economy_dlg->scroll->pscroll_bar, FC_WS_DISABLED);
}
}
......
total_count = pImpr->data.cont->id1;
/* popdown sell dlg */
popdown_window_group_dialog(pEconomy_Sell_Dlg->begin_widget_list,
pEconomy_Sell_Dlg->end_widget_list);
FC_FREE(pEconomy_Sell_Dlg);
popdown_window_group_dialog(economy_sell_dlg->begin_widget_list,
economy_sell_dlg->end_widget_list);
FC_FREE(economy_sell_dlg);
enable_economy_dlg();
/* send sell */
......
} city_list_iterate_end;
if (count == total_count) {
del_widget_from_vertical_scroll_widget_list(pEconomyDlg, pImpr);
del_widget_from_vertical_scroll_widget_list(economy_dlg, pImpr);
}
}
......
static int sell_impr_window_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
move_window_group(pEconomy_Sell_Dlg->begin_widget_list, pwindow);
move_window_group(economy_sell_dlg->begin_widget_list, pwindow);
}
return -1;
......
static int cancel_sell_impr_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pEconomy_Sell_Dlg) {
popdown_window_group_dialog(pEconomy_Sell_Dlg->begin_widget_list,
pEconomy_Sell_Dlg->end_widget_list);
FC_FREE(pEconomy_Sell_Dlg);
if (economy_sell_dlg) {
popdown_window_group_dialog(economy_sell_dlg->begin_widget_list,
economy_sell_dlg->end_widget_list);
FC_FREE(economy_sell_dlg);
enable_economy_dlg();
flush_dirty();
}
......
SDL_Rect dst;
SDL_Rect area;
if (pEconomy_Sell_Dlg) {
if (economy_sell_dlg) {
return 1;
}
......
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
pEconomy_Sell_Dlg = fc_calloc(1, sizeof(struct small_dialog));
economy_sell_dlg = fc_calloc(1, sizeof(struct small_dialog));
imp = pwidget->data.cont->id0;
total_count = pwidget->data.cont->id1;
......
pwindow->action = sell_impr_window_callback;
set_wstate(pwindow, FC_WS_NORMAL);
pEconomy_Sell_Dlg->end_widget_list = pwindow;
economy_sell_dlg->end_widget_list = pwindow;
add_to_gui_list(ID_WINDOW, pwindow);
......
}
/* ============================================ */
pEconomy_Sell_Dlg->begin_widget_list = buf;
economy_sell_dlg->begin_widget_list = buf;
resize_window(pwindow, NULL, get_theme_color(COLOR_THEME_BACKGROUND),
(pwindow->size.w - pwindow->area.w) + area.w,
......
area = pwindow->area;
widget_set_position(pwindow,
pEconomyDlg->end_widget_list->size.x +
(pEconomyDlg->end_widget_list->size.w - pwindow->size.w) / 2,
pEconomyDlg->end_widget_list->size.y +
(pEconomyDlg->end_widget_list->size.h - pwindow->size.h) / 2);
economy_dlg->end_widget_list->size.x +
(economy_dlg->end_widget_list->size.w - pwindow->size.w) / 2,
economy_dlg->end_widget_list->size.y +
(economy_dlg->end_widget_list->size.h - pwindow->size.h) / 2);
/* setup rest of widgets */
/* label */
......
/* ================================================== */
/* redraw */
redraw_group(pEconomy_Sell_Dlg->begin_widget_list, pwindow, 0);
redraw_group(economy_sell_dlg->begin_widget_list, pwindow, 0);
disable_economy_dlg();
widget_mark_dirty(pwindow);
......
**************************************************************************/
void real_economy_report_dialog_update(void *unused)
{
if (pEconomyDlg) {
struct widget *pbuf = pEconomyDlg->end_widget_list;
if (economy_dlg) {
struct widget *pbuf = economy_dlg->end_widget_list;
int tax, total, entries_used = 0;
char cbuf[128];
struct improvement_entry entries[B_LAST];
......
}
/* ---------------- */
redraw_group(pEconomyDlg->begin_widget_list, pEconomyDlg->end_widget_list, 0);
widget_flush(pEconomyDlg->end_widget_list);
redraw_group(economy_dlg->begin_widget_list, economy_dlg->end_widget_list, 0);
widget_flush(economy_dlg->end_widget_list);
}
}
......
**************************************************************************/
void economy_report_dialog_popdown(void)
{
if (pEconomyDlg) {
if (pEconomy_Sell_Dlg) {
del_group_of_widgets_from_gui_list(pEconomy_Sell_Dlg->begin_widget_list,
pEconomy_Sell_Dlg->end_widget_list);
FC_FREE(pEconomy_Sell_Dlg);
if (economy_dlg) {
if (economy_sell_dlg) {
del_group_of_widgets_from_gui_list(economy_sell_dlg->begin_widget_list,
economy_sell_dlg->end_widget_list);
FC_FREE(economy_sell_dlg);
}
popdown_window_group_dialog(pEconomyDlg->begin_widget_list,
pEconomyDlg->end_widget_list);
FC_FREE(pEconomyDlg->scroll);
FC_FREE(pEconomyDlg);
popdown_window_group_dialog(economy_dlg->begin_widget_list,
economy_dlg->end_widget_list);
FC_FREE(economy_dlg->scroll);
FC_FREE(economy_dlg);
set_wstate(get_tax_rates_widget(), FC_WS_NORMAL);
widget_redraw(get_tax_rates_widget());
widget_mark_dirty(get_tax_rates_widget());
......
SDL_Surface *pNetIncomeText;
SDL_Surface *pMaxRateText;
if (pEconomyDlg) {
if (economy_dlg) {
return;
}
......
widget_redraw(buf);
widget_mark_dirty(buf);
pEconomyDlg = fc_calloc(1, sizeof(struct advanced_dialog));
economy_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
get_economy_report_data(entries, &entries_used, &total, &tax);
......
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pEconomyDlg->end_widget_list = pwindow;
economy_dlg->end_widget_list = pwindow;
set_wstate(pwindow, FC_WS_NORMAL);
pwindow->action = economy_dialog_callback;
......
FREEUTF8STR(pstr);
FREESURFACE(background);
pEconomyDlg->end_active_widget_list = pLast->prev;
pEconomyDlg->begin_widget_list = buf;
pEconomyDlg->begin_active_widget_list = pEconomyDlg->begin_widget_list;
economy_dlg->end_active_widget_list = pLast->prev;
economy_dlg->begin_widget_list = buf;
economy_dlg->begin_active_widget_list = economy_dlg->begin_widget_list;
if (entries_used > (TARGETS_ROW * TARGETS_COL)) {
pEconomyDlg->active_widget_list = pEconomyDlg->end_active_widget_list;
count = create_vertical_scrollbar(pEconomyDlg,
economy_dlg->active_widget_list = economy_dlg->end_active_widget_list;
count = create_vertical_scrollbar(economy_dlg,
TARGETS_COL, TARGETS_ROW, TRUE, TRUE);
h += (TARGETS_ROW * buf->size.h + adj_size(10));
} else {
......
}
count = TARGETS_COL * buf->size.w + count;
} else {
pEconomyDlg->begin_widget_list = buf;
economy_dlg->begin_widget_list = buf;
h += adj_size(10);
count = 0;
}
......
setup_vertical_widgets_position(TARGETS_COL,
area.x,
area.y + h,
0, 0, pEconomyDlg->begin_active_widget_list,
pEconomyDlg->end_active_widget_list);
if (pEconomyDlg->scroll) {
setup_vertical_scrollbar_area(pEconomyDlg->scroll,
0, 0, economy_dlg->begin_active_widget_list,
economy_dlg->end_active_widget_list);
if (economy_dlg->scroll) {
setup_vertical_scrollbar_area(economy_dlg->scroll,
area.x + area.w - 1,
area.y + h,
area.h - h - 1, TRUE);
......
}
/* ------------------------ */
redraw_group(pEconomyDlg->begin_widget_list, pwindow, 0);
redraw_group(economy_dlg->begin_widget_list, pwindow, 0);
widget_mark_dirty(pwindow);
flush_dirty();
}
......
/* ===================================================================== */
/* ======================== Science Report ============================= */
/* ===================================================================== */
static struct small_dialog *pScienceDlg = NULL;
static struct small_dialog *science_dlg = NULL;
static struct advanced_dialog *pChangeTechDlg = NULL;
static struct advanced_dialog *change_tech_dlg = NULL;
/**********************************************************************//**
Create icon surface for a tech.
......
**************************************************************************/
static void enable_science_dialog(void)
{
set_group_state(pScienceDlg->begin_widget_list,
pScienceDlg->end_widget_list->prev, FC_WS_NORMAL);
set_group_state(science_dlg->begin_widget_list,
science_dlg->end_widget_list->prev, FC_WS_NORMAL);
}
/**********************************************************************//**
......
**************************************************************************/
static void disable_science_dialog(void)
{
set_group_state(pScienceDlg->begin_widget_list,
pScienceDlg->end_widget_list->prev, FC_WS_DISABLED);
set_group_state(science_dlg->begin_widget_list,
science_dlg->end_widget_list->prev, FC_WS_DISABLED);
}
/**********************************************************************//**
......
{
SDL_Color bg_color = {255, 255, 255, 136};
if (pScienceDlg) {
if (science_dlg) {
const struct research *presearch = research_get(client_player());
char cBuf[128];
utf8_str *pStr;
......
struct widget *pChangeResearchButton;
struct widget *pChangeResearchGoalButton;
SDL_Rect area;
struct widget *pwindow = pScienceDlg->end_widget_list;
struct widget *pwindow = science_dlg->end_widget_list;
area = pwindow->area;
pChangeResearchButton = pwindow->prev;
......
/* -------------------------------- */
widget_mark_dirty(pwindow);
redraw_group(pScienceDlg->begin_widget_list, pwindow->prev, 1);
redraw_group(science_dlg->begin_widget_list, pwindow->prev, 1);
flush_dirty();
FREEUTF8STR(pStr);
......
**************************************************************************/
static void science_report_dialog_popdown(void)
{
if (pScienceDlg) {
popdown_window_group_dialog(pScienceDlg->begin_widget_list,
pScienceDlg->end_widget_list);
FC_FREE(pScienceDlg);
if (science_dlg) {
popdown_window_group_dialog(science_dlg->begin_widget_list,
science_dlg->end_widget_list);
FC_FREE(science_dlg);
set_wstate(get_research_widget(), FC_WS_NORMAL);
widget_redraw(get_research_widget());
widget_mark_dirty(get_research_widget());
......
static int exit_change_tech_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pChangeTechDlg) {
popdown_window_group_dialog(pChangeTechDlg->begin_widget_list,
pChangeTechDlg->end_widget_list);
FC_FREE(pChangeTechDlg->scroll);
FC_FREE(pChangeTechDlg);
if (change_tech_dlg) {
popdown_window_group_dialog(change_tech_dlg->begin_widget_list,
change_tech_dlg->end_widget_list);
FC_FREE(change_tech_dlg->scroll);
FC_FREE(change_tech_dlg);
enable_science_dialog();
if (pwidget) {
flush_dirty();
......
static int change_research_goal_dialog_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
if (select_window_group_dialog(pChangeTechDlg->begin_widget_list, pwindow)) {
if (select_window_group_dialog(change_tech_dlg->begin_widget_list, pwindow)) {
widget_flush(pwindow);
}
}
......
return;
}
pChangeTechDlg = fc_calloc(1, sizeof(struct advanced_dialog));
change_tech_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
pstr = create_utf8_from_char(_("What should we focus on now?"), adj_font(12));
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pChangeTechDlg->end_widget_list = pwindow;
change_tech_dlg->end_widget_list = pwindow;
set_wstate(pwindow, FC_WS_NORMAL);
pwindow->action = change_research_goal_dialog_callback;
......
FREEUTF8STR(pstr);
pChangeTechDlg->begin_widget_list = buf;
pChangeTechDlg->begin_active_widget_list = pChangeTechDlg->begin_widget_list;
pChangeTechDlg->end_active_widget_list = pChangeTechDlg->end_widget_list->prev->prev;
change_tech_dlg->begin_widget_list = buf;
change_tech_dlg->begin_active_widget_list = change_tech_dlg->begin_widget_list;
change_tech_dlg->end_active_widget_list = change_tech_dlg->end_widget_list->prev->prev;
/* -------------------------------------------------------------- */
......
if (count > col) {
count = (count + (col - 1)) / col;
if (count > max_row) {
pChangeTechDlg->active_widget_list = pChangeTechDlg->end_active_widget_list;
change_tech_dlg->active_widget_list = change_tech_dlg->end_active_widget_list;
count = max_row;
i = create_vertical_scrollbar(pChangeTechDlg, col, count, TRUE, TRUE);
i = create_vertical_scrollbar(change_tech_dlg, col, count, TRUE, TRUE);
}
} else {
count = 1;
......
setup_vertical_widgets_position(col, area.x + 1,
area.y, 0, 0,
pChangeTechDlg->begin_active_widget_list,
pChangeTechDlg->end_active_widget_list);
change_tech_dlg->begin_active_widget_list,
change_tech_dlg->end_active_widget_list);
if (pChangeTechDlg->scroll) {
setup_vertical_scrollbar_area(pChangeTechDlg->scroll,
if (change_tech_dlg->scroll) {
setup_vertical_scrollbar_area(change_tech_dlg->scroll,
area.x + area.w, area.y,
area.h, TRUE);
}
redraw_group(pChangeTechDlg->begin_widget_list, pwindow, FALSE);
redraw_group(change_tech_dlg->begin_widget_list, pwindow, FALSE);
widget_flush(pwindow);
}
......
return;
}
pChangeTechDlg = fc_calloc(1, sizeof(struct advanced_dialog));
change_tech_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
pstr = create_utf8_from_char(_("Select target :"), adj_font(12));
pstr->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, pstr, 0);
pChangeTechDlg->end_widget_list = pwindow;
change_tech_dlg->end_widget_list = pwindow;
set_wstate(pwindow, FC_WS_NORMAL);
pwindow->action = change_research_goal_dialog_callback;
......
FREEUTF8STR(pstr);
pChangeTechDlg->begin_widget_list = buf;
pChangeTechDlg->begin_active_widget_list = pChangeTechDlg->begin_widget_list;
pChangeTechDlg->end_active_widget_list = pChangeTechDlg->end_widget_list->prev->prev;
change_tech_dlg->begin_widget_list = buf;
change_tech_dlg->begin_active_widget_list = change_tech_dlg->begin_widget_list;
change_tech_dlg->end_active_widget_list = change_tech_dlg->end_widget_list->prev->prev;
/* -------------------------------------------------------------- */
......
if (count > col) {
count = (count + (col-1)) / col;
if (count > max_row) {
pChangeTechDlg->active_widget_list = pChangeTechDlg->end_active_widget_list;
change_tech_dlg->active_widget_list = change_tech_dlg->end_active_widget_list;
count = max_row;
i = create_vertical_scrollbar(pChangeTechDlg, col, count, TRUE, TRUE);
i = create_vertical_scrollbar(change_tech_dlg, col, count, TRUE, TRUE);
}
} else {
count = 1;
......
setup_vertical_widgets_position(col, area.x + 1,
area.y, 0, 0,
pChangeTechDlg->begin_active_widget_list,
pChangeTechDlg->end_active_widget_list);
change_tech_dlg->begin_active_widget_list,
change_tech_dlg->end_active_widget_list);
if (pChangeTechDlg->scroll) {
setup_vertical_scrollbar_area(pChangeTechDlg->scroll,
if (change_tech_dlg->scroll) {
setup_vertical_scrollbar_area(change_tech_dlg->scroll,
area.x + area.w, area.y,
area.h, TRUE);
}
redraw_group(pChangeTechDlg->begin_widget_list, pwindow, FALSE);
redraw_group(change_tech_dlg->begin_widget_list, pwindow, FALSE);
widget_flush(pwindow);
}
......
static int science_dialog_callback(struct widget *pwindow)
{
if (PRESSED_EVENT(main_data.event)) {
if (!pChangeTechDlg) {
if (select_window_group_dialog(pScienceDlg->begin_widget_list, pwindow)) {
if (!change_tech_dlg) {
if (select_window_group_dialog(science_dlg->begin_widget_list, pwindow)) {
widget_flush(pwindow);
}
if (move_window_group_dialog(pScienceDlg->begin_widget_list, pwindow)) {
if (move_window_group_dialog(science_dlg->begin_widget_list, pwindow)) {
real_science_report_dialog_update(NULL);
}
}
......
int count;
SDL_Rect area;
if (pScienceDlg) {
if (science_dlg) {
return;
}
......
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
pScienceDlg = fc_calloc(1, sizeof(struct small_dialog));
science_dlg = fc_calloc(1, sizeof(struct small_dialog));
/* TRANS: Research report title */
pstr = create_utf8_from_char(_("Research"), adj_font(12));
......
set_wstate(pwindow, FC_WS_NORMAL);
pwindow->action = science_dialog_callback;
pScienceDlg->end_widget_list = pwindow;
science_dlg->end_widget_list = pwindow;
background = theme_get_background(theme, BACKGROUND_SCIENCEDLG);
pwindow->theme = ResizeSurface(background, pwindow->size.w, pwindow->size.h, 1);
......
pwindow->size.y + adj_size(2));
/* ======================== */
pScienceDlg->begin_widget_list = pExitButton;
science_dlg->begin_widget_list = pExitButton;
real_science_report_dialog_update(NULL);
}
......
**************************************************************************/
void science_report_dialogs_popdown_all(void)
{
if (pChangeTechDlg) {
popdown_window_group_dialog(pChangeTechDlg->begin_widget_list,
pChangeTechDlg->end_widget_list);
FC_FREE(pChangeTechDlg->scroll);
FC_FREE(pChangeTechDlg);
if (change_tech_dlg) {
popdown_window_group_dialog(change_tech_dlg->begin_widget_list,
change_tech_dlg->end_widget_list);
FC_FREE(change_tech_dlg->scroll);
FC_FREE(change_tech_dlg);
}
if (pScienceDlg) {
popdown_window_group_dialog(pScienceDlg->begin_widget_list,
pScienceDlg->end_widget_list);
FC_FREE(pScienceDlg);
if (science_dlg) {
popdown_window_group_dialog(science_dlg->begin_widget_list,
science_dlg->end_widget_list);
FC_FREE(science_dlg);
set_wstate(get_research_widget(), FC_WS_NORMAL);
widget_redraw(get_research_widget());
widget_mark_dirty(get_research_widget());
client/gui-sdl2/widget.h
FC_WS_DISABLED)
/* Advanced Dialog */
bool add_widget_to_vertical_scroll_widget_list(struct advanced_dialog *pDlg,
bool add_widget_to_vertical_scroll_widget_list(struct advanced_dialog *dlg,
struct widget *new_widget,
struct widget *add_dock, bool dir,
Sint16 start_x, Sint16 start_y);
bool del_widget_from_vertical_scroll_widget_list(struct advanced_dialog *pDlg,
bool del_widget_from_vertical_scroll_widget_list(struct advanced_dialog *dlg,
struct widget *pwidget);
/* misc */
client/gui-sdl2/widget_scrollbar.c
/**********************************************************************//**
Get current active position of the scrollbar.
**************************************************************************/
static int get_position(struct advanced_dialog *pDlg)
static int get_position(struct advanced_dialog *dlg)
{
struct widget *buf = pDlg->active_widget_list;
int count = pDlg->scroll->active * pDlg->scroll->step - 1;
int step = get_step(pDlg->scroll);
struct widget *buf = dlg->active_widget_list;
int count = dlg->scroll->active * dlg->scroll->step - 1;
int step = get_step(dlg->scroll);
/* find last seen widget */
while (count) {
if (buf == pDlg->begin_active_widget_list) {
if (buf == dlg->begin_active_widget_list) {
break;
}
count--;
......
}
count = 0;
if (buf != pDlg->begin_active_widget_list) {
if (buf != dlg->begin_active_widget_list) {
do {
count++;
buf = buf->prev;
} while (buf != pDlg->begin_active_widget_list);
} while (buf != dlg->begin_active_widget_list);
}
if (pDlg->scroll->pscroll_bar) {
return pDlg->scroll->max - pDlg->scroll->pscroll_bar->size.h -
count * (float)step / pDlg->scroll->step;
if (dlg->scroll->pscroll_bar) {
return dlg->scroll->max - dlg->scroll->pscroll_bar->size.h -
count * (float)step / dlg->scroll->step;
} else {
return pDlg->scroll->max - count * (float)step / pDlg->scroll->step;
return dlg->scroll->max - count * (float)step / dlg->scroll->step;
}
}
......
static int std_up_advanced_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct advanced_dialog *pDlg = pwidget->private_data.adv_dlg;
struct advanced_dialog *dlg = pwidget->private_data.adv_dlg;
struct widget *begin = up_scroll_widget_list(
pDlg->scroll,
pDlg->active_widget_list,
pDlg->begin_active_widget_list,
pDlg->end_active_widget_list);
dlg->scroll,
dlg->active_widget_list,
dlg->begin_active_widget_list,
dlg->end_active_widget_list);
if (begin) {
pDlg->active_widget_list = begin;
dlg->active_widget_list = begin;
}
unselect_widget_action();
......
static int std_down_advanced_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct advanced_dialog *pDlg = pwidget->private_data.adv_dlg;
struct advanced_dialog *dlg = pwidget->private_data.adv_dlg;
struct widget *begin = down_scroll_widget_list(
pDlg->scroll,
pDlg->active_widget_list,
pDlg->begin_active_widget_list,
pDlg->end_active_widget_list);
dlg->scroll,
dlg->active_widget_list,
dlg->begin_active_widget_list,
dlg->end_active_widget_list);
if (begin) {
pDlg->active_widget_list = begin;
dlg->active_widget_list = begin;
}
unselect_widget_action();
......
static int std_vscroll_advanced_dlg_callback(struct widget *pscroll_bar)
{
if (PRESSED_EVENT(main_data.event)) {
struct advanced_dialog *pDlg = pscroll_bar->private_data.adv_dlg;
struct advanced_dialog *dlg = pscroll_bar->private_data.adv_dlg;
struct widget *begin = vertic_scroll_widget_list(
pDlg->scroll,
pDlg->active_widget_list,
pDlg->begin_active_widget_list,
pDlg->end_active_widget_list);
dlg->scroll,
dlg->active_widget_list,
dlg->begin_active_widget_list,
dlg->end_active_widget_list);
if (begin) {
pDlg->active_widget_list = begin;
dlg->active_widget_list = begin;
}
unselect_widget_action();
......
/**********************************************************************//**
Create a new vertical scrollbar to active widgets list.
**************************************************************************/
Uint32 create_vertical_scrollbar(struct advanced_dialog *pDlg,
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg,
Uint8 step, Uint8 active,
bool create_scrollbar, bool create_buttons)
{
Uint16 count = 0;
struct widget *buf = NULL, *pwindow = NULL;
fc_assert_ret_val(pDlg != NULL, 0);
fc_assert_ret_val(dlg != NULL, 0);
pwindow = pDlg->end_widget_list;
pwindow = dlg->end_widget_list;
if (!pDlg->scroll) {
pDlg->scroll = fc_calloc(1, sizeof(struct scroll_bar));
if (!dlg->scroll) {
dlg->scroll = fc_calloc(1, sizeof(struct scroll_bar));
buf = pDlg->end_active_widget_list;
while (buf && (buf != pDlg->begin_active_widget_list->prev)) {
buf = dlg->end_active_widget_list;
while (buf && (buf != dlg->begin_active_widget_list->prev)) {
buf = buf->prev;
count++;
}
pDlg->scroll->count = count;
dlg->scroll->count = count;
}
pDlg->scroll->active = active;
pDlg->scroll->step = step;
dlg->scroll->active = active;
dlg->scroll->step = step;
if (create_buttons) {
/* create up button */
......
NULL, WF_RESTORE_BACKGROUND);
buf->ID = ID_BUTTON;
buf->private_data.adv_dlg = pDlg;
buf->private_data.adv_dlg = dlg;
buf->action = std_up_advanced_dlg_callback;
set_wstate(buf, FC_WS_NORMAL);
pDlg->scroll->up_left_button = buf;
widget_add_as_prev(buf, pDlg->begin_widget_list);
pDlg->begin_widget_list = buf;
dlg->scroll->up_left_button = buf;
widget_add_as_prev(buf, dlg->begin_widget_list);
dlg->begin_widget_list = buf;
count = buf->size.w;
......
NULL, WF_RESTORE_BACKGROUND);
buf->ID = ID_BUTTON;
buf->private_data.adv_dlg = pDlg;
buf->private_data.adv_dlg = dlg;
buf->action = std_down_advanced_dlg_callback;
set_wstate(buf, FC_WS_NORMAL);
pDlg->scroll->down_right_button = buf;
widget_add_as_prev(buf, pDlg->begin_widget_list);
pDlg->begin_widget_list = buf;
dlg->scroll->down_right_button = buf;
widget_add_as_prev(buf, dlg->begin_widget_list);
dlg->begin_widget_list = buf;
}
if (create_scrollbar) {
......
adj_size(10), WF_RESTORE_BACKGROUND);
buf->ID = ID_SCROLLBAR;
buf->private_data.adv_dlg = pDlg;
buf->private_data.adv_dlg = dlg;
buf->action = std_vscroll_advanced_dlg_callback;
set_wstate(buf, FC_WS_NORMAL);
pDlg->scroll->pscroll_bar = buf;
widget_add_as_prev(buf, pDlg->begin_widget_list);
pDlg->begin_widget_list = buf;
dlg->scroll->pscroll_bar = buf;
widget_add_as_prev(buf, dlg->begin_widget_list);
dlg->begin_widget_list = buf;
if (!count) {
count = buf->size.w;
......
TRUE - upper add => add_dock->next = new_widget.
FALSE - down add => add_dock->prev = new_widget.
start_x, start_y - positions of first seen widget (active_widget_list).
pDlg->scroll ( scrollbar ) must exist.
dlg->scroll ( scrollbar ) must exist.
It isn't full secure to multi widget list.
**************************************************************************/
bool add_widget_to_vertical_scroll_widget_list(struct advanced_dialog *pDlg,
bool add_widget_to_vertical_scroll_widget_list(struct advanced_dialog *dlg,
struct widget *new_widget,
struct widget *add_dock,
bool dir,
......
bool last = FALSE, seen = TRUE;
fc_assert_ret_val(new_widget != NULL, FALSE);
fc_assert_ret_val(pDlg != NULL, FALSE);
fc_assert_ret_val(pDlg->scroll != NULL, FALSE);
fc_assert_ret_val(dlg != NULL, FALSE);
fc_assert_ret_val(dlg->scroll != NULL, FALSE);
if (!add_dock) {
add_dock = pDlg->begin_widget_list; /* last item */
add_dock = dlg->begin_widget_list; /* last item */
}
pDlg->scroll->count++;
dlg->scroll->count++;
if (pDlg->scroll->count > (pDlg->scroll->active * pDlg->scroll->step)) {
if (dlg->scroll->count > (dlg->scroll->active * dlg->scroll->step)) {
/* -> scrollbar needed */
if (pDlg->active_widget_list) {
if (dlg->active_widget_list) {
/* -> scrollbar is already visible */
int i = 0;
/* find last active widget */
pOld_End = add_dock;
while (pOld_End != pDlg->active_widget_list) {
while (pOld_End != dlg->active_widget_list) {
pOld_End = pOld_End->next;
i++;
if (pOld_End == pDlg->end_active_widget_list) {
/* implies (pOld_End == pDlg->active_widget_list)? */
if (pOld_End == dlg->end_active_widget_list) {
/* implies (pOld_End == dlg->active_widget_list)? */
seen = FALSE;
break;
}
}
if (seen) {
count = (pDlg->scroll->active * pDlg->scroll->step) - 1;
count = (dlg->scroll->active * dlg->scroll->step) - 1;
if (i > count) {
seen = FALSE;
} else {
......
} else {
last = TRUE;
pDlg->active_widget_list = pDlg->end_active_widget_list;
show_scrollbar(pDlg->scroll);
dlg->active_widget_list = dlg->end_active_widget_list;
show_scrollbar(dlg->scroll);
}
}
......
/* upper add */
widget_add_next(new_widget, add_dock);
if (add_dock == pDlg->end_widget_list) {
pDlg->end_widget_list = new_widget;
if (add_dock == dlg->end_widget_list) {
dlg->end_widget_list = new_widget;
}
if (add_dock == pDlg->end_active_widget_list) {
pDlg->end_active_widget_list = new_widget;
if (add_dock == dlg->end_active_widget_list) {
dlg->end_active_widget_list = new_widget;
}
if (add_dock == pDlg->active_widget_list) {
pDlg->active_widget_list = new_widget;
if (add_dock == dlg->active_widget_list) {
dlg->active_widget_list = new_widget;
}
} else {
/* down add */
widget_add_as_prev(new_widget, add_dock);
if (add_dock == pDlg->begin_widget_list) {
pDlg->begin_widget_list = new_widget;
if (add_dock == dlg->begin_widget_list) {
dlg->begin_widget_list = new_widget;
}
if (add_dock == pDlg->begin_active_widget_list) {
pDlg->begin_active_widget_list = new_widget;
if (add_dock == dlg->begin_active_widget_list) {
dlg->begin_active_widget_list = new_widget;
}
}
/* setup draw positions */
if (seen) {
if (!pDlg->begin_active_widget_list) {
if (!dlg->begin_active_widget_list) {
/* first element ( active list empty ) */
fc_assert_msg(FALSE == dir, "Forbided List Operation");
new_widget->size.x = start_x;
new_widget->size.y = start_y;
pDlg->begin_active_widget_list = new_widget;
pDlg->end_active_widget_list = new_widget;
if (!pDlg->begin_widget_list) {
pDlg->begin_widget_list = new_widget;
pDlg->end_widget_list = new_widget;
dlg->begin_active_widget_list = new_widget;
dlg->end_active_widget_list = new_widget;
if (!dlg->begin_widget_list) {
dlg->begin_widget_list = new_widget;
dlg->end_widget_list = new_widget;
}
} else { /* there are some elements on local active list */
if (last) {
......
buf->gfx = buf->next->gfx;
buf->next->gfx = NULL;
buf = buf->next;
} while (buf != pDlg->active_widget_list);
} while (buf != dlg->active_widget_list);
buf->gfx = NULL;
set_wflag(buf, WF_HIDDEN);
pDlg->active_widget_list = pDlg->active_widget_list->prev;
dlg->active_widget_list = dlg->active_widget_list->prev;
}
} else { /* !last */
buf = new_widget;
/* find last seen widget */
if (pDlg->active_widget_list) {
end = pDlg->active_widget_list;
count = pDlg->scroll->active * pDlg->scroll->step - 1;
while (count && end != pDlg->begin_active_widget_list) {
if (dlg->active_widget_list) {
end = dlg->active_widget_list;
count = dlg->scroll->active * dlg->scroll->step - 1;
while (count && end != dlg->begin_active_widget_list) {
end = end->prev;
count--;
}
}
while (buf) {
if (buf == pDlg->begin_active_widget_list) {
if (buf == dlg->begin_active_widget_list) {
struct widget *pTmp = buf;
count = pDlg->scroll->step;
count = dlg->scroll->step;
while (count) {
pTmp = pTmp->next;
count--;
......
set_wflag(pOld_End, WF_HIDDEN);
}
} /* !last */
} /* pDlg->begin_active_widget_list */
} /* dlg->begin_active_widget_list */
} else { /* !seen */
set_wflag(new_widget, WF_HIDDEN);
}
if (pDlg->active_widget_list && pDlg->scroll->pscroll_bar) {
widget_undraw(pDlg->scroll->pscroll_bar);
widget_mark_dirty(pDlg->scroll->pscroll_bar);
if (dlg->active_widget_list && dlg->scroll->pscroll_bar) {
widget_undraw(dlg->scroll->pscroll_bar);
widget_mark_dirty(dlg->scroll->pscroll_bar);
pDlg->scroll->pscroll_bar->size.h = scrollbar_size(pDlg->scroll);
dlg->scroll->pscroll_bar->size.h = scrollbar_size(dlg->scroll);
if (last) {
pDlg->scroll->pscroll_bar->size.y = get_position(pDlg);
dlg->scroll->pscroll_bar->size.y = get_position(dlg);
}
if (get_wflags(pDlg->scroll->pscroll_bar) & WF_RESTORE_BACKGROUND) {
refresh_widget_background(pDlg->scroll->pscroll_bar);
if (get_wflags(dlg->scroll->pscroll_bar) & WF_RESTORE_BACKGROUND) {
refresh_widget_background(dlg->scroll->pscroll_bar);
}
if (!seen) {
redraw_vert(pDlg->scroll->pscroll_bar);
redraw_vert(dlg->scroll->pscroll_bar);
}
}
......
/**********************************************************************//**
Delete widget from scrolled list and set draw position of all changed
widgets.
Don't free pDlg and pDlg->scroll (if exist)
Don't free dlg and dlg->scroll (if exist)
It is full secure for multi widget list case.
**************************************************************************/
bool del_widget_from_vertical_scroll_widget_list(struct advanced_dialog *pDlg,
bool del_widget_from_vertical_scroll_widget_list(struct advanced_dialog *dlg,
struct widget *pwidget)
{
int count = 0;
struct widget *buf = pwidget;
fc_assert_ret_val(pwidget != NULL, FALSE);
fc_assert_ret_val(pDlg != NULL, FALSE);
fc_assert_ret_val(dlg != NULL, FALSE);
/* if begin == end -> size = 1 */
if (pDlg->begin_active_widget_list == pDlg->end_active_widget_list) {
if (dlg->begin_active_widget_list == dlg->end_active_widget_list) {
if (pDlg->scroll) {
pDlg->scroll->count = 0;
if (dlg->scroll) {
dlg->scroll->count = 0;
}
if (pDlg->begin_active_widget_list == pDlg->begin_widget_list) {
pDlg->begin_widget_list = pDlg->begin_widget_list->next;
if (dlg->begin_active_widget_list == dlg->begin_widget_list) {
dlg->begin_widget_list = dlg->begin_widget_list->next;
}
if (pDlg->end_active_widget_list == pDlg->end_widget_list) {
pDlg->end_widget_list = pDlg->end_widget_list->prev;
if (dlg->end_active_widget_list == dlg->end_widget_list) {
dlg->end_widget_list = dlg->end_widget_list->prev;
}
pDlg->begin_active_widget_list = NULL;
pDlg->active_widget_list = NULL;
pDlg->end_active_widget_list = NULL;
dlg->begin_active_widget_list = NULL;
dlg->active_widget_list = NULL;
dlg->end_active_widget_list = NULL;
widget_undraw(pwidget);
widget_mark_dirty(pwidget);
......
return FALSE;
}
if (pDlg->scroll && pDlg->active_widget_list) {
if (dlg->scroll && dlg->active_widget_list) {
/* scrollbar exist and active, start mod. from last seen label */
struct widget *pLast;
bool widget_found = FALSE;
/* this is always true because no-scrolbar case (active*step < count)
will be supported in other part of code (see "else" part) */
count = pDlg->scroll->active * pDlg->scroll->step;
count = dlg->scroll->active * dlg->scroll->step;
/* find last */
buf = pDlg->active_widget_list;
buf = dlg->active_widget_list;
while (count > 0) {
buf = buf->prev;
count--;
}
if (!buf) {
pLast = pDlg->begin_active_widget_list;
pLast = dlg->begin_active_widget_list;
} else {
pLast = buf->next;
}
if (pLast == pDlg->begin_active_widget_list) {
if (pDlg->scroll->step == 1) {
pDlg->active_widget_list = pDlg->active_widget_list->next;
clear_wflag(pDlg->active_widget_list, WF_HIDDEN);
if (pLast == dlg->begin_active_widget_list) {
if (dlg->scroll->step == 1) {
dlg->active_widget_list = dlg->active_widget_list->next;
clear_wflag(dlg->active_widget_list, WF_HIDDEN);
/* look for the widget in the non-visible part */
buf = pDlg->end_active_widget_list;
while (buf != pDlg->active_widget_list) {
buf = dlg->end_active_widget_list;
while (buf != dlg->active_widget_list) {
if (buf == pwidget) {
widget_found = TRUE;
buf = pDlg->active_widget_list;
buf = dlg->active_widget_list;
break;
}
buf = buf->prev;
......
}
}
if ((pDlg->scroll->count - 1) <= (pDlg->scroll->active * pDlg->scroll->step)) {
if ((dlg->scroll->count - 1) <= (dlg->scroll->active * dlg->scroll->step)) {
/* scrollbar not needed anymore */
hide_scrollbar(pDlg->scroll);
pDlg->active_widget_list = NULL;
hide_scrollbar(dlg->scroll);
dlg->active_widget_list = NULL;
}
pDlg->scroll->count--;
dlg->scroll->count--;
if (pDlg->active_widget_list) {
if (pDlg->scroll->pscroll_bar) {
widget_undraw(pDlg->scroll->pscroll_bar);
pDlg->scroll->pscroll_bar->size.h = scrollbar_size(pDlg->scroll);
refresh_widget_background(pDlg->scroll->pscroll_bar);
if (dlg->active_widget_list) {
if (dlg->scroll->pscroll_bar) {
widget_undraw(dlg->scroll->pscroll_bar);
dlg->scroll->pscroll_bar->size.h = scrollbar_size(dlg->scroll);
refresh_widget_background(dlg->scroll->pscroll_bar);
}
}
} else { /* no scrollbar */
buf = pDlg->begin_active_widget_list;
buf = dlg->begin_active_widget_list;
/* undraw last widget */
widget_undraw(buf);
......
buf = buf->next;
}
if (pDlg->scroll) {
pDlg->scroll->count--;
if (dlg->scroll) {
dlg->scroll->count--;
}
}
if (pwidget == pDlg->begin_widget_list) {
pDlg->begin_widget_list = pwidget->next;
if (pwidget == dlg->begin_widget_list) {
dlg->begin_widget_list = pwidget->next;
}
if (pwidget == pDlg->begin_active_widget_list) {
pDlg->begin_active_widget_list = pwidget->next;
if (pwidget == dlg->begin_active_widget_list) {
dlg->begin_active_widget_list = pwidget->next;
}
if (pwidget == pDlg->end_active_widget_list) {
if (pwidget == pDlg->end_widget_list) {
pDlg->end_widget_list = pwidget->prev;
if (pwidget == dlg->end_active_widget_list) {
if (pwidget == dlg->end_widget_list) {
dlg->end_widget_list = pwidget->prev;
}
if (pwidget == pDlg->active_widget_list) {
pDlg->active_widget_list = pwidget->prev;
if (pwidget == dlg->active_widget_list) {
dlg->active_widget_list = pwidget->prev;
}
pDlg->end_active_widget_list = pwidget->prev;
dlg->end_active_widget_list = pwidget->prev;
}
if (pDlg->active_widget_list && (pDlg->active_widget_list == pwidget)) {
pDlg->active_widget_list = pwidget->prev;
if (dlg->active_widget_list && (dlg->active_widget_list == pwidget)) {
dlg->active_widget_list = pwidget->prev;
}
del_widget_from_gui_list(pwidget);
if (pDlg->scroll && pDlg->scroll->pscroll_bar && pDlg->active_widget_list) {
widget_undraw(pDlg->scroll->pscroll_bar);
pDlg->scroll->pscroll_bar->size.y = get_position(pDlg);
refresh_widget_background(pDlg->scroll->pscroll_bar);
if (dlg->scroll && dlg->scroll->pscroll_bar && dlg->active_widget_list) {
widget_undraw(dlg->scroll->pscroll_bar);
dlg->scroll->pscroll_bar->size.y = get_position(dlg);
refresh_widget_background(dlg->scroll->pscroll_bar);
}
return TRUE;
......
/**********************************************************************//**
Create a new horizontal scrollbar to active widgets list.
**************************************************************************/
Uint32 create_horizontal_scrollbar(struct advanced_dialog *pDlg,
Uint32 create_horizontal_scrollbar(struct advanced_dialog *dlg,
Sint16 start_x, Sint16 start_y,
Uint16 width, Uint16 active,
bool create_scrollbar, bool create_buttons,
......
Uint16 count = 0;
struct widget *buf = NULL, *pwindow = NULL;
fc_assert_ret_val(pDlg != NULL, 0);
fc_assert_ret_val(dlg != NULL, 0);
pwindow = pDlg->end_widget_list;
pwindow = dlg->end_widget_list;
if (!pDlg->scroll) {
pDlg->scroll = fc_calloc(1, sizeof(struct scroll_bar));
if (!dlg->scroll) {
dlg->scroll = fc_calloc(1, sizeof(struct scroll_bar));
pDlg->scroll->active = active;
dlg->scroll->active = active;
buf = pDlg->end_active_widget_list;
while (buf && buf != pDlg->begin_active_widget_list->prev) {
buf = dlg->end_active_widget_list;
while (buf && buf != dlg->begin_active_widget_list->prev) {
buf = buf->prev;
count++;
}
pDlg->scroll->count = count;
dlg->scroll->count = count;
}
if (create_buttons) {
......
buf = create_themeicon_button(current_theme->LEFT_Icon, pwindow->dst, NULL, 0);
buf->ID = ID_BUTTON;
buf->data.ptr = (void *)pDlg;
buf->data.ptr = (void *)dlg;
set_wstate(buf, FC_WS_NORMAL);
buf->size.x = start_x;
......
buf->size.y = start_y;
}
pDlg->scroll->min = start_x + buf->size.w;
pDlg->scroll->up_left_button = buf;
widget_add_as_prev(buf, pDlg->begin_widget_list);
pDlg->begin_widget_list = buf;
dlg->scroll->min = start_x + buf->size.w;
dlg->scroll->up_left_button = buf;
widget_add_as_prev(buf, dlg->begin_widget_list);
dlg->begin_widget_list = buf;
count = buf->size.h;
......
buf = create_themeicon_button(current_theme->RIGHT_Icon, pwindow->dst, NULL, 0);
buf->ID = ID_BUTTON;
buf->data.ptr = (void *)pDlg;
buf->data.ptr = (void *)dlg;
set_wstate(buf, FC_WS_NORMAL);
buf->size.x = start_x + width - buf->size.w;
......
buf->size.y = start_y;
}
pDlg->scroll->max = buf->size.x;
pDlg->scroll->down_right_button = buf;
widget_add_as_prev(buf, pDlg->begin_widget_list);
pDlg->begin_widget_list = buf;
dlg->scroll->max = buf->size.x;
dlg->scroll->down_right_button = buf;
widget_add_as_prev(buf, dlg->begin_widget_list);
dlg->begin_widget_list = buf;
}
if (create_scrollbar) {
......
width, WF_RESTORE_BACKGROUND);
buf->ID = ID_SCROLLBAR;
buf->data.ptr = (void *)pDlg;
buf->data.ptr = (void *)dlg;
set_wstate(buf, FC_WS_NORMAL);
if (swap_start_y) {
......
}
if (create_buttons) {
buf->size.x = start_x + pDlg->scroll->up_left_button->size.w;
if (pDlg->scroll->count > pDlg->scroll->active) {
buf->size.w = scrollbar_size(pDlg->scroll);
buf->size.x = start_x + dlg->scroll->up_left_button->size.w;
if (dlg->scroll->count > dlg->scroll->active) {
buf->size.w = scrollbar_size(dlg->scroll);
} else {
buf->size.w = pDlg->scroll->max - pDlg->scroll->min;
buf->size.w = dlg->scroll->max - dlg->scroll->min;
}
} else {
buf->size.x = start_x;
pDlg->scroll->min = start_x;
pDlg->scroll->max = start_x + width;
dlg->scroll->min = start_x;
dlg->scroll->max = start_x + width;
}
pDlg->scroll->pscroll_bar = buf;
widget_add_as_prev(buf, pDlg->begin_widget_list);
pDlg->begin_widget_list = buf;
dlg->scroll->pscroll_bar = buf;
widget_add_as_prev(buf, dlg->begin_widget_list);
dlg->begin_widget_list = buf;
if (!count) {
count = buf->size.h;
client/gui-sdl2/widget_scrollbar.h
Uint16 height, Uint32 flags);
int draw_vert(struct widget *pVert, Sint16 x, Sint16 y);
Uint32 create_vertical_scrollbar(struct advanced_dialog *pDlg,
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg,
Uint8 step, Uint8 active,
bool create_scrollbar, bool create_buttons);
......
Uint16 width, Uint32 flags);
int draw_horiz(struct widget *pHoriz, Sint16 x, Sint16 y);
Uint32 create_horizontal_scrollbar(struct advanced_dialog *pDlg,
Uint32 create_horizontal_scrollbar(struct advanced_dialog *dlg,
Sint16 start_x, Sint16 start_y,
Uint16 width, Uint16 active,
bool create_scrollbar, bool create_buttons,
    (1-1/1)