From 5554fdc59a308c46012f3afa16af60d66a00465e Mon Sep 17 00:00:00 2001 From: Kraant Date: Sun, 10 Aug 2008 10:56:58 +0000 Subject: Set headers for CURL so that proxies won't cache Applied only to resources2.txt and news.txt. (cherry picked from commits 047f598be826dd57dd1124db914e8367256112be, cabf8905526b6601813573d049f6afaf364e1cac and 416e28057f5a6073a2ef44f296ed1c8bc1280bf6) --- src/gui/updatewindow.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/gui') diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index ff1e600c..0d6b00af 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -315,6 +315,17 @@ int UpdaterWindow::downloadThread(void *ptr) curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 15); + struct curl_slist *pHeaders = NULL; + if (uw->mDownloadStatus != UPDATE_RESOURCES) + { + // Make sure the resources2.txt and news.txt aren't cached, + // in order to always get the latest version. + pHeaders = curl_slist_append(pHeaders, "pragma: no-cache"); + pHeaders = + curl_slist_append(pHeaders, "Cache-Control: no-cache"); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, pHeaders); + } + if ((res = curl_easy_perform(curl)) != 0) { uw->mDownloadStatus = UPDATE_ERROR; @@ -339,6 +350,11 @@ int UpdaterWindow::downloadThread(void *ptr) curl_easy_cleanup(curl); + if (uw->mDownloadStatus != UPDATE_RESOURCES) + { + curl_slist_free_all(pHeaders); + } + if (!uw->mStoreInMemory) { // Don't check resources2.txt checksum -- cgit v1.2.3-70-g09d2 From 1ad1ed215a9f33d2d55efbfb43130dfc58a2a1a4 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 5 Dec 2008 23:01:54 +0100 Subject: Fade out mouse cursor when not used for some time The mouse cursor will now disappear when not used for 15 seconds. When using OpenGL it will even fade. Requested by doorsman. (cherry picked from eAthena branch) --- src/gui/gui.cpp | 47 +++++++++++++++++++++++++++++++++++------------ src/gui/gui.h | 11 +++++++++++ 2 files changed, 46 insertions(+), 12 deletions(-) (limited to 'src/gui') diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 930d4939..dc6306b4 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -37,6 +37,7 @@ #include "../graphics.h" #include "../log.h" +#include "../resources/image.h" #include "../resources/imageset.h" #include "../resources/resourcemanager.h" #include "../resources/imageloader.h" @@ -74,6 +75,8 @@ class GuiConfigListener : public ConfigListener Gui::Gui(Graphics *graphics): mCustomCursor(false), mMouseCursors(NULL), + mMouseCursorAlpha(1.0f), + mMouseInactivityTimer(0), mCursorType(CURSOR_POINTER) { logger->log("Initializing GUI..."); @@ -157,32 +160,47 @@ Gui::~Gui() delete hitBlueFont; delete hitYellowFont; - if (mMouseCursors) { + if (mMouseCursors) mMouseCursors->decRef(); - } delete mGuiFont; delete speechFont; delete viewport; - delete mTop; + delete getTop(); delete guiInput; } -void -Gui::draw() +void Gui::logic() +{ + // Fade out mouse cursor after extended inactivity + if (mMouseInactivityTimer < 100 * 15) { + ++mMouseInactivityTimer; + mMouseCursorAlpha = std::min(1.0f, mMouseCursorAlpha + 0.05f); + } else { + mMouseCursorAlpha = std::max(0.0f, mMouseCursorAlpha - 0.005f); + } + + gcn::Gui::logic(); +} + +void Gui::draw() { - mGraphics->pushClipArea(mTop->getDimension()); - mTop->draw(mGraphics); + mGraphics->pushClipArea(getTop()->getDimension()); + getTop()->draw(mGraphics); int mouseX, mouseY; Uint8 button = SDL_GetMouseState(&mouseX, &mouseY); - if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS || button & SDL_BUTTON(1)) && - mCustomCursor) + if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS || button & SDL_BUTTON(1)) + && mCustomCursor + && mMouseCursorAlpha > 0.0f) { + Image *mouseCursor = mMouseCursors->get(mCursorType); + mouseCursor->setAlpha(mMouseCursorAlpha); + static_cast(mGraphics)->drawImage( - mMouseCursors->get(mCursorType), + mouseCursor, mouseX - 15, mouseY - 17); } @@ -190,8 +208,7 @@ Gui::draw() mGraphics->popClipArea(); } -void -Gui::setUseCustomCursor(bool customCursor) +void Gui::setUseCustomCursor(bool customCursor) { if (customCursor != mCustomCursor) { @@ -224,3 +241,9 @@ Gui::setUseCustomCursor(bool customCursor) } } } + +void Gui::handleMouseMoved(const gcn::MouseInput &mouseInput) +{ + gcn::Gui::handleMouseMoved(mouseInput); + mMouseInactivityTimer = 0; +} diff --git a/src/gui/gui.h b/src/gui/gui.h index a07d236f..7d390df9 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -58,6 +58,12 @@ class Gui : public gcn::Gui */ ~Gui(); + /** + * Performs logic of the GUI. Overridden to track mouse pointer + * activity. + */ + void logic(); + /** * Draws the whole Gui by calling draw functions down in the * Gui hierarchy. It also draws the mouse pointer. @@ -95,11 +101,16 @@ class Gui : public gcn::Gui CURSOR_TOTAL }; + protected: + void handleMouseMoved(const gcn::MouseInput &mouseInput); + private: GuiConfigListener *mConfigListener; gcn::Font *mGuiFont; /**< The global GUI font */ bool mCustomCursor; /**< Show custom cursor */ ImageSet *mMouseCursors; /**< Mouse cursor images */ + float mMouseCursorAlpha; + int mMouseInactivityTimer; int mCursorType; }; -- cgit v1.2.3-70-g09d2 From d26abb724e4d64ca7be507d99d80ab778813684f Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 5 Dec 2008 21:38:31 +0100 Subject: Fix race condition with a std::string access The downloading thread was writing to a std::string while the main thread was trying to draw it, for example. Now access to the label caption is guarded with a mutex. Should fix crashes while downloading updates. (cherry picked from eAthena branch, commits 6ac9c3bce62a8fc79e23477417188108f0ad9fa6 and 06d0205bab253ec5d01e8483ab639a092fe117c5) --- src/Makefile.am | 1 + src/gui/updatewindow.cpp | 31 ++++++++++------ src/gui/updatewindow.h | 13 +++++-- src/utils/mutex.h | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 15 deletions(-) create mode 100644 src/utils/mutex.h (limited to 'src/gui') diff --git a/src/Makefile.am b/src/Makefile.am index e953507a..65e8cafd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -282,6 +282,7 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ utils/strprintf.cpp \ utils/tostring.h \ utils/trim.h \ + utils/mutex.h \ utils/xml.cpp \ utils/xml.h \ animatedsprite.cpp \ diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 0d6b00af..997a9b82 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -47,7 +47,7 @@ /** * Calculates the Alder-32 checksum for the given file. */ -unsigned long fadler32(FILE *file) +static unsigned long fadler32(FILE *file) { // Obtain file size fseek(file, 0, SEEK_END); @@ -146,15 +146,9 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, UpdaterWindow::~UpdaterWindow() { if (mThread) - { - SDL_WaitThread(mThread, NULL); - mThread = NULL; - } + SDL_WaitThread(mThread, NULL); - if (mMemoryBuffer) - { - free(mMemoryBuffer); - } + free(mMemoryBuffer); // Remove possibly leftover temporary download ::remove((mUpdatesDir + "/download.temp").c_str()); @@ -169,8 +163,9 @@ void UpdaterWindow::setProgress(float p) void UpdaterWindow::setLabel(const std::string &str) { - mLabel->setCaption(str); - mLabel->adjustSize(); + // Do delayed label text update, since Guichan isn't thread-safe + MutexLocker lock(&mLabelMutex); + mNewLabelCaption = str; } void UpdaterWindow::enable() @@ -429,6 +424,17 @@ void UpdaterWindow::logic() // Update Scroll logic mScrollArea->logic(); + // Synchronize label caption when necessary + { + MutexLocker lock(&mLabelMutex); + + if (mLabel->getCaption() != mNewLabelCaption) + { + mLabel->setCaption(mNewLabelCaption); + mLabel->adjustSize(); + } + } + switch (mDownloadStatus) { case UPDATE_ERROR: @@ -450,7 +456,8 @@ void UpdaterWindow::logic() mBrowserBox->addRow("##1 It is strongly recommended that"); mBrowserBox->addRow("##1 you try again later"); mBrowserBox->addRow(mCurlError); - mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll()); + mScrollArea->setVerticalScrollAmount( + mScrollArea->getVerticalMaxScroll()); mDownloadStatus = UPDATE_COMPLETE; break; case UPDATE_NEWS: diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h index d7e3c4c7..a7dfe2cb 100644 --- a/src/gui/updatewindow.h +++ b/src/gui/updatewindow.h @@ -30,12 +30,13 @@ #include "../guichanfwd.h" +#include "../utils/mutex.h" + class BrowserBox; class Button; class ProgressBar; class ScrollArea; -struct SDL_mutex; struct SDL_Thread; /** @@ -88,7 +89,7 @@ class UpdaterWindow : public Window, public gcn::ActionListener int updateState; - protected: +private: void download(); /** @@ -133,6 +134,12 @@ class UpdaterWindow : public Window, public gcn::ActionListener /** The file currently downloading. */ std::string mCurrentFile; + /** The new label caption to be set in the logic method. */ + std::string mNewLabelCaption; + + /** The mutex used to guard access to mNewLabelCaption. */ + Mutex mLabelMutex; + /** The Adler32 checksum of the file currently downloading. */ unsigned long mCurrentChecksum; @@ -164,7 +171,7 @@ class UpdaterWindow : public Window, public gcn::ActionListener Button *mCancelButton; /**< Button to stop the update process. */ Button *mPlayButton; /**< Button to start playing. */ ProgressBar *mProgressBar; /**< Update progress bar. */ - BrowserBox* mBrowserBox; /**< Box to display news. */ + BrowserBox *mBrowserBox; /**< Box to display news. */ ScrollArea *mScrollArea; /**< Used to scroll news box. */ }; diff --git a/src/utils/mutex.h b/src/utils/mutex.h new file mode 100644 index 00000000..62c6b4e1 --- /dev/null +++ b/src/utils/mutex.h @@ -0,0 +1,97 @@ +/* + * The Mana World + * Copyright 2008 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 TMW_MUTEX_H +#define TMW_MUTEX_H + +#include + +#include "../log.h" + +/** + * A mutex provides mutual exclusion of access to certain data that is + * accessed by multiple threads. + */ +class Mutex +{ +public: + Mutex(); + ~Mutex(); + + void lock(); + void unlock(); + +private: + Mutex(const Mutex&); // prevent copying + Mutex& operator=(const Mutex&); + + SDL_mutex *mMutex; +}; + +/** + * A convenience class for locking a mutex. + */ +class MutexLocker +{ +public: + MutexLocker(Mutex *mutex); + ~MutexLocker(); + +private: + Mutex *mMutex; +}; + + +inline Mutex::Mutex() +{ + mMutex = SDL_CreateMutex(); +} + +inline Mutex::~Mutex() +{ + SDL_DestroyMutex(mMutex); +} + +inline void Mutex::lock() +{ + if (SDL_mutexP(mMutex) == -1) + logger->log("Mutex locking failed: %s", SDL_GetError()); +} + +inline void Mutex::unlock() +{ + if (SDL_mutexV(mMutex) == -1) + logger->log("Mutex unlocking failed: %s", SDL_GetError()); +} + + +inline MutexLocker::MutexLocker(Mutex *mutex): + mMutex(mutex) +{ + mMutex->lock(); +} + +inline MutexLocker::~MutexLocker() +{ + mMutex->unlock(); +} + +#endif // TMW_MUTEX_H -- cgit v1.2.3-70-g09d2 From 48edf44d7fafe90321e92e05cb22b300d9cad6d9 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 1 Nov 2008 03:36:47 +0000 Subject: Made NPC dialogues resizeable. Conflicts: src/gui/inventorywindow.cpp src/gui/npc_text.cpp (cherry picked from eAthena commit 523eed88816298b1660ecb9e67db80776e4007bb) --- src/gui/npc_text.cpp | 37 +++++++++++++++++++++++++++++++++---- src/gui/npc_text.h | 16 ++++++++++++++++ src/gui/npclistdialog.cpp | 33 ++++++++++++++++++++++++++++++--- src/gui/npclistdialog.h | 15 +++++++++++++++ 4 files changed, 94 insertions(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index c593feb1..60505794 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -34,10 +34,16 @@ NpcTextDialog::NpcTextDialog(): Window(_("NPC")) { + setResizable(true); + + setMinWidth(200); + setMinHeight(150); + mTextBox = new TextBox; mTextBox->setEditable(false); - gcn::ScrollArea *scrollArea = new ScrollArea(mTextBox); - Button *okButton = new Button(_("Ok"), "ok", this); + + scrollArea = new ScrollArea(mTextBox); + okButton = new Button(_("OK"), "ok", this); setContentSize(260, 175); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -57,13 +63,36 @@ NpcTextDialog::NpcTextDialog(): void NpcTextDialog::setText(const std::string &text) { - mTextBox->setTextWrapped(text); + mText = text; + draw(); } void NpcTextDialog::addText(const std::string &text) { - mTextBox->setTextWrapped(mTextBox->getText() + text + "\n"); + mText = mTextBox->getText() + text + "\n"; + draw(); +} + +void NpcTextDialog::widgetResized(const gcn::Event &event) +{ + Window::widgetResized(event); + draw(); +} + +void NpcTextDialog::draw() +{ + const gcn::Rectangle &area = getChildrenArea(); + const int width = area.width; + const int height = area.height; + + mTextBox->setTextWrapped(mText); + + scrollArea->setDimension(gcn::Rectangle( + 5, 5, width - 10, height - 15 - okButton->getHeight())); + okButton->setPosition( + width - 5 - okButton->getWidth(), + height - 5 - okButton->getHeight()); } void diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 2c9771d3..939fb8fa 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -44,6 +44,18 @@ class NpcTextDialog : public Window, public gcn::ActionListener */ NpcTextDialog(); + /** + * Called when resizing the window + * + * @param event The calling event + */ + void widgetResized(const gcn::Event &event); + + /** + * Redraws the window + */ + void draw(); + /** * Called when receiving actions from the widgets. */ @@ -68,7 +80,11 @@ class NpcTextDialog : public Window, public gcn::ActionListener addText(const std::string &string); private: + gcn::Button *okButton; + gcn::ScrollArea *scrollArea; TextBox *mTextBox; + + std::string mText; }; #endif diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index 918031b4..e896778c 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -34,10 +34,15 @@ NpcListDialog::NpcListDialog(): Window(_("NPC")) { + setResizable(true); + + setMinWidth(200); + setMinHeight(150); + mItemList = new ListBox(this); - ScrollArea *scrollArea = new ScrollArea(mItemList); - Button *okButton = new Button(_("Ok"), "ok", this); - Button *cancelButton = new Button(_("Cancel"), "cancel", this); + scrollArea = new ScrollArea(mItemList); + okButton = new Button(_("OK"), "ok", this); + cancelButton = new Button(_("Cancel"), "cancel", this); setContentSize(260, 175); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -84,6 +89,28 @@ NpcListDialog::reset() mItems.clear(); } +void NpcListDialog::widgetResized(const gcn::Event &event) +{ + Window::widgetResized(event); + draw(); +} + +void NpcListDialog::draw() +{ + const gcn::Rectangle &area = getChildrenArea(); + const int width = area.width; + const int height = area.height; + + scrollArea->setDimension(gcn::Rectangle( + 5, 5, width - 10, height - 15 - okButton->getHeight())); + cancelButton->setPosition( + width - 5 - cancelButton->getWidth(), + height - 5 - cancelButton->getHeight()); + okButton->setPosition( + cancelButton->getX() - 5 - okButton->getWidth(), + cancelButton->getY()); +} + void NpcListDialog::action(const gcn::ActionEvent &event) { diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index e21f9e8c..e5e973e7 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -48,6 +48,18 @@ class NpcListDialog : public Window, public gcn::ActionListener, */ NpcListDialog(); + /** + * Called when resizing the window + * + * @param event The calling event + */ + void widgetResized(const gcn::Event &event); + + /** + * Redraws the window + */ + void draw(); + /** * Called when receiving actions from the widgets. */ @@ -79,6 +91,9 @@ class NpcListDialog : public Window, public gcn::ActionListener, private: gcn::ListBox *mItemList; + gcn::ScrollArea *scrollArea; + gcn::Button *okButton; + gcn::Button *cancelButton; std::vector mItems; }; -- cgit v1.2.3-70-g09d2 From ceb3ff6bba5a4133000142920a21899114e91cd1 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 7 Dec 2008 02:00:41 +0100 Subject: Fixed wrapping in some cases, removed draw method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'draw' method was confusingly named, and was actually for updating the GUI after a resize. Its functionality has been merged into 'widgetResized'. The wrapping was broken in the case where text was added to the NPC dialog, cause it was added to an already wrapped string, causing the wrapping to become permanent. Sorry for all the reformatting. Signed-off-by: Bjørn Lindeijer (cherry picked from eAthena commit 43eb6ba950dd8bf978e539c7c7460ef5096438de) Conflicts: src/gui/npclistdialog.cpp src/gui/npclistdialog.h --- src/gui/npc_text.cpp | 23 ++++++++--------------- src/gui/npc_text.h | 16 ++++------------ src/gui/npclistdialog.cpp | 16 ++++------------ src/gui/npclistdialog.h | 19 +++++-------------- 4 files changed, 21 insertions(+), 53 deletions(-) (limited to 'src/gui') diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 60505794..c9ace303 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -60,43 +60,36 @@ NpcTextDialog::NpcTextDialog(): setLocationRelativeTo(getParent()); } -void -NpcTextDialog::setText(const std::string &text) +void NpcTextDialog::setText(const std::string &text) { mText = text; - draw(); + mTextBox->setTextWrapped(mText); } -void -NpcTextDialog::addText(const std::string &text) +void NpcTextDialog::addText(const std::string &text) { - mText = mTextBox->getText() + text + "\n"; - draw(); + setText(mText + text + "\n"); } void NpcTextDialog::widgetResized(const gcn::Event &event) { Window::widgetResized(event); - draw(); -} -void NpcTextDialog::draw() -{ const gcn::Rectangle &area = getChildrenArea(); const int width = area.width; const int height = area.height; - mTextBox->setTextWrapped(mText); - scrollArea->setDimension(gcn::Rectangle( 5, 5, width - 10, height - 15 - okButton->getHeight())); okButton->setPosition( width - 5 - okButton->getWidth(), height - 5 - okButton->getHeight()); + + // Set the text again so that it gets wrapped according to the new size + mTextBox->setTextWrapped(mText); } -void -NpcTextDialog::action(const gcn::ActionEvent &event) +void NpcTextDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "ok") { diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 939fb8fa..76161f88 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -51,24 +51,17 @@ class NpcTextDialog : public Window, public gcn::ActionListener */ void widgetResized(const gcn::Event &event); - /** - * Redraws the window - */ - void draw(); - /** * Called when receiving actions from the widgets. */ - void - action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event); /** * Sets the text shows in the dialog. * * @param string The new text. */ - void - setText(const std::string &string); + void setText(const std::string &string); /** * Adds the text to the text shows in the dialog. Also adds a newline @@ -76,8 +69,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener * * @param string The text to add. */ - void - addText(const std::string &string); + void addText(const std::string &string); private: gcn::Button *okButton; @@ -87,4 +79,4 @@ class NpcTextDialog : public Window, public gcn::ActionListener std::string mText; }; -#endif +#endif // _TMW_NPC_TEXT_H diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index e896778c..57783d96 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -66,14 +66,12 @@ NpcListDialog::NpcListDialog(): setLocationRelativeTo(getParent()); } -int -NpcListDialog::getNumberOfElements() +int NpcListDialog::getNumberOfElements() { return mItems.size(); } -std::string -NpcListDialog::getElementAt(int i) +std::string NpcListDialog::getElementAt(int i) { return mItems[i]; } @@ -83,8 +81,7 @@ void NpcListDialog::addItem(std::string const &item) mItems.push_back(item); } -void -NpcListDialog::reset() +void NpcListDialog::reset() { mItems.clear(); } @@ -92,11 +89,7 @@ NpcListDialog::reset() void NpcListDialog::widgetResized(const gcn::Event &event) { Window::widgetResized(event); - draw(); -} -void NpcListDialog::draw() -{ const gcn::Rectangle &area = getChildrenArea(); const int width = area.width; const int height = area.height; @@ -111,8 +104,7 @@ void NpcListDialog::draw() cancelButton->getY()); } -void -NpcListDialog::action(const gcn::ActionEvent &event) +void NpcListDialog::action(const gcn::ActionEvent &event) { int choice = 0; diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index e5e973e7..9d970ac2 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -55,28 +55,20 @@ class NpcListDialog : public Window, public gcn::ActionListener, */ void widgetResized(const gcn::Event &event); - /** - * Redraws the window - */ - void draw(); - /** * Called when receiving actions from the widgets. */ - void - action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event); /** * Returns the number of items in the choices list. */ - int - getNumberOfElements(); + int getNumberOfElements(); /** * Returns the name of item number i of the choices list. */ - std::string - getElementAt(int i); + std::string getElementAt(int i); /** * Adds an item to the option list. @@ -86,8 +78,7 @@ class NpcListDialog : public Window, public gcn::ActionListener, /** * Resets the list by removing all items. */ - void - reset(); + void reset(); private: gcn::ListBox *mItemList; @@ -98,4 +89,4 @@ class NpcListDialog : public Window, public gcn::ActionListener, std::vector mItems; }; -#endif +#endif // _TMW_GUI_NPCLISTDIALOG_H -- cgit v1.2.3-70-g09d2 From ba02a23b63bf0a1fde2194d163ead365d2a4fdf0 Mon Sep 17 00:00:00 2001 From: Fate Date: Sat, 1 Nov 2008 23:45:48 +0000 Subject: * Use hair.xml to determine hair colours (#514) * Auto-detect number of hair styles available (#514) Conflicts: ChangeLog src/being.cpp src/being.h src/gui/char_select.cpp (cherry picked from eAthena client) --- src/being.cpp | 94 +++++++++++++++++++++++++++++++++++++++++++++++-- src/being.h | 10 ++++-- src/gui/char_select.cpp | 7 ++-- src/player.cpp | 22 +++--------- 4 files changed, 108 insertions(+), 25 deletions(-) (limited to 'src/gui') diff --git a/src/being.cpp b/src/being.cpp index bade64b6..fbee967f 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -31,6 +31,7 @@ #include "map.h" #include "particle.h" +#include "resources/itemdb.h" #include "resources/resourcemanager.h" #include "resources/imageset.h" #include "resources/iteminfo.h" @@ -40,11 +41,14 @@ #include "utils/dtor.h" #include "utils/tostring.h" +#include "utils/xml.h" namespace { const bool debug_movement = true; } +#define HAIR_FILE "hair.xml" + int Being::instances = 0; ImageSet *Being::emotionSet = NULL; @@ -291,8 +295,8 @@ void Being::setPath(const Path &path) void Being::setHairStyle(int style, int color) { - mHairStyle = style < 0 ? mHairStyle : style % NR_HAIR_STYLES; - mHairColor = color < 0 ? mHairColor : color % NR_HAIR_COLORS; + mHairStyle = style < 0 ? mHairStyle : style % getHairStylesNr(); + mHairColor = color < 0 ? mHairColor : color % getHairColorsNr(); } void Being::setSprite(int slot, int id, const std::string &color) @@ -605,3 +609,89 @@ int Being::getHeight() const return 0; } } + + + + +static int hairStylesNr; +static int hairColorsNr; +static std::vector hairColors; + +static void +initializeHair(void); + +int +Being::getHairStylesNr(void) +{ + initializeHair(); + return hairStylesNr; +} + +int +Being::getHairColorsNr(void) +{ + initializeHair(); + return hairColorsNr; +} + +std::string +Being::getHairColor(int index) +{ + initializeHair(); + if (index < 0 || index >= hairColorsNr) + return "#000000"; + + return hairColors[index]; +} + +static bool hairInitialized = false; + +static void +initializeHair(void) +{ + if (hairInitialized) + return; + + // Hairstyles are encoded as negative numbers. Count how far negative we can go. + int hairstylesCtr = -1; + while (ItemDB::get(hairstylesCtr).getSprite(GENDER_MALE) != "error.xml") + --hairstylesCtr; + + hairStylesNr = -hairstylesCtr; // done. + if (hairStylesNr == 0) + hairStylesNr = 1; // No hair style -> no hair + + hairColorsNr = 0; + + XML::Document doc(HAIR_FILE); + xmlNodePtr root = doc.rootNode(); + + if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) + { + logger->log("Error loading being hair configuration file"); + } else { + for_each_xml_child_node(node, root) + { + if (xmlStrEqual(node->name, BAD_CAST "color")) + { + int index = atoi(XML::getProperty(node, "id", "-1").c_str()); + std::string value = XML::getProperty(node, "value", ""); + + if (index >= 0 && value != "") { + if (index >= hairColorsNr) { + hairColorsNr = index + 1; + hairColors.resize(hairColorsNr, "#000000"); + } + hairColors[index] = value; + } + } + } + } // done initializing + + if (hairColorsNr == 0) { // No colours -> black only + hairColorsNr = 1; + hairColors.resize(hairColorsNr, "#000000"); + } + + hairInitialized = 1; +} diff --git a/src/being.h b/src/being.h index cce5e99f..5e8cb2dc 100644 --- a/src/being.h +++ b/src/being.h @@ -33,9 +33,6 @@ #include "animatedsprite.h" #include "vector.h" -#define NR_HAIR_STYLES 8 -#define NR_HAIR_COLORS 10 - class AnimatedSprite; class Equipment; class ItemInfo; @@ -363,6 +360,13 @@ class Being : public Sprite */ const Path &getPath() const { return mPath; } + + static int getHairColorsNr(void); + + static int getHairStylesNr(void); + + static std::string getHairColor(int index); + protected: /** * Sets the new path for this being. diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 3adfbc08..67cb3c7b 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -266,7 +266,8 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot): Window(_("Create Character"), true, parent), mSlot(slot) { mPlayer = new Player(0, 0, NULL); - mPlayer->setHairStyle(rand() % NR_HAIR_STYLES, rand() % NR_HAIR_COLORS); + mPlayer->setHairStyle(rand() % Being::getHairStylesNr(), + rand() % Being::getHairColorsNr()); mPlayer->setGender(GENDER_MALE); mNameField = new TextField(""); @@ -422,13 +423,13 @@ CharCreateDialog::action(const gcn::ActionEvent &event) mPlayer->setHairStyle(-1, mPlayer->getHairColor() + 1); } else if (event.getId() == "prevcolor") { - mPlayer->setHairStyle(-1, mPlayer->getHairColor() + NR_HAIR_COLORS - 1); + mPlayer->setHairStyle(-1, mPlayer->getHairColor() + Being::getHairColorsNr() - 1); } else if (event.getId() == "nextstyle") { mPlayer->setHairStyle(mPlayer->getHairStyle() + 1, -1); } else if (event.getId() == "prevstyle") { - mPlayer->setHairStyle(mPlayer->getHairStyle() + NR_HAIR_STYLES - 1, -1); + mPlayer->setHairStyle(mPlayer->getHairStyle() + Being::getHairStylesNr() - 1, -1); } else if (event.getId() == "statslider") { UpdateSliders(); diff --git a/src/player.cpp b/src/player.cpp index e24a2d8c..19486d6e 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -85,27 +85,13 @@ void Player::setGender(Gender gender) void Player::setHairStyle(int style, int color) { - style = style < 0 ? mHairStyle : style % NR_HAIR_STYLES; - color = color < 0 ? mHairColor : color % NR_HAIR_COLORS; + style = style < 0 ? mHairStyle : style % getHairStylesNr(); + color = color < 0 ? mHairColor : color % getHairColorsNr(); if (style == mHairStyle && color == mHairColor) return; Being::setHairStyle(style, color); - static char const *const colors[NR_HAIR_COLORS] = - { - "#8c4b41,da9041,ffffff", // light brown - "#06372b,489e25,fdedcc", // green - "#5f0b33,91191c,f9ad81", // red - "#602486,934cc3,fdc689", // purple - "#805e74,c6b09b,ffffff", // gray - "#8c6625,dab425,ffffff", // yellow - "#1d2d6d,1594a3,fdedcc", // blue - "#831f2d,be4f2d,f8cc8b", // brown - "#432482,584bbc,dae8e5", // light blue - "#460850,611967,e7b4ae", // dark purple - }; - - setSprite(HAIR_SPRITE, style * -1, colors[color]); + setSprite(HAIR_SPRITE, style * -1, getHairColor(color)); setAction(mAction); } @@ -194,3 +180,5 @@ void Player::setInParty(bool value) { mInParty = value; } + + -- cgit v1.2.3-70-g09d2 From 291a1d63d407a46d3ad9152bbddc6e3d9a93b413 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 13 Dec 2008 16:33:04 +0100 Subject: Center large minimaps on player Based on a patch by QOAL. (cherry picked from eAthena client) Conflicts: src/gui/minimap.cpp --- src/gui/minimap.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/gui') diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 501530f1..02d20d8e 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -44,49 +44,50 @@ Minimap::Minimap(): Minimap::~Minimap() { if (mMapImage) - { mMapImage->decRef(); - } } void Minimap::setMapImage(Image *img) { if (mMapImage) - { mMapImage->decRef(); - } mMapImage = img; - if (mMapImage) - { + if (mMapImage) { mMapImage->setAlpha(0.7); - setSize( mMapImage->getWidth() + 6, mMapImage->getHeight() + 23 ); - setVisible(true); + setContentSize(mMapImage->getWidth(), mMapImage->getHeight()); } - else - { - setVisible(false); - } - } void Minimap::draw(gcn::Graphics *graphics) { Window::draw(graphics); + const gcn::Rectangle a = getChildrenArea(); + + int mapOriginX = a.x; + int mapOriginY = a.y; + if (mMapImage) { - static_cast(graphics)->drawImage( - mMapImage, getPadding(), getTitleBarHeight()); + if (mMapImage->getWidth() > a.width || + mMapImage->getHeight() > a.height) + { + const Vector &pos = player_node->getPosition(); + mapOriginX += (a.width - (int) (pos.x / 32)) / 2; + mapOriginY += (a.height - (int) (pos.y / 32)) / 2; + } + static_cast(graphics)-> + drawImage(mMapImage, mapOriginX, mapOriginY); } - Beings &beings = beingManager->getAll(); - BeingIterator bi; + const Beings &beings = beingManager->getAll(); + Beings::const_iterator bi; for (bi = beings.begin(); bi != beings.end(); bi++) { - Being *being = (*bi); + const Being *being = (*bi); int dotSize = 2; switch (being->getType()) { @@ -116,8 +117,8 @@ void Minimap::draw(gcn::Graphics *graphics) const Vector &pos = being->getPosition(); graphics->fillRectangle(gcn::Rectangle( - (int) pos.x / 64 + getPadding() - offset, - (int) pos.y / 64 + getTitleBarHeight() - offset, + (int) pos.x / 64 + mapOriginX - offset, + (int) pos.x / 64 + mapOriginY - offset, dotSize, dotSize)); } } -- cgit v1.2.3-70-g09d2 From 89c332adbcf584142d49f6829d5227614f2f0968 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 13 Dec 2008 16:51:38 +0100 Subject: Added ability to add equipment to the shurtcut bar Patch by Nikos, with some improvements. Conflicts: NEWS src/gui/itemcontainer.cpp src/itemshortcut.cpp (cherry picked from eAthena client, not functional here yet) --- NEWS | 1 + src/gui/itemcontainer.cpp | 12 ++++-------- src/gui/itemshortcutcontainer.cpp | 6 ++++-- src/itemshortcut.cpp | 25 +++++++++++++++---------- 4 files changed, 24 insertions(+), 20 deletions(-) (limited to 'src/gui') diff --git a/NEWS b/NEWS index bb0d2d09..df906034 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ - Mouse cursor will now hide when not used for some time - Make sure news and update file list aren't cached (from Aethyra) +- Added ability to add equipment to the shortcut bar 0.0.25 (27 July 2008) - Added support for whispering to other players diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 5fb99ffc..141b4360 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -82,8 +82,7 @@ ItemContainer::~ItemContainer() mSelImg->decRef(); } -void -ItemContainer::draw(gcn::Graphics *graphics) +void ItemContainer::draw(gcn::Graphics *graphics) { Graphics *g = static_cast(graphics); @@ -147,8 +146,7 @@ ItemContainer::draw(gcn::Graphics *graphics) } } -void -ItemContainer::selectNone() +void ItemContainer::selectNone() { setSelectedItem(NULL); } @@ -324,8 +322,7 @@ int ItemContainer::getSlotIndex(const int posX, const int posY) const return Inventory::NO_SLOT_INDEX; } -void -ItemContainer::keyAction() +void ItemContainer::keyAction() { // If there is no highlight then return. if (!mHighlightedItem) @@ -362,8 +359,7 @@ ItemContainer::keyAction() } } -void -ItemContainer::moveHighlight(int direction) +void ItemContainer::moveHighlight(int direction) { if (!mHighlightedItem) { diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index 76104e12..e0604c78 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -85,7 +85,7 @@ ItemShortcutContainer::draw(gcn::Graphics *graphics) // Draw item keyboard shortcut. const char *key = SDL_GetKeyName( - (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_0+i)); + (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_0 + i)); g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT); if (itemShortcut->getItem(i) < 0) @@ -96,9 +96,11 @@ ItemShortcutContainer::draw(gcn::Graphics *graphics) // Draw item icon. Image* image = item->getImage(); if (image) { + // TODO: Have label indicate equipped status + const std::string label = toString(item->getQuantity()); g->drawImage(image, itemX, itemY); g->drawText( - toString(item->getQuantity()), + label, itemX + mBoxWidth / 2, itemY + mBoxHeight - 14, gcn::Graphics::CENTER); diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index a89da974..bea14864 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -61,14 +61,8 @@ void ItemShortcut::save() { for (int i = 0; i < SHORTCUT_ITEMS; i++) { - if (mItems[i]) - { - config.setValue("shortcut" + toString(i), mItems[i]); - } - else - { - config.setValue("shortcut" + toString(i), -1); - } + const int itemId = mItems[i] ? mItems[i] : -1; + config.setValue("shortcut" + toString(i), itemId); } } @@ -77,9 +71,20 @@ void ItemShortcut::useItem(int index) if (mItems[index]) { Item *item = player_node->searchForItem(mItems[index]); - if (item && item->getQuantity()) { + if (item && item->getQuantity()) + { // TODO: Fix this (index vs. pointer mismatch) - //player_node->useItem(item); + /* + if (item->isEquipment()) { + if (item->isEquipped()) { + player_node->unequipItem(item); + } else { + player_node->equipItem(item); + } + } else { + player_node->useItem(item); + } + */ } } } -- cgit v1.2.3-70-g09d2 From 3c2af21bf059e8d90b4dd5687061f882ab883a78 Mon Sep 17 00:00:00 2001 From: David Athay Date: Tue, 5 Aug 2008 12:06:40 +0000 Subject: Fixed alignment (patch by Scraggy - Mantis #384) and spelling error. (cherry picked from eAthena client) --- src/gui/setup_video.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 51cee8e3..1b65cad6 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -189,7 +189,7 @@ Setup_Video::Setup_Video(): mScrollRadiusSlider->setDimension(gcn::Rectangle(10, 140, 75, 10)); gcn::Label *scrollRadiusLabel = new gcn::Label(_("Scroll radius")); scrollRadiusLabel->setPosition(90, 140); - mScrollRadiusField->setPosition(180, 140); + mScrollRadiusField->setPosition(mFpsField->getX(), 140); mScrollRadiusField->setWidth(30); mScrollRadiusField->setText(toString(mOriginalScrollRadius)); mScrollRadiusSlider->setValue(mOriginalScrollRadius); @@ -197,7 +197,7 @@ Setup_Video::Setup_Video(): mScrollLazinessSlider->setDimension(gcn::Rectangle(10, 160, 75, 10)); gcn::Label *scrollLazinessLabel = new gcn::Label(_("Scroll laziness")); scrollLazinessLabel->setPosition(90, 160); - mScrollLazinessField->setPosition(180, 160); + mScrollLazinessField->setPosition(mFpsField->getX(), 160); mScrollLazinessField->setWidth(30); mScrollLazinessField->setText(toString(mOriginalScrollLaziness)); mScrollLazinessSlider->setValue(mOriginalScrollLaziness); -- cgit v1.2.3-70-g09d2 From b6eb0e404e74bad6d522bac7e07990f0b10b2703 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 11 Sep 2008 07:07:37 +0000 Subject: Only require a restart to switch to full screen with OpenGL on Windows, since it works fine in Linux without having to reinitialize the OpenGL state. Adapted change by kraant from Aethyra. (cherry picked from eAthena client) --- src/gui/setup_video.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/gui') diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 1b65cad6..d9d6f34a 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -253,9 +253,18 @@ void Setup_Video::apply() bool fullscreen = mFsCheckBox->isSelected(); if (fullscreen != (config.getValue("screen", 0) == 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 + * reinitialize the OpenGL state and reload all textures. + * + * See http://libsdl.org/cgi/docwiki.cgi/SDL_SetVideoMode + */ + +#ifdef WIN32 // checks for opengl usage if (!(config.getValue("opengl", 0) == 1)) { +#endif if (!graphics->setFullscreen(fullscreen)) { fullscreen = !fullscreen; @@ -269,10 +278,12 @@ void Setup_Video::apply() logger->error(error.str()); } } +#ifdef WIN32 } else { new OkDialog(_("Switching to full screen"), _("Restart needed for changes to take effect.")); } +#endif config.setValue("screen", fullscreen ? 1 : 0); } -- cgit v1.2.3-70-g09d2 From 69d62451a7a582e3906a7c9328ae14e4bba5ccfa Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 14 Dec 2008 17:53:38 +0100 Subject: Removed ChargeDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ChargeDialog was removed. This class was long dead anyway. (cherry picked from eAthena client commit 719e2b02bc6833198d6af2d3c95de96ef95f876d) Conflicts: src/CMakeLists.txt src/Makefile.am src/game.cpp src/localplayer.cpp src/localplayer.h src/net/charserverhandler.cpp tmw.cbp Signed-off-by: Bjørn Lindeijer --- src/CMakeLists.txt | 2 -- src/Makefile.am | 2 -- src/game.cpp | 8 ------- src/gui/chargedialog.cpp | 57 ------------------------------------------------ src/gui/chargedialog.h | 48 ---------------------------------------- src/localplayer.h | 3 --- 6 files changed, 120 deletions(-) delete mode 100644 src/gui/chargedialog.cpp delete mode 100644 src/gui/chargedialog.h (limited to 'src/gui') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 43988ea6..a568270a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -77,8 +77,6 @@ SET(SRCS gui/changeemaildialog.h gui/changepassworddialog.cpp gui/changepassworddialog.h - gui/chargedialog.cpp - gui/chargedialog.h gui/char_select.cpp gui/char_select.h gui/chat.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 65e8cafd..09593659 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,8 +29,6 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ gui/changeemaildialog.h \ gui/changepassworddialog.cpp \ gui/changepassworddialog.h \ - gui/chargedialog.cpp \ - gui/chargedialog.h \ gui/char_select.cpp \ gui/char_select.h \ gui/chat.cpp \ diff --git a/src/game.cpp b/src/game.cpp index 97b9e57e..15c2d505 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -46,7 +46,6 @@ #include "gui/buy.h" #include "gui/buysell.h" -//#include "gui/chargedialog.h" #include "gui/chat.h" #include "gui/confirm_dialog.h" #include "gui/debugwindow.h" @@ -123,7 +122,6 @@ MagicDialog *magicDialog; Setup* setupWindow; Minimap *minimap; EquipmentWindow *equipmentWindow; -//ChargeDialog *chargeDialog; TradeWindow *tradeWindow; //BuddyWindow *buddyWindow; GuildWindow *guildWindow; @@ -211,7 +209,6 @@ void createGuiWindows() setupWindow = new Setup(); minimap = new Minimap(); equipmentWindow = new EquipmentWindow(player_node->mEquipment.get()); - //chargeDialog = new ChargeDialog(); tradeWindow = new TradeWindow; //buddyWindow = new BuddyWindow(); guildWindow = new GuildWindow(); @@ -221,10 +218,6 @@ void createGuiWindows() partyWindow = new PartyWindow(); // Initialize window positions - //chargeDialog->setPosition( - // graphics->getWidth() - 5 - chargeDialog->getWidth(), - // graphics->getHeight() - chargeDialog->getHeight() - 15); - //buddyWindow->setPosition(10, minimap->getHeight() + 30); // Set initial window visibility @@ -260,7 +253,6 @@ void destroyGuiWindows() delete setupWindow; delete minimap; delete equipmentWindow; - //delete chargeDialog; //delete newSkillWindow; delete tradeWindow; //delete buddyWindow; diff --git a/src/gui/chargedialog.cpp b/src/gui/chargedialog.cpp deleted file mode 100644 index 1c9edf45..00000000 --- a/src/gui/chargedialog.cpp +++ /dev/null @@ -1,57 +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 - */ - - /* The window supported by this class shows player stats and keeps a charging - * action bar in queue. - */ - -#include "chargedialog.h" - -#include "progressbar.h" - -#include "../localplayer.h" - -ChargeDialog::ChargeDialog(): - Window("") -{ - setContentSize(180, 70); - mProgBar = new ProgressBar(0.0f, 140, 25, 128, 128, 128); - mProgBar->setPosition(20, 40); - add(mProgBar); - setVisible(true); -} - -// update the dialog -void ChargeDialog::logic() -{ - // calculate time since the last attack was made - player_node->mLastAttackTime += .01; // this a hack until someone explains - // to me how to work the timer - if (player_node->mLastAttackTime > 1) - { - player_node->mLastAttackTime = 1; - } - - // reset the progress bar to display accurate time since attack - mProgBar->setProgress(player_node->mLastAttackTime); - - Window::logic(); -} diff --git a/src/gui/chargedialog.h b/src/gui/chargedialog.h deleted file mode 100644 index 9517ef6a..00000000 --- a/src/gui/chargedialog.h +++ /dev/null @@ -1,48 +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 _TMW_CHARGE_H -#define _TMW_CHARGE_H - -#include "window.h" - -class ProgressBar; - -#define CHARGE_TIME 1000 // time in milliseconds it takes to charge up an attack - -/** - * \ingroup Interface - */ -class ChargeDialog : public Window -{ - public: - /** - * Constructor. - */ - ChargeDialog(); - - void logic(); - - private: - ProgressBar* mProgBar; -}; - -#endif diff --git a/src/localplayer.h b/src/localplayer.h index 5dce5ebe..0b9ba712 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -290,8 +290,6 @@ class LocalPlayer : public Player int getHP() const { return mHP; } - Uint32 mCharId; - int getMaxHP() const { return mMaxHP; } @@ -360,7 +358,6 @@ class LocalPlayer : public Player std::pair getExperience(int skill); - float mLastAttackTime; /**< Used to synchronize the charge dialog */ Inventory *mInventory; const std::auto_ptr mEquipment; -- cgit v1.2.3-70-g09d2 From 7a368588910a3eba156e1d3af60f013a5315723b Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 14 Dec 2008 19:27:32 +0100 Subject: Removed the unused NewSkillDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Won't be introduced based on eAthena anyway, I think even with tmwserv we have different plans now. Signed-off-by: Bjørn Lindeijer (cherry picked from eAthena branch, commit bab09df7a8347f39221b2a87487dcd128a686def) Conflicts: src/game.cpp --- src/CMakeLists.txt | 2 - src/Makefile.am | 2 - src/game.cpp | 5 -- src/gui/newskill.cpp | 193 --------------------------------------------------- src/gui/newskill.h | 69 ------------------ 5 files changed, 271 deletions(-) delete mode 100644 src/gui/newskill.cpp delete mode 100644 src/gui/newskill.h (limited to 'src/gui') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a568270a..60eaff74 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -136,8 +136,6 @@ SET(SRCS gui/minimap.h gui/ministatus.cpp gui/ministatus.h - gui/newskill.cpp - gui/newskill.h gui/npclistdialog.cpp gui/npclistdialog.h gui/npcpostdialog.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 09593659..6acf9d18 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -88,8 +88,6 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ gui/minimap.h \ gui/ministatus.cpp \ gui/ministatus.h \ - gui/newskill.cpp \ - gui/newskill.h \ gui/npclistdialog.cpp \ gui/npclistdialog.h \ gui/npcpostdialog.cpp \ diff --git a/src/game.cpp b/src/game.cpp index ee1efb66..2e0a3cb5 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -118,7 +118,6 @@ NpcTextDialog *npcTextDialog; NpcPostDialog *npcPostDialog; SkillDialog *skillDialog; MagicDialog *magicDialog; -//NewSkillDialog *newSkillWindow; Setup* setupWindow; Minimap *minimap; EquipmentWindow *equipmentWindow; @@ -205,7 +204,6 @@ void createGuiWindows() npcPostDialog = new NpcPostDialog(); skillDialog = new SkillDialog(); magicDialog = new MagicDialog(); - //newSkillWindow = new NewSkillDialog(); setupWindow = new Setup(); minimap = new Minimap(); equipmentWindow = new EquipmentWindow(player_node->mEquipment.get()); @@ -253,7 +251,6 @@ void destroyGuiWindows() delete setupWindow; delete minimap; delete equipmentWindow; - //delete newSkillWindow; delete tradeWindow; //delete buddyWindow; delete guildWindow; @@ -519,8 +516,6 @@ void Game::handleInput() used = true; break; - //case SDLK_F11: requestedWindow = newSkillWindow; break; - case SDLK_RETURN: // Input chat window if (chatWindow->isInputFocused() || diff --git a/src/gui/newskill.cpp b/src/gui/newskill.cpp deleted file mode 100644 index 20fc01bd..00000000 --- a/src/gui/newskill.cpp +++ /dev/null @@ -1,193 +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 - */ - - /* This file implements the new skill dialog for use under the latest - * version of the skill system as of 2005/02/20 - */ - -#include "newskill.h" - -#include - -#include "button.h" -#include "progressbar.h" - -#include "../graphics.h" - -const char *skill_name[] = { - // 0-99 - // weapon skills 0-9 - "Short Blades", "Long Blades", "Hammers", "Archery", "Whip", - "Staves", "Throwing", "Piercing", "Hand to Hand", NULL, - // magic skills 10-19 - "Epyri (Fire)", "Merene (Water)", "Geon (Earth)", "Izurial (Air)", - "Lumine (Light)", "Tenebrae (Dark)", "Chronos (Time)", "Teless (Space)", - "Gen (Mana)", NULL, - // craft skills 20-29 - "Metalworking", "Woodworking", "Jeweler", "Cook", "Tailor", - "Alchemist", "Artisan", "Synthesis", NULL, NULL, - // general skills 30-39 - "Running", "Searching", "Sneak", "Trading", "Intimidate", - "Athletics", NULL, NULL, NULL,NULL, - // combat skills 40-49 - "Dodge", "Accuracy", "Critical", "Block", "Parry", "Diehard", "Magic Aura", - "Counter", NULL, NULL, - // resistance skills 50-59 - "Poison", "Silence", "Petrify", "Paralyze", "Blind", "Slow", "Zombie", - "Critical", NULL, NULL, - // element reistance 60-69 - "Heat (Fire)", "Chill (Water)", "Stone (Earth)", "Wind (Air)", - "Shine (Light)", "Shadow (Dark)", "Decay (Time)", "Chaos (Space)", NULL, - NULL, - // hunting skills 70-79 - "Insects", "Birds", "Lizards", "Amorphs", "Undead", "Machines", "Arcana", - "Humanoids", "Plantoids", NULL, - // stats 80-89 - "Strength", "Fortitude", "Vitality", "Menality", "Awareness", "Mana", - "Dexterity", NULL, NULL, NULL, - // unused (reserved) 90-99 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL -}; - - -NewSkillDialog::NewSkillDialog(): - Window("Skills") -{ - startPoint = 0; - for (int i = 0; i < N_SKILL_CAT_SIZE; i++) - { - mSkillLabel[i] = new gcn::Label("Empty "); - mSkillLevel[i] = new gcn::Label("00000"); - mSkillbar[i] = new ProgressBar(0.0f,100,15,0,0,255); - mSkillLevel[i]->setAlignment(Graphics::RIGHT); - add(mSkillLabel[i],40,5+i*25); - add(mSkillLevel[i],150,5+i*25); - add(mSkillbar[i],180,5+i*25); - } - // initialize the skills - for (int i = 0; i < N_SKILL; i++) - { - mPlayerSkill[i].level = 0; - mPlayerSkill[i].exp = 0; - } - resetNSD(); - - // create controls - Button *catButton[N_SKILL_CAT]; - catButton[0] = new Button("Weapons", "g1", this); - catButton[1] = new Button("Magic", "g2", this); - catButton[2] = new Button("Craft", "g3", this); - catButton[3] = new Button("General", "g4", this); - catButton[4] = new Button("Combat", "g5", this); - catButton[5] = new Button("E. Resist", "g6", this); - catButton[6] = new Button("S. Resist", "g7", this); - catButton[7] = new Button("Hunting", "g8", this); - catButton[8] = new Button("Stat", "g9", this); - - setContentSize(350, 250); - - for (int i = 0; i < 9; ++i) { - catButton[i]->setDimension(gcn::Rectangle(0, 0, 60, 20)); - catButton[i]->setPosition(290, 20 * i); - add(catButton[i]); - } - - Button *closeButton = new Button("Close", "close", this); - closeButton->setDimension(gcn::Rectangle(0,0,60,20)); - closeButton->setPosition(290, 230); - add(closeButton); - - // finsihing touches - setLocationRelativeTo(getParent()); -} - -void NewSkillDialog::action(const gcn::ActionEvent &event) -{ - int osp = startPoint; - if (event.getId() == "close") - { - setVisible(false); - } - else if (event.getId() == "g1") // weapons group 0-9 - { - startPoint =0; - } - else if (event.getId() == "g2") // magic group 10-19 - { - startPoint =10; - } - else if (event.getId() == "g3") // craft group 20-29 - { - startPoint =20; - } - else if (event.getId() == "g4") // general group 30-39 - { - startPoint =30; - } - else if (event.getId() == "g5") // combat group 40-49 - { - startPoint =40; - } - else if (event.getId() == "g6") // e. resist group 50-59 - { - startPoint =50; - } - else if (event.getId() == "g7") // s resist group 60-69 - { - startPoint =60; - } - else if (event.getId() == "g8") // hunting group 70-79 - { - startPoint =70; - } - else if (event.getId() == "g9") // stats group 80-89 - { - startPoint =80; - } - if (osp != startPoint) - { - resetNSD(); - } -} - -void NewSkillDialog::resetNSD() -{ - for (int a = 0; a < N_SKILL_CAT_SIZE; a++) - { - if (skill_name[a + startPoint]) - { - mSkillLabel[a]->setCaption(skill_name[a + startPoint]); - mSkillLabel[a]->setVisible(true); - char tmp[5]; - sprintf(tmp, "%d", mPlayerSkill[a+startPoint].level); - mSkillLevel[a]->setCaption(tmp); - mSkillLevel[a]->setVisible(true); - mSkillbar[a]->setProgress(0.0f); - mSkillbar[a]->setVisible(true); - } - else - { - mSkillLevel[a]->setVisible(false); - mSkillLabel[a]->setVisible(false); - mSkillbar[a]->setVisible(false); - } - } -} diff --git a/src/gui/newskill.h b/src/gui/newskill.h deleted file mode 100644 index 49476e5e..00000000 --- a/src/gui/newskill.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 _TMW_NSKILL_H -#define _TMW_NSKILL_H - -#include - -#include "window.h" - -#include "../guichanfwd.h" - -class ProgressBar; - -#define N_SKILL 100 // skill count constant -#define N_SKILL_CAT 9 // skill category count -#define N_SKILL_CAT_SIZE 10 // skill category maximum size - -struct nSkill { - short level; - short exp; -}; - -/** - * Dialog showing the skills in the planned skill model. - * - * \ingroup Interface - */ -class NewSkillDialog : public Window, public gcn::ActionListener -{ - public: - /** - * Constructor. - */ - NewSkillDialog(); - - // action listener - void action(const gcn::ActionEvent &event); - - private: - void resetNSD(); // updates the values in the dialog box - - // members - int startPoint; // starting point of skill listing - ProgressBar *mSkillbar[N_SKILL_CAT_SIZE]; - gcn::Label *mSkillLabel[N_SKILL_CAT_SIZE]; - gcn::Label *mSkillLevel[N_SKILL_CAT_SIZE]; - nSkill mPlayerSkill[N_SKILL]; // pointer to an array of skill values -}; - -#endif -- cgit v1.2.3-70-g09d2 From 34a02000cacc2c553d11e19c09d9d11b9c46eafd Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 14 Dec 2008 21:53:44 +0100 Subject: Fixed inconsistency in default window sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default window sizes were all too small, since they were specified in content size. On pressing "Reset Windows", the sizes would be interpreted as such and apply alright. The inconsistency is now removed, and the default window sizes are always the size of the whole widget now, not just the contents. Signed-off-by: Bjørn Lindeijer (cherry picked from eAthena branch, commit 72f5288682f46af1f7c04c002172178c880e060b) Conflicts: src/gui/chat.cpp src/gui/equipmentwindow.cpp src/gui/inventorywindow.cpp src/gui/ministatus.cpp src/gui/setup.cpp src/gui/skill.cpp src/gui/trade.cpp src/gui/window.cpp --- src/gui/chat.cpp | 4 ++-- src/gui/equipmentwindow.cpp | 1 - src/gui/inventorywindow.cpp | 2 +- src/gui/itemshortcutwindow.cpp | 2 +- src/gui/magic.cpp | 2 +- src/gui/setup.cpp | 2 ++ src/gui/skill.cpp | 2 +- src/gui/window.cpp | 6 +++--- 8 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src/gui') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index c94429c8..c9663192 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -53,10 +53,10 @@ ChatWindow::ChatWindow(): mTmpVisible(false) { setResizable(true); - setDefaultSize(0, (windowContainer->getHeight() - 105), 400, 100); + setDefaultSize(0, windowContainer->getHeight() - 123, 600, 123); setOpaque(false); - mChatInput = new ChatInput(); + mChatInput = new ChatInput; mChatInput->setActionEventId("chatinput"); mChatInput->addActionListener(this); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index aee262d0..57f0899b 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -51,7 +51,6 @@ static const int boxPosition[][2] = { }; EquipmentWindow::EquipmentWindow(Equipment *equipment): - Window(_("Equipment")), mEquipment(equipment), mBackground(NULL), diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 0fda7945..92b635d8 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -60,7 +60,7 @@ InventoryWindow::InventoryWindow(): setMinWidth(375); setMinHeight(283); // If you adjust these defaults, don't forget to adjust the trade window's. - setDefaultSize(115, 25, 375, 283); + setDefaultSize(115, 30, 375, 283); addKeyListener(this); mUseButton = new Button(_("Use"), "use", this); diff --git a/src/gui/itemshortcutwindow.cpp b/src/gui/itemshortcutwindow.cpp index e4d352fe..1a71b11e 100644 --- a/src/gui/itemshortcutwindow.cpp +++ b/src/gui/itemshortcutwindow.cpp @@ -34,7 +34,7 @@ ItemShortcutWindow::ItemShortcutWindow() setResizable(true); setDefaultSize(758, 174, 42, 426); - mItems = new ItemShortcutContainer(); + mItems = new ItemShortcutContainer; const int border = SCROLL_PADDING * 2 + getPadding() * 2; setMinWidth(mItems->getBoxWidth() + border); diff --git a/src/gui/magic.cpp b/src/gui/magic.cpp index ca7b5489..ad63f914 100644 --- a/src/gui/magic.cpp +++ b/src/gui/magic.cpp @@ -36,7 +36,7 @@ MagicDialog::MagicDialog(): Window(_("Magic")) { setCloseButton(true); - setDefaultSize(255, 25, 175, 225); + setDefaultSize(255, 30, 175, 225); gcn::Button *spellButton1 = new Button(_("Cast Test Spell 1"), "spell_1", this); gcn::Button *spellButton2 = new Button(_("Cast Test Spell 2"), "spell_2", this); diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 2a60308b..e062f674 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -43,6 +43,7 @@ extern Window *helpWindow; extern Window *skillDialog; extern Window *magicDialog; extern Window *guildWindow; +extern Window *itemShortcutWindow; Setup::Setup(): Window(_("Setup")) @@ -117,5 +118,6 @@ void Setup::action(const gcn::ActionEvent &event) skillDialog->resetToDefaultSize(); magicDialog->resetToDefaultSize(); guildWindow->resetToDefaultSize(); + itemShortcutWindow->resetToDefaultSize(); } } diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 49bacaf0..2eecca55 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -44,7 +44,7 @@ SkillDialog::SkillDialog(): Window(_("Skills")) { setCloseButton(true); - setDefaultSize(windowContainer->getWidth() - 255, 25, 275, 425); + setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425); TabbedArea *panel = new TabbedArea(); panel->setDimension(gcn::Rectangle(5, 5, 270, 420)); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index e498236a..37c61520 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -248,7 +248,7 @@ void Window::setMaxHeight(unsigned int height) void Window::setResizable(bool r) { - if ((bool)mGrip == r) return; + if ((bool) mGrip == r) return; if (r) { @@ -269,7 +269,7 @@ void Window::widgetResized(const gcn::Event &event) { if (mGrip) { - gcn::Rectangle const &area = getChildrenArea(); + const gcn::Rectangle area = getChildrenArea(); mGrip->setPosition(getWidth() - mGrip->getWidth() - area.x, getHeight() - mGrip->getHeight() - area.y); } @@ -497,7 +497,7 @@ void Window::setDefaultSize(int defaultX, int defaultY, void Window::resetToDefaultSize() { setPosition(mDefaultX, mDefaultY); - setContentSize(mDefaultWidth, mDefaultHeight); + setSize(mDefaultWidth, mDefaultHeight); } int Window::getResizeHandles(gcn::MouseEvent &event) -- cgit v1.2.3-70-g09d2 From 3dba40474d5b1525e8723139ae7be7576967feea Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 14 Dec 2008 21:57:38 +0100 Subject: Tweaked some configuration defaults Scrolling is now a bit less lazy and the scroll radius is 0. In my opinion this is a better default. Framerate limiter is now off by default, since it makes the game appear a bit choppy. It's basically only useful for laptops anyway, and not too hard to find. (cherry picked from eAthena branch, commit c56bc78b5f5676784265dff8ed5334884e8dcc39) Conflicts: src/main.cpp --- src/gui/setup_video.cpp | 14 +++++++------- src/gui/viewport.cpp | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index d9d6f34a..bac342a0 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -106,8 +106,8 @@ Setup_Video::Setup_Video(): mCustomCursorEnabled(config.getValue("customcursor", 1)), mVisibleNamesEnabled(config.getValue("visiblenames", 1)), mOpacity(config.getValue("guialpha", 0.8)), - mFps((int)config.getValue("fpslimit", 60)), - mModeListModel(new ModeListModel()), + mFps((int) config.getValue("fpslimit", 0)), + mModeListModel(new ModeListModel), mModeList(new ListBox(mModeListModel)), mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)), mOpenGLCheckBox(new CheckBox(_("OpenGL"), mOpenGLEnabled)), @@ -116,13 +116,13 @@ Setup_Video::Setup_Video(): mAlphaSlider(new Slider(0.2, 1.0)), mFpsCheckBox(new CheckBox(_("FPS Limit:"))), mFpsSlider(new Slider(10, 200)), - mFpsField(new TextField()), - mOriginalScrollLaziness((int) config.getValue("ScrollLaziness", 32)), + mFpsField(new TextField), + mOriginalScrollLaziness((int) config.getValue("ScrollLaziness", 16)), mScrollLazinessSlider(new Slider(1, 64)), - mScrollLazinessField(new TextField()), - mOriginalScrollRadius((int) config.getValue("ScrollRadius", 32)), + mScrollLazinessField(new TextField), + mOriginalScrollRadius((int) config.getValue("ScrollRadius", 0)), mScrollRadiusSlider(new Slider(0, 128)), - mScrollRadiusField(new TextField()), + mScrollRadiusField(new TextField), mOverlayDetail((int) config.getValue("OverlayDetail", 2)), mOverlayDetailSlider(new Slider(0, 2)), mOverlayDetailField(new gcn::Label("")) diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index a6092c7a..a746fb03 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -61,8 +61,8 @@ Viewport::Viewport(): setOpaque(false); addMouseListener(this); - mScrollLaziness = (int) config.getValue("ScrollLaziness", 32); - mScrollRadius = (int) config.getValue("ScrollRadius", 32); + mScrollLaziness = (int) config.getValue("ScrollLaziness", 16); + mScrollRadius = (int) config.getValue("ScrollRadius", 0); mScrollCenterOffsetX = (int) config.getValue("ScrollCenterOffsetX", 0); mScrollCenterOffsetY = (int) config.getValue("ScrollCenterOffsetY", 0); mVisibleNames = config.getValue("visiblenames", 1); -- cgit v1.2.3-70-g09d2 From 1b3cb122be1a418ce82b66fb9ce1ecf3aa5813fb Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Wed, 17 Dec 2008 20:10:51 +0100 Subject: Code reformatting Mainly making sure 'const std::string &' is used everywhere instead of 'std::string const &'. The former has always been the preferred order in this project. --- src/animatedsprite.h | 27 ++++++++------------- src/being.cpp | 1 + src/being.h | 9 +++---- src/channelmanager.cpp | 45 +++++++++++++++++------------------ src/channelmanager.h | 7 ++++-- src/gui/chat.cpp | 49 ++++++++++++++------------------------- src/gui/chat.h | 31 ++++++++++--------------- src/gui/npclistdialog.cpp | 2 +- src/gui/npclistdialog.h | 2 +- src/gui/widgets/avatar.cpp | 16 ++++--------- src/gui/widgets/avatar.h | 8 +++---- src/gui/window.cpp | 7 +++--- src/gui/window.h | 2 +- src/localplayer.cpp | 7 ++---- src/properties.h | 15 +++++------- src/resources/dye.cpp | 6 ++--- src/resources/dye.h | 6 ++--- src/resources/imageloader.cpp | 2 +- src/resources/imageloader.h | 3 ++- src/resources/resourcemanager.cpp | 12 +++++----- src/resources/resourcemanager.h | 9 +++---- src/resources/spritedef.cpp | 31 ++++++++++--------------- src/resources/spritedef.h | 23 +++++++----------- tools/dyecmd/src/dye.cpp | 6 ++--- tools/dyecmd/src/dye.h | 6 ++--- 25 files changed, 144 insertions(+), 188 deletions(-) (limited to 'src/gui') diff --git a/src/animatedsprite.h b/src/animatedsprite.h index 405bf42e..41857d8f 100644 --- a/src/animatedsprite.h +++ b/src/animatedsprite.h @@ -50,7 +50,8 @@ class AnimatedSprite * @param filename the file of the sprite to animate * @param variant the sprite variant */ - static AnimatedSprite *load(std::string const &filename, int variant = 0); + static AnimatedSprite *load(const std::string &filename, + int variant = 0); /** * Destructor. @@ -60,50 +61,42 @@ class AnimatedSprite /** * Resets the animated sprite. */ - void - reset(); + void reset(); /** * Plays an action using the current direction */ - void - play(SpriteAction action); + void play(SpriteAction action); /** * Inform the animation of the passed time so that it can output the * correct animation frame. */ - void - update(int time); + void update(int time); /** * Draw the current animation frame at the coordinates given in screen * pixels. */ - bool - draw(Graphics* graphics, int posX, int posY) const; + bool draw(Graphics* graphics, int posX, int posY) const; /** * gets the width in pixels of the image of the current frame */ - int - getWidth() const; + int getWidth() const; /** * gets the height in pixels of the image of the current frame */ - int - getHeight() const; + int getHeight() const; /** * Sets the direction. */ - void - setDirection(SpriteDirection direction); + void setDirection(SpriteDirection direction); private: - bool - updateCurrentAnimation(unsigned int dt); + bool updateCurrentAnimation(unsigned int dt); SpriteDirection mDirection; /**< The sprite direction. */ int mLastTime; /**< The last time update was called. */ diff --git a/src/being.cpp b/src/being.cpp index 7c37d8e3..d32ffa59 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -122,6 +122,7 @@ void Being::setPosition(const Vector &pos) { mPos = pos; mDest = pos; + mPath.clear(); } void Being::adjustCourse(int srcX, int srcY, int dstX, int dstY) diff --git a/src/being.h b/src/being.h index f9e6c58f..aeb03564 100644 --- a/src/being.h +++ b/src/being.h @@ -130,14 +130,14 @@ class Being : public Sprite const Vector &getDestination() const { return mDest; } /** - * Adjusts course to expected stat point. + * Adjusts course to expected start point. */ - void adjustCourse(int, int); + void adjustCourse(int srcX, int srcY); /** * Adjusts course to expected start and end points. */ - void adjustCourse(int, int, int, int); + void adjustCourse(int srcX, int srcY, int destX, int destY); /** * Puts a "speech balloon" above this being for the specified amount @@ -298,7 +298,8 @@ class Being : public Sprite int getPixelY() const { return (int) mPos.y; } /** - * Sets the position of this being. + * Sets the position of this being. When the being was walking, it also + * clears the destination and the path. */ void setPosition(const Vector &pos); diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp index a332edbb..2a3f4eff 100644 --- a/src/channelmanager.cpp +++ b/src/channelmanager.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "channelmanager.h" #include "channel.h" @@ -28,7 +26,6 @@ ChannelManager::ChannelManager() { - } ChannelManager::~ChannelManager() @@ -37,39 +34,43 @@ ChannelManager::~ChannelManager() mChannels.clear(); } -Channel* ChannelManager::findById(int id) +Channel *ChannelManager::findById(int id) const { - Channel* channel; - for(std::list::iterator itr = mChannels.begin(); - itr != mChannels.end(); - itr++) + Channel *channel = 0; + for (std::list::const_iterator itr = mChannels.begin(), + end = mChannels.end(); + itr != end; + itr++) { - channel = (*itr); - if(channel->getId() == id) + Channel *c = (*itr); + if (channel->getId() == id) { - return channel; + channel = c; + break; } } - return NULL; + return channel; } -Channel *ChannelManager::findByName(std::string const &name) +Channel *ChannelManager::findByName(const std::string &name) const { - Channel* channel; - if(name != "") + Channel *channel = 0; + if (!name.empty()) { - for(std::list::iterator itr = mChannels.begin(); - itr != mChannels.end(); - itr++) + for (std::list::const_iterator itr = mChannels.begin(), + end = mChannels.end(); + itr != end; + itr++) { - channel = (*itr); - if(channel->getName() == name) + Channel *c = (*itr); + if (c->getName() == name) { - return channel; + channel = c; + break; } } } - return NULL; + return channel; } void ChannelManager::addChannel(Channel *channel) diff --git a/src/channelmanager.h b/src/channelmanager.h index c19c548a..e42a5960 100644 --- a/src/channelmanager.h +++ b/src/channelmanager.h @@ -32,10 +32,13 @@ class ChannelManager public: ChannelManager(); ~ChannelManager(); - Channel* findById(int id); - Channel *findByName(std::string const &name); + + Channel *findById(int id) const; + Channel *findByName(const std::string &name) const; + void addChannel(Channel *channel); void removeChannel(Channel *channel); + private: std::list mChannels; }; diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index c9663192..5bd661d6 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -97,7 +97,7 @@ ChatWindow::~ChatWindow() delete mChatTabs; } -const std::string& ChatWindow::getFocused() const +const std::string &ChatWindow::getFocused() const { return mChatTabs->getSelectedTab()->getCaption(); } @@ -151,8 +151,7 @@ void ChatWindow::logic() } } -void -ChatWindow::chatLog(std::string line, int own, std::string channelName) +void ChatWindow::chatLog(std::string line, int own, std::string channelName) { if(channelName.empty()) channelName = getFocused(); @@ -240,8 +239,7 @@ ChatWindow::chatLog(std::string line, int own, std::string channelName) scroll->logic(); } -void -ChatWindow::action(const gcn::ActionEvent &event) +void ChatWindow::action(const gcn::ActionEvent &event) { if (event.getId() == "chatinput") { @@ -274,8 +272,7 @@ ChatWindow::action(const gcn::ActionEvent &event) } } -void -ChatWindow::requestChatFocus() +void ChatWindow::requestChatFocus() { // Make sure chatWindow is visible if (!isVisible()) @@ -295,13 +292,12 @@ ChatWindow::requestChatFocus() mChatInput->requestFocus(); } -bool -ChatWindow::isInputFocused() +bool ChatWindow::isInputFocused() { return mChatInput->isFocused(); } -void ChatWindow::chatSend(std::string const &msg) +void ChatWindow::chatSend(const std::string &msg) { if (msg.empty()) return; @@ -327,20 +323,17 @@ void ChatWindow::chatSend(std::string const &msg) } } -void -ChatWindow::removeChannel(short channelId) +void ChatWindow::removeChannel(short channelId) { removeChannel(channelManager->findById(channelId)); } -void -ChatWindow::removeChannel(const std::string &channelName) +void ChatWindow::removeChannel(const std::string &channelName) { removeChannel(channelManager->findByName(channelName)); } -void -ChatWindow::removeChannel(Channel *channel) +void ChatWindow::removeChannel(Channel *channel) { if (channel) { @@ -356,8 +349,7 @@ ChatWindow::removeChannel(Channel *channel) } } -void -ChatWindow::createNewChannelTab(const std::string &channelName) +void ChatWindow::createNewChannelTab(const std::string &channelName) { // Create new channel BrowserBox *textOutput = new BrowserBox(BrowserBox::AUTO_WRAP); @@ -384,8 +376,9 @@ ChatWindow::createNewChannelTab(const std::string &channelName) logic(); } -void -ChatWindow::sendToChannel(short channelId, const std::string &user, const std::string &msg) +void ChatWindow::sendToChannel(short channelId, + const std::string &user, + const std::string &msg) { Channel *channel = channelManager->findById(channelId); if (channel) @@ -395,8 +388,7 @@ ChatWindow::sendToChannel(short channelId, const std::string &user, const std::s } } -void -ChatWindow::keyPressed(gcn::KeyEvent &event) +void ChatWindow::keyPressed(gcn::KeyEvent &event) { if (event.getKey().getValue() == Key::DOWN && mCurHist != mHistory.end()) @@ -421,15 +413,13 @@ ChatWindow::keyPressed(gcn::KeyEvent &event) } } -void -ChatWindow::setInputText(std::string input_str) +void ChatWindow::setInputText(std::string input_str) { mChatInput->setText(input_str + " "); requestChatFocus(); } -void -ChatWindow::setVisible(bool isVisible) +void ChatWindow::setVisible(bool isVisible) { Window::setVisible(isVisible); @@ -440,11 +430,8 @@ ChatWindow::setVisible(bool isVisible) mTmpVisible = false; } -bool -ChatWindow::tabExists(const std::string &tabName) +bool ChatWindow::tabExists(const std::string &tabName) { Tab *tab = mChatTabs->getTab(tabName); - if (tab) - return true; - return false; + return tab != 0; } diff --git a/src/gui/chat.h b/src/gui/chat.h index a41b11fb..8ca0e4c9 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -118,41 +118,34 @@ class ChatWindow : public Window, * @param msg The message text which is to be sent. * */ - void chatSend(std::string const &msg); + void chatSend(const std::string &msg); /** Called to remove the channel from the channel manager */ - void - removeChannel(short channelId); + void removeChannel(short channelId); - void - removeChannel(const std::string &channelName); + void removeChannel(const std::string &channelName); - void - removeChannel(Channel *channel); + void removeChannel(Channel *channel); /** Called to create a new channel tab */ - void - createNewChannelTab(const std::string &channelName); + void createNewChannelTab(const std::string &channelName); /** Called to output text to a specific channel */ - void - sendToChannel(short channel, const std::string &user, const std::string &msg); + void sendToChannel(short channel, + const std::string &user, + const std::string &msg); /** Called when key is pressed */ - void - keyPressed(gcn::KeyEvent &event); + void keyPressed(gcn::KeyEvent &event); /** Called to set current text */ - void - setInputText(std::string input_str); + void setInputText(std::string input_str); /** Override to reset mTmpVisible */ - void - setVisible(bool visible); + void setVisible(bool visible); /** Check if tab with that name already exists */ - bool - tabExists(const std::string &tabName); + bool tabExists(const std::string &tabName); void logic(); diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index 57783d96..c55255ea 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -76,7 +76,7 @@ std::string NpcListDialog::getElementAt(int i) return mItems[i]; } -void NpcListDialog::addItem(std::string const &item) +void NpcListDialog::addItem(const std::string &item) { mItems.push_back(item); } diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index 9d970ac2..65281f58 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -73,7 +73,7 @@ class NpcListDialog : public Window, public gcn::ActionListener, /** * Adds an item to the option list. */ - void addItem(std::string const &); + void addItem(const std::string &); /** * Resets the list by removing all items. diff --git a/src/gui/widgets/avatar.cpp b/src/gui/widgets/avatar.cpp index 68ce5243..9fcd00a6 100644 --- a/src/gui/widgets/avatar.cpp +++ b/src/gui/widgets/avatar.cpp @@ -33,23 +33,17 @@ Avatar::Avatar(const std::string &name): mLabel = new gcn::Label(name); mLabel->setSize(85, 12); mLabel->setPosition(25, 0); - mStatusOffline = ResourceManager::getInstance()->getImage("graphics/gui/circle-gray.png"); - mStatusOnline = ResourceManager::getInstance()->getImage("graphics/gui/circle-green.png"); + ResourceManager *resman = ResourceManager::getInstance(); + mStatusOffline = resman->getImage("graphics/gui/circle-gray.png"); + mStatusOnline = resman->getImage("graphics/gui/circle-green.png"); mStatus = new Icon(mStatusOffline); mStatus->setSize(25, 12); mStatus->setPosition(0, 0); } -void Avatar::setOnline(bool status) +void Avatar::setOnline(bool online) { - if (status) - { - mStatus->setImage(mStatusOnline); - } - else - { - mStatus->setImage(mStatusOffline); - } + mStatus->setImage(online ? mStatusOnline : mStatusOffline); } void Avatar::draw(gcn::Graphics *g) diff --git a/src/gui/widgets/avatar.h b/src/gui/widgets/avatar.h index 0f657895..c6151020 100644 --- a/src/gui/widgets/avatar.h +++ b/src/gui/widgets/avatar.h @@ -33,18 +33,18 @@ class Avatar : public gcn::Widget { public: /** - * Constructor + * Constructor. * @param name Character name */ Avatar(const std::string &name); /** - * Set the avatar online status + * Set the avatar online status. */ - void setOnline(bool status); + void setOnline(bool online); /** - * Draws the Avatar + * Draws the avatar. */ void draw(gcn::Graphics *g); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 37c61520..9dc70189 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -129,7 +129,7 @@ Window::~Window() { logger->log("UNLOAD: Window::~Window(\"%s\")", getCaption().c_str()); - std::string const &name = mConfigName; + const std::string &name = mConfigName; if (!name.empty()) { // Saving X, Y and Width and Height for resizables in the config @@ -179,10 +179,9 @@ void Window::setWindowContainer(WindowContainer *wc) void Window::draw(gcn::Graphics *graphics) { - if(mAlphaChanged) + if (mAlphaChanged) setGuiAlpha(); - Graphics *g = static_cast(graphics); //g->drawImageRect(0, 0, getWidth(), getHeight(), border); @@ -467,7 +466,7 @@ void Window::mouseDragged(gcn::MouseEvent &event) } } -void Window::loadWindowState(std::string const &name) +void Window::loadWindowState(const std::string &name) { mConfigName = name; diff --git a/src/gui/window.h b/src/gui/window.h index 22355572..493bce37 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -198,7 +198,7 @@ class Window : public gcn::Window, gcn::WidgetListener * Don't forget to set these default values and resizable before * calling this function. */ - void loadWindowState(std::string const &); + void loadWindowState(const std::string &); /** * Set the default win pos and size. diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 14d253c0..ffb4aac9 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -353,10 +353,7 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y) void LocalPlayer::setWalkingDir(int dir) { - if (mWalkingDir != dir) - { - mWalkingDir = dir; - } + mWalkingDir = dir; // If we're not already walking, start walking. if (mAction != WALK && dir @@ -368,7 +365,7 @@ void LocalPlayer::setWalkingDir(int dir) void LocalPlayer::stopWalking(bool sendToServer) { - if(mAction == WALK && mWalkingDir){ + if (mAction == WALK && mWalkingDir) { mWalkingDir = 0; mLocalWalkTime = 0; Being::setDestination(getPosition().x,getPosition().y); diff --git a/src/properties.h b/src/properties.h index 2eafeeca..a593e8c2 100644 --- a/src/properties.h +++ b/src/properties.h @@ -35,8 +35,7 @@ class Properties /** * Destructor. */ - virtual - ~Properties() {} + virtual ~Properties() {} /** * Get a map property. @@ -46,8 +45,8 @@ class Properties * @return the value of the given property or the given default when it * doesn't exist. */ - const std::string& - getProperty(const std::string &name, const std::string &def = "") const + const std::string &getProperty(const std::string &name, + const std::string &def = "") const { PropertyMap::const_iterator i = mProperties.find(name); return (i != mProperties.end()) ? i->second : def; @@ -61,7 +60,7 @@ class Properties * @return the value of the given property, or 0.0f when it doesn't * exist. */ - float getFloatProperty(std::string const &name, float def = 0.0f) const + float getFloatProperty(const std::string &name, float def = 0.0f) const { PropertyMap::const_iterator i = mProperties.find(name); float ret = def; @@ -81,8 +80,7 @@ class Properties * @return true when a property is defined, * false otherwise. */ - bool - hasProperty(const std::string &name) const + bool hasProperty(const std::string &name) const { return (mProperties.find(name) != mProperties.end()); } @@ -93,8 +91,7 @@ class Properties * @param name The name of the property. * @param value The value of the property. */ - void - setProperty(const std::string &name, const std::string &value) + void setProperty(const std::string &name, const std::string &value) { mProperties[name] = value; } diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 3be105d8..d180d725 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -26,7 +26,7 @@ #include "../log.h" -Palette::Palette(std::string const &description) +Palette::Palette(const std::string &description) { int size = description.length(); if (size == 0) return; @@ -109,7 +109,7 @@ void Palette::getColor(int intensity, int color[3]) const color[2] = ((255 - t) * b1 + t * b2) / 255; } -Dye::Dye(std::string const &description) +Dye::Dye(const std::string &description) { for (int i = 0; i < 7; ++i) mPalettes[i] = 0; @@ -175,7 +175,7 @@ void Dye::update(int color[3]) const mPalettes[i - 1]->getColor(cmax, color); } -void Dye::instantiate(std::string &target, std::string const &palettes) +void Dye::instantiate(std::string &target, const std::string &palettes) { std::string::size_type next_pos = target.find('|'); if (next_pos == std::string::npos || palettes.empty()) return; diff --git a/src/resources/dye.h b/src/resources/dye.h index 528a1d91..f0bd7aab 100644 --- a/src/resources/dye.h +++ b/src/resources/dye.h @@ -36,7 +36,7 @@ class Palette * The string is either a file name or a sequence of hexadecimal RGB * values separated by ',' and starting with '#'. */ - Palette(std::string const &); + Palette(const std::string &); /** * Gets a pixel color depending on its intensity. @@ -63,7 +63,7 @@ class Dye * The parts of string are separated by semi-colons. Each part starts * by an uppercase letter, followed by a colon and then a palette name. */ - Dye(std::string const &); + Dye(const std::string &); /** * Destroys the associated palettes. @@ -79,7 +79,7 @@ class Dye * Fills the blank in a dye placeholder with some palette names. */ static void instantiate(std::string &target, - std::string const &palettes); + const std::string &palettes); private: diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp index 29458ba3..835ba100 100644 --- a/src/resources/imageloader.cpp +++ b/src/resources/imageloader.cpp @@ -88,7 +88,7 @@ void ProxyImage::convertToDisplayFormat() mSDLImage = NULL; } -gcn::Image *ImageLoader::load(std::string const &filename, bool convert) +gcn::Image *ImageLoader::load(const std::string &filename, bool convert) { ResourceManager *resman = ResourceManager::getInstance(); ProxyImage *i = new ProxyImage(resman->loadSDLSurface(filename)); diff --git a/src/resources/imageloader.h b/src/resources/imageloader.h index 7979fd2f..821a0254 100644 --- a/src/resources/imageloader.h +++ b/src/resources/imageloader.h @@ -61,7 +61,8 @@ class ProxyImage : public gcn::Image class ImageLoader : public gcn::ImageLoader { public: - gcn::Image *load(std::string const &filename, bool convertToDisplayFormat); + gcn::Image *load(const std::string &filename, + bool convertToDisplayFormat); }; #endif diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 8c6d1376..bebd17f8 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -211,7 +211,7 @@ std::string ResourceManager::getPath(const std::string &file) return path; } -Resource *ResourceManager::get(std::string const &idPath, generator fun, +Resource *ResourceManager::get(const std::string &idPath, generator fun, void *data) { // Check if the id exists, and return the value if it does. @@ -263,7 +263,7 @@ struct ResourceLoader } }; -Resource *ResourceManager::load(std::string const &path, loader fun) +Resource *ResourceManager::load(const std::string &path, loader fun) { ResourceLoader l = { this, path, fun }; return get(path, ResourceLoader::load, &l); @@ -305,7 +305,7 @@ struct DyedImageLoader } }; -Image *ResourceManager::getImage(std::string const &idPath) +Image *ResourceManager::getImage(const std::string &idPath) { DyedImageLoader l = { this, idPath }; return static_cast(get(idPath, DyedImageLoader::load, &l)); @@ -347,8 +347,7 @@ struct SpriteDefLoader } }; -SpriteDef *ResourceManager::getSprite - (std::string const &path, int variant) +SpriteDef *ResourceManager::getSprite(const std::string &path, int variant) { SpriteDefLoader l = { path, variant }; std::stringstream ss; @@ -377,7 +376,8 @@ void ResourceManager::release(Resource *res) ResourceManager *ResourceManager::getInstance() { // Create a new instance if necessary. - if (instance == NULL) instance = new ResourceManager(); + if (!instance) + instance = new ResourceManager(); return instance; } diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index c1007f4a..e70dfb9d 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -98,7 +98,8 @@ class ResourceManager bool isDirectory(const std::string &path); /** - * Returns the real path to a file + * Returns the real path to a file. Note that this method will always + * return a path, it does not check whether the file exists. * * @param file The file to get the real path to. * @return The real path. @@ -114,7 +115,7 @@ class ResourceManager * @return A valid resource or NULL if the resource could * not be generated. */ - Resource *get(std::string const &idPath, generator fun, void *data); + Resource *get(const std::string &idPath, generator fun, void *data); /** * Loads a resource from a file and adds it to the resource map. @@ -124,7 +125,7 @@ class ResourceManager * @return A valid resource or NULL if the resource could * not be loaded. */ - Resource *load(std::string const &path, loader fun); + Resource *load(const std::string &path, loader fun); /** * Convenience wrapper around ResourceManager::get for loading @@ -154,7 +155,7 @@ class ResourceManager * Creates a sprite definition based on a given path and the supplied * variant. */ - SpriteDef *getSprite(std::string const &path, int variant = 0); + SpriteDef *getSprite(const std::string &path, int variant = 0); /** * Releases a resource, placing it in the set of orphaned resources. diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 5aea55fa..f5b763ea 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -33,8 +33,7 @@ #include "../log.h" #include "../utils/xml.h" -Action* -SpriteDef::getAction(SpriteAction action) const +Action *SpriteDef::getAction(SpriteAction action) const { Actions::const_iterator i = mActions.find(action); @@ -47,7 +46,7 @@ SpriteDef::getAction(SpriteAction action) const return i->second; } -SpriteDef *SpriteDef::load(std::string const &animationFile, int variant) +SpriteDef *SpriteDef::load(const std::string &animationFile, int variant) { std::string::size_type pos = animationFile.find('|'); std::string palettes; @@ -122,7 +121,7 @@ void SpriteDef::loadSprite(xmlNodePtr spriteNode, int variant, } } -void SpriteDef::loadImageSet(xmlNodePtr node, std::string const &palettes) +void SpriteDef::loadImageSet(xmlNodePtr node, const std::string &palettes) { const std::string name = XML::getProperty(node, "name", ""); @@ -147,8 +146,7 @@ void SpriteDef::loadImageSet(xmlNodePtr node, std::string const &palettes) mImageSets[name] = imageSet; } -void -SpriteDef::loadAction(xmlNodePtr node, int variant_offset) +void SpriteDef::loadAction(xmlNodePtr node, int variant_offset) { const std::string actionName = XML::getProperty(node, "name", ""); const std::string imageSetName = XML::getProperty(node, "imageset", ""); @@ -188,10 +186,9 @@ SpriteDef::loadAction(xmlNodePtr node, int variant_offset) } } -void -SpriteDef::loadAnimation(xmlNodePtr animationNode, - Action *action, ImageSet *imageSet, - int variant_offset) +void SpriteDef::loadAnimation(xmlNodePtr animationNode, + Action *action, ImageSet *imageSet, + int variant_offset) { const std::string directionName = XML::getProperty(animationNode, "direction", ""); @@ -268,8 +265,7 @@ SpriteDef::loadAnimation(xmlNodePtr animationNode, } // for frameNode } -void -SpriteDef::includeSprite(xmlNodePtr includeNode) +void SpriteDef::includeSprite(xmlNodePtr includeNode) { // TODO: Perform circular dependency check, since it's easy to crash the // client this way. @@ -290,8 +286,7 @@ SpriteDef::includeSprite(xmlNodePtr includeNode) loadSprite(rootNode, 0); } -void -SpriteDef::substituteAction(SpriteAction complete, SpriteAction with) +void SpriteDef::substituteAction(SpriteAction complete, SpriteAction with) { if (mActions.find(complete) == mActions.end()) { @@ -325,8 +320,7 @@ SpriteDef::~SpriteDef() } } -SpriteAction -SpriteDef::makeSpriteAction(const std::string& action) +SpriteAction SpriteDef::makeSpriteAction(const std::string &action) { if (action == "" || action == "default") { return ACTION_DEFAULT; @@ -408,8 +402,7 @@ SpriteDef::makeSpriteAction(const std::string& action) } } -SpriteDirection -SpriteDef::makeSpriteDirection(const std::string& direction) +SpriteDirection SpriteDef::makeSpriteDirection(const std::string& direction) { if (direction == "" || direction == "default") { return DIRECTION_DEFAULT; @@ -428,5 +421,5 @@ SpriteDef::makeSpriteDirection(const std::string& direction) } else { return DIRECTION_INVALID; - }; + } } diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 56b9a713..0c3e443b 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -81,7 +81,7 @@ class SpriteDef : public Resource /** * Loads a sprite definition file. */ - static SpriteDef *load(std::string const &file, int variant); + static SpriteDef *load(const std::string &file, int variant); /** * Returns the specified action. @@ -91,8 +91,7 @@ class SpriteDef : public Resource /** * Converts a string into a SpriteAction enum. */ - static SpriteAction - makeSpriteAction(const std::string &action); + static SpriteAction makeSpriteAction(const std::string &action); private: /** @@ -114,27 +113,24 @@ class SpriteDef : public Resource /** * Loads an imageset element. */ - void loadImageSet(xmlNodePtr node, std::string const &palettes); + void loadImageSet(xmlNodePtr node, const std::string &palettes); /** * Loads an action element. */ - void - loadAction(xmlNodePtr node, int variant_offset); + void loadAction(xmlNodePtr node, int variant_offset); /** * Loads an animation element. */ - void - loadAnimation(xmlNodePtr animationNode, - Action *action, ImageSet *imageSet, - int variant_offset); + void loadAnimation(xmlNodePtr animationNode, + Action *action, ImageSet *imageSet, + int variant_offset); /** * Include another sprite into this one. */ - void - includeSprite(xmlNodePtr includeNode); + void includeSprite(xmlNodePtr includeNode); /** * Complete missing actions by copying existing ones. @@ -145,8 +141,7 @@ class SpriteDef : public Resource * When there are no animations defined for the action "complete", its * animations become a copy of those of the action "with". */ - void - substituteAction(SpriteAction complete, SpriteAction with); + void substituteAction(SpriteAction complete, SpriteAction with); /** * Converts a string into a SpriteDirection enum. diff --git a/tools/dyecmd/src/dye.cpp b/tools/dyecmd/src/dye.cpp index c93f46c8..058e0515 100644 --- a/tools/dyecmd/src/dye.cpp +++ b/tools/dyecmd/src/dye.cpp @@ -24,7 +24,7 @@ #include "dye.h" -Palette::Palette(std::string const &description) +Palette::Palette(const std::string &description) { int size = description.length(); if (size == 0) return; @@ -105,7 +105,7 @@ void Palette::getColor(int intensity, int color[3]) const color[2] = ((255 - t) * b1 + t * b2) / 255; } -Dye::Dye(std::string const &description) +Dye::Dye(const std::string &description) { for (int i = 0; i < 7; ++i) mPalettes[i] = 0; @@ -169,7 +169,7 @@ void Dye::update(int color[3]) const mPalettes[i - 1]->getColor(cmax, color); } -void Dye::instantiate(std::string &target, std::string const &palettes) +void Dye::instantiate(std::string &target, const std::string &palettes) { std::string::size_type next_pos = target.find('|'); if (next_pos == std::string::npos || palettes.empty()) return; diff --git a/tools/dyecmd/src/dye.h b/tools/dyecmd/src/dye.h index 528a1d91..f0bd7aab 100644 --- a/tools/dyecmd/src/dye.h +++ b/tools/dyecmd/src/dye.h @@ -36,7 +36,7 @@ class Palette * The string is either a file name or a sequence of hexadecimal RGB * values separated by ',' and starting with '#'. */ - Palette(std::string const &); + Palette(const std::string &); /** * Gets a pixel color depending on its intensity. @@ -63,7 +63,7 @@ class Dye * The parts of string are separated by semi-colons. Each part starts * by an uppercase letter, followed by a colon and then a palette name. */ - Dye(std::string const &); + Dye(const std::string &); /** * Destroys the associated palettes. @@ -79,7 +79,7 @@ class Dye * Fills the blank in a dye placeholder with some palette names. */ static void instantiate(std::string &target, - std::string const &palettes); + const std::string &palettes); private: -- cgit v1.2.3-70-g09d2 From fcc90586d1d1631c31b2799fdaf410af1b073cf0 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Wed, 17 Dec 2008 22:13:24 +0100 Subject: Reintroduced window name property Still used in the eAthena client and it seems saner to me to have it. --- src/gui/buy.cpp | 3 ++- src/gui/chat.cpp | 3 ++- src/gui/debugwindow.cpp | 3 ++- src/gui/equipmentwindow.cpp | 3 ++- src/gui/guildwindow.cpp | 3 ++- src/gui/help.cpp | 1 + src/gui/inventorywindow.cpp | 3 ++- src/gui/itemshortcutwindow.cpp | 3 ++- src/gui/login.cpp | 7 ++----- src/gui/magic.cpp | 3 ++- src/gui/minimap.cpp | 5 +++-- src/gui/ministatus.cpp | 3 +-- src/gui/partywindow.cpp | 3 ++- src/gui/sell.cpp | 3 ++- src/gui/skill.cpp | 3 ++- src/gui/status.cpp | 5 +++-- src/gui/trade.cpp | 3 ++- src/gui/window.cpp | 7 ++++--- src/gui/window.h | 17 +++++++++++++---- 19 files changed, 51 insertions(+), 30 deletions(-) (limited to 'src/gui') diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index a948b136..008c7bb9 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -40,6 +40,7 @@ BuyDialog::BuyDialog(): Window(_("Buy")), mMoney(0), mAmountItems(0), mMaxItems(0) { + setWindowName("Buy"); setResizable(true); setMinWidth(260); setMinHeight(230); @@ -85,7 +86,7 @@ BuyDialog::BuyDialog(): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); - loadWindowState("Buy"); + loadWindowState(); setLocationRelativeTo(getParent()); } diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 5bd661d6..888dd27d 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -52,6 +52,7 @@ ChatWindow::ChatWindow(): Window("Chat"), mTmpVisible(false) { + setWindowName("Chat"); setResizable(true); setDefaultSize(0, windowContainer->getHeight() - 123, 600, 123); setOpaque(false); @@ -88,7 +89,7 @@ ChatWindow::ChatWindow(): mChatInput->addKeyListener(this); mCurHist = mHistory.end(); - loadWindowState("Chat"); + loadWindowState(); } ChatWindow::~ChatWindow() diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index d92c3575..36e4c8e1 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -39,10 +39,11 @@ DebugWindow::DebugWindow(): Window("Debug") { + setWindowName("Debug"); setResizable(true); setCloseButton(true); setDefaultSize(0, 0, 400, 100); - loadWindowState("Debug"); + loadWindowState(); mFPSLabel = new gcn::Label("[0 FPS]"); mFPSLabel->setPosition(0,0); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 57f0899b..6848b4d8 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -56,9 +56,10 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment): mBackground(NULL), mSelected(-1) { + setWindowName("Equipment"); setCloseButton(true); setDefaultSize(5, 195, 216, 260); - loadWindowState("Equipment"); + loadWindowState(); mUnequip = new Button(_("Unequip"), "unequip", this); gcn::Rectangle const &area = getChildrenArea(); diff --git a/src/gui/guildwindow.cpp b/src/gui/guildwindow.cpp index ae9684df..0596c75e 100644 --- a/src/gui/guildwindow.cpp +++ b/src/gui/guildwindow.cpp @@ -49,6 +49,7 @@ GuildWindow::GuildWindow(): Window(_("Guild")), mFocus(false) { + setWindowName("Guild"); setCaption(_("Guild")); setResizable(false); setCloseButton(true); @@ -73,7 +74,7 @@ GuildWindow::GuildWindow(): layout.setColWidth(0, 48); layout.setColWidth(1, 65); - loadWindowState("Guild"); + loadWindowState(); } GuildWindow::~GuildWindow() diff --git a/src/gui/help.cpp b/src/gui/help.cpp index ffe9c02d..290679b9 100644 --- a/src/gui/help.cpp +++ b/src/gui/help.cpp @@ -31,6 +31,7 @@ HelpWindow::HelpWindow(): Window("Help") { setContentSize(455, 350); + setWindowName("Help"); mBrowserBox = new BrowserBox(); mBrowserBox->setOpaque(false); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 92b635d8..1e3c4084 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -53,6 +53,7 @@ InventoryWindow::InventoryWindow(): Window(_("Inventory")), mSplit(false) { + setWindowName("Inventory"); setResizable(false); setCloseButton(true); // LEEOR/TODO: Since this window is not resizable, do we really need to set these @@ -82,7 +83,7 @@ InventoryWindow::InventoryWindow(): layout.setColWidth(2, 48); layout.setRowHeight(0, Layout::AUTO_SET); - loadWindowState("Inventory"); + loadWindowState(); } void InventoryWindow::logic() diff --git a/src/gui/itemshortcutwindow.cpp b/src/gui/itemshortcutwindow.cpp index 1a71b11e..e21f421b 100644 --- a/src/gui/itemshortcutwindow.cpp +++ b/src/gui/itemshortcutwindow.cpp @@ -28,6 +28,7 @@ static const int SCROLL_PADDING = 0; ItemShortcutWindow::ItemShortcutWindow() { + setWindowName("ItemShortcut"); // no title presented, title bar is padding so window can be moved. gcn::Window::setTitleBarHeight(gcn::Window::getPadding()); setShowTitle(false); @@ -49,7 +50,7 @@ ItemShortcutWindow::ItemShortcutWindow() add(mScrollArea); - loadWindowState("ItemShortcut"); + loadWindowState(); } ItemShortcutWindow::~ItemShortcutWindow() diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 24c55e37..b4289984 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -71,12 +71,9 @@ LoginDialog::LoginDialog(LoginData *loginData) : Window(_("Login")), mLoginData( setLocationRelativeTo(getParent()); setVisible(true); - if (mUserField->getText().empty()) - { + if (mUserField->getText().empty()) { mUserField->requestFocus(); - } - else - { + } else { mPassField->requestFocus(); } diff --git a/src/gui/magic.cpp b/src/gui/magic.cpp index ad63f914..2c81321b 100644 --- a/src/gui/magic.cpp +++ b/src/gui/magic.cpp @@ -35,6 +35,7 @@ MagicDialog::MagicDialog(): Window(_("Magic")) { + setWindowName("Magic"); setCloseButton(true); setDefaultSize(255, 30, 175, 225); @@ -53,7 +54,7 @@ MagicDialog::MagicDialog(): update(); setLocationRelativeTo(getParent()); - loadWindowState(_("Magic")); + loadWindowState(); } MagicDialog::~MagicDialog() diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 02d20d8e..f7749755 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -34,8 +34,9 @@ Minimap::Minimap(): Window(_("MiniMap")), mMapImage(NULL) { - setDefaultSize(0, 0, 100, 100); - loadWindowState("MiniMap"); + setWindowName("MiniMap"); + setDefaultSize(5, 25, 100, 100); + loadWindowState(); // LEEOR: The Window class needs to modified to accept // setAlignment calls. setAlignment(gcn::Graphics::CENTER); diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 424c3558..86e5a8f1 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -32,8 +32,7 @@ #include "../utils/tostring.h" -MiniStatusWindow::MiniStatusWindow(): - Window() +MiniStatusWindow::MiniStatusWindow() { setResizable(false); setMovable(false); diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 262e3b2e..c4a1c780 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -29,6 +29,7 @@ PartyWindow::PartyWindow() : Window(_("Party")) { + setWindowName("Party"); setVisible(false); setResizable(false); setCaption(_("Party")); @@ -37,7 +38,7 @@ PartyWindow::PartyWindow() : Window(_("Party")) setMinHeight(200); setDefaultSize(620, 300, 110, 200); - loadWindowState("Party"); + loadWindowState(); } PartyWindow::~PartyWindow() diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 30e78368..24391458 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -44,6 +44,7 @@ SellDialog::SellDialog(): Window(_("Sell")), mMaxItems(0), mAmountItems(0) { + setWindowName("Sell"); setResizable(true); setMinWidth(260); setMinHeight(230); @@ -90,7 +91,7 @@ SellDialog::SellDialog(): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); - loadWindowState("Sell"); + loadWindowState(); setLocationRelativeTo(getParent()); } diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 2eecca55..6d747641 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -43,6 +43,7 @@ SkillDialog::SkillDialog(): Window(_("Skills")) { + setWindowName("Skills"); setCloseButton(true); setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425); @@ -69,7 +70,7 @@ SkillDialog::SkillDialog(): update(); setLocationRelativeTo(getParent()); - loadWindowState(_("Skills")); + loadWindowState(); } SkillDialog::~SkillDialog() diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 43f81135..283a771b 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -36,11 +36,12 @@ StatusWindow::StatusWindow(LocalPlayer *player): Window(player->getName()), mPlayer(player) { + setWindowName("Status"); setResizable(true); setCloseButton(true); setDefaultSize((windowContainer->getWidth() - 365) / 2, - (windowContainer->getHeight() - 255) / 2, 365, 280); - loadWindowState("Status"); + (windowContainer->getHeight() - 255) / 2, 365, 275); + loadWindowState(); // ---------------------- // Status Part diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 38064f48..7d5051c7 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -53,6 +53,7 @@ TradeWindow::TradeWindow(): mPartnerInventory(new Inventory), mStatus(PREPARING) { + setWindowName("Trade"); setResizable(true); setDefaultSize(115, 197, 332, 209); @@ -102,7 +103,7 @@ TradeWindow::TradeWindow(): layout.setColWidth(0, Layout::AUTO_SET); layout.setColWidth(1, Layout::AUTO_SET); - loadWindowState("Trade"); + loadWindowState(); } TradeWindow::~TradeWindow() diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 9dc70189..c40f8a25 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -129,7 +129,7 @@ Window::~Window() { logger->log("UNLOAD: Window::~Window(\"%s\")", getCaption().c_str()); - const std::string &name = mConfigName; + const std::string &name = mWindowName; if (!name.empty()) { // Saving X, Y and Width and Height for resizables in the config @@ -466,9 +466,10 @@ void Window::mouseDragged(gcn::MouseEvent &event) } } -void Window::loadWindowState(const std::string &name) +void Window::loadWindowState() { - mConfigName = name; + const std::string &name = mWindowName; + assert(!name.empty()); setPosition((int) config.getValue(name + "WinX", mDefaultX), (int) config.getValue(name + "WinY", mDefaultY)); diff --git a/src/gui/window.h b/src/gui/window.h index 493bce37..6f49e062 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -153,8 +153,7 @@ class Window : public gcn::Window, gcn::WidgetListener * * @return The parent window or NULL if there is none. */ - Window* - getParentWindow() { return mParent; } + Window *getParentWindow() { return mParent; } /** * Schedule this window for deletion. It will be deleted at the start @@ -191,6 +190,16 @@ class Window : public gcn::Window, gcn::WidgetListener */ void mouseExited(gcn::MouseEvent &event); + /** + * Sets the name of the window. This is not the window title. + */ + void setWindowName(const std::string &name) { mWindowName = name; } + + /** + * Returns the name of the window. This is not the window title. + */ + const std::string &getWindowName() { return mWindowName; } + /** * Reads the position (and the size for resizable windows) in the * configuration based on the given string. @@ -198,7 +207,7 @@ class Window : public gcn::Window, gcn::WidgetListener * Don't forget to set these default values and resizable before * calling this function. */ - void loadWindowState(const std::string &); + void loadWindowState(); /** * Set the default win pos and size. @@ -267,7 +276,7 @@ class Window : public gcn::Window, gcn::WidgetListener ResizeGrip *mGrip; /**< Resize grip */ Window *mParent; /**< The parent window */ Layout *mLayout; /**< Layout handler */ - std::string mConfigName; /**< Name used for saving window-related data */ + std::string mWindowName; /**< Name of the window */ bool mShowTitle; /**< Window has a title bar */ bool mModal; /**< Window is modal */ bool mCloseButton; /**< Window has a close button */ -- cgit v1.2.3-70-g09d2 From b885ddf99f73a5a86b72d60264a46bb2c4b0b995 Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Wed, 17 Dec 2008 21:15:26 +0100 Subject: Remember windows visibility. (cherry picked from eathena client repository, commits 88af5cb15a02a26f4a5990ba3ef4df46e572bff4, 19ee623c0a1fdd333ef5b945ea887c983c829b1e, f924885ea0db5842b080610ec63e61a4bcc2a30c) Conflicts: src/gui/itemshortcutwindow.cpp src/gui/window.cpp --- src/game.cpp | 16 ++++++++++++---- src/gui/window.cpp | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/game.cpp b/src/game.cpp index 11712f6b..fc9d89eb 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -219,10 +219,18 @@ void createGuiWindows() //buddyWindow->setPosition(10, minimap->getHeight() + 30); // Set initial window visibility - chatWindow->setVisible(true); - miniStatusWindow->setVisible(true); - menuWindow->setVisible(true); - itemShortcutWindow->setVisible(true); + chatWindow->setVisible((bool) config.getValue( + chatWindow->getWindowName() + "Visible", true)); + miniStatusWindow->setVisible((bool) config.getValue( + miniStatusWindow->getWindowName() + "Visible", + true)); + buyDialog->setVisible(false); + sellDialog->setVisible(false); + tradeWindow->setVisible(false); + menuWindow->setVisible((bool) config.getValue( + menuWindow->getWindowName() + "Visible", true)); + itemShortcutWindow->setVisible((bool) config.getValue( + itemShortcutWindow->getWindowName() + "Visible", true)); if (config.getValue("logToChat", 0)) { diff --git a/src/gui/window.cpp b/src/gui/window.cpp index c40f8a25..582e4a67 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -135,6 +135,7 @@ Window::~Window() // Saving X, Y and Width and Height for resizables in the config config.setValue(name + "WinX", getX()); config.setValue(name + "WinY", getY()); + config.setValue(name + "Visible", isVisible()); if (mGrip) { @@ -473,6 +474,7 @@ void Window::loadWindowState() setPosition((int) config.getValue(name + "WinX", mDefaultX), (int) config.getValue(name + "WinY", mDefaultY)); + setVisible((bool) config.getValue(name + "Visible", false)); if (mGrip) { -- cgit v1.2.3-70-g09d2