Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-gtk-4.0/editgui.c Source File

Freeciv-3.2

Loading...
Searching...
No Matches
editgui.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2005 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <math.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22
23#include <gtk/gtk.h>
24#include <gdk/gdkkeysyms.h>
25
26/* utility */
27#include "fcintl.h"
28#include "log.h"
29#include "shared.h"
30#include "support.h"
31
32/* common */
33#include "connection.h"
34#include "game.h"
35#include "government.h"
36#include "packets.h"
37
38/* client */
39#include "chatline_common.h"
40#include "client_main.h"
41#include "dialogs_g.h"
42#include "editor.h"
43#include "mapview_common.h"
44#include "tilespec.h"
45
46/* client/gui-gtk-4.0 */
47#include "canvas.h"
48#include "editgui.h"
49#include "editprop.h"
50#include "gui_main.h"
51#include "gui_stuff.h"
52#include "plrdlg.h"
53#include "sprite.h"
54
55
56 enum tool_value_selector_columns {
57 TVS_COL_IMAGE = 0,
58 TVS_COL_ID,
59 TVS_COL_NAME,
60
61 TVS_NUM_COLS
62};
63
64 enum player_pov_combo_columns {
65 PPV_COL_FLAG = 0,
66 PPV_COL_NAME,
67 PPV_COL_PLAYER_NO,
68
69 PPV_NUM_COLS
70};
71
72 enum tool_applied_player_columns {
73 TAP_COL_FLAG = 0,
74 TAP_COL_NAME,
75 TAP_COL_PLAYER_NO,
76
77 TAP_NUM_COLS
78};
79
80 enum spin_button_types {
81 SPIN_BUTTON_SIZE,
82 SPIN_BUTTON_COUNT
83};
84
85struct tool_value_selector {
86 struct editbar *editbar_parent;
87
88 GtkWidget *dialog;
89
90 GtkListStore *store;
91 GtkWidget *view;
92};
93
94static struct tool_value_selector *
95 create_tool_value_selector(struct editbar *eb_parent,
96 enum editor_tool_type ett);
97static void editinfobox_refresh(struct editinfobox *ei);
98static void editbar_player_pov_combobox_changed(GtkComboBox *combo,
99 gpointer user_data);
100static void editbar_mode_button_toggled(GtkToggleButton *tb,
101 gpointer userdata);
102static void editbar_tool_button_toggled(GtkToggleButton *tb,
103 gpointer userdata);
104static void try_to_set_editor_tool(enum editor_tool_type ett);
105
106 static struct editbar *editor_toolbar;
107 static struct editinfobox *editor_infobox;
108
109/************************************************************************/
113 static void refresh_all_buttons(struct editbar *eb)
114{
115 enum editor_tool_type ett;
116 enum editor_tool_mode etm;
117 GtkWidget *tb = NULL;
118 int i;
119
120 if (eb == NULL) {
121 return;
122 }
123
124 ett = editor_get_tool();
125 etm = editor_tool_get_mode(ett);
126
127 for (i = 0; i < NUM_EDITOR_TOOL_MODES; i++) {
128 tb = eb->mode_buttons[i];
129 if (tb == NULL) {
130 continue;
131 }
132 disable_gobject_callback(G_OBJECT(tb),
133 G_CALLBACK(editbar_mode_button_toggled));
134 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tb), i == etm);
135 enable_gobject_callback(G_OBJECT(tb),
136 G_CALLBACK(editbar_mode_button_toggled));
137 gtk_widget_set_sensitive(tb, editor_tool_has_mode(ett, i));
138 }
139
140 if (ett < NUM_EDITOR_TOOL_TYPES
141 && eb->tool_buttons[ett] != NULL) {
142 tb = eb->tool_buttons[ett];
143 disable_gobject_callback(G_OBJECT(tb),
144 G_CALLBACK(editbar_tool_button_toggled));
145 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tb), TRUE);
146 enable_gobject_callback(G_OBJECT(tb),
147 G_CALLBACK(editbar_tool_button_toggled));
148 }
149}
150
151/************************************************************************/
154 static void editbar_mode_button_toggled(GtkToggleButton *tb,
155 gpointer userdata)
156{
157 gboolean active;
158 enum editor_tool_mode etm;
159 enum editor_tool_type ett;
160
161 etm = GPOINTER_TO_INT(userdata);
162 if (!(etm < NUM_EDITOR_TOOL_MODES)) {
163 return;
164 }
165
166 active = gtk_toggle_button_get_active(tb);
167 ett = editor_get_tool();
168
169 editor_tool_set_mode(ett, active ? etm : ETM_PAINT);
170 editgui_refresh();
171}
172
173/************************************************************************/
177 static void try_to_set_editor_tool(enum editor_tool_type ett)
178{
179 if (!(ett < NUM_EDITOR_TOOL_TYPES)) {
180 return;
181 }
182
183 if (!editor_tool_is_usable(ett)) {
184 GtkWidget *dialog;
185
186 dialog = gtk_message_dialog_new(GTK_WINDOW(toplevel),
187 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
188 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s",
189 _("The current ruleset does not define any "
190 "objects corresponding to this editor tool."));
191 gtk_window_set_title(GTK_WINDOW(dialog), editor_tool_get_name(ett));
192 blocking_dialog(dialog);
193 gtk_window_destroy(GTK_WINDOW(dialog));
194 } else {
195 editor_set_tool(ett);
196 }
197}
198
199/************************************************************************/
202 static void editbar_tool_button_toggled(GtkToggleButton *tb,
203 gpointer userdata)
204{
205 gboolean active;
206 enum editor_tool_type ett;
207
208 active = gtk_toggle_button_get_active(tb);
209 ett = GPOINTER_TO_INT(userdata);
210
211 if (active) {
212 try_to_set_editor_tool(ett);
213 editgui_refresh();
214 }
215}
216
217/************************************************************************/
224 static void refresh_player_pov_indicator(struct editbar *eb)
225{
226 GtkListStore *store;
227 GdkPixbuf *flag;
228 GtkTreeIter iter;
229 GtkWidget *combo;
230 int index = -1, i;
231
232 if (eb == NULL || eb->player_pov_store == NULL) {
233 return;
234 }
235
236 store = eb->player_pov_store;
237 gtk_list_store_clear(store);
238
239 gtk_list_store_append(store, &iter);
240 gtk_list_store_set(store, &iter, PPV_COL_NAME, _("Global Observer"),
241 PPV_COL_PLAYER_NO, -1, -1);
242
243 i = 1;
244 players_iterate(pplayer) {
245 gtk_list_store_append(store, &iter);
246 gtk_list_store_set(store, &iter, PPV_COL_NAME, player_name(pplayer),
247 PPV_COL_PLAYER_NO, player_number(pplayer), -1);
248
249 if (pplayer->nation != NO_NATION_SELECTED) {
250 flag = get_flag(pplayer->nation);
251
252 if (flag != NULL) {
253 gtk_list_store_set(store, &iter, PPV_COL_FLAG, flag, -1);
254 g_object_unref(flag);
255 }
256 }
257 if (pplayer == client_player()) {
258 index = i;
259 }
260 i++;
261 } players_iterate_end;
262
263 if (client_is_global_observer()) {
264 index = 0;
265 }
266
267 combo = eb->player_pov_combobox;
268 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), index);
269}
270
271/************************************************************************/
278 static void editbar_player_pov_combobox_changed(GtkComboBox *combo,
279 gpointer user_data)
280{
281 struct editbar *eb = user_data;
282 int id;
283 struct player *pplayer;
284 GtkTreeIter iter;
285 GtkTreeModel *model;
286
287 if (eb == NULL || eb->widget == NULL
288 || !gtk_widget_get_visible(eb->widget)) {
289 return;
290 }
291
292 if (!gtk_combo_box_get_active_iter(combo, &iter)) {
293 return;
294 }
295
296 model = gtk_combo_box_get_model(combo);
297 gtk_tree_model_get(model, &iter, PPV_COL_PLAYER_NO, &id, -1);
298
299 if ((client_is_global_observer() && id == -1)
300 || client_player_number() == id) {
301 return;
302 }
303
304 /* Ugh... hard-coded server command strings. :( */
305 if (id == -1) {
306 send_chat("/observe");
307 return;
308 }
309
310 pplayer = player_by_number(id);
311 if (pplayer != NULL) {
312 send_chat_printf("/take \"%s\"", pplayer->name);
313 }
314}
315
316/************************************************************************/
320 static int tool_value_selector_run(struct tool_value_selector *tvs)
321{
322 gint res;
323 GtkWidget *dialog;
324 GtkTreeSelection *sel;
325 GtkTreeIter iter;
326 GtkTreeModel *model;
327 int id;
328
329 if (tvs == NULL) {
330 return -1;
331 }
332
333 dialog = tvs->dialog;
334 res = blocking_dialog(dialog);
335 gtk_widget_set_visible(dialog, FALSE);
336
337 if (res != GTK_RESPONSE_ACCEPT) {
338 return -1;
339 }
340
341 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tvs->view));
342 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) {
343 return -1;
344 }
345
346 gtk_tree_model_get(model, &iter, TVS_COL_ID, &id, -1);
347
348 return id;
349}
350
351/************************************************************************/
357 static bool editgui_run_tool_selection(enum editor_tool_type ett)
358{
359 struct editbar *eb;
360 struct tool_value_selector *tvs;
361 int res = -1;
362
363 eb = editgui_get_editbar();
364 if (eb == NULL || !(ett < NUM_EDITOR_TOOL_TYPES)) {
365 return FALSE;
366 }
367
368 if (!editor_tool_has_value(ett)) {
369 return FALSE;
370 }
371
372 tvs = eb->tool_selectors[ett];
373 if (!tvs) {
374 return FALSE;
375 }
376
377 res = tool_value_selector_run(tvs);
378
379 if (res >= 0) {
380 editor_tool_set_value(ett, res);
381 editinfobox_refresh(editgui_get_editinfobox());
382 }
383
384 return TRUE;
385}
386
387/************************************************************************/
390 static gboolean editbar_tool_right_button(GtkGestureClick *gesture,
391 int n_press,
392 double x, double y, gpointer data)
393{
394 return editgui_run_tool_selection(GPOINTER_TO_INT(data));
395}
396
397/************************************************************************/
401 static void editbar_add_tool_button(struct editbar *eb,
402 enum editor_tool_type ett)
403{
404 GdkPixbuf *pixbuf;
405 GtkWidget *pic, *button, *hbox;
406 GtkToggleButton *parent = NULL;
407 struct sprite *sprite;
408 int i;
409 GtkGesture *gesture;
410 GtkEventController *controller;
411
412 if (!eb || !(ett < NUM_EDITOR_TOOL_TYPES)) {
413 return;
414 }
415
416 for (i = 0; i < NUM_EDITOR_TOOL_TYPES; i++) {
417 if (eb->tool_buttons[i] != NULL) {
418 parent = GTK_TOGGLE_BUTTON(eb->tool_buttons[i]);
419 break;
420 }
421 }
422
423 if (parent == NULL) {
424 button = gtk_toggle_button_new();
425 } else {
426 button = gtk_toggle_button_new();
427 gtk_toggle_button_set_group(GTK_TOGGLE_BUTTON(button),
428 GTK_TOGGLE_BUTTON(parent));
429 }
430
431 sprite = editor_tool_get_sprite(ett);
432 fc_assert_ret(sprite != NULL);
433 pixbuf = sprite_get_pixbuf(sprite);
434 pic = gtk_picture_new_for_pixbuf(pixbuf);
435 g_object_unref(G_OBJECT(pixbuf));
436
437 gtk_button_set_child(GTK_BUTTON(button), pic);
438 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
439 gtk_widget_set_tooltip_text(button, editor_tool_get_tooltip(ett));
440 gtk_size_group_add_widget(eb->size_group, button);
441 gtk_button_set_has_frame(GTK_BUTTON(button), FALSE);
442 gtk_widget_set_focus_on_click(button, FALSE);
443
444 g_signal_connect(button, "toggled",
445 G_CALLBACK(editbar_tool_button_toggled),
446 GINT_TO_POINTER(ett));
447
448 gesture = gtk_gesture_click_new();
449 gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 3);
450 controller = GTK_EVENT_CONTROLLER(gesture);
451 g_signal_connect(controller, "pressed",
452 G_CALLBACK(editbar_tool_right_button),
453 GINT_TO_POINTER(ett));
454 gtk_widget_add_controller(button, controller);
455
456 hbox = eb->widget;
457 gtk_box_append(GTK_BOX(hbox), button);
458 eb->tool_buttons[ett] = button;
459
460 if (editor_tool_has_value(ett)) {
461 eb->tool_selectors[ett] = create_tool_value_selector(eb, ett);
462 }
463}
464
465/************************************************************************/
468 static void editbar_player_properties_button_clicked(GtkButton *b,
469 gpointer userdata)
470{
471 struct property_editor *pe;
472
473 pe = editprop_get_property_editor();
474 property_editor_reload(pe, OBJTYPE_GAME);
475 property_editor_reload(pe, OBJTYPE_PLAYER);
476 property_editor_popup(pe, OBJTYPE_PLAYER);
477}
478
479/************************************************************************/
483 static void editbar_add_mode_button(struct editbar *eb,
484 enum editor_tool_mode etm)
485{
486 GdkPixbuf *pixbuf;
487 GtkWidget *pic, *button, *hbox;
488 struct sprite *sprite;
489 const char *tooltip;
490
491 if (!eb || !(etm < NUM_EDITOR_TOOL_MODES)) {
492 return;
493 }
494
495 button = gtk_toggle_button_new();
496
497 sprite = editor_get_mode_sprite(etm);
498 fc_assert_ret(sprite != NULL);
499 pixbuf = sprite_get_pixbuf(sprite);
500 pic = gtk_picture_new_for_pixbuf(pixbuf);
501 g_object_unref(G_OBJECT(pixbuf));
502
503 gtk_button_set_child(GTK_BUTTON(button), pic);
504 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
505 tooltip = editor_get_mode_tooltip(etm);
506 if (tooltip != NULL) {
507 gtk_widget_set_tooltip_text(button, tooltip);
508 }
509 gtk_size_group_add_widget(eb->size_group, button);
510 gtk_button_set_has_frame(GTK_BUTTON(button), FALSE);
511 gtk_widget_set_focus_on_click(button, FALSE);
512
513 g_signal_connect(button, "toggled",
514 G_CALLBACK(editbar_mode_button_toggled),
515 GINT_TO_POINTER(etm));
516
517 hbox = eb->widget;
518 gtk_box_append(GTK_BOX(hbox), button);
519 eb->mode_buttons[etm] = button;
520}
521
522/************************************************************************/
525 static struct editbar *editbar_create(void)
526{
527 struct editbar *eb;
528 GtkWidget *hbox, *button, *combo, *pic, *separator, *vgrid;
529 GtkListStore *store;
530 GtkCellRenderer *cell;
531 GdkPixbuf *pixbuf;
532 const struct editor_sprites *sprites;
533 int grid_row = 0;
534
535 eb = fc_calloc(1, sizeof(struct editbar));
536
537 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
538 eb->widget = hbox;
539 eb->size_group = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
540
541 sprites = get_editor_sprites(tileset);
542
543 editbar_add_mode_button(eb, ETM_ERASE);
544
545 separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
546 gtk_box_append(GTK_BOX(hbox), separator);
547
548 editbar_add_tool_button(eb, ETT_TERRAIN);
549 editbar_add_tool_button(eb, ETT_TERRAIN_RESOURCE);
550 editbar_add_tool_button(eb, ETT_TERRAIN_SPECIAL);
551 editbar_add_tool_button(eb, ETT_ROAD);
552 editbar_add_tool_button(eb, ETT_MILITARY_BASE);
553 editbar_add_tool_button(eb, ETT_UNIT);
554 editbar_add_tool_button(eb, ETT_CITY);
555 editbar_add_tool_button(eb, ETT_VISION);
556 editbar_add_tool_button(eb, ETT_STARTPOS);
557 editbar_add_tool_button(eb, ETT_COPYPASTE);
558
559 separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
560 gtk_box_append(GTK_BOX(hbox), separator);
561
562 /* Player POV indicator. */
563 vgrid = gtk_grid_new();
564 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
565 GTK_ORIENTATION_VERTICAL);
566 gtk_box_append(GTK_BOX(hbox), vgrid);
567
568 store = gtk_list_store_new(PPV_NUM_COLS,
569 GDK_TYPE_PIXBUF,
570 G_TYPE_STRING,
571 G_TYPE_INT);
572 eb->player_pov_store = store;
573
574 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
575
576 cell = gtk_cell_renderer_pixbuf_new();
577 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, FALSE);
578 gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo),
579 cell, "pixbuf", PPV_COL_FLAG);
580
581 cell = gtk_cell_renderer_text_new();
582 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, TRUE);
583 gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo),
584 cell, "text", PPV_COL_NAME);
585
586 gtk_widget_set_size_request(combo, 140, -1);
587 g_signal_connect(combo, "changed",
588 G_CALLBACK(editbar_player_pov_combobox_changed), eb);
589
590 gtk_widget_set_tooltip_text(combo,
591 _("Switch player point-of-view. Use this to edit "
592 "from the perspective of different players, or "
593 "even as a global observer."));
594 gtk_grid_attach(GTK_GRID(vgrid), combo, 0, grid_row++, 1, 1);
595 eb->player_pov_combobox = combo;
596
597 /* Property editor button. */
598 button = gtk_button_new();
599 pixbuf = sprite_get_pixbuf(sprites->properties);
600 pic = gtk_picture_new_for_pixbuf(pixbuf);
601 g_object_unref(G_OBJECT(pixbuf));
602 gtk_button_set_child(GTK_BUTTON(button), pic);
603 gtk_widget_set_tooltip_text(button, _("Show the property editor."));
604 gtk_size_group_add_widget(eb->size_group, button);
605 gtk_button_set_has_frame(GTK_BUTTON(button), FALSE);
606 gtk_widget_set_focus_on_click(button, FALSE);
607 g_signal_connect(button, "clicked",
608 G_CALLBACK(editbar_player_properties_button_clicked), eb);
609 gtk_box_append(GTK_BOX(hbox), button);
610
611 return eb;
612}
613
614/************************************************************************/
618 static void refresh_tool_value_selector(struct editbar *eb,
619 enum editor_tool_type ett)
620{
621 GtkTreeSelection *sel;
622 GtkTreeIter iter;
623 GtkTreeModel *model;
624 int value, store_value;
625 struct tool_value_selector *tvs;
626
627 if (!editor_is_active() || !eb || !editor_tool_has_value(ett)) {
628 return;
629 }
630
631 tvs = eb->tool_selectors[ett];
632
633 if (!tvs) {
634 return;
635 }
636
637 value = editor_tool_get_value(ett);
638 model = GTK_TREE_MODEL(tvs->store);
639 if (!gtk_tree_model_get_iter_first(model, &iter)) {
640 return;
641 }
642
643 do {
644 gtk_tree_model_get(model, &iter, TVS_COL_ID, &store_value, -1);
645 if (value == store_value) {
646 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tvs->view));
647 gtk_tree_selection_select_iter(sel, &iter);
648 break;
649 }
650 } while (gtk_tree_model_iter_next(model, &iter));
651}
652
653/************************************************************************/
657 static void refresh_all_tool_value_selectors(struct editbar *eb)
658{
659 int ett;
660
661 if (!eb) {
662 return;
663 }
664
665 for (ett = 0; ett < NUM_EDITOR_TOOL_TYPES; ett++) {
666 if (editor_tool_has_value(ett)) {
667 refresh_tool_value_selector(eb, ett);
668 }
669 }
670}
671
672/************************************************************************/
675 static void editbar_refresh(struct editbar *eb)
676{
677 if (eb == NULL || eb->widget == NULL) {
678 return;
679 }
680
681 if (!editor_is_active()) {
682 gtk_widget_set_visible(eb->widget, FALSE);
683 return;
684 }
685
686 refresh_all_buttons(eb);
687 refresh_all_tool_value_selectors(eb);
688 refresh_player_pov_indicator(eb);
689
690 gtk_widget_set_visible(eb->widget, TRUE);
691}
692
693/************************************************************************/
702 static GdkPixbuf *create_terrain_pixbuf(struct terrain *pterrain)
703{
704 int w, h, i;
705 GdkPixbuf *pixbuf;
706 struct canvas canvas = FC_STATIC_CANVAS_INIT;
707 cairo_t *cr;
708
709 w = tileset_tile_width(tileset);
710 h = tileset_tile_height(tileset);
711
712 canvas.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
713
714 cr = cairo_create(canvas.surface);
715 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
716 cairo_paint(cr);
717 cairo_destroy(cr);
718
719 for (i = 0; i < 3; i++) {
720 struct drawn_sprite sprs[80];
721 int count = fill_basic_terrain_layer_sprite_array(tileset, sprs,
722 i, pterrain);
723
724 put_drawn_sprites(&canvas, 1.0, 0, 0, count, sprs, FALSE);
725 }
726
727 pixbuf = surface_get_pixbuf(canvas.surface, w, h);
728 cairo_surface_destroy(canvas.surface);
729
730 return pixbuf;
731}
732
733/************************************************************************/
736 static void clear_tool_store(GtkListStore *store)
737{
738 GtkTreeIter iter;
739 GtkTreeModel *model = GTK_TREE_MODEL(store);
740
741 if (gtk_tree_model_get_iter_first(model, &iter)) {
742 do {
743 GdkPixbuf *pixbuf;
744
745 gtk_tree_model_get(model, &iter, TVS_COL_IMAGE, &pixbuf, -1);
746 if (pixbuf != NULL) {
747 g_object_unref(pixbuf);
748 }
749 } while (gtk_tree_model_iter_next(model, &iter));
750 }
751
752 gtk_list_store_clear(store);
753}
754
755/************************************************************************/
758 static void clear_tool_stores(struct editbar *eb)
759{
760 clear_tool_store(eb->tool_selectors[ETT_TERRAIN]->store);
761 clear_tool_store(eb->tool_selectors[ETT_TERRAIN_RESOURCE]->store);
762 clear_tool_store(eb->tool_selectors[ETT_TERRAIN_SPECIAL]->store);
763 clear_tool_store(eb->tool_selectors[ETT_ROAD]->store);
764 clear_tool_store(eb->tool_selectors[ETT_MILITARY_BASE]->store);
765 clear_tool_store(eb->tool_selectors[ETT_UNIT]->store);
766}
767
768/************************************************************************/
771 static void editbar_reload_tileset(struct editbar *eb)
772{
773 GtkTreeIter iter;
774 GtkListStore *store;
775 GdkPixbuf *pixbuf;
776 struct sprite *sprite;
777 struct tool_value_selector *tvs;
778
779 if (eb == NULL || tileset == NULL) {
780 return;
781 }
782
783 clear_tool_stores(eb);
784
785 /* Reload terrains. */
786
787 tvs = eb->tool_selectors[ETT_TERRAIN];
788 store = tvs->store;
789
790 terrain_type_iterate(pterrain) {
791 gtk_list_store_append(store, &iter);
792 gtk_list_store_set(store, &iter,
793 TVS_COL_ID, terrain_number(pterrain),
794 TVS_COL_NAME, terrain_name_translation(pterrain),
795 -1);
796 pixbuf = create_terrain_pixbuf(pterrain);
797 if (pixbuf != NULL) {
798 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
799 g_object_unref(pixbuf);
800 }
801 } terrain_type_iterate_end;
802
803
804 /* Reload terrain resources. */
805
806 tvs = eb->tool_selectors[ETT_TERRAIN_RESOURCE];
807 store = tvs->store;
808
809 extra_type_by_cause_iterate(EC_RESOURCE, pextra) {
810 gtk_list_store_append(store, &iter);
811 gtk_list_store_set(store, &iter,
812 TVS_COL_ID, extra_index(pextra),
813 TVS_COL_NAME, extra_name_translation(pextra),
814 -1);
815 pixbuf = create_extra_pixbuf(pextra);
816 if (pixbuf != NULL) {
817 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
818 g_object_unref(pixbuf);
819 }
820 } extra_type_by_cause_iterate_end;
821
822 /* Reload terrain specials. */
823
824 tvs = eb->tool_selectors[ETT_TERRAIN_SPECIAL];
825 store = tvs->store;
826
827 extra_type_by_cause_iterate(EC_SPECIAL, pextra) {
828 gtk_list_store_append(store, &iter);
829 gtk_list_store_set(store, &iter,
830 TVS_COL_ID, extra_index(pextra),
831 TVS_COL_NAME, extra_name_translation(pextra),
832 -1);
833 pixbuf = create_extra_pixbuf(pextra);
834 if (pixbuf != NULL) {
835 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
836 g_object_unref(pixbuf);
837 }
838 } extra_type_by_cause_iterate_end;
839
840 /* Reload roads. */
841
842 tvs = eb->tool_selectors[ETT_ROAD];
843 store = tvs->store;
844
845 extra_type_by_cause_iterate(EC_ROAD, pextra) {
846 gtk_list_store_append(store, &iter);
847 gtk_list_store_set(store, &iter,
848 TVS_COL_ID, extra_index(pextra),
849 TVS_COL_NAME, extra_name_translation(pextra),
850 -1);
851 pixbuf = create_extra_pixbuf(pextra);
852 if (pixbuf != NULL) {
853 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
854 g_object_unref(pixbuf);
855 }
856 } extra_type_by_cause_iterate_end;
857
858 /* Reload military bases. */
859
860 tvs = eb->tool_selectors[ETT_MILITARY_BASE];
861 store = tvs->store;
862
863 extra_type_by_cause_iterate(EC_BASE, pextra) {
864 gtk_list_store_append(store, &iter);
865 gtk_list_store_set(store, &iter,
866 TVS_COL_ID, extra_index(pextra),
867 TVS_COL_NAME, extra_name_translation(pextra),
868 -1);
869 pixbuf = create_extra_pixbuf(pextra);
870 if (pixbuf != NULL) {
871 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
872 g_object_unref(pixbuf);
873 }
874 } extra_type_by_cause_iterate_end;
875
876
877 /* Reload unit types. */
878
879 tvs = eb->tool_selectors[ETT_UNIT];
880 store = tvs->store;
881
882 unit_type_iterate(putype) {
883 gtk_list_store_append(store, &iter);
884 gtk_list_store_set(store, &iter,
885 TVS_COL_ID, utype_number(putype),
886 TVS_COL_NAME, utype_name_translation(putype),
887 -1);
888 sprite = get_unittype_sprite(tileset, putype,
889 ACTIVITY_LAST, direction8_invalid());
890 if (sprite == NULL) {
891 continue;
892 }
893 pixbuf = sprite_get_pixbuf(sprite);
894 if (pixbuf != NULL) {
895 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
896 g_object_unref(G_OBJECT(pixbuf));
897 }
898 } unit_type_iterate_end;
899}
900
901/************************************************************************/
904 static int convert_modifiers(int gdk_event_state)
905{
906 int modifiers = EKM_NONE;
907
908 if (gdk_event_state & GDK_SHIFT_MASK) {
909 modifiers |= EKM_SHIFT;
910 }
911 if (gdk_event_state & GDK_CONTROL_MASK) {
912 modifiers |= EKM_CTRL;
913 }
914 if (gdk_event_state & GDK_ALT_MASK) {
915 modifiers |= EKM_ALT;
916 }
917
918 return modifiers;
919}
920
921/************************************************************************/
924 gboolean handle_edit_mouse_button_press(GtkGestureClick *gesture,
925 int editor_mouse_button,
926 double x, double y)
927{
928 GdkModifierType state;
929
930 state = gtk_event_controller_get_current_event_state(
931 GTK_EVENT_CONTROLLER(gesture));
932 editor_mouse_button_press(x, y, editor_mouse_button,
933 convert_modifiers(state));
934
935 return TRUE;
936}
937
938/************************************************************************/
941 gboolean handle_edit_mouse_button_release(GtkGestureClick *gesture,
942 int editor_mouse_button,
943 double x, double y)
944{
945 GdkModifierType state;
946
947 state = gtk_event_controller_get_current_event_state(GTK_EVENT_CONTROLLER(gesture));
948 editor_mouse_button_release(x, y,
949 editor_mouse_button,
950 convert_modifiers(state));
951 return TRUE;
952}
953
954/************************************************************************/
957 gboolean handle_edit_mouse_move(GtkEventControllerMotion *controller,
958 gdouble x, gdouble y)
959{
960 GdkModifierType state;
961
962 state = gtk_event_controller_get_current_event_state(GTK_EVENT_CONTROLLER(controller));
963 editor_mouse_move(x, y, convert_modifiers(state));
964
965 return TRUE;
966}
967
968/************************************************************************/
971 static void tool_value_selector_treeview_row_activated(GtkTreeView *view,
972 GtkTreePath *path,
973 GtkTreeViewColumn *col,
974 gpointer user_data)
975{
976 struct tool_value_selector *tvs = user_data;
977
978 gtk_dialog_response(GTK_DIALOG(tvs->dialog), GTK_RESPONSE_ACCEPT);
979}
980
981/************************************************************************/
984static struct tool_value_selector *
985 create_tool_value_selector(struct editbar *eb,
986 enum editor_tool_type ett)
987{
988 struct tool_value_selector *tvs;
989 GtkWidget *vbox, *view, *scrollwin;
990 GtkCellRenderer *cell;
991 GtkListStore *store;
992 GtkTreeViewColumn *col;
993 GtkTreeSelection *sel;
994
995 tvs = fc_calloc(1, sizeof(struct tool_value_selector));
996
997 tvs->editbar_parent = eb;
998
999 tvs->dialog = gtk_dialog_new_with_buttons(_("Select Tool Value"),
1000 GTK_WINDOW(toplevel),
1001 GTK_DIALOG_MODAL,
1002 _("_OK"), GTK_RESPONSE_ACCEPT,
1003 _("_Cancel"), GTK_RESPONSE_REJECT,
1004 NULL);
1005 vbox = gtk_dialog_get_content_area(GTK_DIALOG(tvs->dialog));
1006
1007 store = gtk_list_store_new(TVS_NUM_COLS,
1008 GDK_TYPE_PIXBUF,
1009 G_TYPE_INT,
1010 G_TYPE_STRING);
1011 tvs->store = store;
1012
1013 scrollwin = gtk_scrolled_window_new();
1014 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(scrollwin), TRUE);
1015 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
1016 GTK_POLICY_NEVER,
1017 GTK_POLICY_AUTOMATIC);
1018 gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(scrollwin),
1019 10 * tileset_tile_height(tileset));
1020 gtk_box_insert_child_after(GTK_BOX(vbox), scrollwin, NULL);
1021
1022 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(tvs->store));
1023 gtk_widget_set_size_request(view, -1, 10 * tileset_tile_height(tileset));
1024 gtk_tree_view_set_search_column(GTK_TREE_VIEW(view), TVS_COL_NAME);
1025 g_signal_connect(view, "row-activated",
1026 G_CALLBACK(tool_value_selector_treeview_row_activated), tvs);
1027
1028 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1029 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
1030
1031 cell = gtk_cell_renderer_pixbuf_new();
1032 col = gtk_tree_view_column_new_with_attributes(editor_tool_get_name(ett),
1033 cell, "pixbuf",
1034 TVS_COL_IMAGE, NULL);
1035 gtk_tree_view_column_set_resizable(col, FALSE);
1036 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
1037 gtk_tree_view_column_set_reorderable(col, FALSE);
1038 gtk_tree_view_column_set_clickable(col, FALSE);
1039 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1040
1041 cell = gtk_cell_renderer_text_new();
1042 col = gtk_tree_view_column_new_with_attributes("ID", cell,
1043 "text", TVS_COL_ID, NULL);
1044 gtk_tree_view_column_set_resizable(col, FALSE);
1045 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
1046 gtk_tree_view_column_set_reorderable(col, FALSE);
1047 gtk_tree_view_column_set_clickable(col, FALSE);
1048 gtk_tree_view_column_set_sort_column_id(col, TVS_COL_ID);
1049 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1050
1051 cell = gtk_cell_renderer_text_new();
1052 col = gtk_tree_view_column_new_with_attributes("Name", cell,
1053 "text", TVS_COL_NAME, NULL);
1054 gtk_tree_view_column_set_resizable(col, FALSE);
1055 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
1056 gtk_tree_view_column_set_reorderable(col, FALSE);
1057 gtk_tree_view_column_set_clickable(col, FALSE);
1058 gtk_tree_view_column_set_sort_column_id(col, TVS_COL_NAME);
1059 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1060
1061 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scrollwin), view);
1062 tvs->view = view;
1063
1064 /* Show everything but the window itself. */
1065 gtk_widget_set_visible(vbox, TRUE);
1066
1067 return tvs;
1068}
1069
1070/************************************************************************/
1073 static gboolean editinfobox_handle_tool_image_button_press(
1074 GtkGestureClick *gesture,
1075 int n_press,
1076 double x, double y)
1077{
1078 editgui_run_tool_selection(editor_get_tool());
1079
1080 return TRUE;
1081}
1082
1083/************************************************************************/
1086 static gboolean editinfobox_handle_mode_image_button_press(
1087 GtkGestureClick *gesture,
1088 int n_press,
1089 double x, double y)
1090{
1091 editor_tool_cycle_mode(editor_get_tool());
1092 editgui_refresh();
1093
1094 return TRUE;
1095}
1096
1097/************************************************************************/
1100 static void editinfobox_spin_button_value_changed(GtkSpinButton *spinbutton,
1101 gpointer userdata)
1102{
1103 struct editinfobox *ei;
1104 int which, value;
1105 enum editor_tool_type ett;
1106
1107 ei = editgui_get_editinfobox();
1108
1109 if (!ei) {
1110 return;
1111 }
1112
1113 value = gtk_spin_button_get_value_as_int(spinbutton);
1114 which = GPOINTER_TO_INT(userdata);
1115 ett = editor_get_tool();
1116
1117 switch (which) {
1118 case SPIN_BUTTON_SIZE:
1119 editor_tool_set_size(ett, value);
1120 break;
1121 case SPIN_BUTTON_COUNT:
1122 editor_tool_set_count(ett, value);
1123 break;
1124 default:
1125 return;
1126 break;
1127 }
1128
1129 editinfobox_refresh(ei);
1130}
1131
1132/************************************************************************/
1136 static void editinfobox_tool_applied_player_changed(GtkComboBox *combo,
1137 gpointer userdata)
1138{
1139 struct editinfobox *ei = userdata;
1140 GtkTreeIter iter;
1141 GtkTreeModel *model;
1142 int player_no = -1;
1143
1144 if (ei == NULL) {
1145 return;
1146 }
1147
1148 if (!gtk_combo_box_get_active_iter(combo, &iter)) {
1149 return;
1150 }
1151
1152 model = gtk_combo_box_get_model(combo);
1153 gtk_tree_model_get(model, &iter, TAP_COL_PLAYER_NO, &player_no, -1);
1154
1155 editor_tool_set_applied_player(editor_get_tool(), player_no);
1156}
1157
1158/************************************************************************/
1161 static struct editinfobox *editinfobox_create(void)
1162{
1163 GtkWidget *label, *vbox, *frame, *hgrid, *vbox2, *pic;
1164 GtkWidget *spin, *combo;
1165 GtkListStore *store;
1166 GtkCellRenderer *cell;
1167 GtkEventController *controller;
1168 struct editinfobox *ei;
1169 char buf[128];
1170 int grid_col = 0;
1171
1172 ei = fc_calloc(1, sizeof(*ei));
1173
1174 /* If you turn this to something else than GtkFrame, also adjust
1175 * editgui.c replace_widget() code that replaces widget in it. */
1176 frame = gtk_frame_new(_("Editor Tool"));
1177 gtk_widget_set_margin_start(frame, 4);
1178 gtk_widget_set_margin_end(frame, 4);
1179 gtk_widget_set_margin_top(frame, 4);
1180 gtk_widget_set_margin_bottom(frame, 4);
1181 ei->widget = frame;
1182
1183 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
1184 gtk_widget_set_margin_start(vbox, 4);
1185 gtk_widget_set_margin_end(vbox, 4);
1186 gtk_widget_set_margin_top(vbox, 4);
1187 gtk_widget_set_margin_bottom(vbox, 4);
1188 gtk_frame_set_child(GTK_FRAME(frame), vbox);
1189
1190 /* Tool section */
1191 hgrid = gtk_grid_new();
1192 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 8);
1193 gtk_box_append(GTK_BOX(vbox), hgrid);
1194
1195 pic = gtk_picture_new();
1196 gtk_widget_set_tooltip_text(pic, _("Click to change value if applicable."));
1197
1198 controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
1199 g_signal_connect(controller, "pressed",
1200 G_CALLBACK(editinfobox_handle_tool_image_button_press),
1201 NULL);
1202 gtk_widget_add_controller(pic, controller);
1203
1204 gtk_grid_attach(GTK_GRID(hgrid), pic, grid_col++, 0, 1, 1);
1205 ei->tool_pic = pic;
1206
1207 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
1208 gtk_grid_attach(GTK_GRID(hgrid), vbox2, grid_col++, 0, 1, 1);
1209
1210 label = gtk_label_new(NULL);
1211 gtk_widget_set_halign(label, GTK_ALIGN_START);
1212 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1213 gtk_box_append(GTK_BOX(vbox2), label);
1214 ei->tool_label = label;
1215
1216 label = gtk_label_new(NULL);
1217 gtk_widget_set_halign(label, GTK_ALIGN_START);
1218 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1219 gtk_box_append(GTK_BOX(vbox2), label);
1220 ei->tool_value_label = label;
1221
1222 /* Mode section */
1223 hgrid = gtk_grid_new();
1224 grid_col = 0;
1225 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 8);
1226 gtk_box_append(GTK_BOX(vbox), hgrid);
1227
1228 pic = gtk_picture_new();
1229 gtk_widget_set_tooltip_text(pic, _("Click to change tool mode."));
1230
1231 controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
1232 g_signal_connect(controller, "pressed",
1233 G_CALLBACK(editinfobox_handle_mode_image_button_press),
1234 NULL);
1235 gtk_widget_add_controller(pic, controller);
1236
1237 gtk_grid_attach(GTK_GRID(hgrid), pic, grid_col++, 0, 1, 1);
1238 ei->mode_pic = pic;
1239
1240 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
1241 gtk_grid_attach(GTK_GRID(hgrid), vbox2, grid_col++, 0, 1, 1);
1242
1243 label = gtk_label_new(NULL);
1244 fc_snprintf(buf, sizeof(buf), "<span weight=\"bold\">%s</span>",
1245 _("Mode"));
1246 gtk_label_set_markup(GTK_LABEL(label), buf);
1247 gtk_widget_set_halign(label, GTK_ALIGN_START);
1248 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1249 gtk_box_append(GTK_BOX(vbox2), label);
1250
1251 label = gtk_label_new(NULL);
1252 gtk_widget_set_halign(label, GTK_ALIGN_START);
1253 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1254 gtk_box_append(GTK_BOX(vbox2), label);
1255 ei->mode_label = label;
1256
1257 /* Spinner section */
1258 hgrid = gtk_grid_new();
1259 grid_col = 0;
1260 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 8);
1261 gtk_box_append(GTK_BOX(vbox), hgrid);
1262 ei->size_hbox = hgrid;
1263 spin = gtk_spin_button_new_with_range(1, 255, 1);
1264 gtk_widget_set_tooltip_text(spin,
1265 _("Use this to change the \"size\" parameter for the tool. "
1266 "This parameter controls for example the half-width "
1267 "of the square of tiles that will be affected by the "
1268 "tool, or the size of a created city."));
1269 g_signal_connect(spin, "value-changed",
1270 G_CALLBACK(editinfobox_spin_button_value_changed),
1271 GINT_TO_POINTER(SPIN_BUTTON_SIZE));
1272 gtk_grid_attach(GTK_GRID(hgrid), spin, grid_col++, 0, 1, 1);
1273 ei->size_spin_button = spin;
1274 label = gtk_label_new(_("Size"));
1275 gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1);
1276
1277 hgrid = gtk_grid_new();
1278 grid_col = 0;
1279 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 8);
1280 gtk_box_append(GTK_BOX(vbox), hgrid);
1281 ei->count_hbox = hgrid;
1282 spin = gtk_spin_button_new_with_range(1, 255, 1);
1283 gtk_widget_set_tooltip_text(spin,
1284 _("Use this to change the tool's \"count\" parameter. "
1285 "This controls for example how many units are placed "
1286 "at once with the unit tool."));
1287 g_signal_connect(spin, "value-changed",
1288 G_CALLBACK(editinfobox_spin_button_value_changed),
1289 GINT_TO_POINTER(SPIN_BUTTON_COUNT));
1290 gtk_grid_attach(GTK_GRID(hgrid), spin, grid_col++, 0, 1, 1);
1291 ei->count_spin_button = spin;
1292 label = gtk_label_new(_("Count"));
1293 gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1);
1294
1295 /* combo section */
1296 store = gtk_list_store_new(TAP_NUM_COLS,
1297 GDK_TYPE_PIXBUF,
1298 G_TYPE_STRING,
1299 G_TYPE_INT);
1300 ei->tool_applied_player_store = store;
1301 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
1302
1303 cell = gtk_cell_renderer_pixbuf_new();
1304 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, FALSE);
1305 gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo),
1306 cell, "pixbuf", TAP_COL_FLAG);
1307
1308 cell = gtk_cell_renderer_text_new();
1309 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, TRUE);
1310 gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo),
1311 cell, "text", TAP_COL_NAME);
1312
1313 gtk_widget_set_size_request(combo, 132, -1);
1314 g_signal_connect(combo, "changed",
1315 G_CALLBACK(editinfobox_tool_applied_player_changed), ei);
1316
1317 gtk_widget_set_tooltip_text(combo,
1318 _("Use this to change the \"applied player\" tool parameter. "
1319 "This controls for example under which player units and cities "
1320 "are created."));
1321 gtk_box_append(GTK_BOX(vbox), combo);
1322 ei->tool_applied_player_combobox = combo;
1323
1324 /* We add a ref to the editinfobox widget so that it is
1325 * not destroyed when replaced by the unit info box when
1326 * we leave edit mode. See editinfobox_refresh() call to replace_widget() */
1327 g_object_ref(ei->widget);
1328
1329 /* The edit info box starts with no parent, so we have to
1330 * show its internal widgets manually. */
1331 gtk_widget_set_visible(ei->widget, TRUE);
1332
1333 return ei;
1334}
1335
1336/************************************************************************/
1340 static void refresh_tool_applied_player_combo(struct editinfobox *ei)
1341{
1342 enum editor_tool_type ett;
1343 GtkListStore *store;
1344 GtkWidget *combo;
1345 GtkTreeIter iter;
1346 GdkPixbuf *flag;
1347 int apno, index, i;
1348
1349 if (!ei) {
1350 return;
1351 }
1352
1353 ett = editor_get_tool();
1354 combo = ei->tool_applied_player_combobox;
1355 store = ei->tool_applied_player_store;
1356
1357 if (!combo || !store) {
1358 return;
1359 }
1360
1361 if (!editor_tool_has_applied_player(ett)) {
1362 gtk_widget_set_visible(combo, FALSE);
1363 return;
1364 }
1365
1366 gtk_list_store_clear(store);
1367
1368 apno = editor_tool_get_applied_player(ett);
1369 index = -1;
1370 i = 0;
1371
1372 players_iterate(pplayer) {
1373 gtk_list_store_append(store, &iter);
1374 gtk_list_store_set(store, &iter,
1375 TAP_COL_PLAYER_NO, player_number(pplayer),
1376 TAP_COL_NAME, player_name(pplayer), -1);
1377
1378 if (pplayer->nation != NO_NATION_SELECTED) {
1379 flag = get_flag(pplayer->nation);
1380
1381 if (flag != NULL) {
1382 gtk_list_store_set(store, &iter, TAP_COL_FLAG, flag, -1);
1383 g_object_unref(flag);
1384 }
1385 }
1386 if (apno == player_number(pplayer)) {
1387 index = i;
1388 }
1389 i++;
1390 } players_iterate_end;
1391
1392 if (index == -1) {
1393 if (player_count() > 0) {
1394 index = 0;
1395 }
1396 editor_tool_set_applied_player(ett, index);
1397 }
1398 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), index);
1399 gtk_widget_set_visible(combo, TRUE);
1400}
1401
1402/************************************************************************/
1408 static GdkPixbuf *get_tool_value_pixbuf(enum editor_tool_type ett,
1409 int value)
1410{
1411 struct sprite *sprite = NULL;
1412 GdkPixbuf *pixbuf = NULL;
1413 struct terrain *pterrain;
1414 struct unit_type *putype;
1415 const struct editor_sprites *sprites;
1416
1417 sprites = get_editor_sprites(tileset);
1418 if (!sprites) {
1419 return NULL;
1420 }
1421
1422 switch (ett) {
1423 case ETT_TERRAIN:
1424 pterrain = terrain_by_number(value);
1425 if (pterrain) {
1426 pixbuf = create_terrain_pixbuf(pterrain);
1427 }
1428 break;
1429 case ETT_TERRAIN_RESOURCE:
1430 case ETT_TERRAIN_SPECIAL:
1431 case ETT_ROAD:
1432 case ETT_MILITARY_BASE:
1433 if (value >= 0) {
1434 pixbuf = create_extra_pixbuf(extra_by_number(value));
1435 }
1436 break;
1437 case ETT_UNIT:
1438 putype = utype_by_number(value);
1439 if (putype) {
1440 sprite = get_unittype_sprite(tileset, putype,
1441 ACTIVITY_LAST, direction8_invalid());
1442 }
1443 break;
1444 case ETT_CITY:
1445 sprite = sprites->city;
1446 break;
1447 case ETT_VISION:
1448 sprite = sprites->vision;
1449 break;
1450 case ETT_STARTPOS:
1451 sprite = sprites->startpos;
1452 break;
1453 case ETT_COPYPASTE:
1454 sprite = sprites->copypaste;
1455 break;
1456 default:
1457 break;
1458 }
1459
1460 if (sprite) {
1461 pixbuf = sprite_get_pixbuf(sprite);
1462 /*
1463 if (pixbuf) {
1464 g_object_ref(pixbuf);
1465 }
1466 */
1467 sprite = NULL;
1468 }
1469
1470 return pixbuf;
1471}
1472
1473/************************************************************************/
1479 static GdkPixbuf *get_tool_mode_pixbuf(enum editor_tool_mode etm)
1480{
1481 struct sprite *sprite = NULL;
1482 GdkPixbuf *pixbuf = NULL;
1483
1484 sprite = editor_get_mode_sprite(etm);
1485
1486 if (sprite) {
1487 pixbuf = sprite_get_pixbuf(sprite);
1488 /*
1489 if (pixbuf) {
1490 g_object_ref(pixbuf);
1491 }
1492 */
1493 }
1494
1495 return pixbuf;
1496}
1497
1498/************************************************************************/
1503 static void replace_widget(GtkWidget *old, GtkWidget *new)
1504{
1505 GtkWidget *parent;
1506
1507 parent = gtk_widget_get_parent(old);
1508 if (parent == NULL) {
1509 return;
1510 }
1511
1512 gtk_widget_set_visible(old, FALSE);
1513
1514 if (GTK_IS_FRAME(parent)) {
1515 gtk_frame_set_child(GTK_FRAME(parent), new);
1516 } else {
1517 fc_assert(GTK_IS_BOX(parent));
1518
1519 gtk_box_remove(GTK_BOX(parent), old);
1520 gtk_box_append(GTK_BOX(parent), new);
1521 }
1522
1523 gtk_widget_set_visible(new, TRUE);
1524}
1525
1526/************************************************************************/
1529 static void editinfobox_refresh(struct editinfobox *ei)
1530{
1531 GdkPixbuf *pixbuf = NULL;
1532 GtkLabel *label;
1533 enum editor_tool_type ett;
1534 enum editor_tool_mode etm;
1535 int value;
1536 char buf[256];
1537
1538 if (ei == NULL) {
1539 return;
1540 }
1541
1542 if (!editor_is_active()) {
1543 replace_widget(ei->widget, unit_info_box);
1544 return;
1545 }
1546
1547 ett = editor_get_tool();
1548 etm = editor_tool_get_mode(ett);
1549 value = editor_tool_get_value(ett);
1550
1551 label = GTK_LABEL(ei->mode_label);
1552 gtk_label_set_text(label, editor_tool_get_mode_name(ett, etm));
1553
1554 pixbuf = get_tool_mode_pixbuf(etm);
1555 gtk_picture_set_pixbuf(GTK_PICTURE(ei->mode_pic), pixbuf);
1556 if (pixbuf) {
1557 g_object_unref(pixbuf);
1558 pixbuf = NULL;
1559 }
1560
1561 fc_snprintf(buf, sizeof(buf), "<span weight=\"bold\">%s</span>",
1562 editor_tool_get_name(ett));
1563 gtk_label_set_markup(GTK_LABEL(ei->tool_label), buf);
1564
1565 if (etm == ETM_COPY || etm == ETM_PASTE) {
1566 struct edit_buffer *ebuf;
1567 struct sprite *spr;
1568 char status[256];
1569
1570 ebuf = editor_get_copy_buffer();
1571 edit_buffer_get_status_string(ebuf, status, sizeof(status));
1572 gtk_label_set_text(GTK_LABEL(ei->tool_value_label), status);
1573
1574 spr = editor_tool_get_sprite(ett);
1575 pixbuf = spr ? sprite_get_pixbuf(spr) : NULL;
1576 gtk_picture_set_pixbuf(GTK_PICTURE(ei->tool_pic), pixbuf);
1577 if (pixbuf) {
1578 g_object_unref(G_OBJECT(pixbuf));
1579 pixbuf = NULL;
1580 }
1581 } else {
1582 pixbuf = get_tool_value_pixbuf(ett, value);
1583 gtk_picture_set_pixbuf(GTK_PICTURE(ei->tool_pic), pixbuf);
1584 if (pixbuf) {
1585 g_object_unref(pixbuf);
1586 pixbuf = NULL;
1587 }
1588 gtk_label_set_text(GTK_LABEL(ei->tool_value_label),
1589 editor_tool_get_value_name(ett, value));
1590 }
1591
1592 replace_widget(unit_info_box, ei->widget);
1593
1594 if (editor_tool_has_size(ett)) {
1595 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ei->size_spin_button),
1596 editor_tool_get_size(ett));
1597 gtk_widget_set_visible(ei->size_hbox, TRUE);
1598 } else {
1599 gtk_widget_set_visible(ei->size_hbox, FALSE);
1600 }
1601
1602 if (editor_tool_has_count(ett)) {
1603 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ei->count_spin_button),
1604 editor_tool_get_count(ett));
1605 gtk_widget_set_visible(ei->count_hbox, TRUE);
1606 } else {
1607 gtk_widget_set_visible(ei->count_hbox, FALSE);
1608 }
1609
1610 refresh_tool_applied_player_combo(ei);
1611}
1612
1613/************************************************************************/
1616 static gboolean handle_edit_key_press_with_ctrl(guint keyval)
1617{
1618 return FALSE; /* Don't gobble. */
1619}
1620
1621/************************************************************************/
1624 static gboolean handle_edit_key_press_with_shift(guint keyval)
1625{
1626 enum editor_tool_type ett;
1627
1628 ett = editor_get_tool();
1629 switch (keyval) {
1630 case GDK_KEY_D:
1631 editor_tool_toggle_mode(ett, ETM_ERASE);
1632 break;
1633 case GDK_KEY_C:
1634 editor_set_tool(ETT_COPYPASTE);
1635 editor_tool_toggle_mode(ett, ETM_COPY);
1636 break;
1637 case GDK_KEY_V:
1638 editor_set_tool(ETT_COPYPASTE);
1639 editor_tool_toggle_mode(ett, ETM_PASTE);
1640 break;
1641 case GDK_KEY_T:
1642 editgui_run_tool_selection(ETT_TERRAIN);
1643 break;
1644 case GDK_KEY_R:
1645 editgui_run_tool_selection(ETT_TERRAIN_RESOURCE);
1646 break;
1647 case GDK_KEY_S:
1648 editgui_run_tool_selection(ETT_TERRAIN_SPECIAL);
1649 break;
1650 case GDK_KEY_P:
1651 editgui_run_tool_selection(ETT_ROAD);
1652 break;
1653 case GDK_KEY_M:
1654 editgui_run_tool_selection(ETT_MILITARY_BASE);
1655 break;
1656 case GDK_KEY_U:
1657 editgui_run_tool_selection(ETT_UNIT);
1658 break;
1659 default:
1660 return TRUE; /* Gobble? */
1661 break;
1662 }
1663
1664 editgui_refresh();
1665
1666 return TRUE;
1667}
1668
1669/************************************************************************/
1672 gboolean handle_edit_key_press(guint keyval, GdkModifierType state)
1673{
1674 enum editor_tool_type ett, new_ett = NUM_EDITOR_TOOL_TYPES;
1675
1676 /* Check ctrl before shift - this is correct also for the case where
1677 * they are both active. */
1678 if (state & GDK_CONTROL_MASK) {
1679 return handle_edit_key_press_with_ctrl(keyval);
1680 }
1681
1682 if (state & GDK_SHIFT_MASK) {
1683 return handle_edit_key_press_with_shift(keyval);
1684 }
1685
1686 ett = editor_get_tool();
1687
1688 switch (keyval) {
1689 case GDK_KEY_t:
1690 new_ett = ETT_TERRAIN;
1691 break;
1692 case GDK_KEY_r:
1693 new_ett = ETT_TERRAIN_RESOURCE;
1694 break;
1695 case GDK_KEY_s:
1696 new_ett = ETT_TERRAIN_SPECIAL;
1697 break;
1698 case GDK_KEY_p:
1699 new_ett = ETT_ROAD;
1700 break;
1701 case GDK_KEY_m:
1702 new_ett = ETT_MILITARY_BASE;
1703 break;
1704 case GDK_KEY_u:
1705 new_ett = ETT_UNIT;
1706 break;
1707 case GDK_KEY_c:
1708 new_ett = ETT_CITY;
1709 break;
1710 case GDK_KEY_v:
1711 new_ett = ETT_VISION;
1712 break;
1713 case GDK_KEY_b:
1714 new_ett = ETT_STARTPOS;
1715 break;
1716 case GDK_KEY_plus:
1717 case GDK_KEY_equal:
1718 case GDK_KEY_KP_Add:
1719 if (editor_tool_has_size(ett)) {
1720 int size = editor_tool_get_size(ett);
1721
1722 editor_tool_set_size(ett, size + 1);
1723 } else if (editor_tool_has_count(ett)) {
1724 int count = editor_tool_get_count(ett);
1725
1726 editor_tool_set_count(ett, count + 1);
1727 }
1728 break;
1729 case GDK_KEY_minus:
1730 case GDK_KEY_underscore:
1731 case GDK_KEY_KP_Subtract:
1732 if (editor_tool_has_size(ett)) {
1733 int size = editor_tool_get_size(ett);
1734
1735 editor_tool_set_size(ett, size - 1);
1736 } else if (editor_tool_has_count(ett)) {
1737 int count = editor_tool_get_count(ett);
1738
1739 editor_tool_set_count(ett, count - 1);
1740 }
1741 break;
1742 case GDK_KEY_1:
1743 case GDK_KEY_2:
1744 case GDK_KEY_3:
1745 case GDK_KEY_4:
1746 case GDK_KEY_5:
1747 case GDK_KEY_6:
1748 case GDK_KEY_7:
1749 case GDK_KEY_8:
1750 case GDK_KEY_9:
1751 if (editor_tool_has_size(ett)) {
1752 editor_tool_set_size(ett, keyval - GDK_KEY_1 + 1);
1753 } else if (editor_tool_has_count(ett)) {
1754 editor_tool_set_count(ett, keyval - GDK_KEY_1 + 1);
1755 }
1756 break;
1757 case GDK_KEY_space:
1758 editor_apply_tool_to_selection();
1759 break;
1760 case GDK_KEY_Tab:
1761 editgui_run_tool_selection(ett);
1762 break;
1763 case GDK_KEY_F1:
1764 case GDK_KEY_F2:
1765 case GDK_KEY_F3:
1766 case GDK_KEY_F4:
1767 case GDK_KEY_F5:
1768 case GDK_KEY_F6:
1769 case GDK_KEY_F7:
1770 case GDK_KEY_F8:
1771 case GDK_KEY_F9:
1772 case GDK_KEY_F10:
1773 case GDK_KEY_F11:
1774 case GDK_KEY_F12:
1775 return FALSE; /* Allow default handler. */
1776 break;
1777 default:
1778 return TRUE; /* Gobbled... */
1779 break;
1780 }
1781
1782 if (new_ett != NUM_EDITOR_TOOL_TYPES) {
1783 try_to_set_editor_tool(new_ett);
1784 }
1785
1786 editgui_refresh();
1787
1788 return TRUE;
1789}
1790
1791/************************************************************************/
1794 struct editbar *editgui_get_editbar(void)
1795{
1796 return editor_toolbar;
1797}
1798
1799/************************************************************************/
1802 void editgui_refresh(void)
1803{
1804 struct property_editor *pe;
1805 struct editbar *eb;
1806 struct editinfobox *ei;
1807
1808 eb = editgui_get_editbar();
1809 if (eb != NULL) {
1810 editbar_refresh(eb);
1811 }
1812
1813 ei = editgui_get_editinfobox();
1814 if (ei != NULL) {
1815 editinfobox_refresh(ei);
1816 }
1817
1818 pe = editprop_get_property_editor();
1819 if (!editor_is_active()) {
1820 property_editor_clear(pe);
1821 property_editor_popdown(pe);
1822 }
1823}
1824
1825/************************************************************************/
1828 void editgui_create_widgets(void)
1829{
1830 if (editor_toolbar == NULL) {
1831 editor_toolbar = editbar_create();
1832 }
1833 if (editor_infobox == NULL) {
1834 editor_infobox = editinfobox_create();
1835 }
1836}
1837
1838/************************************************************************/
1841 void editgui_free(void)
1842{
1843 struct editbar *eb = editgui_get_editbar();
1844 struct editinfobox *ei = editgui_get_editinfobox();
1845
1846 if (ei != NULL) {
1847 /* We have extra ref for ei->widget that has protected
1848 * it from getting destroyed when editinfobox_refresh()
1849 * moves widgets around. Free that extra ref here. */
1850 g_object_unref(ei->widget);
1851 }
1852
1853 clear_tool_stores(eb);
1854}
1855
1856/************************************************************************/
1859 struct editinfobox *editgui_get_editinfobox(void)
1860{
1861 return editor_infobox;
1862}
1863
1864/************************************************************************/
1868 void editgui_tileset_changed(void)
1869{
1870 editbar_reload_tileset(editgui_get_editbar());
1871 editinfobox_refresh(editgui_get_editinfobox());
1872}
1873
1874/************************************************************************/
1881 void editgui_popup_properties(const struct tile_list *tiles, int objtype)
1882{
1883 struct property_editor *pe;
1884
1885 pe = editprop_get_property_editor();
1886 property_editor_clear(pe);
1887 property_editor_reload(pe, OBJTYPE_PLAYER);
1888 property_editor_reload(pe, OBJTYPE_GAME);
1889 property_editor_load_tiles(pe, tiles);
1890 property_editor_popup(pe, objtype);
1891}
1892
1893/************************************************************************/
1896 void editgui_popdown_all(void)
1897{
1898 struct property_editor *pe;
1899
1900 pe = editprop_get_property_editor();
1901 property_editor_popdown(pe);
1902 property_editor_clear(pe); /* And clear it. */
1903}
1904
1905/************************************************************************/
1913 void editgui_notify_object_changed(int objtype, int object_id, bool removal)
1914{
1915 struct property_editor *pe;
1916
1917 if (!editor_is_active()) {
1918 return;
1919 }
1920
1921 pe = editprop_get_property_editor();
1922 property_editor_handle_object_changed(pe, objtype, object_id, removal);
1923}
1924
1925/************************************************************************/
1928 void editgui_notify_object_created(int tag, int id)
1929{
1930 struct property_editor *pe;
1931
1932 if (!editor_is_active()) {
1933 return;
1934 }
1935
1936 pe = editprop_get_property_editor();
1937 property_editor_handle_object_created(pe, tag, id);
1938}
send_chat_printf
int send_chat_printf(const char *format,...)
Definition chatline_common.c:55
send_chat
int send_chat(const char *message)
Definition chatline_common.c:46
chatline_common.h
client_is_global_observer
bool client_is_global_observer(void)
Definition client_main.c:1345
client_player_number
int client_player_number(void)
Definition client_main.c:1353
client_main.h
client_player
#define client_player()
Definition client_main.h:106
incite_cost
char * incite_cost
Definition comments.c:74
connection.h
dialogs_g.h
objtype
int objtype
Definition editgui_g.h:28
editgui_notify_object_changed
editgui_notify_object_changed
Definition editgui_g.h:27
id
int int id
Definition editgui_g.h:28
edit_buffer_get_status_string
int edit_buffer_get_status_string(const struct edit_buffer *ebuf, char *buf, int buflen)
Definition editor.c:1870
editor_is_active
bool editor_is_active(void)
Definition editor.c:346
editor_tool_get_size
int editor_tool_get_size(enum editor_tool_type ett)
Definition editor.c:1218
editor_set_tool
void editor_set_tool(enum editor_tool_type ett)
Definition editor.c:270
editor_mouse_button_press
void editor_mouse_button_press(int canvas_x, int canvas_y, int button, int modifiers)
Definition editor.c:661
editor_mouse_move
void editor_mouse_move(int canvas_x, int canvas_y, int modifiers)
Definition editor.c:866
editor_tool_get_mode
enum editor_tool_mode editor_tool_get_mode(enum editor_tool_type ett)
Definition editor.c:335
editor_tool_set_count
void editor_tool_set_count(enum editor_tool_type ett, int count)
Definition editor.c:1263
editor_tool_toggle_mode
void editor_tool_toggle_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:1041
editor_tool_get_value_name
const char * editor_tool_get_value_name(enum editor_tool_type emt, int value)
Definition editor.c:1172
editor_tool_get_value
int editor_tool_get_value(enum editor_tool_type ett)
Definition editor.c:409
editor_get_copy_buffer
struct edit_buffer * editor_get_copy_buffer(void)
Definition editor.c:1767
editor_tool_set_applied_player
void editor_tool_set_applied_player(enum editor_tool_type ett, int player_no)
Definition editor.c:1352
editor_tool_get_mode_name
const char * editor_tool_get_mode_name(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:1778
editor_tool_cycle_mode
void editor_tool_cycle_mode(enum editor_tool_type ett)
Definition editor.c:1058
editor_tool_get_count
int editor_tool_get_count(enum editor_tool_type ett)
Definition editor.c:1252
editor_tool_set_size
void editor_tool_set_size(enum editor_tool_type ett, int size)
Definition editor.c:1229
editor_get_mode_tooltip
const char * editor_get_mode_tooltip(enum editor_tool_mode etm)
Definition editor.c:1815
editor_tool_is_usable
bool editor_tool_is_usable(enum editor_tool_type ett)
Definition editor.c:359
editor_get_tool
enum editor_tool_type editor_get_tool(void)
Definition editor.c:286
editor_tool_has_applied_player
bool editor_tool_has_applied_player(enum editor_tool_type ett)
Definition editor.c:1365
editor_tool_has_size
bool editor_tool_has_size(enum editor_tool_type ett)
Definition editor.c:1207
editor_tool_set_value
void editor_tool_set_value(enum editor_tool_type ett, int value)
Definition editor.c:397
editor_tool_has_value
bool editor_tool_has_value(enum editor_tool_type ett)
Definition editor.c:385
editor_tool_get_tooltip
const char * editor_tool_get_tooltip(enum editor_tool_type ett)
Definition editor.c:1327
editor_mouse_button_release
void editor_mouse_button_release(int canvas_x, int canvas_y, int button, int modifiers)
Definition editor.c:798
editor_tool_get_sprite
struct sprite * editor_tool_get_sprite(enum editor_tool_type ett)
Definition editor.c:1275
editor_apply_tool_to_selection
void editor_apply_tool_to_selection(void)
Definition editor.c:1128
editor_tool_has_mode
bool editor_tool_has_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:313
editor_tool_get_applied_player
int editor_tool_get_applied_player(enum editor_tool_type ett)
Definition editor.c:1341
editor_tool_has_count
bool editor_tool_has_count(enum editor_tool_type ett)
Definition editor.c:1241
editor_get_mode_sprite
struct sprite * editor_get_mode_sprite(enum editor_tool_mode etm)
Definition editor.c:1837
editor_tool_get_name
const char * editor_tool_get_name(enum editor_tool_type ett)
Definition editor.c:1159
editor_tool_set_mode
void editor_tool_set_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:298
editor.h
editor_tool_mode
editor_tool_mode
Definition editor.h:52
ETM_PASTE
@ ETM_PASTE
Definition editor.h:56
NUM_EDITOR_TOOL_MODES
@ NUM_EDITOR_TOOL_MODES
Definition editor.h:58
ETM_ERASE
@ ETM_ERASE
Definition editor.h:54
ETM_PAINT
@ ETM_PAINT
Definition editor.h:53
ETM_COPY
@ ETM_COPY
Definition editor.h:55
OBJTYPE_PLAYER
@ OBJTYPE_PLAYER
Definition editor.h:30
OBJTYPE_GAME
@ OBJTYPE_GAME
Definition editor.h:31
EKM_CTRL
@ EKM_CTRL
Definition editor.h:120
EKM_SHIFT
@ EKM_SHIFT
Definition editor.h:118
EKM_ALT
@ EKM_ALT
Definition editor.h:119
EKM_NONE
@ EKM_NONE
Definition editor.h:117
editor_tool_type
editor_tool_type
Definition editor.h:36
ETT_ROAD
@ ETT_ROAD
Definition editor.h:40
ETT_TERRAIN_SPECIAL
@ ETT_TERRAIN_SPECIAL
Definition editor.h:39
ETT_UNIT
@ ETT_UNIT
Definition editor.h:42
ETT_VISION
@ ETT_VISION
Definition editor.h:44
ETT_STARTPOS
@ ETT_STARTPOS
Definition editor.h:46
NUM_EDITOR_TOOL_TYPES
@ NUM_EDITOR_TOOL_TYPES
Definition editor.h:49
ETT_CITY
@ ETT_CITY
Definition editor.h:43
ETT_COPYPASTE
@ ETT_COPYPASTE
Definition editor.h:47
ETT_TERRAIN_RESOURCE
@ ETT_TERRAIN_RESOURCE
Definition editor.h:38
ETT_MILITARY_BASE
@ ETT_MILITARY_BASE
Definition editor.h:41
ETT_TERRAIN
@ ETT_TERRAIN
Definition editor.h:37
extra_by_number
struct extra_type * extra_by_number(int id)
Definition extras.c:183
extra_name_translation
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
extra_index
#define extra_index(_e_)
Definition extras.h:183
extra_type_by_cause_iterate_end
#define extra_type_by_cause_iterate_end
Definition extras.h:339
extra_type_by_cause_iterate
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:333
EC_SPECIAL
#define EC_SPECIAL
Definition fc_types.h:1115
fcintl.h
_
#define _(String)
Definition fcintl.h:67
game.h
government.h
FC_STATIC_CANVAS_INIT
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:28
refresh_all_buttons
static void refresh_all_buttons(struct editbar *eb)
Definition editgui.c:113
editbar_player_properties_button_clicked
static void editbar_player_properties_button_clicked(GtkButton *b, gpointer userdata)
Definition editgui.c:463
tool_applied_player_columns
tool_applied_player_columns
Definition editgui.c:72
TAP_COL_FLAG
@ TAP_COL_FLAG
Definition editgui.c:73
TAP_COL_NAME
@ TAP_COL_NAME
Definition editgui.c:74
TAP_COL_PLAYER_NO
@ TAP_COL_PLAYER_NO
Definition editgui.c:75
TAP_NUM_COLS
@ TAP_NUM_COLS
Definition editgui.c:77
editgui_run_tool_selection
static bool editgui_run_tool_selection(enum editor_tool_type ett)
Definition editgui.c:356
editinfobox_refresh
static void editinfobox_refresh(struct editinfobox *ei)
Definition editgui.c:1519
editgui_popup_properties
void editgui_popup_properties(const struct tile_list *tiles, int objtype)
Definition editgui.c:1875
editgui_notify_object_created
void editgui_notify_object_created(int tag, int id)
Definition editgui.c:1922
clear_tool_stores
static void clear_tool_stores(struct editbar *eb)
Definition editgui.c:752
convert_modifiers
static int convert_modifiers(int gdk_event_state)
Definition editgui.c:898
try_to_set_editor_tool
static void try_to_set_editor_tool(enum editor_tool_type ett)
Definition editgui.c:177
clear_tool_store
static void clear_tool_store(GtkListStore *store)
Definition editgui.c:730
handle_edit_mouse_button_release
gboolean handle_edit_mouse_button_release(GdkEventButton *ev)
Definition editgui.c:956
handle_edit_key_press_with_ctrl
static gboolean handle_edit_key_press_with_ctrl(GdkEventKey *ev)
Definition editgui.c:1606
handle_edit_key_press
gboolean handle_edit_key_press(GdkEventKey *ev)
Definition editgui.c:1662
tool_value_selector_run
static int tool_value_selector_run(struct tool_value_selector *tvs)
Definition editgui.c:319
editbar_add_mode_button
static void editbar_add_mode_button(struct editbar *eb, enum editor_tool_mode etm)
Definition editgui.c:478
editbar_tool_button_toggled
static void editbar_tool_button_toggled(GtkToggleButton *tb, gpointer userdata)
Definition editgui.c:201
editbar_add_tool_button
static void editbar_add_tool_button(struct editbar *eb, enum editor_tool_type ett)
Definition editgui.c:407
editgui_create_widgets
void editgui_create_widgets(void)
Definition editgui.c:1822
editbar_create
static struct editbar * editbar_create(void)
Definition editgui.c:519
editgui_popdown_all
void editgui_popdown_all(void)
Definition editgui.c:1890
editbar_reload_tileset
static void editbar_reload_tileset(struct editbar *eb)
Definition editgui.c:765
tool_value_selector_treeview_row_activated
static void tool_value_selector_treeview_row_activated(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data)
Definition editgui.c:980
editinfobox_spin_button_value_changed
static void editinfobox_spin_button_value_changed(GtkSpinButton *spinbutton, gpointer userdata)
Definition editgui.c:1106
refresh_tool_applied_player_combo
static void refresh_tool_applied_player_combo(struct editinfobox *ei)
Definition editgui.c:1338
editbar_mode_button_toggled
static void editbar_mode_button_toggled(GtkToggleButton *tb, gpointer userdata)
Definition editgui.c:154
editinfobox_tool_applied_player_changed
static void editinfobox_tool_applied_player_changed(GtkComboBox *combo, gpointer userdata)
Definition editgui.c:1142
handle_edit_key_press_with_shift
static gboolean handle_edit_key_press_with_shift(GdkEventKey *ev)
Definition editgui.c:1614
refresh_all_tool_value_selectors
static void refresh_all_tool_value_selectors(struct editbar *eb)
Definition editgui.c:651
spin_button_types
spin_button_types
Definition editgui.c:80
SPIN_BUTTON_COUNT
@ SPIN_BUTTON_COUNT
Definition editgui.c:82
SPIN_BUTTON_SIZE
@ SPIN_BUTTON_SIZE
Definition editgui.c:81
handle_edit_mouse_button_press
gboolean handle_edit_mouse_button_press(GdkEventButton *ev)
Definition editgui.c:940
create_tool_value_selector
static struct tool_value_selector * create_tool_value_selector(struct editbar *eb_parent, enum editor_tool_type ett)
Definition editgui.c:994
create_terrain_pixbuf
static GdkPixbuf * create_terrain_pixbuf(struct terrain *pterrain)
Definition editgui.c:696
replace_widget
static void replace_widget(GtkWidget *old, GtkWidget *new)
Definition editgui.c:1501
editbar_player_pov_combobox_changed
static void editbar_player_pov_combobox_changed(GtkComboBox *combo, gpointer user_data)
Definition editgui.c:277
editgui_get_editinfobox
struct editinfobox * editgui_get_editinfobox(void)
Definition editgui.c:1853
handle_edit_mouse_move
gboolean handle_edit_mouse_move(GdkEventMotion *ev)
Definition editgui.c:971
tool_value_selector_columns
tool_value_selector_columns
Definition editgui.c:56
TVS_COL_ID
@ TVS_COL_ID
Definition editgui.c:58
TVS_COL_NAME
@ TVS_COL_NAME
Definition editgui.c:59
TVS_COL_IMAGE
@ TVS_COL_IMAGE
Definition editgui.c:57
TVS_NUM_COLS
@ TVS_NUM_COLS
Definition editgui.c:61
player_pov_combo_columns
player_pov_combo_columns
Definition editgui.c:64
PPV_COL_FLAG
@ PPV_COL_FLAG
Definition editgui.c:65
PPV_COL_PLAYER_NO
@ PPV_COL_PLAYER_NO
Definition editgui.c:67
PPV_COL_NAME
@ PPV_COL_NAME
Definition editgui.c:66
PPV_NUM_COLS
@ PPV_NUM_COLS
Definition editgui.c:69
editgui_refresh
void editgui_refresh(void)
Definition editgui.c:1796
editbar_refresh
static void editbar_refresh(struct editbar *eb)
Definition editgui.c:669
editor_infobox
static struct editinfobox * editor_infobox
Definition editgui.c:107
editor_toolbar
static struct editbar * editor_toolbar
Definition editgui.c:106
editinfobox_handle_tool_image_button_press
static gboolean editinfobox_handle_tool_image_button_press(GtkWidget *evbox, GdkEventButton *ev, gpointer data)
Definition editgui.c:1082
editgui_get_editbar
struct editbar * editgui_get_editbar(void)
Definition editgui.c:1788
refresh_tool_value_selector
static void refresh_tool_value_selector(struct editbar *eb, enum editor_tool_type ett)
Definition editgui.c:612
editinfobox_create
static struct editinfobox * editinfobox_create(void)
Definition editgui.c:1167
refresh_player_pov_indicator
static void refresh_player_pov_indicator(struct editbar *eb)
Definition editgui.c:223
editgui_tileset_changed
void editgui_tileset_changed(void)
Definition editgui.c:1862
editgui_free
void editgui_free(void)
Definition editgui.c:1835
editinfobox_handle_mode_image_button_press
static gboolean editinfobox_handle_mode_image_button_press(GtkWidget *evbox, GdkEventButton *ev, gpointer data)
Definition editgui.c:1093
get_tool_value_pixbuf
static GdkPixbuf * get_tool_value_pixbuf(enum editor_tool_type ett, int value)
Definition editgui.c:1406
get_tool_mode_pixbuf
static GdkPixbuf * get_tool_mode_pixbuf(enum editor_tool_mode etm)
Definition editgui.c:1477
property_editor_handle_object_changed
void property_editor_handle_object_changed(struct property_editor *pe, enum editor_object_type objtype, int object_id, bool remove)
Definition editprop.c:6280
property_editor_handle_object_created
void property_editor_handle_object_created(struct property_editor *pe, int tag, int object_id)
Definition editprop.c:6302
property_editor_popup
void property_editor_popup(struct property_editor *pe, enum editor_object_type objtype)
Definition editprop.c:6250
editprop_get_property_editor
struct property_editor * editprop_get_property_editor(void)
Definition editprop.c:6203
property_editor_reload
void property_editor_reload(struct property_editor *pe, enum editor_object_type objtype)
Definition editprop.c:6340
property_editor_popdown
void property_editor_popdown(struct property_editor *pe)
Definition editprop.c:6268
property_editor_load_tiles
void property_editor_load_tiles(struct property_editor *pe, const struct tile_list *tiles)
Definition editprop.c:6214
property_editor_clear
void property_editor_clear(struct property_editor *pe)
Definition editprop.c:6320
unit_info_box
GtkWidget * unit_info_box
Definition gui_main.c:152
toplevel
GtkWidget * toplevel
Definition gui_main.c:125
disable_gobject_callback
void disable_gobject_callback(GObject *obj, GCallback cb)
Definition gui_stuff.c:1090
enable_gobject_callback
void enable_gobject_callback(GObject *obj, GCallback cb)
Definition gui_stuff.c:1106
get_flag
GdkPixbuf * get_flag(const struct nation_type *nation)
Definition plrdlg.c:607
tooltip
const char * tooltip
Definition repodlgs.c:1315
surface_get_pixbuf
GdkPixbuf * surface_get_pixbuf(cairo_surface_t *surf, int width, int height)
Definition sprite.c:418
sprite_get_pixbuf
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
create_extra_pixbuf
GdkPixbuf * create_extra_pixbuf(const struct extra_type *pextra)
Definition sprite.c:494
editbar_tool_right_button
static gboolean editbar_tool_right_button(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition editgui.c:390
editgui.h
editprop.h
blocking_dialog
gint blocking_dialog(GtkWidget *dlg)
Definition gui_stuff.c:1135
gui_stuff.h
canvas.h
gui_main.h
plrdlg.h
sprite.h
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
fc_assert
#define fc_assert(condition)
Definition log.h:176
put_drawn_sprites
void put_drawn_sprites(struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y, int count, struct drawn_sprite *pdrawn, bool fog)
Definition mapview_common.c:1328
mapview_common.h
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
NO_NATION_SELECTED
#define NO_NATION_SELECTED
Definition nation.h:30
packets.h
player_by_number
struct player * player_by_number(const int player_id)
Definition player.c:849
player_count
int player_count(void)
Definition player.c:817
player_number
int player_number(const struct player *pplayer)
Definition player.c:837
player_name
const char * player_name(const struct player *pplayer)
Definition player.c:895
players_iterate_end
#define players_iterate_end
Definition player.h:537
players_iterate
#define players_iterate(_pplayer)
Definition player.h:532
shared.h
size
size_t size
Definition specvec.h:72
y
struct sprite int int y
Definition sprite_g.h:31
x
struct sprite int x
Definition sprite_g.h:31
canvas
Definition canvas.h:22
canvas::surface
cairo_surface_t * surface
Definition canvas.h:23
drawn_sprite
Definition tilespec.h:110
edit_buffer
Definition editor.c:62
editbar
Definition editgui.h:24
editinfobox
Definition editgui.h:44
editor_sprites
Definition tilespec.h:339
editor_sprites::city
struct sprite * city
Definition tilespec.h:351
editor_sprites::vision
struct sprite * vision
Definition tilespec.h:352
editor_sprites::copypaste
struct sprite * copypaste
Definition tilespec.h:345
editor_sprites::startpos
struct sprite * startpos
Definition tilespec.h:346
editor_sprites::properties
struct sprite * properties
Definition tilespec.h:354
player
Definition player.h:247
player::name
char name[MAX_LEN_NAME]
Definition player.h:249
property_editor
Definition editprop.c:646
sprite
Definition sprite.h:22
terrain
Definition terrain.h:182
tileset
Definition tilespec.c:481
tool_value_selector
Definition editgui.c:85
tool_value_selector::view
GtkWidget * view
Definition editgui.c:91
tool_value_selector::editbar_parent
struct editbar * editbar_parent
Definition editgui.c:86
tool_value_selector::store
GtkListStore * store
Definition editgui.c:90
tool_value_selector::dialog
GtkWidget * dialog
Definition editgui.c:88
unit_type
Definition unittype.h:500
view
Definition mapview_common.h:36
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
terrain_name_translation
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:238
terrain_by_number
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:156
terrain_number
Terrain_type_id terrain_number(const struct terrain *pterrain)
Definition terrain.c:147
terrain_type_iterate
#define terrain_type_iterate(_p)
Definition terrain.h:373
terrain_type_iterate_end
#define terrain_type_iterate_end
Definition terrain.h:379
fill_basic_terrain_layer_sprite_array
int fill_basic_terrain_layer_sprite_array(struct tileset *t, struct drawn_sprite *sprs, int layer, struct terrain *pterrain)
Definition tilespec.c:7171
tileset_tile_height
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:765
get_unittype_sprite
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:6809
tileset_tile_width
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:753
get_editor_sprites
const struct editor_sprites * get_editor_sprites(const struct tileset *t)
Definition tilespec.c:6953
tilespec.h
utype_by_number
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
utype_number
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:852
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:859