Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
modsmenusimpleentry.c
Go to the documentation of this file.
1 class ModsMenuSimpleEntry extends ScriptedWidgetEventHandler
2 {
3  protected ButtonWidget m_ModButton;
4  protected ImageWidget m_Icon;
5  protected Widget m_Hover;
6 
7  protected bool m_HasLogoOver;
8  protected ModInfo m_Data;
9  protected ModsMenuSimple m_ParentMenu;
10 
11  void ModsMenuSimpleEntry(ModInfo data, int index, Widget parent, ModsMenuSimple parent_menu)
12  {
13  m_ModButton = ButtonWidget.Cast(GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/mods_menu/mods_menu_simple_entry.layout", parent));
14  m_Icon = ImageWidget.Cast(m_ModButton.FindAnyWidget("Icon"));
15  m_Hover = m_ModButton.FindAnyWidget("Overlay");
16  m_Data = data;
17  m_ParentMenu = parent_menu;
18 
19  m_ModButton.SetSort(index);
20  m_ModButton.SetHandler(this);
21 
22  LoadData();
23  }
24 
25  void ~ModsMenuSimpleEntry()
26  {
27  delete m_ModButton;
28  }
29 
30  void LoadData()
31  {
32  string logo = m_Data.GetLogo();
33  string logo_over = m_Data.GetLogoOver();
34 
35  if (logo != "")
36  {
37  m_Icon.LoadImageFile(0, logo);
38  }
39  else
40  {
41  m_Icon.LoadImageFile(0, ModInfo.DEFAULT_LOGO);
42  }
43 
44  if (logo_over != "")
45  {
46  m_Icon.LoadImageFile(1, logo_over);
47  }
48  else
49  {
50  m_Icon.LoadImageFile(1, ModInfo.DEFAULT_LOGO_OVER);
51  }
52  m_HasLogoOver = true;
53  }
54 
55  override bool OnClick(Widget w, int x, int y, int button)
56  {
57  if( w == m_ModButton )
58  {
59  m_ParentMenu.Select( m_Data );
60  return true;
61  }
62  return false;
63  }
64 
65  override bool OnMouseEnter(Widget w, int x, int y)
66  {
67  if( w == m_ModButton )
68  {
69  if( m_HasLogoOver )
70  m_Icon.SetImage( 1 );
71  m_Hover.Show( true );
72  return true;
73  }
74  return false;
75  }
76 
77  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
78  {
79  if( enterW != m_ModButton )
80  {
81  if( m_HasLogoOver )
82  m_Icon.SetImage( 0 );
83  m_Hover.Show( false );
84  return true;
85  }
86  return false;
87  }
88 
89  override bool OnFocus( Widget w, int x, int y )
90  {
91  if( w == m_ModButton )
92  {
93  if( m_HasLogoOver )
94  m_Icon.SetImage( 1 );
95  m_Hover.Show( true );
96  return true;
97  }
98  return false;
99  }
100 
101  override bool OnFocusLost( Widget w, int x, int y )
102  {
103  if( w == m_ModButton )
104  {
105  if( m_HasLogoOver )
106  m_Icon.SetImage( 0 );
107  m_Hover.Show( false );
108  return true;
109  }
110  return false;
111  }
112 }
GetGame
proto native CGame GetGame()
ModInfo
Definition: modinfo.c:1
m_Data
string m_Data
Definition: universaltemperaturesource.c:205
y
Icon y
OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition: uihintpanel.c:276
OnFocusLost
override bool OnFocusLost(Widget w, int x, int y)
Definition: serverbrowsertab.c:235
x
Icon x
OnFocus
override bool OnFocus(Widget w, int x, int y)
Definition: serverbrowsertab.c:217
Widget
Definition: enwidgets.c:189
OnClick
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition: dayzgame.c:146
OnMouseEnter
override bool OnMouseEnter(Widget w, int x, int y)
Definition: uihintpanel.c:267
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition: enwidgets.c:650