DayZ 1.24
Loading...
Searching...
No Matches
ModsMenuSimpleEntry.c
Go to the documentation of this file.
1class ModsMenuSimpleEntry extends ScriptedWidgetEventHandler
2{
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
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 m_Icon.LoadImageFile(0, logo);
37 else
38 m_Icon.LoadImageFile(0, ModInfo.DEFAULT_LOGO);
39
40 if (logo_over != "")
41 m_Icon.LoadImageFile(1, logo_over);
42 else
43 m_Icon.LoadImageFile(1, ModInfo.DEFAULT_LOGO_OVER);
44 m_HasLogoOver = true;
45 }
46
47 override bool OnClick(Widget w, int x, int y, int button)
48 {
49 if (w == m_ModButton)
50 {
51 m_ParentMenu.Select(m_Data);
52 return true;
53 }
54 return false;
55 }
56
57 override bool OnMouseEnter(Widget w, int x, int y)
58 {
59 if (w == m_ModButton)
60 {
61 if (m_HasLogoOver)
62 m_Icon.SetImage(1);
63 m_Hover.Show(true);
64 return true;
65 }
66 return false;
67 }
68
69 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
70 {
71 if (enterW != m_ModButton)
72 {
73 if (m_HasLogoOver)
74 m_Icon.SetImage(0);
75 m_Hover.Show(false);
76 return true;
77 }
78 return false;
79 }
80
81 override bool OnFocus(Widget w, int x, int y)
82 {
83 if (w == m_ModButton)
84 {
85 if (m_HasLogoOver)
86 m_Icon.SetImage(1);
87 m_Hover.Show(true);
88 return true;
89 }
90 return false;
91 }
92
93 override bool OnFocusLost(Widget w, int x, int y)
94 {
95 if (w == m_ModButton)
96 {
97 if (m_HasLogoOver)
98 m_Icon.SetImage(0);
99 m_Hover.Show(false);
100 return true;
101 }
102 return false;
103 }
104}
Icon x
Icon y
static const string DEFAULT_LOGO
Definition ModInfo.c:19
static const string DEFAULT_LOGO_OVER
Definition ModInfo.c:21
map: item x vector(index, width, height)
Definition EnWidgets.c:651
override bool OnFocusLost(Widget w, int x, int y)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override bool OnClick(Widget w, int x, int y, int button)
void ModsMenuSimpleEntry(ModInfo data, int index, Widget parent, ModsMenuSimple parent_menu)
override bool OnFocus(Widget w, int x, int y)
override bool OnMouseEnter(Widget w, int x, int y)
ref map< ref ModInfo, ref ModsMenuDetailedEntry > m_Data
proto native CGame GetGame()