forked from diasurgical/devilution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcredits.cpp
235 lines (220 loc) · 6.7 KB
/
credits.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
// ref: 0x10005297
void __cdecl credits_cpp_init()
{
credits_cpp_float = credits_cpp_float_value;
}
// 1001F408: using guessed type int credits_cpp_float_value;
// 100296EC: using guessed type int credits_cpp_float;
// ref: 0x100052A2
BOOL __stdcall UiCreditsDialog(int a1)
{
int v1; // eax
v1 = (int)SDrawGetFrameWindow(NULL);
SDlgDialogBoxParam(ghUiInst, "CREDITS_DIALOG", v1, credits_WndProc, 25);
return 1;
}
// 10010382: using guessed type DWORD __stdcall SDrawGetFrameWindow();
// ref: 0x100052C7
LRESULT __stdcall credits_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
HWND v5; // eax
if (Msg > 0x111) {
if (Msg == 275) {
credits_CalcPosROP3(hWnd);
return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam);
}
if (Msg == 513 || Msg == 516)
goto LABEL_12;
if (Msg != 528) {
if (Msg == 2024) {
if (!Fade_CheckRange5())
Fade_SetFadeTimer((int)hWnd);
return 0;
}
return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam);
}
if ((WORD)wParam != 513 && (WORD)wParam != 516)
return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam);
LABEL_25:
Title_KillAndFadeDlg(hWnd);
return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam);
}
if (Msg == 273)
goto LABEL_25;
if (Msg != 2) {
if (Msg == 135)
return 4;
if (Msg != 256) {
if (Msg > 0x103) {
if (Msg <= 0x105) {
v5 = (HWND)SDrawGetFrameWindow(NULL);
SendMessageA(v5, Msg, wParam, lParam);
} else if (Msg == 272) {
credits_LoadImgCreditTxt(hWnd, lParam);
PostMessageA(hWnd, 0x7E8u, 0, 0);
return 1;
}
}
return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam);
}
if (wParam != 32)
return 0;
LABEL_12:
Title_KillAndFadeDlg(hWnd);
return 0;
}
credits_FreeCreditResrc(hWnd);
return (LRESULT)SDlgDefDialogProc(hWnd, Msg, (HDC)wParam, (HWND)lParam);
}
// 10010382: using guessed type DWORD __stdcall SDrawGetFrameWindow();
// ref: 0x100053D9
void __fastcall credits_FreeCreditResrc(HWND hWnd)
{
void **v2; // eax
if (creditsobj) {
SGdiDeleteObject(creditsobj);
creditsobj = 0;
}
if (credit_back_img) {
SMemFree(credit_back_img, "C:\\Src\\Diablo\\DiabloUI\\credits.cpp", 46, 0);
credit_back_img = 0;
}
v2 = (void **)GetWindowLongA(hWnd, -21);
local_FreeMemPtr(v2);
if (credittext_rsrc) {
FreeResource(credittext_rsrc);
credittext_rsrc = 0;
}
}
// ref: 0x1000543A
void __fastcall credits_LoadImgCreditTxt(HWND hWnd, LPARAM lParam)
{
signed int v2; // eax
HRSRC v3; // eax
HRSRC v4; // eax
DWORD *v5; // eax
DWORD *v6; // esi
int v7; // ebx
int v8; // esi
HFONT v9; // eax MAPDST
BOOL v11; // ebx
struct tagRECT Rect; // [esp+Ch] [ebp-18h]
HWND v13; // [esp+1Ch] [ebp-8h]
if (lParam)
v2 = 1000 / lParam;
else
v2 = 50;
SDlgSetTimer((int)hWnd, 1, v2, 0);
v3 = FindResourceA(ghUiInst, "IDR_CREDITS", "TEXT_FILES");
credittext_rsrc = LoadResource(ghUiInst, v3);
v4 = FindResourceA(ghUiInst, "IDR_CREDITS", "TEXT_FILES");
credittext_size = SizeofResource(ghUiInst, v4);
v5 = local_AllocWndLongData();
v6 = v5;
if (v5) {
SetWindowLongA(hWnd, -21, (LONG)v5);
local_LoadArtWithPal(hWnd, 0, &nullcharacter, -1, 1, "ui_art\\credits.pcx", (BYTE **)v6, v6 + 1, 0);
Fade_NoInputAndArt(hWnd, 0);
}
v13 = GetDlgItem(hWnd, 1000);
GetWindowRect(v13, &Rect);
v7 = Rect.right - Rect.left;
v8 = Rect.bottom - Rect.top + 60;
credit_back_img = SMemAlloc((Rect.right - Rect.left) * v8, "C:\\Src\\Diablo\\DiabloUI\\credits.cpp", 122, 0);
credit_horz_pos = v7;
credit_vertical_pos1 = v8;
local_AdjustRectSize(&Rect, 0, 30);
SDlgSetBitmapI(v13, 0, 0, -1, 1, credit_back_img, (int)&Rect, v7, v8, -1);
credit_vertical_pos2 = v8 - 30;
credits_CalcPosROP3(hWnd);
v9 = CreateFontA(-17, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, 0, 0, VARIABLE_PITCH | (FF_SCRIPT << 2), "Times New Roman");
if (!v9 || (v11 = SGdiImportFont(v9, (int)&creditsobj), DeleteObject(v9), !v11))
Title_KillAndFadeDlg(hWnd);
}
// 100296E8: using guessed type int credittext_size;
// 100296FC: using guessed type int credit_vertical_pos1;
// ref: 0x100055C0
void __fastcall credits_CalcPosROP3(HWND hWnd)
{
DWORD *v2; // edi
struct tagRECT Rect; // [esp+Ch] [ebp-14h]
HWND hWnda; // [esp+1Ch] [ebp-4h]
hWnda = GetDlgItem(hWnd, 1000);
v2 = (DWORD *)GetWindowLongA(hWnd, -21);
GetWindowRect(hWnda, &Rect);
ScreenToClient(hWnd, (LPPOINT)&Rect);
ScreenToClient(hWnd, (LPPOINT)&Rect.right);
SBltROP3(
(char *)credit_back_img + 30 * credit_horz_pos,
(void *)(Rect.left + *v2 + Rect.top * v2[1]),
credit_horz_pos,
Rect.bottom - Rect.top,
credit_horz_pos,
v2[1],
0,
0xCC0020u);
--credit_vertical_pos2;
credits_PrintCredLines(hWnd);
InvalidateRect(hWnda, 0, 0);
UpdateWindow(hWnda);
}
// ref: 0x10005660
void __fastcall credits_PrintCredLines(HWND hWnd)
{
char *v1; // esi
int i; // edi
int v3; // ebp
int v4; // ebx
v1 = (char *)LockResource(credittext_rsrc);
credit_line_count = credittext_size;
SGdiSelectObject((int)creditsobj);
SGdiSetPitch(credit_horz_pos);
for (i = credit_vertical_pos2; credit_line_count > 0; v1 = credits_GetAdjustText(v1, v4)) {
v3 = 0;
while (*v1 == 9) {
v3 += 40;
++v1;
--credit_line_count;
}
v4 = credits_GetCredLineBreak(v1);
if (v4 == -1)
break;
if (i >= 0) {
if (i > credit_vertical_pos1 - 30)
break;
if (v4) {
SGdiTextOut(credit_back_img, v3 + 2, i + 2, 0x1000000, v1, v4);
SGdiTextOut(credit_back_img, v3, i, 16777440, v1, v4);
}
}
i += 22;
}
if (i < 0)
Title_KillAndFadeDlg(hWnd);
}
// 100103A6: using guessed type int __stdcall SGdiSetPitch(DWORD);
// 100103AC: using guessed type int __stdcall SGdiSelectObject(DWORD);
// 100296E8: using guessed type int credittext_size;
// 100296FC: using guessed type int credit_vertical_pos1;
// 10029700: using guessed type int credit_line_count;
// ref: 0x10005736
int __fastcall credits_GetCredLineBreak(char *str)
{
int result; // eax
result = 0;
while (*str != 13 && *str != 10) {
++result;
++str;
if (result > credit_line_count)
return -1;
}
return result;
}
// 10029700: using guessed type int credit_line_count;
// ref: 0x10005755
char *__fastcall credits_GetAdjustText(char *str, int len)
{
credit_line_count += -2 - len;
return &str[len + 2];
}
// 10029700: using guessed type int credit_line_count;