50 int room_min_x,
int room_min_y,
int room_max_x,
int room_max_y,
51 const std::vector<zelda3::RoomObject>& objects,
SelectionMode mode) {
53 int min_x = std::min(room_min_x, room_max_x);
54 int max_x = std::max(room_min_x, room_max_x);
55 int min_y = std::min(room_min_y, room_max_y);
56 int max_y = std::max(room_min_y, room_max_y);
64 for (
size_t i = 0; i < objects.size(); ++i) {
194 gui::Canvas* canvas,
const std::vector<zelda3::RoomObject>& objects,
196 dimension_calculator) {
201 ImDrawList* draw_list = ImGui::GetWindowDrawList();
206 if (index >= objects.size()) {
210 const auto&
object = objects[index];
216 int pixel_width, pixel_height;
217 if (dimension_calculator) {
218 auto dims = dimension_calculator(
object);
219 pixel_width = dims.first;
220 pixel_height = dims.second;
223 auto [tile_x, tile_y, tile_width, tile_height] =
GetObjectBounds(
object);
224 pixel_width = tile_width * 8;
225 pixel_height = tile_height * 8;
229 ImVec2 obj_start(canvas_pos.x + obj_x * scale,
230 canvas_pos.y + obj_y * scale);
231 ImVec2 obj_end(obj_start.x + pixel_width * scale,
232 obj_start.y + pixel_height * scale);
235 constexpr float margin = 2.0f;
236 obj_start.x -= margin;
237 obj_start.y -= margin;
246 0.7f + 0.3f * std::sin(
static_cast<float>(ImGui::GetTime()) * 4.0f);
247 ImVec4 pulsing_color = ImVec4(
248 base_color.x * pulse, base_color.y * pulse, base_color.z * pulse,
251 ImU32 border_color = ImGui::GetColorU32(pulsing_color);
252 draw_list->AddRect(obj_start, obj_end, border_color, 0.0f, 0, 2.5f);
255 constexpr float handle_size = 6.0f;
256 ImVec4 handle_col = ImVec4(base_color.x, base_color.y, base_color.z, 0.95f);
257 ImU32 handle_color = ImGui::GetColorU32(handle_col);
260 draw_list->AddRectFilled(
261 ImVec2(obj_start.x - handle_size / 2, obj_start.y - handle_size / 2),
262 ImVec2(obj_start.x + handle_size / 2, obj_start.y + handle_size / 2),
266 draw_list->AddRectFilled(
267 ImVec2(obj_end.x - handle_size / 2, obj_start.y - handle_size / 2),
268 ImVec2(obj_end.x + handle_size / 2, obj_start.y + handle_size / 2),
272 draw_list->AddRectFilled(
273 ImVec2(obj_start.x - handle_size / 2, obj_end.y - handle_size / 2),
274 ImVec2(obj_start.x + handle_size / 2, obj_end.y + handle_size / 2),
278 draw_list->AddRectFilled(
279 ImVec2(obj_end.x - handle_size / 2, obj_end.y - handle_size / 2),
280 ImVec2(obj_end.x + handle_size / 2, obj_end.y + handle_size / 2),
287 int layer =
object.GetLayerValue();
297 base = ImVec4(0.0f, 0.9f, 1.0f, 1.0f);
300 base = ImVec4(1.0f, 0.6f, 0.0f, 1.0f);
303 base = ImVec4(1.0f, 0.3f, 0.8f, 1.0f);
306 base = ImVec4(0.8f, 0.8f, 0.8f, 1.0f);
311 switch (object_type) {
315 base.x = std::min(1.0f, base.x * 1.1f);
316 base.y = std::min(1.0f, base.y * 1.1f);
317 base.z = std::min(1.0f, base.z * 1.1f);
320 base.x = std::min(1.0f, base.x + 0.1f);
333 ImDrawList* draw_list = ImGui::GetWindowDrawList();
341 ImVec2 box_start(canvas_pos.x + min_x * scale, canvas_pos.y + min_y * scale);
342 ImVec2 box_end(canvas_pos.x + max_x * scale, canvas_pos.y + max_y * scale);
346 ImU32 border_color = ImGui::ColorConvertFloat4ToU32(
347 ImVec4(theme.accent_color.x, theme.accent_color.y, theme.accent_color.z,
350 ImU32 fill_color = ImGui::ColorConvertFloat4ToU32(
351 ImVec4(theme.accent_color.x, theme.accent_color.y, theme.accent_color.z,
354 draw_list->AddRectFilled(box_start, box_end, fill_color);
355 draw_list->AddRect(box_start, box_end, border_color, 0.0f, 0, 2.0f);
void SelectObjectsInRect(int room_min_x, int room_min_y, int room_max_x, int room_max_y, const std::vector< zelda3::RoomObject > &objects, SelectionMode mode=SelectionMode::Single)
Select multiple objects within a rectangle.