Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
mainmenunewsfeed.c
Go to the documentation of this file.
1class MainMenuNewsfeed extends ScriptedWidgetEventHandler
2{
3 protected Widget m_Root;
4
5 protected Widget m_DLDLC;
6 protected Widget m_Discord;
7 protected Widget m_Feedback;
8 protected Widget m_DayZForum;
9 protected Widget m_Twitter;
10 protected Widget m_Youtube;
11
12 protected TextWidget m_MainText1;
13 protected TextWidget m_MainText2;
14 protected TextWidget m_MainText3;
15 protected TextWidget m_SecText1;
16 protected TextWidget m_SecText2;
17 protected TextWidget m_SecText3;
18
19 void MainMenuNewsfeed( Widget root )
20 {
21 m_Root = root;
22
23 m_DLDLC = m_Root.FindAnyWidget( "downloaddlc" );
24 m_Discord = m_Root.FindAnyWidget( "discord" );
25 m_Feedback = m_Root.FindAnyWidget( "feedback_tracker" );
26 m_DayZForum = m_Root.FindAnyWidget( "dayz_forums" );
27 m_Twitter = m_Root.FindAnyWidget( "twitter" );
28 m_Youtube = m_Root.FindAnyWidget( "youtube" );
29
30 m_MainText1 = TextWidget.Cast( m_Root.FindAnyWidget( "SGInfoT1" ) );
31 m_MainText2 = TextWidget.Cast( m_Root.FindAnyWidget( "SGInfoT2" ) );
32 m_MainText3 = TextWidget.Cast( m_Root.FindAnyWidget( "SGInfoT3" ) );
33 m_SecText1 = TextWidget.Cast( m_Root.FindAnyWidget( "SGInfoC1" ) );
34 m_SecText2 = TextWidget.Cast( m_Root.FindAnyWidget( "SGInfoC2" ) );
35 m_SecText3 = TextWidget.Cast( m_Root.FindAnyWidget( "SGInfoC3" ) );
36
37 ShowNewsfeed();
38
39 m_Root.SetHandler( this );
40 }
41
42 void ShowNewsfeed()
43 {
44 //m_Root.Show( true );
45 m_MainText1.SetText( "#layout_mainmenu_newsfeed_sgz_title_1" );
46 m_MainText1.Update();
47 m_MainText2.SetText( "#layout_mainmenu_newsfeed_sgz_title_2" );
48 m_MainText2.Update();
49 m_MainText3.SetText( "#layout_mainmenu_newsfeed_sgz_title_3" );
50 m_MainText3.Update();
51 m_SecText1.SetText( "#layout_mainmenu_newsfeed_sgz_text_1" );
52 m_SecText1.Update();
53 m_SecText2.SetText( "#layout_mainmenu_newsfeed_sgz_text_2" );
54 m_SecText2.Update();
55 m_SecText3.SetText( "#layout_mainmenu_newsfeed_sgz_text_3" );
56 m_SecText3.Update();
57 }
58
59 void HideNewsfeed()
60 {
61 m_Root.Show( false );
62 }
63
64 void OpenDLC()
65 {
66 GetGame().OpenURL( "https://store.steampowered.com/app/830660/Survivor_GameZ/" );
67 }
68
69 void OpenDiscord()
70 {
71 GetGame().OpenURL( "https://discord.gg/bXkyMNm" );
72 }
73
74 void OpenFeedback()
75 {
76 GetGame().OpenURL( "https://feedback.bistudio.com/tag/dayz" );
77 }
78
79 void OpenForums()
80 {
81 GetGame().OpenURL( "https://forums.dayz.com" );
82 }
83
84 void OpenTwitter()
85 {
86 GetGame().OpenURL( "https://twitter.com/DayZ" );
87 }
88
89 void OpenYoutube()
90 {
91 GetGame().OpenURL( "https://www.youtube.com/user/DayZDevTeam" );
92 }
93
94 override bool OnClick( Widget w, int x, int y, int button )
95 {
96 if( button == MouseState.LEFT )
97 {
98 if ( w == m_DLDLC )
99 {
100 OpenDLC();
101 return true;
102 }
103 else if ( w == m_Discord )
104 {
105 OpenDiscord();
106 return true;
107 }
108 else if ( w == m_Feedback )
109 {
110 OpenFeedback();
111 return true;
112 }
113 else if ( w == m_DayZForum )
114 {
115 OpenForums();
116 return true;
117 }
118 else if ( w == m_Twitter )
119 {
120 OpenTwitter();
121 return true;
122 }
123 else if ( w == m_Youtube )
124 {
125 OpenYoutube();
126 return true;
127 }
128 }
129 return false;
130 }
131
132 override bool OnMouseEnter( Widget w, int x, int y )
133 {
134 if( IsFocusable( w ) )
135 {
136 ColorRed( w, x, y );
137 return true;
138 }
139 return false;
140 }
141
142 override bool OnMouseLeave( Widget w, Widget enterW, int x, int y )
143 {
144 if( IsFocusable( w ) )
145 {
146 ColorWhite( w, enterW, x, y );
147 return true;
148 }
149 return false;
150 }
151
152 override bool OnFocus( Widget w, int x, int y )
153 {
154 if( IsFocusable( w ) )
155 {
156 ColorRed( w, x, y );
157 return true;
158 }
159 return false;
160 }
161
162 override bool OnFocusLost( Widget w, int x, int y )
163 {
164 if( IsFocusable( w ) )
165 {
166 ColorWhite( w, null, x, y );
167 return true;
168 }
169 return false;
170 }
171
172 bool IsFocusable( Widget w )
173 {
174 if( w )
175 {
176 return ( w == m_DLDLC || w == m_Discord || w == m_Feedback || w == m_DayZForum || w == m_Twitter || w == m_Youtube );
177 }
178 return false;
179 }
180
181 //Coloring functions (Until WidgetStyles are useful)
182 void ColorRed( Widget w, int x, int y )
183 {
184 SetFocus( w );
185 if( w.IsInherited( ButtonWidget ) )
186 {
187 ButtonWidget button = ButtonWidget.Cast( w );
188 button.SetTextColor( ARGB( 255, 255, 0, 0 ) );
189 button.SetAlpha( 0.9 );
190 }
191
192 TextWidget text = TextWidget.Cast(w.FindWidget( w.GetName() + "_text" ) );
193 TextWidget text2 = TextWidget.Cast(w.FindWidget( w.GetName() + "_text_1" ) );
194 ImageWidget image = ImageWidget.Cast( w.FindWidget( w.GetName() + "_image" ) );
195
196 if( text )
197 {
198 text.SetColor( ARGB( 255, 255, 0, 0 ) );
199 }
200
201 if( text2 )
202 {
203 text2.SetColor( ARGB( 255, 255, 0, 0 ) );
204 }
205
206 if( image )
207 {
208 image.SetColor( ARGB( 255, 255, 0, 0 ) );
209 }
210 }
211
212 void ColorWhite( Widget w, Widget enterW, int x, int y )
213 {
214 if( w.IsInherited( ButtonWidget ) )
215 {
216 ButtonWidget button = ButtonWidget.Cast( w );
217 button.SetTextColor( ARGB( 255, 255, 255, 255 ) );
218 button.SetAlpha( 0.75 );
219 }
220
221 TextWidget text = TextWidget.Cast(w.FindWidget( w.GetName() + "_text" ) );
222 TextWidget text2 = TextWidget.Cast(w.FindWidget( w.GetName() + "_text_1" ) );
223 ImageWidget image = ImageWidget.Cast( w.FindWidget( w.GetName() + "_image" ) );
224
225 if( text )
226 {
227 text.SetColor( ARGB( 255, 255, 255, 255 ) );
228 }
229
230 if( text2 )
231 {
232 text2.SetColor( ARGB( 255, 255, 255, 255 ) );
233 }
234
235 if( image )
236 {
237 image.SetColor( ARGB( 255, 255, 255, 255 ) );
238 }
239 }
240}
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
proto native void OpenURL(string url)
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition dayzgame.c:151
proto native CGame GetGame()
MouseState
Definition ensystem.c:311
Icon x
Icon y
int ARGB(int a, int r, int g, int b)
Definition proto.c:322
override bool OnFocusLost(Widget w, int x, int y)
bool IsFocusable(Widget w)
override bool OnFocus(Widget w, int x, int y)
Widget m_Root
Definition sizetochild.c:91