From 1433667759388cb695ca555a1489cecfea3e044e Mon Sep 17 00:00:00 2001 From: darkrose Date: Thu, 26 Mar 2015 03:39:54 +1000 Subject: [PATCH] always show health/hunger icons when enabled --- src/game.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 96ff7ac..725545d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -354,9 +354,20 @@ void draw_old_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font, font->draw(selected.c_str(), rect2, video::SColor(255,255,255,255), false, false, NULL); } } -void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font, - v2s32 screensize, s32 imgsize, s32 itemcount, - Inventory *inventory, s32 halfheartcount, s32 halfbubblecount, s32 halfhungercount) +void draw_hud( + video::IVideoDriver *driver, + gui::IGUIFont *font, + v2s32 screensize, + s32 imgsize, + s32 itemcount, + Inventory *inventory, + bool have_health, + s32 halfheartcount, + bool have_suffocation, + s32 halfbubblecount, + bool have_hunger, + s32 halfhungercount +) { InventoryList *mainlist = inventory->getList("main"); if (mainlist == NULL) { @@ -545,7 +556,7 @@ void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font, } // health - if (halfheartcount) { + if (have_health) { int c = 55+(halfheartcount*10); const video::SColor color(220,c,c,c); const video::SColor colors[] = {color,color,color,color}; @@ -577,7 +588,7 @@ void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font, font->draw(txt.c_str(), rect2, video::SColor(255,255,255,255), false, false, NULL); } // air - if (halfbubblecount<20) { + if (have_suffocation && halfbubblecount<20) { int c = 55+(halfbubblecount*10); const video::SColor color(255,255,c,c); const video::SColor colors[] = {color,color,color,color}; @@ -609,7 +620,7 @@ void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font, font->draw(txt.c_str(), rect2, video::SColor(255,255,255,255), false, false, NULL); } // hunger - if (halfhungercount) { + if (have_hunger) { int c = 55+(halfhungercount*10); const video::SColor color(255,255,c,c); const video::SColor colors[] = {color,color,color,color}; @@ -2627,15 +2638,18 @@ void the_game( hunger ); }else{ - draw_hotbar( + draw_hud( driver, font, v2s32(screensize.X,screensize.Y), hotbar_imagesize, hotbar_itemcount, &local_inventory, + client.getServerDamage(), client.getHP(), + client.getServerSuffocation(), client.getAir(), + client.getServerHunger(), hunger ); }