summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-28 03:23:46 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-28 03:23:46 +0000
commitaa3f1e097f20695fca6384389f9065a26d29f407 (patch)
treee3c32476c17f17159793f2c73d92be3f9a91dbbf
parent434bd8ec146b5001f8f20ee893f13ba8ba478be9 (diff)
downloadmana-client-aa3f1e097f20695fca6384389f9065a26d29f407.tar.gz
mana-client-aa3f1e097f20695fca6384389f9065a26d29f407.tar.bz2
mana-client-aa3f1e097f20695fca6384389f9065a26d29f407.tar.xz
mana-client-aa3f1e097f20695fca6384389f9065a26d29f407.zip
Formatting updates.
-rw-r--r--docs/progression.txt2
-rw-r--r--src/gui/progressbar.cpp54
-rw-r--r--src/gui/progressbar.h32
-rw-r--r--src/gui/setup.cpp154
-rw-r--r--src/gui/setup.h30
5 files changed, 147 insertions, 125 deletions
diff --git a/docs/progression.txt b/docs/progression.txt
index ce348170..d277b4aa 100644
--- a/docs/progression.txt
+++ b/docs/progression.txt
@@ -64,7 +64,7 @@ Evade (%) : Indicate the chance a player has to evade an opponent's hit.
Evade = ((3 * Luck + Spirit + Vitality )/5) (Max : 75 %)
-3. AN ATTCK PROCESS
+3. AN ATTACK PROCESS
An attack process is quite simple :
The Hit(%) of the attacker is taken, minus the evade of the opponent.
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index aa396a70..5ef5e03f 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -25,13 +25,12 @@
#include "gui.h"
#include "../resources/resourcemanager.h"
-ProgressBar::ProgressBar(float progress, int x, int y, int width, int height, unsigned char red, unsigned green, unsigned char blue) :
-gcn::Widget()
+ProgressBar::ProgressBar(float progress, int x, int y, int width, int height,
+ unsigned char red, unsigned green, unsigned char blue):
+ gcn::Widget(),
+ red(red), green(green), blue(blue)
{
setProgress(progress);
- Red = red;
- Green = green;
- Blue = blue;
setX(x);
setY(y);
setWidth(width);
@@ -66,7 +65,7 @@ gcn::Widget()
colorBar = new Image();
colorBar->create(getWidth() - 8, getHeight() - 8);
- colorBar->fillWithColor(Red, Green, Blue);
+ colorBar->fillWithColor(red, green, blue);
colorBar->setAlpha(0.7f);
}
@@ -79,29 +78,32 @@ ProgressBar::~ProgressBar()
void ProgressBar::draw(gcn::Graphics *graphics)
{
-#ifndef USE_OPENGL
int absx, absy;
getAbsolutePosition(absx, absy);
// We're drawing the bar itself first
// Background
- dBackground->drawPattern(screen, absx+4, absy+4, getWidth()-8, getHeight()-8);
+ dBackground->drawPattern(screen,
+ absx + 4, absy + 4,
+ getWidth() - 8, getHeight() - 8);
+
// The corners
dTopLeftBorder->draw(screen, absx, absy);
- dTopRightBorder->draw(screen, absx+getWidth()-4, absy);
- dBottomLeftBorder->draw(screen, absx, absy+getHeight()-4);
- dBottomRightBorder->draw(screen, absx+getWidth()-4, absy+getHeight()-4);
+ dTopRightBorder->draw(screen, absx + getWidth() - 4, absy);
+ dBottomLeftBorder->draw(screen, absx, absy + getHeight() - 4);
+ dBottomRightBorder->draw(screen,
+ absx+getWidth() - 4, absy+getHeight() - 4);
// The borders
- dTopBorder->drawPattern(screen, absx+4, absy, getWidth()-8, 4);
- dBottomBorder->drawPattern(screen, absx+4, absy+getHeight()-4, getWidth()-8, 4);
- dLeftBorder->drawPattern(screen, absx, absy+4, 4, getHeight()-8);
- dRightBorder->drawPattern(screen, absx+getWidth()-4, absy+4, 4, getHeight()-8);
+ dTopBorder->drawPattern(screen, absx + 4, absy, getWidth() - 8, 4);
+ dBottomBorder->drawPattern(screen, absx + 4, absy + getHeight() - 4,
+ getWidth() - 8, 4);
+ dLeftBorder->drawPattern(screen, absx, absy + 4, 4, getHeight() - 8);
+ dRightBorder->drawPattern(screen, absx + getWidth() - 4, absy + 4,
+ 4, getHeight() - 8);
colorBar->draw(screen, 0, 0, absx + 4, absy + 4,
- int(progress*float(getWidth()-4)), getHeight() - 8);
-
-#endif
+ (int)(progress * float(getWidth() - 4)), getHeight() - 8);
}
void ProgressBar::setProgress(float progress)
@@ -114,17 +116,15 @@ float ProgressBar::getProgress()
return progress;
}
-void ProgressBar::setColor(unsigned char MyRed, unsigned char MyGreen,
- unsigned char MyBlue)
+void ProgressBar::setColor(
+ unsigned char newRed, unsigned char newGreen, unsigned char newBlue)
{
- if ( (Red == MyRed) && (Green == MyGreen) && (Blue == MyBlue) )
- {
- // Nothing
- }
- else
+ if (!(red == newRed) && (green == newGreen) && (blue == newBlue))
{
- Red = MyRed; Green = MyGreen; Blue = MyBlue;
- colorBar->fillWithColor(Red, Green, Blue);
+ red = newRed;
+ green = newGreen;
+ blue = newBlue;
+ colorBar->fillWithColor(red, green, blue);
colorBar->setAlpha(0.7f);
}
}
diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h
index 5da046b7..c8bb22d6 100644
--- a/src/gui/progressbar.h
+++ b/src/gui/progressbar.h
@@ -38,11 +38,12 @@ class ProgressBar : public gcn::Widget {
* Constructor, initializes the progress with the given value.
*/
ProgressBar(float progress = 0.0f, int x = 0, int y = 0,
- int width = 40, int height = 7, unsigned char red = 150, unsigned green = 150,
+ int width = 40, int height = 7,
+ unsigned char red = 150, unsigned green = 150,
unsigned char blue = 150);
/**
- * Destructor
+ * Destructor.
*/
~ProgressBar();
@@ -62,38 +63,47 @@ class ProgressBar : public gcn::Widget {
float getProgress();
/**
- * Change the filling of the progress bar...
+ * Change the filling of the progress bar.
*/
void setColor(
- unsigned char MyRed,
- unsigned char MyGreen,
- unsigned char MyBlue);
+ unsigned char red,
+ unsigned char green,
+ unsigned char blue);
/**
* Get The red value of color
*/
unsigned char getRed()
- { return Red; };
+ {
+ return red;
+ }
/**
* Get The red value of color
*/
unsigned char getGreen()
- { return Green; };
+ {
+ return green;
+ }
/**
* Get The red value of color
*/
unsigned char getBlue()
- { return Blue; };
+ {
+ return blue;
+ }
private:
float progress;
- unsigned char Red, Green, Blue;
+ unsigned char red, green, blue;
+
// Bar Images
Image *dBackground;
- Image *dTopLeftBorder, *dTopRightBorder, *dBottomLeftBorder, *dBottomRightBorder;
+ Image *dTopLeftBorder, *dTopRightBorder, *dBottomLeftBorder;
+ Image *dBottomRightBorder;
Image *dLeftBorder, *dRightBorder, *dTopBorder, *dBottomBorder;
+
// Our color bar
Image *colorBar;
};
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index ea2bb6bf..b43a469c 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -41,48 +41,55 @@
SDL_Rect **modes;
-ModeListModel::ModeListModel() {
- int i;
-
- modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
-
- // Check if any modes available
- if(modes == (SDL_Rect **)0) {
- nmode=0;
- puts("No modes");
- }
-
- // Check if modes restricted
- if(modes == (SDL_Rect **)-1)
- puts("Modes restricted");
-
- for(nmode=0;modes[nmode];++nmode);
-
- mode = (char **) calloc(nmode, sizeof(char *));
-
- for(i=0;modes[i];++i) {
- char *temp = (char *)malloc(20 * sizeof(char));
+ModeListModel::ModeListModel()
+{
+ int i;
+
+ modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
+
+ // Check if any modes available
+ if (modes == (SDL_Rect**)0) {
+ nmode = 0;
+ puts("No modes");
+ }
+
+ // Check if modes restricted
+ if (modes == (SDL_Rect**) - 1) {
+ puts("Modes restricted");
+ }
+
+ for (nmode = 0; modes[nmode]; ++nmode);
+
+ mode = (char**)calloc(nmode, sizeof(char*));
+
+ for (i = 0; modes[i]; ++i) {
+ char *temp = (char*)malloc(20 * sizeof(char));
mode[i] = temp;
- if(sprintf(mode[i], "%d x %d", modes[i]->w, modes[i]->h) == -1)
- puts("Cannot allocate mode list");
- }
+ if (sprintf(mode[i], "%d x %d", modes[i]->w, modes[i]->h) == -1)
+ puts("Cannot allocate mode list");
+ }
}
-ModeListModel::~ModeListModel() {
- int i;
-
- // Cleanup
- for(i=0;i<nmode;i++)
- free(mode[i]);
- free(mode);
+ModeListModel::~ModeListModel()
+{
+ int i;
+
+ // Cleanup
+ for (i = 0; i < nmode; i++) {
+ free(mode[i]);
+ }
+
+ free(mode);
}
-int ModeListModel::getNumberOfElements() {
- return nmode;
+int ModeListModel::getNumberOfElements()
+{
+ return nmode;
}
-std::string ModeListModel::getElementAt(int i) {
- return mode[i];
+std::string ModeListModel::getElementAt(int i)
+{
+ return mode[i];
}
Setup::Setup():
@@ -147,7 +154,8 @@ Setup::Setup():
soundCheckBox->setMarked(config.getValue("sound", 0));
}
-Setup::~Setup() {
+Setup::~Setup()
+{
delete modeListModel;
delete modeList;
delete scrollArea;
@@ -159,53 +167,57 @@ Setup::~Setup() {
delete cancelButton;
}
-void Setup::action(const std::string& eventId)
+void Setup::action(const std::string &eventId)
{
- if (eventId == "apply") {
+ if (eventId == "apply")
+ {
setVisible(false);
-
- // Select video mode
+
+ // Select video mode
sel = modeList->getSelected();
-
- if(sel != last_sel) {
- last_sel = sel;
- screen = SDL_SetVideoMode(modes[sel]->w, modes[sel]->h, 32, SDL_FULLSCREEN | SDL_HWSURFACE);
- }
-
+
+ if (sel != last_sel) {
+ last_sel = sel;
+ screen = SDL_SetVideoMode(modes[sel]->w, modes[sel]->h, 32,
+ SDL_FULLSCREEN | SDL_HWSURFACE);
+ }
+
// Display settings
if (fsCheckBox->isMarked() && config.getValue("screen", 0) == 0)
{
config.setValue("screen", 1);
- #if __USE_UNIX98
- SDL_WM_ToggleFullScreen(screen);
- #else
- int displayFlags = 0;
- displayFlags |= SDL_FULLSCREEN;
- if ((int)config.getValue("hwaccel", 0)) {
- displayFlags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
- }
- else {
- displayFlags |= SDL_SWSURFACE;
- }
- screen = SDL_SetVideoMode(modes[sel]->w, modes[sel]->h, 32, displayFlags);
- #endif
+#if __USE_UNIX98
+ SDL_WM_ToggleFullScreen(screen);
+#else
+ int displayFlags = 0;
+ displayFlags |= SDL_FULLSCREEN;
+ if ((int)config.getValue("hwaccel", 0)) {
+ displayFlags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
+ }
+ else {
+ displayFlags |= SDL_SWSURFACE;
+ }
+ screen = SDL_SetVideoMode(modes[sel]->w, modes[sel]->h, 32,
+ displayFlags);
+#endif
}
else if (!fsCheckBox->isMarked() && config.getValue("screen", 0) == 1)
{
config.setValue("screen", 0);
- #if __USE_UNIX98
- SDL_WM_ToggleFullScreen(screen);
- #else
- int displayFlags = 0;
- if ((int)config.getValue("hwaccel", 0)) {
- displayFlags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
- }
- else {
- displayFlags |= SDL_SWSURFACE;
- }
- screen = SDL_SetVideoMode(modes[sel]->w, modes[sel]->h, 32, displayFlags);
- #endif
+#if __USE_UNIX98
+ SDL_WM_ToggleFullScreen(screen);
+#else
+ int displayFlags = 0;
+ if ((int)config.getValue("hwaccel", 0)) {
+ displayFlags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
+ }
+ else {
+ displayFlags |= SDL_SWSURFACE;
+ }
+ screen = SDL_SetVideoMode(modes[sel]->w, modes[sel]->h, 32,
+ displayFlags);
+#endif
}
// Sound settings
diff --git a/src/gui/setup.h b/src/gui/setup.h
index e1f28beb..2bfab15e 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -35,6 +35,16 @@
class ModeListModel : public gcn::ListModel {
public:
/**
+ * Constructor.
+ */
+ ModeListModel();
+
+ /**
+ * Destructor.
+ */
+ virtual ~ModeListModel();
+
+ /**
* Returns the number of elements in container.
*/
int getNumberOfElements();
@@ -44,19 +54,9 @@ class ModeListModel : public gcn::ListModel {
*/
std::string getElementAt(int i);
- /**
- * Constructor.
- */
- ModeListModel();
-
- /**
- * Destructor.
- */
- virtual ~ModeListModel();
-
private:
- int nmode;
- char **mode;
+ int nmode;
+ char **mode;
};
/**
@@ -78,9 +78,9 @@ class Setup : public Window, public gcn::ActionListener {
gcn::Button *applyButton;
gcn::Button *cancelButton;
- // Video selections
- int last_sel, sel;
-
+ // Video selections
+ int last_sel, sel;
+
public:
/**