mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-19 04:50:05 -07:00
No longer require game restart, but in exchange all differently sized fonts need to be preloaded
This commit is contained in:
parent
9fdf72e82b
commit
6502b35951
2 changed files with 13 additions and 11 deletions
|
@ -346,6 +346,11 @@ void OTRGlobals::Initialize() {
|
||||||
|
|
||||||
auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay();
|
auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay();
|
||||||
overlay->LoadFont("Fipps", 32.0f, "fonts/Fipps-Regular.otf");
|
overlay->LoadFont("Fipps", 32.0f, "fonts/Fipps-Regular.otf");
|
||||||
|
// Currently, differently sized fonts require preloading (reloading font at runtime crashes the game)
|
||||||
|
overlay->LoadFont("Press Start 2P", 12.0f, "fonts/PressStart2P-Regular.ttf");
|
||||||
|
overlay->LoadFont("Press Start 2P 24", 24.0f, "fonts/PressStart2P-Regular.ttf");
|
||||||
|
overlay->LoadFont("Press Start 2P 32", 32.0f, "fonts/PressStart2P-Regular.ttf");
|
||||||
|
overlay->LoadFont("Press Start 2P 40", 40.0f, "fonts/PressStart2P-Regular.ttf");
|
||||||
LoadOverlayTextFont();
|
LoadOverlayTextFont();
|
||||||
|
|
||||||
context->InitAudio({ .SampleRate = 32000, .SampleLength = 1024, .DesiredBuffered = 1680 });
|
context->InitAudio({ .SampleRate = 32000, .SampleLength = 1024, .DesiredBuffered = 1680 });
|
||||||
|
@ -513,27 +518,23 @@ void OTRGlobals::ScaleImGui() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OTRGlobals::LoadOverlayTextFont() {
|
void OTRGlobals::LoadOverlayTextFont() {
|
||||||
// TODO: Currenty, reloading a font causes crash.
|
// TODO: Is Fipps font used in somewhere?
|
||||||
auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay();
|
auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay();
|
||||||
float fontSize;
|
|
||||||
switch (CVarGetInteger(CVAR_SETTING("OverlayTextScale"), 0)) {
|
switch (CVarGetInteger(CVAR_SETTING("OverlayTextScale"), 0)) {
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
fontSize = 12.0f;
|
overlay->SetCurrentFont("Press Start 2P");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
fontSize = 24.0f;
|
overlay->SetCurrentFont("Press Start 2P 24");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
fontSize = 32.0f;
|
overlay->SetCurrentFont("Press Start 2P 32");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
fontSize = 40.0f;
|
overlay->SetCurrentFont("Press Start 2P 40");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SPDLOG_DEBUG("Loading Overlay Text Font with size {}", fontSize);
|
|
||||||
overlay->LoadFont("Press Start 2P", fontSize, "fonts/PressStart2P-Regular.ttf");
|
|
||||||
overlay->SetCurrentFont(CVarGetString(CVAR_GAME_OVERLAY_FONT, "Press Start 2P"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImFont* OTRGlobals::CreateDefaultFontWithSize(float size) {
|
ImFont* OTRGlobals::CreateDefaultFontWithSize(float size) {
|
||||||
|
|
|
@ -256,10 +256,11 @@ void SohMenu::AddMenuSettings() {
|
||||||
.RaceDisable(false)
|
.RaceDisable(false)
|
||||||
.Options(ComboboxOptions()
|
.Options(ComboboxOptions()
|
||||||
.ComboMap(overlayTextScaleOptions)
|
.ComboMap(overlayTextScaleOptions)
|
||||||
.Tooltip("Changes the font size of Overlay Text.\n(REQUIRES RESTART)")
|
.Tooltip("Changes the font size of Overlay Text.")
|
||||||
.DefaultIndex(0)
|
.DefaultIndex(0)
|
||||||
.ComponentAlignment(ComponentAlignments::Right)
|
.ComponentAlignment(ComponentAlignments::Right)
|
||||||
.LabelPosition(LabelPositions::Far));
|
.LabelPosition(LabelPositions::Far))
|
||||||
|
.Callback([](WidgetInfo& info) { OTRGlobals::Instance->LoadOverlayTextFont(); });
|
||||||
|
|
||||||
// General - About
|
// General - About
|
||||||
path.column = SECTION_COLUMN_2;
|
path.column = SECTION_COLUMN_2;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue