Initial commit
This commit is contained in:
73
engines/bagel/hodjnpodj/gfx/bold_font.cpp
Normal file
73
engines/bagel/hodjnpodj/gfx/bold_font.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/gfx/bold_font.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Gfx {
|
||||
|
||||
BoldFont::~BoldFont() {
|
||||
if (_disposeAfterUse == DisposeAfterUse::YES)
|
||||
delete _font;
|
||||
}
|
||||
|
||||
int BoldFont::getFontHeight() const {
|
||||
return _font->getFontHeight();
|
||||
}
|
||||
|
||||
int BoldFont::getFontAscent() const {
|
||||
return _font->getFontAscent();
|
||||
}
|
||||
|
||||
int BoldFont::getFontDescent() const {
|
||||
return _font->getFontDescent();
|
||||
}
|
||||
|
||||
int BoldFont::getFontLeading() const {
|
||||
return _font->getFontLeading();
|
||||
}
|
||||
|
||||
int BoldFont::getMaxCharWidth() const {
|
||||
return _font->getMaxCharWidth() + 1;
|
||||
}
|
||||
|
||||
int BoldFont::getCharWidth(uint32 chr) const {
|
||||
return _font->getCharWidth(chr) + 1;
|
||||
}
|
||||
|
||||
int BoldFont::getKerningOffset(uint32 left, uint32 right) const {
|
||||
return _font->getKerningOffset(left, right);
|
||||
}
|
||||
|
||||
void BoldFont::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const {
|
||||
_font->drawChar(dst, chr, x, y, color);
|
||||
_font->drawChar(dst, chr, x + 1, y, color);
|
||||
}
|
||||
|
||||
void BoldFont::drawChar(Graphics::ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const {
|
||||
_font->drawChar(dst, chr, x, y, color);
|
||||
_font->drawChar(dst, chr, x + 1, y, color);
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
60
engines/bagel/hodjnpodj/gfx/bold_font.h
Normal file
60
engines/bagel/hodjnpodj/gfx/bold_font.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_BOLD_FONT_H
|
||||
#define HODJNPODJ_BOLD_FONT_H
|
||||
|
||||
#include "common/types.h"
|
||||
#include "graphics/font.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
namespace Gfx {
|
||||
|
||||
class BoldFont : public Graphics::Font {
|
||||
private:
|
||||
Graphics::Font *_font;
|
||||
DisposeAfterUse::Flag _disposeAfterUse =
|
||||
DisposeAfterUse::YES;
|
||||
|
||||
public:
|
||||
BoldFont(Graphics::Font *font, DisposeAfterUse::Flag
|
||||
disposeAfterUse = DisposeAfterUse::YES) :
|
||||
_font(font), _disposeAfterUse(disposeAfterUse) {
|
||||
}
|
||||
~BoldFont() override;
|
||||
|
||||
int getFontHeight() const override;
|
||||
int getFontAscent() const override;
|
||||
int getFontDescent() const override;
|
||||
int getFontLeading() const override;
|
||||
int getMaxCharWidth() const override;
|
||||
int getCharWidth(uint32 chr) const override;
|
||||
int getKerningOffset(uint32 left, uint32 right) const override;
|
||||
void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
|
||||
void drawChar(Graphics::ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const override;
|
||||
};
|
||||
|
||||
} // namespace Gfx
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
75
engines/bagel/hodjnpodj/gfx/palette.cpp
Normal file
75
engines/bagel/hodjnpodj/gfx/palette.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/system.h"
|
||||
#include "common/file.h"
|
||||
#include "image/bmp.h"
|
||||
#include "graphics/paletteman.h"
|
||||
#include "bagel/hodjnpodj/gfx/palette.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
Palette::Palette() {
|
||||
}
|
||||
|
||||
void Palette::loadInitialPalette() {
|
||||
Common::File f;
|
||||
Image::BitmapDecoder decoder;
|
||||
const char *FILENAME = "meta/art/mlscroll.bmp";
|
||||
|
||||
if (!f.open(FILENAME) || !decoder.loadStream(f))
|
||||
error("Error loading - %s", FILENAME);
|
||||
|
||||
loadPalette(decoder.getPalette());
|
||||
}
|
||||
|
||||
void Palette::setPalette(const byte *palette) {
|
||||
g_system->getPaletteManager()->setPalette(palette, 0, Graphics::PALETTE_COUNT);
|
||||
}
|
||||
|
||||
void Palette::setPalette(const Graphics::Palette &palette) {
|
||||
g_system->getPaletteManager()->setPalette(palette);
|
||||
}
|
||||
|
||||
Graphics::Palette Palette::getPalette() const {
|
||||
return g_system->getPaletteManager()->grabPalette(0, Graphics::PALETTE_COUNT);
|
||||
}
|
||||
|
||||
void Palette::loadPalette(const byte *palette) {
|
||||
_gamePalette = Graphics::Palette(palette, Graphics::PALETTE_COUNT);
|
||||
setPalette(_gamePalette);
|
||||
}
|
||||
|
||||
void Palette::loadPalette(const Graphics::Palette &palette) {
|
||||
_gamePalette = palette;
|
||||
setPalette(_gamePalette);
|
||||
}
|
||||
|
||||
byte Palette::getPaletteIndex(uint32 color) const {
|
||||
byte r = color & 0xff;
|
||||
byte g = (color >> 8) & 0xff;
|
||||
byte b = (color >> 16) & 0xff;
|
||||
return _gamePalette.findBestColor(r, g, b);
|
||||
}
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
75
engines/bagel/hodjnpodj/gfx/palette.h
Normal file
75
engines/bagel/hodjnpodj/gfx/palette.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HODJNPODJ_GFX_PALETTE_H
|
||||
#define HODJNPODJ_GFX_PALETTE_H
|
||||
|
||||
#include "graphics/palette.h"
|
||||
#include "bagel/boflib/palette.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
constexpr byte BLACK = 0;
|
||||
constexpr byte WHITE = 255;
|
||||
#define RED PALETTERGB(255, 0, 255)
|
||||
#define BLUE PALETTERGB(0, 0, 255)
|
||||
#define CYAN PALETTERGB(0, 255, 255)
|
||||
#define PURPLE PALETTERGB(0x80, 0, 0x80)
|
||||
|
||||
class Palette {
|
||||
private:
|
||||
Graphics::Palette _gamePalette;
|
||||
|
||||
protected:
|
||||
void loadInitialPalette();
|
||||
|
||||
public:
|
||||
Palette();
|
||||
virtual ~Palette() {}
|
||||
|
||||
/**
|
||||
* Set the palette to use, without changing _gamePalette
|
||||
*/
|
||||
virtual void setPalette(const byte *palette);
|
||||
virtual void setPalette(const Graphics::Palette &palette);
|
||||
|
||||
/**
|
||||
* Gets the currently active palette
|
||||
*/
|
||||
virtual Graphics::Palette getPalette() const;
|
||||
|
||||
/**
|
||||
* Set the palette to use, saving it in the internal _gamePalette
|
||||
*/
|
||||
virtual void loadPalette(const byte *palette);
|
||||
virtual void loadPalette(const Graphics::Palette &palette);
|
||||
|
||||
/**
|
||||
* Gets the closest palette index to a given rgb color
|
||||
*/
|
||||
virtual byte getPaletteIndex(uint32 color) const;
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user