Advertisement
ZoriaRPG

Annotated Tango.zh Menu

May 31st, 2019
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.52 KB | None | 0 0
  1. bool isActive = false; //Gives us a boolean for the Tango menu. I use this in my global script, so that the player can't open menus on title, or transition screens.
  2. bool ffcsSuspended; //Establishes if FFCs suspended.
  3. int menuCommand; //Used to store the present command selected in a menu that launches an FFC script.
  4. bool noMenu = false; //This allows you to prevent using menus on desired maps, screens, and so forth. i use it for the title screen in LoE.
  5.  
  6.  
  7. const int TANGO_MENU_FFC_SLOT = 0; //Set to FFC slot of FFC script 'Menu'
  8.  
  9. global script Init { //This script auto-loads into slot ~Init when compiling. It is used to set up the basic tango styles.
  10.     void run() {
  11.         SetCommonStyleData(WINDOW_STYLE_1); //Sets 'Style 1' Tango settings.
  12.         SetCommonStyleData(WINDOW_STYLE_2); //Sets 'Style 2' Tango settings.
  13.         SetCommonStyleData(WINDOW_STYLE_3); //Sets 'Style 1' Tango settings.
  14.     }
  15. }
  16.  
  17. global script activeMenus{ //This is an *example global active script, so that you know where to place TangoStart() TangoUpdate1() and TangoUodate2().
  18.     void run(){
  19.         ffcsSuspended = false;
  20.         Tango_Start(); //Starts Tango.
  21.         menuCommand=0; //Initialises the global variable menuCommand,
  22.         //InitializeGhostZHData();
  23.         while(true){ //This runs once per frame.
  24.             Tango_Update1(); //Do initial Tango bitn=map updating.
  25.             if ( noMenu == false ) { //If we're allowed to open a menu...
  26.                 if(Link->PressEx1 && !Tango_SlotIsActive(WINDOW_SLOT_1)) //If the player presses Button Ex1, the main menu opens. You can change the button.
  27.                 RunFFCScript(TANGO_MENU_FFC_SLOT, NULL); // Runs Menu FFC, from the slot assigned to constant TANGO_MENU_FFC_SLOT.
  28.             }
  29.             if(menuCommand>0){ // A menu changed the variable menuCommand to an FFC slot number.
  30.                 RunFFCScript(menuCommand, NULL); //Run that FFC script without args.
  31.                 menuCommand=0; //Reset the var.
  32.             }
  33.             Waitdraw(); //Paises to do drawing of screen gfx.
  34.             Tango_Update2(); //Post Waitdraw refreshing.
  35.             Waitframe(); //Pause the loop, to repeat.
  36.  
  37.         }
  38.     }
  39. }
  40.  
  41. ffc script TangoBox{
  42.     void run(){
  43.        
  44.         int firstline[]="My first Tango box.";
  45.         int nextline[]="This is my second line."
  46.         int choice1[]="@choice(1)MenuChoice"; // This is a menu choice with the choice token. The menu will display the words 'MenuVhoice' as option-12, and if the player selects it, then menuChoice = 1;
  47.         int linebreak[]="@26"
  48.         int choice2[]="@choice()Second Option"; //This is a second menu choice, displaying 'Secomnd Option' in the ment. Selecting it sets menuChoice = 2;
  49.         int domenu[]="@domenu(1)";
  50.         int lastline[]="@suspend()";
  51.        
  52.         SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_1, 16, 16, SIZE_LARGE);
  53.         //Makes a Tango text box, in slot 1, with the parameters defined as 'WINDOW_STYLE_1', upper-left cornet at X16 and Y16, with dimensions defined as 'SIZE_LARGE'
  54.        
  55.         Tango_LoadString(WINDOW_SLOT_1, firstline);
  56.         //Loads the initial string, to initialise the dialogue box.
  57.        
  58.         Tango_AppendString(WINDOW_SLOT_1, linebreak);
  59.         //Appends the string 'linebreak', cauing a blank line to follow under 'firstline'
  60.        
  61.         Tango_AppendString(WINDOW_SLOT_1, nextline);
  62.         //Appends the string 'nextline' after the linebreak.
  63.        
  64.         Tango_AppendString(WINDOW_SLOT_1, choice1);
  65.         //Appends the string with a menu choice (1).
  66.        
  67.         Tango_AppendString(WINDOW_SLOT_1, choice2);
  68.         //Appends the string with a menu choice (2).
  69.        
  70.         Tango_AppendString(WINDOW_SLOT_1, domenu);
  71.         //Appends the string terminating menu additions, and telling Tango that the menu is ready.
  72.        
  73.         Tango_AppendString(WINDOW_SLOT_1, lastline);
  74.         //Runs the Suspend Tango operation.
  75.    
  76.         Tango_ActivateSlot(WINDOW_SLOT_1);
  77.         //Primes the off-screen bitmap.
  78.        
  79.         while(!isActive){
  80.             Waitframe(); //While we're waiting for the player to open the menu, do nothing.
  81.         }
  82.        
  83.         // Save the state of the text slot and menu. The bitmap won't change,
  84.         // so it doesn't need saved.
  85.         int slotState[274]; //Arrays to hold the Tango window datum.
  86.         int menuState[60];
  87.         int cursorPos; //A variable to track cursor position.
  88.         Tango_SaveSlotState(WINDOW_SLOT_1, slotState); //Saves the bitmap state every frame off-screen, so that it can be drawn every frame on-screen.
  89.         Tango_SaveMenuState(menuState); //Saves the menu state, cursor position, and such, off-screen every frame, and redraws on-screen.
  90.        
  91.         bool done=false; //Gives us a local boolean variable to control menu closing.
  92.         int choice; //Gives us a variable to set the numeric value of selecting a menu option.
  93.        
  94.         while(true) { //While the tango FFC exists...
  95.             if ( Link->PressEx1 ){ //If the player presses button Ex1 (You can change the button)
  96.                 Quit(); //Kill the FFC, closing all boxes.
  97.             }
  98.              while(Tango_MenuIsActive()) { //While a menu is open...
  99.                 cursorPos=Tango_GetMenuCursorPosition(); //Updates cursor movement.
  100.                 Waitframe(); Waits a frame, to draw.
  101.             }
  102.             choice=Tango_GetLastMenuChoice(); //Forwards an int, to modify, for int-based options.
  103.             if(choice==1) { // If the player selects choice 1.
  104.                 int text[]="The Look function is not yet available. Please use your 'L' button for the present."; //Creates a new string to display.
  105.                     ShowString(text, WINDOW_SLOT_2, WINDOW_STYLE_2, 32, 32); //Displays string 'text' in a new window, cascading from the main menu; using SLOT 2.
  106.                 done=true; //Tell FFC menu to close on input
  107.             }
  108.             else if(choice==2) { //If player selects choice 2.
  109.                 showStats(); //Cals the Boolean function showStats()
  110.                 done=true; //Tells menu we're done here.
  111.             }
  112.             else if (Link->PressEx1){
  113.                 Quit(); //If we press Ex1 while this menu is active, it quits the FFC. Run from base menus only, and use return true to close daughter windows.
  114.             }
  115.             else {
  116.                 done=true; //Enables the loop below if the player presses anything other than 'A'.
  117.             }
  118.             // If we need to return to the top-level menu,
  119.             // restore the state and loop again.
  120.             if(done){ //if boolean 'done' = true...
  121.                 break; //Breaks the main while loop, closing the menu.
  122.             }
  123.             else { //If the player did not give any inouts this frame that close the menu...
  124.                 Tango_RestoreSlotState(WINDOW_SLOT_1, slotState); //Refresh the menu bitmap this frame.
  125.                 Tango_RestoreMenuState(menuState); //Redraw bitmap to FFC.
  126.                 Tango_SetMenuCursorPosition(cursorPos); Redraw menu curson on choice to which the selector last pointed.
  127.             }
  128.         }
  129.         //If we reach here, then the menu is closing.
  130.         Tango_ClearSlot(WINDOW_SLOT_1); //Now that we break out, we clear the slot and remove the FFC DISPLAY. This wipes the bitmap, and allows drawing a different bitmap at its location.
  131.     }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement