[Add] Bar class for progress bars.

This commit is contained in:
Tamir Atias 2012-01-16 06:32:54 +02:00
parent 285479cda6
commit c69213695a
3 changed files with 17 additions and 16 deletions

View File

@ -328,6 +328,14 @@
<Filter
Name="Ui"
>
<File
RelativePath="..\..\..\src\libUnuk\UI\Bar.cpp"
>
</File>
<File
RelativePath="..\..\..\src\libUnuk\UI\Bar.h"
>
</File>
<File
RelativePath="..\..\..\src\libUnuk\Ui\Button.cpp"
>

View File

@ -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) {

View File

@ -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 };
@ -58,6 +58,5 @@ private:
Player* _player;
Text _playerHealth;
Rect _healthBarBg;
Rect _healthBar;
Bar _playerHealthBar;
};