mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
Add selector for font type in Launcher, add autoselection
This commit is contained in:
@@ -39,17 +39,36 @@ size_t FontChain::getFontAscentScaled() const
|
|||||||
return maxHeight;
|
return maxHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FontChain::bitmapFontsPrioritized() const
|
||||||
|
{
|
||||||
|
const std::string & fontType = settings["video"]["fontsType"].String();
|
||||||
|
if (fontType == "original")
|
||||||
|
return true;
|
||||||
|
if (fontType == "scalable")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// else - autoselection.
|
||||||
|
|
||||||
|
if (getScalingFactor() != 1)
|
||||||
|
return false; // If xbrz in use ttf/scalable fonts are preferred
|
||||||
|
|
||||||
|
if (!vstd::isAlmostEqual(1.0, settings["video"]["fontScalingFactor"].Float()))
|
||||||
|
return false; // If player requested non-100% scaling - use scalable fonts
|
||||||
|
|
||||||
|
return true; // else - use original bitmap fonts
|
||||||
|
}
|
||||||
|
|
||||||
void FontChain::addTrueTypeFont(const JsonNode & trueTypeConfig)
|
void FontChain::addTrueTypeFont(const JsonNode & trueTypeConfig)
|
||||||
{
|
{
|
||||||
chain.push_back(std::make_unique<CTrueTypeFont>(trueTypeConfig));
|
chain.insert(chain.begin(), std::make_unique<CTrueTypeFont>(trueTypeConfig));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontChain::addBitmapFont(const std::string & bitmapFilename)
|
void FontChain::addBitmapFont(const std::string & bitmapFilename)
|
||||||
{
|
{
|
||||||
if (settings["video"]["scalableFonts"].Bool())
|
if (bitmapFontsPrioritized())
|
||||||
chain.push_back(std::make_unique<CBitmapFont>(bitmapFilename));
|
|
||||||
else
|
|
||||||
chain.insert(chain.begin(), std::make_unique<CBitmapFont>(bitmapFilename));
|
chain.insert(chain.begin(), std::make_unique<CBitmapFont>(bitmapFilename));
|
||||||
|
else
|
||||||
|
chain.push_back(std::make_unique<CBitmapFont>(bitmapFilename));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FontChain::canRepresentCharacter(const char * data) const
|
bool FontChain::canRepresentCharacter(const char * data) const
|
||||||
|
@@ -29,6 +29,7 @@ class FontChain final : public IFont
|
|||||||
|
|
||||||
void renderText(SDL_Surface * surface, const std::string & data, const ColorRGBA & color, const Point & pos) const override;
|
void renderText(SDL_Surface * surface, const std::string & data, const ColorRGBA & color, const Point & pos) const override;
|
||||||
size_t getFontAscentScaled() const override;
|
size_t getFontAscentScaled() const override;
|
||||||
|
bool bitmapFontsPrioritized() const;
|
||||||
public:
|
public:
|
||||||
FontChain() = default;
|
FontChain() = default;
|
||||||
|
|
||||||
|
@@ -356,7 +356,8 @@ std::shared_ptr<const IFont> RenderHandler::loadFont(EFonts font)
|
|||||||
const JsonNode & ttfConf = config["trueType"];
|
const JsonNode & ttfConf = config["trueType"];
|
||||||
|
|
||||||
bitmapPath = bmpConf[index].String();
|
bitmapPath = bmpConf[index].String();
|
||||||
loadedFont->addTrueTypeFont(ttfConf[bitmapPath]);
|
if (!ttfConf[bitmapPath].isNull())
|
||||||
|
loadedFont->addTrueTypeFont(ttfConf[bitmapPath]);
|
||||||
}
|
}
|
||||||
loadedFont->addBitmapFont(bitmapPath);
|
loadedFont->addBitmapFont(bitmapPath);
|
||||||
|
|
||||||
|
@@ -166,7 +166,7 @@
|
|||||||
"showfps",
|
"showfps",
|
||||||
"targetfps",
|
"targetfps",
|
||||||
"vsync",
|
"vsync",
|
||||||
"scalableFonts",
|
"fontsType",
|
||||||
"fontScalingFactor",
|
"fontScalingFactor",
|
||||||
"upscalingFilter",
|
"upscalingFilter",
|
||||||
"fontUpscalingFilter",
|
"fontUpscalingFilter",
|
||||||
@@ -234,9 +234,10 @@
|
|||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
"default" : true
|
"default" : true
|
||||||
},
|
},
|
||||||
"scalableFonts" : {
|
"fontsType" : {
|
||||||
"type" : "boolean",
|
"type" : "string",
|
||||||
"default" : false
|
"enum" : [ "auto", "original", "scalable" ],
|
||||||
|
"default" : "auto"
|
||||||
},
|
},
|
||||||
"fontScalingFactor" : {
|
"fontScalingFactor" : {
|
||||||
"type" : "number",
|
"type" : "number",
|
||||||
|
@@ -175,6 +175,13 @@ void CSettingsView::loadSettings()
|
|||||||
ui->lineEditGameLobbyHost->setText(QString::fromStdString(settings["lobby"]["hostname"].String()));
|
ui->lineEditGameLobbyHost->setText(QString::fromStdString(settings["lobby"]["hostname"].String()));
|
||||||
ui->spinBoxNetworkPortLobby->setValue(settings["lobby"]["port"].Integer());
|
ui->spinBoxNetworkPortLobby->setValue(settings["lobby"]["port"].Integer());
|
||||||
|
|
||||||
|
if (settings["video"]["fontsType"].String() == "auto")
|
||||||
|
ui->buttonFontAuto->setChecked(true);
|
||||||
|
else if (settings["video"]["fontsType"].String() == "original")
|
||||||
|
ui->buttonFontOriginal->setChecked(true);
|
||||||
|
else
|
||||||
|
ui->buttonFontScalable->setChecked(true);
|
||||||
|
|
||||||
loadToggleButtonSettings();
|
loadToggleButtonSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,11 +202,13 @@ void CSettingsView::loadToggleButtonSettings()
|
|||||||
setCheckbuttonState(ui->buttonRelativeCursorMode, settings["general"]["userRelativePointer"].Bool());
|
setCheckbuttonState(ui->buttonRelativeCursorMode, settings["general"]["userRelativePointer"].Bool());
|
||||||
setCheckbuttonState(ui->buttonHapticFeedback, settings["general"]["hapticFeedback"].Bool());
|
setCheckbuttonState(ui->buttonHapticFeedback, settings["general"]["hapticFeedback"].Bool());
|
||||||
|
|
||||||
setCheckbuttonState(ui->buttonTtfFont, settings["video"]["scalableFonts"].Bool());
|
|
||||||
|
|
||||||
std::string cursorType = settings["video"]["cursor"].String();
|
std::string cursorType = settings["video"]["cursor"].String();
|
||||||
int cursorTypeIndex = vstd::find_pos(cursorTypesList, cursorType);
|
int cursorTypeIndex = vstd::find_pos(cursorTypesList, cursorType);
|
||||||
setCheckbuttonState(ui->buttonCursorType, cursorTypeIndex);
|
setCheckbuttonState(ui->buttonCursorType, cursorTypeIndex);
|
||||||
|
|
||||||
|
int fontScalingPercentage = settings["video"]["fontScalingFactor"].Float() * 100;
|
||||||
|
ui->sliderScalingFont->setValue(fontScalingPercentage / 5);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingsView::fillValidResolutions()
|
void CSettingsView::fillValidResolutions()
|
||||||
@@ -757,9 +766,28 @@ void CSettingsView::on_sliderControllerSticksSensitivity_valueChanged(int value)
|
|||||||
node->Integer() = value;
|
node->Integer() = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingsView::on_buttonTtfFont_toggled(bool value)
|
void CSettingsView::on_sliderScalingFont_valueChanged(int value)
|
||||||
{
|
{
|
||||||
Settings node = settings.write["video"]["scalableFonts"];
|
int actualValuePercentage = value * 5;
|
||||||
node->Bool() = value;
|
ui->labelScalingFontValue->setText(QString("%1%").arg(actualValuePercentage));
|
||||||
updateCheckbuttonText(ui->buttonTtfFont);
|
Settings node = settings.write["video"]["fontScalingFactor"];
|
||||||
|
node->Float() = actualValuePercentage / 100.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsView::on_buttonFontAuto_clicked(bool checked)
|
||||||
|
{
|
||||||
|
Settings node = settings.write["video"]["fontsType"];
|
||||||
|
node->String() = "auto";
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsView::on_buttonFontScalable_clicked(bool checked)
|
||||||
|
{
|
||||||
|
Settings node = settings.write["video"]["fontsType"];
|
||||||
|
node->String() = "scalable";
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsView::on_buttonFontOriginal_clicked(bool checked)
|
||||||
|
{
|
||||||
|
Settings node = settings.write["video"]["fontsType"];
|
||||||
|
node->String() = "original";
|
||||||
}
|
}
|
||||||
|
@@ -88,7 +88,13 @@ private slots:
|
|||||||
|
|
||||||
void on_sliderControllerSticksSensitivity_valueChanged(int value);
|
void on_sliderControllerSticksSensitivity_valueChanged(int value);
|
||||||
|
|
||||||
void on_buttonTtfFont_toggled(bool value);
|
//void on_buttonTtfFont_toggled(bool value);
|
||||||
|
|
||||||
|
void on_sliderScalingFont_valueChanged(int value);
|
||||||
|
|
||||||
|
void on_buttonFontAuto_clicked(bool checked);
|
||||||
|
void on_buttonFontScalable_clicked(bool checked);
|
||||||
|
void on_buttonFontOriginal_clicked(bool checked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::CSettingsView * ui;
|
Ui::CSettingsView * ui;
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user