DayZ 1.24
Loading...
Searching...
No Matches
ModsMenuDetailedEntry.c
Go to the documentation of this file.
1class ModsMenuDetailedEntry extends ScriptedWidgetEventHandler
2{
3 protected Widget m_Root;
4 protected Widget m_Detail;
5
6 //Header
9 protected TextWidget m_Name;
10
11 //Left Side Panel
17
18 //Description Panel
20
21 protected ModInfo m_Data;
22 protected ModsMenuDetailed m_ParentMenu;
23 protected bool m_IsOpen;
24
25 void ModsMenuDetailedEntry(ModInfo data, Widget parent, ModsMenuDetailed parent_menu)
26 {
27 m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/mods_menu/mods_menu_detailed_entry.layout", parent);
28 m_Detail = m_Root.FindAnyWidget("DetailContainer");
29
30 m_IconSmall = ImageWidget.Cast(m_Root.FindAnyWidget("IconSmall"));
31 m_IconCollapse = ImageWidget.Cast(m_Root.FindAnyWidget("collapse_button"));
32 m_IconCollapse.LoadImageFile(1, "set:dayz_gui image:icon_open");
33 m_Name = TextWidget.Cast(m_Root.FindAnyWidget("Name"));
34
35 m_IconBig = ImageWidget.Cast(m_Root.FindAnyWidget("IconBig"));
36 m_Author = MultilineTextWidget.Cast(m_Root.FindAnyWidget("Author"));
37 m_Author.SetLineBreakingOverride(LinebreakOverrideMode.LINEBREAK_WESTERN);
38
39 m_Version = TextWidget.Cast(m_Root.FindAnyWidget("Version"));
40 m_ActionWebsite = RichTextWidget.Cast(m_Root.FindAnyWidget("Link"));
41 m_ActionPurchase = RichTextWidget.Cast(m_Root.FindAnyWidget("Purchase"));
42
43 m_Description = RichTextWidget.Cast(m_Root.FindAnyWidget("Description"));
44
45 m_Data = data;
46 m_ParentMenu = parent_menu;
47
48 m_Root.SetHandler(this);
49
50 LoadData();
51 }
52
54 {
55 delete m_Root;
56 }
57
59 {
60 return m_Root;
61 }
62
63 void Select()
64 {
65 m_Root.SetColor(ARGBF(m_Root.GetAlpha(), 0.3, 0, 0));
66
67 m_Detail.Show(true);
68 m_IconBig.Show(true);
69 m_IconSmall.Show(false);
70 m_IconCollapse.SetImage(1);
71 m_Detail.Update();
72 m_Root.Update();
73 m_IsOpen = true;
74 }
75
76 void Deselect()
77 {
78 m_Root.SetColor(ARGBF(m_Root.GetAlpha(), 0.2, 0.2, 0.2));
79
80 m_Detail.Show(false);
81 m_IconBig.Show(false);
82 m_IconSmall.Show(true);
83 m_IconCollapse.SetImage(0);
84 m_Detail.Update();
85 m_Root.Update();
86 m_IsOpen = false;
87 }
88
89 void LoadData()
90 {
91 string picture = m_Data.GetPicture();
92 string logo = m_Data.GetLogoSmall();
93 string name = m_Data.GetName();
94 string description = m_Data.GetOverview();
95 string author = m_Data.GetAuthor();
96 string version = m_Data.GetVersion();
97 string action = m_Data.GetAction();
98
99 //Load Large Icon
100 if (picture != "")
101 m_IconBig.LoadImageFile(0, picture);
102 else if (logo != "")
103 m_IconBig.LoadImageFile(0, logo);
104 else
105 m_IconBig.LoadImageFile(0, ModInfo.DEFAULT_PICTURE);
106
107 //Load Small Icon
108 if (logo != "")
109 m_IconSmall.LoadImageFile(0, logo);
110 else if (picture != "")
111 m_IconSmall.LoadImageFile(0, picture);
112 else
113 m_IconSmall.LoadImageFile(0, ModInfo.DEFAULT_LOGO_SMALL);
114
115 if (name != "")
116 m_Name.SetText(name);
117
118 if (description != "")
119 m_Description.SetText(description);
120 else
122 m_Description.Update();
123 m_Detail.Update();
124
125 if (author != "")
126 {
127 m_Author.Show(true);
128 m_Author.SetText(author);
129 }
130
131 if (version != "")
132 {
133 m_Version.Show(true);
134 m_Version.SetText(version);
135 }
136
137#ifdef PLATFORM_WINDOWS
138 if (action != "")
139 m_ActionWebsite.Show(true);
140#endif
141
142 if (m_Data.GetIsDLC())
143 {
144 bool isOwned = m_Data.GetIsOwned();
145 m_Root.FindAnyWidget("ModOwnership").Show(true);
146 m_Root.FindAnyWidget("Owned").Show(isOwned);
147 m_Root.FindAnyWidget("Unowned").Show(!isOwned);
148 m_ActionPurchase.Show(true);
149 m_Version.Show(false);
150 }
151 }
152
153 override bool OnMouseButtonUp(Widget w, int x, int y, int button)
154 {
155 if (w == m_IconCollapse)
156 {
157 m_ParentMenu.Select(m_Data, !m_IsOpen);
158 return true;
159 }
160 else if (w == m_ActionWebsite)
161 GetGame().OpenURL(m_Data.GetAction());
162 else if (w == m_ActionPurchase)
163 m_Data.GoToStore();
164 return false;
165 }
166
167 override bool OnMouseEnter(Widget w, int x, int y)
168 {
169 if (w == m_ActionWebsite)
170 {
171 m_ActionWebsite.SetBold(true);
172 m_ActionWebsite.SetText("#mod_detail_info_website");
173 }
174
175 if (w == m_ActionPurchase)
176 {
177 m_ActionPurchase.SetBold(true);
178 m_ActionPurchase.SetText("#mod_detail_info_store");
179 }
180
181 if (w == m_Root)
182 {
183 if (m_Data.GetTooltip() != "")
184 m_ParentMenu.PrepareTooltip(m_Data);
185 return true;
186 }
187
188 return false;
189 }
190
191 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
192 {
193 if (w == m_ActionWebsite)
194 {
195 m_ActionWebsite.SetBold(false);
196 m_ActionWebsite.SetText("#mod_detail_info_website");
197 }
198
199 if (w == m_ActionPurchase)
200 {
201 m_ActionPurchase.SetBold(false);
202 m_ActionPurchase.SetText("#mod_detail_info_store");
203 }
204
205 if (enterW != m_Root)
206 {
207 m_ParentMenu.HideTooltip();
208 return true;
209 }
210
211 return false;
212 }
213}
string m_Name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Icon x
Icon y
Widget m_Root
Definition SizeToChild.c:85
static const string DEFAULT_PICTURE
Definition ModInfo.c:18
static const string DEFAULT_OVERVIEW
Definition ModInfo.c:22
static const string DEFAULT_LOGO_SMALL
Definition ModInfo.c:20
map: item x vector(index, width, height)
Definition EnWidgets.c:651
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
void ModsMenuDetailedEntry(ModInfo data, Widget parent, ModsMenuDetailed parent_menu)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override bool OnMouseEnter(Widget w, int x, int y)
proto native CGame GetGame()
string m_Description
class purpose description
Definition EnEntity.c:842
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition proto.c:332