Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
modsmenudetailedentry.c
Go to the documentation of this file.
1 class ModsMenuDetailedEntry extends ScriptedWidgetEventHandler
2 {
3  protected Widget m_Root;
4  protected Widget m_Detail;
5 
6  //Header
7  protected ImageWidget m_IconSmall;
8  protected ImageWidget m_IconCollapse;
9  protected TextWidget m_Name;
10 
11  //Left Side Panel
12  protected ImageWidget m_IconBig;
13  protected MultilineTextWidget m_Author;
14  protected TextWidget m_Version;
15  protected RichTextWidget m_ActionWebsite;
16  protected RichTextWidget m_ActionPurchase;
17 
18  //Description Panel
19  protected RichTextWidget m_Description;
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 
53  void ~ModsMenuDetailedEntry()
54  {
55  delete m_Root;
56  }
57 
58  Widget GetWidget()
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  {
102  m_IconBig.LoadImageFile(0, picture);
103  }
104  else if (logo != "")
105  {
106  m_IconBig.LoadImageFile(0, logo);
107  }
108  else
109  {
110  m_IconBig.LoadImageFile(0, ModInfo.DEFAULT_PICTURE);
111  }
112 
113  //Load Small Icon
114  if (logo != "")
115  {
116  m_IconSmall.LoadImageFile(0, logo);
117  }
118  else if (picture != "")
119  {
120  m_IconSmall.LoadImageFile(0, picture);
121  }
122  else
123  {
124  m_IconSmall.LoadImageFile(0, ModInfo.DEFAULT_LOGO_SMALL);
125  }
126 
127  if (name != "")
128  {
129  m_Name.SetText(name);
130  }
131 
132  if (description != "")
133  {
134  m_Description.SetText(description);
135  }
136  else
137  {
138  m_Description.SetText(ModInfo.DEFAULT_OVERVIEW);
139  }
140  m_Description.Update();
141  m_Detail.Update();
142 
143  if (author != "")
144  {
145  m_Author.Show( true );
146  m_Author.SetText(author);
147  }
148 
149  if (version != "")
150  {
151  m_Version.Show( true );
152  m_Version.SetText(version);
153  }
154 
155  #ifdef PLATFORM_WINDOWS
156  if (action != "")
157  {
158  m_ActionWebsite.Show( true );
159  }
160  #endif
161 
162  if ( m_Data.GetIsDLC() )
163  {
164  bool isOwned = m_Data.GetIsOwned();
165  m_Root.FindAnyWidget("ModOwnership").Show( true );
166  m_Root.FindAnyWidget("Owned").Show( isOwned );
167  m_Root.FindAnyWidget("Unowned").Show( !isOwned );
168  m_ActionPurchase.Show( true );
169  m_Version.Show( false );
170  }
171  }
172 
173  override bool OnMouseButtonUp(Widget w, int x, int y, int button)
174  {
175  if( w == m_IconCollapse )
176  {
177  m_ParentMenu.Select( m_Data, !m_IsOpen );
178  return true;
179  }
180  else if( w == m_ActionWebsite )
181  {
182  GetGame().OpenURL( m_Data.GetAction() );
183  }
184  else if( w == m_ActionPurchase )
185  {
186  m_Data.GoToStore();
187  }
188  return false;
189  }
190 
191  override bool OnMouseEnter(Widget w, int x, int y)
192  {
193  if( w == m_ActionWebsite )
194  {
195  m_ActionWebsite.SetBold( true );
196  m_ActionWebsite.SetText( "#mod_detail_info_website" );
197  }
198 
199  if( w == m_ActionPurchase )
200  {
201  m_ActionPurchase.SetBold( true );
202  m_ActionPurchase.SetText( "#mod_detail_info_store" );
203  }
204 
205  if( w == m_Root )
206  {
207  if( m_Data.GetTooltip() != "" )
208  m_ParentMenu.PrepareTooltip( m_Data );
209  return true;
210  }
211 
212  return false;
213  }
214 
215  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
216  {
217  if( w == m_ActionWebsite )
218  {
219  m_ActionWebsite.SetBold( false );
220  m_ActionWebsite.SetText( "#mod_detail_info_website" );
221  }
222 
223  if( w == m_ActionPurchase )
224  {
225  m_ActionPurchase.SetBold( false );
226  m_ActionPurchase.SetText( "#mod_detail_info_store" );
227  }
228 
229  if( enterW != m_Root )
230  {
231  m_ParentMenu.HideTooltip();
232  return true;
233  }
234 
235  return false;
236  }
237 }
GetGame
proto native CGame GetGame()
ModInfo
Definition: modinfo.c:1
m_Data
string m_Data
Definition: universaltemperaturesource.c:205
m_Name
string m_Name
Definition: bioslobbyservice.c:35
y
Icon y
OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition: uihintpanel.c:276
m_Description
string m_Description
class purpose description
Definition: enentity.c:845
OnMouseButtonUp
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition: radialmenu.c:668
RichTextWidget
Definition: gameplay.c:315
TextWidget
Definition: enwidgets.c:219
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
Widget
Definition: enwidgets.c:189
m_Root
protected Widget m_Root
Definition: sizetochild.c:91
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