comparison UI/UIHouses.cpp @ 1300:bedc304ab617

new files in UI
author Ritor1
date Thu, 20 Jun 2013 15:24:09 +0600
parents 8c2f689b5f0b
children 13b7be8b06a0
comparison
equal deleted inserted replaced
1299:8c2f689b5f0b 1300:bedc304ab617
312 {"Human Temple02", 0x24, 0x3AB, 23, 27, 0 }, 312 {"Human Temple02", 0x24, 0x3AB, 23, 27, 0 },
313 {"Player Castle Good", 0x24, 0, 25, 0, 0 }, 313 {"Player Castle Good", 0x24, 0, 25, 0, 0 },
314 {"Player Castle Bad", 0x24, 0, 25, 0, 0} 314 {"Player Castle Bad", 0x24, 0, 25, 0, 0}
315 }}; 315 }};
316 316
317
318
319 //----- (0044606A) --------------------------------------------------------
320 void PrepareHouse(HOUSE_ID house)
321 {
322 //unsigned int v1; // ebx@1
323 //signed int v2; // esi@1
324 //int uExitPic; // edi@1
325 __int16 uExitMapID; // ax@2
326 //int result; // eax@5
327 //unsigned int *v6; // ecx@8
328 int v7; // ebx@11
329 //int v8; // esi@16
330 //unsigned int v9; // eax@16
331 //unsigned int v10; // eax@19
332 //int v11; // ecx@19
333 //char pContainer[36]; // [sp+Ch] [bp-54h]@16
334 int v13; // [sp+30h] [bp-30h]@11
335 int npc_id_arr[6]; // [sp+34h] [bp-2Ch]@1
336 //unsigned int v15; // [sp+4Ch] [bp-14h]@1
337 int uAnimationID; // [sp+50h] [bp-10h]@1
338 //unsigned int *v17; // [sp+54h] [bp-Ch]@3
339 //unsigned int v18; // [sp+58h] [bp-8h]@1
340 //int v19; // [sp+5Ch] [bp-4h]@7
341
342
343 uAnimationID = p2DEvents[house - 1].uAnimationID;
344 memset(npc_id_arr, 0, sizeof(npc_id_arr));
345 uNumDialogueNPCPortraits = 0;
346 uHouse_ExitPic = p2DEvents[house - 1].uExitPicID;
347 if ( uHouse_ExitPic )
348 {
349 uExitMapID = p2DEvents[house - 1]._quest_related;
350 if ( uExitMapID > 0 )
351 {
352 if(_449B57_test_bit(pParty->_quest_bits,uExitMapID))
353 {
354 uHouse_ExitPic = 0;
355 }
356 }
357 }
358
359 dword_591080 = pAnimatedRooms[uAnimationID].house_npc_id;
360 HouseNPCData[0]=0;
361 uNumDialogueNPCPortraits = 0;
362 if ( dword_591080 )
363 {
364
365 npc_id_arr[0] = dword_591080;
366 uNumDialogueNPCPortraits = 1;
367 }
368
369 for (uint i = 1; i < pNPCStats->uNumNewNPCs; ++i)
370 {
371 if (pNPCStats->pNewNPCData[i].Location2D == house )
372 {
373 if (!(pNPCStats->pNewNPCData[i].uFlags & 0x80))
374 {
375
376 HouseNPCData[uNumDialogueNPCPortraits+1- (dword_591080 != 0) ? 1 : 0] = &pNPCStats->pNewNPCData[i];
377 npc_id_arr[uNumDialogueNPCPortraits] = pNPCStats->pNewNPCData[i].uPortraitID;
378 ++uNumDialogueNPCPortraits;
379 if ((pNPCStats->pNewNPCData[i].uFlags & 3) != 2)
380 ++pNPCStats->pNewNPCData[i].uFlags;
381 }
382 }
383
384 }
385
386 for (uint i = 0; i < uNumDialogueNPCPortraits; ++i)
387 {
388
389 char icon_name[128];
390 sprintfex(icon_name, "npc%03u", npc_id_arr[i]);
391 pDialogueNPCPortraits[i] = pIcons_LOD->LoadTexturePtr(icon_name, TEXTURE_16BIT_PALETTE);
392 }
393
394 if (uHouse_ExitPic)
395 {
396 pDialogueNPCPortraits[uNumDialogueNPCPortraits] = pIcons_LOD->LoadTexturePtr(pHouse_ExitPictures[uHouse_ExitPic], TEXTURE_16BIT_PALETTE);
397 ++uNumDialogueNPCPortraits;
398 uHouse_ExitPic = p2DEvents[house - 1].uExitMapID;
399 }
400 }
401
402
403 //----- (0044622E) -------------------------------------------------------- 317 //----- (0044622E) --------------------------------------------------------
404 bool EnterHouse(enum HOUSE_ID uHouseID) 318 bool EnterHouse(enum HOUSE_ID uHouseID)
405 { 319 {
406 //enum HOUSE_ID v1; // edi@1 320 //enum HOUSE_ID v1; // edi@1
407 //int v2; // edi@5 321 //int v2; // edi@5
555 dword_5C35D4 = 1; 469 dword_5C35D4 = 1;
556 return 1; 470 return 1;
557 } 471 }
558 } 472 }
559 473
474 //----- (0044606A) --------------------------------------------------------
475 void PrepareHouse(HOUSE_ID house)
476 {
477 //unsigned int v1; // ebx@1
478 //signed int v2; // esi@1
479 //int uExitPic; // edi@1
480 __int16 uExitMapID; // ax@2
481 //int result; // eax@5
482 //unsigned int *v6; // ecx@8
483 int v7; // ebx@11
484 //int v8; // esi@16
485 //unsigned int v9; // eax@16
486 //unsigned int v10; // eax@19
487 //int v11; // ecx@19
488 //char pContainer[36]; // [sp+Ch] [bp-54h]@16
489 int v13; // [sp+30h] [bp-30h]@11
490 int npc_id_arr[6]; // [sp+34h] [bp-2Ch]@1
491 //unsigned int v15; // [sp+4Ch] [bp-14h]@1
492 int uAnimationID; // [sp+50h] [bp-10h]@1
493 //unsigned int *v17; // [sp+54h] [bp-Ch]@3
494 //unsigned int v18; // [sp+58h] [bp-8h]@1
495 //int v19; // [sp+5Ch] [bp-4h]@7
496
497
498 uAnimationID = p2DEvents[house - 1].uAnimationID;
499 memset(npc_id_arr, 0, sizeof(npc_id_arr));
500 uNumDialogueNPCPortraits = 0;
501 uHouse_ExitPic = p2DEvents[house - 1].uExitPicID;
502 if ( uHouse_ExitPic )
503 {
504 uExitMapID = p2DEvents[house - 1]._quest_related;
505 if ( uExitMapID > 0 )
506 {
507 if(_449B57_test_bit(pParty->_quest_bits,uExitMapID))
508 {
509 uHouse_ExitPic = 0;
510 }
511 }
512 }
513
514 dword_591080 = pAnimatedRooms[uAnimationID].house_npc_id;
515 HouseNPCData[0]=0;
516 uNumDialogueNPCPortraits = 0;
517 if ( dword_591080 )
518 {
519
520 npc_id_arr[0] = dword_591080;
521 uNumDialogueNPCPortraits = 1;
522 }
523
524 for (uint i = 1; i < pNPCStats->uNumNewNPCs; ++i)
525 {
526 if (pNPCStats->pNewNPCData[i].Location2D == house )
527 {
528 if (!(pNPCStats->pNewNPCData[i].uFlags & 0x80))
529 {
530
531 HouseNPCData[uNumDialogueNPCPortraits+1- (dword_591080 != 0) ? 1 : 0] = &pNPCStats->pNewNPCData[i];
532 npc_id_arr[uNumDialogueNPCPortraits] = pNPCStats->pNewNPCData[i].uPortraitID;
533 ++uNumDialogueNPCPortraits;
534 if ((pNPCStats->pNewNPCData[i].uFlags & 3) != 2)
535 ++pNPCStats->pNewNPCData[i].uFlags;
536 }
537 }
538
539 }
540
541 for (uint i = 0; i < uNumDialogueNPCPortraits; ++i)
542 {
543
544 char icon_name[128];
545 sprintfex(icon_name, "npc%03u", npc_id_arr[i]);
546 pDialogueNPCPortraits[i] = pIcons_LOD->LoadTexturePtr(icon_name, TEXTURE_16BIT_PALETTE);
547 }
548
549 if (uHouse_ExitPic)
550 {
551 pDialogueNPCPortraits[uNumDialogueNPCPortraits] = pIcons_LOD->LoadTexturePtr(pHouse_ExitPictures[uHouse_ExitPic], TEXTURE_16BIT_PALETTE);
552 ++uNumDialogueNPCPortraits;
553 uHouse_ExitPic = p2DEvents[house - 1].uExitMapID;
554 }
555 }
560 //----- (004B1E92) -------------------------------------------------------- 556 //----- (004B1E92) --------------------------------------------------------
561 void PlayHouseSound(unsigned int uHouseID, HouseSoundID sound) 557 void PlayHouseSound(unsigned int uHouseID, HouseSoundID sound)
562 { 558 {
563 //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) ) 559 //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) )
564 if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId ) 560 if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId )
565 pAudioPlayer->PlaySound( 561 pAudioPlayer->PlaySound(
566 //(SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) + 300)), 562 //(SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) + 300)),
567 (SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)), 563 (SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)),
568 806, 0, -1, 0, 0, 0, 0); 564 806, 0, -1, 0, 0, 0, 0);
569 } 565 }
570
571 //----- (004B4F4F) --------------------------------------------------------
572 void JailDialog()
573 {
574 const char *v0; // esi@1
575 const char *v1; // ST10_4@1
576 unsigned __int16 v2; // ST0C_2@1
577 int v3; // eax@1
578 GUIWindow v5; // [sp+8h] [bp-54h]@1
579
580 memcpy(&v5, window_SpeakInHouse, sizeof(v5));
581 v0 = pGlobalTXT_LocalizationStrings[672];
582 v1 = pGlobalTXT_LocalizationStrings[672];
583 v5.uFrameX = 483;
584 v5.uFrameWidth = 148;
585 v5.uFrameZ = 334;
586 v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
587 v3 = pFontArrus->CalcTextHeight(v0, &v5, 0, 0);
588 v5.DrawTitleText(pFontArrus, 0, (310 - v3) / 2 + 18, v2, v1, 3u);
589 }
590
591
592
593 566
594 //----- (004BCACC) -------------------------------------------------------- 567 //----- (004BCACC) --------------------------------------------------------
595 void __fastcall OnSelectShopDialogueOption(signed int uMessageParam) 568 void __fastcall OnSelectShopDialogueOption(signed int uMessageParam)
596 { 569 {
597 //unsigned int v1; // edi@1 570 //unsigned int v1; // edi@1
1611 } 1584 }
1612 } 1585 }
1613 } 1586 }
1614 */ 1587 */
1615 } 1588 }
1616
1617
1618
1619 //----- (004B6943) -------------------------------------------------------- 1589 //----- (004B6943) --------------------------------------------------------
1620 void __cdecl TravelByTransport() 1590 void __cdecl TravelByTransport()
1621 { 1591 {
1622 GUIWindow *v0; // ebx@1 1592 GUIWindow *v0; // ebx@1
1623 Player *v1; // esi@1 1593 Player *v1; // esi@1
1927 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); 1897 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
1928 } 1898 }
1929 } 1899 }
1930 } 1900 }
1931 } 1901 }
1932
1933
1934
1935
1936
1937
1938 //----- (004B68EA) -------------------------------------------------------- 1902 //----- (004B68EA) --------------------------------------------------------
1939 bool __fastcall IsTravelAvailable(int a1) 1903 bool __fastcall IsTravelAvailable(int a1)
1940 { 1904 {
1941 for (uint i = 0; i < 4; ++i) 1905 for (uint i = 0; i < 4; ++i)
1942 { 1906 {
2127 break; 2091 break;
2128 } 2092 }
2129 } 2093 }
2130 return; 2094 return;
2131 } 2095 }
2132
2133
2134 2096
2135 //----- (004B7D7E) -------------------------------------------------------- 2097 //----- (004B7D7E) --------------------------------------------------------
2136 void __cdecl BankDialog() 2098 void __cdecl BankDialog()
2137 { 2099 {
2138 GUIWindow *v0; // eax@4 2100 GUIWindow *v0; // eax@4
2711 default: 2673 default:
2712 { 2674 {
2713 break; 2675 break;
2714 } 2676 }
2715 } 2677 }
2716 }
2717
2718
2719 //----- (004B910F) --------------------------------------------------------
2720 void __cdecl WeaponShopDialog()
2721 {
2722 int v0; // ebx@1
2723 int pNumActiveItem; // eax@6
2724 signed int v2; // esi@8
2725 ItemGen *v4; // eax@11
2726 char *v5; // ecx@12
2727 unsigned __int8 v6; // dl@13
2728 char *v7; // edx@14
2729 int v9; // ST08_4@16
2730 int v10; // eax@16
2731 signed int v11; // esi@18
2732 int v12; // ST08_4@21
2733 int v13; // eax@21
2734 int v14; // edi@23
2735 char **v15; // esi@23
2736 int v16; // eax@24
2737 //int v18; // edx@25
2738 int v19; // edi@25
2739 unsigned __int8 v20; // sf@25
2740 GUIButton *pButton; // esi@27
2741 int pNewItem; // eax@27
2742 unsigned int v24; // ecx@27
2743 int v25; // edx@27
2744 unsigned int pColorText; // ax@27
2745 signed int v27; // esi@32
2746 int v28; // ST08_4@36
2747 int v29; // eax@36
2748 signed int v32; // esi@41
2749 unsigned int v33; // esi@43
2750 int v34; // eax@43
2751 unsigned int v35; // eax@44
2752 int v36; // eax@46
2753 __int32 v37; // ecx@51
2754 int v40; // eax@53
2755 char *v41; // eax@55
2756 unsigned int v43; // ecx@55
2757 const char **v44; // edx@55
2758 int v45; // eax@55
2759 int v47; // eax@59
2760 const char **v48; // eax@63
2761 unsigned int v49; // esi@65
2762 Texture *v50; // eax@65
2763 int v51; // edi@65
2764 int v52; // esi@70
2765 Texture *v53; // ST1C_4@70
2766 int v54; // edi@70
2767 signed int v55; // ecx@73
2768 SHORT v56; // di@82
2769 bool v57; // eax@82
2770 const char *v58; // ecx@84
2771 POINT *v59; // esi@89
2772 LONG v60; // ecx@90
2773 int v61; // eax@90
2774 int v62; // ecx@90
2775 ItemGen *pItemInShop; // esi@90
2776 int v64; // eax@95
2777 int all_text_height; // esi@96
2778 char **v66; // edi@96
2779 int v67; // eax@97
2780 int v69; // edx@98
2781 int v70; // edi@98
2782 int v71;
2783 const char **v72; // eax@100
2784 int pTextHeight; // eax@100
2785 unsigned int v74; // ecx@100
2786 int v78; // [sp-14h] [bp-10Ch]@14
2787 ItemGen *v79; // [sp-10h] [bp-108h]@12
2788 int v80; // [sp-10h] [bp-108h]@14
2789 void *v81; // [sp-Ch] [bp-104h]@12
2790 unsigned __int16 v82; // [sp-Ch] [bp-104h]@14
2791 int v83; // [sp-8h] [bp-100h]@11
2792 char *v84; // [sp-8h] [bp-100h]@14
2793 __int64 *v85; // [sp-4h] [bp-FCh]@11
2794 unsigned int v86; // [sp-4h] [bp-FCh]@14
2795 POINT v87; // [sp+Ch] [bp-ECh]@8
2796 POINT v88; // [sp+14h] [bp-E4h]@18
2797 POINT v89; // [sp+1Ch] [bp-DCh]@89
2798 POINT v90; // [sp+24h] [bp-D4h]@19
2799 POINT v91; // [sp+2Ch] [bp-CCh]@89
2800 POINT v92; // [sp+34h] [bp-C4h]@9
2801 POINT v93; // [sp+3Ch] [bp-BCh]@33
2802 POINT v94; // [sp+44h] [bp-B4h]@18
2803 POINT v95; // [sp+4Ch] [bp-ACh]@32
2804 POINT v96; // [sp+54h] [bp-A4h]@18
2805 POINT v97; // [sp+5Ch] [bp-9Ch]@32
2806 POINT a2; // [sp+64h] [bp-94h]@8
2807 POINT v99; // [sp+6Ch] [bp-8Ch]@32
2808 POINT v100; // [sp+74h] [bp-84h]@8
2809 GUIWindow dialog_window; // [sp+7Ch] [bp-7Ch]@1
2810 char *Str; // [sp+D0h] [bp-28h]@55
2811 __int32 v103; // [sp+D4h] [bp-24h]@25
2812 int pColorYellow; // [sp+D8h] [bp-20h]@1
2813 int pColorWhite; // [sp+DCh] [bp-1Ch]@1
2814 POINT v106; // [sp+E0h] [bp-18h]@8
2815 Player *pPlayer; // [sp+E8h] [bp-10h]@1
2816 int pItemNum; // [sp+ECh] [bp-Ch]@26
2817 const char **v109; // [sp+F0h] [bp-8h]@26
2818 unsigned __int8 v110; // [sp+F7h] [bp-1h]@16
2819 int pNumString;
2820
2821 pPlayer = pPlayers[uActiveCharacter];
2822 memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window));
2823 dialog_window.uFrameX = 483;
2824 dialog_window.uFrameWidth = 148;
2825 dialog_window.uFrameZ = 334;
2826 pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
2827 pColorYellow = TargetColor(0xE1u, 0xCDu, 0x23u);
2828
2829 switch(dialog_menu_id)
2830 {
2831 case HOUSE_DIALOGUE_MAIN:
2832 {
2833 pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
2834 if ( pNumActiveItem )
2835 {
2836 pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
2837 pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
2838 pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
2839 pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
2840 all_text_height = 0;
2841 for (int i = 0; i < 4; ++i)//while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
2842 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
2843 v103 = (174 - all_text_height) / 4;
2844 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
2845 v19 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138;
2846 v20 = -pDialogueWindow->pNumPresenceButton < 0;
2847 if ( v20 ^ (pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton ))
2848 {
2849 pItemNum = 2;
2850 pNumString = 0;
2851 do
2852 {
2853 pButton = pDialogueWindow->GetControl(pItemNum);
2854 pButton->uY = v103 + v19;
2855 pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
2856 pButton->uHeight = pTextHeight;
2857 v19 = pButton->uY + pTextHeight - 1;
2858 pButton->uW = v19;
2859 pColorText = pColorYellow;
2860 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
2861 pColorText = pColorWhite;
2862 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
2863 ++pItemNum;
2864 ++pNumString;
2865 pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
2866 }
2867 while ( pItemNum < pNumActiveItem );
2868 }
2869 }
2870 break;
2871 }
2872
2873 case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
2874 {
2875 pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
2876 v48 = 0;
2877 pItemNum = 0;
2878 v109 = 0;
2879 do
2880 {
2881 // if ( pParty->field_777C[9 * (int)&v48[3 * (unsigned int)window_SpeakInHouse->ptr_1C]] )
2882 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(int)v48].uItemID)
2883 {
2884 v49 = word_F8B158[(signed int)v48];
2885 v50 = ItemsInShopTexture[(signed int)v48];
2886 v49 += 30;
2887 v51 = 60 - ((signed int)v50->uTextureWidth >> 1);
2888 pRenderer->DrawTextureTransparent(v51 + pItemNum, v49, v50);
2889 sub_40F92A(&pRenderer->pActiveZBuffer[v51 + pItemNum + 640 * v49], ItemsInShopTexture[(signed int)v109], (int)((char *)v109 + 1));
2890 v48 = v109;
2891 }
2892 pItemNum += 70;
2893 v48 = (const char **)((char *)v48 + 1);
2894 v109 = v48;
2895 }
2896 while ( (signed int)v48 < 6 );
2897 pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
2898 if ( pNumActiveItem )
2899 {
2900 v55 = 0;
2901 v106.x = 0;
2902 v106.x = 0;
2903 do
2904 {
2905 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID)//9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
2906 ++v106.x;
2907 ++v55;
2908 }
2909 while ( v55 < 6 );
2910 v56 = GetAsyncKeyState(17);
2911 v57 = pPlayer->CanSteal();
2912 Str = (char *)v57;
2913 if ( v56 && v57 )
2914 {
2915 v58 = pGlobalTXT_LocalizationStrings[185];
2916 }
2917 else
2918 {
2919 v58 = pGlobalTXT_LocalizationStrings[195];
2920 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
2921 v58 = pGlobalTXT_LocalizationStrings[196];
2922 }
2923 DrawTextAtStatusBar(v58, 0);
2924 if ( v106.x )
2925 {
2926 v59 = pMouse->GetCursorPos(&v91);
2927 pNumActiveItem = v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y];
2928 if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF )
2929 {
2930 v60 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1;
2931 v106.x = v60;
2932 v61 = (int)window_SpeakInHouse->ptr_1C;//maybe ptr_1C - BuildID_2Events
2933 // v62 = 9 * (v60 + 12 * v61);
2934 pItemInShop = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
2935 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
2936 pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];
2937 if ( !v56 || !Str )
2938 {
2939 v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2);
2940 v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
2941 pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
2942 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
2943 }
2944 else
2945 {
2946 v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
2947 pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
2948 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
2949 }
2950 }
2951 }
2952 else
2953 {
2954 dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
2955 pNumActiveItem = 0; //added
2956 }
2957 }
2958 break;
2959 }
2960
2961 case HOUSE_DIALOGUE_SHOP_SELL:
2962 {
2963 draw_leather();
2964 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
2965 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);
2966 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
2967 return;
2968 if((v11 = pMouse->GetCursorPos(&v96)->x - 14, v106.x = (v11 >> 5) + 14 * ((pMouse->GetCursorPos(&v88)->y - 17) >> 5),
2969 pMouse->GetCursorPos(&v94)->x <= 13) || pMouse->GetCursorPos(&v90)->x >= 462
2970 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) )
2971 return;
2972 v79 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1];
2973 v13 = pPlayer->SelectPhrasesTransaction(v79, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3);
2974 v7 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0);
2975 pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
2976 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
2977 break;
2978 }
2979
2980 case HOUSE_DIALOGUE_SHOP_IDENTIFY:
2981 {
2982 draw_leather();
2983 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
2984 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);
2985 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
2986 return;
2987 if((v2 = pMouse->GetCursorPos(&a2)->x - 14, v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5),
2988 pMouse->GetCursorPos(&v100)->x <= 13) || pMouse->GetCursorPos(&v92)->x >= 462
2989 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) )
2990 return;
2991 v4 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1];
2992 if (!v4->Identified())
2993 {
2994 v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4);
2995 v7 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
2996 pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
2997 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
2998 }
2999 else
3000 {
3001 v7 = BuilDialogueString("%24", uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
3002 pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
3003 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
3004 }
3005 break;
3006 }
3007
3008 case HOUSE_DIALOGUE_SHOP_REPAIR:
3009 {
3010 draw_leather();
3011 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
3012 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);
3013 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
3014 return;
3015 if( (v2 = pMouse->GetCursorPos(&a2)->x - 14, v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5),
3016 pMouse->GetCursorPos(&v100)->x <= 13) || pMouse->GetCursorPos(&v92)->x >= 462
3017 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem)
3018 || (!(pPlayer->pOwnItems[pNumActiveItem-1].uAttributes& 2)) )
3019 return;
3020 v4 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1];
3021 v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5);
3022 v7 = BuilDialogueString((char *)pMerchantsRepairPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 5, 0);
3023 pTextHeight = (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138;
3024 dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, pColorWhite, v7, 3);
3025 return;
3026 }
3027 break;
3028
3029 case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
3030 {
3031 draw_leather();
3032 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
3033 pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];//sell
3034 pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];//identify
3035 pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];//repair
3036 all_text_height = 0;
3037 for ( int i = 0; i < 3; ++i )
3038 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
3039 v103 = (174 - all_text_height) / 3;
3040 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
3041 v70 = (3 * (58 - (signed int)v103) - all_text_height) / 2 - ((174 - all_text_height) / 3) / 2 + 138;
3042 v20 = -pDialogueWindow->pNumPresenceButton < 0;
3043 if ( v20 ^ (pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton ))
3044 {
3045 pItemNum = 2;
3046 pNumString = 0;
3047 do
3048 {
3049 pButton = pDialogueWindow->GetControl(pItemNum);
3050 pButton->uY = v103 + v70;
3051 pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
3052 pButton->uHeight = pTextHeight;
3053 v70 = pButton->uY + pTextHeight - 1;
3054 pButton->uW = v70;
3055 pColorText = pColorYellow;
3056 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
3057 pColorText = pColorWhite;
3058 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
3059 ++pItemNum;
3060 ++pNumString;
3061 pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
3062 }
3063 while ( pItemNum < pNumActiveItem );
3064 }
3065 break;
3066 }
3067
3068 case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
3069 {
3070 pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
3071 v109 = 0;
3072 pItemNum = 0;
3073 do
3074 {
3075 // if ( pParty->field_C59C[9 * (int)&v109[3 * (unsigned int)window_SpeakInHouse->ptr_1C] + 724] )
3076 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v109].uItemID)
3077 {
3078 v52 = word_F8B158[(signed int)v109] + 30;
3079 v53 = ItemsInShopTexture[(signed int)v109];
3080 v54 = 60 - ((signed int)v53->uTextureWidth >> 1);
3081 pRenderer->DrawTextureTransparent(v54 + pItemNum, word_F8B158[(signed int)v109] + 30, v53);
3082 sub_40F92A(&pRenderer->pActiveZBuffer[v54 + pItemNum + 640 * v52], ItemsInShopTexture[(signed int)v109], (int)((char *)v109 + 1));
3083 }
3084 v109 = (const char **)((char *)v109 + 1);
3085 pItemNum += 70;
3086 }
3087 while ( (signed int)v109 < 6 );
3088 pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
3089 if ( pNumActiveItem )
3090 {
3091 v55 = 0;
3092 v106.x = 0;
3093 do
3094 {
3095 // if ( pParty->field_C59C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
3096 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID)
3097 ++v106.x;
3098 ++v55;
3099 }
3100 while ( v55 < 6 );
3101 v56 = GetAsyncKeyState(17);
3102 v57 = pPlayer->CanSteal();
3103 Str = (char *)v57;
3104 if ( v56 && v57 )
3105 {
3106 v58 = pGlobalTXT_LocalizationStrings[185];
3107 }
3108 else
3109 {
3110 v58 = pGlobalTXT_LocalizationStrings[195];
3111 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
3112 v58 = pGlobalTXT_LocalizationStrings[196];
3113 }
3114 DrawTextAtStatusBar(v58, 0);
3115 if ( v106.x )
3116 {
3117 v59 = pMouse->GetCursorPos(&v91);
3118 pNumActiveItem = v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y];
3119 if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF )
3120 {
3121 v60 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1;
3122 v106.x = v60;
3123 v61 = (int)window_SpeakInHouse->ptr_1C;
3124 // v62 = 9 * (v60 + 12 * v61);
3125 pItemInShop = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
3126 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
3127 pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
3128 if ( !v56 || !Str )
3129 {
3130 v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2);
3131 v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
3132 pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
3133 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
3134 }
3135 else
3136 {
3137 v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
3138 pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0);
3139 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3);
3140 }
3141 }
3142 }
3143 else
3144 {
3145 dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
3146 pNumActiveItem = 0; //added
3147 }
3148 }
3149 break;
3150 }
3151
3152 case HOUSE_DIALOGUE_LEARN_SKILLS:
3153 {
3154 if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
3155 return;
3156 v0 = 0;
3157 all_text_height = 0;
3158 //v32 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v31] * 500.0);
3159 v32 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
3160 pItemNum = v32 * (100 - pPlayer->GetMerchant()) / 100;
3161 if ( pItemNum < v32 / 3 )
3162 pItemNum = v32 / 3;
3163 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
3164 if ( pNumActiveItem >= pNumActiveItem + pDialogueWindow->pNumPresenceButton )
3165 {
3166 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
3167 strcat(pTmpBuf.data(), "\n \n");
3168 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);
3169 pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0);
3170 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf.data(), 3);
3171 return;
3172 }
3173 do
3174 {
3175 v35 = pDialogueWindow->GetControl(pNumActiveItem)->msg_param - 36;
3176 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v35] && !pPlayer->pActiveSkills[v35] )
3177 {
3178 all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v35], &dialog_window, 0, 0);
3179 v0++;
3180 }
3181 ++pNumActiveItem;
3182 }
3183 while ( pNumActiveItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
3184 if ( !v0 )
3185 {
3186 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
3187 strcat(pTmpBuf.data(), "\n \n");
3188 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);
3189 pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0);
3190 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf.data(), 3);
3191 return;
3192 }
3193 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pItemNum);
3194 dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
3195 v103 = (149 - all_text_height) / v0;
3196 if ( (149 - all_text_height) / v0 > 32 )
3197 v103 = 32;
3198 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
3199 v37 = (149 - v0 * v103 - all_text_height) / 2 - v103 / 2 + 162;
3200 if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton )
3201 {
3202 pItemNum = 2;
3203 do
3204 {
3205 pButton = pDialogueWindow->GetControl(pItemNum);
3206 v40 = pButton->msg_param - 36;
3207 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v40] || pPlayer->pActiveSkills[v40] )
3208 {
3209 pButton->uW = 0;
3210 pButton->uHeight = 0;
3211 pButton->uY = 0;
3212 }
3213 else
3214 {
3215 pButton->uY = v103 + v37;
3216 pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v40], &dialog_window, 0, 0);
3217 pButton->uHeight = pTextHeight;
3218 v37 = pButton->uY + pTextHeight - 1;
3219 pButton->uW = v37;
3220 pColorText = pColorYellow;
3221 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
3222 pColorText = pColorWhite;
3223 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v40], 3);
3224 }
3225 pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
3226 pItemNum++;
3227 }
3228 while ( pItemNum < pNumActiveItem );
3229 }
3230 break;
3231 }
3232 default:
3233 {
3234 if( dialog_menu_id > HOUSE_DIALOGUE_SHOP_REPAIR)
3235 pNumActiveItem = dialog_menu_id - 96;
3236 else
3237 pNumActiveItem = dialog_menu_id - 4;
3238 break;
3239 }
3240 }
3241 }
3242
3243
3244
3245 //----- (004B9CC6) --------------------------------------------------------
3246 void __cdecl AlchemistDialog()
3247 {
3248 int v0;
3249 int pNumActiveItem; // eax@7
3250 signed int v5; // esi@9
3251 unsigned int v6; // esi@11
3252 int v7; // eax@11
3253 unsigned int v8; // eax@12
3254 int v9; // eax@14
3255 int v10; // ecx@19
3256 int v13; // eax@21
3257 char *v14; // eax@23
3258 int v15; // eax@23
3259 unsigned int v16; // ecx@23
3260 int v17; // edx@23
3261 int v18; // eax@23
3262 int v20; // eax@27
3263 char *v21; // edx@29
3264 int v22; // esi@30
3265 char **v23; // edi@30
3266 int v24; // eax@31
3267 int v26; // edx@32
3268 int v27; // edi@32
3269 unsigned __int8 v28; // sf@32
3270 const char **v30; // eax@34
3271 int v31; // eax@34
3272 unsigned int v32; // ecx@34
3273 int v34; // eax@34
3274 signed int v36; // esi@39
3275 ItemGen *v37; // eax@42
3276 char *v38; // ecx@43
3277 unsigned __int8 v39; // dl@44
3278 int v40; // eax@46
3279 int v41; // ST08_4@47
3280 int v42; // eax@47
3281 signed int v43; // esi@49
3282 int v44; // ST08_4@52
3283 int v45; // eax@52
3284 Texture *v46; // ecx@55
3285 unsigned int v47; // edi@55
3286 unsigned int v48; // esi@57
3287 int v49; // edx@61
3288 Texture *v50; // ecx@67
3289 unsigned int v51; // edi@67
3290 unsigned int v52; // esi@69
3291 int v53; // edx@73
3292 Texture *v54; // ecx@79
3293 unsigned int v55; // edi@79
3294 unsigned int v56; // esi@81
3295 int v57; // edx@85
3296 Texture *v58; // ecx@91
3297 unsigned int v59; // edi@91
3298 unsigned int v60; // esi@93
3299 int v61; // edx@97
3300 signed int v62; // ecx@102
3301 SHORT v63; // di@110
3302 bool v64; // eax@110
3303 const char *v65; // ecx@112
3304 POINT *v66; // esi@117
3305 int v67; // ecx@118
3306 int v68; // eax@118
3307 int v69; // ecx@118
3308 ItemGen *v70; // esi@118
3309 int v71; // eax@123
3310 int all_text_height; // edi@125
3311 char **v73; // esi@125
3312 int v74; // eax@126
3313 int pItemNum;
3314 int v76; // edx@127
3315 int v77; // edi@127
3316 GUIButton *pButton; // esi@129
3317 const char **v79; // eax@129
3318 int pTextHeight; // eax@129
3319 unsigned int v81; // ecx@129
3320 unsigned int pColorText; // ax@129
3321 int v85; // [sp-14h] [bp-ECh]@29
3322 int v86; // [sp-10h] [bp-E8h]@29
3323 ItemGen *v87; // [sp-10h] [bp-E8h]@43
3324 unsigned __int16 v88; // [sp-Ch] [bp-E4h]@29
3325 void *v89; // [sp-Ch] [bp-E4h]@43
3326 char *v90; // [sp-8h] [bp-E0h]@29
3327 int v91; // [sp-8h] [bp-E0h]@42
3328 unsigned int v92; // [sp-4h] [bp-DCh]@29
3329 __int64 *v93; // [sp-4h] [bp-DCh]@42
3330 POINT v94; // [sp+Ch] [bp-CCh]@39
3331 POINT v95; // [sp+14h] [bp-C4h]@49
3332 POINT v96; // [sp+1Ch] [bp-BCh]@117
3333 POINT v97; // [sp+24h] [bp-B4h]@40
3334 POINT v98; // [sp+2Ch] [bp-ACh]@117
3335 POINT v99; // [sp+34h] [bp-A4h]@49
3336 POINT v100; // [sp+3Ch] [bp-9Ch]@50
3337 POINT v101; // [sp+44h] [bp-94h]@39
3338 POINT v102; // [sp+4Ch] [bp-8Ch]@49
3339 POINT a2; // [sp+54h] [bp-84h]@39
3340 GUIWindow dialog_window; // [sp+5Ch] [bp-7Ch]@1
3341 int v105; // [sp+B0h] [bp-28h]@19
3342 int pColorYellow; // [sp+B4h] [bp-24h]@1
3343 int Str; // [sp+B8h] [bp-20h]@23
3344 int pColorWhite; // [sp+BCh] [bp-1Ch]@1
3345 __int32 v109; // [sp+C0h] [bp-18h]@39
3346 Player *pPlayer; // [sp+C4h] [bp-14h]@1
3347 int pNumString; // [sp+C8h] [bp-10h]@9
3348 unsigned int v112; // [sp+CCh] [bp-Ch]@9
3349 unsigned __int8 v113; // [sp+D3h] [bp-5h]@47
3350 int v114; // [sp+D4h] [bp-4h]@11
3351
3352 pPlayer = pPlayers[uActiveCharacter];
3353 memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window));
3354 dialog_window.uFrameX = 483;
3355 dialog_window.uFrameWidth = 148;
3356 dialog_window.uFrameZ = 334;
3357 pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
3358 pColorYellow = TargetColor(0xE1u, 0xCDu, 0x23u);
3359 switch(dialog_menu_id)
3360 {
3361 case HOUSE_DIALOGUE_MAIN:
3362 {
3363 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
3364 {
3365 pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
3366 pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
3367 pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
3368 pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
3369 all_text_height = 0;
3370 for (int i = 0; i < 4; ++i)//while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
3371 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
3372 Str = (174 - all_text_height) / 4;
3373 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
3374 v76 = pNumActiveItem + pDialogueWindow->pNumPresenceButton;
3375 v77 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138;
3376 v28 = -pDialogueWindow->pNumPresenceButton < 0;
3377 if ( v28 ^ (pNumActiveItem > v76) )
3378 {
3379 pItemNum = 2;
3380 pNumString = 0;
3381 do
3382 {
3383 pButton = pDialogueWindow->GetControl(pItemNum);
3384 pButton->uY = Str + v77;
3385 pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
3386 pButton->uHeight = pTextHeight;
3387 v77 = pButton->uY + pTextHeight - 1;
3388 pButton->uW = v77;
3389 pColorText = pColorYellow;
3390 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
3391 pColorText = pColorWhite;
3392 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
3393 ++pItemNum;
3394 ++pNumString;
3395 pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
3396 }
3397 while ( pItemNum < pNumActiveItem );
3398 }
3399 }
3400 return;
3401 }
3402 case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
3403 {
3404 pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
3405 v114 = 0;
3406 do
3407 {
3408 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID)
3409 {
3410 v46 = ItemsInShopTexture[v114];
3411 v47 = 152 - v46->uTextureHeight;
3412 if ( (signed int)v47 < 1 )
3413 v47 = 0;
3414 v48 = 75 * v114 - v46->uTextureWidth / 2 + 40;
3415 if ( v114 )
3416 {
3417 if ( v114 == 5 )
3418 {
3419 v49 = ItemsInShopTexture[5]->uTextureWidth;
3420 if ( (signed int)v48 > 457 - v49 )
3421 v48 = 457 - v49;
3422 }
3423 }
3424 else if ( (signed int)v48 < 18 )
3425 v48 = 18;
3426 pRenderer->DrawTextureTransparent(v48, v47, v46);
3427 sub_40F92A(&pRenderer->pActiveZBuffer[v48 + 640 * v47], ItemsInShopTexture[v114], v114 + 1);
3428 }
3429 ++v114;
3430 }
3431 while ( v114 < 6 );
3432 v114 = 0;
3433 do
3434 {
3435 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114 + 6].uItemID)
3436 {
3437 v50 = ItemsInShopTexture[v114 + 6];
3438 v51 = 308 - v50->uTextureHeight;
3439 if ( (signed int)v51 < 1 )
3440 v51 = 0;
3441 v52 = 75 * v114 - v50->uTextureWidth / 2 + 40;
3442 if ( v114 )
3443 {
3444 if ( v114 == 5 )
3445 {
3446 v53 = ItemsInShopTexture[11]->uTextureWidth;
3447 if ( (signed int)v52 > 457 - v53 )
3448 v52 = 457 - v53;
3449 }
3450 }
3451 else
3452 {
3453 if ( (signed int)v52 < 18 )
3454 v52 = 18;
3455 }
3456 pRenderer->DrawTextureTransparent(v52, v51, v50);
3457 sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v114 + 6], v114 + 7);
3458 }
3459 ++v114;
3460 }
3461 while ( v114 < 6 );
3462 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
3463 {
3464 v62 = 0;
3465 v109 = 0;
3466 do
3467 {
3468 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID)
3469 ++v109;
3470 ++v62;
3471 }
3472 while ( v62 < 12 );
3473 v63 = GetAsyncKeyState(17);
3474 v64 = pPlayer->CanSteal();
3475 Str = v64;
3476 if ( v63 && v64 )
3477 {
3478 v65 = pGlobalTXT_LocalizationStrings[185];
3479 }
3480 else if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
3481 {
3482 v65 = pGlobalTXT_LocalizationStrings[195];
3483 }
3484 else
3485 {
3486 v65 = pGlobalTXT_LocalizationStrings[196];
3487 }
3488 DrawTextAtStatusBar(v65, 0);
3489 if ( !v109 )
3490 {
3491 dialog_window.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
3492 return;
3493 }
3494 v66 = pMouse->GetCursorPos(&v98);
3495 pNumActiveItem = v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y];
3496 if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF )
3497 {
3498 v67 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1;
3499 v70 = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];
3500 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
3501 v70 = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
3502 if ( !v63 || !Str )
3503 {
3504 v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2);
3505 v38 = (char *)pMerchantsBuyPhrases[v71];
3506 }
3507 else
3508 {
3509 v38 = pGlobalTXT_LocalizationStrings[181];
3510 }
3511 v21 = BuilDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
3512 v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0);
3513 dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3);
3514 return ;
3515 }
3516 }
3517 return;
3518 }
3519 case HOUSE_DIALOGUE_SHOP_SELL:
3520 {
3521 draw_leather();
3522 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
3523 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);
3524 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
3525 return;
3526 if ((v43 = pMouse->GetCursorPos(&v99)->x - 14, v109 = (v43 >> 5) + 14 * ((pMouse->GetCursorPos(&v95)->y - 17) >> 5),
3527 pMouse->GetCursorPos(&v102)->x <= 13) || pMouse->GetCursorPos(&v100)->x >= 462
3528 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) )
3529 return;
3530 v87 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1];
3531 v45 = pPlayer->SelectPhrasesTransaction(v87, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3);
3532 v21 = BuilDialogueString((char *)pMerchantsSellPhrases[v45], uActiveCharacter - 1, v87, (char *)window_SpeakInHouse->ptr_1C, 3, 0);
3533 pTextHeight = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0);
3534 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v21, 3);
3535 return;
3536 }
3537 case HOUSE_DIALOGUE_SHOP_IDENTIFY:
3538 {
3539 draw_leather();
3540 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
3541 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);
3542 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
3543 return;
3544 if ((v36 = pMouse->GetCursorPos(&a2)->x - 14, v109 = (v36 >> 5) + 14 * ((pMouse->GetCursorPos(&v94)->y - 17) >> 5),
3545 pMouse->GetCursorPos(&v101)->x <= 13) || pMouse->GetCursorPos(&v97)->x >= 462
3546 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) )
3547 return;
3548 v37 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1];
3549 if (!v37->Identified())
3550 {
3551 v42 = pPlayer->SelectPhrasesTransaction(v37, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4);
3552 v38 = (char *)pMerchantsIdentifyPhrases[v42];
3553 }
3554 else
3555 {
3556 v38 = "%24";
3557 }
3558 v21 = BuilDialogueString(v38, uActiveCharacter - 1, v37, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
3559 v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0);
3560 dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3);
3561 return;
3562 }
3563 case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
3564 {
3565 draw_leather();
3566 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
3567 pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];
3568 pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];
3569 all_text_height = 0;
3570 for ( int i = 0; i < 2; ++i )
3571 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
3572 Str = (174 - all_text_height) / 2;
3573 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
3574 v26 = pNumActiveItem + pDialogueWindow->pNumPresenceButton;
3575 v27 = (2 * (87 - (174 - all_text_height) / 2) - all_text_height) / 2 - (174 - all_text_height) / 2 / 2 + 138;
3576 v28 = -pDialogueWindow->pNumPresenceButton < 0;
3577 if ( v28 ^ (pNumActiveItem > v26) )
3578 {
3579 pItemNum = 2;
3580 pNumString = 0;
3581 do
3582 {
3583 pButton = pDialogueWindow->GetControl(pItemNum);
3584 pButton->uY = Str + v27;
3585 pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
3586 pButton->uHeight = pTextHeight;
3587 v27 = pButton->uY + pTextHeight - 1;
3588 pButton->uW = v27;
3589 pColorText = pColorYellow;
3590 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
3591 pColorText = pColorWhite;
3592 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
3593 ++pItemNum;
3594 ++pNumString;
3595 pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
3596 }
3597 while ( pItemNum < pNumActiveItem );
3598 }
3599 return;
3600 }
3601 case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
3602 {
3603 pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
3604 v114 = 0;
3605 do
3606 {
3607 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID)
3608 {
3609 v54 = ItemsInShopTexture[v114];
3610 v55 = 152 - v54->uTextureHeight;
3611 if ( (signed int)v55 < 1 )
3612 v55 = 0;
3613 v56 = 75 * v114 - v54->uTextureWidth / 2 + 40;
3614 if ( v114 )
3615 {
3616 if ( v114 == 5 )
3617 {
3618 v57 = ItemsInShopTexture[5]->uTextureWidth;
3619 if ( (signed int)v56 > 457 - v57 )
3620 v56 = 457 - v57;
3621 }
3622 }
3623 else
3624 {
3625 if ( (signed int)v56 < 18 )
3626 v56 = 18;
3627 }
3628 pRenderer->DrawTextureTransparent(v56, v55, v54);
3629 sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v114], v114 + 1);
3630 }
3631 ++v114;
3632 }
3633 while ( v114 < 6 );
3634 v114 = 0;
3635 do
3636 {
3637 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114 + 6].uItemID) //not itemid
3638 {
3639 v58 = ItemsInShopTexture[v114 + 6];
3640 v59 = 308 - v58->uTextureHeight;
3641 if ( (signed int)v59 < 1 )
3642 v59 = 0;
3643 v60 = 75 * v114 - v58->uTextureWidth / 2 + 40;
3644 if ( v114 )
3645 {
3646 if ( v114 == 5 )
3647 {
3648 v61 = ItemsInShopTexture[11]->uTextureWidth;
3649 if ( (signed int)v60 > 457 - v61 )
3650 v60 = 457 - v61;
3651 }
3652 }
3653 else
3654 {
3655 if ( (signed int)v60 < 18 )
3656 v60 = 18;
3657 }
3658 pRenderer->DrawTextureTransparent(v60, v59, v58);
3659 sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v114 + 6], v114 + 7);
3660 }
3661 ++v114;
3662 }
3663 while ( v114 < 6 );
3664 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
3665 {
3666 v62 = 0;
3667 v109 = 0;
3668 do
3669 {
3670 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID)
3671 ++v109;
3672 ++v62;
3673 }
3674 while ( v62 < 12 );
3675 v63 = GetAsyncKeyState(17);
3676 v64 = pPlayer->CanSteal();
3677 Str = v64;
3678 if ( v63 && v64 )
3679 {
3680 v65 = pGlobalTXT_LocalizationStrings[185];
3681 }
3682 else
3683 {
3684 v65 = pGlobalTXT_LocalizationStrings[195];
3685 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
3686 v65 = pGlobalTXT_LocalizationStrings[196];
3687 }
3688 DrawTextAtStatusBar(v65, 0);
3689 if ( !v109 )
3690 {
3691 dialog_window.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
3692 return;
3693 }
3694 v66 = pMouse->GetCursorPos(&v98);
3695 pNumActiveItem = v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y];
3696 if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF )
3697 {
3698 v67 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1;
3699 v109 = v67;
3700 v68 = (int)window_SpeakInHouse->ptr_1C;
3701 // v69 = 9 * (v67 + 12 * v68);
3702 v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67];
3703 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
3704 v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
3705 if ( !v63 || !Str )
3706 {
3707 v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, v68, 2);
3708 v38 = (char *)pMerchantsBuyPhrases[v71];
3709 }
3710 else
3711 {
3712 v38 = pGlobalTXT_LocalizationStrings[181];
3713 }
3714 v21 = BuilDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
3715 v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0);
3716 dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3);
3717 return;
3718 }
3719 }
3720 return;
3721 }
3722 case HOUSE_DIALOGUE_LEARN_SKILLS:
3723 {
3724 if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
3725 return;
3726 all_text_height = 0;
3727 v5 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
3728 pItemNum = v5 * (100 - pPlayer->GetMerchant()) / 100;
3729 if ( pItemNum < v5 / 3 )
3730 pItemNum = v5 / 3;
3731 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
3732 v114 = 0;
3733 if ( pNumActiveItem >= pNumActiveItem + pDialogueWindow->pNumPresenceButton )
3734 {
3735 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
3736 strcat(pTmpBuf.data(), "\n \n");
3737 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);
3738 v40 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0);
3739 dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorYellow, pTmpBuf.data(), 3);
3740 return;
3741 }
3742 do
3743 {
3744 v8 = pDialogueWindow->GetControl(pNumActiveItem)->msg_param - 36;
3745 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v8] && !pPlayer->pActiveSkills[v8] )
3746 {
3747 all_text_height = pFontArrus->CalcTextHeight(pSkillNames[v8], &dialog_window, 0, 0);
3748 ++v114;
3749 }
3750 ++pNumActiveItem;
3751 }
3752 while ( pNumActiveItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
3753 if ( !v114 )
3754 {
3755 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
3756 strcat(pTmpBuf.data(), "\n \n");
3757 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);
3758 v40 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0);
3759 dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorYellow, pTmpBuf.data(), 3);
3760 return;
3761 }
3762 if ( v114 )
3763 {
3764 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pItemNum);
3765 dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
3766 v18 = (149 - all_text_height) / v114;
3767 if ( (149 - all_text_height) / v114 > 32 )
3768 v18 = 32;
3769 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
3770 v105 = (149 - v114 * v18 - all_text_height) / 2 - v18 / 2 + 162;
3771 if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton )
3772 {
3773 pItemNum = 2;
3774 do
3775 {
3776 pButton = pDialogueWindow->GetControl(pItemNum);
3777 v13 = pButton->msg_param - 36;
3778 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v13] || pPlayer->pActiveSkills[v13] )
3779 {
3780 pButton->uW = 0;
3781 pButton->uHeight = 0;
3782 pButton->uY = 0;
3783 }
3784 else
3785 {
3786 pButton->uY = v18 + v105;
3787 pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v13], &dialog_window, 0, 0);
3788 pButton->uHeight = pTextHeight;
3789 v105 = pButton->uY + pTextHeight - 1;
3790 pButton->uW = v105;
3791 pColorText = pColorYellow;
3792 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
3793 pColorText = pColorWhite;
3794 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v13], 3);
3795 }
3796 pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
3797 pItemNum++;
3798 }
3799 while ( pItemNum < pNumActiveItem );
3800 }
3801 return;
3802 }
3803 }
3804 default:
3805 {
3806 return;// (POINT *)dialog_menu_id - 96;
3807 }
3808 }
3809 }
3810
3811 //----- (004BA928) --------------------------------------------------------
3812 void __cdecl ArmorShopDialog()
3813 {
3814 signed int v1; // esi@8
3815 unsigned int v2; // eax@10
3816 ItemGen *v3; // eax@11
3817 char *v5; // ecx@12
3818 char *v6; // eax@13
3819 int v8; // eax@15
3820 signed int v9; // esi@17
3821 unsigned int v10; // eax@19
3822 char *v11; // edi@19
3823 int v12; // ST08_4@20
3824 int v13; // eax@20
3825 char *v15; // ecx@20
3826 char **v16; // edi@22
3827 int all_text_height; // ebx@22
3828 char **v18; // esi@22
3829 int v19; // eax@23
3830 GUIWindow *v20; // ecx@24
3831 int v21; // eax@24
3832 int v22; // edx@24
3833 int v23; // ebx@24
3834 unsigned __int8 v24; // sf@24
3835 GUIButton *pButton; // eax@26
3836 unsigned int v28; // ecx@26
3837 int v29; // edx@26
3838 signed int v31; // esi@31
3839 unsigned int v32; // eax@33
3840 int v33; // eax@34
3841 int v35; // eax@35
3842 char *v36; // edx@36
3843 signed int v38; // esi@42
3844 unsigned int v39; // esi@44
3845 int v40; // eax@44
3846 unsigned int v41; // eax@45
3847 int v42; // eax@47
3848 int v43; // ecx@52
3849 int v46; // eax@54
3850 unsigned int v49; // ecx@56
3851 int v51; // eax@56
3852 int v53; // eax@60
3853 int textureH; // eax@60
3854 signed int textureW; // ebx@65
3855 Texture *v56; // eax@67
3856 unsigned int pY_item; // edi@68
3857 Texture *v58; // ST1C_4@68
3858 int v59; // eax@68
3859 int v60; // edi@69
3860 signed int v61; // ebx@73
3861 Texture *v62; // eax@75
3862 int v63; // edi@76
3863 Texture *v64; // ST1C_4@76
3864 unsigned int v65; // ST18_4@76
3865 int v66; // eax@76
3866 int v67; // edi@77
3867 signed int v68; // ecx@81
3868 const char *pStatusText; // ecx@91
3869 void *v72; // eax@95
3870 POINT *v73; // esi@97
3871 int v74; // ecx@97
3872 int v75; // eax@98
3873 int v76; // ecx@98
3874 ItemGen *selected_item; // ecx@99
3875 unsigned __int8 v78; // bl@104
3876 int v80; // ebx@105
3877 char **v81; // esi@105
3878 int v82; // eax@106
3879 int v86; // ebx@107
3880 int pTextHeight; // eax@109
3881 unsigned int v90; // ecx@109
3882 int pNumString; // edx@109
3883 unsigned __int16 pTextColor; // ax@109
3884 signed int v93; // edx@114
3885 POINT *v94; // edi@120
3886 __int32 v95; // ecx@120
3887 void *v96; // ST14_4@122
3888 unsigned __int8 v97; // bl@122
3889 ItemGen *v98; // ST10_4@122
3890 int v99; // eax@122
3891 char *v100; // eax@122
3892 const char *v101; // ST18_4@122
3893 unsigned __int16 v102; // ST14_2@122
3894 int v103; // eax@122
3895 signed int v104; // edi@123
3896 Texture *v105; // eax@125
3897 int v106; // ebx@126
3898 unsigned int v108; // ST18_4@126
3899 int v109; // eax@126
3900 int v110; // ebx@127
3901 GUIWindow *v111; // [sp-18h] [bp-11Ch]@36
3902 unsigned int v112; // [sp-14h] [bp-118h]@13
3903 int v113; // [sp-14h] [bp-118h]@36
3904 unsigned int v115; // [sp-10h] [bp-114h]@13
3905 ItemGen *v116; // [sp-10h] [bp-114h]@20
3906 int v117; // [sp-10h] [bp-114h]@36
3907 unsigned __int16 v119; // [sp-Ch] [bp-110h]@13
3908 char *v121; // [sp-8h] [bp-10Ch]@13
3909 int v122; // [sp-8h] [bp-10Ch]@20
3910 unsigned int v123; // [sp-4h] [bp-108h]@13
3911 __int64 *v124; // [sp-4h] [bp-108h]@20
3912 int v125; // [sp-4h] [bp-108h]@68
3913 int v126; // [sp-4h] [bp-108h]@76
3914 int v127; // [sp-4h] [bp-108h]@126
3915 POINT v128; // [sp+Ch] [bp-F8h]@8
3916 POINT v129; // [sp+14h] [bp-F0h]@18
3917 char v130; // [sp+1Ch] [bp-E8h]@120
3918 POINT a2; // [sp+24h] [bp-E0h]@8
3919 POINT v132; // [sp+2Ch] [bp-D8h]@120
3920 POINT v133; // [sp+34h] [bp-D0h]@17
3921 POINT v134; // [sp+3Ch] [bp-C8h]@97
3922 POINT v135; // [sp+44h] [bp-C0h]@31
3923 POINT v136; // [sp+4Ch] [bp-B8h]@97
3924 POINT v137; // [sp+54h] [bp-B0h]@17
3925 POINT v138; // [sp+5Ch] [bp-A8h]@32
3926 POINT v139; // [sp+64h] [bp-A0h]@17
3927 POINT v140; // [sp+6Ch] [bp-98h]@31
3928 POINT v141; // [sp+74h] [bp-90h]@8
3929 POINT v142; // [sp+7Ch] [bp-88h]@31
3930 POINT v143; // [sp+84h] [bp-80h]@9
3931 GUIWindow dialog_window; // [sp+8Ch] [bp-78h]@1
3932 int v146; // [sp+E4h] [bp-20h]@24
3933 int pYellowColor; // [sp+E8h] [bp-1Ch]@1
3934 int pWhiteColor; // [sp+ECh] [bp-18h]@1
3935 __int32 pItemCount; // [sp+F0h] [bp-14h]@8
3936 int v152; // [sp+FCh] [bp-8h]@24
3937 int v153; // [sp+100h] [bp-4h]@44
3938 int th;
3939 short text_color;
3940 int pActiveButton;
3941
3942 memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window));
3943 dialog_window.uFrameX = 483;
3944 dialog_window.uFrameWidth = 148;
3945 dialog_window.uFrameZ = 334;
3946 pWhiteColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
3947 pYellowColor = TargetColor(0xE1u, 0xCDu, 0x23u);
3948 switch (dialog_menu_id)
3949 {
3950 case HOUSE_DIALOGUE_MAIN:
3951 {
3952 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
3953 return;
3954 pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; //"Buy Standard"
3955 pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; //"Buy Special"
3956 pShopOptions[2] = pGlobalTXT_LocalizationStrings[159]; //"Display Inventory"
3957 pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
3958 all_text_height = 0;
3959 for( int i = 0; i < 4; ++i )
3960 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
3961 v146 = ( 174 - all_text_height ) / 4;
3962 v23 = ( 174 - 4 * ( 174 - all_text_height ) / 4 - all_text_height ) / 2 - ( 174 - all_text_height ) / 4 / 2 + 138;
3963 pNumString = 0;
3964 if ( pDialogueWindow->pNumPresenceButton>=0 )
3965 {
3966 for (pActiveButton = pDialogueWindow->pStartingPosActiveItem; pActiveButton < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++pActiveButton)
3967 {
3968 pButton = pDialogueWindow->GetControl(pActiveButton);
3969 pButton->uY = v146 + v23;
3970 pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0);
3971 pButton->uHeight = pTextHeight;
3972 v23 = pButton->uY + pButton->uHeight - 1;
3973 pButton->uW = v23;
3974 pTextColor = pYellowColor;
3975 if ( pDialogueWindow->pCurrentPosActiveItem != pActiveButton )
3976 pTextColor = pWhiteColor;
3977 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[pNumString], 3);
3978 ++pNumString;
3979 }
3980 }
3981 }
3982 break;
3983 case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
3984 {
3985 pRenderer->DrawTextureIndexed(8, 8, ShopTexture);// ïîäëîæêà
3986 textureW = 0;
3987 v153 = 0;
3988 for ( int i = 0; i < 8; ++i )// ðàçìåñòèòü âåùè
3989 {
3990 if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID)
3991 {
3992 textureW = ItemsInShopTexture[i]->uTextureWidth;
3993 textureH = ItemsInShopTexture[i]->uTextureHeight;
3994 if ( i >= 4 ) //low row
3995 {
3996 v60 = 90 - (textureW/2);
3997 pRenderer->DrawTextureTransparent(v60 + v153 - 420, 126, ItemsInShopTexture[i]);
3998 v59 = v60 + v153 + 80220;
3999 }
4000 else
4001 {
4002 pY_item = 98 - textureH;
4003 v152 = 86 - (textureW/2);
4004 pRenderer->DrawTextureTransparent(v152 + v153, pY_item, ItemsInShopTexture[i]);
4005 v59 = v153 + v152 + 640 * pY_item;
4006 }
4007 ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v59], ItemsInShopTexture[i], i + 1);
4008 }
4009 v153 += 105;
4010 }
4011 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
4012 return;
4013 pItemCount = 0;
4014 for ( int i = 0; i < 8; ++i )
4015 {
4016 if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID )
4017 ++pItemCount;
4018 }
4019 if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 )
4020 pStatusText = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy"
4021 else
4022 pStatusText = pGlobalTXT_LocalizationStrings[185];//"Steal item"
4023 DrawTextAtStatusBar(pStatusText, 0);
4024 if ( pItemCount != 0 )
4025 {
4026 v73 = pMouse->GetCursorPos(&v136);
4027 v74 = pRenderer->pActiveZBuffer[v73->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v134)->y]] & 0xFFFF;
4028 if ( !v74 )
4029 return;
4030 pItemCount = v74 - 1;
4031 selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74-1];
4032 if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0)
4033 v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)];
4034 else
4035 v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24"
4036 v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
4037 v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138;
4038 dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3);
4039 return;
4040 }
4041 dialog_window.DrawCurrentTime( pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed);
4042 return;
4043 }
4044 break;
4045 case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
4046 {
4047 pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
4048 v11 = 0;
4049 v61 = 0;
4050 v153 = 0;
4051 do
4052 {
4053 if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v61].uItemID)
4054 {
4055 v62 = ItemsInShopTexture[v61];
4056 if ( v61 >= 4 )
4057 {
4058 v67 = 90 - ((signed int)v62->uTextureWidth >> 1);
4059 pRenderer->DrawTextureTransparent(v153 + v67 - 420, 0x7Eu, ItemsInShopTexture[v61]);
4060 v66 = v153 + v67 + 80220;
4061 }
4062 else
4063 {
4064 v63 = 98 - v62->uTextureHeight;
4065 v64 = ItemsInShopTexture[v61];
4066 v65 = 98 - v62->uTextureHeight;
4067 v152 = 86 - ((signed int)v62->uTextureWidth >> 1);
4068 pRenderer->DrawTextureTransparent(v152 + v153, v65, v64);
4069 v66 = v152 + v153 + 640 * v63;
4070 }
4071 ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v66], ItemsInShopTexture[v61], v61 + 1);
4072 }
4073 v153 += 105;
4074 ++v61;
4075 }
4076 while ( v61 < 8 );
4077 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
4078 return;
4079 v68 = 0;
4080 pItemCount = 0;
4081 do
4082 {
4083 if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][(signed int)v68].uItemID)
4084 ++pItemCount;
4085 ++v68;
4086 }
4087 while ( v68 < 6 );
4088 if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 )
4089 pStatusText = pGlobalTXT_LocalizationStrings[196]; //Select the Special Item to Buy"
4090 else
4091 pStatusText = pGlobalTXT_LocalizationStrings[185];
4092 DrawTextAtStatusBar(pStatusText, 0);
4093 if ( (char *)pItemCount != 0 )
4094 {
4095 v73 = pMouse->GetCursorPos(&v136);
4096 v74 = pRenderer->pActiveZBuffer[v73->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v134)->y]] & 0xFFFF;
4097 if ( !v74 )
4098 return;
4099 pItemCount = v74 - 1;
4100 if ( dialog_menu_id == 2 )
4101 selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74 - 1];
4102 else
4103 selected_item = &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v74 - 1];
4104 if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 )
4105 v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)];
4106 else
4107 v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24"
4108 v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
4109 v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138;
4110 dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3);
4111 return;
4112 }
4113 dialog_window.DrawCurrentTime( pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed);
4114 return;
4115 }
4116 break;
4117 case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
4118 {
4119 draw_leather();
4120 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
4121 pShopOptions[0] = pGlobalTXT_LocalizationStrings[200]; //"Sell"
4122 pShopOptions[1] = pGlobalTXT_LocalizationStrings[113]; //"Identify"
4123 pShopOptions[2] = pGlobalTXT_LocalizationStrings[179]; //"Repair"
4124 all_text_height = 0;
4125 for ( int i = 0; i < 3; ++i )
4126 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
4127 v152 = (174 - all_text_height) / 3;
4128 v86 = (3 * (58 - v152) - all_text_height) / 2 - v152 / 2 + 138;
4129 v24 = -pDialogueWindow->pNumPresenceButton < 0;
4130 pActiveButton = pDialogueWindow->pStartingPosActiveItem;
4131 if ( v24 ^ (pDialogueWindow->pStartingPosActiveItem > pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton) )
4132 {
4133 pNumString = 0;
4134 do
4135 {
4136 pButton = pDialogueWindow->GetControl((unsigned int)pActiveButton);
4137 pButton->uY = v152 + v86;
4138 pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0);
4139 v90 = pButton->uY;
4140 pButton->uHeight = pTextHeight;
4141 v86 = v90 + pTextHeight - 1;
4142 pButton->uW = v86;
4143 pTextColor = pYellowColor;
4144 if ( pDialogueWindow->pCurrentPosActiveItem != pActiveButton )
4145 pTextColor = pWhiteColor;
4146 dialog_window.DrawTitleText(pFontArrus, 0, v90, pTextColor, pShopOptions[pNumString], 3);
4147 ++pNumString;
4148 ++pActiveButton;
4149 }
4150 while ( (signed int)pActiveButton < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
4151 }
4152 return;
4153 }
4154 break;
4155 case HOUSE_DIALOGUE_SHOP_SELL:
4156 {
4157 draw_leather();
4158 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
4159 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);//"Select the Item to Sell"
4160 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
4161 return;
4162 if((v9 = pMouse->GetCursorPos(&v139)->x - 14, pItemCount = (v9 >> 5) + 14 * ((pMouse->GetCursorPos(&v133)->y - 17) >> 5),
4163 pMouse->GetCursorPos(&v137)->x <= 13) || pMouse->GetCursorPos(&v129)->x >= 462
4164 || (v10 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v10) )
4165 return;
4166 v116 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v10 - 1];
4167 v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3);
4168 v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3)];
4169 v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0);
4170 v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138;
4171 dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3);
4172 return;
4173 }
4174 break;
4175 case HOUSE_DIALOGUE_SHOP_IDENTIFY:
4176 {
4177 draw_leather();
4178 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
4179 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); //"Select the Item to Identify"
4180 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
4181 {
4182 v1 = pMouse->GetCursorPos(&a2)->x - 14;
4183 pItemCount = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v128)->y - 17) >> 5);
4184 if ( pMouse->GetCursorPos(&v141)->x > 13 )
4185 {
4186 if ( pMouse->GetCursorPos(&v143)->x < 462 )
4187 {
4188 v2 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount);
4189 if ( v2 )
4190 {
4191 v3 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v2-1];
4192 if (v3->Identified())
4193 v5 = "%24";
4194 else
4195 {
4196 v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v3, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 4);
4197 v5 = (char *)pMerchantsIdentifyPhrases[v8];
4198 }
4199 v6 = BuilDialogueString(v5, uActiveCharacter - 1, v3, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
4200 v115 = (174 - pFontArrus->CalcTextHeight(v6, &dialog_window, 0, 0)) / 2 + 138;
4201 dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v6, 3);
4202 return;
4203 }
4204 }
4205 }
4206 }
4207 }
4208 break;
4209 case HOUSE_DIALOGUE_SHOP_REPAIR:
4210 {
4211 draw_leather();
4212 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
4213 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);
4214 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
4215 return;
4216 if( (v31 = pMouse->GetCursorPos(&v135)->x - 14,
4217 pItemCount = (v31 >> 5) + 14 * ((pMouse->GetCursorPos(&v142)->y - 17) >> 5),
4218 pMouse->GetCursorPos(&v140)->x <= 13)
4219 || pMouse->GetCursorPos(&v138)->x >= 462
4220 || (v32 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v32)
4221 || (!(pPlayers[uActiveCharacter]->pOwnItems[v32-1].uAttributes& 2)) )
4222 return;
4223 v116 = &pPlayers[uActiveCharacter]->pInventoryItems[v33 - 1];
4224 v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItems[v32 - 1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 5);
4225 v15 = (char *)pMerchantsRepairPhrases[v35];
4226 v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0);
4227 v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138;
4228 dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3);
4229 return;
4230 }
4231 break;
4232 case HOUSE_DIALOGUE_SHOP_6: //buy standart ???
4233 {
4234 pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
4235 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0); //"Select the Item to Buy"
4236 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
4237 return;
4238 pItemCount = 0;
4239 for( int i = 0; i < 6 ; ++i )
4240 if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][i].uItemID)
4241 ++pItemCount;
4242 if ( pItemCount )
4243 {
4244 v94 = pMouse->GetCursorPos(&v132);
4245 pItemCount = pRenderer->pActiveZBuffer[v94->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v130)->y]];
4246 v95 = pItemCount;
4247 if ( pItemCount && pItemCount != -65536 )
4248 {
4249 --pItemCount;
4250 v97 = uActiveCharacter - 1;
4251 v99 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 2);
4252 v100 = BuilDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, v98, (char *)window_SpeakInHouse->par1C, 2, 0);
4253 v103 = pFontArrus->CalcTextHeight(v100, &dialog_window, 0, 0);
4254 dialog_window.DrawTitleText(pFontArrus, 0, (174 - v103) / 2 + 138, pWhiteColor, v100, 3);
4255 }
4256 v104 = 0;
4257 v153 = 0;
4258 do
4259 {
4260 //if ( pParty->field_C59C[9 * (v104 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
4261 if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v104].uItemID)
4262 {
4263 v105 = ItemsInShopTexture[v104];
4264 if ( v104 >= 4 )
4265 {
4266 v110 = 90 - ((signed int)v105->uTextureWidth >> 1);
4267 pRenderer->DrawTextureTransparent(v153 + v110 - 420, 0x7Eu, ItemsInShopTexture[v104]);
4268 v127 = v104 + 1;
4269 v109 = v153 + v110 + 80220;
4270 }
4271 else
4272 {
4273 v106 = 98 - v105->uTextureHeight;
4274 v108 = 98 - v105->uTextureHeight;
4275 v152 = 86 - ((signed int)v105->uTextureWidth >> 1);
4276 pRenderer->DrawTextureTransparent(v152 + v153, v108, ItemsInShopTexture[v104]);
4277 v127 = v104 + 1;
4278 v109 = v152 + v153 + 640 * v106;
4279 }
4280 ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v109], ItemsInShopTexture[v104], v127);
4281 }
4282 v153 += 105;
4283 ++v104;
4284 }
4285 while ( v104 < 8 );
4286 return;
4287 }
4288 dialog_window.DrawCurrentTime(pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed);
4289 return;
4290 }
4291 break;
4292 case HOUSE_DIALOGUE_LEARN_SKILLS:
4293 {
4294 if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
4295 return;
4296 v152 = 0;
4297 v38 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
4298 pActiveButton = v38 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
4299 if ( (signed int)pActiveButton < v38 / 3 )
4300 pActiveButton = v38 / 3;
4301 v39 = pDialogueWindow->pStartingPosActiveItem;
4302 v40 = pDialogueWindow->pNumPresenceButton;
4303 v153 = 0;
4304 if ( (signed int)v39 < (signed int)(v39 + v40) )
4305 {
4306 do
4307 {
4308 v41 = pDialogueWindow->GetControl(v39)->msg_param - 36;
4309 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v41] && !pPlayers[uActiveCharacter]->pActiveSkills[v41] )
4310 {
4311 v42 = pFontArrus->CalcTextHeight(pSkillNames[v41], &dialog_window, 0, 0);
4312 v152 += v42;
4313 ++v153;
4314 }
4315 ++v39;
4316 }
4317 while ( (signed int)v39 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
4318 if ( v153 )
4319 {
4320 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pActiveButton);
4321 dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
4322 pActiveButton = (149 - v152) / v153;
4323 if ( (149 - v152) / v153 > 32 )
4324 pActiveButton = 32;
4325 v43 = (149 - v153 * (signed int)pActiveButton - v152) / 2 - (signed int)pActiveButton / 2 + 162;
4326 v152 = pDialogueWindow->pStartingPosActiveItem;
4327 v146 = v43;
4328 if ( v152 < v152 + pDialogueWindow->pNumPresenceButton )
4329 {
4330 v153 = 2;
4331 do
4332 {
4333 pButton = pDialogueWindow->GetControl(v152);
4334 v46 = pButton->msg_param - 36;
4335 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v46] || pPlayers[uActiveCharacter]->pActiveSkills[v46] )
4336 {
4337 pButton->uW = 0;
4338 pButton->uHeight = 0;
4339 pButton->uY = 0;
4340 }
4341 else
4342 {
4343 pButton->uY = (unsigned int)((char *)pActiveButton + v146);
4344 pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v46], &dialog_window, 0, 0);
4345 v49 = pButton->uY;
4346 pButton->uHeight = pTextHeight;
4347 v51 = v49 + pTextHeight - 1;
4348 pButton->uW = v51;
4349 v146 = v51;
4350 pTextColor = pYellowColor;
4351 if ( pDialogueWindow->pCurrentPosActiveItem != v153 )
4352 pTextColor = pWhiteColor;
4353 dialog_window.DrawTitleText(pFontArrus, 0, v49, pTextColor, pSkillNames[v46], 3);
4354 }
4355 v53 = pDialogueWindow->pStartingPosActiveItem;
4356 ++v152;
4357 textureH = pDialogueWindow->pNumPresenceButton + v53;
4358 ++v153;
4359 }
4360 while ( v152 < textureH );
4361 }
4362 return;
4363 }
4364 }
4365 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); //"Seek knowledge elsewhere %s the %s"
4366 strcat(pTmpBuf.data(), "\n \n");
4367 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
4368 v115 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138;
4369 dialog_window.DrawTitleText(pFontArrus, 0, v115, pYellowColor, pTmpBuf.data(), 3);
4370 return;
4371 }
4372 break;
4373 }
4374 }
4375
4376 //----- (004B5D7C) --------------------------------------------------------
4377 void GuildDialog()
4378 {
4379 signed int base_teach_price; // ebx@1
4380 int v3; // edi@6
4381 int result; // eax@11
4382 int v6; // esi@13
4383 signed int v7; // esi@17
4384 int v8; // esi@22
4385 signed int v9; // ecx@22
4386 char *v10; // eax@22
4387 const char *statusbar_string; // ecx@26
4388 POINT *v12; // esi@30
4389 int v13; // ecx@30
4390 void *v14; // ST1C_4@31
4391 ItemGen *v15; // ST18_4@31
4392 int v16; // ST10_4@31
4393 int v17; // eax@31
4394 char *v18; // edx@31
4395 int v19; // eax@32
4396 int pActiveItem; // esi@35
4397 int v22; // eax@35
4398 unsigned int v23; // eax@36
4399 int v24; // eax@39
4400 int v25; // eax@40
4401 int v26; // ecx@47
4402 GUIButton *pButton; // eax@49
4403 unsigned int v29; // eax@49
4404 char *pText; // eax@52
4405 int pTextHeight; // eax@55
4406 unsigned int v32; // ecx@55
4407 int v33; // eax@55
4408 unsigned __int16 pTextColor; // ax@55
4409 int v35; // eax@58
4410 const char *v36; // ST20_4@61
4411 unsigned __int16 v37; // ST1C_2@61
4412 int v38; // eax@61
4413 int v40; // [sp-14h] [bp-300h]@31
4414 int v41; // [sp-10h] [bp-2FCh]@31
4415 unsigned __int16 v42; // [sp-Ch] [bp-2F8h]@31
4416 char *v43; // [sp-8h] [bp-2F4h]@31
4417 unsigned int v44; // [sp-4h] [bp-2F0h]@31
4418 char Dest[100]; // [sp+Ch] [bp-2E0h]@3
4419 char v46[100]; // [sp+70h] [bp-27Ch]@3
4420 char v47[100]; // [sp+D4h] [bp-218h]@3
4421 char v48[100]; // [sp+138h] [bp-1B4h]@3
4422 char v49[100]; // [sp+19Ch] [bp-150h]@3
4423 POINT v50; // [sp+264h] [bp-88h]@30
4424 POINT v51; // [sp+26Ch] [bp-80h]@30
4425 GUIWindow working_window; // [sp+274h] [bp-78h]@1
4426 signed int v53; // [sp+27Ch] [bp-70h]@1
4427 signed int v54; // [sp+284h] [bp-68h]@1
4428 int pColorWhite; // [sp+2CCh] [bp-20h]@1
4429 int pColorYellow; // [sp+2D0h] [bp-1Ch]@1
4430 int v58; // [sp+2D4h] [bp-18h]@1
4431 unsigned __int8 uPlayerID; // [sp+2DBh] [bp-11h]@31
4432 bool pSkillFlag; // [sp+2DCh] [bp-10h]@35
4433 int v61; // [sp+2E0h] [bp-Ch]@35
4434 int pItemNum;
4435 unsigned int v62; // [sp+2E4h] [bp-8h]@13
4436 int v63; // [sp+2E8h] [bp-4h]@1
4437 int pNumActivItem;
4438 int all_text_height;
4439
4440 memcpy(&working_window, window_SpeakInHouse, sizeof(GUIWindow));
4441 working_window.uFrameX = 483;
4442 working_window.uFrameWidth = 148;
4443 working_window.uFrameZ = 334;
4444 pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
4445 pColorYellow = TargetColor(0xFFu, 0xFFu, 0x9Bu);
4446 base_teach_price = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * 500.0);
4447 v63 = base_teach_price * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
4448 if ( v63 < base_teach_price / 3 )
4449 v63 = base_teach_price / 3;
4450 strcpy(Dest, "");
4451 strcpy(v46, "");
4452 strcpy(v47, "");
4453 strcpy(v48, "");
4454 strcpy(v49, "");
4455 if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN )
4456 {
4457 if ( dialog_menu_id != HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) //buy skill
4458 {
4459 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
4460 {
4461 if ( pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] )
4462 {
4463 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[403], pClassNames[dialog_menu_id - 16]); //"You already know the %s skill"
4464 ShowStatusBarString(pTmpBuf.data(), 2);
4465 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
4466 }
4467 else
4468 {
4469 if ( pParty->uNumGold < v63 )
4470 {
4471 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); //"You don't have enough gold"
4472 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
4473 }
4474 else
4475 {
4476 Party::TakeGold(v63);
4477 pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] = 1;
4478 }
4479 }
4480 }
4481 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
4482 return;
4483 }
4484 pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
4485 v6 = 0;
4486 v62 = 0;
4487 v63 = 32;
4488 do
4489 {
4490 if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v6].uItemID)
4491 {
4492 pRenderer->DrawTextureTransparent(v63, 0x5Au, ItemsInShopTexture[v6]);
4493 ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), ItemsInShopTexture[v6], v6 + 1);
4494 }
4495 v63 += 70;
4496 v62 += 280;
4497 ++v6;
4498 }
4499 while ( v63 < 452 );
4500 v62 = 1680;
4501 v7 = 6;
4502 v63 = 32;
4503 do
4504 {
4505 if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v7].uItemID)
4506 {
4507 pRenderer->DrawTextureTransparent(v63, 0xFAu, ItemsInShopTexture[v7]);
4508 ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 638448), ItemsInShopTexture[v7], v7 + 1);
4509 }
4510 v63 += 70;
4511 v62 += 280;
4512 ++v7;
4513 }
4514 while ( v63 < 452 );
4515 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
4516 {
4517 v8 = 0;
4518 v9 = 12;
4519 do
4520 {
4521 if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v9].uItemID )
4522 ++v8;
4523 --v9;
4524 }
4525 while ( v9 );
4526 GetAsyncKeyState(17);
4527 statusbar_string = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy"
4528 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
4529 statusbar_string = pGlobalTXT_LocalizationStrings[196]; //"Select the Special Item to Buy"
4530 DrawTextAtStatusBar(statusbar_string, 0);
4531 if ( !v8 )
4532 {
4533 working_window.DrawCurrentTime(__PAIR__( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)window_SpeakInHouse->ptr_1C + 44472],
4534 *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)window_SpeakInHouse->ptr_1C + 44468]) - pParty->uTimePlayed);
4535 return;
4536 }
4537 v12 = pMouse->GetCursorPos(&v51);
4538 result = v12->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v50)->y];
4539 v13 = pRenderer->pActiveZBuffer[result] & 0xFFFF;
4540 if ( pRenderer->pActiveZBuffer[result] & 0xFFFF )
4541 {
4542 v14 = window_SpeakInHouse->ptr_1C;
4543 v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)v14));
4544 v16 = (int)window_SpeakInHouse->ptr_1C;
4545 uPlayerID = uActiveCharacter - 1;
4546 v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, BildingType_MagicShop, v16, 2);
4547 v18 = BuilDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0);
4548 v19 = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0);
4549 working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorWhite, v18, 3);
4550 return;
4551 }
4552 }
4553 return;
4554 }
4555 if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_guilds_member_bits,
4556 guild_mambership_flags[(unsigned int)window_SpeakInHouse->ptr_1C-139]) )
4557 { //you must me member
4558 v38 = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &working_window, 0, 0);
4559 working_window.DrawTitleText(pFontArrus, 0, (212 - v38) / 2 + 101, pColorYellow, pNPCTopics[121].pText, 3u);
4560 pDialogueWindow->pNumPresenceButton = 0;
4561 return;
4562 }
4563 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
4564 return;
4565 v61 = 0;
4566 pSkillFlag = false;
4567 pActiveItem = pDialogueWindow->pStartingPosActiveItem;
4568 v22 = pActiveItem + pDialogueWindow->pNumPresenceButton;
4569 pItemNum = 0;
4570 if ( pDialogueWindow->pStartingPosActiveItem >= pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
4571 {
4572 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s"
4573 strcat(pTmpBuf.data(), "\n \n");
4574 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
4575 v19 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0);
4576 working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorYellow, pTmpBuf.data(), 3);
4577 return;
4578 }
4579 all_text_height = 0;
4580 do
4581 {
4582 v23 = pDialogueWindow->GetControl(pActiveItem)->msg_param;
4583 if ( v23 == 18 )
4584 {
4585 all_text_height += pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &working_window, 0, 0); //"Buy Spells"
4586 v61++;
4587 }
4588 else
4589 {
4590 if( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v23 - 36]
4591 && !pPlayers[uActiveCharacter]->pActiveSkills[v23 - 36] )
4592 {
4593 all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v23 - 36], &working_window, 0, 0);
4594 v61++;
4595 pSkillFlag = true;
4596 }
4597 }
4598 ++pActiveItem;
4599 }
4600 while ( pActiveItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
4601 if ( !v61 )
4602 {
4603 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s"
4604 strcat(pTmpBuf.data(), "\n \n");
4605 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
4606 v19 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0);
4607 working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorYellow, pTmpBuf.data(), 3);
4608 return;
4609 }
4610 if ( pSkillFlag )
4611 {
4612 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v63); //"Skill Cost: %lu"
4613 working_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
4614 }
4615 v58 = (149 - all_text_height) / v61;
4616 if ( v58 > 32 )
4617 v58 = 32;
4618 v26 = (149 - v61 * v58 - all_text_height) / 2 - v58 / 2 + 162;
4619 pNumActivItem = pDialogueWindow->pStartingPosActiveItem;
4620 if (pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
4621 {
4622 pItemNum = 2;
4623 do
4624 {
4625 pButton = pDialogueWindow->GetControl(pItemNum);
4626 v29 = pButton->msg_param;
4627 if ( v29 == 18 )
4628 {
4629 pText = pGlobalTXT_LocalizationStrings[400]; //"Buy Spells"
4630 pButton->uY = v58 + v26;
4631 pTextHeight = pFontArrus->CalcTextHeight(pText, &working_window, 0, 0);
4632 v32 = pButton->uY;
4633 pButton->uHeight = pTextHeight;
4634 v33 = v32 + pTextHeight - 1;
4635 pButton->uW = v33;
4636 v26 = v33;
4637 pTextColor = pColorYellow;
4638 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
4639 pTextColor = pColorWhite;
4640 working_window.DrawTitleText(pFontArrus, 0, v32, pTextColor, pText, 3);
4641 }
4642 else
4643 {
4644 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v29 - 36]
4645 && !pPlayers[uActiveCharacter]->pActiveSkills[v29 - 36] )
4646 {
4647 pButton->uY = v58 + v26;
4648 pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v29 - 36], &working_window, 0, 0);
4649 v32 = pButton->uY;
4650 pButton->uHeight = pTextHeight;
4651 v33 = v32 + pTextHeight - 1;
4652 pButton->uW = v33;
4653 v26 = v33;
4654 pTextColor = pColorYellow;
4655 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
4656 pTextColor = pColorWhite;
4657 working_window.DrawTitleText(pFontArrus, 0, v32, pTextColor, pSkillNames[v29 - 36], 3);
4658 }
4659 else
4660 {
4661 pButton->uW = 0;
4662 pButton->uHeight = 0;
4663 pButton->uY = 0;
4664 }
4665 }
4666 ++pItemNum;
4667 }
4668 while ( pItemNum < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
4669 }
4670 return;
4671 } 2678 }
4672 2679
4673 //----- (004B705E) -------------------------------------------------------- 2680 //----- (004B705E) --------------------------------------------------------
4674 void TempleDialog() 2681 void TempleDialog()
4675 { 2682 {
5423 } 3430 }
5424 } 3431 }
5425 } 3432 }
5426 } 3433 }
5427 3434
5428 //----- (004B4FCF) --------------------------------------------------------
5429 void MagicShopDialog()
5430 {
5431 int result; // eax@6
5432 signed int v2; // esi@8
5433 unsigned int v3; // ebx@10
5434 char *v4; // eax@11
5435 char *v5; // eax@12
5436 unsigned int v6; // eax@12
5437 int v7; // ST08_4@14
5438 int v8; // eax@14
5439 unsigned __int8 v9; // dl@14
5440 char *v10; // ecx@14
5441 signed int v11; // esi@16
5442 int v12; // ST08_4@19
5443 int v13; // eax@19
5444 int all_text_height; // edi@21
5445 char **v15; // esi@21
5446 int v16; // eax@22
5447 int v18; // edx@23
5448 int v19; // edi@23
5449 unsigned __int8 v20; // sf@23
5450 GUIButton *control_button; // esi@25
5451 const char **v22; // eax@25
5452 int v23; // eax@25
5453 unsigned int v24; // ecx@25
5454 const char **v25; // edx@25
5455 unsigned __int16 text_color; // ax@25
5456 signed int pTextHeight; // esi@30
5457 int v28; // ST08_4@34
5458 int v29; // eax@34
5459 char *v30; // edx@35
5460 void *v32; // eax@40
5461 signed int v33; // esi@40
5462 unsigned int v34; // esi@42
5463 int v35; // eax@42
5464 unsigned int v36; // eax@43
5465 int v37; // eax@45
5466 int v38; // ecx@50
5467 int v41; // eax@52
5468 char *v42; // eax@54
5469 int v43; // eax@54
5470 unsigned int v44; // ecx@54
5471 int v45; // edx@54
5472 int v46; // eax@54
5473 unsigned __int16 v47; // ax@54
5474 int v48; // eax@58
5475 signed int v49; // esi@62
5476 Texture *v50; // ecx@64
5477 unsigned int v51; // edi@64
5478 unsigned int v52; // esi@66
5479 int v53; // edx@70
5480 Texture *v54; // ecx@76
5481 unsigned int v55; // edi@76
5482 unsigned int v56; // esi@76
5483 int v57; // edx@80
5484 unsigned int v59; // edi@86
5485 unsigned int v60; // esi@88
5486 int v61; // edx@92
5487 unsigned int v63; // edi@98
5488 unsigned int v64; // esi@100
5489 int v65; // edx@104
5490 signed int v66; // ecx@109
5491 SHORT v67; // di@117
5492 bool v68; // eax@117
5493 const char *v69; // ecx@119
5494 POINT *v70; // esi@124
5495 int v71; // ecx@125
5496 int v73; // ecx@125
5497 int v75; // eax@130
5498 int v78; // eax@132
5499 int v80; // edx@133
5500 int v81; // edi@133
5501 const char **v83; // eax@135
5502 int v84; // eax@135
5503 unsigned int v85; // ecx@135
5504 int v86; // edx@135
5505 int v89; // [sp-14h] [bp-10Ch]@35
5506 int v91; // [sp-10h] [bp-108h]@35
5507 unsigned __int16 v92; // [sp-Ch] [bp-104h]@12
5508 void *v93; // [sp-Ch] [bp-104h]@14
5509 int v94; // [sp-8h] [bp-100h]@11
5510 char *v95; // [sp-8h] [bp-100h]@12
5511 __int64 *v96; // [sp-4h] [bp-FCh]@11
5512 unsigned int v97; // [sp-4h] [bp-FCh]@12
5513 POINT v98; // [sp+Ch] [bp-ECh]@8
5514 POINT v99; // [sp+14h] [bp-E4h]@16
5515 POINT v100; // [sp+1Ch] [bp-DCh]@124
5516 POINT v101; // [sp+24h] [bp-D4h]@17
5517 POINT v102; // [sp+2Ch] [bp-CCh]@124
5518 POINT v103; // [sp+34h] [bp-C4h]@9
5519 POINT v104; // [sp+3Ch] [bp-BCh]@31
5520 POINT v105; // [sp+44h] [bp-B4h]@16
5521 POINT v106; // [sp+4Ch] [bp-ACh]@30
5522 POINT v107; // [sp+54h] [bp-A4h]@16
5523 POINT v108; // [sp+5Ch] [bp-9Ch]@30
5524 POINT a2; // [sp+64h] [bp-94h]@8
5525 POINT v110; // [sp+6Ch] [bp-8Ch]@30
5526 POINT v111; // [sp+74h] [bp-84h]@8
5527 GUIWindow dialog_window; // [sp+7Ch] [bp-7Ch]@1
5528 char *Str; // [sp+D0h] [bp-28h]@54
5529 int v146; // [sp+D4h] [bp-24h]@23
5530 unsigned int pYellowColor; // [sp+D8h] [bp-20h]@1
5531 unsigned int pWhiteColor; // [sp+DCh] [bp-1Ch]@1
5532 __int32 v117; // [sp+E0h] [bp-18h]@8
5533 int v118; // [sp+E4h] [bp-14h]@40
5534 const char **v119; // [sp+E8h] [bp-10h]@24
5535 int _this; // [sp+ECh] [bp-Ch]@1
5536 unsigned __int8 uPlayerID; // [sp+F3h] [bp-5h]@14
5537 int v152; // [sp+F4h] [bp-4h]@23
5538 int v122;
5539 int v114;
5540 int pSrtingNum;
5541 int pActiveItemNum;
5542 ItemGen *item;
5543
5544 memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window));
5545 dialog_window.uFrameX = 483;
5546 dialog_window.uFrameWidth = 148;
5547 dialog_window.uFrameZ = 334;
5548 pWhiteColor = TargetColor(255, 255, 255);
5549 pYellowColor = TargetColor(225, 205, 35);
5550 if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN)
5551 {
5552 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
5553 return;
5554 pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; //"Buy Standard"
5555 pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; //"Buy Special"
5556 pShopOptions[2] = pGlobalTXT_LocalizationStrings[159]; //"Display Inventory"
5557 pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
5558 all_text_height = 0;
5559 for ( int i = 0; i < 4; ++i )
5560 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
5561 v146 = (174 - all_text_height) / 4;
5562 v23 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138;
5563 int j = 0;
5564 if ( pDialogueWindow->pNumPresenceButton>=0 )
5565 {
5566 int th = 2;
5567 for (v152 = pDialogueWindow->pStartingPosActiveItem; v152 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++v152)
5568 {
5569 control_button = pDialogueWindow->GetControl(v152);
5570 control_button->uY = v146 + v23;
5571 pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[j], &dialog_window, 0, 0);
5572 control_button->uHeight = pTextHeight;
5573 v23 = control_button->uY + control_button->uHeight - 1;
5574 control_button->uW = v23;
5575 text_color = pYellowColor;
5576 if ( pDialogueWindow->pCurrentPosActiveItem != th )
5577 text_color = pWhiteColor;
5578 dialog_window.DrawTitleText(pFontArrus, 0, control_button->uY, text_color, pShopOptions[j], 3);
5579 ++th;
5580 ++j;
5581 }
5582 }
5583 return;
5584 }
5585 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
5586 {
5587 pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
5588 v3 = 0;
5589 v49 = 0;
5590 v122 = 0;
5591 do
5592 {
5593 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID)
5594 {
5595 v50 = ItemsInShopTexture[v49];
5596 v51 = 152 - v50->uTextureHeight;
5597 if ( (signed int)v51 < 1 )
5598 v51 = 0;
5599 v52 = 75 * v49 - v50->uTextureWidth / 2 + 40;
5600 if ( v122 )
5601 {
5602 if ( v122 == 5 )
5603 {
5604 v53 = ItemsInShopTexture[5]->uTextureWidth;
5605 if ( (signed int)v52 > 457 - v53 )
5606 v52 = 457 - v53;
5607 }
5608 }
5609 else
5610 {
5611 if ( (signed int)v52 < 18 )
5612 v52 = 18;
5613 }
5614 pRenderer->DrawTextureTransparent(v52, v51, v50);
5615 sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v122], v122 + 1);
5616 v49 = v122;
5617 }
5618 ++v49;
5619 v122 = v49;
5620 }
5621 while ( v49 < 6 );
5622 v122 = 0;
5623 do
5624 {
5625 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122 + 6].uItemID)
5626 {
5627 v54 = ItemsInShopTexture[v122 + 6];
5628 v55 = 306 - v54->uTextureHeight;
5629 v56 = 75 * v122 - v54->uTextureWidth / 2 + 40;
5630 if ( v122 )
5631 {
5632 if ( v122 == 5 )
5633 {
5634 v57 = ItemsInShopTexture[11]->uTextureWidth;
5635 if ( (signed int)v56 > 457 - v57 )
5636 v56 = 457 - v57;
5637 }
5638 }
5639 else
5640 {
5641 if ( (signed int)v56 < 18 )
5642 v56 = 18;
5643 }
5644 pRenderer->DrawTextureTransparent(v56, v55, v54);
5645 sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v122 + 6], v122 + 7);
5646 }
5647 ++v122;
5648 }
5649 while ( v122 < 6 );
5650 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
5651 {
5652 v66 = 0;
5653 v117 = 0;
5654 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
5655 {
5656 do
5657 {
5658 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID) //9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
5659 ++v117;
5660 ++v66;
5661 }
5662 while ( v66 < 12 );
5663 }
5664 else
5665 {
5666 do
5667 {
5668 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID)
5669 ++v117;
5670 ++v66;
5671 }
5672 while ( v66 < 12 );
5673 }
5674 v67 = GetAsyncKeyState(VK_CONTROL);
5675 v68 = pPlayers[uActiveCharacter]->CanSteal();
5676 Str = (char *)v68;
5677 if ( v67 && v68 )
5678 {
5679 v69 = pGlobalTXT_LocalizationStrings[185];// "Steal item"
5680 }
5681 else
5682 {
5683 v69 = pGlobalTXT_LocalizationStrings[195];// "Select the Item to Buy"
5684 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
5685 v69 = pGlobalTXT_LocalizationStrings[196];// "Select the Special Item to Buy"
5686 }
5687 DrawTextAtStatusBar(v69, 0);
5688 if ( !v117 )
5689 {
5690 dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
5691 return;
5692 }
5693 v70 = pMouse->GetCursorPos(&v102);
5694 result = v70->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v100)->y];
5695 if ( pRenderer->pActiveZBuffer[result] & 0xFFFF )
5696 {
5697 v71 = (pRenderer->pActiveZBuffer[result] & 0xFFFF) - 1;
5698 item = &pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v71];
5699 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
5700 item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v71];
5701 if ( v67 && Str )
5702 v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24"
5703 else
5704 {
5705 v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2);
5706 v10 = (char *)pMerchantsBuyPhrases[v75];
5707 }
5708 v30 = BuilDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
5709 v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138;
5710 dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3);
5711 return;
5712 }
5713 }
5714 return;
5715 }
5716 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL)
5717 {
5718 pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
5719 v3 = 0;
5720 v49 = 0;
5721 v122 = 0;
5722 do
5723 {
5724 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID)
5725 {
5726 v59 = 152 - ItemsInShopTexture[v49]->uTextureHeight;
5727 if ( (signed int)v59 < 1 )
5728 v59 = 0;
5729 v60 = 75 * v49 - ItemsInShopTexture[v49]->uTextureWidth / 2 + 40;
5730 if ( v122 )
5731 {
5732 if ( v122 == 5 )
5733 {
5734 v61 = ItemsInShopTexture[5]->uTextureWidth;
5735 if ( (signed int)v60 > 457 - v61 )
5736 v60 = 457 - v61;
5737 }
5738 }
5739 else
5740 {
5741 if ( (signed int)v60 < 18 )
5742 v60 = 18;
5743 }
5744 pRenderer->DrawTextureTransparent(v60, v59, ItemsInShopTexture[v49]);
5745 sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v122], v122 + 1);
5746 v49 = v122;
5747 }
5748 ++v49;
5749 v122 = v49;
5750 }
5751 while ( v49 < 6 );
5752 v122 = 0;
5753 do
5754 {
5755 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122 + 6].uItemID)
5756 {
5757 v63 = 306 - ItemsInShopTexture[v122 + 6]->uTextureHeight;
5758 if ( (signed int)v63 < 1 )
5759 v63 = 0;
5760 v64 = 75 * v122 - ItemsInShopTexture[v122 + 6]->uTextureWidth / 2 + 40;
5761 if ( v122 )
5762 {
5763 if ( v122 == 5 )
5764 {
5765 v65 = ItemsInShopTexture[11]->uTextureWidth;
5766 if ( (signed int)v64 > 457 - v65 )
5767 v64 = 457 - v65;
5768 }
5769 }
5770 else
5771 {
5772 if ( (signed int)v64 < 18 )
5773 v64 = 18;
5774 }
5775 pRenderer->DrawTextureTransparent(v64, v63, ItemsInShopTexture[v122 + 6]);
5776 sub_40F92A(&pRenderer->pActiveZBuffer[v64 + 640 * v63], ItemsInShopTexture[v122 + 6], v122 + 7);
5777 }
5778 ++v122;
5779 }
5780 while ( v122 < 6 );
5781 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
5782 {
5783 v66 = 0;
5784 v117 = 0;
5785 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
5786 {
5787 do
5788 {
5789 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID) //9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
5790 ++v117;
5791 ++v66;
5792 }
5793 while ( v66 < 12 );
5794 }
5795 else
5796 {
5797 do
5798 {
5799 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID)
5800 ++v117;
5801 ++v66;
5802 }
5803 while ( v66 < 12 );
5804 }
5805 v67 = GetAsyncKeyState(VK_CONTROL);
5806 v68 = pPlayers[uActiveCharacter]->CanSteal();
5807 Str = (char *)v68;
5808 if ( v67 && v68 )
5809 {
5810 v69 = pGlobalTXT_LocalizationStrings[185];// "Steal item"
5811 }
5812 else
5813 {
5814 v69 = pGlobalTXT_LocalizationStrings[195];// "Select the Item to Buy"
5815 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
5816 v69 = pGlobalTXT_LocalizationStrings[196];// "Select the Special Item to Buy"
5817 }
5818 DrawTextAtStatusBar(v69, 0);
5819 if ( !v117 )
5820 {
5821 dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
5822 return;
5823 }
5824 v70 = pMouse->GetCursorPos(&v102);
5825 result = v70->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v100)->y];
5826 if ( pRenderer->pActiveZBuffer[result] & 0xFFFF )
5827 {
5828 v71 = (pRenderer->pActiveZBuffer[result] & 0xFFFF) - 1;
5829 item = &pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v71];
5830 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
5831 item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v71];
5832 if ( v67 && Str )
5833 v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24"
5834 else
5835 {
5836 v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2);
5837 v10 = (char *)pMerchantsBuyPhrases[v75];
5838 }
5839 v30 = BuilDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
5840 v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138;
5841 dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3);
5842 return;
5843 }
5844 }
5845 return;
5846 }
5847 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT )
5848 {
5849 draw_leather();
5850 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
5851 pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];// "Sell"
5852 pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];// "Identify"
5853 pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];// "Repair"
5854 all_text_height = 0;
5855 for ( uint i = 0; i < 3; ++i )
5856 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
5857 _this = ((174 - all_text_height) / 3);
5858 v81 = (3 * (58 - (signed int)_this) - all_text_height) / 2 - (174 - all_text_height) / 3 / 2 + 138;
5859 v20 = -pDialogueWindow->pNumPresenceButton < 0;
5860 v118 = pDialogueWindow->pStartingPosActiveItem;
5861 if ( v20 ^ (pDialogueWindow->pStartingPosActiveItem > pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton) )
5862 {
5863 v122 = 2;
5864 pSrtingNum = 0;
5865 do
5866 {
5867 control_button = pDialogueWindow->GetControl(v118);
5868 control_button->uY = (unsigned int)((char *)_this + v81);
5869 pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[pSrtingNum], &dialog_window, 0, 0);
5870 v85 = control_button->uY;
5871 control_button->uHeight = pTextHeight;
5872 v81 = pTextHeight + v85 - 1;
5873 control_button->uW = v81;
5874 text_color = pYellowColor;
5875 if ( pDialogueWindow->pCurrentPosActiveItem != v122 )
5876 text_color = pWhiteColor;
5877 dialog_window.DrawTitleText(pFontArrus, 0, v85, text_color, pShopOptions[pSrtingNum], 3);
5878 ++v122;
5879 ++pSrtingNum;
5880 ++v118;
5881 }
5882 while ( v118 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
5883 }
5884 return;
5885 }
5886 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_SELL)
5887 {
5888 draw_leather();
5889 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
5890 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);// "Select the Item to Sell"
5891 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()
5892 || (v11 = pMouse->GetCursorPos(&v107)->x - 14,
5893 v117 = (v11 >> 5) + 14 * ((pMouse->GetCursorPos(&v99)->y - 17) >> 5),
5894 result = (int)pMouse->GetCursorPos(&v105),
5895 *(int *)result <= 13)
5896 || (result = (int)pMouse->GetCursorPos(&v101), *(int *)result >= 462)
5897 || (result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result) )
5898 return;
5899 item = &pPlayers[uActiveCharacter]->pInventoryItems[result - 1];
5900 v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 3);
5901 v30 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0);
5902 v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138;
5903 dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3);
5904 return;
5905 }
5906 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_IDENTIFY)
5907 {
5908 draw_leather();
5909 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
5910 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);// "Select the Item to Identify"
5911 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
5912 {
5913 v2 = pMouse->GetCursorPos(&a2)->x - 14;
5914 v117 = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v98)->y - 17) >> 5);
5915 result = (int)pMouse->GetCursorPos(&v111);
5916 if ( *(int *)result > 13 )
5917 {
5918 result = (int)pMouse->GetCursorPos(&v103);
5919 if ( *(int *)result < 462 )
5920 {
5921 result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117);
5922 if ( result )
5923 {
5924 item = &pPlayers[uActiveCharacter]->pInventoryItems[result-1];
5925 if ( item->uAttributes & 1 )
5926 {
5927 v5 = BuilDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
5928 v6 = (212 - pFontArrus->CalcTextHeight(v5, &dialog_window, 0, 0)) / 2 + 101;
5929 dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v5, 3);
5930 return;
5931 }
5932 v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 4);
5933 v30 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v8], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
5934 v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138;
5935 dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v30, 3);
5936 return;
5937 }
5938 }
5939 }
5940 }
5941 return;
5942 }
5943 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_REPAIR)
5944 {
5945 draw_leather();
5946 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
5947 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);// "Select the Item to Repair"
5948 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()
5949 || (pTextHeight = pMouse->GetCursorPos(&v110)->x - 14,
5950 v117 = (pTextHeight >> 5) + 14 * ((pMouse->GetCursorPos(&v108)->y - 17) >> 5),
5951 result = (int)pMouse->GetCursorPos(&v106),
5952 *(int *)result <= 13)
5953 || (result = (int)pMouse->GetCursorPos(&v104), *(int *)result >= 462)
5954 || (result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result)
5955 // || (result *= 9, !(pPlayers[uActiveCharacter]->field_1F5[4 * result + 15] & 2)) )
5956 || (!(pPlayers[uActiveCharacter]->pOwnItems[result-1].uAttributes& 2)) )
5957 return;
5958 item = &pPlayers[uActiveCharacter]->pInventoryItems[result - 1];
5959 v29 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItems[result - 1], BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5);
5960 v30 = BuilDialogueString((char *)pMerchantsRepairPhrases[v29], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0);
5961 v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138;
5962 dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3);
5963 return;
5964 }
5965 if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
5966 {
5967 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
5968 {
5969 v3 = 0;
5970 all_text_height = 0;
5971 v33 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
5972 v119 = (const char **)(v33 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100);
5973 if ( (signed int)v119 < v33 / 3 )
5974 v119 = (const char **)(v33 / 3);
5975 pActiveItemNum = pDialogueWindow->pStartingPosActiveItem;
5976 v122 = 0;
5977 if ( (signed int)pDialogueWindow->pStartingPosActiveItem >= pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
5978 {
5979 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);//
5980 // "Seek knowledge elsewhere %s the %s"
5981 strcat(pTmpBuf.data(), "\n \n");
5982 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
5983 v6 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138;
5984 dialog_window.DrawTitleText(pFontArrus, v3, v6, pYellowColor, pTmpBuf.data(), 3);
5985 return;
5986 }
5987 do
5988 {
5989 v36 = pDialogueWindow->GetControl(pActiveItemNum)->msg_param - 36;
5990 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v36] && !pPlayers[uActiveCharacter]->pActiveSkills[v36] )
5991 {
5992 all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v36], &dialog_window, 0, 0);
5993 ++v122;
5994 }
5995 ++pActiveItemNum;
5996 }
5997 while ( pActiveItemNum < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
5998 if ( !v122 )
5999 {
6000 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);//
6001 // "Seek knowledge elsewhere %s the %s"
6002 strcat(pTmpBuf.data(), "\n \n");
6003 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
6004 v6 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138;
6005 dialog_window.DrawTitleText(pFontArrus, v3, v6, pYellowColor, pTmpBuf.data(), 3);
6006 return;
6007 }
6008 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v119);// "Skill Cost: %lu"
6009 dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3u);
6010 v119 = (const char **)((149 - all_text_height) / v122);
6011 if ( (149 - all_text_height) / v122 > 32 )
6012 v119 = (const char **)32;
6013 v38 = (149 - v122 * (signed int)v119 - all_text_height) / 2 - (signed int)v119 / 2 + 162;
6014 v118 = 2;
6015 if ( pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
6016 {
6017 v122 = 2;
6018 do
6019 {
6020 control_button = pDialogueWindow->GetControl(v122);
6021 v41 = control_button->msg_param - 36;
6022 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v41] || pPlayers[uActiveCharacter]->pActiveSkills[v41] )
6023 {
6024 control_button->uW = 0;
6025 control_button->uHeight = 0;
6026 control_button->uY = 0;
6027 }
6028 else
6029 {
6030 control_button->uY = (unsigned int)((char *)v119 + v38);
6031 pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v41], &dialog_window, 0, 0);
6032 v44 = control_button->uY;
6033 control_button->uHeight = pTextHeight;
6034 v38 = v44 + pTextHeight - 1;
6035 control_button->uW = v38;
6036 text_color = pYellowColor;
6037 if ( pDialogueWindow->pCurrentPosActiveItem != v122 )
6038 text_color = pWhiteColor;
6039 dialog_window.DrawTitleText(pFontArrus, 0, v44, text_color, pSkillNames[v41], 3);
6040 }
6041 ++v122;
6042 }
6043 while ( v122 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
6044 }
6045 }
6046 return;
6047 }
6048 return;
6049 }
6050
6051
6052 //----- (004B6478) -------------------------------------------------------- 3435 //----- (004B6478) --------------------------------------------------------
6053 void sub_4B6478() 3436 void sub_4B6478()
6054 { 3437 {
6055 GUIWindow *v0; // ebx@1 3438 GUIWindow *v0; // ebx@1
6056 Player *v1; // edi@1 3439 Player *v1; // edi@1
6254 } 3637 }
6255 while ( v35 <v29->pNumPresenceButton + v29->pStartingPosActiveItem ); 3638 while ( v35 <v29->pNumPresenceButton + v29->pStartingPosActiveItem );
6256 } 3639 }
6257 return; 3640 return;
6258 } 3641 }
6259 //----- (004B1A2D) -------------------------------------------------------- 3642
6260 void __cdecl ShowPopupShopItem()
6261 {
6262 POINT *v1; // esi@5
6263 unsigned int v2; // eax@5
6264 int v3; // ecx@5
6265 POINT *v4; // esi@12
6266 int v5; // eax@12
6267 unsigned int v6; // eax@13
6268 ItemGen *v7; // ecx@13
6269 signed int v8; // esi@17
6270 unsigned int v9; // eax@19
6271 POINT v10; // [sp+8h] [bp-44h]@12
6272 POINT v11; // [sp+10h] [bp-3Ch]@12
6273 POINT v12; // [sp+18h] [bp-34h]@18
6274 POINT v13; // [sp+20h] [bp-2Ch]@17
6275 POINT v14; // [sp+28h] [bp-24h]@17
6276 POINT v15; // [sp+30h] [bp-1Ch]@17
6277 POINT v16; // [sp+38h] [bp-14h]@5
6278 POINT a2; // [sp+40h] [bp-Ch]@5
6279
6280 if ( in_current_building_type <= 0 )
6281 return;
6282 if ( in_current_building_type <= BildingType_AlchemistShop )
6283 {
6284 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
6285 {
6286 if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
6287 return;
6288 if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_REPAIR || dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT )
6289 {
6290 v8 = pMouse->GetCursorPos(&v15)->x - 14;
6291 v5 = (v8 >> 5) + 14 * ((pMouse->GetCursorPos(&v14)->y - 17) >> 5);
6292 if ( pMouse->GetCursorPos(&v13)->x <= 13
6293 || pMouse->GetCursorPos(&v12)->x >= 462
6294 || (v9 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v5)) == 0 )
6295 return;
6296 GameUI_DrawItemInfo(&pPlayers[uActiveCharacter]->pInventoryItems[v9 - 1]);
6297 return;
6298 }
6299 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL )
6300 return;
6301 }
6302 v4 = pMouse->GetCursorPos(&v11);
6303 v5 = pRenderer->pActiveZBuffer[v4->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v10)->y]] & 0xFFFF;
6304 if ( !v5 )
6305 return;
6306 v6 = 9 * (v5 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C);
6307 v7 = (ItemGen *)((char *)&pParty->pPickedItem + 4 * v6 + 4);
6308 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
6309 v7 = &pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v5 - 1];
6310 GameUI_DrawItemInfo(v7);
6311 return;
6312 }
6313 if ( in_current_building_type <= BildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS )
6314 {
6315 v1 = pMouse->GetCursorPos(&a2);
6316 v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y];
6317 v3 = pRenderer->pActiveZBuffer[v2] & 0xFFFF;
6318 v5 = pRenderer->pActiveZBuffer[v2] & 0xFFFF;
6319 if ( v5 )
6320 sub_4B1523((int *)&pParty->pPlayers[1].uExpressionTimeLength + 9 * (v3 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C));
6321 }
6322 }
6323 //----- (004B1D27) --------------------------------------------------------
6324 void __cdecl sub_4B1D27()
6325 {
6326 int v0; // edx@2
6327 unsigned int v1; // ecx@7
6328 signed int v2; // edi@10
6329 int v3; // esi@10
6330 __int16 v4; // ax@15
6331 signed int v5; // edi@20
6332 int v6; // esi@20
6333 int v7[4]; // [sp+Ch] [bp-10h]@12
6334
6335 if ( in_current_building_type > 0 )
6336 {
6337 v0 = 3;
6338 if ( in_current_building_type > BildingType_MagicShop )
6339 {
6340 if ( in_current_building_type == BildingType_Bank )
6341 {
6342 if ( !dword_F8B1E4 )
6343 return;
6344 }
6345 else
6346 {
6347 if ( in_current_building_type != BildingType_Temple )
6348 return;
6349 }
6350 v1 = (unsigned int)window_SpeakInHouse->ptr_1C;
6351 PlayHouseSound(v1, (HouseSoundID)v0);
6352 return;
6353 }
6354 v1 = (unsigned int)window_SpeakInHouse->ptr_1C;
6355 if ( (signed __int64)pParty->field_3C._shop_ban_times[v1 ]<= (signed __int64)pParty->uTimePlayed )
6356 {
6357 if ( pParty->uNumGold <= 0x2710 )
6358 {
6359 if ( !dword_F8B1E4 )
6360 return;
6361 v0 = 4;
6362 PlayHouseSound(v1, (HouseSoundID)v0);
6363 return;
6364 }
6365 PlayHouseSound(v1, (HouseSoundID)(dword_F8B1E4 + 3));
6366 if ( !dword_F8B1E4 && !qword_A750D8 )
6367 {
6368 v5 = 0;
6369 v6 = 1;
6370 do
6371 {
6372 if ( pPlayers[v6]->CanAct() )
6373 v7[v5++] = v6;
6374 ++v6;
6375 }
6376 while ( v6 <= 4 );
6377 if ( v5 )
6378 {
6379 qword_A750D8 = 256i64;
6380 word_A750E0 = 80;
6381 v4 = LOWORD(v7[rand() % v5]);
6382 word_A750E2 = v4;
6383 return;
6384 }
6385 }
6386 }
6387 else
6388 {
6389 if ( !qword_A750D8 )
6390 {
6391 v2 = 0;
6392 v3 = 1;
6393 do
6394 {
6395 if ( pPlayers[v3]->CanAct() )
6396 v7[v2++] = v3;
6397 ++v3;
6398 }
6399 while ( v3 <= 4 );
6400 if ( v2 )
6401 {
6402 qword_A750D8 = 256i64;
6403 word_A750E0 = 80;
6404 v4 = LOWORD(v7[rand() % v2]);
6405 word_A750E2 = v4;
6406 return;
6407 }
6408 }
6409 }
6410 }
6411 }
6412 //----- (004B2A74) -------------------------------------------------------- 3643 //----- (004B2A74) --------------------------------------------------------
6413 void SimpleHouseAndBoatsDialog() 3644 void SimpleHouseAndBoatsDialog()
6414 { 3645 {
6415 char *v0; // esi@3 3646 char *v0; // esi@3
6416 char *v1; // ST1C_4@3 3647 char *v1; // ST1C_4@3
6728 pRenderer->DrawTextureIndexed(8u, 347 - v48, pTexture_591428); 3959 pRenderer->DrawTextureIndexed(8u, 347 - v48, pTexture_591428);
6729 v49 = FitTextInAWindow(current_npc_text, v47, &w, 0xDu, 0); 3960 v49 = FitTextInAWindow(current_npc_text, v47, &w, 0xDu, 0);
6730 a1.DrawText(v47, 13, 354 - v48, 0, v49, 0, 0, 0); 3961 a1.DrawText(v47, 13, 354 - v48, 0, v49, 0, 0, 0);
6731 } 3962 }
6732 } 3963 }
6733 //----- (004BDB56) -------------------------------------------------------- 3964 //----- (004B4F4F) --------------------------------------------------------
6734 void __cdecl UIShop_Buy_Identify_Repair() 3965 void JailDialog()
6735 { 3966 {
6736 int v8; // eax@15 3967 const char *v0; // esi@1
6737 unsigned int pItemID; // esi@20 3968 const char *v1; // ST10_4@1
6738 ItemGen *item; // esi@21 3969 unsigned __int16 v2; // ST0C_2@1
6739 unsigned int v15; // eax@33 3970 int v3; // eax@1
6740 POINT *pCursorPos; // esi@37 3971 GUIWindow v5; // [sp+8h] [bp-54h]@1
6741 int v18; // ecx@37 3972
6742 float pPriceMultiplier; // ST1C_4@38 3973 memcpy(&v5, window_SpeakInHouse, sizeof(v5));
6743 int taken_item; // eax@40 3974 v0 = pGlobalTXT_LocalizationStrings[672];
6744 ItemGen *bought_item; // esi@51 3975 v1 = pGlobalTXT_LocalizationStrings[672];
6745 int party_reputation; // eax@55 3976 v5.uFrameX = 483;
6746 int v39; // eax@63 3977 v5.uFrameWidth = 148;
6747 int v42; // esi@74 3978 v5.uFrameZ = 334;
6748 signed int v43; // ebx@74 3979 v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
6749 unsigned __int16 *pSkill; // esi@77 3980 v3 = pFontArrus->CalcTextHeight(v0, &v5, 0, 0);
6750 int v55; // [sp+0h] [bp-B4h]@26 3981 v5.DrawTitleText(pFontArrus, 0, (310 - v3) / 2 + 18, v2, v1, 3u);
6751 POINT cursor; // [sp+40h] [bp-74h]@37
6752 int a6; // [sp+98h] [bp-1Ch]@57
6753 int a3; // [sp+9Ch] [bp-18h]@53
6754 unsigned int uNumSeconds; // [sp+A4h] [bp-10h]@53
6755 unsigned int v79; // [sp+A8h] [bp-Ch]@9
6756 int uPriceItemService; // [sp+ACh] [bp-8h]@12
6757
6758 if ( pCurrentScreen == SCREEN_E )
6759 {
6760 OnInventoryLeftClick();
6761 return;
6762 }
6763 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
6764 {
6765 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
6766 return;
6767 }
6768
6769 switch(dialog_menu_id)
6770 {
6771 case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
6772 {
6773 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
6774 OnInventoryLeftClick();
6775 break;
6776 }
6777 case HOUSE_DIALOGUE_GUILD_BUY_BOOKS:
6778 {
6779 pCursorPos = pMouse->GetCursorPos(&cursor);
6780 v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&cursor)->y]] & 0xFFFF;
6781 if ( !v18 )
6782 return;
6783 bought_item = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C));
6784 pPriceMultiplier = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
6785 uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), pPriceMultiplier);
6786 GetAsyncKeyState(VK_CONTROL);
6787 if ( pParty->uNumGold < uPriceItemService )
6788 {
6789 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
6790 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);
6791 return;
6792 }
6793 taken_item = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID);
6794 if ( taken_item )
6795 {
6796 bought_item->SetIdentified();
6797 memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[taken_item - 1], bought_item, 0x24u);
6798 dword_F8B1E4 = 1;
6799 Party::TakeGold(uPriceItemService);
6800 viewparams->bRedrawGameUI = 1;
6801 bought_item->Reset();
6802 pRenderer->ClearZBuffer(0, 479);
6803 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0);
6804 return;
6805 }
6806 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
6807 ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 5); // "Pack is Full!"
6808 break;
6809 }
6810 case HOUSE_DIALOGUE_SHOP_SELL:
6811 {
6812 v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5);
6813 if ( pMouse->GetCursorPos(&cursor)->x <= 13
6814 || pMouse->GetCursorPos(&cursor)->x >= 462
6815 || (v15 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79), !v15) )
6816 return;
6817 if ( MerchandiseTest(&pPlayers[uActiveCharacter]->pInventoryItems[v15 - 1], (int)window_SpeakInHouse->ptr_1C) )
6818 {
6819 dword_F8B1E4 = 1;
6820 pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)window_SpeakInHouse->ptr_1C);
6821 viewparams->bRedrawGameUI = 1;
6822 pRenderer->ClearZBuffer(0, 479);
6823 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)77, 0);
6824 return;
6825 }
6826 pPlayers[uActiveCharacter]->PlaySound(SPEECH_79, 0);
6827 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
6828 break;
6829 }
6830 case HOUSE_DIALOGUE_SHOP_IDENTIFY:
6831 {
6832 pMouse->GetCursorPos(&cursor);
6833 v79 = ((cursor.x - 14) >> 5) + 14 * ((cursor.y - 17) >> 5);
6834 if (cursor.x > 13 && cursor.x < 462)
6835 {
6836 pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79);
6837 if ( pItemID )
6838 {
6839 uPriceItemService = pPlayers[uActiveCharacter]->GetPriceIdentification(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier);
6840 item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1];
6841 if ( !(item->uAttributes & 1) )
6842 {
6843 if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) )
6844 {
6845 if ( pParty->uNumGold >= uPriceItemService )
6846 {
6847 dword_F8B1E4 = 1;
6848 Party::TakeGold(uPriceItemService);
6849 item->uAttributes |= 1;
6850 pPlayers[uActiveCharacter]->PlaySound(SPEECH_73, 0);
6851 ShowStatusBarString(pGlobalTXT_LocalizationStrings[569], 2);
6852 return;
6853 }
6854 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
6855 return;
6856 }
6857 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
6858 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0);
6859 return;
6860 }
6861 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0);
6862 return;
6863 }
6864 }
6865 break;
6866 }
6867 case HOUSE_DIALOGUE_SHOP_REPAIR:
6868 {
6869 v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5);
6870 if ( pMouse->GetCursorPos(&cursor)->x > 13 )
6871 {
6872 if ( pMouse->GetCursorPos(&cursor)->x < 462 )
6873 {
6874 pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79);
6875 if ( pItemID )
6876 {
6877 item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1];
6878 pPriceMultiplier = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
6879 auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1];
6880 uPriceItemService = pPlayers[uActiveCharacter]->GetPriceRepair(_v->GetValue(), pPriceMultiplier);
6881 if ( item->uAttributes & 2 )
6882 {
6883 if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) )
6884 {
6885 if ( pParty->uNumGold >= uPriceItemService )
6886 {
6887 dword_F8B1E4 = 1;
6888 Party::TakeGold(uPriceItemService);
6889 v8 = item->uAttributes;
6890 LOBYTE(v8) = v8 & 0xFD;
6891 item->uAttributes = v8 | 1;
6892 pPlayers[uActiveCharacter]->PlaySound(SPEECH_74, 0);
6893 ShowStatusBarString(pGlobalTXT_LocalizationStrings[570], 2);
6894 return;
6895 }
6896 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
6897 return;
6898 }
6899 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
6900 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0);
6901 return;
6902 }
6903 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0);
6904 return;
6905 }
6906 }
6907 }
6908 break;
6909 }
6910 case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
6911 case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
6912 {
6913 pCursorPos = pMouse->GetCursorPos(&cursor);
6914 v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pCursorPos->y]] & 0xFFFF;
6915 if ( !v18 )
6916 return;
6917 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
6918 bought_item = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];
6919 else
6920 bought_item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];//(ItemGen *)&pParty->field_C59C[v31 + 724];
6921 uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier);
6922 uNumSeconds = 0;
6923 a3 = 0;
6924 if ( pMapStats->GetMapInfo(pCurrentMapName.data()) )
6925 a3 = pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName.data())]._steal_perm;
6926 party_reputation = GetPartyReputation();
6927 if (pPlayers[uActiveCharacter]->CanSteal())
6928 {
6929 if ( GetAsyncKeyState(VK_CONTROL) )
6930 {
6931 uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(bought_item, a3, party_reputation, 0, &a6);
6932 if ( !uNumSeconds )
6933 {
6934 sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, 0, a6);
6935 return;
6936 }
6937 }
6938 }
6939 if ( pParty->uNumGold < uPriceItemService )
6940 {
6941 if ( uNumSeconds != 2 )
6942 {
6943 if ( uNumSeconds != 1 )
6944 {
6945 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
6946 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
6947 return;
6948 }
6949 }
6950 }
6951 v39 = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID);
6952 if ( v39 )
6953 {
6954 bought_item->SetIdentified();
6955 memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1], bought_item, sizeof(ItemGen));
6956 if ( pPlayers[uActiveCharacter]->CanSteal() )
6957 {
6958 if ( GetAsyncKeyState(VK_CONTROL) )
6959 {
6960 if ( uNumSeconds == 1 || uNumSeconds == 2 )
6961 {
6962 pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1].SetStolen();
6963 sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, uNumSeconds, a6);
6964 viewparams->bRedrawGameUI = 1;
6965 bought_item->Reset();
6966 pRenderer->ClearZBuffer(0, 479);
6967 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0);
6968 return;
6969 }
6970 }
6971 }
6972 dword_F8B1E4 = 1;
6973 Party::TakeGold(uPriceItemService);
6974 viewparams->bRedrawGameUI = 1;
6975 bought_item->Reset();
6976 pRenderer->ClearZBuffer(0, 479);
6977 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0);
6978 return;
6979 }
6980 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
6981 ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 2); // "Pack is Full!"
6982 break;
6983 }
6984 default:// if click video screen in shop
6985 {
6986 __debugbreak(); // please do record these dialogue ids to the HOUSE_DIALOGUE_MENU enum
6987 if( dialog_menu_id >= 36 && dialog_menu_id <= 72 )
6988 {
6989 v42 = dialog_menu_id - 36;
6990 //v43 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
6991 v43 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
6992 uPriceItemService = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
6993 if ( uPriceItemService < v43 / 3 )
6994 uPriceItemService = v43 / 3;
6995 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v42] )
6996 {
6997 pSkill = &pPlayers[uActiveCharacter]->pActiveSkills[v42];
6998 if ( !*pSkill )
6999 {
7000 if ( pParty->uNumGold < uPriceItemService )
7001 {
7002 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
7003 if ( in_current_building_type == BildingType_Training )
7004 v55 = 4;
7005 else
7006 v55 = 2;
7007 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v55);
7008 return;
7009 }
7010 Party::TakeGold(uPriceItemService);
7011 dword_F8B1E4 = 1;
7012 *pSkill = 1;
7013 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)78, 0);
7014 return;
7015 }
7016 }
7017 }
7018 break;
7019 }
7020 }
7021 } 3982 }
7022 //----- (004BC8D5) --------------------------------------------------------
7023 void SpellBookGenerator()//for GuildDialogs
7024 {
7025 int pItemNum; // esi@1
7026 int v4; // esi@7
7027
7028 for( int i = 0; i < 12; ++i )
7029 {
7030 if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType >= 5 )
7031 {
7032 if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 13 )
7033 pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType + 345;
7034 else
7035 {
7036 if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 14 )
7037 v4 = rand() % 4;
7038 else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 15 )
7039 v4 = rand() % 3 + 4;
7040 else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 16 )
7041 v4 = rand() % 2 + 7;
7042 if( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 16 )
7043 pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * v4 + 400;
7044 }
7045 }
7046 if ( pItemNum == 487 )
7047 {
7048 if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) )
7049 pItemNum = 486;
7050 }
7051 ItemGen * item_spellbook = &pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i];
7052 item_spellbook->Reset();
7053 pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].uItemID = pItemNum;
7054 pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].Identified();
7055 ItemsInShopTexture[i] = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[pItemNum].pIconName, TEXTURE_16BIT_PALETTE);
7056 }
7057 return;
7058 }