1
// This program is free software; you can redistribute it and/or modify
2
// it under the terms of the GNU General Public License as published by
3
// the Free Software Foundation; either version 2 of the License, or
4
// (at your option) any later version.
6
// This program is distributed in the hope that it will be useful,
7
// but WITHOUT ANY WARRANTY; without even the implied warranty of
8
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
// GNU Library General Public License for more details.
11
// You should have received a copy of the GNU General Public License
12
// along with this program; if not, write to the Free Software
13
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*
17
#include <libglademm/xml.h>
18
#include <sigc++/functors/mem_fun.h>
19
#include <gtkmm/label.h>
20
#include <gtkmm/scrolledwindow.h>
21
#include <gtkmm/notebook.h>
22
#include <gtkmm/image.h>
24
#include "triumphs-dialog.h"
26
#include "glade-helpers.h"
27
#include "image-helpers.h"
28
#include "input-helpers.h"
29
#include "../ucompose.hpp"
32
#include "../GameMap.h"
33
#include "../GraphicsCache.h"
34
#include "../armysetlist.h"
35
#include "../playerlist.h"
36
#include "../player.h"
38
TriumphsDialog::TriumphsDialog(Player *player)
41
Glib::RefPtr<Gnome::Glade::Xml> xml
42
= Gnome::Glade::Xml::create(get_glade_path() + "/triumphs-dialog.glade");
45
xml->get_widget("dialog", d);
49
xml->get_widget("outer_hbox", contents);
50
notebook = Gtk::manage(new Gtk::Notebook());
51
contents->pack_start(*notebook, true, true, 0);
53
//set the notebook to start off on the player's own page
54
notebook->set_current_page(d_player->getId());
57
void TriumphsDialog::set_parent_window(Gtk::Window &parent)
59
dialog->set_transient_for(parent);
60
//dialog->set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
63
void TriumphsDialog::run()
69
Uint32 TriumphsDialog::tally(Player *p, Player::TriumphType type)
74
// add up what the other players did to us
75
for (unsigned int i = 0; i < MAX_PLAYERS; i++)
77
count += p->getTriumphTally(Playerlist::getInstance()->getPlayer(i),
83
// add up what we did to that player
84
count = d_player->getTriumphTally(p, type);
89
void TriumphsDialog::fill_in_page(Player *p)
91
GraphicsCache *gc = GraphicsCache::getInstance();
92
//here we tally up the stats, make a vbox and append it as a new page
93
//tally it up differently when p == d_player
97
count = tally(p, Player::TALLY_HERO);
99
s = String::ucompose (ngettext("%1 hero earned fates worthy of legend!",
100
"%1 heroes earned fates worthy of legend!",
103
s = String::ucompose (ngettext
104
("%1 so-called hero slaughtered without mercy!",
105
"%1 so-called heroes slaughtered without mercy!",
107
Gtk::Label *hero_label = new Gtk::Label(s);
109
const Army *hero = NULL;
110
const Armysetlist* al = Armysetlist::getInstance();
111
//let's go find the hero army
112
for (unsigned int j = 0; j < al->getSize(p->getArmyset()); j++)
114
const Army *a = al->getArmy (p->getArmyset(), j);
121
Gtk::Image *hero_image = new Gtk::Image
122
(to_pixbuf(gc->getArmyPic(p->getArmyset(), hero->getType(), p, NULL)));
123
Gtk::HBox *hero_hbox = new Gtk::HBox();
124
hero_hbox->pack_start(*manage(hero_image), Gtk::PACK_SHRINK, 10);
125
hero_hbox->pack_start(*manage(hero_label), Gtk::PACK_SHRINK, 10);
127
count = tally(p, Player::TALLY_SHIP);
129
s = String::ucompose (ngettext("%1 navy not currently in service!",
130
"%1 navies not currently in service!",
133
s = String::ucompose (ngettext("%1 navy rests with the fishes!",
134
"%1 navies rest with the fishes!",
136
Gtk::Label *ship_label = new Gtk::Label(s);
137
Gtk::Image *ship_image = new Gtk::Image (to_pixbuf(gc->getShipPic(p)));
138
Gtk::HBox *ship_hbox = new Gtk::HBox();
139
ship_hbox->pack_start(*manage(ship_image), Gtk::PACK_SHRINK, 10);
140
ship_hbox->pack_start(*manage(ship_label), Gtk::PACK_SHRINK, 10);
142
count = tally(p, Player::TALLY_NORMAL);
144
s = String::ucompose (ngettext("%1 army died to ensure final victory!",
145
"%1 armies died to ensure final victory!",
148
s = String::ucompose (ngettext("%1 army smote like sheep!",
149
"%1 armies smote like sheep!",
151
Gtk::Label *normal_label = new Gtk::Label(s);
152
Gtk::Image *normal_image = new Gtk::Image
153
(to_pixbuf(gc->getArmyPic(p->getArmyset(), 0, p, NULL)));
154
Gtk::HBox *normal_hbox = new Gtk::HBox();
155
normal_hbox->pack_start(*manage(normal_image), Gtk::PACK_SHRINK, 10);
156
normal_hbox->pack_start(*manage(normal_label), Gtk::PACK_SHRINK, 10);
158
count = tally(p, Player::TALLY_SPECIAL);
161
(ngettext ("%1 unnatural creature returned from whence it came!",
162
"%1 unnatural creatures returned from whence they came!",
165
s = String::ucompose (ngettext ("%1 unnatural creature dispatched!",
166
"%1 unnatural creatures dispatched!",
168
Gtk::Label *special_label = new Gtk::Label(s);
169
//let's go find a special army
170
const Army *special = NULL;
171
for (unsigned int j = 0; j < al->getSize(p->getArmyset()); j++)
173
const Army *a = al->getArmy (p->getArmyset(), j);
174
if (a->getAwardable())
180
Gtk::Image *special_image = new Gtk::Image
181
(to_pixbuf(gc->getArmyPic(p->getArmyset(),
182
special->getType(), p, NULL)));
183
Gtk::HBox *special_hbox = new Gtk::HBox();
184
special_hbox->pack_start(*manage(special_image), Gtk::PACK_SHRINK, 10);
185
special_hbox->pack_start(*manage(special_label), Gtk::PACK_SHRINK, 10);
187
count = tally(p, Player::TALLY_FLAG);
189
s = String::ucompose (ngettext ("%1 standard betrayed by it's guardian!",
190
"%1 standards betrayed by it's guardian!",
193
s = String::ucompose (ngettext
194
("%1 standard wrested from a vanquished foe!",
195
"%1 standards wrested from a vanquished foe!",
197
Gtk::Label *flag_label = new Gtk::Label(s);
198
Gtk::Image *flag_image = new Gtk::Image
199
(to_pixbuf(gc->getPlantedStandardPic(p)));
200
Gtk::HBox *flag_hbox = new Gtk::HBox();
201
flag_hbox->pack_start(*manage(flag_image), Gtk::PACK_SHRINK, 10);
202
flag_hbox->pack_start(*manage(flag_label), Gtk::PACK_SHRINK, 10);
204
Gtk::VBox *contents = new Gtk::VBox();
205
contents->add(*manage(normal_hbox));
206
contents->add(*manage(special_hbox));
207
contents->add(*manage(hero_hbox));
208
contents->add(*manage(ship_hbox));
209
contents->add(*manage(flag_hbox));
210
notebook->append_page
212
*manage(new Gtk::Image(to_pixbuf(gc->getShieldPic(2, p)))));
215
void TriumphsDialog::fill_in_info()
217
Playerlist::iterator pit = Playerlist::getInstance()->begin();
218
for (; pit != Playerlist::getInstance()->end(); ++pit)
220
if (*pit == Playerlist::getInstance()->getNeutral())