mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-10 12:02:53 +02:00
Convert solidFonts
config option to be an array of fonts
This commit is contained in:
parent
1e9bc765e4
commit
a8e6338598
6 changed files with 29 additions and 10 deletions
|
@ -129,10 +129,10 @@
|
||||||
// "syncToRefreshrate": false,
|
// "syncToRefreshrate": false,
|
||||||
|
|
||||||
|
|
||||||
// Don't use alpha blending when rendering text
|
// A list of fonts to render without alpha blending.
|
||||||
// (default: disabled)
|
// (default: none)
|
||||||
//
|
//
|
||||||
// "solidFonts": false,
|
// "solidFonts": ["Arial", "Times New Roman"]
|
||||||
|
|
||||||
|
|
||||||
// Prefer the use of Metal over OpenGL on macOS.
|
// Prefer the use of Metal over OpenGL on macOS.
|
||||||
|
|
|
@ -141,7 +141,7 @@ void Config::read(int argc, char *argv[]) {
|
||||||
{"fixedFramerate", 0},
|
{"fixedFramerate", 0},
|
||||||
{"frameSkip", false},
|
{"frameSkip", false},
|
||||||
{"syncToRefreshrate", false},
|
{"syncToRefreshrate", false},
|
||||||
{"solidFonts", false},
|
{"solidFonts", json::array({})},
|
||||||
#if defined(__APPLE__) && defined(__aarch64__)
|
#if defined(__APPLE__) && defined(__aarch64__)
|
||||||
{"preferMetalRenderer", true},
|
{"preferMetalRenderer", true},
|
||||||
#else
|
#else
|
||||||
|
@ -262,7 +262,7 @@ try { exp } catch (...) {}
|
||||||
SET_OPT(fixedFramerate, integer);
|
SET_OPT(fixedFramerate, integer);
|
||||||
SET_OPT(frameSkip, boolean);
|
SET_OPT(frameSkip, boolean);
|
||||||
SET_OPT(syncToRefreshrate, boolean);
|
SET_OPT(syncToRefreshrate, boolean);
|
||||||
SET_OPT(solidFonts, boolean);
|
fillStringVec(opts["solidFonts"], solidFonts);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
SET_OPT(preferMetalRenderer, boolean);
|
SET_OPT(preferMetalRenderer, boolean);
|
||||||
#endif
|
#endif
|
||||||
|
@ -327,6 +327,12 @@ static void setupScreenSize(Config &conf) {
|
||||||
conf.defScreenH = (conf.rgssVersion == 1 ? 480 : 416);
|
conf.defScreenH = (conf.rgssVersion == 1 ? 480 : 416);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Config::fontIsSolid(const char *fontName) const {
|
||||||
|
for (std::string solidfont : solidFonts)
|
||||||
|
if (!strcmp(solidfont.c_str(), fontName)) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Config::readGameINI() {
|
void Config::readGameINI() {
|
||||||
if (!customScript.empty()) {
|
if (!customScript.empty()) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ struct Config {
|
||||||
bool frameSkip;
|
bool frameSkip;
|
||||||
bool syncToRefreshrate;
|
bool syncToRefreshrate;
|
||||||
|
|
||||||
bool solidFonts;
|
std::vector<std::string> solidFonts;
|
||||||
|
|
||||||
bool subImageFix;
|
bool subImageFix;
|
||||||
bool enableBlitting;
|
bool enableBlitting;
|
||||||
|
@ -148,6 +148,8 @@ struct Config {
|
||||||
|
|
||||||
Config();
|
Config();
|
||||||
|
|
||||||
|
bool fontIsSolid(const char *fontName) const;
|
||||||
|
|
||||||
void read(int argc, char *argv[]);
|
void read(int argc, char *argv[]);
|
||||||
void readGameINI();
|
void readGameINI();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1546,7 +1546,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
||||||
|
|
||||||
SDL_Surface *txtSurf;
|
SDL_Surface *txtSurf;
|
||||||
|
|
||||||
if (shState->rtData().config.solidFonts)
|
if (p->font->isSolid())
|
||||||
txtSurf = TTF_RenderUTF8_Solid(font, str, c);
|
txtSurf = TTF_RenderUTF8_Solid(font, str, c);
|
||||||
else
|
else
|
||||||
txtSurf = TTF_RenderUTF8_Blended(font, str, c);
|
txtSurf = TTF_RenderUTF8_Blended(font, str, c);
|
||||||
|
@ -1567,7 +1567,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
||||||
SDL_Surface *outline;
|
SDL_Surface *outline;
|
||||||
/* set the next font render to render the outline */
|
/* set the next font render to render the outline */
|
||||||
TTF_SetFontOutline(font, OUTLINE_SIZE);
|
TTF_SetFontOutline(font, OUTLINE_SIZE);
|
||||||
if (shState->rtData().config.solidFonts)
|
if (p->font->isSolid())
|
||||||
outline = TTF_RenderUTF8_Solid(font, str, co);
|
outline = TTF_RenderUTF8_Solid(font, str, co);
|
||||||
else
|
else
|
||||||
outline = TTF_RenderUTF8_Blended(font, str, co);
|
outline = TTF_RenderUTF8_Blended(font, str, co);
|
||||||
|
|
|
@ -292,6 +292,8 @@ struct FontPrivate
|
||||||
* set to null */
|
* set to null */
|
||||||
TTF_Font *sdlFont;
|
TTF_Font *sdlFont;
|
||||||
|
|
||||||
|
bool isSolid;
|
||||||
|
|
||||||
FontPrivate(int size)
|
FontPrivate(int size)
|
||||||
: size(size),
|
: size(size),
|
||||||
bold(defaultBold),
|
bold(defaultBold),
|
||||||
|
@ -302,7 +304,8 @@ struct FontPrivate
|
||||||
outColor(&outColorTmp),
|
outColor(&outColorTmp),
|
||||||
colorTmp(*defaultColor),
|
colorTmp(*defaultColor),
|
||||||
outColorTmp(*defaultOutColor),
|
outColorTmp(*defaultOutColor),
|
||||||
sdlFont(0)
|
sdlFont(0),
|
||||||
|
isSolid(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
FontPrivate(const FontPrivate &other)
|
FontPrivate(const FontPrivate &other)
|
||||||
|
@ -316,7 +319,8 @@ struct FontPrivate
|
||||||
outColor(&outColorTmp),
|
outColor(&outColorTmp),
|
||||||
colorTmp(*other.color),
|
colorTmp(*other.color),
|
||||||
outColorTmp(*other.outColor),
|
outColorTmp(*other.outColor),
|
||||||
sdlFont(other.sdlFont)
|
sdlFont(other.sdlFont),
|
||||||
|
isSolid(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void operator=(const FontPrivate &o)
|
void operator=(const FontPrivate &o)
|
||||||
|
@ -331,6 +335,7 @@ struct FontPrivate
|
||||||
*outColor = *o.outColor;
|
*outColor = *o.outColor;
|
||||||
|
|
||||||
sdlFont = 0;
|
sdlFont = 0;
|
||||||
|
isSolid = o.isSolid;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -348,6 +353,10 @@ Color FontPrivate::defaultOutColorTmp(0, 0, 0, 128);
|
||||||
|
|
||||||
std::vector<std::string> FontPrivate::initialDefaultNames;
|
std::vector<std::string> FontPrivate::initialDefaultNames;
|
||||||
|
|
||||||
|
bool Font::isSolid() const {
|
||||||
|
return p->isSolid;
|
||||||
|
}
|
||||||
|
|
||||||
bool Font::doesExist(const char *name)
|
bool Font::doesExist(const char *name)
|
||||||
{
|
{
|
||||||
if (!name)
|
if (!name)
|
||||||
|
@ -387,6 +396,7 @@ const Font &Font::operator=(const Font &o)
|
||||||
void Font::setName(const std::vector<std::string> &names)
|
void Font::setName(const std::vector<std::string> &names)
|
||||||
{
|
{
|
||||||
pickExistingFontName(names, p->name, shState->fontState());
|
pickExistingFontName(names, p->name, shState->fontState());
|
||||||
|
p->isSolid = strcmp(p->name.c_str(), "") && shState->config().fontIsSolid(p->name.c_str());
|
||||||
p->sdlFont = 0;
|
p->sdlFont = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,7 @@ public:
|
||||||
const SharedFontState &sfs);
|
const SharedFontState &sfs);
|
||||||
|
|
||||||
static const std::vector<std::string> &getInitialDefaultNames();
|
static const std::vector<std::string> &getInitialDefaultNames();
|
||||||
|
bool isSolid() const;
|
||||||
|
|
||||||
/* Assigns heap allocated objects to object properties;
|
/* Assigns heap allocated objects to object properties;
|
||||||
* using this in pure C++ will cause memory leaks
|
* using this in pure C++ will cause memory leaks
|
||||||
|
|
Loading…
Add table
Reference in a new issue