summaryrefslogtreecommitdiff
path: root/src/graphics.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-10 11:50:27 -0600
committerIra Rice <irarice@gmail.com>2009-03-10 11:50:27 -0600
commit58ee835c3763e7bf088fa6c7e31dda1d687589cc (patch)
tree2eb06f7ee3fa05af68fb536284497a9967222ad9 /src/graphics.cpp
parent5bbf8219bffbb587cf9a23561734c917bb23f42f (diff)
downloadmana-client-58ee835c3763e7bf088fa6c7e31dda1d687589cc.tar.gz
mana-client-58ee835c3763e7bf088fa6c7e31dda1d687589cc.tar.bz2
mana-client-58ee835c3763e7bf088fa6c7e31dda1d687589cc.tar.xz
mana-client-58ee835c3763e7bf088fa6c7e31dda1d687589cc.zip
Extended window layout to take relative positions, as well as offsets to
that position. This makes it so that when resolutions are changed, the default locations stay relative to the window's position, and not the 800x600 screen resolution. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r--src/graphics.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 3c507f4b..48fd1340 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -50,30 +50,25 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
mFullscreen = fs;
mHWAccel = hwaccel;
- if (fs) {
+ if (fs)
displayFlags |= SDL_FULLSCREEN;
- }
- if (hwaccel) {
+ if (hwaccel)
displayFlags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
- } else {
+ else
displayFlags |= SDL_SWSURFACE;
- }
mScreen = SDL_SetVideoMode(w, h, bpp, displayFlags);
- if (!mScreen) {
+ if (!mScreen)
return false;
- }
char videoDriverName[64];
- if (SDL_VideoDriverName(videoDriverName, 64)) {
+ if (SDL_VideoDriverName(videoDriverName, 64))
logger->log("Using video driver: %s", videoDriverName);
- }
- else {
+ else
logger->log("Using video driver: unknown");
- }
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
@@ -104,9 +99,8 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
bool Graphics::setFullscreen(bool fs)
{
- if (mFullscreen == fs) {
+ if (mFullscreen == fs)
return true;
- }
return setVideoMode(mScreen->w, mScreen->h,
mScreen->format->BitsPerPixel, fs, mHWAccel);
@@ -128,7 +122,7 @@ bool Graphics::drawImage(Image *image, int x, int y)
}
bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY,
- int width, int height, bool)
+ int width, int height, bool)
{
// Check that preconditions for blitting are met.
if (!mScreen || !image || !image->mImage) return false;
@@ -150,7 +144,7 @@ bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY,
}
void Graphics::drawImage(gcn::Image const *image, int srcX, int srcY,
- int dstX, int dstY, int width, int height)
+ int dstX, int dstY, int width, int height)
{
ProxyImage const *srcImage =
dynamic_cast< ProxyImage const * >(image);
@@ -167,8 +161,10 @@ void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h)
int px = 0; // X position on pattern plane
int py = 0; // Y position on pattern plane
- while (py < h) {
- while (px < w) {
+ while (py < h)
+ {
+ while (px < w)
+ {
int dw = (px + iw >= w) ? w - px : iw;
int dh = (py + ih >= h) ? h - py : ih;
drawImage(image, 0, 0, x + px, y + py, dw, dh);