home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer 5.14 / 2000-11_-_Disc_5.14.iso / Goodies / 3DGameStudio / Mission / menu.wdl < prev    next >
Text File  |  2000-02-08  |  26KB  |  875 lines

  1. //////////////////////////////////////////////////////////
  2. // Simple WDL game menu
  3. //////////////////////////////////////////////////////////
  4. IFNDEF MENU_DEFS;
  5.  SOUND  menu_click <click.wav>;    // menu select sound
  6.  DEFINE menu_font standard_font;    // menu font
  7.  BMAP button_low,<black.pcx>,0,0,64,10;// menu item background
  8.  BMAP button_hi,<white.pcx>,0,0,64,10;    // menu selected item background
  9.  BMAP yesno_back,<black.pcx>,0,0,64,24;// yes/no panel background
  10.  BMAP yesno_low,<black.pcx>,0,0,28,10;    // yes/no button background
  11.  BMAP yesno_hi,<white.pcx>,0,0,28,10;    // yes/no selected button background
  12.  BMAP arrow,<arrow.pcx>;// mouse pointer
  13.  DEFINE YES_OFFS_X,2;    // offsets for yes/no buttons to panel
  14.  DEFINE NO_OFFS_X,34;
  15.  DEFINE YESNO_OFFS_Y,12;
  16. ENDIF;    // MENU_DEFS
  17.  
  18. IFNDEF MENU_DEFS2;
  19.  DEFINE CONSOLE_MODE_2;    // console line don't disappear after [ENTER]
  20.  DEFINE INFO_NAME,"stat";
  21.  DEFINE SAVE_NAME,"game";
  22. ENDIF;
  23. //////////////////////////////////////////////////////////
  24. // skills to be preserved on score loading & level change
  25. SKILL SOUND_VOL { TYPE GLOBAL; VAL 100; }
  26. SKILL MIDI_VOL { TYPE GLOBAL; VAL 50; }
  27. SKILL difficulty { TYPE GLOBAL; VAL 0; }
  28.  
  29. //////////////////////////////////////////////////////////
  30. SKILL menu_pos { X 10; Y 10; }    // position of menu on screen
  31. SKILL menu_dist { X 4; Y 12; }    // distance between buttons
  32. SKILL menu_offs { X 2; Y 1; }        // offset text to button below
  33. SKILL menu_max { VAL 7; }            // max items per menu
  34.  
  35. SKILL yesno_pos { X 10; Y 10; }    // position of yes/no panel
  36. SKILL yesno_offs { X 2; Y 2; }    // offset text to panel
  37.  
  38. //////////////////////////////////////////////////////////
  39. // Texts and messages appearing in the menu
  40. STRING new_game_str,"New";
  41. STRING load_game_str,"Load";
  42. STRING save_game_str,"Save";
  43. STRING quit_game_str,"Quit";
  44. STRING options_str,"Options";
  45. STRING help_str,"Help";
  46. STRING resume_str,"Back";
  47.  
  48. STRING yes_str,"Yes";
  49. STRING no_str," No";
  50.  
  51. STRING quit_yesno,"  Quit?";
  52.  
  53. STRING ok_str,"OK";
  54. STRING wait_str,"Please wait...";
  55. STRING save_error,"MALFUNCTION... can't save game";
  56. STRING load_error,"MALFUNCTION... save before loading!";
  57.  
  58. STRING helptxt_str,
  59. "ESC - Menu
  60. F1  - Help
  61. F2  - Quicksave
  62. F3  - Quickload
  63. F4  - Multiplayer message
  64. F5  - Toggle resolution
  65. F6  - Screenshot
  66. F7  - Toggle person mode
  67. F11 - Toggle gamma
  68. F12 - Toggle sound/music
  69. F10 - Exit";
  70.  
  71. //////////////////////////////////////////////////////////
  72. // a lot of default strings, actions and synonyms
  73. // which are used for the items of the menu
  74.  
  75. SKILL menu_cursor { VAL 0; } // determines which item is selected
  76.  
  77. // strings for the names of the five games to save and load
  78. STRING name1_str,"         ";
  79. STRING name2_str,"         ";
  80. STRING name3_str,"         ";
  81. STRING name4_str,"         ";
  82. STRING name5_str,"         ";
  83.  
  84. SYNONYM mystring { TYPE STRING; }
  85.  
  86. // synonyms for the actions to execute for each of the 7 menu items
  87. SYNONYM menu_do1 { TYPE ACTION; }
  88. SYNONYM menu_do2 { TYPE ACTION; }
  89. SYNONYM menu_do3 { TYPE ACTION; }
  90. SYNONYM menu_do4 { TYPE ACTION; }
  91. SYNONYM menu_do5 { TYPE ACTION; }
  92. SYNONYM menu_do6 { TYPE ACTION; }
  93. SYNONYM menu_do7 { TYPE ACTION; }
  94.  
  95. // Synonyms to save and restore any actions that were
  96. // previously assigned to menu keys
  97. SYNONYM old_menu_esc { TYPE ACTION; }
  98. SYNONYM old_help_esc { TYPE ACTION; }
  99. SYNONYM old_yesno_esc { TYPE ACTION; }
  100. SYNONYM old_menu_enter { TYPE ACTION; }
  101. SYNONYM old_yesno_enter { TYPE ACTION; }
  102. SYNONYM old_cud { TYPE ACTION; }
  103. SYNONYM old_cuu { TYPE ACTION; }
  104. SYNONYM old_cul { TYPE ACTION; }
  105. SYNONYM old_cur { TYPE ACTION; }
  106. SYNONYM old_f1 { TYPE ACTION; }
  107.  
  108. // Actions which are really performed if clicking one of the 7 menu items.
  109. // The menu has to disappear before the action is executed
  110. ACTION _b1 { CALL _menu_clear; CALL menu_do1; }
  111. ACTION _b2 { CALL _menu_clear; CALL menu_do2; }
  112. ACTION _b3 { CALL _menu_clear; CALL menu_do3; }
  113. ACTION _b4 { CALL _menu_clear; CALL menu_do4; }
  114. ACTION _b5 { CALL _menu_clear; CALL menu_do5; }
  115. ACTION _b6 { CALL _menu_clear; CALL menu_do6; }
  116. ACTION _b7 { CALL _menu_clear; CALL menu_do7; }
  117.  
  118. ACTION _buttonclick { PLAY_SOUND menu_click,40; }
  119.  
  120. // Texts on the menu item buttons
  121. TEXT menu_txt1 { LAYER 11; FONT menu_font; STRING empty_str; }
  122. TEXT menu_txt2 { LAYER 11; FONT menu_font; STRING empty_str; }
  123. TEXT menu_txt3 { LAYER 11; FONT menu_font; STRING empty_str; }
  124. TEXT menu_txt4 { LAYER 11; FONT menu_font; STRING empty_str; }
  125. TEXT menu_txt5 { LAYER 11; FONT menu_font; STRING empty_str; }
  126. TEXT menu_txt6 { LAYER 11; FONT menu_font; STRING empty_str; }
  127. TEXT menu_txt7 { LAYER 11; FONT menu_font; STRING empty_str; }
  128.  
  129. // The items of which the menu really consists.
  130. // Each item is a panel with a single button.
  131. PANEL menu_pan1 {
  132.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  133.     BUTTON 0,0,button_hi,button_low,button_hi,_b1,NULL,_buttonclick;
  134. }
  135. PANEL menu_pan2 {
  136.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  137.     BUTTON 0,0,button_hi,button_low,button_hi,_b2,NULL,_buttonclick;
  138. }
  139. PANEL menu_pan3 {
  140.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  141.     BUTTON 0,0,button_hi,button_low,button_hi,_b3,NULL,_buttonclick;
  142. }
  143. PANEL menu_pan4 {
  144.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  145.     BUTTON 0,0,button_hi,button_low,button_hi,_b4,NULL,_buttonclick;
  146. }
  147. PANEL menu_pan5 {
  148.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  149.     BUTTON 0,0,button_hi,button_low,button_hi,_b5,NULL,_buttonclick;
  150. }
  151. PANEL menu_pan6 {
  152.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  153.     BUTTON 0,0,button_hi,button_low,button_hi,_b6,NULL,_buttonclick;
  154. }
  155. PANEL menu_pan7 {
  156.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  157.     BUTTON 0,0,button_hi,button_low,button_hi,_b7,NULL,_buttonclick;
  158. }
  159.  
  160. PANEL menu_select {
  161.     LAYER 10.5; BMAP button_hi; FLAGS REFRESH,TRANSPARENT;
  162. }
  163.  
  164. /////////////////////////////////////////////////////////////////////
  165. // This action initializes the menu
  166. ACTION menu_show {
  167.     CALL _yesno_hide;    // if a yesno panel was active, hide it
  168.  
  169. // First, set all button panels to their correct positions
  170.     menu_pan1.POS_X = menu_pos.X;
  171.     menu_pan1.POS_Y = menu_pos.Y;
  172.     menu_txt1.POS_X = menu_pos.X + menu_offs.X;
  173.     menu_txt1.POS_Y = menu_pos.Y + menu_offs.Y;
  174.     menu_pan2.POS_X = menu_pan1.POS_X + menu_dist.X;
  175.     menu_pan2.POS_Y = menu_pan1.POS_Y + menu_dist.Y;
  176.     menu_txt2.POS_X = menu_txt1.POS_X + menu_dist.X;
  177.     menu_txt2.POS_Y = menu_txt1.POS_Y + menu_dist.Y;
  178.     menu_pan3.POS_X = menu_pan2.POS_X + menu_dist.X;
  179.     menu_pan3.POS_Y = menu_pan2.POS_Y + menu_dist.Y;
  180.     menu_txt3.POS_X = menu_txt2.POS_X + menu_dist.X;
  181.     menu_txt3.POS_Y = menu_txt2.POS_Y + menu_dist.Y;
  182.     menu_pan4.POS_X = menu_pan3.POS_X + menu_dist.X;
  183.     menu_pan4.POS_Y = menu_pan3.POS_Y + menu_dist.Y;
  184.     menu_txt4.POS_X = menu_txt3.POS_X + menu_dist.X;
  185.     menu_txt4.POS_Y = menu_txt3.POS_Y + menu_dist.Y;
  186.     menu_pan5.POS_X = menu_pan4.POS_X + menu_dist.X;
  187.     menu_pan5.POS_Y = menu_pan4.POS_Y + menu_dist.Y;
  188.     menu_txt5.POS_X = menu_txt4.POS_X + menu_dist.X;
  189.     menu_txt5.POS_Y = menu_txt4.POS_Y + menu_dist.Y;
  190.     menu_pan6.POS_X = menu_pan5.POS_X + menu_dist.X;
  191.     menu_pan6.POS_Y = menu_pan5.POS_Y + menu_dist.Y;
  192.     menu_txt6.POS_X = menu_txt5.POS_X + menu_dist.X;
  193.     menu_txt6.POS_Y = menu_txt5.POS_Y + menu_dist.Y;
  194.     menu_pan7.POS_X = menu_pan6.POS_X + menu_dist.X;
  195.     menu_pan7.POS_Y = menu_pan6.POS_Y + menu_dist.Y;
  196.     menu_txt7.POS_X = menu_txt6.POS_X + menu_dist.X;
  197.     menu_txt7.POS_Y = menu_txt6.POS_Y + menu_dist.Y;
  198.  
  199. // Now save the old actions of ESC, Cursor, ENTER keys into synonyms
  200. // and assign them them new actions required for the menu
  201.     SET old_menu_esc,ON_ESC;
  202.     SET ON_ESC,_menu_clear;    // now ESC clears the menu
  203.     SET old_cuu,ON_CUU;
  204.     SET on_cuu,_menu_up;        // CUU moves the selection cursor up
  205.     SET old_cud,ON_CUD;
  206.     SET on_cud,_menu_down;    // CUD moves it down
  207.     SET old_menu_enter,ON_ENTER;
  208.     SET ON_ENTER,_menu_exec;// and ENTER ececutes the selected item
  209.  
  210. // and now place the menu cursor to the first item, and make the
  211. // whole menu visible.
  212.     CALL _menu_visible;
  213.     CALL _menu_set;    // highlight first item
  214. }
  215.  
  216. // This just makes all menu items - buttons and texts above - visible on screen.
  217. ACTION _menu_visible {
  218.     IF (menu_max >= 1) {
  219.         SET menu_pan1.VISIBLE,ON;
  220.         SET menu_txt1.VISIBLE,ON;
  221.     }
  222.     IF (menu_max >= 2) {
  223.         SET menu_pan2.VISIBLE,ON;
  224.         SET menu_txt2.VISIBLE,ON;
  225.     }
  226.     IF (menu_max >= 3) {
  227.         SET menu_pan3.VISIBLE,ON;
  228.         SET menu_txt3.VISIBLE,ON;
  229.     }
  230.     IF (menu_max >= 4) {
  231.         SET menu_pan4.VISIBLE,ON;
  232.         SET menu_txt4.VISIBLE,ON;
  233.     }
  234.     IF (menu_max >= 5) {
  235.         SET menu_pan5.VISIBLE,ON;
  236.         SET menu_txt5.VISIBLE,ON;
  237.     }
  238.     IF (menu_max >= 6) {
  239.         SET menu_pan6.VISIBLE,ON;
  240.         SET menu_txt6.VISIBLE,ON;
  241.     }
  242.     IF (menu_max >= 7) {
  243.         SET menu_pan7.VISIBLE,ON;
  244.         SET menu_txt7.VISIBLE,ON;
  245.     }
  246.     FREEZE_MODE = 1;    // when the menu is on screen, the game freezes
  247.     menu_cursor = 1;    // place to first item
  248. }
  249.  
  250.  
  251. // This just lets all menu items disappear again
  252. ACTION _menu_hide {
  253.     SET menu_pan1.VISIBLE,OFF;
  254.     SET menu_txt1.VISIBLE,OFF;
  255.     SET menu_pan2.VISIBLE,OFF;
  256.     SET menu_txt2.VISIBLE,OFF;
  257.     SET menu_pan3.VISIBLE,OFF;
  258.     SET menu_txt3.VISIBLE,OFF;
  259.     SET menu_pan4.VISIBLE,OFF;
  260.     SET menu_txt4.VISIBLE,OFF;
  261.     SET menu_pan5.VISIBLE,OFF;
  262.     SET menu_txt5.VISIBLE,OFF;
  263.     SET menu_pan6.VISIBLE,OFF;
  264.     SET menu_txt6.VISIBLE,OFF;
  265.     SET menu_pan7.VISIBLE,OFF;
  266.     SET menu_txt7.VISIBLE,OFF;
  267.     SET menu_select.VISIBLE,OFF;
  268. }
  269.  
  270. // This quits the menu, restores old key actions, and continues the game
  271. ACTION _menu_clear {
  272.     if (menu_cursor > 0) {
  273.         CALL _menu_hide;
  274.         SET ON_ESC,old_menu_esc;
  275.         SET ON_CUU,old_cuu;
  276.         SET ON_CUD,old_cud;
  277.         SET ON_ENTER,old_menu_enter;
  278.         FREEZE_MODE = 0;
  279.         menu_cursor = 0;
  280.     }
  281. }
  282.  
  283. // One item up
  284. ACTION _menu_up {
  285.     menu_cursor -= 1;
  286.     BRANCH _menu_set;
  287. }
  288.  
  289. // One item down
  290. ACTION _menu_down {
  291.     menu_cursor += 1;
  292.     BRANCH _menu_set;
  293. }
  294.  
  295. // Highlights the selected menu item, onto which the menu cursor is placed
  296. ACTION _menu_set {
  297. // cursor highlight has no effect in mouse mode
  298.     IF (MOUSE_MODE >= 1) { SET menu_select.VISIBLE,OFF; RETURN; }
  299.  
  300. // restrict the menu cursor to valid values
  301.     IF (menu_cursor < 1) { menu_cursor = menu_max; }
  302.     IF (menu_cursor > menu_max) { menu_cursor = 1; }
  303.  
  304. // set the highlight panel onto the selected item, and make it visible
  305.     menu_select.POS_X = menu_pos.X + (menu_cursor-1) * menu_dist.X;
  306.     menu_select.POS_Y = menu_pos.Y + (menu_cursor-1) * menu_dist.Y;
  307.     SET menu_select.VISIBLE,ON;
  308.     CALL _buttonclick;
  309. }
  310.  
  311. // exceutes the action of the selected menu item
  312. ACTION _menu_exec {
  313. // if alt or ctrl was pressed, don't execute the menu but the old action
  314.     IF (KEY_ALT || KEY_CTRL) { BRANCH old_menu_enter; }
  315.  
  316. // now ececute the item action, dependent on the menu cursor position
  317.     PLAY_SOUND    menu_click,60;
  318.     IF (menu_cursor == 1) { BRANCH _b1; }
  319.     IF (menu_cursor == 2) { BRANCH _b2; }
  320.     IF (menu_cursor == 3) { BRANCH _b3; }
  321.     IF (menu_cursor == 4) { BRANCH _b4; }
  322.     IF (menu_cursor == 5) { BRANCH _b5; }
  323.     IF (menu_cursor == 6) { BRANCH _b6; }
  324.     IF (menu_cursor == 7) { BRANCH _b7; }
  325. }
  326.  
  327. ///////////////////////////////////////////////////////////////////////
  328. // Yes/No Panel stuff
  329. SKILL yesno_active { VAL 0; }
  330.  
  331. // For saving and restoring the old key actions
  332. SYNONYM old_y { TYPE ACTION; }
  333. SYNONYM old_z { TYPE ACTION; }
  334. SYNONYM old_n { TYPE ACTION; }
  335.  
  336. // Action to execute if YES is clicked on
  337. SYNONYM yesno_do { TYPE ACTION; }
  338. ACTION _yes_exec { CALL _yesno_clear; CALL yesno_do; }
  339.  
  340. // The yes/no panel consists of 2 buttons, not surprisingly
  341. PANEL yesno_pan {
  342.     LAYER 12; BMAP yesno_back; FLAGS TRANSPARENT,REFRESH;
  343.     BUTTON YES_OFFS_X,YESNO_OFFS_Y,yesno_hi,yesno_low,yesno_hi,
  344.         _yes_exec,NULL,_buttonclick;
  345.     BUTTON NO_OFFS_X,YESNO_OFFS_Y,yesno_hi,yesno_low,yesno_hi,
  346.         _yesno_clear,NULL,_buttonclick;
  347. }
  348.  
  349. // Texts of the panel and the two buttons
  350. TEXT yesno_txt { LAYER 13; FONT menu_font; STRING empty_str; }
  351. TEXT yes_txt { LAYER 13; FONT menu_font; STRING yes_str; }
  352. TEXT no_txt { LAYER 13; FONT menu_font; STRING no_str; }
  353.  
  354. ///////////////////////////////////////////////////////////////////////
  355. // Initialzes the yesno panel
  356. ACTION yesno_show {
  357.     CALL _menu_clear;        // in case menu was switched on before
  358.     CALL _yesno_clear;    // remove last yesno
  359.  
  360. // set the position of yesno panels and text
  361.     yesno_pan.POS_X = yesno_pos.X;
  362.     yesno_pan.POS_Y = yesno_pos.Y;
  363.     yesno_txt.POS_X = yesno_pan.POS_X + yesno_offs.X;
  364.     yesno_txt.POS_Y = yesno_pan.POS_Y + yesno_offs.Y;
  365.     yes_txt.POS_X = yesno_txt.POS_X + YES_OFFS_X;
  366.     yes_txt.POS_Y = yesno_txt.POS_Y + YESNO_OFFS_Y;
  367.     no_txt.POS_X = yesno_txt.POS_X + NO_OFFS_X;
  368.     no_txt.POS_Y = yes_txt.POS_Y;
  369.  
  370. // let everything appear on screen
  371.     SET yesno_pan.VISIBLE,ON;
  372.     SET yesno_txt.VISIBLE,ON;
  373.     SET yes_txt.VISIBLE,ON;
  374.     SET no_txt.VISIBLE,ON;
  375.  
  376. // Save the old key actions, and set the reqired panel actions
  377.     SET old_yesno_esc,ON_ESC;
  378.     SET ON_ESC,_yesno_clear;
  379.     SET old_n,ON_N;
  380.     SET ON_N,_yesno_clear;
  381.     SET old_yesno_enter,ON_ENTER;
  382.     SET ON_ENTER,_yes_exec;
  383.     SET old_y,ON_Y;
  384.     SET ON_Y,_yes_exec;
  385.     SET old_z,ON_Z;        // for German keyboard...
  386.     SET ON_Z,_yes_exec;
  387.  
  388.     yesno_active = 1;
  389.     FREEZE_MODE = 1;        // freeze game
  390. }
  391.  
  392. // let the yesno panel disappear
  393. ACTION _yesno_hide {
  394.     SET yesno_pan.VISIBLE,OFF;
  395.     SET yesno_txt.VISIBLE,OFF;
  396.     SET yes_txt.VISIBLE,OFF;
  397.     SET no_txt.VISIBLE,OFF;
  398. }
  399.  
  400. // exit the yesno panel
  401. ACTION _yesno_clear {
  402.     if (yesno_active) {
  403.         CALL _yesno_hide;
  404.         FREEZE_MODE = 0;        // unfreeze game
  405. // restore old key actions
  406.         SET ON_ESC,old_yesno_esc;
  407.         SET ON_N,old_n;
  408.         SET ON_ENTER,old_yesno_enter;
  409.         SET ON_Y,old_y;
  410.         SET ON_Z,old_z;
  411.         yesno_active = 0;
  412.     }
  413. }
  414.  
  415. ///////////////////////////////////////////////////////////////////////
  416. // menu actions for a standard game
  417.  
  418. ACTION menu_main {
  419.     SET menu_txt1.STRING,new_game_str;
  420.     SET menu_txt2.STRING,load_game_str;
  421.     SET menu_txt3.STRING,save_game_str;
  422.     SET menu_txt4.STRING,quit_game_str;
  423.     SET menu_txt5.STRING,options_str;
  424.     SET menu_txt6.STRING,help_str;
  425.     SET menu_txt7.STRING,resume_str;
  426.  
  427.     SET menu_do1,game_init;    // normally an action which resets all
  428.     SET menu_do2,_menu_load;
  429.     SET menu_do3,_menu_save;
  430.     SET menu_do4,exit_yesno;
  431.     SET menu_do5,game_options;
  432.     SET menu_do6,game_help;
  433.     SET menu_do7,_menu_clear;
  434.  
  435.     menu_max = 7;
  436.     CALL menu_show;
  437. }
  438.  
  439. ACTION game_init {    // default action, to be replaced by a game-adapted action
  440.     CALL key_init;
  441.     CALL weapon_init;
  442.     CALL main;
  443. }
  444.  
  445. ACTION weapon_init { RETURN; }    // dummy action, if weapons.wdl is not included
  446.  
  447. SKILL _entry { TYPE GLOBAL; VAL 0; }
  448. ACTION game_entry {    // mark the score to re-enter the game (yet to do)
  449.     IF (_entry == 0) {
  450.         _entry = 1;
  451.     }
  452. }
  453.  
  454. ///////////////////////////////////////////////////////////////////////
  455. ACTION exit_yesno {
  456.     SET    yesno_txt.STRING,quit_yesno;
  457.     SET    yesno_do,game_exit;
  458.     CALL    yesno_show;
  459. }
  460.  
  461. ACTION game_exit {
  462.     CALL    save_status;            // save global skills & strings
  463.     EXIT    "3D GameStudio (c) conitec 1999\n";
  464. }
  465.  
  466. ///////////////////////////////////////////////////////////////////////
  467. // save/load stuff
  468. SKILL slot    { VAL 0; }    // number of last score
  469.  
  470. ACTION _menu_save {
  471.     SET menu_txt1.STRING,name1_str;
  472.     SET menu_txt2.STRING,name2_str;
  473.     SET menu_txt3.STRING,name3_str;
  474.     SET menu_txt4.STRING,name4_str;
  475.     SET menu_txt5.STRING,name5_str;
  476.     SET menu_txt6.STRING,resume_str;
  477.  
  478.     SET menu_do1,_menu_save1;
  479.     SET menu_do2,_menu_save2;
  480.     SET menu_do3,_menu_save3;
  481.     SET menu_do4,_menu_save4;
  482.     SET menu_do5,_menu_save5;
  483.     SET menu_do6,_menu_clear;
  484.  
  485.     menu_max = 6;
  486.     CALL menu_show;
  487. }
  488.  
  489. ACTION _menu_save1 { slot = 1; SET mystring,name1_str; BRANCH _game_save; }
  490. ACTION _menu_save2 { slot = 2; SET mystring,name2_str; BRANCH _game_save; }
  491. ACTION _menu_save3 { slot = 3; SET mystring,name3_str; BRANCH _game_save; }
  492. ACTION _menu_save4 { slot = 4; SET mystring,name4_str; BRANCH _game_save; }
  493. ACTION _menu_save5 { slot = 5; SET mystring,name5_str; BRANCH _game_save; }
  494.  
  495. ACTION _game_save
  496. {
  497.     CALL _menu_visible;    // was hidden before
  498.     INKEY    mystring;
  499.     IF (RESULT != 13) { BRANCH _menu_clear; }
  500.     CALL    _menu_clear;
  501.     CALL    save_status;            // save global skills & strings
  502.     SET ON_LOAD,load_status;    // to automatically reload them
  503.  
  504. //    SET msg.STRING,wait_str;
  505. //    CALL    show_message;
  506.  
  507.     SAVE SAVE_NAME,slot;    // save game
  508.     IF (RESULT < 0) {        // Error?
  509.         SET msg.STRING,save_error;
  510.     } ELSE {
  511.         SET msg.STRING,ok_str;
  512.     }
  513.     CALL    show_message;
  514. }
  515.  
  516.  
  517. // after re-loading a game, reload all global parameters
  518. ACTION save_status {
  519.     SAVE_INFO INFO_NAME,0;
  520. }
  521. ACTION load_status {
  522.     WAIT 2;    // don't override previous LOAD etc.
  523.     LOAD_INFO INFO_NAME,0;
  524. }
  525.  
  526. ///////////////////////////////////////////////////////////////////////
  527. ACTION _menu_load {
  528.     SET menu_txt1.STRING,name1_str;
  529.     SET menu_txt2.STRING,name2_str;
  530.     SET menu_txt3.STRING,name3_str;
  531.     SET menu_txt4.STRING,name4_str;
  532.     SET menu_txt5.STRING,name5_str;
  533.     SET menu_txt6.STRING,resume_str;
  534.  
  535.     SET menu_do1,_menu_load1;
  536.     SET menu_do2,_menu_load2;
  537.     SET menu_do3,_menu_load3;
  538.     SET menu_do4,_menu_load4;
  539.     SET menu_do5,_menu_load5;
  540.     SET menu_do6,_menu_clear;
  541.  
  542.     menu_max = 6;
  543.     CALL menu_show;
  544. }
  545.  
  546. ACTION _menu_load1 { slot = 1; BRANCH _game_load; }
  547. ACTION _menu_load2 { slot = 2; BRANCH _game_load; }
  548. ACTION _menu_load3 { slot = 3; BRANCH _game_load; }
  549. ACTION _menu_load4 { slot = 4; BRANCH _game_load; }
  550. ACTION _menu_load5 { slot = 5; BRANCH _game_load; }
  551.  
  552. ACTION _game_load {
  553.     SET    msg.STRING,wait_str;
  554.     CALL    show_message;
  555.     WAIT    1;                // to display wait message before loading
  556.     LOAD    SAVE_NAME,slot;
  557.     SET    msg.STRING,load_error;    // failed!
  558.     CALL    show_message;
  559. }
  560.  
  561. ///////////////////////////////////////////////////////////////////////
  562. ACTION game_help {
  563.     FREEZE_MODE = 1;
  564.     SET msg.STRING,helptxt_str;
  565.     SET msg.VISIBLE,ON;
  566.     SET old_help_esc,ON_ESC;
  567.     SET ON_ESC,help_hide;
  568.     SET old_f1,ON_F1;
  569.     SET ON_F1,help_hide;
  570. }
  571.  
  572. ACTION help_hide {
  573.     FREEZE_MODE = 0;
  574.     SET msg.VISIBLE,OFF;
  575.     SET ON_ESC,old_help_esc;
  576.     SET ON_F1,old_f1;
  577. }
  578.  
  579. ///////////////////////////////////////////////////////////////////////
  580. // Options sliders stuff
  581. DEFINE SLIDER_LEN,70;
  582.  
  583. BMAP slider_map,<white.pcx>,0,0,10,10;
  584. BMAP slider_bar,<black.pcx>,0,0,SLIDER_LEN,2;
  585.  
  586. SKILL bar_val1 { VAL SLIDER_LEN; }
  587. SKILL bar_val2 { VAL SLIDER_LEN; }
  588. SKILL bar_val3 { VAL SLIDER_LEN; }
  589. SKILL slider_soundvol { X 80; Y 0; Z 100; }
  590. SKILL slider_musicvol { X 50; Y 0; Z 100; }
  591. SKILL slider_resolution { X 3; Y 1; Z 8; }
  592.  
  593. PANEL option_pan {
  594.     LAYER 10;    FLAGS REFRESH;
  595.     HBAR 4,8,SLIDER_LEN,slider_bar,1,bar_val1;    // just to draw a black line
  596.     HSLIDER 4,4,SLIDER_LEN,slider_map,slider_soundvol;
  597.  
  598.     HBAR 4,28,SLIDER_LEN,slider_bar,1,bar_val2;
  599.     HSLIDER 4,24,SLIDER_LEN,slider_map,slider_musicvol;
  600.  
  601.     HBAR 4,48,SLIDER_LEN,slider_bar,1,bar_val3;
  602.     HSLIDER 4,44,SLIDER_LEN,slider_map,slider_resolution;
  603. }
  604.  
  605. STRING optionsound_str,"-  volume  +";
  606. STRING optionmusic_str,"-  music   +";
  607. STRING optionres_str,  "-  video   +";
  608.  
  609. // Yet to do: modularize a slider panel
  610. ACTION game_options {
  611.     EXCLUSIVE_GLOBAL;
  612.     FREEZE_MODE = 1;
  613.     option_pan.POS_X = menu_pos.X;
  614.     option_pan.POS_Y = menu_pos.Y;
  615.     menu_txt1.POS_X = menu_pos.X + 2;
  616.     menu_txt1.POS_Y = menu_pos.Y + 15;
  617.     menu_txt2.POS_X = menu_txt1.POS_X;
  618.     menu_txt2.POS_Y = menu_txt1.POS_Y + 20;
  619.     menu_txt3.POS_X = menu_txt2.POS_X;
  620.     menu_txt3.POS_Y = menu_txt2.POS_Y + 20;
  621.     SET option_pan.VISIBLE,ON;
  622.     SET menu_txt1.VISIBLE,ON;
  623.     SET menu_txt2.VISIBLE,ON;
  624.     SET menu_txt3.VISIBLE,ON;
  625.     SET menu_txt1.STRING,optionsound_str;
  626.     SET menu_txt2.STRING,optionmusic_str;
  627.     SET menu_txt3.STRING,optionres_str;
  628.     SET old_menu_esc,ON_ESC;
  629.     SET ON_ESC,options_hide;
  630.     SET old_cuu,ON_CUU;
  631.     SET ON_CUU,_slider_up;
  632.     SET old_cud,ON_CUD;
  633.     SET ON_CUD,_slider_down;
  634.     SET old_cul,ON_CUL;
  635.     SET ON_CUL,_slider_left;
  636.     SET old_cur,ON_CUR;
  637.     SET ON_CUR,_slider_right;
  638.  
  639.     menu_cursor = 1;
  640.     slider_soundvol = SOUND_VOL;
  641.     slider_musicvol = MIDI_VOL;
  642.     slider_resolution = VIDEO_MODE;
  643.  
  644.     WHILE (option_pan.VISIBLE == ON) {
  645.         IF (MOUSE_MODE == 0) {
  646.             IF (menu_cursor == 1) {
  647.                 IF (bar_val1 == 0) {
  648.                     bar_val1 = SLIDER_LEN;
  649.                 } ELSE {
  650.                     bar_val1 = 0;
  651.                 }
  652.                 bar_val2 = SLIDER_LEN;
  653.                 bar_val3 = SLIDER_LEN;
  654.             }
  655.             IF (menu_cursor == 2) {
  656.                 IF (bar_val2 == 0) {
  657.                     bar_val2 = SLIDER_LEN;
  658.                 } ELSE {
  659.                     bar_val2 = 0;
  660.                 }
  661.                 bar_val1 = SLIDER_LEN;
  662.                 bar_val3 = SLIDER_LEN;
  663.             }
  664.             IF (menu_cursor == 3) {
  665.                 IF (bar_val3 == 0) {
  666.                     bar_val3 = SLIDER_LEN;
  667.                 } ELSE {
  668.                     bar_val3 = 0;
  669.                 }
  670.                 bar_val2 = SLIDER_LEN;
  671.                 bar_val1 = SLIDER_LEN;
  672.             }
  673.         } ELSE {
  674.              bar_val1 = SLIDER_LEN;
  675.              bar_val2 = SLIDER_LEN;
  676.              bar_val3 = SLIDER_LEN;
  677.         }
  678.         SOUND_VOL = slider_soundvol;
  679.         MIDI_VOL = slider_musicvol;
  680.         WAIT 1;
  681.     }
  682. }
  683.  
  684. // move the cursor one slider up
  685. ACTION _slider_up {
  686.     IF (MOUSE_MODE != 0) { RETURN; }
  687.     CALL _buttonclick;
  688.     menu_cursor -= 1;
  689.     IF (menu_cursor < 1) { menu_cursor = 3; }
  690. }
  691.  
  692. // move the cursor one slider down
  693. ACTION _slider_down {
  694.     IF (MOUSE_MODE != 0) { RETURN; }
  695.     CALL _buttonclick;
  696.     menu_cursor += 1;
  697.     IF (menu_cursor > 3) { menu_cursor = 1; }
  698. }
  699.  
  700. // move selected slider to right
  701. ACTION _slider_right {
  702.     IF (MOUSE_MODE != 0) { RETURN; }
  703.     CALL _buttonclick;
  704.     IF (menu_cursor == 1) {
  705.         slider_soundvol += 10;
  706.         IF (slider_soundvol > slider_soundvol.Z) { slider_soundvol = slider_soundvol.Z; }
  707.     }
  708.     IF (menu_cursor == 2) {
  709.         slider_musicvol += 10;
  710.         IF (slider_musicvol > slider_musicvol.Z) { slider_musicvol = slider_musicvol.Z; }
  711.     }
  712.     IF (menu_cursor == 3) {
  713.         slider_resolution += 1;
  714.         IF (slider_resolution > slider_resolution.Z) { slider_resolution = slider_resolution.Z; }
  715.     }
  716. }
  717.  
  718. // move selected slider to left
  719. ACTION _slider_left {
  720.     IF (MOUSE_MODE != 0) { RETURN; }
  721.     CALL _buttonclick;
  722.     IF (menu_cursor == 1) {
  723.         slider_soundvol -= 10;
  724.         IF (slider_soundvol < slider_soundvol.Y) { slider_soundvol = slider_soundvol.Y; }
  725.     }
  726.     IF (menu_cursor == 2) {
  727.         slider_musicvol -= 10;
  728.         IF (slider_musicvol < slider_musicvol.Y) { slider_musicvol = slider_musicvol.Y; }
  729.     }
  730.     IF (menu_cursor == 3) {
  731.         slider_resolution -= 1;
  732.         IF (slider_resolution < slider_resolution.Y) { slider_resolution = slider_resolution.Y; }
  733.     }
  734. }
  735.  
  736. ACTION options_hide {
  737.     IF (slider_resolution != VIDEO_MODE) {
  738.         SWITCH_VIDEO slider_resolution,0,0;
  739.         slider_resolution = VIDEO_MODE;
  740.         CALL _show_resolution;
  741.     }
  742.     FREEZE_MODE = 0;
  743.     SET option_pan.VISIBLE,OFF;
  744.     SET menu_txt1.VISIBLE,OFF;
  745.     SET menu_txt2.VISIBLE,OFF;
  746.     SET menu_txt3.VISIBLE,OFF;
  747.     SET ON_ESC,old_menu_esc;
  748.     SET ON_CUU,old_cuu;
  749.     SET ON_CUD,old_cud;
  750.     SET ON_CUL,old_cul;
  751.     SET ON_CUR,old_cur;
  752. }
  753.  
  754.  
  755. ///////////////////////////////////////////////////////////////////////////////////
  756. ACTION mouse_toggle {         // switches the mouse on and off
  757.     MOUSE_MODE += 2;
  758.     IF (MOUSE_MODE > 2) {    // was it already on?
  759.         MOUSE_MODE = 0;        // mouse off
  760.     } ELSE {
  761.         BRANCH mouse_on;
  762.     }
  763. }
  764.  
  765. ACTION mouse_on {         // switches the mouse on
  766.     SET menu_select.VISIBLE,OFF;    // menu now handled by mouse
  767.     SET MOUSE_MAP,arrow;
  768.     WHILE (MOUSE_MODE > 0) {
  769. IFDEF ACKNEX_VERSION414;    // This version suports the true mouse cursor
  770.         MOUSE_POS.X = POINTER.X;
  771.         MOUSE_POS.Y = POINTER.Y;
  772. IFELSE;
  773.         MOUSE_POS.X += MICKEY.X;
  774.         MOUSE_POS.Y += MICKEY.Y;
  775. ENDIF;
  776.         WAIT    1;               // now move it over the screen
  777.     }
  778. }
  779.  
  780. ACTION mouse_off {         // switches the mouse off
  781.     MOUSE_MODE = 0;
  782. }
  783.  
  784. //SKILL MOUSE_SPOT { X 5; Y 5; }
  785.  
  786. ////////////////////////////////////////////////////////////////////////////
  787. // For debugging purposes, use the EXECUTE instruction
  788. // to type in WDL instructions during gameplay, like at a console.
  789. // You can examine skill values through "TO_STRING look,skill;"
  790.  
  791. STRING exec_buffer    // just an 80-char string
  792. "                                                                              ";
  793. STRING look "         "; // to see skills via TO_STRING;
  794.  
  795. TEXT console_txt {
  796.     POS_X 4;
  797.     LAYER    10;
  798.     FONT     standard_font;
  799.     STRINGS 3;
  800. IFDEF CONSOLE_MODE_2;
  801.     STRING "Enter instructions below, abort with [ESC]:";
  802. IFELSE;
  803.     STRING "Enter instructions below:";
  804. ENDIF;
  805.     STRING exec_buffer;
  806.     STRING look;
  807. }
  808.  
  809. ACTION console
  810. {
  811.     IF (console_txt.VISIBLE == ON) { RETURN; }    //already running
  812.     console_txt.POS_Y = SCREEN_SIZE.Y - 60;
  813.     SET console_txt.VISIBLE,ON;
  814.     WHILE (console_txt.VISIBLE == ON)
  815.     {
  816.         INKEY    exec_buffer;
  817.         IF (RESULT == 13) {
  818.             EXECUTE exec_buffer;
  819. IFDEF CONSOLE_MODE_2;
  820.         } ELSE {
  821.             SET console_txt.VISIBLE,OFF;
  822.         }
  823. IFELSE;
  824.         }
  825.         SET console_txt.VISIBLE,OFF;
  826. ENDIF;
  827.     }
  828. }
  829.  
  830. // Implementing a scrolling console, instead of a 1-line one,
  831. // is left as an exercise to the reader...
  832.  
  833. //////////////////////////////////////////////////////////////
  834. // screen resolution display
  835. //////////////////////////////////////////////////////////////////////
  836. STRING resolution_str,"                              ";
  837. STRING screen_str,"Video ";
  838. STRING x_str,"x";
  839.  
  840. ACTION _show_resolution {
  841. // compose the resolution string from strings and numbers
  842.     SET_STRING resolution_str,screen_str;
  843. // now it reads "Video "
  844.     TO_STRING  temp_str,SCREEN_SIZE.X;
  845.     ADD_STRING resolution_str,temp_str;
  846. // now it reads "Video hhhh" (hhhh is the hor resolution)
  847.     ADD_STRING resolution_str,x_str;
  848. // now it reads "Video hhhhx"
  849.     TO_STRING  temp_str,SCREEN_SIZE.Y;
  850.     ADD_STRING resolution_str,temp_str;
  851. // now it reads "Video hhhhxvvvv"
  852.     ADD_STRING resolution_str,x_str;
  853. // now it reads "Video hhhhxvvvvx"
  854.     TO_STRING  temp_str,VIDEO_DEPTH;
  855.     ADD_STRING resolution_str,temp_str;
  856. // and now it reads "Video hhhhxvvvvxdd"
  857.     SET    msg.STRING,resolution_str;
  858.     BRANCH    show_message;
  859. }
  860.  
  861. ACTION game_resolution {
  862.     CALL _toggle_video;
  863.     CALL _show_resolution;
  864. }
  865.  
  866. //////////////////////////////////////////////////////////////////////
  867. // Default key assignements to control the game
  868. ON_ESC menu_main;
  869. ON_F1     game_help;
  870. ON_F5     game_resolution;
  871. ON_F10 exit_yesno;
  872. ON_TAB console;
  873.  
  874. ON_MOUSE_RIGHT    mouse_toggle;
  875.