summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/progressbar.cpp52
-rw-r--r--src/gui/progressbar.h24
-rw-r--r--src/gui/status.cpp46
3 files changed, 100 insertions, 22 deletions
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index 0a4afcf6..bfc481cf 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -25,18 +25,58 @@
#include "gui.h"
-ProgressBar::ProgressBar(float progress)
+ProgressBar::ProgressBar(float progress, int x, int y, int width, unsigned char red, unsigned green, unsigned char blue)
{
setProgress(progress);
+ Red = red;
+ Green = green;
+ Blue = blue;
+ X = x;
+ Y = y;
+ Width = width;
}
void ProgressBar::draw(gcn::Graphics *graphics)
{
- int x, y, w, h;
- getAbsolutePosition(x, y);
- w = getWidth();
- h = getHeight();
+ int absx, absy;
+ getAbsolutePosition(absx, absy);
+
+ // outer bar
+ int MyColor = makecol(abs(Red-70), abs(Green-70), abs(Blue-70));
+ hline(gui_bitmap, absx+X+7, absy+Y, absx+X+Width, MyColor);
+ hline(gui_bitmap, absx+X, absy+Y+7, absx+X+Width-7, MyColor);
+ line(gui_bitmap, absx+X+7, absy+Y, absx+X, absy+Y+7, MyColor);
+ line(gui_bitmap, absx+X+Width, absy+Y, absx+X+Width-7, absy+Y+7, MyColor);
+
+ // Shadow of outer bar
+ MyColor = makeacol(0, 0, 0, 80);
+ hline(gui_bitmap, absx+X+1, absy+Y+7+1, absx+X+Width-7, MyColor);
+ line(gui_bitmap, absx+X+Width+1, absy+Y, absx+X+Width-7+1, absy+Y+7, MyColor);
+
+
+ // Inner bar
+ MyColor = makecol(Red, Green, Blue);
+
+ int Temp = 0;
+
+
+ for(int i = 1; i < 7; i++)
+ {
+ Temp = absx+X+int(float(Width)*progress)-i-1;
+ if ( Temp < (absx+X+8-i) ) Temp = (absx+X+8-i);
+ hline(gui_bitmap, absx+X+8-i, absy+Y+i, Temp, MyColor);
+ }
+
+ // Shadow of inner bar
+ Temp = absx+X+int(float(Width)*progress)-2;
+ if ( Temp < (absx+X+7+1) ) Temp = absx+X+7;
+ MyColor = makeacol(abs(Red-40), abs(Green-40), abs(Blue-40), 80);
+ hline(gui_bitmap, absx+X+7+1, absy+Y+1, Temp, MyColor);
+ line(gui_bitmap, absx+X+7, absy+Y+1, absx+X+2, absy+Y+7-1, MyColor);
+ //rectfill(gui_bitmap, absx+7, absy+7, absx+39, absy+9, MyColor);
+
+/*
if (progress != 0) {
masked_blit(gui_skin.bar.bg.grid[3], gui_bitmap,
0, 0, x, y, gui_bitmap->w, gui_bitmap->h);
@@ -64,7 +104,7 @@ void ProgressBar::draw(gcn::Graphics *graphics)
else {
masked_blit(gui_skin.bar.bg.grid[2], gui_bitmap,
0, 0, x + w - 3, y, gui_bitmap->w, gui_bitmap->h);
- }
+ }*/
}
void ProgressBar::setProgress(float progress)
diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h
index 71d5c8f6..47b6f170 100644
--- a/src/gui/progressbar.h
+++ b/src/gui/progressbar.h
@@ -37,7 +37,7 @@ class ProgressBar : public gcn::Widget {
/**
* Constructor, initializes the progress with the given value.
*/
- ProgressBar(float progress = 0.0f);
+ ProgressBar(float progress = 0.0f, int x = 0, int y = 0, int width = 40, unsigned char red = 150, unsigned green = 150, unsigned char blue = 150);
/**
* Draws the progress bar.
@@ -53,9 +53,31 @@ class ProgressBar : public gcn::Widget {
* Returns the current progress.
*/
float getProgress();
+
+ /**
+ * Change the filling of the progress bar...
+ */
+ void setColor(unsigned char MyRed, unsigned char MyGreen, unsigned char MyBlue)
+ {
+ Red = MyRed; Green = MyGreen; Blue = MyBlue;
+ };
+
+ int getHeight()
+ { return 7; };
+
+ int getWidth()
+ { return Width; };
+
+ int getX()
+ { return X; };
+
+ int getY()
+ { return Y; };
private:
float progress;
+ unsigned char Red, Green, Blue;
+ int X, Y, Width;
};
#endif
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 29de00d4..99ab948c 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -33,26 +33,25 @@ StatusWindow::StatusWindow():
gp = new gcn::Label("GP");
expLabel = new gcn::Label("Exp");
jobExpLabel = new gcn::Label("Job");
- healthBar = new ProgressBar(1.0f);
- manaBar = new ProgressBar(1.0f);
- xpBar = new ProgressBar(1.0f);
- jobXpBar = new ProgressBar(1.0f);
-
- setSize(250, 70);
+
hp->setPosition(5, 5);
sp->setPosition(5, hp->getY() + hp->getHeight() + 5);
- healthBar->setDimension(gcn::Rectangle(25, hp->getY() + 1, 60, 18));
- manaBar->setDimension(gcn::Rectangle(25, sp->getY() + 1, 60, 18));
- hpValue->setPosition(
- healthBar->getX() + healthBar->getWidth() + 5, hp->getY());
- spValue->setPosition(
- manaBar->getX() + manaBar->getWidth() + 5, sp->getY());
+ //healthBar->setDimension(gcn::Rectangle(25, hp->getY() + 1, 60, 18));
+ //manaBar->setDimension(gcn::Rectangle(25, sp->getY() + 1, 60, 18));
+ hpValue->setPosition(120, 5);
+ spValue->setPosition(120, hp->getY() + hp->getHeight() + 5);
gp->setPosition(180, 20);
expLabel->setPosition(6, 40);
jobExpLabel->setPosition(106, 40);
- xpBar->setDimension(gcn::Rectangle(16, 55, 60, 18));
- jobXpBar->setDimension(gcn::Rectangle(116, 55, 60, 18));
-
+ //xpBar->setDimension(gcn::Rectangle(16, 55, 60, 18));
+ //jobXpBar->setDimension(gcn::Rectangle(116, 55, 60, 18));
+
+ healthBar = new ProgressBar(1.0f, 20, 8, 80, 0, 255, 0);
+ manaBar = new ProgressBar(1.0f, 20, 26, 80, 0, 0, 255);
+ xpBar = new ProgressBar(1.0f, 6, 55, 70, 12, 194, 255);
+ jobXpBar = new ProgressBar(1.0f, 106, 55, 70, 200, 0, 0);
+ setSize(250, 70);
+
add(hp);
add(sp);
add(healthBar);
@@ -107,6 +106,23 @@ void StatusWindow::update()
jobExpLabel->setCaption(tempstr);
jobExpLabel->adjustSize();
+ if ( char_info->hp < int(char_info->max_hp / 3) )
+ {
+ healthBar->setColor(255, 0, 0); // Red
+ }
+ else
+ {
+ if ( char_info->hp < int( (char_info->max_hp / 3)*2 ) )
+ {
+ healthBar->setColor(255, 181, 9); // orange
+ }
+ else
+ {
+ healthBar->setColor(0, 255, 0); // Green
+ }
+ }
+
+
healthBar->setProgress((float)char_info->hp / (float)char_info->max_hp);
xpBar->setProgress((float)char_info->xp / (float)char_info->xpForNextLevel);