@@ -45,6 +45,8 @@ Hud::Hud(video::IVideoDriver *driver, gui::IGUIEnvironment* guienv,
45
45
hotbar_imagesize = 48 ;
46
46
hotbar_itemcount = 8 ;
47
47
48
+ tsrc = gamedef->getTextureSource ();
49
+
48
50
v3f crosshair_color = g_settings->getV3F (" crosshair_color" );
49
51
u32 cross_r = rangelim (myround (crosshair_color.X ), 0 , 255 );
50
52
u32 cross_g = rangelim (myround (crosshair_color.Y ), 0 , 255 );
@@ -57,6 +59,8 @@ Hud::Hud(video::IVideoDriver *driver, gui::IGUIEnvironment* guienv,
57
59
u32 sbox_g = rangelim (myround (selectionbox_color.Y ), 0 , 255 );
58
60
u32 sbox_b = rangelim (myround (selectionbox_color.Z ), 0 , 255 );
59
61
selectionbox_argb = video::SColor (255 , sbox_r, sbox_g, sbox_b);
62
+
63
+ use_crosshair_image = tsrc->isKnownSourceImage (" crosshair.png" );
60
64
}
61
65
62
66
@@ -175,8 +179,7 @@ void Hud::drawLuaElements() {
175
179
v2s32 pos (e->pos .X * screensize.X , e->pos .Y * screensize.Y );
176
180
switch (e->type ) {
177
181
case HUD_ELEM_IMAGE: {
178
- video::ITexture *texture =
179
- gamedef->getTextureSource ()->getTextureRaw (e->text );
182
+ video::ITexture *texture = tsrc->getTextureRaw (e->text );
180
183
if (!texture)
181
184
continue ;
182
185
@@ -226,8 +229,7 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture, s
226
229
const video::SColor color (255 , 255 , 255 , 255 );
227
230
const video::SColor colors[] = {color, color, color, color};
228
231
229
- video::ITexture *stat_texture =
230
- gamedef->getTextureSource ()->getTextureRaw (texture);
232
+ video::ITexture *stat_texture = tsrc->getTextureRaw (texture);
231
233
if (!stat_texture)
232
234
return ;
233
235
@@ -299,9 +301,8 @@ void Hud::drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem) {
299
301
void Hud::drawCrosshair () {
300
302
if (!(player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE))
301
303
return ;
302
-
303
- ITextureSource *tsrc = gamedef->getTextureSource ();
304
- if (tsrc->isKnownSourceImage (" crosshair.png" )) {
304
+
305
+ if (use_crosshair_image) {
305
306
video::ITexture *crosshair = tsrc->getTextureRaw (" crosshair.png" );
306
307
v2u32 size = crosshair->getOriginalSize ();
307
308
v2s32 lsize = v2s32 (displaycenter.X - (size.X / 2 ),
0 commit comments