summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--src/configuration.cpp6
-rw-r--r--src/graphics.cpp3
-rw-r--r--src/gui/button.cpp5
-rw-r--r--src/gui/checkbox.cpp7
-rw-r--r--src/gui/equipmentwindow.cpp8
-rw-r--r--src/gui/itemcontainer.cpp6
-rw-r--r--src/gui/minimap.cpp5
-rw-r--r--src/gui/passwordfield.cpp8
-rw-r--r--src/gui/playerbox.cpp39
-rw-r--r--src/gui/progressbar.cpp5
-rw-r--r--src/gui/radiobutton.cpp7
-rw-r--r--src/gui/scrollarea.cpp21
-rw-r--r--src/gui/slider.cpp16
-rw-r--r--src/gui/textfield.cpp12
-rw-r--r--src/gui/window.cpp11
-rw-r--r--src/openglgraphics.cpp3
17 files changed, 62 insertions, 109 deletions
diff --git a/ChangeLog b/ChangeLog
index eb637797..19c364a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,15 @@
2005-08-25 Björn Steinbrink <B.Steinbrink@gmx.de>
+ * src/configuration.cpp: Fix compilation errors.
+ * src/graphics.cpp, src/openglgraphics.cpp, src/gui/button.cpp,
+ src/gui/checkbox.cpp, src/gui/equipmentwindow.cpp,
+ src/gui/itemcontainer.cpp, src/gui/minimap.cpp,
+ src/gui/passwordfield.cpp, src/gui/playerbox.cpp,
+ stc/gui/progressbar.cpp, src/gui/radiobutton.cpp,
+ src/gui/scrollarea.cpp, src/gui/slider.cpp, src/gui/textfield.cpp,
+ src/gui/window.cpp: Made our Graphics::drawImage() method respect the
+ clip area from the guichan part. Removed some obsolete code.
* src/gui/tabbedcontainer.h: Fix include path for guichanfwd.h.
* src/gui/tabbedcontainer.cpp, src/gui/tabbedcontainer.h: Added a new
container type, that allows switching between the contents through a
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 5e21ee5a..0b43418f 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -24,15 +24,17 @@
#include "configuration.h"
+#include <math.h>
#include <sstream>
#include <libxml/xmlwriter.h>
#include "configlistener.h"
#include "log.h"
-void Configuration::init(const std::string &filename):
- mConfigPath(filename)
+void Configuration::init(const std::string &filename)
{
+ mConfigPath = filename;
+
// Do not attempt to read config from non-existant file
FILE *testFile = fopen(filename.c_str(), "r");
if (!testFile) {
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 9bfce133..47414ff0 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -132,6 +132,9 @@ 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)
{
+ dstX += mClipStack.top().xOffset;
+ dstY += mClipStack.top().yOffset;
+
srcX += image->bounds.x;
srcY += image->bounds.y;
diff --git a/src/gui/button.cpp b/src/gui/button.cpp
index 680a9152..b2468036 100644
--- a/src/gui/button.cpp
+++ b/src/gui/button.cpp
@@ -112,10 +112,7 @@ void Button::draw(gcn::Graphics* graphics)
mode = 0;
}
- int x, y;
- getAbsolutePosition(x, y);
-
- dynamic_cast<Graphics*>(graphics)->drawImageRect(x, y, getWidth(), getHeight(),
+ dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0, getWidth(), getHeight(),
button[mode]);
graphics->setColor(getForegroundColor());
diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp
index ce7762d9..7506d3c0 100644
--- a/src/gui/checkbox.cpp
+++ b/src/gui/checkbox.cpp
@@ -68,9 +68,6 @@ CheckBox::~CheckBox()
void CheckBox::drawBox(gcn::Graphics* graphics)
{
Image *box = NULL;
- int x, y;
-
- getAbsolutePosition(x, y);
if (mMarked) {
if (isEnabled()) {
@@ -84,9 +81,7 @@ void CheckBox::drawBox(gcn::Graphics* graphics)
box = checkBoxDisabled;
}
- x += 2;
- y += 2;
if (box != NULL) {
- dynamic_cast<Graphics*>(graphics)->drawImage(box, x, y);
+ dynamic_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
}
}
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 0aeb58e4..5ed0c189 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -54,9 +54,6 @@ EquipmentWindow::~EquipmentWindow()
void EquipmentWindow::draw(gcn::Graphics *graphics)
{
- int x, y;
- getAbsolutePosition(x, y);
-
// Draw window graphics
Window::draw(graphics);
@@ -75,7 +72,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
image = itemset->spriteset[item->getInfo()->getImage() - 1];
dynamic_cast<Graphics*>(graphics)->drawImage(
- image, x + 36 * (i % 4) + 10, y + 36 * (i / 4) + 25);
+ image, 36 * (i % 4) + 10, 36 * (i / 4) + 25);
}
graphics->setColor(gcn::Color(0, 0, 0));
@@ -87,8 +84,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
image = itemset->spriteset[item->getInfo()->getImage() - 1];
- dynamic_cast<Graphics*>(graphics)->drawImage(
- image, x + 160, y + 25);
+ dynamic_cast<Graphics*>(graphics)->drawImage(image, 160, 25);
std::stringstream n;
n << item->getQuantity();
graphics->drawText(n.str(), 170, 62,
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index e2eb6085..7c7baddc 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -78,8 +78,6 @@ void ItemContainer::draw(gcn::Graphics* graphics)
int gridHeight = itemset->spriteset[0]->getHeight() + 10;
int w = getWidth();
int columns = w / gridWidth;
- int x, y;
- getAbsolutePosition(x, y);
// Have at least 1 column
if (columns < 1)
@@ -113,7 +111,7 @@ void ItemContainer::draw(gcn::Graphics* graphics)
if (selectedItem == item)
{
dynamic_cast<Graphics*>(graphics)->drawImage(
- selImg, x + itemX, y + itemY);
+ selImg, itemX, itemY);
}
// Draw item icon
@@ -121,7 +119,7 @@ void ItemContainer::draw(gcn::Graphics* graphics)
if ((idx = item->getInfo()->getImage()) > 0)
{
dynamic_cast<Graphics*>(graphics)->drawImage(
- itemset->spriteset[idx - 1], x + itemX, y + itemY);
+ itemset->spriteset[idx - 1], itemX, itemY);
}
// Draw item caption
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 7b2367c0..6e8d8a04 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -73,13 +73,10 @@ void Minimap::draw(gcn::Graphics *graphics)
{
Window::draw(graphics);
- int x, y;
- getAbsolutePosition(x, y);
-
if (mMapImage != NULL)
{
dynamic_cast<Graphics*>(graphics)->drawImage(
- mMapImage, x + getPadding(), y + getTitleBarHeight());
+ mMapImage, getPadding(), getTitleBarHeight());
}
std::list<Being*>::iterator bi;
diff --git a/src/gui/passwordfield.cpp b/src/gui/passwordfield.cpp
index 29ddb86b..51316fa8 100644
--- a/src/gui/passwordfield.cpp
+++ b/src/gui/passwordfield.cpp
@@ -31,14 +31,10 @@ PasswordField::PasswordField(const std::string& text):
void PasswordField::draw(gcn::Graphics *graphics)
{
- int x, y, w, h;
- getAbsolutePosition(x, y);
- w = getWidth();
- h = getHeight();
std::string stars;
stars.assign(mText.length(), '*');
- if (hasFocus()) {
+ if (hasFocus()) {
drawCaret(graphics,
getFont()->getWidth(stars.substr(0, mCaretPosition)) -
mXScroll);
@@ -46,5 +42,5 @@ void PasswordField::draw(gcn::Graphics *graphics)
graphics->setColor(getForegroundColor());
graphics->setFont(getFont());
- graphics->drawText(stars, 1 - mXScroll, 1);
+ graphics->drawText(stars, 1 - mXScroll, 1);
}
diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp
index 169c37fc..b1414ef8 100644
--- a/src/gui/playerbox.cpp
+++ b/src/gui/playerbox.cpp
@@ -83,37 +83,32 @@ PlayerBox::~PlayerBox()
void PlayerBox::draw(gcn::Graphics *graphics)
{
- if (showPlayer)
+ if (!showPlayer) {
+ return;
+ }
+
+ // Draw character
+ dynamic_cast<Graphics*>(graphics)->drawImage(
+ playerset->spriteset[0], 23, 23);
+
+ // Draw his hair
+ if (hairColor >= 0 && hairStyle >= 0 &&
+ hairColor < NR_HAIR_COLORS && hairStyle < NR_HAIR_STYLES)
{
- int x, y;
- getAbsolutePosition(x, y);
-
- // Draw character
- dynamic_cast<Graphics*>(graphics)->drawImage(
- playerset->spriteset[0], x + 23, y + 23);
-
- // Draw his hair
- if (hairColor >= 0 && hairStyle >= 0 &&
- hairColor < NR_HAIR_COLORS && hairStyle < NR_HAIR_STYLES)
- {
- int hf = hairColor + 40 * (hairStyle);
- if (hf >= 0 && hf < (int)hairset->spriteset.size()) {
- dynamic_cast<Graphics*>(graphics)->drawImage(
- hairset->spriteset[hf], x + 37, y + 5);
- }
+ int hf = hairColor + 40 * (hairStyle);
+ if (hf >= 0 && hf < (int)hairset->spriteset.size()) {
+ dynamic_cast<Graphics*>(graphics)->drawImage(
+ hairset->spriteset[hf], 37, 5);
}
}
}
void PlayerBox::drawBorder(gcn::Graphics *graphics)
{
- int x, y, w, h, bs;
- getAbsolutePosition(x, y);
+ int w, h, bs;
bs = getBorderSize();
w = getWidth() + bs * 2;
h = getHeight() + bs * 2;
- x -= bs;
- y -= bs;
- dynamic_cast<Graphics*>(graphics)->drawImageRect(x, y, w, h, background);
+ dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, background);
}
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index 26933e22..834ca73a 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -98,10 +98,7 @@ void ProgressBar::logic()
void ProgressBar::draw(gcn::Graphics *graphics)
{
- int x, y;
- getAbsolutePosition(x, y);
-
- dynamic_cast<Graphics*>(graphics)->drawImageRect(x, y, getWidth(), getHeight(),
+ dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0, getWidth(), getHeight(),
mBorder);
// The bar
diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp
index d3358604..bbebe48f 100644
--- a/src/gui/radiobutton.cpp
+++ b/src/gui/radiobutton.cpp
@@ -66,9 +66,6 @@ RadioButton::~RadioButton()
void RadioButton::drawBox(gcn::Graphics* graphics)
{
Image *box = NULL;
- int x, y;
-
- getAbsolutePosition(x, y);
if (mMarked) {
if (isEnabled()) {
@@ -82,9 +79,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics)
box = radioDisabled;
}
- x += 2;
- y += 2;
if (box != NULL) {
- dynamic_cast<Graphics*>(graphics)->drawImage(box, x, y);
+ dynamic_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
}
}
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp
index 6bc428e2..ec8a7946 100644
--- a/src/gui/scrollarea.cpp
+++ b/src/gui/scrollarea.cpp
@@ -216,16 +216,13 @@ void ScrollArea::draw(gcn::Graphics *graphics)
void ScrollArea::drawBorder(gcn::Graphics *graphics)
{
- int x, y, w, h, bs;
- getAbsolutePosition(x, y);
+ int w, h, bs;
bs = getBorderSize();
w = getWidth() + bs * 2;
h = getHeight() + bs * 2;
- x -= bs;
- y -= bs;
if (isOpaque()) {
- dynamic_cast<Graphics*>(graphics)->drawImageRect(x, y, w, h, background);
+ dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, background);
}
}
@@ -248,11 +245,9 @@ bool ScrollArea::isOpaque()
void ScrollArea::drawButton(gcn::Graphics *graphics, BUTTON_DIR dir)
{
- int x, y, state = 0;
+ int state = 0;
gcn::Rectangle dim;
- getAbsolutePosition(x,y);
-
switch(dir) {
case UP:
state = mUpButtonPressed ? 1 : 0;
@@ -273,7 +268,7 @@ void ScrollArea::drawButton(gcn::Graphics *graphics, BUTTON_DIR dir)
}
dynamic_cast<Graphics*>(graphics)->drawImage(
- buttons[dir][state], x + dim.x, y + dim.y);
+ buttons[dir][state], dim.x, dim.y);
}
void ScrollArea::drawUpButton(gcn::Graphics *graphics)
@@ -314,20 +309,16 @@ void ScrollArea::drawHBar(gcn::Graphics *graphics)
void ScrollArea::drawVMarker(gcn::Graphics *graphics)
{
- int x, y;
gcn::Rectangle dim = getVerticalMarkerDimension();
- getAbsolutePosition(x, y);
dynamic_cast<Graphics*>(graphics)->drawImageRect(
- x + dim.x, y + dim.y, dim.width, dim.height, vMarker);
+ dim.x, dim.y, dim.width, dim.height, vMarker);
}
void ScrollArea::drawHMarker(gcn::Graphics *graphics)
{
- int x, y;
gcn::Rectangle dim = getHorizontalMarkerDimension();
- getAbsolutePosition(x, y);
dynamic_cast<Graphics*>(graphics)->drawImageRect(
- x + dim.x, y + dim.y, dim.width, dim.height, vMarker);
+ dim.x, dim.y, dim.width, dim.height, vMarker);
}
diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp
index 088b2794..98efc409 100644
--- a/src/gui/slider.cpp
+++ b/src/gui/slider.cpp
@@ -106,10 +106,8 @@ void Slider::draw(gcn::Graphics *graphics)
{
int w = getWidth();
int h = getHeight();
- int x, y;
- getAbsolutePosition(x, y);
-
- y += (h - hStart->getHeight()) / 2;
+ int x = 0;
+ int y = (h - hStart->getHeight()) / 2;
dynamic_cast<Graphics*>(graphics)->drawImage(hStart, x, y);
@@ -127,12 +125,6 @@ void Slider::draw(gcn::Graphics *graphics)
void Slider::drawMarker(gcn::Graphics *graphics)
{
- int h = getHeight();
- int x, y;
- getAbsolutePosition(x, y);
-
- x += getMarkerPosition();
- y += (h - hGrip->getHeight()) / 2;
-
- dynamic_cast<Graphics*>(graphics)->drawImage(hGrip, x, y);
+ dynamic_cast<Graphics*>(graphics)->drawImage(hGrip,
+ getMarkerPosition(), (getHeight() - hGrip->getHeight()) / 2);
}
diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp
index 94ab856e..5055c328 100644
--- a/src/gui/textfield.cpp
+++ b/src/gui/textfield.cpp
@@ -80,11 +80,6 @@ TextField::~TextField()
void TextField::draw(gcn::Graphics *graphics)
{
- int x, y, w, h;
- getAbsolutePosition(x, y);
- w = getWidth();
- h = getHeight();
-
if (hasFocus()) {
drawCaret(graphics,
getFont()->getWidth(mText.substr(0, mCaretPosition)) -
@@ -98,13 +93,10 @@ void TextField::draw(gcn::Graphics *graphics)
void TextField::drawBorder(gcn::Graphics *graphics)
{
- int x, y, w, h, bs;
- getAbsolutePosition(x, y);
+ int w, h, bs;
bs = getBorderSize();
w = getWidth() + bs * 2;
h = getHeight() + bs * 2;
- x -= bs;
- y -= bs;
- dynamic_cast<Graphics*>(graphics)->drawImageRect(x, y, w, h, skin);
+ dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, skin);
}
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index f59e6438..4184f17a 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -134,18 +134,15 @@ void Window::setWindowContainer(WindowContainer *wc)
void Window::draw(gcn::Graphics* graphics)
{
- int x, y;
- getAbsolutePosition(x, y);
-
- dynamic_cast<Graphics*>(graphics)->drawImageRect(x, y, getWidth(), getHeight(),
+ dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0, getWidth(), getHeight(),
border);
// Draw grip
if (resizable)
{
dynamic_cast<Graphics*>(graphics)->drawImage(Window::resizeGrip,
- x + getWidth() - resizeGrip->getWidth(),
- y + getHeight() - resizeGrip->getHeight());
+ getWidth() - resizeGrip->getWidth(),
+ getHeight() - resizeGrip->getHeight());
}
// Draw title
@@ -393,8 +390,6 @@ void Window::optionChanged(const std::string &name)
gcn::Rectangle Window::getGripDimension ()
{
- int x, y;
- getAbsolutePosition(x, y);
return gcn::Rectangle(getWidth() - resizeGrip->getWidth(), getHeight() - resizeGrip->getHeight(), getWidth(),
getHeight());
}
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index 44611045..883672bb 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -74,6 +74,9 @@ bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
bool OpenGLGraphics::drawImage(Image *image, int srcX, int srcY,
int dstX, int dstY, int width, int height)
{
+ dstX += mClipStack.top().xOffset;
+ dstY += mClipStack.top().yOffset;
+
srcX += image->bounds.x;
srcY += image->bounds.y;