~ubuntu-branches/ubuntu/raring/lordsawar/raring

« back to all changes in this revision

Viewing changes to src/gui/city-window.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese, Gonéri Le Bouder
  • Date: 2008-06-17 11:15:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080617111526-yjyvu9df50zmpdo0
Tags: 0.0.9-1
[ Barry deFreese ]
* New upstream release.
  + Fixes gcc-4.3 builds so drop ftbfs_gcc-4.3_fix.diff.
  + Add new build-dependency for libgnet-dev.
* Add simple man page for new lordsawar-tile-editor.
* Add desktop file for lordsawar-tile-editor.
* Remove French translation on install.

[ Gonéri Le Bouder ]
* bump Debian Policy to 3.8.0. No change needed.
* fix wording in the 0.0.8-3 entry of the Debian changelog

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  Copyright (C) 2007, Ole Laursen
 
2
//  Copyright (C) 2007, 2008 Ben Asselstine
 
3
//
1
4
//  This program is free software; you can redistribute it and/or modify
2
5
//  it under the terms of the GNU General Public License as published by
3
6
//  the Free Software Foundation; either version 2 of the License, or
10
13
//
11
14
//  You should have received a copy of the GNU General Public License
12
15
//  along with this program; if not, write to the Free Software
13
 
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*
 
16
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
 
17
//  02110-1301, USA.
14
18
 
15
19
#include <config.h>
16
20
 
86
90
    raze_button->signal_clicked().connect(
87
91
        sigc::mem_fun(this, &CityWindow::on_raze_clicked));
88
92
 
89
 
    for (int i = 1; i <= city->getMaxNoOfBasicProd(); ++i) {
 
93
    for (int i = 1; i <= city->getMaxNoOfProductionBases(); ++i) {
90
94
        Gtk::ToggleButton *toggle;
91
95
        xml->get_widget(String::ucompose("production_toggle%1", i), toggle);
92
96
        production_toggles.push_back(toggle);
161
165
 
162
166
void CityWindow::fill_in_production_toggles()
163
167
{
164
 
    Player *player = city->getPlayer();
 
168
    Player *player = city->getOwner();
165
169
    unsigned int as = player->getArmyset();
166
 
    int production_index = city->getProductionIndex();
 
170
    int production_index = city->getActiveProductionSlot();
167
171
    int type;
168
172
    Glib::RefPtr<Gdk::Pixbuf> pic;
169
173
    GraphicsCache *gc = GraphicsCache::getInstance();
175
179
    empty_pic->fill(0x00000000);
176
180
    
177
181
    ignore_toggles = true;
178
 
    for (int i = 0; i < city->getMaxNoOfBasicProd(); i++)
 
182
    for (int i = 0; i < city->getMaxNoOfProductionBases(); i++)
179
183
    {
180
184
        Gtk::ToggleButton *toggle = production_toggles[i];
181
185
        toggle->foreach(sigc::mem_fun(toggle, &Gtk::Container::remove));
202
206
 
203
207
void CityWindow::on_production_toggled(Gtk::ToggleButton *toggle)
204
208
{
205
 
    if (city->getPlayer() != Playerlist::getActiveplayer())
 
209
    if (city->getOwner() != Playerlist::getActiveplayer())
206
210
    {
207
211
        toggle->set_active(false);
208
212
        return;
223
227
    bool is_empty = city->getArmytype(slot) == -1;
224
228
    
225
229
    if (is_empty)
226
 
        city->getPlayer()->cityChangeProduction(city, -1);
 
230
        city->getOwner()->cityChangeProduction(city, -1);
227
231
    else
228
 
        city->getPlayer()->cityChangeProduction(city, slot);
 
232
        city->getOwner()->cityChangeProduction(city, slot);
229
233
 
230
234
    on_hold_button->set_sensitive(!is_empty);
231
235
    
234
238
 
235
239
void CityWindow::fill_in_production_info()
236
240
{
237
 
    Player *player = city->getPlayer();
 
241
    Player *player = city->getOwner();
238
242
    unsigned int as = player->getArmyset();
239
243
    Glib::RefPtr<Gdk::Pixbuf> pic;
240
244
    GraphicsCache *gc = GraphicsCache::getInstance();
241
 
    int slot = city->getProductionIndex();
 
245
    int slot = city->getActiveProductionSlot();
242
246
    SDL_Surface *s
243
247
        = GraphicsCache::getInstance()->getArmyPic(as, 0, player, NULL);
244
248
    Glib::RefPtr<Gdk::Pixbuf> empty_pic
260
264
    }
261
265
    else
262
266
    {
263
 
        const Army* a = city->getArmy(slot);
 
267
        const Army* a = city->getProductionBase(slot);
264
268
 
265
269
        // fill in first column
266
270
        s1 += a->getName();
295
299
    turns_left_label->set_markup("<i>" + s3 + "</i>");
296
300
    current_label->set_markup("<i>" + s4 + "</i>");
297
301
 
298
 
    if (city->getPlayer () != Playerlist::getActiveplayer())
 
302
    if (city->getOwner () != Playerlist::getActiveplayer())
299
303
      {
300
304
        turns_left_label->hide();
301
305
        current_label->hide();
342
346
        }
343
347
        assert(slot != -1);
344
348
 
345
 
        const Army *army = city->getArmy(slot);
 
349
        const Army *army = city->getProductionBase(slot);
346
350
 
347
351
        if (army)
348
352
            army_info_tip.reset(new ArmyInfoTip(toggle, army));
360
364
void CityWindow::on_on_hold_clicked() //stop button
361
365
{
362
366
    city->setVectoring(Vector<int>(-1,-1));
363
 
    city->getPlayer()->cityChangeProduction(city, -1);
 
367
    city->getOwner()->cityChangeProduction(city, -1);
364
368
    on_hold_button->set_sensitive(false);
365
369
    ignore_toggles = true;
366
370
    for (unsigned int i = 0; i < production_toggles.size(); ++i)
385
389
        if  (slot == -1)
386
390
          {
387
391
            //no free slots available.  change the one we're on.
388
 
            slot = city->getProductionIndex();
 
392
            slot = city->getActiveProductionSlot();
389
393
            if (slot == -1) 
390
394
              slot = 0;
391
395
          }
392
 
        city->getPlayer()->cityBuyProduction(city, slot, army);
393
 
        city->getPlayer()->cityChangeProduction(city, slot);
 
396
        city->getOwner()->cityBuyProduction(city, slot, army);
 
397
        city->getOwner()->cityChangeProduction(city, slot);
394
398
 
395
399
        fill_in_production_toggles();
396
400
        fill_in_production_info();