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