]> ruin.nu Git - hbs.git/commitdiff
Roids/score for planets are now editable
authorMichael Andreen <harv@ruin.nu>
Sun, 7 Apr 2002 00:26:10 +0000 (00:26 +0000)
committerMichael Andreen <harv@ruin.nu>
Sun, 7 Apr 2002 00:26:10 +0000 (00:26 +0000)
bs/fleetview.cpp
bs/fleetview.h
bs/planet.cpp
bs/ui/roidseditview.ui
bs/ui/roidseditview.ui.h

index d40cfc53018bff1c4205e202e24b486e04a9d03b..b16c70fc309d660243241983e78b63d157369739 100644 (file)
@@ -55,7 +55,7 @@ FleetView::FleetView(const Fleet* fleet, bool friendly, QWidget *parent, const c
        m_UnitsLayout = new QGridLayout(m_MainLayout, rows, 6);
        buildUnitTable();
        //QSpacerItem* space = new QSpacerItem(1, 1);
        m_UnitsLayout = new QGridLayout(m_MainLayout, rows, 6);
        buildUnitTable();
        //QSpacerItem* space = new QSpacerItem(1, 1);
-       fillTable();
+       
 
        m_MainLayout->addStretch(10);
 
 
        m_MainLayout->addStretch(10);
 
@@ -63,10 +63,11 @@ FleetView::FleetView(const Fleet* fleet, bool friendly, QWidget *parent, const c
        {
                m_RoidsEditView = new RoidsEditView(this);
                m_MainLayout->addWidget(m_RoidsEditView);
        {
                m_RoidsEditView = new RoidsEditView(this);
                m_MainLayout->addWidget(m_RoidsEditView);
+               connect(m_RoidsEditView, SIGNAL(changed(const QString&, int)), SLOT(slotRoidsChanged(const QString&, int)));
        }
        m_ResourceView = new ResourceView(this);
        m_MainLayout->addWidget(m_ResourceView);
        }
        m_ResourceView = new ResourceView(this);
        m_MainLayout->addWidget(m_ResourceView);
-
+  fillTable();
 }
 
 FleetView::~FleetView(){
 }
 
 FleetView::~FleetView(){
@@ -189,6 +190,31 @@ void FleetView::fillTable()
        {
                m_UnitsEdit[(*i)]->setText(QString("%1").arg(m_Fleet->fleet(i->latin1(), 0)));
        }
        {
                m_UnitsEdit[(*i)]->setText(QString("%1").arg(m_Fleet->fleet(i->latin1(), 0)));
        }
+       Planet* pl;
+       if ((pl = dynamic_cast<Planet*>(m_Fleet)) && m_bHome)
+       {
+               m_RoidsEditView->setValue(tr("score"),pl->planetScore());
+               m_RoidsEditView->setValue(tr("metal"),pl->roids(tr("metal").latin1()));
+               m_RoidsEditView->setValue(tr("crystal"),pl->roids(tr("crystal").latin1()));
+               m_RoidsEditView->setValue(tr("eonium"),pl->roids(tr("eonium").latin1()));
+               m_RoidsEditView->setValue(tr("uninit"),pl->roids(tr("uninit").latin1()));
+       }
+}
+
+/////////////////////////////////////////////////////////////////////
+//
+void FleetView::slotRoidsChanged(const QString& type, int value)
+{
+       Planet* pl;
+       if ((pl = dynamic_cast<Planet*>(m_Fleet)))
+       {
+               if (type == tr("score"))
+                       pl->setPlanetScore(value);
+               else
+               {
+                       pl->setRoids(type.latin1(), value);
+               }
+               emit fleetChanged(pl);
+       }
 }
 
 }
 
-       
index a2bbaaf68ccaec6cc5fac3aa296be54f443ef3b1..adf543337ca9f1c7643ac17d5e1f46744964729a 100644 (file)
@@ -55,6 +55,7 @@ signals:
 
 protected slots:
        void unitsChanged(const QString& number);
 
 protected slots:
        void unitsChanged(const QString& number);
+       void slotRoidsChanged(const QString& type, int value);
 
 protected:
        void findNames();
 
 protected:
        void findNames();
index e0cf514e0c45d7b6054afbaae1c3b3ebc99342a9..c72fb4e61c39e5b9450cac19f3c97a82ac2b723f 100644 (file)
@@ -48,7 +48,7 @@ int Planet::roids(std::string type, int tick = 0) const
 {
        // const... I would like [] as for const types: int ticks = m_Roids[type].size();
        
 {
        // const... I would like [] as for const types: int ticks = m_Roids[type].size();
        
-       vector<int>const* roids;
+       vector<int>const* roids = 0;
        for (RoidList::const_iterator i = m_Roids.begin(); i != m_Roids.end(); ++i)
        {
                if (i->first == type)
        for (RoidList::const_iterator i = m_Roids.begin(); i != m_Roids.end(); ++i)
        {
                if (i->first == type)
@@ -57,6 +57,8 @@ int Planet::roids(std::string type, int tick = 0) const
                        break;
                }
        }
                        break;
                }
        }
+       if (roids == 0)
+               return 0;
 
        int ticks = roids->size();
 
 
        int ticks = roids->size();
 
index 1df54f159524d50c0a8c8fb88c887158a08f2a03..e64e2a562a131e26bf7b493bbbf03d9e4c827fb4 100644 (file)
 </signals>
 <slots>
     <slot>init()</slot>
 </signals>
 <slots>
     <slot>init()</slot>
-    <slot>setValue( const QString &amp; s, unsigned value )</slot>
+    <slot>setValue( const QString &amp; type, unsigned value )</slot>
     <slot access="protected">slotValueChanged( const QString &amp; s )</slot>
 </slots>
 <pixmapinproject/>
     <slot access="protected">slotValueChanged( const QString &amp; s )</slot>
 </slots>
 <pixmapinproject/>
index d5d8b3b83c7b75e22b7e5f50f69cb6930aae4a58..225af827f0d4c8def97187889fb77c6b49f160f1 100644 (file)
@@ -11,36 +11,36 @@ void RoidsEditView::init()
 
 }
 
 
 }
 
-void RoidsEditView::setValue( const QString & s, unsigned value )
+void RoidsEditView::setValue( const QString & type, unsigned value )
 {
     if (type == tr("metal"))
 {
     if (type == tr("metal"))
-       MetalEdit->setText("%1").arg(value);
-    else if (type == tr("crystall"))
-       CrystalEdit->setText("%1").arg(value);
-    else if (type == tr("eoniuml"))
-       EoniumEdit->setText("%1").arg(value);
+       MetalEdit->setText(QString("%1").arg(value));
+    else if (type == tr("crystal"))
+       CrystalEdit->setText(QString("%1").arg(value));
+    else if (type == tr("eonium"))
+       EoniumEdit->setText(QString("%1").arg(value));
     else if (type == tr("uninit"))
     else if (type == tr("uninit"))
-       UninitEdit->setText("%1").arg(value);
+       UninitEdit->setText(QString("%1").arg(value));
     else if (type == tr("score"))
     else if (type == tr("score"))
-       ScoreEdit->setText("%1").arg(value);
+       ScoreEdit->setText(QString("%1").arg(value));
     
 
 }
 
 void RoidsEditView::slotValueChanged( const QString & s )
 {
     
 
 }
 
 void RoidsEditView::slotValueChanged( const QString & s )
 {
-    QString type = send()->name();
+       QString type = sender()->name();
     
     
-    if (type == "MetalEdit")
-       type = tr("metal");
-    else if (type == "CrystalEdit")
-       type = tr("crystal");
-    else if (type == "EoniumEdit")
-       type = tr("eonium");
-    else if (type == "UninitEdit")
-       type = tr("uninit");
-    else if (type == "ScoreEdit")
-       type = tr("score");
+       if (type == "MetalEdit")
+               type = tr("metal");
+       else if (type == "CrystalEdit")
+               type = tr("crystal");
+       else if (type == "EoniumEdit")
+               type = tr("eonium");
+       else if (type == "UninitEdit")
+               type = tr("uninit");
+  else if (type == "ScoreEdit")
+               type = tr("score");
     
     emit changed(type, s.toInt());
 }
\ No newline at end of file
     
     emit changed(type, s.toInt());
 }
\ No newline at end of file