Mercurial > mm7
comparison GUI/UI/Chest.cpp @ 2550:fb42e2662c38
Chest UI refactored to a class
author | a.parshin |
---|---|
date | Tue, 12 May 2015 11:28:22 +0200 |
parents | |
children | 0c67be4ec900 |
comparison
equal
deleted
inserted
replaced
2549:3121fb54a110 | 2550:fb42e2662c38 |
---|---|
1 #include "Engine/Engine.h" | |
2 #include "Engine/Timer.h" | |
3 #include "Engine/LOD.h" | |
4 #include "Engine/texts.h" | |
5 #include "Engine/Graphics/IRender.h" | |
6 #include "Engine/Objects/Chest.h" | |
7 | |
8 #include "GUI/UI/Chest.h" | |
9 | |
10 | |
11 | |
12 int pChestPixelOffsetX[8] = { 42, 18, 18, 42, 42, 42, 18, 42 }; | |
13 int pChestPixelOffsetY[8] = { 34, 30, 30, 34, 34, 34, 30, 34 }; | |
14 int pChestWidthsByType[8] = { 9, 9, 9, 9, 9, 9, 9, 9 }; | |
15 int pChestHeightsByType[8] = { 9, 9, 9, 9, 9, 9, 9, 9 }; | |
16 | |
17 | |
18 | |
19 GUIWindow_Chest::GUIWindow_Chest(unsigned int chest_id) : | |
20 GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), chest_id, nullptr) | |
21 { | |
22 // -------------------------------------- | |
23 // 0041C432 GUIWindow::GUIWindow --- part | |
24 CreateButton(61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); | |
25 CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); | |
26 CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); | |
27 CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); | |
28 CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9, "", 0); | |
29 | |
30 // -------------------------------------------------------- | |
31 // 0042041E bool Chest::Open( signed int uChestID ) -- part | |
32 pBtn_ExitCancel = CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit | |
33 CreateButton(7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0); | |
34 current_screen_type = SCREEN_CHEST; | |
35 pEventTimer->Pause(); | |
36 } | |
37 | |
38 | |
39 | |
40 void GUIWindow_Chest::Update() | |
41 { | |
42 // ----------------------------------- | |
43 // 004156F0 GUI_UpdateWindows --- part | |
44 if (current_screen_type == SCREEN_CHEST_INVENTORY) | |
45 { | |
46 pRenderer->ClearZBuffer(0, 479); | |
47 draw_leather(); | |
48 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
49 pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uExitCancelTextureId)); | |
50 } | |
51 else if (current_screen_type == SCREEN_CHEST) | |
52 { | |
53 //Chest::DrawChestUI(par1C); | |
54 | |
55 // ----------------------------------------------------- | |
56 // 0042092D void Chest::DrawChestUI(signed int uChestID) | |
57 auto uChestID = (unsigned int)ptr_1C; | |
58 | |
59 int chestBitmapId; // eax@1 | |
60 unsigned int v5; // eax@1 | |
61 int chest_item_index; // ecx@3 | |
62 unsigned int item_texture_id; // eax@4 | |
63 Texture *item_texture; // esi@4 | |
64 signed int itemPixelWidth; // ecx@4 | |
65 signed int itemPixelHeght; // edx@4 | |
66 // signed int v11; // eax@4 | |
67 int v12; // eax@6 | |
68 int v13; // eax@6 | |
69 unsigned int itemPixelPosX; // ST34_4@8 | |
70 int itemPixelPosY; // edi@8 | |
71 int *v16; // [sp+Ch] [bp-28h]@1 | |
72 // int v17; // [sp+10h] [bp-24h]@4 | |
73 int chest_offs_y; // [sp+14h] [bp-20h]@1 | |
74 signed int chestHeghtCells; // [sp+18h] [bp-1Ch]@1 | |
75 int chest_offs_x; // [sp+1Ch] [bp-18h]@1 | |
76 signed int chestWidthCells; // [sp+20h] [bp-14h]@1 | |
77 signed int item_counter; // [sp+30h] [bp-4h]@1 | |
78 | |
79 v16 = pRenderer->pActiveZBuffer; | |
80 pRenderer->ClearZBuffer(0, 479); | |
81 chestBitmapId = pChests[uChestID].uChestBitmapID; | |
82 chest_offs_x = pChestPixelOffsetX[chestBitmapId]; | |
83 chest_offs_y = pChestPixelOffsetY[chestBitmapId]; | |
84 chestWidthCells = pChestWidthsByType[chestBitmapId]; | |
85 chestHeghtCells = pChestHeightsByType[chestBitmapId]; | |
86 sprintfex(pTmpBuf.data(), "chest%02d", pChestList->pChests[chestBitmapId].uTextureID); | |
87 v5 = pIcons_LOD->LoadTexture(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); | |
88 pRenderer->DrawTextureIndexed(8u, 8u, pIcons_LOD->GetTexture(v5)); | |
89 | |
90 for (item_counter = 0; item_counter < chestWidthCells * chestHeghtCells; ++item_counter) | |
91 { | |
92 chest_item_index = pChests[uChestID].pInventoryIndices[item_counter]; | |
93 if (chest_item_index > 0) | |
94 { | |
95 item_texture_id = pIcons_LOD->LoadTexture( | |
96 //pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName, | |
97 pChests[uChestID].igChestItems[chest_item_index - 1].GetIconName(), TEXTURE_16BIT_PALETTE); | |
98 item_texture = pIcons_LOD->GetTexture(item_texture_id); | |
99 itemPixelWidth = item_texture->uTextureWidth; | |
100 itemPixelHeght = item_texture->uTextureHeight; | |
101 if (itemPixelWidth < 14) | |
102 itemPixelWidth = 14; | |
103 v12 = itemPixelWidth - 14; | |
104 v12 = v12 & 0xFFFFFFE0; | |
105 v13 = v12 + 32; | |
106 if (itemPixelHeght < 14) | |
107 itemPixelHeght = 14; | |
108 itemPixelPosX = chest_offs_x + 32 * (item_counter % chestWidthCells) + ((signed int)(v13 - itemPixelWidth) / 2); | |
109 itemPixelPosY = chest_offs_y + 32 * (item_counter / chestHeghtCells) + | |
110 ((signed int)(((itemPixelHeght - 14) & 0xFFFFFFE0) + 32 - item_texture->uTextureHeight) / 2); | |
111 pRenderer->DrawTextureIndexedAlpha(itemPixelPosX, itemPixelPosY, item_texture); | |
112 ZBuffer_DoFill2(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1); | |
113 } | |
114 } | |
115 pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uExitCancelTextureId)); | |
116 } | |
117 } |