Polyphase Game Engine
Loading...
Searching...
No Matches
TilePicker.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include <cstdint>
6
7class Texture;
8
9// Reusable atlas tile picker. Hoisted from the Voxel sculpt panel so the
10// TileMap2D paint panel and (eventually) the TileSet asset editor can share
11// the same UI primitives.
12namespace TilePicker
13{
14 // Get or create the ImGui texture descriptor for an atlas. Caches one
15 // descriptor per (cacheKey, texture) pair so multiple panels can call this
16 // every frame without leaking descriptors. Returns 0 if no atlas is bound.
17 void* GetOrCreateImTextureID(const char* cacheKey, Texture* atlasTex);
18
19 // Single tile preview button. Returns true if the user clicked it this frame.
20 bool DrawTileButton(const char* id, void* atlasTexId, int32_t tileIdx,
21 int32_t tilesX, int32_t tilesY, float size);
22
23 // Popup containing a scrollable atlas grid. The user clicks a tile to
24 // select it; the chosen index is written into outTileIdx. Caller is
25 // responsible for opening the popup with ImGui::OpenPopup(popupId).
26 void DrawTilePickerPopup(const char* popupId, void* atlasTexId,
27 int32_t tilesX, int32_t tilesY,
28 int32_t& outTileIdx);
29
30 // Inline atlas grid (not a popup) suitable for the palette panel. Returns
31 // true if the user clicked a tile this frame.
32 bool DrawInlineTileGrid(const char* id, void* atlasTexId,
33 int32_t tilesX, int32_t tilesY,
34 int32_t& selectedTileIdx,
35 float tileDrawSize,
36 float maxWidth, float maxHeight);
37}
38
39#endif
Definition Texture.h:10