!--------------------------------------------------------------------------- 
!  Movie.H              An Inform 6.0 library to put non-interactive  
!   Version 3           "cut scenes" into a game.  By L. Ross Raszewski 
!                       Requires utility.h and the altmenu suite
!                       (altmenu.h, domenu.h)
!
! (major revision, with object-orientation, v6 friendliness, no globals,
!  and use of new domenu features)
!
! I know what you're thinking.  You're thinking, "non-interactive cut scenes"? 
! What would I want a thing like that for?  Well, It may at times be useful, 
! or at least novel, to have the player suddenly be stopped and watch a sort  
! of anecdote.  It could be used for an introduction, and endgame, or a  
! flashback.  The player may, if they wish, choose not to view movies  
! automatically.  This library allows players to review movies they have  
! already seen. 
!
! Usage:
! Moviesystem.play(movie name);
! Call moviesystem.Play(movie,1) if you want the movie to play regardless of  
! autoplay and replay settings!) 
!
! Movies are provided as members of the "movie" class.  these will be moved
! into the moviesystem object when they are played. movies in the "moviesystem"
! object will appear on the movie menu. (you can move separators to the menu,
! for example, to denote section breaks)
! The first time a call to Play a Movie is made, if you have a footnote 
! library installed (especially mine) define the constant MovieNote with a  
! value equal to one of your footnotes, and that footnote will be called. 
! (To alert players to the fact that they can watch movies later). 
! If the moviesystem does not have the "on" attribute, movies will not
! be shown, but
! a message will alert players to the fact that one is being played.   
! If the propery .replay of the system is set to 0, the movie will
! only play the first
! time it is callled, and the alert message will be shown all subsequent  
! times.  
!
! The "movie" proper should be handled by the description property of the
! movie-class item.
! 
! Typing "Movie" will bring up the movie menu.  The names of viewed movies will 
! appear in the same order as the player saw them, and the player can view his  
! choice of movie.  "Movie On" and "Movie Off" will enable and disable movie  
! autoplaying. (A verb to change the replay mode is "left as an exercise to the 
! reader") 
! 
! 
! Questions, Comments, bugs, e-mail me at rraszews@acm.org



Class movie
        class Option,
        with play [; self.description(); ];

Menu MovieSystem "Movies"
 with play [ movie flag flg i;
              self.mtbp=movie;
              #IFDEF MovieNote;
               if (self hasnt general) { Note(MovieNote); 
                        new_line; give self general;}
              #ENDIF;

              if (flag ~= 1 &&(self hasnt on || (movie in self && self.replay==0)))
              {
               style underline; print "^^[Movie: ", (name) Movie, "]^^";
               style roman; 
               if (movie notin self) pmove(movie, self);
              rtrue;
              }
              if (flg==0) {
                WaitForKey("^^^Press [SPACE]");
                @erase_window -1;
               }

    #ifdef V6DEFS_H;
    i = StatusWin.GetCharHeight();
    @split_window i;
    #ifnot;
    @split_window 1;
    #endif;
    i = 0->33; if (i==0) i=80;
    #ifndef V6DEFS_H;
    @set_window 1;
    LocateCursor(1,1);
    style reverse; spaces(i);
    #ifnot;
    StatusWin.Activate();
    LocateCursor(1,1);
    StatusWin.SetColours(MainWin.GetBGColour(),
                         MainWin.GetFGColour());
    StatusWin.Erase();
    #endif;
              CenterU(self.pmtitle,1);
              style roman;
              #ifdef V6DEFS_H;
              Mainwin.activate();
              #ifnot;
              @set_window 0;
              #endif;
              new_line; new_line;
              movie.play();
              if (flg==0){
                WaitForKey("^^^Press [SPACE]"); 
                @erase_window -1;
                Drawstatusline();
              }
              if (movie notin self) Pmove(movie, self);
              new_line; new_line; new_line;
            ],
            mtbp 0,
            banner_tags "N=Next" PKEY__TX RKEY__TX QKEY1__TX QKEY2__TX 12 17,
            pmtitle [; print (name) self.mtbp;],
            replay 1,
            has on;

[ MovieMenuSub;
        MovieSystem.select();
];
[ TurnOffMSub;
  give MovieSystem ~on;
  "[Movie autoplay disabled.]";
];
[ TurnOnMSub;
  give MovieSystem on;
  "[Movie autoplay enabled.]";
];

verb meta "movies" "movie" *            -> MovieMenu
                        * "off"         -> TurnOffM
                        * "on"          -> TurnOnM;

#Ifdef DEBUG;
[ PlayFilmSub;
        if (noun ofclass movie)
        MovieSystem.play(noun);
        ];
[ Films x;
        objectloop (x ofclass Movie) { PlaceInScope(x);};
];
Extend "movie"          * scope=Films -> PlayFilm;
#EndIf;

