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_entity = {};
|
||||||
m_portraitMode = PortraitMode::Full;
|
m_portraitMode = PortraitMode::Full;
|
||||||
m_scale = 1;
|
m_scale = 1;
|
||||||
|
m_renderHumanoid = false;
|
||||||
m_iconMode = false;
|
m_iconMode = false;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
@ -37,9 +38,15 @@ void PortraitWidget::renderImpl() {
|
|||||||
context()->drawInterfaceQuad(m_iconImage, Vec2F(screenPosition()), m_scale);
|
context()->drawInterfaceQuad(m_iconImage, Vec2F(screenPosition()), m_scale);
|
||||||
}
|
}
|
||||||
if (m_entity) {
|
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) {
|
for (auto& i : portrait) {
|
||||||
i.scale(m_scale);
|
i.scale(humanoid ? m_scale * 8.0f : m_scale);
|
||||||
context()->drawInterfaceDrawable(i, Vec2F(screenPosition() + offset));
|
context()->drawInterfaceDrawable(i, Vec2F(screenPosition() + offset));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -88,6 +95,10 @@ void PortraitWidget::setIconMode() {
|
|||||||
updateSize();
|
updateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PortraitWidget::setRenderHumanoid(bool renderHumanoid) {
|
||||||
|
m_renderHumanoid = renderHumanoid;
|
||||||
|
}
|
||||||
|
|
||||||
bool PortraitWidget::sendEvent(InputEvent const&) {
|
bool PortraitWidget::sendEvent(InputEvent const&) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ public:
|
|||||||
void setMode(PortraitMode mode);
|
void setMode(PortraitMode mode);
|
||||||
void setScale(float scale);
|
void setScale(float scale);
|
||||||
void setIconMode();
|
void setIconMode();
|
||||||
|
void setRenderHumanoid(bool);
|
||||||
bool sendEvent(InputEvent const& event);
|
bool sendEvent(InputEvent const& event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -35,6 +36,7 @@ private:
|
|||||||
AssetPath m_noEntityImagePart;
|
AssetPath m_noEntityImagePart;
|
||||||
float m_scale;
|
float m_scale;
|
||||||
|
|
||||||
|
bool m_renderHumanoid;
|
||||||
bool m_iconMode;
|
bool m_iconMode;
|
||||||
AssetPath m_iconImage;
|
AssetPath m_iconImage;
|
||||||
Vec2I m_iconOffset;
|
Vec2I m_iconOffset;
|
||||||
|
@ -378,6 +378,8 @@ WidgetConstructResult WidgetParser::portraitHandler(String const& name, Json con
|
|||||||
|
|
||||||
if (config.contains("portraitMode"))
|
if (config.contains("portraitMode"))
|
||||||
portrait->setMode(PortraitModeNames.getLeft(config.getString("portraitMode")));
|
portrait->setMode(PortraitModeNames.getLeft(config.getString("portraitMode")));
|
||||||
|
if (config.contains("renderHumanoid"))
|
||||||
|
portrait->setRenderHumanoid(config.getBool("renderHumanoid"));
|
||||||
|
|
||||||
portrait->setScale(config.getFloat("scale", 1));
|
portrait->setScale(config.getFloat("scale", 1));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user