initial commit, lordsawar source, slightly modified
[lordsawar] / src / editor / editorbigmap.h
1 //  Copyright (C) 2007 Ole Laursen
2 //  Copyright (C) 2007, 2008, 2009 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 #ifndef EDITORBIGMAP_H
20 #define EDITORBIGMAP_H
21
22 #include <vector>
23 #include <sigc++/signal.h>
24 #include <sigc++/trackable.h>
25 #include <sigc++/connection.h>
26
27 #include "vector.h"
28 #include "input-events.h"
29 #include "bigmap.h"
30 #include "Tile.h"
31 #include "GraphicsCache.h"
32
33 class Stack;
34 class MapRenderer;
35
36 class City;
37 class Ruin;
38 class Signpost;
39 class Temple;
40 class UniquelyIdentified;
41
42
43 //! Scenario editor.  Specializatoin of the BigMap class for the editor.
44 class EditorBigMap: public BigMap
45 {
46  public:
47     EditorBigMap();
48     ~EditorBigMap();
49
50     enum Pointer {
51         POINTER = 0, 
52         TERRAIN, 
53         STACK, 
54         CITY, 
55         RUIN, 
56         TEMPLE, 
57         SIGNPOST,
58         ROAD, 
59         ERASE, 
60         MOVE, 
61         PORT, 
62         BRIDGE,
63         BAG
64     };
65     void set_pointer(Pointer pointer, int size, Tile::Type terrain, 
66                      int tile_style_id);
67
68     void mouse_button_event(MouseButtonEvent e);
69     void mouse_motion_event(MouseMotionEvent e);
70     void mouse_leave_event();
71
72     void toggleViewStylesOrTypes() { show_tile_types_instead_of_tile_styles = 
73       !show_tile_types_instead_of_tile_styles;};
74     // something was selected
75     typedef std::vector<UniquelyIdentified*> map_selection_seq;
76     sigc::signal<void, map_selection_seq> objects_selected;
77
78     // emitted whenever the user moves the mouse to a new tile
79     sigc::signal<void, Vector<int> > mouse_on_tile;
80
81     // emitted when the map is changed by the user
82     sigc::signal<void, Rectangle> map_tiles_changed;
83
84     void smooth_view();
85
86  private:
87     Vector<int> prev_mouse_pos, mouse_pos;
88
89     Pointer pointer;
90     Tile::Type pointer_terrain;
91     int pointer_size;
92     int pointer_tile_style_id;
93     //! moving sets if we're moving objects on the map via the move button
94     Vector<int> moving_objects_from;
95
96     enum {
97         NONE, DRAGGING
98     } mouse_state;
99
100     virtual void after_draw();
101     int tile_to_road_type(Vector<int> tile);
102     int tile_to_bridge_type(Vector<int> tile);
103     void change_map_under_cursor();
104     std::vector<Vector<int> > get_cursor_tiles();
105     Rectangle get_cursor_rectangle();
106     std::vector<Vector<int> > get_screen_tiles();
107     bool show_tile_types_instead_of_tile_styles;
108 };
109
110 #endif