diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-05-04 17:32:03 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-05-04 17:32:03 +0000 |
commit | cc493fae6ed87c2a101ea1ce1a6c2bb821bd51d5 (patch) | |
tree | cbc8d381cb22fe27bac58e5061b9fc1032a5b5f1 /src | |
parent | 4dbb3e75160e465dbcdb6de282d2e4ad8f89bdc0 (diff) | |
download | mana-cc493fae6ed87c2a101ea1ce1a6c2bb821bd51d5.tar.gz mana-cc493fae6ed87c2a101ea1ce1a6c2bb821bd51d5.tar.bz2 mana-cc493fae6ed87c2a101ea1ce1a6c2bb821bd51d5.tar.xz mana-cc493fae6ed87c2a101ea1ce1a6c2bb821bd51d5.zip |
Merged revisions 4031-4044,4046-4058,4061-4062,4064,4066-4067,4069-4070,4072-4079,4082-4092,4094-4097,4099,4101-4109,4112-4115,4117-4129,4131-4150 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/branches/0.0
........
r4031 | the_enemy | 2008-04-03 14:53:00 +0200 (Thu, 03 Apr 2008) | 1 line
Tweaked disconnect dialog to fix crash bug id=250
........
r4050 | b_lindeijer | 2008-04-07 19:37:23 +0200 (Mon, 07 Apr 2008) | 2 lines
Merged changes made for the 0.0.24.1 release (4046:4048 from 0.0.24 branch).
........
r4066 | b_lindeijer | 2008-04-10 23:48:36 +0200 (Thu, 10 Apr 2008) | 2 lines
Fixed compile warning.
........
r4076 | b_lindeijer | 2008-04-12 20:36:15 +0200 (Sat, 12 Apr 2008) | 3 lines
Fixed display of item shortcut container. gcn::Widget::setWidth is no longer
virtual.
........
r4079 | crush_tmw | 2008-04-14 09:50:25 +0200 (Mon, 14 Apr 2008) | 1 line
Fixed multi-channel image dyeing (patch by fate)
........
r4096 | b_lindeijer | 2008-04-16 10:39:59 +0200 (Wed, 16 Apr 2008) | 3 lines
Restored the text wrapping in TextBox, since it was based on overriding a
method that is no longer virtual in Guichan 0.8.0 (gcn::TextBox::setText()).
........
r4097 | peaveydk | 2008-04-16 13:27:31 +0200 (Wed, 16 Apr 2008) | 1 line
Fix a basic_string::at sometimes being out of range in BrowserBox::draw when checking for line separators.
........
r4099 | peaveydk | 2008-04-16 13:50:12 +0200 (Wed, 16 Apr 2008) | 1 line
Also fix potential out of range in BrowserBox::draw when checking for color codes.
........
r4150 | b_lindeijer | 2008-04-20 21:24:33 +0200 (Sun, 20 Apr 2008) | 2 lines
Forgot to remove the sound effects apparently, removed now.
........
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 8 | ||||
-rw-r--r-- | src/game.cpp | 4 | ||||
-rw-r--r-- | src/gui/browserbox.cpp | 2 | ||||
-rw-r--r-- | src/gui/itemshortcutcontainer.cpp | 6 | ||||
-rw-r--r-- | src/gui/itemshortcutcontainer.h | 12 | ||||
-rw-r--r-- | src/gui/itemshortcutwindow.cpp | 18 | ||||
-rw-r--r-- | src/gui/itemshortcutwindow.h | 12 | ||||
-rw-r--r-- | src/gui/npc_text.cpp | 8 | ||||
-rw-r--r-- | src/gui/npc_text.h | 7 | ||||
-rw-r--r-- | src/gui/scrollarea.cpp | 32 | ||||
-rw-r--r-- | src/gui/scrollarea.h | 13 | ||||
-rw-r--r-- | src/gui/textbox.cpp | 9 | ||||
-rw-r--r-- | src/gui/textbox.h | 7 | ||||
-rw-r--r-- | src/resources/dye.cpp | 7 |
14 files changed, 48 insertions, 97 deletions
diff --git a/src/being.cpp b/src/being.cpp index 5a877d85..b984708e 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -584,10 +584,12 @@ Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY) if (!mEmotion) return; - int px = mPx + offsetX + 3; - int py = mPy + offsetY - 60; + const int px = mPx + offsetX + 3; + const int py = mPy + offsetY - 60; + const int emotionIndex = mEmotion - 1; - graphics->drawImage(emotionSet->get(mEmotion - 1), px, py); + if (emotionIndex >= 0 && emotionIndex < (int) emotionSet->size()) + graphics->drawImage(emotionSet->get(emotionIndex), px, py); } void diff --git a/src/game.cpp b/src/game.cpp index d762bde2..8860d4c4 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -145,6 +145,7 @@ namespace { if (event.getId() == "yes" || event.getId() == "ok") { done = true; } + disconnectedDialog = NULL; } } exitListener; } @@ -445,9 +446,8 @@ void Game::logic() OkDialog("Network Error", "The connection to the server was lost, the program will now quit"); disconnectedDialog->addActionListener(&exitListener); + disconnectedDialog->requestMoveToTop(); } - - disconnectedDialog->requestMoveToTop(); } } } diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 61bc571b..53a2ac0f 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -311,7 +311,7 @@ BrowserBox::draw(gcn::Graphics *graphics) (!mUseLinksAndUserColors && (start == 0))) { // Check for color change in format "##x", x = [L,P,0..9] - if (row.find("##", start) == start) + if (row.find("##", start) == start && row.size() > start + 2) { switch (row.at(start + 2)) { diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index d86a99ef..e8cc5711 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -40,6 +40,7 @@ ItemShortcutContainer::ItemShortcutContainer(): mItemMoved(NULL) { addMouseListener(this); + addWidgetListener(this); ResourceManager *resman = ResourceManager::getInstance(); @@ -119,11 +120,8 @@ ItemShortcutContainer::draw(gcn::Graphics *graphics) } } -void -ItemShortcutContainer::setWidth(int width) +void ItemShortcutContainer::widgetResized(const gcn::Event &event) { - gcn::Widget::setWidth(width); - mGridWidth = getWidth() / mBoxWidth; if (mGridWidth < 1) { mGridWidth = 1; diff --git a/src/gui/itemshortcutcontainer.h b/src/gui/itemshortcutcontainer.h index c69525e0..58f0aea7 100644 --- a/src/gui/itemshortcutcontainer.h +++ b/src/gui/itemshortcutcontainer.h @@ -26,6 +26,7 @@ #include <guichan/mouselistener.hpp> #include <guichan/widget.hpp> +#include <guichan/widgetlistener.hpp> class Image; class Item; @@ -35,7 +36,9 @@ class Item; * * \ingroup GUI */ -class ItemShortcutContainer : public gcn::Widget, public gcn::MouseListener +class ItemShortcutContainer : public gcn::Widget, + public gcn::WidgetListener, + public gcn::MouseListener { public: /** @@ -59,10 +62,10 @@ class ItemShortcutContainer : public gcn::Widget, public gcn::MouseListener void draw(gcn::Graphics *graphics); /** - * Sets the width of the container. This is used to determine the new - * height of the container. + * Invoked when a widget changes its size. This is used to determine + * the new height of the container. */ - void setWidth(int width); + void widgetResized(const gcn::Event &event); /** * Handles mouse when dragged. @@ -79,7 +82,6 @@ class ItemShortcutContainer : public gcn::Widget, public gcn::MouseListener */ void mouseReleased(gcn::MouseEvent &event); - int getMaxItems() { return mMaxItems; } diff --git a/src/gui/itemshortcutwindow.cpp b/src/gui/itemshortcutwindow.cpp index c7b2bd05..fb75e20d 100644 --- a/src/gui/itemshortcutwindow.cpp +++ b/src/gui/itemshortcutwindow.cpp @@ -44,11 +44,12 @@ ItemShortcutWindow::ItemShortcutWindow() setMaxWidth(mItems->getBoxWidth() * mItems->getMaxItems() + border); setMaxHeight(mItems->getBoxHeight() * mItems->getMaxItems() + border); - mInvenScroll = new ScrollArea(mItems); - mInvenScroll->setPosition(SCROLL_PADDING, SCROLL_PADDING); - mInvenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); + mScrollArea = new ScrollArea(mItems); + mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING); + mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); + mScrollArea->setOpaque(false); - add(mInvenScroll); + add(mScrollArea); loadWindowState("ItemShortcut"); } @@ -56,12 +57,7 @@ ItemShortcutWindow::ItemShortcutWindow() ItemShortcutWindow::~ItemShortcutWindow() { delete mItems; - delete mInvenScroll; -} - -void ItemShortcutWindow::logic() -{ - Window::logic(); + delete mScrollArea; } void ItemShortcutWindow::widgetResized(const gcn::Event &event) @@ -70,7 +66,7 @@ void ItemShortcutWindow::widgetResized(const gcn::Event &event) const gcn::Rectangle &area = getChildrenArea(); - mInvenScroll->setSize( + mScrollArea->setSize( area.width - SCROLL_PADDING, area.height - SCROLL_PADDING); } diff --git a/src/gui/itemshortcutwindow.h b/src/gui/itemshortcutwindow.h index 51685e49..9742abdc 100644 --- a/src/gui/itemshortcutwindow.h +++ b/src/gui/itemshortcutwindow.h @@ -26,12 +26,11 @@ #include "window.h" -#include "../guichanfwd.h" - class ItemShortcutContainer; +class ScrollArea; /** - * Inventory dialog. + * A window around the ItemShortcutContainer. * * \ingroup Interface */ @@ -49,11 +48,6 @@ class ItemShortcutWindow : public Window ~ItemShortcutWindow(); /** - * Logic (updates buttons and weight information). - */ - void logic(); - - /** * Called whenever the widget changes size. */ void widgetResized(const gcn::Event &event); @@ -61,7 +55,7 @@ class ItemShortcutWindow : public Window private: ItemShortcutContainer *mItems; - gcn::ScrollArea *mInvenScroll; + ScrollArea *mScrollArea; }; extern ItemShortcutWindow *itemShortcutWindow; diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 023307a7..fd02a14a 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -36,7 +36,7 @@ NpcTextDialog::NpcTextDialog(): Window(_("NPC")) { - mTextBox = new TextBox(); + mTextBox = new TextBox; mTextBox->setEditable(false); gcn::ScrollArea *scrollArea = new ScrollArea(mTextBox); Button *okButton = new Button(_("Ok"), "ok", this); @@ -57,15 +57,15 @@ NpcTextDialog::NpcTextDialog(): } void -NpcTextDialog::setText(const char *text) +NpcTextDialog::setText(const std::string &text) { - mTextBox->setText(text); + mTextBox->setTextWrapped(text); } void NpcTextDialog::addText(const std::string &text) { - mTextBox->setText(mTextBox->getText() + text + "\n"); + mTextBox->setTextWrapped(mTextBox->getText() + text + "\n"); } void diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 869661c4..0ef1b938 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -28,7 +28,8 @@ #include <guichan/actionlistener.hpp> #include "window.h" -#include "../guichanfwd.h" + +class TextBox; /** * The npc text dialog. @@ -57,7 +58,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener * @param string The new text. */ void - setText(const char *string); + setText(const std::string &string); /** * Adds the text to the text shows in the dialog. Also adds a newline @@ -69,7 +70,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener addText(const std::string &string); private: - gcn::TextBox *mTextBox; + TextBox *mTextBox; }; #endif diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index 9c88f8e3..255aa2d8 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -165,14 +165,6 @@ void ScrollArea::logic() void ScrollArea::draw(gcn::Graphics *graphics) { - checkPolicies(); - - int alpha = getBaseColor().a; - gcn::Color highlightColor = getBaseColor() + 0x303030; - highlightColor.a = alpha; - gcn::Color shadowColor = getBaseColor() - 0x303030; - shadowColor.a = alpha; - if (mVBarVisible) { drawUpButton(graphics); @@ -198,29 +190,7 @@ void ScrollArea::draw(gcn::Graphics *graphics) mScrollbarWidth)); } - gcn::Widget *content = getContent(); - - if (content != NULL) - { - graphics->pushClipArea(getChildrenArea()); - - if (content->getFrameSize() > 0) - { - gcn::Rectangle rec = content->getDimension(); - rec.x -= content->getFrameSize(); - rec.y -= content->getFrameSize(); - rec.width += 2 * content->getFrameSize(); - rec.height += 2 * content->getFrameSize(); - graphics->pushClipArea(rec); - content->drawFrame(graphics); - graphics->popClipArea(); - } - - graphics->pushClipArea(content->getDimension()); - content->draw(graphics); - graphics->popClipArea(); - graphics->popClipArea(); - } + drawChildren(graphics); } void ScrollArea::drawFrame(gcn::Graphics *graphics) diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h index 9fb7093d..be361f68 100644 --- a/src/gui/scrollarea.h +++ b/src/gui/scrollarea.h @@ -34,17 +34,18 @@ class ImageRect; * * \ingroup GUI */ -class ScrollArea : public gcn::ScrollArea { +class ScrollArea : public gcn::ScrollArea +{ public: /** * Constructor. */ - ScrollArea(bool gc=true); + ScrollArea(bool gc = true); /** * Constructor. */ - ScrollArea(gcn::Widget *content, bool gc=true); + ScrollArea(gcn::Widget *content, bool gc = true); /** * Destructor. @@ -70,14 +71,12 @@ class ScrollArea : public gcn::ScrollArea { /** * Sets whether the widget should draw its background or not. */ - void - setOpaque(bool opaque); + void setOpaque(bool opaque); /** * Returns whether the widget draws its background or not. */ - bool - isOpaque() { return mOpaque; } + bool isOpaque() const { return mOpaque; } protected: enum BUTTON_DIR { diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index 84c8ad4b..8d16dc46 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -35,14 +35,7 @@ TextBox::TextBox(): setFrameSize(0); } -TextBox::TextBox(const std::string& text): - gcn::TextBox(text) -{ - setOpaque(false); - setFrameSize(0); -} - -void TextBox::setText(const std::string &text) +void TextBox::setTextWrapped(const std::string &text) { // Make sure parent scroll area sets width of this widget if (getParent()) diff --git a/src/gui/textbox.h b/src/gui/textbox.h index 54523281..f06f98ec 100644 --- a/src/gui/textbox.h +++ b/src/gui/textbox.h @@ -41,14 +41,9 @@ class TextBox : public gcn::TextBox { TextBox(); /** - * Constructor. - */ - TextBox(const std::string& text); - - /** * Sets the text after wrapping it to the current width of the widget. */ - void setText(const std::string &text); + void setTextWrapped(const std::string &text); }; #endif diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index c27f32c1..a43b1204 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -191,18 +191,19 @@ void Dye::instantiate(std::string &target, std::string const &palettes) std::string::size_type pos = next_pos; next_pos = target.find(';', pos); if (next_pos == std::string::npos) next_pos = last_pos; - if (next_pos == pos + 1) + if (next_pos == pos + 1 && pal_pos != std::string::npos) { - std::string::size_type pal_next_pos = palettes.find(';'); + std::string::size_type pal_next_pos = palettes.find(';', pal_pos); s << target[pos] << ':'; if (pal_next_pos == std::string::npos) { s << palettes.substr(pal_pos); s << target.substr(next_pos); + pal_pos = std::string::npos; break; } s << palettes.substr(pal_pos, pal_next_pos - pal_pos); - pal_pos = pal_next_pos; + pal_pos = pal_next_pos + 1; } else if (next_pos > pos + 2) { |