home *** CD-ROM | disk | FTP | other *** search
- #include <string.h>
- #include "standard.h"
- #include "scenery.h"
- #include "ascii.h"
- #include "theatrix.h"
-
-
- CUELIST(SceneryDirector)
- KEYSTROKE(ESC, on_escape)
- KEYSTROKE(ENTER, on_enter)
- KEYSTROKE(SPACE, on_space)
- ENDCUELIST
-
- SceneryDirector::SceneryDirector(char *scfile, short int trans)
- {
- scenery = scfile;
- mousecursors = 0;
- transition = trans;
- }
-
- void SceneryDirector::display()
- {
- if (scenery != 0) {
- static int inited = 0;
- if (!inited || transition == ClearEveryTime) {
- init_video();
- inited = 1;
- }
- if (transition && transition != ClearEveryTime) {
- fg_setcolor(0);
- fg_fadeout(transition);
- }
- if (!show_pcx(scenery)) {
- char smsg[100] = "Cannot load scenery: ";
- strcat(smsg, scenery);
- Theatrix::fatal(smsg);
- }
- fill_background_buffer(active_page());
- if (transition && transition != ClearEveryTime)
- fg_fadein(transition);
- swap_video_pages();
- synch_video_pages();
- }
- }
-
- const Type_info& SceneryDirector::get_next_director()
- {
- if (next_director_set())
- return VideoDirector::get_next_director();
- return typeid(NextDirector);
- }
-
- inline int inside(int x, int y, int x1, int y1, int x2, int y2)
- {
- return (x >= x1 && x <= x2 && y >= y1 && y <= y2);
- }
-
- void SceneryDirector::refresh_display()
- {
- int mv = mouseinuse;
- if (mv)
- mouse_invisible();
- swap_video_pages();
- synch_video_pages();
- if (mv)
- mouse_visible();
- }
-
- void SceneryDirector::display_original_scenery()
- {
- restore_page();
- refresh_display();
- }
-
- void SceneryDirector::show_mousecursor(char *cursor)
- {
- static int mousevisible = 1;
- if (cursor) {
- mouse_cursorshape(cursor);
- if (!mousevisible) {
- fg_mousevis(1);
- mousevisible = 1;
- }
- }
- else if (mousevisible) {
- fg_mousevis(0);
- mousevisible = 0;
- }
- }
-
- void SceneryDirector::mousemoved(int x, int y, int)
- {
- if (mouseinuse) {
- Mice *mc = mousecursors;
- static char *oldcursorshape = 0;
- while (mc->x1 != -1) {
- if (inside(x,y,mc->x1,mc->y1,mc->x2,mc->y2)) {
- // --- mouse is inside a cursor region
- char *cursor = mc->cursor;
- if (cursor != oldcursorshape) {
- show_mousecursor(cursor);
- oldcursorshape = cursor;
- }
- break;
- }
- mc++;
- }
- if (mc->x1 == -1) {
- // ---- outside of any defined cursor region
- oldcursorshape = DEFAULT;
- show_mousecursor(DEFAULT);
- }
- }
- }
-
- void SceneryDirector::mouseclicked(int x, int y)
- {
- if (mouseinuse) {
- Mice *mc = mousecursors;
- while (mc->x1 != -1) {
- if (inside(x,y,mc->x1,mc->y1,mc->x2,mc->y2)) {
- if (mc->func) {
- // --- button press to be dispatched
- void (Hand::*cf)(int,int);
- Hand *h = (Hand*)this;
- cf=(void(Hand::*)(int,int))(mc->func);
- (h->*cf)(x,y);
- }
- break;
- }
- mc++;
- }
- }
- }
-
- void SceneryDirector::initialize()
- {
- VideoDirector::initialize();
- mousecursors = GetMouseCursors();
- if (mousecursors) {
- request_mousemove_cue((callback)&SceneryDirector::mousemoved);
- request_mouseclick_cue(LEFTMOUSEBUTTON,
- (callback)&SceneryDirector::mouseclicked);
- }
- }
-
-