PRINCE: code convention cleanup

This commit is contained in:
Kamil Zbróg 2013-10-13 22:36:21 +01:00
parent 71f8ce0894
commit 30ad6df5fc
4 changed files with 25 additions and 47 deletions

View File

@ -31,36 +31,30 @@
namespace Prince {
Font::Font()
{
Font::Font() {
}
Font::~Font()
{
Font::~Font() {
delete _fontData;
}
bool Font::load(Common::SeekableReadStream &stream)
{
bool Font::load(Common::SeekableReadStream &stream) {
stream.seek(0);
_fontData = new byte[stream.size()];
stream.read(_fontData, stream.size());
return true;
}
int Font::getFontHeight() const
{
int Font::getFontHeight() const {
debug("Font::getFontHeight %d", _fontData[5]);
return _fontData[5];
}
int Font::getMaxCharWidth() const
{
int Font::getMaxCharWidth() const {
return 0;
}
Font::ChrData Font::getChrData(byte chr) const
{
Font::ChrData Font::getChrData(byte chr) const {
chr -= 32;
uint16 chrOffset = 4*chr+6;
@ -72,13 +66,11 @@ Font::ChrData Font::getChrData(byte chr) const
return chrData;
}
int Font::getCharWidth(byte chr) const
{
int Font::getCharWidth(byte chr) const {
return getChrData(chr)._width;
}
void Font::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) const
{
void Font::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) const {
const ChrData chrData = getChrData(chr);
const byte *src = chrData._pixels;
byte *target = (byte *)dst->getBasePtr(x, y);
@ -88,7 +80,6 @@ void Font::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color
src += chrData._width;
target += dst->pitch;
}
}
}

View File

@ -6,28 +6,24 @@
namespace Prince {
GraphicsMan::GraphicsMan(PrinceEngine *vm) : _vm(vm), _changed(false)
{
GraphicsMan::GraphicsMan(PrinceEngine *vm)
: _vm(vm), _changed(false) {
initGraphics(640, 480, true);
}
void GraphicsMan::update()
{
if (_changed)
{
void GraphicsMan::update() {
if (_changed) {
_vm->_system->copyRectToScreen((byte*)_roomBackground->getBasePtr(0,0), 640, 0, 0, 640, 480);
_vm->_system->updateScreen();
}
}
void GraphicsMan::setPalette(const byte *palette)
{
void GraphicsMan::setPalette(const byte *palette) {
_vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
}
void GraphicsMan::change()
{
void GraphicsMan::change() {
_changed = true;
}

View File

@ -28,19 +28,16 @@
namespace Prince {
MhwanhDecoder::MhwanhDecoder() : _surface(0), _palette(0), _paletteColorCount(0)
{
MhwanhDecoder::MhwanhDecoder()
: _surface(0), _palette(0), _paletteColorCount(0) {
}
MhwanhDecoder::~MhwanhDecoder()
{
MhwanhDecoder::~MhwanhDecoder() {
destroy();
}
void MhwanhDecoder::destroy()
{
if (_surface)
{
void MhwanhDecoder::destroy() {
if (_surface) {
_surface->free();
_surface = 0;
}
@ -49,8 +46,7 @@ void MhwanhDecoder::destroy()
_paletteColorCount = 0;
}
bool MhwanhDecoder::loadStream(Common::SeekableReadStream &stream)
{
bool MhwanhDecoder::loadStream(Common::SeekableReadStream &stream) {
_paletteColorCount = 256;
stream.seek(0);
stream.skip(0x20);
@ -64,8 +60,7 @@ bool MhwanhDecoder::loadStream(Common::SeekableReadStream &stream)
_surface = new Graphics::Surface();
_surface->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
for (int h = 0; h < 480; ++h)
{
for (int h = 0; h < 480; ++h) {
stream.read(_surface->getBasePtr(0, h - 1), 640);
}

View File

@ -79,8 +79,7 @@ Common::Error PrinceEngine::run() {
return Common::kPathNotFile;
Font font1 = Font();
if (font1.load(*font1stream))
{
if (font1.load(*font1stream)) {
font1.getCharWidth(103);
}
delete font1stream;
@ -90,8 +89,7 @@ Common::Error PrinceEngine::run() {
//_frontScreen = new Graphics::Surface();
//_frontScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
if (room)
{
if (room) {
Graphics::BitmapDecoder roomBmp;
roomBmp.loadStream(*room);
//_roomBackground = roomBmp.getSurface();
@ -100,11 +98,9 @@ Common::Error PrinceEngine::run() {
//font1.drawString(_frontScreen, "Hello World", 10, 10, 640, 1);
MhwanhDecoder walizkaBmp;
if (walizka)
{
if (walizka) {
debug("Loading walizka");
if (walizkaBmp.loadStream(*walizka))
{
if (walizkaBmp.loadStream(*walizka)) {
_graph->_roomBackground = walizkaBmp.getSurface();
_graph->setPalette(walizkaBmp.getPalette());
}