2006-04-02 14:20:45 +00:00
|
|
|
/* Residual - Virtual machine to run LucasArts' 3D adventure games
|
|
|
|
* Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
2005-04-07 19:29:06 +00:00
|
|
|
|
2005-04-08 09:33:21 +00:00
|
|
|
#include "stdafx.h"
|
2005-04-07 19:29:06 +00:00
|
|
|
#include "debug.h"
|
|
|
|
#include "font.h"
|
|
|
|
#include "color.h"
|
|
|
|
#include "driver.h"
|
|
|
|
#include "primitives.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
PrimitiveObject::PrimitiveObject() {
|
|
|
|
_x1 = 0;
|
|
|
|
_y1 = 0;
|
|
|
|
_x2 = 0;
|
|
|
|
_y2 = 0;
|
|
|
|
_color._vals[0] = 0;
|
|
|
|
_color._vals[1] = 0;
|
|
|
|
_color._vals[2] = 0;
|
|
|
|
_filled = false;
|
|
|
|
_type = 0;
|
2005-04-08 11:16:57 +00:00
|
|
|
_bitmap = NULL;
|
2005-04-07 19:29:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PrimitiveObject::~PrimitiveObject() {
|
2005-04-08 11:16:57 +00:00
|
|
|
if (_type == 2)
|
|
|
|
g_driver->destroyBitmap(_bitmap);
|
2005-04-07 19:29:06 +00:00
|
|
|
}
|
|
|
|
|
2005-04-08 09:33:21 +00:00
|
|
|
void PrimitiveObject::createRectangle(int x1, int x2, int y1, int y2, Color color, bool filled) {
|
2005-04-07 19:29:06 +00:00
|
|
|
_x1 = x1;
|
|
|
|
_y1 = y1;
|
|
|
|
_x2 = x2;
|
|
|
|
_y2 = y2;
|
|
|
|
_color = color;
|
|
|
|
_filled = filled;
|
|
|
|
_type = 1;
|
|
|
|
}
|
|
|
|
|
2005-08-10 08:33:45 +00:00
|
|
|
void PrimitiveObject::createBitmap(Bitmap *bitmap, int x, int y, bool /*transparent*/) {
|
2005-04-08 11:16:57 +00:00
|
|
|
_type = 2;
|
|
|
|
_bitmap = bitmap;
|
|
|
|
_bitmap->setX(x);
|
|
|
|
_bitmap->setY(y);
|
|
|
|
// transparent: what to do ?
|
|
|
|
g_driver->createBitmap(_bitmap);
|
|
|
|
}
|
|
|
|
|
2005-05-05 21:23:17 +00:00
|
|
|
void PrimitiveObject::createLine(int x1, int x2, int y1, int y2, Color color) {
|
|
|
|
_x1 = x1;
|
|
|
|
_y1 = y1;
|
|
|
|
_x2 = x2;
|
|
|
|
_y2 = y2;
|
|
|
|
_color = color;
|
|
|
|
_type = 3;
|
|
|
|
}
|
|
|
|
|
2005-04-07 19:29:06 +00:00
|
|
|
void PrimitiveObject::draw() {
|
|
|
|
assert(_type);
|
|
|
|
|
|
|
|
if (_type == 1)
|
|
|
|
g_driver->drawRectangle(this);
|
2005-04-08 11:16:57 +00:00
|
|
|
else if (_type == 2)
|
|
|
|
g_driver->drawBitmap(_bitmap);
|
2005-05-05 21:23:17 +00:00
|
|
|
else if (_type == 3)
|
|
|
|
g_driver->drawLine(this);
|
2005-04-07 19:29:06 +00:00
|
|
|
}
|