]> ruin.nu Git - hbs.git/commitdiff
adding, removing and chaning fleets now works.
authorMichael Andreen <harv@ruin.nu>
Sun, 7 Apr 2002 23:02:48 +0000 (23:02 +0000)
committerMichael Andreen <harv@ruin.nu>
Sun, 7 Apr 2002 23:02:48 +0000 (23:02 +0000)
Started the the actual simulation work now.

bs/bsdoc.cpp
bs/bsdoc.h
bs/bsview.cpp
bs/bsview.h
bs/planet.cpp
bs/planet.h
bs/ui/bsappbase.ui
bs/ui/bsappbase.ui.h
bs/ui/infoview.ui

index 70cfd899ba4459461f10ea3cc9e3ed7ebea0f420..d7e04ce336f0e3253c04af305ae94952b0942d1b 100644 (file)
@@ -133,3 +133,19 @@ void BSDoc::newFleet(QString battle, QString group, QString fleet, Fleet* fl)
        emit documentChanged();
 }
 
        emit documentChanged();
 }
 
+//////////////////////////////////////////////////////////////////////////
+//
+void BSDoc::removeFleet(QString battle, QString group, QString fleet)
+{
+       delete m_Battles[battle][group][fleet];
+       m_Battles[battle][group].erase(fleet);
+       emit documentChanged();
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+void BSDoc::runBattleSimulation()
+{
+
+       emit documentChanged();
+}
index 6d6375aff7ef4b20491d899234751fe2df110a50..bcfcfd08e450123c32a0aa6322d0280f3e06698a 100644 (file)
@@ -73,6 +73,9 @@ class BSDoc : public QObject
 
        void newFleet(QString battle, QString group, QString fleet, Fleet* fl);
 
 
        void newFleet(QString battle, QString group, QString fleet, Fleet* fl);
 
+       void removeFleet(QString battle, QString group, QString fleet);
+
+       void runBattleSimulation();
   signals:
     void documentChanged();
 
   signals:
     void documentChanged();
 
index f5e74bc82324a8f93440976d6b9bddad7cc388b9..c050952c291c942b45b733f80af97bb1ab70f297 100644 (file)
@@ -35,10 +35,13 @@ using namespace std;
 #include "tickview.h"
 #include "fleetview.h"
 #include "fleet.h"
 #include "tickview.h"
 #include "fleetview.h"
 #include "fleet.h"
+#include "planet.h"
 
 BSView::BSView(QWidget *parent, BSDoc *doc) : QSplitter(parent)
 {
   /** connect doc with the view*/
 
 BSView::BSView(QWidget *parent, BSDoc *doc) : QSplitter(parent)
 {
   /** connect doc with the view*/
+       
+       m_bMoreDocChanges = false;
        connect(doc, SIGNAL(documentChanged()), this, SLOT(slotDocumentChanged()));
        
        m_doc = doc;
        connect(doc, SIGNAL(documentChanged()), this, SLOT(slotDocumentChanged()));
        
        m_doc = doc;
@@ -120,6 +123,9 @@ void BSView::addBattle(QString name)
  */
 void BSView::slotDocumentChanged()
 {
  */
 void BSView::slotDocumentChanged()
 {
+       if (m_bMoreDocChanges)
+               return;
+
        m_NumberView->clear();
        
        const BattleList& battles = m_doc->battles();   
        m_NumberView->clear();
        
        const BattleList& battles = m_doc->battles();   
@@ -235,6 +241,38 @@ void BSView::slotFleetChanged(const Fleet* fleet)
 //
 void BSView::slotInfoApply()
 {
 //
 void BSView::slotInfoApply()
 {
+       QString battle = m_InfoView->battle();
+       QString group  = m_InfoView->group();
+       QString fleet  = m_InfoView->fleetName();
+
+
+       
+       const Fleet* old = m_doc->specificFleet(m_sBattle, m_sGroup, m_sFleet);
+
+       const Planet* oldpl = dynamic_cast<const Planet*>(old);
+
+       Fleet* fl;
+       if(oldpl)
+               fl = new Planet(*oldpl);
+       else
+               fl = new Fleet(*old);
+
+       
+               
+       m_bMoreDocChanges = true;
+       m_doc->removeFleet(m_sBattle, m_sGroup, m_sFleet);
+       m_bMoreDocChanges = false;
+
+       m_sBattle = battle;
+       m_sGroup = group;
+       m_sFleet = fleet;
+
+
+       fl->setETA(m_InfoView->eta());
+       fl->setName(m_sFleet.latin1());
+       fl->setRace(m_InfoView->race().latin1());
+       
+       m_doc->newFleet(m_sBattle, m_sGroup, m_sFleet, fl);
 }
 
 //////////////////////////////////////////////////////////////////////////
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -248,11 +286,26 @@ void BSView::slotInfoCancel()
 //
 void BSView::slotInfoNew()
 {
 //
 void BSView::slotInfoNew()
 {
+
+       QString battle = m_InfoView->battle();
+       QString group  = m_InfoView->group();
+       QString fleet  = m_InfoView->fleetName();
+
+       const Fleet* fl1 = m_doc->specificFleet(battle, group, fleet);
+       if (fl1)
+       {
+               //fleet does already exist, do not overwrite.
+               //Need something else here....
+               return;
+       }
+
+       
+       
        Fleet* fl = new Fleet();
 
        Fleet* fl = new Fleet();
 
-       m_sBattle = m_InfoView->battle();
-       m_sGroup = m_InfoView->group();
-       m_sFleet = m_InfoView->fleetName();
+       m_sBattle = battle;
+       m_sGroup = group;
+       m_sFleet = fleet;
 
        fl->setETA(m_InfoView->eta());
        fl->setName(m_sFleet.latin1());
 
        fl->setETA(m_InfoView->eta());
        fl->setName(m_sFleet.latin1());
@@ -266,6 +319,8 @@ void BSView::slotInfoNew()
 //
 void BSView::slotInfoRemove()
 {
 //
 void BSView::slotInfoRemove()
 {
+       m_doc->removeFleet(m_sBattle, m_sGroup, m_sFleet);
+       m_sFleet = "";
 }
 
 //////////////////////////////////////////////////////////////////////////
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -276,26 +331,27 @@ void BSView::updateInfoView()
 
        if(!fl)
        {
 
        if(!fl)
        {
-               m_InfoView->setRace("");
                m_InfoView->setFleetName("");
                m_InfoView->setEta(0);
                m_InfoView->setFleetName("");
                m_InfoView->setEta(0);
-               m_InfoView->setGroup("");
-               m_InfoView->setBattle("");              
                m_InfoView->enableNameChange(true);
                m_InfoView->enableRemove(false);
                return;
        }
                m_InfoView->enableNameChange(true);
                m_InfoView->enableRemove(false);
                return;
        }
+       m_InfoView->setGroup(m_sGroup);
+       m_InfoView->setBattle(m_sBattle);
 
 
-       if(m_sFleet == tr("Home Planet"))
+/*     NO LONGER NEEDED SINCE IT'S INTEGRATED IN THE InfoView CLASS
+ *     if(m_sFleet == tr("Home Planet") && m_sGroup == tr("Friendly"))
        {
        {
-               m_InfoView->enableNameChange(false);
-               m_InfoView->enableRemove(false);
+               //m_InfoView->enableNameChange(false);
+               //m_InfoView->enableRemove(false);
        }
        else
        {
                m_InfoView->enableNameChange(true);
                m_InfoView->enableRemove(true);
        }
        }
        else
        {
                m_InfoView->enableNameChange(true);
                m_InfoView->enableRemove(true);
        }
+*/
 
        m_InfoView->setRace(fl->race().c_str());
        m_InfoView->setFleetName(m_sFleet);
 
        m_InfoView->setRace(fl->race().c_str());
        m_InfoView->setFleetName(m_sFleet);
index 8707e0bc6cd677c036e55787e03214abba52090c..16acc2b6ce767966d6e466f5d1818611ecc43ccb 100644 (file)
@@ -82,6 +82,8 @@ class BSView : public QSplitter
        QString         m_sBattle;
        QString         m_sGroup;
        QString         m_sFleet;
        QString         m_sBattle;
        QString         m_sGroup;
        QString         m_sFleet;
+
+       bool m_bMoreDocChanges;
   
 public slots: // Public slots
   /** No descriptions */
   
 public slots: // Public slots
   /** No descriptions */
index c72fb4e61c39e5b9450cac19f3c97a82ac2b723f..81d7daa4f09e66438844be23bc52d6b3f5e65200 100644 (file)
@@ -78,4 +78,9 @@ void Planet::setRoids(std::string type, int number)
        m_Roids[type][0] = number;
 }
 
        m_Roids[type][0] = number;
 }
 
+//////////////////////////////////////////////////////////////////////////
+//
+void runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile)
+{
+}
 
 
index 1fd9109c2cf9e8ba936ce1f12630ec64cad8ae6d..e59007ceebbc46c307d78cc84d96122deb092203 100644 (file)
@@ -42,6 +42,8 @@ public:
        int roids(std::string type, int tick = 0) const;
        void setRoids(std::string type, int number);
 
        int roids(std::string type, int tick = 0) const;
        void setRoids(std::string type, int number);
 
+       void runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile);
+
 protected:
        unsigned m_iScore;
        RoidList m_Roids;
 protected:
        unsigned m_iScore;
        RoidList m_Roids;
index e6baafab460f1bbf2755bb49acf2fe3375db9c48..ed97f11419cc03ac1adc535d6e9c8ced7c193dc2 100644 (file)
@@ -25,7 +25,7 @@
             <x>0</x>
             <y>0</y>
             <width>726</width>
             <x>0</x>
             <y>0</y>
             <width>726</width>
-            <height>29</height>
+            <height>26</height>
         </rect>
     </property>
     <item text="&amp;File" name="fileMenu">
         </rect>
     </property>
     <item text="&amp;File" name="fileMenu">
@@ -50,6 +50,7 @@
     </item>
     <item text="Battle" name="PopupMenu">
         <action name="battleNewAction"/>
     </item>
     <item text="Battle" name="PopupMenu">
         <action name="battleNewAction"/>
+        <action name="battleSimulateAction"/>
     </item>
     <item text="&amp;Help" name="helpMenu">
         <action name="helpContentsAction"/>
     </item>
     <item text="&amp;Help" name="helpMenu">
         <action name="helpContentsAction"/>
             <number>4194382</number>
         </property>
     </action>
             <number>4194382</number>
         </property>
     </action>
+    <action>
+        <property name="name">
+            <cstring>battleSimulateAction</cstring>
+        </property>
+        <property name="text">
+            <string>Run Simulate Battle</string>
+        </property>
+        <property name="accel">
+            <number>4194386</number>
+        </property>
+    </action>
 </actions>
 <images>
     <image name="image0">
 </actions>
 <images>
     <image name="image0">
         <receiver>BSAppBase</receiver>
         <slot>battleNew()</slot>
     </connection>
         <receiver>BSAppBase</receiver>
         <slot>battleNew()</slot>
     </connection>
+    <connection>
+        <sender>battleSimulateAction</sender>
+        <signal>activated()</signal>
+        <receiver>BSAppBase</receiver>
+        <slot>battleSimulate()</slot>
+    </connection>
 </connections>
 <includes>
 </connections>
 <includes>
-    <include location="local" impldecl="in implementation">../bsconf.h</include>
-    <include location="global" impldecl="in implementation">qinputdialog.h</include>
-    <include location="local" impldecl="in implementation">../bsview.h</include>
+    <include location="global" impldecl="in implementation">qapplication.h</include>
     <include location="local" impldecl="in implementation">../bsdoc.h</include>
     <include location="local" impldecl="in implementation">../bsdoc.h</include>
+    <include location="local" impldecl="in implementation">../bsview.h</include>
+    <include location="global" impldecl="in implementation">qinputdialog.h</include>
+    <include location="local" impldecl="in implementation">../bsconf.h</include>
     <include location="local" impldecl="in implementation">bsappbase.ui.h</include>
 </includes>
 <forwards>
     <include location="local" impldecl="in implementation">bsappbase.ui.h</include>
 </includes>
 <forwards>
     <slot>helpContents()</slot>
     <slot>helpAbout()</slot>
     <slot>battleNew()</slot>
     <slot>helpContents()</slot>
     <slot>helpAbout()</slot>
     <slot>battleNew()</slot>
+    <slot>battleSimulate()</slot>
 </slots>
 <layoutdefaults spacing="6" margin="11"/>
 </UI>
 </slots>
 <layoutdefaults spacing="6" margin="11"/>
 </UI>
index 0787e81d3563357ca824bd91598b5e18894348a4..da293f2786f9c3bbae29da3024db3847ca05953f 100644 (file)
@@ -99,4 +99,12 @@ void BSAppBase::battleNew()
        {
       // user entered nothing or pressed Cancel
        }
        {
       // user entered nothing or pressed Cancel
        }
+}
+
+void BSAppBase::battleSimulate()
+{
+     QApplication::setOverrideCursor( Qt::WaitCursor );
+     
+     //doc->runBattleSimulation();
+     QApplication::restoreOverrideCursor();
 }
\ No newline at end of file
 }
\ No newline at end of file
index 411daeb40f27cebea0c743f69ea820dfcdee65e9..33135f7ef3f7373ad4e9a29aa764735cb634b850 100644 (file)
             <property name="name">
                 <cstring>GroupCombo</cstring>
             </property>
             <property name="name">
                 <cstring>GroupCombo</cstring>
             </property>
+            <property name="insertionPolicy">
+                <enum>NoInsertion</enum>
+            </property>
         </widget>
         <widget class="QComboBox" row="0" column="1" rowspan="1" colspan="2">
             <property name="name">
                 <cstring>BattleCombo</cstring>
             </property>
         </widget>
         <widget class="QComboBox" row="0" column="1" rowspan="1" colspan="2">
             <property name="name">
                 <cstring>BattleCombo</cstring>
             </property>
+            <property name="insertionPolicy">
+                <enum>NoInsertion</enum>
+            </property>
         </widget>
         <widget class="QLabel" row="5" column="0">
             <property name="name">
         </widget>
         <widget class="QLabel" row="5" column="0">
             <property name="name">
                 <cstring>NameLabel</cstring>
             </property>
             <property name="text">
                 <cstring>NameLabel</cstring>
             </property>
             <property name="text">
-                <string>&amp;Name</string>
+                <string>Na&amp;me</string>
             </property>
             <property name="buddy" stdset="0">
                 <cstring>NameLine</cstring>
             </property>
             <property name="buddy" stdset="0">
                 <cstring>NameLine</cstring>
                 <cstring>EtaLabel</cstring>
             </property>
             <property name="text">
                 <cstring>EtaLabel</cstring>
             </property>
             <property name="text">
-                <string>&amp;Eta</string>
+                <string>E&amp;ta</string>
             </property>
             <property name="buddy" stdset="0">
                 <cstring>EtaSpin</cstring>
             </property>
             <property name="buddy" stdset="0">
                 <cstring>EtaSpin</cstring>
                         <bool>false</bool>
                     </property>
                     <property name="text">
                         <bool>false</bool>
                     </property>
                     <property name="text">
-                        <string>&amp;Remove</string>
+                        <string>Remo&amp;ve</string>
                     </property>
                 </widget>
             </hbox>
                     </property>
                 </widget>
             </hbox>
         <receiver>InfoView</receiver>
         <slot>ApplyButton_clicked()</slot>
     </connection>
         <receiver>InfoView</receiver>
         <slot>ApplyButton_clicked()</slot>
     </connection>
+    <connection>
+        <sender>NameLine</sender>
+        <signal>textChanged(const QString&amp;)</signal>
+        <receiver>InfoView</receiver>
+        <slot>slotNameChanged(const QString&amp;)</slot>
+    </connection>
 </connections>
 <tabstops>
     <tabstop>NameLine</tabstop>
 </connections>
 <tabstops>
     <tabstop>NameLine</tabstop>
     <include location="global" impldecl="in declaration">vector</include>
     <include location="local" impldecl="in implementation">infoview.ui.h</include>
 </includes>
     <include location="global" impldecl="in declaration">vector</include>
     <include location="local" impldecl="in implementation">infoview.ui.h</include>
 </includes>
+<variables>
+    <variable>QString m_Name;</variable>
+    <variable>QString m_Battle;</variable>
+    <variable>QString m_Group;</variable>
+</variables>
 <signals>
     <signal>remove()</signal>
     <signal>cancel()</signal>
 <signals>
     <signal>remove()</signal>
     <signal>cancel()</signal>
     <slot returnType="QString">fleetName()</slot>
     <slot returnType="QString">group()</slot>
     <slot returnType="QString">race()</slot>
     <slot returnType="QString">fleetName()</slot>
     <slot returnType="QString">group()</slot>
     <slot returnType="QString">race()</slot>
+    <slot>slotNameChanged( const QString &amp; s )</slot>
 </slots>
 <layoutdefaults spacing="0" margin="0"/>
 </UI>
 </slots>
 <layoutdefaults spacing="0" margin="0"/>
 </UI>