pluginsounddebug.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. class PluginSoundDebug extends PluginBase
  2. {
  3. override void OnInit()
  4. {
  5. m_TickTimer = new Timer();
  6. m_TickTimer.Run(0.1, this, "OnGUITimer", NULL, true);
  7. }
  8. override void OnUpdate(float delta_time)
  9. {
  10. ;
  11. }
  12. override void OnDestroy()
  13. {
  14. m_TickTimer = NULL;
  15. }
  16. void Show()
  17. {
  18. m_TickTimer = new Timer();
  19. m_TickTimer.Run(0.1, this, "OnGUITimer", NULL, true);
  20. }
  21. void Hide()
  22. {
  23. m_TickTimer = NULL;
  24. }
  25. void OnGUITimer()
  26. {
  27. DbgUI.BeginCleanupScope();
  28. DbgUI.Begin("Sound debug", 10, 10);
  29. DbgUI.PushID_Str("SoundParams");
  30. DbgUI.Text("SoundParams: ");
  31. DbgUI.SameLine();
  32. string soundsetName = "BearGrowl_SoundSet";
  33. DbgUI.InputText("", soundsetName, 200);
  34. DbgUI.PopID();
  35. DbgUI.PushID_Str("Offset");
  36. DbgUI.Text("Offset pos: ");
  37. vector posOffset = "0 0 0";
  38. float posVal;
  39. DbgUI.SameLine();
  40. DbgUI.PushID_Int(1);
  41. DbgUI.InputFloat("", posVal, 80);
  42. DbgUI.PopID();
  43. posOffset[0] = posVal;
  44. DbgUI.SameLine();
  45. DbgUI.PushID_Int(2);
  46. DbgUI.InputFloat("", posVal, 80);
  47. DbgUI.PopID();
  48. posOffset[1] = posVal;
  49. DbgUI.SameLine();
  50. DbgUI.PushID_Int(3);
  51. DbgUI.InputFloat("", posVal, 80);
  52. DbgUI.PopID();
  53. posOffset[2] = posVal;
  54. DbgUI.PopID();
  55. if(DbgUI.Button("Create"))
  56. {
  57. m_soundParams = new SoundParams(soundsetName);
  58. m_soundBuilder = new SoundObjectBuilder(m_soundParams);
  59. m_soundObject = m_soundBuilder.BuildSoundObject();
  60. m_soundObject.SetPosition(GetGame().GetPlayer().GetPosition() + posOffset);
  61. }
  62. DbgUI.Text("SoundObjectBuilder: ");
  63. DbgUI.Text("SoundObject: ");
  64. DbgUI.Text("AbstractWave: ");
  65. vector posOffset2 = "0 10 0";
  66. if(m_soundParams != NULL)
  67. {
  68. DbgUI.Text("FadeInFactor: ");
  69. DbgUI.SameLine();
  70. DbgUI.PushID_Str("fadeIn");
  71. DbgUI.InputFloat("", fadeInVolume, 80);
  72. DbgUI.PopID();
  73. DbgUI.Text("FadeOutFactor: ");
  74. DbgUI.SameLine();
  75. DbgUI.PushID_Str("fadeOut");
  76. DbgUI.InputFloat("", fadeOutVolume, 80);
  77. DbgUI.PopID();
  78. DbgUI.PushID_Str("Offset2");
  79. DbgUI.Text("Offset2 pos: ");
  80. float posVal2;
  81. DbgUI.SameLine();
  82. DbgUI.PushID_Int(100);
  83. posVal2 = posOffset2[0];
  84. DbgUI.InputFloat("", posVal2, 80);
  85. DbgUI.PopID();
  86. posOffset2[0] = posVal2;
  87. DbgUI.SameLine();
  88. DbgUI.PushID_Int(101);
  89. posVal2 = posOffset2[1];
  90. DbgUI.InputFloat("", posVal2, 80);
  91. DbgUI.PopID();
  92. posOffset2[1] = posVal2;
  93. DbgUI.SameLine();
  94. DbgUI.PushID_Int(102);
  95. posVal2 = posOffset2[2];
  96. DbgUI.InputFloat("", posVal2, 80);
  97. DbgUI.PopID();
  98. posOffset2[2] = posVal2;
  99. DbgUI.PopID();
  100. DbgUI.Text("skip: ");
  101. DbgUI.SameLine();
  102. float skip = 0.0;
  103. DbgUI.PushID_Int(200);
  104. DbgUI.InputFloat("", skip, 80);
  105. DbgUI.PopID();
  106. if(DbgUI.Button("Create and play"))
  107. {
  108. m_wave = GetGame().GetSoundScene().Play3D(m_soundObject, m_soundBuilder);
  109. m_wave.SetFadeInFactor(fadeInVolume);
  110. m_wave.Skip(skip);
  111. m_wave.SetPosition(GetGame().GetPlayer().GetPosition() + posOffset2);
  112. }
  113. }
  114. if(m_wave != NULL)
  115. {
  116. DbgUI.Text("Wave length: " + m_wave.GetLength() + "s");
  117. //DbgUI.Text("Wave position: " + Math.Round(m_wave.GetCurrPosition() * 100) + "%");
  118. DbgUI.Text("Volume: ");
  119. DbgUI.SameLine();
  120. float volume = 1.0;
  121. DbgUI.InputFloat(" ", volume, 80);
  122. DbgUI.SameLine();
  123. if(DbgUI.Button("SetVolume"))
  124. m_wave.SetVolume(volume);
  125. DbgUI.SameLine();
  126. if(DbgUI.Button("SetVolumeRelative"))
  127. m_wave.SetVolumeRelative(volume);
  128. if(DbgUI.Button("Play"))
  129. m_wave.Play();
  130. if(DbgUI.Button("Stop"))
  131. m_wave.Stop();
  132. if(DbgUI.Button("Restart"))
  133. m_wave.Restart();
  134. if(DbgUI.Button("Repeat"))
  135. m_wave.Loop(true);
  136. if(DbgUI.Button("StopRepeat"))
  137. m_wave.Loop(false);
  138. if(DbgUI.Button("Set position"))
  139. m_wave.SetPosition(GetGame().GetPlayer().GetPosition() + posOffset2);
  140. }
  141. DbgUI.End();
  142. DbgUI.EndCleanupScope();
  143. }
  144. ref Timer m_TickTimer;
  145. ref SoundParams m_soundParams;
  146. ref SoundObjectBuilder m_soundBuilder;
  147. ref SoundObject m_soundObject;
  148. float fadeInVolume = 1.1;
  149. float fadeOutVolume = 0.9;
  150. AbstractWave m_wave;
  151. }