block.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. /* Block functions and dialogs */
  22. #include <stdio.h>
  23. #include "helpsys.h"
  24. #include "idput.h"
  25. #include "error.h"
  26. #include "block.h"
  27. #include "window.h"
  28. #include "data.h"
  29. #include "idarray.h"
  30. #include "world.h"
  31. //--------------------------
  32. //
  33. // ( ) Copy block
  34. // ( ) Move block
  35. // ( ) Clear block
  36. // ( ) Flip block
  37. // ( ) Mirror block
  38. // ( ) Paint block
  39. // ( ) Copy to/from overlay
  40. // ( ) Save as ANSi
  41. // ( ) Save as MZM
  42. //
  43. // _OK_ _Cancel_
  44. //
  45. //--------------------------
  46. char bdi_types[3] = { DE_RADIO, DE_BUTTON, DE_BUTTON };
  47. char bdi_xs[3] = { 2, 5, 15 };
  48. char bdi_ys[3] = { 2, 12, 12 };
  49. char *bdi_strs[3] =
  50. {
  51. "Copy block\n"
  52. "Copy block (repeated)\n"
  53. "Move block\n"
  54. "Clear block\n"
  55. "Flip block\n"
  56. "Mirror block\n"
  57. "Paint block\n"
  58. "Copy to/from overlay\n"
  59. "Save as MZM",
  60. "OK", "Cancel"
  61. };
  62. int bdi_p1s[3] = { 9, 0, -1};
  63. int bdi_p2s[1] = { 21 };
  64. int block_op = 0;
  65. void *bdi_storage[1] = { &block_op };
  66. dialog bdi =
  67. {
  68. 26, 3, 54, 17, "Choose block command", 3, bdi_types, bdi_xs,
  69. bdi_ys, bdi_strs, bdi_p1s, bdi_p2s, bdi_storage, 0
  70. };
  71. int block_cmd(World *mzx_world)
  72. {
  73. int dialog_ret;
  74. set_context(73);
  75. dialog_ret = run_dialog(mzx_world, &bdi);
  76. pop_context();
  77. if(dialog_ret)
  78. return -1;
  79. return block_op;
  80. }
  81. char adi_types[3] = { DE_RADIO, DE_BUTTON, DE_BUTTON };
  82. char adi_xs[3] = { 6, 5, 15 };
  83. char adi_ys[3] = { 4, 11, 11 };
  84. char *adi_strs[3] = { "Custom Block\nCustom Floor\nText", "OK", "Cancel" };
  85. int adi_p1s[3] = { 3, 0, -1 };
  86. int adi_p2s[1] = { 12 };
  87. int obj_type = 0;
  88. void *adi_storage[1] = { &obj_type };
  89. dialog adi =
  90. {
  91. 26, 4, 53, 17, "Object type", 3, adi_types, adi_xs, adi_ys, adi_strs,
  92. adi_p1s, adi_p2s, adi_storage, 0
  93. };
  94. int rtoo_obj_type(World *mzx_world)
  95. {
  96. set_context(74);
  97. if(run_dialog(mzx_world, &adi))
  98. {
  99. pop_context();
  100. return -1;
  101. }
  102. pop_context();
  103. return obj_type;
  104. }
  105. char csdi_types[3] = { DE_RADIO, DE_BUTTON, DE_BUTTON };
  106. char csdi_xs[3] = { 4, 5, 15 };
  107. char csdi_ys[3] = { 4, 11, 11 };
  108. char *csdi_strs[3] =
  109. {
  110. "MegaZeux default\n"
  111. "ASCII set\n"
  112. "SMZX set\n"
  113. "Blank set", "OK", "Cancel"
  114. };
  115. int csdi_p1s[3] = { 4, 0, -1};
  116. int csdi_p2s[1] = { 16 };
  117. int cs_type = 0;
  118. void *csdi_storage[1] = { &cs_type };
  119. dialog csdi =
  120. {
  121. 26, 4, 53, 17, "Character set", 3, csdi_types, csdi_xs, csdi_ys,
  122. csdi_strs, csdi_p1s, csdi_p2s, csdi_storage, 0
  123. };
  124. int choose_char_set(World *mzx_world)
  125. {
  126. set_context(75);
  127. if(run_dialog(mzx_world, &csdi))
  128. {
  129. pop_context();
  130. return -1;
  131. }
  132. pop_context();
  133. return cs_type;
  134. }
  135. char ed_types[3] = { DE_INPUT, DE_BUTTON, DE_BUTTON };
  136. char ed_xs[3] = { 5, 15, 37 };
  137. char ed_ys[3] = { 2, 4, 4 };
  138. char *ed_strs[3] = { NULL, "OK", "Cancel" };
  139. int ed_p1s[3] = { 32, 0, 1 };
  140. int ed_p2s = 192;
  141. void *fe_ptr = NULL;
  142. dialog e_di =
  143. {
  144. 10, 8, 69, 14, NULL, 3, ed_types, ed_xs, ed_ys, ed_strs, ed_p1s,
  145. &ed_p2s, &fe_ptr, 0
  146. };
  147. char edc_types[5] = { DE_INPUT, DE_NUMBER, DE_NUMBER, DE_BUTTON, DE_BUTTON };
  148. char edc_xs[5] = { 5, 5, 28, 15, 37 };
  149. char edc_ys[5] = { 2, 3, 3, 5, 5 };
  150. char *edc_strs[5] = { "Save as: ", "Offset: ", "Size: ", "OK", "Cancel" };
  151. int edc_p1s[5] = { 32, 0, 1, 0, 1 };
  152. int edc_p2s[5] = { 192, 255, 256, 0, 0 };
  153. void *edc_storage[5] = { NULL };
  154. dialog ec_di =
  155. {
  156. 10, 8, 69, 15, "Export", 5, edc_types, edc_xs, edc_ys, edc_strs, edc_p1s,
  157. edc_p2s, edc_storage, 0
  158. };
  159. int save_file_dialog(World *mzx_world, char *title, char *prompt, char *dest)
  160. {
  161. fe_ptr = (void *)dest;
  162. ed_strs[0] = prompt;
  163. e_di.title = title;
  164. return run_dialog(mzx_world, &e_di);
  165. }
  166. int save_char_dialog(World *mzx_world, char *dest, int *char_offset,
  167. int *char_size)
  168. {
  169. edc_storage[0] = dest;
  170. edc_storage[1] = char_offset;
  171. edc_storage[2] = char_size;
  172. return run_dialog(mzx_world, &ec_di);
  173. }
  174. // The ansi prefix code
  175. char ansi_pre[3] = "[";
  176. // EGA colors to ANSi colors
  177. char col2ansi[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
  178. // Mini func to output meta codes to transform color from one to another.
  179. // Curr color is the current color and dest color is the color we want.
  180. char exdi_types[3] = { DE_RADIO, DE_BUTTON, DE_BUTTON };
  181. char exdi_xs[3] = { 2, 5, 15 };
  182. char exdi_ys[3] = { 3, 8, 8 };
  183. char *exdi_strs[3] =
  184. {
  185. "Board file (MZB)\n"
  186. "Character set (CHR)\n"
  187. "Palette (PAL)\n"
  188. "Sound effects (SFX)",
  189. "OK", "Cancel"
  190. };
  191. int exdi_p1s[3] = { 4, 0, -1 };
  192. int exdi_p2s[1] = { 19 };
  193. void *exdi_storage[1] = { NULL };
  194. dialog exdi =
  195. {
  196. 26, 5, 53, 15, "Export as:", 3, exdi_types, exdi_xs, exdi_ys,
  197. exdi_strs, exdi_p1s, exdi_p2s, exdi_storage, 0
  198. };
  199. int export_type(World *mzx_world)
  200. {
  201. int storage = 0;
  202. set_context(77);
  203. exdi_storage[0] = &storage;
  204. if(run_dialog(mzx_world, &exdi))
  205. {
  206. pop_context();
  207. return -1;
  208. }
  209. pop_context();
  210. return storage;
  211. }
  212. char imdi_types[3] = { DE_RADIO, DE_BUTTON, DE_BUTTON };
  213. char imdi_xs[3] = { 2, 5, 15 };
  214. char imdi_ys[3] = { 3, 10, 10 };
  215. char *imdi_strs[3] =
  216. {
  217. "Board file (MZB)\n"
  218. "Character set (CHR)\n"
  219. "World file (MZX)\n"
  220. "Palette (PAL)\n"
  221. "Sound effects (SFX)\n"
  222. "MZM (choose pos.)",
  223. "OK", "Cancel"
  224. };
  225. int imdi_p1s[3] = { 6, 0, -1 };
  226. int imdi_p2s[1] = { 19 };
  227. void *imdi_storage[1] = { NULL };
  228. dialog imdi =
  229. {
  230. 26, 4, 53, 16, "Import:", 3, imdi_types, imdi_xs, imdi_ys,
  231. imdi_strs, imdi_p1s, imdi_p2s, imdi_storage, 0
  232. };
  233. int import_type(World *mzx_world)
  234. {
  235. int storage = 0;
  236. set_context(78);
  237. imdi_storage[0] = &storage;
  238. if(run_dialog(mzx_world, &imdi))
  239. {
  240. pop_context();
  241. return -1;
  242. }
  243. pop_context();
  244. return storage;
  245. }
  246. char imzdi_types[3] = { DE_RADIO, DE_BUTTON, DE_BUTTON };
  247. char imzdi_xs[3] = { 6, 5, 15 };
  248. char imzdi_ys[3] = { 5, 11, 11 };
  249. char *imzdi_strs[3] = { "Board\nOverlay", "OK", "Cancel" };
  250. int imzdi_p1s[3] = { 2, 0, -1 };
  251. int imzdi_p2s[1] = { 12 };
  252. int imz_type = 0;
  253. void *imzdi_storage[1] = { &imz_type };
  254. dialog imzdi =
  255. {
  256. 26, 4, 53, 17, "Import MZM as-", 3, imzdi_types, imzdi_xs,
  257. imzdi_ys, imzdi_strs, imzdi_p1s, imzdi_p2s, imzdi_storage, 0
  258. };
  259. int import_mzm_obj_type(World *mzx_world)
  260. {
  261. set_context(78);
  262. if(run_dialog(mzx_world, &imzdi))
  263. {
  264. pop_context();
  265. return -1;
  266. }
  267. pop_context();
  268. return imz_type;
  269. }