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
21 #include <sigc++/functors/mem_fun.h>
23 #include "ruin-rewarded-dialog.h"
25 #include "glade-helpers.h"
26 #include "image-helpers.h"
27 #include "input-helpers.h"
28 #include "ucompose.hpp"
37 RuinRewardedDialog::RuinRewardedDialog(Reward_Ruin *reward)
39 Glib::RefPtr<Gtk::Builder> xml
40 = Gtk::Builder::create_from_file(get_glade_path()
41 + "/ruin-rewarded-dialog.ui");
43 xml->get_widget("dialog", dialog);
45 window_closed.connect(sigc::mem_fun(dialog, &Gtk::Dialog::hide));
47 xml->get_widget("map_image", map_image);
49 ruinmap = new RuinMap(reward->getRuin());
50 ruinmap->map_changed.connect(
51 sigc::mem_fun(this, &RuinRewardedDialog::on_map_changed));
53 Gtk::EventBox *map_eventbox;
54 xml->get_widget("map_eventbox", map_eventbox);
56 xml->get_widget("label", label);
57 set_title(_("A Sage!"));
62 RuinRewardedDialog::~RuinRewardedDialog()
68 void RuinRewardedDialog::set_parent_window(Gtk::Window &parent)
70 dialog->set_transient_for(parent);
71 //dialog->set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
74 void RuinRewardedDialog::hide()
79 void RuinRewardedDialog::run()
82 ruinmap->draw(Playerlist::getActiveplayer());
85 s += String::ucompose(_("The sages show thee the site of %1\n"),
86 d_reward->getRuin()->getName());
87 Reward *reward = d_reward->getRuin()->getReward();
88 if (reward->getType() == Reward::ALLIES)
89 s += _("where powerful allies can be found!");
90 else if (reward->getType() == Reward::ITEM)
92 Item *item = static_cast<Reward_Item*>(reward)->getItem();
93 s += String::ucompose(_("where the %1 can be found!"), item->getName());
95 else if (reward->getType() == Reward::MAP)
96 s += _("where a map can be found!");
97 else if (reward->getType() == Reward::RUIN)
98 s += _("where nothing can be found!");
99 else if (reward->getType() == Reward::GOLD)
100 s += _("where gold can be found!");
101 else //this one shouldn't happen
102 s += _("where something important can be found!");
110 void RuinRewardedDialog::on_map_changed(Glib::RefPtr<Gdk::Pixmap> map)
112 map_image->property_pixmap() = map;