aboutsummaryrefslogtreecommitdiff
path: root/src/ui.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2025-05-17 23:12:46 -0700
committerrtk0c <[email protected]>2025-05-18 10:26:52 -0700
commitf7455f44518d36cc688f915e5d6cc046eaa65896 (patch)
tree4b3e902e624b0f971b10906052ab0552308b4429 /src/ui.cpp
parent82d363cc2c4c1ce2d54802b59fc0e20dbdb438a4 (diff)
X-macro and palette editing menu
Diffstat (limited to 'src/ui.cpp')
-rw-r--r--src/ui.cpp44
1 files changed, 38 insertions, 6 deletions
diff --git a/src/ui.cpp b/src/ui.cpp
index f870a24..64a8a91 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -71,6 +71,32 @@ enum BrushType_ {
BrushType_Circle,
};
+static const char* TILE_NAMES =
+#define X(_0, str, _2) str "\0"
+#include "x/tile_types.inc"
+#undef X
+ ;
+
+static const char* FLUID_NAMES =
+#define X(_0, str, _2) str "\0"
+#include "x/fluid_types.inc"
+#undef X
+ ;
+
+static void edit_tile_palette(Tile& palette) {
+ int tile = palette.so;
+ ImGui::Combo("Tile", &tile, TILE_NAMES);
+ palette.so = static_cast<Tile::Solid>(tile);
+
+ int fluid = palette.fl;
+ ImGui::Combo("Fluid", &fluid, FLUID_NAMES);
+ palette.fl = static_cast<Tile::Fluid>(fluid);
+
+ int fmass = palette.fmass;
+ ImGui::InputInt("Fluid mass", &fmass, 1);
+ palette.fmass = std::clamp(fmass, 1, 255);
+}
+
static void paint_sand(Sandbox& sb, const Tile& palette, Pt pt, BrushType type, int size) {
switch (type) {
case BrushType_Box: {
@@ -142,15 +168,21 @@ void ShowEverything() {
ImGui::SameLine();
bool step = ImGui::Button("Step");
- static Tile palette{ .so = Tile::SAND };
+ static Tile palette{ .so = Tile::Ti_Sand };
static int brush_size = 1;
static BrushType brush_type = BrushType_Box;
- ImGui::SliderInt("Brush radius", &brush_size, 1, 20);
- ImGui::Combo("Brush type",
- &brush_type,
- "Box\0"
- "Circle");
+ if (ImGui::CollapsingHeader("Palette")) {
+ edit_tile_palette(palette);
+ }
+
+ if (ImGui::CollapsingHeader("Brush")) {
+ ImGui::SliderInt("Brush radius", &brush_size, 1, 20);
+ ImGui::Combo("Brush type",
+ &brush_type,
+ "Box\0"
+ "Circle");
+ }
ImGui::End();