2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
* 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 2
|
|
|
|
* 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
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2004-04-12 21:40:49 +00:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2006-02-11 12:44:16 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 07:32:48 +00:00
|
|
|
// Graphics maniuplation routines - private header file
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-02-19 17:30:43 +00:00
|
|
|
#ifndef SAGA_GFX_H
|
|
|
|
#define SAGA_GFX_H
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-06-23 20:20:27 +00:00
|
|
|
#include "graphics/surface.h"
|
2004-10-30 22:13:48 +00:00
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
namespace Saga {
|
|
|
|
|
2004-10-04 23:09:38 +00:00
|
|
|
using Common::Point;
|
|
|
|
using Common::Rect;
|
2004-08-03 00:40:16 +00:00
|
|
|
|
2005-10-09 19:10:59 +00:00
|
|
|
enum CursorType {
|
|
|
|
kCursorNormal,
|
|
|
|
kCursorBusy
|
|
|
|
};
|
|
|
|
|
2005-07-08 16:56:03 +00:00
|
|
|
struct ClipData {
|
2004-08-01 11:48:53 +00:00
|
|
|
// input members
|
2005-07-08 16:56:03 +00:00
|
|
|
Rect sourceRect;
|
|
|
|
Rect destRect;
|
|
|
|
Point destPoint;
|
2004-08-01 11:48:53 +00:00
|
|
|
|
|
|
|
// output members
|
2005-07-09 16:23:45 +00:00
|
|
|
Point drawSource;
|
|
|
|
Point drawDest;
|
|
|
|
int drawWidth;
|
|
|
|
int drawHeight;
|
2005-07-08 16:56:03 +00:00
|
|
|
|
|
|
|
bool calcClip() {
|
|
|
|
Common::Rect s;
|
|
|
|
|
|
|
|
// Adjust the rect to draw to its screen coordinates
|
|
|
|
s = sourceRect;
|
|
|
|
s.left += destPoint.x;
|
|
|
|
s.right += destPoint.x;
|
|
|
|
s.top += destPoint.y;
|
|
|
|
s.bottom += destPoint.y;
|
|
|
|
|
|
|
|
s.clip(destRect);
|
|
|
|
|
|
|
|
if ((s.width() <= 0) || (s.height() <= 0)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
drawSource.x = s.left - sourceRect.left - destPoint.x;
|
|
|
|
drawSource.y = s.top - sourceRect.top - destPoint.y;
|
|
|
|
drawDest.x = s.left;
|
|
|
|
drawDest.y = s.top;
|
|
|
|
drawWidth = s.width();
|
|
|
|
drawHeight = s.height();
|
2005-07-08 16:56:03 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2005-07-10 14:39:04 +00:00
|
|
|
};
|
2004-08-01 11:48:53 +00:00
|
|
|
|
2006-07-23 16:13:26 +00:00
|
|
|
#include "common/pack-start.h" // START STRUCT PACKING
|
2006-07-09 13:01:15 +00:00
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
struct PalEntry {
|
2004-08-01 11:48:53 +00:00
|
|
|
byte red;
|
|
|
|
byte green;
|
|
|
|
byte blue;
|
2007-07-01 18:18:43 +00:00
|
|
|
} PACKED_STRUCT;
|
2004-08-01 11:48:53 +00:00
|
|
|
|
2006-07-23 16:13:26 +00:00
|
|
|
#include "common/pack-end.h" // END STRUCT PACKING
|
2005-07-10 15:23:36 +00:00
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
struct Color {
|
2004-08-01 11:48:53 +00:00
|
|
|
int red;
|
|
|
|
int green;
|
|
|
|
int blue;
|
|
|
|
int alpha;
|
2005-07-10 15:23:36 +00:00
|
|
|
};
|
2004-08-01 11:48:53 +00:00
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
struct Surface : Graphics::Surface {
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-07-09 17:11:41 +00:00
|
|
|
void transitionDissolve(const byte *sourceBuffer, const Common::Rect &sourceRect, int flags, double percent);
|
2005-07-09 16:23:45 +00:00
|
|
|
void drawPalette();
|
|
|
|
void drawPolyLine(const Point *points, int count, int color);
|
|
|
|
void blit(const Common::Rect &destRect, const byte *sourceBuffer);
|
|
|
|
|
|
|
|
void getRect(Common::Rect &rect) {
|
|
|
|
rect.left = rect.top = 0;
|
|
|
|
rect.right = w;
|
|
|
|
rect.bottom = h;
|
|
|
|
}
|
|
|
|
void drawFrame(const Common::Point &p1, const Common::Point &p2, int color) {
|
|
|
|
Common::Rect rect(MIN(p1.x, p2.x), MIN(p1.y, p2.y), MAX(p1.x, p2.x) + 1, MAX(p1.y, p2.y) + 1);
|
|
|
|
frameRect(rect, color);
|
|
|
|
}
|
|
|
|
void drawRect(const Common::Rect &destRect, int color) {
|
|
|
|
Common::Rect rect(w , h);
|
|
|
|
rect.clip(destRect);
|
|
|
|
|
|
|
|
if (rect.isValidRect()) {
|
|
|
|
fillRect(rect, color);
|
2005-07-30 21:11:48 +00:00
|
|
|
}
|
2005-07-09 16:23:45 +00:00
|
|
|
}
|
2004-08-01 11:48:53 +00:00
|
|
|
};
|
2005-07-09 16:23:45 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
#define PAL_ENTRIES 256
|
2004-08-01 11:48:53 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
#define CURSOR_W 7
|
|
|
|
#define CURSOR_H 7
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
#define CURSOR_ORIGIN_X 4
|
|
|
|
#define CURSOR_ORIGIN_Y 4
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-30 22:34:08 +00:00
|
|
|
bool hitTestPoly(const Point *points, unsigned int npoints, const Point& test_point);
|
2005-07-19 19:05:52 +00:00
|
|
|
class SagaEngine;
|
2004-10-30 22:34:08 +00:00
|
|
|
|
2004-08-01 11:48:53 +00:00
|
|
|
class Gfx {
|
|
|
|
public:
|
|
|
|
|
2006-04-15 20:36:41 +00:00
|
|
|
Gfx(SagaEngine *vm, OSystem *system, int width, int height);
|
2005-07-09 16:23:45 +00:00
|
|
|
~Gfx();
|
|
|
|
Surface *getBackBuffer() {
|
|
|
|
return &_backBuffer;
|
|
|
|
}
|
|
|
|
|
2005-10-05 01:31:46 +00:00
|
|
|
void initPalette();
|
2005-10-05 01:40:55 +00:00
|
|
|
void setPalette(const PalEntry *pal, bool full = false);
|
2005-10-04 17:44:41 +00:00
|
|
|
void setPaletteColor(int n, int r, int g, int b);
|
2005-07-09 16:23:45 +00:00
|
|
|
void getCurrentPal(PalEntry *src_pal);
|
2007-06-11 02:30:04 +00:00
|
|
|
void savePalette() { getCurrentPal(_savedPalette); }
|
|
|
|
void restorePalette() { setPalette(_savedPalette, true); }
|
2005-10-05 01:40:55 +00:00
|
|
|
void palToBlack(PalEntry *src_pal, double percent);
|
|
|
|
void blackToPal(PalEntry *src_pal, double percent);
|
2007-08-23 13:56:25 +00:00
|
|
|
void palFade(PalEntry *srcPal, int16 from, int16 to, int16 start, int16 numColors, double percent);
|
2004-11-20 00:05:50 +00:00
|
|
|
void showCursor(bool state);
|
2007-05-06 22:18:31 +00:00
|
|
|
void setCursor(CursorType cursorType = kCursorNormal);
|
2004-10-08 01:22:39 +00:00
|
|
|
|
2004-08-01 11:48:53 +00:00
|
|
|
private:
|
2004-08-02 11:27:50 +00:00
|
|
|
int _init;
|
2005-07-09 16:23:45 +00:00
|
|
|
Surface _backBuffer;
|
|
|
|
byte _currentPal[PAL_ENTRIES * 4];
|
2004-08-02 11:27:50 +00:00
|
|
|
OSystem *_system;
|
2005-07-19 19:05:52 +00:00
|
|
|
SagaEngine *_vm;
|
2005-10-05 01:31:46 +00:00
|
|
|
|
|
|
|
PalEntry _globalPalette[PAL_ENTRIES];
|
2007-06-11 02:30:04 +00:00
|
|
|
PalEntry _savedPalette[PAL_ENTRIES];
|
2004-08-01 11:48:53 +00:00
|
|
|
};
|
2004-05-02 16:32:28 +00:00
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
} // End of namespace Saga
|
|
|
|
|
2004-05-01 07:32:48 +00:00
|
|
|
#endif
|