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

« back to all changes in this revision

Viewing changes to src/Itemlist.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) 2004, 2005 Ulf Lorenz
 
2
// Copyright (C) 2007, 2008 Ben Asselstine
 
3
//
 
4
//  This program is free software; you can redistribute it and/or modify
1
5
//  it under the terms of the GNU General Public License as published by
2
6
//  the Free Software Foundation; either version 2 of the License, or
3
7
//  (at your option) any later version.
9
13
//
10
14
//  You should have received a copy of the GNU General Public License
11
15
//  along with this program; if not, write to the Free Software
12
 
//  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.
13
18
 
14
19
#include <sigc++/functors/mem_fun.h>
15
20
 
22
27
 
23
28
Itemlist* Itemlist::getInstance()
24
29
{
25
 
    return d_instance;
26
 
}
27
 
 
28
 
void Itemlist::createInstance()
 
30
    if (!d_instance)
 
31
        d_instance = new Itemlist();
 
32
 
 
33
    return d_instance;
 
34
}
 
35
 
 
36
Itemlist* Itemlist::getInstance(XML_Helper *helper)
 
37
{
 
38
    if (!d_instance)
 
39
        d_instance = new Itemlist();
 
40
 
 
41
    d_instance = new Itemlist(helper);
 
42
    return d_instance;
 
43
}
 
44
 
 
45
void Itemlist::createStandardInstance()
29
46
{
30
47
    deleteInstance();
31
48
 
54
71
    helper->registerTag("item", sigc::mem_fun(*this, &Itemlist::loadItem));
55
72
}
56
73
 
 
74
Itemlist::Itemlist()
 
75
{
 
76
}
 
77
 
57
78
Itemlist::~Itemlist()
58
79
{
59
 
    fl_clear();
 
80
    flClear();
60
81
}
61
82
 
62
83
bool Itemlist::loadItem(std::string tag, XML_Helper* helper)
70
91
    return true;
71
92
}
72
93
 
73
 
void Itemlist::fl_erase(iterator it)
 
94
void Itemlist::flErase(iterator it)
74
95
{
75
96
    delete (*it).second;
76
97
    erase(it);
77
98
}
78
99
 
79
 
void Itemlist::fl_clear()
 
100
void Itemlist::flClear()
80
101
{
81
102
    while (!empty())
82
 
        fl_erase(begin());
 
103
        flErase(begin());
 
104
}
 
105
 
 
106
bool Itemlist::save(XML_Helper* helper) const
 
107
{
 
108
    bool retval = true;
 
109
 
 
110
    retval &= helper->openTag("itemlist");
 
111
 
 
112
    for (const_iterator it = begin(); it != end(); it++)
 
113
      (*it).second->save(helper);
 
114
    
 
115
    retval &= helper->closeTag();
 
116
 
 
117
    return retval;
 
118
}
 
119
 
 
120
void Itemlist::remove(Item *item)
 
121
{
 
122
  Uint32 index = 0;
 
123
  for (iterator it = begin(); it != end(); it++)
 
124
    {
 
125
      if ((*it).second == item)
 
126
        {
 
127
          erase(index);
 
128
          break;
 
129
        }
 
130
      index++;
 
131
    }
83
132
}