1 // Copyright (C) 2007, 2008, 2009, 2012, 2014, 2017 Ben Asselstine
2 //
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.
7 //
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.
12 //
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
16 // 02110-1301, USA.
17
18 #include <config.h>
19
20 #include <gtkmm.h>
21 #include <sigc++/functors/mem_fun.h>
22
23 #include "quest-assigned-dialog.h"
24
25 #include "ucompose.hpp"
26 #include "defs.h"
27 #include "playerlist.h"
28
29 #define method(x) sigc::mem_fun(*this, &QuestAssignedDialog::x)
30
QuestAssignedDialog(Gtk::Window & parent,Hero * h,Quest * q)31 QuestAssignedDialog::QuestAssignedDialog(Gtk::Window &parent, Hero *h, Quest *q)
32 : LwDialog(parent, "quest-assigned-dialog.ui")
33 {
34 hero = h;
35 quest = q;
36
37 xml->get_widget("map_image", map_image);
38
39 questmap = new QuestMap(quest);
40 questmap->map_changed.connect(method(on_map_changed));
41
42 Gtk::EventBox *map_eventbox;
43 xml->get_widget("map_eventbox", map_eventbox);
44
45 dialog->set_title(String::ucompose(_("Quest for %1"), hero->getName()));
46
47 xml->get_widget("label", label);
48 Glib::ustring s;
49 if (quest)
50 s = quest->getDescription();
51 else
52 s = _("This hero already has a quest.");
53 label->set_text(s);
54
55 }
56
run()57 void QuestAssignedDialog::run()
58 {
59 questmap->resize();
60 questmap->draw();
61
62 dialog->show_all();
63 dialog->run();
64 }
65
on_map_changed(Cairo::RefPtr<Cairo::Surface> map)66 void QuestAssignedDialog::on_map_changed(Cairo::RefPtr<Cairo::Surface> map)
67 {
68 Glib::RefPtr<Gdk::Pixbuf> pixbuf =
69 Gdk::Pixbuf::create(map, 0, 0,
70 questmap->get_width(), questmap->get_height());
71 map_image->property_pixbuf() = pixbuf;
72 }
73
74