annotate Mouse.cpp @ 1068:6cbf4eb0f953

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