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 #893342 ยป 0017-sdl2-Rename-pWidget-as-pwidget.patch

Marko Lindqvist, 2020-10-30 05:45 PM

View differences:

client/gui-sdl2/action_dialog.c
Requests up-to-date list of improvements, the return of
which will trigger the popup_sabotage_dialog() function.
**************************************************************************/
static int spy_strike_bld_request(struct widget *pWidget)
static int spy_strike_bld_request(struct widget *pwidget)
{
if (NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)
&& NULL != game_city_by_number(
......
Requests up-to-date list of improvements, the return of
which will trigger the popup_sabotage_dialog() function.
**************************************************************************/
static int spy_sabotage_request(struct widget *pWidget)
static int spy_sabotage_request(struct widget *pwidget)
{
if (NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)
&& NULL != game_city_by_number(
......
which will trigger the popup_sabotage_dialog() function.
(Escape version)
**************************************************************************/
static int spy_sabotage_esc_request(struct widget *pWidget)
static int spy_sabotage_esc_request(struct widget *pwidget)
{
if (NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)
&& NULL != game_city_by_number(
......
/**********************************************************************//**
Exit spy's steal or sabotage dialog.
**************************************************************************/
static int exit_spy_tgt_dlg_callback(struct widget *pWidget)
static int exit_spy_tgt_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int actor_id = pDiplomat_Dlg->actor_unit_id;
......
/**********************************************************************//**
User selected which tech spy steals.
**************************************************************************/
static int spy_steal_callback(struct widget *pWidget)
static int spy_steal_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int steal_advance = MAX_ID - pWidget->ID;
int steal_advance = MAX_ID - pwidget->ID;
int actor_id = pDiplomat_Dlg->actor_unit_id;
if (NULL != game_unit_by_number(pDiplomat_Dlg->actor_unit_id)
......
/**********************************************************************//**
Popup spy tech stealing dialog.
**************************************************************************/
static int spy_steal_popup_shared(struct widget *pWidget)
static int spy_steal_popup_shared(struct widget *pwidget)
{
const struct research *presearch, *vresearch;
struct city *pVcity = pWidget->data.city;
struct city *pVcity = pwidget->data.city;
int id = pDiplomat_Dlg->actor_unit_id;
struct player *pVictim = NULL;
struct CONTAINER *pCont;
......
/**********************************************************************//**
Popup spy tech stealing dialog for "Targeted Steal Tech".
**************************************************************************/
static int spy_steal_popup(struct widget *pWidget)
static int spy_steal_popup(struct widget *pwidget)
{
pDiplomat_Dlg->act_id = ACTION_SPY_TARGETED_STEAL_TECH;
return spy_steal_popup_shared(pWidget);
return spy_steal_popup_shared(pwidget);
}
/**********************************************************************//**
Popup spy tech stealing dialog for "Targeted Steal Tech Escape Expected".
**************************************************************************/
static int spy_steal_esc_popup(struct widget *pWidget)
static int spy_steal_esc_popup(struct widget *pwidget)
{
pDiplomat_Dlg->act_id = ACTION_SPY_TARGETED_STEAL_TECH_ESC;
return spy_steal_popup_shared(pWidget);
return spy_steal_popup_shared(pwidget);
}
/**********************************************************************//**
Ask the server how much the revolt is going to cost us
**************************************************************************/
static int diplomat_incite_callback(struct widget *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)
......
/**********************************************************************//**
Ask the server how much the revolt is going to cost us
**************************************************************************/
static int spy_incite_callback(struct widget *pWidget)
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)
......
(This should only occur when entering a tile with an allied city
or an allied unit.)
**************************************************************************/
static int act_sel_keep_moving_callback(struct widget *pWidget)
static int act_sel_keep_moving_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *punit;
if ((punit = game_unit_by_number(pDiplomat_Dlg->actor_unit_id))
&& !same_pos(unit_tile(punit), pWidget->data.tile)) {
request_unit_non_action_move(punit, pWidget->data.tile);
&& !same_pos(unit_tile(punit), pwidget->data.tile)) {
request_unit_non_action_move(punit, pwidget->data.tile);
}
popdown_diplomat_dialog();
......
/**********************************************************************//**
Delay selection of what action to take.
**************************************************************************/
static int act_sel_wait_callback(struct widget *pWidget)
static int act_sel_wait_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
key_unit_wait();
......
/**********************************************************************//**
Ask the server how much the bribe costs
**************************************************************************/
static int diplomat_bribe_callback(struct widget *pWidget)
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)
......
/**********************************************************************//**
User clicked "Found City"
**************************************************************************/
static int found_city_callback(struct widget *pWidget)
static int found_city_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int actor_id = pDiplomat_Dlg->actor_unit_id;
......
/**********************************************************************//**
User clicked "Upgrade Unit"
**************************************************************************/
static int upgrade_callback(struct widget *pWidget)
static int upgrade_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *punit;
......
User selected an action from the choice dialog and the action has no
special needs.
**************************************************************************/
static int simple_action_callback(struct widget *pWidget)
static int simple_action_callback(struct widget *pwidget)
{
int actor_id, target_id, sub_target;
struct action *paction;
......
}
/* Data */
paction = action_by_number(MAX_ID - pWidget->ID);
paction = action_by_number(MAX_ID - pwidget->ID);
/* Actor */
fc_assert(action_get_actor_kind(paction) == AAK_UNIT);
......
/**********************************************************************//**
Close diplomat dialog.
**************************************************************************/
static int diplomat_close_callback(struct widget *pWidget)
static int diplomat_close_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_diplomat_dialog();
......
/**********************************************************************//**
User selected what to sabotage.
**************************************************************************/
static int sabotage_impr_callback(struct widget *pWidget)
static int sabotage_impr_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int sabotage_improvement = MAX_ID - pWidget->ID;
int diplomat_target_id = pWidget->data.cont->id0;
int diplomat_id = pWidget->data.cont->id1;
action_id act_id = pWidget->data.cont->value;
int sabotage_improvement = MAX_ID - pwidget->ID;
int diplomat_target_id = pwidget->data.cont->id0;
int diplomat_id = pwidget->data.cont->id1;
action_id act_id = pwidget->data.cont->value;
fc_assert(is_more_user_input_needed);
popdown_diplomat_dialog();
......
/**********************************************************************//**
User confirmed incite
**************************************************************************/
static int diplomat_incite_yes_callback(struct widget *pWidget)
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)
......
/**********************************************************************//**
Close incite dialog.
**************************************************************************/
static int exit_incite_dlg_callback(struct widget *pWidget)
static int exit_incite_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_incite_dialog();
......
/**********************************************************************//**
User confirmed bribe.
**************************************************************************/
static int diplomat_bribe_yes_callback(struct widget *pWidget)
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)
......
/**********************************************************************//**
Close bribe dialog.
**************************************************************************/
static int exit_bribe_dlg_callback(struct widget *pWidget)
static int exit_bribe_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_bribe_dialog();
client/gui-sdl2/chatline.c
/**********************************************************************//**
User clicked load game dialog close-button.
**************************************************************************/
static int exit_load_dlg_callback(struct widget *pWidget)
static int exit_load_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (get_client_page() == PAGE_LOAD) {
......
/**********************************************************************//**
User selected file to load.
**************************************************************************/
static int load_selected_game_callback(struct widget *pWidget)
static int load_selected_game_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
char *filename = (char*)pWidget->data.ptr;
char *filename = (char*)pwidget->data.ptr;
if (is_server_running()) {
send_chat_printf("/load %s", filename);
......
/**********************************************************************//**
Sent msg/command from input dlg to server
**************************************************************************/
static int inputline_return_callback(struct widget *pWidget)
static int inputline_return_callback(struct widget *pwidget)
{
if (main_data.event.type == SDL_KEYDOWN
&& (main_data.event.key.keysym.sym == SDLK_RETURN
|| main_data.event.key.keysym.sym == SDLK_KP_ENTER)) {
if (pWidget->string_utf8->text == NULL) {
if (pwidget->string_utf8->text == NULL) {
return -1;
}
if (pWidget->string_utf8->text[0] != '\0') {
send_chat(pWidget->string_utf8->text);
if (pwidget->string_utf8->text[0] != '\0') {
send_chat(pwidget->string_utf8->text);
output_window_append(ftc_any, pWidget->string_utf8->text);
output_window_append(ftc_any, pwidget->string_utf8->text);
}
}
......
/**********************************************************************//**
User selected to get back from connection list dialog.
**************************************************************************/
static int disconnect_conn_callback(struct widget *pWidget)
static int disconnect_conn_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_conn_list_dialog();
......
/**********************************************************************//**
User interacted with connection dialog input field.
**************************************************************************/
static int input_edit_conn_callback(struct widget *pWidget)
static int input_edit_conn_callback(struct widget *pwidget)
{
if (main_data.event.type == SDL_KEYDOWN
&& (main_data.event.key.keysym.sym == SDLK_RETURN
|| main_data.event.key.keysym.sym == SDLK_KP_ENTER)) {
if (pWidget->string_utf8->text != NULL) {
if (pWidget->string_utf8->text[0] != '\0') {
send_chat(pWidget->string_utf8->text);
if (pwidget->string_utf8->text != NULL) {
if (pwidget->string_utf8->text[0] != '\0') {
send_chat(pwidget->string_utf8->text);
}
free(pWidget->string_utf8->text);
pWidget->string_utf8->text = fc_malloc(1);
pWidget->string_utf8->n_alloc = 0;
free(pwidget->string_utf8->text);
pwidget->string_utf8->text = fc_malloc(1);
pwidget->string_utf8->n_alloc = 0;
}
}
......
/**********************************************************************//**
User interacted with Start Game button.
**************************************************************************/
static int start_game_callback(struct widget *pWidget)
static int start_game_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
send_chat("/start");
......
/**********************************************************************//**
User interacted with Select Nation button.
**************************************************************************/
static int select_nation_callback(struct widget *pWidget)
static int select_nation_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popup_races_dialog(client.conn.playing);
......
/**********************************************************************//**
User interacted with Server Settings button.
**************************************************************************/
static int server_config_callback(struct widget *pWidget)
static int server_config_callback(struct widget *pwidget)
{
return -1;
}
......
/**********************************************************************//**
User interacted with Load Game button.
**************************************************************************/
static int load_game_callback(struct widget *pWidget)
static int load_game_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
/* set_wstate(pConnDlg->pLoadGameButton, FC_WS_NORMAL);
client/gui-sdl2/citydlg.c
/**********************************************************************//**
City option callback
**************************************************************************/
static int misc_panel_city_dlg_callback(struct widget *pWidget)
static int misc_panel_city_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
bv_city_options new_options = pcity_dlg->pCity->city_options;
switch (MAX_ID - pWidget->ID) {
switch (MAX_ID - pwidget->ID) {
case 0x10:
if (BV_ISSET(new_options, CITYO_DISBAND)) {
BV_CLR(new_options, CITYO_DISBAND);
......
BV_SET(new_options, CITYO_GOLD_SPECIALISTS);
}
pWidget->theme2 = get_tax_surface(O_GOLD);
pWidget->ID = MAX_ID - 0x40;
widget_redraw(pWidget);
widget_flush(pWidget);
pwidget->theme2 = get_tax_surface(O_GOLD);
pwidget->ID = MAX_ID - 0x40;
widget_redraw(pwidget);
widget_flush(pwidget);
break;
case 0x40:
BV_CLR(new_options, CITYO_SCIENCE_SPECIALISTS);
BV_CLR(new_options, CITYO_GOLD_SPECIALISTS);
pWidget->theme2 = get_tax_surface(O_LUXURY);
pWidget->ID = MAX_ID - 0x60;
widget_redraw(pWidget);
widget_flush(pWidget);
pwidget->theme2 = get_tax_surface(O_LUXURY);
pwidget->ID = MAX_ID - 0x60;
widget_redraw(pwidget);
widget_flush(pwidget);
break;
case 0x60:
if (BV_ISSET(new_options, CITYO_SCIENCE_SPECIALISTS)) {
......
BV_SET(new_options, CITYO_SCIENCE_SPECIALISTS);
}
pWidget->theme2 = get_tax_surface(O_SCIENCE);
pWidget->ID = MAX_ID - 0x20;
widget_redraw(pWidget);
widget_flush(pWidget);
pwidget->theme2 = get_tax_surface(O_SCIENCE);
pwidget->ID = MAX_ID - 0x20;
widget_redraw(pwidget);
widget_flush(pwidget);
break;
}
......
set_group_state(pcity_dlg->pImprv->pBeginActiveWidgetList,
pcity_dlg->pImprv->pEndActiveWidgetList, FC_WS_DISABLED);
} else {
struct widget *pTmpWidget = pcity_dlg->pImprv->pEndActiveWidgetList;
struct widget *tmp_widget = pcity_dlg->pImprv->pEndActiveWidgetList;
while (TRUE) {
struct impr_type *pimpr = improvement_by_number(MAX_ID - 3000 -
pTmpWidget->ID);
tmp_widget->ID);
if (!can_city_sell_building(pcity_dlg->pCity, pimpr)) {
set_wstate(pTmpWidget, FC_WS_DISABLED);
set_wstate(tmp_widget, FC_WS_DISABLED);
} else {
set_wstate(pTmpWidget, FC_WS_NORMAL);
set_wstate(tmp_widget, FC_WS_NORMAL);
}
if (pTmpWidget == pcity_dlg->pImprv->pBeginActiveWidgetList) {
if (tmp_widget == pcity_dlg->pImprv->pBeginActiveWidgetList) {
break;
}
pTmpWidget = pTmpWidget->prev;
tmp_widget = tmp_widget->prev;
} /* while */
}
client/gui-sdl2/cityrep.c
/**********************************************************************//**
User interacted with city report close button.
**************************************************************************/
static int exit_city_report_callback(struct widget *pWidget)
static int exit_city_report_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
city_report_dialog_popdown();
......
/**********************************************************************//**
User interacted with city button on city report.
**************************************************************************/
static int popup_citydlg_from_city_report_callback(struct widget *pWidget)
static int popup_citydlg_from_city_report_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popup_city_dialog(pWidget->data.city);
popup_city_dialog(pwidget->data.city);
}
return -1;
......
/**********************************************************************//**
User interacted with worklist button on city report.
**************************************************************************/
static int popup_worklist_from_city_report_callback(struct widget *pWidget)
static int popup_worklist_from_city_report_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popup_worklist_editor(pWidget->data.city, NULL);
popup_worklist_editor(pwidget->data.city, NULL);
}
return -1;
......
/**********************************************************************//**
User interacted with city production button on city report.
**************************************************************************/
static int popup_buy_production_from_city_report_callback(struct widget *pWidget)
static int popup_buy_production_from_city_report_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popup_hurry_production_dialog(pWidget->data.city, NULL);
popup_hurry_production_dialog(pwidget->data.city, NULL);
}
return -1;
......
/**********************************************************************//**
User interacted with cma button on city report.
**************************************************************************/
static int popup_cma_from_city_report_callback(struct widget *pWidget)
static int popup_cma_from_city_report_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct city *pCity = game_city_by_number(MAX_ID - pWidget->ID);
struct city *pCity = game_city_by_number(MAX_ID - pwidget->ID);
/* state is changed before enter this function */
if (!get_checkbox_state(pWidget)) {
if (!get_checkbox_state(pwidget)) {
cma_release_city(pCity);
city_report_dialog_update_city(pCity);
} else {
......
/**********************************************************************//**
User interacted with information report button.
**************************************************************************/
static int info_city_report_callback(struct widget *pWidget)
static int info_city_report_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
set_wstate(pWidget, FC_WS_NORMAL);
set_wstate(pwidget, FC_WS_NORMAL);
selected_widget = NULL;
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
real_info_city_report_dialog_update();
}
......
/**********************************************************************//**
Update city information in city report.
**************************************************************************/
static struct widget *real_city_report_dialog_update_city(struct widget *pWidget,
static struct widget *real_city_report_dialog_update_city(struct widget *pwidget,
struct city *pCity)
{
char cbuf[64];
......
/* city name status */
if (city_unhappy(pCity)) {
pWidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_TRADE);
pwidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_TRADE);
} else {
if (city_celebrating(pCity)) {
pWidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_CELEB);
pwidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_CELEB);
} else {
if (city_happy(pCity)) {
pWidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_HAPPY);
pwidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_HAPPY);
}
}
}
/* city size */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
fc_snprintf(cbuf, sizeof(cbuf), "%d", city_size_get(pCity));
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
/* cma check box */
pWidget = pWidget->prev;
if (cma_is_city_under_agent(pCity, NULL) != get_checkbox_state(pWidget)) {
toggle_checkbox(pWidget);
pwidget = pwidget->prev;
if (cma_is_city_under_agent(pCity, NULL) != get_checkbox_state(pwidget)) {
toggle_checkbox(pwidget);
}
/* food consumptions */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->prod[O_FOOD] - pCity->surplus[O_FOOD]);
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
/* food surplus */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->surplus[O_FOOD]);
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
/* time to grow */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
togrow = city_turns_to_grow(pCity);
switch (togrow) {
case 0:
......
fc_snprintf(cbuf, sizeof(cbuf), "%d", togrow);
break;
}
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
if (togrow < 0) {
pWidget->string_utf8->fgcol.r = 255;
pwidget->string_utf8->fgcol.r = 255;
} else {
pWidget->string_utf8->fgcol.r = 0;
pwidget->string_utf8->fgcol.r = 0;
}
/* trade production */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->surplus[O_TRADE]);
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
/* corruptions */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->waste[O_TRADE]);
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
/* gold surplus */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->surplus[O_GOLD]);
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
/* science income */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->prod[O_SCIENCE]);
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
/* lugury income */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->prod[O_LUXURY]);
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
/* total production */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
fc_snprintf(cbuf, sizeof(cbuf), "%d",
pCity->prod[O_SHIELD] + pCity->waste[O_SHIELD]);
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
/* waste */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->waste[O_SHIELD]);
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
/* units support */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->prod[O_SHIELD] +
pCity->waste[O_SHIELD] - pCity->surplus[O_SHIELD]);
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
/* production income */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->surplus[O_SHIELD]);
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
/* change production */
if (VUT_UTYPE == pCity->production.kind) {
......
pName, pCity->shield_stock, togrow);
}
pWidget = pWidget->prev;
copy_chars_to_utf8_str(pWidget->info_label, cbuf);
FREESURFACE(pWidget->theme);
pWidget->theme = pLogo;
pwidget = pwidget->prev;
copy_chars_to_utf8_str(pwidget->info_label, cbuf);
FREESURFACE(pwidget->theme);
pwidget->theme = pLogo;
/* hurry productions */
pWidget = pWidget->prev;
pwidget = pwidget->prev;
togrow = city_production_turns_to_build(pCity, TRUE);
if (togrow == 999) {
fc_snprintf(cbuf, sizeof(cbuf), "%s", _("never"));
......
togrow, PL_("turn", "turns", togrow));
}
copy_chars_to_utf8_str(pWidget->string_utf8, cbuf);
copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
return pWidget->prev;
return pwidget->prev;
}
/* ======================================================================== */
......
void real_city_report_dialog_update(void *unused)
{
if (pCityRep) {
struct widget *pWidget;
struct widget *pwidget;
int count;
/* find if the lists are identical (if not then rebuild all) */
pWidget = pCityRep->pEndActiveWidgetList;/* name of first city */
pwidget = pCityRep->pEndActiveWidgetList;/* name of first city */
city_list_iterate(client.conn.playing->cities, pCity) {
if (pCity->id == MAX_ID - pWidget->ID) {
if (pCity->id == MAX_ID - pwidget->ID) {
count = COL;
while (count) {
count--;
pWidget = pWidget->prev;
pwidget = pwidget->prev;
}
} else {
real_info_city_report_dialog_update();
......
} city_list_iterate_end;
/* check it there are some city widgets left on list */
if (pWidget && pWidget->next != pCityRep->pBeginActiveWidgetList) {
if (pwidget && pwidget->next != pCityRep->pBeginActiveWidgetList) {
real_info_city_report_dialog_update();
return;
}
/* update widget city list (widget list is the same that city list) */
pWidget = pCityRep->pEndActiveWidgetList;
pwidget = pCityRep->pEndActiveWidgetList;
city_list_iterate(client.conn.playing->cities, pCity) {
pWidget = real_city_report_dialog_update_city(pWidget, pCity);
pwidget = real_city_report_dialog_update_city(pwidget, pCity);
} city_list_iterate_end;
/* -------------------------------------- */
client/gui-sdl2/cma_fe.c
/**********************************************************************//**
User interacted with cma dialog close button.
**************************************************************************/
static int exit_cma_dialog_callback(struct widget *pWidget)
static int exit_cma_dialog_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_city_cma_dialog();
......
/**********************************************************************//**
User interacted with minimal horizontal cma scrollbar
**************************************************************************/
static int min_horiz_cma_callback(struct widget *pWidget)
static int min_horiz_cma_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct hmove pMotion;
pMotion.pScrollBar = pWidget;
pMotion.min = pWidget->next->size.x + pWidget->next->size.w + 5;
pMotion.pScrollBar = pwidget;
pMotion.min = pwidget->next->size.x + pwidget->next->size.w + 5;
pMotion.max = pMotion.min + 70;
pMotion.base = -20;
......
MOVE_STEP_X = DEFAULT_MOVE_STEP;
MOVE_STEP_Y = DEFAULT_MOVE_STEP;
selected_widget = pWidget;
set_wstate(pWidget, FC_WS_SELECTED);
selected_widget = pwidget;
set_wstate(pwidget, FC_WS_SELECTED);
/* save the change */
cmafec_set_fe_parameter(pCma->pCity, &pCma->edited_cm_parm);
/* refreshes the cma */
......
/**********************************************************************//**
User interacted with factor horizontal cma scrollbar
**************************************************************************/
static int factor_horiz_cma_callback(struct widget *pWidget)
static int factor_horiz_cma_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct hmove pMotion;
pMotion.pScrollBar = pWidget;
pMotion.min = pWidget->next->size.x + pWidget->next->size.w + 5;
pMotion.pScrollBar = pwidget;
pMotion.min = pwidget->next->size.x + pwidget->next->size.w + 5;
pMotion.max = pMotion.min + 54;
pMotion.base = 1;
......
MOVE_STEP_X = DEFAULT_MOVE_STEP;
MOVE_STEP_Y = DEFAULT_MOVE_STEP;
selected_widget = pWidget;
set_wstate(pWidget, FC_WS_SELECTED);
selected_widget = pwidget;
set_wstate(pwidget, FC_WS_SELECTED);
/* save the change */
cmafec_set_fe_parameter(pCma->pCity, &pCma->edited_cm_parm);
/* refreshes the cma */
......
/**********************************************************************//**
User interacted with cma celebrating -toggle.
**************************************************************************/
static int toggle_cma_celebrating_callback(struct widget *pWidget)
static int toggle_cma_celebrating_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
pCma->edited_cm_parm.require_happy ^= TRUE;
......
/**********************************************************************//**
User interacted with "yes" button from save cma dialog.
**************************************************************************/
static int ok_save_cma_callback(struct widget *pWidget)
static int ok_save_cma_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pWidget && pCma && pCma->pAdv) {
struct widget *pEdit = (struct widget *)pWidget->data.ptr;
if (pwidget && pCma && pCma->pAdv) {
struct widget *pEdit = (struct widget *)pwidget->data.ptr;
if (pEdit->string_utf8->text != NULL) {
cmafec_preset_add(pEdit->string_utf8->text, &pCma->edited_cm_parm);
......
/**********************************************************************//**
Cancel : SAVE, LOAD, DELETE Dialogs
**************************************************************************/
static int cancel_SLD_cma_callback(struct widget *pWidget)
static int cancel_SLD_cma_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pCma && pCma->pAdv) {
......
/**********************************************************************//**
User interacted with cma setting saving button.
**************************************************************************/
static int save_cma_callback(struct widget *pWidget)
static int save_cma_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct widget *pBuf, *pwindow;
......
area = pwindow->area;
widget_set_position(pwindow,
pWidget->size.x - pwindow->size.w / 2,
pWidget->size.y - pwindow->size.h);
pwidget->size.x - pwindow->size.w / 2,
pwidget->size.y - pwindow->size.h);
/* setup rest of widgets */
/* label */
......
/**********************************************************************//**
User interacted with some preset cma button.
**************************************************************************/
static int LD_cma_callback(struct widget *pWidget)
static int LD_cma_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
bool load = pWidget->data.ptr != NULL;
int index = MAX_ID - pWidget->ID;
bool load = pwidget->data.ptr != NULL;
int index = MAX_ID - pwidget->ID;
popdown_window_group_dialog(pCma->pAdv->pBeginWidgetList,
pCma->pAdv->pEndWidgetList);
......
/**********************************************************************//**
User interacted with load cma settings -widget
**************************************************************************/
static int load_cma_callback(struct widget *pWidget)
static int load_cma_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popup_load_del_presets_dialog(TRUE, pWidget);
popup_load_del_presets_dialog(TRUE, pwidget);
}
return -1;
......
/**********************************************************************//**
User interacted with delete cma settings -widget
**************************************************************************/
static int del_cma_callback(struct widget *pWidget)
static int del_cma_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popup_load_del_presets_dialog(FALSE, pWidget);
popup_load_del_presets_dialog(FALSE, pwidget);
}
return -1;
......
Changes the workers of the city to the cma parameters and puts the
city under agent control
**************************************************************************/
static int run_cma_callback(struct widget *pWidget)
static int run_cma_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
cma_put_city_under_agent(pCma->pCity, &pCma->edited_cm_parm);
......
/**********************************************************************//**
Changes the workers of the city to the cma parameters
**************************************************************************/
static int run_cma_once_callback(struct widget *pWidget)
static int run_cma_once_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct cm_result *result;
......
/**********************************************************************//**
User interacted with release city from cma -widget
**************************************************************************/
static int stop_cma_callback(struct widget *pWidget)
static int stop_cma_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
cma_release_city(pCma->pCity);
client/gui-sdl2/connectdlg.c
static struct ADVANCED_DLG *pMeta_Server = NULL;
static struct SMALL_DLG *pConnectDlg = NULL;
static int connect_callback(struct widget *pWidget);
static int convert_portnr_callback(struct widget *pWidget);
static int convert_playername_callback(struct widget *pWidget);
static int convert_servername_callback(struct widget *pWidget);
static int connect_callback(struct widget *pwidget);
static int convert_portnr_callback(struct widget *pwidget);
static int convert_playername_callback(struct widget *pwidget);
static int convert_servername_callback(struct widget *pwidget);
static void popup_new_user_passwd_dialog(const char *pMessage);
/*
......
/**********************************************************************//**
User interacted with connect -widget
**************************************************************************/
static int connect_callback(struct widget *pWidget)
static int connect_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
char errbuf[512];
......
/* button up */
unselect_widget_action();
set_wstate(pWidget, FC_WS_SELECTED);
selected_widget = pWidget;
widget_redraw(pWidget);
widget_flush(pWidget);
set_wstate(pwidget, FC_WS_SELECTED);
selected_widget = pwidget;
widget_redraw(pwidget);
widget_flush(pwidget);
}
}
......
/**********************************************************************//**
Close servers dialog.
**************************************************************************/
static int exit_meta_server_dlg_callback(struct widget *pWidget)
static int exit_meta_server_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
queue_flush();
......
/**********************************************************************//**
Server selected from dialog.
**************************************************************************/
static int select_meta_servers_callback(struct widget *pWidget)
static int select_meta_servers_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct server *pServer = (struct server *)pWidget->data.ptr;
struct server *pServer = (struct server *)pwidget->data.ptr;
sz_strlcpy(server_host, pServer->host);
server_port = pServer->port;
......
/**********************************************************************//**
User interacted with playername widget.
**************************************************************************/
static int convert_playername_callback(struct widget *pWidget)
static int convert_playername_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pWidget->string_utf8->text != NULL) {
sz_strlcpy(user_name, pWidget->string_utf8->text);
if (pwidget->string_utf8->text != NULL) {
sz_strlcpy(user_name, pwidget->string_utf8->text);
} else {
/* empty input -> restore previous content */
copy_chars_to_utf8_str(pWidget->string_utf8, user_name);
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
copy_chars_to_utf8_str(pwidget->string_utf8, user_name);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
flush_dirty();
}
}
......
/**********************************************************************//**
User interacted with servername widget.
**************************************************************************/
static int convert_servername_callback(struct widget *pWidget)
static int convert_servername_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pWidget->string_utf8->text != NULL) {
sz_strlcpy(server_host, pWidget->string_utf8->text);
if (pwidget->string_utf8->text != NULL) {
sz_strlcpy(server_host, pwidget->string_utf8->text);
} else {
/* empty input -> restore previous content */
copy_chars_to_utf8_str(pWidget->string_utf8, server_host);
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
copy_chars_to_utf8_str(pwidget->string_utf8, server_host);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
flush_dirty();
}
}
......
/**********************************************************************//**
User interacted with port number widget.
**************************************************************************/
static int convert_portnr_callback(struct widget *pWidget)
static int convert_portnr_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
char pCharPort[6];
if (pWidget->string_utf8->text != NULL) {
sscanf(pWidget->string_utf8->text, "%d", &server_port);
if (pwidget->string_utf8->text != NULL) {
sscanf(pwidget->string_utf8->text, "%d", &server_port);
} else {
/* empty input -> restore previous content */
fc_snprintf(pCharPort, sizeof(pCharPort), "%d", server_port);
copy_chars_to_utf8_str(pWidget->string_utf8, pCharPort);
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
copy_chars_to_utf8_str(pwidget->string_utf8, pCharPort);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
flush_dirty();
}
}
......
/**********************************************************************//**
User interacted with cancel -button
**************************************************************************/
static int cancel_connect_dlg_callback(struct widget *pWidget)
static int cancel_connect_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
close_connection_dialog();
......
/**********************************************************************//**
User interacted with password widget
**************************************************************************/
static int convert_passwd_callback(struct widget *pWidget)
static int convert_passwd_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pWidget->string_utf8->text != NULL) {
fc_snprintf(password, MAX_LEN_NAME, "%s", pWidget->string_utf8->text);
if (pwidget->string_utf8->text != NULL) {
fc_snprintf(password, MAX_LEN_NAME, "%s", pwidget->string_utf8->text);
}
}
......
/**********************************************************************//**
User interacted with "Next" -button after entering password.
**************************************************************************/
static int send_passwd_callback(struct widget *pWidget)
static int send_passwd_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct packet_authentication_reply reply;
......
memset(password, 0, MAX_LEN_NAME);
password[0] = '\0';
set_wstate(pWidget, FC_WS_DISABLED);
set_wstate(pwidget, FC_WS_DISABLED);
widget_redraw(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pWidget);
widget_mark_dirty(pwidget);
flush_dirty();
......
/**********************************************************************//**
Close password dialog with no password given.
**************************************************************************/
static int cancel_passwd_callback(struct widget *pWidget)
static int cancel_passwd_callback(struct widget *pwidget)
{
memset(password, 0, MAX_LEN_NAME);
password[0] = '\0';
disconnect_from_server();
return cancel_connect_dlg_callback(pWidget);
return cancel_connect_dlg_callback(pwidget);
}
/**********************************************************************//**
......
/**********************************************************************//**
New Password
**************************************************************************/
static int convert_first_passwd_callback(struct widget *pWidget)
static int convert_first_passwd_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pWidget->string_utf8->text != NULL) {
fc_snprintf(password, MAX_LEN_NAME, "%s", pWidget->string_utf8->text);
set_wstate(pWidget->prev, FC_WS_NORMAL);
widget_redraw(pWidget->prev);
widget_flush(pWidget->prev);
if (pwidget->string_utf8->text != NULL) {
fc_snprintf(password, MAX_LEN_NAME, "%s", pwidget->string_utf8->text);
set_wstate(pwidget->prev, FC_WS_NORMAL);
widget_redraw(pwidget->prev);
widget_flush(pwidget->prev);
}
}
......
/**********************************************************************//**
Verify Password
**************************************************************************/
static int convert_second_passwd_callback(struct widget *pWidget)
static int convert_second_passwd_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pWidget->string_utf8->text != NULL
&& !strncmp(password, pWidget->string_utf8->text, MAX_LEN_NAME)) {
set_wstate(pWidget->prev, FC_WS_NORMAL); /* next button */
widget_redraw(pWidget->prev);
widget_flush(pWidget->prev);
if (pwidget->string_utf8->text != NULL
&& !strncmp(password, pwidget->string_utf8->text, MAX_LEN_NAME)) {
set_wstate(pwidget->prev, FC_WS_NORMAL); /* next button */
widget_redraw(pwidget->prev);
widget_flush(pwidget->prev);
} else {
memset(password, 0, MAX_LEN_NAME);
password[0] = '\0';
FC_FREE(pWidget->next->string_utf8->text);/* first edit */
FC_FREE(pWidget->string_utf8->text); /* second edit */
FC_FREE(pwidget->next->string_utf8->text);/* first edit */
FC_FREE(pwidget->string_utf8->text); /* second edit */
popup_new_user_passwd_dialog(_("Passwords don't match, enter password."));
}
client/gui-sdl2/dialogs.c
void popdown_advanced_terrain_dialog(void);
int advanced_terrain_window_dlg_callback(struct widget *pwindow);
int exit_advanced_terrain_dlg_callback(struct widget *pWidget);
int exit_advanced_terrain_dlg_callback(struct widget *pwidget);
static char *pLeaderName = NULL;
......
/**********************************************************************//**
User interacted with notify dialog close button.
**************************************************************************/
static int exit_notify_dialog_callback(struct widget *pWidget)
static int exit_notify_dialog_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pNotifyDlg) {
......
/**********************************************************************//**
User interacted with upgrade unit dialog cancel -button
**************************************************************************/
static int cancel_upgrade_unit_callback(struct widget *pWidget)
static int cancel_upgrade_unit_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_unit_upgrade_dlg();
......
/**********************************************************************//**
User interacted with unit upgrade dialog "Upgrade" -button.
**************************************************************************/
static int ok_upgrade_unit_window_callback(struct widget *pWidget)
static int ok_upgrade_unit_window_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *pUnit = pWidget->data.unit;
struct unit *pUnit = pwidget->data.unit;
popdown_unit_upgrade_dlg();
/* enable city dlg */
......
/**********************************************************************//**
User interacted with disband unit dialog cancel -button
**************************************************************************/
static int cancel_disband_unit_callback(struct widget *pWidget)
static int cancel_disband_unit_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_unit_disband_dlg();
......
/**********************************************************************//**
User interacted with unit disband dialog "Disband" -button.
**************************************************************************/
static int ok_disband_unit_window_callback(struct widget *pWidget)
static int ok_disband_unit_window_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *pUnit = pWidget->data.unit;
struct unit *pUnit = pwidget->data.unit;
popdown_unit_disband_dlg();
/* enable city dlg */
......
/**********************************************************************//**
User requested unit select window to be closed.
**************************************************************************/
static int exit_unit_select_callback(struct widget *pWidget)
static int exit_unit_select_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
unit_select_dialog_popdown();
......
/**********************************************************************//**
User selected unit from unit select window.
**************************************************************************/
static int unit_select_callback(struct widget *pWidget)
static int unit_select_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *pUnit =
player_unit_by_number(client_player(), MAX_ID - pWidget->ID);
player_unit_by_number(client_player(), MAX_ID - pwidget->ID);
unit_select_dialog_popdown();
if (pUnit) {
......
/**********************************************************************//**
User requested closing of advanced terrain dialog.
**************************************************************************/
int exit_advanced_terrain_dlg_callback(struct widget *pWidget)
int exit_advanced_terrain_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_advanced_terrain_dialog();
......
/**********************************************************************//**
User requested terrain info.
**************************************************************************/
static int terrain_info_callback(struct widget *pWidget)
static int terrain_info_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int x = pWidget->data.cont->id0;
int y = pWidget->data.cont->id1;
int x = pwidget->data.cont->id0;
int y = pwidget->data.cont->id1;
popdown_advanced_terrain_dialog();
......
/**********************************************************************//**
User requested zoom to city.
**************************************************************************/
static int zoom_to_city_callback(struct widget *pWidget)
static int zoom_to_city_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct city *pCity = pWidget->data.city;
struct city *pCity = pwidget->data.city;
popdown_advanced_terrain_dialog();
......
/**********************************************************************//**
User requested production change.
**************************************************************************/
static int change_production_callback(struct widget *pWidget)
static int change_production_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct city *pCity = pWidget->data.city;
struct city *pCity = pwidget->data.city;
popdown_advanced_terrain_dialog();
popup_worklist_editor(pCity, NULL);
......
/**********************************************************************//**
User requested hurry production.
**************************************************************************/
static int hurry_production_callback(struct widget *pWidget)
static int hurry_production_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct city *pCity = pWidget->data.city;
struct city *pCity = pwidget->data.city;
popdown_advanced_terrain_dialog();
......
/**********************************************************************//**
User requested opening of cma settings.
**************************************************************************/
static int cma_callback(struct widget *pWidget)
static int cma_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct city *pCity = pWidget->data.city;
struct city *pCity = pwidget->data.city;
popdown_advanced_terrain_dialog();
popup_city_cma_dialog(pCity);
......
/**********************************************************************//**
User selected unit.
**************************************************************************/
static int adv_unit_select_callback(struct widget *pWidget)
static int adv_unit_select_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *pUnit = pWidget->data.unit;
struct unit *pUnit = pwidget->data.unit;
popdown_advanced_terrain_dialog();
......
/**********************************************************************//**
User selected all units from tile.
**************************************************************************/
static int adv_unit_select_all_callback(struct widget *pWidget)
static int adv_unit_select_all_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *pUnit = pWidget->data.unit;
struct unit *pUnit = pwidget->data.unit;
popdown_advanced_terrain_dialog();
......
/**********************************************************************//**
Sentry unit widget contains.
**************************************************************************/
static int adv_unit_sentry_idle_callback(struct widget *pWidget)
static int adv_unit_sentry_idle_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *pUnit = pWidget->data.unit;
struct unit *pUnit = pwidget->data.unit;
popdown_advanced_terrain_dialog();
......
/**********************************************************************//**
Initiate goto to selected tile.
**************************************************************************/
static int goto_here_callback(struct widget *pWidget)
static int goto_here_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int x = pWidget->data.cont->id0;
int y = pWidget->data.cont->id1;
int x = pwidget->data.cont->id0;
int y = pwidget->data.cont->id1;
popdown_advanced_terrain_dialog();
......
/**********************************************************************//**
Initiate patrol to selected tile.
**************************************************************************/
static int patrol_here_callback(struct widget *pWidget)
static int patrol_here_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
/* FIXME */
#if 0
int x = pWidget->data.cont->id0;
int y = pWidget->data.cont->id1;
int x = pwidget->data.cont->id0;
int y = pwidget->data.cont->id1;
struct unit *pUnit = head_of_units_in_focus();
#endif
......
/**********************************************************************//**
Initiate paradrop to selected tile.
**************************************************************************/
static int paradrop_here_callback(struct widget *pWidget)
static int paradrop_here_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
/* FIXME */
#if 0
int x = pWidget->data.cont->id0;
int y = pWidget->data.cont->id1;
int x = pwidget->data.cont->id0;
int y = pwidget->data.cont->id1;
#endif
popdown_advanced_terrain_dialog();
......
/**********************************************************************//**
Show help about unit type.
**************************************************************************/
static int unit_help_callback(struct widget *pWidget)
static int unit_help_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
Unit_type_id unit_id = MAX_ID - pWidget->ID;
Unit_type_id unit_id = MAX_ID - pwidget->ID;
popdown_advanced_terrain_dialog();
popup_unit_info(unit_id);
......
/**********************************************************************//**
User selected what to pillage.
**************************************************************************/
static int pillage_callback(struct widget *pWidget)
static int pillage_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *pUnit = pWidget->data.unit;
int what = MAX_ID - pWidget->ID;
struct unit *pUnit = pwidget->data.unit;
int what = MAX_ID - pwidget->ID;
popdown_pillage_dialog();
......
/**********************************************************************//**
User requested closing of pillage dialog.
**************************************************************************/
static int exit_pillage_dlg_callback(struct widget *pWidget)
static int exit_pillage_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_pillage_dialog();
......
/**********************************************************************//**
User interacted with style widget.
**************************************************************************/
static int style_callback(struct widget *pWidget)
static int style_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct NAT *pSetup = (struct NAT *)(pNationDlg->pEndWidgetList->data.ptr);
......
widget_redraw(pGUI);
widget_mark_dirty(pGUI);
set_wstate(pWidget, FC_WS_DISABLED);
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
set_wstate(pwidget, FC_WS_DISABLED);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
pSetup->nation_style = MAX_ID - 1000 - pWidget->ID;
pSetup->nation_style = MAX_ID - 1000 - pwidget->ID;
flush_dirty();
selected_widget = NULL;
......
/**********************************************************************//**
User requested closing of help dialog.
**************************************************************************/
static int cancel_help_dlg_callback(struct widget *pWidget)
static int cancel_help_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pHelpDlg) {
popdown_window_group_dialog(pHelpDlg->pBeginWidgetList,
pHelpDlg->pEndWidgetList);
FC_FREE(pHelpDlg);
if (pWidget) {
if (pwidget) {
flush_dirty();
}
}
......
{
SDL_Color bg_color = {255,255,255,128};
struct widget *pwindow, *pWidget = NULL, *pBuf, *pLast_City_Style;
struct widget *pwindow, *pwidget = NULL, *pBuf, *pLast_City_Style;
utf8_str *pstr;
int len = 0;
int w = adj_size(10), h = adj_size(10);
......
dst.y += pText_Name->h;
FREESURFACE(pText_Name);
pWidget = create_icon2(pTmp_Surf, pwindow->dst,
pwidget = create_icon2(pTmp_Surf, pwindow->dst,
(WF_RESTORE_BACKGROUND|WF_FREE_THEME));
set_wstate(pWidget, FC_WS_NORMAL);
set_wstate(pwidget, FC_WS_NORMAL);
pWidget->action = nation_button_callback;
pwidget->action = nation_button_callback;
w = MAX(w, pWidget->size.w);
h = MAX(h, pWidget->size.h);
w = MAX(w, pwidget->size.w);
h = MAX(h, pwidget->size.h);
add_to_gui_list(MAX_ID - nation_index(pNation), pWidget);
add_to_gui_list(MAX_ID - nation_index(pNation), pwidget);
if (nation_index(pNation) > (TARGETS_ROW * TARGETS_COL - 1)) {
set_wflag(pWidget, WF_HIDDEN);
set_wflag(pwidget, WF_HIDDEN);
}
} nations_iterate_end;
......
FREESURFACE(pMain_Bg);
pNationDlg->pEndActiveWidgetList = pwindow->prev;
pNationDlg->pBeginWidgetList = pWidget;
pNationDlg->pBeginWidgetList = pwidget;
pNationDlg->pBeginActiveWidgetList = pNationDlg->pBeginWidgetList;
if (get_playable_nation_count() > TARGETS_ROW * TARGETS_COL) {
......
adj_font(12));
change_ptsize_utf8(natset_str, adj_font(24));
pWidget = create_iconlabel(NULL, pwindow->dst, natset_str, 0);
pwidget = create_iconlabel(NULL, pwindow->dst, natset_str, 0);
add_to_gui_list(ID_LABEL, pWidget);
pSetup->pset_name = pWidget;
add_to_gui_list(ID_LABEL, pwidget);
pSetup->pset_name = pwidget;
/* create next nationset button */
pWidget = create_themeicon_button(current_theme->R_ARROW_Icon,
pwidget = create_themeicon_button(current_theme->R_ARROW_Icon,
pwindow->dst, NULL, 0);
pWidget->action = next_set_callback;
pwidget->action = next_set_callback;
if (nation_set_index(pSetup->set) < nation_set_count() - 1) {
set_wstate(pWidget, FC_WS_NORMAL);
set_wstate(pwidget, FC_WS_NORMAL);
}
add_to_gui_list(ID_NATION_NEXT_NATIONSET_BUTTON, pWidget);
pWidget->size.h = pWidget->next->size.h;
pSetup->pset_next = pWidget;
add_to_gui_list(ID_NATION_NEXT_NATIONSET_BUTTON, pwidget);
pwidget->size.h = pwidget->next->size.h;
pSetup->pset_next = pwidget;
/* create prev nationset button */
pWidget = create_themeicon_button(current_theme->L_ARROW_Icon,
pwidget = create_themeicon_button(current_theme->L_ARROW_Icon,
pwindow->dst, NULL, 0);
pWidget->action = prev_set_callback;
pwidget->action = prev_set_callback;
if (nation_set_index(pSetup->set) > 0) {
set_wstate(pWidget, FC_WS_NORMAL);
set_wstate(pwidget, FC_WS_NORMAL);
}
add_to_gui_list(ID_NATION_PREV_NATIONSET_BUTTON, pWidget);
pWidget->size.h = pWidget->next->size.h;
pSetup->pset_prev = pWidget;
add_to_gui_list(ID_NATION_PREV_NATIONSET_BUTTON, pwidget);
pwidget->size.h = pwidget->next->size.h;
pSetup->pset_prev = pwidget;
}
/* nation name */
......
pTmp_Surf_zoomed = adj_surf(get_nation_flag_surface(pnat));
pWidget = create_iconlabel(pTmp_Surf_zoomed, pwindow->dst, pstr,
pwidget = create_iconlabel(pTmp_Surf_zoomed, pwindow->dst, pstr,
(WF_ICON_ABOVE_TEXT|WF_ICON_CENTER|WF_FREE_GFX));
if (nationsets == NULL) {
pBuf = pWidget;
pBuf = pwidget;
} else {
pBuf = nationsets;
}
add_to_gui_list(ID_LABEL, pWidget);
add_to_gui_list(ID_LABEL, pwidget);
/* create leader name edit */
pWidget = create_edit_from_chars(NULL, pwindow->dst,
pwidget = create_edit_from_chars(NULL, pwindow->dst,
NULL, adj_font(16), adj_size(200), 0);
pWidget->size.h = adj_size(24);
pwidget->size.h = adj_size(24);
set_wstate(pWidget, FC_WS_NORMAL);
pWidget->action = leader_name_edit_callback;
add_to_gui_list(ID_NATION_WIZARD_LEADER_NAME_EDIT, pWidget);
pSetup->pName_Edit = pWidget;
set_wstate(pwidget, FC_WS_NORMAL);
pwidget->action = leader_name_edit_callback;
add_to_gui_list(ID_NATION_WIZARD_LEADER_NAME_EDIT, pwidget);
pSetup->pName_Edit = pwidget;
/* create next leader name button */
pWidget = create_themeicon_button(current_theme->R_ARROW_Icon,
pwidget = create_themeicon_button(current_theme->R_ARROW_Icon,
pwindow->dst, NULL, 0);
pWidget->action = next_name_callback;
add_to_gui_list(ID_NATION_WIZARD_NEXT_LEADER_NAME_BUTTON, pWidget);
pWidget->size.h = pWidget->next->size.h;
pSetup->pName_Next = pWidget;
pwidget->action = next_name_callback;
add_to_gui_list(ID_NATION_WIZARD_NEXT_LEADER_NAME_BUTTON, pwidget);
pwidget->size.h = pwidget->next->size.h;
pSetup->pName_Next = pwidget;
/* create prev leader name button */
pWidget = create_themeicon_button(current_theme->L_ARROW_Icon,
pwidget = create_themeicon_button(current_theme->L_ARROW_Icon,
pwindow->dst, NULL, 0);
pWidget->action = prev_name_callback;
add_to_gui_list(ID_NATION_WIZARD_PREV_LEADER_NAME_BUTTON, pWidget);
pWidget->size.h = pWidget->next->size.h;
pSetup->pName_Prev = pWidget;
pwidget->action = prev_name_callback;
add_to_gui_list(ID_NATION_WIZARD_PREV_LEADER_NAME_BUTTON, pwidget);
pwidget->size.h = pwidget->next->size.h;
pSetup->pName_Prev = pwidget;
/* change sex button */
pWidget = create_icon_button_from_chars(NULL, pwindow->dst, _("Male"), adj_font(14), 0);
pWidget->action = change_sex_callback;
pWidget->size.w = adj_size(100);
pWidget->size.h = adj_size(22);
set_wstate(pWidget, FC_WS_NORMAL);
pSetup->pChange_Sex = pWidget;
pwidget = create_icon_button_from_chars(NULL, pwindow->dst, _("Male"), adj_font(14), 0);
pwidget->action = change_sex_callback;
pwidget->size.w = adj_size(100);
pwidget->size.h = adj_size(22);
set_wstate(pwidget, FC_WS_NORMAL);
pSetup->pChange_Sex = pwidget;
/* add to main widget list */
add_to_gui_list(ID_NATION_WIZARD_CHANGE_SEX_BUTTON, pWidget);
add_to_gui_list(ID_NATION_WIZARD_CHANGE_SEX_BUTTON, pwidget);
/* ---------------------------------------------------------- */
i = 0;
......
pTmp_Surf_zoomed = zoomSurface(get_sample_city_surface(i), zoom, zoom, 0);
pWidget = create_icon2(pTmp_Surf_zoomed, pwindow->dst, WF_RESTORE_BACKGROUND);
pWidget->action = style_callback;
pwidget = create_icon2(pTmp_Surf_zoomed, pwindow->dst, WF_RESTORE_BACKGROUND);
pwidget->action = style_callback;
if (i != pSetup->nation_style) {
set_wstate(pWidget, FC_WS_NORMAL);
set_wstate(pwidget, FC_WS_NORMAL);
}
len += pWidget->size.w;
add_to_gui_list(MAX_ID - 1000 - i, pWidget);
len += pwidget->size.w;
add_to_gui_list(MAX_ID - 1000 - i, pwidget);
} styles_iterate_end;
pLast_City_Style = pWidget;
pLast_City_Style = pwidget;
/* ---------------------------------------------------------- */
/* create Cancel button */
pWidget = create_themeicon_button_from_chars(current_theme->CANCEL_Icon,
pwidget = create_themeicon_button_from_chars(current_theme->CANCEL_Icon,
pwindow->dst, _("Cancel"),
adj_font(12), 0);
pWidget->action = races_dialog_cancel_callback;
set_wstate(pWidget, FC_WS_NORMAL);
pwidget->action = races_dialog_cancel_callback;
set_wstate(pwidget, FC_WS_NORMAL);
add_to_gui_list(ID_NATION_WIZARD_DISCONNECT_BUTTON, pWidget);
add_to_gui_list(ID_NATION_WIZARD_DISCONNECT_BUTTON, pwidget);
/* create OK button */
pWidget =
pwidget =
create_themeicon_button_from_chars(current_theme->OK_Icon, pwindow->dst,
_("OK"), adj_font(12), 0);
pWidget->action = races_dialog_ok_callback;
pwidget->action = races_dialog_ok_callback;
set_wstate(pWidget, FC_WS_NORMAL);
add_to_gui_list(ID_NATION_WIZARD_START_BUTTON, pWidget);
pWidget->size.w = MAX(pWidget->size.w, pWidget->next->size.w);
pWidget->next->size.w = pWidget->size.w;
set_wstate(pwidget, FC_WS_NORMAL);
add_to_gui_list(ID_NATION_WIZARD_START_BUTTON, pwidget);
pwidget->size.w = MAX(pwidget->size.w, pwidget->next->size.w);
pwidget->next->size.w = pwidget->size.w;
pNationDlg->pBeginWidgetList = pWidget;
pNationDlg->pBeginWidgetList = pwidget;
/* ---------------------------------------------------------- */
pMain_Bg = theme_get_background(theme, BACKGROUND_NATIONDLG);
client/gui-sdl2/diplodlg.c
/**********************************************************************//**
User interacted with remove clause -widget.
**************************************************************************/
static int remove_clause_callback(struct widget *pWidget)
static int remove_clause_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct diplomacy_dialog *pdialog;
if (!(pdialog = get_diplomacy_dialog(pWidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pWidget->data.cont->id0);
if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pwidget->data.cont->id0);
}
dsend_packet_diplomacy_remove_clause_req(&client.conn,
player_number(pdialog->treaty.plr1),
pWidget->data.cont->id0,
(enum clause_type) ((pWidget->data.
pwidget->data.cont->id0,
(enum clause_type) ((pwidget->data.
cont->value >> 16) & 0xFFFF),
pWidget->data.cont->value & 0xFFFF);
pwidget->data.cont->value & 0xFFFF);
}
return -1;
......
/**********************************************************************//**
User interacted with cancel meeting -widget.
**************************************************************************/
static int cancel_meeting_callback(struct widget *pWidget)
static int cancel_meeting_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
dsend_packet_diplomacy_cancel_meeting_req(&client.conn,
pWidget->data.cont->id1);
pwidget->data.cont->id1);
}
return -1;
......
/**********************************************************************//**
User interacted with accept treaty -widget.
**************************************************************************/
static int accept_treaty_callback(struct widget *pWidget)
static int accept_treaty_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
dsend_packet_diplomacy_accept_treaty_req(&client.conn,
pWidget->data.cont->id1);
pwidget->data.cont->id1);
}
return -1;
......
/**********************************************************************//**
User interacted with pact selection -widget.
**************************************************************************/
static int pact_callback(struct widget *pWidget)
static int pact_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int clause_type;
struct diplomacy_dialog *pdialog;
if (!(pdialog = get_diplomacy_dialog(pWidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pWidget->data.cont->id0);
if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pwidget->data.cont->id0);
}
switch (MAX_ID - pWidget->ID) {
switch (MAX_ID - pwidget->ID) {
case 2:
clause_type = CLAUSE_CEASEFIRE;
break;
......
dsend_packet_diplomacy_create_clause_req(&client.conn,
player_number(pdialog->treaty.plr1),
pWidget->data.cont->id0,
pwidget->data.cont->id0,
clause_type, 0);
}
......
/**********************************************************************//**
User interacted with shared vision -widget.
**************************************************************************/
static int vision_callback(struct widget *pWidget)
static int vision_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct diplomacy_dialog *pdialog;
if (!(pdialog = get_diplomacy_dialog(pWidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pWidget->data.cont->id0);
if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pwidget->data.cont->id0);
}
dsend_packet_diplomacy_create_clause_req(&client.conn,
player_number(pdialog->treaty.plr1),
pWidget->data.cont->id0,
pwidget->data.cont->id0,
CLAUSE_VISION, 0);
}
......
/**********************************************************************//**
User interacted with embassy -widget.
**************************************************************************/
static int embassy_callback(struct widget *pWidget)
static int embassy_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct diplomacy_dialog *pdialog;
if (!(pdialog = get_diplomacy_dialog(pWidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pWidget->data.cont->id0);
if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pwidget->data.cont->id0);
}
dsend_packet_diplomacy_create_clause_req(&client.conn,
player_number(pdialog->treaty.plr1),
pWidget->data.cont->id0,
pwidget->data.cont->id0,
CLAUSE_EMBASSY, 0);
}
......
/**********************************************************************//**
User interacted with map -widget.
**************************************************************************/
static int maps_callback(struct widget *pWidget)
static int maps_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int clause_type;
struct diplomacy_dialog *pdialog;
if (!(pdialog = get_diplomacy_dialog(pWidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pWidget->data.cont->id0);
if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pwidget->data.cont->id0);
}
switch (MAX_ID - pWidget->ID) {
switch (MAX_ID - pwidget->ID) {
case 1:
clause_type = CLAUSE_MAP;
break;
......
dsend_packet_diplomacy_create_clause_req(&client.conn,
player_number(pdialog->treaty.plr1),
pWidget->data.cont->id0,
pwidget->data.cont->id0,
clause_type, 0);
}
......
/**********************************************************************//**
User interacted with tech -widget.
**************************************************************************/
static int techs_callback(struct widget *pWidget)
static int techs_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct diplomacy_dialog *pdialog;
if (!(pdialog = get_diplomacy_dialog(pWidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pWidget->data.cont->id0);
if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pwidget->data.cont->id0);
}
dsend_packet_diplomacy_create_clause_req(&client.conn,
player_number(pdialog->treaty.plr1),
pWidget->data.cont->id0,
pwidget->data.cont->id0,
CLAUSE_ADVANCE,
(MAX_ID - pWidget->ID));
(MAX_ID - pwidget->ID));
}
return -1;
......
/**********************************************************************//**
User interacted with gold -widget.
**************************************************************************/
static int gold_callback(struct widget *pWidget)
static int gold_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int amount;
struct diplomacy_dialog *pdialog;
if (!(pdialog = get_diplomacy_dialog(pWidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pWidget->data.cont->id0);
if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pwidget->data.cont->id0);
}
if (pWidget->string_utf8->text != NULL) {
sscanf(pWidget->string_utf8->text, "%d", &amount);
if (pwidget->string_utf8->text != NULL) {
sscanf(pwidget->string_utf8->text, "%d", &amount);
if (amount > pWidget->data.cont->value) {
if (amount > pwidget->data.cont->value) {
/* max player gold */
amount = pWidget->data.cont->value;
amount = pwidget->data.cont->value;
}
} else {
......
if (amount > 0) {
dsend_packet_diplomacy_create_clause_req(&client.conn,
player_number(pdialog->treaty.plr1),
pWidget->data.cont->id0,
pwidget->data.cont->id0,
CLAUSE_GOLD, amount);
} else {
......
_("Invalid amount of gold specified."));
}
if (amount || pWidget->string_utf8->text == NULL) {
copy_chars_to_utf8_str(pWidget->string_utf8, "0");
widget_redraw(pWidget);
widget_flush(pWidget);
if (amount || pwidget->string_utf8->text == NULL) {
copy_chars_to_utf8_str(pwidget->string_utf8, "0");
widget_redraw(pwidget);
widget_flush(pwidget);
}
}
......
/**********************************************************************//**
User interacted with city -widget.
**************************************************************************/
static int cities_callback(struct widget *pWidget)
static int cities_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct diplomacy_dialog *pdialog;
if (!(pdialog = get_diplomacy_dialog(pWidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pWidget->data.cont->id0);
if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
pdialog = get_diplomacy_dialog(pwidget->data.cont->id0);
}
dsend_packet_diplomacy_create_clause_req(&client.conn,
player_number(pdialog->treaty.plr1),
pWidget->data.cont->id0,
pwidget->data.cont->id0,
CLAUSE_CITY,
(MAX_ID - pWidget->ID));
(MAX_ID - pwidget->ID));
}
return -1;
......
/**********************************************************************//**
User interacted with withdraw vision -widget.
**************************************************************************/
static int withdraw_vision_dlg_callback(struct widget *pWidget)
static int withdraw_vision_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_sdip_dialog();
dsend_packet_diplomacy_cancel_pact(&client.conn,
player_number(pWidget->data.player),
player_number(pwidget->data.player),
CLAUSE_VISION);
flush_dirty();
......
/**********************************************************************//**
User interacted with cancel pact -widget.
**************************************************************************/
static int cancel_pact_dlg_callback(struct widget *pWidget)
static int cancel_pact_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_sdip_dialog();
dsend_packet_diplomacy_cancel_pact(&client.conn,
player_number(pWidget->data.player),
player_number(pwidget->data.player),
CLAUSE_CEASEFIRE);
flush_dirty();
......
/**********************************************************************//**
User interacted with call meeting -widget.
**************************************************************************/
static int call_meeting_dlg_callback(struct widget *pWidget)
static int call_meeting_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_sdip_dialog();
if (can_meet_with_player(pWidget->data.player)) {
if (can_meet_with_player(pwidget->data.player)) {
dsend_packet_diplomacy_init_meeting_req(&client.conn,
player_number
(pWidget->data.player));
(pwidget->data.player));
}
flush_dirty();
......
/**********************************************************************//**
User interacted with cancel small diplomacy dialog -widget.
**************************************************************************/
static int cancel_sdip_dlg_callback(struct widget *pWidget)
static int cancel_sdip_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_sdip_dialog();
client/gui-sdl2/finddlg.c
/**********************************************************************//**
Close find city dialog.
**************************************************************************/
static int exit_find_city_dlg_callback(struct widget *pWidget)
static int exit_find_city_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int orginal_x = pWidget->data.cont->id0;
int orginal_y = pWidget->data.cont->id1;
int orginal_x = pwidget->data.cont->id0;
int orginal_y = pwidget->data.cont->id1;
popdown_find_dialog();
......
/**********************************************************************//**
User has selected city to find.
**************************************************************************/
static int find_city_callback(struct widget *pWidget)
static int find_city_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct city *pCity = pWidget->data.city;
struct city *pCity = pwidget->data.city;
if (pCity) {
center_tile_mapcanvas(pCity->tile);
client/gui-sdl2/gotodlg.c
/**********************************************************************//**
Close goto dialog.
**************************************************************************/
static int exit_goto_dialog_callback(struct widget *pWidget)
static int exit_goto_dialog_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_goto_airlift_dialog();
......
/**********************************************************************//**
Toggle whether player cities are listed as possible destinations.
**************************************************************************/
static int toggle_goto_nations_cities_dialog_callback(struct widget *pWidget)
static int toggle_goto_nations_cities_dialog_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int plr_id = player_index(player_by_number(MAX_ID - pWidget->ID));
int plr_id = player_index(player_by_number(MAX_ID - pwidget->ID));
if (BV_ISSET(all_players, plr_id)) {
BV_CLR(all_players, plr_id);
......
/**********************************************************************//**
User has selected city for unit to go to.
**************************************************************************/
static int goto_city_callback(struct widget *pWidget)
static int goto_city_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct city *pdestcity = game_city_by_number(MAX_ID - pWidget->ID);
struct city *pdestcity = game_city_by_number(MAX_ID - pwidget->ID);
if (pdestcity) {
struct unit *pUnit = head_of_units_in_focus();
client/gui-sdl2/gui_main.c
**************************************************************************/
static Uint16 main_key_down_handler(SDL_Keysym key, void *data)
{
static struct widget *pWidget;
static struct widget *pwidget;
if ((pWidget = find_next_widget_for_key(NULL, key)) != NULL) {
return widget_pressed_action(pWidget);
if ((pwidget = find_next_widget_for_key(NULL, key)) != NULL) {
return widget_pressed_action(pwidget);
} else {
if (key.sym == SDLK_TAB) {
/* input */
......
static Uint16 main_finger_down_handler(SDL_TouchFingerEvent *pTouchEvent,
void *pData)
{
struct widget *pWidget;
struct widget *pwidget;
/* Touch event coordinates are normalized (0...1). */
int x = pTouchEvent->x * main_window_width();
int y = pTouchEvent->y * main_window_height();
if ((pWidget = find_next_widget_at_pos(NULL, x, y)) != NULL) {
if (get_wstate(pWidget) != FC_WS_DISABLED) {
return widget_pressed_action(pWidget);
if ((pwidget = find_next_widget_at_pos(NULL, x, y)) != NULL) {
if (get_wstate(pwidget) != FC_WS_DISABLED) {
return widget_pressed_action(pwidget);
}
} else {
/* No visible widget at this position; map pressed. */
......
static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *pButtonEvent,
void *pData)
{
struct widget *pWidget;
struct widget *pwidget;
if ((pWidget = find_next_widget_at_pos(NULL,
if ((pwidget = find_next_widget_at_pos(NULL,
pButtonEvent->x,
pButtonEvent->y)) != NULL) {
if (get_wstate(pWidget) != FC_WS_DISABLED) {
return widget_pressed_action(pWidget);
if (get_wstate(pwidget) != FC_WS_DISABLED) {
return widget_pressed_action(pwidget);
}
} else {
/* no visible widget at this position -> map click */
......
static Uint16 main_mouse_motion_handler(SDL_MouseMotionEvent *pMotionEvent,
void *pData)
{
static struct widget *pWidget;
static struct widget *pwidget;
struct tile *ptile;
/* stop evaluating button hold time when moving to another tile in medium
......
}
#endif /* UNDER_CE */
if ((pWidget = find_next_widget_at_pos(NULL,
if ((pwidget = find_next_widget_at_pos(NULL,
pMotionEvent->x,
pMotionEvent->y)) != NULL) {
update_mouse_cursor(CURSOR_DEFAULT);
if (get_wstate(pWidget) != FC_WS_DISABLED) {
widget_selected_action(pWidget);
if (get_wstate(pwidget) != FC_WS_DISABLED) {
widget_selected_action(pwidget);
}
} else {
if (selected_widget) {
client/gui-sdl2/helpdlg.c
static const int bufsz = 8192;
static int change_tech_callback(struct widget *pWidget);
static int change_tech_callback(struct widget *pwidget);
/**********************************************************************//**
Open Help Browser without any specific topic in mind
......
/**********************************************************************//**
User requested closing of the help dialog
**************************************************************************/
static int exit_help_dlg_callback(struct widget *pWidget)
static int exit_help_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_help_dialog();
......
/**********************************************************************//**
User requested new government help
**************************************************************************/
static int change_gov_callback(struct widget *pWidget)
static int change_gov_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popup_gov_info(MAX_ID - pWidget->ID);
popup_gov_info(MAX_ID - pwidget->ID);
}
return -1;
......
/**********************************************************************//**
User requested new improvement help
**************************************************************************/
static int change_impr_callback(struct widget *pWidget)
static int change_impr_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popup_impr_info(MAX_ID - pWidget->ID);
popup_impr_info(MAX_ID - pwidget->ID);
}
return -1;
......
/**********************************************************************//**
User requested new unit help
**************************************************************************/
static int change_unit_callback(struct widget *pWidget)
static int change_unit_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popup_unit_info(MAX_ID - pWidget->ID);
popup_unit_info(MAX_ID - pwidget->ID);
}
return -1;
......
/**********************************************************************//**
User requested new tech help
**************************************************************************/
static int change_tech_callback(struct widget *pWidget)
static int change_tech_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popup_tech_info(MAX_ID - pWidget->ID);
popup_tech_info(MAX_ID - pwidget->ID);
}
return -1;
......
/**********************************************************************//**
User requested new tech tree
**************************************************************************/
static int show_tech_tree_callback(struct widget *pWidget)
static int show_tech_tree_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct TECHS_BUTTONS *pStore = (struct TECHS_BUTTONS *)pHelpDlg->pEndWidgetList->data.ptr;
......
struct widget *pwindow,
struct TECHS_BUTTONS *pStore)
{
struct widget *pWidget;
struct widget *pwidget;
struct widget *pLast, *pBudynki;
struct widget *pDock = pStore->pDock;
int i, targets_count,sub_targets_count, max_width = 0;
......
start_x = (pwindow->area.x + adj_size(1) + width + pHelpDlg->pActiveWidgetList->size.w + adj_size(20));
/* tech tree icon */
pWidget = create_icon2(current_theme->Tech_Tree_Icon, pwindow->dst,
pwidget = create_icon2(current_theme->Tech_Tree_Icon, pwindow->dst,
WF_RESTORE_BACKGROUND);
set_wstate(pWidget, FC_WS_NORMAL);
pWidget->action = show_tech_tree_callback;
pWidget->ID = MAX_ID - tech;
DownAdd(pWidget, pDock);
pDock = pWidget;
set_wstate(pwidget, FC_WS_NORMAL);
pwidget->action = show_tech_tree_callback;
pwidget->ID = MAX_ID - tech;
DownAdd(pwidget, pDock);
pDock = pwidget;
/* tech name (heading) */
pWidget = create_iconlabel_from_chars(get_tech_icon(tech),
pwidget = create_iconlabel_from_chars(get_tech_icon(tech),
pwindow->dst,
advance_name_translation(advance_by_number(tech)),
adj_font(24),
WF_FREE_THEME);
pWidget->ID = ID_LABEL;
DownAdd(pWidget, pDock);
pDock = pWidget;
pwidget->ID = ID_LABEL;
DownAdd(pwidget, pDock);
pDock = pwidget;
/* target techs */
targets_count = 0;
......
if ((targets_count < 6)
&& (advance_required(aidx, AR_ONE) == tech
|| advance_required(aidx, AR_TWO) == tech)) {
pWidget = create_iconlabel_from_chars(NULL, pwindow->dst,
pwidget = create_iconlabel_from_chars(NULL, pwindow->dst,
advance_name_translation(advance_by_number(aidx)),
adj_font(12),
WF_RESTORE_BACKGROUND);
pWidget->string_utf8->fgcol = *get_tech_color(aidx);
max_width = MAX(max_width, pWidget->size.w);
set_wstate(pWidget, FC_WS_NORMAL);
pWidget->action = change_tech_callback;
pWidget->ID = MAX_ID - aidx;
DownAdd(pWidget, pDock);
pDock = pWidget;
pStore->pTargets[targets_count++] = pWidget;
pwidget->string_utf8->fgcol = *get_tech_color(aidx);
max_width = MAX(max_width, pwidget->size.w);
set_wstate(pwidget, FC_WS_NORMAL);
pwidget->action = change_tech_callback;
pwidget->ID = MAX_ID - aidx;
DownAdd(pwidget, pDock);
pDock = pwidget;
pStore->pTargets[targets_count++] = pwidget;
}
} advance_index_iterate_end;
if (targets_count < 6) {
......
} else {
continue;
}
pWidget = create_iconlabel_from_chars(NULL, pwindow->dst,
pwidget = create_iconlabel_from_chars(NULL, pwindow->dst,
advance_name_translation(advance_by_number(sub_tech)),
adj_font(12),
WF_RESTORE_BACKGROUND);
pWidget->string_utf8->fgcol = *get_tech_color(sub_tech);
set_wstate(pWidget, FC_WS_NORMAL);
pWidget->action = change_tech_callback;
pWidget->ID = MAX_ID - sub_tech;
DownAdd(pWidget, pDock);
pDock = pWidget;
pStore->pSub_Targets[sub_targets_count++] = pWidget;
pwidget->string_utf8->fgcol = *get_tech_color(sub_tech);
set_wstate(pwidget, FC_WS_NORMAL);
pwidget->action = change_tech_callback;
pwidget->ID = MAX_ID - sub_tech;
DownAdd(pwidget, pDock);
pDock = pwidget;
pStore->pSub_Targets[sub_targets_count++] = pwidget;
}
}
if (sub_targets_count < 6) {
......
}
/* fill array with iprvm. icons */
pBudynki = pWidget;
pBudynki = pwidget;
/* target governments */
gov_count = 0;
......
if (VUT_ADVANCE == preq->source.kind
&& advance_number(preq->source.value.advance) == tech) {
pWidget = create_iconlabel_from_chars(adj_surf(get_government_surface(gov)),
pwidget = create_iconlabel_from_chars(adj_surf(get_government_surface(gov)),
pwindow->dst,
government_name_translation(gov),
adj_font(14),
WF_RESTORE_BACKGROUND | WF_SELECT_WITHOUT_BAR | WF_FREE_THEME);
set_wstate(pWidget, FC_WS_NORMAL);
pWidget->action = change_gov_callback;
pWidget->ID = MAX_ID - government_index(gov);
DownAdd(pWidget, pDock);
pDock = pWidget;
set_wstate(pwidget, FC_WS_NORMAL);
pwidget->action = change_gov_callback;
pwidget->ID = MAX_ID - government_index(gov);
DownAdd(pwidget, pDock);
pDock = pwidget;
gov_count++;
}
} requirement_vector_iterate_end;
......
if (VUT_ADVANCE == preq->source.kind
&& advance_number(preq->source.value.advance) == tech) {
pSurf = get_building_surface(pImprove);
pWidget = create_iconlabel_from_chars(
pwidget = create_iconlabel_from_chars(
ResizeSurfaceBox(pSurf, adj_size(48), adj_size(48), 1, TRUE, TRUE),
pwindow->dst,
improvement_name_translation(pImprove),
adj_font(14),
WF_RESTORE_BACKGROUND | WF_SELECT_WITHOUT_BAR);
set_wstate(pWidget, FC_WS_NORMAL);
set_wstate(pwidget, FC_WS_NORMAL);
if (is_wonder(pImprove)) {
pWidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_LUX);
pwidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_LUX);
}
pWidget->action = change_impr_callback;
pWidget->ID = MAX_ID - improvement_number(pImprove);
DownAdd(pWidget, pDock);
pDock = pWidget;
pwidget->action = change_impr_callback;
pwidget->ID = MAX_ID - improvement_number(pImprove);
DownAdd(pwidget, pDock);
pDock = pwidget;
imp_count++;
}
......
struct unit_type *pUnitType = un;
if (advance_number(pUnitType->require_advance) == tech) {
pWidget = create_iconlabel_from_chars(
pwidget = create_iconlabel_from_chars(
ResizeSurfaceBox(get_unittype_surface(un, direction8_invalid()),
adj_size(48), adj_size(48), 1, TRUE, TRUE),
pwindow->dst, utype_name_translation(pUnitType), adj_font(14),
(WF_FREE_THEME | WF_RESTORE_BACKGROUND | WF_SELECT_WITHOUT_BAR));
set_wstate(pWidget, FC_WS_NORMAL);
pWidget->action = change_unit_callback;
pWidget->ID = MAX_ID - utype_number(un);
DownAdd(pWidget, pDock);
pDock = pWidget;
set_wstate(pwidget, FC_WS_NORMAL);
pwidget->action = change_unit_callback;
pwidget->ID = MAX_ID - utype_number(un);
DownAdd(pwidget, pDock);
pDock = pwidget;
unit_count++;
}
} unit_type_iterate_end;
......
utf8_str *pstr = create_utf8_from_char(buffer, adj_font(12));
convert_utf8_str_to_const_surface_width(pstr, adj_size(640) - start_x - adj_size(20));
pWidget = create_iconlabel(NULL, pwindow->dst, pstr, 0);
pWidget->ID = ID_LABEL;
DownAdd(pWidget, pDock);
pDock = pWidget;
pwidget = create_iconlabel(NULL, pwindow->dst, pstr, 0);
pwidget->ID = ID_LABEL;
DownAdd(pwidget, pDock);
pDock = pwidget;
flags_count = 1;
} else {
flags_count = 0;
}
pLast = pWidget;
pLast = pwidget;
/* --------------------------------------------- */
/* tree button */
pWidget = pStore->pDock->prev;
pWidget->size.x = pwindow->area.x + pwindow->area.w - pWidget->size.w - adj_size(17);
pWidget->size.y = pwindow->area.y + adj_size(16);
pwidget = pStore->pDock->prev;
pwidget->size.x = pwindow->area.x + pwindow->area.w - pwidget->size.w - adj_size(17);
pwidget->size.y = pwindow->area.y + adj_size(16);
/* Tech label */
pWidget = pWidget->prev;
pWidget->size.x = start_x;
pWidget->size.y = pwindow->area.y + adj_size(16);
start_y = pWidget->size.y + pWidget->size.h + adj_size(30);
pwidget = pwidget->prev;
pwidget->size.x = start_x;
pwidget->size.y = pwindow->area.y + adj_size(16);
start_y = pwidget->size.y + pwidget->size.h + adj_size(30);
if (targets_count) {
int j, t0, t1;
......
start_y += adj_size(10);
}
pWidget = NULL;
pwidget = NULL;
if (gov_count) {
pWidget = pBudynki->prev;
while (gov_count-- && pWidget) {
pWidget->size.x = pwindow->size.x + start_x;
pWidget->size.y = start_y;
start_y += pWidget->size.h + adj_size(2);
pWidget = pWidget->prev;
pwidget = pBudynki->prev;
while (gov_count-- && pwidget) {
pwidget->size.x = pwindow->size.x + start_x;
pwidget->size.y = start_y;
start_y += pwidget->size.h + adj_size(2);
pwidget = pwidget->prev;
}
}
if (imp_count) {
if (!pWidget) {
pWidget = pBudynki->prev;
if (!pwidget) {
pwidget = pBudynki->prev;
}
while (imp_count-- && pWidget) {
pWidget->size.x = pwindow->size.x + start_x;
pWidget->size.y = start_y;
start_y += pWidget->size.h + adj_size(2);
pWidget = pWidget->prev;
while (imp_count-- && pwidget) {
pwidget->size.x = pwindow->size.x + start_x;
pwidget->size.y = start_y;
start_y += pwidget->size.h + adj_size(2);
pwidget = pwidget->prev;
}
}
if (unit_count) {
if (!pWidget) {
pWidget = pBudynki->prev;
if (!pwidget) {
pwidget = pBudynki->prev;
}
while (unit_count-- && pWidget) {
pWidget->size.x = pwindow->size.x + start_x;
pWidget->size.y = start_y;
start_y += pWidget->size.h + adj_size(2);
pWidget = pWidget->prev;
while (unit_count-- && pwidget) {
pwidget->size.x = pwindow->size.x + start_x;
pwidget->size.y = start_y;
start_y += pwidget->size.h + adj_size(2);
pwidget = pwidget->prev;
}
}
if (flags_count) {
if (!pWidget) {
pWidget = pBudynki->prev;
if (!pwidget) {
pwidget = pBudynki->prev;
}
while (flags_count-- && pWidget) {
pWidget->size.x = pwindow->size.x + start_x;
pWidget->size.y = start_y;
start_y += pWidget->size.h + adj_size(2);
pWidget = pWidget->prev;
while (flags_count-- && pwidget) {
pwidget->size.x = pwindow->size.x + start_x;
pwidget->size.y = start_y;
start_y += pwidget->size.h + adj_size(2);
pwidget = pwidget->prev;
}
}
......
/**********************************************************************//**
User requested toggling between full tech tree and single tech
**************************************************************************/
static int toggle_full_tree_mode_in_help_dlg_callback(struct widget *pWidget)
static int toggle_full_tree_mode_in_help_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct TECHS_BUTTONS *pStore = (struct TECHS_BUTTONS *)pHelpDlg->pEndWidgetList->data.ptr;
if (pStore->show_full_tree) {
pWidget->theme2 = current_theme->UP_Icon;
pwidget->theme2 = current_theme->UP_Icon;
} else {
pWidget->theme2 = current_theme->DOWN_Icon;
pwidget->theme2 = current_theme->DOWN_Icon;
}
pStore->show_full_tree = !pStore->show_full_tree;
popup_tech_info(MAX_ID - pStore->pDock->prev->ID);
......
struct TECHS_BUTTONS *pStore)
{
int i, w, h, req_count , targets_count, sub_req_count, sub_targets_count;
struct widget *pWidget;
struct widget *pwidget;
struct widget *pTech;
utf8_str *pstr;
SDL_Surface *pSurf;
......
copy_chars_to_utf8_str(pstr, advance_name_translation(advance_by_number(tech)));
pSurf = create_select_tech_icon(pstr, tech, FULL_MODE);
pWidget = create_icon2(pSurf, pwindow->dst,
pwidget = create_icon2(pSurf, pwindow->dst,
WF_FREE_THEME | WF_RESTORE_BACKGROUND);
set_wstate(pWidget, FC_WS_NORMAL);
pWidget->action = show_tech_tree_callback;
pWidget->ID = MAX_ID - tech;
DownAdd(pWidget, pDock);
pTech = pWidget;
pDock = pWidget;
set_wstate(pwidget, FC_WS_NORMAL);
pwidget->action = show_tech_tree_callback;
pwidget->ID = MAX_ID - tech;
DownAdd(pwidget, pDock);
pTech = pwidget;
pDock = pwidget;
req_count = 0;
for (i = AR_ONE; i <= AR_TWO; i++) {
......
if (NULL != vap && A_NONE != ar) {
copy_chars_to_utf8_str(pstr, advance_name_translation(vap));
pSurf = create_select_tech_icon(pstr, ar, SMALL_MODE);
pWidget = create_icon2(pSurf, pwindow->dst,
pwidget = create_icon2(pSurf, pwindow->dst,
WF_FREE_THEME | WF_RESTORE_BACKGROUND);
set_wstate(pWidget, FC_WS_NORMAL);
pWidget->action = change_tech_callback;
pWidget->ID = MAX_ID - ar;
DownAdd(pWidget, pDock);
pDock = pWidget;
pStore->pRequirementButton[i] = pWidget;
set_wstate(pwidget, FC_WS_NORMAL);
pwidget->action = change_tech_callback;
pwidget->ID = MAX_ID - ar;
DownAdd(pwidget, pDock);
pDock = pwidget;
pStore->pRequirementButton[i] = pwidget;
req_count++;
} else {
pStore->pRequirementButton[i] = NULL;
......
if (NULL != vap && A_NONE != ar) {
copy_chars_to_utf8_str(pstr, advance_name_translation(vap));
pSurf = create_select_tech_icon(pstr, ar, SMALL_MODE);
pWidget = create_icon2(pSurf, pwindow->dst,
pwidget = create_icon2(pSurf, pwindow->dst,
WF_FREE_THEME | WF_RESTORE_BACKGROUND);
set_wstate(pWidget, FC_WS_NORMAL);
pWidget->action = change_tech_callback;
pWidget->ID = MAX_ID - ar;
DownAdd(pWidget, pDock);
pDock = pWidget;
pStore->pSub_Req[sub_req_count++] = pWidget;
set_wstate(pwidget, FC_WS_NORMAL);
pwidget->action = change_tech_callback;
pwidget->ID = MAX_ID - ar;
DownAdd(pwidget, pDock);
pDock = pwidget;
pStore->pSub_Req[sub_req_count++] = pwidget;
}
}
}
......
|| advance_required(aidx, AR_TWO) == tech)) {
copy_chars_to_utf8_str(pstr, advance_name_translation(advance_by_number(aidx)));
pSurf = create_select_tech_icon(pstr, aidx, SMALL_MODE);
pWidget = create_icon2(pSurf, pwindow->dst,
pwidget = create_icon2(pSurf, pwindow->dst,
WF_FREE_THEME | WF_RESTORE_BACKGROUND);
set_wstate(pWidget, FC_WS_NORMAL);
pWidget->action = change_tech_callback;
pWidget->ID = MAX_ID - aidx;
DownAdd(pWidget, pDock);
pDock = pWidget;
pStore->pTargets[targets_count++] = pWidget;
set_wstate(pwidget, FC_WS_NORMAL);
pwidget->action = change_tech_callback;
pwidget->ID = MAX_ID - aidx;
DownAdd(pwidget, pDock);
pDock = pwidget;
pStore->pTargets[targets_count++] = pwidget;
}
} advance_index_iterate_end;
if (targets_count < 6) {
......
copy_chars_to_utf8_str(pstr, advance_name_translation(advance_by_number(sub_tech)));
pSurf = create_select_tech_icon(pstr, sub_tech, SMALL_MODE);
pWidget = create_icon2(pSurf, pwindow->dst,
pwidget = create_icon2(pSurf, pwindow->dst,
WF_FREE_THEME | WF_RESTORE_BACKGROUND);
set_wstate(pWidget, FC_WS_NORMAL);
pWidget->action = change_tech_callback;
pWidget->ID = MAX_ID - sub_tech;
DownAdd(pWidget, pDock);
pDock = pWidget;
pStore->pSub_Targets[sub_targets_count++] = pWidget;
set_wstate(pwidget, FC_WS_NORMAL);
pwidget->action = change_tech_callback;
pwidget->ID = MAX_ID - sub_tech;
DownAdd(pwidget, pDock);
pDock = pwidget;
pStore->pSub_Targets[sub_targets_count++] = pwidget;
}
}
if (sub_targets_count < 6) {
......
}
}
return pWidget;
return pwidget;
}
/**********************************************************************//**
client/gui-sdl2/inteldlg.c
/**********************************************************************//**
User interacted with tech widget
**************************************************************************/
static int tech_callback(struct widget *pWidget)
static int tech_callback(struct widget *pwidget)
{
/* get tech help - PORT ME */
return -1;
......
/**********************************************************************//**
User interacted with spaceship widget
**************************************************************************/
static int spaceship_callback(struct widget *pWidget)
static int spaceship_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct player *pplayer = pWidget->data.player;
struct player *pplayer = pwidget->data.player;
popdown_intel_dialog(pplayer);
popup_spaceship_dialog(pplayer);
......
/**********************************************************************//**
User interacted with intelligence dialog close button
**************************************************************************/
static int exit_intel_dlg_callback(struct widget *pWidget)
static int exit_intel_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_intel_dialog(pWidget->data.player);
popdown_intel_dialog(pwidget->data.player);
flush_dirty();
}
client/gui-sdl2/mapctrl.c
#ifdef SCALE_MINIMAP
static struct SMALL_DLG *pScale_MiniMap_Dlg = NULL;
static int popdown_scale_minmap_dlg_callback(struct widget *pWidget);
static int popdown_scale_minmap_dlg_callback(struct widget *pwidget);
#endif /* SCALE_MINIMAP */
#ifdef SCALE_UNITINFO
static struct SMALL_DLG *pScale_UnitInfo_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 int popdown_scale_unitinfo_dlg_callback(struct widget *pwidget);
static void remake_unitinfo(int w, int h);
#endif /* SCALE_UNITINFO */
......
/**********************************************************************//**
User interacted with nations button.
**************************************************************************/
static int players_action_callback(struct widget *pWidget)
static int players_action_callback(struct widget *pwidget)
{
set_wstate(pWidget, FC_WS_NORMAL);
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
set_wstate(pwidget, FC_WS_NORMAL);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
switch (main_data.event.button.button) {
#if 0
......
/**********************************************************************//**
User interacted with units button.
**************************************************************************/
static int units_action_callback(struct widget *pWidget)
static int units_action_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
set_wstate(pWidget, FC_WS_NORMAL);
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
set_wstate(pwidget, FC_WS_NORMAL);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
units_report_dialog_popup(FALSE);
}
......
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *pFocus = head_of_units_in_focus();
struct widget *pWidget;
struct widget *pwidget;
/* make new map icon */
clear_surface(pMap_Button->theme, NULL);
......
/* redraw widgets */
/* ID_NEW_TURN */
pWidget = pMiniMap_Window->prev;
widget_redraw(pWidget);
pwidget = pMiniMap_Window->prev;
widget_redraw(pwidget);
/* ID_PLAYERS */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
/* ID_CITIES */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
/* ID_UNITS */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
/* ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
/* Toggle Minimap mode */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
#ifdef SMALL_SCREEN
/* options */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
#endif /* SMALL_SCREEN */
/* ID_TOGGLE_MAP_WINDOW_BUTTON */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
#ifdef SCALE_MINIMAP
popdown_scale_minmap_dlg_callback(NULL);
......
/**********************************************************************//**
User interacted with minimap toggling button.
**************************************************************************/
static int toggle_minimap_mode_callback(struct widget *pWidget)
static int toggle_minimap_mode_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pWidget != NULL) {
selected_widget = pWidget;
set_wstate(pWidget, FC_WS_SELECTED);
if (pwidget != NULL) {
selected_widget = pwidget;
set_wstate(pwidget, FC_WS_SELECTED);
}
toggle_overview_mode();
refresh_overview();
......
/**********************************************************************//**
User interacted with messages toggling button.
**************************************************************************/
static int toggle_msg_window_callback(struct widget *pWidget)
static int toggle_msg_window_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (meswin_dialog_is_open()) {
meswin_dialog_popdown();
copy_chars_to_utf8_str(pWidget->info_label, _("Show Messages (F9)"));
copy_chars_to_utf8_str(pwidget->info_label, _("Show Messages (F9)"));
} else {
meswin_dialog_popup(TRUE);
copy_chars_to_utf8_str(pWidget->info_label, _("Hide Messages (F9)"));
copy_chars_to_utf8_str(pwidget->info_label, _("Hide Messages (F9)"));
}
selected_widget = pWidget;
set_wstate(pWidget, FC_WS_SELECTED);
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
selected_widget = pwidget;
set_wstate(pwidget, FC_WS_SELECTED);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
flush_dirty();
}
......
/**********************************************************************//**
User interacted with minimap scaling dialog closing button.
**************************************************************************/
static int popdown_scale_minimap_dlg_callback(struct widget *pWidget)
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->pBeginWidgetList,
pScale_MiniMap_Dlg->pEndWidgetList);
FC_FREE(pScale_MiniMap_Dlg);
if (pWidget) {
if (pwidget) {
flush_dirty();
}
}
......
/**********************************************************************//**
User interacted with minimap width increase button.
**************************************************************************/
static int up_width_callback(struct widget *pWidget)
static int up_width_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
if ((((OVERVIEW_TILE_WIDTH + 1) * map.xsize) +
(pMiniMap_Window->size.w - pMiniMap_Window->area.w) + BLOCKM_W) <=
pUnits_Info_Window->dst->dest_rect.x) {
char cBuf[4];
fc_snprintf(cBuf, sizeof(cBuf), "%d", OVERVIEW_TILE_WIDTH);
copy_chars_to_utf8_str(pWidget->next->string_utf8, cBuf);
widget_redraw(pWidget->next);
widget_mark_dirty(pWidget->next);
copy_chars_to_utf8_str(pwidget->next->string_utf8, cBuf);
widget_redraw(pwidget->next);
widget_mark_dirty(pwidget->next);
calculate_overview_dimensions();
resize_minimap();
......
/**********************************************************************//**
User interacted with minimap width decrease button.
**************************************************************************/
static int down_width_callback(struct widget *pWidget)
static int down_width_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
if (OVERVIEW_TILE_WIDTH > 1) {
char cBuf[4];
fc_snprintf(cBuf, sizeof(cBuf), "%d", OVERVIEW_TILE_WIDTH);
copy_chars_to_utf8_str(pWidget->prev->string_utf8, cBuf);
widget_redraw(pWidget->prev);
widget_mark_dirty(pWidget->prev);
copy_chars_to_utf8_str(pwidget->prev->string_utf8, cBuf);
widget_redraw(pwidget->prev);
widget_mark_dirty(pwidget->prev);
resize_minimap();
}
......
/**********************************************************************//**
User interacted with minimap height increase button.
**************************************************************************/
static int up_height_callback(struct widget *pWidget)
static int up_height_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
if (main_data.screen->h -
((OVERVIEW_TILE_HEIGHT + 1) * map.ysize + (current_theme->FR_Bottom->h * 2)) >= 40) {
char cBuf[4];
OVERVIEW_TILE_HEIGHT++;
fc_snprintf(cBuf, sizeof(cBuf), "%d", OVERVIEW_TILE_HEIGHT);
copy_chars_to_utf8_str(pWidget->next->string_utf8, cBuf);
widget_redraw(pWidget->next);
widget_mark_dirty(pWidget->next);
copy_chars_to_utf8_str(pwidget->next->string_utf8, cBuf);
widget_redraw(pwidget->next);
widget_mark_dirty(pwidget->next);
resize_minimap();
}
flush_dirty();
......
/**********************************************************************//**
User interacted with minimap height decrease button.
**************************************************************************/
static int down_height_callback(struct widget *pWidget)
static int down_height_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
if (OVERVIEW_TILE_HEIGHT > 1) {
char cBuf[4];
OVERVIEW_TILE_HEIGHT--;
fc_snprintf(cBuf, sizeof(cBuf), "%d", OVERVIEW_TILE_HEIGHT);
copy_chars_to_utf8_str(pWidget->prev->string_utf8, cBuf);
widget_redraw(pWidget->prev);
widget_mark_dirty(pWidget->prev);
copy_chars_to_utf8_str(pwidget->prev->string_utf8, cBuf);
widget_redraw(pwidget->prev);
widget_mark_dirty(pwidget->prev);
resize_minimap();
}
......
/**********************************************************************//**
Close unitinfo scaling dialog.
**************************************************************************/
static int popdown_scale_unitinfo_dlg_callback(struct widget *pWidget)
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->pBeginWidgetList,
pScale_UnitInfo_Dlg->pEndWidgetList);
FC_FREE(pScale_UnitInfo_Dlg);
if (pWidget) {
if (pwidget) {
flush_dirty();
}
}
......
SDL_Surface *pSurf;
SDL_Rect area = {pUnits_Info_Window->area.x + BLOCKU_W,
pUnits_Info_Window->area.y, 0, 0};
struct widget *pWidget = pUnits_Info_Window;
struct widget *pwidget = pUnits_Info_Window;
if (w < DEFAULT_UNITS_W - BLOCKU_W) {
w = (pUnits_Info_Window->size.w - pUnits_Info_Window->area.w) + DEFAULT_UNITS_W;
......
}
/* clear area under old map window */
clear_surface(pWidget->dst->surface, &pWidget->size);
widget_mark_dirty(pWidget);
clear_surface(pwidget->dst->surface, &pwidget->size);
widget_mark_dirty(pwidget);
pWidget->size.w = w;
pWidget->size.h = h;
pwidget->size.w = w;
pwidget->size.h = h;
pWidget->size.x = main_window_width() - w;
pWidget->size.y = main_window_height() - h;
pwidget->size.x = main_window_width() - w;
pwidget->size.y = main_window_height() - h;
FREESURFACE(pWidget->theme);
pWidget->theme = create_surf(w, h, SDL_SWSURFACE);
FREESURFACE(pwidget->theme);
pwidget->theme = create_surf(w, h, SDL_SWSURFACE);
draw_frame(pWidget->theme, 0, 0, pWidget->size.w, pWidget->size.h);
draw_frame(pwidget->theme, 0, 0, pwidget->size.w, pwidget->size.h);
pSurf = ResizeSurface(current_theme->Block, BLOCKU_W,
pWidget->size.h - ((pUnits_Info_Window->size.h - pUnits_Info_Window->area.h)), 1);
pwidget->size.h - ((pUnits_Info_Window->size.h - pUnits_Info_Window->area.h)), 1);
blit_entire_src(pSurf, pWidget->theme, pUnits_Info_Window->area.x,
blit_entire_src(pSurf, pwidget->theme, pUnits_Info_Window->area.x,
pUnits_Info_Window->area.y);
FREESURFACE(pSurf);
area.w = w - BLOCKU_W - (pUnits_Info_Window->size.w - pUnits_Info_Window->area.w);
area.h = h - (pUnits_Info_Window->size.h - pUnits_Info_Window->area.h);
SDL_FillRect(pWidget->theme, &area, map_rgba(pWidget->theme->format, bg_color));
SDL_FillRect(pwidget->theme, &area, map_rgba(pwidget->theme->format, bg_color));
/* economy button */
pWidget = pTax_Button;
FREESURFACE(pWidget->gfx);
pWidget->size.x = pWidget->dst->surface->w - w + pUnits_Info_Window->area.x
+ (BLOCKU_W - pWidget->size.w) / 2;
pWidget->size.y = pWidget->dst->surface->h - h + pWidget->area.y + 2;
pwidget = pTax_Button;
FREESURFACE(pwidget->gfx);
pwidget->size.x = pwidget->dst->surface->w - w + pUnits_Info_Window->area.x
+ (BLOCKU_W - pwidget->size.w) / 2;
pwidget->size.y = pwidget->dst->surface->h - h + pwidget->area.y + 2;
/* research button */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
pWidget->size.x = pWidget->dst->surface->w - w + pUnits_Info_Window->area.x
+ (BLOCKU_W - pWidget->size.w) / 2;
pWidget->size.y = pWidget->dst->surface->h - h + pUnits_Info_Window->area.y +
pWidget->size.h + 2;
pwidget = pwidget->prev;
FREESURFACE(pwidget->gfx);
pwidget->size.x = pwidget->dst->surface->w - w + pUnits_Info_Window->area.x
+ (BLOCKU_W - pwidget->size.w) / 2;
pwidget->size.y = pwidget->dst->surface->h - h + pUnits_Info_Window->area.y +
pwidget->size.h + 2;
/* revolution button */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
pWidget->size.x = pWidget->dst->surface->w - w + pUnits_Info_Window->area.x
+ (BLOCKU_W - pWidget->size.w) / 2;
pWidget->size.y = pWidget->dst->surface->h - h + pUnits_Info_Window->area.y +
pWidget->size.h * 2 + 2;
pwidget = pwidget->prev;
FREESURFACE(pwidget->gfx);
pwidget->size.x = pwidget->dst->surface->w - w + pUnits_Info_Window->area.x
+ (BLOCKU_W - pwidget->size.w) / 2;
pwidget->size.y = pwidget->dst->surface->h - h + pUnits_Info_Window->area.y +
pwidget->size.h * 2 + 2;
/* show/hide unit's window button */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
pWidget->size.x = pWidget->dst->surface->w - w + pUnits_Info_Window->area.x
+ (BLOCKU_W - pWidget->size.w) / 2;
pWidget->size.y = pUnits_Info_Window->area.y + pUnits_Info_Window->area.h -
pWidget->size.h - 2;
pwidget = pwidget->prev;
FREESURFACE(pwidget->gfx);
pwidget->size.x = pwidget->dst->surface->w - w + pUnits_Info_Window->area.x
+ (BLOCKU_W - pwidget->size.w) / 2;
pwidget->size.y = pUnits_Info_Window->area.y + pUnits_Info_Window->area.h -
pwidget->size.h - 2;
unitinfo_w = w;
unitinfo_h = h;
......
/**********************************************************************//**
User interacted with unitinfo width increase button.
**************************************************************************/
static int up_info_width_callback(struct widget *pWidget)
static int up_info_width_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
if (main_window_width() - ((INFO_WIDTH + 1) * map.xsize + BLOCKU_W +
(pMiniMap_Window->size.w - pMiniMap_Window->area.w)) >=
pMiniMap_Window->size.x + pMiniMap_Window->size.w) {
......
/**********************************************************************//**
User interacted with unitinfo width decrease button.
**************************************************************************/
static int down_info_width_callback(struct widget *pWidget)
static int down_info_width_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
if (INFO_WIDTH > INFO_WIDTH_MIN) {
INFO_WIDTH--;
resize_unit_info();
......
/**********************************************************************//**
User interacted with unitinfo height increase button.
**************************************************************************/
static int up_info_height_callback(struct widget *pWidget)
static int up_info_height_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
if (main_data.screen->h - ((INFO_HEIGHT + 1) * map.ysize +
(pUnits_Info_Window->size.h - pUnits_Info_Window->area.h)) >= adj_size(40)) {
INFO_HEIGHT++;
......
/**********************************************************************//**
User interacted with unitinfo height decrease button.
**************************************************************************/
static int down_info_height_callback(struct widget *pWidget)
static int down_info_height_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
if (INFO_HEIGHT > INFO_HEIGHT_MIN) {
INFO_HEIGHT--;
resize_unit_info();
......
/**********************************************************************//**
User interacted with minimap window.
**************************************************************************/
static int minimap_window_callback(struct widget *pWidget)
static int minimap_window_callback(struct widget *pwidget)
{
int mouse_x, mouse_y;
......
/**********************************************************************//**
User interacted with unitinfo window.
**************************************************************************/
static int unit_info_window_callback(struct widget *pWidget)
static int unit_info_window_callback(struct widget *pwidget)
{
if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
switch (main_data.event.button.button) {
......
void set_new_unitinfo_window_pos(void)
{
struct widget *pUnit_Window = pUnits_Info_Window;
struct widget *pWidget;
struct widget *pwidget;
SDL_Rect area;
if (SDL_Client_Flags & CF_UNITINFO_SHOWN) {
......
area.h = DEFAULT_UNITS_H;
/* ID_ECONOMY */
pWidget = pTax_Button;
widget_set_area(pWidget, area);
widget_set_position(pWidget,
area.x + (area.w - pWidget->size.w) / 2,
pwidget = pTax_Button;
widget_set_area(pwidget, area);
widget_set_position(pwidget,
area.x + (area.w - pwidget->size.w) / 2,
area.y + 2);
/* ID_RESEARCH */
pWidget = pWidget->prev;
widget_set_area(pWidget, area);
widget_set_position(pWidget,
area.x + (area.w - pWidget->size.w) / 2,
area.y + 2 + pWidget->size.h);
pwidget = pwidget->prev;
widget_set_area(pwidget, area);
widget_set_position(pwidget,
area.x + (area.w - pwidget->size.w) / 2,
area.y + 2 + pwidget->size.h);
/* ID_REVOLUTION */
pWidget = pWidget->prev;
widget_set_area(pWidget, area);
widget_set_position(pWidget,
area.x + (area.w - pWidget->size.w) / 2,
area.y + 2 + (pWidget->size.h * 2));
pwidget = pwidget->prev;
widget_set_area(pwidget, area);
widget_set_position(pwidget,
area.x + (area.w - pwidget->size.w) / 2,
area.y + 2 + (pwidget->size.h * 2));
/* ID_TOGGLE_UNITS_WINDOW_BUTTON */
pWidget = pWidget->prev;
widget_set_area(pWidget, area);
widget_set_position(pWidget,
area.x + (area.w - pWidget->size.w) / 2,
area.y + area.h - pWidget->size.h - 2);
pwidget = pwidget->prev;
widget_set_area(pwidget, area);
widget_set_position(pwidget,
area.x + (area.w - pwidget->size.w) / 2,
area.y + area.h - pwidget->size.h - 2);
}
/**********************************************************************//**
......
**************************************************************************/
void set_new_minimap_window_pos(void)
{
struct widget *pWidget;
struct widget *pwidget;
SDL_Rect area;
widget_set_position(pMiniMap_Window, 0,
......
area.h = pMiniMap_Window->area.h;
/* ID_NEW_TURN */
pWidget = pMiniMap_Window->prev;
widget_set_area(pWidget, area);
widget_set_position(pWidget,
area.x + adj_size(2) + pWidget->size.w,
pwidget = pMiniMap_Window->prev;
widget_set_area(pwidget, area);
widget_set_position(pwidget,
area.x + adj_size(2) + pwidget->size.w,
area.y + 2);
/* PLAYERS BUTTON */
pWidget = pWidget->prev;
widget_set_area(pWidget, area);
widget_set_position(pWidget,
area.x + adj_size(2) + pWidget->size.w,
area.y + pWidget->size.h + 2);
pwidget = pwidget->prev;
widget_set_area(pwidget, area);
widget_set_position(pwidget,
area.x + adj_size(2) + pwidget->size.w,
area.y + pwidget->size.h + 2);
/* ID_FIND_CITY */
pWidget = pWidget->prev;
widget_set_area(pWidget, area);
widget_set_position(pWidget,
area.x + adj_size(2) + pWidget->size.w,
area.y + pWidget->size.h * 2 + 2);
pwidget = pwidget->prev;
widget_set_area(pwidget, area);
widget_set_position(pwidget,
area.x + adj_size(2) + pwidget->size.w,
area.y + pwidget->size.h * 2 + 2);
/* UNITS BUTTON */
pWidget = pWidget->prev;
widget_set_area(pWidget, area);
widget_set_position(pWidget,
pwidget = pwidget->prev;
widget_set_area(pwidget, area);
widget_set_position(pwidget,
area.x + adj_size(2),
area.y + 2);
/* ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON */
pWidget = pWidget->prev;
widget_set_area(pWidget, area);
widget_set_position(pWidget,
pwidget = pwidget->prev;
widget_set_area(pwidget, area);
widget_set_position(pwidget,
area.x + adj_size(2),
area.y + pWidget->size.h + 2);
area.y + pwidget->size.h + 2);
/* Toggle minimap mode */
pWidget = pWidget->prev;
widget_set_area(pWidget, area);
widget_set_position(pWidget,
pwidget = pwidget->prev;
widget_set_area(pwidget, area);
widget_set_position(pwidget,
area.x + adj_size(2),
area.y + pWidget->size.h * 2 + 2);
area.y + pwidget->size.h * 2 + 2);
#ifdef SMALL_SCREEN
/* ID_TOGGLE_MAP_WINDOW_BUTTON */
pWidget = pWidget->prev;
widget_set_area(pWidget, area);
widget_set_position(pWidget,
pwidget = pwidget->prev;
widget_set_area(pwidget, area);
widget_set_position(pwidget,
area.x + adj_size(2),
area.y + area.h - pWidget->size.h - 2);
area.y + area.h - pwidget->size.h - 2);
#endif
/* ID_TOGGLE_MAP_WINDOW_BUTTON */
pWidget = pWidget->prev;
widget_set_area(pWidget, area);
widget_set_position(pWidget,
area.x + adj_size(2) + pWidget->size.w,
area.y + area.h - pWidget->size.h - 2);
pwidget = pwidget->prev;
widget_set_area(pwidget, area);
widget_set_position(pwidget,
area.x + adj_size(2) + pwidget->size.w,
area.y + area.h - pwidget->size.h - 2);
}
/**********************************************************************//**
......
**************************************************************************/
void popup_unitinfo_window(void)
{
struct widget *pWidget, *pwindow;
struct widget *pwidget, *pwindow;
SDL_Surface *pIcon_theme = NULL;
char buf[256];
......
pUnits_Info_Window->private_data.adv_dlg = pUnitInfo_Dlg;
/* economy button */
pWidget = create_icon2(get_tax_surface(O_GOLD), pUnits_Info_Window->dst,
pwidget = create_icon2(get_tax_surface(O_GOLD), pUnits_Info_Window->dst,
WF_FREE_GFX | WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND | WF_FREE_THEME);
fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Economy"), "F5");
pWidget->info_label = create_utf8_from_char(buf, adj_font(12));
pWidget->action = economy_callback;
pWidget->key = SDLK_F5;
pwidget->info_label = create_utf8_from_char(buf, adj_font(12));
pwidget->action = economy_callback;
pwidget->key = SDLK_F5;
add_to_gui_list(ID_ECONOMY, pWidget);
add_to_gui_list(ID_ECONOMY, pwidget);
pTax_Button = pWidget;
pTax_Button = pwidget;
/* research button */
pWidget = create_icon2(adj_surf(GET_SURF(client_research_sprite())),
pwidget = create_icon2(adj_surf(GET_SURF(client_research_sprite())),
pUnits_Info_Window->dst,
WF_FREE_GFX | WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND | WF_FREE_THEME);
/* TRANS: Research report action */
fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Research"), "F6");
pWidget->info_label = create_utf8_from_char(buf, adj_font(12));
pWidget->action = research_callback;
pWidget->key = SDLK_F6;
pwidget->info_label = create_utf8_from_char(buf, adj_font(12));
pwidget->action = research_callback;
pwidget->key = SDLK_F6;
add_to_gui_list(ID_RESEARCH, pWidget);
add_to_gui_list(ID_RESEARCH, pwidget);
pResearch_Button = pWidget;
pResearch_Button = pwidget;
/* revolution button */
pWidget = create_icon2(adj_surf(GET_SURF(client_government_sprite())),
pwidget = create_icon2(adj_surf(GET_SURF(client_government_sprite())),
pUnits_Info_Window->dst,
WF_FREE_GFX | WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND | WF_FREE_THEME);
fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Revolution"), "Ctrl+Shift+R");
pWidget->info_label = create_utf8_from_char(buf, adj_font(12));
pWidget->action = revolution_callback;
pWidget->key = SDLK_r;
pWidget->mod = KMOD_CTRL | KMOD_SHIFT;
pwidget->info_label = create_utf8_from_char(buf, adj_font(12));
pwidget->action = revolution_callback;
pwidget->key = SDLK_r;
pwidget->mod = KMOD_CTRL | KMOD_SHIFT;
add_to_gui_list(ID_REVOLUTION, pWidget);
add_to_gui_list(ID_REVOLUTION, pwidget);
pRevolution_Button = pWidget;
pRevolution_Button = pwidget;
/* show/hide unit's window button */
......
alphablit(current_theme->MAP_Icon, NULL, pIcon_theme, NULL, 255);
alphablit(current_theme->R_ARROW_Icon, NULL, pIcon_theme, NULL, 255);
pWidget = create_themeicon(pIcon_theme, pUnits_Info_Window->dst,
pwidget = create_themeicon(pIcon_theme, pUnits_Info_Window->dst,
WF_FREE_GFX | WF_FREE_THEME
| WF_RESTORE_BACKGROUND
| WF_WIDGET_HAS_INFO_LABEL);
pWidget->info_label = create_utf8_from_char(_("Hide Unit Info Window"),
pwidget->info_label = create_utf8_from_char(_("Hide Unit Info Window"),
adj_font(12));
pWidget->action = toggle_unit_info_window_callback;
pwidget->action = toggle_unit_info_window_callback;
add_to_gui_list(ID_TOGGLE_UNITS_WINDOW_BUTTON, pWidget);
add_to_gui_list(ID_TOGGLE_UNITS_WINDOW_BUTTON, pwidget);
pUnitInfo_Dlg->pBeginWidgetList = pWidget;
pUnitInfo_Dlg->pBeginWidgetList = pwidget;
SDL_Client_Flags |= CF_UNITINFO_SHOWN;
......
**************************************************************************/
void show_unitinfo_window_buttons(void)
{
struct widget *pWidget = get_unit_info_window_widget();
struct widget *pwidget = get_unit_info_window_widget();
/* economy button */
pWidget = pWidget->prev;
clear_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
clear_wflag(pwidget, WF_HIDDEN);
/* research button */
pWidget = pWidget->prev;
clear_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
clear_wflag(pwidget, WF_HIDDEN);
/* revolution button */
pWidget = pWidget->prev;
clear_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
clear_wflag(pwidget, WF_HIDDEN);
/* show/hide unit's window button */
pWidget = pWidget->prev;
clear_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
clear_wflag(pwidget, WF_HIDDEN);
}
/**********************************************************************//**
......
**************************************************************************/
void hide_unitinfo_window_buttons(void)
{
struct widget *pWidget = get_unit_info_window_widget();
struct widget *pwidget = get_unit_info_window_widget();
/* economy button */
pWidget = pWidget->prev;
set_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
set_wflag(pwidget, WF_HIDDEN);
/* research button */
pWidget = pWidget->prev;
set_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
set_wflag(pwidget, WF_HIDDEN);
/* revolution button */
pWidget = pWidget->prev;
set_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
set_wflag(pwidget, WF_HIDDEN);
/* show/hide unit's window button */
pWidget = pWidget->prev;
set_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
set_wflag(pwidget, WF_HIDDEN);
}
/**********************************************************************//**
......
**************************************************************************/
void disable_unitinfo_window_buttons(void)
{
struct widget *pWidget = get_unit_info_window_widget();
struct widget *pwidget = get_unit_info_window_widget();
/* economy button */
pWidget = pWidget->prev;
set_wstate(pWidget, FC_WS_DISABLED);
pwidget = pwidget->prev;
set_wstate(pwidget, FC_WS_DISABLED);
/* research button */
pWidget = pWidget->prev;
set_wstate(pWidget, FC_WS_DISABLED);
pwidget = pwidget->prev;
set_wstate(pwidget, FC_WS_DISABLED);
/* revolution button */
pWidget = pWidget->prev;
set_wstate(pWidget, FC_WS_DISABLED);
pwidget = pwidget->prev;
set_wstate(pwidget, FC_WS_DISABLED);
}
/**********************************************************************//**
......
**************************************************************************/
void popup_minimap_window(void)
{
struct widget *pWidget, *pwindow;
struct widget *pwidget, *pwindow;
SDL_Surface *pIcon_theme = NULL;
SDL_Color black = {0, 0, 0, 255};
char buf[256];
......
pMiniMap_Dlg->pEndWidgetList = pMiniMap_Window;
/* new turn button */
pWidget = create_themeicon(current_theme->NEW_TURN_Icon, pMiniMap_Window->dst,
pwidget = create_themeicon(current_theme->NEW_TURN_Icon, pMiniMap_Window->dst,
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Turn Done"), _("Shift+Return"));
pWidget->info_label = create_utf8_from_char(buf, adj_font(12));
pWidget->action = end_turn_callback;
pWidget->key = SDLK_RETURN;
pWidget->mod = KMOD_SHIFT;
pwidget->info_label = create_utf8_from_char(buf, adj_font(12));
pwidget->action = end_turn_callback;
pwidget->key = SDLK_RETURN;
pwidget->mod = KMOD_SHIFT;
add_to_gui_list(ID_NEW_TURN, pWidget);
add_to_gui_list(ID_NEW_TURN, pwidget);
pNew_Turn_Button = pWidget;
pNew_Turn_Button = pwidget;
/* players button */
pWidget = create_themeicon(current_theme->PLAYERS_Icon, pMiniMap_Window->dst,
pwidget = create_themeicon(current_theme->PLAYERS_Icon, pMiniMap_Window->dst,
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
/* TRANS: Nations report action */
fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Nations"), "F3");
pWidget->info_label = create_utf8_from_char(buf, adj_font(12));
pWidget->action = players_action_callback;
pWidget->key = SDLK_F3;
pwidget->info_label = create_utf8_from_char(buf, adj_font(12));
pwidget->action = players_action_callback;
pwidget->key = SDLK_F3;
add_to_gui_list(ID_PLAYERS, pWidget);
add_to_gui_list(ID_PLAYERS, pwidget);
/* find city button */
pWidget = create_themeicon(current_theme->FindCity_Icon, pMiniMap_Window->dst,
pwidget = create_themeicon(current_theme->FindCity_Icon, pMiniMap_Window->dst,
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
fc_snprintf(buf, sizeof(buf), "%s (%s)\n%s\n%s (%s)", _("Cities Report"),
"F4", _("or"), _("Find City"), "Ctrl+F");
pWidget->info_label = create_utf8_from_char(buf, adj_font(12));
pWidget->info_label->style |= SF_CENTER;
pWidget->action = cities_action_callback;
pWidget->key = SDLK_f;
pWidget->mod = KMOD_CTRL;
pwidget->info_label = create_utf8_from_char(buf, adj_font(12));
pwidget->info_label->style |= SF_CENTER;
pwidget->action = cities_action_callback;
pwidget->key = SDLK_f;
pwidget->mod = KMOD_CTRL;
add_to_gui_list(ID_CITIES, pWidget);
add_to_gui_list(ID_CITIES, pwidget);
pFind_City_Button = pWidget;
pFind_City_Button = pwidget;
/* units button */
pWidget = create_themeicon(current_theme->UNITS2_Icon, pMiniMap_Window->dst,
pwidget = create_themeicon(current_theme->UNITS2_Icon, pMiniMap_Window->dst,
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Units"), "F2");
pWidget->info_label = create_utf8_from_char(buf, adj_font(12));
pWidget->action = units_action_callback;
pWidget->key = SDLK_F2;
pwidget->info_label = create_utf8_from_char(buf, adj_font(12));
pwidget->action = units_action_callback;
pwidget->key = SDLK_F2;
add_to_gui_list(ID_UNITS, pWidget);
add_to_gui_list(ID_UNITS, pwidget);
/* show/hide log window button */
pWidget = create_themeicon(current_theme->LOG_Icon, pMiniMap_Window->dst,
pwidget = create_themeicon(current_theme->LOG_Icon, pMiniMap_Window->dst,
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Hide Messages"), "F9");
pWidget->info_label = create_utf8_from_char(buf, adj_font(12));
pWidget->action = toggle_msg_window_callback;
pWidget->key = SDLK_F9;
pwidget->info_label = create_utf8_from_char(buf, adj_font(12));
pwidget->action = toggle_msg_window_callback;
pwidget->key = SDLK_F9;
add_to_gui_list(ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON, pWidget);
add_to_gui_list(ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON, pwidget);
/* toggle minimap mode button */
pWidget = create_themeicon(current_theme->BORDERS_Icon, pMiniMap_Window->dst,
pwidget = create_themeicon(current_theme->BORDERS_Icon, pMiniMap_Window->dst,
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
fc_snprintf(buf, sizeof(buf), "%s (%s)", _("Toggle Mini Map Mode"), "Shift+\\");
pWidget->info_label = create_utf8_from_char(buf, adj_font(12));
pWidget->action = toggle_minimap_mode_callback;
pWidget->key = SDLK_BACKSLASH;
pWidget->mod = KMOD_SHIFT;
pwidget->info_label = create_utf8_from_char(buf, adj_font(12));
pwidget->action = toggle_minimap_mode_callback;
pwidget->key = SDLK_BACKSLASH;
pwidget->mod = KMOD_SHIFT;
add_to_gui_list(ID_TOGGLE_MINIMAP_MODE, pWidget);
add_to_gui_list(ID_TOGGLE_MINIMAP_MODE, pwidget);
#ifdef SMALL_SCREEN
/* options button */
......
alphablit(current_theme->MAP_Icon, NULL, pIcon_theme, NULL, 255);
alphablit(current_theme->L_ARROW_Icon, NULL, pIcon_theme, NULL, 255);
pWidget = create_themeicon(pIcon_theme, pMiniMap_Window->dst,
pwidget = create_themeicon(pIcon_theme, pMiniMap_Window->dst,
WF_FREE_GFX | WF_FREE_THEME |
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
pWidget->info_label = create_utf8_from_char(_("Hide Mini Map"),
pwidget->info_label = create_utf8_from_char(_("Hide Mini Map"),
adj_font(12));
pWidget->action = toggle_map_window_callback;
pwidget->action = toggle_map_window_callback;
add_to_gui_list(ID_TOGGLE_MAP_WINDOW_BUTTON, pWidget);
add_to_gui_list(ID_TOGGLE_MAP_WINDOW_BUTTON, pwidget);
pMiniMap_Dlg->pBeginWidgetList = pWidget;
pMiniMap_Dlg->pBeginWidgetList = pwidget;
SDL_Client_Flags |= CF_OVERVIEW_SHOWN;
......
**************************************************************************/
void show_minimap_window_buttons(void)
{
struct widget *pWidget = get_minimap_window_widget();
struct widget *pwidget = get_minimap_window_widget();
/* new turn button */
pWidget = pWidget->prev;
clear_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
clear_wflag(pwidget, WF_HIDDEN);
/* players button */
pWidget = pWidget->prev;
clear_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
clear_wflag(pwidget, WF_HIDDEN);
/* find city button */
pWidget = pWidget->prev;
clear_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
clear_wflag(pwidget, WF_HIDDEN);
/* units button */
pWidget = pWidget->prev;
clear_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
clear_wflag(pwidget, WF_HIDDEN);
/* show/hide log window button */
pWidget = pWidget->prev;
clear_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
clear_wflag(pwidget, WF_HIDDEN);
/* toggle minimap mode button */
pWidget = pWidget->prev;
clear_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
clear_wflag(pwidget, WF_HIDDEN);
#ifdef SMALL_SCREEN
/* options button */
pWidget = pWidget->prev;
clear_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
clear_wflag(pwidget, WF_HIDDEN);
#endif /* SMALL_SCREEN */
/* show/hide minimap button */
pWidget = pWidget->prev;
clear_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
clear_wflag(pwidget, WF_HIDDEN);
}
/**********************************************************************//**
......
**************************************************************************/
void hide_minimap_window_buttons(void)
{
struct widget *pWidget = get_minimap_window_widget();
struct widget *pwidget = get_minimap_window_widget();
/* new turn button */
pWidget = pWidget->prev;
set_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
set_wflag(pwidget, WF_HIDDEN);
/* players button */
pWidget = pWidget->prev;
set_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
set_wflag(pwidget, WF_HIDDEN);
/* find city button */
pWidget = pWidget->prev;
set_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
set_wflag(pwidget, WF_HIDDEN);
/* units button */
pWidget = pWidget->prev;
set_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
set_wflag(pwidget, WF_HIDDEN);
/* show/hide log window button */
pWidget = pWidget->prev;
set_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
set_wflag(pwidget, WF_HIDDEN);
/* toggle minimap mode button */
pWidget = pWidget->prev;
set_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
set_wflag(pwidget, WF_HIDDEN);
#ifdef SMALL_SCREEN
/* options button */
pWidget = pWidget->prev;
set_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
set_wflag(pwidget, WF_HIDDEN);
#endif /* SMALL_SCREEN */
/* show/hide minimap button */
pWidget = pWidget->prev;
set_wflag(pWidget, WF_HIDDEN);
pwidget = pwidget->prev;
set_wflag(pwidget, WF_HIDDEN);
}
/**********************************************************************//**
......
**************************************************************************/
void redraw_minimap_window_buttons(void)
{
struct widget *pWidget = get_minimap_window_widget();
struct widget *pwidget = get_minimap_window_widget();
/* new turn button */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
/* players button */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
/* find city button */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
/* units button */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
/* show/hide log window button */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
/* toggle minimap mode button */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
#ifdef SMALL_SCREEN
/* options button */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
#endif /* SMALL_SCREEN */
/* show/hide minimap button */
pWidget = pWidget->prev;
widget_redraw(pWidget);
pwidget = pwidget->prev;
widget_redraw(pwidget);
}
/**********************************************************************//**
......
**************************************************************************/
void disable_minimap_window_buttons(void)
{
struct widget *pWidget = get_minimap_window_widget();
struct widget *pwidget = get_minimap_window_widget();
/* new turn button */
pWidget = pWidget->prev;
set_wstate(pWidget, FC_WS_DISABLED);
pwidget = pwidget->prev;
set_wstate(pwidget, FC_WS_DISABLED);
/* players button */
pWidget = pWidget->prev;
set_wstate(pWidget, FC_WS_DISABLED);
pwidget = pwidget->prev;
set_wstate(pwidget, FC_WS_DISABLED);
/* find city button */
pWidget = pWidget->prev;
set_wstate(pWidget, FC_WS_DISABLED);
pwidget = pwidget->prev;
set_wstate(pwidget, FC_WS_DISABLED);
/* units button */
pWidget = pWidget->prev;
set_wstate(pWidget, FC_WS_DISABLED);
pwidget = pwidget->prev;
set_wstate(pwidget, FC_WS_DISABLED);
/* show/hide log window button */
pWidget = pWidget->prev;
set_wstate(pWidget, FC_WS_DISABLED);
pwidget = pwidget->prev;
set_wstate(pwidget, FC_WS_DISABLED);
#ifdef SMALL_SCREEN
/* options button */
pWidget = pWidget->prev;
set_wstate(pWidget, FC_WS_DISABLED);
pwidget = pwidget->prev;
set_wstate(pwidget, FC_WS_DISABLED);
#endif /* SMALL_SCREEN */
}
......
**************************************************************************/
void show_game_page(void)
{
struct widget *pWidget;
struct widget *pwidget;
SDL_Surface *pIcon_theme = NULL;
if (SDL_Client_Flags & CF_MAP_UNIT_W_CREATED) {
......
/* cooling icon */
pIcon_theme = adj_surf(GET_SURF(client_cooling_sprite()));
fc_assert(pIcon_theme != NULL);
pWidget = create_iconlabel(pIcon_theme, main_data.gui, NULL, WF_FREE_THEME);
pwidget = create_iconlabel(pIcon_theme, main_data.gui, NULL, WF_FREE_THEME);
#ifdef SMALL_SCREEN
widget_set_position(pWidget,
pWidget->dst->surface->w - pWidget->size.w - adj_size(10),
widget_set_position(pwidget,
pwidget->dst->surface->w - pwidget->size.w - adj_size(10),
0);
#else /* SMALL_SCREEN */
widget_set_position(pWidget,
pWidget->dst->surface->w - pWidget->size.w - adj_size(10),
widget_set_position(pwidget,
pwidget->dst->surface->w - pwidget->size.w - adj_size(10),
adj_size(10));
#endif /* SMALL_SCREEN */
add_to_gui_list(ID_COOLING_ICON, pWidget);
add_to_gui_list(ID_COOLING_ICON, pwidget);
/* warming icon */
pIcon_theme = adj_surf(GET_SURF(client_warming_sprite()));
fc_assert(pIcon_theme != NULL);
pWidget = create_iconlabel(pIcon_theme, main_data.gui, NULL, WF_FREE_THEME);
pwidget = create_iconlabel(pIcon_theme, main_data.gui, NULL, WF_FREE_THEME);
#ifdef SMALL_SCREEN
widget_set_position(pWidget,
pWidget->dst->surface->w - pWidget->size.w * 2 - adj_size(10),
widget_set_position(pwidget,
pwidget->dst->surface->w - pwidget->size.w * 2 - adj_size(10),
0);
#else /* SMALL_SCREEN */
widget_set_position(pWidget,
pWidget->dst->surface->w - pWidget->size.w * 2 - adj_size(10),
widget_set_position(pwidget,
pwidget->dst->surface->w - pwidget->size.w * 2 - adj_size(10),
adj_size(10));
#endif /* SMALL_SCREEN */
add_to_gui_list(ID_WARMING_ICON, pWidget);
add_to_gui_list(ID_WARMING_ICON, pwidget);
/* create order buttons */
create_units_order_widgets();
......
**************************************************************************/
void close_game_page(void)
{
struct widget *pWidget;
struct widget *pwidget;
del_widget_from_gui_list(pOptions_Button);
pWidget = get_widget_pointer_form_main_list(ID_COOLING_ICON);
del_widget_from_gui_list(pWidget);
pwidget = get_widget_pointer_form_main_list(ID_COOLING_ICON);
del_widget_from_gui_list(pwidget);
pWidget = get_widget_pointer_form_main_list(ID_WARMING_ICON);
del_widget_from_gui_list(pWidget);
pwidget = get_widget_pointer_form_main_list(ID_WARMING_ICON);
del_widget_from_gui_list(pwidget);
delete_units_order_widgets();
client/gui-sdl2/menu.c
static Uint16 redraw_order_widgets(void)
{
Uint16 count = 0;
struct widget *pTmpWidget = pBeginOrderWidgetList;
struct widget *tmp_widget = pBeginOrderWidgetList;
while (TRUE) {
if (!(get_wflags(pTmpWidget) & WF_HIDDEN)) {
if (get_wflags(pTmpWidget) & WF_RESTORE_BACKGROUND) {
refresh_widget_background(pTmpWidget);
if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
if (get_wflags(tmp_widget) & WF_RESTORE_BACKGROUND) {
refresh_widget_background(tmp_widget);
}
widget_redraw(pTmpWidget);
widget_mark_dirty(pTmpWidget);
widget_redraw(tmp_widget);
widget_mark_dirty(tmp_widget);
count++;
}
if (pTmpWidget == pEndOrderWidgetList) {
if (tmp_widget == pEndOrderWidgetList) {
break;
}
pTmpWidget = pTmpWidget->next;
tmp_widget = tmp_widget->next;
}
return count;
......
{
struct widget *pMiniMap = get_minimap_window_widget();
struct widget *pInfoWind = get_unit_info_window_widget();
struct widget *pTmpWidget = pBeginOrderWidgetList;
struct widget *tmp_widget = pBeginOrderWidgetList;
Sint16 sx, sy, xx, yy = 0;
int count = 0, lines = 1, w = 0, count_on_line;
xx = pMiniMap->dst->dest_rect.x + pMiniMap->size.w + adj_size(10);
w = (pInfoWind->dst->dest_rect.x - adj_size(10)) - xx;
if (w < (pTmpWidget->size.w + adj_size(10)) * 2) {
if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
if (pMiniMap->size.h == pInfoWind->size.h) {
xx = 0;
w = main_window_width();
......
} else {
if (pMiniMap->size.h > pInfoWind->size.h) {
w = main_window_width() - xx - adj_size(20);
if (w < (pTmpWidget->size.w + adj_size(10)) * 2) {
if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
xx = 0;
w = pMiniMap->size.w;
yy = pMiniMap->size.h;
......
}
} else {
w = pInfoWind->dst->dest_rect.x - adj_size(20);
if (w < (pTmpWidget->size.w + adj_size(10)) * 2) {
if (w < (tmp_widget->size.w + adj_size(10)) * 2) {
xx = pInfoWind->dst->dest_rect.x;
w = pInfoWind->size.w;
yy = pInfoWind->size.h;
......
}
}
count_on_line = w / (pTmpWidget->size.w + adj_size(5));
count_on_line = w / (tmp_widget->size.w + adj_size(5));
/* find how many to reposition */
while (TRUE) {
if (!(get_wflags(pTmpWidget) & WF_HIDDEN)) {
if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
count++;
}
if (pTmpWidget == pEndOrderWidgetList) {
if (tmp_widget == pEndOrderWidgetList) {
break;
}
pTmpWidget = pTmpWidget->next;
tmp_widget = tmp_widget->next;
}
pTmpWidget = pBeginOrderWidgetList;
tmp_widget = pBeginOrderWidgetList;
if (count - count_on_line > 0) {
lines = (count + (count_on_line - 1)) / count_on_line;
......
count = count_on_line - ((count_on_line * lines) - count);
}
sx = xx + (w - count * (pTmpWidget->size.w + adj_size(5))) / 2;
sx = xx + (w - count * (tmp_widget->size.w + adj_size(5))) / 2;
sy = pTmpWidget->dst->surface->h - yy - lines * (pTmpWidget->size.h + adj_size(5));
sy = tmp_widget->dst->surface->h - yy - lines * (tmp_widget->size.h + adj_size(5));
while (TRUE) {
if (!(get_wflags(pTmpWidget) & WF_HIDDEN)) {
pTmpWidget->size.x = sx;
pTmpWidget->size.y = sy;
if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
tmp_widget->size.x = sx;
tmp_widget->size.y = sy;
count--;
sx += (pTmpWidget->size.w + adj_size(5));
sx += (tmp_widget->size.w + adj_size(5));
if (!count) {
count = count_on_line;
lines--;
sx = xx + (w - count * (pTmpWidget->size.w + adj_size(5))) / 2;
sx = xx + (w - count * (tmp_widget->size.w + adj_size(5))) / 2;
sy = pTmpWidget->dst->surface->h - yy - lines * (pTmpWidget->size.h + adj_size(5));
sy = tmp_widget->dst->surface->h - yy - lines * (tmp_widget->size.h + adj_size(5));
}
}
if (pTmpWidget == pEndOrderWidgetList) {
if (tmp_widget == pEndOrderWidgetList) {
break;
}
pTmpWidget = pTmpWidget->next;
tmp_widget = tmp_widget->next;
}
}
......
**************************************************************************/
void undraw_order_widgets(void)
{
struct widget *pTmpWidget = pBeginOrderWidgetList;
struct widget *tmp_widget = pBeginOrderWidgetList;
if (pTmpWidget == NULL) {
if (tmp_widget == NULL) {
return;
}
while (TRUE) {
if (!(get_wflags(pTmpWidget) & WF_HIDDEN) && (pTmpWidget->gfx)) {
widget_undraw(pTmpWidget);
widget_mark_dirty(pTmpWidget);
if (!(get_wflags(tmp_widget) & WF_HIDDEN) && (tmp_widget->gfx)) {
widget_undraw(tmp_widget);
widget_mark_dirty(tmp_widget);
}
if (pTmpWidget == pEndOrderWidgetList) {
if (tmp_widget == pEndOrderWidgetList) {
break;
}
pTmpWidget = pTmpWidget->next;
tmp_widget = tmp_widget->next;
}
}
......
**************************************************************************/
void free_bcgd_order_widgets(void)
{
struct widget *pTmpWidget = pBeginOrderWidgetList;
struct widget *tmp_widget = pBeginOrderWidgetList;
while (TRUE) {
FREESURFACE(pTmpWidget->gfx);
FREESURFACE(tmp_widget->gfx);
if (pTmpWidget == pEndOrderWidgetList) {
if (tmp_widget == pEndOrderWidgetList) {
break;
}
pTmpWidget = pTmpWidget->next;
tmp_widget = tmp_widget->next;
}
}
client/gui-sdl2/messagewin.c
/**********************************************************************//**
Called from default clicks on a message.
**************************************************************************/
static int msg_callback(struct widget *pWidget)
static int msg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int message_index = *(int*)pWidget->data.ptr;
int message_index = *(int*)pwidget->data.ptr;
pWidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_MESWIN_ACTIVE_TEXT2);
pwidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_MESWIN_ACTIVE_TEXT2);
unselect_widget_action();
meswin_double_click(message_index);
client/gui-sdl2/optiondlg.c
/************************************************************************//**
Back requested.
****************************************************************************/
static int back_callback(struct widget *pWidget)
static int back_callback(struct widget *pwidget)
{
if (NULL == option_dialog || !PRESSED_EVENT(main_data.event)) {
return -1;
......
/************************************************************************//**
Create the client options dialog.
****************************************************************************/
static int client_options_callback(struct widget *pWidget)
static int client_options_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
option_dialog_popup(_("Local Options"), client_optset);
......
/************************************************************************//**
Create the server options dialog.
****************************************************************************/
static int server_options_callback(struct widget *pWidget)
static int server_options_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
option_dialog_popup(_("Server options"), server_optset);
......
/************************************************************************//**
Option set category selected.
****************************************************************************/
static int save_client_options_callback(struct widget *pWidget)
static int save_client_options_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
options_save(NULL);
......
/************************************************************************//**
Save game callback.
****************************************************************************/
static int save_game_callback(struct widget *pWidget)
static int save_game_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
send_save_game(NULL);
......
/************************************************************************//**
Client disconnect from server callback.
****************************************************************************/
static int disconnect_callback(struct widget *pWidget)
static int disconnect_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_optiondlg(TRUE);
......
/************************************************************************//**
Exit callback.
****************************************************************************/
static int exit_callback(struct widget *pWidget)
static int exit_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_optiondlg(TRUE);
client/gui-sdl2/pages.c
/**********************************************************************//**
User interacted with the Start New Game button.
**************************************************************************/
static int start_new_game_callback(struct widget *pWidget)
static int start_new_game_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_start_menu();
......
/**********************************************************************//**
User interacted with the Load Game button.
**************************************************************************/
static int load_game_callback(struct widget *pWidget)
static int load_game_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
set_client_page(PAGE_LOAD);
......
/**********************************************************************//**
User interacted with the Join Game button.
**************************************************************************/
static int join_game_callback(struct widget *pWidget)
static int join_game_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
set_client_page(PAGE_NETWORK);
......
/**********************************************************************//**
User interacted with the Join Pubserver button - open connection dialog.
**************************************************************************/
static int servers_callback(struct widget *pWidget)
static int servers_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
bool lan_scan = (pWidget->ID != ID_JOIN_META_GAME);
bool lan_scan = (pwidget->ID != ID_JOIN_META_GAME);
popdown_start_menu();
popup_connection_dialog(lan_scan);
......
/**********************************************************************//**
User interacted with the Options button - open options dialog.
**************************************************************************/
static int options_callback(struct widget *pWidget)
static int options_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
queue_flush();
......
/**********************************************************************//**
User interacted with the Quit button.
**************************************************************************/
static int quit_callback(struct widget *pWidget)
static int quit_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_start_menu();
......
SDL_Color bg_color = {255, 255, 255, 96};
SDL_Color line_color = {128, 128, 128, 255};
int count = 0;
struct widget *pWidget = NULL, *pwindow = NULL;
struct widget *pwidget = NULL, *pwindow = NULL;
SDL_Surface *pBackground;
int h = 0;
SDL_Rect area;
......
/* Freeciv version */
/* TRANS: Freeciv 2.4.0 */
fc_snprintf(verbuf, sizeof(verbuf), _("Freeciv %s"), VERSION_STRING);
pWidget = create_iconlabel_from_chars(NULL, pwindow->dst, verbuf,
pwidget = create_iconlabel_from_chars(NULL, pwindow->dst, verbuf,
adj_font(12),
(WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND|WF_FREE_DATA));
pWidget->string_utf8->style |= SF_CENTER | TTF_STYLE_BOLD;
pwidget->string_utf8->style |= SF_CENTER | TTF_STYLE_BOLD;
area.w = MAX(area.w, pWidget->size.w);
h = MAX(h, pWidget->size.h);
area.w = MAX(area.w, pwidget->size.w);
h = MAX(h, pwidget->size.h);
count++;
add_to_gui_list(ID_LABEL, pWidget);
add_to_gui_list(ID_LABEL, pwidget);
/* TRANS: gui-sdl2 client */
fc_snprintf(verbuf, sizeof(verbuf), _("%s client"), client_string);
pWidget = create_iconlabel_from_chars(NULL, pwindow->dst, verbuf,
pwidget = create_iconlabel_from_chars(NULL, pwindow->dst, verbuf,
adj_font(12),
(WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND|WF_FREE_DATA));
pWidget->string_utf8->style |= SF_CENTER | TTF_STYLE_BOLD;
pwidget->string_utf8->style |= SF_CENTER | TTF_STYLE_BOLD;
area.w = MAX(area.w, pWidget->size.w);
h = MAX(h, pWidget->size.h);
area.w = MAX(area.w, pwidget->size.w);
h = MAX(h, pwidget->size.h);
count++;
add_to_gui_list(ID_LABEL, pWidget);
add_to_gui_list(ID_LABEL, pwidget);
/* Start New Game */
pWidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Start New Game"),
pwidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Start New Game"),
adj_font(14),
(WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND|WF_FREE_DATA));
pWidget->action = start_new_game_callback;
pWidget->string_utf8->style |= SF_CENTER;
set_wstate(pWidget, FC_WS_NORMAL);
pwidget->action = start_new_game_callback;
pwidget->string_utf8->style |= SF_CENTER;
set_wstate(pwidget, FC_WS_NORMAL);
area.w = MAX(area.w, pWidget->size.w);
h = MAX(h, pWidget->size.h);
area.w = MAX(area.w, pwidget->size.w);
h = MAX(h, pwidget->size.h);
count++;
add_to_gui_list(ID_START_NEW_GAME, pWidget);
add_to_gui_list(ID_START_NEW_GAME, pwidget);
/* Load Game */
pWidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Load Game"),
pwidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Load Game"),
adj_font(14),
(WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND));
pWidget->action = load_game_callback;
pWidget->string_utf8->style |= SF_CENTER;
set_wstate(pWidget, FC_WS_NORMAL);
pwidget->action = load_game_callback;
pwidget->string_utf8->style |= SF_CENTER;
set_wstate(pwidget, FC_WS_NORMAL);
add_to_gui_list(ID_LOAD_GAME, pWidget);
add_to_gui_list(ID_LOAD_GAME, pwidget);
area.w = MAX(area.w, pWidget->size.w);
h = MAX(h, pWidget->size.h);
area.w = MAX(area.w, pwidget->size.w);
h = MAX(h, pwidget->size.h);
count++;
/* Join Game */
pWidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Join Game"),
pwidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Join Game"),
adj_font(14),
WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND);
pWidget->action = join_game_callback;
pWidget->string_utf8->style |= SF_CENTER;
set_wstate(pWidget, FC_WS_NORMAL);
pwidget->action = join_game_callback;
pwidget->string_utf8->style |= SF_CENTER;
set_wstate(pwidget, FC_WS_NORMAL);
add_to_gui_list(ID_JOIN_GAME, pWidget);
add_to_gui_list(ID_JOIN_GAME, pwidget);
area.w = MAX(area.w, pWidget->size.w);
h = MAX(h, pWidget->size.h);
area.w = MAX(area.w, pwidget->size.w);
h = MAX(h, pwidget->size.h);
count++;
/* Join Pubserver */
pWidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Join Pubserver"),
pwidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Join Pubserver"),
adj_font(14),
WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND);
pWidget->action = servers_callback;
pWidget->string_utf8->style |= SF_CENTER;
set_wstate(pWidget, FC_WS_NORMAL);
pwidget->action = servers_callback;
pwidget->string_utf8->style |= SF_CENTER;
set_wstate(pwidget, FC_WS_NORMAL);
add_to_gui_list(ID_JOIN_META_GAME, pWidget);
add_to_gui_list(ID_JOIN_META_GAME, pwidget);
area.w = MAX(area.w, pWidget->size.w);
h = MAX(h, pWidget->size.h);
area.w = MAX(area.w, pwidget->size.w);
h = MAX(h, pwidget->size.h);
count++;
/* Join LAN Server */
pWidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Join LAN Server"),
pwidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Join LAN Server"),
adj_font(14),
WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND);
pWidget->action = servers_callback;
pWidget->string_utf8->style |= SF_CENTER;
set_wstate(pWidget, FC_WS_NORMAL);
pwidget->action = servers_callback;
pwidget->string_utf8->style |= SF_CENTER;
set_wstate(pwidget, FC_WS_NORMAL);
add_to_gui_list(ID_JOIN_GAME, pWidget);
add_to_gui_list(ID_JOIN_GAME, pwidget);
area.w = MAX(area.w, pWidget->size.w);
h = MAX(h, pWidget->size.h);
area.w = MAX(area.w, pwidget->size.w);
h = MAX(h, pwidget->size.h);
count++;
/* Options */
pWidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Options"),
pwidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Options"),
adj_font(14),
WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND);
pWidget->action = options_callback;
pWidget->string_utf8->style |= SF_CENTER;
set_wstate(pWidget, FC_WS_NORMAL);
pwidget->action = options_callback;
pwidget->string_utf8->style |= SF_CENTER;
set_wstate(pwidget, FC_WS_NORMAL);
add_to_gui_list(ID_CLIENT_OPTIONS_BUTTON, pWidget);
add_to_gui_list(ID_CLIENT_OPTIONS_BUTTON, pwidget);
area.w = MAX(area.w, pWidget->size.w);
h = MAX(h, pWidget->size.h);
area.w = MAX(area.w, pwidget->size.w);
h = MAX(h, pwidget->size.h);
count++;
/* Quit */
pWidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Quit"),
pwidget = create_iconlabel_from_chars(NULL, pwindow->dst, _("Quit"),
adj_font(14),
WF_SELECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND);
pWidget->action = quit_callback;
pWidget->string_utf8->style |= SF_CENTER;
pWidget->key = SDLK_ESCAPE;
set_wstate(pWidget, FC_WS_NORMAL);
add_to_gui_list(ID_QUIT, pWidget);
pwidget->action = quit_callback;
pwidget->string_utf8->style |= SF_CENTER;
pwidget->key = SDLK_ESCAPE;
set_wstate(pwidget, FC_WS_NORMAL);
add_to_gui_list(ID_QUIT, pwidget);
area.w = MAX(area.w, pWidget->size.w);
h = MAX(h, pWidget->size.h);
area.w = MAX(area.w, pwidget->size.w);
h = MAX(h, pwidget->size.h);
count++;
pStartMenu->pBeginWidgetList = pWidget;
pStartMenu->pBeginWidgetList = pwidget;
/* ------*/
......
area = pwindow->area;
group_set_area(pWidget, pwindow->prev, area);
group_set_area(pwidget, pwindow->prev, area);
setup_vertical_widgets_position(1, area.x, area.y, area.w, h, pWidget, pwindow->prev);
setup_vertical_widgets_position(1, area.x, area.y, area.w, h, pwidget, pwindow->prev);
area.h = h * 2;
fill_rect_alpha(pwindow->theme, &area, &bg_color);
client/gui-sdl2/plrdlg.c
/**********************************************************************//**
User interacted with player dialog close button.
**************************************************************************/
static int exit_players_dlg_callback(struct widget *pWidget)
static int exit_players_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_players_dialog();
......
/**********************************************************************//**
User interacted with player widget.
**************************************************************************/
static int player_callback(struct widget *pWidget)
static int player_callback(struct widget *pwidget)
{
struct player *pplayer = pWidget->data.player;
struct player *pplayer = pwidget->data.player;
if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
switch (main_data.event.button.button) {
......
/**********************************************************************//**
User interacted with 'draw war status' toggle.
**************************************************************************/
static int toggle_draw_war_status_callback(struct widget *pWidget)
static int toggle_draw_war_status_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
/* exit button -> neutral -> war -> casefire -> peace -> alliance */
......
/**********************************************************************//**
User interacted with 'draw cease-fire status' toggle.
**************************************************************************/
static int toggle_draw_ceasefire_status_callback(struct widget *pWidget)
static int toggle_draw_ceasefire_status_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
/* exit button -> neutral -> war -> casefire -> peace -> alliance */
......
/**********************************************************************//**
User interacted with 'draw peace status' toggle.
**************************************************************************/
static int toggle_draw_peace_status_callback(struct widget *pWidget)
static int toggle_draw_peace_status_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
/* exit button -> neutral -> war -> casefire -> peace -> alliance */
......
/**********************************************************************//**
User interacted with 'draw alliance status' toggle.
**************************************************************************/
static int toggle_draw_alliance_status_callback(struct widget *pWidget)
static int toggle_draw_alliance_status_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
/* exit button -> neutral -> war -> casefire -> peace -> alliance */
......
/**********************************************************************//**
User interacted with 'draw neutral status' toggle.
**************************************************************************/
static int toggle_draw_neutral_status_callback(struct widget *pWidget)
static int toggle_draw_neutral_status_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
/* exit button -> neutral -> war -> casefire -> peace -> alliance */
......
/**********************************************************************//**
User interacted with nations window close button.
**************************************************************************/
static int exit_players_nations_dlg_callback(struct widget *pWidget)
static int exit_players_nations_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_players_nations_dialog();
......
/**********************************************************************//**
User interacted with widget of a single nation/player.
**************************************************************************/
static int player_nation_callback(struct widget *pWidget)
static int player_nation_callback(struct widget *pwidget)
{
struct player *pplayer = pWidget->data.player;
struct player *pplayer = pwidget->data.player;
popdown_players_nations_dialog();
if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
client/gui-sdl2/repodlgs.c
/**********************************************************************//**
User interacted with accept button of the unit upgrade dialog.
**************************************************************************/
static int ok_upgrade_unit_window_callback(struct widget *pWidget)
static int ok_upgrade_unit_window_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int ut1 = MAX_ID - pWidget->ID;
int ut1 = MAX_ID - pwidget->ID;
/* popdown upgrade dlg */
popdown_window_group_dialog(pUnits_Upg_Dlg->pBeginWidgetList,
......
/**********************************************************************//**
User interacted with Cancel button of the unit upgrade dialog.
**************************************************************************/
static int cancel_upgrade_unit_callback(struct widget *pWidget)
static int cancel_upgrade_unit_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pUnits_Upg_Dlg) {
......
/**********************************************************************//**
Open dialog for upgrading units.
**************************************************************************/
static int popup_upgrade_unit_callback(struct widget *pWidget)
static int popup_upgrade_unit_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit_type *ut1;
......
SDL_Rect dst;
SDL_Rect area;
ut1 = utype_by_number(MAX_ID - pWidget->ID);
ut1 = utype_by_number(MAX_ID - pwidget->ID);
if (pUnits_Upg_Dlg) {
return 1;
}
set_wstate(pWidget, FC_WS_NORMAL);
set_wstate(pwidget, FC_WS_NORMAL);
selected_widget = NULL;
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
pUnits_Upg_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
......
pBuf->action = ok_upgrade_unit_window_callback;
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(pWidget->ID, pBuf);
add_to_gui_list(pwidget->ID, pBuf);
pBuf->size.w = MAX(pBuf->size.w, pBuf->next->size.w);
pBuf->next->size.w = pBuf->size.w;
area.w = MAX(area.w, adj_size(30) + pBuf->size.w * 2);
......
/**********************************************************************//**
User interacted with units dialog Close Dialog button.
**************************************************************************/
static int exit_units_dlg_callback(struct widget *pWidget)
static int exit_units_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pUnitsDlg) {
......
if (pUnitsDlg) {
struct units_entry units[U_LAST];
struct units_entry units_total;
struct widget *pWidget, *pbuf;
struct widget *pwidget, *pbuf;
bool is_in_list = FALSE;
char cbuf[32];
bool upgrade;
......
get_units_report_data(units, &units_total);
/* find if there are new units entry (if not then rebuild all) */
pWidget = pUnitsDlg->pEndActiveWidgetList; /* icon of first list entry */
pwidget = pUnitsDlg->pEndActiveWidgetList; /* icon of first list entry */
unit_type_iterate(i) {
if ((units[utype_index(i)].active_count > 0)
|| (units[utype_index(i)].building_count > 0)) {
is_in_list = FALSE;
pbuf = pWidget; /* unit type icon */
pbuf = pwidget; /* unit type icon */
while (pbuf) {
if ((MAX_ID - pbuf->ID) == utype_number(i)) {
is_in_list = TRUE;
pWidget = pbuf;
pwidget = pbuf;
break;
}
if (pbuf->prev->prev->prev->prev->prev->prev->prev ==
......
} unit_type_iterate_end;
/* update list */
pWidget = pUnitsDlg->pEndActiveWidgetList;
pwidget = pUnitsDlg->pEndActiveWidgetList;
unit_type_iterate(i) {
pbuf = pWidget; /* first widget (icon) of the first list entry */
pbuf = pwidget; /* first widget (icon) of the first list entry */
if ((units[utype_index(i)].active_count > 0) || (units[utype_index(i)].building_count > 0)) {
/* the player has at least one unit of this type */
......
}
copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
pWidget = pbuf->prev; /* icon of next unit type */
pwidget = pbuf->prev; /* icon of next unit type */
search_finished = TRUE;
} else { /* list entry for this unit type not found yet */
/* search it */
pbuf = pWidget->next;
pbuf = pwidget->next;
do {
del_widget_from_vertical_scroll_widget_list(pUnitsDlg, pbuf->prev);
} while (((MAX_ID - pbuf->prev->ID) != utype_number(i))
......
if (pbuf->prev == pUnitsDlg->pBeginActiveWidgetList) {
/* list entry not found - can this really happen? */
del_widget_from_vertical_scroll_widget_list(pUnitsDlg, pbuf->prev);
pWidget = pbuf->prev; /* pUnitsDlg->pBeginActiveWidgetList */
pwidget = pbuf->prev; /* pUnitsDlg->pBeginActiveWidgetList */
search_finished = TRUE;
} else {
/* found it */
......
del_widget_from_vertical_scroll_widget_list(pUnitsDlg,
pbuf->prev);
}
pWidget = pbuf->prev;
pwidget = pbuf->prev;
}
}
}
......
/**********************************************************************//**
User interacted with Economy dialog Close Dialog button.
**************************************************************************/
static int exit_economy_dialog_callback(struct widget *pWidget)
static int exit_economy_dialog_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pEconomyDlg) {
......
/**********************************************************************//**
User interacted with Yes button of the improvement selling dialog.
**************************************************************************/
static int ok_sell_impr_callback(struct widget *pWidget)
static int ok_sell_impr_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int imp, total_count, count = 0;
struct widget *pImpr = (struct widget *)pWidget->data.ptr;
struct widget *pImpr = (struct widget *)pwidget->data.ptr;
imp = pImpr->data.cont->id0;
total_count = pImpr->data.cont->id1;
......
/**********************************************************************//**
User interacted with Cancel button of the improvement selling dialog.
**************************************************************************/
static int cancel_sell_impr_callback(struct widget *pWidget)
static int cancel_sell_impr_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pEconomy_Sell_Dlg) {
......
/**********************************************************************//**
Open improvement selling dialog.
**************************************************************************/
static int popup_sell_impr_callback(struct widget *pWidget)
static int popup_sell_impr_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
int imp, total_count ,count = 0, gold = 0;
......
return 1;
}
set_wstate(pWidget, FC_WS_NORMAL);
set_wstate(pwidget, FC_WS_NORMAL);
selected_widget = NULL;
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
pEconomy_Sell_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
imp = pWidget->data.cont->id0;
total_count = pWidget->data.cont->id1;
imp = pwidget->data.cont->id0;
total_count = pwidget->data.cont->id1;
value = impr_sell_gold(improvement_by_number(imp));
city_list_iterate(client.conn.playing->cities, pCity) {
......
pBuf->action = ok_sell_impr_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->data.ptr = (void *)pWidget;
pBuf->data.ptr = (void *)pwidget;
add_to_gui_list(ID_BUTTON, pBuf);
pBuf->size.w = MAX(pBuf->size.w, pBuf->next->size.w);
......
/**********************************************************************//**
Close research target changing dialog.
**************************************************************************/
static int exit_change_tech_dlg_callback(struct widget *pWidget)
static int exit_change_tech_dlg_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
if (pChangeTechDlg) {
......
FC_FREE(pChangeTechDlg->pScroll);
FC_FREE(pChangeTechDlg);
enable_science_dialog();
if (pWidget) {
if (pwidget) {
flush_dirty();
}
}
......
/**********************************************************************//**
User interacted with button of specific Tech.
**************************************************************************/
static int change_research_callback(struct widget *pWidget)
static int change_research_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
dsend_packet_player_research(&client.conn, (MAX_ID - pWidget->ID));
dsend_packet_player_research(&client.conn, (MAX_ID - pwidget->ID));
exit_change_tech_dlg_callback(NULL);
} else if (main_data.event.button.button == SDL_BUTTON_MIDDLE) {
popup_tech_info((MAX_ID - pWidget->ID));
popup_tech_info((MAX_ID - pwidget->ID));
}
return -1;
......
/**********************************************************************//**
User chose spesic tech as research goal.
**************************************************************************/
static int change_research_goal_callback(struct widget *pWidget)
static int change_research_goal_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
dsend_packet_player_tech_goal(&client.conn, (MAX_ID - pWidget->ID));
dsend_packet_player_tech_goal(&client.conn, (MAX_ID - pwidget->ID));
exit_change_tech_dlg_callback(NULL);
......
* there may be a better way to do this? --dwp */
real_science_report_dialog_update(NULL);
} else if (main_data.event.button.button == SDL_BUTTON_MIDDLE) {
popup_tech_info((MAX_ID - pWidget->ID));
popup_tech_info((MAX_ID - pwidget->ID));
}
return -1;
......
/**********************************************************************//**
Open research target changing dialog.
**************************************************************************/
static int popup_change_research_dialog_callback(struct widget *pWidget)
static int popup_change_research_dialog_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
set_wstate(pWidget, FC_WS_NORMAL);
set_wstate(pwidget, FC_WS_NORMAL);
selected_widget = NULL;
widget_redraw(pWidget);
widget_flush(pWidget);
widget_redraw(pwidget);
widget_flush(pwidget);
popup_change_research_dialog();
}
......
/**********************************************************************//**
Open research goal changing dialog.
**************************************************************************/
static int popup_change_research_goal_dialog_callback(struct widget *pWidget)
static int popup_change_research_goal_dialog_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
set_wstate(pWidget, FC_WS_NORMAL);
set_wstate(pwidget, FC_WS_NORMAL);
selected_widget = NULL;
widget_redraw(pWidget);
widget_flush(pWidget);
widget_redraw(pwidget);
widget_flush(pwidget);
popup_change_research_goal_dialog();
}
......
/**********************************************************************//**
Close science dialog.
**************************************************************************/
static int popdown_science_dialog_callback(struct widget *pWidget)
static int popdown_science_dialog_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
science_report_dialog_popdown();
......
void science_report_dialog_popup(bool raise)
{
const struct research *presearch;
struct widget *pWidget, *pwindow;
struct widget *pwidget, *pwindow;
struct widget *pChangeResearchButton;
struct widget *pChangeResearchGoalButton;
struct widget *pExitButton;
......
presearch = research_get(client_player());
/* disable research button */
pWidget = get_research_widget();
set_wstate(pWidget, FC_WS_DISABLED);
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
pwidget = get_research_widget();
set_wstate(pwidget, FC_WS_DISABLED);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
pScienceDlg = fc_calloc(1, sizeof(struct SMALL_DLG));
client/gui-sdl2/spaceshipdlg.c
/**********************************************************************//**
User interacted with spaceship dialog close button.
**************************************************************************/
static int exit_space_dialog_callback(struct widget *pWidget)
static int exit_space_dialog_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_spaceship_dialog(pWidget->data.player);
popdown_spaceship_dialog(pwidget->data.player);
flush_dirty();
}
......
/**********************************************************************//**
User interacted with spaceship dialog launch button.
**************************************************************************/
static int launch_spaceship_callback(struct widget *pWidget)
static int launch_spaceship_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
send_packet_spaceship_launch(&client.conn);
client/gui-sdl2/widget.c
int x, int y)
{
SDL_Rect area = {0, 0, 0, 0};
struct widget *pWidget;
struct widget *pwidget;
pWidget = pStartWidget ? pStartWidget : pBeginMainWidgetList;
pwidget = pStartWidget ? pStartWidget : pBeginMainWidgetList;
while (pWidget) {
area.x = pWidget->dst->dest_rect.x + pWidget->size.x;
area.y = pWidget->dst->dest_rect.y + pWidget->size.y;
area.w = pWidget->size.w;
area.h = pWidget->size.h;
while (pwidget) {
area.x = pwidget->dst->dest_rect.x + pwidget->size.x;
area.y = pwidget->dst->dest_rect.y + pwidget->size.y;
area.w = pwidget->size.w;
area.h = pwidget->size.h;
if (is_in_rect_area(x, y, area)
&& !((get_wflags(pWidget) & WF_HIDDEN) == WF_HIDDEN)) {
return (struct widget *) pWidget;
&& !((get_wflags(pwidget) & WF_HIDDEN) == WF_HIDDEN)) {
return (struct widget *) pwidget;
}
pWidget = pWidget->next;
pwidget = pwidget->next;
}
return NULL;
......
struct widget *find_next_widget_for_key(struct widget *pStartWidget,
SDL_Keysym key)
{
struct widget *pWidget;
struct widget *pwidget;
pWidget = pStartWidget ? pStartWidget : pBeginMainWidgetList;
pwidget = pStartWidget ? pStartWidget : pBeginMainWidgetList;
key.mod &= ~(KMOD_NUM | KMOD_CAPS);
while (pWidget) {
if ((pWidget->key == key.sym
|| (pWidget->key == SDLK_RETURN && key.sym == SDLK_KP_ENTER)
|| (pWidget->key == SDLK_KP_ENTER && key.sym == SDLK_RETURN))
&& ((pWidget->mod & key.mod) || (pWidget->mod == key.mod))) {
if (!((get_wstate(pWidget) == FC_WS_DISABLED)
|| ((get_wflags(pWidget) & WF_HIDDEN) == WF_HIDDEN))) {
return (struct widget *) pWidget;
while (pwidget) {
if ((pwidget->key == key.sym
|| (pwidget->key == SDLK_RETURN && key.sym == SDLK_KP_ENTER)
|| (pwidget->key == SDLK_KP_ENTER && key.sym == SDLK_RETURN))
&& ((pwidget->mod & key.mod) || (pwidget->mod == key.mod))) {
if (!((get_wstate(pwidget) == FC_WS_DISABLED)
|| ((get_wflags(pwidget) & WF_HIDDEN) == WF_HIDDEN))) {
return (struct widget *) pwidget;
}
}
pWidget = pWidget->next;
pwidget = pwidget->next;
}
return NULL;
......
Function normal return Widget ID.
NOTE: NOZERO return of this function deterninate exit of
MAIN_SDL_GAME_LOOP
if ( pWidget->action )
if ( pWidget->action(pWidget) ) ID = 0;
if ( pwidget->action )
if ( pwidget->action(pwidget) ) ID = 0;
if widget callback function return = 0 then return NOZERO
I default return (-1) from Widget callback functions.
**************************************************************************/
Uint16 widget_pressed_action(struct widget *pWidget)
Uint16 widget_pressed_action(struct widget *pwidget)
{
Uint16 ID = 0;
if (!pWidget) {
if (!pwidget) {
return 0;
}
......
FREESURFACE(info_label);
}
switch (get_wtype(pWidget)) {
switch (get_wtype(pwidget)) {
case WT_TI_BUTTON:
case WT_I_BUTTON:
case WT_ICON:
case WT_ICON2:
if (PRESSED_EVENT(main_data.event)) {
set_wstate(pWidget, FC_WS_PRESSED);
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
set_wstate(pwidget, FC_WS_PRESSED);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
flush_dirty();
set_wstate(pWidget, FC_WS_SELECTED);
set_wstate(pwidget, FC_WS_SELECTED);
SDL_Delay(300);
}
ID = pWidget->ID;
if (pWidget->action) {
if (pWidget->action(pWidget)) {
ID = pwidget->ID;
if (pwidget->action) {
if (pwidget->action(pwidget)) {
ID = 0;
}
}
......
case WT_EDIT:
{
if (PRESSED_EVENT(main_data.event)) {
bool ret, loop = (get_wflags(pWidget) & WF_EDIT_LOOP);
bool ret, loop = (get_wflags(pwidget) & WF_EDIT_LOOP);
enum Edit_Return_Codes change;
do {
ret = FALSE;
change = edit_field(pWidget);
change = edit_field(pwidget);
if (change != ED_FORCE_EXIT && (!loop || change != ED_RETURN)) {
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
flush_dirty();
}
if (change != ED_FORCE_EXIT && change != ED_ESC && pWidget->action) {
if (pWidget->action(pWidget)) {
if (change != ED_FORCE_EXIT && change != ED_ESC && pwidget->action) {
if (pwidget->action(pwidget)) {
ID = 0;
}
}
......
case WT_VSCROLLBAR:
case WT_HSCROLLBAR:
if (PRESSED_EVENT(main_data.event)) {
set_wstate(pWidget, FC_WS_PRESSED);
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
set_wstate(pwidget, FC_WS_PRESSED);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
flush_dirty();
}
ID = pWidget->ID;
if (pWidget->action) {
if (pWidget->action(pWidget)) {
ID = pwidget->ID;
if (pwidget->action) {
if (pwidget->action(pwidget)) {
ID = 0;
}
}
......
case WT_CHECKBOX:
case WT_TCHECKBOX:
if (PRESSED_EVENT(main_data.event)) {
set_wstate(pWidget, FC_WS_PRESSED);
widget_redraw(pWidget);
widget_mark_dirty(pWidget);
set_wstate(pwidget, FC_WS_PRESSED);
widget_redraw(pwidget);
widget_mark_dirty(pwidget);
flush_dirty();
set_wstate(pWidget, FC_WS_SELECTED);
toggle_checkbox(pWidget);
set_wstate(pwidget, FC_WS_SELECTED);
toggle_checkbox(pwidget);
SDL_Delay(300);
}
ID = pWidget->ID;
if (pWidget->action) {
if (pWidget->action(pWidget)) {
ID = pwidget->ID;
if (pwidget->action) {
if (pwidget->action(pwidget)) {
ID = 0;
}
}
break;
case WT_COMBO:
if (PRESSED_EVENT(main_data.event)) {
set_wstate(pWidget, FC_WS_PRESSED);
combo_popup(pWidget);
set_wstate(pwidget, FC_WS_PRESSED);
combo_popup(pwidget);
} else {
combo_popdown(pWidget);
combo_popdown(pwidget);
}
break;
default:
ID = pWidget->ID;
if (pWidget->action) {
if (pWidget->action(pWidget) != 0) {
ID = pwidget->ID;
if (pwidget->action) {
if (pwidget->action(pwidget) != 0) {
ID = 0;
}
}
......
/**********************************************************************//**
Select widget. Redraw this widget;
**************************************************************************/
void widget_selected_action(struct widget *pWidget)
void widget_selected_action(struct widget *pwidget)
{
if (!pWidget || pWidget == selected_widget) {
if (!pwidget || pwidget == selected_widget) {
return;
}
......
unselect_widget_action();
}
set_wstate(pWidget, FC_WS_SELECTED);
set_wstate(pwidget, FC_WS_SELECTED);
pWidget->select(pWidget);
pwidget->select(pwidget);
selected_widget = pWidget;
selected_widget = pwidget;
if (get_wflags(pWidget) & WF_WIDGET_HAS_INFO_LABEL) {
if (get_wflags(pwidget) & WF_WIDGET_HAS_INFO_LABEL) {
widget_info_counter = 1;
}
}
......
SDL_Surface *pText;
SDL_Rect srcrect, dstrect;
SDL_Color color;
struct widget *pWidget = selected_widget;
struct widget *pwidget = selected_widget;
if (!pWidget || !pWidget->info_label) {
if (!pwidget || !pwidget->info_label) {
return;
}
if (!info_label) {
pInfo_Area = fc_calloc(1, sizeof(SDL_Rect));
color = pWidget-