mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Make the console font configurable
This commit is contained in:
parent
13c00d1869
commit
d549cbeeaa
3 changed files with 6 additions and 5 deletions
|
|
@ -190,6 +190,7 @@ server.port = "8000" ; Use a free port on your machine.
|
|||
server.threads = "6" ; Enough for the browser's parallel connection limit
|
||||
|
||||
[console]
|
||||
font = "mono-10"
|
||||
history.size = 200
|
||||
|
||||
[hotkey]
|
||||
|
|
|
|||
|
|
@ -52,8 +52,6 @@ namespace
|
|||
// For text being typed into the console.
|
||||
constexpr int CONSOLE_BUFFER_SIZE = 1024;
|
||||
|
||||
const char* CONSOLE_FONT = "mono-10";
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
CConsole* g_Console = 0;
|
||||
|
|
@ -87,6 +85,7 @@ void CConsole::Init()
|
|||
{
|
||||
// Initialise console history file
|
||||
m_MaxHistoryLines = g_ConfigDB.Get("console.history.size", 200);
|
||||
m_consoleFont = g_ConfigDB.Get("console.font", std::string{"mono-10"});
|
||||
|
||||
m_HistoryFile = L"config/console.txt";
|
||||
LoadHistory();
|
||||
|
|
@ -94,7 +93,7 @@ void CConsole::Init()
|
|||
UpdateScreenSize(g_xres, g_yres);
|
||||
|
||||
// Calculate and store the line spacing
|
||||
const CFontMetrics font{CStrIntern(CONSOLE_FONT)};
|
||||
const CFontMetrics font{CStrIntern(m_consoleFont)};
|
||||
m_FontHeight = font.GetLineSpacing();
|
||||
m_FontWidth = font.GetCharacterWidth(L'C');
|
||||
m_CharsPerPage = static_cast<size_t>(g_xres / m_FontWidth);
|
||||
|
|
@ -200,7 +199,7 @@ void CConsole::Render(CCanvas2D& canvas)
|
|||
DrawWindow(canvas);
|
||||
|
||||
CTextRenderer textRenderer;
|
||||
textRenderer.SetCurrentFont(CStrIntern(CONSOLE_FONT));
|
||||
textRenderer.SetCurrentFont(CStrIntern(m_consoleFont));
|
||||
// Animation: slide in from top of screen.
|
||||
const float deltaY = (1.0f - m_VisibleFrac) * m_Height;
|
||||
textRenderer.Translate(m_X, m_Y - deltaY);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2022 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
|
|
@ -103,6 +103,7 @@ private:
|
|||
|
||||
VfsPath m_HistoryFile;
|
||||
int m_MaxHistoryLines;
|
||||
std::string m_consoleFont;
|
||||
|
||||
bool m_Visible; // console is to be drawn
|
||||
bool m_Toggle; // show/hide animation is currently active
|
||||
|
|
|
|||
Loading…
Reference in a new issue