From 994c533a0f7b4aa1a1530405505a53546252e1d1 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Wed, 2 Aug 2023 19:29:21 +1000 Subject: [PATCH] Improve planet name title They began showing during the warp cinematic and their fade-out timing was wrong. --- assets/opensb/interface.config.patch | 3 +- source/frontend/StarMainInterface.cpp | 39 ++++++++++++++---------- source/frontend/StarNameplatePainter.cpp | 2 +- source/windowing/StarItemSlotWidget.cpp | 2 ++ source/windowing/StarLabelWidget.cpp | 6 ++++ source/windowing/StarLabelWidget.hpp | 2 ++ 6 files changed, 36 insertions(+), 18 deletions(-) diff --git a/assets/opensb/interface.config.patch b/assets/opensb/interface.config.patch index a6f5d89..3e2fc77 100644 --- a/assets/opensb/interface.config.patch +++ b/assets/opensb/interface.config.patch @@ -20,7 +20,8 @@ // Change planet name to support the new internal string formatting. "planetNameFormatString" : "- {} -", - + "planetNameDirectives" : "?border=4;000;000", + "buttonClickSound" : [ "/sfx/interface/button/click.wav" ], "buttonReleaseSound" : [ "/sfx/interface/button/release.wav" ], "buttonHoverSound" : [ "/sfx/interface/button/hover.wav" ], diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp index b43319f..4d8a22e 100644 --- a/source/frontend/StarMainInterface.cpp +++ b/source/frontend/StarMainInterface.cpp @@ -173,6 +173,7 @@ MainInterface::MainInterface(UniverseClientPtr client, WorldPainterPtr painter, auto planetName = make_shared(); m_planetText = make_shared(); m_planetText->setFontSize(m_config->planetNameFontSize); + m_planetText->setFontMode(FontMode::Normal); m_planetText->setAnchor(HorizontalAnchor::HMidAnchor, VerticalAnchor::VMidAnchor); m_planetText->setDirectives(m_config->planetNameDirectives); planetName->disableScissoring(); @@ -698,29 +699,35 @@ void MainInterface::update(float dt) { it++; } - auto worldId = m_client->playerWorld(); - if (worldId.is()) { - if (m_planetNameTimer.tick(dt)) + bool playerInWorld = m_client->mainPlayer()->inWorld(); + if (m_cinematicOverlay->completed()) { + if (m_planetNameTimer.tick(dt)) { m_paneManager.dismissRegisteredPane(MainInterfacePanes::PlanetText); - else - m_paneManager.displayRegisteredPane(MainInterfacePanes::PlanetText); + } else { + if (playerInWorld) { + String worldName; + if (auto worldTemplate = m_client->worldClient()->currentTemplate()) + worldName = worldTemplate->worldName(); - if (auto parameters = m_client->celestialDatabase()->parameters(worldId.get())) - m_planetText->setText(strf(m_config->planetNameFormatString.utf8Ptr(), parameters->name())); + if (!worldName.empty()) { + m_planetText->setText(strf(m_config->planetNameFormatString.utf8Ptr(), worldName)); + m_paneManager.displayRegisteredPane(MainInterfacePanes::PlanetText); + } + } - Color textColor = Color::White; // probably need to make this jsonable - float fadeTimer = m_planetNameTimer.percent(); - if (fadeTimer < m_config->planetNameFadeTime) - textColor.setAlphaF(fadeTimer / m_config->planetNameFadeTime); + Color textColor = Color::White; // probably need to make this jsonable + float fadeTimer = m_planetNameTimer.timer; + if (fadeTimer < m_config->planetNameFadeTime) + textColor.setAlphaF(fadeTimer / m_config->planetNameFadeTime); - m_planetText->setColor(textColor); - - } else { - m_paneManager.dismissRegisteredPane(MainInterfacePanes::PlanetText); + m_planetText->setColor(textColor); + } + } else if (!playerInWorld) { m_planetNameTimer.reset(); + m_paneManager.dismissRegisteredPane(MainInterfacePanes::PlanetText); } - for (auto containerResult : m_containerInteractor->pullContainerResults()) { + for (auto& containerResult : m_containerInteractor->pullContainerResults()) { if (!m_containerPane || !m_containerPane->giveContainerResult(containerResult)) { if (!m_inventoryWindow->giveContainerResult(containerResult)) { for (auto item : containerResult) { diff --git a/source/frontend/StarNameplatePainter.cpp b/source/frontend/StarNameplatePainter.cpp index c6bfe8a..fe9d829 100644 --- a/source/frontend/StarNameplatePainter.cpp +++ b/source/frontend/StarNameplatePainter.cpp @@ -87,7 +87,7 @@ void NameplatePainter::render() { auto color = Color::rgb(nametag.color); color.setAlphaF(nametag.opacity); context.setFontColor(color.toRgba()); - context.setFontMode(FontMode::Shadow); + context.setFontMode(FontMode::Normal); context.renderText(nametag.name, namePosition(bubble.currentPosition)); diff --git a/source/windowing/StarItemSlotWidget.cpp b/source/windowing/StarItemSlotWidget.cpp index 4d67175..2958957 100644 --- a/source/windowing/StarItemSlotWidget.cpp +++ b/source/windowing/StarItemSlotWidget.cpp @@ -189,6 +189,8 @@ void ItemSlotWidget::renderImpl() { context()->setFontColor(m_fontColor.toRgba()); context()->setFontMode(m_countFontMode); context()->renderInterfaceText(toString(m_item->count()), m_countPosition.translated(Vec2F(screenPosition()))); + context()->setFontMode(FontMode::Normal); + context()->setDefaultFont(); } } else if (m_drawBackingImageWhenEmpty && m_backingImage != "") { diff --git a/source/windowing/StarLabelWidget.cpp b/source/windowing/StarLabelWidget.cpp index cfc273c..30b1451 100644 --- a/source/windowing/StarLabelWidget.cpp +++ b/source/windowing/StarLabelWidget.cpp @@ -41,6 +41,10 @@ void LabelWidget::setFontSize(int fontSize) { updateTextRegion(); } +void LabelWidget::setFontMode(FontMode fontMode) { + m_fontMode = fontMode; +} + void LabelWidget::setColor(Color newColor) { m_color = move(newColor); } @@ -82,6 +86,7 @@ RectI LabelWidget::getScissorRect() const { void LabelWidget::renderImpl() { context()->setFont(m_font); context()->setFontSize(m_fontSize); + context()->setFontMode(m_fontMode); context()->setFontColor(m_color.toRgba()); context()->setFontProcessingDirectives(m_processingDirectives); @@ -93,6 +98,7 @@ void LabelWidget::renderImpl() { context()->renderInterfaceText(m_text, {Vec2F(screenPosition()), m_hAnchor, m_vAnchor, m_wrapWidth, m_textCharLimit}); context()->setDefaultFont(); + context()->setFontMode(FontMode::Normal); context()->setFontProcessingDirectives(""); context()->setDefaultLineSpacing(); } diff --git a/source/windowing/StarLabelWidget.hpp b/source/windowing/StarLabelWidget.hpp index 725354c..de692ce 100644 --- a/source/windowing/StarLabelWidget.hpp +++ b/source/windowing/StarLabelWidget.hpp @@ -19,6 +19,7 @@ public: Maybe getTextCharLimit() const; void setText(String newText); void setFontSize(int fontSize); + void setFontMode(FontMode fontMode); void setColor(Color newColor); void setAnchor(HorizontalAnchor hAnchor, VerticalAnchor vAnchor); void setWrapWidth(Maybe wrapWidth); @@ -37,6 +38,7 @@ private: String m_text; int m_fontSize; + FontMode m_fontMode; Color m_color; HorizontalAnchor m_hAnchor; VerticalAnchor m_vAnchor;