From 236fcf8db0fa64f8acd0a1eb81aa3ce5f2bfb3e8 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 6 Apr 2002 22:27:34 +0000 Subject: [PATCH] some changes --- bs/planet.cpp | 27 +++++++++++++++++++++------ bs/planet.h | 2 +- bs/ui/roidseditview.ui | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/bs/planet.cpp b/bs/planet.cpp index 4fa6978..e0cf514 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -17,6 +17,8 @@ #include "planet.h" +using namespace std; + Planet::Planet() { m_sRace = "Planet"; @@ -42,22 +44,35 @@ void Planet::setPlanetScore(unsigned i) ////////////////////////////////////////////////////////////////////////// // -int roids(std::string type, int tick = 0) const +int Planet::roids(std::string type, int tick = 0) const { - ticks = m_Roids[type].size(); + // const... I would like [] as for const types: int ticks = m_Roids[type].size(); + + vectorconst* roids; + for (RoidList::const_iterator i = m_Roids.begin(); i != m_Roids.end(); ++i) + { + if (i->first == type) + { + roids = &i->second; + break; + } + } + + int ticks = roids->size(); + if( ticks == 0) return 0; if (ticks < tick) - return m_Roids[type][ticks]; - return m_Roids[type][tick]; + return roids->at(ticks); + return roids->at(tick); } ////////////////////////////////////////////////////////////////////////// // -void setRoids(std::string type, int number) +void Planet::setRoids(std::string type, int number) { if (m_Roids[type].size() == 0) - m_Roids.push_back(number); + m_Roids[type].push_back(number); m_Roids[type][0] = number; } diff --git a/bs/planet.h b/bs/planet.h index 5e2b13a..1fd9109 100644 --- a/bs/planet.h +++ b/bs/planet.h @@ -20,7 +20,7 @@ #include "fleet.h" -typedef std::map RoidList; +typedef std::map > RoidList; /**This class is the implementation of a planet. * diff --git a/bs/ui/roidseditview.ui b/bs/ui/roidseditview.ui index cc48579..1df54f1 100644 --- a/bs/ui/roidseditview.ui +++ b/bs/ui/roidseditview.ui @@ -165,6 +165,38 @@ + + + MetalEdit + textChanged(const QString&) + RoidsEditView + slotValueChanged(const QString&) + + + CrystalEdit + textChanged(const QString&) + RoidsEditView + slotValueChanged(const QString&) + + + EoniumEdit + textChanged(const QString&) + RoidsEditView + slotValueChanged(const QString&) + + + UninitEdit + textChanged(const QString&) + RoidsEditView + slotValueChanged(const QString&) + + + ScoreEdit + textChanged(const QString&) + RoidsEditView + slotValueChanged(const QString&) + + MetalEdit CrystalEdit @@ -177,6 +209,11 @@ changed(const QString&, int) + + init() + setValue( const QString & s, unsigned value ) + slotValueChanged( const QString & s ) + -- 2.39.2