forked from diasurgical/devilution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsbar.cpp
223 lines (212 loc) · 5.78 KB
/
sbar.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
// ref: 0x100099B5
void __cdecl Sbar_cpp_init()
{
Sbar_cpp_float = Sbar_cpp_float_value;
}
// 1001F448: using guessed type int Sbar_cpp_float_value;
// 1002A338: using guessed type int Sbar_cpp_float;
// ref: 0x100099C0
BOOL __fastcall Sbar_CheckIfNextHero(HWND hWnd)
{
_uiheroinfo *v1; // eax
v1 = (_uiheroinfo *)GetWindowLongA(hWnd, -21);
if (!v1 || !v1->next)
return 0;
v1->next = 0;
return 1;
}
// ref: 0x100099DC
int __fastcall Sbar_NumScrollLines(HWND hWnd, int width, int height)
{
DWORD *v4; // eax
DWORD *v5; // esi
int result; // eax
signed int v7; // ecx
LONG v8; // ebx
LONG v9; // edi
int v10; // [esp-4h] [ebp-1Ch]
struct tagPOINT Point; // [esp+Ch] [ebp-Ch]
Point.x = width;
Point.y = height;
if (!hWnd)
return 0;
if (!IsWindowVisible(hWnd))
return 0;
v4 = (DWORD *)GetWindowLongA(hWnd, -21);
v5 = v4;
if (!v4)
return 0;
v7 = v4[13];
if (v7 <= 1)
v8 = 22;
else
v8 = v4[14] * (v4[3] - v4[9] - 44) / (v7 - 1) + 22;
v9 = v8 + v4[9];
ScreenToClient(hWnd, &Point);
if (Point.y >= 22) {
if (Point.y >= v8) {
if (Point.y >= v9) {
if (Point.y >= v5[3] - 22) {
*v5 = 4;
v10 = 2;
} else {
*v5 = 8;
v10 = 4;
}
} else {
*v5 = 16;
v10 = 5;
}
} else {
*v5 = 2;
v10 = 3;
}
result = v10;
} else {
result = 1;
*v5 = 1;
}
return result;
}
// ref: 0x10009A99
void __fastcall Sbar_DrawScrollBar(HWND hWnd, int nIDDlgItem, int width, int height)
{
HWND v4; // eax
LONG v5; // eax MAPDST
bool v7; // zf
int v8; // eax
tagRECT DstRect; // [esp+Ch] [ebp-24h]
tagRECT SrcBuffer; // [esp+1Ch] [ebp-14h]
HWND hWnda; // [esp+2Ch] [ebp-4h]
v4 = GetDlgItem(hWnd, nIDDlgItem);
hWnda = v4;
if (v4) {
v5 = GetWindowLongA(v4, -21);
if (v5) {
if (*(DWORD *)(v5 + 4)) {
v7 = *(DWORD *)(v5 + 16) == 0;
*(DWORD *)(v5 + 52) = width;
*(DWORD *)(v5 + 56) = height;
if (!v7) {
SrcBuffer.left = 0;
DstRect.left = 0;
SrcBuffer.top = 0;
DstRect.top = 0;
DstRect.right = *(DWORD *)(v5 + 8) - 1;
DstRect.bottom = *(DWORD *)(v5 + 12) - 1;
SrcBuffer.right = *(DWORD *)(v5 + 8) - 1;
SrcBuffer.bottom = *(DWORD *)(v5 + 24) - 1;
SBltROP3Tiled(
*(void **)(v5 + 4),
&DstRect,
*(POINT **)(v5 + 8),
*(DWORD *)(v5 + 16),
&SrcBuffer,
*(RECT **)(v5 + 20),
0,
0,
0,
0xCC0020u);
if (*(DWORD *)(v5 + 28)) {
if (width <= 1)
v8 = 22;
else
v8 = height * (*(DWORD *)(v5 + 12) - *(DWORD *)(v5 + 36) - 44) / (width - 1) + 22;
SBltROP3(
(void *)(v8 * *(DWORD *)(v5 + 8) + *(DWORD *)(v5 + 4) + 3),
*(void **)(v5 + 28),
18,
*(DWORD *)(v5 + 36),
*(DWORD *)(v5 + 8),
*(DWORD *)(v5 + 32),
0,
0xCC0020u);
SBltROP3(
*(void **)(v5 + 4),
(void *)(*(DWORD *)(v5 + 40) + 22 * (~*(BYTE *)v5 & 1) * *(DWORD *)(v5 + 44)),
*(DWORD *)(v5 + 8),
22,
*(DWORD *)(v5 + 8),
*(DWORD *)(v5 + 44),
0,
0xCC0020u);
SBltROP3(
(void *)(*(DWORD *)(v5 + 4) + *(DWORD *)(v5 + 8) * (*(DWORD *)(v5 + 12) - 22)),
(void *)(*(DWORD *)(v5 + 40) + 22 * ((~*(BYTE *)v5 & 4 | 8u) >> 2) * *(DWORD *)(v5 + 44)),
*(DWORD *)(v5 + 8),
22,
*(DWORD *)(v5 + 8),
*(DWORD *)(v5 + 44),
0,
0xCC0020u);
InvalidateRect(hWnda, 0, 0);
}
}
}
}
}
}
// ref: 0x10009BF1
void __fastcall Sbar_LoadScrBarGFX(HWND hWnd, int nIDDlgItem)
{
DWORD *v2; // eax MAPDST
void *v4; // eax
struct tagRECT Rect; // [esp+Ch] [ebp-14h]
HWND hWnda; // [esp+1Ch] [ebp-4h]
hWnda = GetDlgItem(hWnd, nIDDlgItem);
if (hWnda) {
v2 = (DWORD *)SMemAlloc(0x3Cu, "C:\\Src\\Diablo\\DiabloUI\\Sbar.cpp", 221, 0);
if (v2) {
SetWindowLongA(hWnda, -21, (LONG)v2);
*v2 = 0;
GetClientRect(hWnda, &Rect);
v2[2] = Rect.right;
v2[3] = Rect.bottom;
v4 = SMemAlloc(Rect.right * Rect.bottom, "C:\\Src\\Diablo\\DiabloUI\\Sbar.cpp", 230, 0);
v2[1] = (DWORD)v4;
if (v4) {
SDlgSetBitmapI(hWnda, 0, &nullcharacter, -1, 1, v4, 0, v2[2], v2[3], -1);
local_LoadArtImage("ui_art\\sb_bg.pcx", (BYTE **)v2 + 4, v2 + 5);
local_LoadArtImage("ui_art\\sb_thumb.pcx", (BYTE **)v2 + 7, v2 + 8);
local_LoadArtImage("ui_art\\sb_arrow.pcx", (BYTE **)v2 + 10, v2 + 11);
}
}
}
}
// ref: 0x10009CC7
void __cdecl Sbar_cpp_init2()
{
Sbar_cpp_float2 = Sbar_cpp_float_value2;
}
// 1001F44C: using guessed type int Sbar_cpp_float_value2;
// 1002A344: using guessed type int Sbar_cpp_float2;
// ref: 0x10009CD2
void __fastcall Sbar_FreeScrollBar(HWND hWnd, int nIDDlgItem)
{
HWND v2; // eax MAPDST
DWORD *v4; // eax MAPDST
void *v6; // eax
void *v7; // eax
void *v8; // eax
void *v9; // eax
v2 = GetDlgItem(hWnd, nIDDlgItem);
if (v2) {
v4 = (DWORD *)GetWindowLongA(v2, -21);
if (v4) {
v6 = (void *)v4[1];
if (v6)
SMemFree(v6, "C:\\Src\\Diablo\\DiabloUI\\Sbar.cpp", 267, 0);
v7 = (void *)v4[4];
if (v7)
SMemFree(v7, "C:\\Src\\Diablo\\DiabloUI\\Sbar.cpp", 269, 0);
v8 = (void *)v4[7];
if (v8)
SMemFree(v8, "C:\\Src\\Diablo\\DiabloUI\\Sbar.cpp", 271, 0);
v9 = (void *)v4[10];
if (v9)
SMemFree(v9, "C:\\Src\\Diablo\\DiabloUI\\Sbar.cpp", 273, 0);
SMemFree(v4, "C:\\Src\\Diablo\\DiabloUI\\Sbar.cpp", 275, 0);
SetWindowLongA(v2, -21, 0);
}
}
}