diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-09-06 13:55:10 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-09-06 13:55:10 +0800 |
commit | 33ae0e52dd2fc1d1bc9306ece0a1591cacbce0f0 (patch) | |
tree | 67f74b608ffcc93da03217f24e6eb8880775a750 /csrc | |
parent | 7c6eda569a9f3ae8814fd01267f655155e06ed8e (diff) | |
download | rich4-33ae0e52dd2fc1d1bc9306ece0a1591cacbce0f0.tar.xz |
draw_some_text
Diffstat (limited to 'csrc')
-rw-r--r-- | csrc/font.c | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/csrc/font.c b/csrc/font.c index e623884..7cfa7f4 100644 --- a/csrc/font.c +++ b/csrc/font.c @@ -44,3 +44,169 @@ void drawStringY(HDC hdc, int nXStart, int nYStart, LPCSTR str) nYStart += h; } } + +void draw_some_text(a1, const char *str, a3, a4, int a5) +{ + DDSURFACEDESC desc; /* esp */ + RECT fmt_dim1; /* esp + 0x6c */ + RECT fmt_dim2; /* esp + 0x7c */ + HDC hDC; /* esp + 0x8c */ + + fmt_dim1 = *(RECT*)0x44f6ec; + fmt_dim2 = *(RECT*)0x44f6fc; + + if (str == NULL || str[0] == 0) + return; + if (str[0] == '#') { + int t = (str[1] - '0') * 1000 + (str[2] - '0') * 100 + + (str[3] - '0') * 10 + (str[4] - '0'); + fcn.0045441a(t); + str += 5; + } + IDirectDrawSurface_GetDC(pddrawsf3, &hDC); + SelectObject(hDC, &gFont); + SetBkMode(hDC, 1); + SetTextCharacterExtra(hDC, gfa[1]-1); + DrawTextA(hDC, str, strlen(str), &fmt_dim2, 0x400); + int t1 = fmt_dim2.right + 10; + int t2 = fmt_dim2.bottom + 10; + fmt_dim2.right = t1; + fmt_dim2.bottom = t2; + if (a5 == 3) { + fmt_dim2.right = t2; + fmt_dim2.bottom = t1; + } else if (a5 == 4 || a5 == 7) { + eax = fmt_dim2.right / 2; + edx = 256 - eax; + fmt_dim2.left = edx; + eax += 256; + fmt_dim2.right = eax; + } + dh = b_4762d8; + if (dh != 1) { + SetTextColor(hDC, dw_4762e4); + eax = 1; + fmt_dim1.left = 1; + fmt_dim1.top = 1; + if (a5 >= 4) { + if (a5 == 4 || a5 == 7) { + DrawTextA(hDC, ebx, strlen(ebx), &fmt_dim1, 1); + } else { + DrawTextA(hDC, ebx, strlen(ebx), &fmt_dim1, 0); + } + } else if (a5 != 3) { + DrawTextA(hDC, ebx, strlen(ebx), &fmt_dim1, 0); + } else { + drawStringY(hDC, eax, eax, ebx); + } + goto L44fe09; + } + if (dh == 4) + goto L44fe09; + SetTextColor(hDC, dw_4762e4); + if (a5 == 3) { + drawStringY(hDC, 1, 0, ebx); + drawStringY(hDC, 1, 2, ebx); + drawStringY(hDC, 0, 1, ebx); + drawStringY(hDC, 2, 1, ebx); + goto L44fe09; + } + if (a5 == 4 || a5 == 7) { + esi = 1; + } else { + esi = 0; + } + + fmt_dim1.left = 1; + fmt_dim1.top = 0; + DrawTextA(hDC, ebx, strlen(ebx), &fmt_dim1, esi); + + fmt_dim1.left = 1; + fmt_dim1.top = 2; + DrawTextA(hDC, ebx, strlen(ebx), &fmt_dim1, esi); + + fmt_dim1.left = 0; + fmt_dim1.top = 1; + DrawTextA(hDC, ebx, strlen(ebx), &fmt_dim1, esi); + + fmt_dim1.left = 2; + fmt_dim1.top = 1; + DrawTextA(hDC, ebx, strlen(ebx), &fmt_dim1, esi); + +L44fe09: + + SetTextColor(hDC, dw_4762e0); + if ( ((uint8_t)gfa[0] & 4) != 0 ) { + edi = 1; + fmt_dim1.left = 1; + fmt_dim1.top = 1; + } else { + ecx = 0; + fmt_dim1.left = 0; + fmt_dim1.top = 0; + } + if (a5 >= 4) { + if (a5 == 4 || a5 == 7) { + DrawTextA(hDC, ebx, strlen(ebx), &fmt_dim1, 1); + } else { + DrawTextA(hDC, ebx, strlen(ebx), &fmt_dim1, 0); + } + } else if (a5 == 3) { + drawStringY(hDC, fmt_dim1.left, fmt_dim1.top, ebx); + } else { + DrawTextA(hDC, ebx, strlen(ebx), &fmt_dim1, 0); + } + + IDirectDrawSurface_ReleaseDC(pddrawsf3, hDC); + + desc.dwSize = 0x6c; + IDirectDrawSurface_Lock(pddrawsf3, NULL, &desc, 1, 0); + + fcn.0044f70c(desc.lpSurface, &fmt_dim2, &fmt_dim1); + esi = fmt_dim1.right - fmt_dim1.left + 1; + ebx = fmt_dim1.bottom - fmt_dim1.top + 1; + dw_4762f0 = desc.lpSurface; + eax = a5-1; + switch (eax) { + case 0: + a3 -= esi; + break; + case 1: + case 2: + case 3: + a3 -= esi / 2; + /* fall through */ + case 4: + eax = ebx / 2; + a4 -= eax; + break; + case 5: + a3 -= esi; + eax = ebx / 2; + a4 -= eax; + break; + case 6: + eax = esi / 2; + a3 = eax; + a4 = ebx; + break; + default: + break; + } + + if ( ((uint8_t)gfa[0] & 8) != 0) { + if (!a1) { + fcn.004564e6(sfdesc1.lpSurface, 0x4762e8, a3, a4, fmt_dim1.left, fmt_dim1.top, esi, ebx); + } else { + fcn.00456356(a1, 0x4762e8, a3, a4, fmt_dim1.left, fmt_dim1.top, esi, ebx); + } + } else { + if (!a1) { + fcn.00456495(sfdesc1.lpSurface, 0x4762e8, a3, a4, fmt_dim1.left, fmt_dim1.top, esi, ebx); + } else { + fcn.00456328(a1, 0x4762e8, a3, a4, fmt_dim1.left, fmt_dim1.top, esi, ebx); + } + } + fcn.004561be(0x4762e8, fmt_dim1.left, fmt_dim1.top, esi, ebx, 0); + IDirectDrawSurface_Unlock(NULL); +} |