#pragma once

#include "ItemTooltipContext.h"

struct GameConfig;
struct VisualsConfig;
class BuildingIconCache;
class ItemIconCache;
class Simulation;

// Everything a selection panel content reads that is not the selection itself: the
// simulation it queries live values from, the immutable config, and the window-wide
// rendering resources. Bundled so a content's constructor stays short and adding a
// shared resource does not touch every content (REQ-UI-SELECTION-CONTENT).
//
// Nothing here is owned: the whole struct is a view onto objects living in MainWindow
// and must not outlive it. Passed by const reference and copied into each content.
struct SelectionContext
{
    Simulation*          sim           = nullptr;
    const GameConfig*    config        = nullptr;
    const VisualsConfig* visuals       = nullptr;
    ItemIconCache*       itemIcons     = nullptr;
    BuildingIconCache*   buildingIcons = nullptr;

    // Whether debug draw is currently on (REQ-UI-DEBUG-DRAW), which the ship card shows
    // its threat cost under (REQ-UI-SHIP-STATS-PANEL). A pointer rather than a copy
    // because cards outlive a toggle: the panel owns the flag, so a card reading it per
    // refresh always sees the current value without subscribing to the event itself.
    const bool*          debugDrawEnabled = nullptr;

    // The part of this a tooltip needs, for the panel's item displays to explain what
    // they name (REQ-UI-ITEM-VALUE-TOOLTIP).
    ItemTooltipContext getItemTooltipContext() const
    {
        return ItemTooltipContext{ sim, config, itemIcons, buildingIcons };
    }
};
