diff options
Diffstat (limited to 'src/gui')
38 files changed, 410 insertions, 117 deletions
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 34293e59d..88bc65a78 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -378,11 +378,6 @@ void BotCheckerWindow::update() { } -void BotCheckerWindow::widgetResized(const gcn::Event &event) -{ - Window::widgetResized(event); -} - void BotCheckerWindow::updateList() { if (mTableModel) diff --git a/src/gui/botcheckerwindow.h b/src/gui/botcheckerwindow.h index a69781865..6af9c91d6 100644 --- a/src/gui/botcheckerwindow.h +++ b/src/gui/botcheckerwindow.h @@ -71,8 +71,6 @@ class BotCheckerWindow : public Window, public gcn::ActionListener, void logic(); - void widgetResized(const gcn::Event &event); - void updateList(); void reset(); diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 8628afc6e..7fad622df 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -22,6 +22,7 @@ #include "gui/buydialog.h" +#include "keyboardconfig.h" #include "shopitem.h" #include "units.h" @@ -29,6 +30,7 @@ #include "gui/tradewindow.h" #include "gui/widgets/button.h" +#include "gui/widgets/inttextfield.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/scrollarea.h" @@ -77,6 +79,9 @@ void BuyDialog::init() setMinHeight(230); setDefaultSize(260, 230, ImageRect::CENTER); + mEnabledKeyboard = keyboard.isEnabled(); + keyboard.setEnabled(false); + mShopItems = new ShopItems; mShopItemList = new ShopListBox(mShopItems, mShopItems); @@ -89,6 +94,15 @@ void BuyDialog::init() mMoneyLabel = new Label(strprintf(_("Price: %s / Total: %s"), "", "")); + mAmountField = new IntTextField(1, 1, 123); + mAmountField->setActionEventId("amount"); + mAmountField->addActionListener(this); + mAmountField->setSendAlwaysEvents(true); + mAmountField->setEnabled(false); + + mAmountLabel = new Label(_("Amount:")); + mAmountLabel->adjustSize(); + // TRANSLATORS: This is a narrow symbol used to denote 'increasing'. // You may change this symbol if your language uses another. mIncreaseButton = new Button(_("+"), "inc", this); @@ -114,15 +128,17 @@ void BuyDialog::init() ContainerPlacer placer; placer = getPlacer(0, 0); - placer(0, 0, mScrollArea, 8, 5).setPadding(3); + placer(0, 0, mScrollArea, 9, 5).setPadding(3); placer(0, 5, mDecreaseButton); - placer(1, 5, mSlider, 3); - placer(4, 5, mIncreaseButton); - placer(5, 5, mQuantityLabel, 2); - placer(7, 5, mAddMaxButton); - placer(0, 6, mMoneyLabel, 8); - placer(6, 7, mBuyButton); - placer(7, 7, mQuitButton); + placer(1, 5, mSlider, 4); + placer(5, 5, mIncreaseButton); + placer(6, 5, mQuantityLabel, 2); + placer(8, 5, mAddMaxButton); + placer(0, 6, mAmountLabel, 2); + placer(2, 6, mAmountField, 2); + placer(0, 7, mMoneyLabel, 8); + placer(7, 8, mBuyButton); + placer(8, 8, mQuitButton); Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); @@ -188,24 +204,34 @@ void BuyDialog::action(const gcn::ActionEvent &event) if (event.getId() == "slider") { mAmountItems = static_cast<int>(mSlider->getValue()); + mAmountField->setValue(mAmountItems); updateButtonsAndLabels(); } else if (event.getId() == "inc" && mAmountItems < mMaxItems) { mAmountItems++; mSlider->setValue(mAmountItems); + mAmountField->setValue(mAmountItems); updateButtonsAndLabels(); } else if (event.getId() == "dec" && mAmountItems > 1) { mAmountItems--; mSlider->setValue(mAmountItems); + mAmountField->setValue(mAmountItems); updateButtonsAndLabels(); } else if (event.getId() == "max") { mAmountItems = mMaxItems; mSlider->setValue(mAmountItems); + mAmountField->setValue(mAmountItems); + updateButtonsAndLabels(); + } + else if (event.getId() == "amount") + { + mAmountItems = mAmountField->getValue(); + mSlider->setValue(mAmountItems); updateButtonsAndLabels(); } // TODO: Actually we'd have a bug elsewhere if this check for the number @@ -256,6 +282,8 @@ void BuyDialog::valueChanged(const gcn::SelectionEvent &event A_UNUSED) updateButtonsAndLabels(); mSlider->gcn::Slider::setScale(1, mMaxItems); + mAmountField->setRange(1, mMaxItems); + mAmountField->setValue(1); } void BuyDialog::updateButtonsAndLabels() @@ -297,6 +325,7 @@ void BuyDialog::updateButtonsAndLabels() mDecreaseButton->setEnabled(mAmountItems > 1); mBuyButton->setEnabled(mAmountItems > 0); mSlider->setEnabled(mMaxItems > 1); + mAmountField->setEnabled(mAmountItems > 0); // Update quantity and money labels mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems)); @@ -326,3 +355,9 @@ void BuyDialog::closeAll() (*it)->close(); } } + +void BuyDialog::scheduleDelete() +{ + keyboard.setEnabled(mEnabledKeyboard); + Window::scheduleDelete(); +} diff --git a/src/gui/buydialog.h b/src/gui/buydialog.h index 0ba2e5cb3..53d20e1e5 100644 --- a/src/gui/buydialog.h +++ b/src/gui/buydialog.h @@ -38,6 +38,7 @@ class ShopItems; class ShopListBox; +class IntTextField; class ListBox; /** @@ -124,6 +125,8 @@ class BuyDialog : public Window, public gcn::ActionListener, */ static void closeAll(); + void scheduleDelete(); + private: typedef std::list<BuyDialog*> DialogList; static DialogList instances; @@ -140,6 +143,8 @@ class BuyDialog : public Window, public gcn::ActionListener, gcn::Label *mMoneyLabel; gcn::Label *mQuantityLabel; gcn::Slider *mSlider; + gcn::Label *mAmountLabel; + IntTextField *mAmountField; ShopItems *mShopItems; @@ -147,6 +152,7 @@ class BuyDialog : public Window, public gcn::ActionListener, int mAmountItems; int mMaxItems; std::string mNick; + bool mEnabledKeyboard; }; #endif diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index cd02a6732..f52151698 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -99,7 +99,8 @@ InventoryWindow::InventoryWindow(Inventory *inventory): Window("Inventory", false, 0, "inventory.xml"), mInventory(inventory), mDropButton(0), - mSplit(false) + mSplit(false), + mCompactMode(false) { if (inventory) { @@ -146,7 +147,6 @@ InventoryWindow::InventoryWindow(Inventory *inventory): mSortDropDown->setSelected(0); mFilterLabel = new Label(_("Filter:")); - mSorterLabel = new Label(_("Sort:")); mNameFilter = new TextField("", true, this, "namefilter", true); std::vector<std::string> tags = ItemDB::getTags(); @@ -181,13 +181,12 @@ InventoryWindow::InventoryWindow(Inventory *inventory): place(0, 0, mWeightLabel, 1).setPadding(3); place(1, 0, mWeightBar, 3); place(4, 0, mSlotsLabel, 1).setPadding(3); - place(5, 0, mSlotsBar, 2); - place(7, 0, mSorterLabel, 1); - place(8, 0, mSortDropDown, 3); + mSlotsBarCell = &place(5, 0, mSlotsBar, 3); + mSortDropDownCell = &place(8, 0, mSortDropDown, 3); place(0, 1, mFilterLabel, 1).setPadding(3); - place(1, 1, mFilter, 7).setPadding(3); - place(8, 1, mNameFilter, 3); + mFilterCell = &place(1, 1, mFilter, 8).setPadding(3); + mNameFilterCell = &place(8, 1, mNameFilter, 3); place(0, 2, invenScroll, 11).setPadding(3); place(0, 3, mUseButton); @@ -206,13 +205,12 @@ InventoryWindow::InventoryWindow(Inventory *inventory): mCloseButton = new Button(_("Close"), "close", this); place(0, 0, mSlotsLabel).setPadding(3); - place(1, 0, mSlotsBar, 4); - place(5, 0, mSorterLabel, 1); - place(6, 0, mSortDropDown, 1); + mSlotsBarCell = &place(1, 0, mSlotsBar, 5); + mSortDropDownCell = &place(6, 0, mSortDropDown, 1); place(0, 1, mFilterLabel, 1).setPadding(3); - place(1, 1, mFilter, 5).setPadding(3); - place(6, 1, mNameFilter, 1); + mFilterCell = &place(1, 1, mFilter, 6).setPadding(3); + mNameFilterCell = &place(6, 1, mNameFilter, 1); place(0, 2, invenScroll, 7, 4); place(0, 6, mStoreButton); @@ -240,6 +238,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory): loadWindowState(); slotsChanged(mInventory); + widgetResized(0); if (!isMainInventory()) setVisible(true); } @@ -376,6 +375,13 @@ Item *InventoryWindow::getSelectedItem() const return mItems->getSelectedItem(); } +void InventoryWindow::widgetHidden(const gcn::Event &event) +{ + Window::widgetHidden(event); + if (mItems) + mItems->hidePopup(); +} + void InventoryWindow::mouseClicked(gcn::MouseEvent &event) { Window::mouseClicked(event); @@ -666,3 +672,35 @@ bool InventoryWindow::isAnyInputFocused() } return false; } + +void InventoryWindow::widgetResized(const gcn::Event &event) +{ + Window::widgetResized(event); + + if (!isMainInventory()) + return; + + if (getWidth() < 600) + { + if (!mCompactMode) + { + mSortDropDown->setVisible(false); + mNameFilter->setVisible(false); + mSortDropDownCell->setType(LayoutCell::NONE); + mNameFilterCell->setType(LayoutCell::NONE); + mFilterCell->setWidth(mFilterCell->getWidth() + 3); + mSlotsBarCell->setWidth(mSlotsBarCell->getWidth() + 3); + mCompactMode = true; + } + } + else if (mCompactMode) + { + mSortDropDown->setVisible(true); + mNameFilter->setVisible(true); + mSortDropDownCell->setType(LayoutCell::WIDGET); + mNameFilterCell->setType(LayoutCell::WIDGET); + mFilterCell->setWidth(mFilterCell->getWidth() - 3); + mSlotsBarCell->setWidth(mSlotsBarCell->getWidth() - 3); + mCompactMode = false; + } +} diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index c32fd8905..9dadeb5a8 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -45,6 +45,7 @@ class DropDown; class Item; class ItemContainer; class InventoryFilter; +class LayoutCell; class ProgressBar; class SortListModel; //class TextBox; @@ -84,6 +85,11 @@ class InventoryWindow : public Window, Item* getSelectedItem() const; /** + * Handles closing of the window + */ + void widgetHidden(const gcn::Event &event); + + /** * Handles the mouse clicks. */ void mouseClicked(gcn::MouseEvent &event); @@ -133,6 +139,8 @@ class InventoryWindow : public Window, bool isInputFocused() const; + void widgetResized(const gcn::Event &event); + static bool isAnyInputFocused(); private: @@ -154,15 +162,20 @@ class InventoryWindow : public Window, *mSplitButton, *mOutfitButton, *mShopButton, *mStoreButton, *mRetrieveButton, *mCloseButton; - gcn::Label *mWeightLabel, *mSlotsLabel, *mFilterLabel, *mSorterLabel; + gcn::Label *mWeightLabel, *mSlotsLabel, *mFilterLabel; ProgressBar *mWeightBar, *mSlotsBar; InventoryFilter *mFilter; DropDown *mSortDropDown; SortListModel *mSortModel; TextField *mNameFilter; + LayoutCell *mSortDropDownCell; + LayoutCell *mNameFilterCell; + LayoutCell *mFilterCell; + LayoutCell *mSlotsBarCell; bool mSplit; + bool mCompactMode; }; extern InventoryWindow *inventoryWindow; diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 3e1ee46d8..b926d260e 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -404,13 +404,6 @@ void NpcDialog::move(int amount) } } -void NpcDialog::widgetResized(const gcn::Event &event) -{ - Window::widgetResized(event); - -// setText(mText); -} - void NpcDialog::setVisible(bool visible) { Window::setVisible(visible); diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 2f5a90b5f..7e9ea7e10 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -147,13 +147,6 @@ class NpcDialog : public Window, public gcn::ActionListener, void move(int amount); - /** - * Called when resizing the window. - * - * @param event The calling event - */ - void widgetResized(const gcn::Event &event); - void setVisible(bool visible); void optionChanged(const std::string &name); diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index a5f5f3ee0..39c6f94f7 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -95,7 +95,11 @@ class TypeListModel : public gcn::ListModel * Used to get number of line in the list */ int getNumberOfElements() +#ifdef MANASERV_SUPPORT + { return 3; } +#else { return 2; } +#endif /** * Used to get an element from the list diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index 5125541cf..922d9797b 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -153,8 +153,17 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event) { if (!mKeySetting) { - mAssignKeyButton->setEnabled(true); - mUnassignKeyButton->setEnabled(true); + int i(mKeyList->getSelected()); + if (keyboard.isSeparator(i)) + { + mAssignKeyButton->setEnabled(false); + mUnassignKeyButton->setEnabled(false); + } + else + { + mAssignKeyButton->setEnabled(true); + mUnassignKeyButton->setEnabled(true); + } } } else if (event.getId() == "assign") @@ -183,11 +192,21 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event) void Setup_Keyboard::refreshAssignedKey(int index) { - std::string caption; - char *temp = SDL_GetKeyName( - static_cast<SDLKey>(keyboard.getKeyValue(index))); - caption = keyboard.getKeyCaption(index) + ": " + toString(temp); - mKeyListModel->setElementAt(index, caption); + if (keyboard.isSeparator(index)) + { + const std::string str = " \342\200\225\342\200\225\342\200\225" + "\342\200\225\342\200\225 "; + mKeyListModel->setElementAt(index, str + + keyboard.getKeyCaption(index) + str); + } + else + { + std::string caption; + char *temp = SDL_GetKeyName( + static_cast<SDLKey>(keyboard.getKeyValue(index))); + caption = keyboard.getKeyCaption(index) + ": " + toString(temp); + mKeyListModel->setElementAt(index, caption); + } } void Setup_Keyboard::newKeyCallback(int index) diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 670fc3635..a6bf5b81c 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -60,6 +60,9 @@ Setup_Players::Setup_Players() new SetupItemCheckBox(_("Show own name"), "", "showownname", this, "showownnameEvent"); + new SetupItemCheckBox(_("Enable extended mouse targeting"), "", + "extMouseTargeting", this, "extMouseTargetingEvent"); + new SetupItemCheckBox(_("Target dead players"), "", "targetDeadPlayers", this, "targetDeadPlayersEvent"); diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 489d5a818..57a51e435 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -228,7 +228,6 @@ public: #define ACTION_OLD "old" #define ACTION_TABLE "table" #define ACTION_STRATEGY "strategy" -#define ACTION_WHISPER_TAB "whisper tab" Setup_Relations::Setup_Relations(): mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)), diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index df21488a5..6d48da197 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -159,3 +159,22 @@ int ShortcutWindow::getTabIndex() return 0; return mTabs->getSelectedTabIndex(); } + +void ShortcutWindow::widgetHidden(const gcn::Event &event) +{ + if (mItems) + mItems->widgetHidden(event); + if (mTabs) + { + ScrollArea *scroll = static_cast<ScrollArea*>( + mTabs->getCurrentWidget()); + if (scroll) + { + ShortcutContainer *content = static_cast<ShortcutContainer*>( + scroll->getContent()); + + if (content) + content->widgetHidden(event); + } + } +} diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h index 1c91835e8..8627a5dce 100644 --- a/src/gui/shortcutwindow.h +++ b/src/gui/shortcutwindow.h @@ -56,6 +56,8 @@ class ShortcutWindow : public Window int getTabIndex(); + void widgetHidden(const gcn::Event &event); + private: ShortcutWindow(); ShortcutContainer *mItems; diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index a8d15f36c..ab19e501b 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1133,7 +1133,7 @@ SocialWindow::SocialWindow() : setMinWidth(120); setMinHeight(55); - setDefaultSize(590, 200, 150, 120); + setDefaultSize(590, 200, 180, 300); setupWindow->registerWindowForReset(this); mCreateButton = new Button(_("Create"), "create", this); diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index c7d25e257..66d69b197 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -42,14 +42,15 @@ #include "debug.h" SpellPopup::SpellPopup(): - Popup("SpellPopup", "spellpopup.xml") + Popup("SpellPopup", "spellpopup.xml"), + mItemName(new Label), + mItemComment(new Label) { - // Item Name - mItemName = new Label; mItemName->setFont(boldFont); - mItemName->setPosition(getPadding(), getPadding()); add(mItemName); + add(mItemComment); + addMouseListener(this); } @@ -60,17 +61,39 @@ SpellPopup::~SpellPopup() void SpellPopup::setItem(TextCommand *spell) { if (spell) + { mItemName->setCaption(spell->getName()); + mItemComment->setCaption(spell->getComment()); + } else + { mItemName->setCaption("?"); + mItemComment->setCaption(""); + } mItemName->adjustSize(); + mItemComment->adjustSize(); int minWidth = mItemName->getWidth(); + if (mItemComment->getWidth() > minWidth) + minWidth = mItemComment->getWidth(); minWidth += 8; - setWidth(minWidth); + setWidth(minWidth + 2 * getPadding()); - setContentSize(minWidth, getPadding() + getFont()->getHeight()); + mItemName->setPosition(getPadding(), getPadding()); + mItemComment->setPosition(getPadding(), + getPadding() + mItemName->getHeight()); + + if (mItemComment->getCaption() != "") + { + setContentSize(minWidth, getPadding() + + 2 * getFont()->getHeight()); + } + else + { + setContentSize(minWidth, getPadding() + + getFont()->getHeight()); + } } void SpellPopup::view(int x, int y) diff --git a/src/gui/spellpopup.h b/src/gui/spellpopup.h index 69c47bf45..883b2bfe0 100644 --- a/src/gui/spellpopup.h +++ b/src/gui/spellpopup.h @@ -63,6 +63,8 @@ class SpellPopup : public Popup private: gcn::Label *mItemName; + + gcn::Label *mItemComment; }; #endif // SPELLPOPUP_H diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 0cad8732a..170fd6ab4 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -133,8 +133,8 @@ StatusWindow::StatusWindow(): setCloseButton(true); setSaveVisible(true); setStickyButtonLock(true); - setDefaultSize((windowContainer->getWidth() - 365) / 2, - (windowContainer->getHeight() - 255) / 2, 365, 275); + setDefaultSize((windowContainer->getWidth() - 480) / 2, + (windowContainer->getHeight() - 500) / 2, 480, 500); // ---------------------- // Status Part @@ -502,7 +502,8 @@ void StatusWindow::updateProgressBar(ProgressBar *bar, int value, int max, if (max == 0) { bar->setText(_("Max")); - bar->setProgress(1.0); + bar->setProgress(1); + bar->setText(toString(value)); } else { diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 282f23ee1..6512f8465 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -168,7 +168,7 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): Window(_("Command Editor"), false, 0, "commandeditor.xml") { int w = 350; - int h = 350; + int h = 370; mEnabledKeyboard = keyboard.isEnabled(); keyboard.setEnabled(false); @@ -197,6 +197,9 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): mCommandLabel = new Label(_("Command:")); mCommandTextField = new TextField(); + mCommentLabel = new Label(_("Comment:")); + mCommentTextField = new TextField(); + mManaLabel = new Label(_("Mana:")); mManaField = new IntTextField(0); mManaField->setRange(0, 500); @@ -248,6 +251,7 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): mSymbolTextField->setText(command->getSymbol()); mCommandTextField->setText(command->getCommand()); + mCommentTextField->setText(command->getComment()); mManaField->setValue(command->getMana()); mTypeDropDown->setSelected(command->getTargetType()); mMagicLvlField->setValue(command->getBaseLvl()); @@ -263,25 +267,29 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): placer(2, 1, mSymbolTextField, 3).setPadding(3); placer(0, 2, mCommandLabel, 2).setPadding(3); placer(2, 2, mCommandTextField, 4).setPadding(3); - placer(0, 3, mTypeLabel, 2).setPadding(3); - placer(2, 3, mTypeDropDown, 3).setPadding(3); - placer(0, 4, mIconLabel, 2).setPadding(3); - placer(2, 4, mIconDropDown, 3).setPadding(3); + placer(0, 3, mCommentLabel, 2).setPadding(3); + placer(2, 3, mCommentTextField, 4).setPadding(3); + + placer(0, 4, mTypeLabel, 2).setPadding(3); + placer(2, 4, mTypeDropDown, 3).setPadding(3); + + placer(0, 5, mIconLabel, 2).setPadding(3); + placer(2, 5, mIconDropDown, 3).setPadding(3); - placer(0, 5, mManaLabel, 2).setPadding(3); - placer(2, 5, mManaField, 3).setPadding(3); - placer(0, 6, mMagicLvlLabel, 2).setPadding(3); - placer(2, 6, mMagicLvlField, 3).setPadding(3); + placer(0, 6, mManaLabel, 2).setPadding(3); + placer(2, 6, mManaField, 3).setPadding(3); + placer(0, 7, mMagicLvlLabel, 2).setPadding(3); + placer(2, 7, mMagicLvlField, 3).setPadding(3); - placer(0, 7, mSchoolLabel, 2).setPadding(3); - placer(2, 7, mSchoolDropDown, 3).setPadding(3); - placer(0, 8, mSchoolLvlLabel, 2).setPadding(3); - placer(2, 8, mSchoolLvlField, 3).setPadding(3); + placer(0, 8, mSchoolLabel, 2).setPadding(3); + placer(2, 8, mSchoolDropDown, 3).setPadding(3); + placer(0, 9, mSchoolLvlLabel, 2).setPadding(3); + placer(2, 9, mSchoolLvlField, 3).setPadding(3); - placer(0, 9, mSaveButton, 2).setPadding(3); - placer(2, 9, mCancelButton, 2).setPadding(3); - placer(4, 9, mDeleteButton, 2).setPadding(3); + placer(0, 10, mSaveButton, 2).setPadding(3); + placer(2, 10, mCancelButton, 2).setPadding(3); + placer(4, 10, mDeleteButton, 2).setPadding(3); setWidth(w); setHeight(h); @@ -335,11 +343,6 @@ void TextCommandEditor::update() { } -void TextCommandEditor::widgetResized(const gcn::Event &event) -{ - Window::widgetResized(event); -} - void TextCommandEditor::updateList() { } @@ -375,6 +378,7 @@ void TextCommandEditor::save() mCommand->setSymbol(mSymbolTextField->getText()); mCommand->setCommand(mCommandTextField->getText()); + mCommand->setComment(mCommentTextField->getText()); mCommand->setMana(mManaField->getValue()); mCommand->setTargetType( static_cast<SpellTarget>(mTypeDropDown->getSelected())); @@ -392,6 +396,7 @@ void TextCommandEditor::deleteCommand() mCommand->setCommandType(TEXT_COMMAND_TEXT); mCommand->setSymbol(""); mCommand->setCommand(""); + mCommand->setComment(""); mCommand->setMana(0); mCommand->setTargetType(NOTARGET); mCommand->setIcon(""); diff --git a/src/gui/textcommandeditor.h b/src/gui/textcommandeditor.h index 236c42320..d0b2f0a54 100644 --- a/src/gui/textcommandeditor.h +++ b/src/gui/textcommandeditor.h @@ -60,8 +60,6 @@ class TextCommandEditor : public Window, public gcn::ActionListener void update(); - void widgetResized(const gcn::Event &event); - void updateList(); void reset(); @@ -84,6 +82,10 @@ class TextCommandEditor : public Window, public gcn::ActionListener TextField *mSymbolTextField; Label *mCommandLabel; TextField *mCommandTextField; + + Label *mCommentLabel; + TextField *mCommentTextField; + Label *mTypeLabel; DropDown *mTypeDropDown; Label *mIconLabel; diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index e1f69c2d7..a14e99afc 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -59,23 +59,27 @@ #undef malloc #endif -bool stringCompare(const std::string &left, const std::string &right); -bool stringCompare(const std::string &left, const std::string &right ) +class NameFunctuator { - for (std::string::const_iterator lit = left.begin(), - rit = right.begin(); - lit != left.end() && rit != right.end(); ++lit, ++rit) - { - if (tolower(*lit) < tolower(*rit)) - return true; - else if (tolower(*lit) > tolower(*rit)) + public: + bool operator()(const std::string &left, + const std::string &right) const + { + for (std::string::const_iterator lit = left.begin(), + rit = right.begin(); + lit != left.end() && rit != right.end(); ++lit, ++rit) + { + if (tolower(*lit) < tolower(*rit)) + return true; + else if (tolower(*lit) > tolower(*rit)) + return false; + } + if (left.size() < right.size()) + return true; return false; - } - if (left.size() < right.size()) - return true; - return false; -} + } +} nameCompare; WhoIsOnline::WhoIsOnline(): Window(_("Who Is Online - Updating"), false, 0, "whoisonline.xml"), @@ -297,9 +301,9 @@ void WhoIsOnline::loadList() setCaption(_("Who Is Online - ") + toString(numOnline)); //List the online people - sort(friends.begin(), friends.end(), stringCompare); - sort(neutral.begin(), neutral.end(), stringCompare); - sort(disregard.begin(), disregard.end(), stringCompare); + sort(friends.begin(), friends.end(), nameCompare); + sort(neutral.begin(), neutral.end(), nameCompare); + sort(disregard.begin(), disregard.end(), nameCompare); bool addedFromSection(false); for (int i = 0; i < static_cast<int>(friends.size()); i++) { diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index b628cf2d4..1fa272448 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -306,5 +306,12 @@ void DropShortcutContainer::mouseMoved(gcn::MouseEvent &event) // Hide ItemTooltip void DropShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) { - mItemPopup->setVisible(false); + if (mItemPopup) + mItemPopup->setVisible(false); +} + +void DropShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +{ + if (mItemPopup) + mItemPopup->setVisible(false); } diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index b2d63a7dd..348f48567 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -76,6 +76,8 @@ class DropShortcutContainer : public ShortcutContainer */ void mouseReleased(gcn::MouseEvent &event); + void widgetHidden(const gcn::Event &event); + private: void mouseExited(gcn::MouseEvent &event); void mouseMoved(gcn::MouseEvent &event); diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 5aced193f..cc9e8badf 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -252,4 +252,10 @@ void EmoteShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) { if (mEmotePopup) mEmotePopup->setVisible(false); -}
\ No newline at end of file +} + +void EmoteShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +{ + if (mEmotePopup) + mEmotePopup->setVisible(false); +} diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index b1cc866d2..06c009f0b 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -27,6 +27,12 @@ #include <vector> +#ifdef __GNUC__ +#define A_UNUSED __attribute__ ((unused)) +#else +#define A_UNUSED +#endif + class AnimatedSprite; class Image; class TextPopup; @@ -73,6 +79,8 @@ class EmoteShortcutContainer : public ShortcutContainer void mouseExited(gcn::MouseEvent &event); + void widgetHidden(const gcn::Event &event); + private: std::vector<const EmoteSprite*> mEmoteImg; diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp index 021340fbe..89544e108 100644 --- a/src/gui/widgets/inttextfield.cpp +++ b/src/gui/widgets/inttextfield.cpp @@ -50,6 +50,9 @@ void IntTextField::keyPressed(gcn::KeyEvent &event) key.getValue() == Key::DELETE) { setText(std::string()); + if (mSendAlwaysEvents) + distributeActionEvent(); + event.consume(); } @@ -62,6 +65,8 @@ void IntTextField::keyPressed(gcn::KeyEvent &event) int i; s >> i; setValue(i); + if (mSendAlwaysEvents) + distributeActionEvent(); } void IntTextField::setRange(int min, int max) diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 2cc80ee8b..9a17d81cd 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -327,6 +327,12 @@ void ItemContainer::distributeValueChangedEvent() } } +void ItemContainer::hidePopup() +{ + if (mItemPopup) + mItemPopup->setVisible(false); +} + void ItemContainer::keyPressed(gcn::KeyEvent &event A_UNUSED) { /*switch (event.getKey().getValue()) diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 845bfb3a9..e4188f54b 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -73,6 +73,8 @@ class ItemContainer : public gcn::Widget, */ virtual ~ItemContainer(); + void hidePopup(); + /** * Necessary for checking how full the inventory is. */ diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 79685fe45..560045a29 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -378,6 +378,16 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) // Hide ItemTooltip void ItemShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) { - mItemPopup->setVisible(false); - mSpellPopup->setVisible(false); + if (mItemPopup) + mItemPopup->setVisible(false); + if (mSpellPopup) + mSpellPopup->setVisible(false); +} + +void ItemShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +{ + if (mItemPopup) + mItemPopup->setVisible(false); + if (mSpellPopup) + mSpellPopup->setVisible(false); } diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index e6b32c6f8..473cef350 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -78,6 +78,8 @@ class ItemShortcutContainer : public ShortcutContainer */ void mouseReleased(gcn::MouseEvent &event); + void widgetHidden(const gcn::Event &event); + private: void mouseExited(gcn::MouseEvent &event); void mouseMoved(gcn::MouseEvent &event); diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index f5e1f1749..5e3ac4532 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -261,6 +261,28 @@ class LayoutCell */ void computeSizes(); + void setType(int t) + { mType = t; } + + int getWidth() + { return mExtent[0]; } + + int getHeight() + { return mExtent[1]; } + + void setWidth(int w) + { mExtent[0] = w; } + + void setHeight(int h) + { mExtent[1] = h; } + + enum + { + NONE = 0, + WIDGET, + ARRAY + }; + private: // Copy not allowed, as the cell may own an array. LayoutCell(LayoutCell const &); @@ -272,13 +294,6 @@ class LayoutCell LayoutArray *mArray; }; - enum - { - NONE = 0, - WIDGET, - ARRAY - }; - /** * Returns the embedded array. Creates it if the cell does not contain * anything yet. Aborts if it contains a widget. diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 2796d3ab2..3204028dc 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -47,6 +47,8 @@ ScrollArea::ScrollArea(): gcn::ScrollArea(), mX(0), mY(0), + mClickX(0), + mClickY(0), mHasMouse(false), mOpaque(true), mVertexes(new GraphicsVertexes()), @@ -64,6 +66,8 @@ ScrollArea::ScrollArea(gcn::Widget *widget): gcn::ScrollArea(widget), mX(0), mY(0), + mClickX(0), + mClickY(0), mHasMouse(false), mOpaque(true), mVertexes(new GraphicsVertexes()), @@ -513,3 +517,56 @@ void ScrollArea::widgetMoved(const gcn::Event& event A_UNUSED) { mRedraw = true; } + +void ScrollArea::mousePressed(gcn::MouseEvent& event) +{ + gcn::ScrollArea::mousePressed(event); + if (event.getButton() == gcn::MouseEvent::LEFT) + { + mClickX = event.getX(); + mClickY = event.getY(); + } +} + +void ScrollArea::mouseReleased(gcn::MouseEvent& event) +{ + if (event.getButton() == gcn::MouseEvent::LEFT && mClickX && mClickY) + { + if (!event.isConsumed()) + { + int dx = event.getX() - mClickX; + int dy = event.getY() - mClickY; + + if ((dx < 10 && dx > 0) || (dx > -10 && dx < 0)) + dx = 0; + + if ((dy < 10 && dy > 0) || (dy > -10 && dy < 0)) + dy = 0; + + if (dx) + { + int s = getHorizontalScrollAmount() + dx; + if (s < 0) + s = 0; + else if (s > getHorizontalMaxScroll()) + s = getHorizontalMaxScroll(); + + setHorizontalScrollAmount(s); + } + if (dy) + { + int s = getVerticalScrollAmount() + dy; + if (s < 0) + s = 0; + else if (s > getVerticalMaxScroll()) + s = getVerticalMaxScroll(); + + setVerticalScrollAmount(s); + } + mClickX = 0; + mClickY = 0; + event.consume(); + } + } + gcn::ScrollArea::mouseReleased(event); +} diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 095010f3c..56e21c58c 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -112,6 +112,10 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener */ void mouseExited(gcn::MouseEvent& event); + void mousePressed(gcn::MouseEvent& event); + + void mouseReleased(gcn::MouseEvent& event); + void widgetResized(const gcn::Event &event); void widgetMoved(const gcn::Event &event); @@ -148,6 +152,7 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener static Image *buttons[4][2]; int mX, mY; + int mClickX, mClickY; bool mHasMouse; bool mOpaque; GraphicsVertexes *mVertexes; diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 8abe727b5..6317dd56f 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -290,5 +290,12 @@ void SpellShortcutContainer::mouseMoved(gcn::MouseEvent &event) // Hide SpellTooltip void SpellShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) { - mSpellPopup->setVisible(false); + if (mSpellPopup) + mSpellPopup->setVisible(false); +} + +void SpellShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +{ + if (mSpellPopup) + mSpellPopup->setVisible(false); } diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index 2155e2a8b..88b00338a 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -77,6 +77,8 @@ class SpellShortcutContainer : public ShortcutContainer */ void mouseReleased(gcn::MouseEvent &event); + void widgetHidden(const gcn::Event &event); + private: void mouseExited(gcn::MouseEvent &event); void mouseMoved(gcn::MouseEvent &event); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 5d4fbc0b4..6ce4cbf3b 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -51,11 +51,11 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab, gcn::ActionListener* listener, std::string eventId, bool sendAlwaysEvents): gcn::TextField(text), + mSendAlwaysEvents(sendAlwaysEvents), mNumeric(false), mMinimum(0), mMaximum(0), - mLastEventPaste(false), - mSendAlwaysEvents(sendAlwaysEvents) + mLastEventPaste(false) { setFrameSize(2); diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 7e19099e8..93f970168 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -96,6 +96,12 @@ class TextField : public gcn::TextField */ int getValue() const; + void setSendAlwaysEvents(bool b) + { mSendAlwaysEvents = b; } + + protected: + bool mSendAlwaysEvents; + private: void handlePaste(); @@ -109,7 +115,6 @@ class TextField : public gcn::TextField int mMaximum; bool mLoseFocusOnTab; int mLastEventPaste; - bool mSendAlwaysEvents; }; #endif diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 510a68323..ffc27ab10 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -113,14 +113,14 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Called whenever the widget changes size. */ - void widgetResized(const gcn::Event &event); + virtual void widgetResized(const gcn::Event &event); virtual void widgetMoved(const gcn::Event& event); /** * Called whenever the widget is hidden. */ - virtual void widgetHidden(const gcn::Event& event); + virtual void widgetHidden(const gcn::Event &event); /** * Sets whether or not the window has a close button. |