diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/button.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/chattab.cpp | 14 | ||||
-rw-r--r-- | src/gui/widgets/chattab.h | 17 | ||||
-rw-r--r-- | src/gui/widgets/checkbox.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/dropdown.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/emoteshortcutcontainer.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/itemshortcutcontainer.cpp | 16 | ||||
-rw-r--r-- | src/gui/widgets/listbox.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/playerbox.cpp | 22 | ||||
-rw-r--r-- | src/gui/widgets/playerbox.h | 8 | ||||
-rw-r--r-- | src/gui/widgets/progressbar.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/radiobutton.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/resizegrip.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/shoplistbox.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/slider.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/tab.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/table.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/textfield.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/textpreview.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/whispertab.cpp | 7 | ||||
-rw-r--r-- | src/gui/widgets/whispertab.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/window.cpp | 4 |
23 files changed, 85 insertions, 75 deletions
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 26e0ad90..dbaa357c 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -125,8 +125,8 @@ Button::~Button() void Button::updateAlpha() { - float alpha = std::max(config.getValue("guialpha", 0.8f), - (double) Theme::instance()->getMinimumOpacity()); + float alpha = std::max(config.getFloatValue("guialpha"), + Theme::instance()->getMinimumOpacity()); if (mAlpha != alpha) { diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 39ea6887..fbde2c9c 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -21,6 +21,7 @@ #include "gui/widgets/chattab.h" +#include "chatlog.h" #include "commandhandler.h" #include "configuration.h" #include "localplayer.h" @@ -50,7 +51,7 @@ ChatTab::ChatTab(const std::string &name) : Tab() mTextOutput = new BrowserBox(BrowserBox::AUTO_WRAP); mTextOutput->setOpaque(false); - mTextOutput->setMaxRow((int) config.getValue("ChatLogLength", 0)); + mTextOutput->setMaxRow((int) config.getIntValue("ChatLogLength")); mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler); mScrollArea = new ScrollArea(mTextOutput); @@ -71,7 +72,7 @@ ChatTab::~ChatTab() delete mScrollArea; } -void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) +void ChatTab::chatLog(std::string line, Own own, bool ignoreRecord) { // Trim whitespace trim(line); @@ -180,6 +181,9 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) line = lineColor + timeStr.str() + tmp.nick + tmp.text; + if (config.getBoolValue("enableChatLog")) + saveToLogFile(line); + // We look if the Vertical Scroll Bar is set at the max before // adding a row, otherwise the max will always be a row higher // at comparison. @@ -275,6 +279,12 @@ void ChatTab::handleCommand(const std::string &msg) commandHandler->handleCommand(msg, this); } +void ChatTab::saveToLogFile(std::string &msg) +{ + if (chatLogger) + chatLogger->log(msg); +} + void ChatTab::addRow(std::string &line) { std::string::size_type idx = 0; diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 7fd3931e..f5682668 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -30,18 +30,6 @@ class BrowserBox; class Recorder; class ScrollArea; -enum -{ - BY_GM, - BY_PLAYER, - BY_OTHER, - BY_SERVER, - BY_CHANNEL, - ACT_WHISPER, // getting whispered at - ACT_IS, // equivalent to "/me" on IRC - BY_LOGGER -}; - /** * A tab for the chat window. This is special to ease chat handling. */ @@ -62,7 +50,8 @@ class ChatTab : public Tab * @param channelName which channel to send the message to. * @param ignoreRecord should this not be recorded? */ - void chatLog(std::string line, int own = BY_SERVER, bool ignoreRecord = false); + void chatLog(std::string line, Own own = BY_SERVER, + bool ignoreRecord = false); /** * Adds the text to the message list @@ -111,6 +100,8 @@ class ChatTab : public Tab const std::string &args) { return false; } + virtual void saveToLogFile(std::string &msg); + protected: friend class ChatWindow; friend class WhisperWindow; diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index f9002166..64594940 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -92,8 +92,8 @@ void CheckBox::draw(gcn::Graphics* graphics) void CheckBox::updateAlpha() { - float alpha = std::max(config.getValue("guialpha", 0.8f), - (double) Theme::instance()->getMinimumOpacity()); + float alpha = std::max(config.getFloatValue("guialpha"), + Theme::instance()->getMinimumOpacity()); if (mAlpha != alpha) { diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 6c3417e7..e694137d 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -110,8 +110,8 @@ DropDown::~DropDown() void DropDown::updateAlpha() { - float alpha = std::max(config.getValue("guialpha", 0.8f), - (double) Theme::instance()->getMinimumOpacity()); + float alpha = std::max(config.getFloatValue("guialpha"), + Theme::instance()->getMinimumOpacity()); if (mAlpha != alpha) { diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 82fb9f8d..28727429 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -51,7 +51,7 @@ EmoteShortcutContainer::EmoteShortcutContainer(): mBackgroundImg = Theme::getImageFromTheme("item_shortcut_bgr.png"); - mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8)); + mBackgroundImg->setAlpha(config.getFloatValue("guialpha")); // Setup emote sprites for (int i = 0; i <= EmoteDB::getLast(); i++) @@ -72,9 +72,9 @@ EmoteShortcutContainer::~EmoteShortcutContainer() void EmoteShortcutContainer::draw(gcn::Graphics *graphics) { - if (config.getValue("guialpha", 0.8) != mAlpha) + if (config.getFloatValue("guialpha") != mAlpha) { - mAlpha = config.getValue("guialpha", 0.8); + mAlpha = config.getFloatValue("guialpha"); mBackgroundImg->setAlpha(mAlpha); } diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 83efd4d4..869264f7 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -27,7 +27,7 @@ #include "item.h" #include "itemshortcut.h" #include "keyboardconfig.h" -#include "localplayer.h" +#include "playerinfo.h" #include "gui/inventorywindow.h" #include "gui/itempopup.h" @@ -53,7 +53,7 @@ ItemShortcutContainer::ItemShortcutContainer(): mBackgroundImg = Theme::getImageFromTheme("item_shortcut_bgr.png"); mMaxItems = itemShortcut->getItemCount(); - mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8)); + mBackgroundImg->setAlpha(config.getFloatValue("guialpha")); mBoxHeight = mBackgroundImg->getHeight(); mBoxWidth = mBackgroundImg->getWidth(); @@ -67,9 +67,9 @@ ItemShortcutContainer::~ItemShortcutContainer() void ItemShortcutContainer::draw(gcn::Graphics *graphics) { - if (config.getValue("guialpha", 0.8) != mAlpha) + if (config.getFloatValue("guialpha") != mAlpha) { - mAlpha = config.getValue("guialpha", 0.8); + mAlpha = config.getFloatValue("guialpha"); mBackgroundImg->setAlpha(mAlpha); } @@ -94,7 +94,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) continue; Item *item = - player_node->getInventory()->findItem(itemShortcut->getItem(i)); + PlayerInfo::getInventory()->findItem(itemShortcut->getItem(i)); if (item) { @@ -151,7 +151,7 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event) if (itemId < 0) return; - Item *item = player_node->getInventory()->findItem(itemId); + Item *item = PlayerInfo::getInventory()->findItem(itemId); if (item) { @@ -187,7 +187,7 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event) } else if (event.getButton() == gcn::MouseEvent::RIGHT) { - Item *item = player_node->getInventory()-> + Item *item = PlayerInfo::getInventory()-> findItem(itemShortcut->getItem(index)); if (!item) @@ -240,7 +240,7 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) if (itemId < 0) return; - Item *item = player_node->getInventory()->findItem(itemId); + Item *item = PlayerInfo::getInventory()->findItem(itemId); if (item) { diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index ef591023..2193b888 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -45,8 +45,8 @@ ListBox::~ListBox() void ListBox::updateAlpha() { - float alpha = std::max(config.getValue("guialpha", 0.8), - (double) Theme::instance()->getMinimumOpacity()); + float alpha = std::max(config.getFloatValue("guialpha"), + Theme::instance()->getMinimumOpacity()); if (mAlpha != alpha) mAlpha = alpha; diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 57cbec6f..cc9e963e 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -22,9 +22,9 @@ #include "gui/widgets/playerbox.h" #include "animatedsprite.h" +#include "being.h" #include "configuration.h" #include "graphics.h" -#include "player.h" #include "gui/theme.h" @@ -36,8 +36,8 @@ int PlayerBox::instances = 0; float PlayerBox::mAlpha = 1.0; ImageRect PlayerBox::background; -PlayerBox::PlayerBox(const Player *player): - mPlayer(player) +PlayerBox::PlayerBox(const Being *being): + mBeing(being) { setFrameSize(2); @@ -57,7 +57,7 @@ PlayerBox::PlayerBox(const Player *player): bggridx[x], bggridy[y], bggridx[x + 1] - bggridx[x] + 1, bggridy[y + 1] - bggridy[y] + 1); - background.grid[a]->setAlpha(config.getValue("guialpha", 0.8)); + background.grid[a]->setAlpha(config.getFloatValue("guialpha")); a++; } } @@ -72,7 +72,7 @@ PlayerBox::~PlayerBox() { instances--; - mPlayer = 0; + mBeing = 0; if (instances == 0) { @@ -82,20 +82,20 @@ PlayerBox::~PlayerBox() void PlayerBox::draw(gcn::Graphics *graphics) { - if (mPlayer) + if (mBeing) { // Draw character const int bs = getFrameSize(); - const int x = getWidth() / 2 + bs; - const int y = getHeight() - bs; - mPlayer->drawSpriteAt(static_cast<Graphics*>(graphics), x, y); + const int x = getWidth() / 2 + bs - 16; + const int y = getHeight() - bs - 32; + mBeing->drawSpriteAt(static_cast<Graphics*>(graphics), x, y); } - if (config.getValue("guialpha", 0.8) != mAlpha) + if (config.getFloatValue("guialpha") != mAlpha) { for (int a = 0; a < 9; a++) { - background.grid[a]->setAlpha(config.getValue("guialpha", 0.8)); + background.grid[a]->setAlpha(config.getFloatValue("guialpha")); } } } diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index 33b4a628..4505367f 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -24,8 +24,8 @@ #include <guichan/widgets/scrollarea.hpp> +class Being; class ImageRect; -class Player; /** * A box showing a player character. @@ -39,7 +39,7 @@ class PlayerBox : public gcn::ScrollArea * Constructor. Takes the initial player character that this box should * display, which defaults to <code>NULL</code>. */ - PlayerBox(const Player *player = 0); + PlayerBox(const Being *being = 0); /** * Destructor. @@ -51,7 +51,7 @@ class PlayerBox : public gcn::ScrollArea * player to <code>NULL</code> causes the box not to draw any * character. */ - void setPlayer(const Player *player) { mPlayer = player; } + void setPlayer(const Being *being) { mBeing = being; } /** * Draws the scroll area. @@ -64,7 +64,7 @@ class PlayerBox : public gcn::ScrollArea void drawFrame(gcn::Graphics *graphics); private: - const Player *mPlayer; /**< The character used for display */ + const Being *mBeing; /**< The character used for display */ static float mAlpha; static int instances; diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 028658ab..60c44fe2 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -123,8 +123,8 @@ void ProgressBar::logic() void ProgressBar::updateAlpha() { - float alpha = std::max(config.getValue("guialpha", 0.8), - (double) Theme::instance()->getMinimumOpacity()); + float alpha = std::max(config.getFloatValue("guialpha"), + Theme::instance()->getMinimumOpacity()); if (mAlpha != alpha) { diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 96797225..4cbc22e7 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -78,9 +78,9 @@ RadioButton::~RadioButton() void RadioButton::drawBox(gcn::Graphics* graphics) { - if (config.getValue("guialpha", 0.8) != mAlpha) + if (config.getFloatValue("guialpha") != mAlpha) { - mAlpha = config.getValue("guialpha", 0.8); + mAlpha = config.getFloatValue("guialpha"); radioNormal->setAlpha(mAlpha); radioChecked->setAlpha(mAlpha); radioDisabled->setAlpha(mAlpha); diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index f0c3691c..496e3727 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -59,9 +59,9 @@ ResizeGrip::~ResizeGrip() void ResizeGrip::draw(gcn::Graphics *graphics) { - if (config.getValue("guialpha", 0.8) != mAlpha) + if (config.getFloatValue("guialpha") != mAlpha) { - mAlpha = config.getValue("guialpha", 0.8); + mAlpha = config.getFloatValue("guialpha"); gripImage->setAlpha(mAlpha); } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 0c7f4d7d..d8ffe5ab 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -108,7 +108,7 @@ void ScrollArea::init() bggridx[x], bggridy[y], bggridx[x + 1] - bggridx[x] + 1, bggridy[y + 1] - bggridy[y] + 1); - background.grid[a]->setAlpha(config.getValue("guialpha", 0.8)); + background.grid[a]->setAlpha(config.getFloatValue("guialpha")); a++; } } @@ -135,8 +135,8 @@ void ScrollArea::init() vsgridx[x], vsgridy[y], vsgridx[x + 1] - vsgridx[x], vsgridy[y + 1] - vsgridy[y]); - vMarker.grid[a]->setAlpha(config.getValue("guialpha", 0.8)); - vMarkerHi.grid[a]->setAlpha(config.getValue("guialpha", 0.8)); + vMarker.grid[a]->setAlpha(config.getFloatValue("guialpha")); + vMarkerHi.grid[a]->setAlpha(config.getFloatValue("guialpha")); a++; } } @@ -213,8 +213,8 @@ void ScrollArea::logic() void ScrollArea::updateAlpha() { - float alpha = std::max(config.getValue("guialpha", 0.8), - (double) Theme::instance()->getMinimumOpacity()); + float alpha = std::max(config.getFloatValue("guialpha"), + Theme::instance()->getMinimumOpacity()); if (alpha != mAlpha) { diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 2f5fab34..b92ec6cb 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -71,8 +71,8 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) if (!mListModel) return; - if (config.getValue("guialpha", 0.8) != mAlpha) - mAlpha = config.getValue("guialpha", 0.8); + if (config.getFloatValue("guialpha") != mAlpha) + mAlpha = config.getFloatValue("guialpha"); int alpha = (int)(mAlpha * 255.0f); const gcn::Color* highlightColor = diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 6a9a5c7c..00a8e86f 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -126,8 +126,8 @@ void Slider::init() void Slider::updateAlpha() { - float alpha = std::max(config.getValue("guialpha", 0.8), - (double) Theme::instance()->getMinimumOpacity()); + float alpha = std::max(config.getFloatValue("guialpha"), + Theme::instance()->getMinimumOpacity()); if (alpha != mAlpha) { diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 2ab126dd..503a8e55 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -118,8 +118,8 @@ void Tab::init() void Tab::updateAlpha() { - float alpha = std::max(config.getValue("guialpha", 0.8), - (double) Theme::instance()->getMinimumOpacity()); + float alpha = std::max(config.getFloatValue("guialpha"), + Theme::instance()->getMinimumOpacity()); // TODO We don't need to do this for every tab on every draw // Maybe use a config listener to do it as the value changes. diff --git a/src/gui/widgets/table.cpp b/src/gui/widgets/table.cpp index f0887ed7..663d6d02 100644 --- a/src/gui/widgets/table.cpp +++ b/src/gui/widgets/table.cpp @@ -270,8 +270,8 @@ void GuiTable::draw(gcn::Graphics* graphics) if (!mModel) return; - if (config.getValue("guialpha", 0.8) != mAlpha) - mAlpha = config.getValue("guialpha", 0.8); + if (config.getFloatValue("guialpha") != mAlpha) + mAlpha = config.getFloatValue("guialpha"); if (mOpaque) { diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 4453f522..f89f6239 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -65,7 +65,7 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab): gridx[x], gridy[y], gridx[x + 1] - gridx[x] + 1, gridy[y + 1] - gridy[y] + 1); - skin.grid[a]->setAlpha(config.getValue("guialpha", 0.8)); + skin.grid[a]->setAlpha(config.getFloatValue("guialpha")); a++; } } @@ -86,8 +86,8 @@ TextField::~TextField() void TextField::updateAlpha() { - float alpha = std::max(config.getValue("guialpha", 0.8), - (double) Theme::instance()->getMinimumOpacity()); + float alpha = std::max(config.getFloatValue("guialpha"), + Theme::instance()->getMinimumOpacity()); if (alpha != mAlpha) { diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 10426d7c..869ebd35 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -45,8 +45,8 @@ TextPreview::TextPreview(const std::string &text): void TextPreview::draw(gcn::Graphics* graphics) { - if (config.getValue("guialpha", 0.8) != mAlpha) - mAlpha = config.getValue("guialpha", 0.8); + if (config.getFloatValue("guialpha") != mAlpha) + mAlpha = config.getFloatValue("guialpha"); int alpha = (int) (mAlpha * 255.0f); diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index 7542e251..685d28ab 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -21,6 +21,7 @@ #include "whispertab.h" +#include "chatlog.h" #include "commandhandler.h" #include "localplayer.h" @@ -115,3 +116,9 @@ bool WhisperTab::handleCommand(const std::string &type, return true; } + +void WhisperTab::saveToLogFile(std::string &msg) +{ + if (chatLogger) + chatLogger->log(getNick(), msg); +} diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h index 447a8fe0..20a07449 100644 --- a/src/gui/widgets/whispertab.h +++ b/src/gui/widgets/whispertab.h @@ -39,6 +39,8 @@ class WhisperTab : public ChatTab bool handleCommand(const std::string &type, const std::string &args); + void saveToLogFile(std::string &msg); + protected: friend class ChatWindow; diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 118ee7c0..dafaaeed 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -697,8 +697,8 @@ int Window::getResizeHandles(gcn::MouseEvent &event) int Window::getGuiAlpha() { - float alpha = std::max(config.getValue("guialpha", 0.8), - (double) Theme::instance()->getMinimumOpacity()); + float alpha = std::max(config.getFloatValue("guialpha"), + Theme::instance()->getMinimumOpacity()); return (int) (alpha * 255.0f); } |