[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 <Filter
Name="Ui" Name="Ui"
> >
<File
RelativePath="..\..\..\src\libUnuk\UI\Bar.cpp"
>
</File>
<File
RelativePath="..\..\..\src\libUnuk\UI\Bar.h"
>
</File>
<File <File
RelativePath="..\..\..\src\libUnuk\Ui\Button.cpp" RelativePath="..\..\..\src\libUnuk\Ui\Button.cpp"
> >

View File

@ -48,13 +48,10 @@ gameNavVal_t Game::Run(const string savegameIDArg) {
_npcHealth.SetXY(10, 110); _npcHealth.SetXY(10, 110);
_npcHealth.SetTextBlended("NPC X Health - XX", vsmall, COLOUR_BLACK); _npcHealth.SetTextBlended("NPC X Health - XX", vsmall, COLOUR_BLACK);
_healthBarBg.SetRGB(0, 0, 0); _playerHealthBar.SetBackgroundRGB(0, 0, 0);
_healthBarBg.SetXY(10, 20); _playerHealthBar.SetForegroundRGB(255, 0, 0);
_healthBarBg.SetWidthHeight(200, 25); _playerHealthBar.SetXY(10, 20);
_playerHealthBar.SetWidthHeight(200, 25);
_healthBar.SetRGB(255, 0, 0);
_healthBar.SetXY(10, 20);
_healthBar.SetWidthHeight(200, 25);
stringstream playerHealth; stringstream playerHealth;
_playerHealth.SetXY(15, 27); _playerHealth.SetXY(15, 27);
@ -102,9 +99,7 @@ gameNavVal_t Game::Run(const string savegameIDArg) {
playerHealth << "Player Health: " << _player->GetHealth(); playerHealth << "Player Health: " << _player->GetHealth();
_playerHealth.SetTextBlended(playerHealth.str(), vsmall, COLOUR_WHITE); _playerHealth.SetTextBlended(playerHealth.str(), vsmall, COLOUR_WHITE);
_healthBar.SetWidthHeight( _playerHealthBar.SetProgress((float)_player->GetHealth() / 100.0f);
(int)(((float)_player->GetHealth() / 100.0f) * 200.0f),
_healthBar.GetHeight());
// Check to see if we are allowed to display debug info. // Check to see if we are allowed to display debug info.
if(debugEnabled) { if(debugEnabled) {
@ -206,8 +201,7 @@ void Game::Render(void) {
_map.Render(); _map.Render();
_player->Render(); _player->Render();
_healthBarBg.DrawLiteral(); _playerHealthBar.DrawLiteral();
_healthBar.DrawLiteral();
_playerHealth.RenderLiteral(); _playerHealth.RenderLiteral();
if(debugEnabled) { if(debugEnabled) {

View File

@ -15,8 +15,8 @@
#include "../libUnuk/System/Timer.h" #include "../libUnuk/System/Timer.h"
#include "../libUnuk/System/Debug.h" #include "../libUnuk/System/Debug.h"
#include "../libUnuk/UI/Text.h" #include "../libUnuk/UI/Text.h"
#include "../libUnuk/UI/Bar.h"
#include "../libUnuk/Engine/MemClass.h" #include "../libUnuk/Engine/MemClass.h"
#include "../libUnuk/System/Rect.h"
using namespace std; using namespace std;
enum gameNavVal_t { gameMainMenu, gameQuitGame }; enum gameNavVal_t { gameMainMenu, gameQuitGame };
@ -57,7 +57,6 @@ private:
Player* _player; Player* _player;
Text _playerHealth; Text _playerHealth;
Rect _healthBarBg; Bar _playerHealthBar;
Rect _healthBar;
}; };