5 private XComboBoxWidget m_WgtComboBox;
8 private int m_PrevIndex;
19 m_WgtThis =
GetGame().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") );
32 bool OnClick(
Widget w,
int x,
int y,
int button)
34 if ( w == m_WgtComboBox )
36 if ( m_PrevIndex != 0 )
38 EntityAI attachment = m_Obj.GetInventory().FindAttachment(m_SlotID);
39 GetGame().ObjectDelete(attachment);
42 int curr_index = m_WgtComboBox.GetCurrentItem();
44 if ( curr_index != 0 )
46 PluginDeveloper module_dev = PluginDeveloper.Cast(
GetPlugin(PluginDeveloper) );
48 EntityAI e = module_dev.SpawnEntityAsAttachment(PluginSceneManager.PLAYER, m_Obj, m_ComboItems.Get(curr_index), 1, -1);
51 m_PrevIndex = curr_index;
59 void SetPos(
float x,
float y)
61 m_WgtThis.SetPos(
x,
y);
64 void SetSize(
float width,
float height)
66 m_WgtThis.SetSize(width, height);
75 m_ComboItems.Insert(
"none");
76 m_ComboItems.InsertAll(att_items);
78 m_WgtSlotName.SetText(slot_name);
80 m_WgtComboBox.ClearAll();
83 EntityAI attachment = e.GetInventory().FindAttachment(m_SlotID);
84 int selected_index = 0;
86 for (
int i = 0; i < m_ComboItems.Count(); ++i )
88 string item_name = m_ComboItems.Get(i);
90 m_WgtComboBox.AddItem(item_name);
92 if ( attachment != NULL && attachment.GetType() == item_name )
98 m_WgtComboBox.SetCurrentItem(selected_index);
99 m_PrevIndex = selected_index;
104 m_WgtThis.Show(
false);
112 return m_WgtThis.IsVisible();