#include "bsdoc.h"
+using namespace std;
BSDoc::BSDoc()
{
/////////////////////////////////////////////////////////////////////////
//
-const std::map<QString, std::map<QString, std::map<QString, Fleet> > >& BSDoc::Battles() const
+const std::map<QString, std::map<QString, std::map<QString, Fleet> > >& BSDoc::battles() const
{
return m_Battles;
}
+//////////////////////////////////////////////////////////////////////////
+//
+Fleet BSDoc::specificFleet(QString battle, QString group, QString fleet) const
+{
+ for (map<QString, map<QString, map<QString, Fleet> > >::const_iterator i = m_Battles.begin(); i != m_Battles.end(); ++i)
+ {
+ if (i->first == battle)
+ {
+ for (map<QString, map<QString, Fleet> >::const_iterator j = i->second.begin(); j != i->second.end(); j++)
+ {
+ if (j->first == group)
+ {
+ for (map<QString, Fleet>::const_iterator k = j->second.begin(); k != j->second.end(); ++k)
+ {
+ if (k->first == fleet)
+ {
+ return k->second;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
* change it.
* \todo remove this, and replace it with a better more closed interface.
*/
- const std::map<QString, std::map<QString, std::map<QString, Fleet> > >& Battles() const;
+ const std::map<QString, std::map<QString, std::map<QString, Fleet> > >& battles() const;
+
+ Fleet specificFleet(QString battle, QString group, QString fleet) const;
signals:
void documentChanged();
//the widget stack
m_BattleSum = new BattleSum();
m_FleetViews->addWidget(m_BattleSum, 0);
- m_FleetView = new FleetView();
+ m_FleetView = new FleetView(Fleet(), true, true);
m_FleetViews->addWidget(m_FleetView, 1);
//m_FleetViews->raiseWidget(0);
{
m_NumberView->clear();
- const map<QString, map<QString, map<QString, Fleet> > >& battles = m_doc->Battles();
+ const map<QString, map<QString, map<QString, Fleet> > >& battles = m_doc->battles();
for (map<QString, map<QString, map<QString, Fleet> > >::const_iterator i = battles.begin(); i != battles.end(); ++i)
{
}
else
{
- if (lvi->parent()->text(0) == tr("Friendly"))
+ bool home = false;
+ bool friendly = false;
+ QString fleet = lvi->text(0);
+ QString group = lvi->parent()->text(0);
+ QString battle = lvi->parent()->parent()->text(0);
+ if ( group == tr("Friendly"))
{
-// m_FleetView->slotAttacker(false);
-// m_FleetView->slotHomePlanet(false);
- if (lvi->text(0) == tr("Home Planet"))
+ friendly = true;
+ if ( fleet == tr("Home Planet"))
{
-// m_FleetView->slotHomePlanet(true);
+ home = true;
}
}
+ Fleet fl = m_doc->specificFleet(battle, group, fleet);
+ if (fl.Race() == m_FleetView->fleet().Race() &&
+ m_FleetView->isHome() == home)
+ {
+ m_FleetView->viewFleet(fl, friendly);
+ }
else
{
-// m_FleetView->slotAttacker(true);
-// m_FleetView->slotHomePlanet(false);
+ m_FleetViews->removeWidget(m_FleetView);
+ m_FleetView = new FleetView(fl, friendly, home);
+ m_FleetViews->addWidget(m_FleetView, 1);
}
m_FleetViews->raiseWidget(1);
-
}
return s_Units;
}
-
+//////////////////////////////////////////////////////////////////////////
+//
+vector<int> Fleet::RacesAllowed() const
+{
+ return s_Races[m_sRace];
+}
*/
std::string Race() const;
+ std::vector<int> RacesAllowed() const;
+
/**Returns the total number of ships in this fleet
*/
int NumberOfShips() const;
//////////////////////////////////////////////////////////////////////////
//
-string UnitType::Name()
+string UnitType::Name() const
{
return m_sName;
}
//////////////////////////////////////////////////////////////////////////
//
-int UnitType::Race()
+int UnitType::Race() const
{
return m_iRace;
}
//////////////////////////////////////////////////////////////////////////
//
-string UnitType::Class()
+string UnitType::Class() const
{
return m_sClass;
}
//////////////////////////////////////////////////////////////////////////
//
-vector<string> UnitType::Target()
+vector<string> UnitType::Target() const
{
return m_vTarget;
}
//////////////////////////////////////////////////////////////////////////
//
-string UnitType::Target(int index)
+string UnitType::Target(int index) const
{
return m_vTarget[index];
}
//////////////////////////////////////////////////////////////////////////
//
-int UnitType::Initiative()
+int UnitType::Initiative() const
{
return m_iInitiative;
}
//////////////////////////////////////////////////////////////////////////
//
-int UnitType::Agility()
+int UnitType::Agility() const
{
return m_iAgility;
}
//////////////////////////////////////////////////////////////////////////
//
-int UnitType::WeaponSpeed()
+int UnitType::WeaponSpeed() const
{
return m_iWeaponSpeed;
}
//////////////////////////////////////////////////////////////////////////
//
-int UnitType::Guns()
+int UnitType::Guns() const
{
return m_iGuns;
}
//////////////////////////////////////////////////////////////////////////
//
-int UnitType::Power()
+int UnitType::Power() const
{
return m_iPower;
}
//////////////////////////////////////////////////////////////////////////
//
-int UnitType::Armor()
+int UnitType::Armor() const
{
return m_iArmor;
}
//////////////////////////////////////////////////////////////////////////
//
-int UnitType::EMP()
+int UnitType::EMP() const
{
return m_iEMP;
}
//////////////////////////////////////////////////////////////////////////
//
-int UnitType::TotRes()
+int UnitType::TotRes() const
{
return m_iTotalResources;
}
//////////////////////////////////////////////////////////////////////////
//
-int UnitType::Fuel()
+int UnitType::Fuel() const
{
return m_iFuel;
}
//////////////////////////////////////////////////////////////////////////
//
-int UnitType::ETA()
+int UnitType::ETA() const
{
return m_iETA;
}
//////////////////////////////////////////////////////////////////////////
//
-string UnitType::Type()
+string UnitType::Type() const
{
return m_sType;
}
/*! This function sets the name for this unittype (ie. interceptor) */
void setName(std::string sName);
/** Returns the name of this unittype */
- std::string Name();
+ std::string Name() const;
/** This functions sets which race this unittype is, the race is represented with a integer. */
void setRace(int iRace);
/** Returns the race this unittype belongs to*/
- int Race();
+ int Race() const;
/** Sets the class for the unittype, it's represented as a integer */
void setClass(std::string sClass);
- std::string Class();
+ std::string Class() const;
/** Sets the classes that this unittype targets. a vector is used. */
void setTarget(std::vector<std::string> Target);
* \param index where to place the target. 0 being the default and first place. */
void insTarget(std::string iTarget, int index = 0);
/** Returns all targets from the target list */
- std::vector<std::string> Target();
+ std::vector<std::string> Target() const;
/** Returns a specific target
* \param index An index value that represents the target. 0 being the first*/
- std::string Target(int index);
+ std::string Target(int index) const;
/** Sets the initiatve, the lower it is the earlier the unit shots */
void setInitiative(int iInit);
- int Initiative();
+ int Initiative() const;
/** Sets the agility, the higher it is the harder it is to hit the unit */
void setAgility (int iAgil);
- int Agility();
+ int Agility() const;
/** Sets the weaponspeed.. just a simple integer that shows how good it is at hitting things */
void setWeaponSpeed(int iWPSP);
- int WeaponSpeed();
+ int WeaponSpeed() const;
/** Sets the number of guns. */
void setGuns(int iGuns);
- int Guns();
+ int Guns() const;
/** Sets the how much power the guns have.. or in other words: the damage they do. */
void setPower(int iPower);
- int Power();
+ int Power() const;
/** Sets the armor, this is how much damage the unittype can take before it's destroyed */
void setArmor(int iArmor);
- int Armor();
+ int Armor() const;
/** Sets the emp resistance, the lower value the easier it is to block it */
void setEMP(int iEMP);
- int EMP();
+ int EMP() const;
/** Sets the resource cost for this unittype. Used for example for score calculation and so on. */
void setTotalResources(int iTR);
/** Returns the number of total resources this unittype cost. */
- int TotRes();
+ int TotRes() const;
/** Sets the fuelcost for this unittype */
void setFuel(int iFuel);
/** Returns the fuelcost */
- int Fuel();
+ int Fuel() const;
/** Sets the ETA, the speed in a sort of inverted form.. the lower ETA, the faster is the unit */
void setETA(int iETA);
- int ETA();
+ int ETA() const;
/** Sets the type of the unit. What the types do must be specified in the real battle engine (Fleet) though.
* \param iType An integer to symbolise the type. */
void setType(std::string type);
/** What type of ship this is. */
- std::string Type();
+ std::string Type() const;
protected:
std::string m_sName;
int m_iRace; //!< Not really the race, but an indiaction on what race can use it..