1 // Copyright (C) 2007, Ole Laursen
2 // Copyright (C) 2007, 2008, 2009 Ben Asselstine
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.
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.
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
22 #include <sigc++/signal.h>
23 #include <sigc++/trackable.h>
24 #include <sigc++/connection.h>
27 #include "input-events.h"
28 #include "GraphicsCache.h"
30 #include "LocationBox.h"
40 /** Specialization of BigMap for the game (as opposed to the editor)
42 class GameBigMap: public BigMap
45 GameBigMap(bool intense_combat, bool see_opponents_production, bool see_opponents_stacks, bool military_advisor);
46 virtual ~GameBigMap();
48 // will center the bigmap on the stack
49 void select_active_stack();
50 void unselect_active_stack();
52 void mouse_button_event(MouseButtonEvent e);
53 void mouse_motion_event(MouseMotionEvent e);
54 void set_shift_key_down (bool down);
55 bool is_shift_key_down () const {return control_key_is_down;}
56 void set_control_key_down (bool down);
57 bool is_control_key_down () const {return control_key_is_down;}
59 // whether the map accepts input events
60 void set_input_locked(bool locked) { input_locked = locked; }
62 // signals for mouse clicks, deselect is signified with a null pointer
63 sigc::signal<void, Stack*> stack_selected;
64 sigc::signal<void, Stack*> stack_grouped_or_ungrouped;
65 sigc::signal<void, City*> city_visited; //for citywindow
66 sigc::signal<void, Vector<int>, City*> city_queried; //for city-info-tip
67 sigc::signal<void> city_unqueried;
68 sigc::signal<void, Ruin*, bool> ruin_queried; //true => show brief info
69 sigc::signal<void, Signpost*> signpost_queried;
70 sigc::signal<void, Vector<int> > stack_queried;
71 sigc::signal<void> stack_unqueried;
72 sigc::signal<void, Temple*, bool> temple_queried; //true=>show brief info
74 // emitted when a path for a stack is set
75 sigc::signal<void> path_set;
76 // emitted when the cursor changes
77 sigc::signal<void, GraphicsCache::CursorType> cursor_changed;
79 //the game object sets this when the active stack is fighting so we can
80 //draw a fight graphic, or not
81 void setFighting(LocationBox ruckus) {d_fighting = ruckus;};
87 static const double zoom_step = 10.0;
88 static const double max_magnification_factor = 200.0;
89 static const double min_magnification_factor = 50.0;
91 void reset_path_calculator(Stack *s);
93 bool d_intense_combat;
94 bool d_see_opponents_production;
95 bool d_see_opponents_stacks;
96 bool d_military_advisor;
98 std::vector<PixMask*> d_waypoint;
99 Vector<int> current_tile, prev_mouse_pos;
103 enum mouse_state_enum {
104 NONE, DRAGGING_MAP, SHOWING_CITY, SHOWING_RUIN,
105 SHOWING_TEMPLE, SHOWING_SIGNPOST, SHOWING_STACK,
106 DRAGGING_STACK, DRAGGING_ENDPOINT
108 bool shift_key_is_down;
109 bool control_key_is_down;
111 GraphicsCache::CursorType d_cursor;
112 void determine_mouse_cursor(Stack *stack, Vector<int> tile);
114 // for the marching ants around selected stack
115 sigc::connection selection_timeout_handler;
116 bool on_selection_timeout();
117 void zoom_view(double percent);
119 virtual void after_draw();
120 LocationBox d_fighting;
121 PathCalculator *path_calculator;