Skip to content

Commit

Permalink
Merge branch 'master' into issue/970
Browse files Browse the repository at this point in the history
  • Loading branch information
chreden authored May 12, 2024
2 parents ff3fc68 + f8913b9 commit 3f7d781
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
29 changes: 29 additions & 0 deletions trview.app.tests/Windows/ViewerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,35 @@ TEST(Viewer, SectorHighlightForwarded)
ui.on_sector_hover(sector);
}

TEST(Viewer, AlternateGroupForwarded)
{
auto level = mock_shared<MockLevel>();
EXPECT_CALL(*level, set_alternate_group(6, true)).Times(1);
ON_CALL(*level, alternate_groups).WillByDefault(Return(std::set<uint32_t>{ 6 }));

auto [ui_ptr, ui] = create_mock<MockViewerUI>();
EXPECT_CALL(ui, set_alternate_group(6, true)).Times(1);

auto viewer = register_test_module().with_ui(std::move(ui_ptr)).build();
viewer->open(level, ILevel::OpenMode::Full);

ui.on_alternate_group(6, true);
}

TEST(Viewer, InvalidAlternateGroupNotForwarded)
{
auto level = mock_shared<MockLevel>();
EXPECT_CALL(*level, set_alternate_group).Times(0);

auto [ui_ptr, ui] = create_mock<MockViewerUI>();
EXPECT_CALL(ui, set_alternate_group).Times(0);

auto viewer = register_test_module().with_ui(std::move(ui_ptr)).build();
viewer->open(level, ILevel::OpenMode::Full);

ui.on_alternate_group(6, true);
}

TEST(Viewer, FontForwarded)
{
auto [ui_ptr, ui] = create_mock<MockViewerUI>();
Expand Down
9 changes: 6 additions & 3 deletions trview.app/Windows/Viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,9 +961,12 @@ namespace trview
{
if (auto level = _level.lock())
{
_was_alternate_select = true;
level->set_alternate_group(group, enabled);
_ui->set_alternate_group(group, enabled);
if (std::ranges::contains(level->alternate_groups(), group))
{
_was_alternate_select = true;
level->set_alternate_group(group, enabled);
_ui->set_alternate_group(group, enabled);
}
}
}

Expand Down

0 comments on commit 3f7d781

Please sign in to comment.