summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-09-20 14:32:06 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-09-20 14:32:06 +0000
commit0f730185d2e73bf80b6a53952c626a7b22ab5055 (patch)
treecacbe04bb3855ade0d3fa9c30302036e1be9a7ec /src
parentaa786b1b7898c9a4cd47135fabd3b1558b6d71c5 (diff)
downloadmana-0f730185d2e73bf80b6a53952c626a7b22ab5055.tar.gz
mana-0f730185d2e73bf80b6a53952c626a7b22ab5055.tar.bz2
mana-0f730185d2e73bf80b6a53952c626a7b22ab5055.tar.xz
mana-0f730185d2e73bf80b6a53952c626a7b22ab5055.zip
Fixed use of Enter for closing death and weight notices, and changed glColor4f
to glColor4ub.
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp25
-rw-r--r--src/gui/ok_dialog.cpp9
-rw-r--r--src/gui/ok_dialog.h6
-rw-r--r--src/gui/window.cpp11
-rw-r--r--src/openglgraphics.cpp30
5 files changed, 37 insertions, 44 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 0748d65b..164eab55 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -124,11 +124,11 @@ const int MAX_TIME = 10000;
class WeightNoticeListener : public gcn::ActionListener
{
-public:
- void action(const std::string &eventId)
- {
- weightNotice = NULL;
- }
+ public:
+ void action(const std::string &eventId)
+ {
+ weightNotice = NULL;
+ }
} weightNoticeListener;
@@ -509,7 +509,10 @@ void do_input()
// Input chat window
case SDLK_RETURN:
- if (chatWindow->isFocused()) {
+ if (chatWindow->isFocused() ||
+ deathNotice != NULL ||
+ weightNotice != NULL)
+ {
break;
}
@@ -518,15 +521,6 @@ void do_input()
{
state = EXIT;
}
- // Accept the Death Notice...
- else if (deathNotice)
- {
- deathNotice->action("ok");
- }
- else if (weightNotice)
- {
- weightNotice->action("ok");
- }
// Close the Browser if opened
else if (helpWindow->isVisible())
{
@@ -1583,7 +1577,6 @@ void do_parse()
deathNotice = new OkDialog("Message",
"You're now dead, press ok to restart",
&deathNoticeListener);
- deathNotice->releaseModalFocus();
player_node->action = Being::DEAD;
}
}
diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp
index fd0408ac..0089f0ae 100644
--- a/src/gui/ok_dialog.cpp
+++ b/src/gui/ok_dialog.cpp
@@ -29,14 +29,14 @@
#include "windowcontainer.h"
OkDialog::OkDialog(const std::string &title, const std::string &msg,
- gcn::ActionListener *listener):
+ gcn::ActionListener *listener):
Window(title, true)
{
init(msg, listener);
}
OkDialog::OkDialog(Window *parent, const std::string &title,
- const std::string &msg, gcn::ActionListener *listener):
+ const std::string &msg, gcn::ActionListener *listener):
Window(title, true, parent)
{
init(msg, listener);
@@ -56,9 +56,8 @@ void OkDialog::init(const std::string &msg, gcn::ActionListener *listener)
setContentSize(w, h);
userLabel->setPosition(10, 10);
- okButton->setPosition(
- (w - okButton->getWidth()) / 2,
- h - 5 - okButton->getHeight());
+ okButton->setPosition((w - okButton->getWidth()) / 2,
+ h - 5 - okButton->getHeight());
okButton->setEventId("ok");
okButton->addActionListener(this);
diff --git a/src/gui/ok_dialog.h b/src/gui/ok_dialog.h
index 6dcf1e6a..3dfc18c8 100644
--- a/src/gui/ok_dialog.h
+++ b/src/gui/ok_dialog.h
@@ -43,7 +43,7 @@ class OkDialog : public Window, public gcn::ActionListener {
* @see Window::Window
*/
OkDialog(const std::string &title, const std::string &msg,
- gcn::ActionListener *listener = NULL);
+ gcn::ActionListener *listener = NULL);
/**
* Constructor with parent reference.
@@ -51,8 +51,8 @@ class OkDialog : public Window, public gcn::ActionListener {
* @see Window::Window
*/
OkDialog(Window *window, const std::string &title,
- const std::string &msg,
- gcn::ActionListener *listener = NULL);
+ const std::string &msg,
+ gcn::ActionListener *listener = NULL);
/**
* Destructor.
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index acb23cd4..642b891f 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -161,15 +161,16 @@ void Window::setWindowContainer(WindowContainer *wc)
void Window::draw(gcn::Graphics* graphics)
{
- dynamic_cast<Graphics*>(graphics)->drawImageRect(0, 0, getWidth(), getHeight(),
- border);
+ Graphics *g = (Graphics*)graphics;
+
+ g->drawImageRect(0, 0, getWidth(), getHeight(), border);
// Draw grip
if (resizable)
{
- dynamic_cast<Graphics*>(graphics)->drawImage(Window::resizeGrip,
- getWidth() - resizeGrip->getWidth(),
- getHeight() - resizeGrip->getHeight());
+ g->drawImage(Window::resizeGrip,
+ getWidth() - resizeGrip->getWidth(),
+ getHeight() - resizeGrip->getHeight());
}
// Draw title
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index b9591591..56ef5b3f 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -157,7 +157,8 @@ SDL_Surface* OpenGLGraphics::getScreenshot()
SDL_LockSurface(screenshot);
}
glPixelStorei(GL_PACK_ALIGNMENT, 1);
- glReadPixels(0, 0, mScreen->w, mScreen->h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels);
+ glReadPixels(0, 0, mScreen->w, mScreen->h, GL_RGB, GL_UNSIGNED_BYTE,
+ screenshot->pixels);
unsigned char *data = (unsigned char*)screenshot->pixels;
for (int x = 0; x < mScreen->w; x++) {
@@ -225,24 +226,23 @@ void OpenGLGraphics::popClipArea()
glPopMatrix();
glScissor(mClipStack.top().x,
- mScreen->h - mClipStack.top().y - mClipStack.top().height,
- mClipStack.top().width,
- mClipStack.top().height);
+ mScreen->h - mClipStack.top().y - mClipStack.top().height,
+ mClipStack.top().width,
+ mClipStack.top().height);
}
void OpenGLGraphics::setColor(const gcn::Color& color)
{
mColor = color;
- glColor4f(color.r/255.0,
- color.g/255.0,
- color.b/255.0,
- color.a/255.0);
+ glColor4ub(color.r, color.g, color.b, color.a);
mColorAlpha = (color.a != 255);
}
-void OpenGLGraphics::drawImage(const gcn::Image* image, int srcX, int srcY,
- int dstX, int dstY, int width, int height)
+void OpenGLGraphics::drawImage(const gcn::Image* image,
+ int srcX, int srcY,
+ int dstX, int dstY,
+ int width, int height)
{
// The following code finds the real width and height of the texture.
// OpenGL only supports texture sizes that are powers of two
@@ -260,8 +260,8 @@ void OpenGLGraphics::drawImage(const gcn::Image* image, int srcX, int srcY,
// Find OpenGL texture coordinates
float texX1 = srcX / (float)realImageWidth;
float texY1 = srcY / (float)realImageHeight;
- float texX2 = (srcX+width) / (float)realImageWidth;
- float texY2 = (srcY+height) / (float)realImageHeight;
+ float texX2 = (srcX + width) / (float)realImageWidth;
+ float texY2 = (srcY + height) / (float)realImageHeight;
// Please dont look too closely at the next line, it is not pretty.
// It uses the image data as a pointer to a GLuint
@@ -284,12 +284,12 @@ void OpenGLGraphics::drawLine(int x1, int y1, int x2, int y2)
setTexturingAndBlending(false);
glBegin(GL_LINES);
- glVertex3f(x1+0.5f, y1+0.5f, 0);
- glVertex3f(x2+0.5f, y2+0.5f, 0);
+ glVertex3f(x1 + 0.5f, y1 + 0.5f, 0);
+ glVertex3f(x2 + 0.5f, y2 + 0.5f, 0);
glEnd();
glBegin(GL_POINTS);
- glVertex3f(x2+0.5f, y2+0.5f, 0);
+ glVertex3f(x2 + 0.5f, y2 + 0.5f, 0);
glEnd();
}