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