1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* aint32 with this program; if not, write to the Free Software
*
*
* Based on the original sources
* Faery Tale II -- The Halls of the Dead
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
#include "saga2/saga2.h"
#include "saga2/videobox.h"
#include "saga2/vpal.h"
namespace Saga2 {
// imports
extern BackWindow *mainWindow;
/* ===================================================================== *
CVideoBox: Methods
* ===================================================================== */
CVideoBox::CVideoBox(const Rect16 &box,
uint16 ident,
AppFunc *cmd) : ModalWindow(box, ident, cmd) {
// set the size of the window panes
_vidPanRects[0] = Rect16(kVBx, kVBy, kVBxBrushSize, kVByBrushSize);
_vidPanRects[1] = Rect16(kVBx, kVBy + kVByBrushSize, kVBxBrushSize, kVByBrushSize);
// options dialog window decorations
_vidDec[0].set(_vidPanRects[0], kVBvidPan1ResID);
_vidDec[1].set(_vidPanRects[1], kVBvidPan2ResID);
// null out the _decRes pointer
_decRes = nullptr;
_rInfo.result = -1;
_rInfo.running = false;
}
CVideoBox::~CVideoBox() {
// remove the resource handle
if (_decRes)
resFile->disposeContext(_decRes);
_decRes = nullptr;
// stop video if not done
g_vm->abortVideo();
}
void CVideoBox::deactivate() {
_selected = 0;
gPanel::deactivate();
}
bool CVideoBox::activate(gEventType why) {
if (why == kEventMouseDown) { // momentarily depress
_selected = 1;
notify(why, 0); // notify App of successful hit
return true;
}
return false;
}
void CVideoBox::pointerMove(gPanelMessage &) {
notify(kEventMouseMove, 0);
}
bool CVideoBox::pointerHit(gPanelMessage &) {
// mouse hit detected, close video box
gWindow *win;
requestInfo *ri;
win = getWindow(); // get the window pointer
ri = win ? (requestInfo *)win->_userData : nullptr;
if (ri) {
ri->running = 0;
ri->result = _id;
}
activate(kEventMouseDown);
return true;
}
void CVideoBox::pointerDrag(gPanelMessage &) {
if (_selected) {
notify(kEventMouseDrag, 0);
}
}
void CVideoBox::pointerRelease(gPanelMessage &) {
if (_selected) notify(kEventMouseUp, 0); // notify App of successful hit
deactivate();
}
void CVideoBox::drawClipped(
gPort &port,
const Point16 &offset,
const Rect16 &clipRect) {
g_vm->_pointer->hide();
ModalWindow::drawClipped(port, offset, clipRect);
g_vm->_pointer->show();
}
void CVideoBox::draw() { // redraw the window
// draw the decoration stuff
drawClipped(g_vm->_mainPort, Point16(0, 0), _extent);
}
void CVideoBox::init() {
assert(resFile);
// set the result info to nominal startup values
_rInfo.result = -1;
_rInfo.running = true;
// init the resource context handle
_decRes = resFile->newContext(MKTAG('V', 'I', 'D', 'O'),
"Video border resources");
// get the decorations for this window
setDecorations(_vidDec,
ARRAYSIZE(_vidDec),
_decRes,
'V', 'B', 'D');
// attach the result info struct to this window
_userData = &_rInfo;
}
int16 CVideoBox::openVidBox(char *fileName) {
// initalize the graphics for this window
init();
// call the rest of the required functionality
ModalWindow::open();
// start the video playback
g_vm->startVideo(fileName, kVBx + kVBborderWidth, kVBy + kVBborderWidth);
// run this modal event loop
//EventLoop( _rInfo.running, true );
_rInfo.running = g_vm->checkVideo();
while (_rInfo.running)
_rInfo.running = g_vm->checkVideo();
// get the result
return _rInfo.result;
}
// this opens a video box for business
int16 openVidBox(char *fileName) {
// get the area of the vid box
Rect16 area = CVideoBox::getAreaRect();
g_vm->_pal->quickSavePalette();
// create a video box
CVideoBox videoBox(area, 0, nullptr);
// open this video box
int16 result = videoBox.openVidBox(fileName);
g_vm->_pal->quickRestorePalette();
// replace the damaged area
mainWindow->invalidate(&area);
// return the result code
return result;
}
} // end of namespace Saga2
|