diff options
author | Blue <bluesansdouze@gmail.com> | 2009-05-13 20:35:44 +0200 |
---|---|---|
committer | Blue <bluesansdouze@gmail.com> | 2009-05-13 20:35:44 +0200 |
commit | 22685431a23b05d66af28abda488d0891b1c0a34 (patch) | |
tree | a207b9230833abbed3da751ca7e3c4ccdc8e9783 /src/gui | |
parent | 9071a692116745f2cafd8556cbff28095910730e (diff) | |
parent | b5ad7e490f0f429a5abac2acae48ecf25485256f (diff) | |
download | mana-22685431a23b05d66af28abda488d0891b1c0a34.tar.gz mana-22685431a23b05d66af28abda488d0891b1c0a34.tar.bz2 mana-22685431a23b05d66af28abda488d0891b1c0a34.tar.xz mana-22685431a23b05d66af28abda488d0891b1c0a34.zip |
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chat.cpp | 8 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 31 | ||||
-rw-r--r-- | src/gui/itemcontainer.h | 13 | ||||
-rw-r--r-- | src/gui/npcdialog.cpp | 19 | ||||
-rw-r--r-- | src/gui/npcdialog.h | 2 | ||||
-rw-r--r-- | src/gui/partywindow.cpp | 7 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 26 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/avatar.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/browserbox.cpp | 12 | ||||
-rw-r--r-- | src/gui/widgets/chattab.cpp | 7 |
11 files changed, 83 insertions, 50 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index eca224fc..414d1e02 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -105,14 +105,6 @@ ChatWindow::ChatWindow(): mReturnToggles = config.getValue("ReturnToggles", "0") == "1"; -#ifdef EATHENA_SUPPORT - // If the player had @assert on in the last session, ask the server to - // run the @assert command for the player again. Convenience for GMs. - if (config.getValue(player_node->getName() + "GMassert", 0)) { - std::string cmd = "@assert"; - chatInput(cmd); - } -#endif mRecorder = new Recorder(this); } diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 6cbdabb2..54aa818b 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -57,6 +57,7 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): mGridRows(1), mSelectedIndex(-1), mHighlightedIndex(-1), + mLastUsedSlot(-1), mSelectionStatus(SEL_NONE), mForceQuantity(forceQuantity), mSwapItems(false), @@ -82,6 +83,19 @@ ItemContainer::~ItemContainer() delete mItemPopup; } +void ItemContainer::logic() +{ + gcn::Widget::logic(); + + const int lastUsedSlot = mInventory->getLastUsedSlot(); + + if (lastUsedSlot != mLastUsedSlot) + { + mLastUsedSlot = lastUsedSlot; + adjustHeight(); + } +} + void ItemContainer::draw(gcn::Graphics *graphics) { Graphics *g = static_cast<Graphics*>(graphics); @@ -178,7 +192,7 @@ void ItemContainer::distributeValueChangedEvent() void ItemContainer::keyPressed(gcn::KeyEvent &event) { - switch (event.getKey().getValue()) + /*switch (event.getKey().getValue()) { case Key::LEFT: moveHighlight(Left); @@ -202,12 +216,12 @@ void ItemContainer::keyPressed(gcn::KeyEvent &event) case Key::RIGHT_CONTROL: mDescItems = true; break; - } + }*/ } void ItemContainer::keyReleased(gcn::KeyEvent &event) { - switch (event.getKey().getValue()) + /*switch (event.getKey().getValue()) { case Key::LEFT_ALT: case Key::RIGHT_ALT: @@ -216,7 +230,7 @@ void ItemContainer::keyReleased(gcn::KeyEvent &event) case Key::RIGHT_CONTROL: mDescItems = false; break; - } + }*/ } void ItemContainer::mousePressed(gcn::MouseEvent &event) @@ -316,8 +330,13 @@ void ItemContainer::mouseExited(gcn::MouseEvent &event) void ItemContainer::widgetResized(const gcn::Event &event) { mGridColumns = std::max(1, getWidth() / BOX_WIDTH); - mGridRows = mInventory->getSize() / mGridColumns; - if (mGridRows == 0 || mInventory->getSize() % mGridColumns > 0) + adjustHeight(); +} + +void ItemContainer::adjustHeight() +{ + mGridRows = (mLastUsedSlot + 1) / mGridColumns; + if (mGridRows == 0 || (mLastUsedSlot + 1) % mGridColumns > 0) ++mGridRows; setHeight(mGridRows * BOX_HEIGHT); diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index f446a647..2cfd06b2 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -65,6 +65,11 @@ class ItemContainer : public gcn::Widget, virtual ~ItemContainer(); /** + * Necessary for checking how full the inventory is. + */ + void logic(); + + /** * Draws the items. */ void draw(gcn::Graphics *graphics); @@ -147,14 +152,9 @@ class ItemContainer : public gcn::Widget, void setSelectedIndex(int index); /** - * Find the current item index by the most recently used item ID - */ - void refindSelectedItem(); - - /** * Determine and set the height of the container. */ - void recalculateHeight(); + void adjustHeight(); /** * Sends out selection events to the list of selection listeners. @@ -174,6 +174,7 @@ class ItemContainer : public gcn::Widget, int mGridColumns, mGridRows; Image *mSelImg; int mSelectedIndex, mHighlightedIndex; + int mLastUsedSlot; SelectionState mSelectionStatus; bool mForceQuantity; bool mSwapItems; diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index eeb76b88..c4b1ec88 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -281,6 +281,25 @@ void NpcDialog::integerRequest(int defaultValue, int min, int max) buildLayout(); } +void NpcDialog::move(int amount) +{ + if (mActionState != NPC_ACTION_INPUT) + return; + + switch (mInputState) + { + case NPC_INPUT_INTEGER: + mIntField->setValue(mIntField->getValue() + amount); + break; + case NPC_INPUT_LIST: + mItemList->setSelected(mItemList->getSelected() - amount); + break; + case NPC_INPUT_NONE: + case NPC_INPUT_STRING: + break; + } +} + void NpcDialog::widgetResized(const gcn::Event &event) { Window::widgetResized(event); diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index bd738e81..ecce0c62 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -141,6 +141,8 @@ class NpcDialog : public Window, public gcn::ActionListener, */ void integerRequest(int defaultValue = 0, int min = 0, int max = 2000); + void move(int amount); + /** * Called when resizing the window. * diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 317811ee..996073bd 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -53,9 +53,9 @@ PartyWindow::PartyWindow() : setResizable(true); setSaveVisible(true); setCloseButton(true); - setMinWidth(212); + setMinWidth(120); setMinHeight(200); - setDefaultSize(590, 200, 212, 200); + setDefaultSize(590, 200, 150, 200); loadWindowState(); } @@ -125,7 +125,8 @@ void PartyWindow::updateMember(int id, const std::string &memberName, member->avatar->setName(memberName); member->avatar->setOnline(online); - if (Player *player = dynamic_cast<Player*>(beingManager->findBeing(id))) + Player *player = dynamic_cast<Player*>(beingManager->findBeing(id)); + if (player && online) player->setInParty(true); } diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 2dcf2628..e12ca822 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -112,12 +112,17 @@ void PopupMenu::showPopup(int x, int y, Being *being) //mBrowserBox->addRow(_(strprintf("@@follow|Follow %s@@"), name.c_str())); //mBrowserBox->addRow(_("@@buddy|Add ") + name + " to Buddy List@@"); +#ifdef TMWSERV_SUPPORT mBrowserBox->addRow(strprintf(_("@@guild|Invite %s to join your guild@@"), name.c_str())); - mBrowserBox->addRow(strprintf(_("@@party|Invite %s to join your party@@"), name.c_str())); +#endif + if (player_node->isInParty()) + mBrowserBox->addRow(strprintf(_("@@party|Invite %s to join your party@@"), name.c_str())); - /* - mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(_("@@admin-kick|Kick player@@"));*/ + if (player_node->isGM()) + { + mBrowserBox->addRow("##3---"); + mBrowserBox->addRow(_("@@admin-kick|Kick player@@")); + } } break; @@ -128,13 +133,14 @@ void PopupMenu::showPopup(int x, int y, Being *being) break; case Being::MONSTER: - // Monsters can be attacked - mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); - break; + { + // Monsters can be attacked + mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); - /*case Being::MONSTER: - mBrowserBox->addRow(_("@@admin-kick|Kick monster@@")); - break;*/ + if (player_node->isGM()) + mBrowserBox->addRow(_("@@admin-kick|Kick monster@@")); + } + break; default: /* Other beings aren't interesting... */ diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 9add3251..1c4043f7 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -479,8 +479,7 @@ void Setup_Video::action(const gcn::ActionEvent &event) } else if (event.getId() == "speech") { - Being::Speech val = - static_cast<Being::Speech>(mSpeechSlider->getValue()); + Being::Speech val = (Being::Speech)mSpeechSlider->getValue(); mSpeechLabel->setCaption(speechModeToString(val)); mSpeechSlider->setValue(val); config.setValue("speech", val); diff --git a/src/gui/widgets/avatar.cpp b/src/gui/widgets/avatar.cpp index b120c51f..0bbdc468 100644 --- a/src/gui/widgets/avatar.cpp +++ b/src/gui/widgets/avatar.cpp @@ -42,7 +42,7 @@ Avatar::Avatar(): mMaxHp(0) { setOpaque(false); - setSize(200, 12); + setSize(250, 12); if (avatarCount == 0) { @@ -58,7 +58,7 @@ Avatar::Avatar(): mStatus->setSize(12, 12); add(mStatus, 1, 0); mLabel = new Label; - mLabel->setSize(174, 12); + mLabel->adjustSize(); add(mLabel, 16, 0); } @@ -108,4 +108,5 @@ void Avatar::updateAvatarLabel() ss << " (" << mHp << "/" << mMaxHp << ")"; mLabel->setCaption(ss.str()); + mLabel->adjustSize(); } diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 52b9bfa6..a03d53eb 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -23,9 +23,9 @@ #include "gui/linkhandler.h" #include "gui/palette.h" -#include "gui/truetypefont.h" #include <guichan/graphics.hpp> +#include <guichan/font.hpp> #include <algorithm> @@ -71,7 +71,7 @@ void BrowserBox::addRow(const std::string &row) std::string newRow; BROWSER_LINK bLink; std::string::size_type idx1, idx2, idx3; - TrueTypeFont *font = static_cast<TrueTypeFont*>(getFont()); + gcn::Font *font = getFont(); // Use links and user defined colors if (mUseLinksAndUserColors) @@ -116,7 +116,6 @@ void BrowserBox::addRow(const std::string &row) newRow += tmp; } - // Don't use links and user defined colors else { @@ -281,7 +280,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) int x = 0, y = 0; int wrappedLines = 0; int link = 0; - TrueTypeFont *font = static_cast<TrueTypeFont*>(getFont()); + gcn::Font *font = getFont(); graphics->setColor(guiPalette->getColor(Palette::TEXT)); for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); i++) @@ -296,10 +295,11 @@ void BrowserBox::draw(gcn::Graphics *graphics) // Check for separator lines if (row.find("---", 0) == 0) { + const int dashWidth = font->getWidth("-"); for (x = 0; x < getWidth(); x++) { font->drawString(graphics, "-", x, y); - x += font->getWidth("-") - 2; + x += dashWidth - 2; } y += font->getHeight(); continue; @@ -389,7 +389,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) { bool forced = false; char const *hyphen = "~"; - int hyphenWidth = font->getWidth(hyphen); + int hyphenWidth = font->getWidth(hyphen); /* FIXME: This code layout makes it easy to crash remote clients by talking garbage. Forged long utf-8 characters diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index d55e5da8..711680d1 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -162,13 +162,6 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) lineColor = "##S"; } -#ifdef EATHENA_SUPPORT - if (tmp.nick.empty() && tmp.text.substr(0, 17) == "Visible GM status") - { - player_node->setGM(); - } -#endif - // Get the current system time time_t t; time(&t); |