mainmenunewsfeed.c 5.2 KB

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