Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'source/frontend')
-rw-r--r--source/frontend/StarChat.cpp4
-rw-r--r--source/frontend/StarChat.hpp1
-rw-r--r--source/frontend/StarChatBubbleManager.cpp3
-rw-r--r--source/frontend/StarMainInterface.cpp10
-rw-r--r--source/frontend/StarMainInterfaceTypes.cpp3
-rw-r--r--source/frontend/StarMainInterfaceTypes.hpp2
-rw-r--r--source/frontend/StarNameplatePainter.cpp6
-rw-r--r--source/frontend/StarNameplatePainter.hpp2
-rw-r--r--source/frontend/StarWidgetLuaBindings.cpp4
9 files changed, 30 insertions, 5 deletions
diff --git a/source/frontend/StarChat.cpp b/source/frontend/StarChat.cpp
index b89bd4e..236d207 100644
--- a/source/frontend/StarChat.cpp
+++ b/source/frontend/StarChat.cpp
@@ -24,6 +24,7 @@ Chat::Chat(UniverseClientPtr client) : m_client(client) {
auto fontConfig = assets->json("/interface/chat/chat.config:config.font");
m_fontSize = fontConfig.getInt("baseSize");
m_fontDirectives = fontConfig.queryString("directives", "");
+ m_font = fontConfig.queryString("type", "");
m_chatLineHeight = assets->json("/interface/chat/chat.config:config.lineHeight").toFloat();
m_chatVisTime = assets->json("/interface/chat/chat.config:config.visTime").toFloat();
m_fadeRate = assets->json("/interface/chat/chat.config:config.fadeRate").toDouble();
@@ -178,6 +179,7 @@ void Chat::addMessages(List<ChatReceivedMessage> const& messages, bool showPane)
if (message.portrait.empty())
wrapWidth = m_chatLog->size()[0];
+ guiContext.setFont(m_font);
guiContext.setFontSize(m_fontSize);
StringList lines;
if (message.fromNick != "" && message.portrait == "")
@@ -237,6 +239,7 @@ void Chat::renderImpl() {
int messageIndex = -m_historyOffset;
GuiContext& guiContext = GuiContext::singleton();
+ guiContext.setFont(m_font);
guiContext.setFontSize(m_fontSize);
guiContext.setLineSpacing(m_chatLineHeight);
for (auto message : m_receivedMessages) {
@@ -284,6 +287,7 @@ void Chat::renderImpl() {
}
guiContext.setDefaultLineSpacing();
+ guiContext.setDefaultFont();
}
void Chat::hide() {
diff --git a/source/frontend/StarChat.hpp b/source/frontend/StarChat.hpp
index 9c1f8f4..e88a797 100644
--- a/source/frontend/StarChat.hpp
+++ b/source/frontend/StarChat.hpp
@@ -69,6 +69,7 @@ private:
float m_fadeRate;
unsigned m_fontSize;
String m_fontDirectives;
+ String m_font;
float m_chatLineHeight;
unsigned m_chatHistoryLimit;
int m_historyOffset;
diff --git a/source/frontend/StarChatBubbleManager.cpp b/source/frontend/StarChatBubbleManager.cpp
index cfb889f..c72b1a6 100644
--- a/source/frontend/StarChatBubbleManager.cpp
+++ b/source/frontend/StarChatBubbleManager.cpp
@@ -194,7 +194,10 @@ void ChatBubbleManager::addChatActions(List<ChatAction> chatActions, bool silent
// TODO: Get rid of this stupid fucking bullshit, this is the ugliest
// fragilest pointlessest horseshit code in the codebase. It wouldn't
// bother me so bad if it weren't so fucking easy to do right.
+
+ // yea I agree
m_guiContext->setFontSize(m_fontSize, m_zoom);
+ m_guiContext->setDefaultFont();
auto result = m_guiContext->determineTextSize(sayAction.text, m_textTemplate);
float textWidth = result.width() / m_zoom + m_textPadding[0];
float textHeight = result.height() / m_zoom + m_textPadding[1];
diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp
index 1f007a5..4485ffa 100644
--- a/source/frontend/StarMainInterface.cpp
+++ b/source/frontend/StarMainInterface.cpp
@@ -997,6 +997,7 @@ void MainInterface::renderMessages() {
m_guiContext->drawQuad(m_config->messageTextContainer,
RectF::withCenter(backgroundTextCenterPos, Vec2F(imgMetadata->imageSize(m_config->messageTextContainer) * interfaceScale())));
+ m_guiContext->setFont(m_config->font);
m_guiContext->setFontSize(m_config->fontSize);
m_guiContext->setFontColor(Color::White.toRgba());
m_guiContext->renderText(message->message, {messageTextOffset, HorizontalAnchor::HMidAnchor, VerticalAnchor::VMidAnchor});
@@ -1024,6 +1025,7 @@ void MainInterface::renderMonsterHealthBar() {
m_guiContext->drawQuad(container, RectF::withCenter(backgroundCenterPos + offset, Vec2F(imgMetadata->imageSize(container) * interfaceScale())));
auto nameTextOffset = jsonToVec2F(assets->json("/interface.config:monsterHealth.nameTextOffset")) * interfaceScale();
+ m_guiContext->setFont(m_config->font);
m_guiContext->setFontSize(m_config->fontSize);
m_guiContext->setFontColor(Color::White.toRgba());
m_guiContext->renderText(showDamageEntity->name(), backgroundCenterPos + nameTextOffset);
@@ -1250,7 +1252,7 @@ void MainInterface::renderDebug() {
auto assets = Root::singleton().assets();
m_guiContext->setFontSize(m_config->debugFontSize);
- int counter = 0;
+ m_guiContext->setFont(m_config->debugFont);
m_guiContext->setFontColor(Color::Green.toRgba());
bool clearMap = m_debugMapClearTimer.wrapTick();
@@ -1258,6 +1260,7 @@ void MainInterface::renderDebug() {
if (clearMap)
LogMap::clear();
+ int counter = 0;
for (auto const& pair : logMapValues) {
TextPositioning positioning = {Vec2F(m_config->debugOffset[0], windowHeight() - m_config->debugOffset[1] - m_config->fontSize * interfaceScale() * counter)};
m_debugTextRect.combine(m_guiContext->determineTextSize(strf("%s: %s", pair.first, pair.second), positioning).padded(m_config->debugBackgroundPad));
@@ -1307,7 +1310,8 @@ void MainInterface::renderDebug() {
m_guiContext->drawLine(position + Vec2F(2, -2), position + Vec2F(-2, -2), point.color, 1);
}
- m_guiContext->setFontSize(assets->json("/interface.config:debugFontSize").toInt());
+ m_guiContext->setFontSize(m_config->debugFontSize);
+
for (auto const& logText : SpatialLogger::getText("world", clearSpatial)) {
m_guiContext->setFontColor(logText.color);
m_guiContext->renderText(logText.text.utf8Ptr(), camera.worldToScreen(logText.position));
@@ -1381,11 +1385,13 @@ void MainInterface::renderCursor() {
Vec2I cursorOffset = (Vec2I{0, -m_cursor.size().y()} + rawCursorOffset) * interfaceScale();
Vec2I tooltipOffset = m_cursorScreenPos + cursorOffset;
size_t fontSize = assets->json("/interface.config:cursorTooltip.fontSize").toUInt();
+ String font = assets->json("/interface.config:cursorTooltip.font").toString();
Vec4B fontColor = jsonToColor(assets->json("/interface.config:cursorTooltip.color")).toRgba();
m_guiContext->drawQuad(backgroundImage, Vec2F(tooltipOffset) + Vec2F(-tooltipSize.x(), 0), interfaceScale());
m_guiContext->setFontSize(fontSize);
m_guiContext->setFontColor(fontColor);
+ m_guiContext->setFont(font);
m_guiContext->renderText(*m_cursorTooltip,
TextPositioning(Vec2F(tooltipOffset) + Vec2F(-tooltipSize.x(), tooltipSize.y()) / 2,
HorizontalAnchor::HMidAnchor,
diff --git a/source/frontend/StarMainInterfaceTypes.cpp b/source/frontend/StarMainInterfaceTypes.cpp
index c32a226..b0f7041 100644
--- a/source/frontend/StarMainInterfaceTypes.cpp
+++ b/source/frontend/StarMainInterfaceTypes.cpp
@@ -14,7 +14,7 @@ MainInterfaceConfigPtr MainInterfaceConfig::loadFromAssets() {
auto config = make_shared<MainInterfaceConfig>();
config->fontSize = assets->json("/interface.config:font.baseSize").toInt();
-
+ config->font = assets->json("/interface.config:font.defaultFont").toString();
config->inventoryImage = assets->json("/interface.config:mainBar.inventory.base").toString();
config->inventoryImageHover = assets->json("/interface.config:mainBar.inventory.hover").toString();
config->inventoryImageGlow = assets->json("/interface.config:mainBar.inventory.glow").toString();
@@ -113,6 +113,7 @@ MainInterfaceConfigPtr MainInterfaceConfig::loadFromAssets() {
config->debugOffset = jsonToVec2I(assets->json("/interface.config:debugOffset"));
config->debugFontSize = assets->json("/interface.config:debugFontSize").toUInt();
+ config->debugFont = assets->json("/interface.config:debugFont").toString();
config->debugSpatialClearTime = assets->json("/interface.config:debugSpatialClearTime").toFloat();
config->debugMapClearTime = assets->json("/interface.config:debugMapClearTime").toFloat();
config->debugBackgroundColor = jsonToColor(assets->json("/interface.config:debugBackgroundColor"));
diff --git a/source/frontend/StarMainInterfaceTypes.hpp b/source/frontend/StarMainInterfaceTypes.hpp
index c989a8e..4158639 100644
--- a/source/frontend/StarMainInterfaceTypes.hpp
+++ b/source/frontend/StarMainInterfaceTypes.hpp
@@ -43,6 +43,7 @@ struct MainInterfaceConfig {
static MainInterfaceConfigPtr loadFromAssets();
unsigned fontSize;
+ String font;
String inventoryImage;
String inventoryImageHover;
@@ -143,6 +144,7 @@ struct MainInterfaceConfig {
Vec2I debugOffset;
unsigned debugFontSize;
+ String debugFont;
float debugSpatialClearTime;
float debugMapClearTime;
Color debugBackgroundColor;
diff --git a/source/frontend/StarNameplatePainter.cpp b/source/frontend/StarNameplatePainter.cpp
index ccfcef3..1259cea 100644
--- a/source/frontend/StarNameplatePainter.cpp
+++ b/source/frontend/StarNameplatePainter.cpp
@@ -13,6 +13,8 @@ NameplatePainter::NameplatePainter() {
Json nametagConfig = assets->json("/interface.config:nametag");
m_opacityRate = nametagConfig.getFloat("opacityRate");
m_offset = jsonToVec2F(nametagConfig.get("offset"));
+ m_font = nametagConfig.optString("font").value("");
+ m_statusFont = nametagConfig.optString("font").value(m_font);
m_fontSize = nametagConfig.getFloat("fontSize");
m_statusFontSize = nametagConfig.getFloat("statusFontSize");
m_statusOffset = jsonToVec2F(nametagConfig.get("statusOffset"));
@@ -74,6 +76,7 @@ void NameplatePainter::render() {
if (nametag.opacity == 0.0f)
return;
+ context.setFont(m_font);
context.setFontSize(m_fontSize);
auto color = Color::rgb(nametag.color);
@@ -87,6 +90,7 @@ void NameplatePainter::render() {
if (nametag.statusText) {
context.setFontSize(m_statusFontSize);
+ context.setFont(m_statusFont);
context.setFontColor(statusColor.toRgba());
context.renderText(*nametag.statusText, statusPosition(bubble.currentPosition));
}
@@ -107,9 +111,11 @@ TextPositioning NameplatePainter::statusPosition(Vec2F bubblePosition) const {
RectF NameplatePainter::determineBoundBox(Vec2F bubblePosition, Nametag const& nametag) const {
auto& context = GuiContext::singleton();
context.setFontSize(m_fontSize);
+ context.setFont(m_font);
RectF nametagBox = context.determineTextSize(nametag.name, namePosition(bubblePosition));
if (nametag.statusText) {
context.setFontSize(m_statusFontSize);
+ context.setFont(m_statusFont);
nametagBox.combine(context.determineTextSize(*nametag.statusText, statusPosition(bubblePosition)));
}
return nametagBox;
diff --git a/source/frontend/StarNameplatePainter.hpp b/source/frontend/StarNameplatePainter.hpp
index ec46576..51af619 100644
--- a/source/frontend/StarNameplatePainter.hpp
+++ b/source/frontend/StarNameplatePainter.hpp
@@ -33,6 +33,8 @@ private:
float m_opacityRate;
Vec2F m_offset;
+ String m_font;
+ String m_statusFont;
float m_fontSize;
float m_statusFontSize;
Vec2F m_statusOffset;
diff --git a/source/frontend/StarWidgetLuaBindings.cpp b/source/frontend/StarWidgetLuaBindings.cpp
index eb81f51..1029daa 100644
--- a/source/frontend/StarWidgetLuaBindings.cpp
+++ b/source/frontend/StarWidgetLuaBindings.cpp
@@ -78,8 +78,8 @@ struct LuaUserDataMethods<CanvasWidgetPtr> {
canvasWidget->drawTriangles(tris, color.value(Color::White).toRgba());
});
methods.registerMethod("drawText",
- [](CanvasWidgetPtr canvasWidget, String text, Json tp, unsigned fontSize, Maybe<Color> color, Maybe<float> lineSpacing, Maybe<String> directives) {
- canvasWidget->drawText(text, TextPositioning(tp), fontSize, color.value(Color::White).toRgba(), FontMode::Normal, lineSpacing.value(DefaultLineSpacing), directives.value(""));
+ [](CanvasWidgetPtr canvasWidget, String text, Json tp, unsigned fontSize, Maybe<Color> color, Maybe<float> lineSpacing, Maybe<String> font, Maybe<String> directives) {
+ canvasWidget->drawText(text, TextPositioning(tp), fontSize, color.value(Color::White).toRgba(), FontMode::Normal, lineSpacing.value(DefaultLineSpacing), font.value(""), directives.value(""));
});
return methods;