1 //  Copyright (C) 2007 Ole Laursen
2 //  Copyright (C) 2007, 2008, 2009, 2014, 2017, 2020 Ben Asselstine
3 //
4 //  This program is free software; you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation; either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU Library General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program; if not, write to the Free Software
16 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 //  02110-1301, USA.
18 
19 #pragma once
20 #ifndef EDITORBIGMAP_H
21 #define EDITORBIGMAP_H
22 
23 #include <vector>
24 #include <sigc++/signal.h>
25 #include <sigc++/trackable.h>
26 #include <sigc++/connection.h>
27 
28 #include "vector.h"
29 #include "input-events.h"
30 #include "bigmap.h"
31 #include "Tile.h"
32 #include "UniquelyIdentified.h"
33 
34 class MapBackpack;
35 //! Scenario editor.  Specializatoin of the BigMap class for the editor.
36 class EditorBigMap: public BigMap
37 {
38  public:
39     EditorBigMap();
~EditorBigMap()40     ~EditorBigMap() {}
41 
42     enum Pointer {
43 	POINTER = 0,
44 	TERRAIN,
45 	STACK,
46 	CITY,
47 	RUIN,
48 	TEMPLE,
49 	SIGNPOST,
50 	ROAD,
51 	ERASE,
52 	MOVE,
53 	PORT,
54 	BRIDGE,
55 	BAG,
56 	FIGHT,
57         STONE
58     };
59     void set_pointer(Pointer pointer, int size, Tile::Type terrain,
60 		     int tile_style_id);
61 
62     void mouse_button_event(MouseButtonEvent e);
63     void mouse_motion_event(MouseMotionEvent e);
64     void mouse_leave_event();
65 
66     // something was selected
67     typedef std::vector<UniquelyIdentified*> map_selection_seq;
68     sigc::signal<void, map_selection_seq> objects_selected;
69 
70     // emitted whenever the user moves the mouse to a new tile
71     sigc::signal<void, Vector<int> > mouse_on_tile;
72 
73     // emitted when the map is changed by the user
74     sigc::signal<void, LwRectangle> map_tiles_changed;
75 
76     // emitted when the water on the map is altered.
77     sigc::signal<void> map_water_changed;
78 
79     // emitted when the water on the map is altered.
80     sigc::signal<void, Vector<int> > bag_selected;
81     sigc::signal<void, Stack*> stack_selected_for_battle_calculator;
82 
83     void smooth_view();
84 
85  private:
86     Vector<int> prev_mouse_pos, mouse_pos;
87 
88     Pointer pointer;
89     Tile::Type pointer_terrain;
90     int pointer_size;
91     int pointer_tile_style_id;
92     //! moving sets if we're moving objects on the map via the move button
93     Vector<int> moving_objects_from;
94 
95     enum {
96 	NONE, DRAGGING, MOVE_DRAGGING
97     } mouse_state;
98 
99     MapBackpack *moving_bag;
100 
101     virtual void after_draw();
102     int tile_to_road_type(Vector<int> tile);
103     int tile_to_bridge_type(Vector<int> tile);
104     void change_map_under_cursor();
105     std::vector<Vector<int> > get_cursor_tiles();
106     LwRectangle get_cursor_rectangle();
107     std::vector<Vector<int> > get_screen_tiles();
108     void bring_up_details();
109     void display_moving_building(Vector<int> src, Vector<int> dest);
110     void blit (PixMask *src, Cairo::RefPtr<Cairo::Surface> dest, Vector<int> pos, double scale);
111 };
112 
113 #endif
114