Advertisement
ywkls

Save Point Script

Nov 17th, 2019
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. //! The physical save station.
  2. //! D0 : Each station needs a unique ID, ranging from 1 to 10.
  3. //! The script is set up to allow up to a total of ten save stations using the menus.
  4.  
  5. ffc script Save_Point{
  6. void run(int station_number, int message){
  7. bool pressed;
  8. int choice;
  9. while ( true ) {
  10. while ( !pressed && !Tango_MenuIsActive() ) {
  11. if (LinkCollision(this)){
  12. Screen->FastCombo(4,Link->X,Link->Y-16,THINK_COMBO,10,128);
  13. if (Link->PressA) {
  14. pressed = true;
  15. Link->PressA = false;
  16. Link->InputA = false;
  17. }
  18. }
  19. Waitframe();
  20. }
  21.  
  22. if ( pressed ) {
  23. pressed = false;
  24. //Set coordinates for this station:
  25. choice = SavePointMenu(station_number, message);
  26. }
  27. Waitframe(); //Main while loop.
  28. }
  29. }
  30. }
  31.  
  32. //Tango Menu Init
  33. void SetUpWindow(int slot, int style, int x, int y, int size)
  34. {
  35. SetStyleSize(style, size);
  36. Tango_ClearSlot(slot);
  37. Tango_SetSlotStyle(slot, style);
  38. Tango_SetSlotPosition(slot, x, y);
  39. }
  40.  
  41. //Quick way to drop a string into a Tango dialogue box.
  42. void ShowString(int string, int slot, int style, int x, int y)
  43. {
  44. SetUpWindow(slot, style, x, y, STYLE_HEART);
  45. Tango_LoadString(slot, string);
  46. Tango_ActivateSlot(slot);
  47. while(Tango_SlotIsActive(slot))
  48. Waitframe();
  49. }
  50.  
  51. //Menu called by the save station ffc.
  52. int SavePointMenu(int station_id, int message) {
  53. int lineBreak[]="@26";
  54. int line1[]="@choice(1)Save@26";
  55. int line2[]="@choice(2)Save and Quit@26";
  56. int line3[]="@choice(3)Cancel";
  57. int initmenu[]="@domenu(1)@suspend()";
  58.  
  59. if ( station_id ) {
  60. ShowMessage(message, TANGO_SLOT_NORMAL,WINDOW_STYLE_1, STYLE_HEART, 16, 16);
  61. Waitframe();
  62. SetUpWindow(WINDOW_SLOT_1,WINDOW_STYLE_1,48,48,STYLE_PLAIN);
  63. Tango_LoadString(WINDOW_SLOT_1, line1);
  64. Tango_AppendString(WINDOW_SLOT_1, line2);
  65. Tango_AppendString(WINDOW_SLOT_1, line3);
  66. Tango_AppendString(WINDOW_SLOT_1, initmenu);
  67. Tango_ActivateSlot(WINDOW_SLOT_1);
  68. }
  69.  
  70. while(!Tango_MenuIsActive()){
  71.  
  72. Waitframe();
  73. }
  74.  
  75. // Save the state again...
  76. int slotState[533];
  77. int menuState[960];
  78. int cursorPos;
  79. Tango_SaveSlotState(WINDOW_SLOT_1, slotState);
  80. Tango_SaveMenuState(menuState);
  81.  
  82. int done = 0;
  83. int choice;
  84. while(true){
  85.  
  86. while( Tango_MenuIsActive() ) {
  87. cursorPos=Tango_GetMenuCursorPosition();
  88. Waitframe();
  89. }
  90.  
  91. choice = Tango_GetLastMenuChoice();
  92. if ( choice == 1) { // Save the game
  93. SaveGame(station_id);
  94. Game->PlaySound(SFX_SAVE_SUCCESS);
  95. int text[]="Game Saved";
  96. Tango_ClearSlot(TANGO_SLOT_NORMAL);
  97. Tango_ClearSlot(WINDOW_SLOT_1);
  98. ShowString(text, WINDOW_SLOT_1, WINDOW_STYLE_1, 48, 48);
  99. done = -9999;
  100. }
  101. else if ( choice == 2 ) { //Save and quit
  102. Game->PlaySound(SFX_SAVE_SUCCESS);
  103. SaveGameAndQuit(station_id);
  104. done = choice;
  105. }
  106. else if ( choice == 3){//Cancel
  107. Tango_ClearSlot(TANGO_SLOT_NORMAL);
  108. done = -9999;
  109. }
  110. if ( done )
  111. break;
  112. // return choice;
  113. else {
  114. Tango_RestoreSlotState(WINDOW_SLOT_1, slotState);
  115. Tango_RestoreMenuState(menuState);
  116. Tango_SetMenuCursorPosition(cursorPos);
  117. }
  118. }
  119.  
  120. Tango_ClearSlot(WINDOW_SLOT_1);
  121. return done;
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement