Skip to content

Commit 43a388e

Browse files
EXio4kwolekr
authored andcommittedApr 26, 2013
Ability to change the crosshair using textures
1 parent d3f0ce6 commit 43a388e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed
 

‎src/hud.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,19 @@ void Hud::drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem) {
297297

298298

299299
void Hud::drawCrosshair() {
300-
if (player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE) {
300+
if (!(player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE))
301+
return;
302+
303+
ITextureSource *tsrc = gamedef->getTextureSource();
304+
if (tsrc->isKnownSourceImage("crosshair.png")) {
305+
video::ITexture *crosshair = tsrc->getTextureRaw("crosshair.png");
306+
v2u32 size = crosshair->getOriginalSize();
307+
v2s32 lsize = v2s32(displaycenter.X - (size.X / 2),
308+
displaycenter.Y - (size.Y / 2));
309+
driver->draw2DImage(crosshair, lsize,
310+
core::rect<s32>(0, 0, size.X, size.Y),
311+
0, crosshair_argb, true);
312+
} else {
301313
driver->draw2DLine(displaycenter - v2s32(10, 0),
302314
displaycenter + v2s32(10, 0), crosshair_argb);
303315
driver->draw2DLine(displaycenter - v2s32(0, 10),

0 commit comments

Comments
 (0)
Please sign in to comment.