Files
dota_factory/src/ui/HeaderBar.h
Malte Langkabel 3d4c0445d1 Add config-defined tooltip to header building blocks stock
Implement REQ-UI-BLOCKS-TOOLTIP: an optional world.toml
[world].building_blocks_tooltip, threaded into HeaderBar via a new
const GameConfig* parameter and shown as the building blocks stock label's
hover tooltip. Omitted when unset. Author the text in the app config and
extend ConfigLoaderTest to cover the field.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DZR44tA8sn4dPqDzAVXyps
2026-07-12 20:37:22 +02:00

62 lines
2.1 KiB
C++

#pragma once
#include <vector>
#include <QWidget>
#include "ArtifactCountChangedEvent.h"
#include "BossWaveUpdatedEvent.h"
#include "BuildingBlocksChangedEvent.h"
#include "EventHandler.h"
#include "ExpansionCostChangedEvent.h"
#include "GameConfig.h"
#include "GameSpeedChangedEvent.h"
#include "Tick.h"
#include "TickAdvancedEvent.h"
class QLabel;
class QPushButton;
class HeaderBar : public QWidget,
public CombinedEventHandler<TickAdvancedEvent,
BuildingBlocksChangedEvent,
ExpansionCostChangedEvent,
GameSpeedChangedEvent,
BossWaveUpdatedEvent,
ArtifactCountChangedEvent>
{
Q_OBJECT
public:
explicit HeaderBar(const GameConfig* config, 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 ExpansionCostChangedEvent> 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 Expand button caption and enabled state from the current
// expansion cost and building block stock (REQ-UI-EXPAND-BUTTON).
void updateExpandButton();
QLabel* m_timeLabel;
QLabel* m_blocksLabel;
QLabel* m_artifactsLabel;
QLabel* m_bossLabel;
QPushButton* m_expandButton;
std::vector<QPushButton*> m_speedButtons;
int m_blocks = 0;
int m_expansionCost = 0;
static const double kSpeeds[];
static const int kSpeedCount;
};