2024-02-25 14:46:47 +00:00
|
|
|
#pragma once
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
#include "StarWidget.hpp"
|
|
|
|
#include "StarProgressWidget.hpp"
|
|
|
|
#include "StarAnimation.hpp"
|
|
|
|
|
|
|
|
namespace Star {
|
|
|
|
|
|
|
|
STAR_CLASS(Item);
|
|
|
|
STAR_CLASS(ItemSlotWidget);
|
|
|
|
|
|
|
|
static float const ItemIndicateNewTime = 1.5f;
|
|
|
|
|
|
|
|
class ItemSlotWidget : public Widget {
|
|
|
|
public:
|
|
|
|
ItemSlotWidget(ItemPtr const& item, String const& backingImage);
|
|
|
|
|
2023-07-20 14:58:49 +00:00
|
|
|
virtual void update(float dt) override;
|
2023-06-20 04:33:09 +00:00
|
|
|
bool sendEvent(InputEvent const& event) override;
|
|
|
|
void setCallback(WidgetCallbackFunc callback);
|
|
|
|
void setRightClickCallback(WidgetCallbackFunc callback);
|
2024-03-27 05:00:13 +00:00
|
|
|
void setMiddleClickCallback(WidgetCallbackFunc callback);
|
2023-06-20 04:33:09 +00:00
|
|
|
void setItem(ItemPtr const& item);
|
|
|
|
ItemPtr item() const;
|
|
|
|
void setProgress(float progress);
|
|
|
|
void setBackingImageAffinity(bool full, bool empty);
|
|
|
|
void setCountPosition(TextPositioning textPositioning);
|
|
|
|
void setCountFontMode(FontMode fontMode);
|
|
|
|
|
|
|
|
void showDurability(bool show);
|
|
|
|
void showCount(bool show);
|
|
|
|
void showRarity(bool showRarity);
|
|
|
|
void showLinkIndicator(bool showLinkIndicator);
|
|
|
|
|
|
|
|
void indicateNew();
|
|
|
|
|
|
|
|
void setHighlightEnabled(bool highlight);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void renderImpl() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
ItemPtr m_item;
|
|
|
|
|
|
|
|
String m_backingImage;
|
|
|
|
bool m_drawBackingImageWhenFull;
|
|
|
|
bool m_drawBackingImageWhenEmpty;
|
|
|
|
bool m_showDurability;
|
|
|
|
bool m_showCount;
|
|
|
|
bool m_showRarity;
|
|
|
|
bool m_showLinkIndicator;
|
|
|
|
|
|
|
|
TextPositioning m_countPosition;
|
|
|
|
FontMode m_countFontMode;
|
|
|
|
|
|
|
|
Vec2I m_durabilityOffset;
|
|
|
|
RectI m_itemDraggableArea;
|
|
|
|
|
|
|
|
int m_fontSize;
|
2023-06-21 12:29:40 +00:00
|
|
|
String m_font;
|
2023-06-20 04:33:09 +00:00
|
|
|
Color m_fontColor;
|
|
|
|
|
|
|
|
WidgetCallbackFunc m_callback;
|
|
|
|
WidgetCallbackFunc m_rightClickCallback;
|
2024-03-27 05:00:13 +00:00
|
|
|
WidgetCallbackFunc m_middleClickCallback;
|
2023-06-20 04:33:09 +00:00
|
|
|
float m_progress;
|
|
|
|
|
|
|
|
ProgressWidgetPtr m_durabilityBar;
|
|
|
|
|
|
|
|
Animation m_newItemIndicator;
|
|
|
|
|
|
|
|
bool m_highlightEnabled;
|
|
|
|
Animation m_highlightAnimation;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|