100 lines
2.6 KiB
C++
100 lines
2.6 KiB
C++
#pragma once
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <QPoint>
|
|
#include <QWidget>
|
|
|
|
#include "entt/entity/entity.hpp"
|
|
|
|
#include "Building.h"
|
|
#include "BuildingId.h"
|
|
#include "EntitySelectedEvent.h"
|
|
#include "EventHandler.h"
|
|
#include "GameConfig.h"
|
|
#include "RecipesConfig.h"
|
|
#include "ShipLayout.h"
|
|
#include "ShipsConfig.h"
|
|
#include "Tick.h"
|
|
#include "TickAdvancedEvent.h"
|
|
|
|
class Simulation;
|
|
class ShipLayoutPreview;
|
|
class ShipStatsPanel;
|
|
class QLabel;
|
|
class QComboBox;
|
|
class QListWidget;
|
|
class QPushButton;
|
|
class QVBoxLayout;
|
|
|
|
class SelectedBuildingPanel : public QWidget,
|
|
public CombinedEventHandler<TickAdvancedEvent, EntitySelectedEvent>
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
SelectedBuildingPanel(Simulation* sim, const GameConfig* config,
|
|
QWidget* parent = nullptr);
|
|
~SelectedBuildingPanel() override;
|
|
|
|
signals:
|
|
void layoutDialogRequested(BuildingId shipyardId);
|
|
|
|
public slots:
|
|
void onSelectionChanged(const std::vector<BuildingId>& ids);
|
|
|
|
private:
|
|
void handleEvent(std::shared_ptr<const TickAdvancedEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const EntitySelectedEvent> event) override;
|
|
|
|
private slots:
|
|
void onRecipeChanged(int comboIndex);
|
|
void onClearBelt();
|
|
void onSplitterFilterChanged();
|
|
|
|
private:
|
|
void rebuild();
|
|
void clearContent();
|
|
void buildEmpty();
|
|
void buildSingle(BuildingId id);
|
|
void buildMulti(const std::vector<BuildingId>& ids);
|
|
void refreshBuffers(const Building* b);
|
|
void buildSplitterFilters(QPoint splitterTile);
|
|
const RecipeDef* findRecipe(const Building* b) const;
|
|
const ShipDef* findShipDef(const std::string& id) const;
|
|
std::vector<std::string> allItemIds() const;
|
|
|
|
Simulation* m_sim;
|
|
const GameConfig* m_config;
|
|
std::vector<BuildingId> m_selectedBuildingIds;
|
|
|
|
QVBoxLayout* m_layout;
|
|
QLabel* m_titleLabel;
|
|
QComboBox* m_recipeCombo;
|
|
QPushButton* m_clearBeltBtn;
|
|
QLabel* m_filterALabel;
|
|
QListWidget* m_filterAList;
|
|
QLabel* m_filterBLabel;
|
|
QListWidget* m_filterBList;
|
|
QLabel* m_buffersLabel;
|
|
|
|
ShipLayoutPreview* m_layoutPreview;
|
|
QPushButton* m_configureLayoutBtn;
|
|
|
|
BuildingId m_singleBuildingId;
|
|
QPoint m_splitterTile;
|
|
std::string m_currentRecipeId;
|
|
|
|
std::optional<entt::entity> m_selectedEntity;
|
|
ShipStatsPanel* m_entityStatsPanel;
|
|
QLabel* m_entityTitleLabel;
|
|
QLabel* m_stationStatsLabel;
|
|
|
|
void buildEntityShip(entt::entity entity);
|
|
void buildEntityStation(entt::entity entity);
|
|
void refreshEntityStats();
|
|
void clearEntityDisplay();
|
|
};
|