Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
header.c
Go to the documentation of this file.
2 {
3  protected int m_DefaultColor;
4  protected int m_DefaultFontSize;
5 
6  protected EntityAI m_Entity;
7 
8  protected Widget m_CollapseButton;
9  protected Widget m_UpArrowButton;
10  protected Widget m_DownArrowButton;
11  protected TextWidget m_HeaderText;
12 
13  void Header( LayoutHolder parent, string function_name )
14  {
15  m_CollapseButton = GetMainWidget().FindAnyWidget( "collapse_button" );
16  m_UpArrowButton = GetMainWidget().FindAnyWidget( "opened" );
17  m_DownArrowButton = GetMainWidget().FindAnyWidget( "closed" );
18 
19  #ifdef PLATFORM_CONSOLE
20  m_CollapseButton.Show( false );
21  #else
22  WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( m_CollapseButton, m_Parent, function_name );
23  WidgetEventHandler.GetInstance().RegisterOnDropReceived( m_CollapseButton, m_Parent, "OnDropReceivedFromHeader" );
24  #endif
25  WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget(), m_Parent, "OnDropReceivedFromHeader" );
26  WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget(), this, "DraggingOverHeader" );
27 
28  m_HeaderText = TextWidget.Cast( GetMainWidget().FindAnyWidget( "TextWidget0" ) );
29 
30  m_DefaultColor = GetRootWidget().GetColor();
31  }
32 
33  void SetName( string name )
34  {
35  name.ToUpper();
36  m_HeaderText.SetText( name );
37  }
38 
39  void SetItemPreview( EntityAI entity_ai )
40  {
41  #ifndef PLATFORM_CONSOLE
42  m_Entity = entity_ai;
43  ItemPreviewWidget item_preview = ItemPreviewWidget.Cast( GetMainWidget().FindAnyWidget( "Render" ) );
44  item_preview.SetItem(entity_ai);
45  item_preview.SetView( entity_ai.GetViewIndex() );
46  #endif
47  }
48 
49  void DraggingOverHeader( Widget w, int x, int y, Widget receiver )
50  {
51  if ( w == null )
52  return;
53 
54  Container parent_container = Container.Cast( m_Parent );
55  parent_container.DraggingOverHeader( w, x, y, receiver );
56  }
57 
58  void OnDropReceivedFromHeader( Widget w, int x, int y, Widget receiver )
59  {
60  Container parent_container = Container.Cast( m_Parent );
61  parent_container.OnDropReceivedFromHeader( w, x, y, receiver );
62  }
63 
64  override void SetActive( bool active )
65  {
66  super.SetActive( active );
67 
68  if ( active )
69  GetMainWidget().SetColor( ARGBF( 1, 1, 0, 0 ) );
70  else
71  GetMainWidget().SetColor( m_DefaultColor );
72  }
73 
74  void ShowCollapseButton(bool state)
75  {
76  m_CollapseButton.Show(state);
77  }
78 }
LayoutHolder
Definition: container.c:1
y
Icon y
m_Parent
protected Widget m_Parent
Definition: sizetochild.c:92
FindAnyWidget
proto native Widget FindAnyWidget(string pathname)
TextWidget
Definition: enwidgets.c:219
Header
Definition: header.c:1
Container
Definition: cargocontainer.c:2
ARGBF
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition: proto.c:332
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
x
Icon x
ItemPreviewWidget
Definition: gameplay.c:275
Widget
Definition: enwidgets.c:189
EntityAI
Definition: building.c:5
m_Entity
EntityAI m_Entity
Definition: actiondebug.c:11
WidgetEventHandler
Definition: widgeteventhandler.c:1