1
// Copyright (C) 2001, 2002, 2003 Michael Bartl
2
// Copyright (C) 2002, 2003, 2004, 2005, 2006 Ulf Lorenz
3
// Copyright (C) 2004, 2005, 2006 Andrea Paternesi
4
// Copyright (C) 2004 Thomas Plonka
5
// Copyright (C) 2006, 2007, 2008 Ben Asselstine
6
// Copyright (C) 2007 Ole Laursen
1
8
// This program is free software; you can redistribute it and/or modify
2
9
// it under the terms of the GNU General Public License as published by
3
10
// the Free Software Foundation; either version 2 of the License, or
11
18
// You should have received a copy of the GNU General Public License
12
19
// along with this program; if not, write to the Free Software
13
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
23
#include <config.h>
61
70
draw_rect(surface, pos.x+1, pos.y+1, pos.x + w-1, pos.y + h-1, raw);
64
void SmallMap::center_view(Vector<int> p, bool slide, bool from_tile)
66
if (from_tile == false)
68
p.x = int(round(p.x / pixels_per_tile));
69
p.y = int(round(p.y / pixels_per_tile));
73
p = clip(Vector<int>(0, 0), p, GameMap::get_dim() - view.dim);
77
p = clip(Vector<int>(0,0), p - view.dim / 2, GameMap::get_dim() - view.dim);
80
slide_view(Rectangle(p.x, p.y, view.w, view.h));
82
set_view(Rectangle(p.x, p.y, view.w, view.h));
84
if (Playerlist::isFinished()) //window closed while computer player moves
73
void SmallMap::center_view_on_tile(Vector<int> pos, bool slide)
75
pos = clip(Vector<int>(0,0), pos - view.dim / calculateResizeFactor(),
76
GameMap::get_dim() - view.dim);
79
slide_view(Rectangle(pos.x, pos.y, view.w, view.h));
81
set_view(Rectangle(pos.x, pos.y, view.w, view.h));
83
view_changed.emit(view);
86
void SmallMap::center_view_on_pixel(Vector<int> pos, bool slide)
88
pos.x = int(round(pos.x / pixels_per_tile));
89
pos.y = int(round(pos.y / pixels_per_tile));
91
pos -= view.dim / calculateResizeFactor();
93
pos = clip(Vector<int>(0, 0), pos, GameMap::get_dim() - view.dim);
96
slide_view(Rectangle(pos.x, pos.y, view.w, view.h));
98
set_view(Rectangle(pos.x, pos.y, view.w, view.h));
86
100
view_changed.emit(view);
89
103
void SmallMap::after_draw()
91
105
OverviewMap::after_draw();
106
if (Playerlist::getActiveplayer()->getType() == Player::HUMAN ||
107
Configuration::s_hidden_map == false)
94
112
map_changed.emit(get_surface());
102
120
if ((e.button == MouseButtonEvent::LEFT_BUTTON ||
103
121
e.button == MouseButtonEvent::RIGHT_BUTTON)
104
122
&& e.state == MouseButtonEvent::PRESSED)
105
center_view(e.pos, true, false);
123
center_view_on_pixel(e.pos, true);
108
126
void SmallMap::mouse_motion_event(MouseMotionEvent e)
178
void SmallMap::blank()
180
Uint32 fog_color = SDL_MapRGB(surface->format, 0, 0, 0);
181
int size = int(pixels_per_tile) > 1 ? int(pixels_per_tile) : 1;
183
for (int i = 0; i < GameMap::getWidth(); i++)
184
for (int j = 0; j < GameMap::getHeight(); j++)
189
pos = mapToSurface(pos);
190
draw_filled_rect(surface, pos.x, pos.y,
191
pos.x + size, pos.y + size, fog_color);
193
map_changed.emit(get_surface());