static void addCreditsLine(std::string & phrase, float & drawpos) { //Create a data containers CreditsTextInformations infomations; infomations.fColors = ExtractPhraseColor(phrase); //int linesize = hFontCredits->GetTextSize(phrase).x; static const int MARGIN_WIDTH = 20; Rect linerect(g_size.width() - MARGIN_WIDTH - MARGIN_WIDTH, hFontCredits->getLineHeight()); while(!phrase.empty()) { // Split long lines long n = ARX_UNICODE_ForceFormattingInRect(hFontCredits, phrase, linerect); arx_assert(n >= 0 && size_t(n) < phrase.length()); infomations.sText = phrase.substr(0, size_t(n + 1) == phrase.length() ? n + 1 : n); phrase = phrase.substr(n + 1); // Center the text on the screen int linesize = hFontCredits->getTextSize(infomations.sText).x; infomations.sPos.x = (g_size.width() - linesize) / 2; LogDebug("credit line: '" << infomations.sText << "' (" << linesize << "," << infomations.sText.length() << ")"); // Calculate height position infomations.sPos.y = static_cast<int>(drawpos); drawpos += CreditsData.iFontAverageHeight; CreditsData.aCreditsInformations.push_back(infomations); } }
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; float startX = 140.f; float startY = 120.f; Vec2f playerPos(0.f, 0.f); if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) { playerPos = computePlayerPos(zoom, showLevel); playerPos.x += startX; playerPos.y += startY; } drawBackground(showLevel, Rect(0, 0, 345, 290), startX, startY, zoom); GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapRepeat); if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) { drawPlayer(3.f, playerPos.x, playerPos.y); drawDetectedEntities(showLevel, startX, startY, zoom); } TexturedVertex verts[4]; for(int k = 0; k < 4; k++) { verts[k].color = 0xFFFFFFFF; verts[k].rhw = 1; verts[k].p.z = 0.00001f; } float caseX = zoom / ((float)MINIMAP_MAX_X); float caseY = 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_x * 8 * ratio * m_activeBkg->Xmul * caseX + startX; float pos_y = m_mapMarkers[i].m_y * 8 * ratio * m_activeBkg->Zmul * caseY + startY; float size = 5.f * ratio; verts[0].color = 0xFFFF0000; verts[1].color = 0xFFFF0000; verts[2].color = 0xFFFF0000; verts[3].color = 0xFFFF0000; verts[0].p.x = (pos_x - size) * Xratio; verts[0].p.y = (pos_y - size) * Yratio; verts[1].p.x = (pos_x + size) * Xratio; verts[1].p.y = (pos_y - size) * Yratio; verts[2].p.x = (pos_x + size) * Xratio; verts[2].p.y = (pos_y + size) * Yratio; verts[3].p.x = (pos_x - size) * Xratio; verts[3].p.y = (pos_y + size) * Yratio; verts[0].uv = Vec2f::ZERO; verts[1].uv = Vec2f::X_AXIS; verts[2].uv = Vec2f::ONE; verts[3].uv = Vec2f::Y_AXIS; if(MouseInRect(verts[0].p.x, verts[0].p.y, verts[2].p.x, verts[2].p.y)) { if(!m_mapMarkers[i].m_text.empty()) { Rect bRect(140, 290, 140 + 205, 358); Rect::Num left = checked_range_cast<Rect::Num>((bRect.left) * Xratio); Rect::Num right = checked_range_cast<Rect::Num>((bRect.right) * Xratio); Rect::Num top = checked_range_cast<Rect::Num>((bRect.top) * Yratio); Rect::Num bottom = checked_range_cast<Rect::Num>((bRect.bottom) * Yratio); Rect rRect = Rect(left, top, right, bottom); long lLengthDraw = ARX_UNICODE_ForceFormattingInRect(hFontInGameNote, m_mapMarkers[i].m_text, rRect); DrawBookTextInRect(hFontInGameNote, float(bRect.left), float(bRect.top), float(bRect.right), 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); } }
bool Note::allocate() { if(allocatedForRatio == sizeRatio()) { return background ? true : false; } deallocate(); // Allocate textures and calculate sizes Vec2f newPos; Vec2f newTextStart; Vec2f newTextEnd; Vec2f prevButtonOffset; Vec2f nextButtonOffset; size_t maxPages = 1; Vec2f scale = Vec2f(minSizeRatio(), minSizeRatio()); if(_type == QuestBook) { // TODO change this once the aspect ratio in character screen, spell book, etc. is fixed. scale = sizeRatio(); } switch(_type) { // TODO this information should not be hardcoded case Notice: { background = TextureContainer::LoadUI("graph/interface/book/notice"); if(background) { newPos = Vec2f(320 * Xratio - background->m_dwWidth * 0.5f * scale.x, 47.f * scale.y); newTextStart = Vec2f(50.f, 50.f); newTextEnd = Vec2f(background->size()) - Vec2f(50.f, 50.f); } break; } case SmallNote: { background = TextureContainer::LoadUI("graph/interface/book/bignote"); if(background) { newPos = Vec2f(320 * Xratio - background->m_dwWidth * 0.5f * scale.x, 47.f * scale.y); newTextStart = Vec2f(30.f, 30.f); newTextEnd = Vec2f(background->size()) - Vec2f(30.f, 40.f); } break; } case BigNote: { background = TextureContainer::LoadUI("graph/interface/book/very_bignote"); if(background) { newPos = Vec2f(320 * Xratio - background->m_dwWidth * 0.5f * scale.x, 47.f * scale.y); newTextStart = Vec2f(40.f, 40.f); newTextEnd = Vec2f(background->size()) * Vec2f(0.5f, 1.f) - Vec2f(10.f, 40.f); maxPages = 2; } break; } case Book: { background = TextureContainer::LoadUI("graph/interface/book/ingame_books"); prevPage = TextureContainer::LoadUI("graph/interface/book/left_corner"); nextPage = TextureContainer::LoadUI("graph/interface/book/right_corner"); if(background) { newPos = Vec2f(320 * Xratio - background->m_dwWidth * 0.5f * scale.x, 47.f * scale.y); newTextStart = Vec2f(40.f, 20.f); newTextEnd = Vec2f(background->size()) * Vec2f(0.5f, 1.f) - Vec2f(10.f, 40.f); maxPages = std::numeric_limits<size_t>::max(); prevButtonOffset = Vec2f(8.f, -6.f); nextButtonOffset = Vec2f(-15.f, -6.f); } break; } case QuestBook: { background = TextureContainer::LoadUI("graph/interface/book/questbook"); prevPage = TextureContainer::LoadUI("graph/interface/book/left_corner_original"); nextPage = TextureContainer::LoadUI("graph/interface/book/right_corner_original"); if(background) { newPos = Vec2f(97, 64) * scale; newTextStart = Vec2f(40.f, 40.f); newTextEnd = Vec2f(background->size()) * Vec2f(0.5f, 1.f) - Vec2f(10.f, 65.f); maxPages = std::numeric_limits<size_t>::max(); prevButtonOffset = Vec2f(8.f, -6.f); nextButtonOffset = Vec2f(-15.f, -6.f); } } case Undefined: break; // Cannot handle notes of undefined type. } if(!background) { allocatedForRatio = sizeRatio(); return false; } _area = Rectf(newPos, background->m_dwWidth * scale.x, background->m_dwHeight * scale.y); _textArea = Rect(Vec2i(newTextStart * scale), Vec2i(newTextEnd * scale)); _pageSpacing = 20 * scale.x; if(prevPage) { Vec2f pos = Vec2f(0.f, background->m_dwHeight - prevPage->m_dwHeight) + prevButtonOffset; pos *= scale; _prevPageButton = Rectf(newPos + pos, prevPage->m_dwWidth * scale.x, prevPage->m_dwHeight * scale.y); } if(nextPage) { Vec2f pos = Vec2f(background->size() - nextPage->size()) + nextButtonOffset; pos *= scale; _nextPageButton = Rectf(newPos + pos, nextPage->m_dwWidth * scale.x, nextPage->m_dwHeight * scale.y); } // Split text into pages // TODO This buffer and related string copies can be avoided by // using iterators for ARX_UNICODE_ForceFormattingInRect std::string buffer = _text; while(!buffer.empty()) { // Change the note type if the text is too long. if(pages.size() >= maxPages) { switch(_type) { case Notice: _type = SmallNote; break; case SmallNote: _type = BigNote; break; case BigNote: _type = Book; break; default: ARX_DEAD_CODE(); break; } return allocate(); } long pageSize = ARX_UNICODE_ForceFormattingInRect(hFontInGameNote, buffer, _textArea); if(pageSize <= 0) { LogWarning << "Error splitting note text into pages"; pages.push_back(buffer); break; } pages.push_back(buffer.substr(0, pageSize)); // Skip whitespace at the start of pages. while(size_t(pageSize) < buffer.size() && std::isspace(buffer[pageSize])) { pageSize++; } buffer = buffer.substr(pageSize); } // Clamp the current page to a valid page. setPage(_page); allocatedForRatio = sizeRatio(); return true; }
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, zoom); GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapRepeat); if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) { drawPlayer(3.f, playerPos, false); 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 / MINIMAP_MAX_X, zoom / 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; } Vec2f pos; pos.x = m_mapMarkers[i].m_pos.x * 8 * ratio * m_activeBkg->Xmul * casePos.x + start.x; 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); } }
//----------------------------------------------------------------------------- void ARX_MINIMAP_Show(LPDIRECT3DDEVICE7 m_pd3dDevice, long SHOWLEVEL, long flag, long fl2) { float sstartx, sstarty; if (!pTexDetect) { GetTextureFile("Graph\\particles\\flare.bmp"); char temp[256]; MakeDir(temp, "Graph\\particles\\flare.bmp"); pTexDetect = D3DTextr_GetSurfaceContainer(temp); } // SHOWLEVEL=8; // First Load Minimap TC & DATA if needed if (minimap[SHOWLEVEL].tc == NULL) { ARX_MINIMAP_GetData(SHOWLEVEL); } if ((minimap[SHOWLEVEL].tc) && (minimap[SHOWLEVEL].tc->m_pddsSurface)) { float startx, starty, casex, casey, ratiooo; float mod_x = (float)MAX_BKGX / (float)MINIMAP_MAX_X; float mod_z = (float)MAX_BKGZ / (float)MINIMAP_MAX_Z; if (flag == 1) { startx = 0; starty = 0; casex = (900) / ((float)MINIMAP_MAX_X); casey = (900) / ((float)MINIMAP_MAX_Z); ratiooo = 900.f / 250.f; if (fl2) { casex = (600) / ((float)MINIMAP_MAX_X); casey = (600) / ((float)MINIMAP_MAX_Z); ratiooo = 600.f / 250.f; } } else { startx = (140); starty = (120); casex = (250) / ((float)MINIMAP_MAX_X); casey = (250) / ((float)MINIMAP_MAX_Z); ratiooo = 1.f; } sstartx = startx; sstarty = starty; float ofx, ofx2, ofy, ofy2, px, py; px = py = 0.f; ofx = mini_offset_x[CURRENTLEVEL]; ofx2 = minimap[SHOWLEVEL].xratio; ofy = mini_offset_y[CURRENTLEVEL]; ofy2 = minimap[SHOWLEVEL].yratio; if ((SHOWLEVEL == ARX_LEVELS_GetRealNum(CURRENTLEVEL)) || (flag == 2)) { // Computes playerpos ofx = mini_offset_x[CURRENTLEVEL]; ofx2 = minimap[SHOWLEVEL].xratio; ofy = mini_offset_y[CURRENTLEVEL]; ofy2 = minimap[SHOWLEVEL].yratio; px = startx + ((player.pos.x + ofx - ofx2) * DIV100 * casex + mini_offset_x[CURRENTLEVEL] * ratiooo * mod_x) / mod_x ; //DIV100*2; py = starty + ((mapmaxy[SHOWLEVEL] - ofy - ofy2) * DIV100 * casey - (player.pos.z + ofy - ofy2) * DIV100 * casey + mini_offset_y[CURRENTLEVEL] * ratiooo * mod_z) / mod_z ; //DIV100*2; if (flag == 1) { sstartx = startx; sstarty = starty; startx = 490.f - px; starty = 220.f - py; px += startx; py += starty; } } D3DTLVERTEX verts[4]; SETTC(m_pd3dDevice, minimap[SHOWLEVEL].tc); for (long k = 0; k < 4; k++) { verts[k].color = 0xFFFFFFFF; verts[k].rhw = 1; verts[k].sz = 0.00001f; } float div = DIV25; TextureContainer * tc = minimap[SHOWLEVEL].tc; float dw = 1.f / (float)max(tc->m_dwDeviceWidth, tc->m_dwOriginalWidth); float dh = 1.f / (float)max(tc->m_dwDeviceHeight, tc->m_dwOriginalHeight); float vx2 = 4.f * dw * mod_x; float vy2 = 4.f * dh * mod_z; float _px; RECT boundaries; float MOD20, MOD20DIV, divXratio, divYratio; boundaries.bottom = boundaries.left = boundaries.right = boundaries.top = 0; MOD20 = MOD20DIV = divXratio = divYratio = 0.f; if (flag != 2) { if (flag == 1) { MOD20 = 20.f * Xratio; MOD20DIV = 1.f / (MOD20); //@PERF do if(fl2){}else{} to make 4 and not 8 flot op if fl2. ARX_CHECK_LONG((360 + MOD20)*Xratio); ARX_CHECK_LONG((555 - MOD20)*Xratio); ARX_CHECK_LONG((85 + MOD20)*Yratio); ARX_CHECK_LONG((355 - MOD20)*Yratio); //CAST boundaries.left = ARX_CLEAN_WARN_CAST_LONG((360 + MOD20) * Xratio); boundaries.right = ARX_CLEAN_WARN_CAST_LONG((555 - MOD20) * Xratio); boundaries.top = ARX_CLEAN_WARN_CAST_LONG((85 + MOD20) * Yratio); boundaries.bottom = ARX_CLEAN_WARN_CAST_LONG((355 - MOD20) * Yratio); if (fl2) { //CHECK (DEBUG) ARX_CHECK_LONG((390 + MOD20)*Xratio); ARX_CHECK_LONG((590 - MOD20)*Xratio); ARX_CHECK_LONG((135 + MOD20)*Yratio); ARX_CHECK_LONG((295 - MOD20)*Yratio); //CAST boundaries.left = ARX_CLEAN_WARN_CAST_LONG((390 + MOD20) * Xratio); boundaries.right = ARX_CLEAN_WARN_CAST_LONG((590 - MOD20) * Xratio); boundaries.top = ARX_CLEAN_WARN_CAST_LONG((135 + MOD20) * Yratio); boundaries.bottom = ARX_CLEAN_WARN_CAST_LONG((295 - MOD20) * Yratio); } } SETALPHABLEND(m_pd3dDevice, TRUE); m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO); m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCCOLOR); m_pd3dDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS); SETTEXTUREWRAPMODE(m_pd3dDevice, D3DTADDRESS_CLAMP); if (fl2) { m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCCOLOR); } } else { divXratio = 1.f / Xratio; divYratio = 1.f / Yratio; } for (long j = -2; j < MINIMAP_MAX_Z + 2; j++) { for (long i = -2; i < MINIMAP_MAX_X + 2; i++) { float vx, vy, vxx, vyy; vxx = ((float)i * (float)ACTIVEBKG->Xdiv * mod_x); vyy = ((float)j * (float)ACTIVEBKG->Zdiv * mod_z); vx = (vxx * div) * dw; vy = (vyy * div) * dh; long okay = 1; float posx = (startx + i * casex) * Xratio; float posy = (starty + j * casey) * Yratio; if (flag == 1) { if ((posx < 360 * Xratio) || (posx > 555 * Xratio) || (posy < 85 * Yratio) || (posy > 355 * Yratio)) okay = 0; if (fl2) { okay = 1; if ((posx < 390 * Xratio) || (posx > 590 * Xratio) || (posy < 135 * Yratio) || (posy > 295 * Yratio)) okay = 0; } } else { if ((posx > 345 * Xratio) || (posy > 290 * Yratio)) okay = 0; } if (okay) { if ((flag == 2) && (i >= 0) && (i < MINIMAP_MAX_X) && (j >= 0) && (j < MINIMAP_MAX_Z)) { float d = Distance2D(posx * divXratio + casex * DIV2, posy * divYratio /*-casey * 2 * Yratio*/, px, py); if (d <= 6.f) { long r; float vv = (6 - d) * DIV6; if (vv >= 0.5f) vv = 1.f; else if (vv > 0.f) vv = vv * 2.f; else vv = 0.f; F2L((float)(vv * 255.f), &r); long ucLevel = __max(r, minimap[SHOWLEVEL].revealed[i][j]); ARX_CHECK_UCHAR(ucLevel); minimap[SHOWLEVEL].revealed[i][j] = ARX_CLEAN_WARN_CAST_UCHAR(ucLevel); } } if (!FOR_EXTERNAL_PEOPLE) { if ((i >= 0) && (i < MINIMAP_MAX_X) && (j >= 0) && (j < MINIMAP_MAX_Z)) { minimap[SHOWLEVEL].revealed[i][j] = 255; } } verts[3].sx = verts[0].sx = (posx); verts[1].sy = verts[0].sy = (posy); verts[2].sx = verts[1].sx = posx + (casex * Xratio); verts[3].sy = verts[2].sy = posy + (casey * Yratio); verts[3].tu = verts[0].tu = vx; verts[1].tv = verts[0].tv = vy; verts[2].tu = verts[1].tu = vx + vx2; verts[3].tv = verts[2].tv = vy + vy2; if (flag != 2) { float v; float oo = 0.f; if ((i < 0) || (i >= MINIMAP_MAX_X) || (j < 0) || (j >= MINIMAP_MAX_Z)) v = 0; else v = ((float)minimap[SHOWLEVEL].revealed[i][j]) * DIV255; if (flag == 1) { long vert = 0; _px = verts[vert].sx - boundaries.left; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; _px = boundaries.right - verts[vert].sx; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; _px = verts[vert].sy - boundaries.top; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; _px = boundaries.bottom - verts[vert].sy; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; } if (fl2) verts[0].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2); else verts[0].color = D3DRGB(v, v, v); oo += v; if ((i + 1 < 0) || (i + 1 >= MINIMAP_MAX_X) || (j < 0) || (j >= MINIMAP_MAX_Z)) v = 0; else v = ((float)minimap[SHOWLEVEL].revealed[__min(i+1, MINIMAP_MAX_X-1)][j]) * DIV255; if (flag == 1) { long vert = 1; _px = verts[vert].sx - boundaries.left; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; _px = boundaries.right - verts[vert].sx; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; _px = verts[vert].sy - boundaries.top; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; _px = boundaries.bottom - verts[vert].sy; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; } if (fl2) verts[1].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2); else verts[1].color = D3DRGB(v, v, v); oo += v; if ((i + 1 < 0) || (i + 1 >= MINIMAP_MAX_X) || (j + 1 < 0) || (j + 1 >= MINIMAP_MAX_Z)) v = 0; else v = ((float)minimap[SHOWLEVEL].revealed[__min(i+1, MINIMAP_MAX_X-1)][__min(j+1, MINIMAP_MAX_Z-1)]) * DIV255; if (flag == 1) { long vert = 2; _px = verts[vert].sx - boundaries.left; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; _px = boundaries.right - verts[vert].sx; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; _px = verts[vert].sy - boundaries.top; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; _px = boundaries.bottom - verts[vert].sy; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; } if (fl2) verts[2].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2); else verts[2].color = D3DRGB(v, v, v); oo += v; if ((i < 0) || (i >= MINIMAP_MAX_X) || (j + 1 < 0) || (j + 1 >= MINIMAP_MAX_Z)) v = 0; else v = ((float)minimap[SHOWLEVEL].revealed[i][__min(j+1, MINIMAP_MAX_Z-1)]) * DIV255; if (flag == 1) { long vert = 3; _px = verts[vert].sx - boundaries.left; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; _px = boundaries.right - verts[vert].sx; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; _px = verts[vert].sy - boundaries.top; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; _px = boundaries.bottom - verts[vert].sy; if (_px < 0.f) v = 0.f; else if (_px < MOD20) v *= _px * MOD20DIV; } if (fl2) verts[3].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2); else verts[3].color = D3DRGB(v, v, v); oo += v; if (oo > 0.f) { if (fl2) { verts[0].sx += DECALX * Xratio; verts[0].sy += DECALY * Yratio; verts[1].sx += DECALX * Xratio; verts[1].sy += DECALY * Yratio; verts[2].sx += DECALX * Xratio; verts[2].sy += DECALY * Yratio; verts[3].sx += DECALX * Xratio; verts[3].sy += DECALY * Yratio; } EERIEDRAWPRIM(GDevice, D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, 4, 0); } } } } } if (flag != 2) { m_pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESS , D3DTADDRESS_WRAP); m_pd3dDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL); SETALPHABLEND(m_pd3dDevice, FALSE); if ((SHOWLEVEL == ARX_LEVELS_GetRealNum(CURRENTLEVEL))) { // Now Draws Playerpos/angle verts[0].color = 0xFFFF0000; verts[1].color = 0xFFFF0000; verts[2].color = 0xFFFF0000; float val; if (flag == 1) val = 6.f; else val = 3.f; float rx = 0.f; float ry = -val * 1.8f; float rx2 = -val * DIV2; float ry2 = val; float rx3 = val * DIV2; float ry3 = val; float angle = DEG2RAD(player.angle.b); float ca = EEcos(angle); float sa = EEsin(angle); verts[0].sx = (px + rx2 * ca + ry2 * sa) * Xratio; verts[0].sy = (py + ry2 * ca - rx2 * sa) * Yratio; verts[1].sx = (px + rx * ca + ry * sa) * Xratio; verts[1].sy = (py + ry * ca - rx * sa) * Yratio; verts[2].sx = (px + rx3 * ca + ry3 * sa) * Xratio; verts[2].sy = (py + ry3 * ca - rx3 * sa) * Yratio; SETTC(GDevice, NULL); if (fl2) { SETALPHABLEND(m_pd3dDevice, TRUE); verts[0].sx += DECALX * Xratio; verts[0].sy += DECALY * Yratio; verts[1].sx += DECALX * Xratio; verts[1].sy += DECALY * Yratio; verts[2].sx += DECALX * Xratio; verts[2].sy += DECALY * Yratio; } EERIEDRAWPRIM(GDevice, D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, 3, 0); if (fl2) SETALPHABLEND(m_pd3dDevice, FALSE); } } // tsu for (long lnpc = 1; lnpc < inter.nbmax; lnpc++) { if ((inter.iobj[lnpc] != NULL) && (inter.iobj[lnpc]->ioflags & IO_NPC)) { if (inter.iobj[lnpc]->_npcdata->life > 0.f) if (!((inter.iobj[lnpc]->GameFlags & GFLAG_MEGAHIDE) || (inter.iobj[lnpc]->show == SHOW_FLAG_MEGAHIDE)) && (inter.iobj[lnpc]->show == SHOW_FLAG_IN_SCENE)) if (!(inter.iobj[lnpc]->show == SHOW_FLAG_HIDDEN)) if (inter.iobj[lnpc]->_npcdata->fDetect >= 0) { if (player.Full_Skill_Etheral_Link >= inter.iobj[lnpc]->_npcdata->fDetect) { float fpx; float fpy; fpx = sstartx + ((inter.iobj[lnpc]->pos.x - 100 + ofx - ofx2) * DIV100 * casex + mini_offset_x[CURRENTLEVEL] * ratiooo * mod_x) / mod_x; fpy = sstarty + ((mapmaxy[SHOWLEVEL] - ofy - ofy2) * DIV100 * casey - (inter.iobj[lnpc]->pos.z + 200 + ofy - ofy2) * DIV100 * casey + mini_offset_y[CURRENTLEVEL] * ratiooo * mod_z) / mod_z; if (flag == 1) { fpx = startx + ((inter.iobj[lnpc]->pos.x - 100 + ofx - ofx2) * DIV100 * casex + mini_offset_x[CURRENTLEVEL] * ratiooo * mod_x) / mod_x; fpy = starty + ((mapmaxy[SHOWLEVEL] - ofy - ofy2) * DIV100 * casey - (inter.iobj[lnpc]->pos.z + 200 + ofy - ofy2) * DIV100 * casey + mini_offset_y[CURRENTLEVEL] * ratiooo * mod_z) / mod_z; } float d = Distance2D(player.pos.x, player.pos.z, inter.iobj[lnpc]->pos.x, inter.iobj[lnpc]->pos.z); if ((d <= 800) && (fabs(inter.iobj[0]->pos.y - inter.iobj[lnpc]->pos.y) < 250.f)) { float col = 1.f; if (d > 600.f) { col = 1.f - (d - 600.f) * DIV200; } if (!fl2) { SETALPHABLEND(m_pd3dDevice, true); m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); } else SETALPHABLEND(m_pd3dDevice, true); if (fl2) { fpx += DECALX * Xratio; fpy += (DECALY + 15) * Yratio; } fpx *= Xratio; fpy *= Yratio; EERIEDrawBitmap(GDevice, fpx, fpy, 5.f * ratiooo, 5.f * ratiooo, 0, pTexDetect, D3DRGB(col, 0, 0)); if (!fl2) SETALPHABLEND(m_pd3dDevice, false); } } } } } if (flag == 0) for (long i = 0; i < Nb_Mapmarkers; i++) { if (Mapmarkers[i].lvl == SHOWLEVEL + 1) { float pos_x = Mapmarkers[i].x * 8 * ratiooo * ACTIVEBKG->Xmul * casex + startx; float pos_y = Mapmarkers[i].y * 8 * ratiooo * ACTIVEBKG->Zmul * casey + starty; float size = 5.f * ratiooo; verts[0].color = 0xFFFF0000; verts[1].color = 0xFFFF0000; verts[2].color = 0xFFFF0000; verts[3].color = 0xFFFF0000; verts[0].sx = (pos_x - size) * Xratio; verts[0].sy = (pos_y - size) * Yratio; verts[1].sx = (pos_x + size) * Xratio; verts[1].sy = (pos_y - size) * Yratio; verts[2].sx = (pos_x + size) * Xratio; verts[2].sy = (pos_y + size) * Yratio; verts[3].sx = (pos_x - size) * Xratio; verts[3].sy = (pos_y + size) * Yratio; verts[0].tu = 0.f; verts[0].tv = 0.f; verts[1].tu = 1.f; verts[1].tv = 0.f; verts[2].tu = 1.f; verts[2].tv = 1.f; verts[3].tu = 0.f; verts[3].tv = 1.f; if ((!fl2) && (MouseInRect(verts[0].sx, verts[0].sy, verts[2].sx, verts[2].sy))) { if (!Mapmarkers[i].tstring) { _TCHAR output[4096]; MakeLocalised(Mapmarkers[i].string, output, 4096, 0); Mapmarkers[i].tstring = (_TCHAR *)malloc((_tcslen(output) + 1) * sizeof(_TCHAR)); ZeroMemory(Mapmarkers[i].tstring, (_tcslen(output) + 1)*sizeof(_TCHAR)); _tcscpy(Mapmarkers[i].tstring, output); } if (Mapmarkers[i].tstring) { RECT rRect, bRect; SetRect(&bRect , (140), (290) , (140 + 205), (358)); float fLeft = (bRect.left) * Xratio ; float fRight = (bRect.right) * Xratio ; float fTop = (bRect.top) * Yratio ; float fBottom = (bRect.bottom) * Yratio ; ARX_CHECK_INT(fLeft); ARX_CHECK_INT(fRight); ARX_CHECK_INT(fTop); ARX_CHECK_INT(fBottom); SetRect(&rRect , ARX_CLEAN_WARN_CAST_INT(fLeft) , ARX_CLEAN_WARN_CAST_INT(fTop) , ARX_CLEAN_WARN_CAST_INT(fRight) , ARX_CLEAN_WARN_CAST_INT(fBottom)); long lLengthDraw = ARX_UNICODE_ForceFormattingInRect( hFontInGameNote, Mapmarkers[i].tstring, 0, rRect); danaeApp.DANAEEndRender(); _TCHAR Page_Buffer[256]; _tcsncpy(Page_Buffer, Mapmarkers[i].tstring, lLengthDraw); Page_Buffer[lLengthDraw] = _T('\0'); DrawBookTextInRect(ARX_CLEAN_WARN_CAST_FLOAT(bRect.left), ARX_CLEAN_WARN_CAST_FLOAT(bRect.top), ARX_CLEAN_WARN_CAST_FLOAT(bRect.right), ARX_CLEAN_WARN_CAST_FLOAT(bRect.bottom), Page_Buffer, 0, 0x00FF00FF, hFontInGameNote); danaeApp.DANAEStartRender(); } } if (MapMarkerTc == NULL) { MapMarkerTc = MakeTCFromFile("Graph\\interface\\icons\\mapmarker.bmp"); } SETTC(GDevice, MapMarkerTc); if (fl2) { verts[0].sx += DECALX * Xratio; verts[0].sy += DECALY * Yratio; verts[1].sx += DECALX * Xratio; verts[1].sy += DECALY * Yratio; verts[2].sx += DECALX * Xratio; verts[2].sy += DECALY * Yratio; verts[3].sx += DECALX * Xratio; verts[3].sy += DECALY * Yratio; } EERIEDRAWPRIM(GDevice, D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, 4, 0); } } } }