Add unused support for using the actual humanoid for armor preview

This commit is contained in:
Kae 2023-06-28 01:34:37 +10:00
parent 59ab7dabe6
commit 4c006afc94
7 changed files with 43 additions and 19 deletions

View File

@ -24,5 +24,5 @@
"buttonHoverOffSound" : [ "/sfx/interface/button/hover_off.wav" ],
"debugSpatialClearTime" : 0.0,
"debugOffset" : [32, 100]
"debugOffset" : [64, 100]
}

View File

@ -798,6 +798,8 @@ void MainInterface::renderInWorldElements() {
if (m_disableHud)
return;
m_guiContext->setDefaultFont();
m_guiContext->setFontProcessingDirectives("");
m_guiContext->setFontColor(Vec4B::filled(255));
m_questIndicatorPainter->render();
m_nameplatePainter->render();
@ -808,6 +810,8 @@ void MainInterface::render() {
if (m_disableHud)
return;
m_guiContext->setDefaultFont();
m_guiContext->setFontProcessingDirectives("");
m_guiContext->setFontColor(Vec4B::filled(255));
renderBreath();
renderMessages();

View File

@ -896,7 +896,7 @@ List<Drawable> Humanoid::renderSkull() const {
Root::singleton().speciesDatabase()->species(m_identity.species)->skull(), 1.0f, true, Vec2F())};
}
List<Drawable> Humanoid::renderDummy(Gender gender, HeadArmor const* head, ChestArmor const* chest, LegsArmor const* legs, BackArmor const* back) {
Humanoid Humanoid::makeDummy(Gender gender) {
auto assets = Root::singleton().assets();
Humanoid humanoid(assets->json("/humanoid.config"));
@ -906,30 +906,34 @@ List<Drawable> Humanoid::renderDummy(Gender gender, HeadArmor const* head, Chest
humanoid.m_backArmFrameset = assets->json("/humanoid/any/dummy.config:backArm").toString();
humanoid.setFacingDirection(DirectionNames.getLeft(assets->json("/humanoid/any/dummy.config:direction").toString()));
return humanoid;
}
List<Drawable> Humanoid::renderDummy(Gender gender, HeadArmor const* head, ChestArmor const* chest, LegsArmor const* legs, BackArmor const* back) {
if (head) {
humanoid.setHeadArmorFrameset(head->frameset(gender));
humanoid.setHeadArmorDirectives(head->directives());
humanoid.setHelmetMaskDirectives(head->maskDirectives());
setHeadArmorFrameset(head->frameset(gender));
setHeadArmorDirectives(head->directives());
setHelmetMaskDirectives(head->maskDirectives());
}
if (chest) {
humanoid.setBackSleeveFrameset(chest->backSleeveFrameset(gender));
humanoid.setFrontSleeveFrameset(chest->frontSleeveFrameset(gender));
humanoid.setChestArmorFrameset(chest->bodyFrameset(gender));
humanoid.setChestArmorDirectives(chest->directives());
setBackSleeveFrameset(chest->backSleeveFrameset(gender));
setFrontSleeveFrameset(chest->frontSleeveFrameset(gender));
setChestArmorFrameset(chest->bodyFrameset(gender));
setChestArmorDirectives(chest->directives());
}
if (legs) {
humanoid.setLegsArmorFrameset(legs->frameset(gender));
humanoid.setLegsArmorDirectives(legs->directives());
setLegsArmorFrameset(legs->frameset(gender));
setLegsArmorDirectives(legs->directives());
}
if (back) {
humanoid.setBackArmorFrameset(back->frameset(gender));
humanoid.setBackArmorDirectives(back->directives());
setBackArmorFrameset(back->frameset(gender));
setBackArmorDirectives(back->directives());
}
auto drawables = humanoid.render();
auto drawables = render();
Drawable::scaleAll(drawables, TilePixels);
return drawables;

View File

@ -98,6 +98,7 @@ public:
Humanoid(Json const& config);
Humanoid(HumanoidIdentity const& identity);
Humanoid(Humanoid const&) = default;
struct HumanoidTiming {
explicit HumanoidTiming(Json config = Json());
@ -199,9 +200,10 @@ public:
List<Drawable> renderSkull() const;
static Humanoid makeDummy(Gender gender);
// Renders to centered drawables (centered on the normal image center for the
// player graphics), (in pixels, not world space)
static List<Drawable> renderDummy(Gender gender, HeadArmor const* head = nullptr, ChestArmor const* chest = nullptr,
List<Drawable> renderDummy(Gender gender, HeadArmor const* head = nullptr, ChestArmor const* chest = nullptr,
LegsArmor const* legs = nullptr, BackArmor const* back = nullptr);
Vec2F primaryHandPosition(Vec2F const& offset) const;

View File

@ -2013,6 +2013,10 @@ void Player::setPersonality(Personality const& personality) {
m_humanoid->setIdentity(m_identity);
}
HumanoidPtr Player::humanoid() {
return m_humanoid;
}
List<String> Player::pullQueuedMessages() {
return take(m_queuedMessages);
}

View File

@ -300,6 +300,8 @@ public:
void setGender(Gender const& gender);
void setPersonality(Personality const& personality);
HumanoidPtr humanoid();
void setAdmin(bool isAdmin);
bool isAdmin() const override;

View File

@ -113,7 +113,9 @@ Directives const& HeadArmor::maskDirectives() const {
List<Drawable> HeadArmor::preview(PlayerPtr const& viewer) const {
Gender gender = viewer ? viewer->gender() : Gender::Male;
return Humanoid::renderDummy(gender, this);
Humanoid humanoid = Humanoid::makeDummy(gender);
//Humanoid humanoid = viewer ? *viewer->humanoid() : Humanoid::makeDummy(gender);
return humanoid.renderDummy(gender, this);
}
ChestArmor::ChestArmor(Json const& config, String const& directory, Json const& data)
@ -156,7 +158,9 @@ String const& ChestArmor::backSleeveFrameset(Gender gender) const {
List<Drawable> ChestArmor::preview(PlayerPtr const& viewer) const {
Gender gender = viewer ? viewer->gender() : Gender::Male;
return Humanoid::renderDummy(gender, nullptr, this);
Humanoid humanoid = Humanoid::makeDummy(gender);
//Humanoid humanoid = viewer ? *viewer->humanoid() : Humanoid::makeDummy(gender);
return humanoid.renderDummy(gender, nullptr, this);
}
LegsArmor::LegsArmor(Json const& config, String const& directory, Json const& data)
@ -178,7 +182,9 @@ String const& LegsArmor::frameset(Gender gender) const {
List<Drawable> LegsArmor::preview(PlayerPtr const& viewer) const {
Gender gender = viewer ? viewer->gender() : Gender::Male;
return Humanoid::renderDummy(gender, nullptr, nullptr, this);
Humanoid humanoid = Humanoid::makeDummy(gender);
//Humanoid humanoid = viewer ? *viewer->humanoid() : Humanoid::makeDummy(gender);
return humanoid.renderDummy(gender, nullptr, nullptr, this);
}
BackArmor::BackArmor(Json const& config, String const& directory, Json const& data)
@ -200,7 +206,9 @@ String const& BackArmor::frameset(Gender gender) const {
List<Drawable> BackArmor::preview(PlayerPtr const& viewer) const {
Gender gender = viewer ? viewer->gender() : Gender::Male;
return Humanoid::renderDummy(gender, nullptr, nullptr, nullptr, this);
Humanoid humanoid = Humanoid::makeDummy(gender);
//Humanoid humanoid = viewer ? *viewer->humanoid() : Humanoid::makeDummy(gender);
return humanoid.renderDummy(gender, nullptr, nullptr, nullptr, this);
}
}