X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bs%2Ffleetview.cpp;h=3935616fb31a7c23ee28fd823ca702af6314a331;hb=e058e65a4a9f0c47b170413c0a085e90b172a3ec;hp=b16c70fc309d660243241983e78b63d157369739;hpb=f7ce9d1a41bdeab4f12110c6911f662dc6e06ca3;p=hbs.git diff --git a/bs/fleetview.cpp b/bs/fleetview.cpp index b16c70f..3935616 100644 --- a/bs/fleetview.cpp +++ b/bs/fleetview.cpp @@ -30,6 +30,10 @@ using namespace std; FleetView::FleetView(const Fleet* fleet, bool friendly, QWidget *parent, const char *name ) : QWidget(parent,name) { + m_iMinTick = 0; + m_iMaxTick = 0; + m_iResultMode = 0; + m_Modified = false; const Planet* planet = 0; if((planet = dynamic_cast(fleet))) @@ -43,6 +47,7 @@ FleetView::FleetView(const Fleet* fleet, bool friendly, QWidget *parent, const c m_bHome = false; } + m_Fleet->printFleet(); m_bFriendly = friendly; //m_ChangesMapper = new QSignalMapper(this); @@ -67,7 +72,7 @@ FleetView::FleetView(const Fleet* fleet, bool friendly, QWidget *parent, const c } m_ResourceView = new ResourceView(this); m_MainLayout->addWidget(m_ResourceView); - fillTable(); + fillTable(); } FleetView::~FleetView(){ @@ -90,6 +95,7 @@ void FleetView::viewFleet(const Fleet* fleet, bool friendly) { m_Fleet = new Fleet(*fleet); } + //m_Fleet->printFleet(); fillTable(); } @@ -199,6 +205,7 @@ void FleetView::fillTable() m_RoidsEditView->setValue(tr("eonium"),pl->roids(tr("eonium").latin1())); m_RoidsEditView->setValue(tr("uninit"),pl->roids(tr("uninit").latin1())); } + slotViewTickRange(); } ///////////////////////////////////////////////////////////////////// @@ -218,3 +225,112 @@ void FleetView::slotRoidsChanged(const QString& type, int value) } } +///////////////////////////////////////////////////////////////////// +// +void FleetView::slotViewTickRange(int min = -1, int max = -1) +{ + if (min > -1) + m_iMinTick = min; + if (max > -1) + m_iMaxTick = max; + + int before = 0; + int after = 0; + for(vector::iterator i = m_Names.begin(); i != m_Names.end(); ++i) + { + int show; + if (m_iResultMode == 1) //Blocked + { + show = m_Fleet->blockedFleet(i->latin1(), m_iMaxTick); + } + else if (m_iResultMode == 2) //Survived + { + show = m_Fleet->fleet(i->latin1(), m_iMaxTick); + } + else + { + before = m_Fleet->fleet(i->latin1(), m_iMinTick); + after = m_Fleet->fleet(i->latin1(), m_iMaxTick); + show = after - before; + } + m_UnitsLostSurvivedView[(*i)]->setText(QString("%1").arg( show )); + } + + int lost; + + int init = 0; + + before = m_Fleet->resource(tr("metal").latin1(),m_iMinTick); + after = m_Fleet->resource(tr("metal").latin1(),m_iMaxTick); + lost = after - before; + init += lost; + m_ResourceView->setLines(tr("metal"),lost); + + before = m_Fleet->resource(tr("crystal").latin1(),m_iMinTick); + after = m_Fleet->resource(tr("crystal").latin1(),m_iMaxTick); + lost = after - before; + init += lost; + m_ResourceView->setLines(tr("crystal"),lost); + + before = m_Fleet->resource(tr("eonium").latin1(),m_iMinTick); + after = m_Fleet->resource(tr("eonium").latin1(),m_iMaxTick); + lost = after - before; + init += lost; + m_ResourceView->setLines(tr("eonium"),lost); + + before = m_Fleet->resource(tr("uninit").latin1(),m_iMinTick); + after = m_Fleet->resource(tr("uninit").latin1(),m_iMaxTick); + lost = after - before; + m_ResourceView->setLines(tr("uninit"),lost); + + before = m_Fleet->score(m_iMinTick); + after = m_Fleet->score(m_iMaxTick); + lost = after - before; + m_ResourceView->setLines(tr("score"),after); + m_ResourceView->setLines(tr("lost"),lost); + float cost = (before - after) / float(init) / 1000; + m_ResourceView->setLines(tr("cost"),cost); + + + + Planet* pl; + if ((pl = dynamic_cast(m_Fleet))) + { + + before = pl->roids(tr("metal").latin1(),m_iMinTick); + after = pl->roids(tr("metal").latin1(),m_iMaxTick); + lost = after - before; + m_RoidsEditView->slotSetLost(tr("metal"),lost); + + before = pl->roids(tr("crystal").latin1(),m_iMinTick); + after = pl->roids(tr("crystal").latin1(),m_iMaxTick); + lost = after - before; + m_RoidsEditView->slotSetLost(tr("crystal"),lost); + + before = pl->roids(tr("eonium").latin1(),m_iMinTick); + after = pl->roids(tr("eonium").latin1(),m_iMaxTick); + lost = after - before; + m_RoidsEditView->slotSetLost(tr("eonium"),lost); + + before = pl->roids(tr("uninit").latin1(),m_iMinTick); + after = pl->roids(tr("uninit").latin1(),m_iMaxTick); + lost = after - before; + m_RoidsEditView->slotSetLost(tr("uninit"),lost); + + before = pl->planetScore(m_iMinTick); + after = pl->planetScore(m_iMaxTick); + lost = after - before; + m_RoidsEditView->slotSetLost(tr("scorelost"),lost); + + m_RoidsEditView->slotSetLost(tr("capping"),pl->capping(m_iMaxTick)); + + } +} + +////////////////////////////////////////////////////////////////////////// +// +void FleetView::slotSetResultMode(int i) +{ + m_iResultMode = i; + slotViewTickRange(); +}