From 9ef72eaa168ca047f91f1dce2d98ef2c243b31c2 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 27 Jan 2009 15:10:02 -0700 Subject: Removed the fairly useless buttonbox class, as well as removing the recorder's dependence upon it. This class should get a bit more work done to it to simplify it further, but right now, it preserves all of the same functionality. Signed-off-by: Ira Rice --- src/Makefile.am | 6 +-- src/gui/buttonbox.cpp | 43 ------------------- src/gui/buttonbox.h | 69 ------------------------------ src/gui/chat.cpp | 6 +-- src/gui/recorder.cpp | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/gui/recorder.h | 88 ++++++++++++++++++++++++++++++++++++++ src/recorder.cpp | 114 ------------------------------------------------- src/recorder.h | 48 --------------------- 8 files changed, 209 insertions(+), 281 deletions(-) delete mode 100644 src/gui/buttonbox.cpp delete mode 100644 src/gui/buttonbox.h create mode 100644 src/gui/recorder.cpp create mode 100644 src/gui/recorder.h delete mode 100644 src/recorder.cpp delete mode 100644 src/recorder.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 8f76b06a..aebfdc41 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,8 +15,6 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ gui/browserbox.h \ gui/button.cpp \ gui/button.h \ - gui/buttonbox.cpp \ - gui/buttonbox.h \ gui/buy.cpp \ gui/buy.h \ gui/buysell.cpp \ @@ -102,6 +100,8 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ gui/progressbar.h \ gui/radiobutton.cpp \ gui/radiobutton.h \ + gui/recorder.cpp \ + gui/recorder.h \ gui/register.cpp \ gui/register.h \ gui/scrollarea.cpp \ @@ -326,8 +326,6 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ position.cpp \ position.h \ properties.h \ - recorder.cpp \ - recorder.h \ serverinfo.h \ shopitem.cpp \ shopitem.h \ diff --git a/src/gui/buttonbox.cpp b/src/gui/buttonbox.cpp deleted file mode 100644 index d29f3c58..00000000 --- a/src/gui/buttonbox.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * The Mana World - * Copyright 2004 The Mana World Development Team - * - * This file is part of The Mana World. - * - * The Mana World is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * The Mana World is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with The Mana World; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "button.h" -#include "buttonbox.h" - -ButtonBox::ButtonBox(const std::string &title, const std::string &buttonTxt, - ButtonBoxListener *listener) : - Window(title), - mListener(listener) -{ - Button *button = new Button(buttonTxt, "activate", this); - setContentSize(button->getWidth() + 10, - button->getHeight() + 10); - button->setPosition(5, 5); - add(button); -} - -void ButtonBox::action(const gcn::ActionEvent &event) -{ - if (event.getId() == "activate") - { - mListener->buttonBoxRespond(); - } -} diff --git a/src/gui/buttonbox.h b/src/gui/buttonbox.h deleted file mode 100644 index 6d0e46b6..00000000 --- a/src/gui/buttonbox.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * The Mana World - * Copyright 2004 The Mana World Development Team - * - * This file is part of The Mana World. - * - * The Mana World is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * The Mana World is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with The Mana World; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef BUTTONBOX_H -#define BUTTONBOX_H - -#include - -#include - -#include "window.h" - -#include "../guichanfwd.h" - -class ButtonBoxListener -{ - public: - - /* - * function that ButtonBox calls when the button has been pressed - */ - virtual void buttonBoxRespond() = 0; -}; - -class ButtonBox : public Window, public gcn::ActionListener -{ - public: - - /* - * Constructor - * - * @param title is the text that appears at the top of the box - * @param buttonTxt is the text that appears on the button - * @param listener points to the class that should respond to the - * button press - */ - ButtonBox(const std::string &title, const std::string &buttonTxt, - ButtonBoxListener *listener); - - /* - * called when the button is pressed - * - * @param event is the event that is generated - */ - void action(const gcn::ActionEvent &event); - - private: - - ButtonBoxListener *mListener; -}; -#endif diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 1a3cb2a4..068fad08 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -28,6 +28,7 @@ #include "chat.h" #include "chatinput.h" #include "itemlinkhandler.h" +#include "recorder.h" #include "scrollarea.h" #include "sdlinput.h" #include "windowcontainer.h" @@ -40,7 +41,6 @@ #include "../game.h" #include "../localplayer.h" #include "../party.h" -#include "../recorder.h" #include "../net/messageout.h" #include "../net/protocol.h" @@ -477,7 +477,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) else if (command == "whisper" || command == "msg" || command == "w") whisper(nick, msg); else if (command == "record") - mRecorder->respond(msg); + mRecorder->changeStatus(msg); else if (command == "toggle") { if (msg == "") @@ -850,7 +850,7 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) } else if (msg1 == "record") { - mRecorder->help(msg2); + mRecorder->help2(); } else if (msg1 == "toggle") { diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp new file mode 100644 index 00000000..da67875b --- /dev/null +++ b/src/gui/recorder.cpp @@ -0,0 +1,116 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "button.h" +#include "chat.h" +#include "recorder.h" + +#include "../utils/trim.h" + +Recorder::Recorder(ChatWindow *chat, const std::string &title, + const std::string &buttonTxt) : + Window(title) +{ + mChat = chat; + Button *button = new Button(buttonTxt, "activate", this); + setContentSize(button->getWidth() + 10, button->getHeight() + 10); + button->setPosition(5, 5); + add(button); +} + +void Recorder::record(const std::string &msg) +{ + if (mStream.is_open()) + { + mStream << msg << std::endl; + } +} + +void Recorder::changeStatus(const std::string &msg) +{ + std::string msgCopy = msg; + trim(msgCopy); + + if (msgCopy == "") + { + if (mStream.is_open()) + { + mStream.close(); + setVisible(false); + + /* + * Message should go after mStream is closed so that it isn't + * recorded. + */ + mChat->chatLog("Finishing recording.", BY_SERVER); + } + else + { + mChat->chatLog("Not currently recording.", BY_SERVER); + } + } + else if (mStream.is_open()) + { + mChat->chatLog("Already recording.", BY_SERVER); + } + else + { + /* + * Message should go before mStream is opened so that it isn't + * recorded. + */ + mChat->chatLog("Starting to record...", BY_SERVER); + std::string file = std::string(PHYSFS_getUserDir()) + "/.aethyra/" + msgCopy; + + mStream.open(file.c_str(), std::ios_base::trunc); + + if (mStream.is_open()) + setVisible(true); + else + mChat->chatLog("Failed to start recording.", BY_SERVER); + } +} + +void Recorder::help() const +{ + mChat->chatLog("/record : Start recording the chat.", BY_SERVER); +} + +void Recorder::help2() const +{ + mChat->chatLog("Command: /record ", BY_SERVER); + mChat->chatLog("This command starts recording the chat log to the file " + ".", BY_SERVER); + mChat->chatLog("Command: /record", BY_SERVER); + mChat->chatLog("This command finishes a recording session.", BY_SERVER); +} + +void Recorder::action(const gcn::ActionEvent &event) +{ + if (event.getId() == "activate") + changeStatus(""); +} + +Recorder::~Recorder() +{ +} diff --git a/src/gui/recorder.h b/src/gui/recorder.h new file mode 100644 index 00000000..6f917c25 --- /dev/null +++ b/src/gui/recorder.h @@ -0,0 +1,88 @@ +/* + * Aethyra + * Copyright (C) 2008 Aethyra Development Team + * + * This file is part of Aethyra. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef RECORD_H +#define RECORD_H + +#include +#include + +#include + +#include "window.h" + +#include "../guichanfwd.h" + +#include "../utils/gettext.h" + +class ChatWindow; + +class Recorder : public Window, public gcn::ActionListener +{ + public: + Recorder(ChatWindow *chat, const std::string &title = _("Recording..."), + const std::string &buttonTxt = _("Stop recording")); + + virtual ~Recorder(); + + /* + * Outputs the message to the recorder file + * + * @param msg the line to write to the recorded file. + */ + void record(const std::string &msg); + + /* + * Outputs the message to the recorder file + * + * @param msg the line to write to the recorded file. + */ + void changeStatus(const std::string &msg); + + /* + * Displays a help message on how to use this class in the chat window. + */ + void help() const; + + /* + * Displays an extended help message on how to use this class in the + * chat window. + */ + void help2() const; + + /* + * Whether or not the recorder is in use. + */ + bool isRecording() {return (bool) mStream.is_open();} + + /* + * called when the button is pressed + * + * @param event is the event that is generated + */ + void action(const gcn::ActionEvent &event); + + private: + ChatWindow *mChat; + + std::ofstream mStream; +}; +#endif diff --git a/src/recorder.cpp b/src/recorder.cpp deleted file mode 100644 index 57f030b2..00000000 --- a/src/recorder.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * The Mana World - * Copyright 2004 The Mana World Development Team - * - * This file is part of The Mana World. - * - * The Mana World is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * The Mana World is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with The Mana World; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include "recorder.h" - -#include "gui/buttonbox.h" -#include "gui/chat.h" - -#include "utils/trim.h" - -Recorder::Recorder(ChatWindow *chat) : mChat(chat) -{ - mButtonBox = new ButtonBox("Recording...", "Stop recording", this); - mButtonBox->setY(20); -} - -void Recorder::record(const std::string &msg) -{ - if (mStream.is_open()) - { - mStream << msg << std::endl; - } -} - -void Recorder::respond(const std::string &msg) -{ - std::string msgCopy = msg; - trim(msgCopy); - if (msgCopy == "") - { - if (mStream.is_open()) - { - mStream.close(); - mButtonBox->setVisible(false); - /* - * Message should go after mStream is closed so that it isn't - * recorded. - */ - mChat->chatLog("Finishing recording.", BY_SERVER); - } - else - { - mChat->chatLog("Not currently recording.", BY_SERVER); - } - return; - } - if (mStream.is_open()) - { - mChat->chatLog("Already recording.", BY_SERVER); - } - else - { - /* - * Message should go before mStream is opened so that it isn't - * recorded. - */ - mChat->chatLog("Starting to record...", BY_SERVER); - std::string file = std::string(PHYSFS_getUserDir()) + "/.aethyra/" + msgCopy; - - mStream.open(file.c_str(), std::ios_base::trunc); - if (mStream.is_open()) - { - mButtonBox->setVisible(true); - } - else - { - mChat->chatLog("Failed to start recording.", BY_SERVER); - } - } -} - -void Recorder::help() const -{ - mChat->chatLog("/record : Start recording the chat.", BY_SERVER); -} - -void Recorder::help(const std::string &args) const -{ - mChat->chatLog("Command: /record ", BY_SERVER); - mChat->chatLog("This command starts recording the chat log to the file " - ".", BY_SERVER); - mChat->chatLog("Command: /record", BY_SERVER); - mChat->chatLog("This command finishes a recording session.", BY_SERVER); -} - -void Recorder::buttonBoxRespond() -{ - respond(""); -} - -Recorder::~Recorder() -{ - delete mButtonBox; -} diff --git a/src/recorder.h b/src/recorder.h deleted file mode 100644 index 4a220166..00000000 --- a/src/recorder.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Aethyra - * Copyright (C) 2008 Aethyra Development Team - * - * This file is part of Aethyra. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef RECORD_H -#define RECORD_H - -#include -#include - -#include "gui/buttonbox.h" - -class ChatWindow; - -class Recorder : public ButtonBoxListener -{ - private: - ChatWindow *mChat; - std::ofstream mStream; - ButtonBox *mButtonBox; - public: - Recorder(ChatWindow *chat); - void record(const std::string &msg); - void respond(const std::string &msg); - void help() const; - void help(const std::string &args) const; - void buttonBoxRespond(); - bool isRecording() {return (bool) mStream.is_open();} - virtual ~Recorder(); -}; -#endif -- cgit v1.2.3-70-g09d2 From 305566b407fd9d440c168650b81a6d711c1e94b8 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 08:49:12 -0700 Subject: Added missing files to CMakeLists. Signed-off-by: Ira Rice --- src/CMakeLists.txt | 40 +++++++++++++++++++++++++++++++++------- src/Makefile.am | 4 ++-- 2 files changed, 35 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 94cf0174..8cd062c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,12 +81,20 @@ SET(SRCS gui/chatinput.h gui/checkbox.cpp gui/checkbox.h + gui/colour.cpp + gui/colour.h gui/confirm_dialog.cpp gui/confirm_dialog.h gui/connection.cpp gui/connection.h gui/debugwindow.cpp gui/debugwindow.h + gui/emotecontainer.cpp + gui/emotecontainer.h + gui/emoteshortcutcontainer.cpp + gui/emoteshortcutcontainer.h + gui/emotewindow.cpp + gui/emotewindow.h gui/equipmentwindow.cpp gui/equipmentwindow.h gui/focushandler.cpp @@ -108,9 +116,7 @@ SET(SRCS gui/itempopup.cpp gui/itempopup.h gui/itemshortcutcontainer.cpp - gui/itemshortcutcontainer.h - gui/itemshortcutwindow.cpp - gui/itemshortcutwindow.h + gui/itemshortcutcontainer.h\ gui/item_amount.cpp gui/item_amount.h gui/linkhandler.h @@ -144,6 +150,8 @@ SET(SRCS gui/progressbar.h gui/radiobutton.cpp gui/radiobutton.h + gui/recorder.cpp + gui/recorder.h gui/register.cpp gui/register.h gui/scrollarea.cpp @@ -152,10 +160,12 @@ SET(SRCS gui/sdlinput.h gui/sell.cpp gui/sell.h - gui/setup_audio.cpp - gui/setup_audio.h gui/setup.cpp gui/setup.h + gui/setup_audio.cpp + gui/setup_audio.h + gui/setup_colours.cpp + gui/setup_colours.h gui/setup_joystick.cpp gui/setup_joystick.h gui/setup_keyboard.cpp @@ -169,6 +179,10 @@ SET(SRCS gui/shop.h gui/shoplistbox.cpp gui/shoplistbox.h + gui/shortcutwindow.cpp + gui/shortcutwindow.h + gui/shortcutcontainer.cpp + gui/shortcutcontainer.h gui/skill.cpp gui/skill.h gui/slider.cpp @@ -187,6 +201,8 @@ SET(SRCS gui/textfield.h gui/trade.cpp gui/trade.h + gui/truetypefont.cpp + gui/truetypefont.h gui/updatewindow.h gui/updatewindow.cpp gui/viewport.cpp @@ -223,6 +239,8 @@ SET(SRCS net/network.h net/npchandler.cpp net/npchandler.h + net/partyhandler.cpp + net/partyhandler.h net/playerhandler.cpp net/playerhandler.h net/protocol.cpp @@ -299,6 +317,8 @@ SET(SRCS configuration.h effectmanager.cpp effectmanager.h + emoteshortcut.cpp + emoteshortcut.h engine.cpp engine.h equipment.cpp @@ -343,9 +363,13 @@ SET(SRCS openglgraphics.h particle.cpp particle.h + particlecontainer.cpp + particlecontainer.h particleemitter.cpp particleemitter.h particleemitterprop.h + party.cpp + party.h player.cpp player.h player_relations.cpp @@ -353,8 +377,6 @@ SET(SRCS position.cpp position.h properties.h - sdltruetypefont.cpp - sdltruetypefont.hpp serverinfo.h shopitem.cpp shopitem.h @@ -363,6 +385,10 @@ SET(SRCS sound.cpp sound.h sprite.h + text.cpp + text.h + textmanager.cpp + textmanager.h textparticle.cpp textparticle.h tileset.h diff --git a/src/Makefile.am b/src/Makefile.am index aebfdc41..3aeecc02 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -88,8 +88,6 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ gui/npc_text.h \ gui/ok_dialog.cpp \ gui/ok_dialog.h \ - gui/truetypefont.cpp \ - gui/truetypefont.h \ gui/passwordfield.cpp \ gui/passwordfield.h \ gui/playerbox.cpp \ @@ -151,6 +149,8 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ gui/textfield.h \ gui/trade.cpp \ gui/trade.h \ + gui/truetypefont.cpp \ + gui/truetypefont.h \ gui/updatewindow.h \ gui/updatewindow.cpp \ gui/viewport.cpp \ -- cgit v1.2.3-70-g09d2 From 487b7237a730469fc4f8a501a93f78c2bbafad51 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 13:43:46 -0700 Subject: Removed manual trimmings in exchange for using trim.h instead. Signed-off-by: Ira Rice --- src/being.cpp | 12 +++--------- src/resources/itemdb.cpp | 10 ++-------- 2 files changed, 5 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index 985be69c..9de03502 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -46,7 +46,8 @@ #include "utils/dtor.h" #include "utils/gettext.h" -#include "utils/tostring.h" +#include "utils/tostring.h" +#include "utils/trim.h" #include "utils/xml.h" int Being::instances = 0; @@ -176,14 +177,7 @@ void Being::setSpeech(const std::string &text, Uint32 time) mSpeech = text; // Trim whitespace - while (mSpeech[0] == ' ') - { - mSpeech = mSpeech.substr(1, mSpeech.size()); - } - while (mSpeech[mSpeech.size()] == ' ') - { - mSpeech = mSpeech.substr(0, mSpeech.size() - 1); - } + trim(mSpeech); // check for links std::string::size_type start = mSpeech.find('['); diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 773febd7..384efdf1 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -31,6 +31,7 @@ #include "../utils/dtor.h" #include "../utils/gettext.h" +#include "../utils/trim.h" #include "../utils/xml.h" namespace @@ -125,14 +126,7 @@ void ItemDB::load() if (itr == mNamedItemInfos.end()) { std::string temp = name; - while (temp[0] == ' ') - { - temp = temp.substr(1, temp.size()); - } - while (temp[temp.size()] == ' ') - { - temp = temp.substr(0, temp.size() - 1); - } + trim(temp); for (unsigned int i = 0; i < temp.size(); i++) { -- cgit v1.2.3-70-g09d2 From 1ca8d08b7619e1958371ce8d82e201b82ae39e32 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Wed, 28 Jan 2009 15:16:12 +0000 Subject: Fix handling of packet 0x81 --- src/net/charserverhandler.cpp | 51 ++++++++++++++++++++++++------------------- src/net/loginhandler.cpp | 34 ++++++++++++++++++++++++----- src/net/maploginhandler.cpp | 26 +++++++++++++++++----- src/net/protocol.h | 1 + 4 files changed, 79 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index 909100e5..b91a506a 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -43,6 +43,7 @@ CharServerHandler::CharServerHandler(): mCharCreateDialog(0) { static const Uint16 _messages[] = { + SMSG_CONNECTION_PROBLEM, 0x006b, 0x006c, 0x006d, @@ -50,7 +51,6 @@ CharServerHandler::CharServerHandler(): 0x006f, 0x0070, 0x0071, - 0x0081, 0 }; handledMessages = _messages; @@ -58,14 +58,40 @@ CharServerHandler::CharServerHandler(): void CharServerHandler::handleMessage(MessageIn *msg) { - int slot; - int flags; + int slot, flags, code; LocalPlayer *tempPlayer; logger->log("CharServerHandler: Packet ID: %x, Length: %d", msg->getId(), msg->getLength()); switch (msg->getId()) { + case SMSG_CONNECTION_PROBLEM: + code = msg->readInt8(); + logger->log("Connection problem: %i", code); + + switch (code) { + case 0: + errorMessage = "Authentication failed"; + break; + case 1: + errorMessage = "Map server(s) offline"; + break; + case 2: + errorMessage = "This account is already logged in"; + break; + case 3: + errorMessage = "Speed hack detected"; + break; + case 8: + errorMessage = "Duplicated login"; + break; + default: + errorMessage = "Unknown connection error"; + break; + } + state = ERROR_STATE; + break; + case 0x006b: msg->skip(2); // Length word flags = msg->readInt32(); // Aethyra extensions flags @@ -165,25 +191,6 @@ void CharServerHandler::handleMessage(MessageIn *msg) mCharInfo->select(slot); state = CONNECTING_STATE; break; - - case 0x0081: - switch (msg->readInt8()) { - case 1: - errorMessage = "Map server offline"; - break; - case 3: - errorMessage = "Speed hack detected"; - break; - case 8: - errorMessage = "Duplicated login"; - break; - default: - errorMessage = "Unknown error with 0x0081"; - break; - } - mCharInfo->unlock(); - state = ERROR_STATE; - break; } } diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index f240618d..db601214 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -34,7 +34,8 @@ extern SERVER_INFO **server_info; LoginHandler::LoginHandler() { static const Uint16 _messages[] = { - 0x0063, + SMSG_CONNECTION_PROBLEM, + SMSG_UPDATE_HOST, 0x0069, 0x006a, 0 @@ -44,9 +45,32 @@ LoginHandler::LoginHandler() void LoginHandler::handleMessage(MessageIn *msg) { + int code; + switch (msg->getId()) { - case 0x0063: + case SMSG_CONNECTION_PROBLEM: + code = msg->readInt8(); + logger->log("Connection problem: %i", code); + + switch (code) { + case 0: + errorMessage = "Authentication failed"; + break; + case 1: + errorMessage = "No servers available"; + break; + case 2: + errorMessage = "This account is already logged in"; + break; + default: + errorMessage = "Unknown connection error"; + break; + } + state = ERROR_STATE; + break; + + case SMSG_UPDATE_HOST: int len; len = msg->readInt16() - 4; @@ -90,10 +114,10 @@ void LoginHandler::handleMessage(MessageIn *msg) break; case 0x006a: - int loginError = msg->readInt8(); - logger->log("Login::error code: %i", loginError); + code = msg->readInt8(); + logger->log("Login::error code: %i", code); - switch (loginError) { + switch (code) { case 0: errorMessage = "Unregistered ID"; break; diff --git a/src/net/maploginhandler.cpp b/src/net/maploginhandler.cpp index 1b0919fa..b851117e 100644 --- a/src/net/maploginhandler.cpp +++ b/src/net/maploginhandler.cpp @@ -30,8 +30,8 @@ MapLoginHandler::MapLoginHandler() { static const Uint16 _messages[] = { + SMSG_CONNECTION_PROBLEM, SMSG_LOGIN_SUCCESS, - 0x0081, 0 }; handledMessages = _messages; @@ -39,10 +39,29 @@ MapLoginHandler::MapLoginHandler() void MapLoginHandler::handleMessage(MessageIn *msg) { + int code; unsigned char direction; switch (msg->getId()) { + case SMSG_CONNECTION_PROBLEM: + code = msg->readInt8(); + logger->log("Connection problem: %i", code); + + switch (code) { + case 0: + errorMessage = "Authentication failed"; + break; + case 2: + errorMessage = "This account is already logged in"; + break; + default: + errorMessage = "Unknown connection error"; + break; + } + state = ERROR_STATE; + break; + case SMSG_LOGIN_SUCCESS: msg->readInt32(); // server tick msg->readCoordinates(player_node->mX, player_node->mY, direction); @@ -51,10 +70,5 @@ void MapLoginHandler::handleMessage(MessageIn *msg) player_node->mX, player_node->mY, direction); state = GAME_STATE; break; - - case 0x0081: - logger->log("Warning: Map server D/C"); - state = ERROR_STATE; - break; } } diff --git a/src/net/protocol.h b/src/net/protocol.h index fd08c45d..e9053451 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -27,6 +27,7 @@ *********************************/ #define SMSG_LOGIN_SUCCESS 0x0073 /**< Contains starting location */ #define SMSG_SERVER_PING 0x007f /**< Contains server tick */ +#define SMSG_CONNECTION_PROBLEM 0x0081 #define SMSG_UPDATE_HOST 0x0063 /**< Custom update host packet */ #define SMSG_PLAYER_UPDATE_1 0x01d8 #define SMSG_PLAYER_UPDATE_2 0x01d9 -- cgit v1.2.3-70-g09d2 From 4418d3678337276070e6d46d8011ce052be388a5 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 16:58:56 -0700 Subject: Moved NPC text back to using the textbox. Rationale is that the textbox code is in much better shape than the browserbox code at the moment, and that the move to using the browserbox was a bit silly, as textbox already wraps. Signed-off-by: Ira Rice --- src/gui/npc_text.cpp | 40 +++++++++++++++++++++++++++------------- src/gui/npc_text.h | 13 +++++++++++-- 2 files changed, 38 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index a2e043d1..b2256f07 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -22,9 +22,9 @@ #include #include "npc_text.h" -#include "browserbox.h" #include "button.h" #include "scrollarea.h" +#include "textbox.h" #include "widgets/layout.h" @@ -42,10 +42,11 @@ NpcTextDialog::NpcTextDialog(): setDefaultSize(0, 0, 260, 200); - mBrowserBox = new BrowserBox(BrowserBox::AUTO_WRAP); - mBrowserBox->setOpaque(false); + mTextBox = new TextBox; + mTextBox->setEditable(false); + mTextBox->setOpaque(false); - scrollArea = new ScrollArea(mBrowserBox); + scrollArea = new ScrollArea(mTextBox); okButton = new Button(_("OK"), "ok", this); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -61,30 +62,43 @@ NpcTextDialog::NpcTextDialog(): setLocationRelativeTo(getParent()); } -void NpcTextDialog::clearText() -{ - mBrowserBox->clearRows(); -} - void NpcTextDialog::setText(const std::string &text) { - mBrowserBox->clearRows(); - mBrowserBox->addRow(text); + const gcn::Rectangle &area = getChildrenArea(); + const int width = area.width; + + mText = text; + mTextBox->setMinWidth(width - 30); + mTextBox->setTextWrapped(mText); } void NpcTextDialog::addText(const std::string &text) { - mBrowserBox->addRow(text); + setText(mText + text + "\n"); } void NpcTextDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "ok") { - clearText(); + setText(""); setVisible(false); if (current_npc) current_npc->nextDialog(); current_npc = 0; } } + +void NpcTextDialog::widgetResized(const gcn::Event &event) +{ + Window::widgetResized(event); + + const gcn::Rectangle &area = getChildrenArea(); + + mTextBox->setMinWidth(area.width - 30); + mTextBox->setTextWrapped(mText); + + // Set the text again so that it gets wrapped according to the new size + mTextBox->setTextWrapped(mText); +} + diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index b4b6f1af..4e0d33aa 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -29,7 +29,7 @@ #include "scrollarea.h" #include "window.h" -class BrowserBox; +class TextBox; /** * The npc text dialog. @@ -71,10 +71,19 @@ class NpcTextDialog : public Window, public gcn::ActionListener */ void addText(const std::string &string); + /** + * Called when resizing the window. + * + * @param event The calling event + */ + void widgetResized(const gcn::Event &event); + private: gcn::Button *okButton; gcn::ScrollArea *scrollArea; - BrowserBox *mBrowserBox; + TextBox *mTextBox; + + std::string mText; }; #endif // NPC_TEXT_H -- cgit v1.2.3-70-g09d2 From 129245a8063f09775930b0ffff11f043c219c277 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 18:03:14 -0700 Subject: Consolidated setMinWidth into textWrap, since all lines are dependant upon knowing what dimension they have to wrap to or beat in order for text wrapping to work. By adding this to be initiated at the same time as the text wrapping is done, this should decrease visual artifacts caused by not initializing it properly to begin with. Also made the item popups compact to the minimum dimension. Signed-off-by: Ira Rice --- src/gui/confirm_dialog.cpp | 6 +++--- src/gui/itempopup.cpp | 41 ++++++++++++++++++++--------------------- src/gui/npc_text.cpp | 14 ++------------ src/gui/ok_dialog.cpp | 3 +-- src/gui/speechbubble.cpp | 5 +---- src/gui/textbox.cpp | 6 +++++- src/gui/textbox.h | 7 +------ 7 files changed, 33 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp index 569fd93f..643d5d7a 100644 --- a/src/gui/confirm_dialog.cpp +++ b/src/gui/confirm_dialog.cpp @@ -41,8 +41,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, mTextArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mTextArea->setOpaque(false); - mTextBox->setMinWidth(260); - mTextBox->setTextWrapped(msg); + mTextBox->setTextWrapped(msg, 260); int numRows = mTextBox->getNumberOfRows(); int width = getFont()->getWidth(title); @@ -77,7 +76,8 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, add(yesButton); add(noButton); - if (getParent()) { + if (getParent()) + { setLocationRelativeTo(getParent()); getParent()->moveToTop(this); } diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 8235d640..1256275d 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -55,8 +55,6 @@ ItemPopup::ItemPopup(): // Item Description mItemDesc = new TextBox(); mItemDesc->setEditable(false); - mItemDesc->setMinWidth(186); - mItemDesc->setTextWrapped(""); mItemDescScroll = new ScrollArea(mItemDesc); mItemDescScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -68,8 +66,6 @@ ItemPopup::ItemPopup(): // Item Effect mItemEffect = new TextBox(); mItemEffect->setEditable(false); - mItemEffect->setMinWidth(186); - mItemEffect->setTextWrapped(""); mItemEffectScroll = new ScrollArea(mItemEffect); mItemEffectScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -81,8 +77,6 @@ ItemPopup::ItemPopup(): // Item Weight mItemWeight = new TextBox(); mItemWeight->setEditable(false); - mItemWeight->setMinWidth(186); - mItemWeight->setTextWrapped(""); mItemWeightScroll = new ScrollArea(mItemWeight); mItemWeightScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -104,35 +98,40 @@ ItemPopup::ItemPopup(): void ItemPopup::setItem(const ItemInfo &item) { - const gcn::Rectangle &area = getChildrenArea(); - const int width = area.width; - - mItemDesc->setMinWidth(width - 10); - mItemEffect->setMinWidth(width - 10); - mItemWeight->setMinWidth(width - 10); - mItemName->setCaption(item.getName()); - mItemDesc->setTextWrapped(item.getDescription()); - mItemEffect->setTextWrapped(item.getEffect()); + mItemDesc->setTextWrapped(item.getDescription(), 196); + mItemEffect->setTextWrapped(item.getEffect(), 196); mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) + - _(" grams")); + _(" grams"), 196); + + int minWidth = mItemName->getWidth(); + + if (mItemDesc->getMinWidth() > minWidth) + minWidth = mItemDesc->getMinWidth(); + if (mItemEffect->getMinWidth() > minWidth) + minWidth = mItemEffect->getMinWidth(); + if (mItemWeight->getMinWidth() > minWidth) + minWidth = mItemWeight->getMinWidth(); + + minWidth += 8; + setWidth(minWidth); int numRowsDesc = mItemDesc->getNumberOfRows(); int numRowsEffect = mItemEffect->getNumberOfRows(); int numRowsWeight = mItemWeight->getNumberOfRows(); - mItemDescScroll->setDimension(gcn::Rectangle(2, 0, 196, + mItemDescScroll->setDimension(gcn::Rectangle(2, 0, minWidth, numRowsDesc * getFont()->getHeight())); - mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, 196, + mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, minWidth, numRowsEffect * getFont()->getHeight())); - mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, 196, + mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, minWidth, numRowsWeight * getFont()->getHeight())); if(item.getEffect() == "") { - setContentSize(200, (numRowsDesc * getFont()->getHeight() + + setContentSize(minWidth, (numRowsDesc * getFont()->getHeight() + (3 * getFont()->getHeight()))); mItemWeightScroll->setPosition(2, @@ -141,7 +140,7 @@ void ItemPopup::setItem(const ItemInfo &item) } else { - setContentSize(200, (numRowsDesc * getFont()->getHeight()) + + setContentSize(minWidth, (numRowsDesc * getFont()->getHeight()) + (numRowsEffect * getFont()->getHeight()) + (3 * getFont()->getHeight())); diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index b2256f07..1e29b793 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -64,12 +64,8 @@ NpcTextDialog::NpcTextDialog(): void NpcTextDialog::setText(const std::string &text) { - const gcn::Rectangle &area = getChildrenArea(); - const int width = area.width; - mText = text; - mTextBox->setMinWidth(width - 30); - mTextBox->setTextWrapped(mText); + mTextBox->setTextWrapped(mText, scrollArea->getWidth() - 15); } void NpcTextDialog::addText(const std::string &text) @@ -93,12 +89,6 @@ void NpcTextDialog::widgetResized(const gcn::Event &event) { Window::widgetResized(event); - const gcn::Rectangle &area = getChildrenArea(); - - mTextBox->setMinWidth(area.width - 30); - mTextBox->setTextWrapped(mText); - - // Set the text again so that it gets wrapped according to the new size - mTextBox->setTextWrapped(mText); + setText(mText); } diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp index dc66a900..7f63b152 100644 --- a/src/gui/ok_dialog.cpp +++ b/src/gui/ok_dialog.cpp @@ -40,8 +40,7 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, mTextArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mTextArea->setOpaque(false); - mTextBox->setMinWidth(260); - mTextBox->setTextWrapped(msg); + mTextBox->setTextWrapped(msg, 260); int numRows = mTextBox->getNumberOfRows(); diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index a6bb5563..7eedce1c 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -65,8 +65,6 @@ SpeechBubble::SpeechBubble(): // LEEOR / TODO: This causes an exception error. //moveToBottom(getParent()); - - mSpeechBox->setTextWrapped( "" ); } void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color) @@ -78,8 +76,7 @@ void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color) void SpeechBubble::setText(std::string mText) { - mSpeechBox->setMinWidth(140); - mSpeechBox->setTextWrapped(mText); + mSpeechBox->setTextWrapped(mText, 130); const int fontHeight = getFont()->getHeight(); const int numRows = mSpeechBox->getNumberOfRows() + 1; diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index ee03c79d..fb5a39e6 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -31,9 +31,10 @@ TextBox::TextBox(): { setOpaque(false); setFrameSize(0); + mMinWidth = getWidth(); } -void TextBox::setTextWrapped(const std::string &text) +void TextBox::setTextWrapped(const std::string &text, int minDimension) { // Make sure parent scroll area sets width of this widget if (getParent()) @@ -41,6 +42,9 @@ void TextBox::setTextWrapped(const std::string &text) getParent()->logic(); } + // Take the supplied minimum dimension as a starting point and try to beat it + mMinWidth = minDimension; + std::stringstream wrappedStream; std::string::size_type newlinePos, lastNewlinePos = 0; int minWidth = 0; diff --git a/src/gui/textbox.h b/src/gui/textbox.h index 98b60402..84dd6268 100644 --- a/src/gui/textbox.h +++ b/src/gui/textbox.h @@ -43,18 +43,13 @@ class TextBox : public gcn::TextBox { /** * Sets the text after wrapping it to the current width of the widget. */ - void setTextWrapped(const std::string &text); + void setTextWrapped(const std::string &text, int minDimension); /** * Get the minimum text width for the text box. */ int getMinWidth() { return mMinWidth; } - /** - * Set the minimum text width for the text box. - */ - void setMinWidth(int width) { mMinWidth = width; } - private: int mMinWidth; }; -- cgit v1.2.3-70-g09d2 From 7a99b87f6f5e42072fa268876795289ab75a271e Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 19:14:41 -0700 Subject: Finally put in the last missing wrapping case that has been missing from the textbox class. Should now always choose the most ideal text wrap possible. Signed-off-by: Ira Rice --- src/gui/textbox.cpp | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index fb5a39e6..98096112 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -92,9 +92,8 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) else { if (xpos > minWidth) - { minWidth = xpos; - } + // The window wasn't big enough. Resize it and try again. if (minWidth > mMinWidth) { @@ -120,17 +119,37 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) while (spacePos != line.size()); if (text.find("\n", lastNewlinePos) != std::string::npos) - { wrappedStream << "\n"; - } + lastNewlinePos = newlinePos + 1; + + // Is the last line we're trying to text wrap longer than the minimum + // width we're trying to beat in the first place? If so, then rewrap + // using that length. + if (newlinePos == text.size()) + { + spacePos = text.rfind(" ", text.size()); + const std::string word = line.substr(spacePos + 1); + const int length = getFont()->getWidth(word); + + if ((length > xpos || length > minWidth) && mMinWidth != length) + { + mMinWidth = length; + wrappedStream.clear(); + wrappedStream.str(""); + spacePos = 0; + lastNewlinePos = 0; + newlinePos = text.find("\n", lastNewlinePos); + line = text.substr(lastNewlinePos, newlinePos - + lastNewlinePos); + } + } } while (newlinePos != text.size()); if (xpos > minWidth) - { minWidth = xpos; - } + mMinWidth = minWidth; gcn::TextBox::setText(wrappedStream.str()); -- cgit v1.2.3-70-g09d2 From 63886946dceb5e3a4345810d35327e9767cba913 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 19:19:25 -0700 Subject: Fix for a mistake in one of the logicc statements in the last commit. Signed-off-by: Ira Rice --- src/gui/textbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index 98096112..b36897d6 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -132,7 +132,7 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) const std::string word = line.substr(spacePos + 1); const int length = getFont()->getWidth(word); - if ((length > xpos || length > minWidth) && mMinWidth != length) + if ((length > xpos || length > minWidth) && length > mMinWidth) { mMinWidth = length; wrappedStream.clear(); -- cgit v1.2.3-70-g09d2 From 0e2a2f39a2137ea1caae96256431c7d35fc2e6ec Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 20:31:36 -0700 Subject: Fixed a slight error in item name widths. Signed-off-by: Ira Rice --- src/gui/itempopup.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 1256275d..402f9e05 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -47,10 +47,8 @@ ItemPopup::ItemPopup(): // Item Name mItemName = new gcn::Label("Label"); - mItemName->setFont(gui->getFont()); - mItemName->setPosition(2, 2); - mItemName->setWidth(getWidth() - 4); mItemName->setFont(boldFont); + mItemName->setPosition(2, 2); // Item Description mItemDesc = new TextBox(); @@ -99,6 +97,7 @@ ItemPopup::ItemPopup(): void ItemPopup::setItem(const ItemInfo &item) { mItemName->setCaption(item.getName()); + mItemName->setWidth(boldFont->getWidth(item.getName())); mItemDesc->setTextWrapped(item.getDescription(), 196); mItemEffect->setTextWrapped(item.getEffect(), 196); mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) + -- cgit v1.2.3-70-g09d2 From 5a3c174a53ed90224dc4fc49744c656eb9d358fa Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 23:41:36 -0700 Subject: Added coloring of item names by type. TODO: Allow this to be customizable through the color interface so that if someone is colorblind to a certain color and it doesn't show up well, they can change it (or even people who just don't like the default color). Signed-off-by: Ira Rice --- src/gui/itempopup.cpp | 35 +++++++++++++++++++++++++++++++++++ src/gui/itempopup.h | 3 +++ src/resources/itemdb.cpp | 4 ++-- src/resources/iteminfo.h | 12 +++++------- 4 files changed, 45 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 402f9e05..9b84b39e 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -97,6 +97,7 @@ ItemPopup::ItemPopup(): void ItemPopup::setItem(const ItemInfo &item) { mItemName->setCaption(item.getName()); + mItemName->setForegroundColor(getColor(item.getType())); mItemName->setWidth(boldFont->getWidth(item.getName())); mItemDesc->setTextWrapped(item.getDescription(), 196); mItemEffect->setTextWrapped(item.getEffect(), 196); @@ -154,6 +155,40 @@ void ItemPopup::setItem(const ItemInfo &item) (2 * getFont()->getHeight())); } +gcn::Color ItemPopup::getColor(const std::string& type) +{ + gcn::Color color; + + if (type.compare("generic") == 0) + color = 0x21a5b1; + else if (type.compare("equip-head") == 0) + color = 0x527fa4; + else if (type.compare("usable") == 0) + color = 0x268d24; + else if (type.compare("equip-torso") == 0) + color = 0xd12aa4; + else if (type.compare("equip-1hand") == 0) + color = 0xf42a2a; + else if (type.compare("equip-legs") == 0) + color = 0x718218; + else if (type.compare("equip-feet") == 0) + color = 0xf44ca5; + else if (type.compare("equip-2hand") == 0) + color = 0xf46d0e; + else if (type.compare("equip-shield") == 0) + color = 0x9c2424; + else if (type.compare("equip-ring") == 0) + color = 0xf4ea17; + else if (type.compare("equip-arms") == 0) + color = 0x9c24e8; + else if (type.compare("equip-ammo") == 0) + color = 0xbe8717; + else + color = 0x000000; + + return color; +} + unsigned int ItemPopup::getNumRows() { return mItemDesc->getNumberOfRows() + mItemEffect->getNumberOfRows() + diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index 0c729231..3c8f575d 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -27,6 +27,7 @@ #include "textbox.h" #include "window.h" +#include "../guichanfwd.h" #include "../item.h" class ItemPopup : public Window @@ -46,6 +47,8 @@ class ItemPopup : public Window ScrollArea *mItemDescScroll; ScrollArea *mItemEffectScroll; ScrollArea *mItemWeightScroll; + + gcn::Color getColor(const std::string& type); }; #endif // ITEMPOPUP_H__ diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 384efdf1..752ea38b 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -84,7 +84,7 @@ void ItemDB::load() logger->log(_("ItemDB: Redefinition of item ID %d"), id); } - int type = XML::getProperty(node, "type", 0); + std::string type = XML::getProperty(node, "type", "other"); int weight = XML::getProperty(node, "weight", 0); int view = XML::getProperty(node, "view", 0); @@ -152,7 +152,7 @@ void ItemDB::load() CHECK_PARAM(description, ""); // CHECK_PARAM(effect, ""); // CHECK_PARAM(type, 0); - CHECK_PARAM(weight, 0); + // CHECK_PARAM(weight, 0); // CHECK_PARAM(slot, 0); #undef CHECK_PARAM diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 86725ca2..c03dec28 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -47,7 +47,7 @@ class ItemInfo * Constructor. */ ItemInfo(): - mType(0), + mType(""), mWeight(0), mView(0), mAttackType(ACTION_DEFAULT) @@ -81,14 +81,12 @@ class ItemInfo void setEffect(const std::string &effect) { mEffect = effect; } - const std::string& - getEffect() const { return mEffect; } + const std::string& getEffect() const { return mEffect; } - void setType(short type) + void setType(const std::string& type) { mType = type; } - short getType() const - { return mType; } + const std::string& getType() const { return mType; } void setWeight(short weight) { mWeight = weight; } @@ -118,7 +116,7 @@ class ItemInfo std::string mName; std::string mDescription; /**< Short description. */ std::string mEffect; /**< Description of effects. */ - char mType; /**< Item type. */ + std::string mType; /**< Item type. */ short mWeight; /**< Weight in grams. */ int mView; /**< Item ID of how this item looks. */ int mId; /**< Item ID */ -- cgit v1.2.3-70-g09d2 From f9cacf3f34db1ccf3b6aea0d1e58029a89bed78b Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 23:54:56 -0700 Subject: Adjusted a few color defaults to make them easier to see. Signed-off-by: Ira Rice --- src/gui/itempopup.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 9b84b39e..80edd354 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -170,19 +170,19 @@ gcn::Color ItemPopup::getColor(const std::string& type) else if (type.compare("equip-1hand") == 0) color = 0xf42a2a; else if (type.compare("equip-legs") == 0) - color = 0x718218; + color = 0x699900; else if (type.compare("equip-feet") == 0) - color = 0xf44ca5; + color = 0xaa1d48; else if (type.compare("equip-2hand") == 0) color = 0xf46d0e; else if (type.compare("equip-shield") == 0) color = 0x9c2424; else if (type.compare("equip-ring") == 0) - color = 0xf4ea17; + color = 0x0000ff; else if (type.compare("equip-arms") == 0) color = 0x9c24e8; else if (type.compare("equip-ammo") == 0) - color = 0xbe8717; + color = 0x8b6311; else color = 0x000000; -- cgit v1.2.3-70-g09d2 From a48b3777b83f9703fb1dbde48bdc6d5f22f66a38 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 29 Jan 2009 00:40:12 -0700 Subject: Fixed a crash caused by getting the wrong string substring. In doing so, the algorithm was optimized further, so that only one correction needs to be done if the last line is the longest. Signed-off-by: Ira Rice --- src/gui/textbox.cpp | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index b36897d6..c04b4262 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -65,6 +65,19 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) std::string::size_type spacePos, lastSpacePos = 0; xpos = 0; + spacePos = text.rfind(" ", text.size()); + if (spacePos == std::string::npos) + { + spacePos = 0; + } + else + { + const std::string word = text.substr(spacePos + 1); + const int length = getFont()->getWidth(word); + + if (length > mMinWidth) + mMinWidth = length; + } do { spacePos = line.find(" ", lastSpacePos); @@ -103,6 +116,8 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) spacePos = 0; lastNewlinePos = 0; newlinePos = text.find("\n", lastNewlinePos); + if (newlinePos == std::string::npos) + newlinePos = text.size(); line = text.substr(lastNewlinePos, newlinePos - lastNewlinePos); width = 0; @@ -122,28 +137,6 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) wrappedStream << "\n"; lastNewlinePos = newlinePos + 1; - - // Is the last line we're trying to text wrap longer than the minimum - // width we're trying to beat in the first place? If so, then rewrap - // using that length. - if (newlinePos == text.size()) - { - spacePos = text.rfind(" ", text.size()); - const std::string word = line.substr(spacePos + 1); - const int length = getFont()->getWidth(word); - - if ((length > xpos || length > minWidth) && length > mMinWidth) - { - mMinWidth = length; - wrappedStream.clear(); - wrappedStream.str(""); - spacePos = 0; - lastNewlinePos = 0; - newlinePos = text.find("\n", lastNewlinePos); - line = text.substr(lastNewlinePos, newlinePos - - lastNewlinePos); - } - } } while (newlinePos != text.size()); -- cgit v1.2.3-70-g09d2 From 0a2883b61472c5dbcd419d033bd8792c335dc175 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 29 Jan 2009 00:43:16 -0700 Subject: Removed useless check from the last commit. Signed-off-by: Ira Rice --- src/gui/textbox.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index c04b4262..e7986244 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -66,11 +66,8 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) xpos = 0; spacePos = text.rfind(" ", text.size()); - if (spacePos == std::string::npos) - { - spacePos = 0; - } - else + + if (spacePos != std::string::npos) { const std::string word = text.substr(spacePos + 1); const int length = getFont()->getWidth(word); @@ -78,6 +75,7 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) if (length > mMinWidth) mMinWidth = length; } + do { spacePos = line.find(" ", lastSpacePos); -- cgit v1.2.3-70-g09d2 From 68f3b73a82999b8ee8c7937b9da8060af1f3b691 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 29 Jan 2009 08:55:59 -0700 Subject: If an item link isn't found, don't treat it as a link. Signed-off-by: Ira Rice --- src/being.cpp | 3 ++- src/gui/chat.cpp | 20 ++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index 9de03502..e2495bc0 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -193,7 +193,8 @@ void Being::setSpeech(const std::string &text, Uint32 time) } std::string::size_type position = mSpeech.find('|'); - mSpeech.erase(end, 1); + if (mSpeech[start + 1] == '@' && mSpeech[start + 2] == '@') + mSpeech.erase(end, 1); mSpeech.erase(start, (position - start) + 1); position = mSpeech.find('@'); diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 068fad08..d790d292 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -376,14 +376,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) std::string temp = msg.substr(start+1, end - start - 1); - while (temp[0] == ' ') - { - temp = temp.substr(1, temp.size()); - } - while (temp[temp.size()] == ' ') - { - temp = temp.substr(0, temp.size() - 1); - } + trim(temp); for (unsigned int i = 0; i < temp.size(); i++) { @@ -391,10 +384,13 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) } const ItemInfo itemInfo = ItemDB::get(temp); - msg.insert(end, "@@"); - msg.insert(start+1, "|"); - msg.insert(start+1, toString(itemInfo.getId())); - msg.insert(start+1, "@@"); + if (itemInfo.getName() != _("Unknown item")) + { + msg.insert(end, "@@"); + msg.insert(start+1, "|"); + msg.insert(start+1, toString(itemInfo.getId())); + msg.insert(start+1, "@@"); + } } start = msg.find('[', start + 1); } -- cgit v1.2.3-70-g09d2 From 0187f66a01fb38f6683f528770a69652af90b35e Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 29 Jan 2009 09:04:02 -0700 Subject: Make sure that strings aren't chopped off when a | isn't found. Signed-off-by: Ira Rice --- src/being.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index e2495bc0..dc36adc2 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -194,8 +194,10 @@ void Being::setSpeech(const std::string &text, Uint32 time) std::string::size_type position = mSpeech.find('|'); if (mSpeech[start + 1] == '@' && mSpeech[start + 2] == '@') + { mSpeech.erase(end, 1); - mSpeech.erase(start, (position - start) + 1); + mSpeech.erase(start, (position - start) + 1); + } position = mSpeech.find('@'); while (position != std::string::npos) -- cgit v1.2.3-70-g09d2 From 59cfd8a03f22f43539d47a55087ad5768e7a330f Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 29 Jan 2009 09:27:45 -0700 Subject: Don't send empty chats (long lines of empty spaces). Signed-off-by: Ira Rice --- src/gui/chat.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index d790d292..3a22581f 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -341,6 +341,11 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) * require server handling by proper packet. Probably * those if elses should be replaced by protocol calls */ + trim(msg); + + if (msg.compare("") == 0) + return; + // Send party message if (msg.at(0) == mPartyPrefix) { -- cgit v1.2.3-70-g09d2 From d3ac12d94f6ddb25866e10856ec47919a4b6d7a6 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 29 Jan 2009 16:25:16 -0700 Subject: Fixed up minimap resizing code so that the minimum width is always long enough to contain the map's name. Also fixed an unnoticed logic flip that was done unintentionally. This class now manages to work perfectly when the config file has no previous dimensional influences, but still won't resize properly without removing the ability to resize or getting rid of those stored configs. TODO: Find out why loading window configuration for the default minimum width or height overrides the Minimap's supplied dimensions it wants. Signed-off-by: Ira Rice --- src/gui/minimap.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 7802b583..d68faa56 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -71,19 +71,25 @@ void Minimap::setMapImage(Image *img) setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth); setMinHeight(mapHeight); - setMaxWidth(mMapImage->getWidth() + offsetX); + setMaxWidth(mMapImage->getWidth() > titleWidth ? + mMapImage->getWidth() + offsetX : titleWidth); setMaxHeight(mMapImage->getHeight() + offsetY); mMapImage->setAlpha(config.getValue("guialpha", 0.8)); - // Set content size to be within the minimum and maximum boundaries - setWidth(getMinWidth() < getWidth() ? getWidth() : getMinWidth()); - if (getMaxWidth() > getWidth()) + // Make sure the window is within the minimum and maximum boundaries + // TODO: Shouldn't this be happening automatically within the Window + // class? + if (getMinWidth() > getWidth()) + setWidth(getMinWidth()); + else if (getMaxWidth() < getWidth()) setWidth(getMaxWidth()); - setHeight(getMinHeight() < getHeight() ? getHeight() : getMinHeight()); - if (getMaxHeight() > getHeight()) + if (getMinHeight() > getHeight()) + setHeight(getMinHeight()); + else if (getMaxHeight() < getHeight()) setHeight(getMaxHeight()); + setContentSize(getWidth() - offsetX, getHeight() - offsetY); setDefaultSize(getX(), getY(), getWidth(), getHeight()); resetToDefaultSize(); -- cgit v1.2.3-70-g09d2 From 5a217925e3088bfbb187d274ced159754e2397c2 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 29 Jan 2009 17:34:37 -0700 Subject: Trimmed out a few help functions from some subclasses, and moved them back to the chat class, where they really belong. Since the party class parses its own suboptions, I left the suboptions within that class. Signed-off-by: Ira Rice --- src/gui/chat.cpp | 13 +++++++++---- src/gui/recorder.cpp | 19 ++----------------- src/gui/recorder.h | 15 ++------------- src/party.cpp | 5 ----- src/party.h | 1 - 5 files changed, 13 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 3a22581f..36e33160 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -478,7 +478,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) else if (command == "whisper" || command == "msg" || command == "w") whisper(nick, msg); else if (command == "record") - mRecorder->changeStatus(msg); + mRecorder->changeRecordingStatus(msg); else if (command == "toggle") { if (msg == "") @@ -804,10 +804,11 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) chatLog(_("/announce: Global announcement (GM only)"), BY_SERVER); chatLog(_("/clear: Clears this window"), BY_SERVER); chatLog(_("/help: Display this help"), BY_SERVER); - mParty->help(); + chatLog(_("/party : Party commands."), BY_SERVER); chatLog(_("/msg : Alternate form for /whisper"), BY_SERVER); chatLog(_("/present: Get list of players present"), BY_SERVER); - mRecorder->help(); + chatLog(_("/record : Start recording the chat to an" + " external file."), BY_SERVER); chatLog(_("/toggle: Determine whether toggles the chat log."), BY_SERVER); chatLog(_("/where: Display map name"), BY_SERVER); @@ -851,7 +852,11 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) } else if (msg1 == "record") { - mRecorder->help2(); + chatLog(_("Command: /record "), BY_SERVER); + chatLog(_("This command starts recording the chat log to the file " + "."), BY_SERVER); + chatLog(_("Command: /record"), BY_SERVER); + chatLog(_("This command finishes a recording session."), BY_SERVER); } else if (msg1 == "toggle") { diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp index da67875b..02eddbe5 100644 --- a/src/gui/recorder.cpp +++ b/src/gui/recorder.cpp @@ -46,7 +46,7 @@ void Recorder::record(const std::string &msg) } } -void Recorder::changeStatus(const std::string &msg) +void Recorder::changeRecordingStatus(const std::string &msg) { std::string msgCopy = msg; trim(msgCopy); @@ -91,24 +91,9 @@ void Recorder::changeStatus(const std::string &msg) } } -void Recorder::help() const -{ - mChat->chatLog("/record : Start recording the chat.", BY_SERVER); -} - -void Recorder::help2() const -{ - mChat->chatLog("Command: /record ", BY_SERVER); - mChat->chatLog("This command starts recording the chat log to the file " - ".", BY_SERVER); - mChat->chatLog("Command: /record", BY_SERVER); - mChat->chatLog("This command finishes a recording session.", BY_SERVER); -} - void Recorder::action(const gcn::ActionEvent &event) { - if (event.getId() == "activate") - changeStatus(""); + changeRecordingStatus(""); } Recorder::~Recorder() diff --git a/src/gui/recorder.h b/src/gui/recorder.h index 6f917c25..420c4a2b 100644 --- a/src/gui/recorder.h +++ b/src/gui/recorder.h @@ -53,20 +53,9 @@ class Recorder : public Window, public gcn::ActionListener /* * Outputs the message to the recorder file * - * @param msg the line to write to the recorded file. - */ - void changeStatus(const std::string &msg); - - /* - * Displays a help message on how to use this class in the chat window. - */ - void help() const; - - /* - * Displays an extended help message on how to use this class in the - * chat window. + * @param msg The file to write out to. If null, then stop recording. */ - void help2() const; + void changeRecordingStatus(const std::string &msg); /* * Whether or not the recorder is in use. diff --git a/src/party.cpp b/src/party.cpp index ecb0ab2d..67262176 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -166,11 +166,6 @@ void Party::receiveChat(Being *being, const std::string &msg) mChat->chatLog(being->getName() + " : " + msg, BY_PARTY); } -void Party::help() -{ - mChat->chatLog(_("/party : Party commands."), BY_SERVER); -} - void Party::help(const std::string &msg) { if (msg == "") diff --git a/src/party.h b/src/party.h index 8d6dce47..5643f894 100644 --- a/src/party.h +++ b/src/party.h @@ -47,7 +47,6 @@ class Party void leftResponse(const std::string &nick); void receiveChat(Being *being, const std::string &msg); - void help(); void help(const std::string &msg); private: ChatWindow *mChat; -- cgit v1.2.3-70-g09d2 From a49b60fc0f9edfba8ec457ce06cf75cc13d4c71b Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 07:51:11 -0700 Subject: Fixed the last freestanding minimap bug. Now minimaps behave perfectly even when there's already a saved window configuration. Signed-off-by: Ira Rice --- src/gui/minimap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index d68faa56..d1d3af46 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -44,6 +44,8 @@ Minimap::Minimap(): mShow = config.getValue(getWindowName() + "Visible", true); setDefaultSize(5, 25, 100, 100); setResizable(true); + + loadWindowState(); } Minimap::~Minimap() @@ -93,7 +95,6 @@ void Minimap::setMapImage(Image *img) setDefaultSize(getX(), getY(), getWidth(), getHeight()); resetToDefaultSize(); - loadWindowState(); setVisible(mShow); } else -- cgit v1.2.3-70-g09d2 From ea9ca516da190a1a328b455c4d98a9fd57182e55 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 08:43:15 -0700 Subject: Fixed color saving on Windows. Signed-off-by: Ira Rice --- src/gui/colour.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/colour.cpp b/src/gui/colour.cpp index 816420ed..e6ceeaca 100644 --- a/src/gui/colour.cpp +++ b/src/gui/colour.cpp @@ -26,6 +26,7 @@ #include "../configuration.h" #include "../utils/gettext.h" +#include "../utils/tostring.h" Colour::Colour() { @@ -48,9 +49,7 @@ Colour::~Colour() col != colEnd; ++col) { - char buffer[20]; - std::sprintf(buffer, "0x%06x", col->rgb); - config.setValue("Colour" + col->text, buffer); + config.setValue("Colour" + col->text, toString(col->rgb)); } } -- cgit v1.2.3-70-g09d2 From 4c0f83e55fd1f6fabc2d8152843175b8ea55bc2b Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 09:06:56 -0700 Subject: Re-enabled real time gui opacity updating. Signed-off-by: Ira Rice --- src/gui/window.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/window.cpp b/src/gui/window.cpp index dba65143..66f38aa8 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -58,9 +58,6 @@ class WindowConfigListener : public ConfigListener void optionChanged(const std::string &) { Window::mAlphaChanged = true; -// for_each(Window::border.grid, Window::border.grid + 9, -// std::bind2nd(std::mem_fun(&Image::setAlpha), -// config.getValue("guialpha", 0.8))); } }; @@ -195,6 +192,14 @@ void Window::draw(gcn::Graphics *graphics) getPadding() ); } + + // Update window alpha values + if (mAlphaChanged) + { + for_each(border.grid, border.grid + 9, + std::bind2nd(std::mem_fun(&Image::setAlpha), + config.getValue("guialpha", 0.8))); + } drawChildren(graphics); } -- cgit v1.2.3-70-g09d2 From cc37b4a9153379d5c5529ba85305d36efba2cd85 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 09:17:03 -0700 Subject: Changed the minimap to remember whether the minimap was toggled or not when the client was last exited. Signed-off-by: Ira Rice --- src/gui/minimap.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index d1d3af46..0b156fc4 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -41,7 +41,7 @@ Minimap::Minimap(): mProportion(0.5) { setWindowName(_("MiniMap")); - mShow = config.getValue(getWindowName() + "Visible", true); + mShow = config.getValue(getWindowName() + "Show", true); setDefaultSize(5, 25, 100, 100); setResizable(true); @@ -52,6 +52,8 @@ Minimap::~Minimap() { if (mMapImage) mMapImage->decRef(); + + config.setValue(getWindowName() + "Show", mShow); } void Minimap::setMapImage(Image *img) @@ -106,7 +108,6 @@ void Minimap::setMapImage(Image *img) void Minimap::toggle() { mShow = !mShow; - config.setValue(getWindowName() + "Visible", mShow); } void Minimap::draw(gcn::Graphics *graphics) -- cgit v1.2.3-70-g09d2 From d57be9d49c55bc0b85eb8f539ff2029518cfafc0 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 10:56:54 -0700 Subject: Exposed most gui elements to take alpha values. There are still a few spots that could also be fixed up as well, but require other methods to fix them (the filled color rectangles on the progress bars, as well as the text on them as well, as an example). Signed-off-by: Ira Rice --- src/gui/button.cpp | 34 ++++++++++++++++++++++------------ src/gui/button.h | 1 + src/gui/checkbox.cpp | 27 +++++++++++++++++++++------ src/gui/checkbox.h | 1 + src/gui/emoteshortcutcontainer.cpp | 13 +++++++++++-- src/gui/itemshortcutcontainer.cpp | 8 ++++++-- src/gui/minimap.cpp | 2 -- src/gui/playerbox.cpp | 9 +++++++++ src/gui/playerbox.h | 1 + src/gui/progressbar.cpp | 17 +++++++++++++++++ src/gui/progressbar.h | 1 + src/gui/scrollarea.cpp | 11 +++++++++++ src/gui/scrollarea.h | 1 + src/gui/shortcutcontainer.cpp | 4 +++- src/gui/shortcutcontainer.h | 2 ++ src/gui/slider.cpp | 16 ++++++++++++++++ src/gui/slider.h | 1 + src/gui/textfield.cpp | 13 ++++++++++--- src/gui/textfield.h | 1 + src/gui/widgets/resizegrip.cpp | 9 +++++++++ src/gui/widgets/resizegrip.h | 1 + src/gui/widgets/tab.cpp | 13 +++++++++++++ src/gui/widgets/tab.h | 1 + src/gui/window.cpp | 1 + 24 files changed, 160 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 9b624015..d578202e 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -21,6 +21,7 @@ #include "button.h" +#include "../configuration.h" #include "../graphics.h" #include "../resources/image.h" @@ -35,6 +36,7 @@ #include int Button::mInstances = 0; +float Button::mAlpha = config.getValue("guialpha", 0.8); enum{ BUTTON_STANDARD, // 0 @@ -100,6 +102,7 @@ void Button::init() data[x].gridX, data[y].gridY, data[x + 1].gridX - data[x].gridX + 1, data[y + 1].gridY - data[y].gridY + 1); + button[mode].grid[a]->setAlpha(mAlpha); a++; } } @@ -126,17 +129,25 @@ void Button::draw(gcn::Graphics *graphics) { int mode; - if (!isEnabled()) { + if (!isEnabled()) mode = BUTTON_DISABLED; - } - else if (isPressed() || mIsLogged) { + else if (isPressed() || mIsLogged) mode = BUTTON_PRESSED; - } - else if (mHasMouse || isFocused()) { + else if (mHasMouse || isFocused()) mode = BUTTON_HIGHLIGHTED; - } - else { + else mode = BUTTON_STANDARD; + + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + for (int a = 0; a < 9; a++) + { + button[BUTTON_DISABLED].grid[a]->setAlpha(mAlpha); + button[BUTTON_PRESSED].grid[a]->setAlpha(mAlpha); + button[BUTTON_HIGHLIGHTED].grid[a]->setAlpha(mAlpha); + button[BUTTON_STANDARD].grid[a]->setAlpha(mAlpha); + } } static_cast(graphics)-> @@ -147,7 +158,8 @@ void Button::draw(gcn::Graphics *graphics) int textX; int textY = getHeight() / 2 - getFont()->getHeight() / 2; - switch (getAlignment()) { + switch (getAlignment()) + { case gcn::Graphics::LEFT: textX = 4; break; @@ -163,10 +175,8 @@ void Button::draw(gcn::Graphics *graphics) graphics->setFont(getFont()); - if (isPressed()) { + if (isPressed()) graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment()); - } - else { + else graphics->drawText(getCaption(), textX, textY, getAlignment()); - } } diff --git a/src/gui/button.h b/src/gui/button.h index d8ed9fa7..1faf2455 100644 --- a/src/gui/button.h +++ b/src/gui/button.h @@ -71,6 +71,7 @@ class Button : public gcn::Button static ImageRect button[4]; /**< Button state graphics */ static int mInstances; /**< Number of button instances */ + static float mAlpha; bool mIsLogged; /**< Makes the button appear pressed all the time */ }; diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp index b8fca2b8..7fa4fa81 100644 --- a/src/gui/checkbox.cpp +++ b/src/gui/checkbox.cpp @@ -21,12 +21,14 @@ #include "checkbox.h" +#include "../configuration.h" #include "../graphics.h" #include "../resources/image.h" #include "../resources/resourcemanager.h" int CheckBox::instances = 0; +float CheckBox::mAlpha = config.getValue("guialpha", 0.8); Image *CheckBox::checkBoxNormal; Image *CheckBox::checkBoxChecked; Image *CheckBox::checkBoxDisabled; @@ -43,6 +45,10 @@ CheckBox::CheckBox(const std::string& caption, bool selected): checkBoxChecked = checkBox->getSubImage(9, 0, 9, 10); checkBoxDisabled = checkBox->getSubImage(18, 0, 9, 10); checkBoxDisabledChecked = checkBox->getSubImage(27, 0, 9, 10); + checkBoxNormal->setAlpha(mAlpha); + checkBoxChecked->setAlpha(mAlpha); + checkBoxDisabled->setAlpha(mAlpha); + checkBoxDisabledChecked->setAlpha(mAlpha); checkBox->decRef(); } @@ -66,16 +72,25 @@ void CheckBox::drawBox(gcn::Graphics* graphics) { Image *box; - if (isSelected()) { - if (isEnabled()) { + if (isSelected()) + { + if (isEnabled()) box = checkBoxChecked; - } else { + else box = checkBoxDisabledChecked; - } - } else if (isEnabled()) { + } + else if (isEnabled()) box = checkBoxNormal; - } else { + else box = checkBoxDisabled; + + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + checkBoxNormal->setAlpha(mAlpha); + checkBoxChecked->setAlpha(mAlpha); + checkBoxDisabled->setAlpha(mAlpha); + checkBoxDisabledChecked->setAlpha(mAlpha); } static_cast(graphics)->drawImage(box, 2, 2); diff --git a/src/gui/checkbox.h b/src/gui/checkbox.h index d92fc822..2e52fd0a 100644 --- a/src/gui/checkbox.h +++ b/src/gui/checkbox.h @@ -54,6 +54,7 @@ class CheckBox : public gcn::CheckBox { private: static int instances; + static float mAlpha; static Image *checkBoxNormal; static Image *checkBoxChecked; static Image *checkBoxDisabled; diff --git a/src/gui/emoteshortcutcontainer.cpp b/src/gui/emoteshortcutcontainer.cpp index f5ee9843..e35d037f 100644 --- a/src/gui/emoteshortcutcontainer.cpp +++ b/src/gui/emoteshortcutcontainer.cpp @@ -22,6 +22,7 @@ #include "emoteshortcutcontainer.h" #include "../animatedsprite.h" +#include "../configuration.h" #include "../emoteshortcut.h" #include "../graphics.h" #include "../inventory.h" @@ -42,11 +43,10 @@ static const int MAX_ITEMS = 12; EmoteShortcutContainer::EmoteShortcutContainer(): + ShortcutContainer(), mEmoteClicked(false), mEmoteMoved(0) { - mGridWidth = 1, - mGridHeight = 1, addMouseListener(this); addWidgetListener(this); @@ -54,6 +54,8 @@ EmoteShortcutContainer::EmoteShortcutContainer(): mBackgroundImg = resman->getImage("graphics/gui/item_shortcut_bgr.png"); + mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8)); + // Setup emote sprites for (int i = 0; i <= EmoteDB::getLast(); i++) { @@ -96,6 +98,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) } } + if (mEmoteMoved) { // Draw the emote image being dragged by the cursor. @@ -108,6 +111,12 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) sprite->draw(g, tPosX, tPosY); } } + + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + mBackgroundImg->setAlpha(mAlpha); + } } void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event) diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index 83d8c9fb..ecadd0e4 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -39,11 +39,10 @@ #include "../utils/tostring.h" ItemShortcutContainer::ItemShortcutContainer(): + ShortcutContainer(), mItemClicked(false), mItemMoved(NULL) { - mGridWidth=1; - mGridHeight=1; addMouseListener(this); addWidgetListener(this); @@ -136,6 +135,11 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) gcn::Graphics::CENTER); } } + + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8)); + } } void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event) diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 0b156fc4..37505305 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -79,8 +79,6 @@ void Minimap::setMapImage(Image *img) mMapImage->getWidth() + offsetX : titleWidth); setMaxHeight(mMapImage->getHeight() + offsetY); - mMapImage->setAlpha(config.getValue("guialpha", 0.8)); - // Make sure the window is within the minimum and maximum boundaries // TODO: Shouldn't this be happening automatically within the Window // class? diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index c22d407c..20ed17f8 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -34,6 +34,7 @@ #include "../utils/dtor.h" int PlayerBox::instances = 0; +float PlayerBox::mAlpha = config.getValue("guialpha", 0.8); ImageRect PlayerBox::background; PlayerBox::PlayerBox(const Player *player): @@ -94,6 +95,14 @@ void PlayerBox::draw(gcn::Graphics *graphics) } } } + + if (config.getValue("guialpha", 0.8) != mAlpha) + { + for (int a = 0; a < 9; a++) + { + background.grid[a]->setAlpha(config.getValue("guialpha", 0.8)); + } + } } void PlayerBox::drawFrame(gcn::Graphics *graphics) diff --git a/src/gui/playerbox.h b/src/gui/playerbox.h index 5aacd26f..70c41644 100644 --- a/src/gui/playerbox.h +++ b/src/gui/playerbox.h @@ -68,6 +68,7 @@ class PlayerBox : public gcn::ScrollArea private: const Player *mPlayer; /**< The character used for display */ + static float mAlpha; static int instances; static ImageRect background; }; diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index ecc0017d..d9db0c3c 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -22,6 +22,7 @@ #include "gui.h" #include "progressbar.h" +#include "../configuration.h" #include "../graphics.h" #include "../resources/image.h" @@ -31,6 +32,7 @@ ImageRect ProgressBar::mBorder; int ProgressBar::mInstances = 0; +float ProgressBar::mAlpha = config.getValue("guialpha", 0.8); ProgressBar::ProgressBar(float progress, unsigned int width, unsigned int height, @@ -56,6 +58,12 @@ ProgressBar::ProgressBar(float progress, mBorder.grid[6] = dBorders->getSubImage(0, 15, 4, 4); mBorder.grid[7] = dBorders->getSubImage(4, 15, 3, 4); mBorder.grid[8] = dBorders->getSubImage(7, 15, 4, 4); + + for (int i = 0; i < 9; i++) + { + mBorder.grid[i]->setAlpha(mAlpha); + } + dBorders->decRef(); } @@ -93,6 +101,15 @@ void ProgressBar::logic() void ProgressBar::draw(gcn::Graphics *graphics) { + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + for (int i = 0; i < 9; i++) + { + mBorder.grid[i]->setAlpha(mAlpha); + } + } + static_cast(graphics)-> drawImageRect(0, 0, getWidth(), getHeight(), mBorder); diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h index ee0a5f81..dd9cc896 100644 --- a/src/gui/progressbar.h +++ b/src/gui/progressbar.h @@ -111,6 +111,7 @@ class ProgressBar : public gcn::Widget static ImageRect mBorder; static int mInstances; + static float mAlpha; }; #endif diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index 1d7f8472..a892f2d0 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -32,6 +32,7 @@ #include "../utils/dtor.h" int ScrollArea::instances = 0; +float ScrollArea::mAlpha = config.getValue("guialpha", 0.8); ImageRect ScrollArea::background; ImageRect ScrollArea::vMarker; Image *ScrollArea::buttons[4][2]; @@ -193,6 +194,16 @@ void ScrollArea::draw(gcn::Graphics *graphics) mScrollbarWidth)); } + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + for (int a = 0; a < 9; a++) + { + background.grid[a]->setAlpha(mAlpha); + vMarker.grid[a]->setAlpha(mAlpha); + } + } + drawChildren(graphics); } diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h index 4fababfa..4324deff 100644 --- a/src/gui/scrollarea.h +++ b/src/gui/scrollarea.h @@ -102,6 +102,7 @@ class ScrollArea : public gcn::ScrollArea void drawHMarker(gcn::Graphics *graphics); static int instances; + static float mAlpha; static ImageRect background; static ImageRect vMarker; static Image *buttons[4][2]; diff --git a/src/gui/shortcutcontainer.cpp b/src/gui/shortcutcontainer.cpp index d03bc809..62b2d382 100644 --- a/src/gui/shortcutcontainer.cpp +++ b/src/gui/shortcutcontainer.cpp @@ -21,6 +21,7 @@ #include "shortcutcontainer.h" +#include "../configuration.h" #include "../graphics.h" #include "../inventory.h" #include "../item.h" @@ -33,13 +34,14 @@ #include "../utils/tostring.h" +float ShortcutContainer::mAlpha = config.getValue("guialpha", 0.8); + ShortcutContainer::ShortcutContainer(): mGridWidth(1), mGridHeight(1) { } - void ShortcutContainer::widgetResized(const gcn::Event &event) { mGridWidth = getWidth() / mBoxWidth; diff --git a/src/gui/shortcutcontainer.h b/src/gui/shortcutcontainer.h index 66aca6c3..b2d0cc78 100644 --- a/src/gui/shortcutcontainer.h +++ b/src/gui/shortcutcontainer.h @@ -97,6 +97,8 @@ class ShortcutContainer : public gcn::Widget, Image *mBackgroundImg; + static float mAlpha; + int mMaxItems; int mBoxWidth; int mBoxHeight; diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp index 37136012..9bfa840f 100644 --- a/src/gui/slider.cpp +++ b/src/gui/slider.cpp @@ -21,6 +21,7 @@ #include "slider.h" +#include "../configuration.h" #include "../graphics.h" #include "../resources/image.h" @@ -28,6 +29,7 @@ Image *Slider::hStart, *Slider::hMid, *Slider::hEnd, *Slider::hGrip; Image *Slider::vStart, *Slider::vMid, *Slider::vEnd, *Slider::vGrip; +float Slider::mAlpha = config.getValue("guialpha", 0.8); int Slider::mInstances = 0; Slider::Slider(double scaleEnd): @@ -107,6 +109,20 @@ void Slider::draw(gcn::Graphics *graphics) int x = 0; int y = (h - hStart->getHeight()) / 2; + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + hStart->setAlpha(mAlpha); + hMid->setAlpha(mAlpha); + hEnd->setAlpha(mAlpha); + hGrip->setAlpha(mAlpha); + + vStart->setAlpha(mAlpha); + vMid->setAlpha(mAlpha); + vEnd->setAlpha(mAlpha); + vGrip->setAlpha(mAlpha); + } + static_cast(graphics)->drawImage(hStart, x, y); w -= hStart->getWidth() + hEnd->getWidth(); diff --git a/src/gui/slider.h b/src/gui/slider.h index c14c5be9..12004f55 100644 --- a/src/gui/slider.h +++ b/src/gui/slider.h @@ -68,6 +68,7 @@ class Slider : public gcn::Slider { static Image *hStart, *hMid, *hEnd, *hGrip; static Image *vStart, *vMid, *vEnd, *vGrip; + static float mAlpha; static int mInstances; }; diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp index 3ecf5c82..7e5004cc 100644 --- a/src/gui/textfield.cpp +++ b/src/gui/textfield.cpp @@ -39,6 +39,7 @@ #undef DELETE //Win32 compatibility hack int TextField::instances = 0; +float TextField::mAlpha = config.getValue("guialpha", 0.8); ImageRect TextField::skin; TextField::TextField(const std::string& text): @@ -55,9 +56,6 @@ TextField::TextField(const std::string& text): Image *textbox = resman->getImage("graphics/gui/deepbox.png"); int gridx[4] = {0, 3, 28, 31}; int gridy[4] = {0, 3, 28, 31}; - //Image *textbox = resman->getImage("graphics/gui/textbox.png"); - //int gridx[4] = {0, 5, 26, 31}; - //int gridy[4] = {0, 5, 26, 31}; int a = 0, x, y; for (y = 0; y < 3; y++) { @@ -98,6 +96,15 @@ void TextField::draw(gcn::Graphics *graphics) graphics->setColor(getForegroundColor()); graphics->setFont(getFont()); graphics->drawText(mText, 1 - mXScroll, 1); + + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + for (int a = 0; a < 9; a++) + { + skin.grid[a]->setAlpha(mAlpha); + } + } } void TextField::drawFrame(gcn::Graphics *graphics) diff --git a/src/gui/textfield.h b/src/gui/textfield.h index a2432175..11a58824 100644 --- a/src/gui/textfield.h +++ b/src/gui/textfield.h @@ -99,6 +99,7 @@ class TextField : public gcn::TextField { private: static int instances; + static float mAlpha; static ImageRect skin; bool mNumeric; int mMinimum; diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index 4b8bb4da..fa264e37 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -23,6 +23,7 @@ #include "resizegrip.h" +#include "../../configuration.h" #include "../../graphics.h" #include "../../resources/image.h" @@ -30,6 +31,7 @@ Image *ResizeGrip::gripImage = 0; int ResizeGrip::mInstances = 0; +float ResizeGrip::mAlpha = config.getValue("guialpha", 0.8); ResizeGrip::ResizeGrip(std::string image) { @@ -38,6 +40,7 @@ ResizeGrip::ResizeGrip(std::string image) // Load the grip image ResourceManager *resman = ResourceManager::getInstance(); gripImage = resman->getImage(image); + gripImage->setAlpha(mAlpha); } mInstances++; @@ -58,5 +61,11 @@ ResizeGrip::~ResizeGrip() void ResizeGrip::draw(gcn::Graphics *graphics) { + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + gripImage->setAlpha(mAlpha); + } + static_cast(graphics)->drawImage(gripImage, 0, 0); } diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h index 7f1329a2..198954f6 100644 --- a/src/gui/widgets/resizegrip.h +++ b/src/gui/widgets/resizegrip.h @@ -56,6 +56,7 @@ class ResizeGrip : public gcn::Widget private: static Image *gripImage; /**< Resize grip image */ static int mInstances; /**< Number of resize grip instances */ + static float mAlpha; }; #endif diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index c54b2390..6f7f497a 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -25,6 +25,7 @@ #include "tabbedarea.h" +#include "../../configuration.h" #include "../../graphics.h" #include "../../resources/image.h" @@ -33,6 +34,7 @@ #include "../../utils/dtor.h" int Tab::mInstances = 0; +float Tab::mAlpha = config.getValue("guialpha", 0.8); enum{ TAB_STANDARD, // 0 @@ -98,6 +100,7 @@ void Tab::init() data[x].gridX, data[y].gridY, data[x + 1].gridX - data[x].gridX + 1, data[y + 1].gridY - data[y].gridY + 1); + tabImg[mode].grid[a]->setAlpha(mAlpha); a++; } } @@ -121,6 +124,16 @@ void Tab::draw(gcn::Graphics *graphics) mode = TAB_STANDARD; } + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + for (int a = 0; a < 9; a++) + { + tabImg[TAB_SELECTED].grid[a]->setAlpha(mAlpha); + tabImg[TAB_STANDARD].grid[a]->setAlpha(mAlpha); + } + } + // draw tab static_cast(graphics)-> drawImageRect(0, 0, getWidth(), getHeight(), tabImg[mode]); diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 8382df83..23987cac 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -53,6 +53,7 @@ class Tab : public gcn::Tab static ImageRect tabImg[4]; /**< Tab state graphics */ static int mInstances; /**< Number of tab instances */ + static float mAlpha; }; #endif diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 66f38aa8..35d47082 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -199,6 +199,7 @@ void Window::draw(gcn::Graphics *graphics) for_each(border.grid, border.grid + 9, std::bind2nd(std::mem_fun(&Image::setAlpha), config.getValue("guialpha", 0.8))); + closeImage->setAlpha(config.getValue("guialpha", 0.8)); } drawChildren(graphics); } -- cgit v1.2.3-70-g09d2 From 3cd6930d1417ae9cf087de8d3a9f40f053e75bf0 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 11:25:46 -0700 Subject: Applied alphas to the progress bar fill and text overlays as well. Signed-off-by: Ira Rice --- src/gui/progressbar.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index d9db0c3c..5e8e6655 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -113,9 +113,12 @@ void ProgressBar::draw(gcn::Graphics *graphics) static_cast(graphics)-> drawImageRect(0, 0, getWidth(), getHeight(), mBorder); + const int alpha = mAlpha * 255; + // The bar if (mProgress > 0) { - graphics->setColor(gcn::Color(mRed, mGreen, mBlue, 200)); + + graphics->setColor(gcn::Color(mRed, mGreen, mBlue, alpha)); graphics->fillRectangle(gcn::Rectangle(4, 4, (int) (mProgress * (getWidth() - 8)), getHeight() - 8)); @@ -129,14 +132,16 @@ void ProgressBar::draw(gcn::Graphics *graphics) graphics->setFont(f); - graphics->setColor(gcn::Color(0, 0, 0)); + graphics->setColor(gcn::Color(0, 0, 0, alpha)); graphics->drawText(mText, textX + 1, textY, gcn::Graphics::CENTER); graphics->drawText(mText, textX, textY - 1, gcn::Graphics::CENTER); graphics->drawText(mText, textX, textY + 1, gcn::Graphics::CENTER); graphics->drawText(mText, textX - 1, textY, gcn::Graphics::CENTER); - graphics->setColor(gcn::Color(255, 255, 255)); + graphics->setColor(gcn::Color(255, 255, 255, alpha)); graphics->drawText(mText, textX, textY, gcn::Graphics::CENTER); + + graphics->setColor(gcn::Color(0, 0, 0)); } } -- cgit v1.2.3-70-g09d2 From e2e23a5889c6b4a9a94e27c04ad8e5f60c7137b9 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 12:32:48 -0700 Subject: Found a few more gui elements that didn't get exposed to transparency updating. Signed-off-by: Ira Rice --- src/gui/listbox.cpp | 18 +++++++++++++----- src/gui/listbox.h | 3 +++ src/gui/radiobutton.cpp | 39 +++++++++++++++++++++++++-------------- src/gui/radiobutton.h | 1 + 4 files changed, 42 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index 990a0ade..1de57593 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -26,6 +26,10 @@ #include "listbox.h" +#include "../configuration.h" + +float ListBox::mAlpha = config.getValue("guialpha", 0.8); + ListBox::ListBox(gcn::ListModel *listModel): gcn::ListBox(listModel) { @@ -36,19 +40,23 @@ void ListBox::draw(gcn::Graphics *graphics) if (!mListModel) return; - graphics->setColor(gcn::Color(235, 200, 115)); + if (config.getValue("guialpha", 0.8) != mAlpha) + mAlpha = config.getValue("guialpha", 0.8); + + const int alpha = mAlpha * 255; + + graphics->setColor(gcn::Color(235, 200, 115, alpha)); graphics->setFont(getFont()); - int fontHeight = getFont()->getHeight(); + const int fontHeight = getFont()->getHeight(); // Draw rectangle below the selected list element - if (mSelected >= 0) { + if (mSelected >= 0) graphics->fillRectangle(gcn::Rectangle(0, fontHeight * mSelected, getWidth(), fontHeight)); - } // Draw the list elements - graphics->setColor(gcn::Color(0, 0, 0)); + graphics->setColor(gcn::Color(0, 0, 0, 255)); for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); ++i, y += fontHeight) diff --git a/src/gui/listbox.h b/src/gui/listbox.h index 3d0062bc..15f7afb4 100644 --- a/src/gui/listbox.h +++ b/src/gui/listbox.h @@ -49,6 +49,9 @@ class ListBox : public gcn::ListBox void draw(gcn::Graphics *graphics); void mouseDragged(gcn::MouseEvent &event); + + private: + static float mAlpha; }; #endif diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp index 245112a7..de8d4d9d 100644 --- a/src/gui/radiobutton.cpp +++ b/src/gui/radiobutton.cpp @@ -21,12 +21,14 @@ #include "radiobutton.h" +#include "../configuration.h" #include "../graphics.h" #include "../resources/image.h" #include "../resources/resourcemanager.h" int RadioButton::instances = 0; +float RadioButton::mAlpha = config.getValue("guialpha", 0.8); Image *RadioButton::radioNormal; Image *RadioButton::radioChecked; Image *RadioButton::radioDisabled; @@ -43,6 +45,10 @@ RadioButton::RadioButton(const std::string& caption, const std::string& group, radioChecked = resman->getImage("graphics/gui/radioin.png"); radioDisabled = resman->getImage("graphics/gui/radioout.png"); radioDisabledChecked = resman->getImage("graphics/gui/radioin.png"); + radioNormal->setAlpha(mAlpha); + radioChecked->setAlpha(mAlpha); + radioDisabled->setAlpha(mAlpha); + radioDisabledChecked->setAlpha(mAlpha); } instances++; @@ -63,32 +69,37 @@ RadioButton::~RadioButton() void RadioButton::drawBox(gcn::Graphics* graphics) { + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + radioNormal->setAlpha(mAlpha); + radioChecked->setAlpha(mAlpha); + radioDisabled->setAlpha(mAlpha); + radioDisabledChecked->setAlpha(mAlpha); + } + Image *box = NULL; - if (isSelected()) { - if (isEnabled()) { + if (isSelected()) + { + if (isEnabled()) box = radioChecked; - } else { + else box = radioDisabledChecked; - } - } else if (isEnabled()) { + } + else if (isEnabled()) box = radioNormal; - } else { + else box = radioDisabled; - } - if (box != NULL) { + if (box != NULL) static_cast(graphics)->drawImage(box, 2, 2); - } } void RadioButton::draw(gcn::Graphics* graphics) { - - graphics->pushClipArea(gcn::Rectangle(1, - 1, - getWidth() - 1, - getHeight() - 1)); + graphics->pushClipArea(gcn::Rectangle(1, 1, getWidth() - 1, + getHeight() - 1)); drawBox(graphics); diff --git a/src/gui/radiobutton.h b/src/gui/radiobutton.h index dcd62802..6ead9da0 100644 --- a/src/gui/radiobutton.h +++ b/src/gui/radiobutton.h @@ -57,6 +57,7 @@ class RadioButton : public gcn::RadioButton { private: static int instances; + static float mAlpha; static Image *radioNormal; static Image *radioChecked; static Image *radioDisabled; -- cgit v1.2.3-70-g09d2 From 7859699944d51056966c2f2415d1ade230c375a9 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 12:54:38 -0700 Subject: Some style cleanups to the image class. TODO: Find a way to fix the subimage class so that when OpenGL isn't enabled, GUI opacities can still be applied. Signed-off-by: Ira Rice --- src/resources/image.cpp | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/resources/image.cpp b/src/resources/image.cpp index c3310849..7a7e6ac8 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -167,7 +167,8 @@ Image *Image::load(SDL_Surface *tmpImage) tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight, 32, rmask, gmask, bmask, amask); - if (!tmpImage) { + if (!tmpImage) + { logger->log("Error, image convert failed: out of memory"); return NULL; } @@ -178,9 +179,8 @@ Image *Image::load(SDL_Surface *tmpImage) glGenTextures(1, &texture); glBindTexture(mTextureType, texture); - if (SDL_MUSTLOCK(tmpImage)) { + if (SDL_MUSTLOCK(tmpImage)) SDL_LockSurface(tmpImage); - } glTexImage2D( mTextureType, 0, 4, @@ -255,14 +255,13 @@ Image *Image::load(SDL_Surface *tmpImage) SDL_Surface *image; // Convert the surface to the current display format - if (hasAlpha) { + if (hasAlpha) image = SDL_DisplayFormatAlpha(tmpImage); - } - else { + else image = SDL_DisplayFormat(tmpImage); - } - if (!image) { + if (!image) + { logger->log("Error: Image convert failed."); return NULL; } @@ -274,14 +273,16 @@ void Image::unload() { mLoaded = false; - if (mImage) { + if (mImage) + { // Free the image surface. SDL_FreeSurface(mImage); mImage = NULL; } #ifdef USE_OPENGL - if (mGLImage) { + if (mGLImage) + { glDeleteTextures(1, &mGLImage); mGLImage = 0; } @@ -292,10 +293,9 @@ Image *Image::getSubImage(int x, int y, int width, int height) { // Create a new clipped sub-image #ifdef USE_OPENGL - if (mUseOpenGL) { + if (mUseOpenGL) return new SubImage(this, mGLImage, x, y, width, height, mTexWidth, mTexHeight); - } #endif return new SubImage(this, mImage, x, y, width, height); @@ -303,13 +303,13 @@ Image *Image::getSubImage(int x, int y, int width, int height) void Image::setAlpha(float a) { - if (mAlpha == a) { + if (mAlpha == a) return; - } mAlpha = a; - if (mImage) { + if (mImage) + { // Set the alpha value this image is drawn at SDL_SetAlpha(mImage, SDL_SRCALPHA, (int) (255 * mAlpha)); } @@ -321,14 +321,12 @@ float Image::getAlpha() } #ifdef USE_OPENGL -void -Image::setLoadAsOpenGL(bool useOpenGL) +void Image::setLoadAsOpenGL(bool useOpenGL) { Image::mUseOpenGL = useOpenGL; } -int -Image::powerOfTwo(int input) +int Image::powerOfTwo(int input) { int value; if (mTextureType == GL_TEXTURE_2D) @@ -353,7 +351,8 @@ Image::powerOfTwo(int input) SubImage::SubImage(Image *parent, SDL_Surface *image, int x, int y, int width, int height): - Image(image), mParent(parent) + Image(image), + mParent(parent) { mParent->incRef(); @@ -368,7 +367,8 @@ SubImage::SubImage(Image *parent, SDL_Surface *image, SubImage::SubImage(Image *parent, GLuint image, int x, int y, int width, int height, int texWidth, int texHeight): - Image(image, width, height, texWidth, texHeight), mParent(parent) + Image(image, width, height, texWidth, texHeight), + mParent(parent) { mParent->incRef(); @@ -394,3 +394,4 @@ Image *SubImage::getSubImage(int x, int y, int w, int h) { return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h); } + -- cgit v1.2.3-70-g09d2 From 85a02d69af733b327e4f3bb8011472de95bbba07 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 13:23:25 -0700 Subject: Moved weight and slots back to the top of the inventory window. Signed-off-by: Ira Rice --- src/gui/inventorywindow.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 58c13910..d7cd7ccd 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -91,16 +91,16 @@ InventoryWindow::InventoryWindow(int invSize): setMinHeight(130); setMinWidth(mWeightLabel->getWidth() + mSlotsLabel->getWidth() + 310); - place(0, 0, mInvenScroll, 7, 4); - place(0, 4, mWeightLabel).setPadding(3); - place(1, 4, mWeightBar, 2); - place(3, 4, mSlotsLabel).setPadding(3); - place(4, 4, mSlotsBar, 2); + place(0, 0, mWeightLabel).setPadding(3); + place(1, 0, mWeightBar, 2); + place(3, 0, mSlotsLabel).setPadding(3); + place(4, 0, mSlotsBar, 2); + place(0, 1, mInvenScroll, 7, 4); place(5, 5, mDropButton); place(6, 5, mUseButton); Layout &layout = getLayout(); - layout.setRowHeight(0, Layout::AUTO_SET); + layout.setRowHeight(0, mDropButton->getHeight()); loadWindowState(); setLocationRelativeTo(getParent()); -- cgit v1.2.3-70-g09d2 From 296b5ce5cf2316dad9b3ebc3328ec1f3a1375a2e Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 13:27:21 -0700 Subject: Fixed the item container so that it displays all item captions with the default font. Signed-off-by: Ira Rice --- src/gui/itemcontainer.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index ab3da9f6..caae3dca 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -123,6 +123,7 @@ void ItemContainer::draw(gcn::Graphics *graphics) } // Draw item caption + graphics->setFont(getFont()); graphics->setColor(0x000000); graphics->drawText( (item->isEquipped() ? "Eq." : toString(item->getQuantity())), -- cgit v1.2.3-70-g09d2 From 678009add727cc34f9c157f2cf41c4c0ac8f7f30 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 14:58:27 -0700 Subject: Reflowed status window using the layout class. Signed-off-by: Ira Rice --- src/gui/status.cpp | 216 +++++++++++++++-------------------------------------- src/gui/status.h | 6 +- 2 files changed, 62 insertions(+), 160 deletions(-) (limited to 'src') diff --git a/src/gui/status.cpp b/src/gui/status.cpp index bd6048f3..86d3f0d0 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -26,6 +26,8 @@ #include "status.h" #include "windowcontainer.h" +#include "widgets/layout.h" + #include "../localplayer.h" #include "../utils/gettext.h" @@ -39,8 +41,7 @@ StatusWindow::StatusWindow(LocalPlayer *player): setWindowName(_("Status")); setCloseButton(true); setDefaultSize((windowContainer->getWidth() - 365) / 2, - (windowContainer->getHeight() - 255) / 2, 400, 275); - loadWindowState(); + (windowContainer->getHeight() - 255) / 2, 400, 335); // ---------------------- // Status Part @@ -52,70 +53,15 @@ StatusWindow::StatusWindow(LocalPlayer *player): mHpLabel = new gcn::Label(_("HP:")); mHpBar = new ProgressBar(1.0f, 80, 15, 0, 171, 34); - mHpValueLabel = new gcn::Label; mXpLabel = new gcn::Label(_("Exp:")); mXpBar = new ProgressBar(1.0f, 80, 15, 143, 192, 211); - mXpValueLabel = new gcn::Label; mMpLabel = new gcn::Label(_("MP:")); mMpBar = new ProgressBar(1.0f, 80, 15, 26, 102, 230); - mMpValueLabel = new gcn::Label; - - mJobXpLabel = new gcn::Label(_("Job:")); - mJobXpBar = new ProgressBar(1.0f, 80, 15, 220, 135, 203); - mJobValueLabel = new gcn::Label; - - int y = 3; - int x = 5; - - mLvlLabel->setPosition(x, y); - x += mLvlLabel->getWidth() + 40; - mJobLvlLabel->setPosition(x, y); - x += mJobLvlLabel->getWidth() + 40; - mGpLabel->setPosition(x, y); - - y += mLvlLabel->getHeight() + 5; // Next Row - x = 5; - - mHpLabel->setPosition(x, y); - x += mHpLabel->getWidth() + 5; - mHpBar->setPosition(x, y); - x += mHpBar->getWidth() + 5; - mHpValueLabel->setPosition(x, y); - - mXpLabel->setPosition(175, y); - mXpBar->setPosition(205, y); - mXpValueLabel->setPosition(290, y); - - y += mHpLabel->getHeight() + 5; // Next Row - x = 5; - - mMpLabel->setPosition(x, y); - x += mMpLabel->getWidth() + 5; - mMpBar->setPosition(x, y); - x += mMpBar->getWidth() + 5; - mMpValueLabel->setPosition(x, y); - - mJobXpLabel->setPosition(175, y); - mJobXpBar->setPosition(205, y); - mJobValueLabel->setPosition(290, y); - - add(mLvlLabel); - add(mJobLvlLabel); - add(mGpLabel); - add(mHpLabel); - add(mHpValueLabel); - add(mMpLabel); - add(mMpValueLabel); - add(mXpLabel); - add(mXpValueLabel); - add(mJobXpLabel); - add(mJobValueLabel); - add(mHpBar); - add(mMpBar); - add(mXpBar); - add(mJobXpBar); + + mJobLabel = new gcn::Label(_("Job:")); + mJobBar = new ProgressBar(1.0f, 80, 15, 220, 135, 203); // ---------------------- // Stats Part @@ -144,7 +90,8 @@ StatusWindow::StatusWindow(LocalPlayer *player): mStatsReflexPoints = new gcn::Label; // New labels - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) + { mStatsLabel[i] = new gcn::Label; mStatsDisplayLabel[i] = new gcn::Label; mPointsLabel[i] = new gcn::Label("0"); @@ -159,68 +106,53 @@ StatusWindow::StatusWindow(LocalPlayer *player): mStatsButton[4] = new Button("+", "DEX", this); mStatsButton[5] = new Button("+", "LUK", this); - - // Set position - mStatsTitleLabel->setPosition(mMpLabel->getX(), mMpLabel->getY() + 23 ); - mStatsTotalLabel->setPosition(110, mStatsTitleLabel->getY() + 15); - int totalLabelY = mStatsTotalLabel->getY(); - mStatsCostLabel->setPosition(170, totalLabelY); - - for (int i = 0; i < 6; i++) - { - mStatsLabel[i]->setPosition(5, mStatsTotalLabel->getY() + (i * 23) + 15); - mStatsDisplayLabel[i]->setPosition(115, - totalLabelY + (i * 23) + 15); - mStatsButton[i]->setPosition(145, totalLabelY + (i * 23) + 10); - mPointsLabel[i]->setPosition(175, totalLabelY + (i * 23) + 15); - } - - mRemainingStatsPointsLabel->setPosition(5, mPointsLabel[5]->getY() + 25); - - mStatsAttackLabel->setPosition(220, mStatsLabel[0]->getY()); - mStatsDefenseLabel->setPosition(220, mStatsLabel[1]->getY()); - mStatsMagicAttackLabel->setPosition(220, mStatsLabel[2]->getY()); - mStatsMagicDefenseLabel->setPosition(220, mStatsLabel[3]->getY()); - mStatsAccuracyLabel->setPosition(220, mStatsLabel[4]->getY()); - mStatsEvadeLabel->setPosition(220, mStatsLabel[5]->getY()); - mStatsReflexLabel->setPosition(220, mRemainingStatsPointsLabel->getY()); - - mStatsAttackPoints->setPosition(310, mStatsLabel[0]->getY()); - mStatsDefensePoints->setPosition(310, mStatsLabel[1]->getY()); - mStatsMagicAttackPoints->setPosition(310, mStatsLabel[2]->getY()); - mStatsMagicDefensePoints->setPosition(310, mStatsLabel[3]->getY()); - mStatsAccuracyPoints->setPosition(310, mStatsLabel[4]->getY()); - mStatsEvadePoints->setPosition(310, mStatsLabel[5]->getY()); - mStatsReflexPoints->setPosition(310, mRemainingStatsPointsLabel->getY()); - // Assemble - add(mStatsTitleLabel); - add(mStatsTotalLabel); - add(mStatsCostLabel); + ContainerPlacer place; + place = getPlacer(0, 0); + + place(0, 0, mLvlLabel, 3); + place(5, 0, mJobLvlLabel, 3); + place(8, 0, mGpLabel, 3); + place(1, 1, mHpLabel); + place(2, 1, mHpBar, 3); + place(6, 1, mXpLabel); + place(7, 1, mXpBar, 3); + place(1, 2, mMpLabel); + place(2, 2, mMpBar, 3); + place(6, 2, mJobLabel); + place(7, 2, mJobBar, 3); + place.getCell().matchColWidth(0, 1); + place = getPlacer(0, 3); + place(0, 0, mStatsTitleLabel, 3); + place(4, 1, mStatsTotalLabel, 2); + place(7, 1, mStatsCostLabel, 2); for(int i = 0; i < 6; i++) { - add(mStatsLabel[i]); - add(mStatsDisplayLabel[i]); - add(mStatsButton[i]); - add(mPointsLabel[i]); + place(0, 2 + i, mStatsLabel[i], 3).setPadding(5); + place(4, 2 + i, mStatsDisplayLabel[i]).setPadding(5); + place(6, 2 + i, mStatsButton[i]); + place(7, 2 + i, mPointsLabel[i]).setPadding(5); } - add(mStatsAttackLabel); - add(mStatsDefenseLabel); - add(mStatsMagicAttackLabel); - add(mStatsMagicDefenseLabel); - add(mStatsAccuracyLabel); - add(mStatsEvadeLabel); - add(mStatsReflexLabel); - - add(mStatsAttackPoints); - add(mStatsDefensePoints); - add(mStatsMagicAttackPoints); - add(mStatsMagicDefensePoints); - add(mStatsAccuracyPoints); - add(mStatsEvadePoints); - add(mStatsReflexPoints); - - add(mRemainingStatsPointsLabel); + place(10, 2, mStatsAttackLabel, 3).setPadding(5); + place(10, 3, mStatsDefenseLabel, 3).setPadding(5); + place(10, 4, mStatsMagicAttackLabel, 3).setPadding(5); + place(10, 5, mStatsMagicDefenseLabel, 3).setPadding(5); + place(10, 6, mStatsAccuracyLabel, 3).setPadding(5); + place(10, 7, mStatsEvadeLabel, 3).setPadding(5); + place(10, 8, mStatsReflexLabel, 3).setPadding(5); + place(13, 2, mStatsAttackPoints, 3).setPadding(5); + place(13, 3, mStatsDefensePoints, 3).setPadding(5); + place(13, 4, mStatsMagicAttackPoints, 3).setPadding(5); + place(13, 5, mStatsMagicDefensePoints, 3).setPadding(5); + place(13, 6, mStatsAccuracyPoints, 3).setPadding(5); + place(13, 7, mStatsEvadePoints, 3).setPadding(5); + place(13, 8, mStatsReflexPoints, 3).setPadding(5); + place(0, 8, mRemainingStatsPointsLabel, 3).setPadding(5); + + Layout &layout = getLayout(); + layout.setRowHeight(0, Layout::AUTO_SET); + + loadWindowState(); } void StatusWindow::update() @@ -236,21 +168,17 @@ void StatusWindow::update() mGpLabel->setCaption(strprintf(_("Money: %d GP"), mPlayer->mGp)); mGpLabel->adjustSize(); - mHpValueLabel->setCaption(toString(mPlayer->mHp) + - "/" + toString(mPlayer->mMaxHp)); - mHpValueLabel->adjustSize(); + mHpBar->setText(toString(mPlayer->mHp) + + "/" + toString(mPlayer->mMaxHp)); - mMpValueLabel->setCaption(toString(mPlayer->mMp) + - "/" + toString(mPlayer->mMaxMp)); - mMpValueLabel->adjustSize(); + mMpBar->setText(toString(mPlayer->mMp) + + "/" + toString(mPlayer->mMaxMp)); - mXpValueLabel->setCaption(toString(mPlayer->getXp()) + - "/" + toString(mPlayer->mXpForNextLevel)); - mXpValueLabel->adjustSize(); + mXpBar->setText(toString(mPlayer->getXp()) + + "/" + toString(mPlayer->mXpForNextLevel)); - mJobValueLabel->setCaption(toString(mPlayer->mJobXp) + - "/" + toString(mPlayer->mJobXpForNextLevel)); - mJobValueLabel->adjustSize(); + mJobBar->setText(toString(mPlayer->mJobXp) + + "/" + toString(mPlayer->mJobXpForNextLevel)); // HP Bar coloration if (mPlayer->mHp < int(mPlayer->mMaxHp / 3)) @@ -271,7 +199,7 @@ void StatusWindow::update() mXpBar->setProgress( (float) mPlayer->getXp() / (float) mPlayer->mXpForNextLevel); - mJobXpBar->setProgress( + mJobBar->setProgress( (float) mPlayer->mJobXp / (float) mPlayer->mJobXpForNextLevel); // Stats Part @@ -336,30 +264,6 @@ void StatusWindow::update() // Reflex % mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter mStatsReflexPoints->adjustSize(); - - // Update Second column widgets position - mJobLvlLabel->setPosition(mLvlLabel->getX() + mLvlLabel->getWidth() + 20, - mLvlLabel->getY()); - mGpLabel->setPosition(mJobLvlLabel->getX() + mJobLvlLabel->getWidth() + 20, - mJobLvlLabel->getY()); - - mXpLabel->setPosition( - mHpValueLabel->getX() + mHpValueLabel->getWidth() + 10, - mHpLabel->getY()); - mXpBar->setPosition( - mXpLabel->getX() + mXpLabel->getWidth() + 5, - mXpLabel->getY()); - mXpValueLabel->setPosition( - mXpBar->getX() + mXpBar->getWidth() + 5, - mXpLabel->getY()); - - mJobXpLabel->setPosition(mXpBar->getX() - mJobXpLabel->getWidth() - 5, - mMpLabel->getY()); - mJobXpBar->setPosition( - mJobXpLabel->getX() + mJobXpLabel->getWidth() + 5, - mJobXpLabel->getY()); - mJobValueLabel->setPosition(mJobXpBar->getX() + mJobXpBar->getWidth() + 5, - mJobXpLabel->getY()); } void StatusWindow::draw(gcn::Graphics *g) diff --git a/src/gui/status.h b/src/gui/status.h index 14a7617e..1e1c4e98 100644 --- a/src/gui/status.h +++ b/src/gui/status.h @@ -69,11 +69,9 @@ class StatusWindow : public Window, public gcn::ActionListener */ gcn::Label *mLvlLabel, *mJobLvlLabel; gcn::Label *mGpLabel; - gcn::Label *mHpLabel, *mHpValueLabel; - gcn::Label *mMpLabel, *mMpValueLabel; - gcn::Label *mXpLabel, *mXpValueLabel, *mJobXpLabel, *mJobValueLabel; + gcn::Label *mHpLabel, *mMpLabel, *mXpLabel, *mJobLabel; ProgressBar *mHpBar, *mMpBar; - ProgressBar *mXpBar, *mJobXpBar; + ProgressBar *mXpBar, *mJobBar; /** * Derived Statistics captions -- cgit v1.2.3-70-g09d2 From ff6cd3ac0855cf516e364382153a77f61521ccdb Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 16:08:19 -0700 Subject: Swapped the default settings for two labels, which had been mixed up. Signed-off-by: Ira Rice --- src/gui/status.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 86d3f0d0..8b760427 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -48,8 +48,8 @@ StatusWindow::StatusWindow(LocalPlayer *player): // ---------------------- mLvlLabel = new gcn::Label(strprintf(_("Level: %d"), 0)); - mGpLabel = new gcn::Label(strprintf(_("Job: %d"), 0)); - mJobLvlLabel = new gcn::Label(strprintf(_("Money: %d GP"), 0)); + mJobLvlLabel = new gcn::Label(strprintf(_("Job: %d"), 0)); + mGpLabel = new gcn::Label(strprintf(_("Money: %d GP"), 0)); mHpLabel = new gcn::Label(_("HP:")); mHpBar = new ProgressBar(1.0f, 80, 15, 0, 171, 34); -- cgit v1.2.3-70-g09d2 From 202280724138614924e473a693dc974929ef5836 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 17:49:31 -0700 Subject: Made the recorder class messages translatable, as well as moved the recorder over to the layout code (not that it helps much at the moment). Signed-off-by: Ira Rice --- po/POTFILES.in | 1 + src/gui/recorder.cpp | 31 +++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/po/POTFILES.in b/po/POTFILES.in index 051ffeaa..fa3b2f9f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -25,6 +25,7 @@ src/gui/npcstringdialog.cpp src/gui/npc_text.cpp src/gui/ok_dialog.cpp src/gui/popupmenu.cpp +src/gui/recorder.cpp src/gui/recorder.h src/gui/register.cpp src/gui/sell.cpp diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp index 02eddbe5..9db1df2a 100644 --- a/src/gui/recorder.cpp +++ b/src/gui/recorder.cpp @@ -24,18 +24,33 @@ #include "button.h" #include "chat.h" #include "recorder.h" +#include "windowcontainer.h" +#include "widgets/layout.h" + +#include "../utils/gettext.h" #include "../utils/trim.h" Recorder::Recorder(ChatWindow *chat, const std::string &title, const std::string &buttonTxt) : Window(title) { + setWindowName(_("Recorder")); + const int offsetX = 2 * getPadding() + 10; + const int offsetY = getTitleBarHeight() + getPadding() + 10; + mChat = chat; Button *button = new Button(buttonTxt, "activate", this); - setContentSize(button->getWidth() + 10, button->getHeight() + 10); - button->setPosition(5, 5); - add(button); + setDefaultSize(0, windowContainer->getHeight() - 123 - button->getHeight() - + offsetY, button->getWidth() + offsetX, button->getHeight() + + offsetY); + + place(0, 0, button); + + Layout &layout = getLayout(); + layout.setRowHeight(0, Layout::AUTO_SET); + + loadWindowState(); } void Recorder::record(const std::string &msg) @@ -62,16 +77,16 @@ void Recorder::changeRecordingStatus(const std::string &msg) * Message should go after mStream is closed so that it isn't * recorded. */ - mChat->chatLog("Finishing recording.", BY_SERVER); + mChat->chatLog(_("Finishing recording."), BY_SERVER); } else { - mChat->chatLog("Not currently recording.", BY_SERVER); + mChat->chatLog(_("Not currently recording."), BY_SERVER); } } else if (mStream.is_open()) { - mChat->chatLog("Already recording.", BY_SERVER); + mChat->chatLog(_("Already recording."), BY_SERVER); } else { @@ -79,7 +94,7 @@ void Recorder::changeRecordingStatus(const std::string &msg) * Message should go before mStream is opened so that it isn't * recorded. */ - mChat->chatLog("Starting to record...", BY_SERVER); + mChat->chatLog(_("Starting to record..."), BY_SERVER); std::string file = std::string(PHYSFS_getUserDir()) + "/.aethyra/" + msgCopy; mStream.open(file.c_str(), std::ios_base::trunc); @@ -87,7 +102,7 @@ void Recorder::changeRecordingStatus(const std::string &msg) if (mStream.is_open()) setVisible(true); else - mChat->chatLog("Failed to start recording.", BY_SERVER); + mChat->chatLog(_("Failed to start recording."), BY_SERVER); } } -- cgit v1.2.3-70-g09d2 From 5b47d0933dcfb6e898ccfa56efe53eb53b7d30cb Mon Sep 17 00:00:00 2001 From: David Athay Date: Wed, 28 Jan 2009 11:47:05 +0000 Subject: Added highlighting ability to tabs. --- src/gui/widgets/tab.cpp | 30 ++++++++++++++++++++++-------- src/gui/widgets/tab.h | 7 +++++++ 2 files changed, 29 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 6f7f497a..5465b431 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -21,8 +21,9 @@ #include -#include "tab.h" +#include +#include "tab.h" #include "tabbedarea.h" #include "../../configuration.h" @@ -81,6 +82,7 @@ Tab::~Tab() void Tab::init() { setFrameSize(0); + mHighlighted = false; if (mInstances == 0) { @@ -112,16 +114,23 @@ void Tab::init() void Tab::draw(gcn::Graphics *graphics) { - int mode; + int mode = TAB_STANDARD; // check which type of tab to draw - if (mTabbedArea && mTabbedArea->isTabSelected(this)) - { - mode = TAB_SELECTED; - } - else + if (mTabbedArea) { - mode = TAB_STANDARD; + if(mTabbedArea->isTabSelected(this)) + { + mode = TAB_SELECTED; + // if tab is selected, it doesnt need to highlight activity + mLabel->setForegroundColor(gcn::Color(0, 0, 0)); + mHighlighted = false; + } + else if (mHighlighted) + { + mode = TAB_HIGHLIGHTED; + mLabel->setForegroundColor(gcn::Color(255, 0, 0)); + } } if (config.getValue("guialpha", 0.8) != mAlpha) @@ -141,3 +150,8 @@ void Tab::draw(gcn::Graphics *graphics) // draw label drawChildren(graphics); } + +void Tab::setHighlighted(bool high) +{ + mHighlighted = high; +} diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 23987cac..3af4e2bf 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -47,6 +47,11 @@ class Tab : public gcn::Tab */ void draw(gcn::Graphics *graphics); + /** + * Set tab highlighted + */ + void setHighlighted(bool high); + private: /** Load images if no other instances exist yet */ void init(); @@ -54,6 +59,8 @@ class Tab : public gcn::Tab static ImageRect tabImg[4]; /**< Tab state graphics */ static int mInstances; /**< Number of tab instances */ static float mAlpha; + + bool mHighlighted; }; #endif -- cgit v1.2.3-70-g09d2 From 0cf29b14232b08c7db9259bce26e96b59dac750c Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 22:13:38 -0700 Subject: Made the shoplist box alpha blend. Signed-off-by: Ira Rice --- src/gui/shoplistbox.cpp | 14 +++++++++++--- src/gui/shoplistbox.h | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index 765b9f08..9db33ac6 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -28,10 +28,13 @@ #include "shoplistbox.h" +#include "../configuration.h" #include "../graphics.h" const int ITEM_ICON_SIZE = 32; +float ShopListBox::mAlpha = config.getValue("guialpha", 0.8); + ShopListBox::ShopListBox(gcn::ListModel *listModel): ListBox(listModel), mPlayerMoney(0) @@ -59,6 +62,11 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) if (!mListModel) return; + if (config.getValue("guialpha", 0.8) != mAlpha) + mAlpha = config.getValue("guialpha", 0.8); + + const int alpha = mAlpha * 255; + Graphics *graphics = static_cast(gcnGraphics); graphics->setFont(getFont()); @@ -68,16 +76,16 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) i < mListModel->getNumberOfElements(); ++i, y += mRowHeight) { - gcn::Color backgroundColor = gcn::Color(0xffffff); + gcn::Color backgroundColor = gcn::Color(255, 255, 255, alpha); if (i == mSelected) { - backgroundColor = gcn::Color(235, 200, 115); + backgroundColor = gcn::Color(235, 200, 115, alpha); } else if (mShopItems && mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck) { - backgroundColor = gcn::Color(0x919191); + backgroundColor = gcn::Color(145, 145, 145, alpha); } graphics->setColor(backgroundColor); diff --git a/src/gui/shoplistbox.h b/src/gui/shoplistbox.h index 733af4eb..12413585 100644 --- a/src/gui/shoplistbox.h +++ b/src/gui/shoplistbox.h @@ -86,6 +86,8 @@ class ShopListBox : public ListBox unsigned int mRowHeight; /**< Row Height */ + static float mAlpha; + bool mPriceCheck; }; -- cgit v1.2.3-70-g09d2 From 269e05e71f09cac3d181f2042cde01e5541658f3 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 3 Feb 2009 12:13:16 -0700 Subject: Made highlights configurable through the color dialog. Signed-off-by: Ira Rice --- src/gui/browserbox.cpp | 17 ++++++++++++++--- src/gui/colour.cpp | 1 + src/gui/listbox.cpp | 7 ++++++- src/gui/shoplistbox.cpp | 7 ++++++- 4 files changed, 27 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 6fd0482a..cd5479c8 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -122,7 +122,18 @@ void BrowserBox::addRow(const std::string &row) //discard older rows when a row limit has been set if (mMaxRows > 0) { - while (mTextRows.size() > mMaxRows) mTextRows.pop_front(); + while (mTextRows.size() > mMaxRows) + { + mTextRows.pop_front(); + for (unsigned int i = 0; i < mLinks.size(); i++) + { + mLinks[i].y1 -= font->getHeight(); + mLinks[i].y2 -= font->getHeight(); + + if (mLinks[i].y1 < 0) + mLinks.erase(mLinks.begin() + i); + } + } } // Auto size mode @@ -238,9 +249,10 @@ void BrowserBox::draw(gcn::Graphics *graphics) if (mSelectedLink >= 0) { + bool valid; if ((mHighMode & BACKGROUND)) { - graphics->setColor(gcn::Color(HIGHLIGHT)); + graphics->setColor(gcn::Color(textColour->getColour('H', valid))); graphics->fillRectangle(gcn::Rectangle( mLinks[mSelectedLink].x1, mLinks[mSelectedLink].y1, @@ -251,7 +263,6 @@ void BrowserBox::draw(gcn::Graphics *graphics) if ((mHighMode & UNDERLINE)) { - bool valid; graphics->setColor(gcn::Color(textColour->getColour('<', valid))); graphics->drawLine( mLinks[mSelectedLink].x1, diff --git a/src/gui/colour.cpp b/src/gui/colour.cpp index e6ceeaca..075e9861 100644 --- a/src/gui/colour.cpp +++ b/src/gui/colour.cpp @@ -32,6 +32,7 @@ Colour::Colour() { addColour('C', 0x000000, _("Chat")); addColour('G', 0xff0000, _("GM")); + addColour('H', 0xebc873, _("Highlight")); addColour('Y', 0x1fa052, _("Player")); addColour('W', 0x0000ff, _("Whisper")); addColour('I', 0xf1dc27, _("Is")); diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index 1de57593..643d234e 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -24,6 +24,7 @@ #include #include +#include "colour.h" #include "listbox.h" #include "../configuration.h" @@ -43,9 +44,13 @@ void ListBox::draw(gcn::Graphics *graphics) if (config.getValue("guialpha", 0.8) != mAlpha) mAlpha = config.getValue("guialpha", 0.8); + bool valid; + const int red = (textColour->getColour('H', valid) >> 16) & 0xFF; + const int green = (textColour->getColour('H', valid) >> 8) & 0xFF; + const int blue = textColour->getColour('H', valid) & 0xFF; const int alpha = mAlpha * 255; - graphics->setColor(gcn::Color(235, 200, 115, alpha)); + graphics->setColor(gcn::Color(red, green, blue, alpha)); graphics->setFont(getFont()); const int fontHeight = getFont()->getHeight(); diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index 9db33ac6..3d17fd55 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -26,6 +26,7 @@ #include #include +#include "colour.h" #include "shoplistbox.h" #include "../configuration.h" @@ -65,6 +66,10 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) if (config.getValue("guialpha", 0.8) != mAlpha) mAlpha = config.getValue("guialpha", 0.8); + bool valid; + const int red = (textColour->getColour('H', valid) >> 16) & 0xFF; + const int green = (textColour->getColour('H', valid) >> 8) & 0xFF; + const int blue = textColour->getColour('H', valid) & 0xFF; const int alpha = mAlpha * 255; Graphics *graphics = static_cast(gcnGraphics); @@ -80,7 +85,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) if (i == mSelected) { - backgroundColor = gcn::Color(235, 200, 115, alpha); + backgroundColor = gcn::Color(red, green, blue, alpha); } else if (mShopItems && mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck) -- cgit v1.2.3-70-g09d2 From 6c5d9cd16b750ae9404407171a5641b5e0ee78b5 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 3 Feb 2009 13:00:05 -0700 Subject: Changed the listbox in the color setup pane to use the customized listbox. Signed-off-by: Ira Rice --- src/gui/setup_colours.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/setup_colours.cpp b/src/gui/setup_colours.cpp index c08c94ef..95e6fff0 100644 --- a/src/gui/setup_colours.cpp +++ b/src/gui/setup_colours.cpp @@ -26,6 +26,7 @@ #include #include "colour.h" +#include "listbox.h" #include "scrollarea.h" #include "setup_colours.h" #include "slider.h" @@ -42,7 +43,7 @@ Setup_Colours::Setup_Colours() : { setOpaque(false); - mColourBox = new gcn::ListBox(textColour); + mColourBox = new ListBox(textColour); mColourBox->setActionEventId("colour_box"); mColourBox->addActionListener(this); -- cgit v1.2.3-70-g09d2 From 8857a59c3818c1ce6eeb6c054cb5543bfc35c087 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 3 Feb 2009 14:38:40 -0700 Subject: Fixed up table class to allow for different background colors, as well as defining whether the given table is opaque or not. Signed-off-by: Ira Rice --- src/gui/setup_players.cpp | 3 +- src/gui/skill.cpp | 11 ++-- src/gui/skill.h | 1 - src/gui/table.cpp | 139 +++++++++++++++++++++++++++++++--------------- src/gui/table.h | 28 +++++++++- src/gui/table_model.cpp | 28 +--------- src/gui/table_model.h | 33 +---------- 7 files changed, 128 insertions(+), 115 deletions(-) (limited to 'src') diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index a4582b48..c8546b4b 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -223,12 +223,13 @@ Setup_Players::Setup_Players(): mIgnoreActionChoicesBox(new gcn::DropDown(new IgnoreChoicesListModel())) { setOpaque(false); + mPlayerTable->setOpaque(false); int table_width = NAME_COLUMN_WIDTH + RELATION_CHOICE_COLUMN_WIDTH; mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH); mPlayerTableTitleModel->fixColumnWidth(RELATION_CHOICE_COLUMN, RELATION_CHOICE_COLUMN_WIDTH); - mPlayerTitleTable->setDimension(gcn::Rectangle(10, 10, table_width, 10)); + mPlayerTitleTable->setDimension(gcn::Rectangle(10, 10, table_width - 1, 10)); mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf)); for (int i = 0; i < COLUMNS_NR; i++) diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 9d23cc3c..60f8ee65 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -53,7 +53,7 @@ class SkillGuiTableModel : public StaticTableModel { public: SkillGuiTableModel(SkillDialog *dialog) : - StaticTableModel(0, 3, 0xbdb5aa) + StaticTableModel(0, 3) { mEntriesNr = 0; mDialog = dialog; @@ -125,6 +125,7 @@ SkillDialog::SkillDialog(): initSkillinfo(); mTableModel = new SkillGuiTableModel(this); mTable.setModel(mTableModel); + mTable.setOpaque(false); mTable.setLinewiseSelection(true); setWindowName(_("Skills")); @@ -134,14 +135,12 @@ SkillDialog::SkillDialog(): setMinHeight(50 + mTableModel->getHeight()); setMinWidth(200); -// mSkillListBox = new ListBox(this); ScrollArea *skillScrollArea = new ScrollArea(&mTable); mPointsLabel = new gcn::Label(strprintf(_("Skill points: %d"), 0)); mIncButton = new Button(_("Up"), _("inc"), this); mUseButton = new Button(_("Use"), _("use"), this); mUseButton->setEnabled(false); -// mSkillListBox->setActionEventId("skill"); mTable.setActionEventId("skill"); skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -155,7 +154,6 @@ SkillDialog::SkillDialog(): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); -// mSkillListBox->addActionListener(this); mTable.addActionListener(this); setLocationRelativeTo(getParent()); @@ -171,7 +169,7 @@ void SkillDialog::action(const gcn::ActionEvent &event) if (event.getId() == "inc") { // Increment skill - int selectedSkill = mTable.getSelectedRow();//mSkillListBox->getSelected(); + int selectedSkill = mTable.getSelectedRow(); if (selectedSkill >= 0) player_node->raiseSkill(mSkillList[selectedSkill]->id); } @@ -278,7 +276,8 @@ static void initSkillinfo(void) std::string name = XML::getProperty(node, "name", ""); bool modifiable = !atoi(XML::getProperty(node, "fixed", "0").c_str()); - if (index >= 0) { + if (index >= 0) + { skill_db.resize(index + 1, emptySkillInfo); skill_db[index].name = name; skill_db[index].modifiable = modifiable; diff --git a/src/gui/skill.h b/src/gui/skill.h index 955666d9..45cfd059 100644 --- a/src/gui/skill.h +++ b/src/gui/skill.h @@ -30,7 +30,6 @@ #include "scrollarea.h" #include "table.h" #include "window.h" -#include "table.h" #include "../guichanfwd.h" diff --git a/src/gui/table.cpp b/src/gui/table.cpp index c4265097..bccdc900 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -24,8 +24,13 @@ #include #include +#include "colour.h" #include "table.h" +#include "../configuration.h" + +float GuiTable::mAlpha = config.getValue("guialpha", 0.8); + class GuiTableActionListener : public gcn::ActionListener { public: @@ -49,7 +54,8 @@ GuiTableActionListener::GuiTableActionListener(GuiTable *table, gcn::Widget *wid mColumn(column), mWidget(widget) { - if (widget) { + if (widget) + { widget->addActionListener(this); widget->_setParent(table); } @@ -57,7 +63,8 @@ GuiTableActionListener::GuiTableActionListener(GuiTable *table, gcn::Widget *wid GuiTableActionListener::~GuiTableActionListener(void) { - if (mWidget) { + if (mWidget) + { mWidget->removeActionListener(this); mWidget->_setParent(NULL); } @@ -70,8 +77,11 @@ void GuiTableActionListener::action(const gcn::ActionEvent& actionEvent) } -GuiTable::GuiTable(TableModel *initial_model) : +GuiTable::GuiTable(TableModel *initial_model, gcn::Color background, + bool opacity) : mLinewiseMode(false), + mOpaque(opacity), + mBackgroundColor(background), mModel(NULL), mSelectedRow(0), mSelectedColumn(0), @@ -94,16 +104,17 @@ TableModel* GuiTable::getModel(void) const void GuiTable::setModel(TableModel *new_model) { - if (mModel) { + if (mModel) + { uninstallActionListeners(); mModel->removeListener(this); } - mModel = new_model; installActionListeners(); - if (new_model) { + if (new_model) + { new_model->installListener(this); recomputeDimensions(); } @@ -184,10 +195,11 @@ void GuiTable::installActionListeners(void) int columns = mModel->getColumns(); for (int row = 0; row < rows; ++row) - for (int column = 0; column < columns; ++column) { + for (int column = 0; column < columns; ++column) + { gcn::Widget *widget = mModel->getElementAt(row, column); action_listeners.push_back(new GuiTableActionListener(this, widget, - row, column)); + row, column)); } _setFocusHandler(_getFocusHandler()); // propagate focus handler to widgets @@ -196,12 +208,22 @@ void GuiTable::installActionListeners(void) // -- widget ops void GuiTable::draw(gcn::Graphics* graphics) { - graphics->setColor(getBackgroundColor()); - graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); - if (!mModel) return; + if (config.getValue("guialpha", 0.8) != mAlpha) + mAlpha = config.getValue("guialpha", 0.8); + + if (mOpaque) + { + const int red = getBackgroundColor().r; + const int green = getBackgroundColor().g; + const int blue = getBackgroundColor().b; + const int alpha = mAlpha * 255; + graphics->setColor(gcn::Color(red, green, blue, alpha)); + graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); + } + // First, determine how many rows we need to draw, and where we should start. int first_row = -(getY() / getRowHeight()); @@ -223,44 +245,68 @@ void GuiTable::draw(gcn::Graphics* graphics) int height = getRowHeight(); int y_offset = first_row * height; - for (int r = first_row; r < first_row + rows_nr; ++r) { + for (int r = first_row; r < first_row + rows_nr; ++r) + { int x_offset = 0; - for (int c = first_column; c <= last_column; ++c) { + for (int c = first_column; c <= last_column; ++c) + { gcn::Widget *widget = mModel->getElementAt(r, c); int width = getColumnWidth(c); - if (widget) { + if (widget) + { gcn::Rectangle bounds(x_offset, y_offset, width, height); - if (widget == mTopWidget) { + if (widget == mTopWidget) + { bounds.height = widget->getHeight(); bounds.width = widget->getWidth(); } widget->setDimension(bounds); + if (!mLinewiseMode && c == mSelectedColumn && r == mSelectedRow) + { + bool valid; + const int red = + (textColour->getColour('H', valid) >> 16) & 0xFF; + const int green = + (textColour->getColour('H', valid) >> 8) & 0xFF; + const int blue = textColour->getColour('H', valid) & 0xFF; + const int alpha = mAlpha * 127; + + graphics->setColor(gcn::Color(red, green, blue, alpha)); + graphics->fillRectangle(bounds); + } + graphics->pushClipArea(bounds); widget->draw(graphics); graphics->popClipArea(); - - if (!mLinewiseMode - && c == mSelectedColumn - && r == mSelectedRow) - graphics->drawRectangle(bounds); } x_offset += width; } - if (mLinewiseMode - && r == mSelectedRow) - graphics->drawRectangle(gcn::Rectangle(0, y_offset, + if (mLinewiseMode && r == mSelectedRow) + { + bool valid; + const int red = + (textColour->getColour('H', valid) >> 16) & 0xFF; + const int green = + (textColour->getColour('H', valid) >> 8) & 0xFF; + const int blue = textColour->getColour('H', valid) & 0xFF; + const int alpha = mAlpha * 127; + + graphics->setColor(gcn::Color(red, green, blue, alpha)); + graphics->fillRectangle(gcn::Rectangle(0, y_offset, x_offset, height)); + } y_offset += height; } - if (mTopWidget) { + if (mTopWidget) + { gcn::Rectangle bounds = mTopWidget->getDimension(); graphics->pushClipArea(bounds); mTopWidget->draw(graphics); @@ -268,21 +314,17 @@ void GuiTable::draw(gcn::Graphics* graphics) } } -void GuiTable::logic(void) -{ -} - void GuiTable::moveToTop(gcn::Widget *widget) { gcn::Widget::moveToTop(widget); - this->mTopWidget = widget; + mTopWidget = widget; } void GuiTable::moveToBottom(gcn::Widget *widget) { gcn::Widget::moveToBottom(widget); - if (widget == this->mTopWidget) - this->mTopWidget = NULL; + if (widget == mTopWidget) + mTopWidget = NULL; } gcn::Rectangle GuiTable::getChildrenArea(void) @@ -298,11 +340,13 @@ void GuiTable::keyPressed(gcn::KeyEvent& keyEvent) // -- MouseListener notifications void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent) { - if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { + if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) + { int row = getRowForY(mouseEvent.getY()); int column = getColumnForX(mouseEvent.getX()); - if (row > -1 && column > -1) { + if (row > -1 && column > -1) + { mSelectedColumn = column; mSelectedRow = row; } @@ -326,10 +370,13 @@ void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent) // -- TableModelListener notifications void GuiTable::modelUpdated(bool completed) { - if (completed) { + if (completed) + { recomputeDimensions(); installActionListeners(); - } else { // before the update? + } + else + { // before the update? mTopWidget = NULL; // No longer valid in general uninstallActionListeners(); } @@ -340,18 +387,18 @@ gcn::Widget* GuiTable::getWidgetAt(int x, int y) int row = getRowForY(y); int column = getColumnForX(x); - if (mTopWidget - && mTopWidget->getDimension().isPointInRect(x, y)) + if (mTopWidget && mTopWidget->getDimension().isPointInRect(x, y)) return mTopWidget; - if (row > -1 - && column > -1) { + if (row > -1 && column > -1) + { gcn::Widget *w = mModel->getElementAt(row, column); if (w && w->isFocusable()) return w; else return NULL; // Grab the event locally - } else + } + else return NULL; } @@ -359,8 +406,7 @@ int GuiTable::getRowForY(int y) { int row = y / getRowHeight(); - if (row < 0 - || row >= mModel->getRows()) + if (row < 0 || row >= mModel->getRows()) return -1; else return row; @@ -371,14 +417,14 @@ int GuiTable::getColumnForX(int x) int column; int delta = 0; - for (column = 0; column < mModel->getColumns(); column++) { + for (column = 0; column < mModel->getColumns(); column++) + { delta += getColumnWidth(column); if (x <= delta) break; } - if (column < 0 - || column >= mModel->getColumns()) + if (column < 0 || column >= mModel->getColumns()) return -1; else return column; @@ -390,7 +436,8 @@ void GuiTable::_setFocusHandler(gcn::FocusHandler* focusHandler) if (mModel) for (int r = 0; r < mModel->getRows(); ++r) - for (int c = 0; c < mModel->getColumns(); ++c) { + for (int c = 0; c < mModel->getColumns(); ++c) + { gcn::Widget *w = mModel->getElementAt(r, c); if (w) w->_setFocusHandler(focusHandler); diff --git a/src/gui/table.h b/src/gui/table.h index e3fd8cf6..bdb41e90 100644 --- a/src/gui/table.h +++ b/src/gui/table.h @@ -51,7 +51,8 @@ class GuiTable : public gcn::Widget, { friend class GuiTableActionListener; // so that the action listener can call distributeActionEvent public: - GuiTable(TableModel * initial_model = NULL); + GuiTable(TableModel * initial_model = NULL, gcn::Color background = 0xffffff, + bool opacity = true); virtual ~GuiTable(void); @@ -94,8 +95,6 @@ public: // Inherited from Widget virtual void draw(gcn::Graphics* graphics); - virtual void logic(void); - virtual gcn::Widget *getWidgetAt(int x, int y); virtual void moveToTop(gcn::Widget *child); @@ -107,6 +106,21 @@ public: // Inherited from KeyListener virtual void keyPressed(gcn::KeyEvent& keyEvent); + /** + * Sets the table to be opaque, that is sets the table + * to display its background. + * + * @param opaque True if the table should be opaque, false otherwise. + */ + virtual void setOpaque(bool opaque) {mOpaque = opaque;} + + /** + * Checks if the table is opaque, that is if the table area displays its + * background. + * + * @return True if the table is opaque, false otherwise. + */ + virtual bool isOpaque() const {return mOpaque;} // Inherited from MouseListener virtual void mousePressed(gcn::MouseEvent& mouseEvent); @@ -134,6 +148,14 @@ private: int getColumnForX(int x); // -1 on error void recomputeDimensions(void); bool mLinewiseMode; + bool mOpaque; + + static float mAlpha; + + /** + * Holds the background color of the table. + */ + gcn::Color mBackgroundColor; TableModel *mModel; diff --git a/src/gui/table_model.cpp b/src/gui/table_model.cpp index 0b31369f..5ee7e9ab 100644 --- a/src/gui/table_model.cpp +++ b/src/gui/table_model.cpp @@ -54,13 +54,10 @@ void TableModel::signalAfterUpdate(void) #define WIDGET_AT(row, column) (((row) * mColumns) + (column)) #define DYN_SIZE(h) ((h) >= 0) // determines whether this size is tagged for auto-detection -StaticTableModel::StaticTableModel(int row, int column, - gcn::Color backgroundColor, bool opacity) : +StaticTableModel::StaticTableModel(int row, int column) : mRows(row), mColumns(column), - mHeight(1), - mOpaque(opacity), - mBackgroundColor(backgroundColor) + mHeight(1) { mTableModel.resize(row * column, NULL); mWidths.resize(column, 1); @@ -165,24 +162,3 @@ int StaticTableModel::getHeight(void) return (mColumns * mHeight); } -void StaticTableModel::drawBackground(gcn::Graphics *graphics) -{ - if (isOpaque()) - { - for (unsigned int i = 0; i < mTableModel.size(); i++) - { - mTableModel[i]->setBackgroundColor(mBackgroundColor); - } - } -} - -void StaticTableModel::setOpaque(bool opaque) -{ - mOpaque = opaque; -} - -bool StaticTableModel::isOpaque() const -{ - return mOpaque; -} - diff --git a/src/gui/table_model.h b/src/gui/table_model.h index 1c36ca46..a2a93887 100644 --- a/src/gui/table_model.h +++ b/src/gui/table_model.h @@ -100,8 +100,7 @@ private: class StaticTableModel : public TableModel { public: - StaticTableModel(int width, int height, gcn::Color background = 0xffffff, - bool opacity = true); + StaticTableModel(int width, int height); virtual ~StaticTableModel(void); /** @@ -130,22 +129,6 @@ public: */ virtual void resize(void); - /** - * Sets the table to be opaque, that is sets the table - * to display its background. - * - * @param opaque True if the table should be opaque, false otherwise. - */ - virtual void setOpaque(bool opaque); - - /** - * Checks if the scroll area is opaque, that is if the scroll area - * displays its background. - * - * @return True if the scroll area is opaque, false otherwise. - */ - virtual bool isOpaque() const; - virtual int getRows(void); virtual int getColumns(void); virtual int getRowHeight(void); @@ -158,22 +141,8 @@ public: protected: int mRows, mColumns; int mHeight; - bool mOpaque; std::vector mTableModel; std::vector mWidths; - - /** - * Holds the background color of the table. - */ - gcn::Color mBackgroundColor; - - /** - * Draws the background of the table, that is - * the area behind the content. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawBackground(gcn::Graphics *graphics); }; #endif /* !defined(TABLE_MODEL_H) */ -- cgit v1.2.3-70-g09d2 From 7d45452187b1c2911b688bbed5fb8981a67b1934 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 3 Feb 2009 16:33:18 -0700 Subject: Modified the dropdown class to handle opacity. Signed-off-by: Ira Rice --- src/gui/login.cpp | 3 ++- src/gui/setup_players.cpp | 17 +++++++++---- src/gui/widgets/dropdown.cpp | 58 +++++++++++++++++++++++++++++++++++--------- src/gui/widgets/dropdown.h | 22 ++++++++++++++++- 4 files changed, 81 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 84e10e97..408456ef 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -63,7 +63,7 @@ LoginDialog::LoginDialog(LoginData *loginData): dfltPort.push_back("21001"); mServerList = new DropDownList("MostRecent00", dfltServer, dfltPort, MAX_SERVER_LIST_SIZE); - mServerListBox = new gcn::ListBox(mServerList); + mServerListBox = new ListBox(mServerList); mServerScrollArea = new ScrollArea(); mUserField = new TextField(mLoginData->username); @@ -73,6 +73,7 @@ LoginDialog::LoginDialog(LoginData *loginData): mServerDropDown = new DropDown(mServerList, mServerScrollArea, mServerListBox); + mServerDropDown->setOpaque(false); mKeepCheck = new CheckBox(_("Keep"), mLoginData->remember); mOkButton = new Button(_("OK"), "ok", this); diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index c8546b4b..932acee7 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -21,20 +21,20 @@ #include -#include #include #include "button.h" #include "checkbox.h" +#include "listbox.h" #include "ok_dialog.h" #include "setup_players.h" +#include "widgets/dropdown.h" #include "widgets/layouthelper.h" #include "../configuration.h" #include "../log.h" #include "../player_relations.h" -#include "../sound.h" #include "../utils/gettext.h" @@ -135,8 +135,12 @@ public: std::string name = (*player_names)[r]; gcn::Widget *widget = new gcn::Label(name); mWidgets.push_back(widget); + gcn::ListModel *playerRelation = new PlayerRelationListModel(); - gcn::DropDown *choicebox = new gcn::DropDown(new PlayerRelationListModel()); + gcn::DropDown *choicebox = new DropDown(playerRelation, + new ScrollArea(), + new ListBox(playerRelation), + false); choicebox->setSelected(player_relations.getRelation(name)); mWidgets.push_back(choicebox); } @@ -219,8 +223,7 @@ Setup_Players::Setup_Players(): player_relations.getDefault() & PlayerRelation::TRADE)), mDefaultWhisper(new CheckBox(_("Allow whispers"), player_relations.getDefault() & PlayerRelation::WHISPER)), - mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)), - mIgnoreActionChoicesBox(new gcn::DropDown(new IgnoreChoicesListModel())) + mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)) { setOpaque(false); mPlayerTable->setOpaque(false); @@ -232,6 +235,10 @@ Setup_Players::Setup_Players(): mPlayerTitleTable->setDimension(gcn::Rectangle(10, 10, table_width - 1, 10)); mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf)); + gcn::ListModel *ignoreChoices = new IgnoreChoicesListModel(); + mIgnoreActionChoicesBox = new DropDown(ignoreChoices, new ScrollArea(), + new ListBox(ignoreChoices), false); + for (int i = 0; i < COLUMNS_NR; i++) { mPlayerTableTitleModel->set(0, i, diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 88a12d68..ac5cbaa2 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -23,6 +23,9 @@ #include "dropdown.h" +#include "../colour.h" + +#include "../../configuration.h" #include "../../graphics.h" #include "../../resources/image.h" @@ -33,12 +36,12 @@ int DropDown::instances = 0; Image *DropDown::buttons[2][2]; ImageRect DropDown::skin; +float DropDown::mAlpha = config.getValue("guialpha", 0.8); -DropDown::DropDown(gcn::ListModel *listModel, - gcn::ScrollArea *scrollArea, - gcn::ListBox *listBox): - gcn::DropDown::DropDown(listModel, - scrollArea, listBox) +DropDown::DropDown(gcn::ListModel *listModel, gcn::ScrollArea *scrollArea, + gcn::ListBox *listBox, bool opacity): + gcn::DropDown::DropDown(listModel, scrollArea, listBox), + mOpaque(opacity) { setFrameSize(2); @@ -58,6 +61,11 @@ DropDown::DropDown(gcn::ListModel *listModel, buttons[0][1] = resman->getImage("graphics/gui/vscroll_down_pressed.png"); + buttons[0][0]->setAlpha(mAlpha); + buttons[0][1]->setAlpha(mAlpha); + buttons[1][0]->setAlpha(mAlpha); + buttons[1][1]->setAlpha(mAlpha); + // get the border skin Image *boxBorder = resman->getImage("graphics/gui/deepbox.png"); int gridx[4] = {0, 3, 28, 31}; @@ -70,6 +78,7 @@ DropDown::DropDown(gcn::ListModel *listModel, gridx[x], gridy[y], gridx[x + 1] - gridx[x] + 1, gridy[y + 1] - gridy[y] + 1); + skin.grid[a]->setAlpha(mAlpha); a++; } } @@ -108,19 +117,44 @@ void DropDown::draw(gcn::Graphics* graphics) h = getHeight(); } - int alpha = getBaseColor().a; + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + + buttons[0][0]->setAlpha(mAlpha); + buttons[0][1]->setAlpha(mAlpha); + buttons[1][0]->setAlpha(mAlpha); + buttons[1][1]->setAlpha(mAlpha); + + for (int a = 0; a < 9; a++) + { + skin.grid[a]->setAlpha(mAlpha); + } + } + + bool valid; + const int alpha = mAlpha * 255; gcn::Color faceColor = getBaseColor(); faceColor.a = alpha; - gcn::Color highlightColor = faceColor + 0x303030; + gcn::Color highlightColor = textColour->getColour('H', valid); highlightColor.a = alpha; gcn::Color shadowColor = faceColor - 0x303030; shadowColor.a = alpha; + if (mOpaque) + { + int red = getBackgroundColor().r; + int green = getBackgroundColor().g; + int blue = getBackgroundColor().b; + graphics->setColor(gcn::Color(red, green, blue, alpha)); + graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), h)); + + red = getForegroundColor().r; + green = getForegroundColor().g; + blue = getForegroundColor().b; + graphics->setColor(gcn::Color(red, green, blue, alpha)); + } - graphics->setColor(getBackgroundColor()); - graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), h)); - - graphics->setColor(getForegroundColor()); graphics->setFont(getFont()); if (mListBox->getListModel() && mListBox->getSelected() >= 0) @@ -140,7 +174,7 @@ void DropDown::draw(gcn::Graphics* graphics) { drawChildren(graphics); - // Draw two lines separating the ListBox with se selected + // Draw two lines separating the ListBox with selected // element view. graphics->setColor(highlightColor); graphics->drawLine(0, h, getWidth(), h); diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 25ae05f8..bff8bd1e 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -56,7 +56,8 @@ class DropDown : public gcn::DropDown */ DropDown(gcn::ListModel *listModel = NULL, gcn::ScrollArea *scrollArea = NULL, - gcn::ListBox *listBox = NULL); + gcn::ListBox *listBox = NULL, + bool opacity = true); /** * Destructor. @@ -67,6 +68,22 @@ class DropDown : public gcn::DropDown void drawFrame(gcn::Graphics* graphics); + /** + * Sets the widget to be opaque, that is sets the widget to display its + * background. + * + * @param opaque True if the widget should be opaque, false otherwise. + */ + void setOpaque(bool opaque) {mOpaque = opaque;} + + /** + * Checks if the widget is opaque, that is if the widget area displays + * its background. + * + * @return True if the widget is opaque, false otherwise. + */ + bool isOpaque() const {return mOpaque;} + protected: /** @@ -80,6 +97,9 @@ class DropDown : public gcn::DropDown static int instances; static Image *buttons[2][2]; static ImageRect skin; + static float mAlpha; + + bool mOpaque; }; #endif // end DROPDOWN_H -- cgit v1.2.3-70-g09d2 From c6cf9a6a9c03f17362171aeed1a22244d99b7530 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 3 Feb 2009 17:33:47 -0700 Subject: Disable alpha values affecting two widgets which would otherwise take alpha values under SDL. Signed-off-by: Ira Rice --- src/gui/checkbox.cpp | 14 +++++++++----- src/gui/progressbar.cpp | 5 ++++- src/resources/image.h | 14 +++++++++++++- 3 files changed, 26 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp index 7fa4fa81..511ed34c 100644 --- a/src/gui/checkbox.cpp +++ b/src/gui/checkbox.cpp @@ -45,10 +45,13 @@ CheckBox::CheckBox(const std::string& caption, bool selected): checkBoxChecked = checkBox->getSubImage(9, 0, 9, 10); checkBoxDisabled = checkBox->getSubImage(18, 0, 9, 10); checkBoxDisabledChecked = checkBox->getSubImage(27, 0, 9, 10); - checkBoxNormal->setAlpha(mAlpha); - checkBoxChecked->setAlpha(mAlpha); - checkBoxDisabled->setAlpha(mAlpha); - checkBoxDisabledChecked->setAlpha(mAlpha); + if (config.getValue("opengl", 0)) + { + checkBoxNormal->setAlpha(mAlpha); + checkBoxChecked->setAlpha(mAlpha); + checkBoxDisabled->setAlpha(mAlpha); + checkBoxDisabledChecked->setAlpha(mAlpha); + } checkBox->decRef(); } @@ -84,7 +87,8 @@ void CheckBox::drawBox(gcn::Graphics* graphics) else box = checkBoxDisabled; - if (config.getValue("guialpha", 0.8) != mAlpha) + if (config.getValue("guialpha", 0.8) != mAlpha && + config.getValue("opengl", 0)) { mAlpha = config.getValue("guialpha", 0.8); checkBoxNormal->setAlpha(mAlpha); diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index 5e8e6655..a1b847c8 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -103,7 +103,10 @@ void ProgressBar::draw(gcn::Graphics *graphics) { if (config.getValue("guialpha", 0.8) != mAlpha) { - mAlpha = config.getValue("guialpha", 0.8); + if (config.getValue("opengl", 0)) + mAlpha = config.getValue("guialpha", 0.8); + else + mAlpha = 1.0f; for (int i = 0; i < 9; i++) { mBorder.grid[i]->setAlpha(mAlpha); diff --git a/src/resources/image.h b/src/resources/image.h index a4048803..5b376053 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -91,6 +91,12 @@ class Image : public Resource */ virtual void unload(); + /** + * Returns the image. + */ + virtual const Image* getImage() const + { return this; } + /** * Returns the width of the image. */ @@ -114,7 +120,7 @@ class Image : public Resource /** * Sets the alpha value of this image. */ - void setAlpha(float alpha); + virtual void setAlpha(float alpha); /** * Returns the alpha value of this image. @@ -180,6 +186,12 @@ class SubImage : public Image */ ~SubImage(); + /** + * Returns the image. + */ + virtual const Image* getImage() const + { return mParent; } + /** * Creates a new image with the desired clipping rectangle. * -- cgit v1.2.3-70-g09d2 From 12cd527f8e554547a0e56d1240c912918db880cb Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 3 Feb 2009 17:37:25 -0700 Subject: Modified video mode selection to not test the resolution clicked on, and to trust that the resolutions presented are legal resolutions to try. This shouldn't be an issue, as the resolutions listed are pulled straight from SDL, and it avoids showing the user a visual artifact. Signed-off-by: Ira Rice --- src/gui/setup_video.cpp | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'src') diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 2ba8b6e8..faf72c68 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -393,23 +393,6 @@ void Setup_Video::action(const gcn::ActionEvent &event) const std::string mode = mModeListModel->getElementAt(mModeList->getSelected()); const int width = atoi(mode.substr(0, mode.find("x")).c_str()); const int height = atoi(mode.substr(mode.find("x") + 1).c_str()); - const int bpp = 0; - const bool fullscreen = ((int) config.getValue("screen", 0) == 1); - const bool hwaccel = ((int) config.getValue("hwaccel", 0) == 1); - - // Try to set the desired video mode - if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) - { - std::cerr << _("Couldn't set ") - << width << "x" << height << "x" << bpp << _(" video mode: ") - << SDL_GetError() << std::endl; - exit(1); - } - - // Initialize for drawing - graphics->_endDraw(); - graphics->_beginDraw(); - graphics->updateScreen(); // TODO: Find out why the drawing area doesn't resize without a restart. new OkDialog(_("Screen resolution changed"), -- cgit v1.2.3-70-g09d2 From 769a34317f100d2d62af57a61f1bb88d876c3c08 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 3 Feb 2009 17:54:01 -0700 Subject: Show the scroll area again for the skill dialog. While this commit isn't needed so much, I think that now that opacity actually works in tables now, it looks a bit bettwe with the scroll area visible. Signed-off-by: Ira Rice --- src/gui/skill.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 60f8ee65..732aaa12 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -144,7 +144,6 @@ SkillDialog::SkillDialog(): mTable.setActionEventId("skill"); skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - skillScrollArea->setOpaque(false); place(0, 0, skillScrollArea, 5).setPadding(3); place(0, 1, mPointsLabel, 2); -- cgit v1.2.3-70-g09d2 From 6110801764f588d0696e75645624be4869b99ee0 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 3 Feb 2009 20:41:02 -0700 Subject: Applied a minimum height and width to the help window. Signed-off-by: Ira Rice --- src/gui/help.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/help.cpp b/src/gui/help.cpp index 6b14f6d8..ece2dce4 100644 --- a/src/gui/help.cpp +++ b/src/gui/help.cpp @@ -33,6 +33,8 @@ HelpWindow::HelpWindow(): Window(_("Help")) { + setMinWidth(300); + setMinHeight(250); setContentSize(455, 350); setWindowName(_("Help")); setResizable(true); -- cgit v1.2.3-70-g09d2 From 555e68e24f2bb7d38f7ce52ce9a43198c0ccedec Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 11:46:03 -0700 Subject: Went through the gui folder and revised the include statements to not include anything not needed by that specific widget or window. This appears to have cleaned up system performance a bit on my current setup, where it went from idling on 45% in game with opengl down to 30% now. Also moved iptostring to the tostring header, as importing all of network.h is a little overkill to use that function, and it goes along with the basic functions that are in that header file anyways. TODO: find out a way to get rid of warnings when a class doesn't use this function. Signed-off-by: Ira Rice --- aethyra.cbp | 1 - src/CMakeLists.txt | 1 - src/Makefile.am | 1 - src/extensions.h | 34 ------------------------------- src/gui/browserbox.h | 5 +---- src/gui/button.cpp | 12 +++++------ src/gui/button.h | 4 ---- src/gui/buy.h | 6 +++--- src/gui/buysell.h | 2 -- src/gui/char_select.cpp | 1 + src/gui/char_select.h | 9 +++------ src/gui/char_server.cpp | 17 +++++++--------- src/gui/char_server.h | 2 -- src/gui/chat.cpp | 43 +++++++++++++++++----------------------- src/gui/chat.h | 3 --- src/gui/chatinput.h | 2 -- src/gui/checkbox.h | 7 ++----- src/gui/colour.cpp | 2 -- src/gui/colour.h | 3 --- src/gui/confirm_dialog.cpp | 3 +++ src/gui/confirm_dialog.h | 9 ++++----- src/gui/connection.cpp | 7 ++++--- src/gui/debugwindow.cpp | 1 - src/gui/debugwindow.h | 4 ---- src/gui/emotecontainer.h | 2 -- src/gui/emoteshortcutcontainer.h | 4 ---- src/gui/emotewindow.cpp | 5 ----- src/gui/emotewindow.h | 2 -- src/gui/focushandler.h | 2 -- src/gui/gccontainer.h | 2 -- src/gui/gui.cpp | 25 +++++++++++++---------- src/gui/help.h | 2 -- src/gui/inttextfield.h | 2 -- src/gui/inventorywindow.cpp | 1 - src/gui/inventorywindow.h | 1 - src/gui/item_amount.cpp | 3 ++- src/gui/item_amount.h | 4 ---- src/gui/itemcontainer.cpp | 1 - src/gui/itemcontainer.h | 2 -- src/gui/itemlinkhandler.cpp | 6 +++--- src/gui/itempopup.cpp | 8 ++------ src/gui/itempopup.h | 7 +++---- src/gui/itemshortcutcontainer.h | 2 -- src/gui/listbox.cpp | 3 +-- src/gui/listbox.h | 2 -- src/gui/login.cpp | 1 + src/gui/login.h | 1 - src/gui/menuwindow.h | 2 -- src/gui/minimap.h | 2 -- src/gui/ministatus.h | 4 ---- src/gui/npc_text.cpp | 4 +--- src/gui/npc_text.h | 3 +-- src/gui/npcintegerdialog.cpp | 11 +++------- src/gui/npcintegerdialog.h | 5 ----- src/gui/npclistdialog.cpp | 2 ++ src/gui/npclistdialog.h | 5 ----- src/gui/npcstringdialog.cpp | 7 +------ src/gui/npcstringdialog.h | 5 ----- src/gui/ok_dialog.cpp | 7 +++++-- src/gui/ok_dialog.h | 6 ++---- src/gui/passwordfield.cpp | 2 -- src/gui/passwordfield.h | 4 ++-- src/gui/playerbox.cpp | 2 -- src/gui/playerbox.h | 2 -- src/gui/popupmenu.cpp | 4 ---- src/gui/progressbar.cpp | 4 ++-- src/gui/progressbar.h | 5 ++--- src/gui/radiobutton.h | 5 ++--- src/gui/recorder.cpp | 1 - src/gui/recorder.h | 2 -- src/gui/register.cpp | 8 ++------ src/gui/register.h | 4 +--- src/gui/scrollarea.cpp | 2 -- src/gui/scrollarea.h | 2 -- src/gui/sell.cpp | 8 +------- src/gui/sell.h | 4 ++-- src/gui/setup.cpp | 3 --- src/gui/setup_audio.h | 2 -- src/gui/setup_colours.cpp | 2 -- src/gui/setup_colours.h | 2 +- src/gui/setup_joystick.h | 2 -- src/gui/setup_keyboard.h | 1 - src/gui/setup_players.cpp | 4 +++- src/gui/setup_players.h | 11 +++++----- src/gui/setup_video.h | 2 -- src/gui/shop.h | 3 +-- src/gui/shoplistbox.cpp | 4 +--- src/gui/shoplistbox.h | 3 +-- src/gui/shortcutcontainer.cpp | 7 ------- src/gui/shortcutcontainer.h | 8 +++----- src/gui/shortcutwindow.cpp | 2 +- src/gui/shortcutwindow.h | 4 +--- src/gui/skill.cpp | 28 ++++++++++++-------------- src/gui/skill.h | 8 ++------ src/gui/slider.h | 2 -- src/gui/speechbubble.cpp | 13 ++---------- src/gui/speechbubble.h | 9 +++++---- src/gui/status.h | 4 ---- src/gui/table.cpp | 2 -- src/gui/table.h | 4 ---- src/gui/table_model.cpp | 3 --- src/gui/table_model.h | 5 ----- src/gui/textbox.cpp | 1 - src/gui/textbox.h | 5 ++--- src/gui/textfield.cpp | 4 ---- src/gui/textfield.h | 2 -- src/gui/trade.cpp | 2 -- src/gui/updatewindow.cpp | 6 +++--- src/gui/updatewindow.h | 2 -- src/gui/viewport.cpp | 5 ----- src/gui/viewport.h | 2 -- src/gui/widgets/dropdown.cpp | 2 ++ src/gui/widgets/dropdown.h | 7 ------- src/gui/widgets/resizegrip.h | 2 -- src/gui/widgets/tab.cpp | 2 -- src/gui/window.cpp | 2 -- src/gui/windowcontainer.h | 5 ++--- src/main.cpp | 1 + src/net/charserverhandler.cpp | 3 ++- src/net/loginhandler.cpp | 3 ++- src/net/network.cpp | 14 +------------ src/net/network.h | 3 --- src/utils/tostring.h | 15 ++++++++++++++ 123 files changed, 177 insertions(+), 438 deletions(-) delete mode 100644 src/extensions.h (limited to 'src') diff --git a/aethyra.cbp b/aethyra.cbp index 2ee2501b..c383dff3 100644 --- a/aethyra.cbp +++ b/aethyra.cbp @@ -106,7 +106,6 @@ - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8cd062c9..86deec0c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -323,7 +323,6 @@ SET(SRCS engine.h equipment.cpp equipment.h - extensions.h floor_item.cpp floor_item.h flooritemmanager.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 3aeecc02..c6a9a9c4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -272,7 +272,6 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ engine.h \ equipment.cpp \ equipment.h \ - extensions.h \ floor_item.cpp \ floor_item.h \ flooritemmanager.cpp \ diff --git a/src/extensions.h b/src/extensions.h deleted file mode 100644 index 5b95afc8..00000000 --- a/src/extensions.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Aethyra - * Copyright 2008 Lloyd Bryant - * - * This file is part of the Aethyra project. - * - * Aethyra is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * Aethyra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with The Mana World; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef _EXTENSIONS_ -#define _EXTENSIONS_ - -struct EXTENSIONS -{ - bool aethyra_inventory; - bool aethyra_spells; - bool aethyra_misc; -}; - -extern struct EXTENSIONS extensions; -#endif diff --git a/src/gui/browserbox.h b/src/gui/browserbox.h index 4bdf224b..15c2ab89 100644 --- a/src/gui/browserbox.h +++ b/src/gui/browserbox.h @@ -22,15 +22,12 @@ #ifndef BROWSERBOX_H #define BROWSERBOX_H -#include +#include #include #include #include -#include "../guichanfwd.h" -#include "../main.h" - class LinkHandler; struct BROWSER_LINK { diff --git a/src/gui/button.cpp b/src/gui/button.cpp index d578202e..2e6bed0a 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -19,6 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + +#include +#include +#include + #include "button.h" #include "../configuration.h" @@ -29,12 +35,6 @@ #include "../utils/dtor.h" -#include -#include -#include - -#include - int Button::mInstances = 0; float Button::mAlpha = config.getValue("guialpha", 0.8); diff --git a/src/gui/button.h b/src/gui/button.h index 1faf2455..abaf5c43 100644 --- a/src/gui/button.h +++ b/src/gui/button.h @@ -22,12 +22,8 @@ #ifndef BUTTON_H #define BUTTON_H -#include - #include -#include "../guichanfwd.h" - class ImageRect; /** diff --git a/src/gui/buy.h b/src/gui/buy.h index 423918ce..0f1cfede 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -25,9 +25,9 @@ #include #include -#include "window.h" +#include -#include "../guichanfwd.h" +#include "window.h" class Network; class ShopItems; @@ -40,7 +40,7 @@ class ListBox; * \ingroup Interface */ class BuyDialog : public Window, public gcn::ActionListener, - gcn::SelectionListener + public gcn::SelectionListener { public: /** diff --git a/src/gui/buysell.h b/src/gui/buysell.h index 60a6398d..e3cdc52a 100644 --- a/src/gui/buysell.h +++ b/src/gui/buysell.h @@ -26,8 +26,6 @@ #include "window.h" -#include "../guichanfwd.h" - /** * A dialog to choose between buying or selling at a shop. * diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index e556dfa0..4433b646 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -22,6 +22,7 @@ #include #include + #include #include "button.h" diff --git a/src/gui/char_select.h b/src/gui/char_select.h index 5d4ecfa8..23de061d 100644 --- a/src/gui/char_select.h +++ b/src/gui/char_select.h @@ -26,9 +26,8 @@ #include "window.h" -#include "../guichanfwd.h" -#include "../lockedarray.h" #include "../being.h" +#include "../lockedarray.h" class LocalPlayer; class Network; @@ -109,14 +108,12 @@ class CharCreateDialog : public Window, public gcn::ActionListener */ ~CharCreateDialog(); - void - action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event); /** * Unlocks the dialog, enabling the create character button again. */ - void - unlock(); + void unlock(); private: /** diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index 2e823b60..bc096379 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -28,10 +28,7 @@ #include "../main.h" #include "../serverinfo.h" -#include "../net/network.h" // TODO this is just for iptostring, move that? - #include "../utils/gettext.h" -#include "../utils/strprintf.h" #include "../utils/tostring.h" extern SERVER_INFO **server_info; @@ -39,7 +36,8 @@ extern SERVER_INFO **server_info; /** * The list model for the server list. */ -class ServerListModel : public gcn::ListModel { +class ServerListModel : public gcn::ListModel +{ public: virtual ~ServerListModel() {}; @@ -80,13 +78,12 @@ ServerSelectDialog::ServerSelectDialog(LoginData *loginData, int nextState): add(mOkButton); add(mCancelButton); - if (n_server == 0) { + if (n_server == 0) // Disable Ok button mOkButton->setEnabled(false); - } else { + else // Select first server mServerList->setSelected(1); - } setLocationRelativeTo(getParent()); setVisible(true); @@ -100,7 +97,8 @@ ServerSelectDialog::~ServerSelectDialog() void ServerSelectDialog::action(const gcn::ActionEvent &event) { - if (event.getId() == "ok") { + if (event.getId() == "ok") + { mOkButton->setEnabled(false); const SERVER_INFO *si = server_info[mServerList->getSelected()]; mLoginData->hostname = iptostring(si->address); @@ -108,9 +106,8 @@ void ServerSelectDialog::action(const gcn::ActionEvent &event) mLoginData->updateHost = si->updateHost; state = mNextState; } - else if (event.getId() == "cancel") { + else if (event.getId() == "cancel") state = LOGIN_STATE; - } } int ServerListModel::getNumberOfElements() diff --git a/src/gui/char_server.h b/src/gui/char_server.h index 9419c92d..49a5b47b 100644 --- a/src/gui/char_server.h +++ b/src/gui/char_server.h @@ -27,8 +27,6 @@ #include "window.h" -#include "../guichanfwd.h" - class LoginData; class ServerListModel; diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 36e33160..a58600a8 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -20,7 +20,6 @@ */ #include -#include #include @@ -37,7 +36,6 @@ #include "../beingmanager.h" #include "../configuration.h" -#include "../extensions.h" #include "../game.h" #include "../localplayer.h" #include "../party.h" @@ -538,32 +536,27 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) * This will eventually be replaced by a GUI, so * we don't need to get too sophisticated */ - if (extensions.aethyra_spells) + MessageOut outMsg(mNetwork); + if (msg == "heal") { - MessageOut outMsg(mNetwork); - if (msg == "heal") - { - outMsg.writeInt16(0x03f3); - outMsg.writeInt16(0x01); - outMsg.writeInt32(0); - outMsg.writeInt8(0); - outMsg.writeInt8(0); - outMsg.writeString("", 24); - } - else if (msg == "gather") - { - outMsg.writeInt16(0x03f3); - outMsg.writeInt16(0x02); - outMsg.writeInt32(0); - outMsg.writeInt8(0); - outMsg.writeInt8(0); - outMsg.writeString("", 24); - } - else - chatLog(_("No such spell!"), BY_SERVER); + outMsg.writeInt16(0x03f3); + outMsg.writeInt16(0x01); + outMsg.writeInt32(0); + outMsg.writeInt8(0); + outMsg.writeInt8(0); + outMsg.writeString("", 24); + } + else if (msg == "gather") + { + outMsg.writeInt16(0x03f3); + outMsg.writeInt16(0x02); + outMsg.writeInt32(0); + outMsg.writeInt8(0); + outMsg.writeInt8(0); + outMsg.writeString("", 24); } else - chatLog(_("The current server doesn't support spells"), BY_SERVER); + chatLog(_("No such spell!"), BY_SERVER); } else if (command == "present") { diff --git a/src/gui/chat.h b/src/gui/chat.h index 176fccb7..872c0041 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -22,7 +22,6 @@ #ifndef CHAT_H #define CHAT_H -#include #include #include @@ -31,8 +30,6 @@ #include "window.h" -#include "../guichanfwd.h" - class BrowserBox; class Network; class Recorder; diff --git a/src/gui/chatinput.h b/src/gui/chatinput.h index d98e120b..a4a50502 100644 --- a/src/gui/chatinput.h +++ b/src/gui/chatinput.h @@ -26,8 +26,6 @@ #include "textfield.h" -#include "../guichanfwd.h" - /** * The chat input hides when it loses focus. It is also invisible by default. */ diff --git a/src/gui/checkbox.h b/src/gui/checkbox.h index 2e52fd0a..20adb43c 100644 --- a/src/gui/checkbox.h +++ b/src/gui/checkbox.h @@ -22,12 +22,8 @@ #ifndef CHECKBOX_H #define CHECKBOX_H -#include - #include -#include "../guichanfwd.h" - class Image; /** @@ -35,7 +31,8 @@ class Image; * * \ingroup GUI */ -class CheckBox : public gcn::CheckBox { +class CheckBox : public gcn::CheckBox +{ public: /** * Constructor. diff --git a/src/gui/colour.cpp b/src/gui/colour.cpp index 075e9861..58d9d1c6 100644 --- a/src/gui/colour.cpp +++ b/src/gui/colour.cpp @@ -19,8 +19,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include - #include "colour.h" #include "../configuration.h" diff --git a/src/gui/colour.h b/src/gui/colour.h index 1e8ba3db..1648e1e8 100644 --- a/src/gui/colour.h +++ b/src/gui/colour.h @@ -22,14 +22,11 @@ #ifndef _COLOUR_H #define _COLOUR_H -#include #include #include #include -#include "../guichanfwd.h" - class Colour : public gcn::ListModel { public: diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp index 643d5d7a..8bb9c578 100644 --- a/src/gui/confirm_dialog.cpp +++ b/src/gui/confirm_dialog.cpp @@ -21,7 +21,10 @@ #include +#include "button.h" #include "confirm_dialog.h" +#include "scrollarea.h" +#include "textbox.h" #include "../utils/gettext.h" diff --git a/src/gui/confirm_dialog.h b/src/gui/confirm_dialog.h index fb8290c8..3fa2b90d 100644 --- a/src/gui/confirm_dialog.h +++ b/src/gui/confirm_dialog.h @@ -24,19 +24,18 @@ #include -#include "button.h" -#include "scrollarea.h" -#include "textbox.h" #include "window.h" -#include "../guichanfwd.h" +class ScrollArea; +class TextBox; /** * An option dialog. * * \ingroup GUI */ -class ConfirmDialog : public Window, public gcn::ActionListener { +class ConfirmDialog : public Window, public gcn::ActionListener +{ public: /** * Constructor. diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp index 15d85bbc..a69698e9 100644 --- a/src/gui/connection.cpp +++ b/src/gui/connection.cpp @@ -31,7 +31,8 @@ #include "../utils/gettext.h" -namespace { +namespace +{ struct ConnectionActionListener : public gcn::ActionListener { void action(const gcn::ActionEvent &event) { state = EXIT_STATE; } @@ -62,10 +63,10 @@ ConnectionDialog::ConnectionDialog(): void ConnectionDialog::logic() { mProgress += 0.005f; + if (mProgress > 1.0f) - { mProgress = 0.0f; - } + mProgressBar->setProgress(mProgress); Window::logic(); } diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 223b7fbd..055d9963 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -23,7 +23,6 @@ #include -#include "button.h" #include "debugwindow.h" #include "gui.h" #include "viewport.h" diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h index 00119d15..e089de27 100644 --- a/src/gui/debugwindow.h +++ b/src/gui/debugwindow.h @@ -22,14 +22,10 @@ #ifndef DEBUGWINDOW_H #define DEBUGWINDOW_H -#include - #include #include "window.h" -#include "../guichanfwd.h" - /** * The debug window. * diff --git a/src/gui/emotecontainer.h b/src/gui/emotecontainer.h index 8e52a206..5a2b8c2e 100644 --- a/src/gui/emotecontainer.h +++ b/src/gui/emotecontainer.h @@ -29,8 +29,6 @@ #include #include -#include "../guichanfwd.h" - class AnimatedSprite; class Image; diff --git a/src/gui/emoteshortcutcontainer.h b/src/gui/emoteshortcutcontainer.h index cffaee6f..e8d87b60 100644 --- a/src/gui/emoteshortcutcontainer.h +++ b/src/gui/emoteshortcutcontainer.h @@ -24,12 +24,8 @@ #include -#include - #include "shortcutcontainer.h" -#include "../guichanfwd.h" - class AnimatedSprite; class Image; diff --git a/src/gui/emotewindow.cpp b/src/gui/emotewindow.cpp index b4e9c735..3fa96a6d 100644 --- a/src/gui/emotewindow.cpp +++ b/src/gui/emotewindow.cpp @@ -19,16 +19,11 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - -#include - #include "button.h" #include "gui.h" #include "emotewindow.h" #include "emotecontainer.h" #include "scrollarea.h" -#include "textbox.h" #include "widgets/layout.h" diff --git a/src/gui/emotewindow.h b/src/gui/emotewindow.h index 8e36e5ce..c642ff6f 100644 --- a/src/gui/emotewindow.h +++ b/src/gui/emotewindow.h @@ -27,8 +27,6 @@ #include "window.h" -#include "../guichanfwd.h" - class EmoteContainer; class TextBox; diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index 124b5472..b0639bd8 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -26,8 +26,6 @@ #include -#include "../guichanfwd.h" - /** * The focus handler. This focus handler does exactly the same as the Guichan * focus handler, but keeps a stack of modal widgets to be able to handle diff --git a/src/gui/gccontainer.h b/src/gui/gccontainer.h index 0a573645..da584a42 100644 --- a/src/gui/gccontainer.h +++ b/src/gui/gccontainer.h @@ -26,8 +26,6 @@ #include -#include "../guichanfwd.h" - /** * A garbage collecting container. Childs added to this container are * automatically deleted when the container is deleted. diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 642e916b..7779a503 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -63,7 +63,8 @@ class GuiConfigListener : public ConfigListener void optionChanged(const std::string &name) { - if (name == "customcursor") { + if (name == "customcursor") + { bool bCustomCursor = config.getValue("customcursor", 1) == 1; mGui->setUseCustomCursor(bCustomCursor); } @@ -107,7 +108,8 @@ Gui::Gui(Graphics *graphics): // Set global font std::string path = resman->getPath("fonts/dejavusans.ttf"); - try { + try + { const int fontSize = config.getValue("fontSize", 11); mGuiFont = new TrueTypeFont(path, fontSize); } @@ -119,7 +121,8 @@ Gui::Gui(Graphics *graphics): // Set bold font path = resman->getPath("fonts/dejavusans-bold.ttf"); - try { + try + { const int fontSize = config.getValue("fontSize", 11); boldFont = new TrueTypeFont(path, fontSize); } @@ -132,7 +135,8 @@ Gui::Gui(Graphics *graphics): gcn::Widget::setGlobalFont(mGuiFont); // Load hits' colourful fonts - try { + try + { hitRedFont = new gcn::ImageFont("graphics/gui/hits_red.png", "0123456789crit! "); hitBlueFont = new gcn::ImageFont("graphics/gui/hits_blue.png", @@ -182,12 +186,13 @@ Gui::~Gui() void Gui::logic() { // Fade out mouse cursor after extended inactivity - if (mMouseInactivityTimer < 100 * 15) { + if (mMouseInactivityTimer < 100 * 15) + { ++mMouseInactivityTimer; mMouseCursorAlpha = std::min(1.0f, mMouseCursorAlpha + 0.05f); - } else { - mMouseCursorAlpha = std::max(0.0f, mMouseCursorAlpha - 0.005f); } + else + mMouseCursorAlpha = std::max(0.0f, mMouseCursorAlpha - 0.005f); gcn::Gui::logic(); } @@ -232,9 +237,8 @@ void Gui::setUseCustomCursor(bool customCursor) mMouseCursors = resman->getImageSet("graphics/gui/mouse.png", 40, 40); - if (!mMouseCursors) { + if (!mMouseCursors) logger->error("Unable to load mouse cursors."); - } } else { @@ -242,7 +246,8 @@ void Gui::setUseCustomCursor(bool customCursor) SDL_ShowCursor(SDL_ENABLE); // Unload the mouse cursor - if (mMouseCursors) { + if (mMouseCursors) + { mMouseCursors->decRef(); mMouseCursors = NULL; } diff --git a/src/gui/help.h b/src/gui/help.h index 2ba74c0a..98e3aa67 100644 --- a/src/gui/help.h +++ b/src/gui/help.h @@ -27,8 +27,6 @@ #include "linkhandler.h" #include "window.h" -#include "../guichanfwd.h" - class BrowserBox; /** diff --git a/src/gui/inttextfield.h b/src/gui/inttextfield.h index 2a913ef6..add78084 100644 --- a/src/gui/inttextfield.h +++ b/src/gui/inttextfield.h @@ -24,8 +24,6 @@ #include "textfield.h" -#include "../guichanfwd.h" - /** * TextBox which only accepts numbers as input. */ diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index d7cd7ccd..246219f4 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -33,7 +33,6 @@ #include "itemcontainer.h" #include "progressbar.h" #include "scrollarea.h" -#include "textbox.h" #include "viewport.h" #include "widgets/layout.h" diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 2c19ce26..2694e90b 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -27,7 +27,6 @@ #include "window.h" -#include "../guichanfwd.h" #include "../localplayer.h" class Item; diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp index d8682c95..92be3d6e 100644 --- a/src/gui/item_amount.cpp +++ b/src/gui/item_amount.cpp @@ -70,7 +70,8 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): resetAmount(); - switch (usage) { + switch (usage) + { case AMOUNT_TRADE_ADD: setCaption(_("Select amount of items to trade.")); okButton->setActionEventId("AddTrade"); diff --git a/src/gui/item_amount.h b/src/gui/item_amount.h index d8eedadb..618d7d51 100644 --- a/src/gui/item_amount.h +++ b/src/gui/item_amount.h @@ -22,14 +22,10 @@ #ifndef ITEM_AMOUNT_WINDOW_H #define ITEM_AMOUNT_WINDOW_H -#include - #include #include "window.h" -#include "../guichanfwd.h" - class IntTextField; class Item; diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index caae3dca..e655d3fc 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -35,7 +35,6 @@ #include "../log.h" #include "../resources/image.h" -#include "../resources/iteminfo.h" #include "../resources/resourcemanager.h" #include "../utils/tostring.h" diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index 5513faa7..f027de19 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -28,8 +28,6 @@ #include #include -#include "../guichanfwd.h" - class Image; class Inventory; class Item; diff --git a/src/gui/itemlinkhandler.cpp b/src/gui/itemlinkhandler.cpp index 34c12a0c..97c0b94f 100644 --- a/src/gui/itemlinkhandler.cpp +++ b/src/gui/itemlinkhandler.cpp @@ -19,6 +19,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include + #include #include "itemlinkhandler.h" @@ -27,9 +30,6 @@ #include "../resources/iteminfo.h" #include "../resources/itemdb.h" -#include -#include - ItemLinkHandler::ItemLinkHandler() { mItemPopup = new ItemPopup; diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 80edd354..39a5ecf1 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -26,16 +26,15 @@ #include "gui.h" #include "itempopup.h" +#include "scrollarea.h" +#include "textbox.h" #include "windowcontainer.h" #include "widgets/layout.h" -#include "../resources/image.h" #include "../resources/iteminfo.h" -#include "../resources/resourcemanager.h" #include "../utils/gettext.h" -#include "../utils/strprintf.h" #include "../utils/tostring.h" ItemPopup::ItemPopup(): @@ -89,9 +88,6 @@ ItemPopup::ItemPopup(): add(mItemWeightScroll); setLocationRelativeTo(getParent()); - - // LEEOR / TODO: This causes an exception error. - //moveToBottom(getParent()); } void ItemPopup::setItem(const ItemInfo &item) diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index 3c8f575d..d9d37264 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -23,12 +23,11 @@ #ifndef ITEMPOPUP_H__ #define ITEMPOPUP_H__ -#include "scrollarea.h" -#include "textbox.h" #include "window.h" -#include "../guichanfwd.h" -#include "../item.h" +class ItemInfo; +class ScrollArea; +class TextBox; class ItemPopup : public Window { diff --git a/src/gui/itemshortcutcontainer.h b/src/gui/itemshortcutcontainer.h index d6a04d7b..22d94ec2 100644 --- a/src/gui/itemshortcutcontainer.h +++ b/src/gui/itemshortcutcontainer.h @@ -26,8 +26,6 @@ #include "shortcutcontainer.h" -#include "../guichanfwd.h" - class Image; class Item; class ItemPopup; diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index 643d234e..e56ddeeb 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -62,8 +62,7 @@ void ListBox::draw(gcn::Graphics *graphics) // Draw the list elements graphics->setColor(gcn::Color(0, 0, 0, 255)); - for (int i = 0, y = 0; - i < mListModel->getNumberOfElements(); + for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); ++i, y += fontHeight) { graphics->drawText(mListModel->getElementAt(i), 1, y); diff --git a/src/gui/listbox.h b/src/gui/listbox.h index 15f7afb4..12fcb955 100644 --- a/src/gui/listbox.h +++ b/src/gui/listbox.h @@ -24,8 +24,6 @@ #include -#include "../guichanfwd.h" - class SelectionListener; /** diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 408456ef..2e9ca57e 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -26,6 +26,7 @@ #include "button.h" #include "checkbox.h" +#include "listbox.h" #include "login.h" #include "ok_dialog.h" #include "passwordfield.h" diff --git a/src/gui/login.h b/src/gui/login.h index b85e5ae1..70f30d5c 100644 --- a/src/gui/login.h +++ b/src/gui/login.h @@ -22,7 +22,6 @@ #ifndef LOGIN_H #define LOGIN_H -#include #include #include diff --git a/src/gui/menuwindow.h b/src/gui/menuwindow.h index 9b784c35..9bb54e29 100644 --- a/src/gui/menuwindow.h +++ b/src/gui/menuwindow.h @@ -24,8 +24,6 @@ #include "window.h" -#include "../guichanfwd.h" - /** * The Button Menu. * diff --git a/src/gui/minimap.h b/src/gui/minimap.h index b4574ad5..3ce0aacd 100644 --- a/src/gui/minimap.h +++ b/src/gui/minimap.h @@ -24,8 +24,6 @@ #include "window.h" -#include "../guichanfwd.h" - class Image; /** diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h index d2bcef1c..832475f1 100644 --- a/src/gui/ministatus.h +++ b/src/gui/ministatus.h @@ -22,12 +22,8 @@ #ifndef MINISTATUS_H #define MINISTATUS_H -#include - #include "window.h" -#include "../guichanfwd.h" - class ProgressBar; /** diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 1e29b793..b4313b70 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -19,10 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - -#include "npc_text.h" #include "button.h" +#include "npc_text.h" #include "scrollarea.h" #include "textbox.h" diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 4e0d33aa..a07aa04f 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -22,11 +22,10 @@ #ifndef NPC_TEXT_H #define NPC_TEXT_H -#include +#include #include -#include "scrollarea.h" #include "window.h" class TextBox; diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp index 65a1a7f1..4444e04b 100644 --- a/src/gui/npcintegerdialog.cpp +++ b/src/gui/npcintegerdialog.cpp @@ -19,20 +19,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "npcintegerdialog.h" - -#include -#include - #include "button.h" #include "inttextfield.h" +#include "npcintegerdialog.h" + +#include "widgets/layout.h" #include "../npc.h" #include "../utils/gettext.h" -#include "../utils/tostring.h" - -#include "widgets/layout.h" NpcIntegerDialog::NpcIntegerDialog(): Window(_("NPC Number Request")) diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h index 983c46fe..b9ce70be 100644 --- a/src/gui/npcintegerdialog.h +++ b/src/gui/npcintegerdialog.h @@ -22,16 +22,11 @@ #ifndef GUI_NPCINTEGERDIALOG_H #define GUI_NPCINTEGERDIALOG_H -#include -#include - #include #include #include "window.h" -#include "../guichanfwd.h" - class IntTextField; /** diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index bb815680..e6406422 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -21,8 +21,10 @@ #include +#include "button.h" #include "listbox.h" #include "npclistdialog.h" +#include "scrollarea.h" #include "widgets/layout.h" diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index ffeced3d..30167a5e 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -22,18 +22,13 @@ #ifndef GUI_NPCLISTDIALOG_H #define GUI_NPCLISTDIALOG_H -#include #include #include #include -#include "button.h" -#include "scrollarea.h" #include "window.h" -#include "../guichanfwd.h" - /** * The npc list dialog. * diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index ccb3c411..468326d6 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -19,18 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "npcstringdialog.h" - -#include -#include - #include "button.h" +#include "npcstringdialog.h" #include "textfield.h" #include "../npc.h" #include "../utils/gettext.h" -#include "../utils/tostring.h" #include "widgets/layout.h" diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h index 5aea2de0..aa39764d 100644 --- a/src/gui/npcstringdialog.h +++ b/src/gui/npcstringdialog.h @@ -22,16 +22,11 @@ #ifndef GUI_NPCSTRINGDIALOG_H #define GUI_NPCSTRINGDIALOG_H -#include -#include - #include #include #include "window.h" -#include "../guichanfwd.h" - /** * The npc integer input dialog. * diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp index 7f63b152..0d1f658f 100644 --- a/src/gui/ok_dialog.cpp +++ b/src/gui/ok_dialog.cpp @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "ok_dialog.h" - #include +#include "button.h" +#include "ok_dialog.h" +#include "scrollarea.h" +#include "textbox.h" + #include "../utils/gettext.h" OkDialog::OkDialog(const std::string &title, const std::string &msg, diff --git a/src/gui/ok_dialog.h b/src/gui/ok_dialog.h index 78b3d44f..3a438513 100644 --- a/src/gui/ok_dialog.h +++ b/src/gui/ok_dialog.h @@ -24,12 +24,10 @@ #include -#include "button.h" -#include "scrollarea.h" -#include "textbox.h" #include "window.h" -#include "../guichanfwd.h" +class ScrollArea; +class TextBox; /** * An 'Ok' button dialog. diff --git a/src/gui/passwordfield.cpp b/src/gui/passwordfield.cpp index 09b6abda..345ee1c3 100644 --- a/src/gui/passwordfield.cpp +++ b/src/gui/passwordfield.cpp @@ -21,8 +21,6 @@ #include "passwordfield.h" -#include - PasswordField::PasswordField(const std::string& text): TextField(text) { diff --git a/src/gui/passwordfield.h b/src/gui/passwordfield.h index e01bedbd..89293b05 100644 --- a/src/gui/passwordfield.h +++ b/src/gui/passwordfield.h @@ -22,9 +22,9 @@ #ifndef PASSWORDFIELD_H #define PASSWORDFIELD_H -#include "textfield.h" +#include -#include "../guichanfwd.h" +#include "textfield.h" /** * A password field. diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index 20ed17f8..60003fb5 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "playerbox.h" #include "../animatedsprite.h" diff --git a/src/gui/playerbox.h b/src/gui/playerbox.h index 70c41644..7c08defd 100644 --- a/src/gui/playerbox.h +++ b/src/gui/playerbox.h @@ -24,8 +24,6 @@ #include -#include "../guichanfwd.h" - class ImageRect; class Player; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index bf7c803a..cf6a7188 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -20,9 +20,6 @@ */ #include -#include - -#include #include "browserbox.h" #include "chat.h" @@ -42,7 +39,6 @@ #include "../net/protocol.h" #include "../resources/itemdb.h" -#include "../resources/iteminfo.h" #include "../utils/gettext.h" #include "../utils/strprintf.h" diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index a1b847c8..867477e0 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -19,6 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "gui.h" #include "progressbar.h" @@ -28,8 +30,6 @@ #include "../resources/image.h" #include "../resources/resourcemanager.h" -#include - ImageRect ProgressBar::mBorder; int ProgressBar::mInstances = 0; float ProgressBar::mAlpha = config.getValue("guialpha", 0.8); diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h index dd9cc896..2c1b22da 100644 --- a/src/gui/progressbar.h +++ b/src/gui/progressbar.h @@ -22,12 +22,11 @@ #ifndef PROGRESSBAR_H #define PROGRESSBAR_H +#include + #include #include -#include - -#include "../guichanfwd.h" class ImageRect; diff --git a/src/gui/radiobutton.h b/src/gui/radiobutton.h index 6ead9da0..3d952b3f 100644 --- a/src/gui/radiobutton.h +++ b/src/gui/radiobutton.h @@ -24,14 +24,13 @@ #include -#include "../guichanfwd.h" - class Image; /* * Guichan based RadioButton with custom look */ -class RadioButton : public gcn::RadioButton { +class RadioButton : public gcn::RadioButton +{ public: /* * Constructor. diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp index 9db1df2a..1e7d8e13 100644 --- a/src/gui/recorder.cpp +++ b/src/gui/recorder.cpp @@ -28,7 +28,6 @@ #include "widgets/layout.h" -#include "../utils/gettext.h" #include "../utils/trim.h" Recorder::Recorder(ChatWindow *chat, const std::string &title, diff --git a/src/gui/recorder.h b/src/gui/recorder.h index 420c4a2b..707f08ab 100644 --- a/src/gui/recorder.h +++ b/src/gui/recorder.h @@ -29,8 +29,6 @@ #include "window.h" -#include "../guichanfwd.h" - #include "../utils/gettext.h" class ChatWindow; diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 9c337d9e..cbf87e5b 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -19,15 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include - #include -#include "../main.h" #include "../configuration.h" #include "../log.h" #include "../logindata.h" +#include "../main.h" #include "button.h" #include "checkbox.h" @@ -38,12 +35,11 @@ #include "register.h" #include "textfield.h" -#include "../utils/tostring.h" - #include "widgets/layout.h" #include "../utils/gettext.h" #include "../utils/strprintf.h" +#include "../utils/tostring.h" /** * Listener used while dealing with wrong data. It is used to direct the focus diff --git a/src/gui/register.h b/src/gui/register.h index 4b95a07b..e58ac9db 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -22,15 +22,13 @@ #ifndef REGISTER_H #define REGISTER_H -#include +#include #include #include #include "window.h" -#include "../guichanfwd.h" - class LoginData; class OkDialog; class WrongDataNoticeListener; diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index a892f2d0..e69b681c 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "scrollarea.h" #include "../configuration.h" diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h index 4324deff..ccc1e178 100644 --- a/src/gui/scrollarea.h +++ b/src/gui/scrollarea.h @@ -24,8 +24,6 @@ #include -#include "../guichanfwd.h" - class Image; class ImageRect; diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 7976e32e..e4be7921 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -19,30 +19,24 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include #include "button.h" -#include "shoplistbox.h" #include "scrollarea.h" #include "sell.h" #include "shop.h" +#include "shoplistbox.h" #include "slider.h" #include "widgets/layout.h" -#include "../item.h" #include "../npc.h" #include "../net/messageout.h" #include "../net/protocol.h" -#include "../resources/iteminfo.h" - #include "../utils/gettext.h" #include "../utils/strprintf.h" -#include "../utils/tostring.h" SellDialog::SellDialog(Network *network): Window(_("Sell")), diff --git a/src/gui/sell.h b/src/gui/sell.h index 8e639a3d..c11a7b7c 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -25,9 +25,9 @@ #include #include -#include "window.h" +#include -#include "../guichanfwd.h" +#include "window.h" class Item; class Network; diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index d18f365c..19575cfb 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -19,9 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include - #include "button.h" #include "setup.h" #include "setup_audio.h" diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h index 2f5cd736..9e951895 100644 --- a/src/gui/setup_audio.h +++ b/src/gui/setup_audio.h @@ -26,8 +26,6 @@ #include "setuptab.h" -#include "../guichanfwd.h" - class Setup_Audio : public SetupTab, public gcn::ActionListener { public: diff --git a/src/gui/setup_colours.cpp b/src/gui/setup_colours.cpp index 95e6fff0..07ec9086 100644 --- a/src/gui/setup_colours.cpp +++ b/src/gui/setup_colours.cpp @@ -19,8 +19,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include - #include #include #include diff --git a/src/gui/setup_colours.h b/src/gui/setup_colours.h index 628efb43..f7984dd5 100644 --- a/src/gui/setup_colours.h +++ b/src/gui/setup_colours.h @@ -23,9 +23,9 @@ #define _SETUP_COLOURS_H #include -#include #include + #include #include diff --git a/src/gui/setup_joystick.h b/src/gui/setup_joystick.h index 2dc56439..eba8a2cc 100644 --- a/src/gui/setup_joystick.h +++ b/src/gui/setup_joystick.h @@ -26,8 +26,6 @@ #include "setuptab.h" -#include "../guichanfwd.h" - class Setup_Joystick : public SetupTab, public gcn::ActionListener { public: diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h index d4966053..082fa84d 100644 --- a/src/gui/setup_keyboard.h +++ b/src/gui/setup_keyboard.h @@ -26,7 +26,6 @@ #include -#include "button.h" #include "setuptab.h" #include "../guichanfwd.h" diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 932acee7..7e76055a 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -19,6 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #include @@ -27,14 +28,15 @@ #include "checkbox.h" #include "listbox.h" #include "ok_dialog.h" +#include "scrollarea.h" #include "setup_players.h" +#include "table.h" #include "widgets/dropdown.h" #include "widgets/layouthelper.h" #include "../configuration.h" #include "../log.h" -#include "../player_relations.h" #include "../utils/gettext.h" diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h index 22c8a9b6..393fc6aa 100644 --- a/src/gui/setup_players.h +++ b/src/gui/setup_players.h @@ -24,17 +24,16 @@ #include -#include "button.h" -#include "scrollarea.h" #include "setuptab.h" -#include "table.h" -#include "../guichanfwd.h" #include "../player_relations.h" +class GuiTable; class PlayerTableModel; +class StaticTableModel; -class Setup_Players : public SetupTab, public gcn::ActionListener, public PlayerRelationsListener +class Setup_Players : public SetupTab, + public gcn::ActionListener, public PlayerRelationsListener { public: Setup_Players(); @@ -60,7 +59,7 @@ private: gcn::CheckBox *mDefaultTrading; gcn::CheckBox *mDefaultWhisper; - Button *mDeleteButton; + gcn::Button *mDeleteButton; gcn::DropDown *mIgnoreActionChoicesBox; }; diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index d863fb64..303b5bfc 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -27,8 +27,6 @@ #include "setuptab.h" -#include "../guichanfwd.h" - class Setup_Video : public SetupTab, public gcn::ActionListener, public gcn::KeyListener { diff --git a/src/gui/shop.h b/src/gui/shop.h index 22b649d0..e0db4c59 100644 --- a/src/gui/shop.h +++ b/src/gui/shop.h @@ -27,10 +27,9 @@ #include -#include "../guichanfwd.h" #include "../shopitem.h" -#include "../resources/image.h" +class ShopItem; class ShopItems : public gcn::ListModel { diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index 3d17fd55..ba636112 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -19,14 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include -#include #include -#include #include "colour.h" +#include "shop.h" #include "shoplistbox.h" #include "../configuration.h" diff --git a/src/gui/shoplistbox.h b/src/gui/shoplistbox.h index 12413585..cde4786e 100644 --- a/src/gui/shoplistbox.h +++ b/src/gui/shoplistbox.h @@ -23,9 +23,8 @@ #define SHOPLISTBOX_H #include "listbox.h" -#include "shop.h" -#include "../guichanfwd.h" +class ShopItems; /** * A list box, meant to be used inside a scroll area. Same as the Guichan list diff --git a/src/gui/shortcutcontainer.cpp b/src/gui/shortcutcontainer.cpp index 62b2d382..eae24785 100644 --- a/src/gui/shortcutcontainer.cpp +++ b/src/gui/shortcutcontainer.cpp @@ -22,15 +22,8 @@ #include "shortcutcontainer.h" #include "../configuration.h" -#include "../graphics.h" -#include "../inventory.h" -#include "../item.h" -#include "../itemshortcut.h" -#include "../keyboardconfig.h" -#include "../localplayer.h" #include "../resources/image.h" -#include "../resources/resourcemanager.h" #include "../utils/tostring.h" diff --git a/src/gui/shortcutcontainer.h b/src/gui/shortcutcontainer.h index b2d0cc78..f5f06163 100644 --- a/src/gui/shortcutcontainer.h +++ b/src/gui/shortcutcontainer.h @@ -26,12 +26,10 @@ #include #include -#include "../guichanfwd.h" - class Image; /** - * An item shortcut container. Used to quickly use items. + * A generic shortcut container. * * \ingroup GUI */ @@ -41,7 +39,7 @@ class ShortcutContainer : public gcn::Widget, { public: /** - * Constructor. Initializes the graphic. + * Constructor. Initializes the shortcut container. */ ShortcutContainer(); @@ -51,7 +49,7 @@ class ShortcutContainer : public gcn::Widget, ~ShortcutContainer(){} /** - * Draws the items. + * Draws the shortcuts */ virtual void draw(gcn::Graphics *graphics) = 0; diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index 3a7cf0e0..91b33b72 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -19,9 +19,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "scrollarea.h" #include "shortcutcontainer.h" #include "shortcutwindow.h" -#include "scrollarea.h" #include "../configuration.h" diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h index 0168669e..2711ced5 100644 --- a/src/gui/shortcutwindow.h +++ b/src/gui/shortcutwindow.h @@ -24,10 +24,8 @@ #include "window.h" -#include "../guichanfwd.h" - -class ShortcutContainer; class ScrollArea; +class ShortcutContainer; /** * A window around the ItemShortcutContainer. diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 732aaa12..4587e75a 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -19,13 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include #include "button.h" #include "listbox.h" +#include "scrollarea.h" #include "skill.h" +#include "table.h" #include "windowcontainer.h" #include "widgets/layout.h" @@ -124,9 +124,11 @@ SkillDialog::SkillDialog(): { initSkillinfo(); mTableModel = new SkillGuiTableModel(this); - mTable.setModel(mTableModel); - mTable.setOpaque(false); - mTable.setLinewiseSelection(true); + mTable = new GuiTable(mTableModel); + mTable->setOpaque(false); + mTable->setLinewiseSelection(true); + mTable->setActionEventId("skill"); + mTable->addActionListener(this); setWindowName(_("Skills")); setCloseButton(true); @@ -135,14 +137,12 @@ SkillDialog::SkillDialog(): setMinHeight(50 + mTableModel->getHeight()); setMinWidth(200); - ScrollArea *skillScrollArea = new ScrollArea(&mTable); + ScrollArea *skillScrollArea = new ScrollArea(mTable); mPointsLabel = new gcn::Label(strprintf(_("Skill points: %d"), 0)); mIncButton = new Button(_("Up"), _("inc"), this); mUseButton = new Button(_("Use"), _("use"), this); mUseButton->setEnabled(false); - mTable.setActionEventId("skill"); - skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); place(0, 0, skillScrollArea, 5).setPadding(3); @@ -153,14 +153,13 @@ SkillDialog::SkillDialog(): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); - mTable.addActionListener(this); - setLocationRelativeTo(getParent()); loadWindowState(); } SkillDialog::~SkillDialog() { + delete mTable; } void SkillDialog::action(const gcn::ActionEvent &event) @@ -168,15 +167,14 @@ void SkillDialog::action(const gcn::ActionEvent &event) if (event.getId() == "inc") { // Increment skill - int selectedSkill = mTable.getSelectedRow(); + int selectedSkill = mTable->getSelectedRow(); if (selectedSkill >= 0) player_node->raiseSkill(mSkillList[selectedSkill]->id); } else if (event.getId() == "skill") { - mIncButton->setEnabled( - mTable.getSelectedRow() > -1 && - player_node->mSkillPoint > 0); + mIncButton->setEnabled(mTable->getSelectedRow() > -1 && + player_node->mSkillPoint > 0); } else if (event.getId() == "close") setVisible(false); @@ -187,7 +185,7 @@ void SkillDialog::update() mPointsLabel->setCaption(strprintf(_("Skill points: %d"), player_node->mSkillPoint)); - int selectedSkill = mTable.getSelectedRow(); + int selectedSkill = mTable->getSelectedRow(); if (selectedSkill >= 0) { diff --git a/src/gui/skill.h b/src/gui/skill.h index 45cfd059..91c2b640 100644 --- a/src/gui/skill.h +++ b/src/gui/skill.h @@ -25,19 +25,15 @@ #include #include -#include -#include "scrollarea.h" -#include "table.h" #include "window.h" -#include "../guichanfwd.h" - struct SKILL { short id; /**< Index into "skill_db" array */ short lv, sp; }; +class GuiTable; class SkillGuiTableModel; /** @@ -72,7 +68,7 @@ class SkillDialog : public Window, public gcn::ActionListener const std::vector& getSkills(void) const { return mSkillList; } private: - GuiTable mTable;//gcn::ListBox *mSkillListBox; + GuiTable *mTable; ScrollArea *skillScrollArea; SkillGuiTableModel *mTableModel; gcn::Label *mPointsLabel; diff --git a/src/gui/slider.h b/src/gui/slider.h index 12004f55..56ea334a 100644 --- a/src/gui/slider.h +++ b/src/gui/slider.h @@ -24,8 +24,6 @@ #include -#include "../guichanfwd.h" - class Image; /** diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 7eedce1c..8e3fe3c7 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -25,19 +25,15 @@ #include #include "gui.h" +#include "scrollarea.h" #include "speechbubble.h" - -#include "../resources/image.h" -#include "../resources/resourcemanager.h" +#include "textbox.h" #include "../utils/gettext.h" -// TODO: Fix windows so that they can each load their own skins without the -// other windows overriding another window's skin. SpeechBubble::SpeechBubble(): Window(_("Speech"), false, NULL, "graphics/gui/speechbubble.xml") { - // Height == Top Graphic (14px) + 1 Row of Text (15px) + Bottom Graphic (17px) setContentSize(140, 46); setShowTitle(false); setTitleBarHeight(0); @@ -62,9 +58,6 @@ SpeechBubble::SpeechBubble(): add(mSpeechArea); setLocationRelativeTo(getParent()); - - // LEEOR / TODO: This causes an exception error. - //moveToBottom(getParent()); } void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color) @@ -83,8 +76,6 @@ void SpeechBubble::setText(std::string mText) if (numRows > 2) { - // 15 == height of each line of text (based on font heights) - // 14 == speechbubble Top + Bottom graphic pixel heights setContentSize(mSpeechBox->getMinWidth() + fontHeight, (numRows * fontHeight) + 6); mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h index 23733813..323e5cbb 100644 --- a/src/gui/speechbubble.h +++ b/src/gui/speechbubble.h @@ -20,13 +20,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _LOM_SPEECHBUBBLE_H__ -#define _LOM_SPEECHBUBBLE_H__ +#ifndef SPEECHBUBBLE_H__ +#define SPEECHBUBBLE_H__ -#include "scrollarea.h" -#include "textbox.h" #include "window.h" +class ScrollArea; +class TextBox; + class SpeechBubble : public Window { public: diff --git a/src/gui/status.h b/src/gui/status.h index 1e1c4e98..00a48f4e 100644 --- a/src/gui/status.h +++ b/src/gui/status.h @@ -22,14 +22,10 @@ #ifndef STATUS_H #define STATUS_H -#include - #include #include "window.h" -#include "../guichanfwd.h" - class LocalPlayer; class ProgressBar; diff --git a/src/gui/table.cpp b/src/gui/table.cpp index bccdc900..9a5c0591 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include #include diff --git a/src/gui/table.h b/src/gui/table.h index bdb41e90..d63b1fb9 100644 --- a/src/gui/table.h +++ b/src/gui/table.h @@ -24,16 +24,12 @@ #include -#include #include #include -#include #include #include "table_model.h" -#include "../guichanfwd.h" - class GuiTableActionListener; /** diff --git a/src/gui/table_model.cpp b/src/gui/table_model.cpp index 5ee7e9ab..19e780f3 100644 --- a/src/gui/table_model.cpp +++ b/src/gui/table_model.cpp @@ -19,9 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - -#include #include #include "table_model.h" diff --git a/src/gui/table_model.h b/src/gui/table_model.h index a2a93887..1d966e8b 100644 --- a/src/gui/table_model.h +++ b/src/gui/table_model.h @@ -25,11 +25,6 @@ #include #include -#include -#include - -#include "../guichanfwd.h" - class TableModelListener { public: diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index e7986244..2a86d549 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -21,7 +21,6 @@ #include -#include #include #include "textbox.h" diff --git a/src/gui/textbox.h b/src/gui/textbox.h index 84dd6268..10a81fc0 100644 --- a/src/gui/textbox.h +++ b/src/gui/textbox.h @@ -24,8 +24,6 @@ #include -#include "../guichanfwd.h" - /** * A text box, meant to be used inside a scroll area. Same as the Guichan text * box except this one doesn't have a background or border, instead completely @@ -33,7 +31,8 @@ * * \ingroup GUI */ -class TextBox : public gcn::TextBox { +class TextBox : public gcn::TextBox +{ public: /** * Constructor. diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp index 7e5004cc..99a95a2e 100644 --- a/src/gui/textfield.cpp +++ b/src/gui/textfield.cpp @@ -19,12 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include -#include - #include "sdlinput.h" #include "textfield.h" diff --git a/src/gui/textfield.h b/src/gui/textfield.h index 11a58824..73824615 100644 --- a/src/gui/textfield.h +++ b/src/gui/textfield.h @@ -24,8 +24,6 @@ #include -#include "../guichanfwd.h" - class ImageRect; class TextField; diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index c89e55a2..f901be5e 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -41,8 +41,6 @@ #include "../net/messageout.h" #include "../net/protocol.h" -#include "../resources/iteminfo.h" - #include "../utils/gettext.h" #include "../utils/strprintf.h" #include "../utils/tostring.h" diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 67e05bbd..1f62bd2d 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -26,6 +26,9 @@ #include +// Curl should be included after Guichan to avoid Windows redefinitions +#include + #include "browserbox.h" #include "button.h" #include "progressbar.h" @@ -34,9 +37,6 @@ #include "widgets/layout.h" -// Curl should be included after Guichan to avoid Windows redefinitions -#include - #include "../configuration.h" #include "../log.h" #include "../main.h" diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h index 6450ece2..4ada3c3a 100644 --- a/src/gui/updatewindow.h +++ b/src/gui/updatewindow.h @@ -29,8 +29,6 @@ #include "window.h" -#include "../guichanfwd.h" - #include "../utils/mutex.h" class BrowserBox; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index f258aba8..11a0004b 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "gui.h" #include "popupmenu.h" #include "viewport.h" @@ -36,9 +34,6 @@ #include "../npc.h" #include "../textmanager.h" -#include "../resources/animation.h" -#include "../resources/image.h" -#include "../resources/imageset.h" #include "../resources/monsterinfo.h" #include "../resources/resourcemanager.h" diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 5ed40166..e352f765 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -26,9 +26,7 @@ #include "windowcontainer.h" -#include "../being.h" #include "../configlistener.h" -#include "../guichanfwd.h" class Map; class FloorItem; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index ac5cbaa2..31d35cb0 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -24,6 +24,8 @@ #include "dropdown.h" #include "../colour.h" +#include "../listbox.h" +#include "../scrollarea.h" #include "../../configuration.h" #include "../../graphics.h" diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index bff8bd1e..e5919dc7 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -22,15 +22,8 @@ #ifndef DROPDOWN_H #define DROPDOWN_H -#include - #include -#include "../listbox.h" -#include "../scrollarea.h" - -#include "../../guichanfwd.h" - class Image; class ImageRect; diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h index 198954f6..620c133f 100644 --- a/src/gui/widgets/resizegrip.h +++ b/src/gui/widgets/resizegrip.h @@ -24,8 +24,6 @@ #include -#include "../../guichanfwd.h" - class Image; /** diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 5465b431..22e952e7 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include #include "tab.h" diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 35d47082..36828194 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -28,7 +28,6 @@ #include #include "gui.h" -#include "gccontainer.h" #include "window.h" #include "windowcontainer.h" @@ -37,7 +36,6 @@ #include "../configlistener.h" #include "../configuration.h" -#include "../graphics.h" #include "../log.h" #include "../resources/image.h" diff --git a/src/gui/windowcontainer.h b/src/gui/windowcontainer.h index a3e80223..62704d1b 100644 --- a/src/gui/windowcontainer.h +++ b/src/gui/windowcontainer.h @@ -24,15 +24,14 @@ #include -#include "../guichanfwd.h" - /** * A window container. This container adds functionality for more convenient * widget (windows in particular) destruction. * * \ingroup GUI */ -class WindowContainer : public gcn::Container { +class WindowContainer : public gcn::Container +{ public: /** * Do GUI logic. This functions adds automatic deletion of objects that diff --git a/src/main.cpp b/src/main.cpp index b933742a..65b61de2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -54,6 +54,7 @@ #include "serverinfo.h" #include "sound.h" +#include "gui/button.h" #include "gui/char_server.h" #include "gui/char_select.h" #include "gui/colour.h" diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index b91a506a..bd3685f3 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -21,7 +21,6 @@ #include "charserverhandler.h" #include "messagein.h" -#include "network.h" #include "protocol.h" #include "../extensions.h" @@ -34,6 +33,8 @@ #include "../gui/char_select.h" #include "../gui/ok_dialog.h" +#include "../utils/tostring.h" + /* * Yeah, this is a global. Get over it. */ diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index db601214..6ad410ec 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -21,7 +21,6 @@ #include "loginhandler.h" #include "messagein.h" -#include "network.h" #include "protocol.h" #include "../log.h" @@ -29,6 +28,8 @@ #include "../main.h" #include "../serverinfo.h" +#include "../utils/tostring.h" + extern SERVER_INFO **server_info; LoginHandler::LoginHandler() diff --git a/src/net/network.cpp b/src/net/network.cpp index 941995c9..059da779 100644 --- a/src/net/network.cpp +++ b/src/net/network.cpp @@ -26,6 +26,7 @@ #include "network.h" #include "../log.h" +#include "../utils/tostring.h" /** Warning: buffers and other variables are shared, so there can be only one connection active at a time */ @@ -418,19 +419,6 @@ void Network::receive() SDLNet_FreeSocketSet(set); } -char *iptostring(int address) -{ - static char asciiIP[16]; - - sprintf(asciiIP, "%i.%i.%i.%i", - (unsigned char)(address), - (unsigned char)(address >> 8), - (unsigned char)(address >> 16), - (unsigned char)(address >> 24)); - - return asciiIP; -} - void Network::setError(const std::string& error) { logger->log("Network error: %s", error.c_str()); diff --git a/src/net/network.h b/src/net/network.h index c035f55c..02fe7538 100644 --- a/src/net/network.h +++ b/src/net/network.h @@ -115,7 +115,4 @@ class Network MessageHandlers mMessageHandlers; }; -/** Convert an address from int format to string */ -char *iptostring(int address); - #endif diff --git a/src/utils/tostring.h b/src/utils/tostring.h index 5ac1d3aa..eb86f99e 100644 --- a/src/utils/tostring.h +++ b/src/utils/tostring.h @@ -32,4 +32,19 @@ std::string toString(const T &arg) return ss.str(); } +// TODO: Is there a good way to suppress warnings from classes which don't use +// this function? +static char *iptostring(int address) +{ + static char asciiIP[16]; + + sprintf(asciiIP, "%i.%i.%i.%i", + (unsigned char)(address), + (unsigned char)(address >> 8), + (unsigned char)(address >> 16), + (unsigned char)(address >> 24)); + + return asciiIP; +} + #endif -- cgit v1.2.3-70-g09d2 From 9aae9a0b20f144859fc68e94b4fb9fdae6f15861 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 12:11:00 -0700 Subject: Few more unneeded headers that weren't noticed originally in the last commit. Also, while the overall performance improved a little, it doesn't appear to be as drastic as the last commit was suggesting. Signed-off-by: Ira Rice --- src/gui/browserbox.cpp | 2 ++ src/gui/button.cpp | 3 --- src/gui/chat.cpp | 2 -- src/gui/listbox.cpp | 1 - src/gui/shoplistbox.cpp | 1 - src/gui/table.cpp | 2 +- src/gui/truetypefont.h | 1 - src/gui/window.cpp | 2 -- 8 files changed, 3 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index cd5479c8..c51852bb 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -21,6 +21,8 @@ #include +#include + #include "browserbox.h" #include "colour.h" #include "linkhandler.h" diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 2e6bed0a..1d3a04e4 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -19,11 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include #include -#include #include "button.h" diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index a58600a8..f4d9763b 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include #include "browserbox.h" diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index e56ddeeb..b63d6424 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include "colour.h" #include "listbox.h" diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index ba636112..b5761535 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -20,7 +20,6 @@ */ #include -#include #include #include "colour.h" diff --git a/src/gui/table.cpp b/src/gui/table.cpp index 9a5c0591..af42165a 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -19,8 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include +#include #include "colour.h" #include "table.h" diff --git a/src/gui/truetypefont.h b/src/gui/truetypefont.h index 288be49a..bd338d84 100644 --- a/src/gui/truetypefont.h +++ b/src/gui/truetypefont.h @@ -25,7 +25,6 @@ #include #include -#include #ifndef __APPLE__ #include #else diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 36828194..934bd9b3 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -25,8 +25,6 @@ #include -#include - #include "gui.h" #include "window.h" #include "windowcontainer.h" -- cgit v1.2.3-70-g09d2 From 98f8f12759fe0aaf05bc124e5682903503fe3fe6 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 13:24:05 -0700 Subject: Not sure how this happened in the first place, but this should ensure that speech bubbles are always at least as long as the name is. Signed-off-by: Ira Rice --- src/gui/speechbubble.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 8e3fe3c7..1137af4b 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -73,9 +73,12 @@ void SpeechBubble::setText(std::string mText) const int fontHeight = getFont()->getHeight(); const int numRows = mSpeechBox->getNumberOfRows() + 1; + int width = mCaption->getWidth() + 3; if (numRows > 2) { + if (width < mSpeechBox->getMinWidth()) + width = mSpeechBox->getMinWidth(); setContentSize(mSpeechBox->getMinWidth() + fontHeight, (numRows * fontHeight) + 6); mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, @@ -84,7 +87,6 @@ void SpeechBubble::setText(std::string mText) } else { - int width = mCaption->getWidth() + 3; if (width < getFont()->getWidth(mText)) width = getFont()->getWidth(mText); setContentSize(width + fontHeight, (fontHeight * 2) + 6); -- cgit v1.2.3-70-g09d2 From ed6a1d2fb487580fe3aee5ed7e0cf3fe091032f8 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 13:26:52 -0700 Subject: Fix for the last commit, where I forgot to modify the set dimension and set content size functions to use the width variable. Signed-off-by: Ira Rice --- src/gui/speechbubble.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 1137af4b..0e58825c 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -79,10 +79,8 @@ void SpeechBubble::setText(std::string mText) { if (width < mSpeechBox->getMinWidth()) width = mSpeechBox->getMinWidth(); - setContentSize(mSpeechBox->getMinWidth() + fontHeight, - (numRows * fontHeight) + 6); - mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, - mSpeechBox->getMinWidth() + 5, + setContentSize(width + fontHeight, (numRows * fontHeight) + 6); + mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, width + 5, (numRows * fontHeight))); } else -- cgit v1.2.3-70-g09d2 From e72f04528e93273af138375a68b09b5907fce964 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 13:30:51 -0700 Subject: Since they're now doing the same thing, having a branch is a little bit silly. Condensed the sizing code for speech bubbles to do the same for speech bubbles of all sizes. Signed-off-by: Ira Rice --- src/gui/speechbubble.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 0e58825c..b2c66ff2 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -75,22 +75,12 @@ void SpeechBubble::setText(std::string mText) const int numRows = mSpeechBox->getNumberOfRows() + 1; int width = mCaption->getWidth() + 3; - if (numRows > 2) - { - if (width < mSpeechBox->getMinWidth()) - width = mSpeechBox->getMinWidth(); - setContentSize(width + fontHeight, (numRows * fontHeight) + 6); - mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, width + 5, - (numRows * fontHeight))); - } - else - { - if (width < getFont()->getWidth(mText)) - width = getFont()->getWidth(mText); - setContentSize(width + fontHeight, (fontHeight * 2) + 6); - mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, - width, fontHeight)); - } + if (width < mSpeechBox->getMinWidth()) + width = mSpeechBox->getMinWidth(); + + setContentSize(width + fontHeight, (numRows * fontHeight) + 6); + mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, width + 5, + (numRows * fontHeight))); } unsigned int SpeechBubble::getNumRows() -- cgit v1.2.3-70-g09d2 From 15d15965978d5ce73252e840c3da8ac15b48d858 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 13:51:22 -0700 Subject: On the offchance that a player's name is longer than 130 pixels, set the mininum width for the text wrapping code to be the length of the player's name instead. Signed-off-by: Ira Rice --- src/gui/speechbubble.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index b2c66ff2..f14dcd52 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -69,11 +69,11 @@ void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color) void SpeechBubble::setText(std::string mText) { - mSpeechBox->setTextWrapped(mText, 130); + int width = mCaption->getWidth() + 3; + mSpeechBox->setTextWrapped(mText, 130 > width ? 130 : width); const int fontHeight = getFont()->getHeight(); const int numRows = mSpeechBox->getNumberOfRows() + 1; - int width = mCaption->getWidth() + 3; if (width < mSpeechBox->getMinWidth()) width = mSpeechBox->getMinWidth(); -- cgit v1.2.3-70-g09d2 From 35c4cb970f14989445828aefa4cf17f3260f9281 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 14:43:01 -0700 Subject: Added a right click popup menu, and item popups to the equipment window. Signed-off-by: Ira Rice --- src/gui/equipmentwindow.cpp | 79 +++++++++++++++++++++++++++++++++++++++------ src/gui/equipmentwindow.h | 9 ++++++ 2 files changed, 79 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 1fb2b601..f5ab604e 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -26,7 +26,10 @@ #include "button.h" #include "equipmentwindow.h" +#include "gui.h" +#include "itempopup.h" #include "playerbox.h" +#include "viewport.h" #include "../equipment.h" #include "../graphics.h" @@ -59,8 +62,9 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment): Window(_("Equipment")), mEquipment(equipment), mSelected(-1) - { + mItemPopup = new ItemPopup(); + // Control that shows the Player mPlayerBox = new PlayerBox; mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 123)); @@ -153,6 +157,23 @@ void EquipmentWindow::action(const gcn::ActionEvent &event) } } +Item* EquipmentWindow::getItem(const int &x, const int &y) +{ + for (int i = EQUIP_LEGS_SLOT; i < EQUIP_VECTOREND; i++) + { + gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY, + BOX_WIDTH, BOX_HEIGHT); + + if (tRect.isPointInRect(x, y)) + { + return (i != EQUIP_AMMO_SLOT) ? + mInventory->getItem(mEquipment->getEquipment(i)) : + mInventory->getItem(mEquipment->getArrows()); + } + } + return NULL; +} + void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) { Window::mousePressed(mouseEvent); @@ -162,21 +183,61 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) Item* item; - // Checks if any of the presses were in the equip boxes. - for (int i = EQUIP_LEGS_SLOT; i < EQUIP_VECTOREND; i++) + if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { - item = (i != EQUIP_AMMO_SLOT) ? - mInventory->getItem(mEquipment->getEquipment(i)) : - mInventory->getItem(mEquipment->getArrows()); - gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY, - BOX_WIDTH, BOX_HEIGHT); - if (tRect.isPointInRect(x, y)) + // Checks if any of the presses were in the equip boxes. + for (int i = EQUIP_LEGS_SLOT; i < EQUIP_VECTOREND; i++) { + item = getItem(x, y); + if (item) { mSelected = i; + break; } } } + else if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT) + { + item = getItem(x, y); + + if (!item) + return; + + /* Convert relative to the window coordinates to absolute screen + * coordinates. + */ + const int mx = x + getX(); + const int my = y + getY(); + viewport->showPopup(mx, my, item); + } } +// Show ItemTooltip +void EquipmentWindow::mouseMoved(gcn::MouseEvent &event) +{ + const int x = event.getX(); + const int y = event.getY(); + + Item* item = getItem(x, y); + + if (item) + { + int mouseX, mouseY; + SDL_GetMouseState(&mouseX, &mouseY); + + mItemPopup->setItem(item->getInfo()); + mItemPopup->setOpaque(false); + mItemPopup->view(x + getX(), y + getY()); + } + else + { + mItemPopup->setVisible(false); + } +} + +// Hide ItemTooltip +void EquipmentWindow::mouseExited(gcn::MouseEvent &event) +{ + mItemPopup->setVisible(false); +} diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index 8e9b22eb..b64c768b 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -28,6 +28,8 @@ class Equipment; class Inventory; +class Item; +class ItemPopup; class PlayerBox; /** @@ -66,6 +68,8 @@ class EquipmentWindow : public Window, public gcn::ActionListener void mousePressed(gcn::MouseEvent& mouseEvent); + Item* getItem(const int &x, const int &y); + enum { // Equipment rules: EQUIP_LEGS_SLOT = 0, @@ -84,11 +88,16 @@ class EquipmentWindow : public Window, public gcn::ActionListener private: + void mouseExited(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event); + Equipment *mEquipment; Inventory *mInventory; gcn::Button *mUnequip; /**< Button for unequipping. */ EquipBox mEquipBox[EQUIP_VECTOREND]; /**< Equipment Boxes. */ + ItemPopup *mItemPopup; + PlayerBox *mPlayerBox; int mSelected; /**< Index of selected item. */ -- cgit v1.2.3-70-g09d2 From 1e20fad127583d7832130ecf50ca90d190ede91b Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 14:45:20 -0700 Subject: Forgot to check left clicking, as I assumed that it wouldn't break using the same lookup code. This fixes left clicking on the last commit. Signed-off-by: Ira Rice --- src/gui/equipmentwindow.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index f5ab604e..7630c53c 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -188,12 +188,18 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) // Checks if any of the presses were in the equip boxes. for (int i = EQUIP_LEGS_SLOT; i < EQUIP_VECTOREND; i++) { - item = getItem(x, y); + item = (i != EQUIP_AMMO_SLOT) ? + mInventory->getItem(mEquipment->getEquipment(i)) : + mInventory->getItem(mEquipment->getArrows()); + gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY, + BOX_WIDTH, BOX_HEIGHT); - if (item) + if (tRect.isPointInRect(x, y)) { - mSelected = i; - break; + if (item) + { + mSelected = i; + } } } } -- cgit v1.2.3-70-g09d2 From f025d7798f1b280c15f44919878c926d2b10c2b7 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 15:27:09 -0700 Subject: Got rid of a few dangling pointers. Signed-off-by: Ira Rice --- src/gui/equipmentwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 7630c53c..8a7b23ae 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -95,6 +95,8 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment): EquipmentWindow::~EquipmentWindow() { delete mUnequip; + delete mItemPopup; + delete mPlayerBox; } void EquipmentWindow::draw(gcn::Graphics *graphics) -- cgit v1.2.3-70-g09d2 From 0bc83fbba9c8b5f2677b8183f16dd95645f3e998 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 15:37:39 -0700 Subject: A few more pointers which weren't getting deleted. Signed-off-by: Ira Rice --- src/gui/inventorywindow.cpp | 12 ++++++++++++ src/gui/inventorywindow.h | 5 +++++ src/gui/itemcontainer.cpp | 1 + src/gui/itemshortcutcontainer.cpp | 1 + 4 files changed, 19 insertions(+) (limited to 'src') diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 246219f4..a3572d4f 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -105,6 +105,18 @@ InventoryWindow::InventoryWindow(int invSize): setLocationRelativeTo(getParent()); } +InventoryWindow::~InventoryWindow() +{ + delete mWeightBar; + delete mSlotsBar; + delete mUseButton; + delete mDropButton; + delete mItems; + delete mWeightLabel; + delete mSlotsLabel; + delete mInvenScroll; +} + void InventoryWindow::logic() { Window::logic(); diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 2694e90b..78d30461 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -48,6 +48,11 @@ class InventoryWindow : public Window, gcn::ActionListener, */ InventoryWindow(int invSize = (INVENTORY_SIZE - 2)); + /** + * Destructor. + */ + ~InventoryWindow(); + /** * Logic (updates buttons and weight information). */ diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index e655d3fc..5693d001 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -66,6 +66,7 @@ ItemContainer::ItemContainer(Inventory *inventory, int offset): ItemContainer::~ItemContainer() { mSelImg->decRef(); + delete mItemPopup; } void ItemContainer::logic() diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index ecadd0e4..e152b03d 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -62,6 +62,7 @@ ItemShortcutContainer::ItemShortcutContainer(): ItemShortcutContainer::~ItemShortcutContainer() { mBackgroundImg->decRef(); + delete mItemPopup; } void ItemShortcutContainer::logic() -- cgit v1.2.3-70-g09d2 From d05b238a3c100ed0b5b31093f3d15bb039dde8d6 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 16:03:18 -0700 Subject: Added destructors to some classes originally obtained from Legends of Mazzeroth. At the moment, I think this is the last of the missing pointer deletes, but if more are found, then I'll add them to the proper classes and delete them. Signed-off-by: Ira Rice --- src/gui/itempopup.cpp | 11 +++++++++++ src/gui/itempopup.h | 1 + src/gui/speechbubble.cpp | 7 +++++++ src/gui/speechbubble.h | 1 + 4 files changed, 20 insertions(+) (limited to 'src') diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 39a5ecf1..8651ede6 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -90,6 +90,17 @@ ItemPopup::ItemPopup(): setLocationRelativeTo(getParent()); } +ItemPopup::~ItemPopup() +{ + delete mItemName; + delete mItemDesc; + delete mItemDescScroll; + delete mItemEffect; + delete mItemEffectScroll; + delete mItemWeight; + delete mItemWeightScroll; +} + void ItemPopup::setItem(const ItemInfo &item) { mItemName->setCaption(item.getName()); diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index d9d37264..95ab6ffa 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -33,6 +33,7 @@ class ItemPopup : public Window { public: ItemPopup(); + ~ItemPopup(); void setItem(const ItemInfo &item); unsigned int getNumRows(); diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index f14dcd52..f8c69e87 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -60,6 +60,13 @@ SpeechBubble::SpeechBubble(): setLocationRelativeTo(getParent()); } +SpeechBubble::~SpeechBubble() +{ + delete mCaption; + delete mSpeechBox; + delete mSpeechArea; +} + void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color) { mCaption->setCaption(name); diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h index 323e5cbb..7f5818af 100644 --- a/src/gui/speechbubble.h +++ b/src/gui/speechbubble.h @@ -33,6 +33,7 @@ class SpeechBubble : public Window public: SpeechBubble(); + ~SpeechBubble(); void setCaption(const std::string &name, const gcn::Color &color = 0x000000); -- cgit v1.2.3-70-g09d2 From 3818b6db81341b840201996c186bdc8ad5e456e9 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 18:29:58 -0700 Subject: Moved mEquipment to the LocalPlayer class, since it's the only place that uses it anyways. Signed-off-by: Ira Rice --- src/being.cpp | 2 -- src/being.h | 3 --- src/localplayer.cpp | 1 + src/localplayer.h | 3 +++ 4 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index dc36adc2..dc843e43 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -25,7 +25,6 @@ #include "animatedsprite.h" #include "being.h" #include "configuration.h" -#include "equipment.h" #include "game.h" #include "graphics.h" #include "localplayer.h" @@ -67,7 +66,6 @@ Being::Being(int id, int job, Map *map): mWalkTime(0), mEmotion(0), mEmotionTime(0), mAttackSpeed(350), - mEquipment(new Equipment()), mId(id), mWalkSpeed(150), mDirection(DOWN), diff --git a/src/being.h b/src/being.h index b4508661..812ffdd3 100644 --- a/src/being.h +++ b/src/being.h @@ -44,7 +44,6 @@ #define STATUS_EFFECTS 32 class AnimatedSprite; -class Equipment; class ItemInfo; class Item; class Map; @@ -362,8 +361,6 @@ class Being : public Sprite // Target cursor being used by the being Image *mTargetCursor; - const std::auto_ptr mEquipment; - static int getHairColorsNr(void); static int getHairStylesNr(void); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index c6fde7a8..bc0b2b81 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -63,6 +63,7 @@ LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map): ATK_BONUS(0), MATK_BONUS(0), DEF_BONUS(0), MDEF_BONUS(0), FLEE_BONUS(0), mStatPoint(0), mSkillPoint(0), mStatsPointsToAttribute(0), + mEquipment(new Equipment()), mXp(0), mNetwork(0), mTarget(NULL), mPickUpTarget(NULL), mTrading(false), mGoingToTarget(false), diff --git a/src/localplayer.h b/src/localplayer.h index 4e0b205f..7f5596e4 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -31,6 +31,7 @@ #define INVENTORY_SIZE 102 #define STORAGE_SIZE 301 +class Equipment; class FloorItem; class ImageSet; class Inventory; @@ -234,6 +235,8 @@ class LocalPlayer : public Player /** Animated out of range target cursor. */ SimpleAnimation *mTargetCursorOutRange[NUM_TC]; + const std::auto_ptr mEquipment; + protected: void walk(unsigned char dir); -- cgit v1.2.3-70-g09d2 From cd511bda4e07f5de49ef66eff9d2fe4d649c17b6 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 18:36:02 -0700 Subject: Simplified equipment window initialization, since only the local player has an inventory or an equipment. Signed-off-by: Ira Rice --- src/game.cpp | 2 +- src/gui/equipmentwindow.cpp | 4 ++-- src/gui/equipmentwindow.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index 5b37d409..43b3e986 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -213,7 +213,7 @@ void createGuiWindows(Network *network) skillDialog = new SkillDialog(); setupWindow = new Setup(); minimap = new Minimap(); - equipmentWindow = new EquipmentWindow(player_node->mEquipment.get()); + equipmentWindow = new EquipmentWindow(); tradeWindow = new TradeWindow(network); helpWindow = new HelpWindow(); debugWindow = new DebugWindow(); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 8a7b23ae..5ba9501d 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -58,9 +58,8 @@ static const int boxPosition[][2] = { {129, 78} // EQUIP_AMMO_SLOT }; -EquipmentWindow::EquipmentWindow(Equipment *equipment): +EquipmentWindow::EquipmentWindow(): Window(_("Equipment")), - mEquipment(equipment), mSelected(-1) { mItemPopup = new ItemPopup(); @@ -89,6 +88,7 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment): mEquipBox[i].posY = boxPosition[i][1] + getTitleBarHeight(); } + mEquipment = player_node->mEquipment.get(); mInventory = player_node->getInventory(); } diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index b64c768b..4ae3300f 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -52,7 +52,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener /** * Constructor. */ - EquipmentWindow(Equipment *equipment); + EquipmentWindow(); /** * Destructor. @@ -68,8 +68,6 @@ class EquipmentWindow : public Window, public gcn::ActionListener void mousePressed(gcn::MouseEvent& mouseEvent); - Item* getItem(const int &x, const int &y); - enum { // Equipment rules: EQUIP_LEGS_SLOT = 0, @@ -91,6 +89,8 @@ class EquipmentWindow : public Window, public gcn::ActionListener void mouseExited(gcn::MouseEvent &event); void mouseMoved(gcn::MouseEvent &event); + Item* getItem(const int &x, const int &y); + Equipment *mEquipment; Inventory *mInventory; gcn::Button *mUnequip; /**< Button for unequipping. */ -- cgit v1.2.3-70-g09d2 From 9f0d62aa2fbc0ec822526b129070615696ac6881 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 20:56:13 -0700 Subject: Changed NPC list dialog to selection wrap. Signed-off-by: Ira Rice --- src/gui/npclistdialog.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index e6406422..7d8a362a 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -43,6 +43,7 @@ NpcListDialog::NpcListDialog(): setDefaultSize(0, 0, 260, 200); mItemList = new ListBox(this); + mItemList->setWrappingEnabled(true); scrollArea = new ScrollArea(mItemList); okButton = new Button(_("OK"), "ok", this); cancelButton = new Button(_("Cancel"), "cancel", this); -- cgit v1.2.3-70-g09d2 From 373f1aca8bb651332fec7031853d9a685ebc896e Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 20:57:04 -0700 Subject: Added key and mouse events to the table class. Signed-off-by: Ira Rice --- src/gui/skill.cpp | 1 + src/gui/table.cpp | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++- src/gui/table.h | 33 ++++++++++----- 3 files changed, 143 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 4587e75a..dd7c3a4e 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -127,6 +127,7 @@ SkillDialog::SkillDialog(): mTable = new GuiTable(mTableModel); mTable->setOpaque(false); mTable->setLinewiseSelection(true); + mTable->setWrappingEnabled(true); mTable->setActionEventId("skill"); mTable->addActionListener(this); diff --git a/src/gui/table.cpp b/src/gui/table.cpp index af42165a..3bed48d8 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -21,12 +21,15 @@ #include #include +#include #include "colour.h" #include "table.h" #include "../configuration.h" +#include "../utils/dtor.h" + float GuiTable::mAlpha = config.getValue("guialpha", 0.8); class GuiTableActionListener : public gcn::ActionListener @@ -78,6 +81,7 @@ void GuiTableActionListener::action(const gcn::ActionEvent& actionEvent) GuiTable::GuiTable(TableModel *initial_model, gcn::Color background, bool opacity) : mLinewiseMode(false), + mWrappingEnabled(false), mOpaque(opacity), mBackgroundColor(background), mModel(NULL), @@ -86,6 +90,8 @@ GuiTable::GuiTable(TableModel *initial_model, gcn::Color background, mTopWidget(NULL) { setModel(initial_model); + setFocusable(true); + addMouseListener(this); addKeyListener(this); } @@ -177,10 +183,63 @@ int GuiTable::getColumnWidth(int i) return 0; } +void GuiTable::setSelectedRow(int selected) +{ + if (mModel == NULL) + { + mSelectedRow = -1; + } + else + { + if (selected < 0) + { + mSelectedRow = -1; + } + else if (selected >= mModel->getRows() && mWrappingEnabled) + { + mSelectedRow = 0; + } + else if (selected >= mModel->getRows() && !mWrappingEnabled) + { + mSelectedRow = mModel->getRows() - 1; + } + else + { + mSelectedRow = selected; + } + } +} + +void GuiTable::setSelectedColumn(int selected) +{ + if (mModel == NULL) + { + mSelectedColumn = -1; + } + else + { + if (selected < 0) + { + mSelectedColumn = -1; + } + else if (selected >= mModel->getColumns() && mWrappingEnabled) + { + mSelectedColumn = 0; + } + else if (selected >= mModel->getColumns() && !mWrappingEnabled) + { + mSelectedColumn = mModel->getColumns() - 1; + } + else + { + mSelectedColumn = selected; + } + } +} + void GuiTable::uninstallActionListeners(void) { - for (std::vector::const_iterator it = action_listeners.begin(); it != action_listeners.end(); it++) - delete *it; + delete_all(action_listeners); action_listeners.clear(); } @@ -333,6 +392,49 @@ gcn::Rectangle GuiTable::getChildrenArea(void) // -- KeyListener notifications void GuiTable::keyPressed(gcn::KeyEvent& keyEvent) { + gcn::Key key = keyEvent.getKey(); + + if (key.getValue() == gcn::Key::ENTER || key.getValue() == gcn::Key::SPACE) + { + distributeActionEvent(); + keyEvent.consume(); + } + else if (key.getValue() == gcn::Key::UP) + { + setSelectedRow(mSelectedRow - 1); + + keyEvent.consume(); + } + else if (key.getValue() == gcn::Key::DOWN) + { + setSelectedRow(mSelectedRow + 1); + + keyEvent.consume(); + } + else if (key.getValue() == gcn::Key::LEFT) + { + setSelectedColumn(mSelectedColumn - 1); + + keyEvent.consume(); + } + else if (key.getValue() == gcn::Key::RIGHT) + { + setSelectedColumn(mSelectedColumn + 1); + + keyEvent.consume(); + } + else if (key.getValue() == gcn::Key::HOME) + { + setSelectedRow(0); + setSelectedColumn(0); + keyEvent.consume(); + } + else if (key.getValue() == gcn::Key::END) + { + setSelectedRow(mModel->getRows() - 1); + setSelectedColumn(mModel->getColumns() - 1); + keyEvent.consume(); + } } // -- MouseListener notifications @@ -355,10 +457,25 @@ void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent) void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) { + if (isFocused()) + { + if (getSelectedRow() > 0 ) + { + setSelectedRow(getSelectedRow() - 1); + } + + mouseEvent.consume(); + } } void GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) { + if (isFocused()) + { + setSelectedRow(getSelectedRow() + 1); + + mouseEvent.consume(); + } } void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent) diff --git a/src/gui/table.h b/src/gui/table.h index d63b1fb9..912eb284 100644 --- a/src/gui/table.h +++ b/src/gui/table.h @@ -33,8 +33,9 @@ class GuiTableActionListener; /** - * A table, with rows and columns made out of sub-widgets. Largely inspired by (and can be thought of as a generalisation of) - * the guichan listbox implementation. + * A table, with rows and columns made out of sub-widgets. Largely inspired by + * (and can be thought of as a generalisation of) the guichan listbox + * implementation. * * Normally you want this within a ScrollArea. * @@ -60,27 +61,38 @@ public: /** * Sets the table model * - * Note that actions issued by widgets returned from the model will update the table - * selection, but only AFTER any event handlers installed within the widget have been - *triggered. To be notified after such an update, add an action listener to the table - * instead. + * Note that actions issued by widgets returned from the model will update + * the table selection, but only AFTER any event handlers installed within + * the widget have been triggered. To be notified after such an update, add + * an action listener to the table instead. */ void setModel(TableModel *m); + const TableModel* getModel() {return mModel;} + void setSelected(int row, int column); int getSelectedRow(void); int getSelectedColumn(void); + void setSelectedRow(int selected); + + void setSelectedColumn(int selected); + + bool isWrappingEnabled() const {return mWrappingEnabled;} + + void setWrappingEnabled(bool wrappingEnabled) + {mWrappingEnabled = wrappingEnabled;} + gcn::Rectangle getChildrenArea(void); /** - * Toggle whether to use linewise selection mode, in which the table selects an entire - * line at a time, rather than a single cell. + * Toggle whether to use linewise selection mode, in which the table selects + * an entire line at a time, rather than a single cell. * - * Note that column information is tracked even in linewise selection mode; this mode - * therefore only affects visualisation. + * Note that column information is tracked even in linewise selection mode; + * this mode therefore only affects visualisation. * * Disabled by default. * @@ -144,6 +156,7 @@ private: int getColumnForX(int x); // -1 on error void recomputeDimensions(void); bool mLinewiseMode; + bool mWrappingEnabled; bool mOpaque; static float mAlpha; -- cgit v1.2.3-70-g09d2 From b0a8b8607962081e87716ab0dfbca2439953f420 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 22:13:12 -0700 Subject: Modified the NPC string and integer classes to automatically take focus to the input fields. Now the only NPC dialog which isn't completely navigatable by the keyboard alone is the NPC list dialog (seems to have regressed slightly recently). Signed-off-by: Ira Rice --- src/gui/npcintegerdialog.cpp | 16 ++++++++++++---- src/gui/npcintegerdialog.h | 14 +++++++++++--- src/gui/npcstringdialog.cpp | 6 ++++++ src/gui/npcstringdialog.h | 6 +++++- src/net/npchandler.cpp | 2 ++ 5 files changed, 36 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp index 4444e04b..c58fc460 100644 --- a/src/gui/npcintegerdialog.cpp +++ b/src/gui/npcintegerdialog.cpp @@ -32,9 +32,10 @@ NpcIntegerDialog::NpcIntegerDialog(): Window(_("NPC Number Request")) { + mValueField = new IntTextField(); + mDecButton = new Button("-", "decvalue", this); mIncButton = new Button("+", "incvalue", this); - mValueField = new IntTextField(); okButton = new Button(_("OK"), "ok", this); cancelButton = new Button(_("Cancel"), "cancel", this); resetButton = new Button(_("Reset"), "reset", this); @@ -56,9 +57,6 @@ NpcIntegerDialog::NpcIntegerDialog(): reflowLayout(175, 0); setLocationRelativeTo(getParent()); - - mValueField->setActionEventId("valuefield"); - mValueField->addKeyListener(this); } void NpcIntegerDialog::setRange(const int min, const int max) @@ -105,3 +103,13 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event) mValueField->reset(); } } + +bool NpcIntegerDialog::isInputFocused() +{ + return mValueField->isFocused(); +} + +void NpcIntegerDialog::requestFocus() +{ + mValueField->requestFocus(); +} diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h index b9ce70be..10ec60b9 100644 --- a/src/gui/npcintegerdialog.h +++ b/src/gui/npcintegerdialog.h @@ -23,7 +23,6 @@ #define GUI_NPCINTEGERDIALOG_H #include -#include #include "window.h" @@ -34,8 +33,7 @@ class IntTextField; * * \ingroup Interface */ -class NpcIntegerDialog : public Window, public gcn::ActionListener, - public gcn::KeyListener +class NpcIntegerDialog : public Window, public gcn::ActionListener { public: /** @@ -63,6 +61,16 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener, */ void setRange(const int min, const int max); + /** + * Checks whether NpcStringDialog is Focused or not. + */ + bool isInputFocused(); + + /** + * Requests the textfield to take focus for input. + */ + void requestFocus(); + private: gcn::Button *mDecButton; gcn::Button *mIncButton; diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index 468326d6..718c416f 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -33,6 +33,7 @@ NpcStringDialog::NpcStringDialog(): Window(_("NPC Text Request")) { mValueField = new TextField(""); + okButton = new Button(_("OK"), "ok", this); cancelButton = new Button(_("Cancel"), "cancel", this); @@ -71,3 +72,8 @@ bool NpcStringDialog::isInputFocused() { return mValueField->isFocused(); } + +void NpcStringDialog::requestFocus() +{ + mValueField->requestFocus(); +} diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h index aa39764d..1933e0f1 100644 --- a/src/gui/npcstringdialog.h +++ b/src/gui/npcstringdialog.h @@ -23,7 +23,6 @@ #define GUI_NPCSTRINGDIALOG_H #include -#include #include "window.h" @@ -64,6 +63,11 @@ class NpcStringDialog : public Window, public gcn::ActionListener */ bool isInputFocused(); + /** + * Requests the textfield to take focus for input. + */ + void requestFocus(); + private: gcn::TextField *mValueField; gcn::Button *okButton; diff --git a/src/net/npchandler.cpp b/src/net/npchandler.cpp index 82b07d41..4e17a27e 100644 --- a/src/net/npchandler.cpp +++ b/src/net/npchandler.cpp @@ -92,6 +92,7 @@ void NPCHandler::handleMessage(MessageIn *msg) current_npc = dynamic_cast(beingManager->findBeing(id)); npcIntegerDialog->setRange(0, 2147483647); npcIntegerDialog->setVisible(true); + npcIntegerDialog->requestFocus(); break; case SMSG_NPC_STR_INPUT: @@ -100,6 +101,7 @@ void NPCHandler::handleMessage(MessageIn *msg) current_npc = dynamic_cast(beingManager->findBeing(id)); npcStringDialog->setValue(""); npcStringDialog->setVisible(true); + npcStringDialog->requestFocus(); break; } } -- cgit v1.2.3-70-g09d2 From a955833718217fe35442bcde8a43375c91002738 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 22:28:43 -0700 Subject: Cleaned up some login includes that I missed earlier. Signed-off-by: Ira Rice --- src/gui/login.cpp | 5 ++--- src/gui/login.h | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 2e9ca57e..3c8e7cb3 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -19,9 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include - #include #include "button.h" @@ -30,8 +27,10 @@ #include "login.h" #include "ok_dialog.h" #include "passwordfield.h" +#include "scrollarea.h" #include "textfield.h" +#include "widgets/dropdown.h" #include "widgets/layout.h" #include "../main.h" diff --git a/src/gui/login.h b/src/gui/login.h index 70f30d5c..023d60aa 100644 --- a/src/gui/login.h +++ b/src/gui/login.h @@ -27,15 +27,13 @@ #include #include +#include -#include "scrollarea.h" #include "window.h" -#include "widgets/dropdown.h" - -#include "../guichanfwd.h" - +class DropDown; class LoginData; +class ScrollArea; /** * The login dialog. @@ -131,7 +129,7 @@ class LoginDialog : public Window, public gcn::ActionListener, }; DropDownList *mServerList; gcn::ListBox *mServerListBox; - ScrollArea *mServerScrollArea; + gcn::ScrollArea *mServerScrollArea; }; -- cgit v1.2.3-70-g09d2 From b64fd3b17bcd3f750851f0213eac43d467de8600 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 22:55:59 -0700 Subject: Fixed a few table events. One prevented wrapping for tables when you are scrolling through the table upward, while the other didn't check upper bounds for rows and columns to see if the event is in the table, but rather just the lower bounds. Signed-off-by: Ira Rice --- src/gui/table.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gui/table.cpp b/src/gui/table.cpp index 3bed48d8..674f3891 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -191,7 +191,7 @@ void GuiTable::setSelectedRow(int selected) } else { - if (selected < 0) + if (selected < 0 && !mWrappingEnabled) { mSelectedRow = -1; } @@ -199,7 +199,8 @@ void GuiTable::setSelectedRow(int selected) { mSelectedRow = 0; } - else if (selected >= mModel->getRows() && !mWrappingEnabled) + else if ((selected >= mModel->getRows() && !mWrappingEnabled) || + (selected < 0 && mWrappingEnabled)) { mSelectedRow = mModel->getRows() - 1; } @@ -218,15 +219,13 @@ void GuiTable::setSelectedColumn(int selected) } else { - if (selected < 0) - { - mSelectedColumn = -1; - } - else if (selected >= mModel->getColumns() && mWrappingEnabled) + if ((selected >= mModel->getColumns() && mWrappingEnabled) || + (selected < 0 && !mWrappingEnabled)) { mSelectedColumn = 0; } - else if (selected >= mModel->getColumns() && !mWrappingEnabled) + else if ((selected >= mModel->getColumns() && !mWrappingEnabled) || + (selected < 0 && mWrappingEnabled)) { mSelectedColumn = mModel->getColumns() - 1; } @@ -445,7 +444,8 @@ void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent) int row = getRowForY(mouseEvent.getY()); int column = getColumnForX(mouseEvent.getX()); - if (row > -1 && column > -1) + if (row > -1 && column > -1 && + row < mModel->getRows() && column < mModel->getColumns()) { mSelectedColumn = column; mSelectedRow = row; @@ -459,7 +459,7 @@ void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) { if (isFocused()) { - if (getSelectedRow() > 0 ) + if (getSelectedRow() >= 0 ) { setSelectedRow(getSelectedRow() - 1); } -- cgit v1.2.3-70-g09d2 From b2972f32eb806f8d3f1acc110f2b8a994c902c2c Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 5 Feb 2009 09:30:52 -0700 Subject: Three things: Split chat and NPC dialog functionality based on the TMW complaint commit d2876ad85935c5d0b181d050bd4c19a4682123b1 (btw, if you're concerned about that, return is also a bad choice for the chat window in general, which overrides the GuiChan default for use widget. Tab would also be a bad choice, as it cycles through the widgets), next, I made the text displayed by the keyboard configuration setup dialog translatable, and lastly, I exposed the rest of the previously unconfigurable keys to be configurable through the keyboard setup tab. Signed-off-by: Ira Rice --- po/POTFILES.in | 1 + src/game.cpp | 110 +++++++++++++++++++++--------------------------- src/keyboardconfig.cpp | 112 +++++++++++++++++++++++++++---------------------- src/keyboardconfig.h | 9 ++++ 4 files changed, 120 insertions(+), 112 deletions(-) (limited to 'src') diff --git a/po/POTFILES.in b/po/POTFILES.in index fa3b2f9f..a70d35d4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -50,5 +50,6 @@ src/resources/monsterdb.cpp src/resources/npcdb.cpp src/being.cpp src/game.cpp +src/keyboardconfig.cpp src/main.cpp src/party.cpp diff --git a/src/game.cpp b/src/game.cpp index 43b3e986..3f6de6af 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -501,55 +501,6 @@ void Game::handleInput() keyboard.setNewKeyIndex(keyboard.KEY_NO_VALUE); return; } - // Keys pressed together with Alt/Meta - // Emotions and some internal gui windows -#ifndef __APPLE__ - if (event.key.keysym.mod & KMOD_LALT) -#else - if (event.key.keysym.mod & KMOD_LMETA) -#endif - { - switch (event.key.keysym.sym) - { - case SDLK_p: - // Screenshot (picture, hence the p) - saveScreenshot(); - used = true; - break; - - default: - break; - - case SDLK_f: - // Find path to mouse (debug purpose) - viewport->toggleDebugPath(); - used = true; - break; - - case SDLK_t: - // Toggle accepting of incoming trade requests - unsigned int deflt = player_relations.getDefault(); - if (deflt & PlayerRelation::TRADE) - { - chatWindow->chatLog( - _("Ignoring incoming trade requests"), - BY_SERVER); - deflt &= ~PlayerRelation::TRADE; - } - else - { - chatWindow->chatLog( - _("Accepting incoming trade requests"), - BY_SERVER); - deflt |= PlayerRelation::TRADE; - } - - player_relations.setDefault(deflt); - - used = true; - break; - } - } // Mode switch to emotes if (keyboard.isKeyActive(keyboard.KEY_EMOTE)) @@ -563,16 +514,18 @@ void Game::handleInput() return; } } - switch (event.key.keysym.sym) + + const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); + switch (tKey) { - case SDLK_PAGEUP: + case KeyboardConfig::KEY_SCROLL_CHAT_UP: if (chatWindow->isVisible()) { chatWindow->scroll(-DEFAULT_CHAT_WINDOW_SCROLL); used = true; } break; - case SDLK_PAGEDOWN: + case KeyboardConfig::KEY_SCROLL_CHAT_DOWN: if (chatWindow->isVisible()) { chatWindow->scroll(DEFAULT_CHAT_WINDOW_SCROLL); @@ -580,7 +533,7 @@ void Game::handleInput() return; } break; - case SDLK_F1: + case KeyboardConfig::KEY_WINDOW_HELP: // In-game Help if (helpWindow->isVisible()) helpWindow->setVisible(false); @@ -592,7 +545,7 @@ void Game::handleInput() used = true; break; - case SDLK_RETURN: + case KeyboardConfig::KEY_TOGGLE_CHAT: // Input chat window if (chatWindow->isInputFocused() || deathNotice != NULL || @@ -610,8 +563,15 @@ void Game::handleInput() // Close the config window, cancelling changes if opened else if (setupWindow->isVisible()) setupWindow->action(gcn::ActionEvent(NULL, "cancel")); + else + { + chatWindow->requestChatFocus(); + used = true; + } + break; + case KeyboardConfig::KEY_OK: // Submits the text and proceeds to the next dialog - else if (npcStringDialog->isVisible()) + if (npcStringDialog->isVisible()) npcStringDialog->action(gcn::ActionEvent(NULL, "ok")); // Proceed to the next dialog option, or close the window else if (npcTextDialog->isVisible()) @@ -622,15 +582,9 @@ void Game::handleInput() // Submits the text and proceeds to the next dialog else if (npcIntegerDialog->isVisible()) npcIntegerDialog->action(gcn::ActionEvent(NULL, "ok")); - // Else, open the chat edit box - else - { - chatWindow->requestChatFocus(); - used = true; - } break; // Quitting confirmation dialog - case SDLK_ESCAPE: + case KeyboardConfig::KEY_QUIT: if (!exitConfirm) { exitConfirm = new ConfirmDialog( _("Quit"), @@ -754,6 +708,38 @@ void Game::handleInput() case KeyboardConfig::KEY_WINDOW_EMOTE_SHORTCUT: requestedWindow = emoteShortcutWindow; break; + case KeyboardConfig::KEY_SCREENSHOT: + // Screenshot (picture, hence the p) + saveScreenshot(); + used = true; + break; + case KeyboardConfig::KEY_PATHFIND: + // Find path to mouse (debug purpose) + viewport->toggleDebugPath(); + used = true; + break; + case KeyboardConfig::KEY_TRADE: + // Toggle accepting of incoming trade requests + unsigned int deflt = player_relations.getDefault(); + if (deflt & PlayerRelation::TRADE) + { + chatWindow->chatLog( + _("Ignoring incoming trade requests"), + BY_SERVER); + deflt &= ~PlayerRelation::TRADE; + } + else + { + chatWindow->chatLog( + _("Accepting incoming trade requests"), + BY_SERVER); + deflt |= PlayerRelation::TRADE; + } + + player_relations.setDefault(deflt); + + used = true; + break; } } diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index d7288796..68d51572 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -27,64 +27,76 @@ #include "gui/setup_keyboard.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" + struct KeyData { const char *configField; int defaultValue; - const char *caption; + std::string caption; }; // keyData must be in same order as enum keyAction. static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = { - {"keyMoveUp", SDLK_UP, "Move Up"}, - {"keyMoveDown", SDLK_DOWN, "Move Down"}, - {"keyMoveLeft", SDLK_LEFT, "Move Left"}, - {"keyMoveRight", SDLK_RIGHT, "Move Right"}, - {"keyAttack", SDLK_LCTRL, "Attack"}, - {"keySmilie", SDLK_LALT, "Smilie"}, - {"keyTalk", SDLK_t, "Talk"}, - {"keyTarget", SDLK_LSHIFT, "Stop Attack"}, - {"keyTargetClosest", SDLK_a, "Target Closest"}, - {"keyTargetNPC", SDLK_n, "Target NPC"}, - {"keyTargetPlayer", SDLK_q, "Target Player"}, - {"keyPickup", SDLK_z, "Pickup"}, - {"keyHideWindows", SDLK_h, "Hide Windows"}, - {"keyBeingSit", SDLK_s, "Sit"}, - {"keyShortcut1", SDLK_1, "Item Shortcut 1"}, - {"keyShortcut2", SDLK_2, "Item Shortcut 2"}, - {"keyShortcut3", SDLK_3, "Item Shortcut 3"}, - {"keyShortcut4", SDLK_4, "Item Shortcut 4"}, - {"keyShortcut5", SDLK_5, "Item Shortcut 5"}, - {"keyShortcut6", SDLK_6, "Item Shortcut 6"}, - {"keyShortcut7", SDLK_7, "Item Shortcut 7"}, - {"keyShortcut8", SDLK_8, "Item Shortcut 8"}, - {"keyShortcut9", SDLK_9, "Item Shortcut 9"}, - {"keyShortcut10", SDLK_0, "Item Shortcut 10"}, - {"keyShortcut11", SDLK_MINUS, "Item Shortcut 11"}, - {"keyShortcut12", SDLK_EQUALS, "Item Shortcut 12"}, - {"keyWindowStatus", SDLK_F2, "Status Window"}, - {"keyWindowInventory", SDLK_F3, "Inventory Window"}, - {"keyWindowEquipment", SDLK_F4, "Equipment WIndow"}, - {"keyWindowSkill", SDLK_F5, "Skill Window"}, - {"keyWindowMinimap", SDLK_F6, "Minimap Window"}, - {"keyWindowChat", SDLK_F7, "Chat Window"}, - {"keyWindowShortcut", SDLK_F8, "Item Shortcut Window"}, - {"keyWindowSetup", SDLK_F9, "Setup Window"}, - {"keyWindowDebug", SDLK_F10, "Debug Window"}, - {"keyWindowEmote", SDLK_F11, "Emote Window"}, - {"keyWindowEmoteBar", SDLK_F12, "Emote Shortcut Window"}, - {"keyEmoteShortcut1", SDLK_1, "Emote Shortcut 1"}, - {"keyEmoteShortcut2", SDLK_2, "Emote Shortcut 2"}, - {"keyEmoteShortcut3", SDLK_3, "Emote Shortcut 3"}, - {"keyEmoteShortcut4", SDLK_4, "Emote Shortcut 4"}, - {"keyEmoteShortcut5", SDLK_5, "Emote Shortcut 5"}, - {"keyEmoteShortcut6", SDLK_6, "Emote Shortcut 6"}, - {"keyEmoteShortcut7", SDLK_7, "Emote Shortcut 7"}, - {"keyEmoteShortcut8", SDLK_8, "Emote Shortcut 8"}, - {"keyEmoteShortcut9", SDLK_9, "Emote Shortcut 9"}, - {"keyEmoteShortcut10", SDLK_0, "Emote Shortcut 10"}, - {"keyEmoteShortcut11", SDLK_MINUS, "Emote Shortcut 11"}, - {"keyEmoteShortcut12", SDLK_EQUALS, "Emote Shortcut 12"} + {"keyMoveUp", SDLK_UP, _("Move Up")}, + {"keyMoveDown", SDLK_DOWN, _("Move Down")}, + {"keyMoveLeft", SDLK_LEFT, _("Move Left")}, + {"keyMoveRight", SDLK_RIGHT, _("Move Right")}, + {"keyAttack", SDLK_LCTRL, _("Attack")}, + {"keySmilie", SDLK_LALT, _("Smilie")}, + {"keyTalk", SDLK_t, _("Talk")}, + {"keyTarget", SDLK_LSHIFT, _("Stop Attack")}, + {"keyTargetClosest", SDLK_a, _("Target Closest")}, + {"keyTargetNPC", SDLK_n, _("Target NPC")}, + {"keyTargetPlayer", SDLK_q, _("Target Player")}, + {"keyPickup", SDLK_z, _("Pickup")}, + {"keyHideWindows", SDLK_h, _("Hide Windows")}, + {"keyBeingSit", SDLK_s, _("Sit")}, + {"keyScreenshot", SDLK_p, _("Screenshot")}, + {"keyTrade", SDLK_r, _("Enable/Disable Trading")}, + {"keyPathfind", SDLK_f, _("Find Path to Mouse")}, + {"keyShortcut1", SDLK_1, strprintf(_("Item Shortcut %d"), 1)}, + {"keyShortcut2", SDLK_2, strprintf(_("Item Shortcut %d"), 2)}, + {"keyShortcut3", SDLK_3, strprintf(_("Item Shortcut %d"), 3)}, + {"keyShortcut4", SDLK_4, strprintf(_("Item Shortcut %d"), 4)}, + {"keyShortcut5", SDLK_5, strprintf(_("Item Shortcut %d"), 5)}, + {"keyShortcut6", SDLK_6, strprintf(_("Item Shortcut %d"), 6)}, + {"keyShortcut7", SDLK_7, strprintf(_("Item Shortcut %d"), 7)}, + {"keyShortcut8", SDLK_8, strprintf(_("Item Shortcut %d"), 8)}, + {"keyShortcut9", SDLK_9, strprintf(_("Item Shortcut %d"), 9)}, + {"keyShortcut10", SDLK_0, strprintf(_("Item Shortcut %d"), 10)}, + {"keyShortcut11", SDLK_MINUS, strprintf(_("Item Shortcut %d"), 11)}, + {"keyShortcut12", SDLK_EQUALS, strprintf(_("Item Shortcut %d"), 12)}, + {"keyWindowHelp", SDLK_F1, _("Help Window")}, + {"keyWindowStatus", SDLK_F2, _("Status Window")}, + {"keyWindowInventory", SDLK_F3, _("Inventory Window")}, + {"keyWindowEquipment", SDLK_F4, _("Equipment WIndow")}, + {"keyWindowSkill", SDLK_F5, _("Skill Window")}, + {"keyWindowMinimap", SDLK_F6, _("Minimap Window")}, + {"keyWindowChat", SDLK_F7, _("Chat Window")}, + {"keyWindowShortcut", SDLK_F8, _("Item Shortcut Window")}, + {"keyWindowSetup", SDLK_F9, _("Setup Window")}, + {"keyWindowDebug", SDLK_F10, _("Debug Window")}, + {"keyWindowEmote", SDLK_F11, _("Emote Window")}, + {"keyWindowEmoteBar", SDLK_F12, _("Emote Shortcut Window")}, + {"keyEmoteShortcut1", SDLK_1, strprintf(_("Emote Shortcut %d"), 1)}, + {"keyEmoteShortcut2", SDLK_2, strprintf(_("Emote Shortcut %d"), 2)}, + {"keyEmoteShortcut3", SDLK_3, strprintf(_("Emote Shortcut %d"), 3)}, + {"keyEmoteShortcut4", SDLK_4, strprintf(_("Emote Shortcut %d"), 4)}, + {"keyEmoteShortcut5", SDLK_5, strprintf(_("Emote Shortcut %d"), 5)}, + {"keyEmoteShortcut6", SDLK_6, strprintf(_("Emote Shortcut %d"), 6)}, + {"keyEmoteShortcut7", SDLK_7, strprintf(_("Emote Shortcut %d"), 7)}, + {"keyEmoteShortcut8", SDLK_8, strprintf(_("Emote Shortcut %d"), 8)}, + {"keyEmoteShortcut9", SDLK_9, strprintf(_("Emote Shortcut %d"), 9)}, + {"keyEmoteShortcut10", SDLK_0, strprintf(_("Emote Shortcut %d"), 10)}, + {"keyEmoteShortcut11", SDLK_MINUS, strprintf(_("Emote Shortcut %d"), 11)}, + {"keyEmoteShortcut12", SDLK_EQUALS, strprintf(_("Emote Shortcut %d"), 12)}, + {"keyChat", SDLK_RETURN, _("Toggle Chat")}, + {"keyChatScrollUp", SDLK_PAGEUP, _("Scroll Chat Up")}, + {"keyChatScrollDown", SDLK_PAGEDOWN, _("Scroll Chat Down")}, + {"keyOK", SDLK_SPACE, _("Select OK")}, + {"keyQuit", SDLK_ESCAPE, _("Quit")} }; void KeyboardConfig::init() diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h index 2077126d..ba8039bf 100644 --- a/src/keyboardconfig.h +++ b/src/keyboardconfig.h @@ -164,6 +164,9 @@ class KeyboardConfig KEY_PICKUP, KEY_HIDE_WINDOWS, KEY_SIT, + KEY_SCREENSHOT, + KEY_TRADE, + KEY_PATHFIND, KEY_SHORTCUT_1, KEY_SHORTCUT_2, KEY_SHORTCUT_3, @@ -176,6 +179,7 @@ class KeyboardConfig KEY_SHORTCUT_10, KEY_SHORTCUT_11, KEY_SHORTCUT_12, + KEY_WINDOW_HELP, KEY_WINDOW_STATUS, KEY_WINDOW_INVENTORY, KEY_WINDOW_EQUIPMENT, @@ -199,6 +203,11 @@ class KeyboardConfig KEY_EMOTE_10, KEY_EMOTE_11, KEY_EMOTE_12, + KEY_TOGGLE_CHAT, + KEY_SCROLL_CHAT_UP, + KEY_SCROLL_CHAT_DOWN, + KEY_OK, + KEY_QUIT, KEY_TOTAL }; -- cgit v1.2.3-70-g09d2 From 34f27b882cf63ca4dfda6079253adb959ebaeadd Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 5 Feb 2009 11:44:31 -0700 Subject: Rather than to settle for a broken default (if it's left at space, then you won't be able to type spaces in the NPC integer or string dialogs. And no, assigning focus to the ok button doesn't resolve anything, but makes things worse, as then the user has to click on the input field to input text, then must click the ok button, as the chat window already overrode it's confirmation action), this commit allows for both the chat input and the NPC dialog confirming to share the same key, but allows for people to change one or the other if they want to. This will still allow for the player to use the keyboard fully for NPC dialogs, but allow for people who don't like not being able to use chat with an NPC dialog open to assign confirmation to another key and get their way as well. This is a rather ugly way of resolving both sides of the issue, but it's the only way to appease both sides. The Aethyra players want things the way they were, while Bjorn wanted things a different way. Signed-off-by: Ira Rice --- src/game.cpp | 91 ++++++++++++++++++++++++++++---------------------- src/keyboardconfig.cpp | 9 ++--- 2 files changed, 56 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index 3f6de6af..7c038074 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -515,6 +515,57 @@ void Game::handleInput() } } + if (keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT)) + { + // Input chat window + if (!(chatWindow->isInputFocused() || + deathNotice != NULL || + weightNotice != NULL)) + { + // Quit by pressing Enter if the exit confirm is there + if (exitConfirm) + done = true; + // Close the Browser if opened + else if (helpWindow->isVisible()) + helpWindow->setVisible(false); + // Close the config window, cancelling changes if opened + else if (setupWindow->isVisible()) + setupWindow->action(gcn::ActionEvent(NULL, "cancel")); + else if (!(keyboard.getKeyValue( + KeyboardConfig::KEY_TOGGLE_CHAT) == + keyboard.getKeyValue( + KeyboardConfig::KEY_OK) && + (npcStringDialog->isVisible() || + npcTextDialog->isVisible() || + npcListDialog->isVisible() || + npcIntegerDialog->isVisible()))) + { + chatWindow->requestChatFocus(); + used = true; + } + } + } + + if (keyboard.isKeyActive(keyboard.KEY_OK)) + { + if (!(exitConfirm || helpWindow->isVisible() || + setupWindow->isVisible())) + { + // Submits the text and proceeds to the next dialog + if (npcStringDialog->isVisible()) + npcStringDialog->action(gcn::ActionEvent(NULL, "ok")); + // Proceed to the next dialog option, or close the window + else if (npcTextDialog->isVisible()) + npcTextDialog->action(gcn::ActionEvent(NULL, "ok")); + // Choose the currently highlighted dialogue option + else if (npcListDialog->isVisible()) + npcListDialog->action(gcn::ActionEvent(NULL, "ok")); + // Submits the text and proceeds to the next dialog + else if (npcIntegerDialog->isVisible()) + npcIntegerDialog->action(gcn::ActionEvent(NULL, "ok")); + } + } + const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); switch (tKey) { @@ -544,45 +595,6 @@ void Game::handleInput() } used = true; break; - - case KeyboardConfig::KEY_TOGGLE_CHAT: - // Input chat window - if (chatWindow->isInputFocused() || - deathNotice != NULL || - weightNotice != NULL) - { - break; - } - - // Quit by pressing Enter if the exit confirm is there - if (exitConfirm) - done = true; - // Close the Browser if opened - else if (helpWindow->isVisible()) - helpWindow->setVisible(false); - // Close the config window, cancelling changes if opened - else if (setupWindow->isVisible()) - setupWindow->action(gcn::ActionEvent(NULL, "cancel")); - else - { - chatWindow->requestChatFocus(); - used = true; - } - break; - case KeyboardConfig::KEY_OK: - // Submits the text and proceeds to the next dialog - if (npcStringDialog->isVisible()) - npcStringDialog->action(gcn::ActionEvent(NULL, "ok")); - // Proceed to the next dialog option, or close the window - else if (npcTextDialog->isVisible()) - npcTextDialog->action(gcn::ActionEvent(NULL, "ok")); - // Choose the currently highlighted dialogue option - else if (npcListDialog->isVisible()) - npcListDialog->action(gcn::ActionEvent(NULL, "ok")); - // Submits the text and proceeds to the next dialog - else if (npcIntegerDialog->isVisible()) - npcIntegerDialog->action(gcn::ActionEvent(NULL, "ok")); - break; // Quitting confirmation dialog case KeyboardConfig::KEY_QUIT: if (!exitConfirm) @@ -598,7 +610,6 @@ void Game::handleInput() exitConfirm->action(gcn::ActionEvent(NULL, _("no"))); } break; - default: break; } diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index 68d51572..745a81db 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -95,7 +95,7 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = { {"keyChat", SDLK_RETURN, _("Toggle Chat")}, {"keyChatScrollUp", SDLK_PAGEUP, _("Scroll Chat Up")}, {"keyChatScrollDown", SDLK_PAGEDOWN, _("Scroll Chat Down")}, - {"keyOK", SDLK_SPACE, _("Select OK")}, + {"keyOK", SDLK_RETURN, _("Select OK")}, {"keyQuit", SDLK_ESCAPE, _("Quit")} }; @@ -151,9 +151,10 @@ bool KeyboardConfig::hasConflicts() for (j = i, j++; j < KEY_TOTAL; j++) { // Allow for item shortcut and emote keys to overlap, but no other keys - if (!(((i >= KEY_SHORTCUT_1) && (i <= KEY_SHORTCUT_12)) && - ((j >= KEY_EMOTE_1) && (j <= KEY_EMOTE_12))) - && mKey[i].value == mKey[j].value + if (!((((i >= KEY_SHORTCUT_1) && (i <= KEY_SHORTCUT_12)) && + ((j >= KEY_EMOTE_1) && (j <= KEY_EMOTE_12))) || + ((i == KEY_TOGGLE_CHAT) && (j == KEY_OK))) && + (mKey[i].value == mKey[j].value) ) { return true; -- cgit v1.2.3-70-g09d2 From 9146b4bff88d2622907b7e9bba618ad9b12da7ce Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 5 Feb 2009 12:19:31 -0700 Subject: Modified the Colors setup pane to take as much space as it can. I left it minimal in the first place so that it could be redone as a theme window in the future, but there's no reason it should be as spread out as it was until it has been made into one. Signed-off-by: Ira Rice --- src/gui/setup_colours.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/gui/setup_colours.cpp b/src/gui/setup_colours.cpp index 07ec9086..695c3f74 100644 --- a/src/gui/setup_colours.cpp +++ b/src/gui/setup_colours.cpp @@ -58,7 +58,7 @@ Setup_Colours::Setup_Colours() : mRedText->addListener(this); mRedSlider = new Slider(0, 255); - mRedSlider->setWidth(90); + mRedSlider->setWidth(160); mRedSlider->setValue(mRedText->getValue()); mRedSlider->setActionEventId("slider_red"); mRedSlider->addActionListener(this); @@ -72,7 +72,7 @@ Setup_Colours::Setup_Colours() : mGreenText->addListener(this); mGreenSlider = new Slider(0, 255); - mGreenSlider->setWidth(90); + mGreenSlider->setWidth(160); mGreenSlider->setValue(mGreenText->getValue()); mGreenSlider->setActionEventId("slider_green"); mGreenSlider->addActionListener(this); @@ -86,7 +86,7 @@ Setup_Colours::Setup_Colours() : mBlueText->addListener(this); mBlueSlider = new Slider(0, 255); - mBlueSlider->setWidth(90); + mBlueSlider->setWidth(160); mBlueSlider->setValue(mBlueText->getValue()); mBlueSlider->setActionEventId("slider_blue"); mBlueSlider->addActionListener(this); @@ -97,18 +97,18 @@ Setup_Colours::Setup_Colours() : LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mScroll, 1, 3).setPadding(2); - place(1, 0, mRedLabel, 2); - place(3, 0, mRedSlider); - place(4, 0, mRedText).setPadding(1); - place(1, 1, mGreenLabel, 2); - place(3, 1, mGreenSlider); - place(4, 1, mGreenText).setPadding(1); - place(1, 2, mBlueLabel, 2); - place(3, 2, mBlueSlider); - place(4, 2, mBlueText).setPadding(1); - - setDimension(gcn::Rectangle(0, 0, 290, 150)); + place(0, 0, mScroll, 4, 3).setPadding(2); + place(0, 3, mRedLabel, 2); + place(2, 3, mRedSlider); + place(3, 3, mRedText).setPadding(1); + place(0, 4, mGreenLabel, 2); + place(2, 4, mGreenSlider); + place(3, 4, mGreenText).setPadding(1); + place(0, 5, mBlueLabel, 2); + place(2, 5, mBlueSlider); + place(3, 5, mBlueText).setPadding(1); + + setDimension(gcn::Rectangle(0, 0, 290, 250)); } Setup_Colours::~Setup_Colours() -- cgit v1.2.3-70-g09d2 From a05c3bbbae4fcb2fd353a9ba972e7caa7b8e566e Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 5 Feb 2009 12:35:32 -0700 Subject: Fixed the keyboard dialog list selection from cutting off before the scrollbar. Signed-off-by: Ira Rice --- src/gui/setup_colours.cpp | 1 - src/gui/setup_keyboard.cpp | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/setup_colours.cpp b/src/gui/setup_colours.cpp index 695c3f74..d0ab426a 100644 --- a/src/gui/setup_colours.cpp +++ b/src/gui/setup_colours.cpp @@ -47,7 +47,6 @@ Setup_Colours::Setup_Colours() : mScroll = new ScrollArea(mColourBox); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mScroll->setWidth(90); mRedLabel = new gcn::Label(_("Red: ")); diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index 7ff2ea7f..6a4363fe 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -78,11 +78,10 @@ Setup_Keyboard::Setup_Keyboard(): refreshKeys(); - mKeyList->setDimension(gcn::Rectangle(0, 0, 185, 140)); mKeyList->addActionListener(this); - mKeyList->setSelected(-1); ScrollArea *scrollArea = new ScrollArea(mKeyList); + scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mAssignKeyButton = new Button(_("Assign"), "assign", this); mAssignKeyButton->addActionListener(this); -- cgit v1.2.3-70-g09d2 From 3f84a6df4d205f3f81e5460850fd3156243d05ed Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 5 Feb 2009 13:01:59 -0700 Subject: Reduced the required checks slightly by handling the chat key and ok key together. Signed-off-by: Ira Rice --- src/game.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index 7c038074..542c8396 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -515,7 +515,8 @@ void Game::handleInput() } } - if (keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT)) + if (keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT) || + keyboard.isKeyActive(keyboard.KEY_OK)) { // Input chat window if (!(chatWindow->isInputFocused() || @@ -543,16 +544,8 @@ void Game::handleInput() chatWindow->requestChatFocus(); used = true; } - } - } - - if (keyboard.isKeyActive(keyboard.KEY_OK)) - { - if (!(exitConfirm || helpWindow->isVisible() || - setupWindow->isVisible())) - { // Submits the text and proceeds to the next dialog - if (npcStringDialog->isVisible()) + else if (npcStringDialog->isVisible()) npcStringDialog->action(gcn::ActionEvent(NULL, "ok")); // Proceed to the next dialog option, or close the window else if (npcTextDialog->isVisible()) -- cgit v1.2.3-70-g09d2 From 5569b5ff92c022c901f27a2e9c563e2ace66557d Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 5 Feb 2009 13:10:06 -0700 Subject: Added a few translation strings to the char server handler, as well as remove the need for extensions.h in it. Signed-off-by: Ira Rice --- po/POTFILES.in | 1 + src/net/charserverhandler.cpp | 57 +++++++++++-------------------------------- 2 files changed, 15 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/po/POTFILES.in b/po/POTFILES.in index a70d35d4..fcda80d4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -41,6 +41,7 @@ src/gui/speechbubble.cpp src/gui/status.cpp src/gui/trade.cpp src/gui/updatewindow.cpp +src/net/charserverhandler.cpp src/net/playerhandler.cpp src/net/tradehandler.cpp src/resources/colordb.cpp diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index bd3685f3..345b8960 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -23,7 +23,6 @@ #include "messagein.h" #include "protocol.h" -#include "../extensions.h" #include "../game.h" #include "../localplayer.h" #include "../log.h" @@ -33,13 +32,9 @@ #include "../gui/char_select.h" #include "../gui/ok_dialog.h" +#include "../utils/gettext.h" #include "../utils/tostring.h" -/* - * Yeah, this is a global. Get over it. - */ -struct EXTENSIONS extensions; - CharServerHandler::CharServerHandler(): mCharCreateDialog(0) { @@ -72,61 +67,37 @@ void CharServerHandler::handleMessage(MessageIn *msg) switch (code) { case 0: - errorMessage = "Authentication failed"; + errorMessage = _("Authentication failed"); break; case 1: - errorMessage = "Map server(s) offline"; + errorMessage = _("Map server(s) offline"); break; case 2: - errorMessage = "This account is already logged in"; + errorMessage = _("This account is already logged in"); break; case 3: - errorMessage = "Speed hack detected"; + errorMessage = _("Speed hack detected"); break; case 8: - errorMessage = "Duplicated login"; + errorMessage = _("Duplicated login"); break; default: - errorMessage = "Unknown connection error"; + errorMessage = _("Unknown connection error"); break; } state = ERROR_STATE; break; - case 0x006b: - msg->skip(2); // Length word - flags = msg->readInt32(); // Aethyra extensions flags - logger->log("Server flags are: %x", flags); - extensions.aethyra_inventory = (bool)(flags & 0x01); - extensions.aethyra_spells = (bool)(flags & 0x02); - extensions.aethyra_misc = (bool)(flags & 0x04); - msg->skip(16); // Unused - - // Derive number of characters from message length - n_character = (msg->getLength() - 24) / 106; - - for (int i = 0; i < n_character; i++) - { - tempPlayer = readPlayerData(*msg, slot); - mCharInfo->select(slot); - mCharInfo->setEntry(tempPlayer); - logger->log("CharServer: Player: %s (%d)", - tempPlayer->getName().c_str(), slot); - } - - state = CHAR_SELECT_STATE; - break; - case 0x006c: switch (msg->readInt8()) { case 0: - errorMessage = "Access denied"; + errorMessage = _("Access denied"); break; case 1: - errorMessage = "Cannot use this ID"; + errorMessage = _("Cannot use this ID"); break; default: - errorMessage = "Unknown failure to select character"; + errorMessage = _("Unknown failure to select character"); break; } mCharInfo->unlock(); @@ -148,8 +119,8 @@ void CharServerHandler::handleMessage(MessageIn *msg) break; case 0x006e: - new OkDialog("Error", "Failed to create character. Most likely" - " the name is already taken."); + new OkDialog(_("Error"), _("Failed to create character. Most likely" + " the name is already taken.")); if (mCharCreateDialog) mCharCreateDialog->unlock(); @@ -160,12 +131,12 @@ void CharServerHandler::handleMessage(MessageIn *msg) mCharInfo->setEntry(0); mCharInfo->unlock(); n_character--; - new OkDialog("Info", "Player deleted"); + new OkDialog(_("Info"), _("Player deleted")); break; case 0x0070: mCharInfo->unlock(); - new OkDialog("Error", "Failed to delete character."); + new OkDialog(_("Error"), _("Failed to delete character.")); break; case 0x0071: -- cgit v1.2.3-70-g09d2 From 69d6f5fce3ee7ac1888c537e8e222431f8fc45da Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 5 Feb 2009 13:26:02 -0700 Subject: Put back the 0x06b packet, which apparently our server uses. Will investigate why we use it and what this packet is meant to do. Signed-off-by: Ira Rice --- src/net/charserverhandler.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src') diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index 345b8960..932cf705 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -88,6 +88,27 @@ void CharServerHandler::handleMessage(MessageIn *msg) state = ERROR_STATE; break; + case 0x006b: + msg->skip(2); // Length word + flags = msg->readInt32(); // Aethyra extensions flags + logger->log("Server flags are: %x", flags); + msg->skip(16); // Unused + + // Derive number of characters from message length + n_character = (msg->getLength() - 24) / 106; + + for (int i = 0; i < n_character; i++) + { + tempPlayer = readPlayerData(*msg, slot); + mCharInfo->select(slot); + mCharInfo->setEntry(tempPlayer); + logger->log("CharServer: Player: %s (%d)", + tempPlayer->getName().c_str(), slot); + } + + state = CHAR_SELECT_STATE; + break; + case 0x006c: switch (msg->readInt8()) { case 0: -- cgit v1.2.3-70-g09d2 From f001a53b494e8b357eba6f7c0cad9afe3258dda8 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 5 Feb 2009 14:19:44 -0700 Subject: Exposed some more strings I found to be translatable. Signed-off-by: Ira Rice --- po/POTFILES.in | 6 ++++++ src/net/buysellhandler.cpp | 12 +++++++----- src/net/chathandler.cpp | 5 +++-- src/net/equipmenthandler.cpp | 6 ++++-- src/net/inventoryhandler.cpp | 10 ++++++---- src/net/loginhandler.cpp | 32 +++++++++++++++++++------------- src/net/maploginhandler.cpp | 8 +++++--- 7 files changed, 50 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/po/POTFILES.in b/po/POTFILES.in index fcda80d4..295a6127 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -41,7 +41,13 @@ src/gui/speechbubble.cpp src/gui/status.cpp src/gui/trade.cpp src/gui/updatewindow.cpp +src/net/buysellhandler.cpp src/net/charserverhandler.cpp +src/net/chathandler.cpp +src/net/equipmenthandler.cpp +src/net/inventoryhandler.cpp +src/net/loginhandler.cpp +src/net/maploginhandler.cpp src/net/playerhandler.cpp src/net/tradehandler.cpp src/resources/colordb.cpp diff --git a/src/net/buysellhandler.cpp b/src/net/buysellhandler.cpp index 5292b6f9..67c79ec4 100644 --- a/src/net/buysellhandler.cpp +++ b/src/net/buysellhandler.cpp @@ -35,6 +35,8 @@ #include "../gui/chat.h" #include "../gui/sell.h" +#include "../utils/gettext.h" + extern BuyDialog *buyDialog; extern Window *buySellDialog; extern SellDialog *sellDialog; @@ -104,27 +106,27 @@ void BuySellHandler::handleMessage(MessageIn *msg) } } else { - chatWindow->chatLog("Nothing to sell", BY_SERVER); + chatWindow->chatLog(_("Nothing to sell"), BY_SERVER); current_npc = 0; } break; case SMSG_NPC_BUY_RESPONSE: if (msg->readInt8() == 0) { - chatWindow->chatLog("Thanks for buying", BY_SERVER); + chatWindow->chatLog(_("Thanks for buying"), BY_SERVER); } else { // Reset player money since buy dialog already assumed purchase // would go fine buyDialog->setMoney(player_node->mGp); - chatWindow->chatLog("Unable to buy", BY_SERVER); + chatWindow->chatLog(_("Unable to buy"), BY_SERVER); } break; case SMSG_NPC_SELL_RESPONSE: if (msg->readInt8() == 0) { - chatWindow->chatLog("Thanks for selling", BY_SERVER); + chatWindow->chatLog(_("Thanks for selling"), BY_SERVER); } else { - chatWindow->chatLog("Unable to sell", BY_SERVER); + chatWindow->chatLog(_("Unable to sell"), BY_SERVER); } break; } diff --git a/src/net/chathandler.cpp b/src/net/chathandler.cpp index bf5a5a37..25877907 100644 --- a/src/net/chathandler.cpp +++ b/src/net/chathandler.cpp @@ -33,6 +33,7 @@ #include "../gui/chat.h" +#include "../utils/gettext.h" #include "../utils/tostring.h" #include "../utils/trim.h" @@ -72,10 +73,10 @@ void ChatHandler::handleMessage(MessageIn *msg) //chatWindow->chatLog("Whisper sent", BY_SERVER); break; case 0x01: - chatWindow->chatLog("Whisper could not be sent, user is offline", BY_SERVER); + chatWindow->chatLog(_("Whisper could not be sent, user is offline"), BY_SERVER); break; case 0x02: - chatWindow->chatLog("Whisper could not be sent, ignored by user", BY_SERVER); + chatWindow->chatLog(_("Whisper could not be sent, ignored by user"), BY_SERVER); break; } break; diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp index 973de0f6..319d1205 100644 --- a/src/net/equipmenthandler.cpp +++ b/src/net/equipmenthandler.cpp @@ -32,6 +32,8 @@ #include "../gui/chat.h" +#include "../utils/gettext.h" + EquipmentHandler::EquipmentHandler() { static const Uint16 _messages[] = { @@ -97,7 +99,7 @@ void EquipmentHandler::handleMessage(MessageIn *msg) logger->log("Equipping: %i %i %i", index, equipPoint, type); if (!type) { - chatWindow->chatLog("Unable to equip.", BY_SERVER); + chatWindow->chatLog(_("Unable to equip."), BY_SERVER); break; } @@ -135,7 +137,7 @@ void EquipmentHandler::handleMessage(MessageIn *msg) type = msg->readInt8(); if (!type) { - chatWindow->chatLog("Unable to unequip.", BY_SERVER); + chatWindow->chatLog(_("Unable to unequip."), BY_SERVER); break; } diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp index 3ce0899a..46f03e28 100644 --- a/src/net/inventoryhandler.cpp +++ b/src/net/inventoryhandler.cpp @@ -35,6 +35,8 @@ #include "../resources/iteminfo.h" +#include "../utils/gettext.h" +#include "../utils/strprintf.h" #include "../utils/tostring.h" InventoryHandler::InventoryHandler() @@ -139,13 +141,13 @@ void InventoryHandler::handleMessage(MessageIn *msg) itemType = msg->readInt8(); if (msg->readInt8() > 0) { - chatWindow->chatLog("Unable to pick up item", BY_SERVER); + chatWindow->chatLog(_("Unable to pick up item"), BY_SERVER); } else { const ItemInfo &itemInfo = ItemDB::get(itemId); const std::string amountStr = (amount > 1) ? toString(amount) : "a"; - chatWindow->chatLog("You picked up " + amountStr + " " + - itemInfo.getName(), BY_SERVER); + chatWindow->chatLog(strprintf(_("You picked up %s %s"), + amountStr.c_str(), itemInfo.getName().c_str()), BY_SERVER); if (Item *item = inventory->getItem(index)) { item->setId(itemId); @@ -182,7 +184,7 @@ void InventoryHandler::handleMessage(MessageIn *msg) amount = msg->readInt16(); if (msg->readInt8() == 0) { - chatWindow->chatLog("Failed to use item", BY_SERVER); + chatWindow->chatLog(_("Failed to use item"), BY_SERVER); } else { if (Item *item = inventory->getItem(index)) item->setQuantity(amount); diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index 6ad410ec..4f5f2acc 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -28,6 +28,8 @@ #include "../main.h" #include "../serverinfo.h" +#include "../utils/gettext.h" +#include "../utils/strprintf.h" #include "../utils/tostring.h" extern SERVER_INFO **server_info; @@ -56,16 +58,16 @@ void LoginHandler::handleMessage(MessageIn *msg) switch (code) { case 0: - errorMessage = "Authentication failed"; + errorMessage = _("Authentication failed"); break; case 1: - errorMessage = "No servers available"; + errorMessage = _("No servers available"); break; case 2: - errorMessage = "This account is already logged in"; + errorMessage = _("This account is already logged in"); break; default: - errorMessage = "Unknown connection error"; + errorMessage = _("Unknown connection error"); break; } state = ERROR_STATE; @@ -120,30 +122,34 @@ void LoginHandler::handleMessage(MessageIn *msg) switch (code) { case 0: - errorMessage = "Unregistered ID"; + errorMessage = _("Unregistered ID"); break; case 1: - errorMessage = "Wrong password"; + errorMessage = _("Wrong password"); break; case 2: - errorMessage = "Account expired"; + errorMessage = _("Account expired"); break; case 3: - errorMessage = "Rejected from server"; + errorMessage = _("Rejected from server"); break; case 4: - errorMessage = "You have been permanently banned from the game. Please contact the GM Team"; + errorMessage = _("You have been permanently banned from the" + " game. Please contact the GM Team"); break; case 6: - errorMessage = "You have been temporarily banned from the game until " - + msg->readString(20) + ".\n Please contact the GM team via the forums"; + errorMessage = strprintf(_("You have been temporarily " + "banned from the game until %s.\n" + " Please contact the GM team via " + "the forums"), + msg->readString(20).c_str()); break; case 9: - errorMessage = "This user name is already taken"; + errorMessage = _("This user name is already taken"); break; default: - errorMessage = "Unknown error"; + errorMessage = _("Unknown error"); break; } state = ERROR_STATE; diff --git a/src/net/maploginhandler.cpp b/src/net/maploginhandler.cpp index b851117e..b5192bd7 100644 --- a/src/net/maploginhandler.cpp +++ b/src/net/maploginhandler.cpp @@ -27,6 +27,8 @@ #include "../log.h" #include "../main.h" +#include "../utils/gettext.h" + MapLoginHandler::MapLoginHandler() { static const Uint16 _messages[] = { @@ -50,13 +52,13 @@ void MapLoginHandler::handleMessage(MessageIn *msg) switch (code) { case 0: - errorMessage = "Authentication failed"; + errorMessage = _("Authentication failed"); break; case 2: - errorMessage = "This account is already logged in"; + errorMessage = _("This account is already logged in"); break; default: - errorMessage = "Unknown connection error"; + errorMessage = _("Unknown connection error"); break; } state = ERROR_STATE; -- cgit v1.2.3-70-g09d2 From d4ff6679427caad730b4caee51f2ddad083cb818 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 5 Feb 2009 14:25:15 -0700 Subject: Forgot to check which key called the keyboard event for the ok or chat toggling. Signed-off-by: Ira Rice --- src/game.cpp | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index 542c8396..28c29874 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -524,14 +524,33 @@ void Game::handleInput() weightNotice != NULL)) { // Quit by pressing Enter if the exit confirm is there - if (exitConfirm) + if (exitConfirm && + keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT)) done = true; // Close the Browser if opened - else if (helpWindow->isVisible()) + else if (helpWindow->isVisible() && + keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT)) helpWindow->setVisible(false); // Close the config window, cancelling changes if opened - else if (setupWindow->isVisible()) + else if (setupWindow->isVisible() && + keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT)) setupWindow->action(gcn::ActionEvent(NULL, "cancel")); + // Submits the text and proceeds to the next dialog + else if (npcStringDialog->isVisible() && + keyboard.isKeyActive(keyboard.KEY_OK)) + npcStringDialog->action(gcn::ActionEvent(NULL, "ok")); + // Proceed to the next dialog option, or close the window + else if (npcTextDialog->isVisible() && + keyboard.isKeyActive(keyboard.KEY_OK)) + npcTextDialog->action(gcn::ActionEvent(NULL, "ok")); + // Choose the currently highlighted dialogue option + else if (npcListDialog->isVisible() && + keyboard.isKeyActive(keyboard.KEY_OK)) + npcListDialog->action(gcn::ActionEvent(NULL, "ok")); + // Submits the text and proceeds to the next dialog + else if (npcIntegerDialog->isVisible() && + keyboard.isKeyActive(keyboard.KEY_OK)) + npcIntegerDialog->action(gcn::ActionEvent(NULL, "ok")); else if (!(keyboard.getKeyValue( KeyboardConfig::KEY_TOGGLE_CHAT) == keyboard.getKeyValue( @@ -544,18 +563,6 @@ void Game::handleInput() chatWindow->requestChatFocus(); used = true; } - // Submits the text and proceeds to the next dialog - else if (npcStringDialog->isVisible()) - npcStringDialog->action(gcn::ActionEvent(NULL, "ok")); - // Proceed to the next dialog option, or close the window - else if (npcTextDialog->isVisible()) - npcTextDialog->action(gcn::ActionEvent(NULL, "ok")); - // Choose the currently highlighted dialogue option - else if (npcListDialog->isVisible()) - npcListDialog->action(gcn::ActionEvent(NULL, "ok")); - // Submits the text and proceeds to the next dialog - else if (npcIntegerDialog->isVisible()) - npcIntegerDialog->action(gcn::ActionEvent(NULL, "ok")); } } -- cgit v1.2.3-70-g09d2 From f0d6cd5a97593003fcca3c800ede409f6c55344c Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 6 Feb 2009 08:58:58 -0700 Subject: While this is not the ideal solution to the link problem, this commit at least ensures that the link will be in the correct location. Should work to fix things until a proper rewrite is figured out. Signed-off-by: Ira Rice --- src/gui/browserbox.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index c51852bb..ecc22e5f 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -276,6 +276,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) int x = 0, y = 0; int wrappedLines = 0; + int link = 0; TrueTypeFont *font = static_cast(getFont()); graphics->setColor(BLACK); @@ -333,6 +334,12 @@ void BrowserBox::draw(gcn::Graphics *graphics) int rgb = textColour->getColour(c, valid); if (c == '<') { + const int size = mLinks[link].x2 - mLinks[link].x1; + mLinks[link].x1 = x; + mLinks[link].y1 = y; + mLinks[link].x2 = mLinks[link].x1 + size; + mLinks[link].y2 = y + font->getHeight(); + link++; prevColor = selColor; } if (valid) -- cgit v1.2.3-70-g09d2 From 1458c6b808afaf3af2f1f50f1988427edf64826c Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 6 Feb 2009 17:38:12 -0700 Subject: Sanitized item links so that at no point is the internal representation of the item link shown. This should help make it easier for people to represent the square brackets with item links, and prevent people from forging item links when they never see the internal representation of an item link. Should also reduce confusion from people who haven't upgraded their clients as well, as they wonder what all the junk is around the item name. Signed-off-by: Ira Rice --- src/gui/chat.cpp | 4 ++-- src/gui/chat.h | 2 +- src/gui/popupmenu.cpp | 21 ++++++++++----------- 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index f4d9763b..b53552a6 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -735,10 +735,10 @@ void ChatWindow::setInputText(std::string input_str) requestChatFocus(); } -void ChatWindow::addItemText(int itemId, const std::string &item) +void ChatWindow::addItemText(const std::string &item) { std::ostringstream text; - text << "[@@" << itemId << "|" << item << "@@] "; + text << "[" << item << "] "; mChatInput->setText(mChatInput->getText() + text.str()); requestChatFocus(); } diff --git a/src/gui/chat.h b/src/gui/chat.h index 872c0041..2fadb014 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -179,7 +179,7 @@ class ChatWindow : public Window, public gcn::ActionListener, void setInputText(std::string input_str); /** Called to add item to chat */ - void addItemText(int itemid, const std::string &item); + void addItemText(const std::string &item); /** Override to reset mTmpVisible */ void setVisible(bool visible); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index cf6a7188..6c0e6ad6 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -75,27 +75,27 @@ void PopupMenu::showPopup(int x, int y, Being *being) // Players can be traded with. Later also attack, follow and // add as buddy will be options in this menu. const std::string &name = mBeing->getName(); - mBrowserBox->addRow(_("@@trade|Trade With ") + name + "@@"); - mBrowserBox->addRow(_("@@attack|Attack ") + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@trade|Trade With %s@@"), name.c_str())); + mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); mBrowserBox->addRow("##3---"); switch (player_relations.getRelation(name)) { case PlayerRelation::NEUTRAL: - mBrowserBox->addRow(_("@@friend|Befriend ") + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@friend|Befriend %s@@"), name.c_str())); case PlayerRelation::FRIEND: - mBrowserBox->addRow(_("@@disregard|Disregard ") + name + "@@"); - mBrowserBox->addRow(_("@@ignore|Ignore ") + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@disregard|Disregard %s@@"), name.c_str())); + mBrowserBox->addRow(strprintf(_("@@ignore|Ignore %s@@"), name.c_str())); break; case PlayerRelation::DISREGARDED: - mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@"); - mBrowserBox->addRow(_("@@ignore|Completely ignore ") + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str())); + mBrowserBox->addRow(strprintf(_("@@ignore|Completely ignore %s@@"), name.c_str())); break; case PlayerRelation::IGNORED: - mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str())); break; } @@ -103,8 +103,7 @@ void PopupMenu::showPopup(int x, int y, Being *being) //mBrowserBox->addRow(_("@@buddy|Add ") + name + " to Buddy List@@"); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(_("@@party-invite|Invite ") + name + - " to party@@"); + mBrowserBox->addRow(strprintf(_("@@party-invite|Invite %s to party@@"), name.c_str())); } break; @@ -247,7 +246,7 @@ void PopupMenu::handleLink(const std::string& link) else if (link == "chat") { - chatWindow->addItemText(mItem->getId(), mItem->getInfo().getName()); + chatWindow->addItemText(mItem->getInfo().getName()); } else if (link == "drop") -- cgit v1.2.3-70-g09d2 From 876f55d0624008a87f0ee6cc2e40895a4fe9f90b Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 6 Feb 2009 21:52:19 -0700 Subject: Fixed the help function so that the help commands on help commands would work. Signed-off-by: Ira Rice --- src/gui/chat.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index b53552a6..067c9e08 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -434,7 +434,6 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) } else if (command == "help") { - msg.erase(0, 6); trim(msg); std::size_t space = msg.find(" "); std::string msg1; -- cgit v1.2.3-70-g09d2 From 074ca287804a56f776d641826b1ecfc1454b6c72 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 7 Feb 2009 10:05:16 -0700 Subject: Small tweak to item popup locations based on some feedback that they were a tad too close to the mouse. Signed-off-by: Ira Rice --- src/gui/itempopup.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 8651ede6..b7e015a4 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -206,10 +206,10 @@ void ItemPopup::view(int x, int y) { if (windowContainer->getWidth() < (x + getWidth() + 5)) x = windowContainer->getWidth() - getWidth(); - if ((y - getHeight() - 5) < 0) + if ((y - getHeight() - 10) < 0) y = 0; else - y = y - getHeight() - 5; + y = y - getHeight() - 10; setPosition(x, y); setVisible(true); requestMoveToTop(); -- cgit v1.2.3-70-g09d2 From 1b8c088a48822641b53c2a304372471a128c2841 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 7 Feb 2009 12:18:52 -0700 Subject: Added a text color preview to the setup color tab. Signed-off-by: Ira Rice --- src/gui/browserbox.cpp | 4 ++-- src/gui/browserbox.h | 2 +- src/gui/chat.cpp | 2 -- src/gui/colour.cpp | 9 ++++++++ src/gui/colour.h | 6 ++++++ src/gui/scrollarea.cpp | 15 ++++++++------ src/gui/scrollarea.h | 4 ++-- src/gui/setup_colours.cpp | 52 +++++++++++++++++++++++++++++++++++++---------- src/gui/setup_colours.h | 16 ++++++++------- 9 files changed, 79 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index ecc22e5f..5895d557 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -28,10 +28,10 @@ #include "linkhandler.h" #include "truetypefont.h" -BrowserBox::BrowserBox(unsigned int mode): +BrowserBox::BrowserBox(unsigned int mode, bool opaque): gcn::Widget(), mMode(mode), mHighMode(UNDERLINE | BACKGROUND), - mOpaque(true), + mOpaque(opaque), mUseLinksAndUserColors(true), mSelectedLink(-1), mMaxRows(0) diff --git a/src/gui/browserbox.h b/src/gui/browserbox.h index 15c2ab89..5dde402e 100644 --- a/src/gui/browserbox.h +++ b/src/gui/browserbox.h @@ -46,7 +46,7 @@ class BrowserBox : public gcn::Widget, public gcn::MouseListener /** * Constructor. */ - BrowserBox(unsigned int mode = AUTO_SIZE); + BrowserBox(unsigned int mode = AUTO_SIZE, bool opaque = true); /** * Destructor. diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 067c9e08..2363fc50 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -71,8 +71,6 @@ Window(""), mNetwork(network), mTmpVisible(false) mTextOutput->setLinkHandler(mItemLinkHandler); mScrollArea = new ScrollArea(mTextOutput); - mScrollArea->setPosition(mScrollArea->getFrameSize(), - mScrollArea->getFrameSize()); mScrollArea->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS); mScrollArea->setScrollAmount(0, 1); diff --git a/src/gui/colour.cpp b/src/gui/colour.cpp index 58d9d1c6..c4505c2f 100644 --- a/src/gui/colour.cpp +++ b/src/gui/colour.cpp @@ -93,6 +93,15 @@ std::string Colour::getElementAt(int i) return mColVector[i].text; } +char Colour::getColourCharAt(int i) +{ + if (i < 0 || i >= getNumberOfElements()) + { + return 'C'; + } + return mColVector[i].ch; +} + void Colour::addColour(const char c, const int rgb, const std::string &text) { int trueRgb = config.getValue("Colour" + text, rgb); diff --git a/src/gui/colour.h b/src/gui/colour.h index 1648e1e8..d0349b7d 100644 --- a/src/gui/colour.h +++ b/src/gui/colour.h @@ -87,6 +87,12 @@ class Colour : public gcn::ListModel */ int getColourAt(int i); + /** + * Get the character used by the colour for the element at index i in + * the current colour model + */ + char getColourCharAt(int i); + /** * Set the colour for the element at index i */ diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index e69b681c..09f7c5e7 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -35,15 +35,17 @@ ImageRect ScrollArea::background; ImageRect ScrollArea::vMarker; Image *ScrollArea::buttons[4][2]; -ScrollArea::ScrollArea(bool gc): +ScrollArea::ScrollArea(bool gc, bool opaque): gcn::ScrollArea(), + mOpaque(opaque), mGC(gc) { init(); } -ScrollArea::ScrollArea(gcn::Widget *widget, bool gc): +ScrollArea::ScrollArea(gcn::Widget *widget, bool gc, bool opaque): gcn::ScrollArea(widget), + mOpaque(opaque), mGC(gc) { init(); @@ -52,9 +54,8 @@ ScrollArea::ScrollArea(gcn::Widget *widget, bool gc): ScrollArea::~ScrollArea() { // Garbage collection - if (mGC) { + if (mGC) delete getContent(); - } instances--; @@ -88,8 +89,10 @@ void ScrollArea::init() const int bggridy[4] = {0, 3, 28, 31}; int a = 0, x, y; - for (y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) { + for (y = 0; y < 3; y++) + { + for (x = 0; x < 3; x++) + { background.grid[a] = textbox->getSubImage( bggridx[x], bggridy[y], bggridx[x + 1] - bggridx[x] + 1, diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h index ccc1e178..33ebc692 100644 --- a/src/gui/scrollarea.h +++ b/src/gui/scrollarea.h @@ -38,12 +38,12 @@ class ScrollArea : public gcn::ScrollArea /** * Constructor. */ - ScrollArea(bool gc = true); + ScrollArea(bool gc = true, bool opaque = true); /** * Constructor. */ - ScrollArea(gcn::Widget *content, bool gc = true); + ScrollArea(gcn::Widget *content, bool gc = true, bool opaque = true); /** * Destructor. diff --git a/src/gui/setup_colours.cpp b/src/gui/setup_colours.cpp index d0ab426a..acc28b1f 100644 --- a/src/gui/setup_colours.cpp +++ b/src/gui/setup_colours.cpp @@ -19,11 +19,15 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include + #include #include #include +#include "browserbox.h" #include "colour.h" +#include "itemlinkhandler.h" #include "listbox.h" #include "scrollarea.h" #include "setup_colours.h" @@ -35,6 +39,7 @@ #include "../configuration.h" #include "../utils/gettext.h" +#include "../utils/tostring.h" Setup_Colours::Setup_Colours() : mSelected(-1) @@ -48,6 +53,18 @@ Setup_Colours::Setup_Colours() : mScroll = new ScrollArea(mColourBox); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); + mPreview = new BrowserBox(BrowserBox::AUTO_WRAP); + mPreview->setOpaque(false); + + // Replace this later with a more appropriate link handler. For now, this'll + // do, as it'll do nothing when clicked on. + mPreview->setLinkHandler(new ItemLinkHandler()); + + mPreviewBox = new ScrollArea(mPreview); + mPreviewBox->setHeight(20); + mPreviewBox->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER, + gcn::ScrollArea::SHOW_NEVER); + mRedLabel = new gcn::Label(_("Red: ")); mRedText = new TextField(); @@ -96,16 +113,17 @@ Setup_Colours::Setup_Colours() : LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mScroll, 4, 3).setPadding(2); - place(0, 3, mRedLabel, 2); - place(2, 3, mRedSlider); - place(3, 3, mRedText).setPadding(1); - place(0, 4, mGreenLabel, 2); - place(2, 4, mGreenSlider); - place(3, 4, mGreenText).setPadding(1); - place(0, 5, mBlueLabel, 2); - place(2, 5, mBlueSlider); - place(3, 5, mBlueText).setPadding(1); + place(0, 0, mScroll, 4, 7).setPadding(2); + place(0, 7, mPreviewBox, 4).setPadding(2); + place(0, 8, mRedLabel, 2); + place(2, 8, mRedSlider); + place(3, 8, mRedText).setPadding(1); + place(0, 9, mGreenLabel, 2); + place(2, 9, mGreenSlider); + place(3, 9, mGreenText).setPadding(1); + place(0, 10, mBlueLabel, 2); + place(2, 10, mBlueSlider); + place(3, 10, mBlueText).setPadding(1); setDimension(gcn::Rectangle(0, 0, 290, 250)); } @@ -133,6 +151,18 @@ void Setup_Colours::action(const gcn::ActionEvent &event) { mSelected = mColourBox->getSelected(); int col = textColour->getColourAt(mSelected); + char ch = textColour->getColourCharAt(mSelected); + std::string msg; + + if (ch == '<') + msg = toString("@@|") + + _("This is what the color looks like") + "@@"; + else + msg = "##" + toString(ch) + + _("This is what the color looks like"); + + mPreview->clearRows(); + mPreview->addRow(msg); setEntry(mRedSlider, mRedText, col >> 16); setEntry(mGreenSlider, mGreenText, (col >> 8) & 0xff); setEntry(mBlueSlider, mBlueText, col & 0xff); @@ -167,7 +197,7 @@ void Setup_Colours::action(const gcn::ActionEvent &event) } } -void Setup_Colours::setEntry(Slider *s, TextField *t, int value) +void Setup_Colours::setEntry(gcn::Slider *s, TextField *t, int value) { s->setValue(value); char buffer[100]; diff --git a/src/gui/setup_colours.h b/src/gui/setup_colours.h index f7984dd5..f56daa60 100644 --- a/src/gui/setup_colours.h +++ b/src/gui/setup_colours.h @@ -29,13 +29,13 @@ #include #include -#include "scrollarea.h" #include "setuptab.h" -#include "slider.h" #include "textfield.h" #include "../guichanfwd.h" +class BrowserBox; + class Setup_Colours : public SetupTab, public gcn::ActionListener, public TextFieldListener { @@ -49,25 +49,27 @@ class Setup_Colours : public SetupTab, public gcn::ActionListener, void listen(const TextField *tf); private: gcn::ListBox *mColourBox; - ScrollArea *mScroll; + gcn::ScrollArea *mScroll; + BrowserBox *mPreview; + gcn::ScrollArea *mPreviewBox; int mSelected; gcn::Label *mRedLabel; - Slider *mRedSlider; + gcn::Slider *mRedSlider; TextField *mRedText; int mRedValue; gcn::Label *mGreenLabel; - Slider *mGreenSlider; + gcn::Slider *mGreenSlider; TextField *mGreenText; int mGreenValue; gcn::Label *mBlueLabel; - Slider *mBlueSlider; + gcn::Slider *mBlueSlider; TextField *mBlueText; int mBlueValue; - void setEntry(Slider *s, TextField *t, int value); + void setEntry(gcn::Slider *s, TextField *t, int value); void updateColour(); }; #endif -- cgit v1.2.3-70-g09d2 From 53db43c9fd37c642bae49138b2e05a1de81ad1a7 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 7 Feb 2009 12:19:37 -0700 Subject: Removed some debug statements, as requested by KageJittai. Signed-off-by: Ira Rice --- src/effectmanager.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index cf77de37..63796f73 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -69,7 +69,6 @@ bool EffectManager::trigger(int id, Being* being) { if ((*i).id == id) { - printf("Found effect, playing it"); rValue = true; if((*i).GFX != "") { @@ -92,7 +91,6 @@ bool EffectManager::trigger(int id, int x, int y) { if ((*i).id == id) { - printf("Found effect, playing it"); rValue = true; if((*i).GFX != "") particleEngine->addEffect((*i).GFX, x, y); -- cgit v1.2.3-70-g09d2 From fda9224156f68587c328ef80c74b6a765b3cb725 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 7 Feb 2009 13:30:02 -0700 Subject: Adjusted the status window to try to make it a little more translation friendly (Omphalia was reporting that the Total label was getting cut off in the German translation) Signed-off-by: Ira Rice --- src/gui/status.cpp | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 8b760427..67a1e5d9 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -71,6 +71,8 @@ StatusWindow::StatusWindow(LocalPlayer *player): gcn::Label *mStatsTitleLabel = new gcn::Label(_("Stats")); gcn::Label *mStatsTotalLabel = new gcn::Label(_("Total")); gcn::Label *mStatsCostLabel = new gcn::Label(_("Cost")); + mStatsTotalLabel->setAlignment(gcn::Graphics::CENTER); + mStatsCostLabel->setAlignment(gcn::Graphics::CENTER); // Derived Stats mStatsAttackLabel = new gcn::Label(_("Attack:")); @@ -92,9 +94,11 @@ StatusWindow::StatusWindow(LocalPlayer *player): // New labels for (int i = 0; i < 6; i++) { - mStatsLabel[i] = new gcn::Label; + mStatsLabel[i] = new gcn::Label("0"); + mStatsLabel[i]->setAlignment(gcn::Graphics::CENTER); mStatsDisplayLabel[i] = new gcn::Label; mPointsLabel[i] = new gcn::Label("0"); + mPointsLabel[i]->setAlignment(gcn::Graphics::CENTER); } mRemainingStatsPointsLabel = new gcn::Label; @@ -123,30 +127,30 @@ StatusWindow::StatusWindow(LocalPlayer *player): place(7, 2, mJobBar, 3); place.getCell().matchColWidth(0, 1); place = getPlacer(0, 3); - place(0, 0, mStatsTitleLabel, 3); - place(4, 1, mStatsTotalLabel, 2); - place(7, 1, mStatsCostLabel, 2); + place(0, 0, mStatsTitleLabel, 5); + place(4, 1, mStatsTotalLabel, 5); + place(10, 1, mStatsCostLabel, 5); for(int i = 0; i < 6; i++) { place(0, 2 + i, mStatsLabel[i], 3).setPadding(5); - place(4, 2 + i, mStatsDisplayLabel[i]).setPadding(5); - place(6, 2 + i, mStatsButton[i]); - place(7, 2 + i, mPointsLabel[i]).setPadding(5); + place(6, 2 + i, mStatsDisplayLabel[i]).setPadding(5); + place(9, 2 + i, mStatsButton[i]); + place(12, 2 + i, mPointsLabel[i]).setPadding(5); } - place(10, 2, mStatsAttackLabel, 3).setPadding(5); - place(10, 3, mStatsDefenseLabel, 3).setPadding(5); - place(10, 4, mStatsMagicAttackLabel, 3).setPadding(5); - place(10, 5, mStatsMagicDefenseLabel, 3).setPadding(5); - place(10, 6, mStatsAccuracyLabel, 3).setPadding(5); - place(10, 7, mStatsEvadeLabel, 3).setPadding(5); - place(10, 8, mStatsReflexLabel, 3).setPadding(5); - place(13, 2, mStatsAttackPoints, 3).setPadding(5); - place(13, 3, mStatsDefensePoints, 3).setPadding(5); - place(13, 4, mStatsMagicAttackPoints, 3).setPadding(5); - place(13, 5, mStatsMagicDefensePoints, 3).setPadding(5); - place(13, 6, mStatsAccuracyPoints, 3).setPadding(5); - place(13, 7, mStatsEvadePoints, 3).setPadding(5); - place(13, 8, mStatsReflexPoints, 3).setPadding(5); + place(15, 2, mStatsAttackLabel, 5).setPadding(5); + place(15, 3, mStatsDefenseLabel, 5).setPadding(5); + place(15, 4, mStatsMagicAttackLabel, 5).setPadding(5); + place(15, 5, mStatsMagicDefenseLabel, 5).setPadding(5); + place(15, 6, mStatsAccuracyLabel, 5).setPadding(5); + place(15, 7, mStatsEvadeLabel, 5).setPadding(5); + place(15, 8, mStatsReflexLabel, 5).setPadding(5); + place(20, 2, mStatsAttackPoints, 3).setPadding(5); + place(20, 3, mStatsDefensePoints, 3).setPadding(5); + place(20, 4, mStatsMagicAttackPoints, 3).setPadding(5); + place(20, 5, mStatsMagicDefensePoints, 3).setPadding(5); + place(20, 6, mStatsAccuracyPoints, 3).setPadding(5); + place(20, 7, mStatsEvadePoints, 3).setPadding(5); + place(20, 8, mStatsReflexPoints, 3).setPadding(5); place(0, 8, mRemainingStatsPointsLabel, 3).setPadding(5); Layout &layout = getLayout(); -- cgit v1.2.3-70-g09d2 From df49049a3951421c39340a8ca4b8dba18056daf0 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 7 Feb 2009 13:56:23 -0700 Subject: More modifications based on critiques by Omphalia. Signed-off-by: Ira Rice --- src/gui/status.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 67a1e5d9..f808eadf 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -72,7 +72,6 @@ StatusWindow::StatusWindow(LocalPlayer *player): gcn::Label *mStatsTotalLabel = new gcn::Label(_("Total")); gcn::Label *mStatsCostLabel = new gcn::Label(_("Cost")); mStatsTotalLabel->setAlignment(gcn::Graphics::CENTER); - mStatsCostLabel->setAlignment(gcn::Graphics::CENTER); // Derived Stats mStatsAttackLabel = new gcn::Label(_("Attack:")); @@ -129,21 +128,21 @@ StatusWindow::StatusWindow(LocalPlayer *player): place = getPlacer(0, 3); place(0, 0, mStatsTitleLabel, 5); place(4, 1, mStatsTotalLabel, 5); - place(10, 1, mStatsCostLabel, 5); + place(11, 1, mStatsCostLabel, 5); for(int i = 0; i < 6; i++) { place(0, 2 + i, mStatsLabel[i], 3).setPadding(5); place(6, 2 + i, mStatsDisplayLabel[i]).setPadding(5); place(9, 2 + i, mStatsButton[i]); - place(12, 2 + i, mPointsLabel[i]).setPadding(5); + place(11, 2 + i, mPointsLabel[i]).setPadding(5); } - place(15, 2, mStatsAttackLabel, 5).setPadding(5); - place(15, 3, mStatsDefenseLabel, 5).setPadding(5); - place(15, 4, mStatsMagicAttackLabel, 5).setPadding(5); - place(15, 5, mStatsMagicDefenseLabel, 5).setPadding(5); - place(15, 6, mStatsAccuracyLabel, 5).setPadding(5); - place(15, 7, mStatsEvadeLabel, 5).setPadding(5); - place(15, 8, mStatsReflexLabel, 5).setPadding(5); + place(13, 2, mStatsAttackLabel, 7).setPadding(5); + place(13, 3, mStatsDefenseLabel, 7).setPadding(5); + place(13, 4, mStatsMagicAttackLabel, 7).setPadding(5); + place(13, 5, mStatsMagicDefenseLabel, 7).setPadding(5); + place(13, 6, mStatsAccuracyLabel, 7).setPadding(5); + place(13, 7, mStatsEvadeLabel, 7).setPadding(5); + place(13, 8, mStatsReflexLabel, 7).setPadding(5); place(20, 2, mStatsAttackPoints, 3).setPadding(5); place(20, 3, mStatsDefensePoints, 3).setPadding(5); place(20, 4, mStatsMagicAttackPoints, 3).setPadding(5); -- cgit v1.2.3-70-g09d2 From e973dd25b1181ddb554a56888c3c361f131b4b3a Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 7 Feb 2009 14:02:37 -0700 Subject: Added a bit more spacing for stat labels as well, which I didn't think about in the last commit. They may work for each of the languages already tested, but this will make sure that it's wide enough for the ones which haven't been tested. Signed-off-by: Ira Rice --- src/gui/status.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/gui/status.cpp b/src/gui/status.cpp index f808eadf..e0e43b36 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -127,29 +127,29 @@ StatusWindow::StatusWindow(LocalPlayer *player): place.getCell().matchColWidth(0, 1); place = getPlacer(0, 3); place(0, 0, mStatsTitleLabel, 5); - place(4, 1, mStatsTotalLabel, 5); - place(11, 1, mStatsCostLabel, 5); + place(5, 1, mStatsTotalLabel, 5); + place(12, 1, mStatsCostLabel, 5); for(int i = 0; i < 6; i++) { - place(0, 2 + i, mStatsLabel[i], 3).setPadding(5); - place(6, 2 + i, mStatsDisplayLabel[i]).setPadding(5); - place(9, 2 + i, mStatsButton[i]); - place(11, 2 + i, mPointsLabel[i]).setPadding(5); + place(0, 2 + i, mStatsLabel[i], 7).setPadding(5); + place(7, 2 + i, mStatsDisplayLabel[i]).setPadding(5); + place(10, 2 + i, mStatsButton[i]); + place(12, 2 + i, mPointsLabel[i]).setPadding(5); } - place(13, 2, mStatsAttackLabel, 7).setPadding(5); - place(13, 3, mStatsDefenseLabel, 7).setPadding(5); - place(13, 4, mStatsMagicAttackLabel, 7).setPadding(5); - place(13, 5, mStatsMagicDefenseLabel, 7).setPadding(5); - place(13, 6, mStatsAccuracyLabel, 7).setPadding(5); - place(13, 7, mStatsEvadeLabel, 7).setPadding(5); - place(13, 8, mStatsReflexLabel, 7).setPadding(5); - place(20, 2, mStatsAttackPoints, 3).setPadding(5); - place(20, 3, mStatsDefensePoints, 3).setPadding(5); - place(20, 4, mStatsMagicAttackPoints, 3).setPadding(5); - place(20, 5, mStatsMagicDefensePoints, 3).setPadding(5); - place(20, 6, mStatsAccuracyPoints, 3).setPadding(5); - place(20, 7, mStatsEvadePoints, 3).setPadding(5); - place(20, 8, mStatsReflexPoints, 3).setPadding(5); + place(14, 2, mStatsAttackLabel, 7).setPadding(5); + place(14, 3, mStatsDefenseLabel, 7).setPadding(5); + place(14, 4, mStatsMagicAttackLabel, 7).setPadding(5); + place(14, 5, mStatsMagicDefenseLabel, 7).setPadding(5); + place(14, 6, mStatsAccuracyLabel, 7).setPadding(5); + place(14, 7, mStatsEvadeLabel, 7).setPadding(5); + place(14, 8, mStatsReflexLabel, 7).setPadding(5); + place(21, 2, mStatsAttackPoints, 3).setPadding(5); + place(21, 3, mStatsDefensePoints, 3).setPadding(5); + place(21, 4, mStatsMagicAttackPoints, 3).setPadding(5); + place(21, 5, mStatsMagicDefensePoints, 3).setPadding(5); + place(21, 6, mStatsAccuracyPoints, 3).setPadding(5); + place(21, 7, mStatsEvadePoints, 3).setPadding(5); + place(21, 8, mStatsReflexPoints, 3).setPadding(5); place(0, 8, mRemainingStatsPointsLabel, 3).setPadding(5); Layout &layout = getLayout(); -- cgit v1.2.3-70-g09d2 From c42eba00701f28b3cf720d90c73d1cfc6c3815da Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 7 Feb 2009 15:09:11 -0700 Subject: Adjusted the shortcut window initialization so that all new shortcut window instances don't overlap by default. After that, it'll defer to the user's saved window positions. Signed-off-by: Ira Rice --- src/gui/shortcutwindow.cpp | 13 +++++++++---- src/gui/shortcutwindow.h | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index 91b33b72..dd8634f7 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -27,6 +27,8 @@ static const int SCROLL_PADDING = 0; +int ShortcutWindow::mInstances = 1; + ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content) { setWindowName(title); @@ -46,16 +48,19 @@ ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content) const int width = (int) config.getValue("screenwidth", 800); const int height = (int) config.getValue("screenheight", 600); - setDefaultSize(width - mItems->getBoxWidth() - border, - height - (mItems->getBoxHeight() * mItems->getMaxItems()) - - border, mItems->getBoxWidth() + border, - (mItems->getBoxHeight() * mItems->getMaxItems()) + border); + setDefaultSize(width - (mInstances * mItems->getBoxWidth()) - + (mInstances * border), height - (mItems->getBoxHeight() * + mItems->getMaxItems()) - border, mItems->getBoxWidth() + + border, (mItems->getBoxHeight() * mItems->getMaxItems()) + + border); mScrollArea = new ScrollArea(mItems); mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mScrollArea->setOpaque(false); + mInstances++; + add(mScrollArea); loadWindowState(); diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h index 2711ced5..64592328 100644 --- a/src/gui/shortcutwindow.h +++ b/src/gui/shortcutwindow.h @@ -55,6 +55,8 @@ class ShortcutWindow : public Window ShortcutContainer *mItems; ScrollArea *mScrollArea; + + static int mInstances; }; extern ShortcutWindow *itemShortcutWindow; -- cgit v1.2.3-70-g09d2 From 472494898ee15e92f16ea5f5667c11b6f46b0057 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 7 Feb 2009 15:21:33 -0700 Subject: While this commit isn't really needed, this cleans up the reported instances number so that it accurately reflects the number of instances, instead of always being +1. I wasn't intending on using that variable that way, but in case anyone does in the future, it'll at least be accurate. Signed-off-by: Ira Rice --- src/gui/shortcutwindow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index dd8634f7..5d49a3c6 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -27,7 +27,7 @@ static const int SCROLL_PADDING = 0; -int ShortcutWindow::mInstances = 1; +int ShortcutWindow::mInstances = 0; ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content) { @@ -39,6 +39,8 @@ ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content) mItems = content; + mInstances++; + const int border = SCROLL_PADDING * 2 + getPadding() * 2; setMinWidth(mItems->getBoxWidth() + border); setMinHeight(mItems->getBoxHeight() + border); @@ -59,8 +61,6 @@ ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content) mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mScrollArea->setOpaque(false); - mInstances++; - add(mScrollArea); loadWindowState(); -- cgit v1.2.3-70-g09d2 From 450edb5900a46ada0cc6292f0079a31ea5d04573 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 7 Feb 2009 21:51:35 -0700 Subject: Some more include cleanups. Signed-off-by: Ira Rice --- src/being.cpp | 6 ++++++ src/being.h | 32 +++++++++++++++++------------ src/beingmanager.cpp | 2 -- src/configlistener.h | 2 +- src/configuration.cpp | 2 -- src/configuration.h | 3 ++- src/effectmanager.cpp | 2 +- src/effectmanager.h | 5 ++--- src/engine.cpp | 10 ---------- src/engine.h | 2 -- src/equipment.cpp | 2 -- src/floor_item.cpp | 16 +++++++++++++++ src/floor_item.h | 22 ++++++++++---------- src/game.cpp | 7 +------ src/game.h | 1 - src/graphics.h | 8 ++++++-- src/gui/char_select.cpp | 2 ++ src/gui/debugwindow.cpp | 1 - src/gui/equipmentwindow.cpp | 1 - src/gui/gui.h | 1 - src/gui/inventorywindow.cpp | 1 - src/gui/itemshortcutcontainer.cpp | 1 - src/gui/setup_players.h | 2 +- src/gui/viewport.cpp | 1 - src/gui/viewport.h | 7 +++++-- src/guichanfwd.h | 3 ++- src/inventory.cpp | 42 +++++++++++++++++++-------------------- src/itemshortcut.cpp | 17 ++++++++-------- src/joystick.cpp | 2 -- src/joystick.h | 6 ++++-- src/keyboardconfig.cpp | 3 +-- src/keyboardconfig.h | 11 +++++----- src/localplayer.cpp | 8 ++++++-- src/localplayer.h | 8 ++++++-- src/log.cpp | 2 -- src/log.h | 1 - src/main.cpp | 4 ---- src/map.cpp | 5 +++++ src/map.h | 3 ++- src/monster.cpp | 3 +-- src/net/beinghandler.cpp | 1 - src/net/equipmenthandler.cpp | 1 - src/net/loginhandler.h | 1 - src/net/partyhandler.cpp | 1 - src/npc.cpp | 1 - src/openglgraphics.cpp | 5 ----- src/particle.cpp | 2 ++ src/particle.h | 2 -- src/particlecontainer.cpp | 5 +---- src/particlecontainer.h | 6 +----- src/particleemitter.cpp | 5 ++--- src/particleemitter.h | 4 ++-- src/particleemitterprop.h | 1 - src/party.cpp | 1 - src/player.cpp | 7 ++----- src/player.h | 2 +- src/player_relations.cpp | 5 +++-- src/player_relations.h | 5 ++--- src/properties.h | 3 +-- src/resources/animation.cpp | 2 -- src/resources/buddylist.h | 3 ++- src/resources/colordb.cpp | 2 -- src/resources/dye.cpp | 1 - src/resources/emotedb.cpp | 2 -- src/resources/image.h | 2 ++ src/resources/imageloader.cpp | 1 - src/resources/imagewriter.h | 2 -- src/resources/itemdb.cpp | 2 -- src/resources/itemdb.h | 2 ++ src/resources/mapreader.cpp | 1 + src/resources/mapreader.h | 2 -- src/resources/monsterdb.cpp | 2 +- src/resources/monsterdb.h | 2 +- src/resources/npcdb.cpp | 2 -- src/resources/resource.h | 3 +-- src/resources/soundeffect.h | 3 +-- src/simpleanimation.cpp | 10 +++++++++- src/simpleanimation.h | 11 +++------- src/text.cpp | 6 ++---- src/text.h | 10 +++++----- src/textmanager.cpp | 14 +++---------- src/textmanager.h | 5 +++-- src/textparticle.cpp | 2 ++ src/textparticle.h | 2 -- src/utils/tostring.h | 2 +- 85 files changed, 189 insertions(+), 222 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index dc843e43..2b4ba767 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -25,6 +25,7 @@ #include "animatedsprite.h" #include "being.h" #include "configuration.h" +#include "effectmanager.h" #include "game.h" #include "graphics.h" #include "localplayer.h" @@ -34,7 +35,12 @@ #include "sound.h" #include "text.h" +#include "gui/speechbubble.h" + +#include "resources/colordb.h" + #include "resources/emotedb.h" +#include "resources/image.h" #include "resources/imageset.h" #include "resources/itemdb.h" #include "resources/iteminfo.h" diff --git a/src/being.h b/src/being.h index 812ffdd3..109a44ad 100644 --- a/src/being.h +++ b/src/being.h @@ -22,37 +22,39 @@ #ifndef BEING_H #define BEING_H -#include -#include +#include + #include + #include #include #include -#include "animatedsprite.h" -#include "effectmanager.h" -#include "map.h" #include "particlecontainer.h" #include "position.h" #include "sprite.h" -#include "gui/speechbubble.h" - -#include "resources/colordb.h" +#include "resources/spritedef.h" #define FIRST_IGNORE_EMOTE 14 #define STATUS_EFFECTS 32 class AnimatedSprite; +class Image; class ItemInfo; class Item; class Map; class Graphics; class Particle; +class Position; class SpeechBubble; class Text; -enum Gender { +typedef std::list Sprites; +typedef Sprites::iterator SpriteIterator; + +enum Gender +{ GENDER_MALE = 0, GENDER_FEMALE = 1, GENDER_UNSPECIFIED = 2 @@ -61,7 +63,8 @@ enum Gender { class Being : public Sprite { public: - enum Type { + enum Type + { UNKNOWN, PLAYER, NPC, @@ -71,7 +74,8 @@ class Being : public Sprite /** * Action the being is currently performing. */ - enum Action { + enum Action + { STAND, WALK, ATTACK, @@ -80,7 +84,8 @@ class Being : public Sprite HURT }; - enum Sprite { + enum Sprite + { BASE_SPRITE = 0, SHOE_SPRITE, BOTTOMCLOTHES_SPRITE, @@ -96,7 +101,8 @@ class Being : public Sprite VECTOREND_SPRITE }; - enum TargetCursorSize { + enum TargetCursorSize + { TC_SMALL = 0, TC_MEDIUM, TC_LARGE, diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 9e620ca0..a417ee50 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "beingmanager.h" #include "localplayer.h" #include "monster.h" diff --git a/src/configlistener.h b/src/configlistener.h index 51d58144..ec7d6a2c 100644 --- a/src/configlistener.h +++ b/src/configlistener.h @@ -22,7 +22,7 @@ #ifndef CONFIGLISTENER_H #define CONFIGLISTENER_H -#include +#include /** * The listener interface for receiving notifications about changes to diff --git a/src/configuration.cpp b/src/configuration.cpp index 04cb4f36..f6c74428 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "configlistener.h" #include "configuration.h" #include "log.h" diff --git a/src/configuration.h b/src/configuration.h index 0cc4e29f..da12e1e4 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -22,8 +22,9 @@ #ifndef CONFIGURATION_H #define CONFIGURATION_H -#include #include + +#include #include #include #include diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index 63796f73..0a04c33d 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - +#include "being.h" #include "effectmanager.h" #include "log.h" #include "particle.h" diff --git a/src/effectmanager.h b/src/effectmanager.h index a9efcdbc..619b8e0d 100644 --- a/src/effectmanager.h +++ b/src/effectmanager.h @@ -25,15 +25,14 @@ #include #include -#include "being.h" - class Being; class EffectManager { public: - struct EffectDescription { + struct EffectDescription + { int id; std::string GFX; std::string SFX; diff --git a/src/engine.cpp b/src/engine.cpp index 29b8921a..c91e42f9 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -19,18 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - -#include "being.h" #include "beingmanager.h" -#include "configuration.h" #include "engine.h" #include "flooritemmanager.h" #include "game.h" -#include "graphics.h" #include "localplayer.h" #include "log.h" -#include "main.h" #include "map.h" #include "particle.h" #include "sound.h" @@ -43,14 +37,10 @@ #include "net/protocol.h" #include "resources/mapreader.h" -#include "resources/monsterdb.h" #include "resources/resourcemanager.h" -#include "utils/dtor.h" #include "utils/tostring.h" -extern Minimap *minimap; - char itemCurrenyQ[10] = "0"; Engine::Engine(Network *network): diff --git a/src/engine.h b/src/engine.h index f2852351..7ad6d894 100644 --- a/src/engine.h +++ b/src/engine.h @@ -22,7 +22,6 @@ #ifndef _ENGINE_H #define _ENGINE_H -#include #include class Map; @@ -52,7 +51,6 @@ class Engine const std::string &getCurrentMapName() { return mMapName; } - /** * Sets the currently active map. */ diff --git a/src/equipment.cpp b/src/equipment.cpp index d5e0f656..b21115a3 100644 --- a/src/equipment.cpp +++ b/src/equipment.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "equipment.h" #include "item.h" #include "inventory.h" diff --git a/src/floor_item.cpp b/src/floor_item.cpp index 0c4c1c10..fbe606b4 100644 --- a/src/floor_item.cpp +++ b/src/floor_item.cpp @@ -20,8 +20,12 @@ */ #include "floor_item.h" +#include "graphics.h" +#include "item.h" #include "map.h" +#include "resources/image.h" + FloorItem::FloorItem(unsigned int id, unsigned int itemId, unsigned short x, @@ -46,3 +50,15 @@ FloorItem::~FloorItem() delete mItem; } + +unsigned int FloorItem::getItemId() const +{ + return mItem->getId(); +} + +void FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const +{ + graphics->drawImage(mItem->getImage(), + mX * 32 + offsetX, + mY * 32 + offsetY); +} diff --git a/src/floor_item.h b/src/floor_item.h index a7299bfb..444c756a 100644 --- a/src/floor_item.h +++ b/src/floor_item.h @@ -22,11 +22,16 @@ #ifndef FLOORITEM_H #define FLOORITEM_H -#include "graphics.h" -#include "item.h" -#include "map.h" +#include + #include "sprite.h" -#include "resources/image.h" + +class Graphics; +class Image; +class Item; +class Map; + +typedef std::list Sprites; /** * An item lying on the floor. @@ -56,7 +61,7 @@ class FloorItem : public Sprite /** * Returns the item id. */ - unsigned int getItemId() const { return mItem->getId(); } + unsigned int getItemId() const; /** * Returns the x coordinate. @@ -80,12 +85,7 @@ class FloorItem : public Sprite * * @see Sprite::draw(Graphics, int, int) */ - void draw(Graphics *graphics, int offsetX, int offsetY) const - { - graphics->drawImage(mItem->getImage(), - mX * 32 + offsetX, - mY * 32 + offsetY); - } + void draw(Graphics *graphics, int offsetX, int offsetY) const; private: unsigned int mId; diff --git a/src/game.cpp b/src/game.cpp index 28c29874..e2064f58 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -25,9 +25,9 @@ #include #include -#include #include "beingmanager.h" +#include "configuration.h" #include "effectmanager.h" #include "emoteshortcut.h" #include "engine.h" @@ -55,7 +55,6 @@ #include "gui/help.h" #include "gui/inventorywindow.h" #include "gui/shortcutwindow.h" -#include "gui/shortcutcontainer.h" #include "gui/itemshortcutcontainer.h" #include "gui/menuwindow.h" #include "gui/minimap.h" @@ -73,7 +72,6 @@ #include "gui/trade.h" #include "gui/viewport.h" -#include "net/protocol.h" #include "net/beinghandler.h" #include "net/buysellhandler.h" #include "net/chathandler.h" @@ -87,14 +85,11 @@ #include "net/protocol.h" #include "net/skillhandler.h" #include "net/tradehandler.h" -#include "net/messageout.h" #include "resources/imagewriter.h" #include "utils/gettext.h" -extern Graphics *graphics; - class Map; std::string map_path; diff --git a/src/game.h b/src/game.h index 4f512d97..c9fc8d79 100644 --- a/src/game.h +++ b/src/game.h @@ -22,7 +22,6 @@ #ifndef GAME_ #define GAME_ -#include #include #include "configlistener.h" diff --git a/src/graphics.h b/src/graphics.h index 8009ceda..172032dc 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -46,14 +46,16 @@ struct SDL_Surface; * Sections 0, 2, 6 and 8 will remain as is. 1, 3, 4, 5 and 7 will be * repeated to fit the size of the widget. */ -struct ImageRect { +struct ImageRect +{ Image *grid[9]; }; /** * A central point of control for graphics. */ -class Graphics : public gcn::SDLGraphics { +class Graphics : public gcn::SDLGraphics +{ public: /** * Constructor. @@ -151,4 +153,6 @@ class Graphics : public gcn::SDLGraphics { bool mFullscreen, mHWAccel; }; +extern Graphics *graphics; + #endif diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 4433b646..6626b848 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -41,6 +41,8 @@ #include "../net/charserverhandler.h" #include "../net/messageout.h" +#include "../resources/colordb.h" + #include "../utils/gettext.h" #include "../utils/strprintf.h" #include "../utils/trim.h" diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 055d9963..5a5acfad 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -24,7 +24,6 @@ #include #include "debugwindow.h" -#include "gui.h" #include "viewport.h" #include "widgets/layout.h" diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 5ba9501d..e553fbe7 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -26,7 +26,6 @@ #include "button.h" #include "equipmentwindow.h" -#include "gui.h" #include "itempopup.h" #include "playerbox.h" #include "viewport.h" diff --git a/src/gui/gui.h b/src/gui/gui.h index 9681d44a..5c0c24f7 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -115,7 +115,6 @@ class Gui : public gcn::Gui }; extern Gui *gui; /**< The GUI system */ -extern Viewport *viewport; /**< The viewport */ extern SDLInput *guiInput; /**< GUI input */ /** diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index a3572d4f..70b3efb5 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -27,7 +27,6 @@ #include #include "button.h" -#include "gui.h" #include "inventorywindow.h" #include "item_amount.h" #include "itemcontainer.h" diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index e152b03d..d3cc2c22 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -20,7 +20,6 @@ */ #include -#include "gui.h" #include "itemshortcutcontainer.h" #include "itempopup.h" #include "viewport.h" diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h index 393fc6aa..2edc6983 100644 --- a/src/gui/setup_players.h +++ b/src/gui/setup_players.h @@ -53,7 +53,7 @@ private: PlayerTableModel *mPlayerTableModel; GuiTable *mPlayerTable; GuiTable *mPlayerTitleTable; - ScrollArea *mPlayerScrollArea; + gcn::ScrollArea *mPlayerScrollArea; gcn::CheckBox *mPersistIgnores; gcn::CheckBox *mDefaultTrading; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 11a0004b..25e69c43 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "gui.h" #include "popupmenu.h" #include "viewport.h" diff --git a/src/gui/viewport.h b/src/gui/viewport.h index e352f765..522ea734 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -27,13 +27,14 @@ #include "windowcontainer.h" #include "../configlistener.h" +#include "../position.h" -class Map; class FloorItem; +class Graphics; class ImageSet; class Item; +class Map; class PopupMenu; -class Graphics; /** * The viewport on the map. Displays the current map and handles mouse input @@ -137,4 +138,6 @@ class Viewport : public WindowContainer, public gcn::MouseListener, PopupMenu *mPopupMenu; /**< Popup menu. */ }; +extern Viewport *viewport; /**< The viewport */ + #endif diff --git a/src/guichanfwd.h b/src/guichanfwd.h index 2e97db68..4863421c 100644 --- a/src/guichanfwd.h +++ b/src/guichanfwd.h @@ -22,7 +22,8 @@ #ifndef GUICHANFWD_H #define GUICHANFWD_H -namespace gcn { +namespace gcn +{ class ActionListener; class AllegroGraphics; class AllegroImage; diff --git a/src/inventory.cpp b/src/inventory.cpp index 8824e1ba..3ca26e1e 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -20,7 +20,6 @@ */ #include -#include #include "inventory.h" #include "item.h" @@ -28,7 +27,8 @@ struct SlotUsed : public std::unary_function { - bool operator()(const Item *item) const { + bool operator()(const Item *item) const + { return item && item->getId() != -1 && item->getQuantity() > 0; } }; @@ -59,10 +59,9 @@ Item* Inventory::getItem(int index) const Item* Inventory::findItem(int itemId) const { for (int i = 0; i < mSize; i++) - { if (mItems[i] && mItems[i]->getId() == itemId) return mItems[i]; - } + return NULL; } @@ -73,38 +72,41 @@ void Inventory::addItem(int id, int quantity, bool equipment) void Inventory::setItem(int index, int id, int quantity, bool equipment) { - if (index < 0 || index >= mSize) { + if (index < 0 || index >= mSize) + { logger->log("Warning: invalid inventory index: %d", index); return; } - if (!mItems[index] && id > 0) { + if (!mItems[index] && id > 0) + { Item *item = new Item(id, quantity, equipment); item->setInvIndex(index); mItems[index] = item; - } else if (id > 0) { + } + else if (id > 0) + { mItems[index]->setId(id); mItems[index]->setQuantity(quantity); mItems[index]->setEquipment(equipment); - } else if (mItems[index]) { + } + else if (mItems[index]) + { removeItemAt(index); } } void Inventory::clear() { - for (int i = 0; i < mSize; i++) { + for (int i = 0; i < mSize; i++) removeItemAt(i); - } } void Inventory::removeItem(int id) { - for (int i = 0; i < mSize; i++) { - if (mItems[i] && mItems[i]->getId() == id) { + for (int i = 0; i < mSize; i++) + if (mItems[i] && mItems[i]->getId() == id) removeItemAt(i); - } - } } void Inventory::removeItemAt(int index) @@ -115,11 +117,9 @@ void Inventory::removeItemAt(int index) bool Inventory::contains(Item *item) const { - for (int i = 0; i < mSize; i++) { - if (mItems[i] && mItems[i]->getId() == item->getId()) { + for (int i = 0; i < mSize; i++) + if (mItems[i] && mItems[i]->getId() == item->getId()) return true; - } - } return false; } @@ -138,11 +138,9 @@ int Inventory::getNumberOfSlotsUsed() const int Inventory::getLastUsedSlot() const { - for (int i = mSize - 1; i >= 0; i--) { - if (SlotUsed()(mItems[i])) { + for (int i = mSize - 1; i >= 0; i--) + if (SlotUsed()(mItems[i])) return i; - } - } return -1; } diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index 7bfbc88e..3404b0e3 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -33,9 +33,8 @@ ItemShortcut::ItemShortcut(): mItemSelected(-1) { for (int i = 0; i < SHORTCUT_ITEMS; i++) - { mItems[i] = -1; - } + load(); } @@ -51,9 +50,7 @@ void ItemShortcut::load() int itemId = (int) config.getValue("shortcut" + toString(i), -1); if (itemId != -1) - { mItems[i] = itemId; - } } } @@ -73,13 +70,15 @@ void ItemShortcut::useItem(int index) Item *item = player_node->getInventory()->findItem(mItems[index]); if (item && item->getQuantity()) { - if (item->isEquipment()) { - if (item->isEquipped()) { + if (item->isEquipment()) + { + if (item->isEquipped()) player_node->unequipItem(item); - } else { + else player_node->equipItem(item); - } - } else { + } + else + { player_node->useItem(item); } } diff --git a/src/joystick.cpp b/src/joystick.cpp index 1233c37f..7e9a2285 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -25,8 +25,6 @@ #include "joystick.h" #include "log.h" -#include - int Joystick::joystickCount = 0; void Joystick::init() diff --git a/src/joystick.h b/src/joystick.h index a7090293..4e5c3d23 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -30,14 +30,16 @@ class Joystick /** * Number of buttons we can handle. */ - enum { + enum + { MAX_BUTTONS = 6 }; /** * Directions, to be used as bitmask values. */ - enum { + enum + { UP = 1, DOWN = 2, LEFT = 4, diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index 745a81db..ecf47573 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -19,12 +19,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "configuration.h" #include "keyboardconfig.h" #include "log.h" +#include "gui/sdlinput.h" #include "gui/setup_keyboard.h" #include "utils/gettext.h" diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h index ba8039bf..bfcde31c 100644 --- a/src/keyboardconfig.h +++ b/src/keyboardconfig.h @@ -22,13 +22,9 @@ #ifndef KEYBOARDCONFIG_H #define KEYBOARDCONFIG_H +#include #include -#include - -#include "gui/sdlinput.h" -#include "gui/setup_keyboard.h" - /** * Each key represents a key function. Such as 'Move up', 'Attack' etc. */ @@ -40,6 +36,8 @@ struct KeyFunction int value; /** The actual value that is used. */ }; +class Setup_Keyboard; + class KeyboardConfig { public: @@ -148,7 +146,8 @@ class KeyboardConfig * The key assignment view gets arranged according to the order of * these values. */ - enum KeyAction { + enum KeyAction + { KEY_NO_VALUE = -1, KEY_MOVE_UP, KEY_MOVE_DOWN, diff --git a/src/localplayer.cpp b/src/localplayer.cpp index bc0b2b81..01de3b41 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -24,20 +24,24 @@ #include "equipment.h" #include "floor_item.h" #include "game.h" +#include "graphics.h" #include "inventory.h" #include "item.h" #include "localplayer.h" -#include "main.h" +#include "map.h" #include "monster.h" #include "particle.h" +#include "simpleanimation.h" #include "sound.h" -#include "monster.h" +#include "text.h" #include "gui/gui.h" #include "net/messageout.h" #include "net/protocol.h" +#include "resources/animation.h" +#include "resources/image.h" #include "resources/imageset.h" #include "resources/resourcemanager.h" diff --git a/src/localplayer.h b/src/localplayer.h index 7f5596e4..d6d5ad2e 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -22,8 +22,9 @@ #ifndef LOCALPLAYER_H #define LOCALPLAYER_H +#include + #include "player.h" -#include "simpleanimation.h" // TODO move into some sane place... #define MAX_SLOT 2 @@ -36,7 +37,9 @@ class FloorItem; class ImageSet; class Inventory; class Item; +class Map; class Network; +class SimpleAnimation; /** * The local player character. @@ -44,7 +47,8 @@ class Network; class LocalPlayer : public Player { public: - enum Attribute { + enum Attribute + { STR = 0, AGI, VIT, INT, DEX, LUK }; diff --git a/src/log.cpp b/src/log.cpp index e50edeb2..b0024f80 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include #include #include diff --git a/src/log.h b/src/log.h index fcd48757..b06bdc89 100644 --- a/src/log.h +++ b/src/log.h @@ -22,7 +22,6 @@ #ifndef _LOG_H #define _LOG_H -#include #include class ChatWindow; diff --git a/src/main.cpp b/src/main.cpp index 65b61de2..73e0b0fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,8 +28,6 @@ #include -#include - #include #include @@ -65,7 +63,6 @@ #include "gui/register.h" #include "gui/sdlinput.h" #include "gui/setup.h" -#include "gui/textfield.h" #include "gui/updatewindow.h" #include "net/charserverhandler.h" @@ -82,7 +79,6 @@ #include "resources/npcdb.h" #include "resources/resourcemanager.h" -#include "utils/dtor.h" #include "utils/gettext.h" #include "utils/tostring.h" diff --git a/src/map.cpp b/src/map.cpp index 57b79ef4..716e9aee 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -68,6 +68,11 @@ TileAnimation::TileAnimation(Animation *ani): { } +TileAnimation::~TileAnimation() +{ + delete mLastImage; +} + void TileAnimation::update() { //update animation diff --git a/src/map.h b/src/map.h index bd4cb122..1423565f 100644 --- a/src/map.h +++ b/src/map.h @@ -27,9 +27,9 @@ #include "position.h" #include "properties.h" - #include "simpleanimation.h" +class Animation; class AmbientOverlay; class Graphics; class Image; @@ -72,6 +72,7 @@ class TileAnimation { public: TileAnimation(Animation *ani); + ~TileAnimation(); void update(); void addAffectedTile(MapLayer *layer, int index) { mAffected.push_back(std::make_pair(layer, index)); } diff --git a/src/monster.cpp b/src/monster.cpp index 4f2c97e7..33703817 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -28,8 +28,7 @@ #include "text.h" #include "resources/monsterdb.h" - -#include "utils/tostring.h" +#include "resources/monsterinfo.h" static const int NAME_X_OFFSET = 16; static const int NAME_Y_OFFSET = 16; diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 69bc462c..69f462ec 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -32,7 +32,6 @@ #include "../game.h" #include "../localplayer.h" #include "../log.h" -#include "../main.h" #include "../npc.h" #include "../particle.h" #include "../player_relations.h" diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp index 319d1205..9a3c396a 100644 --- a/src/net/equipmenthandler.cpp +++ b/src/net/equipmenthandler.cpp @@ -23,7 +23,6 @@ #include "messagein.h" #include "protocol.h" -#include "../beingmanager.h" #include "../equipment.h" #include "../inventory.h" #include "../item.h" diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index c847b4c1..df86b634 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -25,7 +25,6 @@ #include #include "messagehandler.h" -#include struct LoginData; diff --git a/src/net/partyhandler.cpp b/src/net/partyhandler.cpp index d4b7455b..2437d0a0 100644 --- a/src/net/partyhandler.cpp +++ b/src/net/partyhandler.cpp @@ -29,7 +29,6 @@ #include "../gui/confirm_dialog.h" #include "../beingmanager.h" -#include "../game.h" #include "../party.h" PartyHandler::PartyHandler(Party *party) : mParty(party) diff --git a/src/npc.cpp b/src/npc.cpp index cef98e45..7b7db125 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -20,7 +20,6 @@ */ #include "animatedsprite.h" -#include "graphics.h" #include "localplayer.h" #include "npc.h" #include "particle.h" diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index d3278c1a..e7e7b204 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -19,14 +19,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include -#include -#include - #include "log.h" -#include "main.h" #include "openglgraphics.h" #include "resources/image.h" diff --git a/src/particle.cpp b/src/particle.cpp index 4de9fe29..d89d0a3e 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -22,6 +22,8 @@ #include #include +#include + #include "animationparticle.h" #include "configuration.h" #include "imageparticle.h" diff --git a/src/particle.h b/src/particle.h index 87e4d69d..881bbb74 100644 --- a/src/particle.h +++ b/src/particle.h @@ -25,8 +25,6 @@ #include #include -#include - #include "guichanfwd.h" #include "sprite.h" #include "vector.h" diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index d100ba27..1ed51053 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -21,9 +21,9 @@ #include +#include "particle.h" #include "particlecontainer.h" - ParticleContainer::ParticleContainer(ParticleContainer *parent, bool delParent) : mDelParent(delParent), mNext(parent) @@ -103,9 +103,6 @@ void ParticleList::moveTo(float x, float y) } } - - - // -- particle vector ---------------------------------------- ParticleVector::ParticleVector(ParticleContainer *parent, bool delParent) : diff --git a/src/particlecontainer.h b/src/particlecontainer.h index 0181f6e1..4fb00027 100644 --- a/src/particlecontainer.h +++ b/src/particlecontainer.h @@ -25,8 +25,7 @@ #include #include -#include "particle.h" - +class Particle; /** * Set of particle effects. May be stacked with other ParticleContainers. All @@ -65,8 +64,6 @@ protected: ParticleContainer *mNext; /**< Contained container, if any */ }; - - /** * Linked list of particle effects. */ @@ -94,7 +91,6 @@ protected: std::list mElements; /**< Contained particle effects */ }; - /** * Particle container with indexing facilities */ diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index ca9f7bf5..fa5dcde4 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -19,19 +19,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "animationparticle.h" #include "imageparticle.h" #include "log.h" #include "particle.h" #include "particleemitter.h" -#include "resources/animation.h" #include "resources/image.h" #include "resources/imageset.h" #include "resources/resourcemanager.h" -#include - #define SIN45 0.707106781f #define DEG_RAD_FACTOR 0.017453293f diff --git a/src/particleemitter.h b/src/particleemitter.h index cc77f215..67b35ae2 100644 --- a/src/particleemitter.h +++ b/src/particleemitter.h @@ -26,10 +26,10 @@ #include "utils/xml.h" -#include "resources/animation.h" - #include "particleemitterprop.h" +#include "resources/animation.h" + class Image; class Map; class Particle; diff --git a/src/particleemitterprop.h b/src/particleemitterprop.h index fde78f8f..e68ac222 100644 --- a/src/particleemitterprop.h +++ b/src/particleemitterprop.h @@ -20,7 +20,6 @@ */ #include -#include /** * Returns a random numeric value that is larger than or equal min and smaller diff --git a/src/party.cpp b/src/party.cpp index 67262176..e9304ada 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "beingmanager.h" #include "game.h" #include "localplayer.h" #include "party.h" diff --git a/src/player.cpp b/src/player.cpp index ca8c9f14..610dfeb1 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -19,16 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "animatedsprite.h" #include "game.h" -#include "graphics.h" -#include "log.h" #include "player.h" +#include "text.h" +#include "resources/colordb.h" #include "resources/itemdb.h" -#include "resources/iteminfo.h" #include "utils/strprintf.h" diff --git a/src/player.h b/src/player.h index 5fe9963a..f9911bb8 100644 --- a/src/player.h +++ b/src/player.h @@ -23,8 +23,8 @@ #define PLAYER_H #include "being.h" -#include "text.h" +class FlashText; class Graphics; class Map; diff --git a/src/player_relations.cpp b/src/player_relations.cpp index 057eea94..6386c246 100644 --- a/src/player_relations.cpp +++ b/src/player_relations.cpp @@ -21,12 +21,13 @@ #include +#include "being.h" #include "beingmanager.h" +#include "configuration.h" #include "graphics.h" +#include "player.h" #include "player_relations.h" -#include "gui/gui.h" - #define PLAYER_IGNORE_STRATEGY_NOP "nop" #define PLAYER_IGNORE_STRATEGY_EMOTE0 "emote0" #define DEFAULT_IGNORE_STRATEGY PLAYER_IGNORE_STRATEGY_EMOTE0 diff --git a/src/player_relations.h b/src/player_relations.h index 0f8bb4e3..1eb4ede6 100644 --- a/src/player_relations.h +++ b/src/player_relations.h @@ -27,9 +27,8 @@ #include #include -#include "being.h" -#include "configuration.h" -#include "player.h" +class Being; +class Player; struct PlayerRelation { diff --git a/src/properties.h b/src/properties.h index 91367552..4bad8e59 100644 --- a/src/properties.h +++ b/src/properties.h @@ -35,8 +35,7 @@ class Properties /** * Destructor. */ - virtual - ~Properties() {} + virtual ~Properties() {} /** * Get a map property. diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp index 8d7156a9..54c319de 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "animation.h" #include "../utils/dtor.h" diff --git a/src/resources/buddylist.h b/src/resources/buddylist.h index d769b2b8..f0758c25 100644 --- a/src/resources/buddylist.h +++ b/src/resources/buddylist.h @@ -27,7 +27,8 @@ #include -class BuddyList : public gcn::ListModel { +class BuddyList : public gcn::ListModel +{ public: /** * Constructor diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index f80ca6b3..7456f0e4 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -19,14 +19,12 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include "colordb.h" #include "../log.h" -#include "../utils/dtor.h" #include "../utils/gettext.h" #include "../utils/xml.h" diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index fd760c3f..63d85501 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include "dye.h" diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index 2f43822d..adc1635c 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -20,11 +20,9 @@ */ #include "emotedb.h" -#include "resourcemanager.h" #include "../log.h" -#include "../utils/dtor.h" #include "../utils/gettext.h" #include "../utils/xml.h" diff --git a/src/resources/image.h b/src/resources/image.h index 5b376053..9af10fda 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -40,6 +40,8 @@ #include "resource.h" class Dye; +class SDL_Rect; +class SDL_Surface; /** * Defines a class for loading and storing images. diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp index 8ad6c5d4..c182b44c 100644 --- a/src/resources/imageloader.cpp +++ b/src/resources/imageloader.cpp @@ -20,7 +20,6 @@ */ #include -#include #include #include diff --git a/src/resources/imagewriter.h b/src/resources/imagewriter.h index a9133846..039d3afb 100644 --- a/src/resources/imagewriter.h +++ b/src/resources/imagewriter.h @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - struct SDL_Surface; class ImageWriter diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 752ea38b..9976f0d4 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -24,8 +24,6 @@ #include #include "itemdb.h" -#include "iteminfo.h" -#include "resourcemanager.h" #include "../log.h" diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index e7c23ca2..08a7acd0 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -26,6 +26,8 @@ #include "iteminfo.h" +class ItemInfo; + /** * The namespace that holds the item information. */ diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index a4ec3b69..2278dc67 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -23,6 +23,7 @@ #include #include +#include "animation.h" #include "image.h" #include "mapreader.h" #include "resourcemanager.h" diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h index ef945c3f..0ed553c3 100644 --- a/src/resources/mapreader.h +++ b/src/resources/mapreader.h @@ -22,8 +22,6 @@ #ifndef MAPREADER_H #define MAPREADER_H -#include - #include class Map; diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index c7926260..c7824a5d 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -20,7 +20,7 @@ */ #include "monsterdb.h" -#include "resourcemanager.h" +#include "monsterinfo.h" #include "../log.h" diff --git a/src/resources/monsterdb.h b/src/resources/monsterdb.h index 6fbde55f..0a218661 100644 --- a/src/resources/monsterdb.h +++ b/src/resources/monsterdb.h @@ -24,7 +24,7 @@ #include -#include "monsterinfo.h" +class MonsterInfo; /** * Monster information database. diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index 88572481..73c3939d 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -20,11 +20,9 @@ */ #include "npcdb.h" -#include "resourcemanager.h" #include "../log.h" -#include "../utils/dtor.h" #include "../utils/gettext.h" #include "../utils/xml.h" diff --git a/src/resources/resource.h b/src/resources/resource.h index 303b82c8..7c5f989e 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -62,8 +62,7 @@ class Resource /** * Destructor. */ - virtual - ~Resource(); + virtual ~Resource(); private: std::string mIdPath; /**< Path identifying this resource. */ diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h index 05ec9e54..116df930 100644 --- a/src/resources/soundeffect.h +++ b/src/resources/soundeffect.h @@ -35,8 +35,7 @@ class SoundEffect : public Resource /** * Destructor. */ - virtual - ~SoundEffect(); + virtual ~SoundEffect(); /** * Loads a sample from a buffer in memory. diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 17d9ce60..9066ed7f 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -19,14 +19,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "graphics.h" #include "log.h" #include "simpleanimation.h" +#include "resources/animation.h" #include "resources/image.h" #include "resources/imageset.h" #include "resources/resourcemanager.h" +SimpleAnimation::SimpleAnimation(Animation *animation): + mAnimation(animation), + mAnimationTime(0), + mAnimationPhase(0), + mCurrentFrame(mAnimation->getFrame(0)) +{ +}; + SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode): mAnimationTime(0), mAnimationPhase(0) diff --git a/src/simpleanimation.h b/src/simpleanimation.h index a7178145..16ac2906 100644 --- a/src/simpleanimation.h +++ b/src/simpleanimation.h @@ -22,12 +22,12 @@ #ifndef SIMPLEANIMAION_H #define SIMPLEANIMAION_H -#include "resources/animation.h" - #include "utils/xml.h" +class Animation; class Frame; class Graphics; +class Image; /** * This class is a leightweight alternative to the AnimatedSprite class. @@ -39,12 +39,7 @@ class SimpleAnimation /** * Creates a simple animation with an already created animation. */ - SimpleAnimation(Animation *animation): - mAnimation(animation), - mAnimationTime(0), - mAnimationPhase(0), - mCurrentFrame(mAnimation->getFrame(0)) - {}; + SimpleAnimation(Animation *animation); /** * Creates a simple animation that creates its animation from XML Data. diff --git a/src/text.cpp b/src/text.cpp index 14ee3919..8f93f157 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -18,8 +18,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include - #include #include "text.h" @@ -72,7 +70,7 @@ Text::~Text() } } -void Text::draw(Graphics *graphics, int xOff, int yOff) +void Text::draw(gcn::Graphics *graphics, int xOff, int yOff) { graphics->setFont(boldFont); @@ -102,7 +100,7 @@ FlashText::FlashText(const std::string &text, int x, int y, { } -void FlashText::draw(Graphics *graphics, int xOff, int yOff) +void FlashText::draw(gcn::Graphics *graphics, int xOff, int yOff) { if (mTime) { diff --git a/src/text.h b/src/text.h index 43d6b5ea..c898bbe3 100644 --- a/src/text.h +++ b/src/text.h @@ -21,10 +21,10 @@ #ifndef TEXT_H #define TEXT_H -#include "graphics.h" -#include "guichanfwd.h" +#include +#include -#include +#include "guichanfwd.h" class TextManager; @@ -52,7 +52,7 @@ class Text /** * Draws the text. */ - virtual void draw(Graphics *graphics, int xOff, int yOff); + virtual void draw(gcn::Graphics *graphics, int xOff, int yOff); private: int mX; /**< Actual x-value of left of text written. */ @@ -84,7 +84,7 @@ class FlashText : public Text /** * Draws the text */ - virtual void draw(Graphics *graphics, int xOff, int yOff); + virtual void draw(gcn::Graphics *graphics, int xOff, int yOff); private: int mTime; /**< Time left for flashing */ diff --git a/src/textmanager.cpp b/src/textmanager.cpp index 7c5d2713..d40ba4d2 100644 --- a/src/textmanager.cpp +++ b/src/textmanager.cpp @@ -59,7 +59,7 @@ TextManager::~TextManager() { } -void TextManager::draw(Graphics *graphics, int xOff, int yOff) +void TextManager::draw(gcn::Graphics *graphics, int xOff, int yOff) { for (TextList::iterator bPtr = mTextList.begin(), ePtr = mTextList.end(); bPtr != ePtr; ++bPtr) @@ -89,21 +89,13 @@ void TextManager::place(const Text *textObj, const Text *omit, int from = (*ptr)->mY - occupiedTop; int to = from + (*ptr)->mHeight - 1; if (to < 0 || from >= TEST) // out of range considered - { continue; - } if (from < 0) - { from = 0; - } if (to >= TEST) - { to = TEST - 1; - } for (int i = from; i <= to; ++i) - { occupied[i] = true; - } } } bool ok = true; @@ -111,10 +103,10 @@ void TextManager::place(const Text *textObj, const Text *omit, { ok = ok && !occupied[i]; } + if (ok) - { return; - } + // Have to move it up or down, so find nearest spaces either side int consec = 0; int upSlot = -1; // means not found diff --git a/src/textmanager.h b/src/textmanager.h index a08660d5..b1e10f08 100644 --- a/src/textmanager.h +++ b/src/textmanager.h @@ -23,8 +23,9 @@ #include +#include "guichanfwd.h" + class Text; -class Graphics; class TextManager { @@ -57,7 +58,7 @@ class TextManager /** * Draw the text */ - void draw(Graphics *graphics, int xOff, int yOff); + void draw(gcn::Graphics *graphics, int xOff, int yOff); private: /** diff --git a/src/textparticle.cpp b/src/textparticle.cpp index 7e329b4e..f38c32ce 100644 --- a/src/textparticle.cpp +++ b/src/textparticle.cpp @@ -19,6 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "graphics.h" #include "textparticle.h" diff --git a/src/textparticle.h b/src/textparticle.h index bc7cd88c..cdf99d8f 100644 --- a/src/textparticle.h +++ b/src/textparticle.h @@ -22,8 +22,6 @@ #ifndef _TEXTPARTICLE_H #define _TEXTPARTICLE_H -#include - #include "guichanfwd.h" #include "particle.h" diff --git a/src/utils/tostring.h b/src/utils/tostring.h index eb86f99e..62eb44e4 100644 --- a/src/utils/tostring.h +++ b/src/utils/tostring.h @@ -34,7 +34,7 @@ std::string toString(const T &arg) // TODO: Is there a good way to suppress warnings from classes which don't use // this function? -static char *iptostring(int address) +inline char *iptostring(int address) { static char asciiIP[16]; -- cgit v1.2.3-70-g09d2 From 40edf4e91558cffd83d9015a2cf4a16360e27855 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sun, 8 Feb 2009 19:59:28 -0700 Subject: Mostly fixed a few field values to behave better in Windows, as well as removed the need for sending graphics to the setSpeech function (since it isn't needed) and started actually using the time variable which it's passed (could be set to show the speech longer if the dialog is longer, for example). Signed-off-by: Ira Rice --- src/being.cpp | 4 ++-- src/being.h | 7 +++++-- src/game.h | 3 --- src/gui/setup_audio.cpp | 4 ++-- src/gui/setup_joystick.cpp | 2 +- src/gui/setup_keyboard.cpp | 7 +++---- src/gui/setup_video.cpp | 52 +++++++++++++++++++++++----------------------- src/gui/viewport.cpp | 2 +- src/party.cpp | 2 +- src/player_relations.cpp | 2 +- 10 files changed, 42 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index 2b4ba767..9b8ede27 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -215,7 +215,7 @@ void Being::setSpeech(const std::string &text, Uint32 time) } if (mSpeech != "") - mSpeechTime = 500; + mSpeechTime = time <= SPEECH_MAX_TIME ? time : SPEECH_MAX_TIME; } void Being::takeDamage(int amount) @@ -501,7 +501,7 @@ void Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY) emotionSet[emotionIndex]->draw(graphics, px, py); } -void Being::drawSpeech(Graphics *graphics, int offsetX, int offsetY) +void Being::drawSpeech(int offsetX, int offsetY) { int px = mPx + offsetX; int py = mPy + offsetY; diff --git a/src/being.h b/src/being.h index 109a44ad..d722092e 100644 --- a/src/being.h +++ b/src/being.h @@ -39,6 +39,9 @@ #define FIRST_IGNORE_EMOTE 14 #define STATUS_EFFECTS 32 +#define SPEECH_TIME 500 +#define SPEECH_MAX_TIME 1000 + class AnimatedSprite; class Image; class ItemInfo; @@ -152,7 +155,7 @@ class Being : public Sprite * @param text The text that should appear. * @param time The amount of time the text should stay in milliseconds. */ - void setSpeech(const std::string &text, Uint32 time); + void setSpeech(const std::string &text, Uint32 time = 500); /** * Puts a damage bubble above this being. @@ -244,7 +247,7 @@ class Being : public Sprite /** * Draws the speech text above the being. */ - void drawSpeech(Graphics *graphics, int offsetX, int offsetY); + void drawSpeech(int offsetX, int offsetY); /** * Draws the emotion picture above the being. diff --git a/src/game.h b/src/game.h index c9fc8d79..e885ea16 100644 --- a/src/game.h +++ b/src/game.h @@ -26,9 +26,6 @@ #include "configlistener.h" -#define SPEECH_TIME 80 -#define SPEECH_MAX_TIME 100 - class MessageHandler; class Network; diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index 7090136e..5c189882 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -109,8 +109,8 @@ void Setup_Audio::cancel() sound.setMusicVolume(mMusicVolume); mMusicSlider->setValue(mMusicVolume); - config.setValue("sound", mSoundEnabled ? 1 : 0); - config.setValue("sfxVolume", mSfxVolume ? 1 : 0); + config.setValue("sound", mSoundEnabled ? true : false); + config.setValue("sfxVolume", mSfxVolume); config.setValue("musicVolume", mMusicVolume); } diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp index 2c726b87..2ebcdbde 100644 --- a/src/gui/setup_joystick.cpp +++ b/src/gui/setup_joystick.cpp @@ -41,7 +41,7 @@ Setup_Joystick::Setup_Joystick(): { setOpaque(false); - mOriginalJoystickEnabled = (int)config.getValue("joystickEnabled", 0) != 0; + mOriginalJoystickEnabled = !config.getValue("joystickEnabled", false); mJoystickEnabled->setSelected(mOriginalJoystickEnabled); mJoystickEnabled->addActionListener(this); diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index 6a4363fe..06a5a520 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -32,7 +32,6 @@ #include "widgets/layouthelper.h" -#include "../configuration.h" #include "../keyboardconfig.h" #include "../utils/gettext.h" @@ -138,9 +137,8 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event) { if (event.getSource() == mKeyList) { - if (!mKeySetting) { + if (!mKeySetting) mAssignKeyButton->setEnabled(true); - } } else if (event.getId() == "assign") { @@ -184,7 +182,8 @@ void Setup_Keyboard::refreshKeys() void Setup_Keyboard::keyUnresolved() { - if (mKeySetting) { + if (mKeySetting) + { newKeyCallback(keyboard.getNewKeyIndex()); keyboard.setNewKeyIndex(keyboard.KEY_NO_VALUE); } diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index faf72c68..1775665f 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -104,12 +104,12 @@ ModeListModel::ModeListModel() } Setup_Video::Setup_Video(): - mFullScreenEnabled(config.getValue("screen", 0)), - mOpenGLEnabled(config.getValue("opengl", 0)), - mCustomCursorEnabled(config.getValue("customcursor", 1)), - mParticleEffectsEnabled(config.getValue("particleeffects", 1)), - mSpeechBubbleEnabled(config.getValue("speechbubble", 1)), - mNameEnabled(config.getValue("showownname", 0)), + mFullScreenEnabled(config.getValue("screen", false)), + mOpenGLEnabled(config.getValue("opengl", false)), + mCustomCursorEnabled(config.getValue("customcursor", true)), + mParticleEffectsEnabled(config.getValue("particleeffects", true)), + mSpeechBubbleEnabled(config.getValue("speechbubble", true)), + mNameEnabled(config.getValue("showownname", false)), mOpacity(config.getValue("guialpha", 0.8)), mFps((int) config.getValue("fpslimit", 0)), mModeListModel(new ModeListModel), @@ -280,7 +280,7 @@ void Setup_Video::apply() { // Full screen changes bool fullscreen = mFsCheckBox->isSelected(); - if (fullscreen != (config.getValue("screen", 0) == 1)) + if (fullscreen != (config.getValue("screen", false) == 1)) { /* The OpenGL test is only necessary on Windows, since switching * to/from full screen works fine on Linux. On Windows we'd have to @@ -291,7 +291,7 @@ void Setup_Video::apply() #ifdef WIN32 // checks for opengl usage - if (!(config.getValue("opengl", 0) == 1)) + if (!(config.getValue("opengl", false) == 1)) { #endif if (!graphics->setFullscreen(fullscreen)) @@ -313,13 +313,13 @@ void Setup_Video::apply() _("Restart needed for changes to take effect.")); } #endif - config.setValue("screen", fullscreen ? 1 : 0); + config.setValue("screen", fullscreen ? true : false); } // OpenGL change if (mOpenGLCheckBox->isSelected() != mOpenGLEnabled) { - config.setValue("opengl", mOpenGLCheckBox->isSelected() ? 1 : 0); + config.setValue("opengl", mOpenGLCheckBox->isSelected() ? true : false); // OpenGL can currently only be changed by restarting, notify user. new OkDialog(_("Changing OpenGL"), @@ -330,14 +330,14 @@ void Setup_Video::apply() config.setValue("fpslimit", mFps); // We sync old and new values at apply time - mFullScreenEnabled = config.getValue("screen", 0); - mCustomCursorEnabled = config.getValue("customcursor", 1); - mParticleEffectsEnabled = config.getValue("particleeffects", 1); - mSpeechBubbleEnabled = config.getValue("speechbubble", 1); - mNameEnabled = config.getValue("showownname", 0); + mFullScreenEnabled = config.getValue("screen", false); + mCustomCursorEnabled = config.getValue("customcursor", true); + mParticleEffectsEnabled = config.getValue("particleeffects", true); + mSpeechBubbleEnabled = config.getValue("speechbubble", true); + mNameEnabled = config.getValue("showownname", false); mOpacity = config.getValue("guialpha", 0.8); mOverlayDetail = (int) config.getValue("OverlayDetail", 2); - mOpenGLEnabled = config.getValue("opengl", 0); + mOpenGLEnabled = config.getValue("opengl", false); } int Setup_Video::updateSlider(gcn::Slider *slider, gcn::TextField *field, @@ -377,13 +377,13 @@ void Setup_Video::cancel() updateSlider(mScrollRadiusSlider, mScrollRadiusField, "ScrollRadius"); updateSlider(mScrollLazinessSlider, mScrollLazinessField, "ScrollLaziness"); - config.setValue("screen", mFullScreenEnabled ? 1 : 0); - config.setValue("customcursor", mCustomCursorEnabled ? 1 : 0); - config.setValue("particleeffects", mParticleEffectsEnabled ? 1 : 0); - config.setValue("speechbubble", mSpeechBubbleEnabled ? 1 : 0); - config.setValue("showownname", mNameEnabled ? 1 : 0); + config.setValue("screen", mFullScreenEnabled ? true : false); + config.setValue("customcursor", mCustomCursorEnabled ? true : false); + config.setValue("particleeffects", mParticleEffectsEnabled ? true : false); + config.setValue("speechbubble", mSpeechBubbleEnabled ? true : false); + config.setValue("showownname", mNameEnabled ? true : false); config.setValue("guialpha", mOpacity); - config.setValue("opengl", mOpenGLEnabled ? 1 : 0); + config.setValue("opengl", mOpenGLEnabled ? true : false); } void Setup_Video::action(const gcn::ActionEvent &event) @@ -408,19 +408,19 @@ void Setup_Video::action(const gcn::ActionEvent &event) else if (event.getId() == "customcursor") { config.setValue("customcursor", - mCustomCursorCheckBox->isSelected() ? 1 : 0); + mCustomCursorCheckBox->isSelected() ? true : false); } else if (event.getId() == "particleeffects") { config.setValue("particleeffects", - mParticleEffectsCheckBox->isSelected() ? 1 : 0); + mParticleEffectsCheckBox->isSelected() ? true : false); new OkDialog(_("Particle effect settings changed"), _("Restart your client or change maps for the change to take effect.")); } else if (event.getId() == "speechbubble") { config.setValue("speechbubble", - mSpeechBubbleCheckBox->isSelected() ? 1 : 0); + mSpeechBubbleCheckBox->isSelected() ? true : false); } else if (event.getId() == "showownname") { @@ -429,7 +429,7 @@ void Setup_Video::action(const gcn::ActionEvent &event) if (player_node) player_node->mUpdateName = true; config.setValue("showownname", - mNameCheckBox->isSelected() ? 1 : 0); + mNameCheckBox->isSelected() ? true : false); } else if (event.getId() == "fpslimitslider") { diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 25e69c43..19e9a4fb 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -207,7 +207,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) Beings &beings = beingManager->getAll(); for (BeingIterator i = beings.begin(); i != beings.end(); i++) { - (*i)->drawSpeech(graphics, -(int) mPixelViewX, -(int) mPixelViewY); + (*i)->drawSpeech(-(int) mPixelViewX, -(int) mPixelViewY); (*i)->drawEmotion(graphics, -(int) mPixelViewX, -(int) mPixelViewY); } diff --git a/src/party.cpp b/src/party.cpp index e9304ada..70e0d3c2 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "game.h" +#include "being.h" #include "localplayer.h" #include "party.h" diff --git a/src/player_relations.cpp b/src/player_relations.cpp index 6386c246..aa83115c 100644 --- a/src/player_relations.cpp +++ b/src/player_relations.cpp @@ -305,7 +305,7 @@ public: virtual void ignore(Player *player, unsigned int flags) { - player->setSpeech("...", 5); + player->setSpeech("...", 500); } }; -- cgit v1.2.3-70-g09d2