From 03f0aecf93b3785aa45b7e61a63f10ae7f98af3d Mon Sep 17 00:00:00 2001 From: chreden <4263940+chreden@users.noreply.github.com> Date: Mon, 13 Jan 2025 01:13:17 +0000 Subject: [PATCH] Partial rooms diff #634 --- trview.app/Windows/Diff/DiffWindow.cpp | 62 ++++++++++++++++--- trview.app/Windows/Diff/DiffWindow.h | 1 + trview.app/Windows/Diff/DiffWindowManager.cpp | 1 + trview.app/Windows/Diff/IDiffWindow.h | 2 + trview.app/Windows/Diff/IDiffWindowManager.h | 2 + trview.app/Windows/Windows.cpp | 1 + 6 files changed, 60 insertions(+), 9 deletions(-) diff --git a/trview.app/Windows/Diff/DiffWindow.cpp b/trview.app/Windows/Diff/DiffWindow.cpp index d753524ea..7729323de 100644 --- a/trview.app/Windows/Diff/DiffWindow.cpp +++ b/trview.app/Windows/Diff/DiffWindow.cpp @@ -8,6 +8,7 @@ #include "../../Elements/ITrigger.h" #include "../../Elements/ILight.h" #include "../../Elements/SoundSource/ISoundSource.h" +#include "../../Elements/IRoom.h" namespace trview { @@ -302,6 +303,24 @@ namespace trview return results; } + std::vector get_details(const std::shared_ptr& left, const std::shared_ptr& right) + { + std::vector results; + // left->bounding_box() == right->bounding_box() && + // info + add_if_changed(results, "Alternate Group", left->alternate_group(), right->alternate_group()); + add_if_changed(results, "Alternate Mode", left->alternate_mode(), right->alternate_mode()); + add_if_changed(results, "Ambient", left->ambient(), right->ambient()); + add_if_changed(results, "Ambient Intensity 1", left->ambient_intensity_1(), right->ambient_intensity_1()); + add_if_changed(results, "Ambient Intensity 2", left->ambient_intensity_2(), right->ambient_intensity_2()); + add_if_changed(results, "Centre", left->centre() * 1024, right->centre() * 1024); + add_if_changed(results, "Flags", left->flags(), right->flags()); + add_if_changed(results, "Light Mode", left->light_mode(), right->light_mode()); + add_if_changed(results, "X Sectors", left->num_x_sectors(), right->num_x_sectors()); + add_if_changed(results, "Z Sectors", left->num_z_sectors(), right->num_z_sectors()); + return results; + } + template void show_details(const std::shared_ptr& left, const std::shared_ptr& right) { @@ -596,6 +615,25 @@ namespace trview left->sample() == right->sample(); }); + // Rooms: + const auto rooms_results = get_results(left->rooms(), right->rooms(), + [](auto&& left, auto&& right) + { + return + left->alternate_group() == right->alternate_group() && + left->ambient() == right->ambient() && + left->ambient_intensity_1() == right->ambient_intensity_1() && + left->ambient_intensity_2() == right->ambient_intensity_2() && + left->alternate_mode() == right->alternate_mode() && + // left->bounding_box() == right->bounding_box() && + left->centre() == right->centre() && + left->flags() == right->flags() && + // info + left->light_mode() == right->light_mode()&& + left->num_x_sectors() == right->num_x_sectors() && + left->num_z_sectors() == right->num_z_sectors(); + }); + return Diff { .items = item_results, @@ -603,7 +641,8 @@ namespace trview .lights = light_results, .camera_sinks = camera_sink_results, .static_meshes = static_results, - .sound_sources = sound_source_results + .sound_sources = sound_source_results, + .rooms = rooms_results }; } @@ -633,12 +672,14 @@ namespace trview if (ImGui::BeginTabBar("TabBar")) { - const bool any_items = std::ranges::any_of(_diff->diff.items, [](auto&& i) { return i.type != Diff::Type::None; }); - const bool any_triggers = std::ranges::any_of(_diff->diff.items, [](auto&& t) { return t.type != Diff::Type::None; }); - const bool any_lights = std::ranges::any_of(_diff->diff.lights, [](auto&& l) { return l.type != Diff::Type::None; }); - const bool any_camera_sink = std::ranges::any_of(_diff->diff.camera_sinks, [](auto&& c) { return c.type != Diff::Type::None; }); - const bool any_statics = std::ranges::any_of(_diff->diff.static_meshes, [](auto&& c) { return c.type != Diff::Type::None; }); - const bool any_sounds = std::ranges::any_of(_diff->diff.sound_sources, [](auto&& c) { return c.type != Diff::Type::None; }); + const auto any_diff = [](auto&& range) { return std::ranges::any_of(range, [](auto&& e) { return e.type != Diff::Type::None; }); }; + const bool any_items = any_diff(_diff->diff.items); + const bool any_triggers = any_diff(_diff->diff.triggers); + const bool any_lights = any_diff(_diff->diff.lights); + const bool any_camera_sink = any_diff(_diff->diff.camera_sinks); + const bool any_statics = any_diff(_diff->diff.static_meshes); + const bool any_sounds = any_diff(_diff->diff.sound_sources); + const bool any_rooms = any_diff(_diff->diff.rooms); const auto show_table = [this]( const std::string& table_name, @@ -751,8 +792,11 @@ namespace trview ImGui::EndTabItem(); } - // TODO: - // Rooms... + if (ImGui::BeginTabItem(std::format("Rooms{}", any_rooms ? "*" : "").c_str())) + { + show_table("Rooms List", _diff->diff.rooms, on_room_selected, [](auto&&) { return "Room"; }); + ImGui::EndTabItem(); + } ImGui::EndTabBar(); } diff --git a/trview.app/Windows/Diff/DiffWindow.h b/trview.app/Windows/Diff/DiffWindow.h index b7378258f..edbca7722 100644 --- a/trview.app/Windows/Diff/DiffWindow.h +++ b/trview.app/Windows/Diff/DiffWindow.h @@ -55,6 +55,7 @@ namespace trview std::vector> camera_sinks; std::vector> static_meshes; std::vector> sound_sources; + std::vector> rooms; }; private: struct LoadOperation diff --git a/trview.app/Windows/Diff/DiffWindowManager.cpp b/trview.app/Windows/Diff/DiffWindowManager.cpp index bdb948c81..e1a469004 100644 --- a/trview.app/Windows/Diff/DiffWindowManager.cpp +++ b/trview.app/Windows/Diff/DiffWindowManager.cpp @@ -24,6 +24,7 @@ namespace trview window->on_camera_sink_selected += on_camera_sink_selected; window->on_static_mesh_selected += on_static_mesh_selected; window->on_sound_source_selected += on_sound_source_selected; + window->on_room_selected += on_room_selected; return add_window(window); } diff --git a/trview.app/Windows/Diff/IDiffWindow.h b/trview.app/Windows/Diff/IDiffWindow.h index e55e5e31e..1eacf6a59 100644 --- a/trview.app/Windows/Diff/IDiffWindow.h +++ b/trview.app/Windows/Diff/IDiffWindow.h @@ -10,6 +10,7 @@ namespace trview struct ILight; struct ISoundSource; struct ITrigger; + struct IRoom; struct IDiffWindow { @@ -31,5 +32,6 @@ namespace trview Event> on_camera_sink_selected; Event> on_static_mesh_selected; Event> on_sound_source_selected; + Event> on_room_selected; }; } \ No newline at end of file diff --git a/trview.app/Windows/Diff/IDiffWindowManager.h b/trview.app/Windows/Diff/IDiffWindowManager.h index 65a0150c6..dc259f076 100644 --- a/trview.app/Windows/Diff/IDiffWindowManager.h +++ b/trview.app/Windows/Diff/IDiffWindowManager.h @@ -13,6 +13,7 @@ namespace trview struct ISoundSource; struct IStaticMesh; struct ITrigger; + struct IRoom; struct IDiffWindowManager { @@ -28,5 +29,6 @@ namespace trview Event> on_camera_sink_selected; Event> on_static_mesh_selected; Event> on_sound_source_selected; + Event> on_room_selected; }; } diff --git a/trview.app/Windows/Windows.cpp b/trview.app/Windows/Windows.cpp index 85dabce89..ed2deb659 100644 --- a/trview.app/Windows/Windows.cpp +++ b/trview.app/Windows/Windows.cpp @@ -58,6 +58,7 @@ namespace trview _diff_windows->on_camera_sink_selected += on_camera_sink_selected; _diff_windows->on_static_mesh_selected += on_static_selected; _diff_windows->on_sound_source_selected += on_sound_source_selected; + _diff_windows->on_room_selected += on_room_selected; _token_store += _items_windows->on_add_to_route += [this](auto item) {