diff options
Diffstat (limited to 'src/gui')
85 files changed, 1018 insertions, 301 deletions
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 2851d3d1d..7c0339ead 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -290,7 +290,6 @@ BotCheckerWindow::BotCheckerWindow(): } mPlayerTitleTable = new GuiTable(mPlayerTableTitleModel); - //mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf)); mPlayerTitleTable->setHeight(1); mPlayerTableTitleModel->set(0, 0, new Label(_("Name"))); @@ -303,6 +302,7 @@ BotCheckerWindow::BotCheckerWindow(): setWindowName("BotCheckerWindow"); setCloseButton(true); + setStickyButtonLock(true); setDefaultSize(w, h, ImageRect::CENTER); playersScrollArea = new ScrollArea(mTable); diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 04dd425c1..8c1ad62ce 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -72,6 +72,7 @@ void BuyDialog::init() setWindowName("Buy"); setResizable(true); setCloseButton(true); + setStickyButtonLock(true); setMinWidth(260); setMinHeight(230); setDefaultSize(260, 230, ImageRect::CENTER); diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 91c284985..d1773e7f3 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -60,6 +60,9 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mRace(0), mSlot(slot) { + setStickyButtonLock(true); + setSticky(true); + mPlayer = new Being(0, ActorSprite::PLAYER, mRace, NULL); mPlayer->setGender(GENDER_MALE); diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 28c7a083c..1942ebaeb 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -60,7 +60,6 @@ #include <guichan/font.hpp> #include <string> -#include <cassert> #include "debug.h" @@ -342,8 +341,8 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters) void CharSelectDialog::lock() { - assert(!mLocked); - setLocked(true); + if (!mLocked) + setLocked(true); } void CharSelectDialog::unlock() diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 1ef3139db..784fb812a 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -167,6 +167,8 @@ ChatWindow::ChatWindow(): setResizable(true); setDefaultVisible(true); setSaveVisible(true); + setStickyButtonLock(true); + setDefaultSize(600, 123, ImageRect::LOWER_LEFT); setMinWidth(150); setMinHeight(90); @@ -211,6 +213,7 @@ ChatWindow::ChatWindow(): fillCommands(); initTradeFilter(); loadCustomList(); + parseHighlights(); } ChatWindow::~ChatWindow() @@ -659,7 +662,7 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event) if (event.isConsumed()) return; - if (isMovable() && mMoved) + if (canMove() && isMovable() && mMoved) { int newX = std::max(0, getX() + event.getX() - mDragOffsetX); int newY = std::max(0, getY() + event.getY() - mDragOffsetY); @@ -1458,12 +1461,8 @@ void ChatWindow::saveState() std::string ChatWindow::doReplace(const std::string &msg) { - if (Client::getServerName() == "server.themanaworld.org" - || Client::getServerName() == "themanaworld.org" - || Client::getServerName() == "81.161.192.4") - { + if (Client::isTmw()) return msg; - } std::string str = msg; replaceSpecialChars(str); @@ -1503,7 +1502,7 @@ void ChatWindow::addToAwayLog(std::string line) if (mAwayLog.size() > 20) mAwayLog.pop_front(); - if (line.find(player_node->getName()) != std::string::npos) + if (findI(line, mHighlights) != std::string::npos) mAwayLog.push_back("##9away:" + line); } @@ -1520,3 +1519,20 @@ void ChatWindow::displayAwayLog() ++i; } } + +void ChatWindow::parseHighlights() +{ + mHighlights.clear(); + if (!player_node) + return; + + splitToStringVector(mHighlights, config.getStringValue( + "highlightWords"), ','); + + mHighlights.push_back(player_node->getName()); +} + +bool ChatWindow::findHighlight(std::string &str) +{ + return findI(str, mHighlights) != std::string::npos; +}
\ No newline at end of file diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index b6a37ef79..6e1d548a3 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -260,6 +260,10 @@ class ChatWindow : public Window, void clearAwayLog() { mAwayLog.clear(); } + void parseHighlights(); + + bool findHighlight(std::string &str); + protected: friend class ChatTab; friend class WhisperTab; @@ -329,6 +333,7 @@ class ChatWindow : public Window, int mChatColor; unsigned int mChatHistoryIndex; std::list<std::string> mAwayLog; + std::vector<std::string> mHighlights; }; extern ChatWindow *chatWindow; diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 0b84dda1e..dc540a782 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -60,6 +60,8 @@ DebugWindow::DebugWindow(): setResizable(true); setCloseButton(true); setSaveVisible(true); + setStickyButtonLock(true); + setDefaultSize(400, 150, ImageRect::CENTER); mTabs = new TabbedArea; diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp index 4d89bd924..d62417fc4 100644 --- a/src/gui/didyouknowwindow.cpp +++ b/src/gui/didyouknowwindow.cpp @@ -51,6 +51,8 @@ DidYouKnowWindow::DidYouKnowWindow(): setContentSize(455, 350); setWindowName("DidYouKnow"); setResizable(true); + setStickyButtonLock(true); + setupWindow->registerWindowForReset(this); setDefaultSize(500, 400, ImageRect::CENTER); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 67ec78e49..0375d096f 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -80,6 +80,8 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, setCloseButton(true); setSaveVisible(true); + setStickyButtonLock(true); + setDefaultSize(180, 345, ImageRect::CENTER); mBoxes.reserve(13); @@ -99,6 +101,9 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, add(mPlayerBox); add(mUnequip); + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mBorderColor = Theme::getThemeColor(Theme::BORDER); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } EquipmentWindow::~EquipmentWindow() @@ -138,16 +143,15 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) continue; if (i == mSelected) { - const gcn::Color color = Theme::getThemeColor(Theme::HIGHLIGHT); - + mHighlightColor.a = getGuiAlpha(); // Set color to the highlight color - g->setColor(gcn::Color(color.r, color.g, color.b, getGuiAlpha())); + g->setColor(mHighlightColor); g->fillRectangle(gcn::Rectangle(box->first, box->second, BOX_WIDTH, BOX_HEIGHT)); } // Set color black - g->setColor(gcn::Color(0, 0, 0)); + g->setColor(mBorderColor); // Draw box border g->drawRectangle(gcn::Rectangle(box->first, box->second, BOX_WIDTH, BOX_HEIGHT)); @@ -167,7 +171,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) g->drawImage(image, box->first + 2, box->second + 2); if (i == EQUIP_PROJECTILE_SLOT) { - g->setColor(Theme::getThemeColor(Theme::TEXT)); + g->setColor(getForegroundColor()); graphics->drawText(toString(item->getQuantity()), box->first + (BOX_WIDTH / 2), box->second - fontHeight, diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index c59600dd8..cadf27620 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -116,6 +116,8 @@ class EquipmentWindow : public Window, public gcn::ActionListener bool mForing; Being *mBeing; std::vector<std::pair<int, int>*> mBoxes; + gcn::Color mHighlightColor; + gcn::Color mBorderColor; }; extern EquipmentWindow *equipmentWindow; diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index 368049389..b772ea36a 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -47,6 +47,8 @@ HelpWindow::HelpWindow(): setContentSize(455, 350); setWindowName("Help"); setResizable(true); + setStickyButtonLock(true); + setupWindow->registerWindowForReset(this); setDefaultSize(500, 400, ImageRect::CENTER); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 3b7b7b273..d0454c4e1 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -89,6 +89,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory): setResizable(true); setCloseButton(true); setSaveVisible(true); + setStickyButtonLock(true); setDefaultSize(387, 307, ImageRect::CENTER); setMinWidth(316); diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index a3f591634..059f3d785 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -63,7 +63,7 @@ public: if (i->first < 0) continue; - ItemInfo info = (*i->second); + const ItemInfo &info = (*i->second); std::string name = info.getName(); if (name != "unnamed" && !info.getName().empty() && info.getName() != "unnamed") diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index f5117ed5a..4d401a627 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -32,6 +32,7 @@ #include "gui/theme.h" #include "gui/widgets/icon.h" +#include "gui/widgets/label.h" #include "gui/widgets/textbox.h" #include "utils/gettext.h" @@ -54,7 +55,7 @@ ItemPopup::ItemPopup(): mLastColor(1) { // Item Name - mItemName = new gcn::Label; + mItemName = new Label; mItemName->setFont(boldFont); mItemName->setPosition(getPadding(), getPadding()); diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 05a265da7..b9ce7c2a7 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -55,6 +55,7 @@ KillStats::KillStats(): setWindowName("Kill stats"); setCloseButton(true); setResizable(true); + setStickyButtonLock(true); setDefaultSize(250, 250, 350, 300); listen(Mana::CHANNEL_ATTRIBUTES); diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index c735eec82..c3a4417f6 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -29,6 +29,7 @@ #include "localplayer.h" #include "logger.h" #include "map.h" +#include "party.h" #include "gui/userpalette.h" #include "gui/setup.h" @@ -275,9 +276,10 @@ void Minimap::draw(gcn::Graphics *graphics) { type = UserPalette::GM; } - else if (being->isInParty()) + else if (being->getGuild() == player_node->getGuild() + || being->getGuildName() == player_node->getGuildName()) { - type = UserPalette::PARTY; + type = UserPalette::GUILD; } else if (being) { @@ -317,6 +319,49 @@ void Minimap::draw(gcn::Graphics *graphics) dotSize, dotSize)); } + if (player_node->isInParty()) + { + Party *party = player_node->getParty(); + if (party) + { + PartyMember *m = party->getMember(player_node->getName()); + Party::MemberList *members = party->getMembers(); + if (m && members) + { + const std::string curMap = m->getMap(); + Party::MemberList::const_iterator it = members->begin(); + const Party::MemberList::const_iterator + it_end = members->end(); + while (it != it_end) + { + PartyMember *member = *it; + if (member && member->getMap() == curMap + && member->getOnline() && member != m) + { + if (userPalette) + { + graphics->setColor(userPalette->getColor( + UserPalette::PARTY)); + } + + const int offsetHeight = static_cast<int>( + mHeightProportion); + const int offsetWidth = static_cast<int>( + mWidthProportion); + + graphics->fillRectangle(gcn::Rectangle( + static_cast<int>(member->getX() + * mWidthProportion) + mapOriginX - offsetWidth, + static_cast<int>(member->getY() + * mHeightProportion) + mapOriginY - offsetHeight, + 2, 2)); + } + ++ it; + } + } + } + } + const Vector &pos = player_node->getPosition(); // logger->log("width:" + toString(graph->getWidth())); diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 36677446d..0db618d69 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -69,6 +69,7 @@ NpcDialog::NpcDialog(int npcId) setResizable(true); //setupWindow->registerWindowForReset(this); setFocusable(true); + setStickyButtonLock(true); setMinWidth(200); setMinHeight(150); diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 09e75856f..9601e3ca5 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -32,6 +32,7 @@ #include "playerinfo.h" #include "gui/chatwindow.h" +#include "gui/theme.h" #include "gui/viewport.h" #include "gui/widgets/button.h" @@ -71,11 +72,14 @@ OutfitWindow::OutfitWindow(): setWindowName("Outfits"); setResizable(true); setCloseButton(true); + setStickyButtonLock(true); + setDefaultSize(250, 400, 150, 230); setMinWidth(145); setMinHeight(220); - addMouseListener(this); + mBorderColor = Theme::getThemeColor(Theme::BORDER, 64); + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 32); mPreviousButton = new Button(_("<"), "previous", this); mNextButton = new Button(_(">"), "next", this); @@ -303,9 +307,9 @@ void OutfitWindow::draw(gcn::Graphics *graphics) const int itemX = 10 + ((i % mGridWidth) * mBoxWidth); const int itemY = 25 + ((i / mGridWidth) * mBoxHeight); - graphics->setColor(gcn::Color(0, 0, 0, 64)); + graphics->setColor(mBorderColor); graphics->drawRectangle(gcn::Rectangle(itemX, itemY, 32, 32)); - graphics->setColor(gcn::Color(255, 255, 255, 32)); + graphics->setColor(mBackgroundColor); graphics->fillRectangle(gcn::Rectangle(itemX, itemY, 32, 32)); if (mItems[mCurrentOutfit][i] < 0) diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h index 60634dbdd..8dd5fd6a3 100644 --- a/src/gui/outfitwindow.h +++ b/src/gui/outfitwindow.h @@ -137,6 +137,8 @@ class OutfitWindow : public Window, gcn::ActionListener int mAwayOutfit; Image *mBackgroundImg; + gcn::Color mBorderColor; + gcn::Color mBackgroundColor; static float mAlpha; }; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index eefa83500..0eac0a4f9 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -27,6 +27,7 @@ #include "being.h" #include "dropshortcut.h" #include "guild.h" +#include "guildmanager.h" #include "flooritem.h" #include "graphics.h" #include "item.h" @@ -77,8 +78,6 @@ #include "utils/gettext.h" #include "utils/stringutils.h" -#include <cassert> - #include "debug.h" std::string tradePartnerName(""); @@ -224,14 +223,33 @@ void PopupMenu::showPopup(int x, int y, Being *being) { mBrowserBox->addRow(strprintf( "@@guild-kick|%s@@", _("Kick from guild"))); - mBrowserBox->addRow(strprintf("@@guild-pos|%s >@@", + if (guild2->getServerGuild()) + { + mBrowserBox->addRow(strprintf( + "@@guild-pos|%s >@@", + _("Change pos in guild"))); + } + } + } + else if (guild2->getMember(mNick)) + { + mBrowserBox->addRow(strprintf( + "@@guild-kick|%s@@", _("Kick from guild"))); + if (guild2->getServerGuild()) + { + mBrowserBox->addRow(strprintf( + "@@guild-pos|%s >@@", _("Change pos in guild"))); } } else { - mBrowserBox->addRow(strprintf( - "@@guild|%s@@", _("Invite to guild"))); + if (guild2->getServerGuild() + || (guildManager && guildManager->havePower())) + { + mBrowserBox->addRow(strprintf( + "@@guild|%s@@", _("Invite to guild"))); + } } } @@ -435,15 +453,26 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) { if (guild2->getMember(mNick)) { - mBrowserBox->addRow(strprintf( - "@@guild-kick|%s@@", _("Kick from guild"))); - mBrowserBox->addRow(strprintf( - "@@guild-pos|%s >@@", _("Change pos in guild"))); + if (guild2->getServerGuild() || (guildManager + && guildManager->havePower())) + { + mBrowserBox->addRow(strprintf( + "@@guild-kick|%s@@", _("Kick from guild"))); + } + if (guild2->getServerGuild()) + { + mBrowserBox->addRow(strprintf( + "@@guild-pos|%s >@@", _("Change pos in guild"))); + } } else { - mBrowserBox->addRow(strprintf( - "@@guild|%s@@", _("Invite to guild"))); + if (guild2->getServerGuild() || (guildManager + && guildManager->havePower())) + { + mBrowserBox->addRow(strprintf( + "@@guild|%s@@", _("Invite to guild"))); + } } } @@ -574,7 +603,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) if (tab->getRemoveNames()) { mBrowserBox->addRow(strprintf("@@dont remove name|%s@@", - _("Dont remove name"))); + _("Don't remove name"))); } else { @@ -725,16 +754,27 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) { if (guild1->getId() == guild2->getId()) { - mBrowserBox->addRow(strprintf( - "@@guild-kick|%s@@", _("Kick from guild"))); - mBrowserBox->addRow(strprintf( - "@@guild-pos|%s >@@", _("Change pos in guild"))); + if (guild2->getServerGuild() || (guildManager + && guildManager->havePower())) + { + mBrowserBox->addRow(strprintf( + "@@guild-kick|%s@@", _("Kick from guild"))); + } + if (guild2->getServerGuild()) + { + mBrowserBox->addRow(strprintf("@@guild-pos|%s >@@", + _("Change pos in guild"))); + } } } else { - mBrowserBox->addRow(strprintf( - "@@guild|%s@@", _("Invite to guild"))); + if (guild2->getServerGuild() || (guildManager + && guildManager->havePower())) + { + mBrowserBox->addRow(strprintf( + "@@guild|%s@@", _("Invite to guild"))); + } } } } @@ -897,7 +937,12 @@ void PopupMenu::handleLink(const std::string &link, { const Guild *guild = player_node->getGuild(); if (guild) - Net::getGuildHandler()->invite(guild->getId(), mNick); + { + if (guild->getServerGuild()) + Net::getGuildHandler()->invite(guild->getId(), mNick); + else if (guildManager) + guildManager->invite(mNick); + } } } else if (link == "nuke" && being) @@ -1263,7 +1308,12 @@ void PopupMenu::handleLink(const std::string &link, { const Guild *guild = player_node->getGuild(); if (guild) - Net::getGuildHandler()->kick(guild->getMember(mNick)); + { + if (guild->getServerGuild()) + Net::getGuildHandler()->kick(guild->getMember(mNick)); + else if (guildManager) + guildManager->kick(mNick); + } } } else if (link == "enable highlight" && mTab) diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index f66872b5d..04f43fb88 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -41,23 +41,17 @@ #include "utils/gettext.h" -#include <assert.h> - #include "debug.h" QuitDialog::QuitDialog(QuitDialog** pointerToMe): Window(_("Quit"), true, NULL), mMyPointer(pointerToMe) { -// int width = 200; -// int height = 120; - mForceQuit = new RadioButton(_("Quit"), "quitdialog"); mLogoutQuit = new RadioButton(_("Quit"), "quitdialog"); mSwitchAccountServer = new RadioButton(_("Switch server"), "quitdialog"); mSwitchCharacter = new RadioButton(_("Switch character"), "quitdialog"); mOkButton = new Button(_("OK"), "ok", this); mCancelButton = new Button(_("Cancel"), "cancel", this); -// setContentSize(width, height); addKeyListener(this); @@ -149,10 +143,11 @@ void QuitDialog::action(const gcn::ActionEvent &event) } else if (mSwitchCharacter->isSelected()) { - assert(Client::getState() == STATE_GAME); - - Net::getCharHandler()->switchCharacter(); - Client::closeDialogs(); + if (Client::getState() == STATE_GAME) + { + Net::getCharHandler()->switchCharacter(); + Client::closeDialogs(); + } } } scheduleDelete(); diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index cf9bfb667..d9030e3fb 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -69,6 +69,7 @@ void SellDialog::init() //setupWindow->registerWindowForReset(this); setResizable(true); setCloseButton(true); + setStickyButtonLock(true); setMinWidth(260); setMinHeight(230); setDefaultSize(260, 230, ImageRect::CENTER); diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 143d3e5a3..763c190d6 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -158,6 +158,10 @@ public: ServersListBox(ServersListModel *model): ListBox(model) { + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mTextColor = Theme::getThemeColor(Theme::TEXT); + mNotSupportedColor = Theme::getThemeColor( + Theme::SERVER_VERSION_NOT_SUPPORTED); } void draw(gcn::Graphics *graphics) @@ -169,20 +173,18 @@ public: updateAlpha(); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast<int>(mAlpha * 255.0f))); + mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); graphics->setFont(getFont()); const int height = getRowHeight(); - const gcn::Color unsupported = - Theme::getThemeColor(Theme::SERVER_VERSION_NOT_SUPPORTED, - static_cast<int>(mAlpha * 255.0f)); + mNotSupportedColor.a = static_cast<int>(mAlpha * 255.0f); // Draw filled rectangle around the selected list element if (mSelected >= 0) { - graphics->fillRectangle(gcn::Rectangle(0, height * mSelected, - getWidth(), height)); + graphics->fillRectangle(gcn::Rectangle(0, + height * mSelected, getWidth(), height)); } // Draw the list elements @@ -191,7 +193,7 @@ public: { ServerInfo info = model->getServer(i); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(mTextColor); int top; @@ -212,7 +214,7 @@ public: if (info.version.first > 0) { - graphics->setColor(unsupported); + graphics->setColor(mNotSupportedColor); graphics->drawText(info.version.second, getWidth() - info.version.first - 2, top); @@ -224,6 +226,10 @@ public: { return 2 * getFont()->getHeight(); } +private: + gcn::Color mHighlightColor; + gcn::Color mTextColor; + gcn::Color mNotSupportedColor; }; diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 690871189..76e3936c2 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -55,6 +55,7 @@ Setup::Setup(): { setCloseButton(true); setResizable(true); + setStickyButtonLock(true); int width = 620; int height = 450; diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp index 722a3f8b2..9e75b9c0a 100644 --- a/src/gui/setup_chat.cpp +++ b/src/gui/setup_chat.cpp @@ -120,6 +120,11 @@ Setup_Chat::Setup_Chat() new SetupItemCheckBox(_("Use local time"), "", "useLocalTime", this, "useLocalTimeEvent"); + new SetupItemLabel(_("Other"), "", this); + + new SetupItemTextField(_("Highlight words (separated by comma)"), "", + "highlightWords", this, "highlightWordsEvent"); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } @@ -128,5 +133,8 @@ void Setup_Chat::apply() SetupTabScroll::apply(); if (chatWindow) + { chatWindow->adjustTabSize(); + chatWindow->parseHighlights(); + } } diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp index b405f5045..1cad4c594 100644 --- a/src/gui/setup_other.cpp +++ b/src/gui/setup_other.cpp @@ -145,6 +145,15 @@ Setup_Other::Setup_Other() this, "logNpcInGuiEvent"); + new SetupItemLabel(_("Bots support"), "", this); + + new SetupItemCheckBox(_("Enable auction bot support"), "", + "enableAuctionBot", this, "enableAuctionBotEvent", false); + + new SetupItemCheckBox(_("Enable guild bot support and disable native " + "guild support"), "", "enableGuildBot", this, + "enableGuildBotEvent", false); + new SetupItemLabel(_("Other"), "", this); new SetupItemCheckBox(_("Enable server side attack"), "", diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 78c77f6f1..670fc3635 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -78,6 +78,9 @@ Setup_Players::Setup_Players() new SetupItemCheckBox(_("Show ip addresses on screenshots"), "", "showip", this, "showipEvent"); + new SetupItemCheckBox(_("Allow self heal with mouse click"), "", + "selfMouseHeal", this, "selfMouseHealEvent"); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 4311a04d2..9aaf88bf3 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -40,6 +40,7 @@ #include "gui/widgets/tradetab.h" #include "actorspritemanager.h" +#include "auctionmanager.h" #include "configuration.h" #include "confirmdialog.h" #include "inventory.h" @@ -85,6 +86,7 @@ ShopWindow::ShopWindow(): setWindowName("Personal Shop"); setResizable(true); setCloseButton(true); + setStickyButtonLock(true); setMinWidth(260); setMinHeight(230); setDefaultSize(380, 300, ImageRect::CENTER); @@ -141,6 +143,19 @@ ShopWindow::ShopWindow(): place(0, 7, mAnnounceLinks, 8); place(15, 7, mCloseButton); + if (auctionManager && auctionManager->getEnableAuctionBot()) + { + mBuyAuctionButton = new Button(_("Auction"), "auction buy", this); + mSellAuctionButton = new Button(_("Auction"), "auction sell", this); + place(4, 6, mBuyAuctionButton); + place(12, 6, mSellAuctionButton); + } + else + { + mBuyAuctionButton = 0; + mSellAuctionButton = 0; + } + Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); @@ -207,6 +222,16 @@ void ShopWindow::action(const gcn::ActionEvent &event) { announce(mSellShopItems, SELL); } + else if (event.getId() == "auction buy" && mBuyShopItems + && mBuyShopItems->getNumberOfElements() > 0) + { + Net::getChatHandler()->privateMessage("AuctionBot", "!pull4144 seek"); + } + else if (event.getId() == "auction sell" && mSellShopItems + && mSellShopItems->getNumberOfElements() > 0) + { + Net::getChatHandler()->privateMessage("AuctionBot", "!pull4144 offer"); + } if (mSelectedItem < 1) return; diff --git a/src/gui/shopwindow.h b/src/gui/shopwindow.h index e3fd9a5ca..8b170f31e 100644 --- a/src/gui/shopwindow.h +++ b/src/gui/shopwindow.h @@ -151,9 +151,11 @@ class ShopWindow : public Window, public gcn::ActionListener, gcn::Button *mBuyAddButton; gcn::Button *mBuyDeleteButton; gcn::Button *mBuyAnnounceButton; + gcn::Button *mBuyAuctionButton; gcn::Button *mSellAddButton; gcn::Button *mSellDeleteButton; gcn::Button *mSellAnnounceButton; + gcn::Button *mSellAuctionButton; gcn::CheckBox *mAnnounceLinks; ShopItems *mBuyShopItems; diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 896f06cab..bf87e804d 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -152,7 +152,9 @@ public: SkillListBox(SkillModel *model): ListBox(model), mModel(model), - mPopup(new TextPopup()) + mPopup(new TextPopup()), + mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)), + mTextColor(Theme::getThemeColor(Theme::TEXT)) { } @@ -187,8 +189,8 @@ public: Graphics *graphics = static_cast<Graphics*>(gcnGraphics); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast<int>(mAlpha * 255.0f))); + mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); graphics->setFont(getFont()); // Draw filled rectangle around the selected list element @@ -199,7 +201,7 @@ public: } // Draw the list elements - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(mTextColor); for (int i = 0, y = 1; i < model->getNumberOfElements(); ++i, y += getRowHeight()) @@ -239,6 +241,8 @@ public: private: SkillModel *mModel; TextPopup *mPopup; + gcn::Color mHighlightColor; + gcn::Color mTextColor; }; class SkillTab : public Tab @@ -275,6 +279,7 @@ SkillDialog::SkillDialog(): setCloseButton(true); setResizable(true); setSaveVisible(true); + setStickyButtonLock(true); setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425); setupWindow->registerWindowForReset(this); diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index e3aa69b30..749f26f85 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -23,6 +23,7 @@ #include "actorspritemanager.h" #include "guild.h" +#include "guildmanager.h" #include "keyboardconfig.h" #include "localplayer.h" #include "logger.h" @@ -108,10 +109,10 @@ protected: AvatarListBox *mList; }; -class GuildTab : public SocialTab, public gcn::ActionListener +class SocialGuildTab : public SocialTab, public gcn::ActionListener { public: - GuildTab(Guild *guild): + SocialGuildTab(Guild *guild): mGuild(guild) { setCaption(_("Guild")); @@ -125,7 +126,7 @@ public: mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); } - ~GuildTab() + ~SocialGuildTab() { delete mList; mList = 0; @@ -206,10 +207,113 @@ private: Guild *mGuild; }; -class PartyTab : public SocialTab, public gcn::ActionListener +class SocialGuildTab2 : public SocialTab, public gcn::ActionListener { public: - PartyTab(Party *party): + SocialGuildTab2(Guild *guild): + mGuild(guild) + { + setCaption(_("Guild")); + + setTabColor(&Theme::getThemeColor(Theme::GUILD_SOCIAL_TAB)); + + mList = new AvatarListBox(guild); + mScroll = new ScrollArea(mList); + + mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); + mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); + } + + ~SocialGuildTab2() + { + delete mList; + mList = 0; + delete mScroll; + mScroll = 0; + } + + void action(const gcn::ActionEvent &event) + { +/* + if (event.getId() == "do invite") + { + std::string name = mInviteDialog->getText(); + Net::getGuildHandler()->invite(mGuild->getId(), name); + + if (localChatTab) + { + localChatTab->chatLog(strprintf( + _("Invited user %s to guild %s."), + name.c_str(), mGuild->getName().c_str()), BY_SERVER); + } + mInviteDialog = 0; + } + else if (event.getId() == "~do invite") + { + mInviteDialog = 0; + } + else if (event.getId() == "yes") + { + Net::getGuildHandler()->leave(mGuild->getId()); + if (localChatTab) + { + localChatTab->chatLog(strprintf(_("Guild %s quit requested."), + mGuild->getName().c_str()), BY_SERVER); + } + mConfirmDialog = 0; + } + else if (event.getId() == "~yes") + { + mConfirmDialog = 0; + } +*/ + } + + void updateList() + { + } + + void updateAvatar(std::string name A_UNUSED) + { + } + + void resetDamage(std::string name A_UNUSED) + { + } + +protected: + void invite() + { +/* + mInviteDialog = new TextDialog(_("Member Invite to Guild"), + strprintf(_("Who would you like to invite to guild %s?"), + mGuild->getName().c_str()), + socialWindow); + mInviteDialog->setActionEventId("do invite"); + mInviteDialog->addActionListener(this); +*/ + } + + void leave() + { +/* + mConfirmDialog = new ConfirmDialog(_("Leave Guild?"), + strprintf(_("Are you sure you want to leave guild %s?"), + mGuild->getName().c_str()), + socialWindow); + + mConfirmDialog->addActionListener(this); +*/ + } + +private: + Guild *mGuild; +}; + +class SocialPartyTab : public SocialTab, public gcn::ActionListener +{ +public: + SocialPartyTab(Party *party): mParty(party) { setCaption(_("Party")); @@ -223,7 +327,7 @@ public: mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); } - ~PartyTab() + ~SocialPartyTab() { delete mList; mList = 0; @@ -340,10 +444,10 @@ public: std::vector<Avatar*> mMembers; }; -class PlayersTab : public SocialTab +class SocialPlayersTab : public SocialTab { public: - PlayersTab(std::string name) + SocialPlayersTab(std::string name) { mBeings = new BeingsListModal(); @@ -358,7 +462,7 @@ public: setCaption(name); } - ~PlayersTab() + ~SocialPlayersTab() { delete mList; mList = 0; @@ -505,10 +609,10 @@ private: }; -class NavigationTab : public SocialTab +class SocialNavigationTab : public SocialTab { public: - NavigationTab() + SocialNavigationTab() { mBeings = new BeingsListModal(); @@ -522,7 +626,7 @@ public: } - ~NavigationTab() + ~SocialNavigationTab() { delete mList; mList = 0; @@ -783,10 +887,10 @@ protected: }; -class AttackTab : public SocialTab +class SocialAttackTab : public SocialTab { public: - AttackTab() + SocialAttackTab() { mBeings = new BeingsListModal(); @@ -799,7 +903,7 @@ public: setCaption(_("Atk")); } - ~AttackTab() + ~SocialAttackTab() { delete mList; mList = 0; @@ -1025,6 +1129,8 @@ SocialWindow::SocialWindow() : setResizable(true); setSaveVisible(true); setCloseButton(true); + setStickyButtonLock(true); + setMinWidth(120); setMinHeight(55); setDefaultSize(590, 200, 150, 120); @@ -1046,15 +1152,15 @@ SocialWindow::SocialWindow() : loadWindowState(); - mPlayers = new PlayersTab("P"); + mPlayers = new SocialPlayersTab("P"); mTabs->addTab(mPlayers, mPlayers->mScroll); - mNavigation = new NavigationTab(); + mNavigation = new SocialNavigationTab(); mTabs->addTab(mNavigation, mNavigation->mScroll); if (config.getBoolValue("enableAttackFilter")) { - mAttackFilter = new AttackTab(); + mAttackFilter = new SocialAttackTab(); mTabs->addTab(mAttackFilter, mAttackFilter->mScroll); } else @@ -1106,9 +1212,13 @@ bool SocialWindow::addTab(Guild *guild) if (mGuilds.find(guild) != mGuilds.end()) return false; - GuildTab *tab = new GuildTab(guild); - mGuilds[guild] = tab; + SocialTab *tab = 0; + if (guild->getServerGuild()) + tab = new SocialGuildTab(guild); + else + tab = new SocialGuildTab2(guild); + mGuilds[guild] = tab; mTabs->addTab(tab, tab->mScroll); updateButtons(); @@ -1136,7 +1246,7 @@ bool SocialWindow::addTab(Party *party) if (mParties.find(party) != mParties.end()) return false; - PartyTab *tab = new PartyTab(party); + SocialPartyTab *tab = new SocialPartyTab(party); mParties[party] = tab; mTabs->addTab(tab, tab->mScroll); @@ -1203,7 +1313,10 @@ void SocialWindow::action(const gcn::ActionEvent &event) strprintf(_("Accepted guild invite from %s."), mPartyInviter.c_str())); } - Net::getGuildHandler()->inviteResponse(mGuildInvited, true); + if (!guildManager || !GuildManager::getEnableGuildBot()) + Net::getGuildHandler()->inviteResponse(mGuildInvited, true); + else + guildManager->inviteResponse(true); } else if (eventId == "no") { @@ -1213,7 +1326,10 @@ void SocialWindow::action(const gcn::ActionEvent &event) strprintf(_("Rejected guild invite from %s."), mPartyInviter.c_str())); } - Net::getGuildHandler()->inviteResponse(mGuildInvited, false); + if (!guildManager || !GuildManager::getEnableGuildBot()) + Net::getGuildHandler()->inviteResponse(mGuildInvited, false); + else + guildManager->inviteResponse(false); } mGuildInvited = 0; @@ -1449,7 +1565,7 @@ void SocialWindow::updatePortals() void SocialWindow::updatePortalNames() { if (mNavigation) - static_cast<NavigationTab*>(mNavigation)->updateNames(); + static_cast<SocialNavigationTab*>(mNavigation)->updateNames(); } void SocialWindow::selectPortal(unsigned num) @@ -1461,21 +1577,26 @@ void SocialWindow::selectPortal(unsigned num) int SocialWindow::getPortalIndex(int x, int y) { if (mNavigation) - return static_cast<NavigationTab*>(mNavigation)->getPortalIndex(x, y); + { + return static_cast<SocialNavigationTab*>( + mNavigation)->getPortalIndex(x, y); + } else + { return -1; + } } void SocialWindow::addPortal(int x, int y) { if (mNavigation) - static_cast<NavigationTab*>(mNavigation)->addPortal(x, y); + static_cast<SocialNavigationTab*>(mNavigation)->addPortal(x, y); } void SocialWindow::removePortal(int x, int y) { if (mNavigation) - static_cast<NavigationTab*>(mNavigation)->removePortal(x, y); + static_cast<SocialNavigationTab*>(mNavigation)->removePortal(x, y); } void SocialWindow::nextTab() diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index a5d95c7ff..702c31718 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -82,6 +82,7 @@ SpecialsWindow::SpecialsWindow(): setCloseButton(true); setResizable(true); setSaveVisible(true); + setStickyButtonLock(true); setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425); setupWindow->registerWindowForReset(this); diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index 86aeb2206..a918e037d 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -27,6 +27,8 @@ #include "gui/gui.h" #include "gui/palette.h" +#include "gui/widgets/label.h" + #include "textcommand.h" #include "graphics.h" @@ -36,7 +38,6 @@ #include "utils/stringutils.h" #include <guichan/font.hpp> -#include <guichan/widgets/label.hpp> #include "debug.h" @@ -44,7 +45,7 @@ SpellPopup::SpellPopup(): Popup("SpellPopup") { // Item Name - mItemName = new gcn::Label; + mItemName = new Label; mItemName->setFont(boldFont); mItemName->setPosition(getPadding(), getPadding()); diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index 08400a916..bb7a295ab 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -28,6 +28,7 @@ #include "gui/palette.h" #include "gui/viewport.h" +#include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/textbox.h" @@ -50,51 +51,51 @@ StatusPopup::StatusPopup(): const int fontHeight = getFont()->getHeight(); - mMoveType = new gcn::Label; + mMoveType = new Label; mMoveType->setPosition(getPadding(), getPadding()); - mCrazyMoveType = new gcn::Label; + mCrazyMoveType = new Label; mCrazyMoveType->setPosition(getPadding(), fontHeight + getPadding()); - mMoveToTargetType = new gcn::Label; + mMoveToTargetType = new Label; mMoveToTargetType->setPosition(getPadding(), 2 * fontHeight + getPadding()); - mFollowMode = new gcn::Label; + mFollowMode = new Label; mFollowMode->setPosition(getPadding(), 3 * fontHeight + getPadding()); - mAttackWeaponType = new gcn::Label; + mAttackWeaponType = new Label; mAttackWeaponType->setPosition(getPadding(), 4 + 4 * fontHeight + getPadding()); - mAttackType = new gcn::Label; + mAttackType = new Label; mAttackType->setPosition(getPadding(), 4 + 5 * fontHeight + getPadding()); - mMagicAttackType = new gcn::Label; + mMagicAttackType = new Label; mMagicAttackType->setPosition(getPadding(), 4 + 6 * fontHeight + getPadding()); - mDropCounter = new gcn::Label; + mDropCounter = new Label; mDropCounter->setPosition(getPadding(), 8 + 7 * fontHeight + getPadding()); - mPickUpType = new gcn::Label; + mPickUpType = new Label; mPickUpType->setPosition(getPadding(), 8 + 8 * fontHeight + getPadding()); - mMapType = new gcn::Label; + mMapType = new Label; mMapType->setPosition(getPadding(), 12 + 9 * fontHeight + getPadding()); - mImitationMode = new gcn::Label; + mImitationMode = new Label; mImitationMode->setPosition(getPadding(), 16 + 10 * fontHeight + getPadding()); - mAwayMode = new gcn::Label; + mAwayMode = new Label; mAwayMode->setPosition(getPadding(), 16 + 11 * fontHeight + getPadding()); - mCameraMode = new gcn::Label; + mCameraMode = new Label; mCameraMode->setPosition(getPadding(), 16 + 12 * fontHeight + getPadding()); - mDisableGameModifiers = new gcn::Label; + mDisableGameModifiers = new Label; mDisableGameModifiers->setPosition(getPadding(), 20 + 13 * fontHeight + getPadding()); diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index fcc324730..d1fde2dd1 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -132,6 +132,7 @@ StatusWindow::StatusWindow(): setResizable(true); setCloseButton(true); setSaveVisible(true); + setStickyButtonLock(true); setDefaultSize((windowContainer->getWidth() - 365) / 2, (windowContainer->getHeight() - 255) / 2, 365, 275); @@ -356,7 +357,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED, if (!lvl) { - // possible server broken and dont send job level, + // possible server broken and don't send job level, // then we fixing it :) if (exp.second < 20000) { @@ -372,7 +373,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED, } if (exp.first < oldExp && exp.second >= 20000) - { // possible job level up. but server broken and dont send + { // possible job level up. but server broken and don't send // new job exp limit, we fixing it lvl ++; blocked = true; @@ -889,7 +890,6 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED) col.r = 100; col.g = 100; col.b = 100; -// bar->setColor(new gcn::Color(100, 100, 100)); bar->setColor(col); } else @@ -898,7 +898,6 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED) col.r = 255; col.g = 255; col.b = 0; -// bar->setColor(new gcn::Color(255, 255, 0)); bar->setColor(col); } } diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 8cf9fa398..9d759c4a2 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -71,7 +71,7 @@ public: if (i->first < 0) continue; - ItemInfo info = (*i->second); + const ItemInfo &info = (*i->second); std::string name = info.getName(); if (name != "unnamed" && !info.getName().empty() && info.getName() != "unnamed") diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index 7f1e0e6b8..1ff601154 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -26,6 +26,9 @@ #include "gui/gui.h" #include "gui/palette.h" +#include "gui/theme.h" + +#include "gui/widgets/label.h" #include "graphics.h" #include "units.h" @@ -34,7 +37,6 @@ #include "utils/stringutils.h" #include <guichan/font.hpp> -#include <guichan/widgets/label.hpp> #include "debug.h" @@ -43,13 +45,13 @@ TextPopup::TextPopup(): { const int fontHeight = getFont()->getHeight(); - mText1 = new gcn::Label; + mText1 = new Label; mText1->setPosition(getPadding(), getPadding()); - mText2 = new gcn::Label; + mText2 = new Label; mText2->setPosition(getPadding(), fontHeight + 2 * getPadding()); - mText3 = new gcn::Label; + mText3 = new Label; mText3->setPosition(getPadding(), (2 * fontHeight) + 2 * getPadding()); add(mText1); diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 056eafc0f..0607564f9 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -599,6 +599,7 @@ static int readColorType(const std::string &type) "TEXT", "SHADOW", "OUTLINE", + "BORDER", "PROGRESS_BAR", "BUTTON", "BUTTON_DISABLED", @@ -608,11 +609,15 @@ static int readColorType(const std::string &type) "GUILD_CHAT_TAB", "GUILD_SOCIAL_TAB", "BACKGROUND", + "BACKGROUND_GRAY", + "SCROLLBAR_GRAY", + "DROPDOWN_SHADOW", "HIGHLIGHT", "TAB_FLASH", "TAB_PLAYER_FLASH", "SHOP_WARNING", "ITEM_EQUIPPED", + "ITEM_NOT_EQUIPPED", "CHAT", "GM", "PLAYER", @@ -639,7 +644,16 @@ static int readColorType(const std::string &type) "SERVER_VERSION_NOT_SUPPORTED", "WARNING", "CHARM", - "PLAYER_ADVANCED" + "PLAYER_ADVANCED", + "RED", + "GREEN", + "BLUE", + "ORANGE", + "YELLOW", + "PINK", + "PURPLE", + "GRAY", + "BROWN" }; if (type.empty()) diff --git a/src/gui/theme.h b/src/gui/theme.h index 120214232..fbc6f13da 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -143,6 +143,7 @@ class Theme : public Palette, public ConfigListener TEXT = 0, SHADOW, OUTLINE, + BORDER, PROGRESS_BAR, BUTTON, BUTTON_DISABLED, @@ -152,11 +153,15 @@ class Theme : public Palette, public ConfigListener GUILD_CHAT_TAB, GUILD_SOCIAL_TAB, BACKGROUND, + BACKGROUND_GRAY, + SCROLLBAR_GRAY, + DROPDOWN_SHADOW, HIGHLIGHT, TAB_FLASH, TAB_PLAYER_FLASH, SHOP_WARNING, ITEM_EQUIPPED, + ITEM_NOT_EQUIPPED, CHAT, GM, PLAYER, @@ -184,6 +189,15 @@ class Theme : public Palette, public ConfigListener WARNING, CHARM, PLAYER_ADVANCED, + RED, + GREEN, + BLUE, + ORANGE, + YELLOW, + PINK, + PURPLE, + GRAY, + BROWN, THEME_COLORS_END }; diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index d00fb61f4..3c19ee9c2 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -78,6 +78,7 @@ TradeWindow::TradeWindow(): setWindowName("Trade"); setResizable(true); setCloseButton(true); + setStickyButtonLock(true); setDefaultSize(386, 180, ImageRect::CENTER); setMinWidth(386); setMinHeight(180); diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index 7534b12a9..4ba1c9179 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -54,6 +54,8 @@ const std::string xmlUpdateFile = "resources.xml"; const std::string txtUpdateFile = "resources2.txt"; +const std::string updateServer2 + = "http://download.evolonline.org/manaplus/updates/"; std::vector<updateFile> loadXMLFile(const std::string &fileName); std::vector<updateFile> loadTxtFile(const std::string &fileName); @@ -137,6 +139,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, mDownloadStatus(UPDATE_NEWS), mUpdateHost(updateHost), mUpdatesDir(updatesDir), + mUpdatesDirReal(updatesDir), mCurrentFile("news.txt"), mDownloadProgress(0.0f), mCurrentChecksum(0), @@ -147,6 +150,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, mMemoryBuffer(NULL), mDownload(NULL), mUpdateIndex(0), + mUpdateIndexOffset(0), mLoadUpdates(applyUpdates), mUpdateType(updateType) { @@ -181,6 +185,9 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, setVisible(true); mCancelButton->requestFocus(); + mUpdateServerPath = mUpdateHost; + removeProtocol(mUpdateServerPath); + // Try to download the updates list download(); } @@ -539,8 +546,9 @@ void UpdaterWindow::logic() mProgressBar->setProgress(mDownloadProgress); if (mUpdateFiles.size() && mUpdateIndex <= mUpdateFiles.size()) { - mProgressBar->setText(strprintf("%d/%d", - mUpdateIndex + 1, (int)mUpdateFiles.size() + 1)); + mProgressBar->setText(strprintf("%d/%d", mUpdateIndex + + mUpdateIndexOffset + 1, (int)mUpdateFiles.size() + + (int)mTempUpdateFiles.size() + 1)); } else { @@ -582,13 +590,12 @@ void UpdaterWindow::logic() // Parse current memory buffer as news and dispose of the data loadPatch(); -/* - mCurrentFile = "news.txt"; - mStoreInMemory = true; - mDownloadStatus = UPDATE_NEWS; - download(); // download() changes mDownloadComplete to false -*/ - mDownloadStatus = UPDATE_COMPLETE; + mUpdateHost = updateServer2 + mUpdateServerPath; + mUpdatesDir += "/fix"; + mCurrentFile = xmlUpdateFile; + mStoreInMemory = false; + mDownloadStatus = UPDATE_LIST2; + download(); } break; @@ -681,7 +688,58 @@ void UpdaterWindow::logic() } } break; + case UPDATE_LIST2: + if (mDownloadComplete) + { + if (mCurrentFile == xmlUpdateFile) + { + mTempUpdateFiles = loadXMLFile( + mUpdatesDir + "/" + xmlUpdateFile); + } + mUpdateIndexOffset = mUpdateIndex; + mUpdateIndex = 0; + mStoreInMemory = false; + mDownloadStatus = UPDATE_RESOURCES2; + download(); + } + break; + case UPDATE_RESOURCES2: + if (mDownloadComplete) + { + if (mUpdateIndex < mTempUpdateFiles.size()) + { + updateFile thisFile = mTempUpdateFiles[mUpdateIndex]; + mCurrentFile = thisFile.name; + std::string checksum; + checksum = thisFile.hash; + std::stringstream ss(checksum); + ss >> std::hex >> mCurrentChecksum; + + std::ifstream temp( + (mUpdatesDir + "/" + mCurrentFile).c_str()); + + if (!temp.is_open() || !validateFile(mUpdatesDir + "/" + + mCurrentFile, mCurrentChecksum)) + { + temp.close(); + download(); + } + else + { + temp.close(); + logger->log("%s already here", mCurrentFile.c_str()); + } + mUpdateIndex++; + } + else + { + mUpdatesDir = mUpdatesDirReal; + mDownloadStatus = UPDATE_COMPLETE; + } + } + break; case UPDATE_COMPLETE: + mUpdatesDir = mUpdatesDirReal; enable(); setLabel(_("Completed")); break; diff --git a/src/gui/updaterwindow.h b/src/gui/updaterwindow.h index a1dc556d5..e9a45241f 100644 --- a/src/gui/updaterwindow.h +++ b/src/gui/updaterwindow.h @@ -146,7 +146,9 @@ private: UPDATE_COMPLETE, UPDATE_NEWS, UPDATE_RESOURCES, - UPDATE_PATCH + UPDATE_PATCH, + UPDATE_LIST2, + UPDATE_RESOURCES2 }; /** Status of the current download. */ @@ -158,6 +160,8 @@ private: /** Place where the updates are stored (absolute path). */ std::string mUpdatesDir; + std::string mUpdatesDirReal; + /** The file currently downloading. */ std::string mCurrentFile; @@ -194,9 +198,15 @@ private: /** List of files to download. */ std::vector<updateFile> mUpdateFiles; + /** List of temp files to download. */ + std::vector<updateFile> mTempUpdateFiles; + /** Index of the file to be downloaded. */ unsigned int mUpdateIndex; + /** Index offset for disaplay downloaded file. */ + unsigned int mUpdateIndexOffset; + /** Tells ~UpdaterWindow() if it should load updates */ bool mLoadUpdates; @@ -208,6 +218,7 @@ private: ProgressBar *mProgressBar; /**< Update progress bar. */ BrowserBox *mBrowserBox; /**< Box to display news. */ ScrollArea *mScrollArea; /**< Used to scroll news box. */ + std::string mUpdateServerPath; }; #endif diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 70d02b016..b6e09c011 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -79,10 +79,12 @@ Viewport::Viewport(): mScrollCenterOffsetX = config.getIntValue("ScrollCenterOffsetX"); mScrollCenterOffsetY = config.getIntValue("ScrollCenterOffsetY"); mShowBeingPopup = config.getBoolValue("showBeingPopup"); + mSelfMouseHeal = config.getBoolValue("selfMouseHeal"); config.addListener("ScrollLaziness", this); config.addListener("ScrollRadius", this); config.addListener("showBeingPopup", this); + config.addListener("selfMouseHeal", this); mPopupMenu = new PopupMenu; mBeingPopup = new BeingPopup; @@ -96,6 +98,7 @@ Viewport::~Viewport() config.removeListener("ScrollLaziness", this); config.removeListener("ScrollRadius", this); config.removeListener("showBeingPopup", this); + config.removeListener("selfMouseHeal", this); delete mPopupMenu; mPopupMenu = 0; @@ -145,8 +148,10 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) if (mScrollLaziness < 1) mScrollLaziness = 1; // Avoids division by zero + int cnt = 0; + // Apply lazy scrolling - while (lastTick < tick_time) + while (lastTick < tick_time && cnt < 32) { if (player_x > static_cast<int>(mPixelViewX) + mScrollRadius) { @@ -172,17 +177,29 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) - static_cast<int>(mPixelViewY) + mScrollRadius) / static_cast<float>(mScrollLaziness); } - lastTick++; + lastTick ++; + cnt ++; } // Auto center when player is off screen - if (player_x - static_cast<int>(mPixelViewX) > graphics->mWidth / 2 - || static_cast<int>(mPixelViewX) - player_x > graphics->mWidth / 2 - || static_cast<int>(mPixelViewY) - player_y - > graphics->getHeight() / 2 - || player_y - static_cast<int>(mPixelViewY) - > graphics->getHeight() / 2) + if (cnt > 30 || player_x - static_cast<int>(mPixelViewX) + > graphics->mWidth / 2 || static_cast<int>(mPixelViewX) + - player_x > graphics->mWidth / 2 || static_cast<int>(mPixelViewY) + - player_y > graphics->getHeight() / 2 || player_y + - static_cast<int>(mPixelViewY) > graphics->getHeight() / 2) { + if (player_x <= 0 || player_y <= 0) + { + if (debugChatTab) + debugChatTab->chatLog("incorrect player position!"); + logger->log("incorrect player position: %d, %d, %d, %d", + player_x, player_y, (int)mPixelViewX, (int)mPixelViewY); + if (player_node) + { + logger->log("tile position: %d, %d", + player_node->getTileX(), player_node->getTileY()); + } + } mPixelViewX = static_cast<float>(player_x); mPixelViewY = static_cast<float>(player_y); }; @@ -459,17 +476,24 @@ void Viewport::mousePressed(gcn::MouseEvent &event) if (mHoverBeing->getType() == ActorSprite::PLAYER) { if (actorSpriteManager) - actorSpriteManager->heal(player_node, mHoverBeing); + { + if (player_node != mHoverBeing || mSelfMouseHeal) + actorSpriteManager->heal(player_node, mHoverBeing); + } } else if (player_node->withinAttackRange(mHoverBeing) || keyboard.isKeyActive(keyboard.KEY_ATTACK)) { - player_node->attack(mHoverBeing, - !keyboard.isKeyActive(keyboard.KEY_TARGET)); + if (player_node != mHoverBeing) + { + player_node->attack(mHoverBeing, + !keyboard.isKeyActive(keyboard.KEY_TARGET)); + } } else if (!keyboard.isKeyActive(keyboard.KEY_ATTACK)) { - player_node->setGotoTarget(mHoverBeing); + if (player_node != mHoverBeing) + player_node->setGotoTarget(mHoverBeing); } } // Picks up a item if we clicked on one diff --git a/src/gui/viewport.h b/src/gui/viewport.h index d6ee54834..50c81aff4 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -285,6 +285,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, int mScrollRadius; int mScrollLaziness; bool mShowBeingPopup; + bool mSelfMouseHeal; int mScrollCenterOffsetX; int mScrollCenterOffsetY; int mMouseX; /**< Current mouse position in pixels. */ diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 99da53c66..1e9f686e4 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -97,6 +97,7 @@ WhoIsOnline::WhoIsOnline(): // setContentSize(w, h); setCloseButton(true); setResizable(true); + setStickyButtonLock(true); mUpdateButton = new Button(_("Update"), "update", this); mUpdateButton->setEnabled(false); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 0d35ad188..d4764cba5 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -66,6 +66,9 @@ AvatarListBox::AvatarListBox(AvatarListModel *model): config.addListener("showgender", this); config.addListener("showlevel", this); + + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } AvatarListBox::~AvatarListBox() @@ -102,8 +105,8 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) Graphics *graphics = static_cast<Graphics*>(gcnGraphics); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast<int>(mAlpha * 255.0f))); + mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); graphics->setFont(getFont()); const int fontHeight = getFont()->getHeight(); @@ -113,7 +116,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) const std::string name = player_node->getName(); // Draw the list elements - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); for (int i = 0, y = 0; i < model->getNumberOfElements(); ++i, y += fontHeight) @@ -206,7 +209,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) if (a->getLevel() > 1) { - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); int minHp = 40 + ((a->getLevel() - 1) * 5); if (minHp < 0) minHp = 40; @@ -283,7 +286,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) } } - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); // Draw Name if (a->getType() == MapItem::SEPARATOR) diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index 2fe1dfe3d..afb4abdf5 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -62,6 +62,7 @@ public: private: bool mShowGender; bool mShowLevel; + gcn::Color mHighlightColor; static int instances; static Image *onlineIcon; diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 7df70bd04..65a25363d 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -64,6 +64,19 @@ BrowserBox::BrowserBox(unsigned int mode, bool opaque): { setFocusable(true); addMouseListener(this); + + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND); + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mHyperLinkColor = Theme::getThemeColor(Theme::HYPERLINK); + mColors[RED] = Theme::getThemeColor(Theme::RED); + mColors[GREEN] = Theme::getThemeColor(Theme::GREEN); + mColors[BLUE] = Theme::getThemeColor(Theme::BLUE); + mColors[ORANGE] = Theme::getThemeColor(Theme::ORANGE); + mColors[YELLOW] = Theme::getThemeColor(Theme::YELLOW); + mColors[PINK] = Theme::getThemeColor(Theme::PINK); + mColors[PURPLE] = Theme::getThemeColor(Theme::PURPLE); + mColors[GRAY] = Theme::getThemeColor(Theme::GRAY); + mColors[BROWN] = Theme::getThemeColor(Theme::BROWN); } BrowserBox::~BrowserBox() @@ -310,7 +323,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) if (mOpaque) { - graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND)); + graphics->setColor(mBackgroundColor); graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } @@ -319,7 +332,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) { if ((mHighMode & BACKGROUND)) { - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT)); + graphics->setColor(mHighlightColor); graphics->fillRectangle(gcn::Rectangle( mLinks[mSelectedLink].x1, mLinks[mSelectedLink].y1, @@ -330,7 +343,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) if ((mHighMode & UNDERLINE)) { - graphics->setColor(Theme::getThemeColor(Theme::HYPERLINK)); + graphics->setColor(mHyperLinkColor); graphics->drawLine( mLinks[mSelectedLink].x1, mLinks[mSelectedLink].y2, @@ -474,15 +487,15 @@ int BrowserBox::calcHeight() switch (c) { - case '1': selColor = RED; break; - case '2': selColor = GREEN; break; - case '3': selColor = BLUE; break; - case '4': selColor = ORANGE; break; - case '5': selColor = YELLOW; break; - case '6': selColor = PINK; break; - case '7': selColor = PURPLE; break; - case '8': selColor = GRAY; break; - case '9': selColor = BROWN; break; + case '1': selColor = mColors[RED]; break; + case '2': selColor = mColors[GREEN]; break; + case '3': selColor = mColors[BLUE]; break; + case '4': selColor = mColors[ORANGE]; break; + case '5': selColor = mColors[YELLOW]; break; + case '6': selColor = mColors[PINK]; break; + case '7': selColor = mColors[PURPLE]; break; + case '8': selColor = mColors[GRAY]; break; + case '9': selColor = mColors[BROWN]; break; case '0': default: selColor = textColor; diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 6fdb40042..cd69ce56f 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -147,27 +147,18 @@ class BrowserBox : public gcn::Widget, AUTO_WRAP /**< Maybe it needs a fix or to be redone. */ }; - /** - * BrowserBox colors. - * - * NOTES (by Javila): - * - color values is "0x" prefix followed by HTML color style. - * - we can add up to 10 different colors: [0..9]. - * - not all colors will be fine with all backgrounds due transparent - * windows and widgets. So, I think it's better keep BrowserBox - * opaque (white background) by default. - */ enum { - RED = 0xff0000, /**< Color 1 */ - GREEN = 0x009000, /**< Color 2 */ - BLUE = 0x0000ff, /**< Color 3 */ - ORANGE = 0xe0980e, /**< Color 4 */ - YELLOW = 0xf1dc27, /**< Color 5 */ - PINK = 0xff00d8, /**< Color 6 */ - PURPLE = 0x8415e2, /**< Color 7 */ - GRAY = 0x919191, /**< Color 8 */ - BROWN = 0x8e4c17 /**< Color 9 */ + RED = 0, + GREEN = 1, + BLUE = 2, + ORANGE = 3, + YELLOW = 4, + PINK = 5, + PURPLE = 6, + GRAY = 7, + BROWN = 8, + COLORS_MAX = 9 }; /** @@ -225,6 +216,11 @@ class BrowserBox : public gcn::Widget, bool mAlwaysUpdate; bool mProcessVersion; bool mEnableImages; + + gcn::Color mBackgroundColor; + gcn::Color mHighlightColor; + gcn::Color mHyperLinkColor; + gcn::Color mColors[COLORS_MAX]; }; #endif diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 2d9678a53..7c46ae9df 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -135,6 +135,9 @@ void Button::init() } updateAlpha(); } + mEnabledColor = Theme::getThemeColor(Theme::BUTTON); + mDisabledColor = Theme::getThemeColor(Theme::BUTTON_DISABLED); + mInstances++; } @@ -202,7 +205,7 @@ void Button::draw(gcn::Graphics *graphics) } else { - // because we dont know where parent windows was moved, + // because we don't know where parent windows was moved, // need recalc vertexes gcn::ClipRectangle &rect = static_cast<Graphics*>( graphics)->getTopClip(); @@ -238,9 +241,9 @@ void Button::draw(gcn::Graphics *graphics) // drawImageRect(0, 0, getWidth(), getHeight(), button[mode]); if (mode == BUTTON_DISABLED) - graphics->setColor(Theme::getThemeColor(Theme::BUTTON_DISABLED)); + graphics->setColor(mDisabledColor); else - graphics->setColor(Theme::getThemeColor(Theme::BUTTON)); + graphics->setColor(mEnabledColor); int textX; int textY = getHeight() / 2 - getFont()->getHeight() / 2; diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 8c43b6ddd..1b62179b3 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -101,6 +101,8 @@ class Button : public gcn::Button, public gcn::WidgetListener int mMode; int mXOffset; int mYOffset; + gcn::Color mEnabledColor; + gcn::Color mDisabledColor; }; #endif diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 785bdd6be..81c0d277f 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -283,9 +283,7 @@ void ChatTab::chatLog(std::string line, Own own, { if (player_node) { - std::string::size_type pos - = tmp.text.find(player_node->getName()); - if (pos != std::string::npos) + if (chatWindow && chatWindow->findHighlight(tmp.text)) setFlash(2); else setFlash(1); diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 61e5d9118..65d26e196 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -86,6 +86,8 @@ CheckBox::CheckBox(const std::string &caption, bool selected, if (listener) addActionListener(listener); + + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } CheckBox::~CheckBox() @@ -114,7 +116,7 @@ void CheckBox::draw(gcn::Graphics* graphics) drawBox(graphics); graphics->setFont(getFont()); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); const int h = getHeight() + getHeight() / 2; diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index 96cea7119..558257507 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -37,7 +37,7 @@ Container::~Container() bool Container::safeRemove(gcn::Widget* widget) { - WidgetListIterator iter; + WidgetListConstIterator iter; for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter) { if (*iter == widget) diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index 1d8872477..c011b8925 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -26,6 +26,10 @@ #include <guichan/widget.hpp> #include <guichan/widgets/container.hpp> +#if !defined USE_INTERNALGUICHAN +typedef std::list<gcn::Widget *>::const_iterator WidgetListConstIterator; +#endif + /** * A widget container. * diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index cfb757638..46240f76d 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -53,8 +53,12 @@ Desktop::Desktop() : mVersionLabel = new Label(strprintf("%s (Mana %s)", appName.c_str(), FULL_VERSION)); - mVersionLabel->setBackgroundColor(gcn::Color(255, 255, 255, 128)); + mVersionLabel->setBackgroundColor( + Theme::getThemeColor(Theme::BACKGROUND, 128)); add(mVersionLabel, 25, 2); + + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 128); + mBackgroundGrayColor = Theme::getThemeColor(Theme::BACKGROUND_GRAY); } Desktop::~Desktop() @@ -84,8 +88,7 @@ void Desktop::draw(gcn::Graphics *graphics) if (!mWallpaper || (getWidth() > mWallpaper->getWidth() || getHeight() > mWallpaper->getHeight())) { - // TODO: Color from palette - g->setColor(gcn::Color(64, 64, 64)); + g->setColor(mBackgroundGrayColor); g->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } @@ -106,7 +109,7 @@ void Desktop::draw(gcn::Graphics *graphics) } // Draw a thin border under the application version... - g->setColor(gcn::Color(255, 255, 255, 128)); + g->setColor(mBackgroundColor); g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension())); Container::draw(graphics); diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index 962cc3c01..6364ecfe9 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -68,6 +68,8 @@ class Desktop : public Container, gcn::WidgetListener Image *mWallpaper; gcn::Label *mVersionLabel; + gcn::Color mBackgroundColor; + gcn::Color mBackgroundGrayColor; }; #endif // DESKTOP_H diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 681d7736e..f01d3fb55 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -101,6 +101,10 @@ DropDown::DropDown(gcn::ListModel *listModel): } instances++; + + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mShadowColor = Theme::getThemeColor(Theme::DROPDOWN_SHADOW); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } DropDown::~DropDown() @@ -163,25 +167,20 @@ void DropDown::draw(gcn::Graphics* graphics) updateAlpha(); const int alpha = static_cast<int>(mAlpha * 255.0f); - gcn::Color faceColor = getBaseColor(); - faceColor.a = alpha; - const gcn::Color *highlightColor = &Theme::getThemeColor(Theme::HIGHLIGHT, - alpha); - gcn::Color shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; + mHighlightColor.a = alpha; + mShadowColor.a = alpha; if (mListBox->getListModel() && mListBox->getSelected() >= 0) { graphics->setFont(getFont()); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); graphics->drawText(mListBox->getListModel()->getElementAt( mListBox->getSelected()), 1, 0); } if (isFocused()) { - if (highlightColor) - graphics->setColor(*highlightColor); + graphics->setColor(mHighlightColor); graphics->drawRectangle(gcn::Rectangle(0, 0, getWidth() - h, h)); } @@ -193,10 +192,9 @@ void DropDown::draw(gcn::Graphics* graphics) // Draw two lines separating the ListBox with selected // element view. - if (highlightColor) - graphics->setColor(*highlightColor); + graphics->setColor(mHighlightColor); graphics->drawLine(0, h, getWidth(), h); - graphics->setColor(shadowColor); + graphics->setColor(mShadowColor); graphics->drawLine(0, h + 1, getWidth(), h + 1); } } diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index d85c3166c..6a22ba497 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -87,6 +87,9 @@ class DropDown : public gcn::DropDown */ void drawButton(gcn::Graphics *graphics); + gcn::Color mShadowColor; + gcn::Color mHighlightColor; + // Add own Images. static int instances; static Image *buttons[2][2]; diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 92f02c78f..b628cf2d4 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -73,6 +73,8 @@ DropShortcutContainer::DropShortcutContainer(): mBoxHeight = 1; mBoxWidth = 1; } + mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED); + mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED); } DropShortcutContainer::~DropShortcutContainer() @@ -110,12 +112,6 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) if (mBackgroundImg) g->drawImage(mBackgroundImg, itemX, itemY); -/* // Draw item keyboard shortcut. - const char *key = SDL_GetKeyName( - (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_1 + i)); - graphics->setColor(guiPalette->getColor(Palette::TEXT)); - g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT); -*/ if (dropShortcut->getItem(i) < 0) continue; @@ -142,11 +138,11 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) image->setAlpha(1.0f); g->drawImage(image, itemX, itemY); if (item->isEquipped()) - g->setColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)); + g->setColor(mEquipedColor); else - g->setColor(Theme::getThemeColor(Theme::TEXT)); + g->setColor(mUnEquipedColor); g->drawText(caption, itemX + mBoxWidth / 2, - itemY + mBoxHeight - 14, gcn::Graphics::CENTER); + itemY + mBoxHeight - 14, gcn::Graphics::CENTER); } } } diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index 723b215cf..b2d63a7dd 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -84,6 +84,8 @@ class DropShortcutContainer : public ShortcutContainer Item *mItemMoved; ItemPopup *mItemPopup; + gcn::Color mEquipedColor; + gcn::Color mUnEquipedColor; }; #endif diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 5bb972adc..5aced193f 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -80,6 +80,7 @@ EmoteShortcutContainer::EmoteShortcutContainer(): mBoxHeight = 1; mBoxWidth = 1; } + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } EmoteShortcutContainer::~EmoteShortcutContainer() @@ -118,20 +119,9 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) std::string key = keyboard.getKeyValueString( keyboard.KEY_EMOTE_1 + i); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT); -/* - if (emoteShortcut->getEmote(i) - && static_cast<unsigned>(emoteShortcut->getEmote(i)) - 1 - < mEmoteImg.size() - && mEmoteImg[emoteShortcut->getEmote(i) - 1]) - { - mEmoteImg[emoteShortcut->getEmote(i) - 1]->draw(g, emoteX + 2, - emoteY + 10); - } -*/ - if (i < mEmoteImg.size() && mEmoteImg[i] && mEmoteImg[i]->sprite) mEmoteImg[i]->sprite->draw(g, emoteX + 2, emoteY + 10); } diff --git a/src/gui/widgets/guildchattab.cpp b/src/gui/widgets/guildchattab.cpp new file mode 100644 index 000000000..0353ac23f --- /dev/null +++ b/src/gui/widgets/guildchattab.cpp @@ -0,0 +1,128 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "gui/widgets/guildchattab.h" + +#include "chatlogger.h" +#include "commandhandler.h" +#include "guild.h" +#include "guildmanager.h" +#include "localplayer.h" + +#include "gui/theme.h" + +#include "resources/iteminfo.h" +#include "resources/itemdb.h" + +#include "utils/dtor.h" +#include "utils/gettext.h" +#include "utils/stringutils.h" + +#include "debug.h" + +GuildChatTab::GuildChatTab() : + ChatTab(_("Guild")) +{ + setTabColor(&Theme::getThemeColor(Theme::GUILD_CHAT_TAB)); +} + +GuildChatTab::~GuildChatTab() +{ +} + +bool GuildChatTab::handleCommand(const std::string &type, + const std::string &args) +{ + if (type == "help") + { + if (args == "invite") + { + chatLog(_("Command: /invite <nick>")); + chatLog(_("This command invites <nick> to the guild you're in.")); + chatLog(_("If the <nick> has spaces in it, enclose it in " + "double quotes (\").")); + } + else if (args == "leave") + { + chatLog(_("Command: /leave")); + chatLog(_("This command causes the player to leave the guild.")); + } + else + return false; + } + else if (type == "invite" && guildManager) + { + guildManager->invite(args); + } + else if (type == "leave" && guildManager) + { + guildManager->leave(); + } + else if (type == "kick" && guildManager) + { + guildManager->kick(args); + } + else if (type == "notice" && guildManager) + { + guildManager->notice(args); + } + else + { + return false; + } + + return true; +} + +void GuildChatTab::handleInput(const std::string &msg) +{ + if (!guildManager) + return; + + if (chatWindow) + guildManager->chat(chatWindow->doReplace(msg)); + else + guildManager->chat(msg); +} + +void GuildChatTab::showHelp() +{ + chatLog(_("/help > Display this help.")); + chatLog(_("/invite > Invite a player to your guild")); + chatLog(_("/leave > Leave the guild you are in")); + chatLog(_("/kick > Kick some one from the guild you are in")); +} + +void GuildChatTab::getAutoCompleteList(std::vector<std::string> &names) const +{ + if (!guildManager) + return; + + guildManager->getNames(names); + names.push_back("/notice "); +} + +void GuildChatTab::saveToLogFile(std::string &msg) +{ + if (chatLogger) + chatLogger->log("#Guild", msg); +} diff --git a/src/gui/widgets/guildchattab.h b/src/gui/widgets/guildchattab.h new file mode 100644 index 000000000..4f5ee3a8e --- /dev/null +++ b/src/gui/widgets/guildchattab.h @@ -0,0 +1,52 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GUI_GUILDTAB_H +#define GUI_GUILDTAB_H + +#include "gui/widgets/chattab.h" + +/** + * A tab for a guild chat channel. + */ +class GuildChatTab : public ChatTab +{ + public: + GuildChatTab(); + + ~GuildChatTab(); + + bool handleCommand(const std::string &type, const std::string &args); + + void showHelp(); + + void saveToLogFile(std::string &msg); + + int getType() const { return ChatTab::TAB_GUILD; } + + protected: + void handleInput(const std::string &msg); + + void getAutoCompleteList(std::vector<std::string> &names) const; +}; + +#endif diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index e25e0bb8c..e02eda88c 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -88,17 +88,17 @@ void GuiTableActionListener::action(const gcn::ActionEvent } -GuiTable::GuiTable(TableModel *initial_model, gcn::Color background, - bool opacity) : +GuiTable::GuiTable(TableModel *initial_model, bool opacity) : mLinewiseMode(false), mWrappingEnabled(false), mOpaque(opacity), - mBackgroundColor(background), mModel(NULL), mSelectedRow(0), mSelectedColumn(0), mTopWidget(NULL) { + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND); + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); setModel(initial_model); setFocusable(true); @@ -292,8 +292,8 @@ void GuiTable::draw(gcn::Graphics* graphics) if (mOpaque) { - graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND, - static_cast<int>(mAlpha * 255.0f))); + mBackgroundColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mBackgroundColor); graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } @@ -304,7 +304,7 @@ void GuiTable::draw(gcn::Graphics* graphics) first_row = 0; unsigned rows_nr = 1 + (getHeight() / getRowHeight()); // May overestimate - // by one. + // by one. unsigned max_rows_nr; if (mModel->getRows() < first_row) @@ -343,8 +343,8 @@ void GuiTable::draw(gcn::Graphics* graphics) widget->setDimension(bounds); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast<int>(mAlpha * 255.0f))); + mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); if (mSelectedRow > 0) { diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index c4fab6a0d..d248c4820 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -58,7 +58,6 @@ class GuiTable : public gcn::Widget, public: GuiTable(TableModel * initial_model = NULL, - gcn::Color background = 0xffffff, bool opacity = true); virtual ~GuiTable(); @@ -190,6 +189,8 @@ private: /** Vector for compactness; used as a list in practice. */ std::vector<GuiTableActionListener *> mActionListeners; + + gcn::Color mHighlightColor; }; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index b79f26226..91b674018 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -118,6 +118,9 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): if (!mSelImg) logger->log1("Error: Unable to load selection.png"); + mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED); + mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED); + addKeyListener(this); addMouseListener(this); addWidgetListener(this); @@ -204,15 +207,16 @@ void ItemContainer::draw(gcn::Graphics *graphics) caption = "Eq."; if (item->isEquipped()) - g->setColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)); + g->setColor(mEquipedColor); else - g->setColor(gcn::Color(0, 0, 0)); + g->setColor(mUnEquipedColor); g->drawText(caption, itemX + BOX_WIDTH / 2, itemY + BOX_HEIGHT - 14, gcn::Graphics::CENTER); } } +/* // Draw an orange box around the selected item if (isFocused() && mHighlightedIndex != -1 && mGridColumns) { @@ -221,6 +225,7 @@ void ItemContainer::draw(gcn::Graphics *graphics) g->setColor(gcn::Color(255, 128, 0)); g->drawRectangle(gcn::Rectangle(itemX, itemY, BOX_WIDTH, BOX_HEIGHT)); } +*/ } void ItemContainer::selectNone() diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 5fd897a29..df7de63ee 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -202,6 +202,8 @@ class ItemContainer : public gcn::Widget, typedef SelectionListenerList::iterator SelectionListenerIterator; SelectionListenerList mSelectionListeners; + gcn::Color mEquipedColor; + gcn::Color mUnEquipedColor; }; #endif diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 328d5ae4d..79685fe45 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -77,6 +77,9 @@ ItemShortcutContainer::ItemShortcutContainer(unsigned number): mBoxHeight = 1; mBoxWidth = 1; } + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); + mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED); + mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED); } ItemShortcutContainer::~ItemShortcutContainer() @@ -119,7 +122,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) // Draw item keyboard shortcut. std::string key = keyboard.getKeyValueString( keyboard.KEY_SHORTCUT_1 + i); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT); @@ -154,14 +157,9 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) image->setAlpha(1.0f); g->drawImage(image, itemX, itemY); if (item->isEquipped()) - { - g->setColor(Theme::getThemeColor( - Theme::ITEM_EQUIPPED)); - } + g->setColor(mEquipedColor); else - { - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); - } + g->setColor(mUnEquipedColor); g->drawText(caption, itemX + mBoxWidth / 2, itemY + mBoxHeight - 14, gcn::Graphics::CENTER); } diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index 7eac431ec..e6b32c6f8 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -88,7 +88,8 @@ class ItemShortcutContainer : public ShortcutContainer ItemPopup *mItemPopup; SpellPopup *mSpellPopup; + gcn::Color mEquipedColor; + gcn::Color mUnEquipedColor; }; -//extern SpellManager *spellManager; #endif diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 16b813dd5..67e8bd12b 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -26,6 +26,7 @@ Label::Label() { + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } Label::Label(const std::string &caption) : diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index 382d169dc..a14b416ce 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -68,7 +68,9 @@ LayoutArray &LayoutCell::getArray() void LayoutCell::reflow(int nx, int ny, int nw, int nh) { - assert(mType != NONE); + if (mType == NONE) + return; + nx += mHPadding; ny += mVPadding; nw -= 2 * mHPadding; @@ -81,7 +83,8 @@ void LayoutCell::reflow(int nx, int ny, int nw, int nh) void LayoutCell::computeSizes() { - assert(mType == ARRAY); + if (mType != ARRAY) + return; std::vector< std::vector< LayoutCell * > >::iterator i = mArray->mCells.begin(); diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index de8707406..53299ca46 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -41,6 +41,8 @@ float ListBox::mAlpha = 1.0; ListBox::ListBox(gcn::ListModel *listModel): gcn::ListBox(listModel) { + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } ListBox::~ListBox() @@ -63,8 +65,8 @@ void ListBox::draw(gcn::Graphics *graphics) updateAlpha(); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast<int>(mAlpha * 255.0f))); + mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); graphics->setFont(getFont()); const int height = getRowHeight(); @@ -77,7 +79,7 @@ void ListBox::draw(gcn::Graphics *graphics) } // Draw the list elements - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); ++i, y += height) { diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 5f8c20059..418b83f58 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -73,6 +73,7 @@ class ListBox : public gcn::ListBox void mouseDragged(gcn::MouseEvent &event); protected: + gcn::Color mHighlightColor; static float mAlpha; }; diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index a82ec3e8d..e641be323 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -46,6 +46,7 @@ RadioButton::RadioButton(const std::string &caption, const std::string &group, gcn::RadioButton(caption, group, marked), mHasMouse(false) { + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); if (instances == 0) { radioNormal = Theme::getImageFromTheme("radioout.png"); diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 08f0b5a70..2796d3ab2 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -73,7 +73,6 @@ ScrollArea::ScrollArea(gcn::Widget *widget): mDrawWidth(0), mDrawHeight(0) { -// addWidgetListener(this); init(); } @@ -219,6 +218,9 @@ void ScrollArea::init() } instances++; + + mGray = Theme::getThemeColor(Theme::SCROLLBAR_GRAY, 32); + mBackground = Theme::getThemeColor(Theme::BACKGROUND); } void ScrollArea::logic() @@ -336,7 +338,7 @@ void ScrollArea::drawFrame(gcn::Graphics *graphics) } else { - // because we dont know where parent windows was moved, + // because we don't know where parent windows was moved, // need recalc vertexes gcn::ClipRectangle &rect = static_cast<Graphics*>( graphics)->getTopClip(); @@ -439,17 +441,17 @@ void ScrollArea::drawRightButton(gcn::Graphics *graphics) void ScrollArea::drawVBar(gcn::Graphics *graphics) { const gcn::Rectangle dim = getVerticalBarDimension(); - graphics->setColor(gcn::Color(0, 0, 0, 32)); + graphics->setColor(mGray); graphics->fillRectangle(dim); - graphics->setColor(gcn::Color(255, 255, 255)); + graphics->setColor(mBackground); } void ScrollArea::drawHBar(gcn::Graphics *graphics) { const gcn::Rectangle dim = getHorizontalBarDimension(); - graphics->setColor(gcn::Color(0, 0, 0, 32)); + graphics->setColor(mGray); graphics->fillRectangle(dim); - graphics->setColor(gcn::Color(255, 255, 255)); + graphics->setColor(mBackground); } void ScrollArea::drawVMarker(gcn::Graphics *graphics) diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 440fcec15..095010f3c 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -156,6 +156,9 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener int mYOffset; int mDrawWidth; int mDrawHeight; + + gcn::Color mGray; + gcn::Color mBackground; }; #endif diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 2fe28181b..793491808 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -50,9 +50,7 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel): mShopItems(0) { mRowHeight = getFont()->getHeight(); - mPriceCheck = true; - - mItemPopup = new ItemPopup; + init(); } ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel): @@ -61,9 +59,17 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel): mShopItems(shopListModel) { mRowHeight = std::max(getFont()->getHeight(), ITEM_ICON_SIZE); - mPriceCheck = true; + init(); +} +void ShopListBox::init() +{ + mPriceCheck = true; mItemPopup = new ItemPopup; + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND); + mWarningColor = Theme::getThemeColor(Theme::SHOP_WARNING); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } void ShopListBox::setPlayersMoney(int money) @@ -80,8 +86,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) mAlpha = Client::getGuiAlpha(); int alpha = static_cast<int>(mAlpha * 255.0f); - const gcn::Color* highlightColor = - &Theme::getThemeColor(Theme::HIGHLIGHT, alpha); + mHighlightColor.a = alpha; Graphics *graphics = static_cast<Graphics*>(gcnGraphics); @@ -93,29 +98,30 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) ++i, y += mRowHeight) { gcn::Color temp; - const gcn::Color* backgroundColor = - &Theme::getThemeColor(Theme::BACKGROUND, alpha); + gcn::Color* backgroundColor = &mBackgroundColor; + mBackgroundColor.a = alpha; if (mShopItems && mShopItems->at(i) && mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck) { if (i != mSelected) { - backgroundColor = &Theme::getThemeColor(Theme::SHOP_WARNING, - alpha); + backgroundColor = &mWarningColor; + backgroundColor->a = alpha; } else { - temp = Theme::getThemeColor(Theme::SHOP_WARNING, alpha); - temp.r = (temp.r + highlightColor->r) / 2; - temp.g = (temp.g + highlightColor->g) / 2; - temp.b = (temp.g + highlightColor->b) / 2; + temp = mWarningColor; + temp.r = (temp.r + mHighlightColor.r) / 2; + temp.g = (temp.g + mHighlightColor.g) / 2; + temp.b = (temp.g + mHighlightColor.b) / 2; + temp.a = alpha; backgroundColor = &temp; } } else if (i == mSelected) { - backgroundColor = highlightColor; + backgroundColor = &mHighlightColor; } graphics->setColor(*backgroundColor); @@ -130,9 +136,9 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) graphics->drawImage(icon, 1, y); } } - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); graphics->drawText(mListModel->getElementAt(i), ITEM_ICON_SIZE + 5, - y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2); + y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2); } } diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index 917f46729..38e238f20 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -85,6 +85,8 @@ class ShopListBox : public ListBox void mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED); private: + void init(); + int mPlayerMoney; /** @@ -100,6 +102,10 @@ class ShopListBox : public ListBox static float mAlpha; bool mPriceCheck; + + gcn::Color mHighlightColor; + gcn::Color mBackgroundColor; + gcn::Color mWarningColor; }; #endif // SHOPLISTBOX_H diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 8d5b563bb..8abe727b5 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -81,6 +81,7 @@ SpellShortcutContainer::SpellShortcutContainer(unsigned number): mBoxHeight = 1; mBoxWidth = 1; } + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } SpellShortcutContainer::~SpellShortcutContainer() @@ -106,11 +107,10 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics) Graphics *g = static_cast<Graphics*>(graphics); - graphics->setColor(gcn::Color(0, 0, 0, 255)); graphics->setFont(getFont()); int selectedId = spellShortcut->getSelectedItem(); - g->setColor(Theme::getThemeColor(Theme::TEXT)); + g->setColor(getForegroundColor()); for (unsigned i = 0; i < mMaxItems; i++) { diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index b7d6b4458..530f1ac82 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -77,6 +77,8 @@ Tab::Tab() : gcn::Tab(), mMode(0) { init(); + mFlashColor = Theme::getThemeColor(Theme::TAB_FLASH); + mPlayerFlashColor = Theme::getThemeColor(Theme::TAB_PLAYER_FLASH); } Tab::~Tab() @@ -177,12 +179,10 @@ void Tab::draw(gcn::Graphics *graphics) switch (mFlash) { case 1: - mLabel->setForegroundColor(Theme::getThemeColor( - Theme::TAB_FLASH)); + mLabel->setForegroundColor(mFlashColor); break; case 2: - mLabel->setForegroundColor(Theme::getThemeColor( - Theme::TAB_PLAYER_FLASH)); + mLabel->setForegroundColor(mPlayerFlashColor); break; default: break; diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 5847bd505..ba51e6c74 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -91,6 +91,8 @@ class Tab : public gcn::Tab, public gcn::WidgetListener GraphicsVertexes *mVertexes; bool mRedraw; int mMode; + gcn::Color mFlashColor; + gcn::Color mPlayerFlashColor; }; #endif diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index f80039650..2729e5407 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -59,6 +59,8 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab, mLoseFocusOnTab = loseFocusOnTab; + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); + if (instances == 0) { // Load the skin @@ -136,7 +138,7 @@ void TextField::draw(gcn::Graphics *graphics) mXScroll); } - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); graphics->setFont(getFont()); graphics->drawText(mText, 1 - mXScroll, 1); } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 9a7c689e6..4435496a7 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -60,6 +60,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent, mSaveVisible(false), mStickyButton(false), mSticky(false), + mStickyButtonLock(false), mMinWinWidth(100), mMinWinHeight(40), mMaxWinWidth(graphics->mWidth), @@ -95,6 +96,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent, addWidgetListener(this); mCaptionFont = getFont(); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } Window::~Window() @@ -146,15 +148,10 @@ void Window::draw(gcn::Graphics *graphics) g->drawImageRect2(mVertexes, mSkin->getBorder()); -/* - g->drawImageRect(0, 0, getWidth(), - getHeight(), mSkin->getBorder()); -*/ - // Draw title if (mShowTitle) { - g->setColor(Theme::getThemeColor(Theme::TEXT)); + g->setColor(getForegroundColor()); g->setFont(mCaptionFont); g->drawText(getCaption(), 7, 5, gcn::Graphics::LEFT); } @@ -162,9 +159,9 @@ void Window::draw(gcn::Graphics *graphics) // Draw Close Button if (mCloseButton && mSkin->getCloseImage()) { - g->drawImage(mSkin->getCloseImage(), - getWidth() - mSkin->getCloseImage()->getWidth() - getPadding(), - getPadding()); + Image *button = mSkin->getCloseImage(); + const int x = getWidth() - button->getWidth() - getPadding(); + g->drawImage(button, x, getPadding()); } // Draw Sticky Button @@ -175,7 +172,7 @@ void Window::draw(gcn::Graphics *graphics) { int x = getWidth() - button->getWidth() - getPadding(); if (mCloseButton && mSkin->getCloseImage()) - x -= mSkin->getCloseImage()->getWidth(); + x -= mSkin->getCloseImage()->getWidth() + getPadding(); g->drawImage(button, x, getPadding()); } @@ -371,7 +368,7 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED) if (gui) gui->setCursorType(Gui::CURSOR_POINTER); - WidgetListIterator it; + WidgetListConstIterator it; if (!mFocusHandler) return; @@ -403,6 +400,13 @@ void Window::setSticky(bool sticky) mSticky = sticky; } +void Window::setStickyButtonLock(bool lock) +{ + mStickyButtonLock = lock; + mStickyButton = lock; +// mMovable = false; +} + void Window::setVisible(bool visible) { setVisible(visible, false); @@ -417,7 +421,10 @@ void Window::setVisible(bool visible, bool forceSticky) if (visible) checkIfIsOffScreen(); - gcn::Window::setVisible((!forceSticky && isSticky()) || visible); + if (isStickyButtonLock()) + gcn::Window::setVisible(visible); + else + gcn::Window::setVisible((!forceSticky && isSticky()) || visible); } void Window::scheduleDelete() @@ -483,7 +490,10 @@ void Window::mousePressed(gcn::MouseEvent &event) // Handle window resizing mouseResize = getResizeHandles(event); - mMoved = !mouseResize; + if (canMove()) + mMoved = !mouseResize; + else + mMoved = false; } } @@ -545,10 +555,24 @@ void Window::mouseMoved(gcn::MouseEvent &event) viewport->hideBeingPopup(); } +bool Window::canMove() +{ + return !mStickyButtonLock || !mSticky; +} + void Window::mouseDragged(gcn::MouseEvent &event) { - // Let Guichan handle title bar drag - gcn::Window::mouseDragged(event); + if (canMove()) + { + // Let Guichan handle title bar drag + gcn::Window::mouseDragged(event); + } + else + { + if (!event.isConsumed() && event.getSource() == this) + event.consume(); + return; + } // Keep guichan window inside screen when it may be moved if (isMovable() && mMoved) @@ -639,21 +663,22 @@ void Window::setModal(bool modal) void Window::loadWindowState() { const std::string &name = mWindowName; - assert(!name.empty()); + if (name.empty()) + return; setPosition(config.getValueInt(name + "WinX", mDefaultX), - config.getValueInt(name + "WinY", mDefaultY)); + config.getValueInt(name + "WinY", mDefaultY)); if (mSaveVisible) { setVisible(config.getValueBool(name - + "Visible", mDefaultVisible)); + + "Visible", mDefaultVisible)); } if (mStickyButton) { setSticky(config.getValueBool(name - + "Sticky", isSticky())); + + "Sticky", isSticky())); } if (mGrip) @@ -685,10 +710,10 @@ void Window::loadWindowState() int width = getWidth(); int height = getHeight(); - if (getX() + width >= viewport->getWidth()) - width = viewport->getWidth() - getX() - 1; - if (getY() + height >= viewport->getHeight()) - height = viewport->getHeight() - getY() - 1; + if (getX() + width > viewport->getWidth()) + width = viewport->getWidth() - getX(); + if (getY() + height > viewport->getHeight()) + height = viewport->getHeight() - getY(); if (width < 0) width = 0; if (height < 0) @@ -815,7 +840,7 @@ void Window::resetToDefaultSize() int Window::getResizeHandles(gcn::MouseEvent &event) { - if (event.getX() < 0 || event.getY() < 0) + if ((mStickyButtonLock && mSticky) || event.getX() < 0 || event.getY() < 0) return 0; int resizeHandles = 0; diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index d36d6c5ad..b9f65dceb 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -189,6 +189,17 @@ class Window : public gcn::Window, gcn::WidgetListener { return mSticky; } /** + * Sets whether the window sticky mean window locked or not. + */ + void setStickyButtonLock(bool sticky); + + /** + * Returns whether the window sticky locking window. + */ + bool isStickyButtonLock() const + { return mStickyButtonLock; } + + /** * Overloads window setVisible by Guichan to allow sticky window * handling. */ @@ -387,6 +398,9 @@ class Window : public gcn::Window, gcn::WidgetListener void setCaptionFont(gcn::Font *font) { mCaptionFont = font; } + protected: + bool canMove(); + private: enum ResizeHandles { @@ -423,6 +437,7 @@ class Window : public gcn::Window, gcn::WidgetListener bool mSaveVisible; /**< Window will save visibility */ bool mStickyButton; /**< Window has a sticky button */ bool mSticky; /**< Window resists hiding*/ + bool mStickyButtonLock; /**< Window locked if sticky enabled*/ int mMinWinWidth; /**< Minimum window width */ int mMinWinHeight; /**< Minimum window height */ int mMaxWinWidth; /**< Maximum window width */ |