X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bs%2Ffleetview.cpp;h=3935616fb31a7c23ee28fd823ca702af6314a331;hb=e058e65a4a9f0c47b170413c0a085e90b172a3ec;hp=5cbed5377caa4797c794f8a3bba2f167779298fe;hpb=d1b57a078d3edb148f8b6ec61944a0b852a4bf94;p=hbs.git diff --git a/bs/fleetview.cpp b/bs/fleetview.cpp index 5cbed53..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))) @@ -68,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(){ @@ -91,7 +95,7 @@ void FleetView::viewFleet(const Fleet* fleet, bool friendly) { m_Fleet = new Fleet(*fleet); } - m_Fleet->printFleet(); + //m_Fleet->printFleet(); fillTable(); } @@ -201,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(); } ///////////////////////////////////////////////////////////////////// @@ -228,11 +233,104 @@ void FleetView::slotViewTickRange(int min = -1, int max = -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 before = m_Fleet->fleet(i->latin1(), m_iMinTick); - int after = m_Fleet->fleet(i->latin1(), m_iMaxTick); - m_UnitsLostSurvivedView[(*i)]->setText(QString("%1").arg(after - before)); + 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(); +}