//! draws the element and its children void CGUIImage::draw() { if (!IsVisible) return; IGUISkin* skin = Environment->getSkin(); video::IVideoDriver* driver = Environment->getVideoDriver(); if (Texture) { core::rect<s32> sourceRect(SourceRect); if (sourceRect.getWidth() == 0 || sourceRect.getHeight() == 0) { sourceRect = core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(Texture->getOriginalSize())); } if (ScaleImage) { const video::SColor Colors[] = {Color,Color,Color,Color}; core::rect<s32> clippingRect(AbsoluteClippingRect); checkBounds(clippingRect); driver->draw2DImage(Texture, AbsoluteRect, sourceRect, &clippingRect, Colors, UseAlphaChannel); } else { core::rect<s32> clippingRect(AbsoluteRect.UpperLeftCorner, sourceRect.getSize()); checkBounds(clippingRect); clippingRect.clipAgainst(AbsoluteClippingRect); driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, sourceRect, &clippingRect, Color, UseAlphaChannel); } } else { core::rect<s32> clippingRect(AbsoluteClippingRect); checkBounds(clippingRect); skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &clippingRect); } IGUIElement::draw(); }
void ARX_SPEECH_Update() { unsigned long tim = (unsigned long)(arxtime); if(cinematicBorder.isActive() || BLOCK_PLAYER_CONTROLS) ARX_CONVERSATION_CheckAcceleratedSpeech(); for(size_t i = 0; i < MAX_ASPEECH; i++) { if(!aspeech[i].exist) continue; Entity * io = aspeech[i].io; // updates animations if(io) { if(aspeech[i].flags & ARX_SPEECH_FLAG_OFFVOICE) ARX_SOUND_RefreshSpeechPosition(aspeech[i].sample); else ARX_SOUND_RefreshSpeechPosition(aspeech[i].sample, io); if((io != entities.player() || (io == entities.player() && EXTERNALVIEW)) && ValidIOAddress(io)) { if(!io->anims[aspeech[i].mood]) aspeech[i].mood = ANIM_TALK_NEUTRAL; ANIM_HANDLE * anim = io->anims[aspeech[i].mood]; if(anim) { AnimLayer & layer2 = io->animlayer[2]; if(layer2.cur_anim != anim || (layer2.flags & EA_ANIMEND)) { changeAnimation(io, 2, anim); } } } } // checks finished speech if(tim >= aspeech[i].time_creation + aspeech[i].duration) { EERIE_SCRIPT *es = aspeech[i].es; Entity *io = aspeech[i].ioscript; long scrpos = aspeech[i].scrpos; ARX_SPEECH_Release(i); if(es && ValidIOAddress(io)) ScriptEvent::send(es, SM_EXECUTELINE, "", io, "", scrpos); } } for(size_t i = 0; i < MAX_ASPEECH; i++) { ARX_SPEECH *speech = &aspeech[i]; if(!speech->exist) continue; if(speech->text.empty()) continue; if(!cinematicBorder.isActive()) continue; if(CINEMA_DECAL < 100.f) continue; Vec2i sSize = hFontInBook->getTextSize(speech->text); float fZoneClippHeight = static_cast<float>(sSize.y * 3); float fStartYY = 100 * g_sizeRatio.y; float fStartY = static_cast<float>(((int)fStartYY - (int)fZoneClippHeight) >> 1); float fDepY = ((float)g_size.height()) - fStartYY + fStartY - speech->fDeltaY + sSize.y; float fZoneClippY = fDepY + speech->fDeltaY; float fAdd = fZoneClippY + fZoneClippHeight ; Rect::Num y = checked_range_cast<Rect::Num>(fZoneClippY); Rect::Num h = checked_range_cast<Rect::Num>(fAdd); Rect clippingRect(0, y+1, g_size.width(), h); if(config.video.limitSpeechWidth) { s32 w = std::min(g_size.width(), s32(640 * g_sizeRatio.y)); clippingRect.left = (g_size.width() - w) / 2; clippingRect.right = (g_size.width() + w) / 2; } float height = (float)ARX_UNICODE_DrawTextInRect( hFontInBook, Vec2f(clippingRect.left + 10.f, fDepY + fZoneClippHeight), clippingRect.right - 10.f, speech->text, Color::white, &clippingRect); GRenderer->SetBlendFunc(Renderer::BlendZero, Renderer::BlendInvSrcColor); GRenderer->SetRenderState(Renderer::AlphaBlending, true); GRenderer->SetRenderState(Renderer::DepthTest, false); EERIEDrawFill2DRectDegrad(Vec2f(0.f, fZoneClippY - 1.f), Vec2f(static_cast<float>(g_size.width()), fZoneClippY + (sSize.y * 3 / 4)), 0.f, Color::white, Color::black); EERIEDrawFill2DRectDegrad(Vec2f(0.f, fZoneClippY + fZoneClippHeight - (sSize.y * 3 / 4)), Vec2f(static_cast<float>(g_size.width()), fZoneClippY + fZoneClippHeight), 0.f, Color::black, Color::white); GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendZero); GRenderer->SetRenderState(Renderer::DepthTest, true); GRenderer->SetRenderState(Renderer::AlphaBlending, false); height += fZoneClippHeight; if(speech->fDeltaY <= height) { //vitesse du scroll float fDTime; if(speech->sample) { float duration = ARX_SOUND_GetDuration(speech->sample); if(duration == 0.0f) { duration = 4000.0f; } fDTime = (height * framedelay) / duration; //speech->duration; float fTimeOneLine = ((float)sSize.y) * fDTime; if(((float)speech->iTimeScroll) >= fTimeOneLine) { float fResteLine = (float)sSize.y - speech->fPixelScroll; float fTimePlus = (fResteLine * framedelay) / duration; fDTime -= fTimePlus; speech->fPixelScroll = 0.f; speech->iTimeScroll = 0; } speech->iTimeScroll += checked_range_cast<int>(framedelay); } else { fDTime = (height * framedelay) / 4000.0f; } speech->fDeltaY += fDTime; speech->fPixelScroll += fDTime; } } }
void wxSwitcherItems::PaintItems(wxDC& dc, wxWindow* win) { wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); wxColour standardTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); wxColour selectionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); wxColour selectionOutlineColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); wxColour selectionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); wxFont standardFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont groupFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); groupFont.SetWeight(wxFONTWEIGHT_BOLD); if (GetBackgroundColour().Ok()) backgroundColour = GetBackgroundColour(); if (GetTextColour().Ok()) standardTextColour = GetTextColour(); if (GetSelectionColour().Ok()) selectionColour = GetSelectionColour(); if (GetSelectionOutlineColour().Ok()) selectionOutlineColour = GetSelectionOutlineColour(); if (GetSelectionTextColour().Ok()) selectionTextColour = GetSelectionTextColour(); if (GetItemFont().Ok()) { standardFont = GetItemFont(); groupFont = wxFont(standardFont.GetPointSize(), standardFont.GetFamily(), standardFont.GetStyle(), wxFONTWEIGHT_BOLD, standardFont.GetUnderlined(), standardFont.GetFaceName()); } int textMarginX = wxSWITCHER_TEXT_MARGIN_X; dc.SetLogicalFunction(wxCOPY); dc.SetBrush(wxBrush(backgroundColour)); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(win->GetClientRect()); dc.SetBackgroundMode(wxTRANSPARENT); size_t i; for (i = 0; i < m_items.GetCount(); i++) { wxSwitcherItem& item = m_items[i]; bool selected = ((int) i == m_selection); if (selected) { dc.SetPen(wxPen(selectionOutlineColour)); dc.SetBrush(wxBrush(selectionColour)); dc.DrawRectangle(item.GetRect()); } wxRect clippingRect(item.GetRect()); clippingRect.Deflate(1, 1); dc.SetClippingRegion(clippingRect); if (selected) dc.SetTextForeground(selectionTextColour); else if (item.GetTextColour().Ok()) dc.SetTextForeground(item.GetTextColour()); else dc.SetTextForeground(standardTextColour); if (item.GetFont().Ok()) dc.SetFont(item.GetFont()); else { if (item.GetIsGroup()) dc.SetFont(groupFont); else dc.SetFont(standardFont); } int w, h; dc.GetTextExtent(item.GetTitle(), & w, & h); int x = item.GetRect().x; x += textMarginX; if (!item.GetIsGroup()) { if (item.GetBitmap().Ok() && item.GetBitmap().GetWidth() <= 16 && item.GetBitmap().GetHeight() <= 16) { dc.DrawBitmap(item.GetBitmap(), x, item.GetRect().y + (item.GetRect().height - item.GetBitmap().GetHeight()) / 2, true); } x += 16; x += textMarginX; } int y = item.GetRect().y + (item.GetRect().height - h)/2; dc.DrawText(item.GetTitle(), x, y); dc.DestroyClippingRegion(); } }