diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-02-26 21:29:49 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-02-26 21:29:49 +0100 |
commit | 3008805eea4b972265597ba196ab05ce64c69965 (patch) | |
tree | d3195600e956e496b6b21f200fc04e5b08cab368 /src/gui | |
parent | 3ad6ac47d4967870a54fddd66aa9996724115b94 (diff) | |
parent | 6b0cff837b7adae56dc90d12e9c0e256e6aab134 (diff) | |
download | mana-3008805eea4b972265597ba196ab05ce64c69965.tar.gz mana-3008805eea4b972265597ba196ab05ce64c69965.tar.bz2 mana-3008805eea4b972265597ba196ab05ce64c69965.tar.xz mana-3008805eea4b972265597ba196ab05ce64c69965.zip |
Merge branch 'aethyra/master'
Conflicts:
data/graphics/images/login_wallpaper.png
src/being.cpp
src/beingmanager.cpp
src/engine.cpp
src/game.cpp
src/gui/buysell.cpp
src/gui/buysell.h
src/gui/gui.h
src/gui/npc_text.cpp
src/gui/npc_text.h
src/gui/npcintegerdialog.cpp
src/gui/npclistdialog.cpp
src/gui/npclistdialog.h
src/gui/npcstringdialog.cpp
src/gui/sell.cpp
src/gui/shop.cpp
src/gui/table.cpp
src/net/beinghandler.cpp
src/net/npchandler.cpp
src/net/playerhandler.cpp
src/npc.cpp
src/npc.h
src/shopitem.cpp
src/shopitem.h
src/utils/stringutils.cpp
src/utils/stringutils.h
src/utils/trim.h
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/buy.cpp | 2 | ||||
-rw-r--r-- | src/gui/buy.h | 2 | ||||
-rw-r--r-- | src/gui/buysell.cpp | 16 | ||||
-rw-r--r-- | src/gui/gui.cpp | 22 | ||||
-rw-r--r-- | src/gui/gui.h | 9 | ||||
-rw-r--r-- | src/gui/listbox.cpp | 88 | ||||
-rw-r--r-- | src/gui/listbox.h | 19 | ||||
-rw-r--r-- | src/gui/npc_text.cpp | 11 | ||||
-rw-r--r-- | src/gui/npc_text.h | 2 | ||||
-rw-r--r-- | src/gui/npcintegerdialog.cpp | 13 | ||||
-rw-r--r-- | src/gui/npcintegerdialog.h | 7 | ||||
-rw-r--r-- | src/gui/npclistdialog.cpp | 14 | ||||
-rw-r--r-- | src/gui/npclistdialog.h | 7 | ||||
-rw-r--r-- | src/gui/npcstringdialog.cpp | 4 | ||||
-rw-r--r-- | src/gui/npcstringdialog.h | 4 | ||||
-rw-r--r-- | src/gui/sell.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 8 | ||||
-rw-r--r-- | src/gui/shop.cpp | 3 | ||||
-rw-r--r-- | src/gui/shoplistbox.cpp | 9 | ||||
-rw-r--r-- | src/gui/shoplistbox.h | 2 | ||||
-rw-r--r-- | src/gui/table.cpp | 6 | ||||
-rw-r--r-- | src/gui/textbox.cpp | 32 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 29 |
23 files changed, 215 insertions, 96 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index cad21ab5..768dab4d 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -119,7 +119,7 @@ void BuyDialog::reset() setMoney(0); } -void BuyDialog::addItem(short id, int price) +void BuyDialog::addItem(int id, int price) { mShopItems->addItem(id, price); mShopItemList->adjustSize(); diff --git a/src/gui/buy.h b/src/gui/buy.h index 55a1898c..2555e139 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -68,7 +68,7 @@ class BuyDialog : public Window, public gcn::ActionListener, /** * Adds an item to the shop inventory. */ - void addItem(short id, int price); + void addItem(int id, int price); /** * Called when receiving actions from the widgets. diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index c1c934d1..818413c2 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -64,12 +64,20 @@ void BuySellDialog::logic() void BuySellDialog::action(const gcn::ActionEvent &event) { setVisible(false); - int action; - if (event.getId() == "Buy") { + int action = 0; + + NPC::isTalking = false; + + if (event.getId() == "Buy") + { action = 0; - } else if (event.getId() == "Sell") { + } + else if (event.getId() == "Sell") + { action = 1; - } else if (event.getId() == "Cancel") { + } + else if (event.getId() == "Cancel") + { current_npc = 0; return; } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 26192e26..6d6ccbdf 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -135,22 +135,6 @@ Gui::Gui(Graphics *graphics): gcn::Widget::setGlobalFont(mGuiFont); - // Load hits' colorful fonts - try - { - hitRedFont = new gcn::ImageFont("graphics/gui/hits_red.png", - "0123456789crit! "); - hitBlueFont = new gcn::ImageFont("graphics/gui/hits_blue.png", - "0123456789crit! "); - hitYellowFont = new gcn::ImageFont("graphics/gui/hits_yellow.png", - "0123456789misxp "); - } - catch (gcn::Exception e) - { - logger->error(std::string("Unable to load colored hits' fonts: ") - + e.getMessage()); - } - // Initialize mouse cursor and listen for changes to the option setUseCustomCursor(config.getValue("customcursor", 1) == 1); mConfigListener = new GuiConfigListener(this); @@ -168,16 +152,12 @@ Gui::~Gui() config.removeListener("customcursor", mConfigListener); delete mConfigListener; - // Fonts used in showing hits - delete hitRedFont; - delete hitBlueFont; - delete hitYellowFont; - if (mMouseCursors) mMouseCursors->decRef(); delete mGuiFont; delete boldFont; + delete mInfoParticleFont; delete viewport; delete getTop(); diff --git a/src/gui/gui.h b/src/gui/gui.h index 41df3dda..340eec09 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -114,7 +114,7 @@ class Gui : public gcn::Gui private: GuiConfigListener *mConfigListener; gcn::Font *mGuiFont; /**< The global GUI font */ - gcn::Font *mInfoParticleFont; /**< Font for Info Particles*/ + gcn::Font *mInfoParticleFont; /**< Font for Info Particles*/ bool mCustomCursor; /**< Show custom cursor */ ImageSet *mMouseCursors; /**< Mouse cursor images */ float mMouseCursorAlpha; @@ -126,13 +126,6 @@ extern Gui *gui; /**< The GUI system */ extern SDLInput *guiInput; /**< GUI input */ /** - * Fonts used in showing hits - */ -extern gcn::Font *hitRedFont; -extern gcn::Font *hitBlueFont; -extern gcn::Font *hitYellowFont; - -/** * Bolded text font */ extern gcn::Font *boldFont; diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index 74d0b9ad..64c8be85 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -21,6 +21,7 @@ #include <guichan/font.hpp> #include <guichan/graphics.hpp> +#include <guichan/key.hpp> #include <guichan/listmodel.hpp> #include "color.h" @@ -54,7 +55,7 @@ void ListBox::draw(gcn::Graphics *graphics) const int fontHeight = getFont()->getHeight(); - // Draw rectangle below the selected list element + // Draw filled rectangle around the selected list element if (mSelected >= 0) graphics->fillRectangle(gcn::Rectangle(0, fontHeight * mSelected, getWidth(), fontHeight)); @@ -68,6 +69,91 @@ void ListBox::draw(gcn::Graphics *graphics) } } +void ListBox::setSelected(int selected) +{ + if (!mListModel) + { + mSelected = -1; + } + else + { + if (selected < 0 && !mWrappingEnabled) + { + mSelected = -1; + } + else if (selected >= mListModel->getNumberOfElements() && + mWrappingEnabled) + { + mSelected = 0; + } + else if ((selected >= mListModel->getNumberOfElements() && + !mWrappingEnabled) || (selected < 0 && mWrappingEnabled)) + { + mSelected = mListModel->getNumberOfElements() - 1; + } + else + { + mSelected = selected; + } + } + gcn::ListBox::setSelected(mSelected); +} + +// -- KeyListener notifications +void ListBox::keyPressed(gcn::KeyEvent& keyEvent) +{ + gcn::Key key = keyEvent.getKey(); + + if (key.getValue() == gcn::Key::ENTER || key.getValue() == gcn::Key::SPACE) + { + distributeActionEvent(); + keyEvent.consume(); + } + else if (key.getValue() == gcn::Key::UP) + { + setSelected(mSelected - 1); + keyEvent.consume(); + } + else if (key.getValue() == gcn::Key::DOWN) + { + setSelected(mSelected + 1); + keyEvent.consume(); + } + else if (key.getValue() == gcn::Key::HOME) + { + setSelected(0); + keyEvent.consume(); + } + else if (key.getValue() == gcn::Key::END) + { + setSelected(getListModel()->getNumberOfElements() - 1); + keyEvent.consume(); + } +} + +void ListBox::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) +{ + if (isFocused()) + { + if (getSelected() > 0 || (getSelected() == 0 && mWrappingEnabled)) + { + setSelected(getSelected() - 1); + } + + mouseEvent.consume(); + } +} + +void ListBox::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) +{ + if (isFocused()) + { + setSelected(getSelected() + 1); + + mouseEvent.consume(); + } +} + void ListBox::mouseDragged(gcn::MouseEvent &event) { // Pretend mouse is pressed continuously while dragged. Causes list diff --git a/src/gui/listbox.h b/src/gui/listbox.h index 12fcb955..cfb58f15 100644 --- a/src/gui/listbox.h +++ b/src/gui/listbox.h @@ -46,8 +46,27 @@ class ListBox : public gcn::ListBox */ void draw(gcn::Graphics *graphics); + // Inherited from KeyListener + + void keyPressed(gcn::KeyEvent& keyEvent); + + // Inherited from MouseListener + + void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent); + + void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent); + void mouseDragged(gcn::MouseEvent &event); + /** + * Sets the selected item. The selected item is represented by + * an index from the list model. + * + * @param selected the selected item as an index from the list model. + * @see getSelected + */ + void setSelected(int selected); + private: static float mAlpha; }; diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 520efad4..954f22d8 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -64,6 +64,12 @@ NpcTextDialog::NpcTextDialog(Network *network): setLocationRelativeTo(getParent()); } +void NpcTextDialog::clearText() +{ + NPC::isTalking = false; + setText(""); +} + void NpcTextDialog::setText(const std::string &text) { mText = text; @@ -76,11 +82,6 @@ void NpcTextDialog::addText(const std::string &text) mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll()); } -void NpcTextDialog::clearText() -{ - setText(""); -} - void NpcTextDialog::showNextButton() { mButton->setCaption(_("Next")); diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 62486fff..019c22a5 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -102,4 +102,6 @@ class NpcTextDialog : public Window, public gcn::ActionListener NPCTextState mState; }; +extern NpcTextDialog *npcTextDialog; + #endif // NPC_TEXT_H diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp index f6d788df..9dc3660b 100644 --- a/src/gui/npcintegerdialog.cpp +++ b/src/gui/npcintegerdialog.cpp @@ -76,18 +76,23 @@ int NpcIntegerDialog::getValue() return mValueField->getValue(); } +void NpcIntegerDialog::reset() +{ + mValueField->reset(); +} + void NpcIntegerDialog::action(const gcn::ActionEvent &event) { - int finish = 0; + bool finish = false; if (event.getId() == "ok") { - finish = 1; + finish = true; npcTextDialog->addText(strprintf("\n> %d\n", mValueField->getValue())); } else if (event.getId() == "cancel") { - finish = 1; + finish = true; mValueField->reset(); npcTextDialog->addText(_("\n> Cancel\n")); } @@ -107,12 +112,14 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event) if (finish) { setVisible(false); + NPC::isTalking = false; MessageOut outMsg(mNetwork); outMsg.writeInt16(CMSG_NPC_INT_RESPONSE); outMsg.writeInt32(current_npc); outMsg.writeInt32(mValueField->getValue()); + current_npc = 0; mValueField->reset(); } } diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h index 80a21848..58f6970b 100644 --- a/src/gui/npcintegerdialog.h +++ b/src/gui/npcintegerdialog.h @@ -55,6 +55,11 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener int getValue(); /** + * Resets the integer input field. + */ + void reset(); + + /** * Prepares the NPC dialog. * * @param min The minimum value to allow @@ -88,4 +93,6 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener IntTextField *mValueField; }; +extern NpcIntegerDialog *npcIntegerDialog; + #endif // GUI_NPCINTEGERDIALOG_H diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index fc7d2979..53d4f21f 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -51,7 +51,9 @@ NpcListDialog::NpcListDialog(Network *network): mItemList = new ListBox(this); mItemList->setWrappingEnabled(true); + gcn::ScrollArea *scrollArea = new ScrollArea(mItemList); + gcn::Button *okButton = new Button(_("OK"), "ok", this); gcn::Button *cancelButton = new Button(_("Cancel"), "cancel", this); @@ -90,6 +92,8 @@ void NpcListDialog::parseItems(const std::string &itemString) void NpcListDialog::reset() { + NPC::isTalking = false; + mItemList->setSelected(-1); mItems.clear(); } @@ -100,6 +104,7 @@ void NpcListDialog::action(const gcn::ActionEvent &event) { // Send the selected index back to the server int selectedIndex = mItemList->getSelected(); + if (selectedIndex > -1) { choice = selectedIndex + 1; @@ -118,10 +123,13 @@ void NpcListDialog::action(const gcn::ActionEvent &event) { setVisible(false); reset(); + MessageOut outMsg(mNetwork); outMsg.writeInt16(CMSG_NPC_LIST_CHOICE); outMsg.writeInt32(current_npc); outMsg.writeInt8(choice); + + current_npc = 0; } } @@ -131,3 +139,9 @@ void NpcListDialog::setVisible(bool visible) Window::setVisible(visible); } + +void NpcListDialog::requestFocus() +{ + mItemList->requestFocus(); + mItemList->setSelected(0); +} diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index a7b49506..b5a62515 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -76,6 +76,11 @@ class NpcListDialog : public Window, public gcn::ActionListener, void setVisible(bool visible); + /** + * Requests the listbox to take focus for input. + */ + void requestFocus(); + private: Network *mNetwork; gcn::ListBox *mItemList; @@ -83,4 +88,6 @@ class NpcListDialog : public Window, public gcn::ActionListener, std::vector<std::string> mItems; }; +extern NpcListDialog *npcListDialog; + #endif // GUI_NPCLISTDIALOG_H diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index 7ed05288..fb3b43db 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -77,6 +77,8 @@ void NpcStringDialog::action(const gcn::ActionEvent &event) } setVisible(false); + NPC::isTalking = false; + std::string text = mValueField->getText(); mValueField->setText(""); @@ -86,6 +88,8 @@ void NpcStringDialog::action(const gcn::ActionEvent &event) outMsg.writeInt32(current_npc); outMsg.writeString(text, text.length()); outMsg.writeInt8(0); + + current_npc = 0; } bool NpcStringDialog::isInputFocused() diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h index 43283219..0c552baa 100644 --- a/src/gui/npcstringdialog.h +++ b/src/gui/npcstringdialog.h @@ -28,6 +28,8 @@ class Network; +class Network; + /** * The npc integer input dialog. * @@ -78,4 +80,6 @@ class NpcStringDialog : public Window, public gcn::ActionListener std::string mDefault; }; +extern NpcStringDialog *npcStringDialog; + #endif // GUI_NPCSTRINGDIALOG_H diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 51fc8f9f..1aa0e2d3 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -121,7 +121,7 @@ void SellDialog::addItem(const Item *item, int price) } mShopItems->addItem(item->getInvIndex(), item->getId(), - item->getQuantity(), price); + item->getQuantity(), price); mShopItemList->adjustSize(); } diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index b019edb9..e89afd94 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -287,7 +287,7 @@ Setup_Video::Setup_Video(): place(0, 11, mOverlayDetailSlider); place(0, 12, mParticleDetailSlider); - place(1, 6, alphaLabel, 2); + place(1, 6, alphaLabel, 3); place(1, 7, mFpsCheckBox).setPadding(3); place(1, 8, scrollRadiusLabel); place(1, 9, scrollLazinessLabel); @@ -298,9 +298,9 @@ Setup_Video::Setup_Video(): place(2, 7, mFpsField).setPadding(1); place(2, 8, mScrollRadiusField).setPadding(1); place(2, 9, mScrollLazinessField).setPadding(1); - place(2, 10, mSpeechLabel, 2).setPadding(2); - place(2, 11, mOverlayDetailField, 2).setPadding(2); - place(2, 12, mParticleDetailField, 2).setPadding(2); + place(2, 10, mSpeechLabel, 3).setPadding(2); + place(2, 11, mOverlayDetailField, 3).setPadding(2); + place(2, 12, mParticleDetailField, 3).setPadding(2); setDimension(gcn::Rectangle(0, 0, 325, 280)); } diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp index e13e218c..85f238c0 100644 --- a/src/gui/shop.cpp +++ b/src/gui/shop.cpp @@ -43,8 +43,7 @@ std::string ShopItems::getElementAt(int i) return mShopItems.at(i)->getDisplayName(); } -void ShopItems::addItem(int inventoryIndex, int id, int quantity, - int price) +void ShopItems::addItem(int inventoryIndex, int id, int quantity, int price) { ShopItem* item = 0; if (mMergeDuplicates) diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index b258c2d8..c0c8f7a1 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -106,15 +106,6 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) } } -void ShopListBox::mousePressed(gcn::MouseEvent &event) -{ - if (event.getButton() == gcn::MouseEvent::LEFT) - { - setSelected(event.getY() / mRowHeight); - distributeActionEvent(); - } -} - void ShopListBox::adjustSize() { if (mListModel) diff --git a/src/gui/shoplistbox.h b/src/gui/shoplistbox.h index cde4786e..5d3378b1 100644 --- a/src/gui/shoplistbox.h +++ b/src/gui/shoplistbox.h @@ -56,8 +56,6 @@ class ShopListBox : public ListBox */ unsigned int getRowHeight() const { return mRowHeight; } - void mousePressed(gcn::MouseEvent &event); - /** * gives information about the current player's money */ diff --git a/src/gui/table.cpp b/src/gui/table.cpp index 1fd088ce..68f36329 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -401,25 +401,21 @@ void GuiTable::keyPressed(gcn::KeyEvent& keyEvent) else if (key.getValue() == gcn::Key::UP) { setSelectedRow(mSelectedRow - 1); - keyEvent.consume(); } else if (key.getValue() == gcn::Key::DOWN) { setSelectedRow(mSelectedRow + 1); - keyEvent.consume(); } else if (key.getValue() == gcn::Key::LEFT) { setSelectedColumn(mSelectedColumn - 1); - keyEvent.consume(); } else if (key.getValue() == gcn::Key::RIGHT) { setSelectedColumn(mSelectedColumn + 1); - keyEvent.consume(); } else if (key.getValue() == gcn::Key::HOME) @@ -459,7 +455,7 @@ void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) { if (isFocused()) { - if (getSelectedRow() >= 0 ) + if (getSelectedRow() > 0 || (getSelectedRow() == 0 && mWrappingEnabled)) { setSelectedRow(getSelectedRow() - 1); } diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index 2a86d549..a4024de3 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -37,52 +37,46 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) { // Make sure parent scroll area sets width of this widget if (getParent()) - { getParent()->logic(); - } // Take the supplied minimum dimension as a starting point and try to beat it mMinWidth = minDimension; std::stringstream wrappedStream; - std::string::size_type newlinePos, lastNewlinePos = 0; + std::string::size_type spacePos, newlinePos, lastNewlinePos = 0; int minWidth = 0; int xpos; + spacePos = text.rfind(" ", text.size()); + + if (spacePos != std::string::npos) + { + const std::string word = text.substr(spacePos + 1); + const int length = getFont()->getWidth(word); + + if (length > mMinWidth) + mMinWidth = length; + } + do { // Determine next piece of string to wrap newlinePos = text.find("\n", lastNewlinePos); if (newlinePos == std::string::npos) - { newlinePos = text.size(); - } std::string line = text.substr(lastNewlinePos, newlinePos - lastNewlinePos); - std::string::size_type spacePos, lastSpacePos = 0; + std::string::size_type lastSpacePos = 0; xpos = 0; - spacePos = text.rfind(" ", text.size()); - - if (spacePos != std::string::npos) - { - const std::string word = text.substr(spacePos + 1); - const int length = getFont()->getWidth(word); - - if (length > mMinWidth) - mMinWidth = length; - } - do { spacePos = line.find(" ", lastSpacePos); if (spacePos == std::string::npos) - { spacePos = line.size(); - } std::string word = line.substr(lastSpacePos, spacePos - lastSpacePos); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 1ac82281..cba52cf9 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -113,19 +113,23 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) { if (player_x > mPixelViewX + mScrollRadius) { - mPixelViewX += (player_x - mPixelViewX - mScrollRadius) / mScrollLaziness; + mPixelViewX += (player_x - mPixelViewX - mScrollRadius) / + mScrollLaziness; } if (player_x < mPixelViewX - mScrollRadius) { - mPixelViewX += (player_x - mPixelViewX + mScrollRadius) / mScrollLaziness; + mPixelViewX += (player_x - mPixelViewX + mScrollRadius) / + mScrollLaziness; } if (player_y > mPixelViewY + mScrollRadius) { - mPixelViewY += (player_y - mPixelViewY - mScrollRadius) / mScrollLaziness; + mPixelViewY += (player_y - mPixelViewY - mScrollRadius) / + mScrollLaziness; } if (player_y < mPixelViewY - mScrollRadius) { - mPixelViewY += (player_y - mPixelViewY + mScrollRadius) / mScrollLaziness; + mPixelViewY += (player_y - mPixelViewY + mScrollRadius) / + mScrollLaziness; } lastTick++; } @@ -168,8 +172,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) { mMap->draw(graphics, (int) mPixelViewX, (int) mPixelViewY); - // Find a path from the player to the mouse, and draw it. This is for debug - // purposes. + // Find a path from the player to the mouse, and draw it. This is for + // debug purposes. if (mShowDebugPath) { // Get the current mouse position @@ -179,7 +183,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) int mouseTileX = mouseX / 32 + mTileViewX; int mouseTileY = mouseY / 32 + mTileViewY; - Path debugPath = mMap->findPath(player_node->mX, player_node->mY, mouseTileX, mouseTileY); + Path debugPath = mMap->findPath(player_node->mX, player_node->mY, + mouseTileX, mouseTileY); graphics->setColor(gcn::Color(255, 0, 0)); for (PathIterator i = debugPath.begin(); i != debugPath.end(); i++) @@ -188,7 +193,9 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) int squareY = i->y * 32 - (int) mPixelViewY + 12; graphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8)); - graphics->drawText(toString(mMap->getMetaTile(i->x, i->y)->Gcost), squareX + 4, squareY + 12, gcn::Graphics::CENTER); + graphics->drawText(toString(mMap->getMetaTile(i->x, i->y)->Gcost), + squareX + 4, squareY + 12, + gcn::Graphics::CENTER); } } } @@ -305,10 +312,12 @@ void Viewport::mousePressed(gcn::MouseEvent &event) if (being->mAction == Being::DEAD) break; - if (player_node->withinAttackRange(being) || keyboard.isKeyActive(keyboard.KEY_ATTACK)) + if (player_node->withinAttackRange(being) || + keyboard.isKeyActive(keyboard.KEY_ATTACK)) { player_node->setGotoTarget(being); - player_node->attack(being, !keyboard.isKeyActive(keyboard.KEY_TARGET)); + player_node->attack(being, + !keyboard.isKeyActive(keyboard.KEY_TARGET)); } else { |