Fun: Draw the actual Humanoid in the inventory pane
undecided. might need to set a scissor rect on the portrait
This commit is contained in:
parent
69b8eed8f7
commit
1fc295b979
@ -0,0 +1,7 @@
|
||||
{
|
||||
"paneLayout" : {
|
||||
"portrait" : {
|
||||
"renderHumanoid" : true
|
||||
}
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ PortraitWidget::PortraitWidget() {
|
||||
m_entity = {};
|
||||
m_portraitMode = PortraitMode::Full;
|
||||
m_scale = 1;
|
||||
m_renderHumanoid = false;
|
||||
m_iconMode = false;
|
||||
|
||||
init();
|
||||
@ -37,9 +38,15 @@ void PortraitWidget::renderImpl() {
|
||||
context()->drawInterfaceQuad(m_iconImage, Vec2F(screenPosition()), m_scale);
|
||||
}
|
||||
if (m_entity) {
|
||||
List<Drawable> portrait = m_entity->portrait(m_portraitMode);
|
||||
HumanoidPtr humanoid = nullptr;
|
||||
if (m_renderHumanoid) {
|
||||
if (auto player = as<Player>(m_entity))
|
||||
humanoid = player->humanoid();
|
||||
}
|
||||
|
||||
List<Drawable> portrait = humanoid ? humanoid->render() : m_entity->portrait(m_portraitMode);
|
||||
for (auto& i : portrait) {
|
||||
i.scale(m_scale);
|
||||
i.scale(humanoid ? m_scale * 8.0f : m_scale);
|
||||
context()->drawInterfaceDrawable(i, Vec2F(screenPosition() + offset));
|
||||
}
|
||||
} else {
|
||||
@ -88,6 +95,10 @@ void PortraitWidget::setIconMode() {
|
||||
updateSize();
|
||||
}
|
||||
|
||||
void PortraitWidget::setRenderHumanoid(bool renderHumanoid) {
|
||||
m_renderHumanoid = renderHumanoid;
|
||||
}
|
||||
|
||||
bool PortraitWidget::sendEvent(InputEvent const&) {
|
||||
return false;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public:
|
||||
void setMode(PortraitMode mode);
|
||||
void setScale(float scale);
|
||||
void setIconMode();
|
||||
void setRenderHumanoid(bool);
|
||||
bool sendEvent(InputEvent const& event);
|
||||
|
||||
protected:
|
||||
@ -35,6 +36,7 @@ private:
|
||||
AssetPath m_noEntityImagePart;
|
||||
float m_scale;
|
||||
|
||||
bool m_renderHumanoid;
|
||||
bool m_iconMode;
|
||||
AssetPath m_iconImage;
|
||||
Vec2I m_iconOffset;
|
||||
|
@ -378,6 +378,8 @@ WidgetConstructResult WidgetParser::portraitHandler(String const& name, Json con
|
||||
|
||||
if (config.contains("portraitMode"))
|
||||
portrait->setMode(PortraitModeNames.getLeft(config.getString("portraitMode")));
|
||||
if (config.contains("renderHumanoid"))
|
||||
portrait->setRenderHumanoid(config.getBool("renderHumanoid"));
|
||||
|
||||
portrait->setScale(config.getFloat("scale", 1));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user