Skip to content

Commit

Permalink
Include Look At in triggered by, rename to references
Browse files Browse the repository at this point in the history
Include LookAt in triggered by - rename triggered by to trigger references in UI and Lua.
Closes #1273
  • Loading branch information
chreden committed Aug 9, 2024
1 parent 02ac331 commit d895348
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions doc/lua/camera_sink.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 |
2 changes: 1 addition & 1 deletion doc/lua/item.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
8 changes: 4 additions & 4 deletions trview.app.tests/Lua/Elements/Lua_CameraSinkTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
8 changes: 4 additions & 4 deletions trview.app.tests/Lua/Elements/Lua_ItemTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions trview.app.ui.tests/ContextMenuTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void register_context_menu_tests(ImGuiTestEngine* engine)
ASSERT_FALSE(menu.visible());
});

test<ContextMenu>(engine, "Context Menu", "Triggered By",
test<ContextMenu>(engine, "Context Menu", "Trigger References",
[](ImGuiTestContext* ctx) { ctx->GetVars<ContextMenu>().render(); },
[](ImGuiTestContext* ctx)
{
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion trview.app/Elements/Trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion trview.app/Lua/Elements/CameraSink/Lua_CameraSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion trview.app/Lua/Elements/Item/Lua_Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion trview.app/UI/ContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion trview.app/UI/ContextMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions trview.app/Windows/CameraSink/CameraSinkWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("#");
Expand Down Expand Up @@ -392,7 +392,7 @@ namespace trview
[](const auto& r) { if (auto room = r.lock()) { return static_cast<float>(room->number()); } return 0.0f; }) |
std::ranges::to<std::vector>();
});
_filters.add_multi_getter<float>("Triggered By", [&](auto&& camera_sink)
_filters.add_multi_getter<float>("Trigger References", [&](auto&& camera_sink)
{
std::vector<float> results;
for (const auto& trigger : camera_sink.triggers())
Expand Down
4 changes: 2 additions & 2 deletions trview.app/Windows/ItemsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("#");
Expand Down Expand Up @@ -406,7 +406,7 @@ namespace trview
_filters.add_getter<bool>("Invisible", [](auto&& item) { return item.invisible_flag(); });
_filters.add_getter<std::string>("Flags", [](auto&& item) { return format_binary(item.activation_flags()); });
_filters.add_getter<float>("OCB", [](auto&& item) { return static_cast<float>(item.ocb()); });
_filters.add_multi_getter<float>("Triggered By", [](auto&& item)
_filters.add_multi_getter<float>("Trigger References", [](auto&& item)
{
std::vector<float> results;
for (auto trigger : item.triggers())
Expand Down

0 comments on commit d895348

Please sign in to comment.