comparison GUI/UI/UIHouses.cpp @ 2574:dd36326a9994

More texture refactoring GetLeather -> DrawTextureCustomHeight
author a.parshin
date Mon, 07 Mar 2016 03:48:40 +0200
parents 0c67be4ec900
children a76d408c5132
comparison
equal deleted inserted replaced
2573:0c67be4ec900 2574:dd36326a9994
4 4
5 #define _CRT_SECURE_NO_WARNINGS 5 #define _CRT_SECURE_NO_WARNINGS
6 6
7 #include "Engine/Engine.h" 7 #include "Engine/Engine.h"
8 #include "Engine/AssetsManager.h" 8 #include "Engine/AssetsManager.h"
9
10 #include "GUI/UI/UIGame.h"
9 11
10 #include "UIGuilds.h" 12 #include "UIGuilds.h"
11 #include "UIPartyCreation.h" 13 #include "UIPartyCreation.h"
12 #include "UIShops.h" 14 #include "UIShops.h"
13 #include "..\../GUI/GUIButton.h" 15 #include "..\../GUI/GUIButton.h"
802 signed int am_pm_flag_close; // eax@10 804 signed int am_pm_flag_close; // eax@10
803 // int v9; // esi@10 805 // int v9; // esi@10
804 // int v11; // ecx@17 806 // int v11; // ecx@17
805 // unsigned int v12; // kr00_4@25 807 // unsigned int v12; // kr00_4@25
806 // int v14; // eax@25 808 // int v14; // eax@25
807 unsigned int v17; // eax@37 809 //unsigned int v17; // eax@37
808 signed int v18; // edi@37 810 signed int v18; // edi@37
809 signed int v19; // edi@41 811 signed int v19; // edi@41
810 char pContainer[40]; // [sp+Ch] [bp-30h]@32 812 char pContainer[40]; // [sp+Ch] [bp-30h]@32
811 // unsigned int v24; // [sp+34h] [bp-8h]@5 813 // unsigned int v24; // [sp+34h] [bp-8h]@5
812 814
899 case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); break; 901 case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); break;
900 case PartyAlignment_Evil: sprintf(pContainer, "evt%02d-c", const_2()); break; 902 case PartyAlignment_Evil: sprintf(pContainer, "evt%02d-c", const_2()); break;
901 default: Error("Invalid alignment type: %u", pParty->alignment); 903 default: Error("Invalid alignment type: %u", pParty->alignment);
902 } 904 }
903 905
904 v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); 906 pDialogueNPCCount = 0;
905 pDialogueNPCCount = 0; 907 //v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
906 pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17]; 908 //game_ui_dialogue_background = &pIcons_LOD->pTextures[v17];
909 game_ui_dialogue_background = assets->GetImage_16Bit(pContainer);
907 910
908 PrepareHouse(uHouseID); 911 PrepareHouse(uHouseID);
909 v18 = 1; 912 v18 = 1;
910 913
911 if ( uNumDialogueNPCPortraits == 1 ) 914 if ( uNumDialogueNPCPortraits == 1 )
1040 return; 1043 return;
1041 } 1044 }
1042 pDialogueWindow->Release(); 1045 pDialogueWindow->Release();
1043 pDialogueWindow = new GUIWindow(0, 0, window->GetWidth(), 345, 0, 0); 1046 pDialogueWindow = new GUIWindow(0, 0, window->GetWidth(), 345, 0, 0);
1044 pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" 1047 pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation"
1045 pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); 1048 ui_buttdesc2, 0);
1046 pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr); 1049 pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr);
1047 } 1050 }
1048 if ( in_current_building_type != BuildingType_Training ) 1051 if ( in_current_building_type != BuildingType_Training )
1049 { 1052 {
1050 if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) && 1053 if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) &&
1052 || in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild ) 1055 || in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild )
1053 { 1056 {
1054 pDialogueWindow->Release(); 1057 pDialogueWindow->Release();
1055 pDialogueWindow = new GUIWindow(0, 0, window->GetWidth(), 345, 0, 0); 1058 pDialogueWindow = new GUIWindow(0, 0, window->GetWidth(), 345, 0, 0);
1056 pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" 1059 pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation"
1057 pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); 1060 ui_buttdesc2, 0);
1058 pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr); 1061 pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr);
1059 } 1062 }
1060 else if (uActiveCharacter) 1063 else if (uActiveCharacter)
1061 { 1064 {
1062 if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() ) 1065 if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() )
1734 if ( 352 - pTextHeight < 8 ) 1737 if ( 352 - pTextHeight < 8 )
1735 { 1738 {
1736 pOutString = pFontCreate; 1739 pOutString = pFontCreate;
1737 pTextHeight = pFontCreate->CalcTextHeight(current_npc_text, &window, 13, 0) + 7; 1740 pTextHeight = pFontCreate->CalcTextHeight(current_npc_text, &window, 13, 0) + 7;
1738 } 1741 }
1739 pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight); 1742 pRenderer->DrawTextureCustomHeight(8/640.0f, (352 - pTextHeight)/480.0f, ui_leather_mm7, pTextHeight);
1740 pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - pTextHeight)/480.0f, _591428_endcap); 1743 pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - pTextHeight)/480.0f, _591428_endcap);
1741 window.DrawText(pOutString, 13, 354 - pTextHeight, 0, FitTextInAWindow(current_npc_text, pOutString, &window, 13, 0), 0, 0, 0); 1744 window.DrawText(pOutString, 13, 354 - pTextHeight, 0, FitTextInAWindow(current_npc_text, pOutString, &window, 13, 0), 0, 0, 0);
1742 break; 1745 break;
1743 } 1746 }
1744 case HOUSE_DIALOGUE_TOWNHALL_PAY_FINE: 1747 case HOUSE_DIALOGUE_TOWNHALL_PAY_FINE:
2033 if ( 352 - pTextHeight < 8 ) 2036 if ( 352 - pTextHeight < 8 )
2034 { 2037 {
2035 pOutString = pFontCreate; 2038 pOutString = pFontCreate;
2036 pTextHeight = pFontCreate->CalcTextHeight(pTmpBuf.data(), &dialog_window, 12, 0) + 7; 2039 pTextHeight = pFontCreate->CalcTextHeight(pTmpBuf.data(), &dialog_window, 12, 0) + 7;
2037 } 2040 }
2038 pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight); 2041 pRenderer->DrawTextureCustomHeight(8/640.0f, (352 - pTextHeight)/480.0f, ui_leather_mm7, pTextHeight);
2039 pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - pTextHeight)/480.0f, _591428_endcap); 2042 pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - pTextHeight)/480.0f, _591428_endcap);
2040 window_SpeakInHouse->DrawText(pOutString, 12, 354 - pTextHeight, 0, FitTextInAWindow(pTmpBuf.data(), pOutString, &dialog_window, 0xCu, 0), 0, 0, 0); 2043 window_SpeakInHouse->DrawText(pOutString, 12, 354 - pTextHeight, 0, FitTextInAWindow(pTmpBuf.data(), pOutString, &dialog_window, 0xCu, 0), 0, 0, 0);
2041 break; 2044 break;
2042 } 2045 }
2043 case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_VICTORY_CONDITIONS: 2046 case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_VICTORY_CONDITIONS:
2044 { 2047 {
2045 strcpy(pTmpBuf.data(), pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText); 2048 strcpy(pTmpBuf.data(), pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText);
2046 dialog_window.uFrameWidth = game_viewport_width; 2049 dialog_window.uFrameWidth = game_viewport_width;
2047 dialog_window.uFrameZ = 452; 2050 dialog_window.uFrameZ = 452;
2048 pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 12, 0) + 7; 2051 pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 12, 0) + 7;
2049 pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight); 2052 pRenderer->DrawTextureCustomHeight(8/640.0f, (352 - pTextHeight)/480.0f, ui_leather_mm7, pTextHeight);
2050 pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - pTextHeight)/480.0f, _591428_endcap); 2053 pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - pTextHeight)/480.0f, _591428_endcap);
2051 window_SpeakInHouse->DrawText(pFontArrus, 12, 354 - pTextHeight, 0, 2054 window_SpeakInHouse->DrawText(pFontArrus, 12, 354 - pTextHeight, 0,
2052 FitTextInAWindow(pTmpBuf.data(), pFontArrus, &dialog_window, 0xCu, 0), 0, 0, 0); 2055 FitTextInAWindow(pTmpBuf.data(), pFontArrus, &dialog_window, 0xCu, 0), 0, 0, 0);
2053 break; 2056 break;
2054 } 2057 }
2922 { 2925 {
2923 house_window.uFrameWidth = game_viewport_width; 2926 house_window.uFrameWidth = game_viewport_width;
2924 house_window.uFrameZ = 452; 2927 house_window.uFrameZ = 452;
2925 pInString = pNPCStats->pNPCGreetings[pNPC->greet].pGreetings[((pNPC->uFlags & 3) == 2)]; 2928 pInString = pNPCStats->pNPCGreetings[pNPC->greet].pGreetings[((pNPC->uFlags & 3) == 2)];
2926 //pInString = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * pNPC->greet); 2929 //pInString = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * pNPC->greet);
2927 pRenderer->GetLeather(8, 352 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7), 2930 pRenderer->DrawTextureCustomHeight(
2928 pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight 2931 8/640.0f,
2929 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7)); 2932 (352 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7))/480.0f,
2933 ui_leather_mm7,
2934 (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7));
2930 2935
2931 int h = (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7); 2936 int h = (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7);
2932 pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - h)/480.0f, _591428_endcap); 2937 pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - h)/480.0f, _591428_endcap);
2933 pDialogueWindow->DrawText(pFontArrus, 13, 354 - h, 0, FitTextInAWindow(pInString, pFontArrus, &house_window, 0xDu, 0), 0, 0, 0); 2938 pDialogueWindow->DrawText(pFontArrus, 13, 354 - h, 0, FitTextInAWindow(pInString, pFontArrus, &house_window, 0xDu, 0), 0, 0, 0);
2934 } 2939 }
3082 if ( 352 - pTextHeight < 8 ) 3087 if ( 352 - pTextHeight < 8 )
3083 { 3088 {
3084 pTextFont = pFontCreate; 3089 pTextFont = pFontCreate;
3085 pTextHeight = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; 3090 pTextHeight = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7;
3086 } 3091 }
3087 pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight); 3092 pRenderer->DrawTextureCustomHeight(8/640.0f, (352 - pTextHeight)/480.0f, ui_leather_mm7, pTextHeight);
3088 pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - pTextHeight)/480.0f, _591428_endcap); 3093 pRenderer->DrawTextureAlphaNew(8/640.0f, (347 - pTextHeight)/480.0f, _591428_endcap);
3089 house_window.DrawText(pTextFont, 13, 354 - pTextHeight, 0, FitTextInAWindow(current_npc_text, pTextFont, &w, 13, 0), 0, 0, 0); 3094 house_window.DrawText(pTextFont, 13, 354 - pTextHeight, 0, FitTextInAWindow(current_npc_text, pTextFont, &w, 13, 0), 0, 0, 0);
3090 } 3095 }
3091 } 3096 }
3092 3097