diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-21 00:58:49 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-21 00:58:49 +1000 |
commit | 4b0bc220e4da1173f742a4973939b139bef562db (patch) | |
tree | 0ff66d5957575fa814fc10b8cd93e3dd378f45dc /source/frontend | |
parent | 607be749451aa40e3619e7ceab0927d1fcec8233 (diff) |
Support for changing the game's timescale
Context-specific (like per-world) timescales can also be added later
Diffstat (limited to 'source/frontend')
57 files changed, 121 insertions, 116 deletions
diff --git a/source/frontend/StarActionBar.cpp b/source/frontend/StarActionBar.cpp index 5ccff7b..82eb7d2 100644 --- a/source/frontend/StarActionBar.cpp +++ b/source/frontend/StarActionBar.cpp @@ -173,7 +173,7 @@ bool ActionBar::sendEvent(InputEvent const& event) { return false; } -void ActionBar::update() { +void ActionBar::update(float dt) { auto inventory = m_player->inventory(); auto abl = inventory->selectedActionBarLocation(); if (abl.is<CustomBarIndex>()) { diff --git a/source/frontend/StarActionBar.hpp b/source/frontend/StarActionBar.hpp index 2239bda..883b364 100644 --- a/source/frontend/StarActionBar.hpp +++ b/source/frontend/StarActionBar.hpp @@ -22,7 +22,7 @@ public: PanePtr createTooltip(Vec2I const& screenPosition) override; bool sendEvent(InputEvent const& event) override; - void update() override; + void update(float dt) override; Maybe<String> cursorOverride(Vec2I const& screenPosition) override; diff --git a/source/frontend/StarAiInterface.cpp b/source/frontend/StarAiInterface.cpp index d9a543a..599b829 100644 --- a/source/frontend/StarAiInterface.cpp +++ b/source/frontend/StarAiInterface.cpp @@ -98,21 +98,21 @@ AiInterface::AiInterface(UniverseClientPtr client, CinematicPtr cinematic, MainI m_defaultRecruitDescription = assets->json("/interface/ai/ai.config:defaultRecruitDescription").toString(); } -void AiInterface::update() { +void AiInterface::update(float dt) { if (!m_client->playerOnOwnShip()) dismiss(); - Pane::update(); + Pane::update(dt); m_showCrewButton->setVisibility(m_currentPage == AiPages::StatusPage); m_showMissionsButton->setVisibility(m_currentPage == AiPages::StatusPage); m_backButton->setVisibility(m_currentPage != AiPages::StatusPage); - m_staticAnimation.update(WorldTimestep); - m_scanlineAnimation.update(WorldTimestep); + m_staticAnimation.update(dt); + m_scanlineAnimation.update(dt); if (m_currentSpeech) { - m_textLength += m_currentSpeech->speedModifier * m_aiDatabase->charactersPerSecond() * WorldTimestep; + m_textLength += m_currentSpeech->speedModifier * m_aiDatabase->charactersPerSecond() * dt; m_currentTextWidget->setText(m_currentSpeech->text); m_currentTextWidget->setTextCharLimit(min(m_textMaxLength, floor(m_textLength))); @@ -129,10 +129,10 @@ void AiInterface::update() { if (m_chatterSound) m_chatterSound->stop(); } - m_faceAnimation.second.update(WorldTimestep * m_currentSpeech->speedModifier); + m_faceAnimation.second.update(dt * m_currentSpeech->speedModifier); } else { setFaceAnimation("idle"); - m_faceAnimation.second.update(WorldTimestep); + m_faceAnimation.second.update(dt); if (m_chatterSound) m_chatterSound->stop(); } diff --git a/source/frontend/StarAiInterface.hpp b/source/frontend/StarAiInterface.hpp index 0b5e713..7a4a229 100644 --- a/source/frontend/StarAiInterface.hpp +++ b/source/frontend/StarAiInterface.hpp @@ -34,7 +34,7 @@ class AiInterface : public Pane { public: AiInterface(UniverseClientPtr client, CinematicPtr cinematic, MainInterfacePaneManager* paneManager); - void update() override; + void update(float dt) override; void displayed() override; void dismissed() override; diff --git a/source/frontend/StarBaseScriptPane.cpp b/source/frontend/StarBaseScriptPane.cpp index 0254e46..90d253c 100644 --- a/source/frontend/StarBaseScriptPane.cpp +++ b/source/frontend/StarBaseScriptPane.cpp @@ -71,8 +71,8 @@ void BaseScriptPane::dismissed() { m_script.uninit(); } -void BaseScriptPane::tick() { - Pane::tick(); +void BaseScriptPane::tick(float dt) { + Pane::tick(dt); for (auto p : m_canvasClickCallbacks) { for (auto const& clickEvent : p.first->pullClickEvents()) @@ -83,7 +83,7 @@ void BaseScriptPane::tick() { m_script.invoke(p.second, (int)keyEvent.key, keyEvent.keyDown); } - m_script.update(m_script.updateDt()); + m_script.update(m_script.updateDt(dt)); } bool BaseScriptPane::sendEvent(InputEvent const& event) { diff --git a/source/frontend/StarBaseScriptPane.hpp b/source/frontend/StarBaseScriptPane.hpp index b5aa502..4a47a4a 100644 --- a/source/frontend/StarBaseScriptPane.hpp +++ b/source/frontend/StarBaseScriptPane.hpp @@ -22,7 +22,7 @@ public: void displayed() override; void dismissed() override; - void tick() override; + void tick(float dt) override; bool sendEvent(InputEvent const& event) override; diff --git a/source/frontend/StarCharCreation.cpp b/source/frontend/StarCharCreation.cpp index d873a72..440902c 100644 --- a/source/frontend/StarCharCreation.cpp +++ b/source/frontend/StarCharCreation.cpp @@ -183,13 +183,13 @@ void CharCreationPane::randomize() { changed(); } -void CharCreationPane::tick() { - Pane::tick(); +void CharCreationPane::tick(float dt) { + Pane::tick(dt); if (!active()) return; if (!m_previewPlayer) return; - m_previewPlayer->animatePortrait(); + m_previewPlayer->animatePortrait(dt); } bool CharCreationPane::sendEvent(InputEvent const& event) { diff --git a/source/frontend/StarCharCreation.hpp b/source/frontend/StarCharCreation.hpp index 272ea71..7a52f4f 100644 --- a/source/frontend/StarCharCreation.hpp +++ b/source/frontend/StarCharCreation.hpp @@ -23,7 +23,7 @@ public: void randomize(); void randomizeName(); - virtual void tick() override; + virtual void tick(float dt) override; virtual bool sendEvent(InputEvent const& event) override; virtual PanePtr createTooltip(Vec2I const&) override; diff --git a/source/frontend/StarChat.cpp b/source/frontend/StarChat.cpp index 7b75f2d..72c1409 100644 --- a/source/frontend/StarChat.cpp +++ b/source/frontend/StarChat.cpp @@ -95,8 +95,8 @@ Chat::Chat(UniverseClientPtr client) : m_client(client) { updateSize(); } -void Chat::update() { - Pane::update(); +void Chat::update(float dt) { + Pane::update(dt); auto team = m_client->teamClient()->currentTeam(); for (auto button : fetchChild<ButtonGroup>("filterGroup")->buttons()) { diff --git a/source/frontend/StarChat.hpp b/source/frontend/StarChat.hpp index e88a797..7d9d127 100644 --- a/source/frontend/StarChat.hpp +++ b/source/frontend/StarChat.hpp @@ -26,7 +26,7 @@ public: virtual void renderImpl() override; virtual void hide() override; - virtual void update() override; + virtual void update(float dt) override; void addLine(String const& text, bool showPane = true); void addMessages(List<ChatReceivedMessage> const& messages, bool showPane = true); diff --git a/source/frontend/StarChatBubbleManager.cpp b/source/frontend/StarChatBubbleManager.cpp index b9077fe..166eba0 100644 --- a/source/frontend/StarChatBubbleManager.cpp +++ b/source/frontend/StarChatBubbleManager.cpp @@ -86,9 +86,9 @@ void ChatBubbleManager::setCamera(WorldCamera const& camera) { } } -void ChatBubbleManager::update(WorldClientPtr world) { - m_bubbles.forEach([this, &world](BubbleState<Bubble>& bubbleState, Bubble& bubble) { - bubble.age += WorldTimestep; +void ChatBubbleManager::update(float dt, WorldClientPtr world) { + m_bubbles.forEach([this, dt, &world](BubbleState<Bubble>& bubbleState, Bubble& bubble) { + bubble.age += dt; if (auto entity = world->get<ChattyEntity>(bubble.entity)) { bubble.onscreen = m_camera.worldGeometry().rectIntersectsRect( m_camera.worldScreenRect(), entity->metaBoundBox().translated(entity->position())); @@ -97,7 +97,7 @@ void ChatBubbleManager::update(WorldClientPtr world) { }); for (auto& portraitBubble : m_portraitBubbles) { - portraitBubble.age += WorldTimestep; + portraitBubble.age += dt; if (auto entity = world->entity(portraitBubble.entity)) { portraitBubble.onscreen = m_camera.worldGeometry().rectIntersectsRect(m_camera.worldScreenRect(), entity->metaBoundBox().translated(entity->position())); if (auto chatter = as<ChattyEntity>(entity)) @@ -125,7 +125,7 @@ void ChatBubbleManager::update(WorldClientPtr world) { return false; }); - m_bubbles.update(); + m_bubbles.update(dt); } uint8_t ChatBubbleManager::calcDistanceFadeAlpha(Vec2F bubbleScreenPosition, StoredFunctionPtr fadeFunction) const { diff --git a/source/frontend/StarChatBubbleManager.hpp b/source/frontend/StarChatBubbleManager.hpp index b23037a..9d8a867 100644 --- a/source/frontend/StarChatBubbleManager.hpp +++ b/source/frontend/StarChatBubbleManager.hpp @@ -22,7 +22,7 @@ public: void addChatActions(List<ChatAction> chatActions, bool silent = false); - void update(WorldClientPtr world); + void update(float dt, WorldClientPtr world); void render(); private: diff --git a/source/frontend/StarChatBubbleSeparation.hpp b/source/frontend/StarChatBubbleSeparation.hpp index 756db27..4bbf018 100644 --- a/source/frontend/StarChatBubbleSeparation.hpp +++ b/source/frontend/StarChatBubbleSeparation.hpp @@ -52,7 +52,7 @@ public: List<Bubble> filtered(function<bool(Bubble const&, T const&)> func); void forEach(function<void(Bubble&, T&)> func); - void update(); + void update(float dt); void clear(); bool empty() const; @@ -170,7 +170,7 @@ void BubbleSeparator<T>::forEach(function<void(Bubble&, T&)> func) { } template <typename T> -void BubbleSeparator<T>::update() { +void BubbleSeparator<T>::update(float dt) { m_bubbles.exec([this](Bubble& bubble) { Vec2F delta = bubble.seperatedOffset - bubble.currentOffset; bubble.currentOffset += m_tweenFactor * delta; diff --git a/source/frontend/StarCinematic.cpp b/source/frontend/StarCinematic.cpp index bf39bd0..40fc8d1 100644 --- a/source/frontend/StarCinematic.cpp +++ b/source/frontend/StarCinematic.cpp @@ -103,7 +103,7 @@ void Cinematic::setPlayer(PlayerPtr player) { m_player = player; } -void Cinematic::update() { +void Cinematic::update(float dt) { m_currentTimeSkip = {}; for (auto timeSkip : m_timeSkips) { if (currentTimecode() >= timeSkip.availableTime && currentTimecode() < timeSkip.skipToTime) diff --git a/source/frontend/StarCinematic.hpp b/source/frontend/StarCinematic.hpp index 0939369..96f40e7 100644 --- a/source/frontend/StarCinematic.hpp +++ b/source/frontend/StarCinematic.hpp @@ -22,7 +22,7 @@ public: void setPlayer(PlayerPtr player); - void update(); + void update(float dt); void render(); bool completed() const; diff --git a/source/frontend/StarCodexInterface.cpp b/source/frontend/StarCodexInterface.cpp index aca0930..dcd82f3 100644 --- a/source/frontend/StarCodexInterface.cpp +++ b/source/frontend/StarCodexInterface.cpp @@ -50,7 +50,7 @@ void CodexInterface::show() { updateCodexList(); } -void CodexInterface::tick() { +void CodexInterface::tick(float dt) { updateCodexList(); } diff --git a/source/frontend/StarCodexInterface.hpp b/source/frontend/StarCodexInterface.hpp index 0f4b549..bd8e103 100644 --- a/source/frontend/StarCodexInterface.hpp +++ b/source/frontend/StarCodexInterface.hpp @@ -21,7 +21,7 @@ public: CodexInterface(PlayerPtr player); virtual void show() override; - virtual void tick() override; + virtual void tick(float dt) override; void showTitles(); void showSelectedContents(); diff --git a/source/frontend/StarContainerInterface.cpp b/source/frontend/StarContainerInterface.cpp index 5a69fda..6540dfb 100644 --- a/source/frontend/StarContainerInterface.cpp +++ b/source/frontend/StarContainerInterface.cpp @@ -258,11 +258,11 @@ void ContainerPane::burn() { m_containerInteractor->burnContainer(); } -void ContainerPane::update() { - Pane::update(); +void ContainerPane::update(float dt) { + Pane::update(dt); if (m_script) - m_script->update(m_script->updateDt()); + m_script->update(m_script->updateDt(dt)); m_itemBag->clearItems(); diff --git a/source/frontend/StarContainerInterface.hpp b/source/frontend/StarContainerInterface.hpp index dee1e07..811be89 100644 --- a/source/frontend/StarContainerInterface.hpp +++ b/source/frontend/StarContainerInterface.hpp @@ -27,7 +27,7 @@ public: bool giveContainerResult(ContainerResult result); protected: - void update() override; + void update(float dt) override; private: enum class ExpectingSwap { diff --git a/source/frontend/StarCraftingInterface.cpp b/source/frontend/StarCraftingInterface.cpp index df0100a..5ad25ce 100644 --- a/source/frontend/StarCraftingInterface.cpp +++ b/source/frontend/StarCraftingInterface.cpp @@ -226,7 +226,7 @@ size_t CraftingPane::itemCount(List<ItemPtr> const& store, ItemDescriptor const& return itemDb->getCountOfItem(store, item); } -void CraftingPane::update() { +void CraftingPane::update(float dt) { // shut down if we can't reach the table anymore. if (m_sourceEntityId != NullEntityId) { auto sourceEntity = as<TileEntity>(m_worldClient->entity(m_sourceEntityId)); @@ -296,7 +296,7 @@ void CraftingPane::update() { setLabel("lblPlayerMoney", toString((int)m_player->currency("money"))); - Pane::update(); + Pane::update(dt); } void CraftingPane::updateCraftButtons() { diff --git a/source/frontend/StarCraftingInterface.hpp b/source/frontend/StarCraftingInterface.hpp index 282729a..33c1e32 100644 --- a/source/frontend/StarCraftingInterface.hpp +++ b/source/frontend/StarCraftingInterface.hpp @@ -34,7 +34,7 @@ private: List<ItemRecipe> determineRecipes(); - virtual void update() override; + virtual void update(float dt) override; void updateCraftButtons(); void updateAvailableRecipes(); bool consumeIngredients(ItemRecipe& recipe, int count); diff --git a/source/frontend/StarErrorScreen.cpp b/source/frontend/StarErrorScreen.cpp index 9162e5b..1dc5f12 100644 --- a/source/frontend/StarErrorScreen.cpp +++ b/source/frontend/StarErrorScreen.cpp @@ -70,12 +70,12 @@ bool ErrorScreen::handleInputEvent(InputEvent const& event) { return m_paneManager->sendInputEvent(event); } -void ErrorScreen::update() { - m_paneManager->update(); +void ErrorScreen::update(float dt) { + m_paneManager->update(dt); + m_cursor.update(dt); } void ErrorScreen::renderCursor() { - m_cursor.update(WorldTimestep); Vec2I cursorPos = m_cursorScreenPos; Vec2I cursorSize = m_cursor.size(); Vec2I cursorOffset = m_cursor.offset(); diff --git a/source/frontend/StarErrorScreen.hpp b/source/frontend/StarErrorScreen.hpp index eb1f73e..e16d6f4 100644 --- a/source/frontend/StarErrorScreen.hpp +++ b/source/frontend/StarErrorScreen.hpp @@ -26,7 +26,7 @@ public: void render(bool useBackdrop = false); bool handleInputEvent(InputEvent const& event); - void update(); + void update(float dt); private: void renderCursor(); diff --git a/source/frontend/StarInventory.cpp b/source/frontend/StarInventory.cpp index 850eedf..bcc2c15 100644 --- a/source/frontend/StarInventory.cpp +++ b/source/frontend/StarInventory.cpp @@ -236,7 +236,7 @@ bool InventoryPane::containsNewItems() const { return false; } -void InventoryPane::update() { +void InventoryPane::update(float dt) { auto inventory = m_player->inventory(); auto context = Widget::context(); @@ -255,7 +255,7 @@ void InventoryPane::update() { m_trashSlot->setItem(inventory->itemsAt(TrashSlot())); m_trashSlot->showLinkIndicator(customBarItems.contains(m_trashSlot->item())); if (auto trashItem = m_trashSlot->item()) { - if (m_trashBurn.tick() && trashItem->count() > 0) { + if (m_trashBurn.tick(dt) && trashItem->count() > 0) { m_player->statistics()->recordEvent("trashItem", JsonObject{ {"itemName", trashItem->name()}, {"count", trashItem->count()}, diff --git a/source/frontend/StarInventory.hpp b/source/frontend/StarInventory.hpp index 035045c..cb5deed 100644 --- a/source/frontend/StarInventory.hpp +++ b/source/frontend/StarInventory.hpp @@ -35,7 +35,7 @@ public: bool containsNewItems() const; protected: - virtual void update() override; + virtual void update(float dt) override; void selectTab(String const& selected); private: diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp index 0dc3a01..526ab99 100644 --- a/source/frontend/StarMainInterface.cpp +++ b/source/frontend/StarMainInterface.cpp @@ -520,8 +520,9 @@ void MainInterface::handleInteractAction(InteractAction interactAction) { } } -void MainInterface::update() { - m_paneManager.update(); +void MainInterface::update(float dt) { + m_paneManager.update(dt); + m_cursor.update(dt); m_questLogInterface->pollDialog(&m_paneManager); @@ -544,7 +545,7 @@ void MainInterface::update() { // update mouseover target EntityId newMouseOverTarget = NullEntityId; - m_stickyTargetingTimer.tick(); + m_stickyTargetingTimer.tick(dt); auto mouseoverEntities = m_client->worldClient()->query<DamageBarEntity>(RectF::withCenter(cursorWorldPos, Vec2F(1, 1)), [=](shared_ptr<DamageBarEntity> const& entity) { return entity != player && entity->damageBar() == DamageBarType::Default @@ -578,10 +579,10 @@ void MainInterface::update() { if (damageBarEntity && damageBarEntity->damageBar() == DamageBarType::Special) { float targetHealth = damageBarEntity->health() / damageBarEntity->maxHealth(); float fillSpeed = 1.0f / Root::singleton().assets()->json("/interface.config:specialDamageBar.fillTime").toFloat(); - if (abs(targetHealth - m_specialDamageBarValue) < fillSpeed * WorldTimestep) + if (abs(targetHealth - m_specialDamageBarValue) < fillSpeed * dt) m_specialDamageBarValue = targetHealth; else - m_specialDamageBarValue += copysign(1.0f, targetHealth - m_specialDamageBarValue) * fillSpeed * WorldTimestep; + m_specialDamageBarValue += copysign(1.0f, targetHealth - m_specialDamageBarValue) * fillSpeed * dt; } else { m_specialDamageBarTarget = NullEntityId; } @@ -696,7 +697,7 @@ void MainInterface::update() { for (auto it = m_messages.begin(); it != m_messages.end();) { auto& message = *it; - message->cooldown -= WorldTimestep; + message->cooldown -= dt; if (message->cooldown < 0) it = m_messages.erase(it); else @@ -713,7 +714,7 @@ void MainInterface::update() { auto worldId = m_client->playerWorld(); if (worldId.is<CelestialWorldId>()) { - if (m_planetNameTimer.tick()) + if (m_planetNameTimer.tick(dt)) m_paneManager.dismissRegisteredPane(MainInterfacePanes::PlanetText); else m_paneManager.displayRegisteredPane(MainInterfacePanes::PlanetText); @@ -755,8 +756,8 @@ void MainInterface::update() { updateCursor(); - m_nameplatePainter->update(m_client->worldClient(), m_worldPainter->camera(), m_client->worldClient()->interactiveHighlightMode()); - m_questIndicatorPainter->update(m_client->worldClient(), m_worldPainter->camera()); + m_nameplatePainter->update(dt, m_client->worldClient(), m_worldPainter->camera(), m_client->worldClient()->interactiveHighlightMode()); + m_questIndicatorPainter->update(dt, m_client->worldClient(), m_worldPainter->camera()); m_chatBubbleManager->setCamera(m_worldPainter->camera()); if (auto worldClient = m_client->worldClient()) { @@ -781,7 +782,7 @@ void MainInterface::update() { } m_chatBubbleManager->addChatActions(chatActions); - m_chatBubbleManager->update(worldClient); + m_chatBubbleManager->update(dt, worldClient); } if (auto container = m_client->worldClient()->get<ContainerEntity>(m_containerInteractor->openContainerId())) { @@ -803,7 +804,7 @@ void MainInterface::update() { pair.second->setSize(Vec2I(m_guiContext->windowSize())); else pair.second->setSize(Vec2I(m_guiContext->windowInterfaceSize())); - pair.second->update(); + pair.second->update(dt); } } @@ -1427,8 +1428,6 @@ void MainInterface::renderCursor() { if (m_cinematicOverlay && !m_cinematicOverlay->completed()) return m_guiContext->applicationController()->setCursorVisible(false); - m_cursor.update(WorldTimestep); - Vec2I cursorPos = m_cursorScreenPos; Vec2I cursorSize = m_cursor.size(); Vec2I cursorOffset = m_cursor.offset(); diff --git a/source/frontend/StarMainInterface.hpp b/source/frontend/StarMainInterface.hpp index 9cf2342..ddc4d3d 100644 --- a/source/frontend/StarMainInterface.hpp +++ b/source/frontend/StarMainInterface.hpp @@ -91,7 +91,7 @@ public: void handleInteractAction(InteractAction interactAction); // Handles incoming client messages, aims main player, etc. - void update(); + void update(float dt); // Render things e.g. quest indicators that should be drawn in the world // behind interface e.g. chat bubbles diff --git a/source/frontend/StarMainMixer.cpp b/source/frontend/StarMainMixer.cpp index d4a2e73..219daa2 100644 --- a/source/frontend/StarMainMixer.cpp +++ b/source/frontend/StarMainMixer.cpp @@ -23,7 +23,7 @@ void MainMixer::setWorldPainter(WorldPainterPtr worldPainter) { m_worldPainter = move(worldPainter); } -void MainMixer::update(bool muteSfx, bool muteMusic) { +void MainMixer::update(float dt, bool muteSfx, bool muteMusic) { auto assets = Root::singleton().assets(); auto updateGroupVolume = [&](MixerGroup group, bool muted, String const& settingName) { @@ -111,9 +111,9 @@ void MainMixer::update(bool muteSfx, bool muteMusic) { }; if (Voice* voice = Voice::singletonPtr()) - voice->update(attenuationFunction); + voice->update(dt, attenuationFunction); - m_mixer->update(attenuationFunction); + m_mixer->update(dt, attenuationFunction); } else { if (m_mixer->hasEffect("lowpass")) @@ -122,9 +122,9 @@ void MainMixer::update(bool muteSfx, bool muteMusic) { m_mixer->removeEffect("echo", 0); if (Voice* voice = Voice::singletonPtr()) - voice->update(); + voice->update(dt); - m_mixer->update(); + m_mixer->update(dt); } } @@ -132,6 +132,10 @@ MixerPtr MainMixer::mixer() const { return m_mixer; } +void MainMixer::setSpeed(float speed) { + m_mixer->setSpeed(max(speed, 0.0f)); +} + void MainMixer::setVolume(float volume, float rampTime) { m_mixer->setVolume(volume, rampTime); } diff --git a/source/frontend/StarMainMixer.hpp b/source/frontend/StarMainMixer.hpp index 2582a2f..9e5ba3f 100644 --- a/source/frontend/StarMainMixer.hpp +++ b/source/frontend/StarMainMixer.hpp @@ -17,10 +17,11 @@ public: void setUniverseClient(UniverseClientPtr universeClient); void setWorldPainter(WorldPainterPtr worldPainter); - void update(bool muteSfx = false, bool muteMusic = false); + void update(float dt, bool muteSfx = false, bool muteMusic = false); MixerPtr mixer() const; + void setSpeed(float speed); void setVolume(float volume, float rampTime = 0.0f); void read(int16_t* sampleData, size_t frameCount, Mixer::ExtraMixFunction = {}); diff --git a/source/frontend/StarMerchantInterface.cpp b/source/frontend/StarMerchantInterface.cpp index c4b1047..8e3ad3a 100644 --- a/source/frontend/StarMerchantInterface.cpp +++ b/source/frontend/StarMerchantInterface.cpp @@ -138,8 +138,8 @@ PanePtr MerchantPane::createTooltip(Vec2I const& screenPosition) { return {}; } -void MerchantPane::update() { - Pane::update(); +void MerchantPane::update(float dt) { + Pane::update(dt); if (!m_worldClient->playerCanReachEntity(m_sourceEntityId)) dismiss(); diff --git a/source/frontend/StarMerchantInterface.hpp b/source/frontend/StarMerchantInterface.hpp index a4ac0c8..d123c9b 100644 --- a/source/frontend/StarMerchantInterface.hpp +++ b/source/frontend/StarMerchantInterface.hpp @@ -30,7 +30,7 @@ public: ItemPtr addItems(ItemPtr const& items); protected: - void update() override; + void update(float dt) override; private: void swapSlot(); diff --git a/source/frontend/StarModsMenu.cpp b/source/frontend/StarModsMenu.cpp index eeceb72..039a94a 100644 --- a/source/frontend/StarModsMenu.cpp +++ b/source/frontend/StarModsMenu.cpp @@ -51,8 +51,8 @@ ModsMenu::ModsMenu() { copyLinkLabel->setVisibility(!hasDesktopService); } -void ModsMenu::update() { - Pane::update(); +void ModsMenu::update(float dt) { + Pane::update(dt); size_t selectedItem = m_modList->selectedItem(); if (selectedItem == NPos) { diff --git a/source/frontend/StarModsMenu.hpp b/source/frontend/StarModsMenu.hpp index a9e8739..e73ac23 100644 --- a/source/frontend/StarModsMenu.hpp +++ b/source/frontend/StarModsMenu.hpp @@ -13,7 +13,7 @@ class ModsMenu : public Pane { public: ModsMenu(); - void update() override; + void update(float dt) override; private: static String bestModName(JsonObject const& metadata, String const& sourcePath); diff --git a/source/frontend/StarNameplatePainter.cpp b/source/frontend/StarNameplatePainter.cpp index 06ffabb..c6bfe8a 100644 --- a/source/frontend/StarNameplatePainter.cpp +++ b/source/frontend/StarNameplatePainter.cpp @@ -28,7 +28,7 @@ NameplatePainter::NameplatePainter() { m_nametags.setMovementThreshold(nametagConfig.getFloat("movementThreshold")); } -void NameplatePainter::update(WorldClientPtr const& world, WorldCamera const& camera, bool inspectionMode) { +void NameplatePainter::update(float dt, WorldClientPtr const& world, WorldCamera const& camera, bool inspectionMode) { m_camera = camera; Set<EntityId> foundEntities; @@ -70,7 +70,7 @@ void NameplatePainter::update(WorldClientPtr const& world, WorldCamera const& ca }); m_entitiesWithNametags = move(foundEntities); - m_nametags.update(); + m_nametags.update(dt); } void NameplatePainter::render() { diff --git a/source/frontend/StarNameplatePainter.hpp b/source/frontend/StarNameplatePainter.hpp index 08c7827..7c3aeb4 100644 --- a/source/frontend/StarNameplatePainter.hpp +++ b/source/frontend/StarNameplatePainter.hpp @@ -15,7 +15,7 @@ class NameplatePainter { public: NameplatePainter(); - void update(WorldClientPtr const& world, WorldCamera const& camera, bool inspectionMode); + void update(float dt, WorldClientPtr const& world, WorldCamera const& camera, bool inspectionMode); void render(); private: diff --git a/source/frontend/StarQuestIndicatorPainter.cpp b/source/frontend/StarQuestIndicatorPainter.cpp index d144021..cad4ace 100644 --- a/source/frontend/StarQuestIndicatorPainter.cpp +++ b/source/frontend/StarQuestIndicatorPainter.cpp @@ -16,7 +16,7 @@ AnimationPtr indicatorAnimation(String indicatorPath) { return make_shared<Animation>(assets->json(indicatorPath), indicatorPath); } -void QuestIndicatorPainter::update(WorldClientPtr const& world, WorldCamera const& camera) { +void QuestIndicatorPainter::update(float dt, WorldClientPtr const& world, WorldCamera const& camera) { m_camera = camera; Set<EntityId> foundIndicators; @@ -30,7 +30,7 @@ void QuestIndicatorPainter::update(WorldClientPtr const& world, WorldCamera cons if (auto currentIndicator = m_indicators.ptr(entity->entityId())) { currentIndicator->screenPos = screenPos; if (currentIndicator->indicatorName == indicator->indicatorImage) { - currentIndicator->animation->update(WorldTimestep); + currentIndicator->animation->update(dt); } else { currentIndicator->indicatorName = indicator->indicatorImage; currentIndicator->animation = indicatorAnimation(indicator->indicatorImage); diff --git a/source/frontend/StarQuestIndicatorPainter.hpp b/source/frontend/StarQuestIndicatorPainter.hpp index 311680d..c222ac4 100644 --- a/source/frontend/StarQuestIndicatorPainter.hpp +++ b/source/frontend/StarQuestIndicatorPainter.hpp @@ -13,7 +13,7 @@ class QuestIndicatorPainter { public: QuestIndicatorPainter(UniverseClientPtr const& client); - void update(WorldClientPtr const& world, WorldCamera const& camera); + void update(float dt, WorldClientPtr const& world, WorldCamera const& camera); void render(); private: diff --git a/source/frontend/StarQuestInterface.cpp b/source/frontend/StarQuestInterface.cpp index 324cbd8..d9f0b1b 100644 --- a/source/frontend/StarQuestInterface.cpp +++ b/source/frontend/StarQuestInterface.cpp @@ -93,12 +93,12 @@ void QuestLogInterface::pollDialog(PaneManager* paneManager) { void QuestLogInterface::displayed() { Pane::displayed(); - tick(); + tick(0); fetchData(); } -void QuestLogInterface::tick() { - Pane::tick(); +void QuestLogInterface::tick(float dt) { + Pane::tick(dt); auto selected = getSelected(); if (selected && m_manager->hasQuest(selected->data().toString())) { auto quest = m_manager->getQuest(selected->data().toString()); @@ -284,7 +284,7 @@ void QuestLogInterface::showQuests(List<QuestPtr> quests) { } auto verticalLayout = fetchChild<VerticalLayout>("scrollArea.verticalLayout"); - verticalLayout->update(); + verticalLayout->update(0); } QuestPane::QuestPane(QuestPtr const& quest, PlayerPtr player) : Pane(), m_quest(quest), m_player(move(player)) {} diff --git a/source/frontend/StarQuestInterface.hpp b/source/frontend/StarQuestInterface.hpp index d7d68e8..366d4ac 100644 --- a/source/frontend/StarQuestInterface.hpp +++ b/source/frontend/StarQuestInterface.hpp @@ -19,7 +19,7 @@ public: virtual ~QuestLogInterface() {} virtual void displayed() override; - virtual void tick() override; + virtual void tick(float dt) override; virtual PanePtr createTooltip(Vec2I const& screenPosition) override; void fetchData(); diff --git a/source/frontend/StarQuestTracker.cpp b/source/frontend/StarQuestTracker.cpp index cb603b4..747852a 100644 --- a/source/frontend/StarQuestTracker.cpp +++ b/source/frontend/StarQuestTracker.cpp @@ -71,7 +71,7 @@ bool QuestTrackerPane::sendEvent(InputEvent const& event) { return false; } -void QuestTrackerPane::update() { +void QuestTrackerPane::update(float dt) { if (m_currentQuest) { if (auto objectiveList = m_currentQuest->objectiveList()) { if (objectiveList->size() == 0) { @@ -172,7 +172,7 @@ void QuestTrackerPane::update() { } } - Pane::update(); + Pane::update(dt); } void QuestTrackerPane::setQuest(QuestPtr const& quest) { diff --git a/source/frontend/StarQuestTracker.hpp b/source/frontend/StarQuestTracker.hpp index 226b520..4fbeb7a 100644 --- a/source/frontend/StarQuestTracker.hpp +++ b/source/frontend/StarQuestTracker.hpp @@ -16,7 +16,7 @@ public: QuestTrackerPane(); bool sendEvent(InputEvent const& event) override; - void update() override; + void update(float dt) override; void setQuest(QuestPtr const& quest); diff --git a/source/frontend/StarRadioMessagePopup.cpp b/source/frontend/StarRadioMessagePopup.cpp index f7c9061..503f2d1 100644 --- a/source/frontend/StarRadioMessagePopup.cpp +++ b/source/frontend/StarRadioMessagePopup.cpp @@ -44,9 +44,9 @@ RadioMessagePopup::RadioMessagePopup() { enterStage(PopupStage::Hidden); } -void RadioMessagePopup::update() { +void RadioMessagePopup::update(float dt) { if (messageActive()) { - if (m_stageTimer.tick()) + if (m_stageTimer.tick(dt)) nextPopupStage(); if (m_popupStage == PopupStage::AnimateIn) { @@ -65,11 +65,11 @@ void RadioMessagePopup::update() { setBG("", strf("{}:{}", m_animateOutImage, frame), ""); } - m_slideTimer = min(m_slideTimer + WorldTimestep, m_slideTime); + m_slideTimer = min(m_slideTimer + dt, m_slideTime); updateAnchorOffset(); } - Pane::update(); + Pane::update(dt); } void RadioMessagePopup::dismissed() { diff --git a/source/frontend/StarRadioMessagePopup.hpp b/source/frontend/StarRadioMessagePopup.hpp index 11c18d5..d1d6c11 100644 --- a/source/frontend/StarRadioMessagePopup.hpp +++ b/source/frontend/StarRadioMessagePopup.hpp @@ -16,7 +16,7 @@ class RadioMessagePopup : public Pane { public: RadioMessagePopup(); - void update() override; + void update(float dt) override; void dismissed() override; bool messageActive(); diff --git a/source/frontend/StarScriptPane.cpp b/source/frontend/StarScriptPane.cpp index 3de3c26..2cd74a5 100644 --- a/source/frontend/StarScriptPane.cpp +++ b/source/frontend/StarScriptPane.cpp @@ -47,11 +47,11 @@ void ScriptPane::dismissed() { m_script.removeCallbacks("world"); } -void ScriptPane::tick() { +void ScriptPane::tick(float dt) { if (m_sourceEntityId != NullEntityId && !m_client->worldClient()->playerCanReachEntity(m_sourceEntityId)) dismiss(); - BaseScriptPane::tick(); + BaseScriptPane::tick(dt); } PanePtr ScriptPane::createTooltip(Vec2I const& screenPosition) { diff --git a/source/frontend/StarScriptPane.hpp b/source/frontend/StarScriptPane.hpp index 229ebbb..e7ed2ae 100644 --- a/source/frontend/StarScriptPane.hpp +++ b/source/frontend/StarScriptPane.hpp @@ -16,7 +16,7 @@ public: void displayed() override; void dismissed() override; - void tick() override; + void tick(float dt) override; PanePtr createTooltip(Vec2I const& screenPosition) override; diff --git a/source/frontend/StarStatusPane.cpp b/source/frontend/StarStatusPane.cpp index e325a88..d1bedbb 100644 --- a/source/frontend/StarStatusPane.cpp +++ b/source/frontend/StarStatusPane.cpp @@ -58,8 +58,8 @@ void StatusPane::renderImpl() { } } -void StatusPane::update() { - Pane::update(); +void StatusPane::update(float dt) { + Pane::update(dt); auto assets = Root::singleton().assets(); auto interfaceScale = m_guiContext->interfaceScale(); diff --git a/source/frontend/StarStatusPane.hpp b/source/frontend/StarStatusPane.hpp index 54a87a3..5deba33 100644 --- a/source/frontend/StarStatusPane.hpp +++ b/source/frontend/StarStatusPane.hpp @@ -18,7 +18,7 @@ public: protected: virtual void renderImpl() override; - virtual void update() override; + virtual void update(float dt) override; private: struct StatusEffectIndicator { diff --git a/source/frontend/StarTeamBar.cpp b/source/frontend/StarTeamBar.cpp index 06b3ee7..192edfa 100644 --- a/source/frontend/StarTeamBar.cpp +++ b/source/frontend/StarTeamBar.cpp @@ -80,8 +80,8 @@ void TeamBar::acceptInvitation(Uuid const& inviterUuid) { m_client->teamClient()->acceptInvitation(inviterUuid); } -void TeamBar::update() { - Pane::update(); +void TeamBar::update(float dt) { + Pane::update(dt); updatePlayerResources(); @@ -338,7 +338,7 @@ void TeamMemberMenu::open(Uuid memberUuid, Vec2I position) { Pane::show(); } -void TeamMemberMenu::update() { +void TeamMemberMenu::update(float dt) { auto stillValid = false; auto members = m_owner->m_client->teamClient()->members(); for (auto member : members) { @@ -355,7 +355,7 @@ void TeamMemberMenu::update() { updateWidgets(); - Pane::update(); + Pane::update(dt); } void TeamMemberMenu::updateWidgets() { diff --git a/source/frontend/StarTeamBar.hpp b/source/frontend/StarTeamBar.hpp index 8273ab6..9ebbb50 100644 --- a/source/frontend/StarTeamBar.hpp +++ b/source/frontend/StarTeamBar.hpp @@ -52,7 +52,7 @@ public: void open(Uuid memberUuid, Vec2I position); - virtual void update() override; + virtual void update(float dt) override; private: void updateWidgets(); @@ -77,7 +77,7 @@ public: void acceptInvitation(Uuid const& inviterUuid); protected: - virtual void update() override; + virtual void update(float dt) override; private: void updatePlayerResources(); diff --git a/source/frontend/StarTeleportDialog.cpp b/source/frontend/StarTeleportDialog.cpp index 76f0310..01c6a69 100644 --- a/source/frontend/StarTeleportDialog.cpp +++ b/source/frontend/StarTeleportDialog.cpp @@ -120,7 +120,7 @@ TeleportDialog::TeleportDialog(UniverseClientPtr client, fetchChild<ButtonWidget>("btnTeleport")->setEnabled(destList->selectedItem() != NPos); } -void TeleportDialog::tick() { +void TeleportDialog::tick(float dt) { if (!m_client->worldClient()->playerCanReachEntity(m_sourceEntityId)) dismiss(); } diff --git a/source/frontend/StarTeleportDialog.hpp b/source/frontend/StarTeleportDialog.hpp index 445f73a..3dea84d 100644 --- a/source/frontend/StarTeleportDialog.hpp +++ b/source/frontend/StarTeleportDialog.hpp @@ -19,7 +19,7 @@ public: EntityId sourceEntityId, TeleportBookmark currentLocation); - void tick() override; + void tick(float dt) override; void selectDestination(); void teleport(); diff --git a/source/frontend/StarTitleScreen.cpp b/source/frontend/StarTitleScreen.cpp index 842efc9..f9f16bd 100644 --- a/source/frontend/StarTitleScreen.cpp +++ b/source/frontend/StarTitleScreen.cpp @@ -114,15 +114,17 @@ bool TitleScreen::handleInputEvent(InputEvent const& event) { return m_paneManager.sendInputEvent(event); } -void TitleScreen::update() { +void TitleScreen::update(float dt) { + m_cursor.update(dt); + for (auto p : m_rightAnchoredButtons) p.first->setPosition(Vec2I(m_guiContext->windowWidth() / m_guiContext->interfaceScale(), 0) + p.second); m_mainMenu->determineSizeFromChildren(); - m_skyBackdrop->update(); - m_environmentPainter->update(); + m_skyBackdrop->update(dt); + m_environmentPainter->update(dt); - m_paneManager.update(); + m_paneManager.update(dt); if (!finishedState()) { if (auto audioSample = m_musicTrackManager.updateAmbient(m_musicTrack, m_skyBackdrop->isDayTime())) { @@ -423,7 +425,6 @@ void TitleScreen::back() { void TitleScreen::renderCursor() { auto assets = Root::singleton().assets(); - m_cursor.update(WorldTimestep); Vec2I cursorPos = m_cursorScreenPos; Vec2I cursorSize = m_cursor.size(); Vec2I cursorOffset = m_cursor.offset(); diff --git a/source/frontend/StarTitleScreen.hpp b/source/frontend/StarTitleScreen.hpp index 5ce000d..87ce0c8 100644 --- a/source/frontend/StarTitleScreen.hpp +++ b/source/frontend/StarTitleScreen.hpp @@ -47,7 +47,7 @@ public: void render(); bool handleInputEvent(InputEvent const& event); - void update(); + void update(float dt); bool textInputActive() const; diff --git a/source/frontend/StarVoice.cpp b/source/frontend/StarVoice.cpp index 82205bd..d72bc57 100644 --- a/source/frontend/StarVoice.cpp +++ b/source/frontend/StarVoice.cpp @@ -420,7 +420,7 @@ void Voice::mix(int16_t* buffer, size_t frameCount, unsigned channels) { } } -void Voice::update(PositionalAttenuationFunction positionalAttenuationFunction) { +void Voice::update(float dt, PositionalAttenuationFunction positionalAttenuationFunction) { for (auto& entry : m_speakers) { if (SpeakerPtr& speaker = entry.second) { if (positionalAttenuationFunction) { diff --git a/source/frontend/StarVoice.hpp b/source/frontend/StarVoice.hpp index 95046af..f776cb7 100644 --- a/source/frontend/StarVoice.hpp +++ b/source/frontend/StarVoice.hpp @@ -136,7 +136,7 @@ public: void mix(int16_t* buffer, size_t frames, unsigned channels); typedef function<float(unsigned, Vec2F, float)> PositionalAttenuationFunction; - void update(PositionalAttenuationFunction positionalAttenuationFunction = {}); + void update(float dt, PositionalAttenuationFunction positionalAttenuationFunction = {}); void setDeviceName(Maybe<String> device); StringList availableDevices(); diff --git a/source/frontend/StarWireInterface.cpp b/source/frontend/StarWireInterface.cpp index 1cec9e8..61506fe 100644 --- a/source/frontend/StarWireInterface.cpp +++ b/source/frontend/StarWireInterface.cpp @@ -35,7 +35,7 @@ void WirePane::reset() { m_connecting = false; } -void WirePane::update() { +void WirePane::update(float dt) { if (!active()) return; if (!m_worldClient->inWorld()) { diff --git a/source/frontend/StarWireInterface.hpp b/source/frontend/StarWireInterface.hpp index 6c124a7..f1c44d2 100644 --- a/source/frontend/StarWireInterface.hpp +++ b/source/frontend/StarWireInterface.hpp @@ -16,7 +16,7 @@ public: WirePane(WorldClientPtr worldClient, PlayerPtr player, WorldPainterPtr worldPainter); virtual ~WirePane() {} - virtual void update() override; + virtual void update(float dt) override; virtual bool sendEvent(InputEvent const& event) override; virtual SwingResult swing(WorldGeometry const& geometry, Vec2F position, FireMode mode) override; |