From 0f730185d2e73bf80b6a53952c626a7b22ab5055 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Tue, 20 Sep 2005 14:32:06 +0000 Subject: Fixed use of Enter for closing death and weight notices, and changed glColor4f to glColor4ub. --- src/game.cpp | 25 +++++++++---------------- src/gui/ok_dialog.cpp | 9 ++++----- src/gui/ok_dialog.h | 6 +++--- src/gui/window.cpp | 11 ++++++----- src/openglgraphics.cpp | 30 +++++++++++++++--------------- 5 files changed, 37 insertions(+), 44 deletions(-) (limited to 'src') 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)->drawImageRect(0, 0, getWidth(), getHeight(), - border); + Graphics *g = (Graphics*)graphics; + + g->drawImageRect(0, 0, getWidth(), getHeight(), border); // Draw grip if (resizable) { - dynamic_cast(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(); } -- cgit v1.2.3-70-g09d2