summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-09-27 14:54:09 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-09-27 14:54:09 +0000
commit285da0d05eb2e6b680a8dfc497cf4ecab75b7aa4 (patch)
tree0a4e4169ffada0fbdc25fd91822a8c0fe678571c /src/gui
parentc24856707233ceb3995e43f8f7da63e65999df1e (diff)
downloadmana-client-285da0d05eb2e6b680a8dfc497cf4ecab75b7aa4.tar.gz
mana-client-285da0d05eb2e6b680a8dfc497cf4ecab75b7aa4.tar.bz2
mana-client-285da0d05eb2e6b680a8dfc497cf4ecab75b7aa4.tar.xz
mana-client-285da0d05eb2e6b680a8dfc497cf4ecab75b7aa4.zip
Merged another bunch of changes from trunk to 0.0 to reduce the difference.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/button.cpp60
-rw-r--r--src/gui/button.h7
-rw-r--r--src/gui/checkbox.cpp6
-rw-r--r--src/gui/equipmentwindow.cpp4
-rw-r--r--src/gui/itemcontainer.cpp4
-rw-r--r--src/gui/linkhandler.h2
-rw-r--r--src/gui/minimap.cpp4
-rw-r--r--src/gui/radiobutton.cpp2
-rw-r--r--src/gui/scrollarea.cpp16
-rw-r--r--src/gui/slider.cpp12
-rw-r--r--src/gui/textfield.cpp2
-rw-r--r--src/gui/updatewindow.cpp17
-rw-r--r--src/gui/updatewindow.h5
-rw-r--r--src/gui/viewport.cpp2
-rw-r--r--src/gui/windowlistener.h4
15 files changed, 80 insertions, 67 deletions
diff --git a/src/gui/button.cpp b/src/gui/button.cpp
index a9212e83..0379ebc0 100644
--- a/src/gui/button.cpp
+++ b/src/gui/button.cpp
@@ -34,9 +34,32 @@
#include "../utils/dtor.h"
-ImageRect Button::button[4];
int Button::mInstances = 0;
+enum{
+ BUTTON_STANDARD, // 0
+ BUTTON_HIGHLIGHTED, // 1
+ BUTTON_PRESSED, // 2
+ BUTTON_DISABLED, // 3
+ BUTTON_COUNT // 4 - Must be last.
+};
+
+struct ButtonData
+{
+ char const *file;
+ int gridX;
+ int gridY;
+};
+
+static ButtonData const data[BUTTON_COUNT] = {
+ {"graphics/gui/button.png", 0, 0},
+ {"graphics/gui/buttonhi.png", 9, 4},
+ {"graphics/gui/buttonpress.png", 16, 19},
+ {"graphics/gui/button_disabled.png", 25, 23}
+};
+
+ImageRect Button::button[BUTTON_COUNT];
+
Button::Button():
mIsLogged(false)
{
@@ -63,24 +86,20 @@ void Button::init()
{
// Load the skin
ResourceManager *resman = ResourceManager::getInstance();
- Image *btn[4];
- btn[0] = resman->getImage("graphics/gui/button.png");
- btn[1] = resman->getImage("graphics/gui/buttonhi.png");
- btn[2] = resman->getImage("graphics/gui/buttonpress.png");
- btn[3] = resman->getImage("graphics/gui/button_disabled.png");
- int bgridx[4] = {0, 9, 16, 25};
- int bgridy[4] = {0, 4, 19, 24};
+ Image *btn[BUTTON_COUNT];
+
int a, x, y, mode;
- for (mode = 0; mode < 4; mode++)
+ for (mode = 0; mode < BUTTON_COUNT; mode++)
{
+ btn[mode] = resman->getImage(data[mode].file);
a = 0;
for (y = 0; y < 3; y++) {
for (x = 0; x < 3; x++) {
button[mode].grid[a] = btn[mode]->getSubImage(
- bgridx[x], bgridy[y],
- bgridx[x + 1] - bgridx[x] + 1,
- bgridy[y + 1] - bgridy[y] + 1);
+ data[x].gridX, data[y].gridY,
+ data[x + 1].gridX - data[x].gridX + 1,
+ data[y + 1].gridY - data[y].gridY + 1);
a++;
}
}
@@ -96,7 +115,7 @@ Button::~Button()
if (mInstances == 0)
{
- for (int mode = 0; mode < 4; mode++)
+ for (int mode = 0; mode < BUTTON_COUNT; mode++)
{
for_each(button[mode].grid, button[mode].grid + 9, dtor<Image*>());
}
@@ -109,21 +128,20 @@ Button::draw(gcn::Graphics *graphics)
int mode;
if (!isEnabled()) {
- mode = 3;
+ mode = BUTTON_DISABLED;
}
else if (isPressed() || mIsLogged) {
- mode = 2;
+ mode = BUTTON_PRESSED;
}
- else if (mHasMouse) {
- mode = 1;
+ else if (mHasMouse || isFocused()) {
+ mode = BUTTON_HIGHLIGHTED;
}
else {
- mode = 0;
+ mode = BUTTON_STANDARD;
}
- dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0,
- getWidth(), getHeight(),
- button[mode]);
+ static_cast<Graphics*>(graphics)->
+ drawImageRect(0, 0, getWidth(), getHeight(), button[mode]);
graphics->setColor(getForegroundColor());
diff --git a/src/gui/button.h b/src/gui/button.h
index 68831d5a..d12173b2 100644
--- a/src/gui/button.h
+++ b/src/gui/button.h
@@ -37,9 +37,14 @@ class ImageRect;
*/
class Button : public gcn::Button {
public:
+ /**
+ * Default constructor.
+ */
Button();
+
/**
- * Constructor, sets the caption of the button to the given string.
+ * Constructor, sets the caption of the button to the given string and
+ * adds the given action listener.
*/
Button(const std::string& caption, const std::string &actionEventId,
gcn::ActionListener *listener);
diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp
index ec7eb578..fab4780c 100644
--- a/src/gui/checkbox.cpp
+++ b/src/gui/checkbox.cpp
@@ -66,7 +66,7 @@ CheckBox::~CheckBox()
void CheckBox::drawBox(gcn::Graphics* graphics)
{
- Image *box = NULL;
+ Image *box;
if (mMarked) {
if (isEnabled()) {
@@ -80,7 +80,5 @@ void CheckBox::drawBox(gcn::Graphics* graphics)
box = checkBoxDisabled;
}
- if (box != NULL) {
- dynamic_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
- }
+ static_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
}
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 78727ff8..4df18b19 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -66,7 +66,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
}
image = item->getInfo().getImage();
- dynamic_cast<Graphics*>(graphics)->drawImage(
+ static_cast<Graphics*>(graphics)->drawImage(
image, 36 * (i % 4) + 10, 36 * (i / 4) + 25);
}
@@ -78,7 +78,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
image = item->getInfo().getImage();
- dynamic_cast<Graphics*>(graphics)->drawImage(image, 160, 25);
+ static_cast<Graphics*>(graphics)->drawImage(image, 160, 25);
graphics->drawText(toString(item->getQuantity()), 170, 62,
gcn::Graphics::CENTER);
}
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 43de8db3..0e203905 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -110,7 +110,7 @@ ItemContainer::draw(gcn::Graphics *graphics)
// Draw selection image below selected item
if (mSelectedItem == item)
{
- dynamic_cast<Graphics*>(graphics)->drawImage(
+ static_cast<Graphics*>(graphics)->drawImage(
mSelImg, itemX, itemY);
}
@@ -118,7 +118,7 @@ ItemContainer::draw(gcn::Graphics *graphics)
Image* image;
if ((image = item->getInfo().getImage()) != NULL)
{
- dynamic_cast<Graphics*>(graphics)->drawImage(
+ static_cast<Graphics*>(graphics)->drawImage(
image, itemX, itemY);
}
diff --git a/src/gui/linkhandler.h b/src/gui/linkhandler.h
index 33416ec7..3a32f825 100644
--- a/src/gui/linkhandler.h
+++ b/src/gui/linkhandler.h
@@ -24,6 +24,8 @@
#ifndef _TMW_LINK_HANDLER_H_
#define _TMW_LINK_HANDLER_H_
+#include <string>
+
/**
* A simple interface to windows that need to handle links from BrowserBox
* widget.
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 69c5eb6e..2720225d 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -72,8 +72,8 @@ void Minimap::draw(gcn::Graphics *graphics)
if (mMapImage != NULL)
{
- dynamic_cast<Graphics*>(graphics)->drawImage(
- mMapImage, getPadding(), getTitleBarHeight());
+ static_cast<Graphics*>(graphics)->
+ drawImage(mMapImage, getPadding(), getTitleBarHeight());
}
Beings &beings = beingManager->getAll();
diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp
index bbebe48f..e318116a 100644
--- a/src/gui/radiobutton.cpp
+++ b/src/gui/radiobutton.cpp
@@ -80,6 +80,6 @@ void RadioButton::drawBox(gcn::Graphics* graphics)
}
if (box != NULL) {
- dynamic_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
+ static_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
}
}
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp
index 903ec95d..816f94a8 100644
--- a/src/gui/scrollarea.cpp
+++ b/src/gui/scrollarea.cpp
@@ -228,8 +228,8 @@ void ScrollArea::drawBorder(gcn::Graphics *graphics)
int h = getHeight() + bs * 2;
if (mOpaque) {
- dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h,
- background);
+ static_cast<Graphics*>(graphics)->
+ drawImageRect(0, 0, w, h, background);
}
}
@@ -269,8 +269,8 @@ void ScrollArea::drawButton(gcn::Graphics *graphics, BUTTON_DIR dir)
break;
}
- dynamic_cast<Graphics*>(graphics)->drawImage(
- buttons[dir][state], dim.x, dim.y);
+ static_cast<Graphics*>(graphics)->
+ drawImage(buttons[dir][state], dim.x, dim.y);
}
void ScrollArea::drawUpButton(gcn::Graphics *graphics)
@@ -313,14 +313,14 @@ void ScrollArea::drawVMarker(gcn::Graphics *graphics)
{
gcn::Rectangle dim = getVerticalMarkerDimension();
- dynamic_cast<Graphics*>(graphics)->drawImageRect(
- dim.x, dim.y, dim.width, dim.height, vMarker);
+ static_cast<Graphics*>(graphics)->
+ drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarker);
}
void ScrollArea::drawHMarker(gcn::Graphics *graphics)
{
gcn::Rectangle dim = getHorizontalMarkerDimension();
- dynamic_cast<Graphics*>(graphics)->drawImageRect(
- dim.x, dim.y, dim.width, dim.height, vMarker);
+ static_cast<Graphics*>(graphics)->
+ drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarker);
}
diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp
index 98efc409..f0170a1b 100644
--- a/src/gui/slider.cpp
+++ b/src/gui/slider.cpp
@@ -109,22 +109,22 @@ void Slider::draw(gcn::Graphics *graphics)
int x = 0;
int y = (h - hStart->getHeight()) / 2;
- dynamic_cast<Graphics*>(graphics)->drawImage(hStart, x, y);
+ static_cast<Graphics*>(graphics)->drawImage(hStart, x, y);
w -= hStart->getWidth() + hEnd->getWidth();
x += hStart->getWidth();
- dynamic_cast<Graphics*>(graphics)->drawImagePattern(
- hMid, x, y, w, hMid->getHeight());
+ static_cast<Graphics*>(graphics)->
+ drawImagePattern(hMid, x, y, w, hMid->getHeight());
x += w;
- dynamic_cast<Graphics*>(graphics)->drawImage(hEnd, x, y);
+ static_cast<Graphics*>(graphics)->drawImage(hEnd, x, y);
drawMarker(graphics);
}
void Slider::drawMarker(gcn::Graphics *graphics)
{
- dynamic_cast<Graphics*>(graphics)->drawImage(hGrip,
- getMarkerPosition(), (getHeight() - hGrip->getHeight()) / 2);
+ static_cast<Graphics*>(graphics)->
+ drawImage(hGrip, getMarkerPosition(), (getHeight() - hGrip->getHeight()) / 2);
}
diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp
index adf41a9a..ce7f6d5f 100644
--- a/src/gui/textfield.cpp
+++ b/src/gui/textfield.cpp
@@ -98,5 +98,5 @@ void TextField::drawBorder(gcn::Graphics *graphics)
w = getWidth() + bs * 2;
h = getHeight() + bs * 2;
- dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, skin);
+ static_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, skin);
}
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 183adc93..73dbd604 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -211,12 +211,6 @@ void UpdaterWindow::loadNews()
mScrollArea->setVerticalScrollAmount(0);
}
-void UpdaterWindow::addRow(const std::string &row)
-{
- mBrowserBox->addRow(row);
- mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
-}
-
int UpdaterWindow::updateProgress(void *ptr,
double dt, double dn, double ut, double un)
{
@@ -418,11 +412,12 @@ void UpdaterWindow::logic()
}
mThread = NULL;
}
- addRow("");
- addRow("##1 The update process is incomplete.");
- addRow("##1 It is strongly recommended that");
- addRow("##1 you try again later");
- addRow(mCurlError);
+ mBrowserBox->addRow("");
+ mBrowserBox->addRow("##1 The update process is incomplete.");
+ mBrowserBox->addRow("##1 It is strongly recommended that");
+ mBrowserBox->addRow("##1 you try again later");
+ mBrowserBox->addRow(mCurlError);
+ mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
mDownloadStatus = UPDATE_COMPLETE;
break;
case UPDATE_NEWS:
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h
index adc96078..b5f6a6df 100644
--- a/src/gui/updatewindow.h
+++ b/src/gui/updatewindow.h
@@ -81,11 +81,6 @@ class UpdaterWindow : public Window, public gcn::ActionListener
void action(const gcn::ActionEvent &event);
- /**
- * Add a row to the message field.
- */
- void addRow(const std::string &row);
-
void logic();
int updateState;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 4c64c627..a39db509 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -309,7 +309,7 @@ Viewport::drawTargetCursor(Graphics *graphics)
int rangeY = abs(target->mY - player_node->mY);
int attackRange = player_node->getAttackRange();
- // get the correct target cursors graphic
+ // Get the correct target cursors graphic
Being::TargetCursorSize cursorSize = target->getTargetCursorSize();
Image* targetCursor;
if (rangeX > attackRange || rangeY > attackRange)
diff --git a/src/gui/windowlistener.h b/src/gui/windowlistener.h
index 08aab71d..24f6a7b8 100644
--- a/src/gui/windowlistener.h
+++ b/src/gui/windowlistener.h
@@ -73,12 +73,12 @@ class WindowListener
/**
* Called whenever the window is moved.
*/
- virtual void windowMoved(const WindowEvent &event) {}
+ virtual void windowMoved(const WindowEvent &) {}
/**
* Called whenever the window is resized.
*/
- virtual void windowResized(const WindowEvent &event) {}
+ virtual void windowResized(const WindowEvent &) {}
};
typedef std::list<WindowListener*> WindowListeners;