diff options
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | src/gui/playerbox.cpp | 6 | ||||
-rw-r--r-- | src/gui/window.cpp | 73 | ||||
-rw-r--r-- | src/gui/window.h | 6 | ||||
-rw-r--r-- | src/resources/itemdb.cpp | 2 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 10 |
6 files changed, 63 insertions, 51 deletions
@@ -1,8 +1,23 @@ -2007-10-19 Philipp Sehmisch <tmw@crushnet.org> +2007-10-21 Guillaume Melquiond <guillaume.melquiond@gmail.com> + + * src/gui/window.cpp, src/gui/window.h: Removed redundant resizable + flag. Factored moving/resizing code, so that events are fired only + once per size change. + +2007-10-20 Guillaume Melquiond <guillaume.melquiond@gmail.com> + + * src/gui/playerbox.cpp: Centered sprite inside selection box. + +2007-10-19 Philipp Sehmisch <tmw@crushnet.org> * data/graphics/images/ambient/fog.png: Added fog effect overlay graphic. +2007-10-18 Guillaume Melquiond <guillaume.melquiond@gmail.com> + + * src/resources/iteminfo.h, src/resources/itemdb.cpp: Removed unused + slot field. + 2007-10-18 Philipp Sehmisch <tmw@crushnet.org> * data/graphics/sprites/hairstyle7-male.png, diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index 95366bee..e3f5b540 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -80,7 +80,11 @@ PlayerBox::draw(gcn::Graphics *graphics) if (mPlayer) { // Draw character - mPlayer->draw(static_cast<Graphics*>(graphics), 40, 42); + int x, y, bs; + bs = getBorderSize(); + x = getWidth() / 2 - 16 + bs; + y = getHeight() / 2 + bs; + mPlayer->draw(static_cast<Graphics*>(graphics), x, y); } } diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 650016cb..8317684a 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -64,7 +64,6 @@ Window::Window(const std::string& caption, bool modal, Window *parent): mWindowName("window"), mShowTitle(true), mModal(modal), - mResizable(false), mCloseButton(false), mSticky(false), mMinWinWidth(100), @@ -134,7 +133,7 @@ Window::~Window() config.setValue(name + "WinX", getX()); config.setValue(name + "WinY", getY()); - if (mResizable) + if (mGrip) { config.setValue(name + "WinWidth", getWidth()); config.setValue(name + "WinHeight", getHeight()); @@ -208,64 +207,64 @@ void Window::setContentHeight(int height) void Window::setContentSize(int width, int height) { - setContentWidth(width); - setContentHeight(height); + mChrome->setSize(width, height); + setSize(width + 2 * getPadding(), + height + getPadding() + getTitleBarHeight()); } -void Window::setWidth(int width) +void Window::setSize(int width, int height) { - gcn::Window::setWidth(width); + if (width == mDimension.width && height == mDimension.height) return; + + // No call to ancestor! Infinite loop otherwise. + mDimension.width = width; + mDimension.height = height; if (mGrip) { - mGrip->setX(getWidth() - mGrip->getWidth() - getChildrenArea().x); + gcn::Rectangle const &area = getChildrenArea(); + mGrip->setPosition(width - mGrip->getWidth() - area.x, + height - mGrip->getHeight() - area.y); } fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_RESIZED)); } -void Window::setHeight(int height) +void Window::setWidth(int width) { - gcn::Window::setHeight(height); - - if (mGrip) - { - mGrip->setY(getHeight() - mGrip->getHeight() - getChildrenArea().y); - } + setSize(width, mDimension.height); +} - fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_RESIZED)); +void Window::setHeight(int height) +{ + setSize(mDimension.width, height); } -void Window::setDimension(const gcn::Rectangle &dimension) +void Window::setPosition(int x, int y) { - gcn::Window::setDimension(dimension); + if (x == mDimension.x && y == mDimension.y) return; - if (mGrip) - { - mGrip->setX(getWidth() - mGrip->getWidth() - getChildrenArea().x); - mGrip->setY(getHeight() - mGrip->getHeight() - getChildrenArea().y); - } + // No call to ancestor! + mDimension.x = x; + mDimension.y = y; - fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_RESIZED)); fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED)); } -void Window::setPosition(int x, int y) +void Window::setDimension(const gcn::Rectangle &dimension) { - gcn::Window::setPosition(x, y); - fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED)); + setPosition(dimension.x, dimension.y); + setSize(dimension.width, dimension.height); } void Window::setX(int x) { - gcn::Window::setX(x); - fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED)); + setPosition(x, mDimension.y); } void Window::setY(int y) { - gcn::Window::setY(y); - fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED)); + setPosition(mDimension.x, y); } void Window::setLocationRelativeTo(gcn::Widget *widget) @@ -302,9 +301,9 @@ void Window::setMaxHeight(unsigned int height) void Window::setResizable(bool r) { - mResizable = r; + if ((bool)mGrip == r) return; - if (mResizable) + if (r) { mGrip = new ResizeGrip(); mGrip->setX(getWidth() - mGrip->getWidth() - getChildrenArea().x); @@ -325,7 +324,7 @@ void Window::setCloseButton(bool flag) bool Window::isResizable() { - return mResizable; + return mGrip; } void Window::setSticky(bool sticky) @@ -397,7 +396,7 @@ void Window::mousePressed(gcn::MouseEvent &event) void Window::mouseReleased(gcn::MouseEvent &event) { - if (mResizable && mouseResize) + if (mGrip && mouseResize) { mouseResize = 0; gui->setCursorType(Gui::CURSOR_POINTER); @@ -409,7 +408,7 @@ void Window::mouseReleased(gcn::MouseEvent &event) void Window::mouseExited(gcn::MouseEvent &event) { - if (mResizable && !mouseResize) + if (mGrip && !mouseResize) { gui->setCursorType(Gui::CURSOR_POINTER); } @@ -530,7 +529,7 @@ Window::loadWindowState() setPosition((int) config.getValue(name + "WinX", getX()), (int) config.getValue(name + "WinY", getY())); - if (mResizable) + if (mGrip) { setSize((int) config.getValue(name + "WinWidth", getWidth()), (int) config.getValue(name + "WinHeight", getHeight())); @@ -563,7 +562,7 @@ int Window::getResizeHandles(gcn::MouseEvent &event) int resizeHandles = 0; const int y = event.getY(); - if (mResizable && y > (int) mTitleBarHeight) + if (mGrip && y > (int) mTitleBarHeight) { const int x = event.getX(); diff --git a/src/gui/window.h b/src/gui/window.h index 583601ab..8e3fdef9 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -102,6 +102,11 @@ class Window : public gcn::Window void setContentSize(int width, int height); /** + * Sets the size of this window. + */ + void setSize(int width, int height); + + /** * Sets the width of this window. */ void setWidth(int width); @@ -310,7 +315,6 @@ class Window : public gcn::Window std::string mWindowName; /**< Name of the window */ bool mShowTitle; /**< Window has a title bar */ bool mModal; /**< Window is modal */ - bool mResizable; /**< Window can be resized */ bool mCloseButton; /**< Window has a close button */ bool mSticky; /**< Window resists minimization */ int mMinWinWidth; /**< Minimum window width */ diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 18952ae9..636763fc 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -101,7 +101,6 @@ void ItemDB::load() int type = XML::getProperty(node, "type", 0); int weight = XML::getProperty(node, "weight", 0); int view = XML::getProperty(node, "view", 0); - int slot = XML::getProperty(node, "slot", 0); std::string name = XML::getProperty(node, "name", ""); std::string image = XML::getProperty(node, "image", ""); @@ -119,7 +118,6 @@ void ItemDB::load() itemInfo->setType(type); itemInfo->setView(view); itemInfo->setWeight(weight); - itemInfo->setSlot(slot); itemInfo->setAttackType(attackType); for_each_xml_child_node(itemChild, node) diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 4fd1638e..457daf7f 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -54,7 +54,6 @@ class ItemInfo mType(0), mWeight(0), mView(0), - mSlot(0), mAttackType(ACTION_DEFAULT) { } @@ -102,12 +101,6 @@ class ItemInfo void setView(int view) { mView = view; } - void setSlot(char slot) - { mSlot = slot; } - - char getSlot() const - { return mSlot; } - void setSprite(const std::string &animationFile, int gender) { mAnimationFiles[gender] = animationFile; } @@ -134,12 +127,11 @@ class ItemInfo std::string mName; std::string mDescription; /**< Short description. */ std::string mEffect; /**< Description of effects. */ - short mType; /**< Item type (never used). */ + char mType; /**< Item type. */ short mWeight; /**< Weight in grams. */ int mView; /**< Item ID of how this item looks. */ // Equipment related members - char mSlot; /**< Equipment slot. */ SpriteAction mAttackType; /**< Attack type, in case of weapon. */ /** Maps gender to sprite filenames. */ |