-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Categories property to Items (#1202)
Add a `Categories` property to `Item`. The user can see this category in the items window and is able to use filters against the category property. This will help for finding all pickups, all enemies or for excluding a certain type of item amongst other uses. The `Categories` field is accessible from Lua so scripts can alter the categories on an item. The categories are taken as a copy of the initial category values from the type list so they can be safely changed by a script. Closes #1200
- Loading branch information
Showing
34 changed files
with
5,128 additions
and
4,183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include <trview.app/Elements/TypeInfoLookup.h> | ||
|
||
using namespace trview; | ||
using namespace trlevel; | ||
|
||
// Test that looking up an ID gives the correct result. | ||
TEST(TypeInfoLookup, LookupTR1) | ||
{ | ||
std::string json = "{\"games\":{\"tr1\":[{\"id\":123,\"name\":\"Test Name\"}]}}"; | ||
|
||
TypeInfoLookup lookup(json); | ||
|
||
ASSERT_EQ("Test Name", lookup.lookup(LevelVersion::Tomb1, 123, 0).name); | ||
} | ||
|
||
// Tests that if there are identical entries for different games, the correct result is returned. | ||
TEST(TypeInfoLookup, LookupMultipleGames) | ||
{ | ||
std::string json = "{\"games\":{\"tr1\":[{\"id\":123,\"name\":\"Test Name TR1\"}],\"tr2\":[{\"id\":123,\"name\":\"Test Name TR2\"}]}}"; | ||
|
||
TypeInfoLookup lookup(json); | ||
|
||
ASSERT_EQ("Test Name TR1", lookup.lookup(LevelVersion::Tomb1, 123, 0).name); | ||
ASSERT_EQ("Test Name TR2", lookup.lookup(LevelVersion::Tomb2, 123, 0).name); | ||
} | ||
|
||
// Tests that if the name is missing, it still returns the number. | ||
TEST(TypeInfoLookup, LookupMissingItem) | ||
{ | ||
std::string json = "{}"; | ||
|
||
TypeInfoLookup lookup(json); | ||
|
||
ASSERT_EQ("123", lookup.lookup(LevelVersion::Tomb3, 123, 0).name); | ||
} | ||
|
||
TEST(TypeInfoLookup, LookupNormalMutantEggs) | ||
{ | ||
std::string json = "{\"games\":{\"tr1\":[{\"id\":163,\"name\":\"Test Name 1\"}]}}"; | ||
TypeInfoLookup lookup(json); | ||
|
||
auto winged = lookup.lookup(trlevel::LevelVersion::Tomb1, 163, 0).name; | ||
auto shooter = lookup.lookup(trlevel::LevelVersion::Tomb1, 163, 1 << 9).name; | ||
auto centaur = lookup.lookup(trlevel::LevelVersion::Tomb1, 163, 2 << 9).name; | ||
auto torso = lookup.lookup(trlevel::LevelVersion::Tomb1, 163, 4 << 9).name; | ||
auto grounded = lookup.lookup(trlevel::LevelVersion::Tomb1, 163, 8 << 9).name; | ||
auto def = lookup.lookup(trlevel::LevelVersion::Tomb1, 163, 3 << 9).name; | ||
|
||
ASSERT_EQ(winged, "Mutant Egg (Winged)"); | ||
ASSERT_EQ(shooter, "Mutant Egg (Shooter)"); | ||
ASSERT_EQ(centaur, "Mutant Egg (Centaur)"); | ||
ASSERT_EQ(torso, "Mutant Egg (Torso)"); | ||
ASSERT_EQ(grounded, "Mutant Egg (Grounded)"); | ||
ASSERT_EQ(def, "Mutant Egg (Winged)"); | ||
} | ||
|
||
TEST(TypeInfoLookup, LookupBigMutantEggs) | ||
{ | ||
std::string json = "{\"games\":{\"tr1\":[{\"id\":181,\"name\":\"Test Name 2\"}]}}"; | ||
TypeInfoLookup lookup(json); | ||
|
||
auto winged = lookup.lookup(trlevel::LevelVersion::Tomb1, 181, 0).name; | ||
auto shooter = lookup.lookup(trlevel::LevelVersion::Tomb1, 181, 1 << 9).name; | ||
auto centaur = lookup.lookup(trlevel::LevelVersion::Tomb1, 181, 2 << 9).name; | ||
auto torso = lookup.lookup(trlevel::LevelVersion::Tomb1, 181, 4 << 9).name; | ||
auto grounded = lookup.lookup(trlevel::LevelVersion::Tomb1, 181, 8 << 9).name; | ||
auto def = lookup.lookup(trlevel::LevelVersion::Tomb1, 181, 3 << 9).name; | ||
|
||
ASSERT_EQ(winged, "Mutant Egg (Winged)"); | ||
ASSERT_EQ(shooter, "Mutant Egg (Shooter)"); | ||
ASSERT_EQ(centaur, "Mutant Egg (Centaur)"); | ||
ASSERT_EQ(torso, "Mutant Egg (Torso)"); | ||
ASSERT_EQ(grounded, "Mutant Egg (Grounded)"); | ||
ASSERT_EQ(def, "Mutant Egg (Winged)"); | ||
} | ||
|
||
TEST(TypeInfoLookup, LookupNormalMutantEggsTR2) | ||
{ | ||
std::string json = "{\"games\":{\"tr1\":[{\"id\":163,\"name\":\"Test Name 1\"}],\"tr2\":[{\"id\":163,\"name\":\"Test Name 2\"}]}}"; | ||
TypeInfoLookup lookup(json); | ||
|
||
auto winged = lookup.lookup(trlevel::LevelVersion::Tomb2, 163, 0).name; | ||
|
||
ASSERT_EQ(winged, "Test Name 2"); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.