yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
minecart_rail_tools.cc
Go to the documentation of this file.
2
4#include "imgui/imgui.h"
5
6namespace yaze::editor {
7
9 if (!ImGui::CollapsingHeader("Rails and behavior",
10 ImGuiTreeNodeFlags_DefaultOpen))
11 return;
12 ImGui::TextWrapped(
13 "Choose artwork, then place it on the room canvas. "
14 "Rail behavior is stamped separately below.");
16 set_canvas_editing(false);
18 }
19 ImGui::Separator();
20 bool stamping = collision_stamping_;
21 ImGui::BeginDisabled(!apply_collision_stamp_);
22 if (ImGui::Checkbox("Stamp rail behavior", &stamping)) {
23 set_collision_stamping(stamping);
24 }
25 gui::AutoRegisterLastItem("checkbox", "Stamp rail behavior");
26 ImGui::EndDisabled();
28 return;
29
30 struct Behavior {
31 uint8_t value;
32 const char* label;
33 };
34 static constexpr Behavior kBehaviors[] = {
35 {0xB0, "Straight: horizontal"},
36 {0xB1, "Straight: vertical"},
37 {0xB2, "Corner: right / down"},
38 {0xB3, "Corner: right / up"},
39 {0xB4, "Corner: left / down"},
40 {0xB5, "Corner: left / up"},
41 {0xB6, "Crossing"},
42 {0xB7, "Stop: depart south"},
43 {0xB8, "Stop: depart north"},
44 {0xB9, "Stop: depart east"},
45 {0xBA, "Stop: depart west"},
46 {0xBB, "Junction: south / east / west"},
47 {0xBC, "Junction: north / east / west"},
48 {0xBD, "Junction: north / south / west"},
49 {0xBE, "Junction: north / south / east"},
50 {0xD0, "Switch: right / down"},
51 {0xD1, "Switch: right / up"},
52 {0xD2, "Switch: left / down"},
53 {0xD3, "Switch: left / up"},
54 {0x00, "Erase rail behavior"}};
55 const char* selected = kBehaviors[1].label;
56 for (const auto& behavior : kBehaviors) {
57 if (behavior.value == collision_stamp_value_)
58 selected = behavior.label;
59 }
60 ImGui::SetNextItemWidth(-1);
61 const bool open = ImGui::BeginCombo("##RailBehavior", selected);
62 gui::AutoRegisterLastItem("combo", "RailBehavior");
63 if (open) {
64 for (const auto& behavior : kBehaviors) {
65 if (ImGui::Selectable(behavior.label,
66 behavior.value == collision_stamp_value_)) {
67 collision_stamp_value_ = behavior.value;
68 }
69 gui::AutoRegisterLastItem("selectable", behavior.label);
70 }
71 ImGui::EndCombo();
72 }
73 ImGui::Checkbox("2 x 2 cells (16 pixels)", &collision_stamp_large_);
74 ImGui::TextWrapped(
75 "Upper layer only. Hover to preview; click to stamp. "
76 "Each click is one Undo step. Click the room canvas, then Escape "
77 "leaves stamping.");
78 ImGui::TextWrapped(
79 "Ordinary rails preserve stops, switches and other "
80 "collision. Use a stop or switch tool to change its direction. "
81 "Erase rail behavior removes rails, stops and switches only; "
82 "artwork is unchanged.");
83}
84
85} // namespace yaze::editor
Editors are the view controllers for the application.
void AutoRegisterLastItem(const std::string &widget_type, const std::string &explicit_label, const std::string &description)
Automatically register the last ImGui item.
Automatic widget registration helpers for ImGui Test Engine integration.