1 // Copyright (C) 2007, 2008, 2009 Ben Asselstine
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 3 of the License, or
6 // (at your option) any later version.
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 Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 #include "gui/image-helpers.h"
21 #include "playerlist.h"
22 #include "GraphicsCache.h"
23 #include "stacklist.h"
24 #include "playerlist.h"
28 #include "templelist.h"
32 RuinMap::RuinMap(NamedLocation *r)
38 void RuinMap::draw_ruins (bool show_selected)
40 GraphicsCache *gc = GraphicsCache::getInstance();
42 // Draw all ruins as pictures over their location -- showing them as
43 // explored/unexplored
44 for (Ruinlist::iterator it = Ruinlist::getInstance()->begin();
45 it != Ruinlist::getInstance()->end(); it++)
47 if ((*it)->isHidden() == true &&
48 (*it)->getOwner() != Playerlist::getInstance()->getViewingplayer())
50 if ((*it)->isVisible(Playerlist::getViewingplayer()) == false)
53 if ((*it)->isSearched())
54 tmp = gc->getSmallRuinExploredPic();
57 if ((*it)->getType() == Ruin::STRONGHOLD)
58 tmp = gc->getSmallStrongholdUnexploredPic();
60 tmp = gc->getSmallRuinUnexploredPic();
63 Vector<int> pos = (*it)->getPos();
64 pos = mapToSurface(pos);
65 tmp->blit_centered(surface, pos);
68 if ((*it)->getId() == ruin->getId()) //is this the selected ruin?
70 Gdk::Color box_color = Gdk::Color();
71 box_color.set_rgb_p(100,100,100);
72 draw_rect(pos.x - (tmp->get_width()/2),
73 pos.y - (tmp->get_height()/2),
74 tmp->get_width(), tmp->get_height(), box_color);
80 void RuinMap::draw_temples (bool show_selected)
82 GraphicsCache *gc = GraphicsCache::getInstance();
84 // Draw all temples as pictures over their location
85 for (Templelist::iterator it = Templelist::getInstance()->begin();
86 it != Templelist::getInstance()->end(); it++)
88 if ((*it)->isVisible(Playerlist::getViewingplayer()) == false)
91 Vector<int> pos = (*it)->getPos();
92 pos = mapToSurface(pos);
93 PixMask *templepic = gc->getSmallTemplePic();
94 templepic->blit_centered(surface, pos);
97 if ((*it)->getId() == ruin->getId()) //is this the selected ruin?
99 Gdk::Color box_color = Gdk::Color();
100 box_color.set_rgb_p(100,100,100);
101 draw_rect(pos.x - (templepic->get_width()/2),
102 pos.y - (templepic->get_height()/2),
103 templepic->get_width(), templepic->get_height(),
110 void RuinMap::after_draw()
113 bool show_selected = true;
115 show_selected = false;
116 draw_ruins (show_selected);
117 draw_temples (show_selected);
118 map_changed.emit(surface);
121 void RuinMap::mouse_button_event(MouseButtonEvent e)
123 if (e.button == MouseButtonEvent::LEFT_BUTTON &&
124 e.state == MouseButtonEvent::PRESSED)
126 Ruinlist *rl = Ruinlist::getInstance();
128 Templelist *tl = Templelist::getInstance();
129 Temple *nearestTemple;
131 dest = mapFromScreen(e.pos);
133 nearestRuin = rl->getNearestVisibleRuin(dest, 4);
137 location_changed.emit (ruin);
138 draw(Playerlist::getViewingplayer());
142 nearestTemple = tl->getNearestVisibleTemple(dest, 4);
145 ruin = nearestTemple;
146 location_changed.emit (ruin);
147 draw(Playerlist::getViewingplayer());