The button leaves the header bar for the world, centered on the columns the next purchase unlocks and panning with them until it leaves the view. Those columns now take a lighter tint than the locked ground behind them, so the boundary between the two says how far one purchase reaches. Nothing in the code reported a scroll: the camera knew it had moved and told only the hover. A ViewScrolledEvent says it now, which is what a widget keeping a place in the world rather than on the screen needs. The panels want none of it -- they are placed against the screen and stay put as the world moves under them -- so the button is placed after their pass and never joins the rectangles they step around. Its face is two lines, "Expand" over the cost. That makes the cost a display of its own, so it carries the building-block tooltip the way every other item value does, on hover alone since the click buys the expansion. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
74 lines
2.6 KiB
C++
74 lines
2.6 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <QPixmap>
|
|
#include <QWidget>
|
|
|
|
#include "ArtifactCountChangedEvent.h"
|
|
#include "BossWaveUpdatedEvent.h"
|
|
#include "BuildingBlocksChangedEvent.h"
|
|
#include "EventHandler.h"
|
|
#include "GameConfig.h"
|
|
#include "GameSpeedChangedEvent.h"
|
|
#include "ItemTooltipContext.h"
|
|
#include "Tick.h"
|
|
#include "TickAdvancedEvent.h"
|
|
|
|
class QLabel;
|
|
class QPushButton;
|
|
class ItemIconCache;
|
|
class Simulation;
|
|
|
|
class HeaderBar : public QWidget,
|
|
public CombinedEventHandler<TickAdvancedEvent,
|
|
BuildingBlocksChangedEvent,
|
|
GameSpeedChangedEvent,
|
|
BossWaveUpdatedEvent,
|
|
ArtifactCountChangedEvent>
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
// The context carries the simulation the bar reads, the config, and the icon caches
|
|
// -- the item cache draws the building_block icon in the stock display
|
|
// (REQ-UI-BLOCKS-ICON), and the stock display explains that item with the cache's
|
|
// help (REQ-UI-ITEM-VALUE-TOOLTIP). Nothing in it is owned; all of it must outlive
|
|
// this widget.
|
|
explicit HeaderBar(const ItemTooltipContext& context, QWidget* parent = nullptr);
|
|
~HeaderBar() override;
|
|
|
|
private slots:
|
|
void onSpeedButton(int index);
|
|
|
|
private:
|
|
void handleEvent(std::shared_ptr<const TickAdvancedEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const BuildingBlocksChangedEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const GameSpeedChangedEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const BossWaveUpdatedEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const ArtifactCountChangedEvent> event) override;
|
|
|
|
// Refreshes the building blocks stock display from the simulation:
|
|
// `Stock: <n>` with the building_block icon after it, or the
|
|
// `Stock: <n> Blocks` text fallback when no icon file exists
|
|
// (REQ-UI-BLOCKS-ICON).
|
|
void updateBlocksLabel();
|
|
|
|
QLabel* m_timeLabel;
|
|
QLabel* m_blocksLabel;
|
|
QLabel* m_artifactsLabel;
|
|
QLabel* m_bossWaveLabel;
|
|
QLabel* m_nextBossLabel;
|
|
std::vector<QPushButton*> m_speedButtons;
|
|
|
|
// Not owned; all of it lives in MainWindow. The simulation it names is the single
|
|
// source of truth for everything the header displays; the change events are only
|
|
// refresh signals.
|
|
ItemTooltipContext m_context;
|
|
|
|
static const double kSpeeds[];
|
|
static const int kSpeedCount;
|
|
};
|