sfx_edit.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 <string.h>
  23. #include "helpsys.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. {
  31. "Gem \0"
  32. "MagicGem \0"
  33. "Health \0"
  34. "Ammo \0"
  35. "Coin \0"
  36. "Life \0"
  37. "Lo Bomb \0"
  38. "Hi Bomb \0"
  39. "Key \0"
  40. "FullKeys \0"
  41. "Unlock \0"
  42. "Need Key \0"
  43. "InvsWall \0"
  44. "Forest \0"
  45. "GateLock \0"
  46. "OpenGate \0"
  47. "Invinco1 \0"
  48. "Invinco2 \0"
  49. "Invinco3 \0"
  50. "DoorLock \0"
  51. "OpenDoor \0"
  52. "Ouch \0"
  53. "Lava \0"
  54. "Death \0"
  55. "GameOver \0"
  56. "GateClse \0"
  57. "Push \0"
  58. "Trnsport \0"
  59. "Shoot \0"
  60. "Break \0"
  61. "NeedAmmo \0"
  62. "Ricochet \0"
  63. "NeedBomb \0"
  64. "Place Lo \0"
  65. "Place Hi \0"
  66. "BombType \0"
  67. "Explsion \0"
  68. "Entrance \0"
  69. "Pouch \0"
  70. "Potion \0"
  71. "EmtyChst \0"
  72. "Chest \0"
  73. "Time Out \0"
  74. "FireOuch \0"
  75. "StolenGm \0"
  76. "EnemyHit \0"
  77. "DrgnFire \0"
  78. "Scroll \0"
  79. "Goop \0"
  80. "Unused "
  81. };
  82. //--------------------------
  83. //
  84. // ( ) Default internal SFX
  85. // ( ) Custom SFX
  86. //
  87. // _OK_ _Cancel_
  88. //
  89. //--------------------------
  90. char sfxdi_types[3] = { DE_RADIO, DE_BUTTON, DE_BUTTON };
  91. char sfxdi_xs[3] = { 2, 5, 15 };
  92. char sfxdi_ys[3] = { 2, 5, 5 };
  93. char *sfxdi_strs[3] =
  94. {
  95. "Default internal SFX\nCustom SFX", "OK", "Cancel"
  96. };
  97. int sfxdi_p1s[3] = { 2, 0, -1 };
  98. int sfxdi_p2s[1] = { 20 };
  99. // Patch this with mzx_world->custom_sfx_on
  100. void *sfxdi_storage[1];
  101. dialog sfxdi =
  102. {
  103. 26, 7, 53, 14, "Choose SFX mode", 3, sfxdi_types, sfxdi_xs,
  104. sfxdi_ys, sfxdi_strs, sfxdi_p1s, sfxdi_p2s, sfxdi_storage, 0
  105. };
  106. //(full screen)
  107. //
  108. //|--
  109. //|
  110. //|Explsion_________//_____|
  111. //|MagicGem_________//_____|
  112. //|etc. _________//_____|
  113. //|
  114. //|
  115. //|
  116. //| Next Prev Done
  117. //|
  118. //|--
  119. // 17 on pg 1/2, 16 on pg 3
  120. char sedi_types[21] =
  121. {
  122. DE_BUTTON, DE_BUTTON, DE_BUTTON, DE_TEXT, DE_INPUT, DE_INPUT,
  123. DE_INPUT, DE_INPUT, DE_INPUT, DE_INPUT, DE_INPUT, DE_INPUT,
  124. DE_INPUT, DE_INPUT, DE_INPUT, DE_INPUT, DE_INPUT, DE_INPUT,
  125. DE_INPUT, DE_INPUT, DE_INPUT
  126. };
  127. char sedi_xs[21] =
  128. {
  129. 16, 36, 60, 23, 1, 1, 1, 1, 1, 1, 1,
  130. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  131. };
  132. char sedi_ys[21] =
  133. {
  134. 22, 22, 22, 20, 2, 3, 4, 5, 6, 7, 8,
  135. 9, 10, 11, 12, 13, 14, 15, 16, 17, 18
  136. };
  137. int sedi_p1s[21] =
  138. {
  139. 1, 2, 0, 0, 68, 68, 68, 68, 68, 68, 68,
  140. 68, 68, 68, 68, 68, 68, 68, 68, 68, 68
  141. };
  142. int sedi_p2s[21] =
  143. {
  144. 0, 0, 0, 0, 224, 224, 224, 224, 224, 224, 224,
  145. 224, 224, 224, 224, 224, 224, 224,224, 224, 224
  146. };
  147. char *sedi_strs[21] =
  148. {
  149. "Next", "Previous", "Done", "Press Alt+T to test a sound effect"
  150. };
  151. void *sedi_storage[21];
  152. dialog sedi =
  153. {
  154. 0, 0, 79, 24, "Edit custom SFX", 21, sedi_types, sedi_xs, sedi_ys,
  155. sedi_strs, sedi_p1s, sedi_p2s, sedi_storage, 4
  156. };
  157. void sfx_edit(World *mzx_world)
  158. {
  159. // First, ask whether sfx should be INTERNAL or CUSTOM. If change is made
  160. // from CUSTOM to INTERNAL, verify deletion of CUSTOM sfx. If changed to
  161. // CUSTOM, copy over INTERNAL to CUSTOM. If changed to or left at CUSTOM,
  162. // go to sfx editing.
  163. int i;
  164. int old_sfx_mode = mzx_world->custom_sfx_on;
  165. int pg = 0;
  166. int dialog_result;
  167. sfxdi_storage[0] = &mzx_world->custom_sfx_on;
  168. set_context(97);
  169. if(!run_dialog(mzx_world, &sfxdi, 1))
  170. {
  171. // Custom to internal
  172. if((old_sfx_mode) && (!mzx_world->custom_sfx_on))
  173. {
  174. if(confirm(mzx_world, "Delete current custom SFX?"))
  175. {
  176. mzx_world->custom_sfx_on = 1;
  177. }
  178. }
  179. // Internal to custom
  180. if((!old_sfx_mode) && (mzx_world->custom_sfx_on))
  181. {
  182. char *offset = mzx_world->custom_sfx;
  183. for(i = 0; i < NUM_SFX; i++, offset += 69)
  184. {
  185. strcpy(offset, sfx_strs[i]);
  186. }
  187. }
  188. // Internal
  189. if(mzx_world->custom_sfx_on)
  190. {
  191. // Edit custom
  192. do
  193. {
  194. // Setup page
  195. for(i = 0; i < 17; i++)
  196. {
  197. sedi_strs[i + 4] = sfx_names + ((i + (pg * 17)) * 10);
  198. sedi_storage[i + 4] = mzx_world->custom_sfx + ((i + (pg * 17)) * 69);
  199. }
  200. // Setup number and current
  201. if(pg < 2)
  202. sedi.num_elements = 21;
  203. else
  204. sedi.num_elements = 20;
  205. sedi.curr_element = 4;
  206. // Run dialog
  207. dialog_result = run_dialog(mzx_world, &sedi, 0, 1);
  208. // Next/prev page?
  209. switch(dialog_result)
  210. {
  211. case 1:
  212. pg++;
  213. if(pg > 2)
  214. pg = 0;
  215. break;
  216. case 2:
  217. pg--;
  218. if(pg < 0)
  219. pg = 2;
  220. break;
  221. }
  222. } while(dialog_result > 0);
  223. }
  224. }
  225. // Done!
  226. pop_context();
  227. }