home *** CD-ROM | disk | FTP | other *** search
- #include <fastgraf.h>
- #include <conio.h>
- #include "pages.h"
- #include "match.h"
- #include "menu.h"
-
- const int PLAY = 1;
- const int HELP = 2;
- const int QUIT = 3;
-
- const int MENU_PATCH_Y = 59;
- const int MENU_PATCH_X = 92;
-
- //class Match;
- //class HelpPage;
-
- MenuItem::MenuItem(Director* d,int m) : Performer(d)
- {
- myimage=m;
- }
-
- void MenuItem::display()
- {
- show_frame(MENU_PATCH_X,MENU_PATCH_Y,myimage);
- }
-
- void MenuItem::initialize()
- {
- load_gfxlib("menu.gfx");
- load_sfxlib("sounds.sfx");
- }
-
- void MenuItem::play_switch_sound()
- {
- play_sound_clip(1);
- }
-
- //---------------------------------------------- MENU -----------
-
- CUELIST(Menu)
- KEYSTROKE(UP,on_up)
- KEYSTROKE(DN,on_down)
- KEYSTROKE('\r',on_enter)
- KEYSTROKE(ESC,on_escape)
- KEYSTROKE('f',on_fight)
- KEYSTROKE('h',on_help)
- KEYSTROKE('q',on_quit)
- ENDCUELIST
-
- Menu::Menu() : VideoDirector()
- {
- item[1]=new MenuItem(this,PLAY);
- item[2]=new MenuItem(this,HELP);
- item[3]=new MenuItem(this,QUIT);
- }
-
- Menu::~Menu()
- {
- delete item[1];
- delete item[2];
- delete item[3];
- }
-
- const Type_info& Menu::get_next_director()
- {
- if (cur==PLAY) return typeid(Match);
- if (cur==HELP) return typeid(HelpPage);
- return typeid(StopDirector);
- }
-
- void Menu::initialize()
- {
- cur=PLAY;
- }
-
- void Menu::display()
- {
- init_video();
- show_pcx("menu.pcx");
- if (cur!=PLAY)
- item[cur]->display();
- swap_video_pages();
- synch_video_pages();
- } //tag
-
- void Menu::on_up(int)
- {
- if (cur>PLAY) cur--;
- else cur=ITEMS;
- item[cur]->display();
- item[cur]->play_switch_sound();
- swap_video_pages();
- }
-
- void Menu::on_down(int)
- {
- if (cur<ITEMS) cur++;
- else cur=PLAY;
- item[cur]->display();
- item[cur]->play_switch_sound();
- swap_video_pages();
- }
-
-
- void Menu::on_fight(int)
- {
- if (cur!=PLAY)
- {
- cur=PLAY;
- item[cur]->display();
- item[cur]->play_switch_sound();
- swap_video_pages();
- }
- }
-
- void Menu::on_help(int)
- {
- if (cur!=HELP)
- {
- cur=HELP;
- item[cur]->display();
- item[cur]->play_switch_sound();
- swap_video_pages();
- }
- }
-
- void Menu::on_quit(int)
- {
- if (cur!=QUIT)
- {
- cur=QUIT;
- item[cur]->display();
- item[cur]->play_switch_sound();
- swap_video_pages();
- }
- }
-
- void Menu::on_enter(int)
- {
- stop_director();
- }
-
- void Menu::on_escape(int)
- {
- cur=QUIT;
- stop_director();
- }
-
-