aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEsteban I. Ruiz Moreno <exio4.com@gmail.com>2013-04-20 22:39:31 -0300
committerkwolekr <kwolekr@minetest.net>2013-04-25 20:07:46 -0400
commit43a388ec533220fcdb84fb3680bcb87a38fd010d (patch)
tree89dee2509b40f195e8f9907a95023ab720ef5bc4 /src
parentd3f0ce62240b7598eded13153eacb410bf2420a1 (diff)
downloadminetest-43a388ec533220fcdb84fb3680bcb87a38fd010d.tar.gz
minetest-43a388ec533220fcdb84fb3680bcb87a38fd010d.tar.bz2
minetest-43a388ec533220fcdb84fb3680bcb87a38fd010d.zip
Ability to change the crosshair using textures
Diffstat (limited to 'src')
-rw-r--r--src/hud.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/hud.cpp b/src/hud.cpp
index cf53354b2..375d65878 100644
--- a/src/hud.cpp
+++ b/src/hud.cpp
@@ -297,7 +297,19 @@ void Hud::drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem) {
void Hud::drawCrosshair() {
- if (player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE) {
+ if (!(player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE))
+ return;
+
+ ITextureSource *tsrc = gamedef->getTextureSource();
+ if (tsrc->isKnownSourceImage("crosshair.png")) {
+ video::ITexture *crosshair = tsrc->getTextureRaw("crosshair.png");
+ v2u32 size = crosshair->getOriginalSize();
+ v2s32 lsize = v2s32(displaycenter.X - (size.X / 2),
+ displaycenter.Y - (size.Y / 2));
+ driver->draw2DImage(crosshair, lsize,
+ core::rect<s32>(0, 0, size.X, size.Y),
+ 0, crosshair_argb, true);
+ } else {
driver->draw2DLine(displaycenter - v2s32(10, 0),
displaycenter + v2s32(10, 0), crosshair_argb);
driver->draw2DLine(displaycenter - v2s32(0, 10),