DayZ 1.24
Loading...
Searching...
No Matches
ClosableHeader.c
Go to the documentation of this file.
2{
3 protected float m_SquareSize;
4 protected int m_DefaultSort;
5
6 protected Widget m_MovePanel;
11
12 protected bool m_IsInLocalEquipment;
13
15 {
16 m_MovePanel = GetMainWidget().FindAnyWidget("MovePanel");
17 m_PanelWidget = GetMainWidget().FindAnyWidget("PanelWidget");
18 m_DragRender = GetMainWidget().FindAnyWidget("Drag_Render");
19 m_MoveUp = ButtonWidget.Cast(GetMainWidget().FindAnyWidget("MoveUp"));
20 m_MoveDown = ButtonWidget.Cast(GetMainWidget().FindAnyWidget("MoveDown"));
21
22 WidgetEventHandler.GetInstance().RegisterOnClick(m_MoveUp, m_Parent, "MoveContainerUp");
23 WidgetEventHandler.GetInstance().RegisterOnClick(m_MoveDown, m_Parent, "MoveContainerDown");
24 WidgetEventHandler.GetInstance().RegisterOnMouseLeave(m_MoveUp, this, "MouseLeave");
25 WidgetEventHandler.GetInstance().RegisterOnMouseLeave(m_MoveDown, this, "MouseLeave");
26
27 WidgetEventHandler.GetInstance().RegisterOnDrag(GetMainWidget(), this, "OnDragHeader");
28 WidgetEventHandler.GetInstance().RegisterOnDrop(GetMainWidget(), this, "OnDropHeader");
29
30 WidgetEventHandler.GetInstance().RegisterOnMouseEnter(GetMainWidget(), this, "MouseEnter");
31 WidgetEventHandler.GetInstance().RegisterOnMouseLeave(GetMainWidget(), this, "MouseLeave");
32
33 float temp;
34 GetMainWidget().GetScreenSize(temp, m_SquareSize);
35
36 m_DefaultColor = m_PanelWidget.GetColor();
38
40 m_IsInLocalEquipment = GetParent().GetParent().GetParent().IsInherited(RightArea);
41 }
42
44 {
45 if (InventoryItem.Cast(m_Entity))
46 InventoryItem.Cast(m_Entity).GetOnItemFlipped().Remove(UpdateFlip);
47 }
48
49 override void SetLayoutName()
50 {
51 m_LayoutName = WidgetLayoutName.ClosableHeader;
52 }
53
54 override void SetName(string name)
55 {
56 name.ToUpper();
57
58 m_HeaderText.SetText(name);
59 m_HeaderText.Update();
60
61 float x, y;
62 m_HeaderText.GetScreenSize(x, y);
63 m_PanelWidget.SetSize(1, y + InventoryMenu.GetHeightMultiplied(10));
64 }
65
66 void OnDragHeader(Widget w, int x, int y)
67 {
69 if (parent && GetMainWidget() && m_Entity)
70 {
72 item_preview_drag.SetFlags(WidgetFlags.EXACTPOS);
73 m_DefaultSort = GetRootWidget().GetSort();
74 item_preview_drag.GetParent().GetParent().GetParent().GetParent().GetParent().GetParent().GetParent().GetParent().AddChild(GetRootWidget());
76 {
78 item_preview_drag.SetView(m_Entity.GetViewIndex());
79 }
80
81 ItemManager.GetInstance().SetIsDragging(true);
82
83 parent.HideContent(true);
84
85 m_PanelWidget.Show(false);
87 item_preview_drag.Show(true);
88
89 int ww, hh;
90 GetGame().GetInventoryItemSize(InventoryItem.Cast(m_Entity), ww, hh);
92 {
93 m_Entity.GetOnItemFlipped().Insert(UpdateFlip);
94 if (m_Entity.GetInventory().GetFlipCargo())
96 else
98 }
99 }
100 }
101
103 {
106 {
107 int ww, hh;
108 GetGame().GetInventoryItemSize(InventoryItem.Cast(m_Entity), ww, hh);
109 if (flipped)
111 else
113 }
114 }
115
117 {
119 parent.GetMainWidget().AddChild(GetRootWidget());
120 GetRootWidget().SetSort(0);
121 if (parent)
122 {
123 //
126 {
127 item_preview_drag.SetItem(null); //TODO: is this safe?
128 }
129 //
130
131 m_PanelWidget.Show(true);
132 m_DragRender.Show(false);
133
134 parent.ShowContent(true);
135
136 ItemManager.GetInstance().HideDropzones();
137 ItemManager.GetInstance().SetIsDragging(false);
138 }
139 if (InventoryItem.Cast(m_Entity))
140 InventoryItem.Cast(m_Entity).GetOnItemFlipped().Remove(UpdateFlip);
141 }
142
143 bool MouseEnter(Widget w, int x, int y)
144 {
146 {
147#ifdef PLATFORM_CONSOLE
148 m_MovePanel.Show(GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer());
149#else
150 m_MovePanel.Show(true);
151#endif
152 }
153 PrepareOwnedTooltip(m_Entity, x, y);
154 return true;
155 }
156
157 bool MouseLeave(Widget w, Widget enter_w, int x, int y)
158 {
160 {
162 m_MovePanel.Show(false);
163 }
164 HideOwnedTooltip();
165 return true;
166 }
167
168 override void SetActive(bool active)
169 {
170 super.SetActive(active);
171 if (active)
172 m_PanelWidget.SetColor(ARGBF(1, 1, 0, 0));
173 else
175 }
176}
ActionInput GetInput()
Definition ActionBase.c:989
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Icon x
Icon y
void InventoryMenu()
Widget m_Parent
Definition SizeToChild.c:86
override void SetActive(bool active)
ButtonWidget m_MoveUp
void OnDropHeader(Widget w)
void UpdateFlip(bool flipped)
bool MouseEnter(Widget w, int x, int y)
void OnDragHeader(Widget w, int x, int y)
void ClosableHeader(LayoutHolder parent, string function_name)
ButtonWidget m_MoveDown
override void SetLayoutName()
override void SetName(string name)
bool MouseLeave(Widget w, Widget enter_w, int x, int y)
Definition Header.c:2
EntityAI m_Entity
Definition Header.c:6
int m_DefaultFontSize
Definition Header.c:4
int m_DefaultColor
Definition Header.c:3
Widget m_CollapseButton
Definition Header.c:8
TextWidget m_HeaderText
Definition Header.c:11
static ItemManager GetInstance()
static WidgetEventHandler GetInstance()
const string ClosableHeader
proto native CGame GetGame()
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:389
WidgetFlags
Definition EnWidgets.c:58
proto native Widget FindAnyWidget(string pathname)
proto native Widget GetDragWidget()
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition proto.c:332