summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/.cvsignore1
-rw-r--r--src/game.cpp2
-rw-r--r--src/resources/image.cpp25
-rw-r--r--src/resources/image.h11
4 files changed, 38 insertions, 1 deletions
diff --git a/src/.cvsignore b/src/.cvsignore
index 9a639215..8bd3ad01 100644
--- a/src/.cvsignore
+++ b/src/.cvsignore
@@ -1,3 +1,4 @@
.deps
Makefile.in
Makefile
+tmw
diff --git a/src/game.cpp b/src/game.cpp
index 2d9c4cc7..4db888f8 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -385,7 +385,7 @@ void do_input()
int get_packet_length(short id) {
int len = get_length(id);
- if (len == -1)len = RFIFOW(2);
+ if (len == -1) len = RFIFOW(2);
return len;
}
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index eca4b42f..02eb2393 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -40,6 +40,8 @@ Image::Image(GLuint image, int width, int height, int texWidth, int texHeight):
texHeight(texHeight)
#endif
{
+ // Default to opaque
+ alpha = 1.0f;
}
Image::~Image()
@@ -250,6 +252,9 @@ bool Image::draw(SDL_Surface *screen, int srcX, int srcY, int dstX, int dstY,
// Check that preconditions for blitting are met.
if (screen == NULL || image == NULL) return false;
+ // Set the alpha value this image is drawn at
+ SDL_SetAlpha(image, SDL_SRCALPHA, 255 * alpha);
+
SDL_Rect dstRect;
SDL_Rect srcRect;
dstRect.x = dstX; dstRect.y = dstY;
@@ -303,6 +308,9 @@ bool Image::draw(SDL_Surface *screen, int x, int y)
// Check that preconditions for blitting are met.
if (screen == NULL || image == NULL) return false;
+ // Set the alpha value this image is drawn at
+ SDL_SetAlpha(image, SDL_SRCALPHA, 255 * alpha);
+
SDL_Rect dstRect;
dstRect.x = x;
dstRect.y = y;
@@ -367,6 +375,17 @@ void Image::drawPattern(SDL_Surface *screen, int x, int y, int w, int h)
}
}
+void Image::setAlpha(float alpha)
+{
+ this->alpha = alpha;
+}
+
+float Image::getAlpha()
+{
+ return alpha;
+}
+
+
//============================================================================
#ifndef USE_OPENGL
@@ -420,6 +439,9 @@ bool SubImage::draw(SDL_Surface *screen, int srcX, int srcY,
// Check that preconditions for blitting are met.
if (screen == NULL || image == NULL) return false;
+ // Set the alpha value this image is drawn at
+ SDL_SetAlpha(image, SDL_SRCALPHA, 255 * alpha);
+
SDL_Rect dstRect;
SDL_Rect srcRect;
dstRect.x = dstX; dstRect.y = dstY;
@@ -473,6 +495,9 @@ bool SubImage::draw(SDL_Surface *screen, int x, int y)
// Check that drawing preconditions are satisfied.
if (screen == NULL || image == NULL) return false;
+ // Set the alpha value this image is drawn at
+ SDL_SetAlpha(image, SDL_SRCALPHA, 255 * alpha);
+
SDL_Rect dstRect;
dstRect.x = x;
dstRect.y = y;
diff --git a/src/resources/image.h b/src/resources/image.h
index 09a0fc7e..a92e6cc3 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -117,6 +117,16 @@ class Image : public Resource
virtual void drawPattern(
SDL_Surface *screen, int x, int y, int w, int h);
+ /**
+ * Sets the alpha value of this image.
+ */
+ void setAlpha(float alpha);
+
+ /**
+ * Returns the alpha value of this image.
+ */
+ float getAlpha();
+
protected:
#ifdef USE_OPENGL
GLuint image;
@@ -125,6 +135,7 @@ class Image : public Resource
#else
SDL_Surface *image;
#endif
+ float alpha;
};
/**