sfx_edit.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* $Id$
  2. * MegaZeux
  3. *
  4. * Copyright (C) 1996 Greg Janson
  5. * Copyright (C) 1998 Matthew D. Williams - dbwilli@scsn.net
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. //Code to edit (via edit dialog) and test custom sound effects
  22. #include "helpsys.h"
  23. #include "string.h"
  24. #include "sfx_edit.h"
  25. #include "sfx.h"
  26. #include "window.h"
  27. #include "data.h"
  28. //8 char names per sfx
  29. char sfx_names[NUM_SFX*10]={
  30. "Gem \0"
  31. "MagicGem \0"
  32. "Health \0"
  33. "Ammo \0"
  34. "Coin \0"
  35. "Life \0"
  36. "Lo Bomb \0"
  37. "Hi Bomb \0"
  38. "Key \0"
  39. "FullKeys \0"
  40. "Unlock \0"
  41. "Need Key \0"
  42. "InvsWall \0"
  43. "Forest \0"
  44. "GateLock \0"
  45. "OpenGate \0"
  46. "Invinco1 \0"
  47. "Invinco2 \0"
  48. "Invinco3 \0"
  49. "DoorLock \0"
  50. "OpenDoor \0"
  51. "Ouch \0"
  52. "Lava \0"
  53. "Death \0"
  54. "GameOver \0"
  55. "GateClse \0"
  56. "Push \0"
  57. "Trnsport \0"
  58. "Shoot \0"
  59. "Break \0"
  60. "NeedAmmo \0"
  61. "Ricochet \0"
  62. "NeedBomb \0"
  63. "Place Lo \0"
  64. "Place Hi \0"
  65. "BombType \0"
  66. "Explsion \0"
  67. "Entrance \0"
  68. "Pouch \0"
  69. "Potion \0"
  70. "EmtyChst \0"
  71. "Chest \0"
  72. "Time Out \0"
  73. "FireOuch \0"
  74. "StolenGm \0"
  75. "EnemyHit \0"
  76. "DrgnFire \0"
  77. "Scroll \0"
  78. "Goop \0"
  79. "Unused " };
  80. //--------------------------
  81. //
  82. // ( ) Default internal SFX
  83. // ( ) Custom SFX
  84. //
  85. // _OK_ _Cancel_
  86. //
  87. //--------------------------
  88. char sfxdi_types[3]={ DE_RADIO,DE_BUTTON,DE_BUTTON };
  89. char sfxdi_xs[3]={ 2,5,15 };
  90. char sfxdi_ys[3]={ 2,5,5 };
  91. char far *sfxdi_strs[3]={ "Default internal SFX\nCustom SFX",
  92. "OK","Cancel" };
  93. int sfxdi_p1s[3]={ 2,0,-1 };
  94. int sfxdi_p2s[1]={ 20 };
  95. void far *sfxdi_storage[1]={ &custom_sfx_on };
  96. dialog sfxdi={
  97. 26,7,53,14,"Choose SFX mode",3,
  98. sfxdi_types,
  99. sfxdi_xs,
  100. sfxdi_ys,
  101. sfxdi_strs,
  102. sfxdi_p1s,
  103. sfxdi_p2s,
  104. sfxdi_storage,0 };
  105. //(full screen)
  106. //
  107. //|--
  108. //|
  109. //|Explsion_________//_____|
  110. //|MagicGem_________//_____|
  111. //|etc. _________//_____|
  112. //|
  113. //|
  114. //|
  115. //| Next Prev Done
  116. //|
  117. //|--
  118. //17 on pg 1/2, 16 on pg 3
  119. char sedi_types[21]={ DE_BUTTON,DE_BUTTON,DE_BUTTON,DE_TEXT,DE_INPUT,DE_INPUT,
  120. DE_INPUT,DE_INPUT,DE_INPUT,DE_INPUT,DE_INPUT,DE_INPUT,DE_INPUT,DE_INPUT,
  121. DE_INPUT,DE_INPUT,DE_INPUT,DE_INPUT,DE_INPUT,DE_INPUT,DE_INPUT };
  122. char sedi_xs[21]={ 16,36,60,23,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 };
  123. char sedi_ys[21]={ 22,22,22,20,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 };
  124. int sedi_p1s[21]={ 1,2,0,0,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,
  125. 68 };
  126. int sedi_p2s[21]={ 0,0,0,0,224,224,224,224,224,224,224,224,224,224,224,224,
  127. 224,224,224,224,224 };
  128. char far *sedi_strs[21]={ "Next","Previous","Done","Press Alt+T to test a sound effect" };
  129. void far *sedi_storage[21];
  130. dialog sedi={
  131. 0,0,79,24,"Edit custom SFX",21,
  132. sedi_types,
  133. sedi_xs,
  134. sedi_ys,
  135. sedi_strs,
  136. sedi_p1s,
  137. sedi_p2s,
  138. sedi_storage,4 };
  139. void sfx_edit(void) {
  140. //First, ask whether sfx should be INTERNAL or CUSTOM. If change is made
  141. //from CUSTOM to INTERNAL, verify deletion of CUSTOM sfx. If changed to
  142. //CUSTOM, copy over INTERNAL to CUSTOM. If changed to or left at CUSTOM,
  143. //go to sfx editing.
  144. int t1;
  145. int old_sfx_mode=custom_sfx_on;
  146. char pg=0;
  147. set_context(97);
  148. if(run_dialog(&sfxdi,current_pg_seg,1)) {
  149. pop_context();
  150. return;
  151. }
  152. //Custom to internal
  153. if((old_sfx_mode)&&(!custom_sfx_on)) {
  154. if(!confirm("Delete current custom SFX?")) {
  155. pop_context();
  156. return;
  157. }
  158. else {
  159. custom_sfx_on=1;
  160. pop_context();
  161. return;
  162. }
  163. }
  164. //Internal to custom
  165. if((!old_sfx_mode)&&(custom_sfx_on)) {
  166. for(t1=0;t1<NUM_SFX;t1++)
  167. str_cpy(&custom_sfx[t1*69],sfx_strs[t1]);
  168. }
  169. //Internal
  170. if(!custom_sfx_on) {
  171. pop_context();
  172. return;
  173. }
  174. //Edit custom
  175. do {
  176. //Setup page
  177. for(t1=0;t1<17;t1++) {
  178. sedi_strs[t1+4]=&sfx_names[(t1+pg*17)*10];
  179. sedi_storage[t1+4]=&custom_sfx[(t1+pg*17)*69];
  180. }
  181. //Setup number and current
  182. sedi.num_elements=(pg<2)?21:20;
  183. sedi.curr_element=4;
  184. //Run dialog
  185. t1=run_dialog(&sedi,current_pg_seg,0,1);
  186. //Next/prev page?
  187. if(t1==1) pg++;
  188. else if(t1==2) pg--;
  189. if(pg<0) pg=2;
  190. if(pg>2) pg=0;
  191. } while(t1>0);
  192. //Done!
  193. pop_context();
  194. }