Mercurial > mm7
annotate IO/Mouse.cpp @ 2544:c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
author | a.parshin |
---|---|
date | Mon, 11 May 2015 09:51:04 +0200 |
parents | a902abdfc7f2 |
children | 87e5590d034b |
rev | line source |
---|---|
2502 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
5 #define _CRT_SECURE_NO_WARNINGS | |
6 | |
2541 | 7 #include "Engine/Engine.h" |
8 | |
2502 | 9 #include "Mouse.h" |
10 #include "Engine/Party.h" | |
11 #include "Engine/LOD.h" | |
12 | |
13 #include "Engine/TurnEngine/TurnEngine.h" | |
14 #include "Engine/Graphics/Viewport.h" | |
15 #include "GUI/GUIWindow.h" | |
16 #include "Engine/Graphics/Vis.h" | |
17 #include "Engine/Objects/Actor.h" | |
18 #include "Media/Audio/AudioPlayer.h" | |
19 | |
20 | |
21 Mouse *pMouse; | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 //----- (00469860) -------------------------------------------------------- | |
28 void Mouse::GetClickPos(unsigned int *pX, unsigned int *pY) | |
29 { | |
30 *pX = uMouseClickX; | |
31 *pY = uMouseClickY; | |
32 } | |
33 | |
34 //----- (004698A6) -------------------------------------------------------- | |
35 void Mouse::RemoveHoldingItem() | |
36 { | |
37 pParty->pPickedItem.Reset(); | |
38 if (_stricmp(pCurrentCursorName, "MICON2")) | |
39 SetCursorBitmap("MICON1"); | |
40 } | |
41 | |
42 //----- (004698D8) -------------------------------------------------------- | |
43 void Mouse::SetCursorBitmapFromItemID(unsigned int uItemID) | |
44 { | |
45 pMouse->SetCursorBitmap(pItemsTable->pItems[uItemID].pIconName); | |
46 } | |
47 | |
48 //----- (004698F6) -------------------------------------------------------- | |
49 void Mouse::SetCurrentCursorBitmap() | |
50 { | |
51 SetCursorBitmap(pCurrentCursorName); | |
52 } | |
53 | |
54 //----- (00469903) -------------------------------------------------------- | |
55 void Mouse::SetCursorBitmap(const char *pName) | |
56 { | |
57 // DDSURFACEDESC2 Dst; | |
58 | |
59 if ( !this->bInitialized || !pName ) | |
60 return; | |
61 if ( _stricmp("MICON2", pName) )//если кусор не мишень | |
2541 | 62 pEngine->uFlags2 &= 0xFFFFFFEF; |
2502 | 63 else |
2541 | 64 pEngine->uFlags2 |= 0x10; |
2502 | 65 if ( _stricmp(this->pCurrentCursorName, pName) ) |
66 strcpy(this->pCurrentCursorName, pName); | |
67 ClearCursor(); | |
68 if ( _strnicmp(pName, "MICON1", 5) )//for click to item / если курсор с вещью | |
69 { | |
70 this->uCursorTextureID = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); | |
71 this->uCursorTextureID_2 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); | |
72 this->AllocCursorSystemMem(); | |
73 this->field_C = 0; | |
74 this->bRedraw = true; | |
75 this->bActive = true; | |
76 if ( !areWeLoadingTexture ) | |
77 { | |
78 if (uCursorTextureID != -1) | |
79 pIcons_LOD->pTextures[uCursorTextureID].Release(); | |
80 pIcons_LOD->SyncLoadedFilesCount(); | |
81 } | |
82 return; | |
83 } | |
84 this->bActive = false; | |
85 this->field_C = 1; | |
86 window->SetCursor(pName); | |
87 } | |
88 // 506128: using guessed type int areWeLoadingTexture; | |
89 | |
90 //----- (00469AE4) -------------------------------------------------------- | |
91 LONG Mouse::_469AE4() | |
92 { | |
93 LONG v2; // ecx@2 | |
94 LONG result; // eax@2 | |
95 struct tagPOINT Point; // [sp+Ch] [bp-8h]@2 | |
96 | |
97 this->field_8 = 1; | |
98 /*if (pAsyncMouse) | |
99 { | |
100 v2 = *((int *)pAsyncMouse + 6); | |
101 Point.x = *((int *)pAsyncMouse + 6); | |
102 result = *((int *)pAsyncMouse + 7); | |
103 } | |
104 else | |
105 {*/ | |
106 GetCursorPos(&Point); | |
107 //if ( pRenderer->bWindowMode ) | |
108 ScreenToClient(window->GetApiHandle(), &Point); | |
109 result = Point.y; | |
110 v2 = Point.x; | |
111 //} | |
112 this->uMouseClickX = v2; | |
113 this->uMouseClickY = result; | |
114 | |
115 /* | |
116 //This block has been commented out, because of the changed condition above "if(true)" | |
117 //Also the next condition and the first line has been commented out as well | |
118 | |
119 // if (pRenderer->bWindowMode) | |
120 if ( true ) | |
121 goto LABEL_16; | |
122 //if (pAsyncMouse) | |
123 // goto LABEL_24; | |
124 | |
125 | |
126 if ( v2 < 0 ) | |
127 v2 = 0; | |
128 if ( result < 0 ) | |
129 result = 0; | |
130 if ( v2 > window->GetWidth() - 1 ) | |
131 v2 = window->GetWidth() - 1; | |
132 */ | |
133 | |
134 // if ( result > window->GetHeight() - 1 ) | |
135 // { | |
136 // result = window->GetHeight() - 1; | |
137 //LABEL_16: | |
138 //if (pAsyncMouse) | |
139 // goto LABEL_24; | |
140 if (true/*pRenderer->bWindowMode*/ && (v2 < 0 || result < 0 || v2 > window->GetWidth() - 1 || result > window->GetHeight() - 1)) | |
141 { | |
142 this->bActive = false; | |
143 //LABEL_24: | |
144 this->field_8 = 0; | |
145 return result; | |
146 } | |
147 //} | |
148 | |
149 if ( this->field_C ) | |
150 //LABEL_23: | |
151 this->bActive = false; | |
152 //LABEL_24: | |
153 this->field_8 = 0; | |
154 return result; | |
155 } | |
156 | |
157 //----- (00469BA3) -------------------------------------------------------- | |
158 void Mouse::ClearCursor() | |
159 { | |
160 this->bActive = false; | |
161 free(this->pCursorBitmap_sysmem); | |
162 this->pCursorBitmap_sysmem = nullptr; | |
163 free(this->pCursorBitmap2_sysmem); | |
164 this->pCursorBitmap2_sysmem = nullptr; | |
165 free(this->ptr_90); | |
166 this->ptr_90 = nullptr; | |
167 } | |
168 | |
169 //----- (00469BE6) -------------------------------------------------------- | |
170 void Mouse::AllocCursorSystemMem() | |
171 { | |
172 bActive = false; | |
173 if (!pCursorBitmap_sysmem) | |
174 pCursorBitmap_sysmem = (unsigned __int16 *)DoAllocCursorMem(); | |
175 if (!pCursorBitmap2_sysmem) | |
176 pCursorBitmap2_sysmem = (unsigned __int8 *)DoAllocCursorMem(); | |
177 } | |
178 | |
179 //----- (00469C0D) -------------------------------------------------------- | |
180 void *Mouse::DoAllocCursorMem() | |
181 { | |
182 Texture* tex = pIcons_LOD->GetTexture(uCursorTextureID); | |
183 return malloc(4 * tex->uTextureWidth * tex->uTextureHeight); | |
184 } | |
185 | |
186 //----- (00469C39) -------------------------------------------------------- | |
187 POINT *Mouse::GetCursorPos(POINT *a2) | |
188 { | |
189 a2->x = this->uMouseClickX; | |
190 a2->y = this->uMouseClickY; | |
191 return a2; | |
192 } | |
193 | |
194 //----- (00469C65) -------------------------------------------------------- | |
195 void Mouse::Initialize(OSWindow *window) | |
196 { | |
197 this->window = window; | |
198 this->bActive = false; | |
199 this->bInitialized = true; | |
200 | |
201 //this->field_8 = 0;//Ritor1: result incorrect uMouseClickX, this->uMouseClickY in _469AE4() | |
202 this->uCursorBitmapPitch = 0;//Ritor1: it's include | |
203 for ( uint i = 0; i < 13; i++ ) | |
204 this->field_5C[i] = 0; | |
205 | |
206 this->pCursorBitmapPos.x = 0; | |
207 this->pCursorBitmapPos.y = 0; | |
208 this->uMouseClickX = 0; | |
209 this->uMouseClickY = 0; | |
210 this->pCursorBitmap_sysmem = nullptr; | |
211 this->field_34 = 0; | |
212 this->pCursorBitmap2_sysmem = nullptr; | |
213 | |
214 SetCursorBitmap("MICON3"); | |
215 SetCursorBitmap("MICON2"); | |
216 SetCursorBitmap("MICON1"); | |
217 } | |
218 | |
219 // inlined | |
220 //----- (0045FE00) mm6 chinese -------------------------------------------- | |
221 void Mouse::SetActive(bool active) | |
222 { | |
223 bActive = active; | |
224 } | |
225 | |
226 //----- (00469CC2) -------------------------------------------------------- | |
227 void Mouse::Deactivate() | |
228 { | |
229 if (bInitialized) | |
230 SetActive(false); | |
231 } | |
232 | |
233 //----- (00469CCD) -------------------------------------------------------- | |
234 void Mouse::DrawCursor() | |
235 { | |
236 unsigned int v9; // eax@31 | |
237 | |
238 if ( this->bInitialized ) | |
239 { | |
240 if ( !this->field_8 && this->bActive && !this->field_C ) //Uninitialized memory access(this->field_8) | |
241 pMouse->_469AE4();//Ritor1: странная, непонятная функция | |
242 this->field_F4 = 1; | |
243 if ( this->field_C ) | |
244 { | |
245 this->field_F4 = 0; | |
246 return; | |
247 } | |
248 | |
249 //if ( pRenderer->bWindowMode ) | |
250 { | |
251 if ( this->uMouseClickX < 0 || this->uMouseClickY < 0 || this->uMouseClickX > window->GetWidth() - 1 || this->uMouseClickY > window->GetHeight() - 1 ) | |
252 { | |
253 this->field_F4 = 0; | |
254 return; | |
255 } | |
256 } | |
257 /*else | |
258 { | |
259 if ( this->uMouseClickX < 0 ) | |
260 this->uMouseClickX = 0; | |
261 if ( this->uMouseClickY < 0 ) | |
262 this->uMouseClickY = 0; | |
263 if ( this->uMouseClickX > 639 ) | |
264 this->uMouseClickX = 639; | |
265 if ( this->uMouseClickY > 479 ) | |
266 this->uMouseClickY = 479; | |
267 }*/ | |
268 this->pCursorBitmapRect.x = this->uMouseClickX; | |
269 this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0]; //Ritor1: Maybe this->field_5C[0] - cursor width | |
270 this->pCursorBitmapRect.y = this->uMouseClickY; | |
271 this->pCursorBitmapRect.z = this->uMouseClickX + this->uCursorBitmapPitch; //Ritor1: Maybe this->uCursorBitmapPitch - cursor height | |
272 if ( this->uMouseClickX < 0 ) | |
273 this->pCursorBitmapRect.x = 0; | |
274 if ( this->uMouseClickY < 0 ) | |
275 this->pCursorBitmapRect.y = 0; | |
276 if ( this->pCursorBitmapRect.z > window->GetWidth() ) | |
277 this->pCursorBitmapRect.z = window->GetWidth(); | |
278 if ( this->pCursorBitmapRect.w > window->GetHeight() ) | |
279 this->pCursorBitmapRect.w = window->GetHeight(); | |
280 this->bActive = false; | |
281 this->uCursorBitmapWidth = this->pCursorBitmapRect.z - this->pCursorBitmapRect.x; | |
282 this->uCursorBitmapHeight = this->pCursorBitmapRect.w - this->pCursorBitmapRect.y; | |
283 if ( this->bRedraw ) | |
284 { | |
285 if ( pMouse->ptr_90 ) | |
286 v9 = 2 * pMouse->uCursorBitmapPitch; | |
287 else | |
288 v9 = 0; | |
289 pRenderer->_4A6DF5( this->pCursorBitmap_sysmem, v9, &this->pCursorBitmapPos, pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, | |
290 &this->pCursorBitmapRect);//срабатывает когда берём курсором вещь в инвенторе | |
291 this->bRedraw = false; | |
292 } | |
293 } | |
294 } | |
295 | |
296 //----- (00469E1C) -------------------------------------------------------- | |
297 void Mouse::Activate() | |
298 { | |
299 bActive = true; | |
300 } | |
301 | |
302 //----- (00469E24) -------------------------------------------------------- | |
303 void Mouse::_469E24() | |
304 { | |
305 free(pCursorBitmap3_sysmembits_16bit); | |
306 pCursorBitmap3_sysmembits_16bit = nullptr; | |
307 } | |
308 | |
309 //----- (00469E3B) -------------------------------------------------------- | |
310 void Mouse::DrawCursorToTarget()//??? DrawCursorWithItem | |
311 { | |
312 if (!pCursorBitmap3_sysmembits_16bit) | |
313 return; | |
314 //пишем на экран курсор с вещью | |
315 ushort* pSrc = pCursorBitmap3_sysmembits_16bit; | |
316 for (int y = uCursorWithItemY; y < uCursorWithItemZ; ++y) | |
317 for (int x = uCursorWithItemX; x < uCursorWithItemW; ++x) | |
318 //pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++; | |
319 pRenderer->WritePixel16(x, y, *pSrc++); | |
320 } | |
321 | |
322 //----- (00469EA4) -------------------------------------------------------- | |
323 void Mouse::ReadCursorWithItem() | |
324 { | |
325 unsigned int pTextureID; // eax@2 | |
326 Texture *pTexture; // edi@2 | |
327 // int v8; // ecx@25 | |
328 // int v9; // ebx@26 | |
329 // unsigned int v10; // eax@26 | |
330 // int v11; // edx@27 | |
331 int pTextureHeight; // [sp+20h] [bp-8h]@15 | |
332 // unsigned __int16 *v20; // [sp+20h] [bp-8h]@28 | |
333 int pTextureWidth; // [sp+24h] [bp-4h]@12 | |
334 unsigned __int16 *v22; // [sp+24h] [bp-4h]@25 | |
335 | |
336 if ( pParty->pPickedItem.uItemID ) | |
337 { | |
338 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); | |
339 pTexture = (Texture *)(pTextureID != -1 ? (int)&pIcons_LOD->pTextures[pTextureID] : 0); | |
340 | |
341 if ( (signed int)pMouse->uMouseClickX <= window->GetWidth() - 1 && (signed int)pMouse->uMouseClickY <= window->GetHeight() - 1 ) | |
342 { | |
343 /*if ( (v4 & 0x80000000u) != 0 ) | |
344 a2 = 0; | |
345 if ( (v5 & 0x80000000u) != 0 ) | |
346 { | |
347 //v6 = 0; | |
348 v15 = 0; | |
349 } */ | |
350 if ( (signed int)(pTexture->uTextureWidth + pMouse->uMouseClickX) <= window->GetWidth() ) | |
351 pTextureWidth = pTexture->uTextureWidth; | |
352 else | |
353 pTextureWidth = window->GetWidth() - pMouse->uMouseClickX; | |
354 if ( (signed int)(pTexture->uTextureHeight + pMouse->uMouseClickY) <= window->GetHeight() ) | |
355 pTextureHeight = pTexture->uTextureHeight; | |
356 else | |
357 pTextureHeight = window->GetHeight() - pMouse->uMouseClickY; | |
358 if ( !this->pCursorBitmap3_sysmembits_16bit | |
359 || pMouse->uMouseClickX != this->uCursorWithItemX | |
360 || pMouse->uMouseClickY != this->uCursorWithItemY | |
361 || pMouse->uMouseClickX + pTextureWidth != this->uCursorWithItemW | |
362 || pMouse->uMouseClickY + pTextureHeight != this->uCursorWithItemZ ) | |
363 { | |
364 free(this->pCursorBitmap3_sysmembits_16bit); | |
365 this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)malloc(2 * pTexture->uTextureHeight * pTexture->uTextureWidth); | |
366 this->uCursorWithItemX = pMouse->uMouseClickX; | |
367 this->uCursorWithItemW = pMouse->uMouseClickX + pTextureWidth; | |
368 this->uCursorWithItemY = pMouse->uMouseClickY; | |
369 this->uCursorWithItemZ = pMouse->uMouseClickY + pTextureHeight; | |
370 } | |
371 v22 = this->pCursorBitmap3_sysmembits_16bit; | |
372 | |
373 for (int y = this->uCursorWithItemY; y < this->uCursorWithItemZ; ++y) | |
374 { | |
375 for (int x = this->uCursorWithItemX; x < this->uCursorWithItemW; ++x) | |
376 { | |
377 *v22++ = pRenderer->ReadPixel16(x, y); | |
378 } | |
379 } | |
380 /*if ( v8 < this->field_4C ) | |
381 { | |
382 v9 = this->field_48; | |
383 v10 = pRenderer->uTargetSurfacePitch * v8; | |
384 do | |
385 { | |
386 v11 = this->field_40; | |
387 v18 = this->field_40; | |
388 if ( v11 < v9 ) | |
389 { | |
390 v20 = &v17[v10 + v11]; | |
391 do | |
392 { | |
393 //v12 = v20; | |
394 ++v18; | |
395 //++v20; | |
396 *v22++ = *v20++; | |
397 } | |
398 while ( v18 < v9 ); | |
399 } | |
400 v10 += v16; | |
401 ++v8; | |
402 } | |
403 while ( v8 < this->field_4C ); | |
404 v6 = v15; | |
405 }*/ | |
406 | |
407 if (pParty->pPickedItem.IsBroken()) | |
408 pRenderer->DrawTransparentRedShade(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture); | |
409 else if (!pParty->pPickedItem.IsIdentified()) | |
410 pRenderer->DrawTransparentGreenShade(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture); | |
411 else | |
2524 | 412 pRenderer->DrawTextureIndexedAlpha(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture); |
2502 | 413 } |
414 } | |
415 else | |
416 { | |
417 free(this->pCursorBitmap3_sysmembits_16bit); | |
418 this->pCursorBitmap3_sysmembits_16bit = nullptr; | |
419 } | |
420 } | |
421 | |
422 //----- (0046A080) -------------------------------------------------------- | |
423 void Mouse::ChangeActivation(int a1) | |
424 { | |
425 this->bActive = a1; | |
426 } | |
427 | |
428 //----- (0046A08A) -------------------------------------------------------- | |
429 void Mouse::SetMouseClick(int x, int y) | |
430 { | |
431 uMouseClickX = x; | |
432 uMouseClickY = y; | |
433 } | |
434 //----- (004175C0) -------------------------------------------------------- | |
435 void Mouse::UI_OnMouseLeftClick(int *pXY) | |
436 { | |
437 signed int y; // eax@7 | |
438 signed int x; // ecx@7 | |
439 signed int v5; // eax@17 | |
440 GUIButton *control; // esi@37 | |
441 signed int v10; // eax@50 | |
442 // int v11; // ecx@52 | |
443 unsigned int pX; // [sp+14h] [bp-8h]@7 | |
444 unsigned int pY; // [sp+18h] [bp-4h]@7 | |
445 | |
2541 | 446 if ( current_screen_type == SCREEN_VIDEO || sub_4637E0_is_there_popup_onscreen() ) |
2502 | 447 return; |
448 if ( pGUIWindow2 && pGUIWindow2->ptr_1C == (void *)33 ) | |
449 { | |
450 sub_4452BB(); | |
451 return; | |
452 } | |
453 if ( pXY ) | |
454 { | |
455 x = *pXY; | |
456 y = pXY[1]; | |
457 pX = *pXY; | |
458 pY = y; | |
459 } | |
460 else | |
461 { | |
462 pMouse->GetClickPos(&pX, &pY); | |
463 y = pY; | |
464 x = pX; | |
465 } | |
466 | |
467 extern bool _507B98_ctrl_pressed; | |
468 x = pX; | |
2541 | 469 if ( GetCurrentMenuID() != -1 || current_screen_type != SCREEN_GAME || !_507B98_ctrl_pressed // stealing cursor |
2502 | 470 || (signed int)pX < (signed int)pViewport->uViewportTL_X || (signed int)pX > (signed int)pViewport->uViewportBR_X |
471 || (signed int)pY < (signed int)pViewport->uViewportTL_Y || (signed int)pY > (signed int)pViewport->uViewportBR_Y) | |
472 { | |
473 y = pY; | |
474 for ( int i = uNumVisibleWindows; i >= 0; --i ) | |
475 { | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
476 if ( x >= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1]->uFrameX && x <= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1]->uFrameZ |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
477 && y >= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1]->uFrameY && y <= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1]->uFrameW ) |
2502 | 478 { |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
479 for ( control = pWindowList[pVisibleWindowsIdxs[i] - 1]->pControlsHead; control; control = control->pNext ) |
2502 | 480 { |
481 if ( control->uButtonType == 1 ) | |
482 { | |
483 if ( x >= (signed int)control->uX && x <= (signed int)control->uZ && y >= (signed int)control->uY && y <= (signed int)control->uW ) | |
484 { | |
485 control->field_2C_is_pushed = 1; | |
486 v10 = pMessageQueue_50CBD0->uNumMessages; | |
487 if ( pMessageQueue_50CBD0->uNumMessages ) | |
488 { | |
489 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
490 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
491 } | |
492 pMessageQueue_50CBD0->AddGUIMessage(control->msg, control->msg_param, 0); | |
493 return; | |
494 } | |
495 continue; | |
496 } | |
497 if ( control->uButtonType == 2 )//когда нажимаешь на партреты персов | |
498 { | |
499 if ( (signed int)(signed __int64)sqrt((double)((x - control->uX) * (x - control->uX) + (y - control->uY) * (y - control->uY))) < (signed int)control->uWidth ) | |
500 { | |
501 control->field_2C_is_pushed = 1; | |
502 v10 = pMessageQueue_50CBD0->uNumMessages; | |
503 if ( pMessageQueue_50CBD0->uNumMessages ) | |
504 { | |
505 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
506 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
507 } | |
508 pMessageQueue_50CBD0->AddGUIMessage(control->msg, control->msg_param, 0); | |
509 return; | |
510 } | |
511 continue; | |
512 } | |
513 if ( control->uButtonType == 3 )//когда нажимаешь на скиллы | |
514 { | |
515 if ( x >= (signed int)control->uX && x <= (signed int)control->uZ && y >= (signed int)control->uY && y <= (signed int)control->uW ) | |
516 { | |
517 control->field_2C_is_pushed = 1; | |
518 v10 = pMessageQueue_50CBD0->uNumMessages; | |
519 if ( pMessageQueue_50CBD0->uNumMessages ) | |
520 { | |
521 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
522 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
523 } | |
524 pMessageQueue_50CBD0->AddGUIMessage(control->msg, control->msg_param, 0); | |
525 return; | |
526 } | |
527 continue; | |
528 } | |
529 y = pY; | |
530 x = pX; | |
531 } | |
532 } | |
533 } | |
534 return; | |
535 } | |
536 y = pY; | |
537 //if ( pRenderer->pRenderD3D ) | |
2541 | 538 v5 = pEngine->pVisInstance->get_picked_object_zbuf_val(); |
2502 | 539 /*else |
540 v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];*/ | |
541 | |
542 uint type = PID_TYPE((unsigned __int16)v5); | |
543 if (type == OBJECT_Actor && uActiveCharacter && v5 < 0x2000000 | |
544 && pPlayers[uActiveCharacter]->CanAct() && pPlayers[uActiveCharacter]->CanSteal() ) | |
545 { | |
546 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
547 { | |
548 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_1B; | |
549 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6 >> 3; | |
550 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
551 ++pMessageQueue_50CBD0->uNumMessages; | |
552 }*/ | |
553 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_STEALFROMACTOR, PID_ID((unsigned __int16)v5), 0); | |
554 | |
555 if ( pParty->bTurnBasedModeOn == 1 ) | |
556 { | |
557 if ( pTurnEngine->turn_stage == TE_MOVEMENT ) | |
558 pTurnEngine->field_18 |= TE_FLAG_8; | |
559 } | |
560 } | |
561 } | |
562 | |
563 | |
564 //----- (0041CD4F) -------------------------------------------------------- | |
565 bool Mouse::UI_OnKeyDown(unsigned int vkKey) | |
566 { | |
567 //unsigned int v1; // edi@1 | |
568 //unsigned int v2; // eax@2 | |
569 int v3; // esi@3 | |
570 int v4; // ecx@10 | |
571 GUIButton *pButton; // eax@11 | |
572 int v6; // edx@12 | |
573 int v7; // ecx@20 | |
574 char v8; // zf@21 | |
575 //GUIButton *v9; // ecx@24 | |
576 int v10; // esi@24 | |
577 //int v11; // edx@26 | |
578 int v12; // edx@28 | |
579 int v13; // esi@32 | |
580 //GUIButton *v14; // eax@37 | |
581 int v15; // edx@38 | |
582 int v17; // ecx@50 | |
583 int v18; // edx@50 | |
584 //GUIButton *v19; // ecx@54 | |
585 int v20; // esi@54 | |
586 //int v21; // edx@56 | |
587 int v22; // ecx@59 | |
588 int v23; // edx@59 | |
589 int v24; // ecx@60 | |
590 int v25; // esi@63 | |
591 //unsigned int v26; // [sp+Ch] [bp-14h]@1 | |
592 //int v27; // [sp+10h] [bp-10h]@1 | |
593 int v28; // [sp+14h] [bp-Ch]@10 | |
594 int v29; // [sp+14h] [bp-Ch]@36 | |
595 unsigned int uClickX; // [sp+18h] [bp-8h]@10 | |
596 unsigned int uClickY; // [sp+1Ch] [bp-4h]@10 | |
597 | |
598 //v1 = 0; | |
599 //v27 = uNumVisibleWindows; | |
600 if ( uNumVisibleWindows < 0 ) | |
601 return false; | |
602 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
603 for (int i = uNumVisibleWindows; i >= 0; --i) | |
604 //while ( 1 ) | |
605 { | |
606 v3 = pVisibleWindowsIdxs[i] - 1; | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
607 if (!pWindowList[v3]->receives_keyboard_input) |
2502 | 608 continue; |
609 | |
610 switch (vkKey) | |
611 { | |
612 case VK_LEFT: | |
613 { | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
614 v12 = pWindowList[v3]->field_34; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
615 if ( pWindowList[v3]->pCurrentPosActiveItem - pWindowList[v3]->pStartingPosActiveItem - v12 >= 0 ) |
2502 | 616 { |
2541 | 617 v8 = current_screen_type == SCREEN_PARTY_CREATION; |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
618 pWindowList[v3]->pCurrentPosActiveItem -= v12; |
2502 | 619 if ( v8 ) |
620 { | |
2534 | 621 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); |
2502 | 622 //v2 = pMessageQueue_50CBD0->uNumMessages; |
623 } | |
624 } | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
625 if ( pWindowList[v3]->field_30 != 0 ) |
2502 | 626 { |
627 break; | |
628 } | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
629 pButton = pWindowList[v3]->pControlsHead; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
630 v13 = pWindowList[v3]->pCurrentPosActiveItem; |
2502 | 631 if ( v13 > 0) |
632 { | |
633 do | |
634 { | |
635 pButton = pButton->pNext; | |
636 --v13; | |
637 } | |
638 while ( v13 ); | |
639 } | |
640 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); | |
641 break; | |
642 } | |
643 case VK_RIGHT: | |
644 { | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
645 v7 = pWindowList[v3]->pCurrentPosActiveItem + pWindowList[v3]->field_34; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
646 if ( v7 < pWindowList[v3]->pNumPresenceButton + pWindowList[v3]->pStartingPosActiveItem ) |
2502 | 647 { |
2541 | 648 v8 = current_screen_type == SCREEN_PARTY_CREATION; |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
649 pWindowList[v3]->pCurrentPosActiveItem = v7; |
2502 | 650 if ( v8 ) |
651 { | |
2534 | 652 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); |
2502 | 653 //v2 = pMessageQueue_50CBD0->uNumMessages; |
654 } | |
655 } | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
656 if ( pWindowList[v3]->field_30 != 0 ) |
2502 | 657 { |
658 break; | |
659 } | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
660 pButton = pWindowList[v3]->pControlsHead; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
661 v10 = pWindowList[v3]->pCurrentPosActiveItem; |
2502 | 662 if ( v10 > 0) |
663 { | |
664 do | |
665 { | |
666 pButton = pButton->pNext; | |
667 --v10; | |
668 } | |
669 while ( v10 ); | |
670 } | |
671 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); | |
672 break; | |
673 } | |
674 case VK_DOWN: | |
675 { | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
676 v17 = pWindowList[v3]->pStartingPosActiveItem; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
677 v18 = pWindowList[v3]->pCurrentPosActiveItem; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
678 if ( v18 >= pWindowList[v3]->pNumPresenceButton + v17 - 1 ) |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
679 pWindowList[v3]->pCurrentPosActiveItem = v17; |
2502 | 680 else |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
681 pWindowList[v3]->pCurrentPosActiveItem = v18 + 1; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
682 if ( pWindowList[v3]->field_30 != 0 ) |
2502 | 683 return true; |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
684 pButton = pWindowList[v3]->pControlsHead; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
685 v20 = pWindowList[v3]->pCurrentPosActiveItem; |
2502 | 686 if ( v20 > 0) |
687 { | |
688 do | |
689 { | |
690 pButton = pButton->pNext; | |
691 --v20; | |
692 } | |
693 while ( v20 ); | |
694 } | |
695 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); | |
696 return true; | |
697 } | |
698 case VK_SELECT: | |
699 { | |
700 pMouse->GetClickPos(&uClickX, &uClickY); | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
701 v4 = pWindowList[v3]->pStartingPosActiveItem; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
702 v28 = v4 + pWindowList[v3]->pNumPresenceButton; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
703 if ( v4 < v4 + pWindowList[v3]->pNumPresenceButton ) |
2502 | 704 { |
705 while ( 1 ) | |
706 { | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
707 pButton = pWindowList[v3]->pControlsHead; |
2502 | 708 if ( v4 > 0 ) |
709 { | |
710 v6 = v4; | |
711 do | |
712 { | |
713 pButton = pButton->pNext; | |
714 --v6; | |
715 } | |
716 while ( v6 ); | |
717 } | |
718 if ( (signed int)uClickX >= (signed int)pButton->uX//test for StatsTab in PlayerCreation Window | |
719 && (signed int)uClickX <= (signed int)pButton->uZ | |
720 && (signed int)uClickY >= (signed int)pButton->uY | |
721 && (signed int)uClickY <= (signed int)pButton->uW ) | |
722 break; | |
723 ++v4; | |
724 if ( v4 >= v28 ) | |
725 { | |
726 //v1 = 0; | |
727 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
728 //--i; | |
729 //if ( i < 0 ) | |
730 return false; | |
731 //continue; | |
732 } | |
733 } | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
734 pWindowList[v3]->pCurrentPosActiveItem = v4; |
2502 | 735 return true; |
736 } | |
737 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
738 break; | |
739 } | |
740 case VK_UP: | |
741 { | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
742 v22 = pWindowList[v3]->pCurrentPosActiveItem; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
743 v23 = pWindowList[v3]->pStartingPosActiveItem; |
2502 | 744 if ( v22 <= v23 ) |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
745 v24 = pWindowList[v3]->pNumPresenceButton + v23 - 1; |
2502 | 746 else |
747 v24 = v22 - 1; | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
748 v8 = pWindowList[v3]->field_30 == 0; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
749 pWindowList[v3]->pCurrentPosActiveItem = v24; |
2502 | 750 if ( !v8 ) |
751 return true; | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
752 pButton = pWindowList[v3]->pControlsHead; |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
753 v25 = pWindowList[v3]->pCurrentPosActiveItem; |
2502 | 754 if ( v25 > 0) |
755 { | |
756 do | |
757 { | |
758 pButton = pButton->pNext; | |
759 --v25; | |
760 } | |
761 while ( v25 ); | |
762 } | |
763 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); | |
764 return true; | |
765 } | |
766 case VK_NEXT: | |
767 { | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
768 if ( pWindowList[v3]->field_30 != 0 ) //crashed at skill draw |
2502 | 769 { |
770 pMouse->GetClickPos(&uClickX, &uClickY); | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
771 v29 = pWindowList[v3]->pStartingPosActiveItem + pWindowList[v3]->pNumPresenceButton; //num buttons more than buttons |
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
772 for ( v4 = pWindowList[v3]->pStartingPosActiveItem; v4 < v29; ++v4 ) |
2502 | 773 { |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
774 pButton = pWindowList[v3]->pControlsHead; |
2502 | 775 if ( v4 > 0 ) |
776 { | |
777 for ( v15 = v4; v15; --v15 ) | |
778 pButton = pButton->pNext; | |
779 } | |
780 if ( (signed int)uClickX >= (signed int)pButton->uX && (signed int)uClickX <= (signed int)pButton->uZ | |
781 && (signed int)uClickY >= (signed int)pButton->uY && (signed int)uClickY <= (signed int)pButton->uW ) | |
782 { | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
783 pWindowList[v3]->pCurrentPosActiveItem = v4; |
2502 | 784 return true; |
785 } | |
786 } | |
787 } | |
788 break; | |
789 } | |
790 default: | |
791 break; | |
792 } | |
793 } | |
794 } |