comparison GUI/UI/UIPopup.cpp @ 2572:d87bfbd3bb3b

Step towards unification of Texture and RGBTexture (class Image)
author a.parshin
date Sat, 05 Mar 2016 01:51:54 +0200
parents d569340b05ff
children dd36326a9994
comparison
equal deleted inserted replaced
2571:cf29f444ddd7 2572:d87bfbd3bb3b
29 #include "UIShops.h" 29 #include "UIShops.h"
30 30
31 static char static_sub_417BB5_out_string[1200]; // static to a file, not sub actually 31 static char static_sub_417BB5_out_string[1200]; // static to a file, not sub actually
32 32
33 33
34 struct Image *parchment = nullptr;
35 struct Image *messagebox_corner_x = nullptr; // 5076AC
36 struct Image *messagebox_corner_y = nullptr; // 5076B4
37 struct Image *messagebox_corner_z = nullptr; // 5076A8
38 struct Image *messagebox_corner_w = nullptr; // 5076B0
39 struct Image *messagebox_border_top = nullptr; // 507698
40 struct Image *messagebox_border_bottom = nullptr; // 5076A4
41 struct Image *messagebox_border_left = nullptr; // 50769C
42 struct Image *messagebox_border_right = nullptr; // 5076A0
43
34 //----- (004179BC) -------------------------------------------------------- 44 //----- (004179BC) --------------------------------------------------------
35 void CharacterUI_DrawTooltip(const char *Title, const char *content) 45 void CharacterUI_DrawTooltip(const char *Title, const char *content)
36 { 46 {
37 GUIWindow popup_window; // [sp+Ch] [bp-5Ch]@1 47 GUIWindow popup_window; // [sp+Ch] [bp-5Ch]@1
38 POINT v6; // [sp+60h] [bp-8h]@1 48 POINT v6; // [sp+60h] [bp-8h]@1
57 popup_window.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3); 67 popup_window.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3);
58 popup_window.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, content, 0, popup_window.uFrameY + popup_window.uFrameHeight, 0); 68 popup_window.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, content, 0, popup_window.uFrameY + popup_window.uFrameHeight, 0);
59 } 69 }
60 70
61 //----- (004151D9) -------------------------------------------------------- 71 //----- (004151D9) --------------------------------------------------------
62 void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight) 72 void DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight)
63 { 73 {
64 unsigned int uNumTiles; // [sp+2Ch] [bp-Ch]@6 74 unsigned int uNumTiles; // [sp+2Ch] [bp-Ch]@6
65 unsigned int coord_x; // [sp+2Ch] [bp-Ch]@3 75 int coord_x; // [sp+2Ch] [bp-Ch]@3
66 unsigned int coord_y; // [sp+34h] [bp-4h]@5 76 int coord_y; // [sp+34h] [bp-4h]@5
67 77
68 auto parchment = pIcons_LOD->GetTexture(uTextureID_Parchment); 78 if (!parchment)
69 79 return;
70 if ( parchment->uTextureWidth && parchment->uTextureHeight) 80
71 { 81
72 pRenderer->SetUIClipRect(uX, uY, uX + uWidth, uY + uHeight); 82 pRenderer->SetUIClipRect(uX, uY, uX + uWidth, uY + uHeight);
73 83
74 uNumTiles = uWidth / parchment->uTextureWidth; 84 unsigned int parchment_width = parchment->GetWidth();
75 if ( uWidth % parchment->uTextureWidth ) 85 unsigned int parchment_height = parchment->GetHeight();
86
87 uNumTiles = uWidth / parchment_width;
88 if ( uWidth % parchment_width)
76 ++uNumTiles; 89 ++uNumTiles;
77 coord_y = uY; 90 coord_y = uY;
78 for ( uint j = 0; j <= uHeight / parchment->uTextureHeight; j++ ) 91 for ( uint j = 0; j <= uHeight / parchment_height; j++ )
79 { 92 {
80 coord_x = uX - parchment->uTextureWidth; 93 coord_x = uX - parchment_width;
81 for ( uint i = uNumTiles + 1; i; --i ) 94 for ( uint i = uNumTiles + 1; i; --i )
82 { 95 {
83 coord_x += parchment->uTextureWidth; 96 coord_x += parchment_width;
84 pRenderer->DrawTextureIndexed(coord_x, coord_y, parchment); 97 pRenderer->DrawTextureNew(coord_x / 640.0f, coord_y / 480.0f, parchment);
85 } 98 }
86 coord_y += parchment->uTextureHeight; 99 coord_y += parchment_height;
87 } 100 }
88 pRenderer->DrawTextureIndexedAlpha(uX, uY, pIcons_LOD->GetTexture(uTextureID_5076AC)); 101
89 pRenderer->DrawTextureIndexedAlpha(uX, uY + uHeight - 32, pIcons_LOD->GetTexture(uTextureID_5076B4)); 102
90 pRenderer->DrawTextureIndexedAlpha(uX + uWidth - 32, uY, pIcons_LOD->GetTexture(uTextureID_5076A8)); 103 pRenderer->DrawTextureAlphaNew(
91 pRenderer->DrawTextureIndexedAlpha(uX + uWidth - 32, uY + uHeight - 32, pIcons_LOD->GetTexture(uTextureID_5076B0)); 104 uX / 640.0f,
92 if ( uWidth > 64 ) 105 uY / 480.0f,
93 { 106 messagebox_corner_x
94 pRenderer->SetUIClipRect(uX + 32, uY, uX + uWidth - 32, uY + uHeight); 107 );
95 pRenderer->DrawTextureIndexedAlpha(uX + 32, uY, pIcons_LOD->GetTexture(uTextureID_507698)); 108 pRenderer->DrawTextureAlphaNew(
96 pRenderer->DrawTextureIndexedAlpha(uX + 32, uY + uHeight - 10, pIcons_LOD->GetTexture(uTextureID_5076A4)); 109 uX / 640.0f,
97 if ( uWidth > 512 ) 110 (uY + uHeight - messagebox_corner_y->GetHeight()) / 480.0f,
98 { 111 messagebox_corner_y
99 pRenderer->DrawTextureIndexedAlpha(uX + 544, uY, pIcons_LOD->GetTexture(uTextureID_507698)); 112 );
100 pRenderer->DrawTextureIndexedAlpha(uX + 544, uY + uHeight - 10, pIcons_LOD->GetTexture(uTextureID_5076A4)); 113 pRenderer->DrawTextureAlphaNew(
101 } 114 (uX + uWidth - messagebox_corner_z->GetWidth()) / 640.0f,
102 } 115 uY / 480.0f,
103 if ( uHeight > 64 ) 116 messagebox_corner_z
104 { 117 );
105 pRenderer->SetUIClipRect(uX, uY + 32, uX + uWidth, uY + uHeight - 32); 118 pRenderer->DrawTextureAlphaNew(
106 pRenderer->DrawTextureIndexedAlpha(uX, uY + 32, pIcons_LOD->GetTexture(uTextureID_5076A0)); 119 (uX + uWidth - messagebox_corner_z->GetWidth()) / 640.0f,
107 pRenderer->DrawTextureIndexedAlpha(uX + uWidth - 10, uY + 32, pIcons_LOD->GetTexture(uTextureID_50769C)); 120 (uY + uHeight - messagebox_corner_y->GetHeight()) / 480.0f,
121 messagebox_corner_w
122 );
123
124
125 if (uWidth > messagebox_corner_x->GetWidth() + messagebox_corner_z->GetWidth())
126 {
127 pRenderer->SetUIClipRect(
128 uX + messagebox_corner_x->GetWidth(),
129 uY,
130 uX + uWidth - messagebox_corner_z->GetWidth(),
131 uY + uHeight
132 );
133
134 // horizontal borders
135 for (
136 unsigned int x = uX + messagebox_corner_x->GetWidth();
137 x < uX + uWidth - messagebox_corner_x->GetWidth();
138 x += messagebox_border_top->GetWidth()
139 )
140 {
141 pRenderer->DrawTextureAlphaNew(
142 x / 640.0f,
143 uY / 480.0f,
144 messagebox_border_top
145 );
146 pRenderer->DrawTextureAlphaNew(
147 x / 640.0f,
148 (uY + uHeight - messagebox_border_bottom->GetHeight()) / 480.0f,
149 messagebox_border_bottom
150 );
151 }
152 }
153
154 // vertical borders
155 if ( uHeight > messagebox_corner_x->GetHeight() + messagebox_corner_y->GetHeight())
156 {
157 pRenderer->SetUIClipRect(
158 uX,
159 uY + messagebox_corner_x->GetHeight(),
160 uX + uWidth,
161 uY + uHeight - messagebox_corner_y->GetHeight()
162 );
163
164 for (
165 unsigned int y = uY + messagebox_corner_x->GetHeight();
166 y < uY + uHeight - messagebox_corner_y->GetHeight();
167 y += messagebox_border_top->GetHeight()
168 )
169 {
170 pRenderer->DrawTextureAlphaNew(
171 uX / 640.0f,
172 y / 480.0f,
173 messagebox_border_left
174 );
175 pRenderer->DrawTextureAlphaNew(
176 (uX + uWidth - messagebox_border_right->GetWidth() - 1) / 640.0f,
177 y / 480.0f,
178 messagebox_border_right
179 );
180 }
108 } 181 }
109 pRenderer->ResetUIClipRect(); 182 pRenderer->ResetUIClipRect();
110 }
111 } 183 }
112 184
113 //----- (0041D895) -------------------------------------------------------- 185 //----- (0041D895) --------------------------------------------------------
114 void GameUI_DrawItemInfo( struct ItemGen* inspect_item ) 186 void GameUI_DrawItemInfo( struct ItemGen* inspect_item )
115 { 187 {