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

Method ItemSlotWidget

source/windowing/StarItemSlotWidget.cpp:52–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52ItemSlotWidget::ItemSlotWidget(ItemPtr const& item, String const& backingImage)
53 : m_item(item), m_backingImage(backingImage) {
54 m_drawBackingImageWhenFull = false;
55 m_drawBackingImageWhenEmpty = true;
56 m_progress = 1;
57
58 auto assets = Root::singleton().assets();
59 auto interfaceConfig = assets->json("/interface.config");
60 m_countPosition = TextPositioning(jsonToVec2F(interfaceConfig.get("itemCountRightAnchor")), HorizontalAnchor::RightAnchor);
61 m_countFontMode = FontMode::Normal;
62 m_textStyle = interfaceConfig.get("itemSlotTextStyle");
63 m_itemDraggableArea = jsonToRectI(interfaceConfig.get("itemDraggableArea"));
64 m_durabilityOffset = jsonToVec2I(interfaceConfig.get("itemIconDurabilityOffset"));
65
66 auto newItemIndicatorConfig = interfaceConfig.get("newItemAnimation");
67 m_newItemIndicator = Animation(newItemIndicatorConfig);
68 // End animation before it begins, only display when triggered
69 m_newItemIndicator.update(newItemIndicatorConfig.getDouble("animationCycle") * newItemIndicatorConfig.getDouble("loops", 1.0f));
70
71 Json highlightAnimationConfig = interfaceConfig.get("highlightAnimation");
72 m_highlightAnimation = Animation(highlightAnimationConfig);
73 m_highlightEnabled = false;
74
75 Vec2I backingImageSize;
76 if (m_backingImage.size()) {
77 auto imgMetadata = Root::singleton().imageMetadataDatabase();
78 backingImageSize = Vec2I(imgMetadata->imageSize(m_backingImage));
79 }
80 setSize(m_itemDraggableArea.max().piecewiseMax(backingImageSize));
81
82 WidgetParser parser;
83
84 parser.construct(assets->json("/interface/itemSlot.config").get("config"), this);
85 m_durabilityBar = fetchChild<ProgressWidget>("durabilityBar");
86 m_durabilityBar->hide();
87 m_showDurability = false;
88 m_showCount = true;
89 m_showRarity = true;
90 m_showLinkIndicator = false;
91
92 disableScissoring();
93}
94
95void ItemSlotWidget::update(float dt) {
96 if (m_item)

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
TextPositioningClass · 0.85
jsonToVec2FFunction · 0.85
jsonToRectIFunction · 0.85
jsonToVec2IFunction · 0.85
AnimationClass · 0.85
assetsMethod · 0.80
jsonMethod · 0.80
getDoubleMethod · 0.80
imageMetadataDatabaseMethod · 0.80
piecewiseMaxMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected