annotate Mouse.cpp @ 1250:c515e406df4a

aWinProc cleanup - removing unused vars, unnesting conditions, removeing a few DefWindowProcA calls
author Grumpy7
date Mon, 10 Jun 2013 04:16:49 +0200
parents 29a8defbad9e
children fac7751b2dc9
rev   line source
1165
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1104
diff changeset
1 #ifdef _MSC_VER
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1104
diff changeset
2 #define _CRT_SECURE_NO_WARNINGS
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1104
diff changeset
3 #endif
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1104
diff changeset
4
0
Ritor1
parents:
diff changeset
5 #include "OSAPI.h"
Ritor1
parents:
diff changeset
6
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 973
diff changeset
7 #include "VideoPlayer.h"
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 973
diff changeset
8 #include "Vis.h"
0
Ritor1
parents:
diff changeset
9 #include "Mouse.h"
Ritor1
parents:
diff changeset
10 #include "Items.h"
Ritor1
parents:
diff changeset
11 #include "Party.h"
Ritor1
parents:
diff changeset
12 #include "LOD.h"
Ritor1
parents:
diff changeset
13 #include "Game.h"
Ritor1
parents:
diff changeset
14
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 973
diff changeset
15 #include "stru11.h"
0
Ritor1
parents:
diff changeset
16
Ritor1
parents:
diff changeset
17
Ritor1
parents:
diff changeset
18
Ritor1
parents:
diff changeset
19
Ritor1
parents:
diff changeset
20
Ritor1
parents:
diff changeset
21 Mouse *pMouse;
Ritor1
parents:
diff changeset
22
Ritor1
parents:
diff changeset
23
Ritor1
parents:
diff changeset
24
Ritor1
parents:
diff changeset
25
Ritor1
parents:
diff changeset
26
Ritor1
parents:
diff changeset
27 //----- (00469860) --------------------------------------------------------
Ritor1
parents:
diff changeset
28 void Mouse::GetClickPos(unsigned int *pX, unsigned int *pY)
Ritor1
parents:
diff changeset
29 {
1038
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
30 *pX = uMouseClickX;
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
31 *pY = uMouseClickY;
0
Ritor1
parents:
diff changeset
32 }
Ritor1
parents:
diff changeset
33
Ritor1
parents:
diff changeset
34 //----- (004698A6) --------------------------------------------------------
Ritor1
parents:
diff changeset
35 void Mouse::RemoveHoldingItem()
Ritor1
parents:
diff changeset
36 {
Ritor1
parents:
diff changeset
37 pParty->pPickedItem.Reset();
1165
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1104
diff changeset
38 if (_stricmp(pCurrentCursorName, "MICON2"))
0
Ritor1
parents:
diff changeset
39 SetCursorBitmap("MICON1");
Ritor1
parents:
diff changeset
40 }
Ritor1
parents:
diff changeset
41
Ritor1
parents:
diff changeset
42 //----- (004698D8) --------------------------------------------------------
Ritor1
parents:
diff changeset
43 void Mouse::SetCursorBitmapFromItemID(unsigned int uItemID)
Ritor1
parents:
diff changeset
44 {
Ritor1
parents:
diff changeset
45 pMouse->SetCursorBitmap(pItemsTable->pItems[uItemID].pIconName);
Ritor1
parents:
diff changeset
46 }
Ritor1
parents:
diff changeset
47
Ritor1
parents:
diff changeset
48 //----- (004698F6) --------------------------------------------------------
Ritor1
parents:
diff changeset
49 void Mouse::SetCurrentCursorBitmap()
Ritor1
parents:
diff changeset
50 {
Ritor1
parents:
diff changeset
51 SetCursorBitmap(pCurrentCursorName);
Ritor1
parents:
diff changeset
52 }
Ritor1
parents:
diff changeset
53
Ritor1
parents:
diff changeset
54 //----- (00469903) --------------------------------------------------------
Ritor1
parents:
diff changeset
55 void Mouse::SetCursorBitmap(const char *pName)
Ritor1
parents:
diff changeset
56 {
Ritor1
parents:
diff changeset
57 Mouse *v2; // esi@1
Ritor1
parents:
diff changeset
58 HCURSOR v3; // eax@10
1038
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
59 //int v4; // ecx@10
0
Ritor1
parents:
diff changeset
60 double v5; // st7@11
Ritor1
parents:
diff changeset
61 float v6; // ST04_4@12
Ritor1
parents:
diff changeset
62 LONG v7; // eax@14
Ritor1
parents:
diff changeset
63 LONG v8; // eax@17
Ritor1
parents:
diff changeset
64 unsigned int v9; // eax@21
Ritor1
parents:
diff changeset
65 float v10; // [sp+4h] [bp-18h]@11
Ritor1
parents:
diff changeset
66 struct tagPOINT Point; // [sp+14h] [bp-8h]@20
Ritor1
parents:
diff changeset
67
Ritor1
parents:
diff changeset
68 v2 = this;
Ritor1
parents:
diff changeset
69 if ( !this->bInitialized || !pName )
Ritor1
parents:
diff changeset
70 return;
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1068
diff changeset
71 if ( _stricmp("MICON2", pName) )
0
Ritor1
parents:
diff changeset
72 pGame->uFlags2 &= 0xFFFFFFEFu;
Ritor1
parents:
diff changeset
73 else
Ritor1
parents:
diff changeset
74 pGame->uFlags2 |= 0x10u;
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1068
diff changeset
75 if ( _stricmp(v2->pCurrentCursorName, pName) )
0
Ritor1
parents:
diff changeset
76 strcpy(v2->pCurrentCursorName, pName);
Ritor1
parents:
diff changeset
77 ClearCursor();
Ritor1
parents:
diff changeset
78 if ( _strnicmp(pName, "MICON1", 5u) )
Ritor1
parents:
diff changeset
79 {
Ritor1
parents:
diff changeset
80 v9 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE);
Ritor1
parents:
diff changeset
81 v2->uCursorTextureID = v9;
Ritor1
parents:
diff changeset
82 v2->uCursorTextureID_2 = v9;
Ritor1
parents:
diff changeset
83 v2->AllocCursorSystemMem();
Ritor1
parents:
diff changeset
84 v2->field_C = 0;
791
346f7069676a Indoor::GetSector and various stuff
Nomad
parents: 779
diff changeset
85 v2->bRedraw = 1;
0
Ritor1
parents:
diff changeset
86 v2->bActive = 1;
Ritor1
parents:
diff changeset
87 if ( !areWeLoadingTexture )
Ritor1
parents:
diff changeset
88 {
Ritor1
parents:
diff changeset
89 if (uCursorTextureID != -1)
Ritor1
parents:
diff changeset
90 pIcons_LOD->pTextures[uCursorTextureID].Release();
1006
e865f349aa41 ui cleanup
Gloval
parents: 973
diff changeset
91 pIcons_LOD->SyncLoadedFilesCount();
0
Ritor1
parents:
diff changeset
92 }
Ritor1
parents:
diff changeset
93 return;
Ritor1
parents:
diff changeset
94 }
Ritor1
parents:
diff changeset
95 v2->bActive = 0;
Ritor1
parents:
diff changeset
96 v2->field_C = 1;
Ritor1
parents:
diff changeset
97 if ( !strcmp(pName, "MICON1") )
Ritor1
parents:
diff changeset
98 {
Ritor1
parents:
diff changeset
99 v3 = LoadCursorA(GetModuleHandleW(nullptr), "Arrow");
Ritor1
parents:
diff changeset
100 SetClassLongA(hWnd, GCL_HCURSOR, (LONG)v3);
Ritor1
parents:
diff changeset
101 }
1068
6cbf4eb0f953 Mouse jumps fixed
zipi
parents: 1038
diff changeset
102 else if ( !strcmp(pName, "MICON2") )
0
Ritor1
parents:
diff changeset
103 {
Ritor1
parents:
diff changeset
104 v7 = (LONG)LoadCursorA(GetModuleHandleW(nullptr), "Target");
Ritor1
parents:
diff changeset
105 SetClassLongA(hWnd, -12, v7);
Ritor1
parents:
diff changeset
106 }
1068
6cbf4eb0f953 Mouse jumps fixed
zipi
parents: 1038
diff changeset
107 else if ( !strcmp(pName, "MICON3") )
0
Ritor1
parents:
diff changeset
108 {
Ritor1
parents:
diff changeset
109 v8 = (LONG)LoadCursorA(0, (LPCSTR)IDC_WAIT);
Ritor1
parents:
diff changeset
110 SetClassLongA(hWnd, -12, v8);
Ritor1
parents:
diff changeset
111 }
779
2a3fd4d89ec2 Mouse::SetCursorBitmap clean, mouse jump fix
zipi
parents: 762
diff changeset
112 //LABEL_18:
1038
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
113
779
2a3fd4d89ec2 Mouse::SetCursorBitmap clean, mouse jump fix
zipi
parents: 762
diff changeset
114 GetCursorPos(&Point);
1068
6cbf4eb0f953 Mouse jumps fixed
zipi
parents: 1038
diff changeset
115 ClientToScreen(hWnd,&Point);
779
2a3fd4d89ec2 Mouse::SetCursorBitmap clean, mouse jump fix
zipi
parents: 762
diff changeset
116 SetCursorPos(Point.x, Point.y);
0
Ritor1
parents:
diff changeset
117 }
Ritor1
parents:
diff changeset
118 // 506128: using guessed type int areWeLoadingTexture;
Ritor1
parents:
diff changeset
119
Ritor1
parents:
diff changeset
120 //----- (00469AE4) --------------------------------------------------------
Ritor1
parents:
diff changeset
121 LONG Mouse::_469AE4()
Ritor1
parents:
diff changeset
122 {
Ritor1
parents:
diff changeset
123 Mouse *v1; // esi@1
Ritor1
parents:
diff changeset
124 LONG v2; // ecx@2
Ritor1
parents:
diff changeset
125 LONG result; // eax@2
Ritor1
parents:
diff changeset
126 struct tagPOINT Point; // [sp+Ch] [bp-8h]@2
Ritor1
parents:
diff changeset
127
Ritor1
parents:
diff changeset
128 v1 = this;
Ritor1
parents:
diff changeset
129 this->field_8 = 1;
1038
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
130 /*if (pAsyncMouse)
0
Ritor1
parents:
diff changeset
131 {
Ritor1
parents:
diff changeset
132 v2 = *((int *)pAsyncMouse + 6);
Ritor1
parents:
diff changeset
133 Point.x = *((int *)pAsyncMouse + 6);
Ritor1
parents:
diff changeset
134 result = *((int *)pAsyncMouse + 7);
Ritor1
parents:
diff changeset
135 }
Ritor1
parents:
diff changeset
136 else
1038
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
137 {*/
0
Ritor1
parents:
diff changeset
138 GetCursorPos(&Point);
Ritor1
parents:
diff changeset
139 if ( pRenderer->bWindowMode )
Ritor1
parents:
diff changeset
140 ScreenToClient(hWnd, &Point);
Ritor1
parents:
diff changeset
141 result = Point.y;
Ritor1
parents:
diff changeset
142 v2 = Point.x;
1038
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
143 //}
0
Ritor1
parents:
diff changeset
144 v1->uMouseClickX = v2;
Ritor1
parents:
diff changeset
145 v1->uMouseClickY = result;
Ritor1
parents:
diff changeset
146 if ( pRenderer->bWindowMode )
Ritor1
parents:
diff changeset
147 goto LABEL_16;
1038
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
148 //if (pAsyncMouse)
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
149 // goto LABEL_24;
0
Ritor1
parents:
diff changeset
150 if ( v2 < 0 )
Ritor1
parents:
diff changeset
151 v2 = 0;
Ritor1
parents:
diff changeset
152 if ( result < 0 )
Ritor1
parents:
diff changeset
153 result = 0;
Ritor1
parents:
diff changeset
154 if ( v2 > 639 )
Ritor1
parents:
diff changeset
155 v2 = 639;
Ritor1
parents:
diff changeset
156 if ( result > 479 )
Ritor1
parents:
diff changeset
157 {
Ritor1
parents:
diff changeset
158 result = 479;
Ritor1
parents:
diff changeset
159 LABEL_16:
1038
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
160 //if (pAsyncMouse)
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
161 // goto LABEL_24;
0
Ritor1
parents:
diff changeset
162 if ( pRenderer->bWindowMode && (v2 < 0 || result < 0 || v2 > 639 || result > 479) )
Ritor1
parents:
diff changeset
163 goto LABEL_23;
Ritor1
parents:
diff changeset
164 }
Ritor1
parents:
diff changeset
165 if ( v1->field_C )
Ritor1
parents:
diff changeset
166 LABEL_23:
Ritor1
parents:
diff changeset
167 v1->bActive = 0;
Ritor1
parents:
diff changeset
168 LABEL_24:
Ritor1
parents:
diff changeset
169 v1->field_8 = 0;
Ritor1
parents:
diff changeset
170 return result;
Ritor1
parents:
diff changeset
171 }
Ritor1
parents:
diff changeset
172
Ritor1
parents:
diff changeset
173 //----- (00469BA3) --------------------------------------------------------
Ritor1
parents:
diff changeset
174 void Mouse::ClearCursor()
Ritor1
parents:
diff changeset
175 {
Ritor1
parents:
diff changeset
176 Mouse *v1; // esi@1
Ritor1
parents:
diff changeset
177 void *v2; // eax@1
Ritor1
parents:
diff changeset
178 void **v3; // esi@5
Ritor1
parents:
diff changeset
179
Ritor1
parents:
diff changeset
180 v1 = this;
Ritor1
parents:
diff changeset
181 v2 = this->pCursorBitmap_sysmem;
Ritor1
parents:
diff changeset
182 this->bActive = 0;
Ritor1
parents:
diff changeset
183 if ( v2 )
Ritor1
parents:
diff changeset
184 {
Ritor1
parents:
diff changeset
185 free(v2);
Ritor1
parents:
diff changeset
186 v1->pCursorBitmap_sysmem = 0;
Ritor1
parents:
diff changeset
187 }
Ritor1
parents:
diff changeset
188 if ( v1->pCursorBitmap2_sysmem )
Ritor1
parents:
diff changeset
189 {
Ritor1
parents:
diff changeset
190 free(v1->pCursorBitmap2_sysmem);
Ritor1
parents:
diff changeset
191 v1->pCursorBitmap2_sysmem = 0;
Ritor1
parents:
diff changeset
192 }
Ritor1
parents:
diff changeset
193 v3 = &v1->ptr_90;
Ritor1
parents:
diff changeset
194 if ( *v3 )
Ritor1
parents:
diff changeset
195 free(*v3);
Ritor1
parents:
diff changeset
196 *v3 = 0;
Ritor1
parents:
diff changeset
197 }
Ritor1
parents:
diff changeset
198
Ritor1
parents:
diff changeset
199 //----- (00469BE6) --------------------------------------------------------
Ritor1
parents:
diff changeset
200 void Mouse::AllocCursorSystemMem()
Ritor1
parents:
diff changeset
201 {
Ritor1
parents:
diff changeset
202 bActive = 0;
Ritor1
parents:
diff changeset
203 if (!pCursorBitmap_sysmem)
Ritor1
parents:
diff changeset
204 pCursorBitmap_sysmem = (unsigned __int16 *)DoAllocCursorMem();
Ritor1
parents:
diff changeset
205 if (!pCursorBitmap2_sysmem)
Ritor1
parents:
diff changeset
206 pCursorBitmap2_sysmem = (unsigned __int8 *)DoAllocCursorMem();
Ritor1
parents:
diff changeset
207 }
Ritor1
parents:
diff changeset
208
Ritor1
parents:
diff changeset
209 //----- (00469C0D) --------------------------------------------------------
Ritor1
parents:
diff changeset
210 void *Mouse::DoAllocCursorMem()
Ritor1
parents:
diff changeset
211 {
973
ec7568e13b24 Minor code cleaning.
Nomad
parents: 972
diff changeset
212 auto tex = pIcons_LOD->GetTexture(uCursorTextureID);
ec7568e13b24 Minor code cleaning.
Nomad
parents: 972
diff changeset
213 return malloc(4 * tex->uTextureWidth * tex->uTextureHeight);
0
Ritor1
parents:
diff changeset
214 }
Ritor1
parents:
diff changeset
215
Ritor1
parents:
diff changeset
216 //----- (00469C39) --------------------------------------------------------
Ritor1
parents:
diff changeset
217 POINT *Mouse::GetCursorPos(POINT *a2)
Ritor1
parents:
diff changeset
218 {
1038
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
219 a2->x = this->uMouseClickX;
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
220 a2->y = this->uMouseClickY;
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
221 return a2;
0
Ritor1
parents:
diff changeset
222 }
Ritor1
parents:
diff changeset
223
Ritor1
parents:
diff changeset
224 //----- (00469C65) --------------------------------------------------------
Ritor1
parents:
diff changeset
225 void Mouse::Initialize(HWND hWnd)
Ritor1
parents:
diff changeset
226 {
Ritor1
parents:
diff changeset
227 this->hWnd = hWnd;
Ritor1
parents:
diff changeset
228 this->bActive = 0;
Ritor1
parents:
diff changeset
229 this->bInitialized = 1;
Ritor1
parents:
diff changeset
230 this->pCursorBitmapPos.x = 0;
Ritor1
parents:
diff changeset
231 this->pCursorBitmapPos.y = 0;
Ritor1
parents:
diff changeset
232 this->uMouseClickX = 0;
Ritor1
parents:
diff changeset
233 this->uMouseClickY = 0;
Ritor1
parents:
diff changeset
234 this->pCursorBitmap_sysmem = 0;
Ritor1
parents:
diff changeset
235 this->field_34 = 0;
Ritor1
parents:
diff changeset
236 this->pCursorBitmap2_sysmem = 0;
Ritor1
parents:
diff changeset
237
Ritor1
parents:
diff changeset
238 SetCursorBitmap("MICON3");
Ritor1
parents:
diff changeset
239 SetCursorBitmap("MICON2");
Ritor1
parents:
diff changeset
240 SetCursorBitmap("MICON1");
Ritor1
parents:
diff changeset
241 }
Ritor1
parents:
diff changeset
242
762
cf2fbac6edc9 Misc cleaning
Nomad
parents: 710
diff changeset
243 // inlined
cf2fbac6edc9 Misc cleaning
Nomad
parents: 710
diff changeset
244 //----- (0045FE00) mm6 chinese --------------------------------------------
cf2fbac6edc9 Misc cleaning
Nomad
parents: 710
diff changeset
245 void Mouse::SetActive(bool active)
cf2fbac6edc9 Misc cleaning
Nomad
parents: 710
diff changeset
246 {
cf2fbac6edc9 Misc cleaning
Nomad
parents: 710
diff changeset
247 bActive = active;
cf2fbac6edc9 Misc cleaning
Nomad
parents: 710
diff changeset
248 }
cf2fbac6edc9 Misc cleaning
Nomad
parents: 710
diff changeset
249
0
Ritor1
parents:
diff changeset
250 //----- (00469CC2) --------------------------------------------------------
Ritor1
parents:
diff changeset
251 void Mouse::Deactivate()
Ritor1
parents:
diff changeset
252 {
Ritor1
parents:
diff changeset
253 if (bInitialized)
762
cf2fbac6edc9 Misc cleaning
Nomad
parents: 710
diff changeset
254 SetActive(false);
0
Ritor1
parents:
diff changeset
255 }
Ritor1
parents:
diff changeset
256
Ritor1
parents:
diff changeset
257 //----- (00469CCD) --------------------------------------------------------
Ritor1
parents:
diff changeset
258 void Mouse::DrawCursor()
Ritor1
parents:
diff changeset
259 {
Ritor1
parents:
diff changeset
260 Mouse *v1; // esi@1
Ritor1
parents:
diff changeset
261 char v11; // zf@6
Ritor1
parents:
diff changeset
262 signed int v3; // eax@6
Ritor1
parents:
diff changeset
263 signed int v4; // ecx@6
Ritor1
parents:
diff changeset
264 Vec4_int_ *v5; // edx@21
Ritor1
parents:
diff changeset
265 int v6; // edi@21
Ritor1
parents:
diff changeset
266 int v7; // ebx@21
Ritor1
parents:
diff changeset
267 int v8; // eax@29
Ritor1
parents:
diff changeset
268 unsigned int v9; // eax@31
Ritor1
parents:
diff changeset
269
Ritor1
parents:
diff changeset
270 v1 = this;
Ritor1
parents:
diff changeset
271 if ( this->bInitialized )
Ritor1
parents:
diff changeset
272 {
Ritor1
parents:
diff changeset
273 if ( !this->field_8 && this->bActive && !this->field_C )
Ritor1
parents:
diff changeset
274 pMouse->_469AE4();
Ritor1
parents:
diff changeset
275 v11 = v1->field_C == 0;
Ritor1
parents:
diff changeset
276 v3 = v1->uMouseClickX;
Ritor1
parents:
diff changeset
277 v4 = v1->uMouseClickY;
Ritor1
parents:
diff changeset
278 v1->field_F4 = 1;
Ritor1
parents:
diff changeset
279 if ( !v11 )
Ritor1
parents:
diff changeset
280 goto LABEL_12;
Ritor1
parents:
diff changeset
281 if ( pRenderer->bWindowMode )
Ritor1
parents:
diff changeset
282 {
Ritor1
parents:
diff changeset
283 if ( v3 < 0 || v4 < 0 || v3 > 639 || v4 > 479 )
Ritor1
parents:
diff changeset
284 {
Ritor1
parents:
diff changeset
285 LABEL_12:
Ritor1
parents:
diff changeset
286 v1->field_F4 = 0;
Ritor1
parents:
diff changeset
287 return;
Ritor1
parents:
diff changeset
288 }
Ritor1
parents:
diff changeset
289 }
Ritor1
parents:
diff changeset
290 else
Ritor1
parents:
diff changeset
291 {
Ritor1
parents:
diff changeset
292 if ( v3 < 0 )
Ritor1
parents:
diff changeset
293 v3 = 0;
Ritor1
parents:
diff changeset
294 if ( v4 < 0 )
Ritor1
parents:
diff changeset
295 v4 = 0;
Ritor1
parents:
diff changeset
296 if ( v3 > 639 )
Ritor1
parents:
diff changeset
297 v3 = 639;
Ritor1
parents:
diff changeset
298 if ( v4 > 479 )
Ritor1
parents:
diff changeset
299 v4 = 479;
Ritor1
parents:
diff changeset
300 }
Ritor1
parents:
diff changeset
301 v5 = &v1->pCursorBitmapRect;
Ritor1
parents:
diff changeset
302 v6 = v3 + v1->uCursorBitmapPitch;
Ritor1
parents:
diff changeset
303 v7 = v4 + v1->field_5C[0];
Ritor1
parents:
diff changeset
304 v1->pCursorBitmapRect.y = v4;
Ritor1
parents:
diff changeset
305 v1->pCursorBitmapRect.x = v3;
Ritor1
parents:
diff changeset
306 v1->pCursorBitmapRect.z = v6;
Ritor1
parents:
diff changeset
307 v1->pCursorBitmapRect.w = v7;
Ritor1
parents:
diff changeset
308 if ( v3 < 0 )
Ritor1
parents:
diff changeset
309 v5->x = 0;
Ritor1
parents:
diff changeset
310 if ( v4 < 0 )
Ritor1
parents:
diff changeset
311 v1->pCursorBitmapRect.y = 0;
Ritor1
parents:
diff changeset
312 if ( v6 > 640 )
Ritor1
parents:
diff changeset
313 v1->pCursorBitmapRect.z = 640;
Ritor1
parents:
diff changeset
314 if ( v7 > 480 )
Ritor1
parents:
diff changeset
315 v1->pCursorBitmapRect.w = 480;
Ritor1
parents:
diff changeset
316 v8 = v1->pCursorBitmapRect.z;
Ritor1
parents:
diff changeset
317 v1->bActive = 0;
Ritor1
parents:
diff changeset
318 v1->uCursorBitmapWidth = v8 - v5->x;
791
346f7069676a Indoor::GetSector and various stuff
Nomad
parents: 779
diff changeset
319 v11 = v1->bRedraw == 0;
0
Ritor1
parents:
diff changeset
320 v1->uCursorBitmapHeight = v1->pCursorBitmapRect.w - v1->pCursorBitmapRect.y;
Ritor1
parents:
diff changeset
321 if ( !v11 )
Ritor1
parents:
diff changeset
322 {
Ritor1
parents:
diff changeset
323 if ( pMouse->ptr_90 )
Ritor1
parents:
diff changeset
324 v9 = 2 * pMouse->uCursorBitmapPitch;
Ritor1
parents:
diff changeset
325 else
Ritor1
parents:
diff changeset
326 v9 = 0;
Ritor1
parents:
diff changeset
327 pRenderer->_4A6DF5(
Ritor1
parents:
diff changeset
328 v1->pCursorBitmap_sysmem,
Ritor1
parents:
diff changeset
329 v9,
Ritor1
parents:
diff changeset
330 &v1->pCursorBitmapPos,
Ritor1
parents:
diff changeset
331 pRenderer->pTargetSurface,
Ritor1
parents:
diff changeset
332 pRenderer->uTargetSurfacePitch,
Ritor1
parents:
diff changeset
333 &v1->pCursorBitmapRect);
791
346f7069676a Indoor::GetSector and various stuff
Nomad
parents: 779
diff changeset
334 v1->bRedraw = false;
0
Ritor1
parents:
diff changeset
335 }
Ritor1
parents:
diff changeset
336 }
Ritor1
parents:
diff changeset
337 }
Ritor1
parents:
diff changeset
338
Ritor1
parents:
diff changeset
339 //----- (00469E1C) --------------------------------------------------------
Ritor1
parents:
diff changeset
340 void Mouse::_469E1C()
Ritor1
parents:
diff changeset
341 {
Ritor1
parents:
diff changeset
342 bActive = true;
Ritor1
parents:
diff changeset
343 }
Ritor1
parents:
diff changeset
344
Ritor1
parents:
diff changeset
345 //----- (00469E24) --------------------------------------------------------
Ritor1
parents:
diff changeset
346 void Mouse::_469E24()
Ritor1
parents:
diff changeset
347 {
Ritor1
parents:
diff changeset
348 if (pCursorBitmap3_sysmembits_16bit)
Ritor1
parents:
diff changeset
349 {
Ritor1
parents:
diff changeset
350 free(pCursorBitmap3_sysmembits_16bit);
Ritor1
parents:
diff changeset
351 pCursorBitmap3_sysmembits_16bit = 0;
Ritor1
parents:
diff changeset
352 }
Ritor1
parents:
diff changeset
353 }
Ritor1
parents:
diff changeset
354
Ritor1
parents:
diff changeset
355 //----- (00469E3B) --------------------------------------------------------
Ritor1
parents:
diff changeset
356 void Mouse::DrawCursorToTarget()
Ritor1
parents:
diff changeset
357 {
Ritor1
parents:
diff changeset
358 if (!pCursorBitmap3_sysmembits_16bit)
Ritor1
parents:
diff changeset
359 return;
Ritor1
parents:
diff changeset
360
Ritor1
parents:
diff changeset
361 auto pSrc = pCursorBitmap3_sysmembits_16bit;
Ritor1
parents:
diff changeset
362 for (uint y = field_44; y < field_4C; ++y)
Ritor1
parents:
diff changeset
363 for (uint x = field_40; x < field_48; ++x)
Ritor1
parents:
diff changeset
364 pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++;
Ritor1
parents:
diff changeset
365 }
Ritor1
parents:
diff changeset
366
Ritor1
parents:
diff changeset
367 //----- (00469EA4) --------------------------------------------------------
Ritor1
parents:
diff changeset
368 void Mouse::_469EA4()
Ritor1
parents:
diff changeset
369 {
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
370 //Mouse *v1; // esi@1
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
371 unsigned int pTextureID; // eax@2
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
372 Texture *pTexture; // edi@2
0
Ritor1
parents:
diff changeset
373 unsigned int v4; // ecx@3
Ritor1
parents:
diff changeset
374 unsigned int v5; // eax@3
Ritor1
parents:
diff changeset
375 unsigned int v6; // ebx@5
Ritor1
parents:
diff changeset
376 int v7; // ecx@15
Ritor1
parents:
diff changeset
377 int v8; // ecx@25
Ritor1
parents:
diff changeset
378 int v9; // ebx@26
Ritor1
parents:
diff changeset
379 unsigned int v10; // eax@26
Ritor1
parents:
diff changeset
380 int v11; // edx@27
Ritor1
parents:
diff changeset
381 unsigned __int16 *v12; // edx@29
Ritor1
parents:
diff changeset
382 unsigned __int16 *v13; // ebx@29
Ritor1
parents:
diff changeset
383 unsigned int a2; // [sp+Ch] [bp-1Ch]@5
Ritor1
parents:
diff changeset
384 unsigned int v15; // [sp+10h] [bp-18h]@5
Ritor1
parents:
diff changeset
385 unsigned int v16; // [sp+14h] [bp-14h]@25
Ritor1
parents:
diff changeset
386 unsigned __int16 *v17; // [sp+18h] [bp-10h]@25
Ritor1
parents:
diff changeset
387 int v18; // [sp+1Ch] [bp-Ch]@27
Ritor1
parents:
diff changeset
388 int v19; // [sp+20h] [bp-8h]@15
Ritor1
parents:
diff changeset
389 unsigned __int16 *v20; // [sp+20h] [bp-8h]@28
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
390 int pTextureWidth; // [sp+24h] [bp-4h]@12
0
Ritor1
parents:
diff changeset
391 unsigned __int16 *v22; // [sp+24h] [bp-4h]@25
Ritor1
parents:
diff changeset
392
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
393 //v1 = this;
0
Ritor1
parents:
diff changeset
394 if ( pParty->pPickedItem.uItemID )
Ritor1
parents:
diff changeset
395 {
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
396 pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE);
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
397 pTexture = (Texture *)(pTextureID != -1 ? (int)&pIcons_LOD->pTextures[pTextureID] : 0);
1038
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
398
0
Ritor1
parents:
diff changeset
399 v4 = pMouse->uMouseClickX;
Ritor1
parents:
diff changeset
400 v5 = pMouse->uMouseClickY;
1038
39f42990698f Cleanings
Nomad
parents: 1018
diff changeset
401
0
Ritor1
parents:
diff changeset
402 v6 = v5;
Ritor1
parents:
diff changeset
403 a2 = v4;
Ritor1
parents:
diff changeset
404 v15 = v5;
Ritor1
parents:
diff changeset
405 if ( (signed int)v4 <= 639 && (signed int)v5 <= 479 )
Ritor1
parents:
diff changeset
406 {
Ritor1
parents:
diff changeset
407 if ( (v4 & 0x80000000u) != 0 )
Ritor1
parents:
diff changeset
408 a2 = 0;
Ritor1
parents:
diff changeset
409 if ( (v5 & 0x80000000u) != 0 )
Ritor1
parents:
diff changeset
410 {
Ritor1
parents:
diff changeset
411 v6 = 0;
Ritor1
parents:
diff changeset
412 v15 = 0;
Ritor1
parents:
diff changeset
413 }
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
414 if ( (signed int)(pTexture->uTextureWidth + a2) <= 640 )
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
415 pTextureWidth = pTexture->uTextureWidth;
0
Ritor1
parents:
diff changeset
416 else
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
417 pTextureWidth = 640 - a2;
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
418 if ( (signed int)(pTexture->uTextureHeight + v6) <= 480 )
0
Ritor1
parents:
diff changeset
419 {
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
420 v19 = pTexture->uTextureHeight;
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
421 v7 = pTexture->uTextureHeight;
0
Ritor1
parents:
diff changeset
422 }
Ritor1
parents:
diff changeset
423 else
Ritor1
parents:
diff changeset
424 {
Ritor1
parents:
diff changeset
425 v7 = 480 - v6;
Ritor1
parents:
diff changeset
426 v19 = 480 - v6;
Ritor1
parents:
diff changeset
427 }
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
428 if ( !this->pCursorBitmap3_sysmembits_16bit
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
429 || a2 != this->field_40
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
430 || v6 != this->field_44
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
431 || a2 + pTextureWidth != this->field_48
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
432 || v6 + v7 != this->field_4C )
0
Ritor1
parents:
diff changeset
433 {
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
434 if ( this->pCursorBitmap3_sysmembits_16bit )
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
435 free(this->pCursorBitmap3_sysmembits_16bit);
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
436 this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)operator new(2 * pTexture->uTextureHeight * pTexture->uTextureWidth);
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
437 this->field_40 = a2;
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
438 this->field_48 = a2 + pTextureWidth;
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
439 this->field_44 = v6;
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
440 this->field_4C = v6 + v19;
0
Ritor1
parents:
diff changeset
441 }
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
442 v8 = this->field_44;
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
443 v22 = this->pCursorBitmap3_sysmembits_16bit;
0
Ritor1
parents:
diff changeset
444 v17 = pRenderer->pTargetSurface;
Ritor1
parents:
diff changeset
445 v16 = pRenderer->uTargetSurfacePitch;
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
446 if ( v8 < this->field_4C )
0
Ritor1
parents:
diff changeset
447 {
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
448 v9 = this->field_48;
0
Ritor1
parents:
diff changeset
449 v10 = pRenderer->uTargetSurfacePitch * v8;
Ritor1
parents:
diff changeset
450 do
Ritor1
parents:
diff changeset
451 {
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
452 v11 = this->field_40;
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
453 v18 = this->field_40;
0
Ritor1
parents:
diff changeset
454 if ( v11 < v9 )
Ritor1
parents:
diff changeset
455 {
Ritor1
parents:
diff changeset
456 v20 = &v17[v10 + v11];
Ritor1
parents:
diff changeset
457 do
Ritor1
parents:
diff changeset
458 {
Ritor1
parents:
diff changeset
459 v12 = v20;
Ritor1
parents:
diff changeset
460 v13 = v22;
Ritor1
parents:
diff changeset
461 ++v18;
Ritor1
parents:
diff changeset
462 ++v20;
Ritor1
parents:
diff changeset
463 ++v22;
Ritor1
parents:
diff changeset
464 *v13 = *v12;
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
465 v9 = this->field_48;
0
Ritor1
parents:
diff changeset
466 }
Ritor1
parents:
diff changeset
467 while ( v18 < v9 );
Ritor1
parents:
diff changeset
468 }
Ritor1
parents:
diff changeset
469 v10 += v16;
Ritor1
parents:
diff changeset
470 ++v8;
Ritor1
parents:
diff changeset
471 }
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
472 while ( v8 < this->field_4C );
0
Ritor1
parents:
diff changeset
473 v6 = v15;
Ritor1
parents:
diff changeset
474 }
315
2a09e1d6fc8f Some 0041D895 GameUI_DrawItemInfo overhaul
Nomad
parents: 194
diff changeset
475 if (pParty->pPickedItem.Broken())
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
476 pRenderer->DrawTransparentRedShade(a2, v6, pTexture);
315
2a09e1d6fc8f Some 0041D895 GameUI_DrawItemInfo overhaul
Nomad
parents: 194
diff changeset
477 else if (!pParty->pPickedItem.Identified())
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
478 pRenderer->DrawTransparentGreenShade(a2, v6, pTexture);
0
Ritor1
parents:
diff changeset
479 else
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
480 pRenderer->DrawTextureTransparent(a2, v6, pTexture);
0
Ritor1
parents:
diff changeset
481 }
Ritor1
parents:
diff changeset
482 }
Ritor1
parents:
diff changeset
483 else
Ritor1
parents:
diff changeset
484 {
Ritor1
parents:
diff changeset
485 if ( this->pCursorBitmap3_sysmembits_16bit )
Ritor1
parents:
diff changeset
486 {
Ritor1
parents:
diff changeset
487 free(this->pCursorBitmap3_sysmembits_16bit);
920
34ed2d5e7cfb MagicShopDialog clean and other
Ritor1
parents: 791
diff changeset
488 this->pCursorBitmap3_sysmembits_16bit = 0;
0
Ritor1
parents:
diff changeset
489 }
Ritor1
parents:
diff changeset
490 }
Ritor1
parents:
diff changeset
491 }
Ritor1
parents:
diff changeset
492
Ritor1
parents:
diff changeset
493 //----- (0046A080) --------------------------------------------------------
Ritor1
parents:
diff changeset
494 void Mouse::Activate(int bActive)
Ritor1
parents:
diff changeset
495 {
Ritor1
parents:
diff changeset
496 bActive = bActive;
Ritor1
parents:
diff changeset
497 }
Ritor1
parents:
diff changeset
498
Ritor1
parents:
diff changeset
499 //----- (0046A08A) --------------------------------------------------------
Ritor1
parents:
diff changeset
500 void Mouse::SetMouseClick(int x, int y)
Ritor1
parents:
diff changeset
501 {
Ritor1
parents:
diff changeset
502 uMouseClickX = x;
Ritor1
parents:
diff changeset
503 uMouseClickY = y;
Ritor1
parents:
diff changeset
504 }
Ritor1
parents:
diff changeset
505