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: Improve planet name title They began showing during the warp cinematic and their fade-out timing was wrong. --- source/frontend/StarMainInterface.cpp | 41 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'source/frontend/StarMainInterface.cpp') 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); - - if (auto parameters = m_client->celestialDatabase()->parameters(worldId.get())) - m_planetText->setText(strf(m_config->planetNameFormatString.utf8Ptr(), parameters->name())); - - 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); + } else { + if (playerInWorld) { + String worldName; + if (auto worldTemplate = m_client->worldClient()->currentTemplate()) + worldName = worldTemplate->worldName(); + + if (!worldName.empty()) { + m_planetText->setText(strf(m_config->planetNameFormatString.utf8Ptr(), worldName)); + m_paneManager.displayRegisteredPane(MainInterfacePanes::PlanetText); + } + } - m_planetText->setColor(textColor); + 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); - } 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) { -- cgit v1.2.3