From f6e7a477681109aea040456e3f4ebd0f65645ecc Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 25 Mar 2009 09:55:44 -0600 Subject: Moved the responsibility for skin alpha adjustment to the Skin class. This fixes a break that occured where skins wouldn't update in real time in the client, due to being passed a reference, rather than getting the skin itself. Signed-off-by: Ira Rice --- src/gui/popup.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src/gui/popup.h') diff --git a/src/gui/popup.h b/src/gui/popup.h index bfe8d7e9..3e3ff5ad 100644 --- a/src/gui/popup.h +++ b/src/gui/popup.h @@ -28,7 +28,6 @@ #include "../graphics.h" #include "../guichanfwd.h" -class ConfigListener; class Skin; class SkinLoader; class Window; @@ -43,8 +42,6 @@ class WindowContainer; class Popup : public gcn::Container { public: - friend class PopupConfigListener; - /** * Constructor. Initializes the title to the given text and hooks * itself into the popup container. @@ -170,21 +167,13 @@ class Popup : public gcn::Container virtual gcn::Rectangle getChildrenArea(); private: - void setGuiAlpha(); - Window *mParent; /**< The parent Window (if there is one) */ std::string mPopupName; /**< Name of the Popup */ - static bool mAlphaChanged; /**< Whether the alpha percent was changed */ int mMinWidth; /**< Minimum Popup width */ int mMinHeight; /**< Minimum Popup height */ int mMaxWidth; /**< Maximum Popup width */ int mMaxHeight; /**< Maximum Popup height */ - unsigned int mPadding; /**< Holds the padding of the window. */ - - /** - * The config listener that listens to changes relevant to all Popups. - */ - static ConfigListener *popupConfigListener; + unsigned int mPadding; /**< Holds the padding of the window. */ static int instances; /**< Number of Popup instances */ -- cgit v1.2.3-70-g09d2 From e0be7afc936c39e2b0e1db84a13653cfd78a6035 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 25 Mar 2009 11:31:02 -0600 Subject: Modified skin loading to save and load a skin's XML path, as well as modified the skin loading method to take a default value, in case the value in the configuration file fails to load for one reason or another. While this doesn't directly expose skinning on a per window basis to the user at the moment, it does allow people to change what skins get loaded with which windows now without needing to modify the code. TODO: Determine a decent approach to allowing the user to change their window skins in game, as well as moving all widget skin loading to the skin class (for instance, the button skins, progressbar skins, etc.) so that different skin configurations can use different widget skins. Signed-off-by: Ira Rice --- src/gui/itempopup.cpp | 4 +++- src/gui/popup.cpp | 33 +++++++++++++++++++++++++++++- src/gui/popup.h | 35 ++++++++++++++++++++++---------- src/gui/popupmenu.cpp | 4 +++- src/gui/skin.cpp | 53 ++++++++++++++++++++++++++++++++---------------- src/gui/skin.h | 11 ++++++++-- src/gui/speechbubble.cpp | 2 ++ src/gui/window.cpp | 12 ++++++++++- src/gui/window.h | 46 ++++++++++++++++++++--------------------- 9 files changed, 142 insertions(+), 58 deletions(-) (limited to 'src/gui/popup.h') diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index a4042ae2..2ebe6645 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -39,7 +39,7 @@ #include "../utils/stringutils.h" ItemPopup::ItemPopup(): - Popup() + Popup("ItemPopup") { mItemType = ""; @@ -85,6 +85,8 @@ ItemPopup::ItemPopup(): add(mItemDescScroll); add(mItemEffectScroll); add(mItemWeightScroll); + + loadPopupConfiguration(); } ItemPopup::~ItemPopup() diff --git a/src/gui/popup.cpp b/src/gui/popup.cpp index d44dbc93..6d57081f 100644 --- a/src/gui/popup.cpp +++ b/src/gui/popup.cpp @@ -42,6 +42,7 @@ Popup::Popup(const std::string& name, Window *parent, const std::string& skin): mParent(parent), mPopupName(name), + mDefaultSkinPath(skin), mMinWidth(100), mMinHeight(40), mMaxWidth(INT_MAX), @@ -57,7 +58,7 @@ Popup::Popup(const std::string& name, Window *parent, instances++; // Loads the skin - mSkin = skinLoader->load(skin); + mSkin = skinLoader->load(skin, mDefaultSkinPath); // Add this window to the window container windowContainer->add(this); @@ -70,6 +71,8 @@ Popup::~Popup() { logger->log("Popup::~Popup(\"%s\")", mPopupName.c_str()); + savePopupConfiguration(); + while (!mWidgets.empty()) { gcn::Widget *w = mWidgets.front(); @@ -87,6 +90,34 @@ void Popup::setWindowContainer(WindowContainer *wc) windowContainer = wc; } +void Popup::loadPopupConfiguration() +{ + if (mPopupName.empty()) + return; + + const std::string &name = mPopupName; + const std::string &skinName = config.getValue(name + "Skin", + mSkin->getFilePath()); + + if (skinName.compare(mSkin->getFilePath()) != 0) + { + mSkin->instances--; + mSkin = skinLoader->load(skinName, mDefaultSkinPath); + } +} + +void Popup::savePopupConfiguration() +{ + if (mPopupName.empty()) + return; + + const std::string &name = mPopupName; + + // Saves the skin path in a config file (which allows for skins to be + // changed from the default path) + config.setValue(name + "Skin", mSkin->getFilePath()); +} + void Popup::draw(gcn::Graphics *graphics) { if (!isVisible()) diff --git a/src/gui/popup.h b/src/gui/popup.h index 3e3ff5ad..868f2a2b 100644 --- a/src/gui/popup.h +++ b/src/gui/popup.h @@ -66,6 +66,18 @@ class Popup : public gcn::Container */ static void setWindowContainer(WindowContainer *windowContainer); + /** + * Changes the popup's skin to use the skin defined in the saved + * configuration file. + */ + void loadPopupConfiguration(); + + /** + * Currently only saves the skin used by the popup so that when the + * client is reloaded, it can use the saved skin. + */ + void savePopupConfiguration(); + /** * Draws the popup. */ @@ -167,17 +179,18 @@ class Popup : public gcn::Container virtual gcn::Rectangle getChildrenArea(); private: - Window *mParent; /**< The parent Window (if there is one) */ - std::string mPopupName; /**< Name of the Popup */ - int mMinWidth; /**< Minimum Popup width */ - int mMinHeight; /**< Minimum Popup height */ - int mMaxWidth; /**< Maximum Popup width */ - int mMaxHeight; /**< Maximum Popup height */ - unsigned int mPadding; /**< Holds the padding of the window. */ - - static int instances; /**< Number of Popup instances */ - - Skin* mSkin; /**< Skin in use by this Popup */ + Window *mParent; /**< The parent Window (if there is one) */ + std::string mPopupName; /**< Name of the popup */ + std::string mDefaultSkinPath; /**< Default skin path for this popup */ + int mMinWidth; /**< Minimum popup width */ + int mMinHeight; /**< Minimum popup height */ + int mMaxWidth; /**< Maximum popup width */ + int mMaxHeight; /**< Maximum popup height */ + unsigned int mPadding; /**< Holds the padding of the popup. */ + + static int instances; /**< Number of popup instances */ + + Skin* mSkin; /**< Skin in use by this popup */ }; #endif diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 02be3055..fd2a0361 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -61,8 +61,10 @@ PopupMenu::PopupMenu(): mBrowserBox->setPosition(4, 4); mBrowserBox->setHighlightMode(BrowserBox::BACKGROUND); mBrowserBox->setOpaque(false); - add(mBrowserBox); mBrowserBox->setLinkHandler(this); + add(mBrowserBox); + + loadWindowState(); } void PopupMenu::showPopup(int x, int y, Being *being) diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp index ac258175..515ef01b 100644 --- a/src/gui/skin.cpp +++ b/src/gui/skin.cpp @@ -31,6 +31,7 @@ #include "../resources/resourcemanager.h" #include "../utils/dtor.h" +#include "../utils/strprintf.h" #include "../utils/xml.h" SkinLoader* skinLoader = NULL; @@ -45,8 +46,9 @@ class SkinConfigListener : public ConfigListener } }; -Skin::Skin(ImageRect skin, Image* close, std::string name): +Skin::Skin(ImageRect skin, Image* close, std::string filePath, std::string name): instances(0), + mFilePath(filePath), mName(name), border(skin), closeImage(close) @@ -86,32 +88,47 @@ unsigned int Skin::getMinHeight() border.grid[6]->getHeight(); } -Skin* SkinLoader::load(const std::string &filename) +Skin* SkinLoader::load(const std::string &filename, + const std::string &defaultPath) { - SkinIterator skinIterator = mSkins.find(filename); - - if (mSkins.end() != skinIterator) - { - skinIterator->second->instances++; - return skinIterator->second; - } + std::string filePath = filename; ResourceManager *resman = ResourceManager::getInstance(); logger->log("Loading Skin '%s'.", filename.c_str()); - if (filename.empty()) + if (filename.empty() && defaultPath.empty()) logger->error("SkinLoader::load(): Invalid File Name."); - // TODO: - // If there is an error loading the specified file, we should try to revert - // to a 'default' skin file. Only if the 'default' skin file can't be loaded - // should we have a terminating error. - XML::Document doc(filename); - xmlNodePtr rootNode = doc.rootNode(); + XML::Document *doc = new XML::Document(filePath); + xmlNodePtr rootNode = doc->rootNode(); if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "skinset")) - logger->error("Widget Skinning error"); + { + filePath = defaultPath; + + logger->log("Widget Skinning error. Loading '%s' instead.", + filePath.c_str()); + + delete doc; + + doc = new XML::Document(filePath); + rootNode = doc->rootNode(); + if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "skinset")) + { + logger->error(strprintf("Skinning failed. Check this skin file " + "to make sure it's valid: %s", + filePath.c_str())); + } + } + + SkinIterator skinIterator = mSkins.find(filePath); + + if (mSkins.end() != skinIterator) + { + skinIterator->second->instances++; + return skinIterator->second; + } std::string skinSetImage; skinSetImage = XML::getProperty(rootNode, "image", ""); @@ -197,7 +214,7 @@ Skin* SkinLoader::load(const std::string &filename) // Hard-coded for now until we update the above code to look for window buttons. Image* closeImage = resman->getImage("graphics/gui/close_button.png"); - Skin* skin = new Skin(border, closeImage); + Skin* skin = new Skin(border, closeImage, filename); mSkins[filename] = skin; diff --git a/src/gui/skin.h b/src/gui/skin.h index c90952e3..b7e2c29f 100644 --- a/src/gui/skin.h +++ b/src/gui/skin.h @@ -33,7 +33,8 @@ class Image; class Skin { public: - Skin(ImageRect skin, Image* close, std::string name = ""); + Skin(ImageRect skin, Image* close, std::string filePath, + std::string name = ""); ~Skin(); /** @@ -43,6 +44,11 @@ class Skin */ std::string getName() { return mName; } + /** + * Returns the skin's xml file path. + */ + std::string getFilePath() { return mFilePath; } + /** * Returns the background skin. */ @@ -76,6 +82,7 @@ class Skin int instances; private: + std::string mFilePath; /**< File name path for the skin */ std::string mName; /**< Name of the skin to use */ ImageRect border; /**< The window border and background */ Image *closeImage; /**< Close Button Image */ @@ -98,7 +105,7 @@ class SkinLoader /** * Loads a skin */ - Skin* load(const std::string &filename); + Skin* load(const std::string &filename, const std::string &defaultPath); /** * Updates the alpha values of all of the skins diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 9e4c9234..ca771fce 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -60,6 +60,8 @@ SpeechBubble::SpeechBubble(): add(mCaption); add(mSpeechArea); + + loadPopupConfiguration(); } void SpeechBubble::setCaption(const std::string &name, const gcn::Color *color) diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 75820521..642fdeb8 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -48,6 +48,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent, const std mParent(parent), mLayout(NULL), mWindowName("window"), + mDefaultSkinPath(skin), mShowTitle(true), mModal(modal), mCloseButton(false), @@ -74,7 +75,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent, const std setTitleBarHeight(20); // Loads the skin - mSkin = skinLoader->load(skin); + mSkin = skinLoader->load(skin, mDefaultSkinPath); // Add this window to the window container windowContainer->add(this); @@ -476,12 +477,20 @@ void Window::mouseDragged(gcn::MouseEvent &event) void Window::loadWindowState() { const std::string &name = mWindowName; + const std::string skinName = config.getValue(name + "Skin", + mSkin->getFilePath()); assert(!name.empty()); setPosition((int) config.getValue(name + "WinX", mDefaultX), (int) config.getValue(name + "WinY", mDefaultY)); setVisible((bool) config.getValue(name + "Visible", false)); + if (skinName.compare(mSkin->getFilePath()) != 0) + { + mSkin->instances--; + mSkin = skinLoader->load(skinName, mDefaultSkinPath); + } + if (mGrip) { int width = (int) config.getValue(name + "WinWidth", mDefaultWidth); @@ -512,6 +521,7 @@ void Window::saveWindowState() config.setValue(mWindowName + "WinX", getX()); config.setValue(mWindowName + "WinY", getY()); config.setValue(mWindowName + "Visible", isVisible()); + config.setValue(mWindowName + "Skin", mSkin->getFilePath()); if (mGrip) { diff --git a/src/gui/window.h b/src/gui/window.h index b0b67ad8..66e73e12 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -320,29 +320,29 @@ class Window : public gcn::Window, gcn::WidgetListener */ int getResizeHandles(gcn::MouseEvent &event); - GCContainer *mChrome; /**< Contained container */ - ResizeGrip *mGrip; /**< Resize grip */ - Window *mParent; /**< The parent window */ - Layout *mLayout; /**< Layout handler */ - 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 */ - bool mSticky; /**< Window resists minimization */ - bool mAlphaChanged; /**< Whether the alpha percent was changed */ - int mMinWinWidth; /**< Minimum window width */ - int mMinWinHeight; /**< Minimum window height */ - int mMaxWinWidth; /**< Maximum window width */ - int mMaxWinHeight; /**< Maximum window height */ - int mDefaultX; /**< Default window X position */ - int mDefaultY; /**< Default window Y position */ - int mDefaultWidth; /**< Default window width */ - int mDefaultHeight; /**< Default window height */ - - static int mouseResize; /**< Active resize handles */ - static int instances; /**< Number of Window instances */ - - Skin* mSkin; /**< Skin in use by this window */ + GCContainer *mChrome; /**< Contained container */ + ResizeGrip *mGrip; /**< Resize grip */ + Window *mParent; /**< The parent window */ + Layout *mLayout; /**< Layout handler */ + std::string mWindowName; /**< Name of the window */ + std::string mDefaultSkinPath; /**< Default skin path for this window */ + bool mShowTitle; /**< Window has a title bar */ + bool mModal; /**< Window is modal */ + bool mCloseButton; /**< Window has a close button */ + bool mSticky; /**< Window resists minimization */ + int mMinWinWidth; /**< Minimum window width */ + int mMinWinHeight; /**< Minimum window height */ + int mMaxWinWidth; /**< Maximum window width */ + int mMaxWinHeight; /**< Maximum window height */ + int mDefaultX; /**< Default window X position */ + int mDefaultY; /**< Default window Y position */ + int mDefaultWidth; /**< Default window width */ + int mDefaultHeight; /**< Default window height */ + + static int mouseResize; /**< Active resize handles */ + static int instances; /**< Number of Window instances */ + + Skin* mSkin; /**< Skin in use by this window */ /** * The width of the resize border. Is independent of the actual window -- cgit v1.2.3-70-g09d2 From 2ec46b9a6e5ca1beb043da00cf2bb9d34722ec72 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 27 Mar 2009 00:17:27 +0100 Subject: Compile warning fixes Mostly unsigned/signed mismatches and an unused variable. --- src/gui/popup.cpp | 8 ++++---- src/gui/popup.h | 20 ++++++++++---------- src/gui/skin.cpp | 4 ++-- src/gui/skin.h | 4 ++-- src/gui/window.cpp | 13 ++++--------- src/gui/window.h | 21 +++++++++++---------- 6 files changed, 33 insertions(+), 37 deletions(-) (limited to 'src/gui/popup.h') diff --git a/src/gui/popup.cpp b/src/gui/popup.cpp index 85ba3b7a..8dfc3c61 100644 --- a/src/gui/popup.cpp +++ b/src/gui/popup.cpp @@ -163,22 +163,22 @@ void Popup::setLocationRelativeTo(gcn::Widget *widget) getY() + (wy + (widget->getHeight() - getHeight()) / 2 - y)); } -void Popup::setMinWidth(unsigned int width) +void Popup::setMinWidth(int width) { mMinWidth = width > mSkin->getMinWidth() ? width : mSkin->getMinWidth(); } -void Popup::setMinHeight(unsigned int height) +void Popup::setMinHeight(int height) { mMinHeight = height > mSkin->getMinHeight() ? height : mSkin->getMinHeight(); } -void Popup::setMaxWidth(unsigned int width) +void Popup::setMaxWidth(int width) { mMaxWidth = width; } -void Popup::setMaxHeight(unsigned int height) +void Popup::setMaxHeight(int height) { mMaxHeight = height; } diff --git a/src/gui/popup.h b/src/gui/popup.h index 868f2a2b..37c99ded 100644 --- a/src/gui/popup.h +++ b/src/gui/popup.h @@ -96,42 +96,42 @@ class Popup : public gcn::Container /** * Sets the minimum width of the popup. */ - void setMinWidth(unsigned int width); + void setMinWidth(int width); /** * Sets the minimum height of the popup. */ - void setMinHeight(unsigned int height); + void setMinHeight(int height); /** * Sets the maximum width of the popup. */ - void setMaxWidth(unsigned int width); + void setMaxWidth(int width); /** * Sets the minimum height of the popup. */ - void setMaxHeight(unsigned int height); + void setMaxHeight(int height); /** * Gets the minimum width of the popup. */ - int getMinWidth() { return mMinWidth; } + int getMinWidth() const { return mMinWidth; } /** * Gets the minimum height of the popup. */ - int getMinHeight() { return mMinHeight; } + int getMinHeight() const { return mMinHeight; } /** * Gets the maximum width of the popup. */ - int getMaxWidth() { return mMaxWidth; } + int getMaxWidth() const { return mMaxWidth; } /** * Gets the minimum height of the popup. */ - int getMaxHeight() { return mMaxHeight; } + int getMaxHeight() const { return mMaxHeight; } /** * Gets the padding of the popup. The padding is the distance between @@ -149,7 +149,7 @@ class Popup : public gcn::Container * @param padding The padding of the popup. * @see getPadding */ - void setPadding(unsigned int padding) { mPadding = padding; } + void setPadding(int padding) { mPadding = padding; } /** * Returns the parent Window. @@ -186,7 +186,7 @@ class Popup : public gcn::Container int mMinHeight; /**< Minimum popup height */ int mMaxWidth; /**< Maximum popup width */ int mMaxHeight; /**< Maximum popup height */ - unsigned int mPadding; /**< Holds the padding of the popup. */ + int mPadding; /**< Holds the padding of the popup. */ static int instances; /**< Number of popup instances */ diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp index e87f6761..10b9885a 100644 --- a/src/gui/skin.cpp +++ b/src/gui/skin.cpp @@ -76,13 +76,13 @@ void Skin::updateAlpha() closeImage->setAlpha(alpha); } -unsigned int Skin::getMinWidth() +int Skin::getMinWidth() const { return (border.grid[0]->getWidth() + border.grid[1]->getWidth()) + border.grid[2]->getWidth(); } -unsigned int Skin::getMinHeight() +int Skin::getMinHeight() const { return (border.grid[0]->getHeight() + border.grid[3]->getHeight()) + border.grid[6]->getHeight(); diff --git a/src/gui/skin.h b/src/gui/skin.h index b7e2c29f..1a603e29 100644 --- a/src/gui/skin.h +++ b/src/gui/skin.h @@ -67,12 +67,12 @@ class Skin /** * Returns the minimum width which can be used with this skin. */ - unsigned int getMinWidth(); + int getMinWidth() const; /** * Returns the minimum height which can be used with this skin. */ - unsigned int getMinHeight(); + int getMinHeight() const; /** * Updates the alpha value of the skin diff --git a/src/gui/window.cpp b/src/gui/window.cpp index f64f1caf..476dcd7e 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -221,23 +221,23 @@ void Window::setLocationRelativeTo(ImageRect::ImagePosition position, setPosition(offsetX, offsetY); } -void Window::setMinWidth(unsigned int width) +void Window::setMinWidth(int width) { mMinWinWidth = width > mSkin->getMinWidth() ? width : mSkin->getMinWidth(); } -void Window::setMinHeight(unsigned int height) +void Window::setMinHeight(int height) { mMinWinHeight = height > mSkin->getMinHeight() ? height : mSkin->getMinHeight(); } -void Window::setMaxWidth(unsigned int width) +void Window::setMaxWidth(int width) { mMaxWinWidth = width; } -void Window::setMaxHeight(unsigned int height) +void Window::setMaxHeight(int height) { mMaxWinHeight = height; } @@ -292,11 +292,6 @@ void Window::setSticky(bool sticky) mSticky = sticky; } -bool Window::isSticky() -{ - return mSticky; -} - void Window::setVisible(bool visible) { gcn::Window::setVisible(isSticky() || visible); diff --git a/src/gui/window.h b/src/gui/window.h index 66e73e12..8907ead4 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -116,42 +116,42 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Sets the minimum width of the window. */ - void setMinWidth(unsigned int width); + void setMinWidth(int width); /** * Sets the minimum height of the window. */ - void setMinHeight(unsigned int height); + void setMinHeight(int height); /** * Sets the maximum width of the window. */ - void setMaxWidth(unsigned int width); + void setMaxWidth(int width); /** * Sets the minimum height of the window. */ - void setMaxHeight(unsigned int height); + void setMaxHeight(int height); /** * Gets the minimum width of the window. */ - int getMinWidth() { return mMinWinWidth; } + int getMinWidth() const { return mMinWinWidth; } /** * Gets the minimum height of the window. */ - int getMinHeight() { return mMinWinHeight; } + int getMinHeight() const { return mMinWinHeight; } /** * Gets the maximum width of the window. */ - int getMaxWidth() { return mMaxWinWidth; } + int getMaxWidth() const { return mMaxWinWidth; } /** * Gets the minimum height of the window. */ - int getMaxHeight() { return mMaxWinHeight; } + int getMaxHeight() const { return mMaxWinHeight; } /** * Sets flag to show a title or not. @@ -167,7 +167,8 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Returns whether the window is sticky. */ - bool isSticky(); + bool isSticky() const + { return mSticky; } /** * Overloads window setVisible by Guichan to allow sticky window @@ -180,7 +181,7 @@ class Window : public gcn::Window, gcn::WidgetListener * * @return The parent window or NULL if there is none. */ - Window* getParentWindow() { return mParent; } + Window *getParentWindow() const { return mParent; } /** * Schedule this window for deletion. It will be deleted at the start -- cgit v1.2.3-70-g09d2 From 798e9a37aff31dad38f48ea051322b978fcf849b Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 26 Mar 2009 19:18:08 -0600 Subject: Fixed popup comment. This got chopped off some time when it was first created. Signed-off-by: Ira Rice --- src/gui/popup.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/gui/popup.h') diff --git a/src/gui/popup.h b/src/gui/popup.h index 37c99ded..639f2cc9 100644 --- a/src/gui/popup.h +++ b/src/gui/popup.h @@ -35,7 +35,11 @@ class WindowContainer; /** * A rather reduced down version of the Window class that is particularly suited - * for + * for popup type functionality that doesn't need to be resized or moved around + * by the mouse once created, but only needs to display some simple content, + * like a static message. Popups, in general, shouldn't also need to update + * their content once created, although this is not an explicit requirement to + * use the popup class. * * \ingroup GUI */ @@ -140,7 +144,7 @@ class Popup : public gcn::Container * @return The padding of the popup. * @see setPadding */ - unsigned int getPadding() const { return mPadding; } + int getPadding() const { return mPadding; } /** * Sets the padding of the popup. The padding is the distance between the -- cgit v1.2.3-70-g09d2 From 5561f4355ae1b1c167cd19575527ae0eae24e029 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 26 Mar 2009 19:38:10 -0600 Subject: Removed getting and setting a parent window from the popup class, since this currently does not provide any useful functionality to popups, as well as doing anything for that matter. Signed-off-by: Ira Rice --- src/gui/popup.cpp | 5 +---- src/gui/popup.h | 14 +------------- src/gui/speechbubble.cpp | 2 +- 3 files changed, 3 insertions(+), 18 deletions(-) (limited to 'src/gui/popup.h') diff --git a/src/gui/popup.cpp b/src/gui/popup.cpp index 8dfc3c61..a27b1d90 100644 --- a/src/gui/popup.cpp +++ b/src/gui/popup.cpp @@ -25,7 +25,6 @@ #include "gui.h" #include "skin.h" #include "popup.h" -#include "window.h" #include "windowcontainer.h" #include "../configlistener.h" @@ -36,9 +35,7 @@ int Popup::instances = 0; -Popup::Popup(const std::string& name, Window *parent, - const std::string& skin): - mParent(parent), +Popup::Popup(const std::string& name, const std::string& skin): mPopupName(name), mDefaultSkinPath(skin), mMinWidth(100), diff --git a/src/gui/popup.h b/src/gui/popup.h index 639f2cc9..58ccd16e 100644 --- a/src/gui/popup.h +++ b/src/gui/popup.h @@ -30,7 +30,6 @@ class Skin; class SkinLoader; -class Window; class WindowContainer; /** @@ -52,12 +51,9 @@ class Popup : public gcn::Container * * @param name A human readable name for the popup. Only useful for * debugging purposes. - * @param parent The parent Window. This is the Window standing above - * this one in the Window hiearchy. When reordering, - * a Popup will never go below its parent Window. * @param skin The location where the Popup's skin XML can be found. */ - Popup(const std::string& name = "", Window *parent = NULL, + Popup(const std::string& name = "", const std::string &skin = "graphics/gui/gui.xml"); /** @@ -155,13 +151,6 @@ class Popup : public gcn::Container */ void setPadding(int padding) { mPadding = padding; } - /** - * Returns the parent Window. - * - * @return The parent Window or NULL if there is none. - */ - Window* getParentWindow() { return mParent; } - /** * Sets the name of the popup. This is only useful for debug purposes. */ @@ -183,7 +172,6 @@ class Popup : public gcn::Container virtual gcn::Rectangle getChildrenArea(); private: - Window *mParent; /**< The parent Window (if there is one) */ std::string mPopupName; /**< Name of the popup */ std::string mDefaultSkinPath; /**< Default skin path for this popup */ int mMinWidth; /**< Minimum popup width */ diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index ca771fce..cd483c30 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -34,7 +34,7 @@ #include "../utils/gettext.h" SpeechBubble::SpeechBubble(): - Popup("Speech", NULL, "graphics/gui/speechbubble.xml"), + Popup("Speech", "graphics/gui/speechbubble.xml"), mText("") { setContentSize(140, 46); -- cgit v1.2.3-70-g09d2 From 2aab736bc5d77ffda789d7de56cef100fac207e1 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 26 Mar 2009 19:50:12 -0600 Subject: Removed setting and getting parent windows for popup classes, as this wasn't really useful or used at all. Also removed some unneeded includes in the popup class. Signed-off-by: Ira Rice --- src/gui/popup.cpp | 9 +-------- src/gui/popup.h | 3 --- 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'src/gui/popup.h') diff --git a/src/gui/popup.cpp b/src/gui/popup.cpp index a27b1d90..f4c7d4a3 100644 --- a/src/gui/popup.cpp +++ b/src/gui/popup.cpp @@ -22,19 +22,16 @@ #include -#include "gui.h" #include "skin.h" #include "popup.h" #include "windowcontainer.h" -#include "../configlistener.h" #include "../configuration.h" +#include "../graphics.h" #include "../log.h" #include "../resources/image.h" -int Popup::instances = 0; - Popup::Popup(const std::string& name, const std::string& skin): mPopupName(name), mDefaultSkinPath(skin), @@ -50,8 +47,6 @@ Popup::Popup(const std::string& name, const std::string& skin): setPadding(3); - instances++; - // Loads the skin mSkin = skinLoader->load(skin, mDefaultSkinPath); @@ -75,8 +70,6 @@ Popup::~Popup() delete(w); } - instances--; - mSkin->instances--; } diff --git a/src/gui/popup.h b/src/gui/popup.h index 58ccd16e..c68c2098 100644 --- a/src/gui/popup.h +++ b/src/gui/popup.h @@ -25,7 +25,6 @@ #include -#include "../graphics.h" #include "../guichanfwd.h" class Skin; @@ -180,8 +179,6 @@ class Popup : public gcn::Container int mMaxHeight; /**< Maximum popup height */ int mPadding; /**< Holds the padding of the popup. */ - static int instances; /**< Number of popup instances */ - Skin* mSkin; /**< Skin in use by this popup */ }; -- cgit v1.2.3-70-g09d2