9 private Widget m_infoWidget;
10 private VerticalLayoutWidget m_wHintWidget;
11 private TextWidget m_wTextName;
12 private TextWidget m_wTextDescription;
13 private TextWidget m_wTextWeight;
14 private ImageWidget m_wItemIcon;
16 protected Widget m_wWidgetUnderCursor;
17 protected bool m_bForceShow;
19 private string m_sHintLayout =
"{9996B50BE8DFED5F}UI/layouts/Menus/Inventory/InventoryItemHintElement.layout";
24 protected void ShowInfoWidget(
bool bShow )
28 m_infoWidget.SetVisible(
true );
32 if ( !m_wWidgetUnderCursor )
34 if ( WidgetManager.GetWidgetUnderCursor() != m_wWidgetUnderCursor )
36 m_infoWidget.SetVisible(
true );
40 void Show(
float fDelay = 0.0, Widget w =
null,
bool forceShow =
false )
42 m_bForceShow = forceShow;
43 m_wWidgetUnderCursor = w;
45 ShowInfoWidget(
true );
48 GetGame().GetCallqueue().Remove( ShowInfoWidget );
49 GetGame().GetCallqueue().CallLater( ShowInfoWidget, fDelay*1000,
false,
true );
54 void SetIcon(ResourceName iconPath, Color color =
null)
56 if (iconPath.IsEmpty())
59 m_wItemIcon.SetVisible(m_wItemIcon.LoadImageTexture(0, iconPath));
61 m_wItemIcon.SetColor(color);
65 void ShowIcon(
bool isVisible)
67 m_wItemIcon.SetVisible(isVisible);
71 void Hide(
float fDelay = 1.0 )
73 m_infoWidget.SetVisible(
false );
74 m_infoWidget.SetEnabled(
false );
75 m_wItemIcon.SetVisible(
false);
77 Widget childWidget = m_wHintWidget.GetChildren();
80 Widget next = childWidget.GetSibling();
81 m_wHintWidget.RemoveChild(childWidget);
85 GetGame().GetCallqueue().Remove(ShowInfoWidget);
89 void Move(
float x,
float y )
91 if ( !m_pFrameSlotUI )
93 m_pFrameSlotUI.SetPosX( x );
94 m_pFrameSlotUI.SetPosY( y );
98 void SetName(
string sName )
100 m_wTextName.SetText( sName );
104 void SetDescription(
string sDescr )
108 m_wTextDescription.SetEnabled(
true );
109 m_wTextDescription.SetVisible(
true );
110 m_wTextDescription.SetText( sDescr );
114 m_wTextDescription.SetEnabled(
false );
115 m_wTextDescription.SetVisible(
false );
122 WorkspaceWidget workspace =
GetGame().GetWorkspace();
125 Widget hintChild = m_wHintWidget.GetChildren();
129 deleteHint = hintChild;
130 hintChild = deleteHint.GetSibling();
135 foreach (SCR_InventoryItemHintUIInfo hintUIInfo : itemHintArray)
137 if (!hintUIInfo.CanBeShown(item, focusedSlot))
140 Widget createdWidget = workspace.CreateWidgets(m_sHintLayout, m_wHintWidget);
144 hintUIInfo.SetItemHintNameTo(item, RichTextWidget.Cast(createdWidget.FindAnyWidget(
"ItemInfo_hintText")));
145 hintUIInfo.SetIconTo(ImageWidget.Cast(createdWidget.FindAnyWidget(
"ItemInfo_hintIcon")));
150 void SetWeight(
string sWeight )
152 if (!sWeight.IsEmpty())
154 m_wTextWeight.SetEnabled(
true );
155 m_wTextWeight.SetVisible(
true );
156 m_wTextWeight.SetTextFormat(
"#AR-ValueUnit_Short_Kilograms", sWeight);
160 m_wTextWeight.SetEnabled(
false );
161 m_wTextWeight.SetVisible(
false );
166 void SetWeight(
float fWeight )
171 SetWeight( fWeight.ToString() );
175 override void HandlerAttached( Widget w )
180 m_wHintWidget = VerticalLayoutWidget.Cast( w.FindAnyWidget(
"VerticalHintParent" ) );
181 m_wTextName = TextWidget.Cast( w.FindAnyWidget(
"ItemInfo_name" ) );
182 m_wTextDescription = TextWidget.Cast( w.FindAnyWidget(
"ItemInfo_description" ) );
183 m_wTextWeight = TextWidget.Cast( w.FindAnyWidget(
"ItemInfo_weight" ) );
184 m_wItemIcon = ImageWidget.Cast(w.FindAnyWidget(
"ItemInfo_icon"));
185 Widget wItemInfo = m_infoWidget.FindAnyWidget(
"ItemInfo" );
196 GetGame().GetCallqueue().Remove( ShowInfoWidget );
197 m_infoWidget.RemoveHandler( m_pFrameSlotUI );
198 m_infoWidget.RemoveHandler(
this );
199 m_infoWidget.RemoveFromHierarchy();
204 Widget GetInfoWidget()
206 return m_infoWidget.FindAnyWidget(
"size");