1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-10 22:31:40 +02:00

Launcher now controls ttf fonts usage directly instead of toggling mod

from extras
This commit is contained in:
Ivan Savenko
2024-09-23 18:31:44 +00:00
parent 97e24ff126
commit 557b72f2b3
3 changed files with 11 additions and 21 deletions

View File

@@ -23,6 +23,7 @@
#include "../render/ColorFilter.h" #include "../render/ColorFilter.h"
#include "../render/IScreenHandler.h" #include "../render/IScreenHandler.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/json/JsonUtils.h" #include "../../lib/json/JsonUtils.h"
#include "../../lib/filesystem/Filesystem.h" #include "../../lib/filesystem/Filesystem.h"
#include "../../lib/VCMIDirs.h" #include "../../lib/VCMIDirs.h"
@@ -352,7 +353,7 @@ std::shared_ptr<const IFont> RenderHandler::loadFont(EFonts font)
std::shared_ptr<const IFont> loadedFont; std::shared_ptr<const IFont> loadedFont;
if (ttfConf[filename].isNull()) if(ttfConf[filename].isNull() || settings["video"]["scalableFonts"].Bool() == false)
loadedFont = std::make_shared<CBitmapFont>(filename); loadedFont = std::make_shared<CBitmapFont>(filename);
else else
loadedFont = std::make_shared<CTrueTypeFont>(ttfConf[filename]); loadedFont = std::make_shared<CTrueTypeFont>(ttfConf[filename]);

View File

@@ -166,6 +166,7 @@
"showfps", "showfps",
"targetfps", "targetfps",
"vsync", "vsync",
"scalableFonts",
"upscalingFilter", "upscalingFilter",
"fontUpscalingFilter", "fontUpscalingFilter",
"downscalingFilter" "downscalingFilter"
@@ -232,6 +233,10 @@
"type" : "boolean", "type" : "boolean",
"default" : true "default" : true
}, },
"scalableFonts" : {
"type" : "boolean",
"default" : false
},
"fontUpscalingFilter" : { "fontUpscalingFilter" : {
"type" : "string", "type" : "string",
"enum" : [ "nearest", "bilinear", "xbrz" ], "enum" : [ "nearest", "bilinear", "xbrz" ],

View File

@@ -175,17 +175,6 @@ 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());
auto mainWindow = getMainWindow();
if(mainWindow)
{
bool fontModAvailable = mainWindow->getModView()->isModInstalled("vcmi-extras.truetypefonts");
if(!fontModAvailable)
{
ui->labelTtfFont->hide();
ui->buttonTtfFont->hide();
}
}
loadToggleButtonSettings(); loadToggleButtonSettings();
} }
@@ -206,13 +195,11 @@ 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);
auto mainWindow = getMainWindow();
if(mainWindow)
setCheckbuttonState(ui->buttonTtfFont, mainWindow->getModView()->isModEnabled("vcmi-extras.truetypefonts"));
} }
void CSettingsView::fillValidResolutions() void CSettingsView::fillValidResolutions()
@@ -772,10 +759,7 @@ void CSettingsView::on_sliderControllerSticksSensitivity_valueChanged(int value)
void CSettingsView::on_buttonTtfFont_toggled(bool value) void CSettingsView::on_buttonTtfFont_toggled(bool value)
{ {
auto mainWindow = getMainWindow(); Settings node = settings.write["video"]["scalableFonts"];
if(value) node->Bool() = value;
mainWindow->getModView()->enableModByName("vcmi-extras.truetypefonts");
else
mainWindow->getModView()->disableModByName("vcmi-extras.truetypefonts");
updateCheckbuttonText(ui->buttonTtfFont); updateCheckbuttonText(ui->buttonTtfFont);
} }