fix issue where building stats don't update while the building is kept selected
This commit is contained in:
@@ -45,6 +45,9 @@ MainWindow::MainWindow(Simulation* sim, const GameConfig* config,
|
|||||||
connect(m_gameWorldView, SIGNAL(stateUpdated(Tick, int, double)),
|
connect(m_gameWorldView, SIGNAL(stateUpdated(Tick, int, double)),
|
||||||
this, SLOT(onStateUpdated(Tick, int, double))); // for affordability
|
this, SLOT(onStateUpdated(Tick, int, double))); // for affordability
|
||||||
|
|
||||||
|
connect(m_gameWorldView, SIGNAL(stateUpdated(Tick, int, double)),
|
||||||
|
m_selectedBuildingPanel, SLOT(onStateUpdated(Tick, int, double)));
|
||||||
|
|
||||||
connect(m_gameWorldView, SIGNAL(gameOver()),
|
connect(m_gameWorldView, SIGNAL(gameOver()),
|
||||||
this, SLOT(onGameOver()));
|
this, SLOT(onGameOver()));
|
||||||
|
|
||||||
|
|||||||
@@ -188,6 +188,11 @@ void SelectedBuildingPanel::buildSingle(EntityId id)
|
|||||||
m_clearBeltBtn->hide();
|
m_clearBeltBtn->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshBuffers(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectedBuildingPanel::refreshBuffers(const Building* b)
|
||||||
|
{
|
||||||
QString bufText;
|
QString bufText;
|
||||||
if (!b->inputBuffer.counts.empty())
|
if (!b->inputBuffer.counts.empty())
|
||||||
{
|
{
|
||||||
@@ -221,6 +226,18 @@ void SelectedBuildingPanel::buildSingle(EntityId id)
|
|||||||
m_buffersLabel->setText(bufText);
|
m_buffersLabel->setText(bufText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SelectedBuildingPanel::onStateUpdated(Tick /*tick*/, int /*blocks*/, double /*speed*/)
|
||||||
|
{
|
||||||
|
if (m_singleId == kInvalidEntityId) { return; }
|
||||||
|
const Building* b = m_sim->buildings().findBuilding(m_singleId);
|
||||||
|
if (!b)
|
||||||
|
{
|
||||||
|
buildEmpty();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
refreshBuffers(b);
|
||||||
|
}
|
||||||
|
|
||||||
void SelectedBuildingPanel::buildMulti(const std::vector<EntityId>& ids)
|
void SelectedBuildingPanel::buildMulti(const std::vector<EntityId>& ids)
|
||||||
{
|
{
|
||||||
m_singleId = kInvalidEntityId;
|
m_singleId = kInvalidEntityId;
|
||||||
|
|||||||
@@ -5,8 +5,10 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "Building.h"
|
||||||
#include "EntityId.h"
|
#include "EntityId.h"
|
||||||
#include "GameConfig.h"
|
#include "GameConfig.h"
|
||||||
|
#include "Tick.h"
|
||||||
|
|
||||||
class Simulation;
|
class Simulation;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
@@ -24,6 +26,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onSelectionChanged(const std::vector<EntityId>& ids);
|
void onSelectionChanged(const std::vector<EntityId>& ids);
|
||||||
|
void onStateUpdated(Tick tick, int blocks, double speed);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onRecipeChanged(int comboIndex);
|
void onRecipeChanged(int comboIndex);
|
||||||
@@ -35,6 +38,7 @@ private:
|
|||||||
void buildEmpty();
|
void buildEmpty();
|
||||||
void buildSingle(EntityId id);
|
void buildSingle(EntityId id);
|
||||||
void buildMulti(const std::vector<EntityId>& ids);
|
void buildMulti(const std::vector<EntityId>& ids);
|
||||||
|
void refreshBuffers(const Building* b);
|
||||||
|
|
||||||
Simulation* m_sim;
|
Simulation* m_sim;
|
||||||
const GameConfig* m_config;
|
const GameConfig* m_config;
|
||||||
|
|||||||
Reference in New Issue
Block a user