huddebug.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. // *************************************************************************************
  2. // ! PluginDayzPlayerDebugUI
  3. // *************************************************************************************
  4. class HudDebugEventHandler extends ScriptedWidgetEventHandler
  5. {
  6. HudDebug m_HudDebug;
  7. void HudDebugEventHandler( HudDebug hud_debug )
  8. {
  9. m_HudDebug = hud_debug;
  10. }
  11. HudDebug GetHudDebug()
  12. {
  13. return m_HudDebug;
  14. }
  15. override bool OnClick( Widget w, int x, int y, int button )
  16. {
  17. super.OnClick( w, x, y, button );
  18. return GetHudDebug().OnClick( w, x, y, button );
  19. }
  20. override bool OnFocus(Widget w, int x, int y)
  21. {
  22. //Print("OnFocus");
  23. return true;
  24. }
  25. override bool OnFocusLost(Widget w, int x, int y)
  26. {
  27. //Print("OnFocusLost");
  28. return true;
  29. }
  30. /*
  31. override bool OnMouseEnter(Widget w, int x, int y)
  32. {
  33. Print("OnMouseEnter");
  34. return true;
  35. }
  36. override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
  37. {
  38. Print("OnMouseLeaves");
  39. return true;
  40. }*/
  41. override bool OnMouseButtonDown(Widget w, int x, int y, int button)
  42. {
  43. //Print("OnMouseButtonDown");
  44. return true;
  45. }
  46. override bool OnSelect(Widget w, int x, int y)
  47. {
  48. //Print("OnSelect");
  49. return true;
  50. }
  51. override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
  52. {
  53. //Print("OnItemSelected");
  54. return true;
  55. }
  56. override bool OnModalResult(Widget w, int x, int y, int code, int result)
  57. {
  58. //Print("OnModalResult");
  59. return true;
  60. }
  61. override bool OnChange(Widget w, int x, int y, bool finished)
  62. {
  63. //Print("OnChange " + finished);
  64. super.OnChange( w, x, y, finished );
  65. return GetHudDebug().OnChange( w, x, y, finished );
  66. }
  67. }
  68. class HudDebug extends Hud
  69. {
  70. static const int HUD_WIN_UNDEFINED = 0;
  71. static const int HUD_WIN_CHAR_STATS = 1;
  72. static const int HUD_WIN_CHAR_MODIFIERS = 2;
  73. static const int HUD_WIN_CHAR_AGENTS = 3;
  74. static const int HUD_WIN_CHAR_DEBUG = 4;
  75. static const int HUD_WIN_CHAR_LEVELS = 5;
  76. static const int HUD_WIN_CHAR_STOMACH = 6;
  77. static const int HUD_WIN_VERSION = 7;
  78. static const int HUD_WIN_TEMPERATURE = 8;
  79. static const int HUD_WIN_HEALTH = 9;
  80. Widget m_WgtRoot;
  81. Widget m_Crosshair;
  82. ref array<ref HudDebugWinBase> m_Panels;
  83. ref Timer m_TimerUpdate;
  84. ref HudDebugEventHandler m_HudDebugHandler;
  85. ref HudDebugWinCharModifiers m_WinCharModifiers;
  86. ref HudDebugWinCharStats m_WinCharStats;
  87. ref HudDebugWinCharAgents m_WinCharAgents;
  88. ref HudDebugWinHealth m_WinHealth;
  89. //============================================
  90. // HudDebug
  91. //============================================
  92. void HudDebug()
  93. {
  94. }
  95. //============================================
  96. // ~HudDebug
  97. //============================================
  98. void ~HudDebug()
  99. {
  100. delete m_WgtRoot;
  101. m_TimerUpdate.Stop();
  102. }
  103. //============================================
  104. // Init
  105. //============================================
  106. override void Init( Widget hud_panel_widget )
  107. {
  108. m_WgtRoot = hud_panel_widget;
  109. m_WgtRoot.Show( true );
  110. // Crosshair widget root
  111. m_Crosshair = m_WgtRoot.FindAnyWidget( "wdw_Crosshair" );
  112. m_Panels = new array<ref HudDebugWinBase>;
  113. // Register Window Character Stats
  114. m_WinCharStats = new HudDebugWinCharStats( m_WgtRoot.FindAnyWidget( "wdw_CharacterStats" ) );
  115. m_Panels.Insert( m_WinCharStats );
  116. // Register Window Character Stats
  117. HudDebugWinCharLevels win_char_levels = new HudDebugWinCharLevels( m_WgtRoot.FindAnyWidget( "wdw_CharacterLevels" ) );
  118. m_Panels.Insert( win_char_levels );
  119. // Register Window Chracter Modifiers
  120. m_WinCharModifiers = new HudDebugWinCharModifiers( m_WgtRoot.FindAnyWidget( "wdw_CharacterModifiers" ) );
  121. m_Panels.Insert( m_WinCharModifiers );
  122. // Register Window Chracter Agents
  123. m_WinCharAgents = new HudDebugWinCharAgents( m_WgtRoot.FindAnyWidget( "wdw_CharacterAgents" ) );
  124. m_Panels.Insert( m_WinCharAgents );
  125. // Register Window Chracter Debug
  126. HudDebugWinCharDebug win_char_debug = new HudDebugWinCharDebug( m_WgtRoot.FindAnyWidget( "wdw_CharacterDebug" ) );
  127. m_Panels.Insert( win_char_debug );
  128. // Register Window Chracter Debug
  129. HudDebugWinCharStomach win_char_stomach = new HudDebugWinCharStomach( m_WgtRoot.FindAnyWidget( "wdw_CharacterStomach" ) );
  130. m_Panels.Insert( win_char_stomach );
  131. // Register Window Version
  132. HudDebugWinVersion win_version = new HudDebugWinVersion( m_WgtRoot.FindAnyWidget( "wdw_Version" ) );
  133. m_Panels.Insert( win_version );
  134. // Register Window Temperature
  135. HudDebugWinTemperature win_temp = new HudDebugWinTemperature( m_WgtRoot.FindAnyWidget( "wdw_Temp" ) );
  136. m_Panels.Insert( win_temp );
  137. // Register Window Character Health
  138. m_WinHealth = new HudDebugWinHealth( m_WgtRoot.FindAnyWidget( "wdw_Health" ) );
  139. m_Panels.Insert( m_WinHealth );
  140. RefreshByLocalProfile();
  141. RefreshCrosshairVisibility();
  142. m_TimerUpdate = new Timer();
  143. m_TimerUpdate.Run( 1.0, this, "Update", NULL, true );
  144. //set ui event handler
  145. m_HudDebugHandler = new HudDebugEventHandler( this );
  146. m_WgtRoot.SetHandler( m_HudDebugHandler );
  147. }
  148. //============================================
  149. // Update
  150. //============================================
  151. override void Update( float timeslice )
  152. {
  153. for ( int i = 0; i < m_Panels.Count(); ++i )
  154. {
  155. if ( m_Panels.Get( i ).IsVisible() )
  156. {
  157. m_Panels.Get( i ).Update();
  158. }
  159. }
  160. }
  161. //============================================
  162. // SetPanetVisible
  163. //============================================
  164. void SetPanelVisible(int panel_type, bool visible)
  165. {
  166. if ( visible )
  167. {
  168. PanelShow( panel_type );
  169. }
  170. else
  171. {
  172. PanelHide( panel_type );
  173. }
  174. }
  175. //============================================
  176. // PanelShow
  177. //============================================
  178. void PanelShow(int panel_type)
  179. {
  180. for ( int i = 0; i < m_Panels.Count(); ++i )
  181. {
  182. HudDebugWinBase panel = m_Panels.Get( i );
  183. if ( panel.GetType() == panel_type )
  184. {
  185. panel.Show();
  186. }
  187. }
  188. }
  189. //============================================
  190. // PanelHide
  191. //============================================
  192. void PanelHide(int panel_type)
  193. {
  194. for ( int i = 0; i < m_Panels.Count(); ++i )
  195. {
  196. HudDebugWinBase panel = m_Panels.Get( i );
  197. if ( panel.GetType() == panel_type )
  198. {
  199. panel.Hide();
  200. }
  201. }
  202. }
  203. //============================================
  204. // RefreshCrosshairVisibility
  205. //============================================
  206. void RefreshCrosshairVisibility()
  207. {
  208. PluginConfigDebugProfile module_cfg_profile = PluginConfigDebugProfile.Cast( GetPlugin( PluginConfigDebugProfile ) );
  209. if ( module_cfg_profile )
  210. {
  211. PluginDeveloper modul_dev = PluginDeveloper.Cast( GetPlugin( PluginDeveloper ) );
  212. if ( modul_dev.IsEnabledFreeCamera() )
  213. {
  214. m_Crosshair.Show( module_cfg_profile.GetFreeCameraCrosshairVisible() );
  215. }
  216. else
  217. {
  218. m_Crosshair.Show( false );
  219. }
  220. }
  221. }
  222. //============================================
  223. // HideCrosshairVisibility
  224. //============================================
  225. void HideCrosshairVisibility()
  226. {
  227. PluginConfigDebugProfile module_cfg_profile = PluginConfigDebugProfile.Cast( GetPlugin( PluginConfigDebugProfile ) );
  228. if ( module_cfg_profile )
  229. {
  230. PluginDeveloper modul_dev = PluginDeveloper.Cast( GetPlugin( PluginDeveloper ) );
  231. if ( modul_dev.IsEnabledFreeCamera() )
  232. {
  233. m_Crosshair.Show( false );
  234. }
  235. }
  236. }
  237. //============================================
  238. // RefreshByLocalProfile
  239. //============================================
  240. void RefreshByLocalProfile()
  241. {
  242. PluginConfigDebugProfile module_cfg_profile = PluginConfigDebugProfile.Cast( GetPlugin( PluginConfigDebugProfile ) );
  243. if ( module_cfg_profile )
  244. {
  245. SetPanelVisible( HudDebug.HUD_WIN_CHAR_STATS, module_cfg_profile.GetCharacterStatsVisible() );
  246. SetPanelVisible( HudDebug.HUD_WIN_CHAR_LEVELS, module_cfg_profile.GetCharacterLevelsVisible() );
  247. SetPanelVisible( HudDebug.HUD_WIN_CHAR_MODIFIERS, module_cfg_profile.GetCharacterModifiersVisible() );
  248. SetPanelVisible( HudDebug.HUD_WIN_CHAR_AGENTS, module_cfg_profile.GetCharacterAgentsVisible() );
  249. SetPanelVisible( HudDebug.HUD_WIN_CHAR_DEBUG, module_cfg_profile.GetCharacterDebugVisible() );
  250. SetPanelVisible( HudDebug.HUD_WIN_CHAR_STOMACH, module_cfg_profile.GetCharacterStomachVisible() );
  251. SetPanelVisible( HudDebug.HUD_WIN_VERSION, module_cfg_profile.GetVersionVisible() );
  252. SetPanelVisible( HudDebug.HUD_WIN_TEMPERATURE, module_cfg_profile.GetTempVisible() );
  253. SetPanelVisible( HudDebug.HUD_WIN_HEALTH, module_cfg_profile.GetHealthVisible() );
  254. }
  255. }
  256. //============================================
  257. // IsInitialized
  258. //============================================
  259. bool IsInitialized()
  260. {
  261. if ( m_WgtRoot == NULL )
  262. {
  263. return false;
  264. }
  265. return false;
  266. }
  267. //============================================
  268. // OnClick
  269. //============================================
  270. bool OnClick( Widget w, int x, int y, int button )
  271. {
  272. //send OnClick to HudDebugWinCharModifiers
  273. if ( m_WinCharModifiers )
  274. {
  275. if (m_WinCharModifiers.OnClick( w, x, y, button ))
  276. return true;
  277. }
  278. if ( m_WinCharAgents )
  279. {
  280. if (m_WinCharAgents.OnClick( w, x, y, button ))
  281. return true;
  282. }
  283. if ( m_WinCharStats )
  284. {
  285. if (m_WinCharStats.OnClick( w, x, y, button ))
  286. return true;
  287. }
  288. if ( m_WinHealth )
  289. {
  290. if (m_WinHealth.OnClick( w, x, y, button ))
  291. return true;
  292. }
  293. return false;
  294. }
  295. bool OnChange(Widget w, int x, int y, bool finished)
  296. {
  297. if ( m_WinCharStats )
  298. {
  299. if (m_WinCharStats.OnChange( w, x, y, finished ))
  300. return true;
  301. }
  302. return false;
  303. }
  304. }