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

« back to all changes in this revision

Viewing changes to src/gui/report-dialog.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 "image-helpers.h"
28
28
#include "input-helpers.h"
29
29
#include "bar-chart.h"
30
 
#include "../ucompose.hpp"
31
 
#include "../defs.h"
32
 
#include "../File.h"
33
 
#include "../GameMap.h"
34
 
#include "../playerlist.h"
35
 
#include "../citylist.h"
36
 
#include "../stacklist.h"
37
 
#include "../action.h"
38
 
#include "../GraphicsCache.h"
39
 
#include "../armysetlist.h"
 
30
#include "ucompose.hpp"
 
31
#include "defs.h"
 
32
#include "File.h"
 
33
#include "GameMap.h"
 
34
#include "playerlist.h"
 
35
#include "citylist.h"
 
36
#include "stacklist.h"
 
37
#include "action.h"
 
38
#include "GraphicsCache.h"
 
39
#include "armyprodbase.h"
 
40
#include "armysetlist.h"
40
41
 
41
42
ReportDialog::ReportDialog(Player *player, ReportType type)
42
43
{
47
48
  Gtk::Dialog *d = 0;
48
49
  xml->get_widget("dialog", d);
49
50
  dialog.reset(d);
 
51
  decorate(dialog.get());
 
52
  window_closed.connect(sigc::mem_fun(dialog.get(), &Gtk::Dialog::hide));
50
53
 
51
54
  xml->get_widget("map_image", map_image);
52
55
  citymap.reset(new CityMap());
133
136
void ReportDialog::run()
134
137
{
135
138
  citymap->resize();
136
 
  citymap->draw();
 
139
  citymap->draw(Playerlist::getActiveplayer());
137
140
  vectormap->resize();
138
 
  vectormap->draw();
 
141
  vectormap->draw(Playerlist::getActiveplayer());
139
142
  armymap->resize();
140
 
  armymap->draw();
 
143
  armymap->draw(Playerlist::getActiveplayer());
141
144
 
142
145
  dialog->show_all();
143
146
  dialog->run();
189
192
  switch (report_notebook->get_current_page())
190
193
    {
191
194
    case ARMY:
192
 
      dialog->set_title(_("Army Report"));
 
195
      set_title(_("Army Report"));
193
196
      break;
194
197
    case CITY: 
195
 
      dialog->set_title(_("City Report"));
 
198
      set_title(_("City Report"));
196
199
      break;
197
200
    case GOLD: 
198
 
      dialog->set_title(_("Gold Report"));
 
201
      set_title(_("Gold Report"));
199
202
      break;
200
203
    case PRODUCTION:
201
 
      dialog->set_title(_("Production Report"));
 
204
      set_title(_("Production Report"));
202
205
      break;
203
206
    case WINNING:
204
 
      dialog->set_title(_("Winning Report"));
 
207
      set_title(_("Winning Report"));
205
208
      break;
206
209
    }
207
210
}
213
216
  Gdk::Color colour;
214
217
  Glib::ustring s;
215
218
  Uint32 total;
216
 
  Playerlist::iterator pit = Playerlist::getInstance()->begin();
217
 
  for (; pit != Playerlist::getInstance()->end(); ++pit)
 
219
  for (unsigned int i = 0; i < MAX_PLAYERS; i++)
218
220
    {
219
 
      if (*pit == Playerlist::getInstance()->getNeutral())
 
221
      Player *p = Playerlist::getInstance()->getPlayer(i);
 
222
      if (p == NULL)
 
223
        continue;
 
224
      if (p == Playerlist::getInstance()->getNeutral())
220
225
        continue;
221
226
      total = 0;
222
 
      total = (*pit)->getStacklist()->countArmies();
 
227
      total = p->getStacklist()->countArmies();
223
228
      bars.push_back(total);
224
 
      SDL_Color sdl = (*pit)->getColor();
 
229
      SDL_Color sdl = p->getColor();
225
230
      colour.set_red(sdl.r * 255); colour.set_green(sdl.g * 255); colour.set_blue(sdl.b * 255);
226
231
      colours.push_back(colour);
227
 
      if (*pit == d_player)
 
232
      if (p == d_player)
228
233
        {
229
234
          s = String::ucompose(ngettext("You have %1 army!",
230
235
                                        "You have %1 armies!",
235
240
 
236
241
  army_chart = new BarChart(bars, colours, 0);
237
242
  army_alignment->add(*manage(army_chart));
 
243
}
238
244
 
239
 
}
240
245
void ReportDialog::updateCityChart()
241
246
{
242
247
  std::list<Uint32> bars;
244
249
  Gdk::Color colour;
245
250
  Glib::ustring s;
246
251
  Uint32 total;
247
 
  Playerlist::iterator pit = Playerlist::getInstance()->begin();
248
 
  for (; pit != Playerlist::getInstance()->end(); ++pit)
 
252
  for (unsigned int i = 0; i < MAX_PLAYERS; i++)
249
253
    {
250
 
      if (*pit == Playerlist::getInstance()->getNeutral())
251
 
        continue;
252
 
      total = Citylist::getInstance()->countCities(*pit);
 
254
      Player *p = Playerlist::getInstance()->getPlayer(i);
 
255
      if (p == NULL)
 
256
        continue;
 
257
      if (p == Playerlist::getInstance()->getNeutral())
 
258
        continue;
 
259
      total = Citylist::getInstance()->countCities(p);
253
260
 
254
261
      bars.push_back(total);
255
 
      SDL_Color sdl = (*pit)->getColor();
 
262
      SDL_Color sdl = p->getColor();
256
263
      colour.set_red(sdl.r * 255); colour.set_green(sdl.g * 255); colour.set_blue(sdl.b * 255);
257
264
      colours.push_back(colour);
258
 
      if (*pit == d_player)
 
265
      if (p == d_player)
259
266
        {
260
267
          s = String::ucompose(ngettext("You have %1 city!",
261
268
                                        "You have %1 cities!",
276
283
  Glib::ustring s;
277
284
  Uint32 total;
278
285
  bars.clear();
279
 
  Playerlist::iterator pit = Playerlist::getInstance()->begin();
280
 
  for (; pit != Playerlist::getInstance()->end(); ++pit)
 
286
  for (unsigned int i = 0; i < MAX_PLAYERS; i++)
281
287
    {
282
 
      if (*pit == Playerlist::getInstance()->getNeutral())
283
 
        continue;
284
 
      total = (*pit)->getGold();
 
288
      Player *p = Playerlist::getInstance()->getPlayer(i);
 
289
      if (p == NULL)
 
290
        continue;
 
291
      if (p == Playerlist::getInstance()->getNeutral())
 
292
        continue;
 
293
      total = p->getGold();
285
294
      bars.push_back(total);
286
 
      SDL_Color sdl = (*pit)->getColor();
 
295
      SDL_Color sdl = p->getColor();
287
296
      colour.set_red(sdl.r * 255); colour.set_green(sdl.g * 255); colour.set_blue(sdl.b * 255);
288
297
      colours.push_back(colour);
289
 
      if (*pit == d_player)
 
298
      if (p == d_player)
290
299
        {
291
300
          s = String::ucompose(ngettext("You have %1 gold piece!",
292
301
                                        "You have %1 gold pieces!",
322
331
  std::list<Gdk::Color> colours;
323
332
  Gdk::Color colour;
324
333
  Glib::ustring s;
325
 
  Playerlist::iterator pit = Playerlist::getInstance()->begin();
326
334
  Uint32 score;
327
 
  for (; pit != Playerlist::getInstance()->end(); ++pit)
 
335
  for (unsigned int i = 0; i < MAX_PLAYERS; i++)
328
336
    {
329
 
      if (*pit == Playerlist::getInstance()->getNeutral())
330
 
        continue;
331
 
      score = (*pit)->getScore();
 
337
      Player *p = Playerlist::getInstance()->getPlayer(i);
 
338
      if (p == NULL)
 
339
        continue;
 
340
      if (p == Playerlist::getInstance()->getNeutral())
 
341
        continue;
 
342
      score = p->getScore();
332
343
      bars.push_back(score);
333
 
      SDL_Color sdl = (*pit)->getColor();
 
344
      SDL_Color sdl = p->getColor();
334
345
      colour.set_red(sdl.r * 255); colour.set_green(sdl.g * 255); colour.set_blue(sdl.b * 255);
335
346
      colours.push_back(colour);
336
347
    }
352
363
    {
353
364
      const Action_Produce *act;
354
365
      act = dynamic_cast<const Action_Produce*>(action);
355
 
      army_type = act->getArmyType();
 
366
      army_type = act->getArmy()->getTypeId();
356
367
      Citylist::iterator cit = Citylist::getInstance()->begin();
357
368
      for (; cit != Citylist::getInstance()->end(); ++cit)
358
 
        if ((*cit).getId() == act->getCityId())
 
369
        if ((*cit)->getId() == act->getCityId())
359
370
          {
360
 
            s += (*cit).getName();
 
371
            s += (*cit)->getName();
361
372
            break;
362
373
          }
363
374
      if (act->getVectored())
367
378
    {
368
379
      const Action_ProduceVectored *act;
369
380
      act = dynamic_cast<const Action_ProduceVectored*>(action);
370
 
      army_type = act->getArmyType();
 
381
      army_type = act->getArmy()->getTypeId();
371
382
      Vector<int> pos = act->getDestination();
372
383
      City *c = Citylist::getInstance()->getObjectAt(pos);
373
384
      s+="...";
385
396
      s = c->getName();
386
397
      s += " stops production!";
387
398
    }
388
 
  const Army *a;
 
399
  const ArmyProto *a;
389
400
  a = Armysetlist::getInstance()->getArmy(p->getArmyset(), army_type);
390
401
  Gtk::TreeIter i = armies_list->append();
391
402
  (*i)[armies_columns.image] = to_pixbuf(gc->getArmyPic(p->getArmyset(),