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-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
63
71
79
84
86 struct editbar *editbar_parent;
87
88 GtkWidget *dialog;
89
90 GtkListStore *store;
91 GtkWidget *view;
92};
93
94static struct tool_value_selector *
95create_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
106static struct editbar *editor_toolbar;
108
109/************************************************************************/
113static 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/************************************************************************/
154static 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);
171}
172
173/************************************************************************/
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/************************************************************************/
202static 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) {
214 }
215}
216
217/************************************************************************/
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++;
262
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/************************************************************************/
278static 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/************************************************************************/
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_hide(dialog);
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/************************************************************************/
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);
382 }
383
384 return TRUE;
385}
386
387/************************************************************************/
390static 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/************************************************************************/
401static 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
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/************************************************************************/
469 gpointer userdata)
470{
471 struct property_editor *pe;
472
477}
478
479/************************************************************************/
483static 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
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);
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/************************************************************************/
525static 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
544
545 separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
546 gtk_box_append(GTK_BOX(hbox), separator);
547
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",
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",
609 gtk_box_append(GTK_BOX(hbox), button);
610
611 return eb;
612}
613
614/************************************************************************/
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/************************************************************************/
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)) {
668 }
669 }
670}
671
672/************************************************************************/
675static 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_hide(eb->widget);
683 return;
684 }
685
689
690 gtk_widget_show(eb->widget);
691}
692
693/************************************************************************/
702static GdkPixbuf *create_terrain_pixbuf(struct terrain *pterrain)
703{
704 int w, h, i;
705 GdkPixbuf *pixbuf;
707 cairo_t *cr;
708
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];
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/************************************************************************/
736static 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/************************************************************************/
767
768/************************************************************************/
771static 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
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),
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 }
802
803
804 /* Reload terrain resources. */
805
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),
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 }
821
822 /* Reload terrain specials. */
823
825 store = tvs->store;
826
828 gtk_list_store_append(store, &iter);
829 gtk_list_store_set(store, &iter,
830 TVS_COL_ID, extra_index(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 }
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),
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 }
857
858 /* Reload military bases. */
859
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),
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 }
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),
887 -1);
888 sprite = get_unittype_sprite(tileset, putype, direction8_invalid());
889 if (sprite == NULL) {
890 continue;
891 }
892 pixbuf = sprite_get_pixbuf(sprite);
893 if (pixbuf != NULL) {
894 gtk_list_store_set(store, &iter, TVS_COL_IMAGE, pixbuf, -1);
895 g_object_unref(G_OBJECT(pixbuf));
896 }
898}
899
900/************************************************************************/
903static int convert_modifiers(int gdk_event_state)
904{
905 int modifiers = EKM_NONE;
906
907 if (gdk_event_state & GDK_SHIFT_MASK) {
908 modifiers |= EKM_SHIFT;
909 }
910 if (gdk_event_state & GDK_CONTROL_MASK) {
911 modifiers |= EKM_CTRL;
912 }
913 if (gdk_event_state & GDK_ALT_MASK) {
914 modifiers |= EKM_ALT;
915 }
916
917 return modifiers;
918}
919
920/************************************************************************/
923gboolean handle_edit_mouse_button_press(GtkGestureClick *gesture,
924 int editor_mouse_button,
925 double x, double y)
926{
927 GdkModifierType state;
928
929 state = gtk_event_controller_get_current_event_state(
930 GTK_EVENT_CONTROLLER(gesture));
931 editor_mouse_button_press(x, y, editor_mouse_button,
932 convert_modifiers(state));
933
934 return TRUE;
935}
936
937/************************************************************************/
940gboolean handle_edit_mouse_button_release(GtkGestureClick *gesture,
941 int editor_mouse_button,
942 double x, double y)
943{
944 GdkModifierType state;
945
946 state = gtk_event_controller_get_current_event_state(GTK_EVENT_CONTROLLER(gesture));
948 editor_mouse_button,
949 convert_modifiers(state));
950 return TRUE;
951}
952
953/************************************************************************/
956gboolean handle_edit_mouse_move(GtkEventControllerMotion *controller,
957 gdouble x, gdouble y)
958{
959 GdkModifierType state;
960
961 state = gtk_event_controller_get_current_event_state(GTK_EVENT_CONTROLLER(controller));
963
964 return TRUE;
965}
966
967/************************************************************************/
971 GtkTreePath *path,
972 GtkTreeViewColumn *col,
973 gpointer user_data)
974{
975 struct tool_value_selector *tvs = user_data;
976
977 gtk_dialog_response(GTK_DIALOG(tvs->dialog), GTK_RESPONSE_ACCEPT);
978}
979
980/************************************************************************/
983static struct tool_value_selector *
985 enum editor_tool_type ett)
986{
987 struct tool_value_selector *tvs;
988 GtkWidget *vbox, *view, *scrollwin;
989 GtkCellRenderer *cell;
990 GtkListStore *store;
991 GtkTreeViewColumn *col;
992 GtkTreeSelection *sel;
993
994 tvs = fc_calloc(1, sizeof(struct tool_value_selector));
995
996 tvs->editbar_parent = eb;
997
998 tvs->dialog = gtk_dialog_new_with_buttons(_("Select Tool Value"),
999 GTK_WINDOW(toplevel), GTK_DIALOG_MODAL,
1000 _("_OK"), GTK_RESPONSE_ACCEPT,
1001 _("_Cancel"), GTK_RESPONSE_REJECT,
1002 NULL);
1003 vbox = gtk_dialog_get_content_area(GTK_DIALOG(tvs->dialog));
1004
1005 store = gtk_list_store_new(TVS_NUM_COLS,
1006 GDK_TYPE_PIXBUF,
1007 G_TYPE_INT,
1008 G_TYPE_STRING);
1009 tvs->store = store;
1010
1011 scrollwin = gtk_scrolled_window_new();
1012 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(scrollwin), TRUE);
1013 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
1014 GTK_POLICY_NEVER,
1015 GTK_POLICY_AUTOMATIC);
1016 gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(scrollwin),
1018 gtk_box_insert_child_after(GTK_BOX(vbox), scrollwin, NULL);
1019
1020 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(tvs->store));
1021 gtk_widget_set_size_request(view, -1, 10 * tileset_tile_height(tileset));
1022 gtk_tree_view_set_search_column(GTK_TREE_VIEW(view), TVS_COL_NAME);
1023 g_signal_connect(view, "row-activated",
1025
1026 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1027 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
1028
1029 cell = gtk_cell_renderer_pixbuf_new();
1030 col = gtk_tree_view_column_new_with_attributes(editor_tool_get_name(ett),
1031 cell, "pixbuf",
1032 TVS_COL_IMAGE, NULL);
1033 gtk_tree_view_column_set_resizable(col, FALSE);
1034 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
1035 gtk_tree_view_column_set_reorderable(col, FALSE);
1036 gtk_tree_view_column_set_clickable(col, FALSE);
1037 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1038
1039 cell = gtk_cell_renderer_text_new();
1040 col = gtk_tree_view_column_new_with_attributes("ID", cell,
1041 "text", TVS_COL_ID, NULL);
1042 gtk_tree_view_column_set_resizable(col, FALSE);
1043 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
1044 gtk_tree_view_column_set_reorderable(col, FALSE);
1045 gtk_tree_view_column_set_clickable(col, FALSE);
1046 gtk_tree_view_column_set_sort_column_id(col, TVS_COL_ID);
1047 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1048
1049 cell = gtk_cell_renderer_text_new();
1050 col = gtk_tree_view_column_new_with_attributes("Name", cell,
1051 "text", TVS_COL_NAME, NULL);
1052 gtk_tree_view_column_set_resizable(col, FALSE);
1053 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
1054 gtk_tree_view_column_set_reorderable(col, FALSE);
1055 gtk_tree_view_column_set_clickable(col, FALSE);
1056 gtk_tree_view_column_set_sort_column_id(col, TVS_COL_NAME);
1057 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1058
1059 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scrollwin), view);
1060 tvs->view = view;
1061
1062 /* Show everything but the window itself. */
1063 gtk_widget_show(vbox);
1064
1065 return tvs;
1066}
1067
1068/************************************************************************/
1072 GtkGestureClick *gesture,
1073 int n_press,
1074 double x, double y)
1075{
1077
1078 return TRUE;
1079}
1080
1081/************************************************************************/
1085 GtkGestureClick *gesture,
1086 int n_press,
1087 double x, double y)
1088{
1091
1092 return TRUE;
1093}
1094
1095/************************************************************************/
1098static void editinfobox_spin_button_value_changed(GtkSpinButton *spinbutton,
1099 gpointer userdata)
1100{
1101 struct editinfobox *ei;
1102 int which, value;
1103 enum editor_tool_type ett;
1104
1106
1107 if (!ei) {
1108 return;
1109 }
1110
1111 value = gtk_spin_button_get_value_as_int(spinbutton);
1112 which = GPOINTER_TO_INT(userdata);
1113 ett = editor_get_tool();
1114
1115 switch (which) {
1116 case SPIN_BUTTON_SIZE:
1117 editor_tool_set_size(ett, value);
1118 break;
1119 case SPIN_BUTTON_COUNT:
1120 editor_tool_set_count(ett, value);
1121 break;
1122 default:
1123 return;
1124 break;
1125 }
1126
1128}
1129
1130/************************************************************************/
1134static void editinfobox_tool_applied_player_changed(GtkComboBox *combo,
1135 gpointer userdata)
1136{
1137 struct editinfobox *ei = userdata;
1138 GtkTreeIter iter;
1139 GtkTreeModel *model;
1140 int player_no = -1;
1141
1142 if (ei == NULL) {
1143 return;
1144 }
1145
1146 if (!gtk_combo_box_get_active_iter(combo, &iter)) {
1147 return;
1148 }
1149
1150 model = gtk_combo_box_get_model(combo);
1151 gtk_tree_model_get(model, &iter, TAP_COL_PLAYER_NO, &player_no, -1);
1152
1154}
1155
1156/************************************************************************/
1160{
1161 GtkWidget *label, *vgrid, *frame, *hgrid, *vgrid2, *pic;
1162 GtkWidget *spin, *combo;
1163 GtkListStore *store;
1164 GtkCellRenderer *cell;
1165 GtkEventController *controller;
1166 struct editinfobox *ei;
1167 char buf[128];
1168 int grid_row = 0;
1169 int grid_col = 0;
1170 int grid2_row = 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 vgrid = gtk_grid_new();
1184 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
1185 GTK_ORIENTATION_VERTICAL);
1186 gtk_grid_set_row_spacing(GTK_GRID(vgrid), 8);
1187 gtk_widget_set_margin_start(vgrid, 4);
1188 gtk_widget_set_margin_end(vgrid, 4);
1189 gtk_widget_set_margin_top(vgrid, 4);
1190 gtk_widget_set_margin_bottom(vgrid, 4);
1191 gtk_frame_set_child(GTK_FRAME(frame), vgrid);
1192
1193 /* tool section */
1194 hgrid = gtk_grid_new();
1195 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 8);
1196 gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1);
1197
1198 pic = gtk_picture_new();
1199 gtk_widget_set_tooltip_text(pic, _("Click to change value if applicable."));
1200
1201 controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
1202 g_signal_connect(controller, "pressed",
1204 NULL);
1205 gtk_widget_add_controller(pic, controller);
1206
1207 gtk_grid_attach(GTK_GRID(hgrid), pic, grid_col++, 0, 1, 1);
1208 ei->tool_pic = pic;
1209
1210 vgrid2 = gtk_grid_new();
1211 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid2),
1212 GTK_ORIENTATION_VERTICAL);
1213 gtk_grid_set_row_spacing(GTK_GRID(vgrid2), 4);
1214 gtk_grid_attach(GTK_GRID(hgrid), vgrid2, grid_col++, 0, 1, 1);
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_grid_attach(GTK_GRID(vgrid2), label, 0, grid2_row++, 1, 1);
1220 ei->tool_label = label;
1221
1222 label = gtk_label_new(NULL);
1223 gtk_widget_set_halign(label, GTK_ALIGN_START);
1224 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1225 gtk_grid_attach(GTK_GRID(vgrid2), label, 0, grid2_row++, 1, 1);
1226 ei->tool_value_label = label;
1227
1228 /* mode section */
1229 hgrid = gtk_grid_new();
1230 grid_col = 0;
1231 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 8);
1232 gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1);
1233
1234 pic = gtk_picture_new();
1235 gtk_widget_set_tooltip_text(pic, _("Click to change tool mode."));
1236
1237 controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
1238 g_signal_connect(controller, "pressed",
1240 NULL);
1241 gtk_widget_add_controller(pic, controller);
1242
1243 gtk_grid_attach(GTK_GRID(hgrid), pic, grid_col++, 0, 1, 1);
1244 ei->mode_pic = pic;
1245
1246 vgrid2 = gtk_grid_new();
1247 grid2_row = 0;
1248 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid2),
1249 GTK_ORIENTATION_VERTICAL);
1250 gtk_grid_set_row_spacing(GTK_GRID(vgrid2), 4);
1251 gtk_grid_attach(GTK_GRID(hgrid), vgrid2, grid_col++, 0, 1, 1);
1252
1253 label = gtk_label_new(NULL);
1254 fc_snprintf(buf, sizeof(buf), "<span weight=\"bold\">%s</span>",
1255 _("Mode"));
1256 gtk_label_set_markup(GTK_LABEL(label), buf);
1257 gtk_widget_set_halign(label, GTK_ALIGN_START);
1258 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1259 gtk_grid_attach(GTK_GRID(vgrid2), label, 0, grid2_row++, 1, 1);
1260
1261 label = gtk_label_new(NULL);
1262 gtk_widget_set_halign(label, GTK_ALIGN_START);
1263 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
1264 gtk_grid_attach(GTK_GRID(vgrid2), label, 0, grid2_row++, 1, 1);
1265 ei->mode_label = label;
1266
1267 /* spinner section */
1268 hgrid = gtk_grid_new();
1269 grid_col = 0;
1270 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 8);
1271 gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1);
1272 ei->size_hbox = hgrid;
1273 spin = gtk_spin_button_new_with_range(1, 255, 1);
1274 gtk_widget_set_tooltip_text(spin,
1275 _("Use this to change the \"size\" parameter for the tool. "
1276 "This parameter controls for example the half-width "
1277 "of the square of tiles that will be affected by the "
1278 "tool, or the size of a created city."));
1279 g_signal_connect(spin, "value-changed",
1281 GINT_TO_POINTER(SPIN_BUTTON_SIZE));
1282 gtk_grid_attach(GTK_GRID(hgrid), spin, grid_col++, 0, 1, 1);
1283 ei->size_spin_button = spin;
1284 label = gtk_label_new(_("Size"));
1285 gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1);
1286
1287 hgrid = gtk_grid_new();
1288 grid_col = 0;
1289 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 8);
1290 gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1);
1291 ei->count_hbox = hgrid;
1292 spin = gtk_spin_button_new_with_range(1, 255, 1);
1293 gtk_widget_set_tooltip_text(spin,
1294 _("Use this to change the tool's \"count\" parameter. "
1295 "This controls for example how many units are placed "
1296 "at once with the unit tool."));
1297 g_signal_connect(spin, "value-changed",
1299 GINT_TO_POINTER(SPIN_BUTTON_COUNT));
1300 gtk_grid_attach(GTK_GRID(hgrid), spin, grid_col++, 0, 1, 1);
1301 ei->count_spin_button = spin;
1302 label = gtk_label_new(_("Count"));
1303 gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1);
1304
1305 /* combo section */
1306 store = gtk_list_store_new(TAP_NUM_COLS,
1307 GDK_TYPE_PIXBUF,
1308 G_TYPE_STRING,
1309 G_TYPE_INT);
1310 ei->tool_applied_player_store = store;
1311 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
1312
1313 cell = gtk_cell_renderer_pixbuf_new();
1314 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, FALSE);
1315 gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo),
1316 cell, "pixbuf", TAP_COL_FLAG);
1317
1318 cell = gtk_cell_renderer_text_new();
1319 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, TRUE);
1320 gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo),
1321 cell, "text", TAP_COL_NAME);
1322
1323 gtk_widget_set_size_request(combo, 132, -1);
1324 g_signal_connect(combo, "changed",
1326
1327 gtk_widget_set_tooltip_text(combo,
1328 _("Use this to change the \"applied player\" tool parameter. "
1329 "This controls for example under which player units and cities "
1330 "are created."));
1331 gtk_grid_attach(GTK_GRID(vgrid), combo, 0, grid_row++, 1, 1);
1332 ei->tool_applied_player_combobox = combo;
1333
1334 /* We add a ref to the editinfobox widget so that it is
1335 * not destroyed when replaced by the unit info box when
1336 * we leave edit mode. See editinfobox_refresh() call to replace_widget() */
1337 g_object_ref(ei->widget);
1338
1339 /* The edit info box starts with no parent, so we have to
1340 * show its internal widgets manually. */
1341 gtk_widget_show(ei->widget);
1342
1343 return ei;
1344}
1345
1346/************************************************************************/
1351{
1352 enum editor_tool_type ett;
1353 GtkListStore *store;
1354 GtkWidget *combo;
1355 GtkTreeIter iter;
1356 GdkPixbuf *flag;
1357 int apno, index, i;
1358
1359 if (!ei) {
1360 return;
1361 }
1362
1363 ett = editor_get_tool();
1364 combo = ei->tool_applied_player_combobox;
1365 store = ei->tool_applied_player_store;
1366
1367 if (!combo || !store) {
1368 return;
1369 }
1370
1372 gtk_widget_hide(combo);
1373 return;
1374 }
1375
1376 gtk_list_store_clear(store);
1377
1379 index = -1;
1380 i = 0;
1381
1382 players_iterate(pplayer) {
1383 gtk_list_store_append(store, &iter);
1384 gtk_list_store_set(store, &iter,
1386 TAP_COL_NAME, player_name(pplayer), -1);
1387
1388 if (pplayer->nation != NO_NATION_SELECTED) {
1389 flag = get_flag(pplayer->nation);
1390
1391 if (flag != NULL) {
1392 gtk_list_store_set(store, &iter, TAP_COL_FLAG, flag, -1);
1393 g_object_unref(flag);
1394 }
1395 }
1396 if (apno == player_number(pplayer)) {
1397 index = i;
1398 }
1399 i++;
1401
1402 if (index == -1) {
1403 if (player_count() > 0) {
1404 index = 0;
1405 }
1407 }
1408 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), index);
1409 gtk_widget_show(combo);
1410}
1411
1412/************************************************************************/
1418static GdkPixbuf *get_tool_value_pixbuf(enum editor_tool_type ett,
1419 int value)
1420{
1421 struct sprite *sprite = NULL;
1422 GdkPixbuf *pixbuf = NULL;
1423 struct terrain *pterrain;
1424 struct unit_type *putype;
1425 const struct editor_sprites *sprites;
1426
1427 sprites = get_editor_sprites(tileset);
1428 if (!sprites) {
1429 return NULL;
1430 }
1431
1432 switch (ett) {
1433 case ETT_TERRAIN:
1434 pterrain = terrain_by_number(value);
1435 if (pterrain) {
1436 pixbuf = create_terrain_pixbuf(pterrain);
1437 }
1438 break;
1441 case ETT_ROAD:
1442 case ETT_MILITARY_BASE:
1443 if (value >= 0) {
1444 pixbuf = create_extra_pixbuf(extra_by_number(value));
1445 }
1446 break;
1447 case ETT_UNIT:
1448 putype = utype_by_number(value);
1449 if (putype) {
1450 sprite = get_unittype_sprite(tileset, putype, direction8_invalid());
1451 }
1452 break;
1453 case ETT_CITY:
1454 sprite = sprites->city;
1455 break;
1456 case ETT_VISION:
1457 sprite = sprites->vision;
1458 break;
1459 case ETT_STARTPOS:
1460 sprite = sprites->startpos;
1461 break;
1462 case ETT_COPYPASTE:
1463 sprite = sprites->copypaste;
1464 break;
1465 default:
1466 break;
1467 }
1468
1469 if (sprite) {
1470 pixbuf = sprite_get_pixbuf(sprite);
1471 /*
1472 if (pixbuf) {
1473 g_object_ref(pixbuf);
1474 }
1475 */
1476 sprite = NULL;
1477 }
1478
1479 return pixbuf;
1480}
1481
1482/************************************************************************/
1488static GdkPixbuf *get_tool_mode_pixbuf(enum editor_tool_mode etm)
1489{
1490 struct sprite *sprite = NULL;
1491 GdkPixbuf *pixbuf = NULL;
1492
1494
1495 if (sprite) {
1496 pixbuf = sprite_get_pixbuf(sprite);
1497 /*
1498 if (pixbuf) {
1499 g_object_ref(pixbuf);
1500 }
1501 */
1502 }
1503
1504 return pixbuf;
1505}
1506
1507/************************************************************************/
1512static void replace_widget(GtkWidget *old, GtkWidget *new)
1513{
1514 GtkWidget *parent;
1515
1516 parent = gtk_widget_get_parent(old);
1517 if (!parent) {
1518 return;
1519 }
1520
1521 gtk_widget_hide(old);
1522
1523 if (GTK_IS_FRAME(parent)) {
1524 gtk_frame_set_child(GTK_FRAME(parent), new);
1525 } else {
1526 fc_assert(GTK_IS_BOX(parent));
1527
1528 gtk_box_remove(GTK_BOX(parent), old);
1529 gtk_box_append(GTK_BOX(parent), new);
1530 }
1531
1532 gtk_widget_show(new);
1533}
1534
1535/************************************************************************/
1538static void editinfobox_refresh(struct editinfobox *ei)
1539{
1540 GdkPixbuf *pixbuf = NULL;
1541 GtkLabel *label;
1542 enum editor_tool_type ett;
1543 enum editor_tool_mode etm;
1544 int value;
1545 char buf[256];
1546
1547 if (ei == NULL) {
1548 return;
1549 }
1550
1551 if (!editor_is_active()) {
1553 return;
1554 }
1555
1556 ett = editor_get_tool();
1557 etm = editor_tool_get_mode(ett);
1558 value = editor_tool_get_value(ett);
1559
1560 label = GTK_LABEL(ei->mode_label);
1561 gtk_label_set_text(label, editor_tool_get_mode_name(ett, etm));
1562
1563 pixbuf = get_tool_mode_pixbuf(etm);
1564 gtk_picture_set_pixbuf(GTK_PICTURE(ei->mode_pic), pixbuf);
1565 if (pixbuf) {
1566 g_object_unref(pixbuf);
1567 pixbuf = NULL;
1568 }
1569
1570 fc_snprintf(buf, sizeof(buf), "<span weight=\"bold\">%s</span>",
1572 gtk_label_set_markup(GTK_LABEL(ei->tool_label), buf);
1573
1574 if (etm == ETM_COPY || etm == ETM_PASTE) {
1575 struct edit_buffer *ebuf;
1576 struct sprite *spr;
1577 char status[256];
1578
1579 ebuf = editor_get_copy_buffer();
1580 edit_buffer_get_status_string(ebuf, status, sizeof(status));
1581 gtk_label_set_text(GTK_LABEL(ei->tool_value_label), status);
1582
1583 spr = editor_tool_get_sprite(ett);
1584 pixbuf = spr ? sprite_get_pixbuf(spr) : NULL;
1585 gtk_picture_set_pixbuf(GTK_PICTURE(ei->tool_pic), pixbuf);
1586 if (pixbuf) {
1587 g_object_unref(G_OBJECT(pixbuf));
1588 pixbuf = NULL;
1589 }
1590 } else {
1591 pixbuf = get_tool_value_pixbuf(ett, value);
1592 gtk_picture_set_pixbuf(GTK_PICTURE(ei->tool_pic), pixbuf);
1593 if (pixbuf) {
1594 g_object_unref(pixbuf);
1595 pixbuf = NULL;
1596 }
1597 gtk_label_set_text(GTK_LABEL(ei->tool_value_label),
1598 editor_tool_get_value_name(ett, value));
1599 }
1600
1602
1603 if (editor_tool_has_size(ett)) {
1604 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ei->size_spin_button),
1606 gtk_widget_show(ei->size_hbox);
1607 } else {
1608 gtk_widget_hide(ei->size_hbox);
1609 }
1610
1611 if (editor_tool_has_count(ett)) {
1612 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ei->count_spin_button),
1614 gtk_widget_show(ei->count_hbox);
1615 } else {
1616 gtk_widget_hide(ei->count_hbox);
1617 }
1618
1620}
1621
1622/************************************************************************/
1625static gboolean handle_edit_key_press_with_ctrl(guint keyval)
1626{
1627 return FALSE; /* Don't gobble. */
1628}
1629
1630/************************************************************************/
1633static gboolean handle_edit_key_press_with_shift(guint keyval)
1634{
1635 enum editor_tool_type ett;
1636
1637 ett = editor_get_tool();
1638 switch (keyval) {
1639 case GDK_KEY_D:
1641 break;
1642 case GDK_KEY_C:
1645 break;
1646 case GDK_KEY_V:
1649 break;
1650 case GDK_KEY_T:
1652 break;
1653 case GDK_KEY_R:
1655 break;
1656 case GDK_KEY_S:
1658 break;
1659 case GDK_KEY_P:
1661 break;
1662 case GDK_KEY_M:
1664 break;
1665 case GDK_KEY_U:
1667 break;
1668 default:
1669 return TRUE; /* Gobble? */
1670 break;
1671 }
1672
1674
1675 return TRUE;
1676}
1677
1678/************************************************************************/
1681gboolean handle_edit_key_press(guint keyval, GdkModifierType state)
1682{
1683 enum editor_tool_type ett, new_ett = NUM_EDITOR_TOOL_TYPES;
1684
1685 /* Check ctrl before shift - this is correct also for the case where
1686 * they are both active. */
1687 if (state & GDK_CONTROL_MASK) {
1688 return handle_edit_key_press_with_ctrl(keyval);
1689 }
1690
1691 if (state & GDK_SHIFT_MASK) {
1692 return handle_edit_key_press_with_shift(keyval);
1693 }
1694
1695 ett = editor_get_tool();
1696
1697 switch (keyval) {
1698 case GDK_KEY_t:
1699 new_ett = ETT_TERRAIN;
1700 break;
1701 case GDK_KEY_r:
1702 new_ett = ETT_TERRAIN_RESOURCE;
1703 break;
1704 case GDK_KEY_s:
1705 new_ett = ETT_TERRAIN_SPECIAL;
1706 break;
1707 case GDK_KEY_p:
1708 new_ett = ETT_ROAD;
1709 break;
1710 case GDK_KEY_m:
1711 new_ett = ETT_MILITARY_BASE;
1712 break;
1713 case GDK_KEY_u:
1714 new_ett = ETT_UNIT;
1715 break;
1716 case GDK_KEY_c:
1717 new_ett = ETT_CITY;
1718 break;
1719 case GDK_KEY_v:
1720 new_ett = ETT_VISION;
1721 break;
1722 case GDK_KEY_b:
1723 new_ett = ETT_STARTPOS;
1724 break;
1725 case GDK_KEY_plus:
1726 case GDK_KEY_equal:
1727 case GDK_KEY_KP_Add:
1728 if (editor_tool_has_size(ett)) {
1729 int size = editor_tool_get_size(ett);
1730
1731 editor_tool_set_size(ett, size + 1);
1732 } else if (editor_tool_has_count(ett)) {
1733 int count = editor_tool_get_count(ett);
1734
1735 editor_tool_set_count(ett, count + 1);
1736 }
1737 break;
1738 case GDK_KEY_minus:
1739 case GDK_KEY_underscore:
1740 case GDK_KEY_KP_Subtract:
1741 if (editor_tool_has_size(ett)) {
1742 int size = editor_tool_get_size(ett);
1743
1744 editor_tool_set_size(ett, size - 1);
1745 } else if (editor_tool_has_count(ett)) {
1746 int count = editor_tool_get_count(ett);
1747
1748 editor_tool_set_count(ett, count - 1);
1749 }
1750 break;
1751 case GDK_KEY_1:
1752 case GDK_KEY_2:
1753 case GDK_KEY_3:
1754 case GDK_KEY_4:
1755 case GDK_KEY_5:
1756 case GDK_KEY_6:
1757 case GDK_KEY_7:
1758 case GDK_KEY_8:
1759 case GDK_KEY_9:
1760 if (editor_tool_has_size(ett)) {
1761 editor_tool_set_size(ett, keyval - GDK_KEY_1 + 1);
1762 } else if (editor_tool_has_count(ett)) {
1763 editor_tool_set_count(ett, keyval - GDK_KEY_1 + 1);
1764 }
1765 break;
1766 case GDK_KEY_space:
1768 break;
1769 case GDK_KEY_Tab:
1771 break;
1772 case GDK_KEY_F1:
1773 case GDK_KEY_F2:
1774 case GDK_KEY_F3:
1775 case GDK_KEY_F4:
1776 case GDK_KEY_F5:
1777 case GDK_KEY_F6:
1778 case GDK_KEY_F7:
1779 case GDK_KEY_F8:
1780 case GDK_KEY_F9:
1781 case GDK_KEY_F10:
1782 case GDK_KEY_F11:
1783 case GDK_KEY_F12:
1784 return FALSE; /* Allow default handler. */
1785 break;
1786 default:
1787 return TRUE; /* Gobbled... */
1788 break;
1789 }
1790
1791 if (new_ett != NUM_EDITOR_TOOL_TYPES) {
1792 try_to_set_editor_tool(new_ett);
1793 }
1794
1796
1797 return TRUE;
1798}
1799
1800/************************************************************************/
1804{
1805 return editor_toolbar;
1806}
1807
1808/************************************************************************/
1812{
1813 struct property_editor *pe;
1814 struct editbar *eb;
1815 struct editinfobox *ei;
1816
1817 eb = editgui_get_editbar();
1818 if (eb != NULL) {
1819 editbar_refresh(eb);
1820 }
1821
1823 if (ei != NULL) {
1825 }
1826
1828 if (!editor_is_active()) {
1831 }
1832}
1833
1834/************************************************************************/
1838{
1839 if (editor_toolbar == NULL) {
1841 }
1842 if (editor_infobox == NULL) {
1844 }
1845}
1846
1847/************************************************************************/
1851{
1852 struct editbar *eb = editgui_get_editbar();
1853 struct editinfobox *ei = editgui_get_editinfobox();
1854
1855 if (ei != NULL) {
1856 /* We have extra ref for ei->widget that has protected
1857 * it from getting destroyed when editinfobox_refresh()
1858 * moves widgets around. Free that extra ref here. */
1859 g_object_unref(ei->widget);
1860 }
1861
1863}
1864
1865/************************************************************************/
1869{
1870 return editor_infobox;
1871}
1872
1873/************************************************************************/
1882
1883/************************************************************************/
1890void editgui_popup_properties(const struct tile_list *tiles, int objtype)
1891{
1892 struct property_editor *pe;
1893
1898 property_editor_load_tiles(pe, tiles);
1900}
1901
1902/************************************************************************/
1906{
1907 struct property_editor *pe;
1908
1911 property_editor_clear(pe); /* And clear it. */
1912}
1913
1914/************************************************************************/
1922void editgui_notify_object_changed(int objtype, int object_id, bool removal)
1923{
1924 struct property_editor *pe;
1925
1926 if (!editor_is_active()) {
1927 return;
1928 }
1929
1931 property_editor_handle_object_changed(pe, objtype, object_id, removal);
1932}
1933
1934/************************************************************************/
1938{
1939 struct property_editor *pe;
1940
1941 if (!editor_is_active()) {
1942 return;
1943 }
1944
1947}
int send_chat_printf(const char *format,...)
int send_chat(const char *message)
bool client_is_global_observer(void)
int client_player_number(void)
#define client_player()
int objtype
Definition editgui_g.h:28
editgui_notify_object_changed
Definition editgui_g.h:27
int int id
Definition editgui_g.h:28
int edit_buffer_get_status_string(const struct edit_buffer *ebuf, char *buf, int buflen)
Definition editor.c:1870
bool editor_is_active(void)
Definition editor.c:346
int editor_tool_get_size(enum editor_tool_type ett)
Definition editor.c:1218
void editor_set_tool(enum editor_tool_type ett)
Definition editor.c:270
void editor_mouse_button_press(int canvas_x, int canvas_y, int button, int modifiers)
Definition editor.c:661
void editor_mouse_move(int canvas_x, int canvas_y, int modifiers)
Definition editor.c:866
enum editor_tool_mode editor_tool_get_mode(enum editor_tool_type ett)
Definition editor.c:335
void editor_tool_set_count(enum editor_tool_type ett, int count)
Definition editor.c:1263
void editor_tool_toggle_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:1041
const char * editor_tool_get_value_name(enum editor_tool_type emt, int value)
Definition editor.c:1172
int editor_tool_get_value(enum editor_tool_type ett)
Definition editor.c:409
struct edit_buffer * editor_get_copy_buffer(void)
Definition editor.c:1767
void editor_tool_set_applied_player(enum editor_tool_type ett, int player_no)
Definition editor.c:1352
const char * editor_tool_get_mode_name(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:1778
void editor_tool_cycle_mode(enum editor_tool_type ett)
Definition editor.c:1058
int editor_tool_get_count(enum editor_tool_type ett)
Definition editor.c:1252
void editor_tool_set_size(enum editor_tool_type ett, int size)
Definition editor.c:1229
const char * editor_get_mode_tooltip(enum editor_tool_mode etm)
Definition editor.c:1815
bool editor_tool_is_usable(enum editor_tool_type ett)
Definition editor.c:359
enum editor_tool_type editor_get_tool(void)
Definition editor.c:286
bool editor_tool_has_applied_player(enum editor_tool_type ett)
Definition editor.c:1365
bool editor_tool_has_size(enum editor_tool_type ett)
Definition editor.c:1207
void editor_tool_set_value(enum editor_tool_type ett, int value)
Definition editor.c:397
bool editor_tool_has_value(enum editor_tool_type ett)
Definition editor.c:385
const char * editor_tool_get_tooltip(enum editor_tool_type ett)
Definition editor.c:1327
void editor_mouse_button_release(int canvas_x, int canvas_y, int button, int modifiers)
Definition editor.c:798
struct sprite * editor_tool_get_sprite(enum editor_tool_type ett)
Definition editor.c:1275
void editor_apply_tool_to_selection(void)
Definition editor.c:1128
bool editor_tool_has_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:313
int editor_tool_get_applied_player(enum editor_tool_type ett)
Definition editor.c:1341
bool editor_tool_has_count(enum editor_tool_type ett)
Definition editor.c:1241
struct sprite * editor_get_mode_sprite(enum editor_tool_mode etm)
Definition editor.c:1837
const char * editor_tool_get_name(enum editor_tool_type ett)
Definition editor.c:1159
void editor_tool_set_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:298
editor_tool_mode
Definition editor.h:52
@ ETM_PASTE
Definition editor.h:56
@ NUM_EDITOR_TOOL_MODES
Definition editor.h:58
@ ETM_ERASE
Definition editor.h:54
@ ETM_PAINT
Definition editor.h:53
@ ETM_COPY
Definition editor.h:55
@ OBJTYPE_PLAYER
Definition editor.h:30
@ OBJTYPE_GAME
Definition editor.h:31
@ EKM_CTRL
Definition editor.h:120
@ EKM_SHIFT
Definition editor.h:118
@ EKM_ALT
Definition editor.h:119
@ EKM_NONE
Definition editor.h:117
editor_tool_type
Definition editor.h:36
@ ETT_ROAD
Definition editor.h:40
@ ETT_TERRAIN_SPECIAL
Definition editor.h:39
@ ETT_UNIT
Definition editor.h:42
@ ETT_VISION
Definition editor.h:44
@ ETT_STARTPOS
Definition editor.h:46
@ NUM_EDITOR_TOOL_TYPES
Definition editor.h:49
@ ETT_CITY
Definition editor.h:43
@ ETT_COPYPASTE
Definition editor.h:47
@ ETT_TERRAIN_RESOURCE
Definition editor.h:38
@ ETT_MILITARY_BASE
Definition editor.h:41
@ ETT_TERRAIN
Definition editor.h:37
struct extra_type * extra_by_number(int id)
Definition extras.c:175
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:186
#define extra_index(_e_)
Definition extras.h:177
#define extra_type_by_cause_iterate_end
Definition extras.h:315
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:309
#define EC_SPECIAL
Definition fc_types.h:968
#define _(String)
Definition fcintl.h:67
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:27
static void refresh_all_buttons(struct editbar *eb)
Definition editgui.c:113
static void editbar_player_properties_button_clicked(GtkButton *b, gpointer userdata)
Definition editgui.c:463
tool_applied_player_columns
Definition editgui.c:72
@ TAP_COL_FLAG
Definition editgui.c:73
@ TAP_COL_NAME
Definition editgui.c:74
@ TAP_COL_PLAYER_NO
Definition editgui.c:75
@ TAP_NUM_COLS
Definition editgui.c:77
static bool editgui_run_tool_selection(enum editor_tool_type ett)
Definition editgui.c:356
static void editinfobox_refresh(struct editinfobox *ei)
Definition editgui.c:1518
void editgui_popup_properties(const struct tile_list *tiles, int objtype)
Definition editgui.c:1874
void editgui_notify_object_created(int tag, int id)
Definition editgui.c:1921
static void clear_tool_stores(struct editbar *eb)
Definition editgui.c:752
static int convert_modifiers(int gdk_event_state)
Definition editgui.c:897
static void try_to_set_editor_tool(enum editor_tool_type ett)
Definition editgui.c:177
static void clear_tool_store(GtkListStore *store)
Definition editgui.c:730
gboolean handle_edit_mouse_button_release(GdkEventButton *ev)
Definition editgui.c:955
static gboolean handle_edit_key_press_with_ctrl(GdkEventKey *ev)
Definition editgui.c:1605
gboolean handle_edit_key_press(GdkEventKey *ev)
Definition editgui.c:1661
static int tool_value_selector_run(struct tool_value_selector *tvs)
Definition editgui.c:319
static void editbar_add_mode_button(struct editbar *eb, enum editor_tool_mode etm)
Definition editgui.c:478
static void editbar_tool_button_toggled(GtkToggleButton *tb, gpointer userdata)
Definition editgui.c:201
static void editbar_add_tool_button(struct editbar *eb, enum editor_tool_type ett)
Definition editgui.c:407
void editgui_create_widgets(void)
Definition editgui.c:1821
static struct editbar * editbar_create(void)
Definition editgui.c:519
void editgui_popdown_all(void)
Definition editgui.c:1889
static void editbar_reload_tileset(struct editbar *eb)
Definition editgui.c:765
static void tool_value_selector_treeview_row_activated(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data)
Definition editgui.c:979
static void editinfobox_spin_button_value_changed(GtkSpinButton *spinbutton, gpointer userdata)
Definition editgui.c:1106
static void refresh_tool_applied_player_combo(struct editinfobox *ei)
Definition editgui.c:1338
static void editbar_mode_button_toggled(GtkToggleButton *tb, gpointer userdata)
Definition editgui.c:154
static void editinfobox_tool_applied_player_changed(GtkComboBox *combo, gpointer userdata)
Definition editgui.c:1142
static gboolean handle_edit_key_press_with_shift(GdkEventKey *ev)
Definition editgui.c:1613
static void refresh_all_tool_value_selectors(struct editbar *eb)
Definition editgui.c:651
spin_button_types
Definition editgui.c:80
@ SPIN_BUTTON_COUNT
Definition editgui.c:82
@ SPIN_BUTTON_SIZE
Definition editgui.c:81
gboolean handle_edit_mouse_button_press(GdkEventButton *ev)
Definition editgui.c:939
static struct tool_value_selector * create_tool_value_selector(struct editbar *eb_parent, enum editor_tool_type ett)
Definition editgui.c:993
static GdkPixbuf * create_terrain_pixbuf(struct terrain *pterrain)
Definition editgui.c:696
static void replace_widget(GtkWidget *old, GtkWidget *new)
Definition editgui.c:1500
static void editbar_player_pov_combobox_changed(GtkComboBox *combo, gpointer user_data)
Definition editgui.c:277
struct editinfobox * editgui_get_editinfobox(void)
Definition editgui.c:1852
gboolean handle_edit_mouse_move(GdkEventMotion *ev)
Definition editgui.c:970
tool_value_selector_columns
Definition editgui.c:56
@ TVS_COL_ID
Definition editgui.c:58
@ TVS_COL_NAME
Definition editgui.c:59
@ TVS_COL_IMAGE
Definition editgui.c:57
@ TVS_NUM_COLS
Definition editgui.c:61
player_pov_combo_columns
Definition editgui.c:64
@ PPV_COL_FLAG
Definition editgui.c:65
@ PPV_COL_PLAYER_NO
Definition editgui.c:67
@ PPV_COL_NAME
Definition editgui.c:66
@ PPV_NUM_COLS
Definition editgui.c:69
void editgui_refresh(void)
Definition editgui.c:1795
static void editbar_refresh(struct editbar *eb)
Definition editgui.c:669
static struct editinfobox * editor_infobox
Definition editgui.c:107
static struct editbar * editor_toolbar
Definition editgui.c:106
static gboolean editinfobox_handle_tool_image_button_press(GtkWidget *evbox, GdkEventButton *ev, gpointer data)
Definition editgui.c:1082
struct editbar * editgui_get_editbar(void)
Definition editgui.c:1787
static void refresh_tool_value_selector(struct editbar *eb, enum editor_tool_type ett)
Definition editgui.c:612
static struct editinfobox * editinfobox_create(void)
Definition editgui.c:1167
static void refresh_player_pov_indicator(struct editbar *eb)
Definition editgui.c:223
void editgui_tileset_changed(void)
Definition editgui.c:1861
void editgui_free(void)
Definition editgui.c:1834
static gboolean editinfobox_handle_mode_image_button_press(GtkWidget *evbox, GdkEventButton *ev, gpointer data)
Definition editgui.c:1093
static GdkPixbuf * get_tool_value_pixbuf(enum editor_tool_type ett, int value)
Definition editgui.c:1406
static GdkPixbuf * get_tool_mode_pixbuf(enum editor_tool_mode etm)
Definition editgui.c:1476
void property_editor_handle_object_changed(struct property_editor *pe, enum editor_object_type objtype, int object_id, bool remove)
Definition editprop.c:6284
void property_editor_handle_object_created(struct property_editor *pe, int tag, int object_id)
Definition editprop.c:6306
void property_editor_popup(struct property_editor *pe, enum editor_object_type objtype)
Definition editprop.c:6254
struct property_editor * editprop_get_property_editor(void)
Definition editprop.c:6207
void property_editor_reload(struct property_editor *pe, enum editor_object_type objtype)
Definition editprop.c:6344
void property_editor_popdown(struct property_editor *pe)
Definition editprop.c:6272
void property_editor_load_tiles(struct property_editor *pe, const struct tile_list *tiles)
Definition editprop.c:6218
void property_editor_clear(struct property_editor *pe)
Definition editprop.c:6324
GtkWidget * unit_info_box
Definition gui_main.c:151
GtkWidget * toplevel
Definition gui_main.c:124
void disable_gobject_callback(GObject *obj, GCallback cb)
Definition gui_stuff.c:1087
void enable_gobject_callback(GObject *obj, GCallback cb)
Definition gui_stuff.c:1103
GdkPixbuf * get_flag(const struct nation_type *nation)
Definition plrdlg.c:609
const char * tooltip
Definition repodlgs.c:1314
GdkPixbuf * surface_get_pixbuf(cairo_surface_t *surf, int width, int height)
Definition sprite.c:418
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
GdkPixbuf * create_extra_pixbuf(const struct extra_type *pextra)
Definition sprite.c:494
static gboolean editbar_tool_right_button(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition editgui.c:390
gint blocking_dialog(GtkWidget *dlg)
Definition gui_stuff.c:1126
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
void put_drawn_sprites(struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y, int count, struct drawn_sprite *pdrawn, bool fog)
#define fc_calloc(n, esz)
Definition mem.h:38
#define NO_NATION_SELECTED
Definition nation.h:29
struct player * player_by_number(const int player_id)
Definition player.c:840
int player_count(void)
Definition player.c:808
int player_number(const struct player *pplayer)
Definition player.c:828
const char * player_name(const struct player *pplayer)
Definition player.c:886
#define players_iterate_end
Definition player.h:535
#define players_iterate(_pplayer)
Definition player.h:530
size_t size
Definition specvec.h:72
cairo_surface_t * surface
Definition canvas.h:22
GtkWidget * tool_buttons[NUM_EDITOR_TOOL_TYPES]
Definition editgui.h:31
GtkWidget * player_pov_combobox
Definition editgui.h:35
GtkListStore * player_pov_store
Definition editgui.h:34
GtkSizeGroup * size_group
Definition editgui.h:28
GtkWidget * widget
Definition editgui.h:26
GtkWidget * mode_buttons[NUM_EDITOR_TOOL_MODES]
Definition editgui.h:30
struct tool_value_selector * tool_selectors[NUM_EDITOR_TOOL_TYPES]
Definition editgui.h:32
GtkWidget * tool_label
Definition editgui.h:50
GtkListStore * tool_applied_player_store
Definition editgui.h:59
GtkWidget * size_spin_button
Definition editgui.h:55
GtkWidget * tool_applied_player_combobox
Definition editgui.h:60
GtkWidget * count_hbox
Definition editgui.h:56
GtkWidget * tool_value_label
Definition editgui.h:51
GtkWidget * count_spin_button
Definition editgui.h:57
GtkWidget * widget
Definition editgui.h:45
GtkWidget * mode_label
Definition editgui.h:48
GtkWidget * tool_pic
Definition editgui.h:56
GtkWidget * size_hbox
Definition editgui.h:54
GtkWidget * mode_pic
Definition editgui.h:51
struct sprite * city
Definition tilespec.h:348
struct sprite * vision
Definition tilespec.h:349
struct sprite * copypaste
Definition tilespec.h:342
struct sprite * startpos
Definition tilespec.h:343
struct sprite * properties
Definition tilespec.h:351
char name[MAX_LEN_NAME]
Definition player.h:251
GtkWidget * view
Definition editgui.c:91
struct editbar * editbar_parent
Definition editgui.c:86
GtkListStore * store
Definition editgui.c:90
GtkWidget * dialog
Definition editgui.c:88
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:226
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:144
Terrain_type_id terrain_number(const struct terrain *pterrain)
Definition terrain.c:135
#define terrain_type_iterate(_p)
Definition terrain.h:358
#define terrain_type_iterate_end
Definition terrain.h:364
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing)
Definition tilespec.c:6516
int fill_basic_terrain_layer_sprite_array(struct tileset *t, struct drawn_sprite *sprs, int layer, struct terrain *pterrain)
Definition tilespec.c:6864
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:728
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:716
const struct editor_sprites * get_editor_sprites(const struct tileset *t)
Definition tilespec.c:6645
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
#define unit_type_iterate(_p)
Definition unittype.h:841
#define unit_type_iterate_end
Definition unittype.h:848