MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / renderImpl

Method renderImpl

source/windowing/StarPortraitWidget.cpp:31–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31void PortraitWidget::renderImpl() {
32 auto imgMetadata = Root::singleton().imageMetadataDatabase();
33
34 Vec2I offset = Vec2I();
35 if (m_iconMode) {
36 auto imgSize = Vec2F(imgMetadata->imageSize(m_iconImage));
37 offset = Vec2I(m_scale * imgSize / 2);
38 offset += m_iconOffset;
39 context()->drawInterfaceQuad(m_iconImage, Vec2F(screenPosition()), m_scale);
40 }
41 if (m_entity) {
42 HumanoidPtr humanoid = nullptr;
43 if (m_renderHumanoid) {
44 if (auto player = as<Player>(m_entity))
45 if (!player->isPermaDead())
46 humanoid = player->humanoid();
47 }
48
49 List<Drawable> portrait = humanoid ? humanoid->render(false, false) : m_entity->portrait(m_portraitMode);
50 for (auto& i : portrait) {
51 i.scale(humanoid ? m_scale * 8.0f : m_scale);
52 context()->drawInterfaceDrawable(i, Vec2F(screenPosition() + offset));
53 }
54 } else {
55 if (m_portraitMode == PortraitMode::Bust || m_portraitMode == PortraitMode::Head) {
56 Vec2I pos = offset;
57 auto imgSize = Vec2F(imgMetadata->imageSize(m_noEntityImagePart));
58 pos -= Vec2I(m_scale * imgSize * 0.5);
59 context()->drawInterfaceQuad(m_noEntityImagePart, Vec2F(screenPosition() + pos), m_scale);
60 } else {
61 Vec2I pos = offset;
62 auto imgSize = Vec2F(imgMetadata->imageSize(m_noEntityImageFull));
63 pos -= Vec2I(m_scale * imgSize * 0.5);
64 context()->drawInterfaceQuad(m_noEntityImageFull, Vec2F(screenPosition() + pos), m_scale);
65 }
66 }
67}
68
69void PortraitWidget::init() {
70 auto assets = Root::singleton().assets();

Callers

nothing calls this directly

Calls 10

singletonClass · 0.85
imageMetadataDatabaseMethod · 0.80
drawInterfaceQuadMethod · 0.80
isPermaDeadMethod · 0.80
humanoidMethod · 0.80
drawInterfaceDrawableMethod · 0.80
imageSizeMethod · 0.45
renderMethod · 0.45
portraitMethod · 0.45
scaleMethod · 0.45

Tested by

no test coverage detected