| 60 | } |
| 61 | |
| 62 | void UI::LoadingScreen::update(double dt, Engine::Input::MouseState& mstate, Render::RenderConfig& config) |
| 63 | { |
| 64 | if (m_IsHidden) |
| 65 | return; |
| 66 | |
| 67 | // G2s image is a little bit different and needs some tweaking |
| 68 | // Need to set this here, rather than in the constructor, since the constructor |
| 69 | // is ran before the engine knows what game it runs |
| 70 | if (m_Engine.getBasicGameType() == Daedalus::GameType::GT_Gothic2) |
| 71 | { |
| 72 | m_pProgressBar->setInnerOffset(UI::INNER_OFFSET_G2_PROGRESS); |
| 73 | m_pProgressBar->setTranslation(BAR_POSITION_G2); |
| 74 | m_pProgressBar->setSize(BAR_SIZE_G2); |
| 75 | m_pInfo->setTranslation(BAR_POSITION_G2 + Math::float2(0.0f, 0.03f)); |
| 76 | } |
| 77 | else |
| 78 | { |
| 79 | m_pProgressBar->setInnerOffset(UI::INNER_OFFSET_G1_PROGRESS); |
| 80 | m_pProgressBar->setTranslation(BAR_POSITION_G1); |
| 81 | m_pProgressBar->setSize(BAR_SIZE_G1); |
| 82 | m_pInfo->setTranslation(BAR_POSITION_G1 + Math::float2(0.0f, 0.03f)); |
| 83 | } |
| 84 | |
| 85 | int start, end; |
| 86 | float p; |
| 87 | std::string info; |
| 88 | |
| 89 | // Get section params - threadsave |
| 90 | getSection(start, end, p, info); |
| 91 | |
| 92 | // Add a slight amount so that the bar doesn't appear to be stuck |
| 93 | p = std::min(p + (float)dt * FAKE_PROGRESS_PERCENT_PER_SECOND, 100.0f); |
| 94 | setSectionProgress(p); |
| 95 | |
| 96 | // Convert section progress to global progress |
| 97 | float value = bx::flerp(start, end, p / 100.0f); |
| 98 | |
| 99 | // Don't smooth if we reached 100% so we can start the game with the progress-bar being full |
| 100 | if (value <= 99.0f) |
| 101 | { |
| 102 | m_VisibleProgress = bx::flerp(m_VisibleProgress, value, (float)dt * PROGRESS_BAR_SOFT_SPEED); |
| 103 | m_VisibleProgress = std::min(value, m_VisibleProgress); // Faked value should never overshoot the real one |
| 104 | } |
| 105 | else |
| 106 | { |
| 107 | m_VisibleProgress = 100.0f; |
| 108 | } |
| 109 | m_pProgressBar->setValue(m_VisibleProgress / 100.0f); |
| 110 | m_pInfo->setText(info); |
| 111 | |
| 112 | ImageView::update(dt, mstate, config); |
| 113 | } |
| 114 | |
| 115 | void UI::LoadingScreen::startSection(int p1, int p2, const std::string& message) |
| 116 | { |
nothing calls this directly
no test coverage detected