Advertisement
ZoriaRPG

ZScript SavePoints for JudasRising

Dec 25th, 2016
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 32.82 KB | None | 0 0
  1. //Save Points for JudasRising by ZoriaRPG
  2. //25th December, 2016
  3.  
  4. ///////////
  5. /// FFC ///
  6. ///////////
  7.  
  8.  
  9. //! The physical save station.
  10. //! D0 : Each station needs a unique ID, ranging from 1 to 20.
  11. //! D1 : The reill type to allow at this save point, where 0 == none, 1 == health only,
  12. //!         2 == ,agic only, and 3 == both health and magic.
  13. //! D2 : Set to '1' to allow warping from this station to another. Otherwise, set to 0.
  14. //! The script is set up to allow up to a total of twenty save stations using the menus.
  15. ffc script MetroidSaveStation{
  16.     void run(int station_number, int refill, int allow_warp){
  17.         bool pressed;
  18.         int choice;
  19.        
  20.        
  21.         while ( true ) {
  22.             //If this station is active...
  23.                 //Draw station ID.
  24.                 if ( WarpPointActive(station_number) && station_number ) {
  25.                     //Draw the station ID, firstthe background
  26.                     Screen->DrawInteger(    MET_SAVE_STATION_DRAW_ID_FONT_LAYER,
  27.                                 this->X + MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_X_OFFSET,
  28.                                 this->Y + MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_Y_OFFSET,
  29.                                 MET_SAVE_STATION_DRAW_ID_FONT,
  30.                                 MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_COLOUR, 0,
  31.                                 MET_SAVE_STATION_DRAW_ID_FONT_WIDTH,
  32.                                 MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT,
  33.                                 station_number, 0, OP_OPAQUE);
  34.                     //Then, the foreground...
  35.                     Screen->DrawInteger(    MET_SAVE_STATION_DRAW_ID_FONT_LAYER,
  36.                                 this->X + MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_X_OFFSET,
  37.                                 this->Y + MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_Y_OFFSET,
  38.                                 MET_SAVE_STATION_DRAW_ID_FONT,
  39.                                 MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_COLOUR, 0,
  40.                                 MET_SAVE_STATION_DRAW_ID_FONT_WIDTH,
  41.                                 MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT,
  42.                                 station_number, 0, OP_OPAQUE);
  43.                 }
  44.                    
  45.                
  46.  
  47.                    
  48.                 //|| ( !Tango_MenuIsActive() && SamusCanTeleport() )
  49.             while ( ( !pressed && !Tango_MenuIsActive() ) ) {
  50.                 if ( DistX(this, SAVEPOINTS_DIST_X) && DistY(this, SAVEPOINTS_DIST_Y) && LinkFacing(this) ) {
  51.                     if  ( MET_SAVE_USE_BUTTON_R && Link->PressR ) { pressed = true; Link->PressR = false; Link->InputR = false; }
  52.                     if  ( MET_SAVE_USE_BUTTON_L && Link->PressL ) { pressed = true; Link->PressL = false; Link->InputL = false; }
  53.                     if  ( MET_SAVE_USE_BUTTON_A && Link->PressA ) { pressed = true; Link->PressA = false; Link->InputA = false; }
  54.                     if  ( MET_SAVE_USE_BUTTON_B && Link->PressB ) { pressed = true; Link->PressB = false; Link->InputB = false; }
  55.                     if  ( MET_SAVE_USE_BUTTON_EX1 && Link->PressEx1 ) { pressed = true; Link->PressEx1 = false; Link->InputEx1 = false; }
  56.                     if  ( MET_SAVE_USE_BUTTON_EX2 && Link->PressEx2 ) { pressed = true; Link->PressEx2 = false; Link->InputEx2 = false; }
  57.                     if  ( MET_SAVE_USE_BUTTON_EX3 && Link->PressEx3 ) { pressed = true; Link->PressEx3 = false; Link->InputEx3 = false; }
  58.                     if  ( MET_SAVE_USE_BUTTON_EX4 && Link->PressEx4 ) { pressed = true; Link->PressEx4 = false; Link->InputEx4 = false; }
  59.                     if  ( MET_SAVE_USE_BUTTON_START && Link->PressStart ) { pressed = true; Link->PressStart = false; Link->InputStart = false; }
  60.                     if  ( MET_SAVE_USE_BUTTON_MAP && Link->PressMap ) { pressed = true; Link->PressMap = false; Link->InputMap = false; }
  61.                
  62.                 }
  63.                 //If this station is active...
  64.                 //Draw station ID.
  65.                 if ( WarpPointActive(station_number) && station_number  ) {
  66.                     //Draw the station ID, firstthe background
  67.                     Screen->DrawInteger(    MET_SAVE_STATION_DRAW_ID_FONT_LAYER,
  68.                                 this->X + MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_X_OFFSET,
  69.                                 this->Y + MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_Y_OFFSET,
  70.                                 MET_SAVE_STATION_DRAW_ID_FONT,
  71.                                 MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_COLOUR, 0,
  72.                                 MET_SAVE_STATION_DRAW_ID_FONT_WIDTH,
  73.                                 MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT,
  74.                                 station_number, 0, OP_OPAQUE);
  75.                     //Then, the foreground...
  76.                     Screen->DrawInteger(    MET_SAVE_STATION_DRAW_ID_FONT_LAYER,
  77.                                 this->X + MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_X_OFFSET,
  78.                                 this->Y + MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_Y_OFFSET,
  79.                                 MET_SAVE_STATION_DRAW_ID_FONT,
  80.                                 MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_COLOUR, 0,
  81.                                 MET_SAVE_STATION_DRAW_ID_FONT_WIDTH,
  82.                                 MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT,
  83.                                 station_number, 0, OP_OPAQUE);
  84.                 }
  85.                
  86.                 Waitframe();
  87.             }
  88.                
  89.             if ( pressed ) {
  90.                 pressed = false;
  91.                 //Set coordinates for this station:
  92.                
  93.                 if ( station_number ) SetWarpPoint(station_number,this);
  94.                
  95.                 //Activate this station if it is inactive
  96.                 if ( !WarpPointActive(station_number) && station_number )  WarpPointActive(station_number,true);
  97.                    
  98.                 //MetroidSaveStationMenu(int station_number);
  99.                
  100.                 //Do menu
  101.                 if ( !station_number && !refill ) choice = MetroidSaveStationMenu(station_number,3,allow_warp);
  102.                 else choice = MetroidSaveStationMenu(station_number,refill,allow_warp);
  103.                 if ( choice < 0 && choice > -9999) WarpSamus( (choice * -1), MET_WARP_EFFECT_DURATION );
  104.                 //Do save, activate, or warp when menu returns
  105.                     //!No, handled by the manu.
  106.                
  107.             }
  108.             Waitframe(); //Main while loop.
  109.         }
  110.     }
  111. }
  112.  
  113.  
  114. //Array
  115. int SavePoints[214747];
  116.  
  117. //!Indices 0-5 are not used to store coordinates
  118.  
  119. const int MET_SAVE_LAST_SAVESTATION = 0; //ID of last    save station used. arr[0]
  120. const int ISWARPING = 1; //arr[1] :     Used by accessors
  121. const int FLASHINGGREEN = 2; //arr[2] : ...
  122. const int TELEPORTING = 3; //arr[3] :   ...
  123. const int ARRIVING = 4; //arr[4] :  ...
  124.  
  125. //Because we number stations starting at '1', array indices arr[5] through arr[10] are unused.
  126.  
  127. const int MET_SAVE_BASE = 5; // First index of save point values.
  128.                 //!     In reality, it is this, plus six, because we start Warp Station IDs at '1'.
  129. const int MET_SAVE_INDICES = 6; //Math. Indices used per set o hold warp station datum.
  130.  
  131. const int MET_SAVE_ID = 0; //Holds the ID of the point in game.
  132. const int MET_SAVE_DMAP = 1; //The DMAP for a given warp.
  133. const int MET_SAVE_SCREEN = 2; //The screen of a given warp.
  134. const int MET_SAVE_X = 3; //The X position to warp to.
  135. const int MET_SAVE_Y = 4; //The Y position to warp to.
  136. const int MET_SAVE_STATION_ACTIVE = 5; //The Y position to warp to.
  137.  
  138.  
  139. ////////////////
  140. /// Settings ///
  141. ////////////////
  142.  
  143. //Enable some save point menu settings globally.
  144. //Enable these to override all save point settings.
  145. const int SAVEPOINTS_ALLOW_WARPING = 0;
  146. const int SAVEPOINTS_ALLOW_REFILL = 0;
  147. const int SAVEPOINTS_REFILL_MAGIC = 0;
  148. const int SAVEPOINTS_REFILL_HP = 0;
  149.  
  150. const int SAVEPOINTS_DIST_X = 20;
  151. const int SAVEPOINTS_DIST_Y = 20;
  152.  
  153. const int HP_REFILL_RATE = 30;
  154. const int SFX_ETANK_REFILL = 60;
  155.  
  156. const int INITIAL_SCREEN = 0x19;
  157. const int INITIAL_DMAP = 02;
  158. const int INITIAL_X = 120;
  159. const int INITIAL_Y = 112;
  160.  
  161.  
  162. const int DEBUG_MENUS = 1; //Set to 1 to enable debugging. 0 to disable.
  163.  
  164. const int SFX_ERROR = 0; //Set to generic error sound.
  165.  
  166. const int MET_SAVE_NUMBER_OF_SAVEPOINTS = 20; //Set to the number of save points in the entire quest.
  167.  
  168. //Activation Buttons
  169. const int MET_SAVE_USE_BUTTON_A = 0; //Set any of these to '1' to allow trigering the save point with that button.
  170. const int MET_SAVE_USE_BUTTON_B = 0;
  171. const int MET_SAVE_USE_BUTTON_L = 0;
  172. const int MET_SAVE_USE_BUTTON_R = 0;
  173. const int MET_SAVE_USE_BUTTON_EX1 = 0;
  174. const int MET_SAVE_USE_BUTTON_EX2 = 1;
  175. const int MET_SAVE_USE_BUTTON_EX3 = 0;
  176. const int MET_SAVE_USE_BUTTON_EX4 = 1;
  177. const int MET_SAVE_USE_BUTTON_START = 1;
  178. const int MET_SAVE_USE_BUTTON_MAP = 0;
  179.  
  180. //Settings
  181. const int MET_WARP_EFFECT_DURATION = 60;  //Duration of warp special visuals.
  182.  
  183. const int MET_SAVE_STATION_REG = 9; //Screen->D[reg]
  184. const int MET_SAVE_STATION_DRAW_ID_FONT = 0;
  185. const int MET_SAVE_STATION_DRAW_ID_FONT_LAYER = 2;
  186. const int MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_COLOUR = 0x0F; //Black
  187. const int MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_COLOUR = 0x01; //White
  188. const int MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_Y_SCALE = -1;  //DrawString(0 scale factor
  189. const int MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_X_OFFSET = 8;  //Offset from f->X
  190. const int MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_X_OFFSET = 9;  //Offset from f->X
  191. const int MET_SAVE_STATION_DRAW_ID_FONT_BACKGROUND_Y_OFFSET = 8;  //Offset from f->Y
  192. const int MET_SAVE_STATION_DRAW_ID_FONT_FOREGROUND_Y_OFFSET = 9;  //Offset from f->Y
  193. const int MET_SAVE_STATION_ = 0; //Default constant template for this beast.
  194. const int MET_SAVE_STATION_DRAW_ID_FONT_WIDTH = 16;
  195. const int MET_SAVE_STATION_DRAW_ID_FONT_HEIGHT = 16;
  196.  
  197. const int SFX_SAVE_ERROR = 80; //
  198. const int SFX_SAVE_SUCCESS = 7; //
  199. const int SFX_TELEPORT_TRANSITION = 37; //Sound effect of teleportation EFFECT.
  200. //const int SFX_WARP_ERROR = 80;
  201. const int SFX_TELEPORT = 67; //Sound effect for teleportation matrix item.
  202.  
  203. //const int WARP_WAVE = 30;
  204.  
  205. const int TELEPORT_CIRCLE_COLOUR = 181; //Colour for teleport circle.
  206. const int TELEPORT_WAVE = 60; //Duration of Teleport Wave Effect
  207.  
  208. //! We'll remove this in a future edit.
  209. const int SFX_SET_TELEPORT = 21; //Menu Sound for Setting Teleport Destination
  210.  
  211.  
  212. //const int FLASH_LAYER = 6;
  213. //const int TELEPORT_OVERLAY = 5;
  214. //const int TELEPORT_SAFETY = 10;
  215.  
  216. //const int WARP_DURATION = 80;
  217.  
  218. //Drawing Colours - ! Set to colours in your palette, or adjust as you see fit.
  219. const int WARP_GREEN = 45;
  220. const int WARP_BLUE = 11;
  221. const int WARP_YELLOW = 126;
  222. const int WARP_TEAL = 88;
  223. const int WARP_LTBLUE = 93; //or 88
  224. const int WARP_LTGREEN = 44;
  225. const int WARP_BRIGHTGREEN = 47;
  226. const int WARP_PERIDOT = 97;
  227. const int WARP_SMOKE = 73;
  228.  
  229.  
  230. //if you lack an init script, use this one.
  231. //Otherwise, if your init scrit doesn't call anying from this, add these function calls to it, then remove
  232. //this one.
  233.  
  234. //global script Init{
  235. //  void run(){
  236. //      //IsDead(false);
  237. //      SetDefaultWarpPoint();
  238. //      //Initialize counters.
  239. //      SetCommonStyleData(WINDOW_STYLE_1);
  240. //      SetCommonStyleData(WINDOW_STYLE_2);
  241. //      SetCommonStyleData(WINDOW_STYLE_3);
  242. //  }
  243. //}
  244.  
  245.  
  246. //You shouldn't need this for anything, but it's a base lobal script for tango + ghost.
  247. global script MetroidActive{
  248.     void run(){
  249.        
  250.         //IsDead(false);
  251.        
  252.         Tango_Start();
  253.         StartGhostZH();
  254.         //Used by function in grapple.
  255.        
  256.         //ResumeGame(); //Go to last saved position.
  257.         while ( true ) {
  258.            
  259.            
  260.            
  261.            
  262.             UpdateGhostZH1();
  263.            
  264.             Tango_Update1();
  265.             Waitdraw();
  266.            
  267.            
  268.             Tango_Update2();
  269.            
  270.             UpdateGhostZH2();
  271.            
  272.             Waitframe();
  273.  
  274.         }
  275.     }
  276. }
  277.  
  278.  
  279.  
  280. void SetDefaultWarpPoint(){
  281.     SavePoints[MET_SAVE_BASE + MET_SAVE_ID + ( 128 * MET_SAVE_INDICES ) ] = 128;
  282.     SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( 128 * MET_SAVE_INDICES ) ] = INITIAL_SCREEN;
  283.     SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( 128 * MET_SAVE_INDICES ) ] = INITIAL_DMAP;
  284.     SavePoints[MET_SAVE_BASE + MET_SAVE_X + ( 128 * MET_SAVE_INDICES ) ] = INITIAL_X;
  285.     SavePoints[MET_SAVE_BASE + MET_SAVE_Y + ( 128 * MET_SAVE_INDICES ) ] = INITIAL_Y;
  286.     SetGameRestoreStation(128);
  287. }
  288.  
  289. //Accessors
  290. bool SamusIsWarping(){ return (SavePoints[ISWARPING] != 0); }
  291. bool FlashingGreen(){ return (SavePoints[FLASHINGGREEN] != 0); }
  292. bool SamusTeleporting(){ return (SavePoints[TELEPORTING] != 0); }
  293. bool SamusArriving(){ return (SavePoints[ARRIVING] != 0); }
  294.  
  295. void SamusWarping(bool state){ if ( state ) SavePoints[ISWARPING] = 1; else SavePoints[ISWARPING] = 0;}
  296. void FlashingGreen(bool state){ if ( state ) SavePoints[FLASHINGGREEN] = 1; else SavePoints[FLASHINGGREEN] = 0;}
  297. void SamusTeleporting(bool state){ if ( state ) SavePoints[TELEPORTING] = 1; else SavePoints[TELEPORTING] = 0;}
  298. void SamusArriving(bool state){ if ( state ) SavePoints[ARRIVING] = 1; else SavePoints[ARRIVING] = 0;}
  299.  
  300. //Returns if samus can teleport, or activate a save point station.
  301. bool SamusCanTeleport(){
  302.     return true; //If you want conditions, they go in this function.
  303. }
  304.  
  305.  
  306.  
  307. //We do this when we activate the station.
  308. void SetWarpPoint(int warp_id, ffc f){
  309.     SavePoints[MET_SAVE_BASE + MET_SAVE_ID + ( warp_id * MET_SAVE_INDICES ) ] = warp_id;
  310.     SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( warp_id * MET_SAVE_INDICES ) ] = Game->GetCurDMap();
  311.     SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( warp_id * MET_SAVE_INDICES ) ] = Game->GetCurScreen();
  312.     SavePoints[MET_SAVE_BASE + MET_SAVE_X + ( warp_id * MET_SAVE_INDICES ) ] = f->X;
  313.     SavePoints[MET_SAVE_BASE + MET_SAVE_Y + ( warp_id * MET_SAVE_INDICES ) ] = f->Y;
  314. }
  315.  
  316. //A way to set the point based on Samus coordinates, instead of ffc coordinates, if needed.
  317. void SetWarpPoint(int warp_id){
  318.     SavePoints[MET_SAVE_BASE + MET_SAVE_ID + ( warp_id * MET_SAVE_INDICES ) ] = warp_id;
  319.     SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( warp_id * MET_SAVE_INDICES ) ] = Game->GetCurDMap();
  320.     SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( warp_id * MET_SAVE_INDICES ) ] = Game->GetCurScreen();
  321.     SavePoints[MET_SAVE_BASE + MET_SAVE_X + ( warp_id * MET_SAVE_INDICES ) ] = Link->X;
  322.     SavePoints[MET_SAVE_BASE + MET_SAVE_Y + ( warp_id * MET_SAVE_INDICES ) ] = Link->Y;
  323. }
  324.  
  325. //Checks if a given station is active.
  326. int WarpPointActive(int station_id) {
  327.     return SavePoints[MET_SAVE_BASE + MET_SAVE_STATION_ACTIVE + ( station_id * MET_SAVE_INDICES )];
  328. }
  329.  
  330. //Sets a given warp point active/inactive.
  331. void WarpPointActive(int station_id, bool setting) {
  332.     if ( setting ) SavePoints[MET_SAVE_BASE + MET_SAVE_STATION_ACTIVE + ( station_id * MET_SAVE_INDICES )] = 1;
  333.     else SavePoints[MET_SAVE_BASE + MET_SAVE_STATION_ACTIVE + ( station_id * MET_SAVE_INDICES )] = 0;
  334. }  
  335.  
  336. //Saving the game automation.
  337. void SaveGame(int station_id){
  338.     SetGameRestoreStation(station_id);
  339.     ///
  340.     Game->Save();
  341. }
  342.  
  343. //Save and quit automation.
  344. void SaveGameAndQuit(int station_id){
  345.     SetGameRestoreStation(station_id);
  346.     Game->Save();
  347.     Game->End();
  348. }
  349.  
  350. //Sets the station that we'll load when the player reloads the game.
  351. void SetGameRestoreStation(int station_id){
  352.     SavePoints[MET_SAVE_LAST_SAVESTATION] = station_id;
  353. }
  354.  
  355. //Gets the station to use as a restore point, on player death, or onContinue.
  356. int GetGameRestoreStation(){
  357.     return SavePoints[MET_SAVE_LAST_SAVESTATION];
  358. }
  359.  
  360. //Call during onContinue script, or on death.
  361. void RestoreGame(){
  362.         //if the game has been saved, then we have a restore station set
  363.     if ( GetGameRestoreStation() ) {
  364.         WarpSamus( GetGameRestoreStation(), MET_WARP_EFFECT_DURATION );
  365.     }
  366. }
  367.  
  368. // Tango Functions
  369.  
  370.  
  371. // There are certainly other ways to handle these...
  372. // Vars used by the Tango menu.
  373. //int menuCommand;
  374. //int menuArg;
  375.  
  376. //Tango Menu Init
  377. //void SetUpWindow(int slot, int style, int x, int y, int size)
  378. //{
  379. //    SetStyleSize(style, size);
  380. //    Tango_ClearSlot(slot);
  381. //    Tango_SetSlotStyle(slot, style);
  382. //    Tango_SetSlotPosition(slot, x, y);
  383. //}
  384.  
  385. //Quick way to drop a string into a Tango dialogue box.
  386. //void ShowString(int string, int slot, int style, int x, int y)
  387. //{
  388. //    SetUpWindow(slot, style, x, y, SIZE_LARGE);
  389. //    Tango_LoadString(slot, string);
  390. //    Tango_ActivateSlot(slot);
  391. //    while(Tango_SlotIsActive(slot))  
  392. //        Waitframe();
  393. //}
  394.  
  395.  
  396.    
  397. void DebugMetroidSaveStationMenu(int val) {
  398.     int t[]="MetroidSaveStationMenu() returned: ";
  399.     TraceNL(); TraceS(t); Trace(val); TraceNL();
  400. }
  401.  
  402. void DebugRefill(int val){
  403.     int t[]="Refill is set to: ";
  404.     TraceNL(); TraceS(t); Trace(val); TraceNL();
  405. }
  406.  
  407. void DebuggingMetroidSaveStation(){
  408.     int t[]="Debugging int MetroidSaveStationMenu(int station_id, int refill)";
  409.     TraceNL(); TraceS(t); TraceNL();
  410. }
  411.  
  412.  
  413. //refill == 0 for none, 1 for hp, 2 for mp, 3 for both
  414. //Menu called by the save station ffc.
  415. int MetroidSaveStationMenu(int station_id, int refill, int warp) {
  416.     if ( DEBUG_MENUS ) {
  417.         DebuggingMetroidSaveStation();
  418.         DebugRefill(refill);
  419.     }
  420.     int lineBreak[]="@26";
  421.     int line1[]="@choice(1)Save@26";
  422.     int line3[]="@choice(2)Warp@26";
  423.     int line2[]="@choice(5)Refill@26";
  424.     int line4[]="@choice(3)Save and Quit@26";
  425.     int line5[]="@choice(4)Cancel";
  426.     int initmenu[]="@domenu(1)@suspend()";
  427.    
  428.     if ( station_id ) {
  429.    
  430.         SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_1, 32, 32, SIZE_LARGE);
  431.         Tango_LoadString(WINDOW_SLOT_1, line1);
  432.         if ( refill || SAVEPOINTS_ALLOW_REFILL ) Tango_AppendString(WINDOW_SLOT_1, line2);
  433.         if ( warp || SAVEPOINTS_ALLOW_WARPING ) Tango_AppendString(WINDOW_SLOT_1, line3);
  434.         Tango_AppendString(WINDOW_SLOT_1, line4);
  435.         Tango_AppendString(WINDOW_SLOT_1, line5);
  436.         Tango_AppendString(WINDOW_SLOT_1, initmenu);
  437.         Tango_ActivateSlot(WINDOW_SLOT_1);
  438.     }
  439.    
  440.     else {  //Refill station, only. Arg d1 will default to 3 in this case, if it is un-set.
  441.         SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_1, 32, 32, SIZE_LARGE);
  442.         Tango_LoadString(WINDOW_SLOT_1, line2);
  443.         Tango_AppendString(WINDOW_SLOT_1, line5);
  444.         Tango_AppendString(WINDOW_SLOT_1, initmenu);
  445.         Tango_ActivateSlot(WINDOW_SLOT_1);
  446.     }
  447.  
  448.    
  449.     while(!Tango_MenuIsActive()){
  450.        
  451.         Waitframe();
  452.     }
  453.    
  454.     // Save the state again...
  455.     int slotState[278];
  456.     int menuState[960];
  457.     int cursorPos;
  458.     Tango_SaveSlotState(WINDOW_SLOT_1, slotState);
  459.     Tango_SaveMenuState(menuState);
  460.    
  461.     int done = 0;
  462.     int choice;
  463.     while(true){
  464.    
  465.         while( Tango_MenuIsActive() ) {
  466.             cursorPos=Tango_GetMenuCursorPosition();
  467.             Waitframe();
  468.         }
  469.        
  470.         choice = Tango_GetLastMenuChoice();
  471.         if ( choice == 1 ) { // Save the game
  472.             SaveGame(station_id);
  473.             Game->PlaySound(SFX_SAVE_SUCCESS);
  474.             int text[]="Game Saved";
  475.             Tango_ClearSlot(2);
  476.             ShowString(text, WINDOW_SLOT_2, WINDOW_STYLE_2, 48, 48);
  477.             done = -9999;
  478.         }
  479.         else if ( choice == 2 ) { //Warp
  480.             //! Run the warp menu.
  481.             done = WarpMenu();
  482.             // done = choice;
  483.             //menuArg = choice;
  484.         }
  485.        
  486.         else if ( choice == 3 ) { //Save and quit
  487.             Game->PlaySound(SFX_SAVE_SUCCESS);
  488.             SaveGameAndQuit(station_id);
  489.             done = choice;
  490.         }
  491.        
  492.         else if ( choice == 4 ) {//cancel
  493.             done = -9999;
  494.         }
  495.        
  496.         else if ( choice == 5 ) { //refill
  497.             RefillMenu(refill);
  498.             done = -9999;
  499.         }
  500.        
  501.         if ( done ) {
  502.             break;
  503.         //  return choice;
  504.         }
  505.         else {
  506.             Tango_RestoreSlotState(WINDOW_SLOT_1, slotState);
  507.             Tango_RestoreMenuState(menuState);
  508.             Tango_SetMenuCursorPosition(cursorPos);
  509.         }
  510.     }
  511.    
  512.     Tango_ClearSlot(WINDOW_SLOT_1);
  513.     if ( DEBUG_MENUS ) DebugMetroidSaveStationMenu(done);
  514.     return done;
  515. }
  516.  
  517. //Populte these functions with instructions to refill stocks.  
  518.  
  519. void RefillMissiles() {}
  520.  
  521.    
  522. void DebuggingRefillMenu(){
  523.     int t[]="Debugging Refillmeny(int type)";
  524.     TraceNL(); TraceS(t); TraceNL();
  525. }
  526.    
  527.    
  528. //refill == 0 for none, 1 for hp, 2 for mp, 3 for both
  529. int RefillMenu(int type){
  530.     if ( DEBUG_MENUS ) {
  531.         DebuggingRefillMenu();
  532.         DebugRefill(type);
  533.     }
  534.     int lineBreak[]="@26";
  535.    
  536.     //Three springs per destination pair. We'll check if they are active, and only display those that are actie.
  537.        
  538.     int missiles[]="@choice(1)Refill Magic@26";
  539.     int health[]="@choice(2)Refill Energy@26";
  540.         int both[]="@choice(3)Refill Both@26";
  541.  
  542.    
  543.     int initmenu[]="@domenu(1)@suspend()";
  544.    
  545.    
  546.     //int restoredmissiles[]="Magic replenished.";
  547.     //int restoredhealth[]="Health replenished.";
  548.     //int restoredboth[]="Energy and missile supplies replenished.";
  549.    
  550.     //We can change '10' to cancel if needed.
  551.    
  552.     SetUpWindow(WINDOW_SLOT_3, WINDOW_STYLE_1, 32, 32, SIZE_LARGE);
  553.    
  554.     //Magic Only
  555.    
  556.     //ShowString(restoredmissiles, WINDOW_SLOT_4, WINDOW_STYLE_1, 48, 48);
  557.    
  558.    
  559.     if ( type == 2 )  {
  560.         Tango_LoadString(WINDOW_SLOT_3, missiles);
  561.         Tango_AppendString(WINDOW_SLOT_3, initmenu);
  562.         Tango_ActivateSlot(WINDOW_SLOT_3);
  563.     }
  564.    
  565.     //Health only
  566.    
  567.     if ( type == 1 )  {
  568.         Tango_LoadString(WINDOW_SLOT_3, health);
  569.         Tango_AppendString(WINDOW_SLOT_3, initmenu);
  570.         Tango_ActivateSlot(WINDOW_SLOT_3);
  571.     }
  572.    
  573.     //Both
  574.    
  575.     if ( type == 3 )  {
  576.         Tango_LoadString(WINDOW_SLOT_3, missiles);
  577.         Tango_LoadString(WINDOW_SLOT_3, health);
  578.         Tango_LoadString(WINDOW_SLOT_3, both);
  579.         Tango_AppendString(WINDOW_SLOT_3, initmenu);
  580.         Tango_ActivateSlot(WINDOW_SLOT_3);
  581.     }
  582.    
  583.        
  584.  
  585.  
  586.    
  587.     while(!Tango_MenuIsActive()){
  588.        
  589.         Waitframe();
  590.     }
  591.    
  592.     // Save the state again...
  593.     int slotState[278];
  594.     int menuState[960];
  595.     int cursorPos;
  596.     Tango_SaveSlotState(WINDOW_SLOT_3, slotState);
  597.     Tango_SaveMenuState(menuState);
  598.    
  599.     int done = 0;
  600.     int choice;
  601.     while(true){
  602.    
  603.         while( Tango_MenuIsActive() ) {
  604.             cursorPos=Tango_GetMenuCursorPosition();
  605.             Waitframe();
  606.         }
  607.        
  608.        
  609.        
  610.         choice = Tango_GetLastMenuChoice();
  611.        
  612.         if ( choice == 1 ) { //Refill magic
  613.             Game->DCounter[CR_MAGIC] = Link->MaxMP;
  614.             Tango_ClearSlot(WINDOW_SLOT_2);
  615.             done = -99999;
  616.         }
  617.        
  618.        
  619.         if ( choice == 2 ) { //Refill missiles
  620.             Game->DCounter[CR_LIFE] = Link->MaxHP;
  621.             Tango_ClearSlot(WINDOW_SLOT_2);
  622.             done = -99999;
  623.         }
  624.        
  625.         if ( choice == 3 ) { //Refill both
  626.             Game->DCounter[CR_MAGIC] = Link->MaxMP;
  627.             Game->DCounter[CR_LIFE] = Link->MaxHP;
  628.             Tango_ClearSlot(WINDOW_SLOT_2);
  629.             done = -99999;
  630.         }
  631.        
  632.         if ( done ) {
  633.             break;
  634.         //  return choice;
  635.         }
  636.         else {
  637.             Tango_RestoreSlotState(WINDOW_SLOT_3, slotState);
  638.             Tango_RestoreMenuState(menuState);
  639.             Tango_SetMenuCursorPosition(cursorPos);
  640.         }
  641.     }
  642.    
  643.     Tango_ClearSlot(WINDOW_SLOT_3);
  644.     return done;
  645. }
  646.  
  647. //Warp menu, called by MetroidSaveStationMenu(), or by other functions/scripts.
  648. int WarpMenu(){
  649.  
  650.     int lineBreak[]="@26";
  651.    
  652.     //Three springs per destination pair. We'll check if they are active, and only display those that are actie.
  653.         int line1_both[]="@choice(1)Go 1@tab(56)@choice(2)Go 2@26";
  654.     int line1_first[]="@choice(1)Go 1@26";
  655.         int line1_second[]="   @tab(56)@choice(2)Go 2@26";
  656.    
  657.     int line2_both[]="@choice(3)Go 3@tab(56)@choice(4)Go 4@26";
  658.     int line2_first[]="@choice(3)Go 3@26";
  659.         int line2_second[]="   @tab(56)@choice(4)Go 4@26";
  660.    
  661.     int line3_both[]="@choice(5)Go 5@tab(56)@choice(6)Go 6@26";
  662.     int line3_first[]="@choice(5)Go 5@26";
  663.         int line3_second[]="   @tab(56)@choice(6)Go 6@26";
  664.    
  665.     int line4_both[]="@choice(7)Go 7@tab(56)@choice(8)Go 8@26";
  666.     int line4_first[]="@choice(7)Go 7@26";
  667.         int line4_second[]="   @tab(56)@choice(8)Go 8@26";
  668.    
  669.     int line5_both[]="@choice(9)Go 9@tab(56)@choice(10)Go 10@26";
  670.     int line5_first[]="@choice(9)Go 9@26";
  671.         int line5_second[]="   @tab(56)@choice(10)Go 10@26";
  672.    
  673.     int line6_both[]="@choice(11)Go 11@tab(56)@choice(12)Go 12@26";
  674.     int line6_first[]="@choice(11)Go 11@26";
  675.         int line6_second[]="   @tab(56)@choice(12)Go 12@26";
  676.    
  677.     int line7_both[]="@choice(13)Go 13@tab(56)@choice(14)Go 14@26";
  678.     int line7_first[]="@choice(13)Go 13@26";
  679.         int line7_second[]="   @tab(56)@choice(14)Go 14@26";
  680.    
  681.     int line8_both[]="@choice(15)Go 15@tab(56)@choice(16)Go 16@26";
  682.     int line8_first[]="@choice(15)Go 15@26";
  683.         int line8_second[]="   @tab(56)@choice(16)Go 16@26";
  684.    
  685.     int line9_both[]="@choice(17)Go 17@tab(56)@choice(18)Go 18@26";
  686.     int line9_first[]="@choice(17)Go 17@26";
  687.         int line9_second[]="   @tab(56)@choice(18)Go 18@26";
  688.    
  689.     int line10_both[]="@choice(19)Go 19@tab(56)@choice(20)Go 20@26";
  690.     int line10_first[]="@choice(19)Go 19@26";
  691.         int line10_second[]="   @tab(56)@choice(20)Go 20@26";
  692.    
  693.     int initmenu[]="@domenu(1)@suspend()";
  694.    
  695.     //We can change '10' to cancel if needed.
  696.    
  697.     SetUpWindow(WINDOW_SLOT_2, WINDOW_STYLE_3, 32, 32, SIZE_LARGE);
  698.    
  699.     if ( WarpPointActive(1) && WarpPointActive(2) ) Tango_LoadString(WINDOW_SLOT_2, line1_both);
  700.     if ( WarpPointActive(1) && !WarpPointActive(2) ) Tango_LoadString(WINDOW_SLOT_2, line1_first);
  701.     if ( !WarpPointActive(1) && WarpPointActive(2) ) Tango_LoadString(WINDOW_SLOT_2, line1_second);
  702.    
  703.     if ( WarpPointActive(3) && WarpPointActive(4) ) Tango_AppendString(WINDOW_SLOT_2, line2_both);
  704.     if ( WarpPointActive(3) && !WarpPointActive(4) ) Tango_AppendString(WINDOW_SLOT_2, line2_first);
  705.     if ( WarpPointActive(3) && WarpPointActive(4) ) Tango_AppendString(WINDOW_SLOT_2, line2_second);
  706.    
  707.     if ( WarpPointActive(5) && WarpPointActive(6) ) Tango_AppendString(WINDOW_SLOT_2, line3_both);
  708.     if ( WarpPointActive(5) && !WarpPointActive(6) ) Tango_AppendString(WINDOW_SLOT_2, line3_first);
  709.     if ( WarpPointActive(5) && WarpPointActive(6) ) Tango_AppendString(WINDOW_SLOT_2, line3_second);
  710.    
  711.     if ( WarpPointActive(7) && WarpPointActive(8) ) Tango_AppendString(WINDOW_SLOT_2, line4_both);
  712.     if ( WarpPointActive(7) && !WarpPointActive(8) ) Tango_AppendString(WINDOW_SLOT_2, line4_first);
  713.     if ( WarpPointActive(7) && WarpPointActive(8) ) Tango_AppendString(WINDOW_SLOT_2, line4_second);
  714.    
  715.     if ( WarpPointActive(9) && WarpPointActive(10) ) Tango_AppendString(WINDOW_SLOT_2, line5_both);
  716.     if ( WarpPointActive(9) && !WarpPointActive(10) ) Tango_AppendString(WINDOW_SLOT_2, line5_first);
  717.     if ( WarpPointActive(9) && WarpPointActive(10) ) Tango_AppendString(WINDOW_SLOT_2, line5_second);
  718.    
  719.     if ( WarpPointActive(11) && WarpPointActive(12) ) Tango_AppendString(WINDOW_SLOT_2, line6_both);
  720.     if ( WarpPointActive(11) && !WarpPointActive(12) ) Tango_AppendString(WINDOW_SLOT_2, line6_first);
  721.     if ( WarpPointActive(11) && WarpPointActive(12) ) Tango_AppendString(WINDOW_SLOT_2, line6_second);
  722.    
  723.     if ( WarpPointActive(13) && WarpPointActive(14) ) Tango_AppendString(WINDOW_SLOT_2, line7_both);
  724.     if ( WarpPointActive(13) && !WarpPointActive(14) ) Tango_AppendString(WINDOW_SLOT_2, line7_first);
  725.     if ( WarpPointActive(13) && WarpPointActive(14) ) Tango_AppendString(WINDOW_SLOT_2, line7_second);
  726.    
  727.     if ( WarpPointActive(15) && WarpPointActive(16) ) Tango_AppendString(WINDOW_SLOT_2, line8_both);
  728.     if ( WarpPointActive(15) && !WarpPointActive(16) ) Tango_AppendString(WINDOW_SLOT_2, line8_first);
  729.     if ( WarpPointActive(15) && WarpPointActive(16) ) Tango_AppendString(WINDOW_SLOT_2, line8_second);
  730.    
  731.     if ( WarpPointActive(17) && WarpPointActive(18) ) Tango_AppendString(WINDOW_SLOT_2, line9_both);
  732.     if ( WarpPointActive(17) && !WarpPointActive(18) ) Tango_AppendString(WINDOW_SLOT_2, line9_first);
  733.     if ( WarpPointActive(17) && WarpPointActive(18) ) Tango_AppendString(WINDOW_SLOT_2, line9_second);
  734.    
  735.     if ( WarpPointActive(19) && WarpPointActive(20) ) Tango_AppendString(WINDOW_SLOT_2, line10_both);
  736.     if ( WarpPointActive(19) && !WarpPointActive(20) ) Tango_AppendString(WINDOW_SLOT_2, line10_first);
  737.     if ( WarpPointActive(19) && WarpPointActive(20) ) Tango_AppendString(WINDOW_SLOT_2, line10_second);
  738.    
  739.     Tango_AppendString(WINDOW_SLOT_2, initmenu);
  740.    
  741.         Tango_ActivateSlot(WINDOW_SLOT_2);
  742.  
  743.  
  744.    
  745.     while(!Tango_MenuIsActive()){
  746.        
  747.         Waitframe();
  748.     }
  749.    
  750.     // Save the state again...
  751.     int slotState[278];
  752.     int menuState[960];
  753.     int cursorPos;
  754.     Tango_SaveSlotState(WINDOW_SLOT_2, slotState);
  755.     Tango_SaveMenuState(menuState);
  756.    
  757.     int done = 0;
  758.     int choice;
  759.     while(true){
  760.    
  761.         while( Tango_MenuIsActive() ) {
  762.             cursorPos=Tango_GetMenuCursorPosition();
  763.             Waitframe();
  764.         }
  765.        
  766.        
  767.        
  768.         choice = Tango_GetLastMenuChoice();
  769.        
  770.         if ( choice ) {
  771.             Tango_ClearSlot(WINDOW_SLOT_2);
  772.             done = choice * -1;
  773.         }
  774.        
  775.         if ( done ) {
  776.             break;
  777.         //  return choice;
  778.         }
  779.         else {
  780.             Tango_RestoreSlotState(WINDOW_SLOT_2, slotState);
  781.             Tango_RestoreMenuState(menuState);
  782.             Tango_SetMenuCursorPosition(cursorPos);
  783.         }
  784.     }
  785.    
  786.     Tango_ClearSlot(WINDOW_SLOT_2);
  787.     if ( DEBUG_MENUS ) DebugWarpChoice(done);
  788.     return done;
  789. }
  790.    
  791. void DebugWarpChoice(int val){
  792.     int t[]="WarpMenu() returned: ";
  793.     TraceNL(); TraceS(t); Trace(val); TraceNL();
  794. }
  795.  
  796. //Does the warp animation, and the phsyical warp.
  797. void WarpSamus(int warp_id, int warpDuration) {
  798.     int startHP = Link->HP;
  799.     int goDMAP = SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( warp_id * MET_SAVE_INDICES )];
  800.     int goSCREEN = SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( warp_id * MET_SAVE_INDICES )];
  801.     int goX = SavePoints[MET_SAVE_BASE + MET_SAVE_X + ( warp_id * MET_SAVE_INDICES )];
  802.     int goY = SavePoints[MET_SAVE_BASE + MET_SAVE_Y + ( warp_id * MET_SAVE_INDICES )]; 
  803.    
  804.     if ( SamusCanTeleport() ) {
  805.         Game->PlaySound(SFX_TELEPORT_TRANSITION);
  806.         //freezeAction();
  807.         SamusTeleporting(true);
  808.         SamusArriving(true);
  809.         for(int i = warpDuration; i > 0; i--){ //Duration of song/effect.
  810.             NoAction(); //Freeze Link
  811.             //Game->PlaySound(SFX_TELEPORT_TRANSITION);
  812.             //Create animation.
  813.             Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, WARP_TEAL, 1, 0, 0, 0, false, 100 );
  814.            
  815.             FlashingGreen(false);
  816.  
  817.            
  818.             do {
  819.                 for ( int j = 1; j > 0; j--){
  820.                     ScreenToLayer(goDMAP, goSCREEN, 4, 75);
  821.                     Screen->Rectangle(5, 0, 0, 256, 172, WARP_GREEN, 1, 0, 0, 0, true, 25);
  822.                     Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, 1, 1, 0, 0, 0, false, 100 );
  823.                     FlashingGreen(true);
  824.                     Waitframe();
  825.                 }
  826.             } while(SamusTeleporting() && !FlashingGreen());
  827.                
  828.             do {   
  829.                 for ( int j = 1; j > 0; j--){
  830.                 ScreenToLayer(goDMAP, goSCREEN, 4, 80);
  831.                 Screen->Rectangle(5, 0, 0, 256, 172, WARP_LTGREEN, 1, 0, 0, 0, true, 10);
  832.                 Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, WARP_TEAL, 1, 0, 0, 0, false, 100 );
  833.                 FlashingGreen(false);
  834.                
  835.                 Waitframe();
  836.                 }
  837.                
  838.             } while(SamusTeleporting() && FlashingGreen());
  839.  
  840.             if ( Link->HP < startHP ) {
  841.                 return; //If Link is hurt, quit
  842.             }
  843.             Waitframe();
  844.         }
  845.            
  846.         Screen->Wavy =60;
  847.         Link->PitWarp( goDMAP, goSCREEN );
  848.         Link->X = goX;
  849.         Link->Y = goY;
  850.  
  851.         SamusTeleporting(false);
  852.         //unfreezeAction();
  853.         Waitframe();
  854.         SamusTeleporting(false);
  855.         FlashingGreen(false);
  856.  
  857.     }
  858.            
  859.         else {
  860.             Game->PlaySound(SFX_WARP_ERROR);
  861.             SamusWarping(false);
  862.         //NotEnoughMP();
  863.             //return;
  864.         }
  865.    
  866. }
  867.  
  868. //Does the warp animation, and the phsyical warp.
  869. void WarpSamusForced(int warp_id, int warpDuration) {
  870.     int startHP = Link->HP;
  871.     int goDMAP = SavePoints[MET_SAVE_BASE + MET_SAVE_DMAP + ( warp_id * MET_SAVE_INDICES )];
  872.     int goSCREEN = SavePoints[MET_SAVE_BASE + MET_SAVE_SCREEN + ( warp_id * MET_SAVE_INDICES )];
  873.     int goX = SavePoints[MET_SAVE_BASE + MET_SAVE_X + ( warp_id * MET_SAVE_INDICES )];
  874.     int goY = SavePoints[MET_SAVE_BASE + MET_SAVE_Y + ( warp_id * MET_SAVE_INDICES )]; 
  875.  
  876.         Game->PlaySound(SFX_TELEPORT_TRANSITION);
  877.         //freezeAction();
  878.         SamusTeleporting(true);
  879.         SamusArriving(true);
  880.         for(int i = warpDuration; i > 0; i--){ //Duration of song/effect.
  881.             NoAction(); //Freeze Link
  882.             //Game->PlaySound(SFX_TELEPORT_TRANSITION);
  883.             //Create animation.
  884.             Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, WARP_TEAL, 1, 0, 0, 0, false, 100 );
  885.            
  886.             FlashingGreen(false);
  887.  
  888.            
  889.             do {
  890.                 for ( int j = 1; j > 0; j--){
  891.                     ScreenToLayer(goDMAP, goSCREEN, 4, 75);
  892.                     Screen->Rectangle(5, 0, 0, 256, 172, WARP_GREEN, 1, 0, 0, 0, true, 25);
  893.                     Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, 1, 1, 0, 0, 0, false, 100 );
  894.                     FlashingGreen(true);
  895.                     Waitframe();
  896.                 }
  897.             } while(SamusTeleporting() && !FlashingGreen());
  898.                
  899.             do {   
  900.                 for ( int j = 1; j > 0; j--){
  901.                 ScreenToLayer(goDMAP, goSCREEN, 4, 80);
  902.                 Screen->Rectangle(5, 0, 0, 256, 172, WARP_LTGREEN, 1, 0, 0, 0, true, 10);
  903.                 Screen->Circle ( 6, Link->X+8, Link->Y+8, 20*i/warpDuration, WARP_TEAL, 1, 0, 0, 0, false, 100 );
  904.                 FlashingGreen(false);
  905.                
  906.                 Waitframe();
  907.                 }
  908.                
  909.             } while(SamusTeleporting() && FlashingGreen());
  910.  
  911.             if ( Link->HP < startHP ) {
  912.                 return; //If Link is hurt, quit
  913.             }
  914.             Waitframe();
  915.         }
  916.            
  917.         Screen->Wavy =60;
  918.         Link->PitWarp( goDMAP, goSCREEN );
  919.         Link->X = goX;
  920.         Link->Y = goY;
  921.  
  922.         SamusTeleporting(false);
  923.         //unfreezeAction();
  924.         Waitframe();
  925.         SamusTeleporting(false);
  926.         FlashingGreen(false);
  927.    
  928. }
  929.  
  930.  
  931. //Used if teleporting requires magic. Modify and use if desired.
  932. bool NotEnoughMP(){
  933.  
  934.     int lineBreak[]="@26";
  935.     int menuEnd[]="@domenu(1)@suspend()";
  936.  
  937.    
  938.     int line2[]="You do not have enough MP to do that.@26";
  939.     int line1[]="@choice(1)Done@26@26";
  940.  
  941.  
  942.    
  943.     SetUpWindow(WINDOW_SLOT_2, WINDOW_STYLE_2, 32, 32, SIZE_LARGE);
  944.         Tango_LoadString(WINDOW_SLOT_2, line1);
  945.         Tango_AppendString(WINDOW_SLOT_2, line2);
  946.         Tango_AppendString(WINDOW_SLOT_2, menuEnd);
  947.         Tango_ActivateSlot(WINDOW_SLOT_2);
  948.    
  949.    
  950.     while(!Tango_MenuIsActive()){
  951.        
  952.         Waitframe();
  953.     }
  954.    
  955.     // Save the state again...
  956.     int slotState[274];
  957.     int menuState[60];
  958.     int cursorPos;
  959.     Tango_SaveSlotState(WINDOW_SLOT_2, slotState);
  960.     Tango_SaveMenuState(menuState);
  961.    
  962.     int done=0;
  963.     int choice;
  964.     while(true)
  965.     {
  966.    
  967.         while(Tango_MenuIsActive())
  968.         {
  969.            
  970.             cursorPos=Tango_GetMenuCursorPosition();
  971.          
  972.             Waitframe();
  973.         }
  974.        
  975.         choice=Tango_GetLastMenuChoice();
  976.         if(choice==0) // Canceled
  977.             done=2;
  978.            
  979.         else if(choice == 1)
  980.         {
  981.             done=2;
  982.         }
  983.          
  984.         else if (Link->PressEx1){
  985.                 done = 2;
  986.         }
  987.         else
  988.             done=2;
  989.  
  990.        
  991.  
  992.        
  993.         if(done>0){
  994.            
  995.             break;
  996.         }
  997.         else
  998.         {
  999.             Tango_RestoreSlotState(WINDOW_SLOT_2, slotState);
  1000.             Tango_RestoreMenuState(menuState);
  1001.             Tango_SetMenuCursorPosition(cursorPos);
  1002.         }
  1003.     }
  1004.    
  1005.     Tango_ClearSlot(WINDOW_SLOT_2);
  1006.    
  1007.     if(done==1)
  1008.         return true; // Tell parent menu to close
  1009.     else
  1010.         return false; // Tell parent not to close
  1011. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement