5#include "imgui/imgui.h"
13constexpr int kRoomMatrixCols = 16;
14constexpr int kRoomMatrixRows = 19;
24 const char* direction) {
25 if (!target.has_value()) {
30 snprintf(buf,
sizeof(buf),
"%s: [%03X] %s", direction, *target, label.c_str());
35 const std::optional<int>& target,
36 const std::string& tooltip,
37 const std::function<
void(
int)>& on_navigate) {
38 const bool enabled = target.has_value();
40 ImGui::BeginDisabled();
42 const bool pressed = ImGui::ArrowButton(
id, dir);
46 if (enabled && ImGui::IsItemHovered() && !tooltip.empty()) {
47 ImGui::SetTooltip(
"%s", tooltip.c_str());
49 if (pressed && enabled && on_navigate) {
63 const int col = room_id % kRoomMatrixCols;
64 const int row = room_id / kRoomMatrixCols;
68 out.
west = RoomIfValid(col > 0 ? room_id - 1 : -1);
69 out.
east = RoomIfValid(col < (kRoomMatrixCols - 1) ? room_id + 1 : -1);
70 out.
north = RoomIfValid(row > 0 ? room_id - kRoomMatrixCols : -1);
71 out.
south = RoomIfValid(row < (kRoomMatrixRows - 1) ? room_id + kRoomMatrixCols
77 const std::function<
void(
int)>& on_navigate) {
81 const std::string tip_w = MakeTooltip(n.
west,
"West");
82 const std::string tip_n = MakeTooltip(n.
north,
"North");
83 const std::string tip_s = MakeTooltip(n.
south,
"South");
84 const std::string tip_e = MakeTooltip(n.
east,
"East");
86 bool navigated =
false;
87 navigated |= ArrowButtonWithTooltip(
"West", ImGuiDir_Left, n.
west, tip_w,
90 navigated |= ArrowButtonWithTooltip(
"North", ImGuiDir_Up, n.
north, tip_n,
93 navigated |= ArrowButtonWithTooltip(
"South", ImGuiDir_Down, n.
south, tip_s,
96 navigated |= ArrowButtonWithTooltip(
"East", ImGuiDir_Right, n.
east, tip_e,
Editors are the view controllers for the application.
std::string GetRoomLabel(int id)
Convenience function to get a room label.
constexpr int kNumberOfRooms