Skip to content

Commit

Permalink
[objects] add: PlaceableInfo::editor_name
Browse files Browse the repository at this point in the history
  • Loading branch information
jd28 committed Feb 9, 2025
1 parent bcb546a commit 8bb63ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/nw/objects/Placeable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ PlaceableInfo::PlaceableInfo(const TwoDARowView& tda)
tda.get_to("Static", static_);
}

String PlaceableInfo::editor_name() const
{
auto string = nw::kernel::strings().get(name);
if (!string.empty()) { return string; }
return label;
}

bool PlaceableScripts::from_json(const nlohmann::json& archive)
{
archive.at("on_click").get_to(on_click);
Expand Down
3 changes: 3 additions & 0 deletions lib/nw/objects/Placeable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ struct PlaceableInfo {
// Reflection
bool static_;

/// Gets the name to display when using in contexts like a toolset.
String editor_name() const;

bool valid() const noexcept { return name != 0xFFFFFFFF || !label.empty(); }
};

Expand Down

0 comments on commit 8bb63ba

Please sign in to comment.