Prefix all getters with "get"
This commit is contained in:
@@ -211,7 +211,7 @@ void GameWorldView::onFrame()
|
||||
if (m_replayPlayer->isFinished()
|
||||
|| m_sim->isWon() || m_sim->isGameOver()) { break; }
|
||||
m_sim->tick();
|
||||
m_replayPlayer->advanceTo(m_sim->currentTick());
|
||||
m_replayPlayer->advanceTo(m_sim->getCurrentTick());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -263,7 +263,7 @@ void GameWorldView::onFrame()
|
||||
// Expire old beams. Lifetime is measured in game ticks so beams stay
|
||||
// visible while the simulation is paused or slowed (REQ-SHP-FIRING-BEAM).
|
||||
{
|
||||
const Tick now = m_sim->currentTick();
|
||||
const Tick now = m_sim->getCurrentTick();
|
||||
std::vector<ActiveBeam> live;
|
||||
for (const ActiveBeam& b : m_activeBeams)
|
||||
{
|
||||
@@ -314,11 +314,11 @@ void GameWorldView::onFrame()
|
||||
|
||||
// Fire events for any state that changed since the last frame
|
||||
{
|
||||
const Tick newTick = m_sim->currentTick();
|
||||
const int newBlocks = m_sim->buildingBlocksStock();
|
||||
const int newExpCost = m_sim->currentExpansionCost();
|
||||
const int newBoss = m_sim->bossWaveCounter();
|
||||
const Tick newCountdown = m_sim->bossCountdownTicks();
|
||||
const Tick newTick = m_sim->getCurrentTick();
|
||||
const int newBlocks = m_sim->getBuildingBlocksStock();
|
||||
const int newExpCost = m_sim->getCurrentExpansionCost();
|
||||
const int newBoss = m_sim->getBossWaveCounter();
|
||||
const Tick newCountdown = m_sim->getBossCountdownTicks();
|
||||
|
||||
if (newTick != m_lastTick)
|
||||
{
|
||||
@@ -384,16 +384,16 @@ void GameWorldView::onFrame()
|
||||
|
||||
// Artifact count is a passive reflection of sim state (not a live-input source
|
||||
// like the schematic/game-over polls above), so it updates during replay too —
|
||||
// the recorded ApplySchematicChoice drives m_sim->artifactCount() forward and
|
||||
// the recorded ApplySchematicChoice drives m_sim->getArtifactCount() forward and
|
||||
// the header bar must track it. Fires on the first frame (count 0 vs the -1
|
||||
// sentinel), which also populates the win-count max (replacing the "0/?" label).
|
||||
const int currentArtifactCount = m_sim->artifactCount();
|
||||
const int currentArtifactCount = m_sim->getArtifactCount();
|
||||
if (currentArtifactCount != m_lastArtifactCount)
|
||||
{
|
||||
m_lastArtifactCount = currentArtifactCount;
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<ArtifactCountChangedEvent>(
|
||||
currentArtifactCount, m_sim->config().world.artifacts.artifactWinCount));
|
||||
currentArtifactCount, m_sim->getConfig().world.artifacts.artifactWinCount));
|
||||
}
|
||||
|
||||
update();
|
||||
@@ -432,27 +432,27 @@ void GameWorldView::paintGL()
|
||||
// Coordinate helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
float GameWorldView::tilePx() const
|
||||
float GameWorldView::getTilePx() const
|
||||
{
|
||||
if (m_config->world.heightTiles <= 0) { return 1.0f; }
|
||||
return static_cast<float>(height()) / static_cast<float>(m_config->world.heightTiles);
|
||||
}
|
||||
|
||||
float GameWorldView::viewportWidthTiles() const
|
||||
float GameWorldView::getViewportWidthTiles() const
|
||||
{
|
||||
return static_cast<float>(width()) / tilePx();
|
||||
return static_cast<float>(width()) / getTilePx();
|
||||
}
|
||||
|
||||
float GameWorldView::viewLeftTiles() const
|
||||
float GameWorldView::getViewLeftTiles() const
|
||||
{
|
||||
return m_scrollXTiles - viewportWidthTiles() / 2.0f;
|
||||
return m_scrollXTiles - getViewportWidthTiles() / 2.0f;
|
||||
}
|
||||
|
||||
QPointF GameWorldView::worldToWidget(QVector2D worldPos) const
|
||||
{
|
||||
return QPointF(
|
||||
static_cast<qreal>((worldPos.x() - viewLeftTiles()) * tilePx()),
|
||||
static_cast<qreal>(worldPos.y() * tilePx()));
|
||||
static_cast<qreal>((worldPos.x() - getViewLeftTiles()) * getTilePx()),
|
||||
static_cast<qreal>(worldPos.y() * getTilePx()));
|
||||
}
|
||||
|
||||
QPointF GameWorldView::tileToWidget(QPoint tile) const
|
||||
@@ -463,15 +463,15 @@ QPointF GameWorldView::tileToWidget(QPoint tile) const
|
||||
|
||||
QPoint GameWorldView::widgetToTile(QPoint widgetPt) const
|
||||
{
|
||||
const float wx = static_cast<float>(widgetPt.x()) / tilePx() + viewLeftTiles();
|
||||
const float wy = static_cast<float>(widgetPt.y()) / tilePx();
|
||||
const float wx = static_cast<float>(widgetPt.x()) / getTilePx() + getViewLeftTiles();
|
||||
const float wy = static_cast<float>(widgetPt.y()) / getTilePx();
|
||||
return QPoint(static_cast<int>(std::floor(wx)), static_cast<int>(std::floor(wy)));
|
||||
}
|
||||
|
||||
QVector2D GameWorldView::widgetToWorld(QPoint widgetPt) const
|
||||
{
|
||||
const float wx = static_cast<float>(widgetPt.x()) / tilePx() + viewLeftTiles();
|
||||
const float wy = static_cast<float>(widgetPt.y()) / tilePx();
|
||||
const float wx = static_cast<float>(widgetPt.x()) / getTilePx() + getViewLeftTiles();
|
||||
const float wy = static_cast<float>(widgetPt.y()) / getTilePx();
|
||||
return QVector2D(wx, wy);
|
||||
}
|
||||
|
||||
@@ -479,22 +479,22 @@ QRectF GameWorldView::tileRect(QPoint tile) const
|
||||
{
|
||||
const QPointF tl = tileToWidget(tile);
|
||||
return QRectF(tl.x(), tl.y(),
|
||||
static_cast<qreal>(tilePx()), static_cast<qreal>(tilePx()));
|
||||
static_cast<qreal>(getTilePx()), static_cast<qreal>(getTilePx()));
|
||||
}
|
||||
|
||||
QRect GameWorldView::viewportRect() const
|
||||
QRect GameWorldView::getViewportRect() const
|
||||
{
|
||||
const int left = static_cast<int>(std::floor(viewLeftTiles())) - 1;
|
||||
const int left = static_cast<int>(std::floor(getViewLeftTiles())) - 1;
|
||||
const int top = 0;
|
||||
const int right = static_cast<int>(std::ceil(viewLeftTiles() + viewportWidthTiles())) + 1;
|
||||
const int right = static_cast<int>(std::ceil(getViewLeftTiles() + getViewportWidthTiles())) + 1;
|
||||
const int bottom = m_config->world.heightTiles;
|
||||
return QRect(left, top, right - left, bottom - top);
|
||||
}
|
||||
|
||||
float GameWorldView::asteroidLeftEdge() const
|
||||
float GameWorldView::getAsteroidLeftEdge() const
|
||||
{
|
||||
float leftX = -static_cast<float>(m_sim->currentAsteroidWidth_tiles());
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
float leftX = -static_cast<float>(m_sim->getCurrentAsteroidWidth_tiles());
|
||||
for (const Building& b : m_sim->getBuildings().getAllBuildings())
|
||||
{
|
||||
for (const QPoint& cell : b.bodyCells)
|
||||
{
|
||||
@@ -507,11 +507,11 @@ float GameWorldView::asteroidLeftEdge() const
|
||||
return leftX;
|
||||
}
|
||||
|
||||
float GameWorldView::enemyStationRightEdge() const
|
||||
float GameWorldView::getEnemyStationRightEdge() const
|
||||
{
|
||||
float rightX = static_cast<float>(m_config->world.regions.playerBufferWidth_tiles
|
||||
+ m_config->world.regions.contestZoneWidth_tiles);
|
||||
m_sim->admin().forEach<StationBodyComponent, FactionComponent>(
|
||||
m_sim->getAdmin().forEach<StationBodyComponent, FactionComponent>(
|
||||
[&rightX](entt::entity /*e*/, const StationBodyComponent& sb, const FactionComponent& f)
|
||||
{
|
||||
if (!f.isEnemy) { return; }
|
||||
@@ -546,7 +546,7 @@ float GameWorldView::panSpeedTilesPerSecondAt(float viewCenterXTiles) const
|
||||
const float fast = static_cast<float>(m_config->world.scroll.panSpeedFast_tps);
|
||||
const float half = static_cast<float>(m_config->world.scroll.panRampBandWidth_tiles) / 2.0f;
|
||||
const float leftEdge = static_cast<float>(m_config->world.regions.playerBufferWidth_tiles);
|
||||
const float rightEdge = enemyStationRightEdge();
|
||||
const float rightEdge = getEnemyStationRightEdge();
|
||||
|
||||
// Rising ramp at the left boundary (slow -> fast) and falling ramp at the right
|
||||
// boundary (fast -> slow); their minimum yields flat-slow outside, flat-fast in
|
||||
@@ -562,8 +562,8 @@ void GameWorldView::clampScroll()
|
||||
// m_scrollXTiles is the view center, so the pan limits are the edges themselves:
|
||||
// the view can pan left until the buildable/asteroid edge is centered, and right
|
||||
// until the enemy stations are centered (revealing a little space beyond them).
|
||||
const float leftBound = asteroidLeftEdge();
|
||||
const float rightBound = enemyStationRightEdge();
|
||||
const float leftBound = getAsteroidLeftEdge();
|
||||
const float rightBound = getEnemyStationRightEdge();
|
||||
m_scrollXTiles = std::max(leftBound, std::min(m_scrollXTiles, rightBound));
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ bool GameWorldView::isValidPlacement(BuildingType type, QPoint anchor,
|
||||
// Terrain and world-bounds validity are owned by the simulation
|
||||
// (REQ-BLD-PLACE-VALID); the presentation layer only adds the occupancy /
|
||||
// rotate-in-place check.
|
||||
if (!m_sim->buildings().isPlacementValid(type, anchor, rot))
|
||||
if (!m_sim->getBuildings().isPlacementValid(type, anchor, rot))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -598,7 +598,7 @@ bool GameWorldView::isValidPlacement(BuildingType type, QPoint anchor,
|
||||
bool anyOccupied = false;
|
||||
for (const QPoint& relCell : parsed.bodyCells)
|
||||
{
|
||||
if (m_sim->buildings().isTileOccupied(anchor + relCell))
|
||||
if (m_sim->getBuildings().isTileOccupied(anchor + relCell))
|
||||
{
|
||||
anyOccupied = true;
|
||||
break;
|
||||
@@ -607,14 +607,14 @@ bool GameWorldView::isValidPlacement(BuildingType type, QPoint anchor,
|
||||
|
||||
if (anyOccupied)
|
||||
{
|
||||
return m_sim->buildings().findRotateInPlaceTarget(type, anchor, rot).has_value();
|
||||
return m_sim->getBuildings().findRotateInPlaceTarget(type, anchor, rot).has_value();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
BuildingId GameWorldView::buildingAtTile(QPoint tile) const
|
||||
{
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
for (const Building& b : m_sim->getBuildings().getAllBuildings())
|
||||
{
|
||||
for (const QPoint& cell : b.bodyCells)
|
||||
{
|
||||
@@ -629,7 +629,7 @@ BuildingId GameWorldView::buildingAtTile(QPoint tile) const
|
||||
|
||||
BuildingId GameWorldView::siteAtTile(QPoint tile) const
|
||||
{
|
||||
for (const ConstructionSite& s : m_sim->buildings().allSites())
|
||||
for (const ConstructionSite& s : m_sim->getBuildings().getAllSites())
|
||||
{
|
||||
for (const QPoint& cell : s.bodyCells)
|
||||
{
|
||||
@@ -651,7 +651,7 @@ std::vector<BuildingId> GameWorldView::buildingsInBox(QPoint cornerA, QPoint cor
|
||||
const int y1 = std::max(cornerA.y(), cornerB.y());
|
||||
|
||||
std::vector<BuildingId> ids;
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
for (const Building& b : m_sim->getBuildings().getAllBuildings())
|
||||
{
|
||||
for (const QPoint& cell : b.bodyCells)
|
||||
{
|
||||
@@ -663,7 +663,7 @@ std::vector<BuildingId> GameWorldView::buildingsInBox(QPoint cornerA, QPoint cor
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const ConstructionSite& s : m_sim->buildings().allSites())
|
||||
for (const ConstructionSite& s : m_sim->getBuildings().getAllSites())
|
||||
{
|
||||
for (const QPoint& cell : s.bodyCells)
|
||||
{
|
||||
@@ -680,11 +680,11 @@ std::vector<BuildingId> GameWorldView::buildingsInBox(QPoint cornerA, QPoint cor
|
||||
|
||||
std::optional<QVector2D> GameWorldView::entityPosition(entt::entity entity) const
|
||||
{
|
||||
if (!m_sim->admin().isValid(entity) || !m_sim->admin().hasAll<PositionComponent>(entity))
|
||||
if (!m_sim->getAdmin().isValid(entity) || !m_sim->getAdmin().hasAll<PositionComponent>(entity))
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
return m_sim->admin().get<PositionComponent>(entity).value;
|
||||
return m_sim->getAdmin().get<PositionComponent>(entity).value;
|
||||
}
|
||||
|
||||
void GameWorldView::clearScrapSelection()
|
||||
@@ -700,7 +700,7 @@ void GameWorldView::pruneDespawnedScrap()
|
||||
if (m_selectedScrap.empty()) { return; }
|
||||
|
||||
std::vector<entt::entity> live;
|
||||
for (const ScrapInfo& info : m_sim->scraps().allScrapInfo())
|
||||
for (const ScrapInfo& info : m_sim->getScraps().getAllScrapInfo())
|
||||
{
|
||||
if (std::find(m_selectedScrap.begin(), m_selectedScrap.end(), info.entity)
|
||||
!= m_selectedScrap.end())
|
||||
@@ -747,7 +747,7 @@ void GameWorldView::placeBlueprintAtTile(QPoint center)
|
||||
int totalCost = 0;
|
||||
for (const BlueprintBuilding& bb : bp.buildings)
|
||||
{
|
||||
if (m_sim->buildings().findRotateInPlaceTarget(
|
||||
if (m_sim->getBuildings().findRotateInPlaceTarget(
|
||||
bb.type, center + bb.offset, bb.rotation).has_value())
|
||||
{
|
||||
continue;
|
||||
@@ -755,13 +755,13 @@ void GameWorldView::placeBlueprintAtTile(QPoint center)
|
||||
const BuildingDef* def = findBuildingDef(bb.type);
|
||||
if (def) { totalCost += def->cost; }
|
||||
}
|
||||
if (m_sim->buildingBlocksStock() < totalCost) { return; }
|
||||
if (m_sim->getBuildingBlocksStock() < totalCost) { return; }
|
||||
|
||||
for (const BlueprintBuilding& bb : bp.buildings)
|
||||
{
|
||||
const QPoint anchor = center + bb.offset;
|
||||
const std::optional<BuildingId> rotateTarget =
|
||||
m_sim->buildings().findRotateInPlaceTarget(bb.type, anchor, bb.rotation);
|
||||
m_sim->getBuildings().findRotateInPlaceTarget(bb.type, anchor, bb.rotation);
|
||||
if (rotateTarget.has_value())
|
||||
{
|
||||
std::shared_ptr<RotateInPlaceCommand> rotateCommand =
|
||||
@@ -832,7 +832,7 @@ void GameWorldView::placeAtTile(QPoint tile)
|
||||
}
|
||||
|
||||
const std::optional<BuildingId> rotateTarget =
|
||||
m_sim->buildings().findRotateInPlaceTarget(type, tile, m_ghostRotation);
|
||||
m_sim->getBuildings().findRotateInPlaceTarget(type, tile, m_ghostRotation);
|
||||
if (rotateTarget.has_value())
|
||||
{
|
||||
std::shared_ptr<RotateInPlaceCommand> command =
|
||||
@@ -853,7 +853,7 @@ void GameWorldView::placeAtTile(QPoint tile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!m_sim->buildings().isTileOccupied(tile) && canAfford(type))
|
||||
if (!m_sim->getBuildings().isTileOccupied(tile) && canAfford(type))
|
||||
{
|
||||
enqueuePlaceBuilding(type, tile, m_ghostRotation);
|
||||
m_beltDragTiles.insert(tile);
|
||||
@@ -863,7 +863,7 @@ void GameWorldView::placeAtTile(QPoint tile)
|
||||
|| type == BuildingType::TunnelEntry
|
||||
|| type == BuildingType::TunnelExit)
|
||||
{
|
||||
if (!m_sim->buildings().isTileOccupied(tile) && canAfford(type))
|
||||
if (!m_sim->getBuildings().isTileOccupied(tile) && canAfford(type))
|
||||
{
|
||||
enqueuePlaceBuilding(type, tile, m_ghostRotation);
|
||||
if (type == BuildingType::TunnelEntry)
|
||||
@@ -889,7 +889,7 @@ void GameWorldView::placeAtTile(QPoint tile)
|
||||
void GameWorldView::drawPortGlyph(QPainter& painter, QPoint bodyTile,
|
||||
Rotation direction, const QColor& color)
|
||||
{
|
||||
const float px = tilePx();
|
||||
const float px = getTilePx();
|
||||
const QRectF tr = tileRect(bodyTile);
|
||||
const QPointF center(tr.x() + static_cast<qreal>(px) * 0.5,
|
||||
tr.y() + static_cast<qreal>(px) * 0.5);
|
||||
@@ -922,13 +922,13 @@ void GameWorldView::drawPortGlyph(QPainter& painter, QPoint bodyTile,
|
||||
|
||||
void GameWorldView::drawTiles(QPainter& painter)
|
||||
{
|
||||
const int leftTile = static_cast<int>(std::floor(viewLeftTiles())) - 1;
|
||||
const int rightTile = leftTile + static_cast<int>(std::ceil(viewportWidthTiles())) + 2;
|
||||
const int leftTile = static_cast<int>(std::floor(getViewLeftTiles())) - 1;
|
||||
const int rightTile = leftTile + static_cast<int>(std::ceil(getViewportWidthTiles())) + 2;
|
||||
const int bottomTile = m_config->world.heightTiles;
|
||||
|
||||
// Asteroid columns left of the buildable edge are not yet unlocked by
|
||||
// expansion; tint them so the player sees the reachable-but-locked area.
|
||||
const int buildableLeftX = -m_sim->currentAsteroidWidth_tiles();
|
||||
const int buildableLeftX = -m_sim->getCurrentAsteroidWidth_tiles();
|
||||
|
||||
painter.setPen(Qt::NoPen);
|
||||
for (int x = leftTile; x <= rightTile; ++x)
|
||||
@@ -951,7 +951,7 @@ void GameWorldView::drawTiles(QPainter& painter)
|
||||
|
||||
void GameWorldView::drawBuildings(QPainter& painter)
|
||||
{
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
for (const Building& b : m_sim->getBuildings().getAllBuildings())
|
||||
{
|
||||
const std::map<BuildingType, BuildingVisuals>::const_iterator it =
|
||||
m_visuals->buildings.find(b.type);
|
||||
@@ -966,8 +966,8 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
|
||||
const QPointF tl = tileToWidget(b.anchor);
|
||||
const QRectF bboxRect(tl.x(), tl.y(),
|
||||
b.footprint.width() * static_cast<qreal>(tilePx()),
|
||||
b.footprint.height() * static_cast<qreal>(tilePx()));
|
||||
b.footprint.width() * static_cast<qreal>(getTilePx()),
|
||||
b.footprint.height() * static_cast<qreal>(getTilePx()));
|
||||
|
||||
painter.setPen(QPen(bv.outline, 1));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
@@ -988,7 +988,7 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
// HP bar below the HQ footprint; the HQ's HP lives on its proxy entity.
|
||||
if (b.type == BuildingType::Hq)
|
||||
{
|
||||
m_sim->admin().forEach<HqProxyComponent, FactionComponent, HealthComponent>(
|
||||
m_sim->getAdmin().forEach<HqProxyComponent, FactionComponent, HealthComponent>(
|
||||
[&](entt::entity /*e*/, const HqProxyComponent& /*hq*/,
|
||||
const FactionComponent& f, const HealthComponent& h)
|
||||
{
|
||||
@@ -1002,7 +1002,7 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
}
|
||||
|
||||
painter.setOpacity(0.5);
|
||||
for (const ConstructionSite& s : m_sim->buildings().allSites())
|
||||
for (const ConstructionSite& s : m_sim->getBuildings().getAllSites())
|
||||
{
|
||||
const std::map<BuildingType, BuildingVisuals>::const_iterator it =
|
||||
m_visuals->buildings.find(s.type);
|
||||
@@ -1016,8 +1016,8 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
|
||||
const QPointF tl = tileToWidget(s.anchor);
|
||||
const QRectF bboxRect(tl.x(), tl.y(),
|
||||
s.footprint.width() * static_cast<qreal>(tilePx()),
|
||||
s.footprint.height() * static_cast<qreal>(tilePx()));
|
||||
s.footprint.width() * static_cast<qreal>(getTilePx()),
|
||||
s.footprint.height() * static_cast<qreal>(getTilePx()));
|
||||
painter.setPen(QPen(bv.outline, 1, Qt::DashLine));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
painter.drawRect(bboxRect);
|
||||
@@ -1030,7 +1030,7 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
int pct = 0;
|
||||
if (s.completesAt > 0 && durationTicks > 0)
|
||||
{
|
||||
const Tick elapsed = m_sim->currentTick()
|
||||
const Tick elapsed = m_sim->getCurrentTick()
|
||||
- (s.completesAt - durationTicks);
|
||||
pct = static_cast<int>(
|
||||
std::max(Tick(0), std::min(durationTicks, elapsed))
|
||||
@@ -1079,12 +1079,12 @@ std::optional<QRectF> GameWorldView::footprintWidgetRect(BuildingId id) const
|
||||
std::optional<QPoint> anchor;
|
||||
std::optional<QSize> footprint;
|
||||
|
||||
if (const Building* b = m_sim->buildings().findBuilding(id))
|
||||
if (const Building* b = m_sim->getBuildings().findBuilding(id))
|
||||
{
|
||||
anchor = b->anchor;
|
||||
footprint = b->footprint;
|
||||
}
|
||||
else if (const ConstructionSite* s = m_sim->buildings().findSite(id))
|
||||
else if (const ConstructionSite* s = m_sim->getBuildings().findSite(id))
|
||||
{
|
||||
anchor = s->anchor;
|
||||
footprint = s->footprint;
|
||||
@@ -1093,8 +1093,8 @@ std::optional<QRectF> GameWorldView::footprintWidgetRect(BuildingId id) const
|
||||
|
||||
const QPointF tl = tileToWidget(*anchor);
|
||||
return QRectF(tl.x(), tl.y(),
|
||||
footprint->width() * static_cast<qreal>(tilePx()),
|
||||
footprint->height() * static_cast<qreal>(tilePx()));
|
||||
footprint->width() * static_cast<qreal>(getTilePx()),
|
||||
footprint->height() * static_cast<qreal>(getTilePx()));
|
||||
}
|
||||
|
||||
void GameWorldView::drawSelectionHighlights(QPainter& painter)
|
||||
@@ -1111,11 +1111,11 @@ void GameWorldView::drawSelectionHighlights(QPainter& painter)
|
||||
}
|
||||
|
||||
// A ring around each selected scrap pile, sitting just outside the pile's
|
||||
// rendered circle (radius tilePx()*0.2, matching drawScrap) (REQ-UI-SCRAP-CLICK-SELECT).
|
||||
// rendered circle (radius getTilePx()*0.2, matching drawScrap) (REQ-UI-SCRAP-CLICK-SELECT).
|
||||
if (!m_selectedScrap.empty())
|
||||
{
|
||||
const qreal outlineRadius = static_cast<qreal>(tilePx() * 0.2f) + 3.0;
|
||||
for (const ScrapInfo& scrap : m_sim->scraps().allScrapInfo())
|
||||
const qreal outlineRadius = static_cast<qreal>(getTilePx() * 0.2f) + 3.0;
|
||||
for (const ScrapInfo& scrap : m_sim->getScraps().getAllScrapInfo())
|
||||
{
|
||||
if (std::find(m_selectedScrap.begin(), m_selectedScrap.end(), scrap.entity)
|
||||
== m_selectedScrap.end()) { continue; }
|
||||
@@ -1136,13 +1136,13 @@ void GameWorldView::drawCopyConfigFeedback(QPainter& painter)
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(color);
|
||||
const BuildingType type = m_copiedConfig->type;
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
for (const Building& b : m_sim->getBuildings().getAllBuildings())
|
||||
{
|
||||
if (b.type != type) { continue; }
|
||||
const std::optional<QRectF> rect = footprintWidgetRect(b.id);
|
||||
if (rect.has_value()) { painter.drawRect(*rect); }
|
||||
}
|
||||
for (const ConstructionSite& s : m_sim->buildings().allSites())
|
||||
for (const ConstructionSite& s : m_sim->getBuildings().getAllSites())
|
||||
{
|
||||
if (s.type != type) { continue; }
|
||||
const std::optional<QRectF> rect = footprintWidgetRect(s.id);
|
||||
@@ -1163,7 +1163,7 @@ void GameWorldView::drawCopyConfigFeedback(QPainter& painter)
|
||||
|
||||
void GameWorldView::drawPortItems(QPainter& painter)
|
||||
{
|
||||
const float halfPx = tilePx() * 0.5f * 0.5f;
|
||||
const float halfPx = getTilePx() * 0.5f * 0.5f;
|
||||
|
||||
// Port items are drawn over the buildings (drawBuildings runs first) but clipped
|
||||
// to a thin margin at each machine's edges: the clip region is the whole view
|
||||
@@ -1174,10 +1174,10 @@ void GameWorldView::drawPortItems(QPainter& painter)
|
||||
// (REQ-MAT-DIRECT-COUPLE). Transport tiles are not machines and never occlude, so
|
||||
// items on belts stay fully visible.
|
||||
constexpr double kPortMarginTiles = 0.2;
|
||||
const double margin = kPortMarginTiles * static_cast<double>(tilePx());
|
||||
const double margin = kPortMarginTiles * static_cast<double>(getTilePx());
|
||||
|
||||
QRegion clip(rect());
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
for (const Building& b : m_sim->getBuildings().getAllBuildings())
|
||||
{
|
||||
if (b.type == BuildingType::Belt || b.type == BuildingType::Splitter
|
||||
|| b.type == BuildingType::TunnelEntry || b.type == BuildingType::TunnelExit)
|
||||
@@ -1218,17 +1218,17 @@ void GameWorldView::drawPortItems(QPainter& painter)
|
||||
|
||||
painter.save();
|
||||
painter.setClipRegion(clip);
|
||||
m_sim->buildings().forEachEmergingItem(drawItem);
|
||||
m_sim->buildings().forEachIncomingItem(drawItem);
|
||||
m_sim->getBuildings().forEachEmergingItem(drawItem);
|
||||
m_sim->getBuildings().forEachIncomingItem(drawItem);
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
void GameWorldView::drawBeltItems(QPainter& painter)
|
||||
{
|
||||
const float halfPx = tilePx() * 0.5f * 0.5f;
|
||||
const QRect vr = viewportRect();
|
||||
const float halfPx = getTilePx() * 0.5f * 0.5f;
|
||||
const QRect vr = getViewportRect();
|
||||
|
||||
m_sim->belts().forEachVisualItem(vr, [&](const VisualItem& vi)
|
||||
m_sim->getBelts().forEachVisualItem(vr, [&](const VisualItem& vi)
|
||||
{
|
||||
const std::map<std::string, ItemVisuals>::const_iterator it =
|
||||
m_visuals->items.find(vi.type.id);
|
||||
@@ -1248,8 +1248,8 @@ void GameWorldView::drawBeltItems(QPainter& painter)
|
||||
|
||||
void GameWorldView::drawScrap(QPainter& painter)
|
||||
{
|
||||
const float r = tilePx() * 0.2f;
|
||||
for (const ScrapInfo& scrap : m_sim->scraps().allScrapInfo())
|
||||
const float r = getTilePx() * 0.2f;
|
||||
for (const ScrapInfo& scrap : m_sim->getScraps().getAllScrapInfo())
|
||||
{
|
||||
const QPointF center = worldToWidget(scrap.position);
|
||||
painter.setBrush(QColor(128, 110, 90));
|
||||
@@ -1261,7 +1261,7 @@ void GameWorldView::drawScrap(QPainter& painter)
|
||||
|
||||
void GameWorldView::drawStations(QPainter& painter)
|
||||
{
|
||||
m_sim->admin().forEach<StationBodyComponent, FactionComponent, HealthComponent>(
|
||||
m_sim->getAdmin().forEach<StationBodyComponent, FactionComponent, HealthComponent>(
|
||||
[&](entt::entity e, const StationBodyComponent& sb, const FactionComponent& f,
|
||||
const HealthComponent& h)
|
||||
{
|
||||
@@ -1281,8 +1281,8 @@ void GameWorldView::drawStations(QPainter& painter)
|
||||
|
||||
const QPointF tl = tileToWidget(QPoint(sb.anchor.x(), sb.anchor.y()));
|
||||
const QRectF bboxRect(tl.x(), tl.y(),
|
||||
sb.footprint.width() * static_cast<qreal>(tilePx()),
|
||||
sb.footprint.height() * static_cast<qreal>(tilePx()));
|
||||
sb.footprint.width() * static_cast<qreal>(getTilePx()),
|
||||
sb.footprint.height() * static_cast<qreal>(getTilePx()));
|
||||
|
||||
painter.setPen(QPen(bv.outline, 1));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
@@ -1306,7 +1306,7 @@ void GameWorldView::drawStations(QPainter& painter)
|
||||
|
||||
void GameWorldView::drawShips(QPainter& painter)
|
||||
{
|
||||
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
|
||||
m_sim->getAdmin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
|
||||
FactionComponent, HealthComponent>(
|
||||
[&](entt::entity e, const ShipIdentityComponent& si,
|
||||
const PositionComponent& pos, const FacingComponent& facing,
|
||||
@@ -1320,8 +1320,8 @@ void GameWorldView::drawShips(QPainter& painter)
|
||||
const QVector2D dir(std::cos(facing.radians), std::sin(facing.radians));
|
||||
const QVector2D perp(-dir.y(), dir.x());
|
||||
|
||||
const float fwd = tilePx() * 0.45f;
|
||||
const float side = tilePx() * 0.25f;
|
||||
const float fwd = getTilePx() * 0.45f;
|
||||
const float side = getTilePx() * 0.25f;
|
||||
|
||||
QPolygonF tri;
|
||||
tri << QPointF(center.x() + static_cast<qreal>(dir.x() * fwd),
|
||||
@@ -1356,7 +1356,7 @@ void GameWorldView::drawShips(QPainter& painter)
|
||||
void GameWorldView::drawHpBar(QPainter& painter, qreal left, qreal top, qreal width,
|
||||
float fraction, bool isEnemy)
|
||||
{
|
||||
const qreal barH = static_cast<qreal>(tilePx()) * 0.12;
|
||||
const qreal barH = static_cast<qreal>(getTilePx()) * 0.12;
|
||||
const float clamped = std::max(0.0f, fraction);
|
||||
painter.fillRect(QRectF(left, top, width, barH), QColor(60, 60, 60));
|
||||
painter.fillRect(QRectF(left, top, width * static_cast<qreal>(clamped), barH),
|
||||
@@ -1366,7 +1366,7 @@ void GameWorldView::drawHpBar(QPainter& painter, qreal left, qreal top, qreal wi
|
||||
void GameWorldView::drawDebugSensorRanges(QPainter& painter)
|
||||
{
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
|
||||
m_sim->getAdmin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
|
||||
FactionComponent, SensorRangeComponent>(
|
||||
[&](entt::entity /*e*/, const ShipIdentityComponent& si,
|
||||
const PositionComponent& pos, const FacingComponent& /*facing*/,
|
||||
@@ -1378,7 +1378,7 @@ void GameWorldView::drawDebugSensorRanges(QPainter& painter)
|
||||
|
||||
const QPointF center = worldToWidget(pos.value);
|
||||
const qreal radiusPx = static_cast<qreal>(sensor.value_tiles)
|
||||
* static_cast<qreal>(tilePx());
|
||||
* static_cast<qreal>(getTilePx());
|
||||
QColor circleColor = it->second.outline;
|
||||
circleColor.setAlpha(77);
|
||||
painter.setPen(QPen(circleColor, 1));
|
||||
@@ -1404,7 +1404,7 @@ void GameWorldView::drawDebugTargetLines(QPainter& painter)
|
||||
painter.drawLine(worldToWidget(from), worldToWidget(to));
|
||||
};
|
||||
|
||||
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, AttackBehavior>(
|
||||
m_sim->getAdmin().forEach<ShipIdentityComponent, PositionComponent, AttackBehavior>(
|
||||
[&](entt::entity /*e*/, const ShipIdentityComponent& si,
|
||||
const PositionComponent& pos, const AttackBehavior& attack)
|
||||
{
|
||||
@@ -1417,7 +1417,7 @@ void GameWorldView::drawDebugTargetLines(QPainter& painter)
|
||||
drawTargetLine(si.schematicId, pos.value, *targetPos);
|
||||
});
|
||||
|
||||
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, RepairBehavior>(
|
||||
m_sim->getAdmin().forEach<ShipIdentityComponent, PositionComponent, RepairBehavior>(
|
||||
[&](entt::entity /*e*/, const ShipIdentityComponent& si,
|
||||
const PositionComponent& pos, const RepairBehavior& repair)
|
||||
{
|
||||
@@ -1430,7 +1430,7 @@ void GameWorldView::drawDebugTargetLines(QPainter& painter)
|
||||
drawTargetLine(si.schematicId, pos.value, *targetPos);
|
||||
});
|
||||
|
||||
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, SalvageScrapBehavior>(
|
||||
m_sim->getAdmin().forEach<ShipIdentityComponent, PositionComponent, SalvageScrapBehavior>(
|
||||
[&](entt::entity /*e*/, const ShipIdentityComponent& si,
|
||||
const PositionComponent& pos, const SalvageScrapBehavior& salvage)
|
||||
{
|
||||
@@ -1446,15 +1446,15 @@ void GameWorldView::drawDebugOverlay(QPainter& painter)
|
||||
|
||||
const QStringList lines = {
|
||||
tr("Accumulated Threat Level: %1")
|
||||
.arg(m_sim->threatLevel(), 0, 'f', 1),
|
||||
.arg(m_sim->getThreatLevel(), 0, 'f', 1),
|
||||
tr("Time until Wave: %1s")
|
||||
.arg(ticksToSeconds(m_sim->normalGapRemainingTicks()), 0, 'f', 1),
|
||||
.arg(ticksToSeconds(m_sim->getNormalGapRemainingTicks()), 0, 'f', 1),
|
||||
tr("Threat Accumulation Rate: %1 threat/s")
|
||||
.arg(m_sim->threatAccumulationRate(), 0, 'f', 1),
|
||||
.arg(m_sim->getThreatAccumulationRate(), 0, 'f', 1),
|
||||
tr("Max Factory Production: %1 threat/s")
|
||||
.arg(m_sim->maxFactoryProductionThreatRate(), 0, 'f', 1),
|
||||
.arg(m_sim->getMaxFactoryProductionThreatRate(), 0, 'f', 1),
|
||||
tr("Current Factory Production: %1 threat/s")
|
||||
.arg(m_sim->currentFactoryProductionThreatRate(), 0, 'f', 1),
|
||||
.arg(m_sim->getCurrentFactoryProductionThreatRate(), 0, 'f', 1),
|
||||
};
|
||||
|
||||
QFont font = painter.font();
|
||||
@@ -1582,12 +1582,12 @@ void GameWorldView::drawOverlays(QPainter& painter)
|
||||
{
|
||||
for (BuildingId id : buildingsInBox(m_boxStartTile, m_boxCurrentTile))
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(id);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(id);
|
||||
if (b && b->type == BuildingType::Hq) { continue; }
|
||||
const std::vector<QPoint>* cells = nullptr;
|
||||
const ConstructionSite* s = nullptr;
|
||||
if (b) { cells = &b->bodyCells; }
|
||||
else if ((s = m_sim->buildings().findSite(id))) { cells = &s->bodyCells; }
|
||||
else if ((s = m_sim->getBuildings().findSite(id))) { cells = &s->bodyCells; }
|
||||
if (cells)
|
||||
{
|
||||
for (const QPoint& cell : *cells)
|
||||
@@ -1599,7 +1599,7 @@ void GameWorldView::drawOverlays(QPainter& painter)
|
||||
}
|
||||
else if (m_demolishMode && m_demolishHoverBuildingId != kInvalidBuildingId)
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(m_demolishHoverBuildingId);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(m_demolishHoverBuildingId);
|
||||
if (b)
|
||||
{
|
||||
for (const QPoint& cell : b->bodyCells)
|
||||
@@ -1663,8 +1663,8 @@ void GameWorldView::drawBuildingGhost(QPainter& painter, BuildingType type,
|
||||
|
||||
const QPointF tl = tileToWidget(anchorTile + minCell);
|
||||
const QRectF bboxRect(tl.x(), tl.y(),
|
||||
(maxCell.x() - minCell.x() + 1) * static_cast<qreal>(tilePx()),
|
||||
(maxCell.y() - minCell.y() + 1) * static_cast<qreal>(tilePx()));
|
||||
(maxCell.x() - minCell.x() + 1) * static_cast<qreal>(getTilePx()),
|
||||
(maxCell.y() - minCell.y() + 1) * static_cast<qreal>(getTilePx()));
|
||||
|
||||
painter.setPen(QPen(lineColor, 1));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
@@ -1932,7 +1932,7 @@ void GameWorldView::mousePressEvent(QMouseEvent* event)
|
||||
}
|
||||
|
||||
const QVector2D worldPos = widgetToWorld(event->pos());
|
||||
const entt::entity hitEntity = entityAtWorldPos(m_sim->admin(), worldPos);
|
||||
const entt::entity hitEntity = entityAtWorldPos(m_sim->getAdmin(), worldPos);
|
||||
|
||||
if (hitEntity != entt::null)
|
||||
{
|
||||
@@ -1983,7 +1983,7 @@ void GameWorldView::mousePressEvent(QMouseEvent* event)
|
||||
std::make_shared<SelectionChangedEvent>(m_selectedBuildingIds));
|
||||
}
|
||||
else if (const entt::entity scrapHit =
|
||||
scrapAtWorldPos(m_sim->admin(), worldPos); scrapHit != entt::null)
|
||||
scrapAtWorldPos(m_sim->getAdmin(), worldPos); scrapHit != entt::null)
|
||||
{
|
||||
// Scrap forms its own selection category; picking it clears any
|
||||
// building selection (REQ-UI-SCRAP-CLICK-SELECT, REQ-UI-SCRAP-MULTI-SELECT).
|
||||
@@ -2081,7 +2081,7 @@ void GameWorldView::mouseReleaseEvent(QMouseEvent* event)
|
||||
// (REQ-BLD-DEMOLISH, REQ-BLD-DEMOLISH-BOX).
|
||||
for (BuildingId id : boxIds)
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(id);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(id);
|
||||
if (b && b->type == BuildingType::Hq) { continue; }
|
||||
std::shared_ptr<DemolishCommand> command =
|
||||
std::make_shared<DemolishCommand>();
|
||||
@@ -2123,7 +2123,7 @@ void GameWorldView::mouseReleaseEvent(QMouseEvent* event)
|
||||
// No buildings in the box: a scrap-only box selects the scrap it covers
|
||||
// (REQ-UI-SCRAP-MULTI-SELECT).
|
||||
const std::vector<entt::entity> boxScrap =
|
||||
scrapInBox(m_sim->admin(), m_boxStartTile, m_boxCurrentTile);
|
||||
scrapInBox(m_sim->getAdmin(), m_boxStartTile, m_boxCurrentTile);
|
||||
if (!boxScrap.empty())
|
||||
{
|
||||
if (!m_selectedBuildingIds.empty())
|
||||
@@ -2260,7 +2260,7 @@ void GameWorldView::pasteConfigTo(BuildingId id)
|
||||
{
|
||||
// Operational splitters are configured by tile; sites by BuildingId
|
||||
// (mirrors SelectedBuildingPanel::onSplitterFilterChanged).
|
||||
if (const Building* building = m_sim->buildings().findBuilding(id))
|
||||
if (const Building* building = m_sim->getBuildings().findBuilding(id))
|
||||
{
|
||||
std::shared_ptr<SetSplitterFiltersCommand> command =
|
||||
std::make_shared<SetSplitterFiltersCommand>();
|
||||
@@ -2338,7 +2338,7 @@ void GameWorldView::exitBuilderMode()
|
||||
std::make_shared<BuilderModeExitedEvent>());
|
||||
}
|
||||
|
||||
double GameWorldView::gameSpeed() const
|
||||
double GameWorldView::getGameSpeed() const
|
||||
{
|
||||
return m_gameSpeedMultiplier;
|
||||
}
|
||||
@@ -2402,17 +2402,17 @@ void GameWorldView::handleEvent(std::shared_ptr<const BeamFiredEvent> event)
|
||||
{
|
||||
// Endpoint offset is a fraction of the target's visual size (REQ-SHP-FIRING-BEAM):
|
||||
// half a ship's rendered radius, half a station's shorter footprint side, or
|
||||
// half a scrap pile's rendered radius (scrap is drawn at tilePx()*0.2).
|
||||
// half a scrap pile's rendered radius (scrap is drawn at getTilePx()*0.2).
|
||||
float maxRadius = 0.125f;
|
||||
if (m_sim->admin().isValid(event->target)
|
||||
&& m_sim->admin().hasAll<StationBodyComponent>(event->target))
|
||||
if (m_sim->getAdmin().isValid(event->target)
|
||||
&& m_sim->getAdmin().hasAll<StationBodyComponent>(event->target))
|
||||
{
|
||||
const StationBodyComponent& sb = m_sim->admin().get<StationBodyComponent>(event->target);
|
||||
const StationBodyComponent& sb = m_sim->getAdmin().get<StationBodyComponent>(event->target);
|
||||
const int shorter = std::min(sb.footprint.width(), sb.footprint.height());
|
||||
maxRadius = shorter / 2.0f;
|
||||
}
|
||||
else if (m_sim->admin().isValid(event->target)
|
||||
&& m_sim->admin().hasAll<ScrapDataComponent>(event->target))
|
||||
else if (m_sim->getAdmin().isValid(event->target)
|
||||
&& m_sim->getAdmin().hasAll<ScrapDataComponent>(event->target))
|
||||
{
|
||||
maxRadius = 0.1f;
|
||||
}
|
||||
@@ -2488,5 +2488,5 @@ bool GameWorldView::canAfford(BuildingType type) const
|
||||
{
|
||||
const BuildingDef* def = findBuildingDef(type);
|
||||
if (!def) { return false; }
|
||||
return m_sim->buildingBlocksStock() >= def->cost;
|
||||
return m_sim->getBuildingBlocksStock() >= def->cost;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
const ParsedReplay* replay, QWidget* parent = nullptr);
|
||||
~GameWorldView() override;
|
||||
|
||||
double gameSpeed() const;
|
||||
double getGameSpeed() const;
|
||||
bool isDebugDrawEnabled() const;
|
||||
void resetFrameTimer();
|
||||
void setGameSpeed(double multiplier);
|
||||
@@ -133,23 +133,23 @@ private:
|
||||
void drawScreenSpace(QPainter& painter);
|
||||
void drawReplayOverlay(QPainter& painter);
|
||||
|
||||
float tilePx() const;
|
||||
float viewportWidthTiles() const;
|
||||
float getTilePx() const;
|
||||
float getViewportWidthTiles() const;
|
||||
// World-X (tiles) at the left edge of the viewport. m_scrollXTiles stores the
|
||||
// view center; this derives the left edge the world<->widget conversions need.
|
||||
float viewLeftTiles() const;
|
||||
float getViewLeftTiles() const;
|
||||
QPointF worldToWidget(QVector2D worldPos) const;
|
||||
QPointF tileToWidget(QPoint tile) const;
|
||||
QPoint widgetToTile(QPoint widgetPt) const;
|
||||
QRectF tileRect(QPoint tile) const;
|
||||
QRect viewportRect() const;
|
||||
QRect getViewportRect() const;
|
||||
// Widget-space rectangle covering a building or construction site's footprint,
|
||||
// or nullopt if the id resolves to neither. Shared by the selection highlight
|
||||
// and the copy-settings feedback (REQ-BLD-COPY-CONFIG-FEEDBACK).
|
||||
std::optional<QRectF> footprintWidgetRect(BuildingId id) const;
|
||||
|
||||
float asteroidLeftEdge() const;
|
||||
float enemyStationRightEdge() const;
|
||||
float getAsteroidLeftEdge() const;
|
||||
float getEnemyStationRightEdge() const;
|
||||
// Horizontal pan speed at a given view-center X, in tiles/s (REQ-UI-SCROLL-SPEED).
|
||||
float panSpeedTilesPerSecondAt(float viewCenterXTiles) const;
|
||||
void clampScroll();
|
||||
@@ -222,7 +222,7 @@ private:
|
||||
std::mt19937 m_rng;
|
||||
double m_gameSpeedMultiplier;
|
||||
double m_prevNonZeroSpeed;
|
||||
// World-X (tiles) at the center of the viewport (see viewLeftTiles()).
|
||||
// World-X (tiles) at the center of the viewport (see getViewLeftTiles()).
|
||||
float m_scrollXTiles;
|
||||
|
||||
QTimer* m_renderTimer;
|
||||
|
||||
@@ -42,9 +42,9 @@ MainWindow::MainWindow(Simulation* sim, const std::string& configDir,
|
||||
setWindowTitle(tr("Dota Factory"));
|
||||
resize(1280, 768);
|
||||
|
||||
m_headerBar = new HeaderBar(&sim->config(), this);
|
||||
m_headerBar = new HeaderBar(&sim->getConfig(), this);
|
||||
|
||||
m_gameWorldView = new GameWorldView(sim, &sim->config(), &m_visuals, m_configDir,
|
||||
m_gameWorldView = new GameWorldView(sim, &sim->getConfig(), &m_visuals, m_configDir,
|
||||
m_replay.get(), this);
|
||||
|
||||
m_sidePanel = new QWidget(this);
|
||||
@@ -52,9 +52,9 @@ MainWindow::MainWindow(Simulation* sim, const std::string& configDir,
|
||||
sideLayout->setContentsMargins(1, 1, 1, 1);
|
||||
sideLayout->setSpacing(1);
|
||||
|
||||
m_selectedBuildingPanel = new SelectedBuildingPanel(sim, &sim->config(), m_sidePanel);
|
||||
m_buildButtonGrid = new BuildButtonGrid(&sim->config(), m_sidePanel);
|
||||
m_blueprintPanel = new BlueprintPanel(sim, &sim->config(), m_sidePanel);
|
||||
m_selectedBuildingPanel = new SelectedBuildingPanel(sim, &sim->getConfig(), m_sidePanel);
|
||||
m_buildButtonGrid = new BuildButtonGrid(&sim->getConfig(), m_sidePanel);
|
||||
m_blueprintPanel = new BlueprintPanel(sim, &sim->getConfig(), m_sidePanel);
|
||||
|
||||
sideLayout->addWidget(m_selectedBuildingPanel, 1);
|
||||
sideLayout->addWidget(m_buildButtonGrid, 1);
|
||||
@@ -158,11 +158,11 @@ void MainWindow::handleEvent(std::shared_ptr<const BuildingBlocksChangedEvent> e
|
||||
|
||||
void MainWindow::handleEvent(std::shared_ptr<const SchematicChoicesAvailableEvent> event)
|
||||
{
|
||||
const double prevSpeed = m_gameWorldView->gameSpeed();
|
||||
const double prevSpeed = m_gameWorldView->getGameSpeed();
|
||||
m_gameWorldView->setGameSpeed(0.0);
|
||||
|
||||
ModalDimScope dim(*m_dimOverlay);
|
||||
SchematicChoiceDialog dialog(event->choices, m_sim->config().recipes, this);
|
||||
SchematicChoiceDialog dialog(event->choices, m_sim->getConfig().recipes, this);
|
||||
dialog.exec();
|
||||
|
||||
std::shared_ptr<ApplySchematicChoiceCommand> command =
|
||||
@@ -177,7 +177,7 @@ void MainWindow::handleEvent(std::shared_ptr<const SchematicChoicesAvailableEven
|
||||
|
||||
void MainWindow::handleEvent(std::shared_ptr<const EscapeMenuRequestedEvent> /*event*/)
|
||||
{
|
||||
const double prevSpeed = m_gameWorldView->gameSpeed();
|
||||
const double prevSpeed = m_gameWorldView->getGameSpeed();
|
||||
m_gameWorldView->setGameSpeed(0.0);
|
||||
|
||||
ModalDimScope dim(*m_dimOverlay);
|
||||
@@ -232,11 +232,11 @@ void MainWindow::openShipLayoutDialog(BuildingId shipyardId,
|
||||
const std::string& schematicId,
|
||||
const ShipLayoutConfig& currentLayout)
|
||||
{
|
||||
const double prevSpeed = m_gameWorldView->gameSpeed();
|
||||
const double prevSpeed = m_gameWorldView->getGameSpeed();
|
||||
m_gameWorldView->setGameSpeed(0.0);
|
||||
|
||||
std::set<std::string> unlockedModuleIds;
|
||||
for (const ModuleDef& def : m_sim->config().modules.modules)
|
||||
for (const ModuleDef& def : m_sim->getConfig().modules.modules)
|
||||
{
|
||||
if (m_sim->isModuleSchematicUnlocked(def.id))
|
||||
{
|
||||
@@ -245,17 +245,17 @@ void MainWindow::openShipLayoutDialog(BuildingId shipyardId,
|
||||
}
|
||||
|
||||
ModalDimScope dim(*m_dimOverlay);
|
||||
ShipLayoutDialog dialog(&m_sim->config(), schematicId, currentLayout,
|
||||
ShipLayoutDialog dialog(&m_sim->getConfig(), schematicId, currentLayout,
|
||||
m_layoutBlueprints,
|
||||
std::move(unlockedModuleIds),
|
||||
m_gameWorldView->isDebugDrawEnabled(),
|
||||
this);
|
||||
if (dialog.exec() == QDialog::Accepted && dialog.result().has_value())
|
||||
if (dialog.exec() == QDialog::Accepted && dialog.getResult().has_value())
|
||||
{
|
||||
std::shared_ptr<SetShipLayoutCommand> command =
|
||||
std::make_shared<SetShipLayoutCommand>();
|
||||
command->id = shipyardId;
|
||||
command->layout = *dialog.result();
|
||||
command->layout = *dialog.getResult();
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<CommandRequestedEvent>(command));
|
||||
}
|
||||
@@ -268,9 +268,9 @@ void MainWindow::handleEvent(std::shared_ptr<const LayoutDialogRequestedEvent> e
|
||||
{
|
||||
// A construction site has no Building yet; fall back to its site record so
|
||||
// the shipyard layout can be configured before it is built (REQ-BLD-SITE-CONFIG).
|
||||
const Building* b = m_sim->buildings().findBuilding(event->shipyardId);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(event->shipyardId);
|
||||
const ConstructionSite* s =
|
||||
b ? nullptr : m_sim->buildings().findSite(event->shipyardId);
|
||||
b ? nullptr : m_sim->getBuildings().findSite(event->shipyardId);
|
||||
if (!b && !s)
|
||||
{
|
||||
return;
|
||||
@@ -291,14 +291,14 @@ void MainWindow::handleEvent(std::shared_ptr<const LayoutDialogRequestedEvent> e
|
||||
|
||||
void MainWindow::handleEvent(std::shared_ptr<const RecipeSelectionRequestedEvent> event)
|
||||
{
|
||||
const double prevSpeed = m_gameWorldView->gameSpeed();
|
||||
const double prevSpeed = m_gameWorldView->getGameSpeed();
|
||||
m_gameWorldView->setGameSpeed(0.0);
|
||||
|
||||
// A construction site has no Building yet; fall back to its site record so
|
||||
// the recipe/schematic can be chosen before it is built (REQ-BLD-SITE-CONFIG).
|
||||
const Building* b = m_sim->buildings().findBuilding(event->buildingId);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(event->buildingId);
|
||||
const ConstructionSite* s =
|
||||
b ? nullptr : m_sim->buildings().findSite(event->buildingId);
|
||||
b ? nullptr : m_sim->getBuildings().findSite(event->buildingId);
|
||||
if (!b && !s)
|
||||
{
|
||||
m_gameWorldView->setGameSpeed(prevSpeed);
|
||||
@@ -316,7 +316,7 @@ void MainWindow::handleEvent(std::shared_ptr<const RecipeSelectionRequestedEvent
|
||||
// dereferenced after dialog.exec() returns.
|
||||
const std::string oldSchematic = b ? b->recipeId : s->recipeId;
|
||||
const std::vector<RecipeSelectionOption> options =
|
||||
buildRecipeSelectionOptions(type, *m_sim, m_sim->config());
|
||||
buildRecipeSelectionOptions(type, *m_sim, m_sim->getConfig());
|
||||
const QString title = (type == BuildingType::Shipyard)
|
||||
? tr("Select Schematic")
|
||||
: tr("Select Recipe");
|
||||
@@ -356,7 +356,7 @@ void MainWindow::handleEvent(std::shared_ptr<const RecipeSelectionRequestedEvent
|
||||
|
||||
void MainWindow::handleEvent(std::shared_ptr<const GameOverEvent> /*event*/)
|
||||
{
|
||||
const Tick tick = m_sim->currentTick();
|
||||
const Tick tick = m_sim->getCurrentTick();
|
||||
const int totalSeconds = static_cast<int>(ticksToSeconds(tick));
|
||||
const int minutes = totalSeconds / 60;
|
||||
const int seconds = totalSeconds % 60;
|
||||
@@ -403,7 +403,7 @@ void MainWindow::handleEvent(std::shared_ptr<const GameOverEvent> /*event*/)
|
||||
|
||||
void MainWindow::handleEvent(std::shared_ptr<const WinEvent> /*event*/)
|
||||
{
|
||||
const Tick tick = m_sim->currentTick();
|
||||
const Tick tick = m_sim->getCurrentTick();
|
||||
const int totalSeconds = static_cast<int>(ticksToSeconds(tick));
|
||||
const int minutes = totalSeconds / 60;
|
||||
const int seconds = totalSeconds % 60;
|
||||
|
||||
@@ -274,8 +274,8 @@ void SelectedBuildingPanel::buildSingle(BuildingId id)
|
||||
m_singleBuildingId = id;
|
||||
hideAllWidgets();
|
||||
|
||||
const Building* b = m_sim->buildings().findBuilding(id);
|
||||
const ConstructionSite* s = b ? nullptr : m_sim->buildings().findSite(id);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(id);
|
||||
const ConstructionSite* s = b ? nullptr : m_sim->getBuildings().findSite(id);
|
||||
if (!b && !s)
|
||||
{
|
||||
buildEmpty();
|
||||
@@ -353,12 +353,12 @@ void SelectedBuildingPanel::buildSingle(BuildingId id)
|
||||
std::optional<BeltSystem::SplitterInfo> info;
|
||||
if (m_singleIsSite)
|
||||
{
|
||||
info = m_sim->buildings().getSiteSplitterInfo(id);
|
||||
info = m_sim->getBuildings().getSiteSplitterInfo(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_splitterTile = anchor;
|
||||
info = m_sim->belts().getSplitterInfo(m_splitterTile);
|
||||
info = m_sim->getBelts().getSplitterInfo(m_splitterTile);
|
||||
}
|
||||
buildSplitterFilters(info);
|
||||
}
|
||||
@@ -397,7 +397,7 @@ void SelectedBuildingPanel::refreshSiteProgress(const ConstructionSite* s)
|
||||
if (def && def->constructionTimeSeconds > 0)
|
||||
{
|
||||
const Tick duration = secondsToTicks(def->constructionTimeSeconds);
|
||||
const Tick elapsed = m_sim->currentTick() - (s->completesAt - duration);
|
||||
const Tick elapsed = m_sim->getCurrentTick() - (s->completesAt - duration);
|
||||
const int pct = static_cast<int>(
|
||||
std::max(Tick(0), std::min(duration, elapsed)) * 100 / duration);
|
||||
progress = tr("%1% complete").arg(pct);
|
||||
@@ -554,7 +554,7 @@ void SelectedBuildingPanel::refreshBuffers(const Building* b)
|
||||
{
|
||||
const Tick cycleTicks = secondsToTicks(durationSeconds);
|
||||
const Tick completesAt = b->production->completesAt;
|
||||
const Tick currentTick = m_sim->currentTick();
|
||||
const Tick currentTick = m_sim->getCurrentTick();
|
||||
const Tick elapsed = currentTick - (completesAt - cycleTicks);
|
||||
const int pct = static_cast<int>(
|
||||
std::max(Tick(0), std::min(cycleTicks, elapsed)) * 100 / cycleTicks);
|
||||
@@ -673,7 +673,7 @@ void SelectedBuildingPanel::refreshSelectionDisplay(RefreshReason reason)
|
||||
}
|
||||
|
||||
if (m_singleBuildingId == kInvalidBuildingId) { return; }
|
||||
const Building* b = m_sim->buildings().findBuilding(m_singleBuildingId);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(m_singleBuildingId);
|
||||
if (b)
|
||||
{
|
||||
if (m_titleLabel->text().startsWith(tr("(Building) ")))
|
||||
@@ -686,7 +686,7 @@ void SelectedBuildingPanel::refreshSelectionDisplay(RefreshReason reason)
|
||||
}
|
||||
return;
|
||||
}
|
||||
const ConstructionSite* s = m_sim->buildings().findSite(m_singleBuildingId);
|
||||
const ConstructionSite* s = m_sim->getBuildings().findSite(m_singleBuildingId);
|
||||
if (s)
|
||||
{
|
||||
// A periodic tick only advances construction progress, so update just the
|
||||
@@ -720,13 +720,13 @@ void SelectedBuildingPanel::buildMulti(const std::vector<BuildingId>& ids)
|
||||
std::map<BuildingType, int> counts;
|
||||
for (BuildingId id : ids)
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(id);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(id);
|
||||
if (b)
|
||||
{
|
||||
counts[b->type]++;
|
||||
continue;
|
||||
}
|
||||
const ConstructionSite* s = m_sim->buildings().findSite(id);
|
||||
const ConstructionSite* s = m_sim->getBuildings().findSite(id);
|
||||
if (s)
|
||||
{
|
||||
counts[s->type]++;
|
||||
@@ -791,7 +791,7 @@ void SelectedBuildingPanel::buildSplitterFilters(
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string> items = allItemIds();
|
||||
const std::vector<std::string> items = getAllItemIds();
|
||||
|
||||
auto populateList = [&](QListWidget* list, QLabel* label,
|
||||
const QString& dirLabel,
|
||||
@@ -866,7 +866,7 @@ void SelectedBuildingPanel::onSplitterFilterChanged()
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> SelectedBuildingPanel::allItemIds() const
|
||||
std::vector<std::string> SelectedBuildingPanel::getAllItemIds() const
|
||||
{
|
||||
std::set<std::string> seen;
|
||||
for (const RecipeDef& recipe : m_config->recipes.recipes)
|
||||
@@ -888,7 +888,7 @@ void SelectedBuildingPanel::onClearBelt()
|
||||
std::vector<QPoint> tiles;
|
||||
for (BuildingId id : m_selectedBuildingIds)
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(id);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(id);
|
||||
if (b && isBeltLike(b->type))
|
||||
{
|
||||
for (const QPoint& cell : b->bodyCells)
|
||||
@@ -918,7 +918,7 @@ void SelectedBuildingPanel::handleEvent(std::shared_ptr<const EntitySelectedEven
|
||||
m_scrapLabel->hide();
|
||||
clearContent();
|
||||
|
||||
EntityAdmin& admin = m_sim->admin();
|
||||
EntityAdmin& admin = m_sim->getAdmin();
|
||||
entt::entity entity = *m_selectedEntity;
|
||||
|
||||
if (!admin.isValid(entity))
|
||||
@@ -944,7 +944,7 @@ void SelectedBuildingPanel::handleEvent(std::shared_ptr<const EntitySelectedEven
|
||||
|
||||
void SelectedBuildingPanel::buildEntityShip(entt::entity entity)
|
||||
{
|
||||
EntityAdmin& admin = m_sim->admin();
|
||||
EntityAdmin& admin = m_sim->getAdmin();
|
||||
const ShipIdentityComponent& identity = admin.get<ShipIdentityComponent>(entity);
|
||||
const HealthComponent& health = admin.get<HealthComponent>(entity);
|
||||
|
||||
@@ -976,7 +976,7 @@ void SelectedBuildingPanel::buildEntityShip(entt::entity entity)
|
||||
|
||||
void SelectedBuildingPanel::buildEntityStation(entt::entity entity)
|
||||
{
|
||||
EntityAdmin& admin = m_sim->admin();
|
||||
EntityAdmin& admin = m_sim->getAdmin();
|
||||
const HealthComponent& health = admin.get<HealthComponent>(entity);
|
||||
|
||||
const bool isEnemy = admin.hasAll<FactionComponent>(entity)
|
||||
@@ -1019,7 +1019,7 @@ void SelectedBuildingPanel::refreshEntityStats()
|
||||
{
|
||||
if (!m_selectedEntity.has_value()) { return; }
|
||||
|
||||
EntityAdmin& admin = m_sim->admin();
|
||||
EntityAdmin& admin = m_sim->getAdmin();
|
||||
entt::entity entity = *m_selectedEntity;
|
||||
|
||||
if (!admin.isValid(entity))
|
||||
@@ -1098,7 +1098,7 @@ void SelectedBuildingPanel::refreshScrapTotal()
|
||||
{
|
||||
// Sum the remaining amounts of the still-living selected piles (REQ-UI-SCRAP-PANEL).
|
||||
int total = 0;
|
||||
for (const ScrapInfo& info : m_sim->scraps().allScrapInfo())
|
||||
for (const ScrapInfo& info : m_sim->getScraps().getAllScrapInfo())
|
||||
{
|
||||
if (std::find(m_selectedScrap.begin(), m_selectedScrap.end(), info.entity)
|
||||
!= m_selectedScrap.end())
|
||||
|
||||
@@ -90,7 +90,7 @@ private:
|
||||
void buildSplitterFilters(const std::optional<BeltSystem::SplitterInfo>& info);
|
||||
const RecipeDef* findRecipe(const Building* b) const;
|
||||
const ShipDef* findShipDef(const std::string& id) const;
|
||||
std::vector<std::string> allItemIds() const;
|
||||
std::vector<std::string> getAllItemIds() const;
|
||||
|
||||
Simulation* m_sim;
|
||||
const GameConfig* m_config;
|
||||
|
||||
@@ -578,7 +578,7 @@ ShipLayoutDialog::ShipLayoutDialog(const GameConfig* config,
|
||||
});
|
||||
}
|
||||
|
||||
std::optional<ShipLayoutConfig> ShipLayoutDialog::result() const
|
||||
std::optional<ShipLayoutConfig> ShipLayoutDialog::getResult() const
|
||||
{
|
||||
return m_result;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
bool debugDraw,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
std::optional<ShipLayoutConfig> result() const;
|
||||
std::optional<ShipLayoutConfig> getResult() const;
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
|
||||
Reference in New Issue
Block a user