From a3680aa63b8ab53231fc9772b9ab1ccec7dc6cf8 Mon Sep 17 00:00:00 2001 From: darkrose Date: Sat, 25 Apr 2015 23:40:02 +1000 Subject: [PATCH] new crosshair --- data/textures/crosshair_focused.png | Bin 0 -> 265 bytes data/textures/crosshair_unfocused.png | Bin 0 -> 258 bytes src/game.cpp | 59 ++++++++++++++++++++------ 3 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 data/textures/crosshair_focused.png create mode 100644 data/textures/crosshair_unfocused.png diff --git a/data/textures/crosshair_focused.png b/data/textures/crosshair_focused.png new file mode 100644 index 0000000000000000000000000000000000000000..ae46e4987cd1a304c68738ce2690aa5a8f8f3232 GIT binary patch literal 265 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}oCO|{#S9Gm zi6G3l!hU%sP>{XE)7O>#K8qw5pNVVlvm~Im!J6CZ}-aeu-b9Z#{He9&Ugv0U&AFlzvncQ>Vd0U4<;{E^5w~P zn>FKFm%+w08{XE)7O>#K8qw5A47_z&~>2D6i*k&kch)qr+f1?DDbdKzrXNX{_D<5 z6Mj6tT&ARLzGo(bQ}(1YcTnTk>VmEVzv3_HMdE^G zqKo?lf5|Ln<&2uN&{Z>P+Tvc$TeBXX)x10J{l}wbOS-o#S_O0;gQu&X%Q~loCIFQb BV5$HB literal 0 HcmV?d00001 diff --git a/src/game.cpp b/src/game.cpp index 16da51f..003c069 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -366,7 +366,8 @@ void draw_hud( bool have_suffocation, s32 halfbubblecount, bool have_hunger, - s32 halfhungercount + s32 halfhungercount, + int crosshair ) { InventoryList *mainlist = inventory->getList("main"); @@ -651,6 +652,31 @@ void draw_hud( ); font->draw(txt.c_str(), rect2, video::SColor(255,255,255,255), false, false, NULL); } + + // crosshair + if (crosshair) { + const video::SColor color(220,255,255,255); + const video::SColor colors[] = {color,color,color,color}; + std::string tex(""); + if (crosshair == 1) { + tex = getTexturePath("crosshair_unfocused.png"); + }else{ + tex = getTexturePath("crosshair_focused.png"); + } + video::ITexture *texture = driver->getTexture(tex.c_str()); + core::rect rect((screensize.X/2)-16,(screensize.Y/2)-16,(screensize.X/2)+16,(screensize.Y/2)+16); + driver->draw2DImage( + texture, + rect, + core::rect( + core::position2d(0,0), + core::dimension2di(texture->getOriginalSize()) + ), + NULL, + colors, + true + ); + } } /* @@ -2601,18 +2627,6 @@ void the_game( } } - /* - Draw crosshair - */ - if (show_hud) { - driver->draw2DLine(displaycenter - core::vector2d(10,0), - displaycenter + core::vector2d(10,0), - video::SColor(255,255,255,255)); - driver->draw2DLine(displaycenter - core::vector2d(0,10), - displaycenter + core::vector2d(0,10), - video::SColor(255,255,255,255)); - } - } // timer /* @@ -2629,6 +2643,16 @@ void the_game( if (client.getServerHunger()) hunger = client.getHunger(); if (old_hotbar) { + + /* + Draw crosshair + */ + driver->draw2DLine(displaycenter - core::vector2d(10,0), + displaycenter + core::vector2d(10,0), + video::SColor(255,255,255,255)); + driver->draw2DLine(displaycenter - core::vector2d(0,10), + displaycenter + core::vector2d(0,10), + video::SColor(255,255,255,255)); draw_old_hotbar( driver, font, @@ -2641,6 +2665,12 @@ void the_game( hunger ); }else{ + int crosshair = 1; + if (g_menumgr.menuCount() > 0) { + crosshair = 0; + }else if (client.getPointedContent() != CONTENT_IGNORE) { + crosshair = 2; + } draw_hud( driver, font, @@ -2653,7 +2683,8 @@ void the_game( client.getServerSuffocation(), client.getAir(), client.getServerHunger(), - hunger + hunger, + crosshair ); } }