@@ -64,6 +64,8 @@ Hud::Hud(video::IVideoDriver *driver, gui::IGUIEnvironment* guienv,
64
64
selectionbox_argb = video::SColor (255 , sbox_r, sbox_g, sbox_b);
65
65
66
66
use_crosshair_image = tsrc->isKnownSourceImage (" crosshair.png" );
67
+ use_hotbar_bg_img = tsrc->isKnownSourceImage (" hotbar.png" );
68
+ use_hotbar_border_img = tsrc->isKnownSourceImage (" hotbar_selected.png" );
67
69
}
68
70
69
71
@@ -90,6 +92,18 @@ void Hud::drawItem(v2s32 upperleftpos, s32 imgsize, s32 itemcount,
90
92
driver->draw2DRectangle(bgcolor, barrect, NULL);*/
91
93
92
94
core::rect<s32> imgrect (0 , 0 , imgsize, imgsize);
95
+ const video::SColor hbar_color (255 , 255 , 255 , 255 );
96
+ const video::SColor hbar_colors[] = {hbar_color, hbar_color, hbar_color, hbar_color};
97
+
98
+ if (use_hotbar_bg_img) {
99
+ core::rect<s32> imgrect2 (-padding/2 , -padding/2 , width+padding/2 , height+padding/2 );
100
+ core::rect<s32> rect2 = imgrect2 + pos;
101
+ video::ITexture *texture = tsrc->getTexture (" hotbar.png" );
102
+ core::dimension2di imgsize (texture->getOriginalSize ());
103
+ driver->draw2DImage (texture, rect2,
104
+ core::rect<s32>(core::position2d<s32>(0 ,0 ), imgsize),
105
+ NULL , hbar_colors, true );
106
+ }
93
107
94
108
for (s32 i = 0 ; i < itemcount; i++)
95
109
{
@@ -112,62 +126,74 @@ void Hud::drawItem(v2s32 upperleftpos, s32 imgsize, s32 itemcount,
112
126
113
127
core::rect<s32> rect = imgrect + pos + steppos;
114
128
115
- if (selectitem == i + 1 )
116
- {
117
- video::SColor c_outside (255 ,255 ,0 ,0 );
118
- // video::SColor c_outside(255,0,0,0);
119
- // video::SColor c_inside(255,192,192,192);
120
- s32 x1 = rect.UpperLeftCorner .X ;
121
- s32 y1 = rect.UpperLeftCorner .Y ;
122
- s32 x2 = rect.LowerRightCorner .X ;
123
- s32 y2 = rect.LowerRightCorner .Y ;
124
- // Black base borders
125
- driver->draw2DRectangle (c_outside,
129
+ if (selectitem == i + 1 ) {
130
+ if (use_hotbar_border_img) {
131
+ core::rect<s32> imgrect2 (-padding*2 , -padding*2 , height, height);
132
+ rect = imgrect2 + pos + steppos;
133
+ video::ITexture *texture = tsrc->getTexture (" hotbar_selected.png" );
134
+ core::dimension2di imgsize (texture->getOriginalSize ());
135
+ driver->draw2DImage (texture, rect,
136
+ core::rect<s32>(core::position2d<s32>(0 ,0 ), imgsize),
137
+ NULL , hbar_colors, true );
138
+ rect = imgrect + pos + steppos;
139
+ } else {
140
+ rect = imgrect + pos + steppos;
141
+ video::SColor c_outside (255 ,255 ,0 ,0 );
142
+ // video::SColor c_outside(255,0,0,0);
143
+ // video::SColor c_inside(255,192,192,192);
144
+ s32 x1 = rect.UpperLeftCorner .X ;
145
+ s32 y1 = rect.UpperLeftCorner .Y ;
146
+ s32 x2 = rect.LowerRightCorner .X ;
147
+ s32 y2 = rect.LowerRightCorner .Y ;
148
+ // Black base borders
149
+ driver->draw2DRectangle (c_outside,
126
150
core::rect<s32>(
127
151
v2s32 (x1 - padding, y1 - padding),
128
152
v2s32 (x2 + padding, y1 )
129
153
), NULL );
130
- driver->draw2DRectangle (c_outside,
154
+ driver->draw2DRectangle (c_outside,
131
155
core::rect<s32>(
132
156
v2s32 (x1 - padding, y2),
133
157
v2s32 (x2 + padding, y2 + padding)
134
158
), NULL );
135
- driver->draw2DRectangle (c_outside,
159
+ driver->draw2DRectangle (c_outside,
136
160
core::rect<s32>(
137
161
v2s32 (x1 - padding, y1 ),
138
162
v2s32 (x1, y2)
139
163
), NULL );
140
- driver->draw2DRectangle (c_outside,
164
+ driver->draw2DRectangle (c_outside,
141
165
core::rect<s32>(
142
166
v2s32 (x2, y1 ),
143
167
v2s32 (x2 + padding, y2)
144
168
), NULL );
145
- /* // Light inside borders
146
- driver->draw2DRectangle(c_inside,
169
+ /* // Light inside borders
170
+ driver->draw2DRectangle(c_inside,
147
171
core::rect<s32>(
148
172
v2s32(x1 - padding/2, y1 - padding/2),
149
173
v2s32(x2 + padding/2, y1)
150
174
), NULL);
151
- driver->draw2DRectangle(c_inside,
175
+ driver->draw2DRectangle(c_inside,
152
176
core::rect<s32>(
153
177
v2s32(x1 - padding/2, y2),
154
178
v2s32(x2 + padding/2, y2 + padding/2)
155
179
), NULL);
156
- driver->draw2DRectangle(c_inside,
180
+ driver->draw2DRectangle(c_inside,
157
181
core::rect<s32>(
158
182
v2s32(x1 - padding/2, y1),
159
183
v2s32(x1, y2)
160
184
), NULL);
161
- driver->draw2DRectangle(c_inside,
185
+ driver->draw2DRectangle(c_inside,
162
186
core::rect<s32>(
163
187
v2s32(x2, y1),
164
188
v2s32(x2 + padding/2, y2)
165
189
), NULL);
166
- */
190
+ */
191
+ }
167
192
}
168
193
169
194
video::SColor bgcolor2 (128 , 0 , 0 , 0 );
170
- driver->draw2DRectangle (bgcolor2, rect, NULL );
195
+ if (!use_hotbar_bg_img)
196
+ driver->draw2DRectangle (bgcolor2, rect, NULL );
171
197
drawItemStack (driver, font, item, rect, NULL , gamedef);
172
198
}
173
199
}
@@ -222,7 +248,7 @@ void Hud::drawLuaElements() {
222
248
break ; }
223
249
default :
224
250
infostream << " Hud::drawLuaElements: ignoring drawform " << e->type <<
225
- " of hud element ID " << i << " due to unrecognized type" << std::endl;
251
+ " of hud element ID " << i << " due to unrecognized type" << std::endl;
226
252
}
227
253
}
228
254
}
0 commit comments