From c69213695aa24af069e634684b559535ebbdafb5 Mon Sep 17 00:00:00 2001 From: Tamir Atias Date: Mon, 16 Jan 2012 06:32:54 +0200 Subject: [PATCH] [Add] Bar class for progress bars. --- Win32/Unuk/LibUnuk/LibUnuk.vcproj | 8 ++++++++ src/Unuk/Game.cpp | 18 ++++++------------ src/Unuk/Game.h | 7 +++---- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Win32/Unuk/LibUnuk/LibUnuk.vcproj b/Win32/Unuk/LibUnuk/LibUnuk.vcproj index b21ebea..3263c2b 100644 --- a/Win32/Unuk/LibUnuk/LibUnuk.vcproj +++ b/Win32/Unuk/LibUnuk/LibUnuk.vcproj @@ -328,6 +328,14 @@ + + + + diff --git a/src/Unuk/Game.cpp b/src/Unuk/Game.cpp index d5d2526..bf3fba5 100644 --- a/src/Unuk/Game.cpp +++ b/src/Unuk/Game.cpp @@ -48,13 +48,10 @@ gameNavVal_t Game::Run(const string savegameIDArg) { _npcHealth.SetXY(10, 110); _npcHealth.SetTextBlended("NPC X Health - XX", vsmall, COLOUR_BLACK); - _healthBarBg.SetRGB(0, 0, 0); - _healthBarBg.SetXY(10, 20); - _healthBarBg.SetWidthHeight(200, 25); - - _healthBar.SetRGB(255, 0, 0); - _healthBar.SetXY(10, 20); - _healthBar.SetWidthHeight(200, 25); + _playerHealthBar.SetBackgroundRGB(0, 0, 0); + _playerHealthBar.SetForegroundRGB(255, 0, 0); + _playerHealthBar.SetXY(10, 20); + _playerHealthBar.SetWidthHeight(200, 25); stringstream playerHealth; _playerHealth.SetXY(15, 27); @@ -102,9 +99,7 @@ gameNavVal_t Game::Run(const string savegameIDArg) { playerHealth << "Player Health: " << _player->GetHealth(); _playerHealth.SetTextBlended(playerHealth.str(), vsmall, COLOUR_WHITE); - _healthBar.SetWidthHeight( - (int)(((float)_player->GetHealth() / 100.0f) * 200.0f), - _healthBar.GetHeight()); + _playerHealthBar.SetProgress((float)_player->GetHealth() / 100.0f); // Check to see if we are allowed to display debug info. if(debugEnabled) { @@ -206,8 +201,7 @@ void Game::Render(void) { _map.Render(); _player->Render(); - _healthBarBg.DrawLiteral(); - _healthBar.DrawLiteral(); + _playerHealthBar.DrawLiteral(); _playerHealth.RenderLiteral(); if(debugEnabled) { diff --git a/src/Unuk/Game.h b/src/Unuk/Game.h index 723ab21..ce6daa6 100644 --- a/src/Unuk/Game.h +++ b/src/Unuk/Game.h @@ -15,8 +15,8 @@ #include "../libUnuk/System/Timer.h" #include "../libUnuk/System/Debug.h" #include "../libUnuk/UI/Text.h" +#include "../libUnuk/UI/Bar.h" #include "../libUnuk/Engine/MemClass.h" -#include "../libUnuk/System/Rect.h" using namespace std; enum gameNavVal_t { gameMainMenu, gameQuitGame }; @@ -57,7 +57,6 @@ private: Player* _player; - Text _playerHealth; - Rect _healthBarBg; - Rect _healthBar; + Text _playerHealth; + Bar _playerHealthBar; };