CGFontTexture.cpp
unknown
plain_text
2 years ago
3.2 kB
124
Indexable
int CGFontTexture::Render_0(int x, int y, int z, byte alpha) { int result = reinterpret_cast<int(__thiscall *)(CGFontTexture *, int, int, int, byte)>(0x00B17E20)(this, x, y, z, alpha); RenderDDJ(x, y, 0); return result; } int CGFontTexture::Render_1(int x, int y, byte alpha) { int result = reinterpret_cast<int(__thiscall *)(CGFontTexture *, int, int, byte)>(0x00B18CD0)(this, x, y, alpha); RenderDDJ(x, y, 1); return result; } void CGFontTexture::RenderDDJ(int x, int y, byte type) { std::n_wstring text; this->GetText(&text); if (g_pCGInterface && text.length() > 1) { std::map<std::string, IDirect3DBaseTexture9 *>::const_iterator it = m_RenderOverText.begin(); for (; it != m_RenderOverText.end(); ++it) { std::n_wstring wstr_key = TO_NWSTRING(it->first); size_t found_pos = text.rfind(wstr_key.c_str()); if (found_pos != std::string::npos) { for (size_t j = 0; j < text.length(); j++) { if (text.compare(j, wstr_key.length(), wstr_key) == 0) { int textOffset = GetTextWidth(text, j) - 1; int textWidth = GetTextWidth(wstr_key.c_str()) + 2; float zValue = (type == 0) ? 1.0 : 0.9; int textOffsetY = 0; if (type == 1 && textOffset > -1) { int linesToMove = static_cast<int>(ceil(float(textOffset) / 200.0)) - 1; textOffset -= linesToMove * 198; textOffsetY = 14 * linesToMove; } D3DVECTOR dataOut[8] = { {x + textOffset, y + textOffsetY, zValue}, {0.1, 0.0, 0.0}, {x + textOffset + textWidth, y + textOffsetY, zValue}, {0.1, 1.0, 0.0}, {x + textOffset + textWidth, y + textOffsetY + 16.0f, zValue}, {0.1, 1.0, 1.0}, {x + textOffset, y + textOffsetY + 16.0f, zValue}, {0.1, 0.0, 1.0} }; g_RStateMgr.SetTextureForStage(0, it->second); int local_158 = 0; if (g_pDynamicVertexBuffer->IVBDynamic_Func_6(dataOut, 0x60, &local_158) != 0) { IDirect3DVertexBuffer9 *iVar5 = g_pDynamicVertexBuffer->IVBDynamic_Func_5(); g_RStateMgr.m_pDevice->SetStreamSource(0, iVar5, 0, 0x18); g_RStateMgr.m_pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, local_158, 2); } } } } } } } int CGFontTexture::GetTextWidth(std::n_wstring str, int index) { CGFontTexture tempTexture; tempTexture.SetSomething(theApp.GetFont(0)); std::n_wstring tempText = (index == -1) ? str : str.substr(0, index); tempTexture.sub_B1D410(&tempText); return tempTexture.GetDimensions().width; }
Editor is loading...