huddebugwincharlevels.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. class HudDebugWinCharLevels extends HudDebugWinBase
  2. {
  3. TextListboxWidget m_WgtValues;
  4. //============================================
  5. // Constructor
  6. //============================================
  7. void HudDebugWinCharLevels(Widget widget_root)
  8. {
  9. m_WgtValues = TextListboxWidget.Cast( widget_root.FindAnyWidget("txl_CharLevels_Values") );
  10. FitWindow();
  11. }
  12. //============================================
  13. // Destructor
  14. //============================================
  15. void ~HudDebugWinCharLevels()
  16. {
  17. SetUpdate( false );
  18. }
  19. //============================================
  20. // GetWinType
  21. //============================================
  22. override int GetType()
  23. {
  24. return HudDebug.HUD_WIN_CHAR_LEVELS;
  25. }
  26. //============================================
  27. // Show
  28. //============================================
  29. override void Show()
  30. {
  31. super.Show();
  32. //Print("Show()");
  33. SetUpdate( true );
  34. }
  35. //============================================
  36. // Hide
  37. //============================================
  38. override void Hide()
  39. {
  40. super.Hide();
  41. //Print("Hide()");
  42. SetUpdate( false );
  43. }
  44. //============================================
  45. // SetUpdate
  46. //============================================
  47. override void SetUpdate( bool state )
  48. {
  49. //Disable update on server (PluginDeveloperSync)
  50. PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
  51. PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast( GetPlugin( PluginDeveloperSync ) );
  52. //if client, send RPC
  53. if ( GetGame().IsClient() )
  54. {
  55. ref Param1<bool> params = new Param1<bool>( state );
  56. if ( player )
  57. {
  58. player.RPCSingleParam( ERPCs.DEV_LEVELS_UPDATE, params, true );
  59. SetRPCSent();
  60. }
  61. }
  62. //else set directly
  63. else
  64. {
  65. if ( developer_sync )
  66. {
  67. developer_sync.EnableUpdate( state, ERPCs.DEV_LEVELS_UPDATE, player );
  68. }
  69. }
  70. }
  71. override void Update()
  72. {
  73. super.Update();
  74. //Print("Update()");
  75. //refresh notifiers
  76. SetValues();
  77. }
  78. void SetValues()
  79. {
  80. PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast( GetPlugin( PluginDeveloperSync ) );
  81. //clear window
  82. ClearValues();
  83. if ( developer_sync.m_PlayerLevelsSynced.Count() > 0 )
  84. {
  85. //set
  86. for ( int i = 0; i < developer_sync.m_PlayerLevelsSynced.Count(); i++ )
  87. {
  88. string bar = MiscGameplayFunctions.ValueToBar(developer_sync.m_PlayerLevelsSynced.Get( i ).GetValue2());
  89. AddValue( developer_sync.m_PlayerLevelsSynced.Get( i ).GetName(), developer_sync.m_PlayerLevelsSynced.Get( i ).GetValue().ToString() ,bar );
  90. }
  91. }
  92. //fit to screen
  93. FitWindow();
  94. }
  95. void AddValue( string title, string value, string value2 )
  96. {
  97. int index = m_WgtValues.AddItem( title, NULL, 0 );
  98. m_WgtValues.SetItem( index, value, NULL, 1 );
  99. m_WgtValues.SetItem( index, value2, NULL, 2 );
  100. }
  101. void ClearValues()
  102. {
  103. m_WgtValues.ClearItems();
  104. }
  105. void FitWindow()
  106. {
  107. //FitWindowByContent( m_WgtValues );
  108. }
  109. }