~ubuntu-branches/ubuntu/saucy/lordsawar/saucy

« back to all changes in this revision

Viewing changes to src/gui/army-info-tip.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese
  • Date: 2008-12-20 13:52:12 UTC
  • mfrom: (1.1.6 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20081220135212-noeb2w3y98ebo7o9
Tags: 0.1.4-1
[ Barry deFreese ]
* New upstream release.
* Move 0.0.8-2.1 changelog entry to correct point in changelog.
* Make lordsawar-data suggest lordsawar.
* Update my e-mail address.
* Add build-depends on intltool, uuid-dev, and libboost-dev.
* Don't install locales since there are no translations currently.
* Add simple man page for new lordsawar-pbm binary.
* Drop gcc4.3 patches as they have been fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "glade-helpers.h"
28
28
#include "image-helpers.h"
29
29
 
30
 
#include "../ucompose.hpp"
31
 
#include "../vector.h"
32
 
#include "../defs.h"
33
 
#include "../army.h"
34
 
#include "../GraphicsCache.h"
35
 
#include "../playerlist.h"
36
 
 
37
 
 
38
 
ArmyInfoTip::ArmyInfoTip(Gtk::Widget *target, const Army *army, ArmyInfoTipType type)
 
30
#include "ucompose.hpp"
 
31
#include "vector.h"
 
32
#include "defs.h"
 
33
#include "army.h"
 
34
#include "armyprodbase.h"
 
35
#include "armyproto.h"
 
36
#include "GraphicsCache.h"
 
37
#include "playerlist.h"
 
38
 
 
39
 
 
40
ArmyInfoTip::ArmyInfoTip(Gtk::Widget *target, const Army *army)
39
41
{
40
42
    Glib::RefPtr<Gnome::Glade::Xml> xml
41
43
        = Gnome::Glade::Xml::create(get_glade_path()
49
51
    xml->get_widget("army_image", army_image);
50
52
    Player *p;
51
53
    int armyset;
52
 
    if (army->getImageName() != "")
53
 
      {
54
 
        p = Playerlist::getActiveplayer();
55
 
        armyset = p->getArmyset();
56
 
      }
57
 
    else
58
 
      {
59
 
        p = army->getOwner();
60
 
        armyset = army->getArmyset();
61
 
      }
62
 
    GraphicsCache *gc = GraphicsCache::getInstance();
63
 
    army_image->property_pixbuf() = to_pixbuf (gc->getArmyPic(armyset, 
64
 
                                                              army->getType(), 
 
54
    p = army->getOwner();
 
55
    armyset = army->getArmyset();
 
56
    GraphicsCache *gc = GraphicsCache::getInstance();
 
57
    army_image->property_pixbuf() = to_pixbuf (gc->getArmyPic(armyset, 
 
58
                                                              army->getTypeId(), 
 
59
                                                              p, NULL));
 
60
 
 
61
    // fill in terrain image
 
62
    Gtk::Image *terrain_image;
 
63
    xml->get_widget("terrain_image", terrain_image);
 
64
    SDL_Surface *terrain = gc->getMoveBonusPic(army->getMoveBonus(), false);
 
65
    terrain_image->property_pixbuf() = to_pixbuf(terrain);
 
66
    //terrain_image->hide();
 
67
 
 
68
    // fill in info
 
69
    Gtk::Label *info_label;
 
70
    xml->get_widget("info_label", info_label);
 
71
    Glib::ustring s;
 
72
    s += army->getName();
 
73
    s += "\n";
 
74
    // note to translators: %1 is ranged strength
 
75
    s += String::ucompose(_("Strength: %1"),
 
76
                          army->getStat(Army::STRENGTH));
 
77
    s += "\n";
 
78
        
 
79
    // note to translators: %1 is remaining moves, %2 is total moves
 
80
    s += String::ucompose(_("Moves: %1/%2"),
 
81
                          army->getMoves(), army->getStat(Army::MOVES));
 
82
    s += "\n";
 
83
    s += String::ucompose(_("Upkeep: %1"), army->getUpkeep());
 
84
    info_label->set_text(s);
 
85
 
 
86
    // move into correct position
 
87
    window->get_child()->show();
 
88
    Vector<int> pos(0, 0);
 
89
    target->get_window()->get_origin(pos.x, pos.y);
 
90
    if (target->has_no_window())
 
91
      {
 
92
        Gtk::Allocation a = target->get_allocation();
 
93
        pos.x += a.get_x();
 
94
        pos.y += a.get_y();
 
95
      }
 
96
    Vector<int> size(0, 0);
 
97
    window->get_size(size.x, size.y);
 
98
    window->set_gravity(Gdk::GRAVITY_SOUTH);
 
99
    pos.y -= size.y + 2;
 
100
 
 
101
    window->move(pos.x, pos.y);
 
102
    window->show();
 
103
}
 
104
 
 
105
ArmyInfoTip::ArmyInfoTip(Gtk::Widget *target, const ArmyProdBase *army)
 
106
{
 
107
    Glib::RefPtr<Gnome::Glade::Xml> xml
 
108
        = Gnome::Glade::Xml::create(get_glade_path()
 
109
                                    + "/army-info-window.glade");
 
110
 
 
111
    Gtk::Window *w = 0;
 
112
    xml->get_widget("window", w);
 
113
    window.reset(w);
 
114
 
 
115
    Gtk::Image *army_image;
 
116
    xml->get_widget("army_image", army_image);
 
117
    Player *p = Playerlist::getInstance()->getActiveplayer();
 
118
    int armyset;
 
119
    armyset = army->getArmyset();
 
120
    GraphicsCache *gc = GraphicsCache::getInstance();
 
121
    army_image->property_pixbuf() = to_pixbuf (gc->getArmyPic(armyset, 
 
122
                                                              army->getTypeId(), 
 
123
                                                              p, NULL));
 
124
 
 
125
    // fill in terrain image
 
126
    Gtk::Image *terrain_image;
 
127
    xml->get_widget("terrain_image", terrain_image);
 
128
    SDL_Surface *terrain = gc->getMoveBonusPic(army->getMoveBonus(), false);
 
129
    terrain_image->property_pixbuf() = to_pixbuf(terrain);
 
130
    //terrain_image->hide();
 
131
 
 
132
    // fill in info
 
133
    Gtk::Label *info_label;
 
134
    xml->get_widget("info_label", info_label);
 
135
    Glib::ustring s;
 
136
    s += army->getName();
 
137
    s += "\n";
 
138
    // note to translators: %1 is melee strength
 
139
    s += String::ucompose(_("Strength: %1"),
 
140
                          army->getStrength());
 
141
    s += "\n";
 
142
    // note to translators: %1 is total moves
 
143
    s += String::ucompose(_("Moves: %1"), army->getMaxMoves());
 
144
    s += "\n";
 
145
    s += String::ucompose(_("Time: %1"), army->getProduction());
 
146
    s += "\n";
 
147
    s += String::ucompose(_("Cost: %1"), army->getUpkeep());
 
148
    info_label->set_text(s);
 
149
 
 
150
    // move into correct position
 
151
    window->get_child()->show();
 
152
    Vector<int> pos(0, 0);
 
153
    target->get_window()->get_origin(pos.x, pos.y);
 
154
    if (target->has_no_window())
 
155
      {
 
156
        Gtk::Allocation a = target->get_allocation();
 
157
        pos.x += a.get_x();
 
158
        pos.y += a.get_y();
 
159
      }
 
160
    Vector<int> size(0, 0);
 
161
    window->get_size(size.x, size.y);
 
162
    window->set_gravity(Gdk::GRAVITY_SOUTH);
 
163
    pos.y -= size.y + 2;
 
164
 
 
165
    window->move(pos.x, pos.y);
 
166
    window->show();
 
167
}
 
168
 
 
169
ArmyInfoTip::ArmyInfoTip(Gtk::Widget *target, const ArmyProto *army)
 
170
{
 
171
    Glib::RefPtr<Gnome::Glade::Xml> xml
 
172
        = Gnome::Glade::Xml::create(get_glade_path()
 
173
                                    + "/army-info-window.glade");
 
174
 
 
175
    Gtk::Window *w = 0;
 
176
    xml->get_widget("window", w);
 
177
    window.reset(w);
 
178
 
 
179
    Gtk::Image *army_image;
 
180
    xml->get_widget("army_image", army_image);
 
181
    Player *p = Playerlist::getInstance()->getActiveplayer();
 
182
    int armyset;
 
183
    armyset = army->getArmyset();
 
184
    GraphicsCache *gc = GraphicsCache::getInstance();
 
185
    army_image->property_pixbuf() = to_pixbuf (gc->getArmyPic(armyset, 
 
186
                                                              army->getTypeId(), 
65
187
                                                              p, NULL));
66
188
 
67
189
    // fill in terrain image
79
201
    s += "\n";
80
202
    // note to translators: %1 is melee strength, %2 is ranged strength
81
203
    s += String::ucompose(_("Strength: %1"),
82
 
                          army->getStat(Army::STRENGTH));
83
 
    s += "\n";
84
 
    if (type == ARMY_TYPE)
85
 
      {
86
 
        // note to translators: %1 is remaining moves, %2 is total moves
87
 
        s += String::ucompose(_("Movement: %1"), army->getStat(Army::MOVES));
88
 
        s += "\n";
89
 
        s += String::ucompose(_("Time: %1"), army->getProduction());
90
 
        s += "\n";
91
 
        s += String::ucompose(_("Cost: %1"), army->getUpkeep());
92
 
      }
93
 
    else if (type == ARMY_INSTANCE)
94
 
      {
95
 
        // note to translators: %1 is remaining moves, %2 is total moves
96
 
        s += String::ucompose(_("Moves: %1/%2"),
97
 
                              army->getMoves(), army->getStat(Army::MOVES));
98
 
        s += "\n";
99
 
        s += String::ucompose(_("Upkeep: %1"), army->getUpkeep());
100
 
      }
 
204
                          army->getStrength());
 
205
    s += "\n";
 
206
    // note to translators: %1 is remaining moves, %2 is total moves
 
207
    s += String::ucompose(_("Movement: %1"), army->getMaxMoves());
 
208
    s += "\n";
 
209
    s += String::ucompose(_("Time: %1"), army->getProduction());
 
210
    s += "\n";
 
211
    s += String::ucompose(_("Cost: %1"), army->getUpkeep());
101
212
    info_label->set_text(s);
102
213
 
103
214
    // move into correct position