From d895348257d3aecaa63257462611aa4f35eda8e2 Mon Sep 17 00:00:00 2001 From: chreden <4263940+chreden@users.noreply.github.com> Date: Fri, 9 Aug 2024 22:03:54 +0100 Subject: [PATCH] Include Look At in triggered by, rename to references Include LookAt in triggered by - rename triggered by to trigger references in UI and Lua. Closes #1273 --- doc/lua/camera_sink.md | 4 ++-- doc/lua/item.md | 2 +- trview.app.tests/Lua/Elements/Lua_CameraSinkTests.cpp | 8 ++++---- trview.app.tests/Lua/Elements/Lua_ItemTests.cpp | 8 ++++---- trview.app.ui.tests/ContextMenuTests.cpp | 4 ++-- trview.app/Elements/Trigger.cpp | 2 +- trview.app/Lua/Elements/CameraSink/Lua_CameraSink.cpp | 2 +- trview.app/Lua/Elements/Item/Lua_Item.cpp | 2 +- trview.app/UI/ContextMenu.cpp | 2 +- trview.app/UI/ContextMenu.h | 2 +- trview.app/Windows/CameraSink/CameraSinkWindow.cpp | 4 ++-- trview.app/Windows/ItemsWindow.cpp | 4 ++-- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/doc/lua/camera_sink.md b/doc/lua/camera_sink.md index e5ef2178e..16da9a528 100644 --- a/doc/lua/camera_sink.md +++ b/doc/lua/camera_sink.md @@ -13,7 +13,7 @@ Cameras and Sinks share a data type, so this type provides access to both sets o | position | [Vector3](vector3.md) | R | Position of the camera/sink | | room | [Room](room.md) | R | Room that contains the Camera | | type | string | RW | Type: `Camera` or `Sink` | -| triggered_by | [Trigger](trigger.md)[] | R | Triggers that reference the camera | +| trigger_references | [Trigger](trigger.md)[] | R | Triggers that reference the camera | | visible | boolean | RW | Whether the room is visible in the viewer | # Sink Properties @@ -25,5 +25,5 @@ Cameras and Sinks share a data type, so this type provides access to both sets o | position | [Vector3](vector3.md) | R | Position of the camera/sink | | strength | number | R | How quickly this moves Lara | | type | string | RW | Type: `Camera` or `Sink` | -| triggered_by | [Trigger](trigger.md)[] | R | Triggers that reference the sink | +| trigger_references | [Trigger](trigger.md)[] | R | Triggers that reference the sink | | visible | boolean | RW | Whether the room is visible in the viewer | diff --git a/doc/lua/item.md b/doc/lua/item.md index 70be45132..e7a75f8b5 100644 --- a/doc/lua/item.md +++ b/doc/lua/item.md @@ -14,7 +14,7 @@ The Item library provides information about an item in a [level](level.md). | ocb | number | R | Object code bit, used for extra actions in TR4+ | | position | [Vector3](vector3.md) | R | Position of the object in game units | room | [Room](room.md) | R | The room that the item is in | -| triggered_by | [Trigger](trigger.md)[] | R | The triggers that reference this item | +| trigger_references | [Trigger](trigger.md)[] | R | The triggers that reference this item | | type | string | R | The item type name e.g Lara | | type_id | number | R | The item type number | | visible | boolean | RW | Whether the item is visible in the viewer | \ No newline at end of file diff --git a/trview.app.tests/Lua/Elements/Lua_CameraSinkTests.cpp b/trview.app.tests/Lua/Elements/Lua_CameraSinkTests.cpp index 0f5729431..c96d723da 100644 --- a/trview.app.tests/Lua/Elements/Lua_CameraSinkTests.cpp +++ b/trview.app.tests/Lua/Elements/Lua_CameraSinkTests.cpp @@ -176,15 +176,15 @@ TEST(Lua_CameraSink, TriggeredBy) lua::create_camera_sink(L, cs); lua_setglobal(L, "c"); - ASSERT_EQ(0, luaL_dostring(L, "return c.triggered_by")); + ASSERT_EQ(0, luaL_dostring(L, "return c.trigger_references")); ASSERT_EQ(LUA_TTABLE, lua_type(L, -1)); - ASSERT_EQ(0, luaL_dostring(L, "return #c.triggered_by")); + ASSERT_EQ(0, luaL_dostring(L, "return #c.trigger_references")); ASSERT_EQ(LUA_TNUMBER, lua_type(L, -1)); ASSERT_EQ(2, lua_tointeger(L, -1)); - ASSERT_EQ(0, luaL_dostring(L, "return c.triggered_by[1].number")); + ASSERT_EQ(0, luaL_dostring(L, "return c.trigger_references[1].number")); ASSERT_EQ(LUA_TNUMBER, lua_type(L, -1)); ASSERT_EQ(100, lua_tointeger(L, -1)); - ASSERT_EQ(0, luaL_dostring(L, "return c.triggered_by[2].number")); + ASSERT_EQ(0, luaL_dostring(L, "return c.trigger_references[2].number")); ASSERT_EQ(LUA_TNUMBER, lua_type(L, -1)); ASSERT_EQ(200, lua_tointeger(L, -1)); } diff --git a/trview.app.tests/Lua/Elements/Lua_ItemTests.cpp b/trview.app.tests/Lua/Elements/Lua_ItemTests.cpp index b5b84e259..b4c72ebb3 100644 --- a/trview.app.tests/Lua/Elements/Lua_ItemTests.cpp +++ b/trview.app.tests/Lua/Elements/Lua_ItemTests.cpp @@ -165,15 +165,15 @@ TEST(Lua_Item, TriggeredBy) lua::create_item(L, item); lua_setglobal(L, "i"); - ASSERT_EQ(0, luaL_dostring(L, "return i.triggered_by")); + ASSERT_EQ(0, luaL_dostring(L, "return i.trigger_references")); ASSERT_EQ(LUA_TTABLE, lua_type(L, -1)); - ASSERT_EQ(0, luaL_dostring(L, "return #i.triggered_by")); + ASSERT_EQ(0, luaL_dostring(L, "return #i.trigger_references")); ASSERT_EQ(LUA_TNUMBER, lua_type(L, -1)); ASSERT_EQ(2, lua_tointeger(L, -1)); - ASSERT_EQ(0, luaL_dostring(L, "return i.triggered_by[1].number")); + ASSERT_EQ(0, luaL_dostring(L, "return i.trigger_references[1].number")); ASSERT_EQ(LUA_TNUMBER, lua_type(L, -1)); ASSERT_EQ(100, lua_tointeger(L, -1)); - ASSERT_EQ(0, luaL_dostring(L, "return i.triggered_by[2].number")); + ASSERT_EQ(0, luaL_dostring(L, "return i.trigger_references[2].number")); ASSERT_EQ(LUA_TNUMBER, lua_type(L, -1)); ASSERT_EQ(200, lua_tointeger(L, -1)); } diff --git a/trview.app.ui.tests/ContextMenuTests.cpp b/trview.app.ui.tests/ContextMenuTests.cpp index e8e5a9daa..2570c9ded 100644 --- a/trview.app.ui.tests/ContextMenuTests.cpp +++ b/trview.app.ui.tests/ContextMenuTests.cpp @@ -244,7 +244,7 @@ void register_context_menu_tests(ImGuiTestEngine* engine) ASSERT_FALSE(menu.visible()); }); - test(engine, "Context Menu", "Triggered By", + test(engine, "Context Menu", "Trigger References", [](ImGuiTestContext* ctx) { ctx->GetVars().render(); }, [](ImGuiTestContext* ctx) { @@ -261,7 +261,7 @@ void register_context_menu_tests(ImGuiTestEngine* engine) auto token = menu.on_trigger_selected += [&raised](auto type) { raised = type; }; ctx->MouseClickOnVoid(ImGuiMouseButton_Right); - ctx->ItemOpen("/**/Triggered By"); + ctx->ItemOpen("/**/Trigger References"); ctx->ItemClick("/##Menu_00/Trigger 100"); ASSERT_TRUE(raised); diff --git a/trview.app/Elements/Trigger.cpp b/trview.app/Elements/Trigger.cpp index 227f091b9..eac62502e 100644 --- a/trview.app/Elements/Trigger.cpp +++ b/trview.app/Elements/Trigger.cpp @@ -33,7 +33,7 @@ namespace trview { _commands.push_back({ command_index++, action.first, action.second }); // Special case for object still. - if (action.first == TriggerCommandType::Object) + if (equals_any(action.first, TriggerCommandType::Object, TriggerCommandType::LookAtItem)) { _objects.push_back(action.second); } diff --git a/trview.app/Lua/Elements/CameraSink/Lua_CameraSink.cpp b/trview.app/Lua/Elements/CameraSink/Lua_CameraSink.cpp index fb490ed21..fbce993db 100644 --- a/trview.app/Lua/Elements/CameraSink/Lua_CameraSink.cpp +++ b/trview.app/Lua/Elements/CameraSink/Lua_CameraSink.cpp @@ -58,7 +58,7 @@ namespace trview lua_pushstring(L, to_string(camera_sink->type()).c_str()); return 1; } - else if (key == "triggered_by") + else if (equals_any(key, "triggered_by", "trigger_references")) { return push_list_p(L, camera_sink->triggers(), create_trigger); } diff --git a/trview.app/Lua/Elements/Item/Lua_Item.cpp b/trview.app/Lua/Elements/Item/Lua_Item.cpp index a2efb278e..7f76c3cd8 100644 --- a/trview.app/Lua/Elements/Item/Lua_Item.cpp +++ b/trview.app/Lua/Elements/Item/Lua_Item.cpp @@ -60,7 +60,7 @@ namespace trview { return create_room(L, item->room().lock()); } - else if (key == "triggered_by") + else if (equals_any(key, "triggered_by", "trigger_references")) { return push_list_p(L, item->triggers(), create_trigger); } diff --git a/trview.app/UI/ContextMenu.cpp b/trview.app/UI/ContextMenu.cpp index 7e5b1c02f..21c54ec15 100644 --- a/trview.app/UI/ContextMenu.cpp +++ b/trview.app/UI/ContextMenu.cpp @@ -45,7 +45,7 @@ namespace trview ImGui::EndMenu(); } - if (ImGui::BeginMenu(Names::triggered_by.c_str(), !_triggered_by.empty())) + if (ImGui::BeginMenu(Names::trigger_references.c_str(), !_triggered_by.empty())) { for (const auto& trigger : _triggered_by) { diff --git a/trview.app/UI/ContextMenu.h b/trview.app/UI/ContextMenu.h index b43286a9a..96b037753 100644 --- a/trview.app/UI/ContextMenu.h +++ b/trview.app/UI/ContextMenu.h @@ -18,7 +18,7 @@ namespace trview static inline const std::string copy = "Copy"; static inline const std::string copy_position = "Position"; static inline const std::string copy_number = "Room/Object Number"; - static inline const std::string triggered_by = "Triggered By"; + static inline const std::string trigger_references = "Trigger References"; }; virtual ~ContextMenu() = default; diff --git a/trview.app/Windows/CameraSink/CameraSinkWindow.cpp b/trview.app/Windows/CameraSink/CameraSinkWindow.cpp index b8558e10f..509888e98 100644 --- a/trview.app/Windows/CameraSink/CameraSinkWindow.cpp +++ b/trview.app/Windows/CameraSink/CameraSinkWindow.cpp @@ -309,7 +309,7 @@ namespace trview ImGui::Spacing(); - ImGui::Text("Triggered By"); + ImGui::Text("Trigger References"); if (ImGui::BeginTable(Names::triggers_list.c_str(), 3, ImGuiTableFlags_ScrollY | ImGuiTableFlags_Sortable | ImGuiTableFlags_SizingFixedFit, ImVec2(-1, -1))) { ImGui::TableSetupColumn("#"); @@ -392,7 +392,7 @@ namespace trview [](const auto& r) { if (auto room = r.lock()) { return static_cast(room->number()); } return 0.0f; }) | std::ranges::to(); }); - _filters.add_multi_getter("Triggered By", [&](auto&& camera_sink) + _filters.add_multi_getter("Trigger References", [&](auto&& camera_sink) { std::vector results; for (const auto& trigger : camera_sink.triggers()) diff --git a/trview.app/Windows/ItemsWindow.cpp b/trview.app/Windows/ItemsWindow.cpp index 97edbed69..7f855632b 100644 --- a/trview.app/Windows/ItemsWindow.cpp +++ b/trview.app/Windows/ItemsWindow.cpp @@ -267,7 +267,7 @@ namespace trview { on_add_to_route(_selected_item); } - ImGui::Text("Triggered By"); + ImGui::Text("Trigger References"); if (ImGui::BeginTable(Names::triggers_list.c_str(), 3, ImGuiTableFlags_ScrollY | ImGuiTableFlags_Sortable | ImGuiTableFlags_SizingFixedFit, ImVec2(-1, -1))) { ImGui::TableSetupColumn("#"); @@ -406,7 +406,7 @@ namespace trview _filters.add_getter("Invisible", [](auto&& item) { return item.invisible_flag(); }); _filters.add_getter("Flags", [](auto&& item) { return format_binary(item.activation_flags()); }); _filters.add_getter("OCB", [](auto&& item) { return static_cast(item.ocb()); }); - _filters.add_multi_getter("Triggered By", [](auto&& item) + _filters.add_multi_getter("Trigger References", [](auto&& item) { std::vector results; for (auto trigger : item.triggers())