23#include <gdk/gdkkeysyms.h>
68#define PLR_DLG_COL_STYLE (0 + num_player_dlg_columns)
69#define PLR_DLG_COL_WEIGHT (1 + num_player_dlg_columns)
70#define PLR_DLG_COL_ID (2 + num_player_dlg_columns)
71#define PLR_DLG_COL_TOOLTIP (3 + num_player_dlg_columns)
73#define PLR_DLG_COL_TOTAL (PLR_DLG_COL_TOOLTIP + 1)
121 cairo_surface_t *surface;
129 gtk_icon_size_lookup_for_settings(
130 gtk_settings_get_for_screen(gtk_widget_get_screen(
top_notebook)),
132 surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
width,
height);
134 cr = cairo_create(surface);
148 cairo_surface_destroy(surface);
213 if (ev->type == GDK_2BUTTON_PRESS) {
216 gtk_tree_view_get_cursor(
view, &path, NULL);
218 GtkTreeModel *model = gtk_tree_view_get_model(
view);
223 gtk_tree_model_get_iter(model, &it, path);
224 gtk_tree_path_free(path);
229 if (ev->button == 1) {
245 GtkTreeIter *a, GtkTreeIter *b, gpointer data)
247 GValue value = { 0, };
252 n = GPOINTER_TO_INT(data);
256 g_value_unset(&value);
260 g_value_unset(&value);
277 model_types[i] = GDK_TYPE_PIXBUF;
280 model_types[i] = GDK_TYPE_PIXBUF;
283 model_types[i] = G_TYPE_BOOLEAN;
287 model_types[i] = G_TYPE_STRING;
293 model_types[i++] = G_TYPE_INT;
294 model_types[i++] = G_TYPE_INT;
295 model_types[i++] = G_TYPE_INT;
296 model_types[i++] = G_TYPE_STRING;
298 store = gtk_list_store_newv(i, model_types);
303 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), i,
319 pcol->
show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(
item));
329 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(
item));
339 GtkWidget *menu, *
item;
341 menu = gtk_menu_new();
343 item = gtk_menu_item_new_with_mnemonic(
_(
"_Meet"));
344 g_signal_connect(
item,
"activate",
346 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
349 item = gtk_menu_item_new_with_mnemonic(
_(
"Cancel _Treaty"));
350 g_signal_connect(
item,
"activate",
352 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
355 item = gtk_menu_item_new_with_mnemonic(
_(
"_Withdraw Vision"));
356 g_signal_connect(
item,
"activate",
358 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
370 GtkWidget *menu, *
item;
372 menu = gtk_menu_new();
374 item = gtk_menu_item_new_with_mnemonic(
_(
"_Report"));
375 g_signal_connect(
item,
"activate",
377 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
380 item = gtk_menu_item_new_with_mnemonic(
_(
"_Wonders"));
381 g_signal_connect(
item,
"activate",
383 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
385 item = gtk_menu_item_new_with_mnemonic(
_(
"_Spaceship"));
386 g_signal_connect(
item,
"activate",
388 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
400 GtkWidget *menu = gtk_menu_new();
408 item = gtk_check_menu_item_new_with_label(pcol->
title);
409 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
item), pcol->
show);
410 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
414 item = gtk_separator_menu_item_new();
415 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
417 item = gtk_check_menu_item_new_with_label(
Q_(
"?show:Dead Players"));
418 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
item),
420 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
433 GtkWidget *menubar, *menu, *
item, *vbox;
442 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
448 players_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL
450 gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(
players_list),
465 GtkCellRenderer *renderer;
466 GtkTreeViewColumn *col;
471 switch (pcol->
type) {
473 renderer = gtk_cell_renderer_pixbuf_new();
475 col = gtk_tree_view_column_new_with_attributes(pcol->
title,
476 renderer,
"pixbuf", i, NULL);
479 renderer = gtk_cell_renderer_toggle_new();
481 col = gtk_tree_view_column_new_with_attributes(pcol->
title, renderer,
485 renderer = gtk_cell_renderer_pixbuf_new();
487 col = gtk_tree_view_column_new_with_attributes(pcol->
title, renderer,
491 renderer = gtk_cell_renderer_text_new();
492 g_object_set(renderer,
"style-set",
TRUE,
"weight-set",
TRUE, NULL);
494 col = gtk_tree_view_column_new_with_attributes(pcol->
title, renderer,
499 gtk_tree_view_column_set_sort_column_id(col, i);
502 renderer = gtk_cell_renderer_text_new();
503 g_object_set(renderer,
"style-set",
TRUE,
"weight-set",
TRUE, NULL);
505 col = gtk_tree_view_column_new_with_attributes(pcol->
title, renderer,
510 gtk_tree_view_column_set_sort_column_id(col, i);
511 g_object_set(renderer,
"xalign", 1.0, NULL);
512 gtk_tree_view_column_set_alignment(col, 1.0);
517 gtk_tree_view_append_column(GTK_TREE_VIEW(
players_list), col);
521 gtk_tree_view_set_search_column(GTK_TREE_VIEW(
players_list),
524 sw = gtk_scrolled_window_new(NULL, NULL);
525 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
526 GTK_SHADOW_ETCHED_IN);
527 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
528 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
533 vbox = gtk_grid_new();
534 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
535 GTK_ORIENTATION_VERTICAL);
537 sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
538 gtk_container_add(GTK_CONTAINER(vbox), sep);
541 gtk_container_add(GTK_CONTAINER(vbox), menubar);
546 item = gtk_menu_item_new_with_mnemonic(
_(
"Di_plomacy"));
548 gtk_menu_item_set_submenu(GTK_MENU_ITEM(
item), menu);
549 gtk_menu_shell_append(GTK_MENU_SHELL(menubar),
item);
551 item = gtk_menu_item_new_with_mnemonic(
_(
"_Intelligence"));
553 gtk_menu_item_set_submenu(GTK_MENU_ITEM(
item), menu);
554 gtk_menu_shell_append(GTK_MENU_SHELL(menubar),
item);
556 item = gtk_menu_item_new_with_mnemonic(
_(
"_Display"));
558 gtk_menu_item_set_submenu(GTK_MENU_ITEM(
item), menu);
559 gtk_menu_shell_append(GTK_MENU_SHELL(menubar),
item);
561 item = gtk_menu_item_new_with_mnemonic(
_(
"_AI"));
562 gtk_menu_shell_append(GTK_MENU_SHELL(menubar),
item);
564 menu = gtk_menu_new();
565 gtk_menu_item_set_submenu(GTK_MENU_ITEM(
item), menu);
567 item = gtk_menu_item_new_with_mnemonic(
_(
"_Toggle AI Mode"));
568 g_signal_connect(
item,
"activate",
570 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
572 sep = gtk_separator_menu_item_new();
573 gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep);
577 const char *level_name = ai_level_translated_name(
level);
579 item = gtk_menu_item_new_with_label(level_name);
580 g_signal_connect(
item,
"activate",
582 GUINT_TO_POINTER(
level));
583 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
586 gtk_widget_show_all(menu);
602#define MIN_DIMENSION 5
611 int x0, y0, x1, y1, w, h;
632 im = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
TRUE, 8, w, h);
636 gdk_pixbuf_copy_area(pixbuf, x0, y0, w, h,
638 g_object_unref(G_OBJECT(pixbuf));
650static void fill_row(GtkListStore *store, GtkTreeIter *it,
651 const struct player *pplayer)
655 int style = PANGO_STYLE_NORMAL, weight = PANGO_WEIGHT_NORMAL;
660 switch (pcol->
type) {
663 gtk_list_store_set(store, it, k, pcol->
func(pplayer), -1);
667 if (pixbuf != NULL) {
668 gtk_list_store_set(store, it, k, pixbuf, -1);
669 g_object_unref(pixbuf);
674 if (pixbuf != NULL) {
675 gtk_list_store_set(store, it, k, pixbuf, -1);
676 g_object_unref(pixbuf);
680 gtk_list_store_set(store, it, k, pcol->
bool_func(pplayer), -1);
692 weight = PANGO_WEIGHT_NORMAL;
693 style = PANGO_STYLE_ITALIC;
697 weight = PANGO_WEIGHT_BOLD;
698 style = PANGO_STYLE_NORMAL;
704 weight = PANGO_WEIGHT_NORMAL;
705 style = PANGO_STYLE_NORMAL;
712 gtk_list_store_set(store, it,
788 char *
title,
char *question)
792 shell = gtk_message_dialog_new(NULL, 0,
793 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
795 gtk_window_set_title(GTK_WINDOW(
shell),
title);
797 gtk_dialog_set_default_response(GTK_DIALOG(
shell), GTK_RESPONSE_NO);
799 if (gtk_dialog_run(GTK_DIALOG(
shell)) == GTK_RESPONSE_YES) {
802 gtk_widget_destroy(
shell);
819 enum diplstate_type oldstate, newstate;
829 astr_set(&
title,
_(
"Cancel %s"), diplstate_type_translated_name(oldstate));
831 if (newstate == DS_WAR) {
832 astr_set(&question,
_(
"Really declare war on the %s?"),
836 astr_set(&question,
_(
"Cancel %s %s? New diplomatic state will be %s."),
838 diplstate_type_translated_name(oldstate),
839 diplstate_type_translated_name(newstate));
866 astr_set(&question,
_(
"Withdraw shared vision from the %s?"),
971 GtkTreeViewColumn *col;
973 col = gtk_tree_view_get_column(GTK_TREE_VIEW(
players_list), i);
void astr_set(struct astring *astr, const char *format,...)
char * astr_to_str(struct astring *astr)
struct canvas int int struct sprite int int int int height
struct canvas int int struct sprite int int int width
int send_chat_printf(const char *format,...)
bool can_meet_with_player(const struct player *pplayer)
bool can_intel_with_player(const struct player *pplayer)
bool can_client_issue_orders(void)
bool client_has_player(void)
struct color * get_player_color(const struct tileset *t, const struct player *pplayer)
bool player_has_color(const struct player *pplayer)
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
void gtk_tree_view_focus(GtkTreeView *view)
void gui_dialog_destroy(struct gui_dialog *dlg)
void gui_dialog_present(struct gui_dialog *dlg)
void gui_dialog_set_default_response(struct gui_dialog *dlg, int response)
void gui_dialog_raise(struct gui_dialog *dlg)
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
GtkWidget * gui_dialog_add_widget(struct gui_dialog *dlg, GtkWidget *widget)
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *text, int response)
void gui_dialog_show_all(struct gui_dialog *dlg)
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height)
GtkWidget * gtk_aux_menu_bar_new(void)
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
void popup_intel_dialog(struct player *p)
void popup_intel_wonder_dialog(struct player *p)
static struct gui_dialog * shell
static GtkWidget * players_int_command
static void players_war_callback(GtkMenuItem *item, gpointer data)
void popdown_players_dialog(void)
static void fill_row(GtkListStore *store, GtkTreeIter *it, const struct player *pplayer)
static GtkTreeSelection * players_selection
static void update_views(void)
static GtkWidget * players_vision_command
static GtkWidget * players_list
static GtkWidget * players_sship_command
struct gui_dialog * players_dialog_shell
static void players_ai_toggle_callback(GtkMenuItem *item, gpointer data)
static void players_sship_callback(GtkMenuItem *item, gpointer data)
#define PLR_DLG_COL_WEIGHT
#define PLR_DLG_COL_STYLE
void real_players_dialog_update(void *unused)
static GtkWidget * create_diplomacy_menu(void)
static bool player_should_be_shown(const struct player *pplayer)
#define PLR_DLG_COL_TOTAL
GdkPixbuf * create_player_icon(const struct player *plr)
static GtkWidget * create_intelligence_menu(void)
static gboolean button_press_callback(GtkTreeView *view, GdkEventButton *ev)
void popup_players_dialog(bool raise)
static GtkListStore * players_dialog_store
static void players_intel_wonder_callback(GtkMenuItem *item, gpointer data)
static void toggle_dead_players(GtkCheckMenuItem *item, gpointer data)
#define PLR_DLG_COL_TOOLTIP
static void players_meet_callback(GtkMenuItem *item, gpointer data)
static void confirm_cancel_pact(enum clause_type clause, int plrno, char *title, char *question)
static void players_vision_callback(GtkMenuItem *item, gpointer data)
static gint plrdlg_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer data)
GdkPixbuf * get_flag(const struct nation_type *nation)
static GtkListStore * players_dialog_store_new(void)
static GtkWidget * players_meet_command
static void toggle_view(GtkCheckMenuItem *item, gpointer data)
static void players_ai_skill_callback(GtkMenuItem *item, gpointer data)
static void create_players_dialog(void)
static void players_intel_callback(GtkMenuItem *item, gpointer data)
static void update_players_menu(void)
static GtkWidget * create_show_menu(void)
static GtkWidget * players_war_command
static void selection_callback(GtkTreeSelection *selection, gpointer data)
void popup_spaceship_dialog(struct player *pplayer)
GdkPixbuf * surface_get_pixbuf(cairo_surface_t *surf, int width, int height)
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
void sprite_get_bounding_box(struct sprite *sprite, int *start_x, int *start_y, int *end_x, int *end_y)
#define fc_assert_ret(condition)
#define fc_assert_ret_val(condition, val)
const char * nation_adjective_for_player(const struct player *pplayer)
struct nation_type * nation_of_player(const struct player *pplayer)
const char * nation_plural_for_player(const struct player *pplayer)
struct client_options gui_options
int dsend_packet_diplomacy_cancel_pact(struct connection *pc, int other_player_id, enum clause_type clause)
int dsend_packet_diplomacy_init_meeting_req(struct connection *pc, int counterpart)
bool is_settable_ai_level(enum ai_level level)
struct player * player_by_number(const int player_id)
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
enum diplstate_type cancel_pact_result(enum diplstate_type oldstate)
int player_number(const struct player *pplayer)
const char * player_name(const struct player *pplayer)
enum dipl_reason pplayer_can_cancel_treaty(const struct player *p1, const struct player *p2)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
bool gives_shared_vision(const struct player *me, const struct player *them)
#define ai_level_cmd(_level_)
#define players_iterate_end
#define players_iterate(_pplayer)
static bool is_barbarian(const struct player *pplayer)
int player_dlg_default_sort_column(void)
struct player_dlg_column player_dlg_columns[]
const int num_player_dlg_columns
struct setting_list * level[OLEVELS_NUM]
bool player_dlg_show_dead_players
bool(* bool_func)(const struct player *)
plr_dlg_sort_func sort_func
const char *(* func)(const struct player *)
enum player_dlg_column_type type
enum spaceship_state state
struct player_spaceship spaceship
struct player_score score
const char * score_tooltip(const struct player *pplayer, int score)
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)