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 #902483 ยป 0040-sdl2-Rename-p-Button-to-adhere-with-coding-style.patch

Marko Lindqvist, 2020-12-03 05:44 AM

View differences:

client/gui-sdl2/chatline.c
struct widget *begin_widget_list;
struct widget *end_widget_list;
struct widget *start_button;
struct widget *pSelectNationButton;
struct widget *pLoadGameButton;
struct widget *select_nation_button;
struct widget *load_game_button;
struct widget *pConfigure;
struct widget *pBackButton;
struct widget *back_button;
struct widget *pedit;
int text_width;
int active;
......
FC_FREE(pLoadDialog);
/* enable buttons */
set_wstate(conn_dlg->pBackButton, FC_WS_NORMAL);
widget_redraw(conn_dlg->pBackButton);
widget_mark_dirty(conn_dlg->pBackButton);
set_wstate(conn_dlg->pLoadGameButton, FC_WS_NORMAL);
widget_redraw(conn_dlg->pLoadGameButton);
widget_mark_dirty(conn_dlg->pLoadGameButton);
set_wstate(conn_dlg->back_button, FC_WS_NORMAL);
widget_redraw(conn_dlg->back_button);
widget_mark_dirty(conn_dlg->back_button);
set_wstate(conn_dlg->load_game_button, FC_WS_NORMAL);
widget_redraw(conn_dlg->load_game_button);
widget_mark_dirty(conn_dlg->load_game_button);
set_wstate(conn_dlg->start_button, FC_WS_NORMAL);
widget_redraw(conn_dlg->start_button);
widget_mark_dirty(conn_dlg->start_button);
......
static void popup_load_game_dialog(void)
{
struct widget *pwindow;
struct widget *pCloseButton;
struct widget *close_button;
struct widget *pFilenameLabel = NULL;
struct widget *pFirstLabel = NULL;
struct widget *lastLabel = NULL;
......
}
/* disable buttons */
set_wstate(conn_dlg->pBackButton, FC_WS_DISABLED);
widget_redraw(conn_dlg->pBackButton);
widget_mark_dirty(conn_dlg->pBackButton);
set_wstate(conn_dlg->pLoadGameButton, FC_WS_DISABLED);
widget_redraw(conn_dlg->pLoadGameButton);
widget_mark_dirty(conn_dlg->pLoadGameButton);
set_wstate(conn_dlg->pSelectNationButton, FC_WS_DISABLED);
widget_redraw(conn_dlg->pSelectNationButton);
widget_mark_dirty(conn_dlg->pSelectNationButton);
set_wstate(conn_dlg->back_button, FC_WS_DISABLED);
widget_redraw(conn_dlg->back_button);
widget_mark_dirty(conn_dlg->back_button);
set_wstate(conn_dlg->load_game_button, FC_WS_DISABLED);
widget_redraw(conn_dlg->load_game_button);
widget_mark_dirty(conn_dlg->load_game_button);
set_wstate(conn_dlg->select_nation_button, FC_WS_DISABLED);
widget_redraw(conn_dlg->select_nation_button);
widget_mark_dirty(conn_dlg->select_nation_button);
set_wstate(conn_dlg->start_button, FC_WS_DISABLED);
widget_redraw(conn_dlg->start_button);
widget_mark_dirty(conn_dlg->start_button);
......
title->style |= TTF_STYLE_BOLD;
pwindow = create_window_skeleton(NULL, title, 0);
pwindow->action = move_load_game_dlg_callback;
pwindow->action = move_load_game_dlg_callback;
set_wstate(pwindow, FC_WS_NORMAL);
add_to_gui_list(ID_WINDOW, pwindow);
......
area = pwindow->area;
/* close button */
pCloseButton = create_themeicon(current_theme->Small_CANCEL_Icon, pwindow->dst,
close_button = create_themeicon(current_theme->Small_CANCEL_Icon, pwindow->dst,
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
pCloseButton->info_label = create_utf8_from_char(_("Close Dialog (Esc)"),
close_button->info_label = create_utf8_from_char(_("Close Dialog (Esc)"),
adj_font(12));
pCloseButton->action = exit_load_dlg_callback;
set_wstate(pCloseButton, FC_WS_NORMAL);
pCloseButton->key = SDLK_ESCAPE;
close_button->action = exit_load_dlg_callback;
set_wstate(close_button, FC_WS_NORMAL);
close_button->key = SDLK_ESCAPE;
add_to_gui_list(ID_BUTTON, pCloseButton);
add_to_gui_list(ID_BUTTON, close_button);
area.w += pCloseButton->size.w;
area.w += close_button->size.w;
pLoadDialog->begin_widget_list = pCloseButton;
pLoadDialog->begin_widget_list = close_button;
/* create scrollbar */
scrollbar_width = create_vertical_scrollbar(pLoadDialog, 1, 20, TRUE, TRUE);
......
del_widget_pointer_from_gui_list(pFilenameLabel);
if (pFilenameLabel == pFirstLabel) {
add_widget_to_vertical_scroll_widget_list(pLoadDialog,
pFilenameLabel, pCloseButton,
pFilenameLabel, close_button,
FALSE,
area.x + 1,
area.y + adj_size(2));
......
(main_window_width() - pwindow->size.w) / 2,
(main_window_height() - pwindow->size.h) / 2);
widget_set_position(pCloseButton,
area.x + area.w - pCloseButton->size.w - 1,
widget_set_position(close_button,
area.x + area.w - close_button->size.w - 1,
pwindow->size.y + adj_size(2));
/* FIXME: the scrollbar already got a background saved in
......
static int load_game_callback(struct widget *pwidget)
{
if (PRESSED_EVENT(main_data.event)) {
/* set_wstate(conn_dlg->pLoadGameButton, FC_WS_NORMAL);
* widget_redraw(conn_dlg->pLoadGameButton);
/* set_wstate(conn_dlg->load_game_button, FC_WS_NORMAL);
* widget_redraw(conn_dlg->load_game_button);
* flush_dirty(); */
popup_load_game_dialog();
}
......
SDL_Color window_bg_color = {255, 255, 255, 96};
struct widget *pwindow = NULL, *buf = NULL, *pLabel = NULL;
struct widget* pBackButton = NULL;
struct widget* back_button = NULL;
struct widget *start_game_button = NULL;
struct widget *pSelectNationButton = NULL;
/* struct widget *pServerSettingsButton = NULL;*/
struct widget *select_nation_button = NULL;
/* struct widget *server_settings_button = NULL;*/
utf8_str *pstr = NULL;
int n;
SDL_Rect area;
......
_("Back"), adj_font(12), 0);
buf->size.x = adj_size(10);
buf->size.y = pwindow->size.h - adj_size(10) - buf->size.h;
conn_dlg->pBackButton = buf;
conn_dlg->back_button = buf;
buf->action = disconnect_conn_callback;
set_wstate(buf, FC_WS_NORMAL);
buf->key = SDLK_ESCAPE;
add_to_gui_list(ID_BUTTON, buf);
pBackButton = buf;
back_button = buf;
buf = create_themeicon_button_from_chars(current_theme->OK_Icon, pwindow->dst,
_("Start"), adj_font(12), 0);
buf->size.x = pwindow->size.w - adj_size(10) - buf->size.w;
buf->size.y = pBackButton->size.y;
buf->size.y = back_button->size.y;
conn_dlg->start_button = buf;
buf->action = start_game_callback;
set_wstate(buf, FC_WS_NORMAL);
......
buf->size.h = start_game_button->size.h;
buf->size.x = start_game_button->size.x - adj_size(10) - buf->size.w;
buf->size.y = start_game_button->size.y;
conn_dlg->pSelectNationButton = buf;
conn_dlg->select_nation_button = buf;
buf->action = select_nation_callback;
set_wstate(buf, FC_WS_NORMAL);
add_to_gui_list(ID_BUTTON, buf);
pSelectNationButton = buf;
select_nation_button = buf;
buf = create_themeicon_button_from_chars(NULL, pwindow->dst,
_("Load Game"), adj_font(12), 0);
buf->size.h = pSelectNationButton->size.h;
buf->size.x = pSelectNationButton->size.x - adj_size(10) - buf->size.w;
buf->size.y = pSelectNationButton->size.y;
conn_dlg->pLoadGameButton = buf;
buf->size.h = select_nation_button->size.h;
buf->size.x = select_nation_button->size.x - adj_size(10) - buf->size.w;
buf->size.y = select_nation_button->size.y;
conn_dlg->load_game_button = buf;
buf->action = load_game_callback;
set_wstate(buf, FC_WS_NORMAL);
add_to_gui_list(ID_BUTTON, buf);
......
buf = create_themeicon_button_from_chars(NULL, pwindow->dst,
_("Server Settings"),
adj_font(12), 0);
buf->size.h = pSelectNationButton->size.h;
buf->size.x = pSelectNationButton->size.x - adj_size(10) - buf->size.w;
buf->size.y = pSelectNationButton->size.y;
buf->size.h = select_nation_button->size.h;
buf->size.x = select_nation_button->size.x - adj_size(10) - buf->size.w;
buf->size.y = select_nation_button->size.y;
conn_dlg->pConfigure = buf;
buf->action = server_config_callback;
set_wstate(buf, FC_WS_DISABLED);
add_to_gui_list(ID_BUTTON, buf);
pServerSettingsButton = buf;
server_settings_button = buf;
#endif
/* not implemented yet */
client/gui-sdl2/dialogs.c
/**********************************************************************//**
User selected nation.
**************************************************************************/
static int nation_button_callback(struct widget *pNationButton)
static int nation_button_callback(struct widget *nation_button)
{
set_wstate(pNationButton, FC_WS_SELECTED);
selected_widget = pNationButton;
set_wstate(nation_button, FC_WS_SELECTED);
selected_widget = nation_button;
if (PRESSED_EVENT(main_data.event)) {
struct NAT *setup = (struct NAT *)(nation_dlg->end_widget_list->data.ptr);
if (setup->nation == MAX_ID - pNationButton->id) {
widget_redraw(pNationButton);
widget_flush(pNationButton);
if (setup->nation == MAX_ID - nation_button->id) {
widget_redraw(nation_button);
widget_flush(nation_button);
return -1;
}
setup->nation = MAX_ID - pNationButton->id;
setup->nation = MAX_ID - nation_button->id;
change_nation_label();
......
utf8_str *pstr;
SDL_Surface *text;
SDL_Rect area, area2;
struct nation_type *pNation = nation_by_number(MAX_ID - pNationButton->id);
struct nation_type *pNation = nation_by_number(MAX_ID - nation_button->id);
widget_redraw(pNationButton);
widget_mark_dirty(pNationButton);
widget_redraw(nation_button);
widget_mark_dirty(nation_button);
if (!help_dlg) {
help_dlg = fc_calloc(1, sizeof(struct small_dialog));
client/gui-sdl2/gui_tilespec.c
load_theme_surface(buf, FR_Right, "theme.right_frame");
load_theme_surface(buf, FR_Top, "theme.top_frame");
load_theme_surface(buf, FR_Bottom, "theme.bottom_frame");
load_theme_surface(buf, Button, "theme.button");
load_theme_surface(buf, button, "theme.button");
load_theme_surface(buf, Edit, "theme.edit");
load_theme_surface(buf, CBOX_Sell_Icon, "theme.sbox");
load_theme_surface(buf, CBOX_Unsell_Icon, "theme.ubox");
client/gui-sdl2/gui_tilespec.h
SDL_Surface *FR_Bottom;
/* Button */
SDL_Surface *Button;
SDL_Surface *button;
/* Edit */
SDL_Surface *Edit;
client/gui-sdl2/helpdlg.c
struct techs_buttons {
struct widget *pTargets[6], *pSub_Targets[6];
struct widget *pRequirementButton[2], *pSub_Req[4];
struct widget *requirement_button[2], *pSub_Req[4];
struct widget *dock;
bool show_tree;
bool show_full_tree;
};
struct units_buttons {
struct widget *pObsoleteByButton;
struct widget *pRequirementButton;
struct widget *obsolete_by_button;
struct widget *requirement_button;
struct widget *dock;
};
......
SDL_Color bg_color = {255, 255, 255, 128};
struct widget *pwindow;
struct units_buttons *store;
struct widget *pCloseButton = NULL;
struct widget *pListToggleButton = NULL;
struct widget *close_button = NULL;
struct widget *list_toggle_button = NULL;
struct widget *improvement_button = NULL;
struct widget *pImprNameLabel = NULL;
struct widget *pCostLabel = NULL;
......
/* ------------------ */
/* close button */
pCloseButton = create_themeicon(current_theme->Small_CANCEL_Icon, pwindow->dst,
close_button = create_themeicon(current_theme->Small_CANCEL_Icon, pwindow->dst,
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
pCloseButton->info_label =
close_button->info_label =
create_utf8_from_char(_("Close Dialog (Esc)"), adj_font(12));
pCloseButton->action = exit_help_dlg_callback;
set_wstate(pCloseButton, FC_WS_NORMAL);
pCloseButton->key = SDLK_ESCAPE;
close_button->action = exit_help_dlg_callback;
set_wstate(close_button, FC_WS_NORMAL);
close_button->key = SDLK_ESCAPE;
add_to_gui_list(ID_BUTTON, pCloseButton);
add_to_gui_list(ID_BUTTON, close_button);
/* ------------------ */
dock = pCloseButton;
dock = close_button;
pstr = create_utf8_str(NULL, 0, adj_font(10));
pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
......
FREESURFACE(background_tmpl);
help_dlg->end_active_widget_list = dock->prev;
help_dlg->begin_widget_list = improvement_button ? improvement_button : pCloseButton;
help_dlg->begin_widget_list = improvement_button ? improvement_button : close_button;
help_dlg->begin_active_widget_list = help_dlg->begin_widget_list;
if (impr_type_count > 10) {
......
}
/* toggle techs list button */
pListToggleButton = create_themeicon_button_from_chars(current_theme->UP_Icon,
list_toggle_button = create_themeicon_button_from_chars(current_theme->UP_Icon,
pwindow->dst,
_("Improvements"),
adj_font(10), 0);
#if 0
pListToggleButton->action = toggle_full_tree_mode_in_help_dlg_callback;
list_toggle_button->action = toggle_full_tree_mode_in_help_dlg_callback;
if (store->show_tree) {
set_wstate(pListToggleButton, FC_WS_NORMAL);
set_wstate(list_toggle_button, FC_WS_NORMAL);
}
#endif
widget_resize(pListToggleButton, adj_size(160), adj_size(15));
pListToggleButton->string_utf8->fgcol = *get_theme_color(COLOR_THEME_HELPDLG_TEXT);
widget_resize(list_toggle_button, adj_size(160), adj_size(15));
list_toggle_button->string_utf8->fgcol = *get_theme_color(COLOR_THEME_HELPDLG_TEXT);
add_to_gui_list(ID_BUTTON, pListToggleButton);
add_to_gui_list(ID_BUTTON, list_toggle_button);
dock = pListToggleButton;
dock = list_toggle_button;
store->dock = dock;
} else {
created = FALSE;
......
}
widget_add_as_prev(pRequirementLabel2, dock);
dock = pRequirementLabel2;
store->pRequirementButton = pRequirementLabel2;
store->requirement_button = pRequirementLabel2;
/* obsolete by */
pObsoleteByLabel = create_iconlabel_from_chars(NULL, pwindow->dst,
......
}
widget_add_as_prev(pObsoleteByLabel2, dock);
dock = pObsoleteByLabel2;
store->pObsoleteByButton = pObsoleteByLabel2;
store->obsolete_by_button = pObsoleteByLabel2;
/* helptext */
start_x = (area.x + 1 + scrollbar_width + help_dlg->end_active_widget_list->size.w + adj_size(20));
......
(main_window_height() - pwindow->size.h) / 2);
/* exit button */
pCloseButton = pwindow->prev;
widget_set_position(pCloseButton,
area.x + area.w - pCloseButton->size.w - 1,
close_button = pwindow->prev;
widget_set_position(close_button,
area.x + area.w - close_button->size.w - 1,
pwindow->size.y + adj_size(2));
/* list toggle button */
pListToggleButton = store->dock;
widget_set_position(pListToggleButton, area.x, area.y);
list_toggle_button = store->dock;
widget_set_position(list_toggle_button, area.x, area.y);
/* list entries */
h = setup_vertical_widgets_position(1, area.x + scrollbar_width,
area.y + pListToggleButton->size.h, 0, 0,
area.y + list_toggle_button->size.h, 0, 0,
help_dlg->begin_active_widget_list,
help_dlg->end_active_widget_list);
/* scrollbar */
if (help_dlg->scroll) {
setup_vertical_scrollbar_area(help_dlg->scroll,
area.x, area.y + pListToggleButton->size.h,
area.x, area.y + list_toggle_button->size.h,
h, FALSE);
}
}
......
start_y += pCostLabel->size.h;
}
pRequirementLabel = store->pRequirementButton->next;
pRequirementLabel = store->requirement_button->next;
widget_set_position(pRequirementLabel, start_x, start_y);
pRequirementLabel2 = store->pRequirementButton;
pRequirementLabel2 = store->requirement_button;
widget_set_position(pRequirementLabel2,
pRequirementLabel->size.x + pRequirementLabel->size.w + adj_size(5),
start_y);
if (store->pObsoleteByButton) {
pObsoleteByLabel = store->pObsoleteByButton->next;
if (store->obsolete_by_button) {
pObsoleteByLabel = store->obsolete_by_button->next;
widget_set_position(pObsoleteByLabel,
pRequirementLabel2->size.x + pRequirementLabel2->size.w + adj_size(10),
start_y);
pObsoleteByLabel2 = store->pObsoleteByButton;
pObsoleteByLabel2 = store->obsolete_by_button;
widget_set_position(pObsoleteByLabel2,
pObsoleteByLabel->size.x + pObsoleteByLabel->size.w + adj_size(5),
start_y);
......
SDL_Color bg_color = {255, 255, 255, 128};
struct widget *pwindow;
struct units_buttons *store;
struct widget *pCloseButton = NULL;
struct widget *pListToggleButton = NULL;
struct widget *close_button = NULL;
struct widget *list_toggle_button = NULL;
struct widget *unit_button = NULL;
struct widget *unit_name_label = NULL;
struct widget *unit_info_label = NULL;
......
/* ------------------ */
/* close button */
pCloseButton = create_themeicon(current_theme->Small_CANCEL_Icon, pwindow->dst,
close_button = create_themeicon(current_theme->Small_CANCEL_Icon, pwindow->dst,
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
pCloseButton->info_label =
close_button->info_label =
create_utf8_from_char(_("Close Dialog (Esc)"), adj_font(12));
pCloseButton->action = exit_help_dlg_callback;
set_wstate(pCloseButton, FC_WS_NORMAL);
pCloseButton->key = SDLK_ESCAPE;
close_button->action = exit_help_dlg_callback;
set_wstate(close_button, FC_WS_NORMAL);
close_button->key = SDLK_ESCAPE;
add_to_gui_list(ID_BUTTON, pCloseButton);
add_to_gui_list(ID_BUTTON, close_button);
/* ------------------ */
dock = pCloseButton;
dock = close_button;
/* --- create scrollable unit list on the left side ---*/
......
FREESURFACE(background_tmpl);
help_dlg->end_active_widget_list = dock->prev;
help_dlg->begin_widget_list = unit_button ? unit_button : pCloseButton;
help_dlg->begin_widget_list = unit_button ? unit_button : close_button;
help_dlg->begin_active_widget_list = help_dlg->begin_widget_list;
if (utype_count > 10) {
......
}
/* toggle techs list button */
pListToggleButton = create_themeicon_button_from_chars(current_theme->UP_Icon,
list_toggle_button = create_themeicon_button_from_chars(current_theme->UP_Icon,
pwindow->dst, _("Units"), adj_font(10), 0);
#if 0
pListToggleButton->action = toggle_full_tree_mode_in_help_dlg_callback;
list_toggle_button->action = toggle_full_tree_mode_in_help_dlg_callback;
if (store->show_tree) {
set_wstate(pListToggleButton, FC_WS_NORMAL);
set_wstate(list_toggle_button, FC_WS_NORMAL);
}
#endif
widget_resize(pListToggleButton, adj_size(160), adj_size(15));
pListToggleButton->string_utf8->fgcol = *get_theme_color(COLOR_THEME_HELPDLG_TEXT);
widget_resize(list_toggle_button, adj_size(160), adj_size(15));
list_toggle_button->string_utf8->fgcol = *get_theme_color(COLOR_THEME_HELPDLG_TEXT);
add_to_gui_list(ID_BUTTON, pListToggleButton);
add_to_gui_list(ID_BUTTON, list_toggle_button);
dock = pListToggleButton;
dock = list_toggle_button;
store->dock = dock;
} else {
created = FALSE;
......
}
widget_add_as_prev(pRequirementLabel2, dock);
dock = pRequirementLabel2;
store->pRequirementButton = pRequirementLabel2;
store->requirement_button = pRequirementLabel2;
/* obsolete by */
pObsoleteByLabel = create_iconlabel_from_chars(NULL, pwindow->dst,
......
}
widget_add_as_prev(pObsoleteByLabel2, dock);
dock = pObsoleteByLabel2;
store->pObsoleteByButton = pObsoleteByLabel2;
store->obsolete_by_button = pObsoleteByLabel2;
/* helptext */
start_x = (area.x + 1 + scrollbar_width + help_dlg->active_widget_list->size.w + adj_size(20));
......
(main_window_height() - pwindow->size.h) / 2);
/* exit button */
pCloseButton = pwindow->prev;
widget_set_position(pCloseButton,
area.x + area.w - pCloseButton->size.w - 1,
close_button = pwindow->prev;
widget_set_position(close_button,
area.x + area.w - close_button->size.w - 1,
pwindow->size.y + adj_size(2));
/* list toggle button */
pListToggleButton = store->dock;
widget_set_position(pListToggleButton, area.x, area.y);
list_toggle_button = store->dock;
widget_set_position(list_toggle_button, area.x, area.y);
/* list entries */
h = setup_vertical_widgets_position(1, area.x + scrollbar_width,
area.y + pListToggleButton->size.h, 0, 0,
area.y + list_toggle_button->size.h, 0, 0,
help_dlg->begin_active_widget_list,
help_dlg->end_active_widget_list);
/* scrollbar */
if (help_dlg->scroll) {
setup_vertical_scrollbar_area(help_dlg->scroll,
area.x, area.y + pListToggleButton->size.h,
area.x, area.y + list_toggle_button->size.h,
h, FALSE);
}
}
......
start_y += unit_info_label->size.h;
pRequirementLabel = store->pRequirementButton->next;
pRequirementLabel = store->requirement_button->next;
widget_set_position(pRequirementLabel, start_x, start_y);
pRequirementLabel2 = store->pRequirementButton;
pRequirementLabel2 = store->requirement_button;
widget_set_position(pRequirementLabel2,
pRequirementLabel->size.x + pRequirementLabel->size.w + adj_size(5),
start_y);
pObsoleteByLabel = store->pObsoleteByButton->next;
pObsoleteByLabel = store->obsolete_by_button->next;
widget_set_position(pObsoleteByLabel,
pRequirementLabel2->size.x + pRequirementLabel2->size.w + adj_size(10),
start_y);
pObsoleteByLabel2 = store->pObsoleteByButton;
pObsoleteByLabel2 = store->obsolete_by_button;
widget_set_position(pObsoleteByLabel2,
pObsoleteByLabel->size.x + pObsoleteByLabel->size.w + adj_size(5),
start_y);
......
start_y += pObsoleteByLabel2->size.h + adj_size(20);
if (text) {
pHelptextLabel = store->pObsoleteByButton->prev;
pHelptextLabel = store->obsolete_by_button->prev;
widget_set_position(pHelptextLabel, start_x, start_y);
}
......
count = i;
i = 0;
while (i < 2 && store->pRequirementButton[i]) {
tech = MAX_ID - store->pRequirementButton[i]->id;
while (i < 2 && store->requirement_button[i]) {
tech = MAX_ID - store->requirement_button[i]->id;
/*find Sub_Req's */
if (i) {
......
}
/* draw main Arrow */
create_line(store->pRequirementButton[i]->dst->surface,
store->pRequirementButton[i]->size.x + store->pRequirementButton[i]->size.w,
store->pRequirementButton[i]->size.y + store->pRequirementButton[i]->size.h / 2,
create_line(store->requirement_button[i]->dst->surface,
store->requirement_button[i]->size.x + store->requirement_button[i]->size.w,
store->requirement_button[i]->size.y + store->requirement_button[i]->size.h / 2,
ptech->size.x,
store->pRequirementButton[i]->size.y + store->pRequirementButton[i]->size.h / 2,
store->requirement_button[i]->size.y + store->requirement_button[i]->size.h / 2,
line_color);
/* Draw Sub_Req arrows */
if (pSub0 || pSub1) {
create_line(store->pRequirementButton[i]->dst->surface,
store->pRequirementButton[i]->size.x - adj_size(10),
store->pRequirementButton[i]->size.y + store->pRequirementButton[i]->size.h / 2,
store->pRequirementButton[i]->size.x ,
store->pRequirementButton[i]->size.y + store->pRequirementButton[i]->size.h / 2,
create_line(store->requirement_button[i]->dst->surface,
store->requirement_button[i]->size.x - adj_size(10),
store->requirement_button[i]->size.y + store->requirement_button[i]->size.h / 2,
store->requirement_button[i]->size.x ,
store->requirement_button[i]->size.y + store->requirement_button[i]->size.h / 2,
line_color);
}
if (pSub0) {
create_line(store->pRequirementButton[i]->dst->surface,
store->pRequirementButton[i]->size.x - adj_size(10),
create_line(store->requirement_button[i]->dst->surface,
store->requirement_button[i]->size.x - adj_size(10),
pSub0->size.y + pSub0->size.h / 2,
store->pRequirementButton[i]->size.x - adj_size(10),
store->pRequirementButton[i]->size.y + store->pRequirementButton[i]->size.h / 2,
store->requirement_button[i]->size.x - adj_size(10),
store->requirement_button[i]->size.y + store->requirement_button[i]->size.h / 2,
line_color);
create_line(store->pRequirementButton[i]->dst->surface,
create_line(store->requirement_button[i]->dst->surface,
pSub0->size.x + pSub0->size.w,
pSub0->size.y + pSub0->size.h / 2,
store->pRequirementButton[i]->size.x - adj_size(10),
store->requirement_button[i]->size.x - adj_size(10),
pSub0->size.y + pSub0->size.h / 2,
line_color);
}
if (pSub1) {
create_line(store->pRequirementButton[i]->dst->surface,
store->pRequirementButton[i]->size.x - adj_size(10),
create_line(store->requirement_button[i]->dst->surface,
store->requirement_button[i]->size.x - adj_size(10),
pSub1->size.y + pSub1->size.h / 2,
store->pRequirementButton[i]->size.x - adj_size(10),
store->pRequirementButton[i]->size.y + store->pRequirementButton[i]->size.h / 2,
store->requirement_button[i]->size.x - adj_size(10),
store->requirement_button[i]->size.y + store->requirement_button[i]->size.h / 2,
line_color);
create_line(store->pRequirementButton[i]->dst->surface,
create_line(store->requirement_button[i]->dst->surface,
pSub1->size.x + pSub1->size.w,
pSub1->size.y + pSub1->size.h / 2,
store->pRequirementButton[i]->size.x - adj_size(10),
store->requirement_button[i]->size.x - adj_size(10),
pSub1->size.y + pSub1->size.h / 2,
line_color);
}
......
pwidget->id = MAX_ID - ar;
widget_add_as_prev(pwidget, dock);
dock = pwidget;
store->pRequirementButton[i] = pwidget;
store->requirement_button[i] = pwidget;
req_count++;
} else {
store->pRequirementButton[i] = NULL;
store->requirement_button[i] = NULL;
}
}
......
int j, sub_tech;
for (j = 0; j < req_count; j++) {
sub_tech = MAX_ID - store->pRequirementButton[j]->id;
sub_tech = MAX_ID - store->requirement_button[j]->id;
for (i = AR_ONE; i <= AR_TWO; i++) {
Tech_type_id ar = advance_required(sub_tech, i);
struct advance *vap = valid_advance_by_number(ar);
......
w += (pwindow->size.w - (20 + store->pSub_Req[0]->size.w + w + ptech->size.w)) / 2;
} else {
if (req_count) {
w = (pwindow->area.x + 1 + width + store->pRequirementButton[0]->size.w * 2 + adj_size(20));
w += (pwindow->size.w - ((adj_size(20) + store->pRequirementButton[0]->size.w) + w + ptech->size.w)) / 2;
w = (pwindow->area.x + 1 + width + store->requirement_button[0]->size.w * 2 + adj_size(20));
w += (pwindow->size.w - ((adj_size(20) + store->requirement_button[0]->size.w) + w + ptech->size.w)) / 2;
} else {
w = (pwindow->size.w - ptech->size.w) / 2;
}
......
ptech->size.y = pwindow->area.y + (pwindow->area.h - ptech->size.h) / 2;
if (req_count) {
h = (req_count == 1 ? store->pRequirementButton[0]->size.h :
req_count * (store->pRequirementButton[0]->size.h + adj_size(80)) - adj_size(80));
h = (req_count == 1 ? store->requirement_button[0]->size.h :
req_count * (store->requirement_button[0]->size.h + adj_size(80)) - adj_size(80));
h = ptech->size.y + (ptech->size.h - h) / 2;
for (i = 0; i < req_count; i++) {
store->pRequirementButton[i]->size.x = ptech->size.x - adj_size(20) - store->pRequirementButton[i]->size.w;
store->pRequirementButton[i]->size.y = h;
h += (store->pRequirementButton[i]->size.h + adj_size(80));
store->requirement_button[i]->size.x = ptech->size.x - adj_size(20) - store->requirement_button[i]->size.w;
store->requirement_button[i]->size.y = h;
h += (store->requirement_button[i]->size.h + adj_size(80));
}
}
......
{
struct widget *pwindow;
struct techs_buttons *store;
struct widget *pCloseButton = NULL;
struct widget *close_button = NULL;
struct widget *pAdvanceLabel = NULL;
struct widget *pListToggleButton = NULL;
struct widget *list_toggle_button = NULL;
struct widget *dock;
utf8_str *title;
utf8_str *pstr;
......
/* ------------------ */
/* close button */
pCloseButton = create_themeicon(current_theme->Small_CANCEL_Icon, pwindow->dst,
close_button = create_themeicon(current_theme->Small_CANCEL_Icon, pwindow->dst,
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
pCloseButton->info_label =
close_button->info_label =
create_utf8_from_char(_("Close Dialog (Esc)"), adj_font(12));
pCloseButton->action = exit_help_dlg_callback;
set_wstate(pCloseButton, FC_WS_NORMAL);
pCloseButton->key = SDLK_ESCAPE;
close_button->action = exit_help_dlg_callback;
set_wstate(close_button, FC_WS_NORMAL);
close_button->key = SDLK_ESCAPE;
add_to_gui_list(ID_BUTTON, pCloseButton);
add_to_gui_list(ID_BUTTON, close_button);
/* ------------------ */
dock = pCloseButton;
dock = close_button;
/* --- create scrollable advance list on the left side ---*/
pstr = create_utf8_str(NULL, 0, adj_font(10));
......
FREEUTF8STR(pstr);
help_dlg->end_active_widget_list = dock->prev;
help_dlg->begin_widget_list = pAdvanceLabel ? pAdvanceLabel : pCloseButton;
help_dlg->begin_widget_list = pAdvanceLabel ? pAdvanceLabel : close_button;
help_dlg->begin_active_widget_list = help_dlg->begin_widget_list;
if (tech_count > 10) {
......
}
/* toggle techs list button */
pListToggleButton = create_themeicon_button_from_chars(current_theme->UP_Icon,
list_toggle_button = create_themeicon_button_from_chars(current_theme->UP_Icon,
pwindow->dst,
_("Advances"),
adj_font(10), 0);
pListToggleButton->action = toggle_full_tree_mode_in_help_dlg_callback;
list_toggle_button->action = toggle_full_tree_mode_in_help_dlg_callback;
if (store->show_tree) {
set_wstate(pListToggleButton, FC_WS_NORMAL);
set_wstate(list_toggle_button, FC_WS_NORMAL);
}
widget_resize(pListToggleButton, adj_size(160), adj_size(15));
pListToggleButton->string_utf8->fgcol = *get_theme_color(COLOR_THEME_HELPDLG_TEXT);
widget_resize(list_toggle_button, adj_size(160), adj_size(15));
list_toggle_button->string_utf8->fgcol = *get_theme_color(COLOR_THEME_HELPDLG_TEXT);
add_to_gui_list(ID_BUTTON, pListToggleButton);
add_to_gui_list(ID_BUTTON, list_toggle_button);
dock = pListToggleButton;
dock = list_toggle_button;
store->dock = dock;
} else {
created = FALSE;
......
}
/* show/hide techs list */
pListToggleButton = dock;
list_toggle_button = dock;
if (store->show_tree) {
set_wstate(pListToggleButton, FC_WS_NORMAL);
set_wstate(list_toggle_button, FC_WS_NORMAL);
} else {
set_wstate(pListToggleButton, FC_WS_DISABLED);
set_wstate(list_toggle_button, FC_WS_DISABLED);
}
if (store->show_full_tree) {
......
(main_window_height() - pwindow->size.h) / 2);
/* exit button */
pCloseButton = pwindow->prev;
widget_set_position(pCloseButton,
area.x + area.w - pCloseButton->size.w - 1,
close_button = pwindow->prev;
widget_set_position(close_button,
area.x + area.w - close_button->size.w - 1,
pwindow->size.y + adj_size(2));
/* list toggle button */
pListToggleButton = store->dock;
widget_set_position(pListToggleButton, area.x, area.y);
list_toggle_button = store->dock;
widget_set_position(list_toggle_button, area.x, area.y);
/* list entries */
h = setup_vertical_widgets_position(1, area.x + scrollbar_width,
area.y + pListToggleButton->size.h, 0, 0,
area.y + list_toggle_button->size.h, 0, 0,
help_dlg->begin_active_widget_list,
help_dlg->end_active_widget_list);
/* scrollbar */
if (help_dlg->scroll) {
setup_vertical_scrollbar_area(help_dlg->scroll,
area.x, area.y + pListToggleButton->size.h,
area.x, area.y + list_toggle_button->size.h,
h, FALSE);
}
}
client/gui-sdl2/repodlgs.c
int step, i, cost;
SDL_Rect dest;
struct unit_type *punit;
struct widget *pChangeResearchButton;
struct widget *pChangeResearchGoalButton;
struct widget *change_research_button;
struct widget *change_research_goal_button;
SDL_Rect area;
struct widget *pwindow = science_dlg->end_widget_list;
area = pwindow->area;
pChangeResearchButton = pwindow->prev;
pChangeResearchGoalButton = pwindow->prev->prev;
change_research_button = pwindow->prev;
change_research_goal_button = pwindow->prev->prev;
if (A_UNSET != presearch->researching) {
cost = presearch->client.researching_cost;
......
}
/* update current research icons */
FREESURFACE(pChangeResearchButton->theme);
pChangeResearchButton->theme = get_tech_icon(presearch->researching);
FREESURFACE(pChangeResearchGoalButton->theme);
pChangeResearchGoalButton->theme = get_tech_icon(presearch->tech_goal);
FREESURFACE(change_research_button->theme);
change_research_button->theme = get_tech_icon(presearch->researching);
FREESURFACE(change_research_goal_button->theme);
change_research_goal_button->theme = get_tech_icon(presearch->tech_goal);
/* redraw Window */
widget_redraw(pwindow);
......
dest.y += adj_size(6);
widget_set_position(pChangeResearchButton, dest.x, dest.y + adj_size(18));
widget_set_position(change_research_button, dest.x, dest.y + adj_size(18));
/* current research text */
fc_snprintf(cbuf, sizeof(cbuf), "%s: %s",
......
msurf = create_text_surf_from_utf8(pStr);
dest.x = pChangeResearchButton->size.x + pChangeResearchButton->size.w + adj_size(10);
dest.x = change_research_button->size.x + change_research_button->size.w + adj_size(10);
alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
......
/* improvement icons */
dest.y += dest.h + adj_size(4);
dest.x = pChangeResearchButton->size.x + pChangeResearchButton->size.w + adj_size(10);
dest.x = change_research_button->size.x + change_research_button->size.w + adj_size(10);
/* buildings */
improvement_iterate(pimprove) {
......
dest.x, dest.y, (area.x + area.w - adj_size(16)), dest.y,
get_theme_color(COLOR_THEME_SCIENCEDLG_FRAME));
dest.x = pChangeResearchButton->size.x;
dest.x = change_research_button->size.x;
dest.y += adj_size(6);
widget_set_position(pChangeResearchGoalButton, dest.x, dest.y + adj_size(16));
widget_set_position(change_research_goal_button, dest.x, dest.y + adj_size(16));
/* -------------------------------- */
......
(presearch, presearch->tech_goal));
msurf = create_text_surf_from_utf8(pStr);
dest.x = pChangeResearchGoalButton->size.x + pChangeResearchGoalButton->size.w + adj_size(10);
dest.x = change_research_goal_button->size.x + change_research_goal_button->size.w + adj_size(10);
alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
dest.y += msurf->h;
......
(presearch->tech_goal));
msurf = create_text_surf_from_utf8(pStr);
dest.x = pChangeResearchGoalButton->size.x + pChangeResearchGoalButton->size.w + adj_size(10);
dest.x = change_research_goal_button->size.x + change_research_goal_button->size.w + adj_size(10);
alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
dest.y += msurf->h + adj_size(6);
......
{
const struct research *presearch;
struct widget *pwidget, *pwindow;
struct widget *pChangeResearchButton;
struct widget *pChangeResearchGoalButton;
struct widget *pExitButton;
struct widget *change_research_button;
struct widget *change_research_goal_button;
struct widget *exit_button;
utf8_str *pstr;
SDL_Surface *background, *tech_icon;
int count;
......
/* current research icon */
tech_icon = get_tech_icon(presearch->researching);
pChangeResearchButton = create_icon2(tech_icon, pwindow->dst, WF_RESTORE_BACKGROUND | WF_FREE_THEME);
change_research_button = create_icon2(tech_icon, pwindow->dst, WF_RESTORE_BACKGROUND | WF_FREE_THEME);
pChangeResearchButton->action = popup_change_research_dialog_callback;
change_research_button->action = popup_change_research_dialog_callback;
if (count > 0) {
set_wstate(pChangeResearchButton, FC_WS_NORMAL);
set_wstate(change_research_button, FC_WS_NORMAL);
}
add_to_gui_list(ID_SCIENCE_DLG_CHANGE_REASARCH_BUTTON, pChangeResearchButton);
add_to_gui_list(ID_SCIENCE_DLG_CHANGE_REASARCH_BUTTON, change_research_button);
/* current research goal icon */
tech_icon = get_tech_icon(presearch->tech_goal);
pChangeResearchGoalButton = create_icon2(tech_icon, pwindow->dst, WF_RESTORE_BACKGROUND | WF_FREE_THEME);
change_research_goal_button = create_icon2(tech_icon, pwindow->dst, WF_RESTORE_BACKGROUND | WF_FREE_THEME);
pChangeResearchGoalButton->action = popup_change_research_goal_dialog_callback;
change_research_goal_button->action = popup_change_research_goal_dialog_callback;
if (count > 0) {
set_wstate(pChangeResearchGoalButton, FC_WS_NORMAL);
set_wstate(change_research_goal_button, FC_WS_NORMAL);
}
add_to_gui_list(ID_SCIENCE_DLG_CHANGE_GOAL_BUTTON, pChangeResearchGoalButton);
add_to_gui_list(ID_SCIENCE_DLG_CHANGE_GOAL_BUTTON, change_research_goal_button);
/* ------ */
/* exit button */
pExitButton = create_themeicon(current_theme->Small_CANCEL_Icon, pwindow->dst,
exit_button = create_themeicon(current_theme->Small_CANCEL_Icon, pwindow->dst,
WF_WIDGET_HAS_INFO_LABEL
| WF_RESTORE_BACKGROUND);
pExitButton->info_label = create_utf8_from_char(_("Close Dialog (Esc)"),
exit_button->info_label = create_utf8_from_char(_("Close Dialog (Esc)"),
adj_font(12));
pExitButton->action = popdown_science_dialog_callback;
set_wstate(pExitButton, FC_WS_NORMAL);
pExitButton->key = SDLK_ESCAPE;
exit_button->action = popdown_science_dialog_callback;
set_wstate(exit_button, FC_WS_NORMAL);
exit_button->key = SDLK_ESCAPE;
add_to_gui_list(ID_SCIENCE_CANCEL_DLG_BUTTON, pExitButton);
add_to_gui_list(ID_SCIENCE_CANCEL_DLG_BUTTON, exit_button);
widget_set_position(pExitButton,
area.x + area.w - pExitButton->size.w - adj_size(1),
widget_set_position(exit_button,
area.x + area.w - exit_button->size.w - adj_size(1),
pwindow->size.y + adj_size(2));
/* ======================== */
science_dlg->begin_widget_list = pExitButton;
science_dlg->begin_widget_list = exit_button;
real_science_report_dialog_update(NULL);
}
client/gui-sdl2/widget_button.c
/**********************************************************************//**
Create Icon Button image with text and Icon then blit to Dest(ination)
on position pTIButton->size.x, pTIButton->size.y. WARNING: pdest must
exist.
on position theme_icon_button->size.x, theme_icon_button->size.y.
WARNING: pdest must exist.
Text with attributes is taken from pTIButton->string_utf8 parameter.
Text with attributes is taken from theme_icon_button->string_utf8 parameter.
Graphic for button is taken from pTIButton->theme surface
Graphic for button is taken from theme_icon_button->theme surface
and blit to new created image.
Graphic for Icon Theme is taken from pTIButton->theme2 surface
Graphic for Icon Theme is taken from theme_icon_button->theme2 surface
and blit to new created image.
function return (-1) if there are no Icon and Text. Else return 0.
**************************************************************************/
static int redraw_tibutton(struct widget *pTIButton)
static int redraw_tibutton(struct widget *theme_icon_button)
{
int iRet = 0;
SDL_Surface *icon;
SDL_Surface *pCopy_Of_Icon_Theme;
iRet = (*baseclass_redraw)(pTIButton);
iRet = (*baseclass_redraw)(theme_icon_button);
if (iRet != 0) {
return iRet;
}
icon = create_icon_from_theme(pTIButton->theme2, get_wstate(pTIButton));
pCopy_Of_Icon_Theme = pTIButton->theme2;
icon = create_icon_from_theme(theme_icon_button->theme2,
get_wstate(theme_icon_button));
pCopy_Of_Icon_Theme = theme_icon_button->theme2;
pTIButton->theme2 = icon;
theme_icon_button->theme2 = icon;
iRet = redraw_ibutton(pTIButton);
iRet = redraw_ibutton(theme_icon_button);
FREESURFACE(pTIButton->theme2);
pTIButton->theme2 = pCopy_Of_Icon_Theme;
FREESURFACE(theme_icon_button->theme2);
theme_icon_button->theme2 = pCopy_Of_Icon_Theme;
return iRet;
}
......
Create ( malloc ) Icon (theme)Button Widget structure.
Icon graphic is taken from 'icon' surface (don't change with button
changes ); Button Theme graphic is taken from current_theme->Button surface;
changes ); Button Theme graphic is taken from current_theme->button surface;
Text is taken from 'pstr'.
This function determinate future size of Button ( width, height ) and
......
button = widget_new();
button->theme = current_theme->Button;
button->theme = current_theme->button;
button->theme2 = icon;
button->string_utf8 = pstr;
set_wflag(button, (WF_FREE_STRING | flags));
......
h += adj_size(2);
}
correct_size_bcgnd_surf(current_theme->Button, &w, &h);
correct_size_bcgnd_surf(current_theme->button, &w, &h);
button->size.w = w;
button->size.h = h;
......
Create ( malloc ) Theme Icon (theme)Button Widget structure.
Icon Theme graphic is taken from 'pIcon_theme' surface ( change with
button changes ); Button Theme graphic is taken from current_theme->Button
button changes ); Button Theme graphic is taken from current_theme->button
surface; Text is taken from 'pstr'.
This function determinate future size of Button ( width, height ) and
client/gui-sdl2/wldlg.c
if (width) {
SDL_Rect dst = {2,1,0,0};
SDL_Surface *buf = create_bcgnd_surf(current_theme->Button, 3, width,
adj_size(28));
SDL_Surface *buf = create_bcgnd_surf(current_theme->button, 3, width,
adj_size(28));
alphablit(buf, NULL, icon, &dst, 255);
FREESURFACE(buf);
    (1-1/1)