]> ruin.nu Git - hbs.git/commitdiff
some changes
authorMichael Andreen <harv@ruin.nu>
Mon, 18 Mar 2002 16:47:42 +0000 (16:47 +0000)
committerMichael Andreen <harv@ruin.nu>
Mon, 18 Mar 2002 16:47:42 +0000 (16:47 +0000)
bs/bsdoc.cpp
bs/bsview.cpp
bs/bsview.h
bs/fleet.cpp
bs/share/race.conf
bs/share/stats.conf
bs/ui/infoview.ui
bs/ui/resourceview.ui
bs/ui/roidseditview.ui

index 1c6e60bf24f4f31cfe50e29bbb66e983ecc77ba8..47688a7bfd06e20b37cf312b818fcc8e676a973c 100644 (file)
@@ -58,7 +58,8 @@ bool BSDoc::isModified() const
 
 int BSDoc::newBattle(QString name)
 {
-       m_Battles[name]["Friendly"]["Home Planet"];
+       m_Battles[name]["Friendly"]["Home Planet"].setRace("Planet");
+       m_Battles[name]["Friendly"]["Home Fleet"];
        m_Battles[name]["Hostile"];
 
        modified = true;
index f7f3aa8a771b30783c4058810d2f987a7fa14f75..5ae770305468a68475a8c3b62b03ad02c4eed9d0 100644 (file)
@@ -39,7 +39,7 @@ using namespace std;
 BSView::BSView(QWidget *parent, BSDoc *doc) : QSplitter(parent)
 {
   /** connect doc with the view*/
-  connect(doc, SIGNAL(documentChanged()), this, SLOT(slotDocumentChanged()));
+       connect(doc, SIGNAL(documentChanged()), this, SLOT(slotDocumentChanged()));
        
        m_doc = doc;
        
@@ -54,19 +54,39 @@ BSView::BSView(QWidget *parent, BSDoc *doc) : QSplitter(parent)
        m_NumberView->addColumn("ETA");
        //addBattle("NO BATTLES");
 
+       
+       
+       connect(m_NumberView, SIGNAL(expanded(QListViewItem*)), SLOT(slotItemExpanded(QListViewItem*)));
+       connect(m_NumberView, SIGNAL(collapsed(QListViewItem*)), SLOT(slotItemCollapsed(QListViewItem*)));
+       
        m_InfoView = new InfoView(m_LeftSplit);
+
+       vector<QString> raceNames;
+       const map<string, vector<int> >& races = Fleet::Races();
+       for(map<string, vector<int> >::const_iterator i = races.begin(); i != races.end(); ++i)
+       {
+               raceNames.push_back(i->first.c_str());
+       }
+       m_InfoView->setRaces(raceNames);
        
        //the right side
        m_TickView = new TickView(m_RightSplit);
        m_FleetViews = new QWidgetStack(m_RightSplit);
        m_ScanView = new ScanView(m_RightSplit);
        
+       Fleet fl1;
+       //fl1.setRace(tr("Terran").latin1());
+       fl1.setRace("Terran");
+       Fleet fl2;
+       fl2.setRace(tr("Generic").latin1());
+
        //the widget stack
        m_BattleSum = new BattleSum();
        m_FleetViews->addWidget(m_BattleSum, 0);
-       m_FleetView = new FleetView(Fleet(), true, true);
+       m_FleetView = new FleetView(fl1, true, true);
        m_FleetViews->addWidget(m_FleetView, 1);
-
+       m_GenericFleetView = new FleetView(fl2, true, false);
+       m_FleetViews->addWidget(m_GenericFleetView, 2);
        //m_FleetViews->raiseWidget(0);
        connect(m_NumberView, SIGNAL(selectionChanged(QListViewItem *)), SLOT(slotFleetSelection(QListViewItem *))); 
 }
@@ -100,12 +120,15 @@ void BSView::slotDocumentChanged()
        {
                QString b = (*i).first;
                QListViewItem* battle = new QListViewItem(m_NumberView, b);
+               battle->setOpen(m_TreeExpanded[b]["--"]);
+                       
 
                for (map<QString, map<QString, Fleet> >::const_iterator j = i->second.begin(); j != i->second.end(); ++j)
                {
                        QString g = (*j).first;
                        QListViewItem* group = new QListViewItem(battle, g);
                        int groupShips = 0;
+                       group->setOpen(m_TreeExpanded[b][g]);
 
                        for (map<QString, Fleet>::const_iterator k = j->second.begin(); k != j->second.end(); ++k)
                        {       
@@ -142,7 +165,7 @@ void BSView::slotFleetSelection(QListViewItem *lvi)
                {
 //                     m_FleetView->slotAttacker(true);
                }
-               m_FleetViews->raiseWidget(1);
+               m_FleetViews->raiseWidget(2);
                
        }
        else
@@ -161,19 +184,58 @@ void BSView::slotFleetSelection(QListViewItem *lvi)
                        }
                }
                Fleet fl = m_doc->specificFleet(battle, group, fleet);
-               if (fl.Race() == m_FleetView->fleet().Race() &&
-                       m_FleetView->isHome() == home)
+               m_InfoView->setRace(fl.Race().c_str());
+               m_InfoView->setFleetName(fleet);
+               m_InfoView->setEta(fl.ETA());
+               if (fl.Race() == tr("Generic").latin1())
                {
-                       m_FleetView->viewFleet(fl, friendly);
+                       m_GenericFleetView->viewFleet(fl, friendly);
+                       m_FleetViews->raiseWidget(2);
+
                }
-               else
+               else 
                {
-                       m_FleetViews->removeWidget(m_FleetView);
-                       m_FleetView = new FleetView(fl, friendly, home);
-                       m_FleetViews->addWidget(m_FleetView, 1);
+                       if (fl.Race() == m_FleetView->fleet().Race() &&
+                       m_FleetView->isHome() == home)
+                       {
+                               m_FleetView->viewFleet(fl, friendly);
+                       }
+                       else
+                       {
+                               m_FleetViews->removeWidget(m_FleetView);
+                               m_FleetView = new FleetView(fl, friendly, home);
+                               m_FleetViews->addWidget(m_FleetView, 1);
+                       }
+                       m_FleetViews->raiseWidget(1);
                }
-               m_FleetViews->raiseWidget(1);
        }
+}
 
-       
+//////////////////////////////////////////////////////////////////////////
+//
+void BSView::slotItemExpanded(QListViewItem *lvi)
+{
+       if (lvi->parent() == '\0')
+       {
+               m_TreeExpanded[lvi->text(0)]["--"] = true;
+       }
+       else if (lvi->parent()->parent() == '\0')
+       {
+               m_TreeExpanded[lvi->parent()->text(0)][lvi->text(0)] = true;    
+       }
 }
+
+//////////////////////////////////////////////////////////////////////////
+//
+void BSView::slotItemCollapsed(QListViewItem *lvi)
+{
+       if (lvi->parent() == '\0')
+       {
+               m_TreeExpanded[lvi->text(0)]["--"] = false;
+       }
+       else if (lvi->parent()->parent() == '\0')
+       {
+               m_TreeExpanded[lvi->parent()->text(0)][lvi->text(0)] = false;   
+       }
+}
+
index d706e59bc15f92a6370be096837a0776522e72db..f33fce3e23cc1c4e0f99eb9b8f3be64aaa7f9e57 100644 (file)
@@ -21,6 +21,9 @@
 // include files for QT
 #include <qsplitter.h>
 
+//Standard includes
+#include <map>
+
 // application specific includes
 #include "bsdoc.h"
 
@@ -61,12 +64,16 @@ class BSView : public QSplitter
        InfoView                *m_InfoView;
        TickView                *m_TickView;
        QWidgetStack    *m_FleetViews;
-       FleetView   *m_FleetView;
+       FleetView       *m_FleetView;
+       FleetView       *m_GenericFleetView;
        BSDoc                   *m_doc;
+       std::map<QString, std::map<QString, bool> > m_TreeExpanded;
   
 public slots: // Public slots
   /** No descriptions */
   void slotFleetSelection(QListViewItem *lvi);
+  void slotItemExpanded(QListViewItem *lvi);
+  void slotItemCollapsed(QListViewItem *lvi);
 };
 
 #endif
index f086833c0b3266e9f7fa02ff5c2353cc281f5db6..2bd245ba29af67dfc1abadb6a4bdd33f12e35528 100644 (file)
@@ -27,7 +27,7 @@ UnitList Fleet::s_Units;
 Fleet::Fleet()
 {
        m_iETA = 0;
-       m_sRace = "Generic";
+       m_sRace = "Cathaar";
 }
 Fleet::~Fleet(){
 }
index 6e94c4545c3c1bd80e436bc40ada75bc79b7bf80..954fcab608cfefc5560390806e3d34651684e195 100644 (file)
@@ -3,3 +3,4 @@ Terran 0 1
 Cathaar 0 2
 Xandathrii 0 3
 Zikonian 0 4
+Planet 5
index 7149e25ac96c79103cb26f0f7865d5d0c99dcde7..a5aa54d4d24ab14f74394165f14ba41f7c87f9bf 100644 (file)
@@ -96,3 +96,13 @@ Man o' War
 4      Bs      Fr      Co      Fi      40      5       30      40      6       400     90      76000   800     5       Normal
 Astro Pod
 0      Fr      --      --      --      48      20      0       0       0       10      55      3700    125     4       Special
+Mesonic Cutter
+5      Co      Fi      Co      --      49      25      40      1       3       50      N/A     1600    0       0       PDS
+Tachyon Beamer
+5      Fr      Fr      Co      --      50      20      35      1       10      75      N/A     3000    0       0       PDS
+Pulse Cannon
+5      De      De      Fr      All     51      15      30      1       20      150     N/A     8500    0       0       PDS
+Hadron Turret
+5      Cr      Cr      De      All     52      10      25      1       30      225     N/A     18000   0       0       PDS
+Ion Launcher
+5      Bs      Bs      Cr      All     53      5       20      1       60      350     N/A     36000   0       0       PDS
index e9e7ffa148d17eaaa1b0dc5adff8e5f75d00335e..6354911dd7506a4d1c6a671048dd96c81531ffcc 100644 (file)
@@ -1,6 +1,5 @@
 <!DOCTYPE UI><UI version="3.0" stdsetdef="1">
 <class>InfoView</class>
-<layoutdefaults spacing="0" margin="0"/>
 <widget class="QWidget">
     <property name="name">
         <cstring>InfoView</cstring>
@@ -9,28 +8,34 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>192</width>
-            <height>144</height>
+            <width>263</width>
+            <height>117</height>
         </rect>
     </property>
+    <property name="maximumSize">
+        <size>
+            <width>32767</width>
+            <height>150</height>
+        </size>
+    </property>
     <property name="caption">
         <string>Form2</string>
     </property>
-    <grid>
+    <vbox>
         <property name="name">
             <cstring>unnamed</cstring>
         </property>
         <property name="margin">
-            <number>1</number>
+            <number>0</number>
         </property>
         <property name="spacing">
-            <number>1</number>
+            <number>0</number>
         </property>
-        <widget class="QLayoutWidget" row="0" column="0">
+        <widget class="QLayoutWidget">
             <property name="name">
-                <cstring>Layout11</cstring>
+                <cstring>Layout7</cstring>
             </property>
-            <hbox>
+            <grid>
                 <property name="name">
                     <cstring>unnamed</cstring>
                 </property>
                     <number>0</number>
                 </property>
                 <property name="spacing">
-                    <number>6</number>
+                    <number>0</number>
                 </property>
-                <widget class="QLayoutWidget">
+                <widget class="QLabel" row="2" column="0">
                     <property name="name">
-                        <cstring>Layout10</cstring>
-                    </property>
-                    <vbox>
-                        <property name="name">
-                            <cstring>unnamed</cstring>
-                        </property>
-                        <property name="margin">
-                            <number>0</number>
-                        </property>
-                        <property name="spacing">
-                            <number>6</number>
-                        </property>
-                        <widget class="QLabel">
-                            <property name="name">
-                                <cstring>TextLabel3</cstring>
-                            </property>
-                            <property name="text">
-                                <string>Name</string>
-                            </property>
-                        </widget>
-                        <widget class="QLabel">
-                            <property name="name">
-                                <cstring>TextLabel1</cstring>
-                            </property>
-                            <property name="text">
-                                <string>Eta</string>
-                            </property>
-                        </widget>
-                        <widget class="QLabel">
-                            <property name="name">
-                                <cstring>TextLabel2</cstring>
-                            </property>
-                            <property name="text">
-                                <string>Planet score</string>
-                            </property>
-                        </widget>
-                    </vbox>
+                        <cstring>RaceLabel</cstring>
+                    </property>
+                    <property name="text">
+                        <string>&amp;Race</string>
+                    </property>
+                    <property name="buddy" stdset="0">
+                        <cstring>RaceCombo</cstring>
+                    </property>
                 </widget>
-                <widget class="QLayoutWidget">
+                <widget class="QComboBox" row="2" column="1">
                     <property name="name">
-                        <cstring>Layout9</cstring>
-                    </property>
-                    <vbox>
-                        <property name="name">
-                            <cstring>unnamed</cstring>
-                        </property>
-                        <property name="margin">
-                            <number>0</number>
-                        </property>
-                        <property name="spacing">
-                            <number>6</number>
-                        </property>
-                        <widget class="QLineEdit">
-                            <property name="name">
-                                <cstring>LineEdit5</cstring>
-                            </property>
-                        </widget>
-                        <widget class="QLineEdit">
-                            <property name="name">
-                                <cstring>LineEdit3</cstring>
-                            </property>
-                        </widget>
-                        <widget class="QLineEdit">
-                            <property name="name">
-                                <cstring>LineEdit4</cstring>
-                            </property>
-                        </widget>
-                    </vbox>
+                        <cstring>RaceCombo</cstring>
+                    </property>
                 </widget>
-            </hbox>
+                <widget class="QLabel" row="1" column="0">
+                    <property name="name">
+                        <cstring>EtaLabel</cstring>
+                    </property>
+                    <property name="text">
+                        <string>&amp;Eta</string>
+                    </property>
+                    <property name="buddy" stdset="0">
+                        <cstring>EtaSpin</cstring>
+                    </property>
+                </widget>
+                <widget class="QSpinBox" row="1" column="1">
+                    <property name="name">
+                        <cstring>EtaSpin</cstring>
+                    </property>
+                </widget>
+                <widget class="QLineEdit" row="0" column="1">
+                    <property name="name">
+                        <cstring>NameLine</cstring>
+                    </property>
+                </widget>
+                <widget class="QLabel" row="0" column="0">
+                    <property name="name">
+                        <cstring>NameLabel</cstring>
+                    </property>
+                    <property name="text">
+                        <string>&amp;Name</string>
+                    </property>
+                    <property name="buddy" stdset="0">
+                        <cstring>NameLine</cstring>
+                    </property>
+                </widget>
+            </grid>
         </widget>
-        <widget class="QLayoutWidget" row="1" column="0">
+        <widget class="QLayoutWidget">
             <property name="name">
                 <cstring>Layout13</cstring>
             </property>
                 </property>
                 <widget class="QPushButton">
                     <property name="name">
-                        <cstring>PushButton1</cstring>
+                        <cstring>ApplyButton</cstring>
                     </property>
                     <property name="text">
-                        <string>Apply</string>
+                        <string>&amp;Apply</string>
                     </property>
                 </widget>
                 <widget class="QPushButton">
                     <property name="name">
-                        <cstring>PushButton2</cstring>
+                        <cstring>CancelButton</cstring>
                     </property>
                     <property name="text">
-                        <string>Cancel</string>
+                        <string>&amp;Cancel</string>
                     </property>
                 </widget>
                 <spacer>
-                    <property name="name">
+                    <property name="name" stdset="0">
                         <cstring>Spacer1</cstring>
                     </property>
                     <property name="orientation">
                 </spacer>
                 <widget class="QPushButton">
                     <property name="name">
-                        <cstring>PushButton3</cstring>
+                        <cstring>NewButton</cstring>
                     </property>
                     <property name="enabled">
                         <bool>false</bool>
                     </property>
                     <property name="text">
-                        <string>New</string>
+                        <string>&amp;New</string>
                     </property>
                 </widget>
                 <widget class="QPushButton">
                     <property name="name">
-                        <cstring>PushButton4</cstring>
+                        <cstring>RemoveButton</cstring>
                     </property>
                     <property name="enabled">
                         <bool>false</bool>
                     </property>
                     <property name="text">
-                        <string>Remove</string>
+                        <string>&amp;Remove</string>
                     </property>
                 </widget>
             </hbox>
         </widget>
-    </grid>
+    </vbox>
 </widget>
 <connections>
-    <slot access="protected" language="C++" returnType="void">init()</slot>
-    <slot access="protected" language="C++" returnType="void">destroy()</slot>
+    <connection>
+        <sender>ApplyButton</sender>
+        <signal>clicked()</signal>
+        <receiver>InfoView</receiver>
+        <slot>ApplyButton_clicked()</slot>
+    </connection>
+    <connection>
+        <sender>CancelButton</sender>
+        <signal>clicked()</signal>
+        <receiver>InfoView</receiver>
+        <slot>CancelButton_clicked()</slot>
+    </connection>
+    <connection>
+        <sender>NewButton</sender>
+        <signal>clicked()</signal>
+        <receiver>InfoView</receiver>
+        <slot>NewButton_clicked()</slot>
+    </connection>
+    <connection>
+        <sender>RemoveButton</sender>
+        <signal>clicked()</signal>
+        <receiver>InfoView</receiver>
+        <slot>RemoveButton_clicked()</slot>
+    </connection>
 </connections>
-<functions>
-    <function name="init()" >{
-
-}</function>
-    <function name="destroy()" >{
-
-}</function>
-</functions>
+<includes>
+    <include location="global" impldecl="in declaration">vector</include>
+    <include location="local" impldecl="in implementation">infoview.ui.h</include>
+</includes>
+<signals>
+    <signal>remove()</signal>
+    <signal>cancel()</signal>
+    <signal>apply()</signal>
+    <signal>add()</signal>
+</signals>
+<slots>
+    <slot access="protected">init()</slot>
+    <slot access="protected">destroy()</slot>
+    <slot>setRaces( std::vector&lt;QString&gt; races )</slot>
+    <slot>setEta( int eta )</slot>
+    <slot>setFleetName( QString name )</slot>
+    <slot>setRace( QString name )</slot>
+    <slot>InfoView_destroyed( QObject * )</slot>
+    <slot>ApplyButton_clicked()</slot>
+    <slot>CancelButton_clicked()</slot>
+    <slot>NewButton_clicked()</slot>
+    <slot>RemoveButton_clicked()</slot>
+</slots>
+<layoutdefaults spacing="0" margin="0"/>
 </UI>
index 8fde5eb6f79676013527f8ad991d98691c3e9d8c..6221366e10bcd157292bf733be147631801b9b0d 100644 (file)
             <height>75</height>
         </rect>
     </property>
+    <property name="maximumSize">
+        <size>
+            <width>32767</width>
+            <height>90</height>
+        </size>
+    </property>
     <property name="caption">
         <string>QGroupBoxForm</string>
     </property>
@@ -88,6 +94,9 @@
             <property name="name">
                 <cstring>UninitLine</cstring>
             </property>
+            <property name="focusPolicy">
+                <enum>NoFocus</enum>
+            </property>
             <property name="readOnly">
                 <bool>true</bool>
             </property>
         </widget>
     </grid>
 </widget>
+<includes>
+    <include location="local" impldecl="in implementation">resourceview.ui.h</include>
+</includes>
 <pixmapinproject/>
 <layoutdefaults spacing="6" margin="11"/>
 </UI>
index 42b59666fb658a9b905f534c05c861702c0a99c1..3199fddaabe123d41217ea0e674bbfc40bf8fd8c 100644 (file)
             <height>100</height>
         </rect>
     </property>
+    <property name="maximumSize">
+        <size>
+            <width>32767</width>
+            <height>110</height>
+        </size>
+    </property>
     <property name="caption">
         <string>Roids</string>
     </property>
@@ -64,6 +70,9 @@
             <property name="name">
                 <cstring>LineEdit27</cstring>
             </property>
+            <property name="focusPolicy">
+                <enum>NoFocus</enum>
+            </property>
             <property name="readOnly">
                 <bool>true</bool>
             </property>
             <property name="name">
                 <cstring>LineEdit28</cstring>
             </property>
+            <property name="focusPolicy">
+                <enum>NoFocus</enum>
+            </property>
             <property name="readOnly">
                 <bool>true</bool>
             </property>
             <property name="name">
                 <cstring>LineEdit30</cstring>
             </property>
+            <property name="focusPolicy">
+                <enum>NoFocus</enum>
+            </property>
             <property name="readOnly">
                 <bool>true</bool>
             </property>
             <property name="name">
                 <cstring>LineEdit33</cstring>
             </property>
+            <property name="focusPolicy">
+                <enum>NoFocus</enum>
+            </property>
             <property name="readOnly">
                 <bool>true</bool>
             </property>