Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
uipropertyattachment.c
Go to the documentation of this file.
1
class
UIPropertyAttachment
2
{
3
private
Widget
m_WgtRoot
;
4
private
Widget
m_WgtThis
;
5
private
XComboBoxWidget
m_WgtComboBox
;
6
private
TextWidget
m_WgtSlotName
;
7
private
ref
TStringArray
m_ComboItems
;
8
private
int
m_PrevIndex
;
9
private
EntityAI
m_Obj
;
10
private
int
m_SlotID
;
11
12
13
void
UIPropertyAttachment
(
Widget
root)
14
{
15
m_WgtRoot
= root;
16
17
m_ComboItems
=
new
TStringArray
;
18
19
m_WgtThis
=
g_Game
.GetWorkspace().CreateWidgets(
"gui/layouts/scene_editor/day_z_scene_editor_attachment.layout"
,
m_WgtRoot
);
20
m_WgtComboBox
= XComboBoxWidget.Cast(
m_WgtThis
.FindAnyWidget(
"combo_box"
) );
21
m_WgtSlotName
=
TextWidget
.Cast(
m_WgtThis
.FindAnyWidget(
"txt_slot_name"
) );
22
}
23
24
void
~UIPropertyAttachment
()
25
{
26
m_WgtRoot
= NULL;
27
m_WgtComboBox
= NULL;
28
29
delete
m_WgtThis
;
30
}
31
32
bool
OnClick
(
Widget
w,
int
x
,
int
y
,
int
button)
33
{
34
if
( w ==
m_WgtComboBox
)
35
{
36
if
(
m_PrevIndex
!= 0 )
37
{
38
EntityAI
attachment =
m_Obj
.GetInventory().FindAttachment(
m_SlotID
);
39
g_Game
.ObjectDelete(attachment);
40
}
41
42
int
curr_index =
m_WgtComboBox
.GetCurrentItem();
43
44
if
( curr_index != 0 )
45
{
46
PluginDeveloper module_dev = PluginDeveloper.Cast(
GetPlugin
(PluginDeveloper) );
47
48
EntityAI
e = module_dev.SpawnEntityAsAttachment(PluginSceneManager.PLAYER,
m_Obj
,
m_ComboItems
.Get(curr_index), 1, -1);
49
}
50
51
m_PrevIndex
= curr_index;
52
53
return
true
;
54
}
55
56
return
false
;
57
}
58
59
void
SetPos
(
float
x
,
float
y
)
60
{
61
m_WgtThis
.SetPos(
x
,
y
);
62
}
63
64
void
SetSize
(
float
width,
float
height)
65
{
66
m_WgtThis
.SetSize(width, height);
67
}
68
69
void
Show
(
EntityAI
e,
string
slot_name,
TStringArray
att_items)
70
{
71
m_WgtThis
.Show(
true
);
72
73
m_Obj
= e;
74
m_ComboItems
.Clear();
75
m_ComboItems
.Insert(
"none"
);
76
m_ComboItems
.InsertAll(att_items);
77
78
m_WgtSlotName
.SetText(slot_name);
79
80
m_WgtComboBox
.ClearAll();
81
82
m_SlotID
=
InventorySlots
.
GetSlotIdFromString
(slot_name);
83
EntityAI
attachment = e.GetInventory().FindAttachment(
m_SlotID
);
84
int
selected_index = 0;
85
86
for
(
int
i = 0; i <
m_ComboItems
.Count(); ++i )
87
{
88
string
item_name =
m_ComboItems
.Get(i);
89
90
m_WgtComboBox
.AddItem(item_name);
91
92
if
( attachment != NULL && attachment.GetType() == item_name )
93
{
94
selected_index = i;
95
}
96
}
97
98
m_WgtComboBox
.SetCurrentItem(selected_index);
99
m_PrevIndex
= selected_index;
100
}
101
102
void
Hide
()
103
{
104
m_WgtThis
.Show(
false
);
105
106
m_Obj
= NULL;
107
m_SlotID
= -1;
108
}
109
110
bool
IsVisible
()
111
{
112
return
m_WgtThis
.IsVisible();
113
}
114
}
EntityAI
Definition
inventoryitem.c:2
InventorySlots
provides access to slot configuration
Definition
inventoryslots.c:6
InventorySlots::GetSlotIdFromString
static proto native int GetSlotIdFromString(string slot_name)
TextWidget
Definition
enwidgets.c:220
UIPropertyAttachment::m_WgtComboBox
XComboBoxWidget m_WgtComboBox
Definition
uipropertyattachment.c:5
UIPropertyAttachment::Hide
void Hide()
Definition
uipropertyattachment.c:102
UIPropertyAttachment::UIPropertyAttachment
void UIPropertyAttachment(Widget root)
Definition
uipropertyattachment.c:13
UIPropertyAttachment::m_SlotID
int m_SlotID
Definition
uipropertyattachment.c:10
UIPropertyAttachment::m_WgtSlotName
TextWidget m_WgtSlotName
Definition
uipropertyattachment.c:6
UIPropertyAttachment::m_ComboItems
ref TStringArray m_ComboItems
Definition
uipropertyattachment.c:7
UIPropertyAttachment::SetPos
void SetPos(float x, float y)
Definition
uipropertyattachment.c:59
UIPropertyAttachment::Show
void Show(EntityAI e, string slot_name, TStringArray att_items)
Definition
uipropertyattachment.c:69
UIPropertyAttachment::OnClick
bool OnClick(Widget w, int x, int y, int button)
Definition
uipropertyattachment.c:32
UIPropertyAttachment::m_Obj
EntityAI m_Obj
Definition
uipropertyattachment.c:9
UIPropertyAttachment::m_PrevIndex
int m_PrevIndex
Definition
uipropertyattachment.c:8
UIPropertyAttachment::m_WgtThis
Widget m_WgtThis
Definition
uipropertyattachment.c:4
UIPropertyAttachment::~UIPropertyAttachment
void ~UIPropertyAttachment()
Definition
uipropertyattachment.c:24
UIPropertyAttachment::SetSize
void SetSize(float width, float height)
Definition
uipropertyattachment.c:64
UIPropertyAttachment::IsVisible
bool IsVisible()
Definition
uipropertyattachment.c:110
UIPropertyAttachment::m_WgtRoot
Widget m_WgtRoot
Definition
uipropertyattachment.c:3
Widget
Definition
enwidgets.c:190
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
TStringArray
array< string > TStringArray
Definition
enscript.c:712
x
Icon x
y
Icon y
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition
pluginmanager.c:325
Games
Dayz
scripts
5_mission
gui
sceneeditormenu
uipropertyattachment.c
Generated by
1.17.0