Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-gtk-3.0/editgui.c Source File

Freeciv-3.1

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-3.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
85 struct 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 dialog = gtk_message_dialog_new(GTK_WINDOW(toplevel),
186 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
187 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s",
188 _("The current ruleset does not define any "
189 "objects corresponding to this editor tool."));
190 gtk_window_set_title(GTK_WINDOW(dialog), editor_tool_get_name(ett));
191 gtk_dialog_run(GTK_DIALOG(dialog));
192 gtk_widget_destroy(dialog);
193 } else {
194 editor_set_tool(ett);
195 }
196}
197
198/************************************************************************/
201 static void editbar_tool_button_toggled(GtkToggleButton *tb,
202 gpointer userdata)
203{
204 gboolean active;
205 enum editor_tool_type ett;
206
207 active = gtk_toggle_button_get_active(tb);
208 ett = GPOINTER_TO_INT(userdata);
209
210 if (active) {
211 try_to_set_editor_tool(ett);
212 editgui_refresh();
213 }
214}
215
216/************************************************************************/
223 static void refresh_player_pov_indicator(struct editbar *eb)
224{
225 GtkListStore *store;
226 GdkPixbuf *flag;
227 GtkTreeIter iter;
228 GtkWidget *combo;
229 int index = -1, i;
230
231 if (eb == NULL || eb->player_pov_store == NULL) {
232 return;
233 }
234
235 store = eb->player_pov_store;
236 gtk_list_store_clear(store);
237
238 gtk_list_store_append(store, &iter);
239 gtk_list_store_set(store, &iter, PPV_COL_NAME, _("Global Observer"),
240 PPV_COL_PLAYER_NO, -1, -1);
241
242 i = 1;
243 players_iterate(pplayer) {
244 gtk_list_store_append(store, &iter);
245 gtk_list_store_set(store, &iter, PPV_COL_NAME, player_name(pplayer),
246 PPV_COL_PLAYER_NO, player_number(pplayer), -1);
247
248 if (pplayer->nation != NO_NATION_SELECTED) {
249 flag = get_flag(pplayer->nation);
250
251 if (flag != NULL) {
252 gtk_list_store_set(store, &iter, PPV_COL_FLAG, flag, -1);
253 g_object_unref(flag);
254 }
255 }
256 if (pplayer == client_player()) {
257 index = i;
258 }
259 i++;
260 } players_iterate_end;
261
262 if (client_is_global_observer()) {
263 index = 0;
264 }
265
266 combo = eb->player_pov_combobox;
267 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), index);
268}
269
270/************************************************************************/
277 static void editbar_player_pov_combobox_changed(GtkComboBox *combo,
278 gpointer user_data)
279{
280 struct editbar *eb = user_data;
281 int id;
282 struct player *pplayer;
283 GtkTreeIter iter;
284 GtkTreeModel *model;
285
286 if (eb == NULL || eb->widget == NULL
287 || !gtk_widget_get_visible(eb->widget)) {
288 return;
289 }
290
291 if (!gtk_combo_box_get_active_iter(combo, &iter)) {
292 return;
293 }
294
295 model = gtk_combo_box_get_model(combo);
296 gtk_tree_model_get(model, &iter, PPV_COL_PLAYER_NO, &id, -1);
297
298 if ((client_is_global_observer() && id == -1)
299 || client_player_number() == id) {
300 return;
301 }
302
303 /* Ugh... hard-coded server command strings. :( */
304 if (id == -1) {
305 send_chat("/observe");
306 return;
307 }
308
309 pplayer = player_by_number(id);
310 if (pplayer != NULL) {
311 send_chat_printf("/take \"%s\"", pplayer->name);
312 }
313}
314
315/************************************************************************/
319 static int tool_value_selector_run(struct tool_value_selector *tvs)
320{
321 gint res;
322 GtkWidget *dialog;
323 GtkTreeSelection *sel;
324 GtkTreeIter iter;
325 GtkTreeModel *model;
326 int id;
327
328 if (tvs == NULL) {
329 return -1;
330 }
331
332 dialog = tvs->dialog;
333 res = gtk_dialog_run(GTK_DIALOG(dialog));
334 gtk_widget_hide(dialog);
335
336 if (res != GTK_RESPONSE_ACCEPT) {
337 return -1;
338 }
339
340 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tvs->view));
341 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) {
342 return -1;
343 }
344
345 gtk_tree_model_get(model, &iter, TVS_COL_ID, &id, -1);
346
347 return id;
348}
349
350/************************************************************************/
356 static bool editgui_run_tool_selection(enum editor_tool_type ett)
357{
358 struct editbar *eb;
359 struct tool_value_selector *tvs;
360 int res = -1;
361
362 eb = editgui_get_editbar();
363 if (eb == NULL || !(ett < NUM_EDITOR_TOOL_TYPES)) {
364 return FALSE;
365 }
366
367 if (!editor_tool_has_value(ett)) {
368 return FALSE;
369 }
370
371 tvs = eb->tool_selectors[ett];
372 if (!tvs) {
373 return FALSE;
374 }
375
376 res = tool_value_selector_run(tvs);
377
378 if (res >= 0) {
379 editor_tool_set_value(ett, res);
380 editinfobox_refresh(editgui_get_editinfobox());
381 }
382
383 return TRUE;
384}
385
386/************************************************************************/
389 static gboolean editbar_tool_button_mouse_click(GtkWidget *w,
390 GdkEventButton *ev,
391 gpointer userdata)
392{
393 int ett;
394
395 if (ev->button != 3) {
396 return FALSE; /* Propagate event further. */
397 }
398
399 ett = GPOINTER_TO_INT(userdata);
400 return editgui_run_tool_selection(ett);
401}
402
403/************************************************************************/
407 static void editbar_add_tool_button(struct editbar *eb,
408 enum editor_tool_type ett)
409{
410 GdkPixbuf *pixbuf;
411 GtkWidget *image, *button, *hbox;
412 GtkRadioButton *parent = NULL;
413 struct sprite *sprite;
414 int i;
415
416 if (!eb || !(ett < NUM_EDITOR_TOOL_TYPES)) {
417 return;
418 }
419
420 for (i = 0; i < NUM_EDITOR_TOOL_TYPES; i++) {
421 if (eb->tool_buttons[i] != NULL) {
422 parent = GTK_RADIO_BUTTON(eb->tool_buttons[i]);
423 break;
424 }
425 }
426
427 if (parent == NULL) {
428 button = gtk_radio_button_new(NULL);
429 } else {
430 button = gtk_radio_button_new_from_widget(parent);
431 }
432
433 sprite = editor_tool_get_sprite(ett);
434 fc_assert_ret(sprite != NULL);
435 pixbuf = sprite_get_pixbuf(sprite);
436 image = gtk_image_new_from_pixbuf(pixbuf);
437 g_object_unref(G_OBJECT(pixbuf));
438
439 gtk_container_add(GTK_CONTAINER(button), image);
440 gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);
441 gtk_widget_set_tooltip_text(button, editor_tool_get_tooltip(ett));
442 gtk_size_group_add_widget(eb->size_group, button);
443 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
444 gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE);
445
446 g_signal_connect(button, "toggled",
447 G_CALLBACK(editbar_tool_button_toggled), GINT_TO_POINTER(ett));
448 g_signal_connect(button, "button_press_event",
449 G_CALLBACK(editbar_tool_button_mouse_click), GINT_TO_POINTER(ett));
450
451 hbox = eb->widget;
452 gtk_container_add(GTK_CONTAINER(hbox), button);
453 eb->tool_buttons[ett] = button;
454
455 if (editor_tool_has_value(ett)) {
456 eb->tool_selectors[ett] = create_tool_value_selector(eb, ett);
457 }
458}
459
460/************************************************************************/
463 static void editbar_player_properties_button_clicked(GtkButton *b,
464 gpointer userdata)
465{
466 struct property_editor *pe;
467
468 pe = editprop_get_property_editor();
469 property_editor_reload(pe, OBJTYPE_GAME);
470 property_editor_reload(pe, OBJTYPE_PLAYER);
471 property_editor_popup(pe, OBJTYPE_PLAYER);
472}
473
474/************************************************************************/
478 static void editbar_add_mode_button(struct editbar *eb,
479 enum editor_tool_mode etm)
480{
481 GdkPixbuf *pixbuf;
482 GtkWidget *image, *button, *hbox;
483 struct sprite *sprite;
484 const char *tooltip;
485
486 if (!eb || !(etm < NUM_EDITOR_TOOL_MODES)) {
487 return;
488 }
489
490 button = gtk_toggle_button_new();
491
492 sprite = editor_get_mode_sprite(etm);
493 fc_assert_ret(sprite != NULL);
494 pixbuf = sprite_get_pixbuf(sprite);
495 image = gtk_image_new_from_pixbuf(pixbuf);
496 g_object_unref(G_OBJECT(pixbuf));
497
498 gtk_container_add(GTK_CONTAINER(button), image);
499 gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);
500 tooltip = editor_get_mode_tooltip(etm);
501 if (tooltip != NULL) {
502 gtk_widget_set_tooltip_text(button, tooltip);
503 }
504 gtk_size_group_add_widget(eb->size_group, button);
505 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
506 gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE);
507
508 g_signal_connect(button, "toggled",
509 G_CALLBACK(editbar_mode_button_toggled), GINT_TO_POINTER(etm));
510
511 hbox = eb->widget;
512 gtk_container_add(GTK_CONTAINER(hbox), button);
513 eb->mode_buttons[etm] = button;
514}
515
516/************************************************************************/
519 static struct editbar *editbar_create(void)
520{
521 struct editbar *eb;
522 GtkWidget *hbox, *button, *combo, *image, *separator, *vbox;
523 GtkListStore *store;
524 GtkCellRenderer *cell;
525 GdkPixbuf *pixbuf;
526 const struct editor_sprites *sprites;
527
528 eb = fc_calloc(1, sizeof(struct editbar));
529
530 hbox = gtk_grid_new();
531 gtk_grid_set_column_spacing(GTK_GRID(hbox), 4);
532 eb->widget = hbox;
533 eb->size_group = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
534
535 sprites = get_editor_sprites(tileset);
536
537 editbar_add_mode_button(eb, ETM_ERASE);
538
539 separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
540 gtk_container_add(GTK_CONTAINER(hbox), separator);
541
542 editbar_add_tool_button(eb, ETT_TERRAIN);
543 editbar_add_tool_button(eb, ETT_TERRAIN_RESOURCE);
544 editbar_add_tool_button(eb, ETT_TERRAIN_SPECIAL);
545 editbar_add_tool_button(eb, ETT_ROAD);
546 editbar_add_tool_button(eb, ETT_MILITARY_BASE);
547 editbar_add_tool_button(eb, ETT_UNIT);
548 editbar_add_tool_button(eb, ETT_CITY);
549 editbar_add_tool_button(eb, ETT_VISION);
550 editbar_add_tool_button(eb, ETT_STARTPOS);
551 editbar_add_tool_button(eb, ETT_COPYPASTE);
552
553 separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
554 gtk_container_add(GTK_CONTAINER(hbox), separator);
555
556 /* Player POV indicator. */
557 vbox = gtk_grid_new();
558 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
559 GTK_ORIENTATION_VERTICAL);
560 gtk_container_add(GTK_CONTAINER(hbox), vbox);
561
562 store = gtk_list_store_new(PPV_NUM_COLS,
563 GDK_TYPE_PIXBUF,
564 G_TYPE_STRING,
565 G_TYPE_INT);
566 eb->player_pov_store = store;
567
568 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
569
570 cell = gtk_cell_renderer_pixbuf_new();
571 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, FALSE);
572 gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo),
573 cell, "pixbuf", PPV_COL_FLAG);
574
575 cell = gtk_cell_renderer_text_new();
576 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, TRUE);
577 gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo),
578 cell, "text", PPV_COL_NAME);
579
580 gtk_widget_set_size_request(combo, 140, -1);
581 g_signal_connect(combo, "changed",
582 G_CALLBACK(editbar_player_pov_combobox_changed), eb);
583
584 gtk_widget_set_tooltip_text(combo,
585 _("Switch player point-of-view. Use this to edit "
586 "from the perspective of different players, or "
587 "even as a global observer."));
588 gtk_container_add(GTK_CONTAINER(vbox), combo);
589 eb->player_pov_combobox = combo;
590
591 /* Property editor button. */
592 button = gtk_button_new();
593 pixbuf = sprite_get_pixbuf(sprites->properties);
594 image = gtk_image_new_from_pixbuf(pixbuf);
595 g_object_unref(G_OBJECT(pixbuf));
596 gtk_container_add(GTK_CONTAINER(button), image);
597 gtk_widget_set_tooltip_text(button, _("Show the property editor."));
598 gtk_size_group_add_widget(eb->size_group, button);
599 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
600 gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE);
601 g_signal_connect(button, "clicked",
602 G_CALLBACK(editbar_player_properties_button_clicked), eb);
603 gtk_container_add(GTK_CONTAINER(hbox), button);
604
605 return eb;
606}
607
608/************************************************************************/
612 static void refresh_tool_value_selector(struct editbar *eb,
613 enum editor_tool_type ett)
614{
615 GtkTreeSelection *sel;
616 GtkTreeIter iter;
617 GtkTreeModel *model;
618 int value, store_value;
619 struct tool_value_selector *tvs;
620
621 if (!editor_is_active() || !eb || !editor_tool_has_value(ett)) {
622 return;
623 }
624
625 tvs = eb->tool_selectors[ett];
626
627 if (!tvs) {
628 return;
629 }
630
631 value = editor_tool_get_value(ett);
632 model = GTK_TREE_MODEL(tvs->store);
633 if (!gtk_tree_model_get_iter_first(model, &iter)) {
634 return;
635 }
636
637 do {
638 gtk_tree_model_get(model, &iter, TVS_COL_ID, &store_value, -1);
639 if (value == store_value) {
640 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tvs->view));
641 gtk_tree_selection_select_iter(sel, &iter);
642 break;
643 }
644 } while (gtk_tree_model_iter_next(model, &iter));
645}
646
647/************************************************************************/
651 static void refresh_all_tool_value_selectors(struct editbar *eb)
652{
653 int ett;
654
655 if (!eb) {
656 return;
657 }
658
659 for (ett = 0; ett < NUM_EDITOR_TOOL_TYPES; ett++) {
660 if (editor_tool_has_value(ett)) {
661 refresh_tool_value_selector(eb, ett);
662 }
663 }
664}
665
666/************************************************************************/
669 static void editbar_refresh(struct editbar *eb)
670{
671 if (eb == NULL || eb->widget == NULL) {
672 return;
673 }
674
675 if (!editor_is_active()) {
676 gtk_widget_hide(eb->widget);
677 return;
678 }
679
680 refresh_all_buttons(eb);
681 refresh_all_tool_value_selectors(eb);
682 refresh_player_pov_indicator(eb);
683
684 gtk_widget_show_all(eb->widget);
685}
686
687/************************************************************************/
696 static GdkPixbuf *create_terrain_pixbuf(struct terrain *pterrain)
697{
698 int w, h, i;
699 GdkPixbuf *pixbuf;
700 struct canvas canvas = FC_STATIC_CANVAS_INIT;
701 cairo_t *cr;
702
703 w = tileset_tile_width(tileset);
704 h = tileset_tile_height(tileset);
705
706 canvas.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
707
708 cr = cairo_create(canvas.surface);
709 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
710 cairo_paint(cr);
711 cairo_destroy(cr);
712
713 for (i = 0; i < 3; i++) {
714 struct drawn_sprite sprs[80];
715 int count = fill_basic_terrain_layer_sprite_array(tileset, sprs,
716 i, pterrain);
717
718 put_drawn_sprites(&canvas, 1.0, 0, 0, count, sprs, FALSE);
719 }
720
721 pixbuf = surface_get_pixbuf(canvas.surface, w, h);
722 cairo_surface_destroy(canvas.surface);
723
724 return pixbuf;
725}
726
727/************************************************************************/
730 static void clear_tool_store(GtkListStore *store)
731{
732 GtkTreeIter iter;
733 GtkTreeModel *model = GTK_TREE_MODEL(store);
734
735 if (gtk_tree_model_get_iter_first(model, &iter)) {
736 do {
737 GdkPixbuf *pixbuf;
738
739 gtk_tree_model_get(model, &iter, TVS_COL_IMAGE, &pixbuf, -1);
740 if (pixbuf != NULL) {
741 g_object_unref(pixbuf);
742 }
743 } while (gtk_tree_model_iter_next(model, &iter));
744 }
745
746 gtk_list_store_clear(store);
747}
748
749/************************************************************************/
752 static void clear_tool_stores(struct editbar *eb)
753{
754 clear_tool_store(eb->tool_selectors[ETT_TERRAIN]->store);
755 clear_tool_store(eb->tool_selectors[ETT_TERRAIN_RESOURCE]->store);
756 clear_tool_store(eb->tool_selectors[ETT_TERRAIN_SPECIAL]->store);
757 clear_tool_store(eb->tool_selectors[ETT_ROAD]->store);
758 clear_tool_store(eb->tool_selectors[ETT_MILITARY_BASE]->store);
759 clear_tool_store(eb->tool_selectors[ETT_UNIT]->store);
760}
761
762/************************************************************************/
765 static void editbar_reload_tileset(struct editbar *eb)
766{
767 GtkTreeIter iter;
768 GtkListStore *store;
769 GdkPixbuf *pixbuf;
770 struct sprite *sprite;
771 struct tool_value_selector *tvs;
772
773 if (eb == NULL || tileset == NULL) {
774 return;
775 }
776
777 clear_tool_stores(eb);
778
779 /* Reload terrains. */
780
781 tvs = eb->tool_selectors[ETT_TERRAIN];
782 store = tvs->store;
783
784 terrain_type_iterate(pterrain) {
785 gtk_list_store_append(store, &iter);
786 gtk_list_store_set(store, &iter,
787 TVS_COL_ID, terrain_number(pterrain),
788 TVS_COL_NAME, terrain_name_translation(pterrain),
789 -1);
790 pixbuf = create_terrain_pixbuf(pterrain);
791 if (pixbuf != NULL) {
792 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
793 g_object_unref(pixbuf);
794 }
795 } terrain_type_iterate_end;
796
797
798 /* Reload terrain resources. */
799
800 tvs = eb->tool_selectors[ETT_TERRAIN_RESOURCE];
801 store = tvs->store;
802
803 extra_type_by_cause_iterate(EC_RESOURCE, pextra) {
804 gtk_list_store_append(store, &iter);
805 gtk_list_store_set(store, &iter,
806 TVS_COL_ID, extra_index(pextra),
807 TVS_COL_NAME, extra_name_translation(pextra),
808 -1);
809 pixbuf = create_extra_pixbuf(pextra);
810 if (pixbuf != NULL) {
811 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
812 g_object_unref(pixbuf);
813 }
814 } extra_type_by_cause_iterate_end;
815
816 /* Reload terrain specials. */
817
818 tvs = eb->tool_selectors[ETT_TERRAIN_SPECIAL];
819 store = tvs->store;
820
821 extra_type_by_cause_iterate(EC_SPECIAL, pextra) {
822 gtk_list_store_append(store, &iter);
823 gtk_list_store_set(store, &iter,
824 TVS_COL_ID, extra_index(pextra),
825 TVS_COL_NAME, extra_name_translation(pextra),
826 -1);
827 pixbuf = create_extra_pixbuf(pextra);
828 if (pixbuf != NULL) {
829 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
830 g_object_unref(pixbuf);
831 }
832 } extra_type_by_cause_iterate_end;
833
834 /* Reload roads. */
835
836 tvs = eb->tool_selectors[ETT_ROAD];
837 store = tvs->store;
838
839 extra_type_by_cause_iterate(EC_ROAD, pextra) {
840 gtk_list_store_append(store, &iter);
841 gtk_list_store_set(store, &iter,
842 TVS_COL_ID, extra_index(pextra),
843 TVS_COL_NAME, extra_name_translation(pextra),
844 -1);
845 pixbuf = create_extra_pixbuf(pextra);
846 if (pixbuf != NULL) {
847 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
848 g_object_unref(pixbuf);
849 }
850 } extra_type_by_cause_iterate_end;
851
852 /* Reload military bases. */
853
854 tvs = eb->tool_selectors[ETT_MILITARY_BASE];
855 store = tvs->store;
856
857 extra_type_by_cause_iterate(EC_BASE, pextra) {
858 gtk_list_store_append(store, &iter);
859 gtk_list_store_set(store, &iter,
860 TVS_COL_ID, extra_index(pextra),
861 TVS_COL_NAME, extra_name_translation(pextra),
862 -1);
863 pixbuf = create_extra_pixbuf(pextra);
864 if (pixbuf != NULL) {
865 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
866 g_object_unref(pixbuf);
867 }
868 } extra_type_by_cause_iterate_end;
869
870
871 /* Reload unit types. */
872
873 tvs = eb->tool_selectors[ETT_UNIT];
874 store = tvs->store;
875
876 unit_type_iterate(putype) {
877 gtk_list_store_append(store, &iter);
878 gtk_list_store_set(store, &iter,
879 TVS_COL_ID, utype_number(putype),
880 TVS_COL_NAME, utype_name_translation(putype),
881 -1);
882 sprite = get_unittype_sprite(tileset, putype, direction8_invalid());
883 if (sprite == NULL) {
884 continue;
885 }
886 pixbuf = sprite_get_pixbuf(sprite);
887 if (pixbuf != NULL) {
888 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
889 g_object_unref(G_OBJECT(pixbuf));
890 }
891 } unit_type_iterate_end;
892}
893
894/************************************************************************/
897 static int convert_modifiers(int gdk_event_state)
898{
899 int modifiers = EKM_NONE;
900
901 if (gdk_event_state & GDK_SHIFT_MASK) {
902 modifiers |= EKM_SHIFT;
903 }
904 if (gdk_event_state & GDK_CONTROL_MASK) {
905 modifiers |= EKM_CTRL;
906 }
907 if (gdk_event_state & GDK_MOD1_MASK) {
908 modifiers |= EKM_ALT;
909 }
910
911 return modifiers;
912}
913
914/************************************************************************/
917 static int convert_mouse_button(int gdk_mouse_button)
918{
919 switch (gdk_mouse_button) {
920 case 1:
921 return MOUSE_BUTTON_LEFT;
922 break;
923 case 2:
924 return MOUSE_BUTTON_MIDDLE;
925 break;
926 case 3:
927 return MOUSE_BUTTON_RIGHT;
928 break;
929 default:
930 break;
931 }
932
933 return MOUSE_BUTTON_OTHER;
934}
935
936/************************************************************************/
939gboolean handle_edit_mouse_button_press(GdkEventButton *ev)
940{
941 if (ev->type != GDK_BUTTON_PRESS) {
942 return TRUE;
943 }
944
945 editor_mouse_button_press(ev->x, ev->y,
946 convert_mouse_button(ev->button),
947 convert_modifiers(ev->state));
948
949 return TRUE;
950}
951
952/************************************************************************/
955gboolean handle_edit_mouse_button_release(GdkEventButton *ev)
956{
957 if (ev->type != GDK_BUTTON_RELEASE) {
958 return TRUE;
959 }
960
961 editor_mouse_button_release(ev->x, ev->y,
962 convert_mouse_button(ev->button),
963 convert_modifiers(ev->state));
964 return TRUE;
965}
966
967/************************************************************************/
970gboolean handle_edit_mouse_move(GdkEventMotion *ev)
971{
972 editor_mouse_move(ev->x, ev->y, convert_modifiers(ev->state));
973 return TRUE;
974}
975
976/************************************************************************/
979 static void tool_value_selector_treeview_row_activated(GtkTreeView *view,
980 GtkTreePath *path,
981 GtkTreeViewColumn *col,
982 gpointer user_data)
983{
984 struct tool_value_selector *tvs = user_data;
985
986 gtk_dialog_response(GTK_DIALOG(tvs->dialog), GTK_RESPONSE_ACCEPT);
987}
988
989/************************************************************************/
992static struct tool_value_selector *
993create_tool_value_selector(struct editbar *eb,
994 enum editor_tool_type ett)
995{
996 struct tool_value_selector *tvs;
997 GtkWidget *vbox, *view, *scrollwin;
998 GtkCellRenderer *cell;
999 GtkListStore *store;
1000 GtkTreeViewColumn *col;
1001 GtkTreeSelection *sel;
1002
1003 tvs = fc_calloc(1, sizeof(struct tool_value_selector));
1004
1005 tvs->editbar_parent = eb;
1006
1007 tvs->dialog = gtk_dialog_new_with_buttons(_("Select Tool Value"),
1008 GTK_WINDOW(toplevel), GTK_DIALOG_MODAL,
1009 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
1010 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
1011 NULL);
1012 vbox = gtk_dialog_get_content_area(GTK_DIALOG(tvs->dialog));
1013
1014 store = gtk_list_store_new(TVS_NUM_COLS,
1015 GDK_TYPE_PIXBUF,
1016 G_TYPE_INT,
1017 G_TYPE_STRING);
1018 tvs->store = store;
1019
1020 scrollwin = gtk_scrolled_window_new(NULL, NULL);
1021 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin),
1022 GTK_SHADOW_ETCHED_IN);
1023 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
1024 GTK_POLICY_NEVER,
1025 GTK_POLICY_AUTOMATIC);
1026 gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(scrollwin),
1027 10 * tileset_tile_height(tileset));
1028 gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0);
1029
1030 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(tvs->store));
1031 gtk_widget_set_size_request(view, -1, 10 * tileset_tile_height(tileset));
1032 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
1033 gtk_tree_view_set_search_column(GTK_TREE_VIEW(view), TVS_COL_NAME);
1034 g_signal_connect(view, "row-activated",
1035 G_CALLBACK(tool_value_selector_treeview_row_activated), tvs);
1036
1037 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1038 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
1039
1040 cell = gtk_cell_renderer_pixbuf_new();
1041 col = gtk_tree_view_column_new_with_attributes(editor_tool_get_name(ett),
1042 cell, "pixbuf",
1043 TVS_COL_IMAGE, 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_append_column(GTK_TREE_VIEW(view), col);
1049
1050 cell = gtk_cell_renderer_text_new();
1051 col = gtk_tree_view_column_new_with_attributes("ID", cell,
1052 "text", TVS_COL_ID, NULL);
1053 gtk_tree_view_column_set_resizable(col, FALSE);
1054 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
1055 gtk_tree_view_column_set_reorderable(col, FALSE);
1056 gtk_tree_view_column_set_clickable(col, FALSE);
1057 gtk_tree_view_column_set_sort_column_id(col, TVS_COL_ID);
1058 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1059
1060 cell = gtk_cell_renderer_text_new();
1061 col = gtk_tree_view_column_new_with_attributes("Name", cell,
1062 "text", TVS_COL_NAME, NULL);
1063 gtk_tree_view_column_set_resizable(col, FALSE);
1064 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
1065 gtk_tree_view_column_set_reorderable(col, FALSE);
1066 gtk_tree_view_column_set_clickable(col, FALSE);
1067 gtk_tree_view_column_set_sort_column_id(col, TVS_COL_NAME);
1068 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1069
1070 gtk_container_add(GTK_CONTAINER(scrollwin), view);
1071 tvs->view = view;
1072
1073 /* Show everything but the window itself. */
1074 gtk_widget_show_all(vbox);
1075
1076 return tvs;
1077}
1078
1079/************************************************************************/
1082 static gboolean editinfobox_handle_tool_image_button_press(GtkWidget *evbox,
1083 GdkEventButton *ev,
1084 gpointer data)
1085{
1086 editgui_run_tool_selection(editor_get_tool());
1087 return TRUE;
1088}
1089
1090/************************************************************************/
1093 static gboolean editinfobox_handle_mode_image_button_press(GtkWidget *evbox,
1094 GdkEventButton *ev,
1095 gpointer data)
1096{
1097 editor_tool_cycle_mode(editor_get_tool());
1098 editgui_refresh();
1099
1100 return TRUE;
1101}
1102
1103/************************************************************************/
1106 static void editinfobox_spin_button_value_changed(GtkSpinButton *spinbutton,
1107 gpointer userdata)
1108{
1109 struct editinfobox *ei;
1110 int which, value;
1111 enum editor_tool_type ett;
1112
1113 ei = editgui_get_editinfobox();
1114
1115 if (!ei) {
1116 return;
1117 }
1118
1119 value = gtk_spin_button_get_value_as_int(spinbutton);
1120 which = GPOINTER_TO_INT(userdata);
1121 ett = editor_get_tool();
1122
1123 switch (which) {
1124 case SPIN_BUTTON_SIZE:
1125 editor_tool_set_size(ett, value);
1126 break;
1127 case SPIN_BUTTON_COUNT:
1128 editor_tool_set_count(ett, value);
1129 break;
1130 default:
1131 return;
1132 break;
1133 }
1134
1135 editinfobox_refresh(ei);
1136}
1137
1138/************************************************************************/
1142 static void editinfobox_tool_applied_player_changed(GtkComboBox *combo,
1143 gpointer userdata)
1144{
1145 struct editinfobox *ei = userdata;
1146 GtkTreeIter iter;
1147 GtkTreeModel *model;
1148 int player_no = -1;
1149
1150 if (ei == NULL) {
1151 return;
1152 }
1153
1154 if (!gtk_combo_box_get_active_iter(combo, &iter)) {
1155 return;
1156 }
1157
1158 model = gtk_combo_box_get_model(combo);
1159 gtk_tree_model_get(model, &iter, TAP_COL_PLAYER_NO, &player_no, -1);
1160
1161 editor_tool_set_applied_player(editor_get_tool(), player_no);
1162}
1163
1164/************************************************************************/
1167 static struct editinfobox *editinfobox_create(void)
1168{
1169 GtkWidget *label, *vbox, *frame, *hbox, *vbox2, *image, *evbox;
1170 GtkWidget *spin, *combo;
1171 GtkListStore *store;
1172 GtkCellRenderer *cell;
1173 struct editinfobox *ei;
1174 char buf[128];
1175
1176 ei = fc_calloc(1, sizeof(*ei));
1177
1178 frame = gtk_frame_new(_("Editor Tool"));
1179 gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
1180 ei->widget = frame;
1181
1182 vbox = gtk_grid_new();
1183 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
1184 GTK_ORIENTATION_VERTICAL);
1185 gtk_grid_set_row_spacing(GTK_GRID(vbox), 8);
1186 gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
1187 gtk_container_add(GTK_CONTAINER(frame), vbox);
1188
1189 /* tool section */
1190 hbox = gtk_grid_new();
1191 gtk_grid_set_column_spacing(GTK_GRID(hbox), 8);
1192 gtk_container_add(GTK_CONTAINER(vbox), hbox);
1193
1194 evbox = gtk_event_box_new();
1195 gtk_widget_set_tooltip_text(evbox, _("Click to change value if applicable."));
1196 g_signal_connect(evbox, "button_press_event",
1197 G_CALLBACK(editinfobox_handle_tool_image_button_press), NULL);
1198 gtk_container_add(GTK_CONTAINER(hbox), evbox);
1199
1200 image = gtk_image_new();
1201 gtk_container_add(GTK_CONTAINER(evbox), image);
1202 ei->tool_image = image;
1203
1204 vbox2 = gtk_grid_new();
1205 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox2),
1206 GTK_ORIENTATION_VERTICAL);
1207 gtk_grid_set_row_spacing(GTK_GRID(vbox2), 4);
1208 gtk_container_add(GTK_CONTAINER(hbox), vbox2);
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_container_add(GTK_CONTAINER(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_container_add(GTK_CONTAINER(vbox2), label);
1220 ei->tool_value_label = label;
1221
1222 /* mode section */
1223 hbox = gtk_grid_new();
1224 gtk_grid_set_column_spacing(GTK_GRID(hbox), 8);
1225 gtk_container_add(GTK_CONTAINER(vbox), hbox);
1226
1227 evbox = gtk_event_box_new();
1228 gtk_widget_set_tooltip_text(evbox, _("Click to change tool mode."));
1229 g_signal_connect(evbox, "button_press_event",
1230 G_CALLBACK(editinfobox_handle_mode_image_button_press), NULL);
1231 gtk_container_add(GTK_CONTAINER(hbox), evbox);
1232
1233 image = gtk_image_new();
1234 gtk_container_add(GTK_CONTAINER(evbox), image);
1235 ei->mode_image = image;
1236
1237 vbox2 = gtk_grid_new();
1238 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox2),
1239 GTK_ORIENTATION_VERTICAL);
1240 gtk_grid_set_row_spacing(GTK_GRID(vbox2), 4);
1241 gtk_container_add(GTK_CONTAINER(hbox), vbox2);
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_container_add(GTK_CONTAINER(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_container_add(GTK_CONTAINER(vbox2), label);
1255 ei->mode_label = label;
1256
1257 /* spinner section */
1258 hbox = gtk_grid_new();
1259 gtk_grid_set_column_spacing(GTK_GRID(hbox), 8);
1260 gtk_container_add(GTK_CONTAINER(vbox), hbox);
1261 ei->size_hbox = hbox;
1262 spin = gtk_spin_button_new_with_range(1, 255, 1);
1263 gtk_widget_set_tooltip_text(spin,
1264 _("Use this to change the \"size\" parameter for the tool. "
1265 "This parameter controls for example the half-width "
1266 "of the square of tiles that will be affected by the "
1267 "tool, or the size of a created city."));
1268 g_signal_connect(spin, "value-changed",
1269 G_CALLBACK(editinfobox_spin_button_value_changed),
1270 GINT_TO_POINTER(SPIN_BUTTON_SIZE));
1271 gtk_container_add(GTK_CONTAINER(hbox), spin);
1272 ei->size_spin_button = spin;
1273 label = gtk_label_new(_("Size"));
1274 gtk_container_add(GTK_CONTAINER(hbox), label);
1275
1276 hbox = gtk_grid_new();
1277 gtk_grid_set_column_spacing(GTK_GRID(hbox), 8);
1278 gtk_container_add(GTK_CONTAINER(vbox), hbox);
1279 ei->count_hbox = hbox;
1280 spin = gtk_spin_button_new_with_range(1, 255, 1);
1281 gtk_widget_set_tooltip_text(spin,
1282 _("Use this to change the tool's \"count\" parameter. "
1283 "This controls for example how many units are placed "
1284 "at once with the unit tool."));
1285 g_signal_connect(spin, "value-changed",
1286 G_CALLBACK(editinfobox_spin_button_value_changed),
1287 GINT_TO_POINTER(SPIN_BUTTON_COUNT));
1288 gtk_container_add(GTK_CONTAINER(hbox), spin);
1289 ei->count_spin_button = spin;
1290 label = gtk_label_new(_("Count"));
1291 gtk_container_add(GTK_CONTAINER(hbox), label);
1292
1293 /* combo section */
1294 store = gtk_list_store_new(TAP_NUM_COLS,
1295 GDK_TYPE_PIXBUF,
1296 G_TYPE_STRING,
1297 G_TYPE_INT);
1298 ei->tool_applied_player_store = store;
1299 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
1300
1301 cell = gtk_cell_renderer_pixbuf_new();
1302 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, FALSE);
1303 gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo),
1304 cell, "pixbuf", TAP_COL_FLAG);
1305
1306 cell = gtk_cell_renderer_text_new();
1307 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, TRUE);
1308 gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo),
1309 cell, "text", TAP_COL_NAME);
1310
1311 gtk_widget_set_size_request(combo, 132, -1);
1312 g_signal_connect(combo, "changed",
1313 G_CALLBACK(editinfobox_tool_applied_player_changed), ei);
1314
1315 gtk_widget_set_tooltip_text(combo,
1316 _("Use this to change the \"applied player\" tool parameter. "
1317 "This controls for example under which player units and cities "
1318 "are created."));
1319 gtk_container_add(GTK_CONTAINER(vbox), combo);
1320 ei->tool_applied_player_combobox = combo;
1321
1322 /* We add a ref to the editinfobox widget so that it is
1323 * not destroyed when replaced by the unit info box when
1324 * we leave edit mode. See editinfobox_refresh(). */
1325 g_object_ref(ei->widget);
1326
1327 /* The edit info box starts with no parent, so we have to
1328 * show its internal widgets manually. */
1329 gtk_widget_show_all(ei->widget);
1330
1331 return ei;
1332}
1333
1334/************************************************************************/
1338 static void refresh_tool_applied_player_combo(struct editinfobox *ei)
1339{
1340 enum editor_tool_type ett;
1341 GtkListStore *store;
1342 GtkWidget *combo;
1343 GtkTreeIter iter;
1344 GdkPixbuf *flag;
1345 int apno, index, i;
1346
1347 if (!ei) {
1348 return;
1349 }
1350
1351 ett = editor_get_tool();
1352 combo = ei->tool_applied_player_combobox;
1353 store = ei->tool_applied_player_store;
1354
1355 if (!combo || !store) {
1356 return;
1357 }
1358
1359 if (!editor_tool_has_applied_player(ett)) {
1360 gtk_widget_hide(combo);
1361 return;
1362 }
1363
1364 gtk_list_store_clear(store);
1365
1366 apno = editor_tool_get_applied_player(ett);
1367 index = -1;
1368 i = 0;
1369
1370 players_iterate(pplayer) {
1371 gtk_list_store_append(store, &iter);
1372 gtk_list_store_set(store, &iter,
1373 TAP_COL_PLAYER_NO, player_number(pplayer),
1374 TAP_COL_NAME, player_name(pplayer), -1);
1375
1376 if (pplayer->nation != NO_NATION_SELECTED) {
1377 flag = get_flag(pplayer->nation);
1378
1379 if (flag != NULL) {
1380 gtk_list_store_set(store, &iter, TAP_COL_FLAG, flag, -1);
1381 g_object_unref(flag);
1382 }
1383 }
1384 if (apno == player_number(pplayer)) {
1385 index = i;
1386 }
1387 i++;
1388 } players_iterate_end;
1389
1390 if (index == -1) {
1391 if (player_count() > 0) {
1392 index = 0;
1393 }
1394 editor_tool_set_applied_player(ett, index);
1395 }
1396 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), index);
1397 gtk_widget_show(combo);
1398}
1399
1400/************************************************************************/
1406 static GdkPixbuf *get_tool_value_pixbuf(enum editor_tool_type ett,
1407 int value)
1408{
1409 struct sprite *sprite = NULL;
1410 GdkPixbuf *pixbuf = NULL;
1411 struct terrain *pterrain;
1412 struct unit_type *putype;
1413 const struct editor_sprites *sprites;
1414
1415 sprites = get_editor_sprites(tileset);
1416 if (!sprites) {
1417 return NULL;
1418 }
1419
1420 switch (ett) {
1421 case ETT_TERRAIN:
1422 pterrain = terrain_by_number(value);
1423 if (pterrain) {
1424 pixbuf = create_terrain_pixbuf(pterrain);
1425 }
1426 break;
1427 case ETT_TERRAIN_RESOURCE:
1428 case ETT_TERRAIN_SPECIAL:
1429 case ETT_ROAD:
1430 case ETT_MILITARY_BASE:
1431 if (value >= 0) {
1432 pixbuf = create_extra_pixbuf(extra_by_number(value));
1433 }
1434 break;
1435 case ETT_UNIT:
1436 putype = utype_by_number(value);
1437 if (putype) {
1438 sprite = get_unittype_sprite(tileset, putype, direction8_invalid());
1439 }
1440 break;
1441 case ETT_CITY:
1442 sprite = sprites->city;
1443 break;
1444 case ETT_VISION:
1445 sprite = sprites->vision;
1446 break;
1447 case ETT_STARTPOS:
1448 sprite = sprites->startpos;
1449 break;
1450 case ETT_COPYPASTE:
1451 sprite = sprites->copypaste;
1452 break;
1453 default:
1454 break;
1455 }
1456
1457 if (sprite) {
1458 pixbuf = sprite_get_pixbuf(sprite);
1459 /*
1460 if (pixbuf) {
1461 g_object_ref(pixbuf);
1462 }
1463 */
1464 sprite = NULL;
1465 }
1466
1467 return pixbuf;
1468}
1469
1470/************************************************************************/
1476 static GdkPixbuf *get_tool_mode_pixbuf(enum editor_tool_mode etm)
1477{
1478 struct sprite *sprite = NULL;
1479 GdkPixbuf *pixbuf = NULL;
1480
1481 sprite = editor_get_mode_sprite(etm);
1482
1483 if (sprite) {
1484 pixbuf = sprite_get_pixbuf(sprite);
1485 /*
1486 if (pixbuf) {
1487 g_object_ref(pixbuf);
1488 }
1489 */
1490 }
1491
1492 return pixbuf;
1493}
1494
1495/************************************************************************/
1500 static void replace_widget(GtkWidget *old, GtkWidget *new)
1501{
1502 GtkWidget *parent;
1503
1504 parent = gtk_widget_get_parent(old);
1505 if (!parent) {
1506 return;
1507 }
1508
1509 gtk_widget_hide(old);
1510 gtk_container_remove(GTK_CONTAINER(parent), old);
1511 gtk_container_add(GTK_CONTAINER(parent), new);
1512 gtk_widget_show_all(new);
1513}
1514
1515/************************************************************************/
1518 static void editinfobox_refresh(struct editinfobox *ei)
1519{
1520 GdkPixbuf *pixbuf = NULL;
1521 GtkLabel *label;
1522 enum editor_tool_type ett;
1523 enum editor_tool_mode etm;
1524 int value;
1525 char buf[256];
1526
1527 if (ei == NULL) {
1528 return;
1529 }
1530
1531 if (!editor_is_active()) {
1532 replace_widget(ei->widget, unit_info_box);
1533 return;
1534 }
1535
1536 ett = editor_get_tool();
1537 etm = editor_tool_get_mode(ett);
1538 value = editor_tool_get_value(ett);
1539
1540 label = GTK_LABEL(ei->mode_label);
1541 gtk_label_set_text(label, editor_tool_get_mode_name(ett, etm));
1542
1543 pixbuf = get_tool_mode_pixbuf(etm);
1544 gtk_image_set_from_pixbuf(GTK_IMAGE(ei->mode_image), pixbuf);
1545 if (pixbuf) {
1546 g_object_unref(pixbuf);
1547 pixbuf = NULL;
1548 }
1549
1550 fc_snprintf(buf, sizeof(buf), "<span weight=\"bold\">%s</span>",
1551 editor_tool_get_name(ett));
1552 gtk_label_set_markup(GTK_LABEL(ei->tool_label), buf);
1553
1554 if (etm == ETM_COPY || etm == ETM_PASTE) {
1555 struct edit_buffer *ebuf;
1556 struct sprite *spr;
1557 char status[256];
1558
1559 ebuf = editor_get_copy_buffer();
1560 edit_buffer_get_status_string(ebuf, status, sizeof(status));
1561 gtk_label_set_text(GTK_LABEL(ei->tool_value_label), status);
1562
1563 spr = editor_tool_get_sprite(ett);
1564 pixbuf = spr ? sprite_get_pixbuf(spr) : NULL;
1565 gtk_image_set_from_pixbuf(GTK_IMAGE(ei->tool_image), pixbuf);
1566 if (pixbuf) {
1567 g_object_unref(G_OBJECT(pixbuf));
1568 pixbuf = NULL;
1569 }
1570 } else {
1571 pixbuf = get_tool_value_pixbuf(ett, value);
1572 gtk_image_set_from_pixbuf(GTK_IMAGE(ei->tool_image), pixbuf);
1573 if (pixbuf) {
1574 g_object_unref(pixbuf);
1575 pixbuf = NULL;
1576 }
1577 gtk_label_set_text(GTK_LABEL(ei->tool_value_label),
1578 editor_tool_get_value_name(ett, value));
1579 }
1580
1581 replace_widget(unit_info_box, ei->widget);
1582
1583 if (editor_tool_has_size(ett)) {
1584 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ei->size_spin_button),
1585 editor_tool_get_size(ett));
1586 gtk_widget_show(ei->size_hbox);
1587 } else {
1588 gtk_widget_hide(ei->size_hbox);
1589 }
1590
1591 if (editor_tool_has_count(ett)) {
1592 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ei->count_spin_button),
1593 editor_tool_get_count(ett));
1594 gtk_widget_show(ei->count_hbox);
1595 } else {
1596 gtk_widget_hide(ei->count_hbox);
1597 }
1598
1599 refresh_tool_applied_player_combo(ei);
1600}
1601
1602/************************************************************************/
1605 static gboolean handle_edit_key_press_with_ctrl(GdkEventKey *ev)
1606{
1607 return FALSE; /* Don't gobble. */
1608}
1609
1610/************************************************************************/
1613 static gboolean handle_edit_key_press_with_shift(GdkEventKey *ev)
1614{
1615 enum editor_tool_type ett;
1616
1617 ett = editor_get_tool();
1618 switch (ev->keyval) {
1619 case GDK_KEY_D:
1620 editor_tool_toggle_mode(ett, ETM_ERASE);
1621 break;
1622 case GDK_KEY_C:
1623 editor_set_tool(ETT_COPYPASTE);
1624 editor_tool_toggle_mode(ett, ETM_COPY);
1625 break;
1626 case GDK_KEY_V:
1627 editor_set_tool(ETT_COPYPASTE);
1628 editor_tool_toggle_mode(ett, ETM_PASTE);
1629 break;
1630 case GDK_KEY_T:
1631 editgui_run_tool_selection(ETT_TERRAIN);
1632 break;
1633 case GDK_KEY_R:
1634 editgui_run_tool_selection(ETT_TERRAIN_RESOURCE);
1635 break;
1636 case GDK_KEY_S:
1637 editgui_run_tool_selection(ETT_TERRAIN_SPECIAL);
1638 break;
1639 case GDK_KEY_P:
1640 editgui_run_tool_selection(ETT_ROAD);
1641 break;
1642 case GDK_KEY_M:
1643 editgui_run_tool_selection(ETT_MILITARY_BASE);
1644 break;
1645 case GDK_KEY_U:
1646 editgui_run_tool_selection(ETT_UNIT);
1647 break;
1648 default:
1649 return TRUE; /* Gobble? */
1650 break;
1651 }
1652
1653 editgui_refresh();
1654
1655 return TRUE;
1656}
1657
1658/************************************************************************/
1661gboolean handle_edit_key_press(GdkEventKey *ev)
1662{
1663 enum editor_tool_type ett, new_ett = NUM_EDITOR_TOOL_TYPES;
1664
1665 /* Check ctrl before shift - this is correct also for the case where
1666 * they are both active. */
1667 if (ev->state & GDK_CONTROL_MASK) {
1668 return handle_edit_key_press_with_ctrl(ev);
1669 }
1670
1671 if (ev->state & GDK_SHIFT_MASK) {
1672 return handle_edit_key_press_with_shift(ev);
1673 }
1674
1675 ett = editor_get_tool();
1676
1677 switch (ev->keyval) {
1678 case GDK_KEY_t:
1679 new_ett = ETT_TERRAIN;
1680 break;
1681 case GDK_KEY_r:
1682 new_ett = ETT_TERRAIN_RESOURCE;
1683 break;
1684 case GDK_KEY_s:
1685 new_ett = ETT_TERRAIN_SPECIAL;
1686 break;
1687 case GDK_KEY_p:
1688 new_ett = ETT_ROAD;
1689 break;
1690 case GDK_KEY_m:
1691 new_ett = ETT_MILITARY_BASE;
1692 break;
1693 case GDK_KEY_u:
1694 new_ett = ETT_UNIT;
1695 break;
1696 case GDK_KEY_c:
1697 new_ett = ETT_CITY;
1698 break;
1699 case GDK_KEY_v:
1700 new_ett = ETT_VISION;
1701 break;
1702 case GDK_KEY_b:
1703 new_ett = ETT_STARTPOS;
1704 break;
1705 case GDK_KEY_plus:
1706 case GDK_KEY_equal:
1707 case GDK_KEY_KP_Add:
1708 if (editor_tool_has_size(ett)) {
1709 int size = editor_tool_get_size(ett);
1710 editor_tool_set_size(ett, size + 1);
1711 } else if (editor_tool_has_count(ett)) {
1712 int count = editor_tool_get_count(ett);
1713 editor_tool_set_count(ett, count + 1);
1714 }
1715 break;
1716 case GDK_KEY_minus:
1717 case GDK_KEY_underscore:
1718 case GDK_KEY_KP_Subtract:
1719 if (editor_tool_has_size(ett)) {
1720 int size = editor_tool_get_size(ett);
1721 editor_tool_set_size(ett, size - 1);
1722 } else if (editor_tool_has_count(ett)) {
1723 int count = editor_tool_get_count(ett);
1724 editor_tool_set_count(ett, count - 1);
1725 }
1726 break;
1727 case GDK_KEY_1:
1728 case GDK_KEY_2:
1729 case GDK_KEY_3:
1730 case GDK_KEY_4:
1731 case GDK_KEY_5:
1732 case GDK_KEY_6:
1733 case GDK_KEY_7:
1734 case GDK_KEY_8:
1735 case GDK_KEY_9:
1736 if (editor_tool_has_size(ett)) {
1737 editor_tool_set_size(ett, ev->keyval - GDK_KEY_1 + 1);
1738 } else if (editor_tool_has_count(ett)) {
1739 editor_tool_set_count(ett, ev->keyval - GDK_KEY_1 + 1);
1740 }
1741 break;
1742 case GDK_KEY_space:
1743 editor_apply_tool_to_selection();
1744 break;
1745 case GDK_KEY_Tab:
1746 editgui_run_tool_selection(ett);
1747 break;
1748 case GDK_KEY_F1:
1749 case GDK_KEY_F2:
1750 case GDK_KEY_F3:
1751 case GDK_KEY_F4:
1752 case GDK_KEY_F5:
1753 case GDK_KEY_F6:
1754 case GDK_KEY_F7:
1755 case GDK_KEY_F8:
1756 case GDK_KEY_F9:
1757 case GDK_KEY_F10:
1758 case GDK_KEY_F11:
1759 case GDK_KEY_F12:
1760 return FALSE; /* Allow default handler. */
1761 break;
1762 default:
1763 return TRUE; /* Gobbled... */
1764 break;
1765 }
1766
1767 if (new_ett != NUM_EDITOR_TOOL_TYPES) {
1768 try_to_set_editor_tool(new_ett);
1769 }
1770
1771 editgui_refresh();
1772
1773 return TRUE;
1774}
1775
1776/************************************************************************/
1779gboolean handle_edit_key_release(GdkEventKey *ev)
1780{
1781 return FALSE;
1782}
1783
1784/************************************************************************/
1787 struct editbar *editgui_get_editbar(void)
1788{
1789 return editor_toolbar;
1790}
1791
1792/************************************************************************/
1795 void editgui_refresh(void)
1796{
1797 struct property_editor *pe;
1798 struct editbar *eb;
1799 struct editinfobox *ei;
1800
1801 eb = editgui_get_editbar();
1802 if (eb != NULL) {
1803 editbar_refresh(eb);
1804 }
1805
1806 ei = editgui_get_editinfobox();
1807 if (ei != NULL) {
1808 editinfobox_refresh(ei);
1809 }
1810
1811 pe = editprop_get_property_editor();
1812 if (!editor_is_active()) {
1813 property_editor_clear(pe);
1814 property_editor_popdown(pe);
1815 }
1816}
1817
1818/************************************************************************/
1821 void editgui_create_widgets(void)
1822{
1823 if (editor_toolbar == NULL) {
1824 editor_toolbar = editbar_create();
1825 }
1826 if (editor_infobox == NULL) {
1827 editor_infobox = editinfobox_create();
1828 }
1829}
1830
1831/************************************************************************/
1834 void editgui_free(void)
1835{
1836 struct editbar *eb = editgui_get_editbar();
1837 struct editinfobox *ei = editgui_get_editinfobox();
1838
1839 if (ei != NULL) {
1840 /* We have extra ref for ei->widget that has protected
1841 * it from getting destroyed when editinfobox_refresh()
1842 * moves widgets around. Free that extra ref here. */
1843 g_object_unref(ei->widget);
1844 }
1845
1846 clear_tool_stores(eb);
1847}
1848
1849/************************************************************************/
1852 struct editinfobox *editgui_get_editinfobox(void)
1853{
1854 return editor_infobox;
1855}
1856
1857/************************************************************************/
1861 void editgui_tileset_changed(void)
1862{
1863 editbar_reload_tileset(editgui_get_editbar());
1864 editinfobox_refresh(editgui_get_editinfobox());
1865}
1866
1867/************************************************************************/
1874 void editgui_popup_properties(const struct tile_list *tiles, int objtype)
1875{
1876 struct property_editor *pe;
1877
1878 pe = editprop_get_property_editor();
1879 property_editor_clear(pe);
1880 property_editor_reload(pe, OBJTYPE_PLAYER);
1881 property_editor_reload(pe, OBJTYPE_GAME);
1882 property_editor_load_tiles(pe, tiles);
1883 property_editor_popup(pe, objtype);
1884}
1885
1886/************************************************************************/
1889 void editgui_popdown_all(void)
1890{
1891 struct property_editor *pe;
1892
1893 pe = editprop_get_property_editor();
1894 property_editor_popdown(pe);
1895 property_editor_clear(pe); /* And clear it. */
1896}
1897
1898/************************************************************************/
1906 void editgui_notify_object_changed(int objtype, int object_id, bool removal)
1907{
1908 struct property_editor *pe;
1909
1910 if (!editor_is_active()) {
1911 return;
1912 }
1913
1914 pe = editprop_get_property_editor();
1915 property_editor_handle_object_changed(pe, objtype, object_id, removal);
1916}
1917
1918/************************************************************************/
1921 void editgui_notify_object_created(int tag, int id)
1922{
1923 struct property_editor *pe;
1924
1925 if (!editor_is_active()) {
1926 return;
1927 }
1928
1929 pe = editprop_get_property_editor();
1930 property_editor_handle_object_created(pe, tag, id);
1931}
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:1346
client_player_number
int client_player_number(void)
Definition client_main.c:1354
client_main.h
client_player
#define client_player()
Definition client_main.h:106
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
MOUSE_BUTTON_OTHER
@ MOUSE_BUTTON_OTHER
Definition editor.h:124
MOUSE_BUTTON_LEFT
@ MOUSE_BUTTON_LEFT
Definition editor.h:126
MOUSE_BUTTON_RIGHT
@ MOUSE_BUTTON_RIGHT
Definition editor.h:128
MOUSE_BUTTON_MIDDLE
@ MOUSE_BUTTON_MIDDLE
Definition editor.h:127
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:175
extra_name_translation
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:186
extra_index
#define extra_index(_e_)
Definition extras.h:177
extra_type_by_cause_iterate_end
#define extra_type_by_cause_iterate_end
Definition extras.h:315
extra_type_by_cause_iterate
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:309
EC_SPECIAL
#define EC_SPECIAL
Definition fc_types.h:968
fcintl.h
_
#define _(String)
Definition fcintl.h:67
game.h
government.h
FC_STATIC_CANVAS_INIT
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:27
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:1518
editgui_popup_properties
void editgui_popup_properties(const struct tile_list *tiles, int objtype)
Definition editgui.c:1874
editgui_notify_object_created
void editgui_notify_object_created(int tag, int id)
Definition editgui.c:1921
handle_edit_key_release
gboolean handle_edit_key_release(GdkEventKey *ev)
Definition editgui.c:1779
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:897
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:955
handle_edit_key_press_with_ctrl
static gboolean handle_edit_key_press_with_ctrl(GdkEventKey *ev)
Definition editgui.c:1605
handle_edit_key_press
gboolean handle_edit_key_press(GdkEventKey *ev)
Definition editgui.c:1661
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:1821
editbar_create
static struct editbar * editbar_create(void)
Definition editgui.c:519
editgui_popdown_all
void editgui_popdown_all(void)
Definition editgui.c:1889
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:979
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:1613
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:939
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:993
create_terrain_pixbuf
static GdkPixbuf * create_terrain_pixbuf(struct terrain *pterrain)
Definition editgui.c:696
editbar_tool_button_mouse_click
static gboolean editbar_tool_button_mouse_click(GtkWidget *w, GdkEventButton *ev, gpointer userdata)
Definition editgui.c:389
replace_widget
static void replace_widget(GtkWidget *old, GtkWidget *new)
Definition editgui.c:1500
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:1852
convert_mouse_button
static int convert_mouse_button(int gdk_mouse_button)
Definition editgui.c:917
handle_edit_mouse_move
gboolean handle_edit_mouse_move(GdkEventMotion *ev)
Definition editgui.c:970
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:1795
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:1787
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:1861
editgui_free
void editgui_free(void)
Definition editgui.c:1834
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:1476
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:6261
property_editor_handle_object_created
void property_editor_handle_object_created(struct property_editor *pe, int tag, int object_id)
Definition editprop.c:6283
property_editor_popup
void property_editor_popup(struct property_editor *pe, enum editor_object_type objtype)
Definition editprop.c:6231
editprop_get_property_editor
struct property_editor * editprop_get_property_editor(void)
Definition editprop.c:6184
property_editor_reload
void property_editor_reload(struct property_editor *pe, enum editor_object_type objtype)
Definition editprop.c:6321
property_editor_popdown
void property_editor_popdown(struct property_editor *pe)
Definition editprop.c:6249
property_editor_load_tiles
void property_editor_load_tiles(struct property_editor *pe, const struct tile_list *tiles)
Definition editprop.c:6195
property_editor_clear
void property_editor_clear(struct property_editor *pe)
Definition editprop.c:6301
unit_info_box
GtkWidget * unit_info_box
Definition gui_main.c:151
toplevel
GtkWidget * toplevel
Definition gui_main.c:124
disable_gobject_callback
void disable_gobject_callback(GObject *obj, GCallback cb)
Definition gui_stuff.c:1087
enable_gobject_callback
void enable_gobject_callback(GObject *obj, GCallback cb)
Definition gui_stuff.c:1103
get_flag
GdkPixbuf * get_flag(const struct nation_type *nation)
Definition plrdlg.c:609
tooltip
const char * tooltip
Definition repodlgs.c:1314
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
editgui.h
editprop.h
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
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:1313
mapview_common.h
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
NO_NATION_SELECTED
#define NO_NATION_SELECTED
Definition nation.h:29
packets.h
player_by_number
struct player * player_by_number(const int player_id)
Definition player.c:840
player_count
int player_count(void)
Definition player.c:808
player_number
int player_number(const struct player *pplayer)
Definition player.c:828
player_name
const char * player_name(const struct player *pplayer)
Definition player.c:886
players_iterate_end
#define players_iterate_end
Definition player.h:535
players_iterate
#define players_iterate(_pplayer)
Definition player.h:530
shared.h
size
size_t size
Definition specvec.h:72
canvas
Definition canvas.h:21
canvas::surface
cairo_surface_t * surface
Definition canvas.h:22
drawn_sprite
Definition tilespec.h:109
edit_buffer
Definition editor.c:62
editbar
Definition editgui.h:24
editbar::tool_buttons
GtkWidget * tool_buttons[NUM_EDITOR_TOOL_TYPES]
Definition editgui.h:31
editbar::player_pov_combobox
GtkWidget * player_pov_combobox
Definition editgui.h:35
editbar::player_pov_store
GtkListStore * player_pov_store
Definition editgui.h:34
editbar::size_group
GtkSizeGroup * size_group
Definition editgui.h:28
editbar::widget
GtkWidget * widget
Definition editgui.h:26
editbar::mode_buttons
GtkWidget * mode_buttons[NUM_EDITOR_TOOL_MODES]
Definition editgui.h:30
editbar::tool_selectors
struct tool_value_selector * tool_selectors[NUM_EDITOR_TOOL_TYPES]
Definition editgui.h:32
editinfobox
Definition editgui.h:44
editinfobox::tool_label
GtkWidget * tool_label
Definition editgui.h:50
editinfobox::tool_applied_player_store
GtkListStore * tool_applied_player_store
Definition editgui.h:59
editinfobox::size_spin_button
GtkWidget * size_spin_button
Definition editgui.h:55
editinfobox::tool_applied_player_combobox
GtkWidget * tool_applied_player_combobox
Definition editgui.h:60
editinfobox::mode_image
GtkWidget * mode_image
Definition editgui.h:47
editinfobox::count_hbox
GtkWidget * count_hbox
Definition editgui.h:56
editinfobox::tool_image
GtkWidget * tool_image
Definition editgui.h:52
editinfobox::tool_value_label
GtkWidget * tool_value_label
Definition editgui.h:51
editinfobox::count_spin_button
GtkWidget * count_spin_button
Definition editgui.h:57
editinfobox::widget
GtkWidget * widget
Definition editgui.h:45
editinfobox::mode_label
GtkWidget * mode_label
Definition editgui.h:48
editinfobox::size_hbox
GtkWidget * size_hbox
Definition editgui.h:54
editor_sprites
Definition tilespec.h:336
editor_sprites::city
struct sprite * city
Definition tilespec.h:348
editor_sprites::vision
struct sprite * vision
Definition tilespec.h:349
editor_sprites::copypaste
struct sprite * copypaste
Definition tilespec.h:342
editor_sprites::startpos
struct sprite * startpos
Definition tilespec.h:343
editor_sprites::properties
struct sprite * properties
Definition tilespec.h:351
player
Definition player.h:249
player::name
char name[MAX_LEN_NAME]
Definition player.h:251
property_editor
Definition editprop.c:644
sprite
Definition sprite.h:22
terrain
Definition terrain.h:176
tileset
Definition tilespec.c:459
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:481
view
Definition mapview_common.h:36
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
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:226
terrain_by_number
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:144
terrain_number
Terrain_type_id terrain_number(const struct terrain *pterrain)
Definition terrain.c:135
terrain_type_iterate
#define terrain_type_iterate(_p)
Definition terrain.h:358
terrain_type_iterate_end
#define terrain_type_iterate_end
Definition terrain.h:364
get_unittype_sprite
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing)
Definition tilespec.c:6520
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:6868
tileset_tile_height
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:728
tileset_tile_width
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:716
get_editor_sprites
const struct editor_sprites * get_editor_sprites(const struct tileset *t)
Definition tilespec.c:6649
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:1612
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:838
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:845