Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int START_SAVE_POINT = 1;
- //! The physical save station.
- //! D0 : Each station needs a unique ID, ranging from 1 to 10.
- //! The script is set up to allow up to a total of ten save stations using the menus.
- ffc script Save_Point{
- void run(int station_number){
- bool pressed;
- int choice;
- if(station_number==START_SAVE_POINT){
- if(Screen->D[station_number]==0){
- SaveGame(station_number);
- SaveDMap();
- Screen->D[station_number]=1;
- }
- }
- while ( true ) {
- while ( !pressed && !Tango_MenuIsActive() ) {
- if (LinkCollision(this)){
- if ( PressExamine() ) {
- pressed = true;
- DampButton(BUTTON_EX1);
- }
- DampButton(BUTTON_EX3);
- DampButton(BUTTON_EX4);
- }
- Waitframe();
- }
- if ( pressed ) {
- pressed = false;
- //Set coordinates for this station:
- choice = SavePointMenu(station_number);
- }
- Waitframe(); //Main while loop.
- }
- }
- }
- //Menu called by the save station ffc.
- int SavePointMenu(int station_id) {
- int lineBreak[]="@26";
- int line1[]="@choice(1)Save@26";
- int line2[]="@choice(2)Save and Quit@26";
- int line3[]="@choice(3)Cancel";
- int initmenu[]="@domenu(1)@suspend()";
- if ( station_id ) {
- SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_1, 32, 16, SIZE_SMALL);
- Tango_LoadString(WINDOW_SLOT_1, line1);
- Tango_AppendString(WINDOW_SLOT_1, line2);
- Tango_AppendString(WINDOW_SLOT_1, line3);
- Tango_AppendString(WINDOW_SLOT_1, initmenu);
- Tango_ActivateSlot(WINDOW_SLOT_1);
- }
- while(!Tango_MenuIsActive())
- Waitframe();
- // Save the state again...
- int slotState[278];
- int menuState[960];
- int cursorPos;
- Tango_SaveSlotState(WINDOW_SLOT_1, slotState);
- Tango_SaveMenuState(menuState);
- int done = 0;
- int choice;
- while(true){
- while( Tango_MenuIsActive() ) {
- cursorPos=Tango_GetMenuCursorPosition();
- Link->Jump=0;
- Waitframe();
- }
- choice = Tango_GetLastMenuChoice();
- if ( choice == 1) { // Save the game
- SaveGame(station_id);
- SaveDMap();
- Game->PlaySound(SFX_SAVE_SUCCESS);
- int text[]="Game Saved";
- Tango_ClearSlot(2);
- ShowString(text, WINDOW_SLOT_2, WINDOW_STYLE_2, 48, 32);
- done = -9999;
- }
- else if ( choice == 2 ) { //Save and quit
- Game->PlaySound(SFX_SAVE_SUCCESS);
- SaveDMap();
- SaveGameAndQuit(station_id);
- done = choice;
- }
- else if ( choice == 3)//Cancel
- done = -9999;
- if ( done )
- break;
- // return choice;
- else {
- Tango_RestoreSlotState(WINDOW_SLOT_1, slotState);
- Tango_RestoreMenuState(menuState);
- Tango_SetMenuCursorPosition(cursorPos);
- }
- }
- Tango_ClearSlot(WINDOW_SLOT_1);
- return done;
- }
- //Saves DMap and Screen Data to array.
- void SaveDMap(){
- if(DestinyVars[CURRENT_OVERWORLD]==LABRYNNA_OVERWORLD){
- DestinyVars[SAVE_X_LABRYNNA]= Link->X;
- DestinyVars[SAVE_Y_LABRYNNA]= Link->Y;
- DestinyVars[SAVE_DMAP_LABRYNNA] = Game->GetCurDMap();
- DestinyVars[SAVE_SCREEN_LABRYNNA] = Game->GetCurDMapScreen();
- }
- else if(DestinyVars[CURRENT_OVERWORLD]==MIRROR_OVERWORLD){
- DestinyVars[SAVE_X_MIRROR] = Link->X;
- DestinyVars[SAVE_Y_MIRROR] = Link->Y;
- DestinyVars[SAVE_DMAP_MIRROR] = Game->GetCurDMap();
- DestinyVars[SAVE_SCREEN_MIRROR] = Game->GetCurDMapScreen();
- }
- }
- //Saving the game automation.
- void SaveGame(int station_id){
- SetGameSavePoint(station_id);
- Game->Save();
- }
- //Save and quit automation.
- void SaveGameAndQuit(int station_id){
- SetGameSavePoint(station_id);
- Game->Save();
- Game->End();
- }
- void SetStyleSize(int style, int size)
- {
- if(size==SIZE_SMALL)
- {
- Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, 5);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 59380);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 10);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 3);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 160);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 48);
- //Tango_SetStyleAttribute(style, TANGO_STYLE_FLAGS, TANGO_FLAG_FREEZE_SCREEN);
- }
- else if (size==SIZE_MEDIUM)
- {
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 59280);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 10);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 5);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 160);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 80);
- //Tango_SetStyleAttribute(style, TANGO_STYLE_FLAGS, TANGO_FLAG_FREEZE_SCREEN);
- }
- else if(size == SIZE_LARGE)
- {
- Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, 5);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 59280);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 8);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 6);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 112);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 96);
- //Tango_SetStyleAttribute(style, TANGO_STYLE_FLAGS, TANGO_FLAG_FREEZE_SCREEN);
- }
- else if(size == SIZE_WIDE){
- Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, 5);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 52260);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 11);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 3);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 176);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 48);
- }
- else if(size == SIZE_TALL){
- Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, 5);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 52260);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 11);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 6);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 176);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 80);
- }
- else{
- Tango_SetStyleAttribute(style, TANGO_STYLE_MENU_CURSOR_MOVE_SFX, 5);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_TILE, 52360);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_WIDTH, 10);
- Tango_SetStyleAttribute(style, TANGO_STYLE_BACKDROP_HEIGHT, 3);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_WIDTH, 160);
- Tango_SetStyleAttribute(style, TANGO_STYLE_TEXT_HEIGHT, 80);
- }
- }
- //Tango Menu Init
- void SetUpWindow(int slot, int style, int x, int y, int size)
- {
- SetStyleSize(style, size);
- Tango_ClearSlot(slot);
- Tango_SetSlotStyle(slot, style);
- Tango_SetSlotPosition(slot, x, y);
- }
- //Quick way to drop a string into a Tango dialogue box.
- void ShowString(int string, int slot, int style, int x, int y)
- {
- SetUpWindow(slot, style, x, y, SIZE_SMALL);
- Tango_LoadString(slot, string);
- Tango_ActivateSlot(slot);
- while(Tango_SlotIsActive(slot))
- Waitframe();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement