68 const int col = room_id % kRoomMatrixCols;
69 const int row = room_id / kRoomMatrixCols;
73 out.
west = RoomIfValid(col > 0 ? room_id - 1 : -1);
74 out.
east = RoomIfValid(col < (kRoomMatrixCols - 1) ? room_id + 1 : -1);
75 out.
north = RoomIfValid(row > 0 ? room_id - kRoomMatrixCols : -1);
77 RoomIfValid(row < (kRoomMatrixRows - 1) ? room_id + kRoomMatrixCols : -1);
82 const std::function<
void(
int)>& on_navigate) {
86 snprintf(room_text,
sizeof(room_text),
"%03X", room_id);
87 ImGui::SetNextItemWidth(ImGui::CalcTextSize(
"00000").x +
88 ImGui::GetStyle().FramePadding.x * 2.0f);
89 const bool submitted =
90 ImGui::InputText(
"##RoomId", room_text,
sizeof(room_text),
91 ImGuiInputTextFlags_CharsHexadecimal |
92 ImGuiInputTextFlags_EnterReturnsTrue);
93 if (ImGui::IsItemHovered()) {
94 ImGui::SetTooltip(
"Room ID (hexadecimal, 000-127). Press Enter to open.");
96 bool navigated =
false;
97 if (submitted && on_navigate) {
98 int requested_room = -1;
99 const auto parsed = std::from_chars(
100 room_text, room_text + std::strlen(room_text), requested_room, 16);
101 if (parsed.ec == std::errc{} &&
102 parsed.ptr == room_text + std::strlen(room_text) &&
103 requested_room != room_id && RoomIfValid(requested_room)) {
104 on_navigate(requested_room);
111 const std::string tip_w = MakeTooltip(n.
west,
"West");
112 const std::string tip_n = MakeTooltip(n.
north,
"North");
113 const std::string tip_s = MakeTooltip(n.
south,
"South");
114 const std::string tip_e = MakeTooltip(n.
east,
"East");
117 ArrowButtonWithTooltip(
"West", ImGuiDir_Left, n.
west, tip_w, on_navigate);
120 ArrowButtonWithTooltip(
"North", ImGuiDir_Up, n.
north, tip_n, on_navigate);
122 navigated |= ArrowButtonWithTooltip(
"South", ImGuiDir_Down, n.
south, tip_s,
125 navigated |= ArrowButtonWithTooltip(
"East", ImGuiDir_Right, n.
east, tip_e,