void ARX_TEXT_Draw(Font* ef, const Vec2f & pos, const std::string& car, Color col) { if (car.empty() || car[0] == 0) return; ARX_UNICODE_DrawTextInRect(ef, pos, std::numeric_limits<float>::infinity(), car, col); }
void TextManager::Render() { std::vector<ManagedText *>::const_iterator itManage = entries.begin(); for(; itManage != entries.end(); ++itManage) { ManagedText * pArxText = *itManage; Rect * pRectClip = NULL; if(pArxText->rRectClipp.right != Rect::Limits::max() || pArxText->rRectClipp.bottom != Rect::Limits::max()) { pRectClip = &pArxText->rRectClipp; } float maxx; if(pArxText->rRect.right == Rect::Limits::max()) { maxx = std::numeric_limits<float>::infinity(); } else { maxx = static_cast<float>(pArxText->rRect.right); } long height = ARX_UNICODE_DrawTextInRect(pArxText->pFont, Vec2f(pArxText->rRect.left, pArxText->rRect.top - pArxText->fDeltaY), maxx, pArxText->lpszUText, pArxText->lCol, pRectClip); pArxText->rRect.bottom = pArxText->rRect.top + height; } }
void TextWidget::render(bool mouseOver) { Color color = Color(232, 204, 142); bool hasAction = targetPage() != NOP || clicked || doubleClicked; bool dynamic = m_display == Dynamic || (m_display == Automatic && hasAction); if(m_display == Disabled || (dynamic && !m_enabled)) { color = Color::gray(0.5f); } else if(m_display == MouseOver || (dynamic && mouseOver)) { color = Color::white; } ARX_UNICODE_DrawTextInRect(m_font, m_rect.topLeft(), m_rect.right, m_text, color, NULL); }
static void ARX_SPEECH_Render() { long igrec = 14; Vec2i sSize = hFontInBook->getTextSize("p"); sSize.y *= 3; int iEnd = igrec + sSize.y; for(size_t i = 0; i < MAX_SPEECH; i++) { if(speech[i].timecreation == 0 || speech[i].text.empty()) { continue; } Rectf rect( Vec2f(120 * g_sizeRatio.x - 16 * minSizeRatio(), igrec), 16 * minSizeRatio(), 16 * minSizeRatio() ); GRenderer->SetRenderState(Renderer::AlphaBlending, true); GRenderer->SetBlendFunc(Renderer::BlendSrcAlpha, Renderer::BlendInvSrcAlpha); EERIEDrawBitmap(rect, .00001f, arx_logo_tc, Color::white); igrec += ARX_UNICODE_DrawTextInRect(hFontInBook, Vec2f(120.f * g_sizeRatio.x, igrec), 500 * g_sizeRatio.x, ' ' + speech[i].text, Color::white, NULL); if(igrec > iEnd && !isLastSpeech(i)) { ARX_SPEECH_MoveUp(); break; } } GRenderer->SetRenderState(Renderer::AlphaBlending, false); }
void CharacterCreation::render() { arx_assert(ARXmenu.mode() == Mode_CharacterCreation); GRenderer->Clear(Renderer::ColorBuffer); //------------------------------------------------------------------------- arx_assert(BookBackground); { UseRenderState state(render2D()); EERIEDrawBitmap(Rectf(Vec2f(0, 0), g_size.width(), g_size.height()), 0.9f, BookBackground, Color::white); g_playerBook.stats.manageNewQuest(); bool DONE = (player.Skill_Redistribute == 0 && player.Attribute_Redistribute == 0); Color color = Color::none; Rectf book = g_playerBook.getArea(); Vec2f spacing = Vec2f(20.f, 30.f) * minSizeRatio(); Vec2f quickGenerateButtonSize(hFontMenu->getTextSize(str_button_quickgen).size()); Rectf quickGenerateButton(book.bottomLeft() + Vec2f(0.f, spacing.y), quickGenerateButtonSize.x, quickGenerateButtonSize.y); Vec2f doneButtonSize(hFontMenu->getTextSize(str_button_done).size()); Rectf doneButton(book.bottomRight() + Vec2f(-doneButtonSize.x, spacing.y), doneButtonSize.x, doneButtonSize.y); Vec2f skinButtonSize(hFontMenu->getTextSize(str_button_skin).size()); Rectf skinButton((quickGenerateButton.centerRight() + doneButton.centerLeft() - skinButtonSize) / 2.f, skinButtonSize.x, skinButtonSize.y); if(quickGenerateButton.right > skinButton.left - spacing.x) { quickGenerateButton.move(skinButton.left - spacing.x - quickGenerateButton.right, 0.f); } if(doneButton.left < skinButton.right + spacing.x) { doneButton.move(skinButton.right + spacing.x - doneButton.left, 0.f); } // Button QUICK GENERATION if(quickGenerateButton.contains(Vec2f(DANAEMouse))) { cursorSetInteraction(); if(!eeMousePressed1() && eeMouseUp1()) { m_cheatQuickGenButtonClickCount++; int iSkin = player.skin; ARX_SOUND_PlayMenu(g_snd.MENU_CLICK); if(bQuickGenFirstClick) { ARX_PLAYER_MakeAverageHero(); bQuickGenFirstClick = false; } else { ARX_PLAYER_QuickGeneration(); } player.skin = checked_range_cast<char>(iSkin); } characterCreationAddDescription(m_desc_quickgen); color = Color::white; } else { color = Color(232, 204, 143); } ARX_UNICODE_DrawTextInRect(hFontMenu, quickGenerateButton.topLeft(), 999999, str_button_quickgen, color); // Button SKIN if(skinButton.contains(Vec2f(DANAEMouse))) { cursorSetInteraction(); if(eeMouseUp1()) { m_cheatSkinButtonClickCount++; ARX_SOUND_PlayMenu(g_snd.MENU_CLICK); player.skin++; if(player.skin > 3) { player.skin = 0; } ARX_PLAYER_Restore_Skin(); } characterCreationAddDescription(m_desc_skin); color = Color::white; } else { color = Color::rgb(0.91f, 0.8f, 0.56f); } ARX_UNICODE_DrawTextInRect(hFontMenu, skinButton.topLeft(), 999999, str_button_skin, color); // Button DONE if(doneButton.contains(Vec2f(DANAEMouse))) { if(DONE) cursorSetInteraction(); if(DONE && eeMouseUp1()) { if(m_cheatSkinButtonClickCount == 8 && m_cheatQuickGenButtonClickCount == 10) { m_cheatSkinButtonClickCount = -2; } else if(m_cheatSkinButtonClickCount == -1) { ARX_PLAYER_MakeSpHero(); player.skin = 4; ARX_PLAYER_Restore_Skin(); m_cheatSkinButtonClickCount = 0; SP_HEAD = 1; } else { if(SP_HEAD) { player.skin = 4; ARX_PLAYER_Restore_Skin(); SP_HEAD = 0; } ARX_SOUND_PlayMenu(g_snd.MENU_CLICK); MenuFader_start(Fade_In, Mode_InGame); } } else { if(DONE) { color = Color::white; } else { color = Color::gray(0.75f); } } characterCreationAddDescription(m_desc_done); } else { if(DONE) { color = Color(232, 204, 143); } else { color = Color::gray(0.75f); } } if(m_cheatSkinButtonClickCount < 0) { color = Color::magenta; } ARX_UNICODE_DrawTextInRect(hFontMenu, doneButton.topLeft(), 999999, str_button_done, color); } EERIE_LIGHT * light = lightHandleGet(torchLightHandle); light->pos.x = 0.f + GInput->getMousePosition().x - (g_size.width() >> 1); light->pos.y = 0.f + GInput->getMousePosition().y - (g_size.height() >> 1); if(pTextManage) { pTextManage->Update(g_platformTime.lastFrameDuration()); pTextManage->Render(); } ARX_INTERFACE_RenderCursor(true); if(MenuFader_process()) { if(iFadeAction == Mode_InGame) { ARX_MENU_NEW_QUEST_Clicked_QUIT(); MenuFader_reset(); if(pTextManage) { pTextManage->Clear(); } } } }
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 Note::render() { if(!allocate()) { return; } float z = 0.000001f; GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapClamp); if(background) { EERIEDrawBitmap2(_area.left, _area.top, _area.width(), _area.height(), z, background, Color::white); } if(pages.empty()) { return; } arx_assert(_page < pages.size()); // Draw the "previous page" button Rectf prevRect = prevPageButton(); if(!prevRect.empty()) { arx_assert(prevPage != NULL); EERIEDrawBitmap2(prevRect.left, prevRect.top, prevRect.width(), prevRect.height(), z, prevPage, Color::white); } // Draw the "next page" button Rectf nextRect = nextPageButton(); if(!nextRect.empty()) { arx_assert(nextPage != NULL); EERIEDrawBitmap2(nextRect.left, nextRect.top, nextRect.width(), nextRect.height(), z, nextPage, Color::white); } Font * font = hFontInGameNote; // Draw the left page { ARX_UNICODE_DrawTextInRect( font, _area.left + _textArea.left, _area.top + _textArea.top, _area.left + _textArea.right, pages[_page], Color::none ); } // Draw the right page if(_page + 1 < pages.size()) { ARX_UNICODE_DrawTextInRect( font, _area.left + _textArea.right + _pageSpacing, _area.top + _textArea.top, _area.left + _textArea.right + _pageSpacing + _textArea.width(), pages[_page + 1], Color::none ); } }
void MiniMap::showBookEntireMap(int showLevel) { // First Load Minimap TC & DATA if needed if(m_levels[showLevel].m_texContainer == NULL) { getData(showLevel); } if(!m_levels[showLevel].m_texContainer) { return; } GRenderer->SetRenderState(Renderer::DepthTest, false); float zoom = 250.f; Vec2f start(140.f, 120.f); Vec2f playerPos(0.f, 0.f); if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) { playerPos = computePlayerPos(zoom, showLevel); playerPos += start; } drawBackground(showLevel, Rect(0, 0, 345, 290), start.x, start.y, zoom); GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapRepeat); if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) { drawPlayer(3.f, playerPos); drawDetectedEntities(showLevel, start, zoom); } TexturedVertex verts[4]; for(int k = 0; k < 4; k++) { verts[k].color = Color(255, 255, 255, 255).toRGBA(); verts[k].rhw = 1; verts[k].p.z = 0.00001f; } Vec2f casePos(zoom / ((float)MINIMAP_MAX_X), zoom / ((float)MINIMAP_MAX_Z)); float ratio = 1.f; for(size_t i = 0; i < m_mapMarkers.size(); i++) { if(m_mapMarkers[i].m_lvl != showLevel + 1) { continue; } float pos_x = m_mapMarkers[i].m_pos.x * 8 * ratio * m_activeBkg->Xmul * casePos.x + start.x; float pos_y = m_mapMarkers[i].m_pos.y * 8 * ratio * m_activeBkg->Zmul * casePos.y + start.y; float size = 5.f * ratio; verts[0].color = Color(255, 0, 0, 255).toRGBA(); verts[1].color = Color(255, 0, 0, 255).toRGBA(); verts[2].color = Color(255, 0, 0, 255).toRGBA(); verts[3].color = Color(255, 0, 0, 255).toRGBA(); verts[0].p.x = (pos_x - size) * g_sizeRatio.x; verts[0].p.y = (pos_y - size) * g_sizeRatio.y; verts[1].p.x = (pos_x + size) * g_sizeRatio.x; verts[1].p.y = (pos_y - size) * g_sizeRatio.y; verts[2].p.x = (pos_x + size) * g_sizeRatio.x; verts[2].p.y = (pos_y + size) * g_sizeRatio.y; verts[3].p.x = (pos_x - size) * g_sizeRatio.x; verts[3].p.y = (pos_y + size) * g_sizeRatio.y; verts[0].uv = Vec2f_ZERO; verts[1].uv = Vec2f_X_AXIS; verts[2].uv = Vec2f_ONE; verts[3].uv = Vec2f_Y_AXIS; const Rect mouseTestRect( verts[0].p.x, verts[0].p.y, verts[2].p.x, verts[2].p.y ); if(mouseTestRect.contains(Vec2i(DANAEMouse))) { if(!m_mapMarkers[i].m_text.empty()) { Rect bRect(140, 295, 140 + 205, 358); Rect::Num left = checked_range_cast<Rect::Num>((bRect.left) * g_sizeRatio.x); Rect::Num right = checked_range_cast<Rect::Num>((bRect.right) * g_sizeRatio.x); Rect::Num top = checked_range_cast<Rect::Num>((bRect.top) * g_sizeRatio.y); Rect::Num bottom = checked_range_cast<Rect::Num>((bRect.bottom) * g_sizeRatio.y); Rect rRect = Rect(left, top, right, bottom); long lLengthDraw = ARX_UNICODE_ForceFormattingInRect(hFontInGameNote, m_mapMarkers[i].m_text, rRect); ARX_UNICODE_DrawTextInRect(hFontInGameNote, (BOOKDEC + Vec2f(bRect.topLeft())) * g_sizeRatio, (BOOKDEC.x + float(bRect.right)) * g_sizeRatio.x, m_mapMarkers[i].m_text.substr(0, lLengthDraw), Color::none); } } if(m_mapMarkerTexCont == NULL) { m_mapMarkerTexCont = TextureContainer::Load("graph/interface/icons/mapmarker"); } GRenderer->SetTexture(0, m_mapMarkerTexCont); EERIEDRAWPRIM(Renderer::TriangleFan, verts, 4); } }