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(GTK_ICON_SIZE_MENU, &
width, &
height);
130 surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
width,
height);
132 cr = cairo_create(surface);
146 cairo_surface_destroy(surface);
211 if (ev->type == GDK_2BUTTON_PRESS) {
214 gtk_tree_view_get_cursor(
view, &path, NULL);
216 GtkTreeModel *model = gtk_tree_view_get_model(
view);
221 gtk_tree_model_get_iter(model, &it, path);
222 gtk_tree_path_free(path);
227 if (ev->button == 1) {
243 GtkTreeIter *a, GtkTreeIter *b, gpointer data)
245 GValue value = { 0, };
250 n = GPOINTER_TO_INT(data);
254 g_value_unset(&value);
258 g_value_unset(&value);
275 model_types[i] = GDK_TYPE_PIXBUF;
278 model_types[i] = GDK_TYPE_PIXBUF;
281 model_types[i] = G_TYPE_BOOLEAN;
285 model_types[i] = G_TYPE_STRING;
291 model_types[i++] = G_TYPE_INT;
292 model_types[i++] = G_TYPE_INT;
293 model_types[i++] = G_TYPE_INT;
294 model_types[i++] = G_TYPE_STRING;
296 store = gtk_list_store_newv(i, model_types);
301 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), i,
317 pcol->
show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(
item));
327 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(
item));
337 GtkWidget *menu, *
item;
339 menu = gtk_menu_new();
341 item = gtk_menu_item_new_with_mnemonic(
_(
"_Meet"));
342 g_signal_connect(
item,
"activate",
344 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
347 item = gtk_menu_item_new_with_mnemonic(
_(
"Cancel _Treaty"));
348 g_signal_connect(
item,
"activate",
350 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
353 item = gtk_menu_item_new_with_mnemonic(
_(
"_Withdraw Vision"));
354 g_signal_connect(
item,
"activate",
356 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
368 GtkWidget *menu, *
item;
370 menu = gtk_menu_new();
372 item = gtk_menu_item_new_with_mnemonic(
_(
"_Report"));
373 g_signal_connect(
item,
"activate",
375 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
378 item = gtk_menu_item_new_with_mnemonic(
_(
"_Wonders"));
379 g_signal_connect(
item,
"activate",
381 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
383 item = gtk_menu_item_new_with_mnemonic(
_(
"_Spaceship"));
384 g_signal_connect(
item,
"activate",
386 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
398 GtkWidget *menu = gtk_menu_new();
406 item = gtk_check_menu_item_new_with_label(pcol->
title);
407 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
item), pcol->
show);
408 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
412 item = gtk_separator_menu_item_new();
413 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
415 item = gtk_check_menu_item_new_with_label(
Q_(
"?show:Dead Players"));
416 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
item),
418 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
431 GtkWidget *menubar, *menu, *
item, *vbox;
446 players_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL
448 gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(
players_list),
463 GtkCellRenderer *renderer;
464 GtkTreeViewColumn *col;
469 switch (pcol->
type) {
471 renderer = gtk_cell_renderer_pixbuf_new();
473 col = gtk_tree_view_column_new_with_attributes(pcol->
title,
474 renderer,
"pixbuf", i, NULL);
477 renderer = gtk_cell_renderer_toggle_new();
479 col = gtk_tree_view_column_new_with_attributes(pcol->
title, renderer,
483 renderer = gtk_cell_renderer_pixbuf_new();
485 col = gtk_tree_view_column_new_with_attributes(pcol->
title, renderer,
489 renderer = gtk_cell_renderer_text_new();
490 g_object_set(renderer,
"style-set",
TRUE,
"weight-set",
TRUE, NULL);
492 col = gtk_tree_view_column_new_with_attributes(pcol->
title, renderer,
497 gtk_tree_view_column_set_sort_column_id(col, i);
500 renderer = gtk_cell_renderer_text_new();
501 g_object_set(renderer,
"style-set",
TRUE,
"weight-set",
TRUE, NULL);
503 col = gtk_tree_view_column_new_with_attributes(pcol->
title, renderer,
508 gtk_tree_view_column_set_sort_column_id(col, i);
509 g_object_set(renderer,
"xalign", 1.0, NULL);
510 gtk_tree_view_column_set_alignment(col, 1.0);
515 gtk_tree_view_append_column(GTK_TREE_VIEW(
players_list), col);
519 gtk_tree_view_set_search_column(GTK_TREE_VIEW(
players_list),
522 sw = gtk_scrolled_window_new(NULL, NULL);
523 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
524 GTK_SHADOW_ETCHED_IN);
525 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
526 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
531 vbox = gtk_grid_new();
532 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
533 GTK_ORIENTATION_VERTICAL);
535 sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
536 gtk_container_add(GTK_CONTAINER(vbox), sep);
539 gtk_container_add(GTK_CONTAINER(vbox), menubar);
544 item = gtk_menu_item_new_with_mnemonic(
_(
"Di_plomacy"));
546 gtk_menu_item_set_submenu(GTK_MENU_ITEM(
item), menu);
547 gtk_menu_shell_append(GTK_MENU_SHELL(menubar),
item);
549 item = gtk_menu_item_new_with_mnemonic(
_(
"_Intelligence"));
551 gtk_menu_item_set_submenu(GTK_MENU_ITEM(
item), menu);
552 gtk_menu_shell_append(GTK_MENU_SHELL(menubar),
item);
554 item = gtk_menu_item_new_with_mnemonic(
_(
"_Display"));
556 gtk_menu_item_set_submenu(GTK_MENU_ITEM(
item), menu);
557 gtk_menu_shell_append(GTK_MENU_SHELL(menubar),
item);
559 item = gtk_menu_item_new_with_mnemonic(
_(
"_AI"));
560 gtk_menu_shell_append(GTK_MENU_SHELL(menubar),
item);
562 menu = gtk_menu_new();
563 gtk_menu_item_set_submenu(GTK_MENU_ITEM(
item), menu);
565 item = gtk_menu_item_new_with_mnemonic(
_(
"_Toggle AI Mode"));
566 g_signal_connect(
item,
"activate",
568 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
570 sep = gtk_separator_menu_item_new();
571 gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep);
575 const char *level_name = ai_level_translated_name(
level);
577 item = gtk_menu_item_new_with_label(level_name);
578 g_signal_connect(
item,
"activate",
580 GUINT_TO_POINTER(
level));
581 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
item);
584 gtk_widget_show_all(menu);
600#define MIN_DIMENSION 5
609 int x0, y0, x1, y1, w, h;
630 im = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
TRUE, 8, w, h);
634 gdk_pixbuf_copy_area(pixbuf, x0, y0, w, h,
636 g_object_unref(G_OBJECT(pixbuf));
648static void fill_row(GtkListStore *store, GtkTreeIter *it,
649 const struct player *pplayer)
653 int style = PANGO_STYLE_NORMAL, weight = PANGO_WEIGHT_NORMAL;
658 switch (pcol->
type) {
661 gtk_list_store_set(store, it, k, pcol->
func(pplayer), -1);
665 if (pixbuf != NULL) {
666 gtk_list_store_set(store, it, k, pixbuf, -1);
667 g_object_unref(pixbuf);
672 if (pixbuf != NULL) {
673 gtk_list_store_set(store, it, k, pixbuf, -1);
674 g_object_unref(pixbuf);
678 gtk_list_store_set(store, it, k, pcol->
bool_func(pplayer), -1);
690 weight = PANGO_WEIGHT_NORMAL;
691 style = PANGO_STYLE_ITALIC;
695 weight = PANGO_WEIGHT_BOLD;
696 style = PANGO_STYLE_NORMAL;
702 weight = PANGO_WEIGHT_NORMAL;
703 style = PANGO_STYLE_NORMAL;
710 gtk_list_store_set(store, it,
786 char *
title,
char *question)
790 shell = gtk_message_dialog_new(NULL, 0,
791 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
793 gtk_window_set_title(GTK_WINDOW(
shell),
title);
795 gtk_dialog_set_default_response(GTK_DIALOG(
shell), GTK_RESPONSE_NO);
797 if (gtk_dialog_run(GTK_DIALOG(
shell)) == GTK_RESPONSE_YES) {
800 gtk_widget_destroy(
shell);
817 enum diplstate_type oldstate, newstate;
827 astr_set(&
title,
_(
"Cancel %s"), diplstate_type_translated_name(oldstate));
829 if (newstate == DS_WAR) {
830 astr_set(&question,
_(
"Really declare war on the %s?"),
834 astr_set(&question,
_(
"Cancel %s %s? New diplomatic state will be %s."),
836 diplstate_type_translated_name(oldstate),
837 diplstate_type_translated_name(newstate));
864 astr_set(&question,
_(
"Withdraw shared vision from the %s?"),
969 GtkTreeViewColumn *col;
971 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)