void Client::render(ui::Frame &f) { const Clamped &gameFocusFactor = uiState.gameFocusFactor, &pageFocusFactor = uiState.pageFocusFactor; if (uiState.gameFocused() && game) { renderGame(f); } else { if (!game) { f.drawSprite(resources.getTexture(ui::TextureID::MenuBackground), {0, 0}, {0, 0, 1600, 900}); } else { renderGame(f); f.drawRect( {0, 0, 1600, 900}, mixColors(style.menu.gameOverlayColor, sf::Color(255, 255, 255, 0), gameFocusFactor)); } f.withAlpha( linearTween(1, 0, gameFocusFactor) * (game ? linearTween(style.menu.menuInGameFade, 1, pageFocusFactor) : linearTween(style.menu.menuNormalFade, 1, pageFocusFactor)), [&]() { renderUI(f); }); } }
void Client::renderPage(ui::Frame &f, const PageType type, const sf::Vector2f &offset, const std::string &name, ui::TransformedBase &page) { const float focusFactor = uiState.pageFocusFactor; float alpha, scale, offsetAmnt, titleAlpha, backdropAlpha; if (type == uiState.focusedPage) { alpha = 1; scale = linearTween(style.menu.unfocusedPageScale, 1.0f, focusFactor); offsetAmnt = linearTween(1.0f, 0.0f, focusFactor); titleAlpha = linearTween(1.0f, 0.0f, focusFactor); backdropAlpha = 0; } else { alpha = linearTween(1.0f, 0.0f, focusFactor); scale = style.menu.unfocusedPageScale; offsetAmnt = 1; titleAlpha = 1; backdropAlpha = alpha; } if (alpha == 0) return; page.setTransform(sf::Transform() .translate(offsetAmnt * offset) .translate(0, linearTween(0, style.menu.pageYOffset, focusFactor)) .scale(scale, scale)); f.withAlpha(alpha, [&]() { // Underlay f.withAlpha(backdropAlpha, [&]() { f.drawRect({0, 0, 1600, 900}, style.menu.pageUnderlayColor); }); // Page itself. page.render(f); // Page title. f.withAlpha(titleAlpha, [&]() { f.drawText( sf::Vector2f(0, style.menu.pageDescMargin) + offsetAmnt * offset, name, style.base.freeTextColor, style.menu.menuDescText, resources.defaultFont); }); }); }
void Client::renderUI(ui::Frame &f) { const Clamped &pageFocusFactor = uiState.pageFocusFactor; renderPage( f, PageType::Home, style.menu.homeOffset, "home", homePage.base); renderPage( f, PageType::Listing, style.menu.listingOffset, "server listing", listingPage.base); renderPage( f, PageType::Settings, style.menu.settingsOffset, "settings", settingsPage.base); if (const auto game = shared.getGame()) { f.drawText( style.menu.closeButtonOffset - sf::Vector2f(10, 0), [&](ui::TextFrame &tf) { tf.setColor(style.menu.statusFontColor); tf.print(" (" + game->status + ")"); tf.print(game->name); }, style.menu.gameDescText, resources.defaultFont); closeButton.render(f); } f.withAlpha( linearTween(1, 0, pageFocusFactor), [&]() { // buttons that fade out as the page focuses quitButton.render(f); aboutButton.render(f); }); f.withAlpha( linearTween(0, 1, pageFocusFactor), [&]() { // buttons that fade in as the page focuses backButton.render(f); }); }
void RoundAnimation::Play( void ) { if(!isEnd) { //アニメーション終了フラグ bool anim_is_end = FALSE; //現在のラウンド取得 int now_draw = 0; if(!RoundIsEnd) { now_draw = 0; } else if(!RoundNumIsEnd) { now_draw = 1; } else { now_draw = 2; } //アニメーション用移動量取得 int x_buf, y_buf; GetGraphSize(Fight_RoundNum_Graph[now_draw] , &x_buf, &y_buf); Animation_X_Size[now_draw] = linearTween(time[now_draw], 0, 600, 5); Animation_Y_Size[now_draw] = linearTween(time[now_draw], 0, 600, 5); if(Animation_X_Size[now_draw] > x_buf) { Animation_X_Size[now_draw] = x_buf; anim_is_end = TRUE; //アニメーション終了 } if(Animation_Y_Size[now_draw] > y_buf) { Animation_Y_Size[now_draw] = y_buf; anim_is_end = TRUE; //アニメーション終了 } x_buf = Animation_X_Size[now_draw]/8; y_buf = Animation_Y_Size[now_draw]/8; time[now_draw]++; //round表示 if(!RoundIsEnd) { DrawExtendGraph(LOGO_POSI_CENTER_X - x_buf, LOGO_POSI_CENTER_Y - y_buf, LOGO_POSI_CENTER_X + x_buf, LOGO_POSI_CENTER_Y + y_buf, Fight_Round_Graph, TRUE); if(anim_time + ANIM_STOP_TIME < Timer::GetTime()){ if(anim_is_end) { RoundIsEnd = TRUE; anim_time = Timer::GetTime(); //ラウンド数SE switch (RoundNum) { case 0: SOUND::SetSoundEffect(SOUND::SE_ONE); break; case 1: SOUND::SetSoundEffect(SOUND::SE_TWO); break; case 2: SOUND::SetSoundEffect(SOUND::SE_FINAL); break; } } } } //ラウンド数表示 else if(!RoundNumIsEnd) { DrawExtendGraph(LOGO_POSI_CENTER_X - x_buf, LOGO_POSI_CENTER_Y - y_buf, LOGO_POSI_CENTER_X + x_buf, LOGO_POSI_CENTER_Y + y_buf, Fight_RoundNum_Graph[RoundNum], TRUE); if(anim_time + ANIM_STOP_TIME < Timer::GetTime()){ if(anim_is_end) { RoundNumIsEnd = TRUE; anim_time = Timer::GetTime(); //ラウンド数SE SOUND::SetSoundEffect(SOUND::SE_FIGHT); } } } //Fight表示 else { DrawExtendGraph(LOGO_POSI_CENTER_X - x_buf, LOGO_POSI_CENTER_Y - y_buf, LOGO_POSI_CENTER_X + x_buf, LOGO_POSI_CENTER_Y + y_buf, Fight_Graph, TRUE); if(anim_time + ANIM_STOP_TIME < Timer::GetTime()){ if(anim_is_end) { isEnd = TRUE; } } } } return; }
float AnimationCurve::getValue(float time) const { const AnimatedKeys* pKeys = getPointer(); if (!pKeys) return m_constantValue; const AnimatedKeys& ak = *pKeys; size_t keyCount = ak.keys.size(); if (keyCount == 1) // it's constant, so return that return ak.keys.begin()->second; float value = 0.0f; // see if it exists std::map<float, float>::const_iterator itFind = ak.keys.find(time); if (itFind != ak.keys.end()) { value = itFind->second; return value; } std::map<float, float>::const_iterator findLower = ak.keys.lower_bound(time); std::map<float, float>::const_iterator findUpper = ak.keys.upper_bound(time); if (findLower == ak.keys.end()) { // after last frame std::map<float, float>::const_iterator itLastKey = --ak.keys.rbegin().base(); value = itLastKey->second; return value; } if (findUpper == ak.keys.begin()) { // before first frame value = ak.keys.begin()->second; return value; } if (findUpper != ak.keys.end()) { std::map<float, float>::const_iterator itPrevKey = findUpper; --itPrevKey; float lowerTime = (*itPrevKey).first; float lowerValue = (*itPrevKey).second; float upperTime = (*findUpper).first; float upperValue = (*findUpper).second; float timeRatio = (time - lowerTime) / (upperTime - lowerTime); switch (ak.interpolationType) { default: case eLinearInterpolation: value = linearTween(timeRatio, lowerValue, upperValue); break; case eCubicInterpolation: value = cubicTween(timeRatio, lowerValue, upperValue); break; case eQuadraticInterpolation: value = quadraticTween(timeRatio, lowerValue, upperValue); break; } return value; } else { assert(false); } return 0.0f; }