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 | |
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')
-rw-r--r-- | src/game.cpp | 24 | ||||
-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 | ||||
-rw-r--r-- | src/keyboardconfig.cpp | 1 | ||||
-rw-r--r-- | src/keyboardconfig.h | 1 | ||||
-rw-r--r-- | src/localplayer.cpp | 19 | ||||
-rw-r--r-- | src/localplayer.h | 6 | ||||
-rw-r--r-- | src/net/ea/beinghandler.cpp | 16 | ||||
-rw-r--r-- | src/net/ea/partyhandler.cpp | 3 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 1 | ||||
-rw-r--r-- | src/player.cpp | 60 | ||||
-rw-r--r-- | src/player.h | 2 |
21 files changed, 170 insertions, 96 deletions
diff --git a/src/game.cpp b/src/game.cpp index b56cbdde..59c57607 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -582,6 +582,13 @@ void Game::handleInput() if (chatWindow->requestChatFocus()) used = true; } + if (npcDialog->isVisible()) + { + if (keyboard.isKeyActive(keyboard.KEY_MOVE_UP)) + npcDialog->move(1); + else if (keyboard.isKeyActive(keyboard.KEY_MOVE_DOWN)) + npcDialog->move(-1); + } } @@ -923,6 +930,23 @@ void Game::handleInput() if (player_node->getTarget()) player_node->attack(player_node->getTarget(), true); } + + if (keyboard.isKeyActive(keyboard.KEY_TARGET_ATTACK)) + { + Being *target = NULL; + + bool newTarget = !keyboard.isKeyActive(keyboard.KEY_TARGET); + // A set target has highest priority + if (!player_node->getTarget()) + { + Uint16 targetX = x, targetY = y; + // Only auto target Monsters + target = beingManager->findNearestLivingBeing(targetX, targetY, + 20, Being::MONSTER); + } + player_node->attack(target, newTarget); + } + #endif // Target the nearest player/monster/npc 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); diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index ff05d75b..b5db3de5 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -43,6 +43,7 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = { {"keyMoveLeft", SDLK_LEFT, _("Move Left")}, {"keyMoveRight", SDLK_RIGHT, _("Move Right")}, {"keyAttack", SDLK_LCTRL, _("Attack")}, + {"keyTargetAttack", SDLK_x, _("Target & Attack")}, {"keySmilie", SDLK_LALT, _("Smilie")}, {"keyTalk", SDLK_t, _("Talk")}, {"keyTarget", SDLK_LSHIFT, _("Stop Attack")}, diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h index d461c827..68a5efa6 100644 --- a/src/keyboardconfig.h +++ b/src/keyboardconfig.h @@ -154,6 +154,7 @@ class KeyboardConfig KEY_MOVE_LEFT, KEY_MOVE_RIGHT, KEY_ATTACK, + KEY_TARGET_ATTACK, KEY_EMOTE, KEY_TALK, KEY_TARGET, diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 059ccd31..c1423190 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -236,14 +236,17 @@ void LocalPlayer::setAction(Action action, int attackType) Player::setAction(action, attackType); } -void LocalPlayer::setGM() -{ - mIsGM = !mIsGM; - mNameColor = mIsGM ? - &guiPalette->getColor(Palette::GM) : - &guiPalette->getColor(Palette::PLAYER); - setName(getName()); - config.setValue(getName() + "GMassert", mIsGM); +void LocalPlayer::setGM(bool gm) +{ + mIsGM = gm; +} + +void LocalPlayer::setGMLevel(int level) +{ + mGMLevel = level; + + if (level > 0) + setGM(true); } void LocalPlayer::setName(const std::string &name) diff --git a/src/localplayer.h b/src/localplayer.h index bab254ab..add5c049 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -223,7 +223,9 @@ class LocalPlayer : public Player /** * Triggers whether or not to show the name as a GM name. */ - virtual void setGM(); + virtual void setGM(bool gm); + + void setGMLevel(int level); void stopAttack(); @@ -458,6 +460,8 @@ class LocalPlayer : public Player int mHp; int mMaxHp; + int mGMLevel; + Being *mTarget; FloorItem *mPickUpTarget; diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 29ed733a..34a0d70a 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -35,6 +35,8 @@ #include "npc.h" #include "playerrelations.h" +#include "gui/partywindow.h" + #include <iostream> namespace EAthena { @@ -445,12 +447,15 @@ void BeingHandler::handleMessage(MessageIn &msg) dstBeing = createBeing(id, job); } - // Fix monster jobs - if (dstBeing->getType() == Being::MONSTER) { - job -= 1002; + PartyMember *member = partyWindow->findMember(id); + if (member && member->online) + { + dynamic_cast<Player*>(dstBeing)->setInParty(true); + } } + dstBeing->setWalkSpeed(speed); dstBeing->mJob = job; hairStyle = msg.readInt16(); @@ -503,8 +508,9 @@ void BeingHandler::handleMessage(MessageIn &msg) } gmstatus = msg.readInt16(); - if ((gmstatus & 0x80) && dstBeing->getType() == Being::PLAYER) - static_cast<Player*>(dstBeing)->setGM(); + if (gmstatus & 0x80) + if (Player *player = dynamic_cast<Player*>(dstBeing)) + player->setGM(true); if (msg.getId() == SMSG_PLAYER_UPDATE_1) { diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 2f1b02ab..5e7f43c4 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -156,6 +156,9 @@ void PartyHandler::handleMessage(MessageIn &msg) } case SMSG_PARTY_SETTINGS: { + if (!partyTab) + break; + // These seem to indicate the sharing mode for exp and items short exp = msg.readInt16(); short item = msg.readInt16(); diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 29f0bac4..b7131f0a 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -262,6 +262,7 @@ void PlayerHandler::handleMessage(MessageIn &msg) case 0x0032: player_node->FLEE = value; break; case 0x0035: player_node->mAttackSpeed = value; break; case 0x0037: player_node->mJobLevel = value; break; + case 500: player_node->setGMLevel(value); break; } if (player_node->getHp() == 0 && !deathNotice) diff --git a/src/player.cpp b/src/player.cpp index 453b8bdd..520342e3 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -58,44 +58,34 @@ void Player::setName(const std::string &name) { if (!mName && mShowName) { - if (mIsGM) + mNameColor = &guiPalette->getColor(Palette::PLAYER); + + const gcn::Color *color; + if (this == player_node) + { + color = &guiPalette->getColor(Palette::SELF); + } + else if (mIsGM) { mNameColor = &guiPalette->getColor(Palette::GM); - mName = new FlashText("(GM) " + name, - getPixelX(), - getPixelY(), - gcn::Graphics::CENTER, - &guiPalette->getColor(Palette::GM_NAME)); + color = &guiPalette->getColor(Palette::GM_NAME); + } + else if (mInParty) + { + color = &guiPalette->getColor(Palette::PARTY); } else { - mNameColor = &guiPalette->getColor(Palette::PLAYER); - - const gcn::Color *color; - if (this == player_node) - { - color = &guiPalette->getColor(Palette::SELF); - } - else if (mIsGM) - { - color = &guiPalette->getColor(Palette::GM); - } - else if (mInParty) - { - color = &guiPalette->getColor(Palette::PARTY); - } - else - { - color = &guiPalette->getColor(Palette::PC); - } - - mName = new FlashText(name, - getPixelX(), - getPixelY(), - gcn::Graphics::CENTER, - color); + color = &guiPalette->getColor(Palette::PC); } + + mName = new FlashText(name, + getPixelX(), + getPixelY(), + gcn::Graphics::CENTER, + color); } + Being::setName(name); } @@ -191,6 +181,14 @@ void Player::setGender(Gender gender) } } +void Player::setGM(bool gm) +{ + mIsGM = gm; + + if (gm && mName) + mName->setColor(&guiPalette->getColor(Palette::GM)); +} + void Player::setHairStyle(int style, int color) { style = style < 0 ? mHairStyle : style % mNumberOfHairstyles; diff --git a/src/player.h b/src/player.h index 330d0c14..bb44f462 100644 --- a/src/player.h +++ b/src/player.h @@ -67,7 +67,7 @@ class Player : public Being /** * Triggers whether or not to show the name as a GM name. */ - virtual void setGM() { mIsGM = true; } + virtual void setGM(bool gm); /** * Sets the hair style and color for this player. |