Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- union GfxColor {
- char array[4];
- unsigned int packed;
- };
- struct GfxCmdHeader {
- unsigned __int16 id;
- unsigned __int16 byteCount;
- };
- struct GfxCmdArray {
- char* cmds;
- unsigned __int64 usedTotal;
- unsigned __int64 usedCritical;
- GfxCmdHeader* lastCmd;
- };
- void(*R_ConvertColorToBytes)(float*, GfxColor*) = (decltype(R_ConvertColorToBytes))0x14061EC50;
- struct __declspec(align(2)) GfxCmdDrawText2D
- {
- GfxCmdHeader header;
- float x;
- float y;
- float rotation;
- Font_s* font;
- float xScale;
- float yScale;
- GfxColor color;
- int maxChars;
- int renderFlags;
- int cursorPos;
- char cursorLetter;
- GfxColor glowForceColor;
- int fxBirthTime;
- int fxLetterTime;
- int fxDecayStartTime;
- int fxDecayDuration;
- Material* fxMaterial;
- Material* fxMaterialGlow;
- float padding;
- char text[3];
- };
- GfxCmdHeader* R_GetCommandBuffer(int type, int bytes) {
- GfxCmdArray* s_cmdList = *(GfxCmdArray**)0x148111820;
- std::uint64_t cmdCount = *(std::uint64_t*)0x148111810;
- std::uint64_t remaining = (cmdCount - 0x2000 + s_cmdList->usedCritical - s_cmdList->usedTotal);
- if (bytes < remaining) {
- s_cmdList->usedTotal = s_cmdList->usedTotal + bytes;
- GfxCmdHeader* cmd = (GfxCmdHeader*)(s_cmdList->cmds + s_cmdList->usedTotal);
- s_cmdList->lastCmd = cmd;
- cmd->id = type;
- cmd->byteCount = bytes;
- return cmd;
- }
- return nullptr;
- }
- void R_AddCmdDrawText(const char* text, int maxChars, Font_s* font, float x, float y, float xscale, float yscale, float rotation, float* color, int style) {
- int len = strlen(text);
- GfxCmdDrawText2D* cmd = (GfxCmdDrawText2D*)R_GetCommandBuffer(0x11, len + 1 & 0xFFFFFFFFFFFFFFFC);
- if (cmd) {
- cmd->x = x;
- cmd->y = y;
- cmd->rotation = rotation;
- cmd->font = font;
- cmd->xScale = xscale;
- cmd->yScale = yscale;
- cmd->maxChars = maxChars;
- switch (style) {
- case 3: cmd->renderFlags = 4; break;
- case 6: cmd->renderFlags = 12; break;
- case 7: cmd->renderFlags = 1024; break;
- case 8: cmd->renderFlags = 3072; break;
- case 128: cmd->renderFlags = 1; break;
- case 132: cmd->renderFlags = 5; break;
- }
- R_ConvertColorToBytes(color, &cmd->color);
- memcpy(cmd->text, text, len);
- cmd->text[len] = '\0';
- }
- }
- void CopyPoolTextToCmd(char* textPool, int poolSize, int firstChar, int charCount, GfxCmdDrawText2D* cmd) {
- int poolRemaining = poolSize - firstChar;
- if (charCount > poolSize - firstChar) {
- memcpy(cmd->text, &textPool[firstChar], poolRemaining);
- memcpy(&cmd->text[poolRemaining], textPool, charCount - poolRemaining);
- }
- else {
- memcpy(cmd->text, &textPool[firstChar], charCount);
- }
- cmd->text[charCount] = 0;
- }
- GfxCmdDrawText2D* AddBaseDrawConsoleTextCmd(char* textPool, int poolSize, int firstChar, int charCount, Font_s* font, float x, float y, float xScale, float yScale, float* color, int style) {
- if (!charCount)
- return 0;
- GfxCmdDrawText2D* cmd = (GfxCmdDrawText2D*)R_GetCommandBuffer(0x11, (charCount + 96) & 0xFFFFFFFFFFFFFFFC);
- if (!cmd)
- return 0;
- cmd->x = x;
- cmd->y = y;
- cmd->rotation = 0.0f;
- cmd->font = font;
- cmd->xScale = xScale;
- cmd->yScale = yScale;
- cmd->maxChars = 0x7FFFFFFF;
- cmd->renderFlags = 0;
- switch (style) {
- case 3: cmd->renderFlags = 4; break;
- case 6: cmd->renderFlags = 12; break;
- case 7: cmd->renderFlags = 1024; break;
- case 8: cmd->renderFlags = 3072; break;
- case 128: cmd->renderFlags = 1; break;
- case 132: cmd->renderFlags = 5; break;
- }
- R_ConvertColorToBytes(color, &cmd->color);
- CopyPoolTextToCmd(textPool, poolSize, firstChar, charCount, cmd);
- return cmd;
- }
Advertisement
Add Comment
Please, Sign In to add comment