mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-14 16:07:39 +00:00
GLK: Move _width/_height setting to Conf class
This commit is contained in:
parent
74622a9e6c
commit
a27cadedff
@ -24,7 +24,6 @@
|
||||
#include "glk/utils.h"
|
||||
#include "glk/windows.h"
|
||||
#include "common/config-manager.h"
|
||||
#include "common/system.h"
|
||||
|
||||
namespace Glk {
|
||||
|
||||
@ -64,17 +63,17 @@ WindowStyleStatic G_STYLES[style_NUMSTYLES] = {
|
||||
Conf *g_conf;
|
||||
|
||||
Conf::Conf(InterpreterType interpType) : _interpType(interpType), _graphics(true),
|
||||
_rows(25), _cols(60), _lockRows(0), _lockCols(0), _wPaddingX(0),
|
||||
_wPaddingY(0), _wBorderX(0), _wBorderY(0), _tMarginX(7), _tMarginY(7),
|
||||
_gamma(1.0), _borderColor(0), _borderSave(0),
|
||||
_width(640), _height(400), _screenFormat(2, 5, 6, 5, 0, 11, 5, 0, 0),
|
||||
_rows(25), _cols(60), _lockRows(0), _lockCols(0), _wPaddingX(0), _wPaddingY(0),
|
||||
_wBorderX(0), _wBorderY(0), _tMarginX(7), _tMarginY(7), _gamma(1.0),
|
||||
_borderColor(0), _borderSave(0),
|
||||
_windowColor(parseColor(WHITE)), _windowSave(parseColor(WHITE)),
|
||||
_sound(true), _speak(false), _speakInput(false), _styleHint(1),
|
||||
_scrollBg(parseColor(SCROLL_BG)), _scrollFg(parseColor(SCROLL_FG)),
|
||||
_lcd(1), _scrollWidth(0), _safeClicks(false)
|
||||
{
|
||||
_lcd(1), _scrollWidth(0), _safeClicks(false) {
|
||||
g_conf = this;
|
||||
_imageW = g_system->getWidth();
|
||||
_imageH = g_system->getHeight();
|
||||
_imageW = _width;
|
||||
_imageH = _height;
|
||||
|
||||
_propInfo._morePrompt = "\207 more \207";
|
||||
_propInfo._moreColor = 0;
|
||||
@ -105,7 +104,7 @@ Conf::Conf(InterpreterType interpType) : _interpType(interpType), _graphics(true
|
||||
_wMarginY = _wMarginSaveY = DEFAULT_MARGIN_Y;
|
||||
|
||||
// For simplicity's sake, only allow graphics when in non-paletted graphics modes
|
||||
if (g_system->getScreenFormat().bytesPerPixel == 1)
|
||||
if (_screenFormat.bytesPerPixel == 1)
|
||||
_graphics = false;
|
||||
|
||||
Common::copy(T_STYLES, T_STYLES + style_NUMSTYLES, _tStyles);
|
||||
@ -116,6 +115,8 @@ Conf::Conf(InterpreterType interpType) : _interpType(interpType), _graphics(true
|
||||
}
|
||||
|
||||
void Conf::load() {
|
||||
get("width", _width);
|
||||
get("height", _height);
|
||||
get("moreprompt", _propInfo._morePrompt);
|
||||
get("morecolor", _propInfo._moreColor);
|
||||
get("morecolor", _propInfo._moreSave);
|
||||
@ -128,6 +129,9 @@ void Conf::load() {
|
||||
get("rows", _rows);
|
||||
get("cols", _cols);
|
||||
|
||||
_imageW = _width;
|
||||
_imageH = _height;
|
||||
|
||||
if (ConfMan.hasKey("leading"))
|
||||
_monoInfo._leading = _propInfo._leading = static_cast<int>(atof(ConfMan.get("leading").c_str()) + 0.5);
|
||||
if (ConfMan.hasKey("baseline"))
|
||||
@ -285,14 +289,14 @@ uint Conf::parseColor(const Common::String &str) {
|
||||
rv = strtol(r, nullptr, 16);
|
||||
gv = strtol(g, nullptr, 16);
|
||||
bv = strtol(b, nullptr, 16);
|
||||
return g_system->getScreenFormat().RGBToColor(rv, gv, bv);
|
||||
return _screenFormat.RGBToColor(rv, gv, bv);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint Conf::parseColor(const byte *rgb) {
|
||||
return g_system->getScreenFormat().RGBToColor(rgb[0], rgb[1], rgb[2]);
|
||||
return _screenFormat.RGBToColor(rgb[0], rgb[1], rgb[2]);
|
||||
}
|
||||
|
||||
} // End of namespace Glk
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "glk/glk_types.h"
|
||||
#include "glk/fonts.h"
|
||||
#include "glk/windows.h"
|
||||
#include "graphics/pixelformat.h"
|
||||
|
||||
namespace Glk {
|
||||
|
||||
@ -70,14 +71,16 @@ public:
|
||||
/**
|
||||
* Parse a color
|
||||
*/
|
||||
static uint parseColor(const Common::String &str);
|
||||
uint parseColor(const Common::String &str);
|
||||
|
||||
/**
|
||||
* Convert an RGB tuplet to a color
|
||||
*/
|
||||
static uint parseColor(const byte *rgb);
|
||||
uint parseColor(const byte *rgb);
|
||||
|
||||
public:
|
||||
uint _width, _height;
|
||||
Graphics::PixelFormat _screenFormat;
|
||||
MonoFontInfo _monoInfo;
|
||||
PropFontInfo _propInfo;
|
||||
int _cols, _rows;
|
||||
|
@ -81,12 +81,12 @@ GlkEngine::~GlkEngine() {
|
||||
}
|
||||
|
||||
void GlkEngine::initialize() {
|
||||
initGraphicsMode();
|
||||
createDebugger();
|
||||
|
||||
createConfiguration();
|
||||
_conf->load();
|
||||
|
||||
initGraphicsMode();
|
||||
createDebugger();
|
||||
|
||||
_screen = createScreen();
|
||||
_screen->initialize();
|
||||
_clipboard = new Clipboard();
|
||||
@ -107,19 +107,7 @@ Screen *GlkEngine::createScreen() {
|
||||
}
|
||||
|
||||
void GlkEngine::initGraphicsMode() {
|
||||
uint width = ConfMan.hasKey("width") ? ConfMan.getInt("width") : 640;
|
||||
uint height = ConfMan.hasKey("height") ? ConfMan.getInt("height") : 480;
|
||||
Common::List<Graphics::PixelFormat> formats = g_system->getSupportedFormats();
|
||||
Graphics::PixelFormat format = formats.front();
|
||||
|
||||
for (Common::List<Graphics::PixelFormat>::iterator i = formats.begin(); i != formats.end(); ++i) {
|
||||
if ((*i).bytesPerPixel > 1) {
|
||||
format = *i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
initGraphics(width, height, &format);
|
||||
initGraphics(_conf->_width, _conf->_height, &_conf->_screenFormat);
|
||||
}
|
||||
|
||||
void GlkEngine::createDebugger() {
|
||||
@ -287,8 +275,8 @@ void GlkEngine::beep() {
|
||||
}
|
||||
|
||||
void GlkEngine::switchToWhiteOnBlack() {
|
||||
const uint WHITE = Conf::parseColor("ffffff");
|
||||
const uint BLACK = Conf::parseColor("000000");
|
||||
const uint WHITE = _conf->parseColor("ffffff");
|
||||
const uint BLACK = _conf->parseColor("000000");
|
||||
|
||||
_conf->_wMarginX = 0;
|
||||
_conf->_wMarginY = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user