Started the the actual simulation work now.
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();
+}
void newFleet(QString battle, QString group, QString fleet, Fleet* fl);
+ void removeFleet(QString battle, QString group, QString fleet);
+
+ void runBattleSimulation();
signals:
void documentChanged();
#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*/
+
+ m_bMoreDocChanges = false;
connect(doc, SIGNAL(documentChanged()), this, SLOT(slotDocumentChanged()));
m_doc = doc;
*/
void BSView::slotDocumentChanged()
{
+ if (m_bMoreDocChanges)
+ return;
+
m_NumberView->clear();
const BattleList& battles = m_doc->battles();
//
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);
}
//////////////////////////////////////////////////////////////////////////
//
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();
- 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());
//
void BSView::slotInfoRemove()
{
+ m_doc->removeFleet(m_sBattle, m_sGroup, m_sFleet);
+ m_sFleet = "";
}
//////////////////////////////////////////////////////////////////////////
if(!fl)
{
- m_InfoView->setRace("");
m_InfoView->setFleetName("");
m_InfoView->setEta(0);
- m_InfoView->setGroup("");
- m_InfoView->setBattle("");
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);
}
+*/
m_InfoView->setRace(fl->race().c_str());
m_InfoView->setFleetName(m_sFleet);
QString m_sBattle;
QString m_sGroup;
QString m_sFleet;
+
+ bool m_bMoreDocChanges;
public slots: // Public slots
/** No descriptions */
m_Roids[type][0] = number;
}
+//////////////////////////////////////////////////////////////////////////
+//
+void runBattle(std::vector<Fleet*> friendly, std::vector<Fleet*> hostile)
+{
+}
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;
<x>0</x>
<y>0</y>
<width>726</width>
- <height>29</height>
+ <height>26</height>
</rect>
</property>
<item text="&File" name="fileMenu">
</item>
<item text="Battle" name="PopupMenu">
<action name="battleNewAction"/>
+ <action name="battleSimulateAction"/>
</item>
<item text="&Help" name="helpMenu">
<action name="helpContentsAction"/>
<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">
<receiver>BSAppBase</receiver>
<slot>battleNew()</slot>
</connection>
+ <connection>
+ <sender>battleSimulateAction</sender>
+ <signal>activated()</signal>
+ <receiver>BSAppBase</receiver>
+ <slot>battleSimulate()</slot>
+ </connection>
</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">../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>
<slot>helpContents()</slot>
<slot>helpAbout()</slot>
<slot>battleNew()</slot>
+ <slot>battleSimulate()</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>
{
// user entered nothing or pressed Cancel
}
+}
+
+void BSAppBase::battleSimulate()
+{
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+
+ //doc->runBattleSimulation();
+ QApplication::restoreOverrideCursor();
}
\ No newline at end of file
<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>
+ <property name="insertionPolicy">
+ <enum>NoInsertion</enum>
+ </property>
</widget>
<widget class="QLabel" row="5" column="0">
<property name="name">
<cstring>NameLabel</cstring>
</property>
<property name="text">
- <string>&Name</string>
+ <string>Na&me</string>
</property>
<property name="buddy" stdset="0">
<cstring>NameLine</cstring>
<cstring>EtaLabel</cstring>
</property>
<property name="text">
- <string>&Eta</string>
+ <string>E&ta</string>
</property>
<property name="buddy" stdset="0">
<cstring>EtaSpin</cstring>
<bool>false</bool>
</property>
<property name="text">
- <string>&Remove</string>
+ <string>Remo&ve</string>
</property>
</widget>
</hbox>
<receiver>InfoView</receiver>
<slot>ApplyButton_clicked()</slot>
</connection>
+ <connection>
+ <sender>NameLine</sender>
+ <signal>textChanged(const QString&)</signal>
+ <receiver>InfoView</receiver>
+ <slot>slotNameChanged(const QString&)</slot>
+ </connection>
</connections>
<tabstops>
<tabstop>NameLine</tabstop>
<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>
<slot returnType="QString">fleetName()</slot>
<slot returnType="QString">group()</slot>
<slot returnType="QString">race()</slot>
+ <slot>slotNameChanged( const QString & s )</slot>
</slots>
<layoutdefaults spacing="0" margin="0"/>
</UI>