DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
DropdownPrefab.c
См. документацию.
1class DropdownPrefab extends ScriptedWidgetEventHandler
2{
3 protected Widget m_Root;
4 protected Widget m_Parent;
5 protected ScrollWidget m_Scroller;
8
9 protected Widget m_Button;
10 protected Widget m_Holder;
11 protected TextWidget m_Text;
12 protected ImageWidget m_ImageExpand;
13 protected ImageWidget m_ImageCollapse;
14
15 protected bool m_IsExpanded;
17
18 void DropdownPrefab( Widget root, string text = "" )
19 {
20 m_Parent = root;
21 m_Root = GetGame().GetWorkspace().CreateWidgets( "gui/layouts/new_ui/dropdown_prefab/dropdown_prefab.layout", root );
22
23 m_Scroller = ScrollWidget.Cast( m_Root.FindAnyWidget( "dropdown_container" ) );
24 m_ContentContainer = m_Root.FindAnyWidget( "dropdown_content" );
25 m_Text = TextWidget.Cast( m_Root.FindAnyWidget( "dropdown_text" ) );
26 m_Holder = m_Root.FindAnyWidget( "holder" );
27 SetText( text );
28
29 m_Button = m_Root.FindAnyWidget( "dropdown_selector_button" );
30 m_ImageExpand = ImageWidget.Cast( m_Root.FindAnyWidget( "expand_image" ) );
31 m_ImageCollapse = ImageWidget.Cast( m_Root.FindAnyWidget( "collapse_image" ) );
32
33 m_Root.SetHandler( this );
34
36 }
37
39 {
40 Widget child = m_ContentContainer.GetChildren();
41 while( child )
42 {
43 if( m_Content.Find( child ) > -1 )
44 {
45 m_Content.Insert( child );
46 }
47 }
48
49 m_ContentContainer.Update();
50 m_Root.Update();
51
52 float x, y;
53 m_ContentContainer.GetScreenSize( x, y );
54 if( y > m_Scroller.GetContentHeight() )
55 {
56 m_Scroller.SetAlpha( 1 );
57 }
58 else
59 {
60 m_Scroller.SetAlpha( 0 );
61 }
62 }
63
64 int AddElement( string text, Widget content = null )
65 {
66 ButtonWidget element = ButtonWidget.Cast( GetGame().GetWorkspace().CreateWidgets( "gui/layouts/new_ui/dropdown_prefab/dropdown_element.layout", m_ContentContainer ) );
67 RichTextWidget textWidget = RichTextWidget.Cast(element.FindAnyWidget("dropdown_element_text"));
68 textWidget.SetText( text );
69
70 if( content )
71 {
72 element.AddChild( content, false );
73 }
74 m_ContentContainer.Update();
75 textWidget.Update();
76 m_Root.Update();
77 element.Update();
78
79 m_Content.Insert( element );
80 return m_Content.Count() - 1;
81 }
82
83 void RemoveElement( int index )
84 {
85 if( 0 < index && index < m_Content.Count() )
86 {
87 delete m_Content.Get( index );
88 m_ContentContainer.Update();
89 m_Root.Update();
90 m_Parent.Update();
91 }
92 }
93
94 void Close()
95 {
96 if( m_IsExpanded )
97 {
102
103 m_Root.Update();
104 m_Parent.Update();
105 }
106 }
107
108 void SetText( string text )
109 {
110 m_Text.SetText( text );
111 }
112
113 override bool OnClick( Widget w, int x, int y, int button )
114 {
115 int index = m_Content.Find( w );
116 if ( index > -1 )
117 {
118 m_OnSelectItem.Invoke( index );
119 m_IsExpanded = false;
120 m_Scroller.Show( m_IsExpanded );
123 return true;
124 }
125 return false;
126 }
127
128 override bool OnMouseButtonDown( Widget w, int x, int y, int button )
129 {
130 if ( (w == m_Button || w == m_Text || w == m_Holder) && button == MouseState.LEFT )
131 {
133 m_Scroller.Show( m_IsExpanded );
136
137 m_Root.Update();
138 m_Parent.Update();
139 m_ContentContainer.Update();
140
141 return true;
142 }
143 return false;
144 }
145}
Icon x
Icon y
Widget m_Root
Определения SizeToChild.c:91
proto native WorkspaceWidget GetWorkspace()
Определения gameplay.c:317
ScriptInvoker Class provide list of callbacks usage:
Определения tools.c:116
Widget m_ContentContainer
Определения DropdownPrefab.c:6
ref ScriptInvoker m_OnSelectItem
Определения DropdownPrefab.c:16
LayoutHolder m_Parent
Определения LayoutHolder.c:6
void DropdownPrefab(Widget root, string text="")
Определения DropdownPrefab.c:18
Widget m_Root
Определения SizeToChild.c:9
ScrollWidget m_Scroller
Определения DropdownPrefab.c:5
void RefreshContent()
Определения DropdownPrefab.c:38
void Close()
Определения DropdownPrefab.c:94
TextWidget m_Text
Определения DropdownPrefab.c:11
int AddElement(string text, Widget content=null)
Определения DropdownPrefab.c:64
override bool OnClick(Widget w, int x, int y, int button)
Определения DropdownPrefab.c:113
bool m_IsExpanded
Определения DropdownPrefab.c:15
ImageWidget m_ImageExpand
Определения DropdownPrefab.c:12
void SetText(string text)
Определения DropdownPrefab.c:108
void RemoveElement(int index)
Определения DropdownPrefab.c:83
Widget m_Button
Определения DropdownPrefab.c:9
ImageWidget m_ImageCollapse
Определения DropdownPrefab.c:13
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
Определения DropdownPrefab.c:128
Widget m_Holder
Определения DropdownPrefab.c:10
map: item x vector(index, width, height)
Определения EnWidgets.c:651
Определения EnWidgets.c:220
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
MouseState
Определения EnSystem.c:311
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.
WorkspaceWidget Widget
Defined in code.