From dd5a317dbfdb24d905ade4ebea458e370619f61f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 11 Aug 2011 03:03:53 +0300 Subject: Save whisper tabs state to configuration after each change. Before was only after correct game disconnect. --- src/game.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 9a5128f37..40b6896b7 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -532,8 +532,6 @@ void Game::logic() map->saveExtraLayer(); } Client::closeDialogs(); - if (chatWindow) - chatWindow->saveState(); disconnectedDialog = new OkDialog(_("Network Error"), errorMessage, false); disconnectedDialog->addActionListener(&errorListener); -- cgit v1.2.3-70-g09d2 From fca4273667f15afba055d3c296094f2f41c7ae91 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 12 Aug 2011 01:53:54 +0300 Subject: Add ability to add comments to npcs. --- src/being.cpp | 41 +++++++++++++++++++++++++++++++++-------- src/being.h | 4 ++-- src/client.cpp | 13 +++++++++++++ src/client.h | 3 +++ src/game.cpp | 2 +- src/gui/beingpopup.cpp | 6 ++++++ src/gui/popupmenu.cpp | 24 +++++++++++++++++++----- src/gui/popupmenu.h | 5 +++++ src/gui/viewport.cpp | 3 ++- 9 files changed, 84 insertions(+), 17 deletions(-) (limited to 'src/game.cpp') diff --git a/src/being.cpp b/src/being.cpp index cd616fc67..b6f06a75a 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -263,7 +263,7 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map): if (mType == PLAYER) mShowName = config.getBoolValue("visiblenames"); - else + else if (mType != NPC) mGotComment = true; config.addListener("visiblenames", this); @@ -2363,13 +2363,26 @@ void Being::updateComment() return; mGotComment = true; - mComment = loadComment(mName); + mComment = loadComment(mName, mType); } -std::string Being::loadComment(const std::string &name) +std::string Being::loadComment(const std::string &name, int type) { - std::string str = Client::getUsersDirectory() - + stringToHexPath(name) + "/comment.txt"; + std::string str; + switch (type) + { + case PLAYER: + str = Client::getUsersDirectory(); + break; + case NPC: + str = Client::getNpcsDirectory(); + break; + default: + return ""; + } + + str += stringToHexPath(name) + "/comment.txt"; + logger->log("load from: %s", str.c_str()); std::vector lines; ResourceManager *resman = ResourceManager::getInstance(); @@ -2383,10 +2396,22 @@ std::string Being::loadComment(const std::string &name) } void Being::saveComment(const std::string &name, - const std::string &comment) + const std::string &comment, int type) { - std::string dir = Client::getUsersDirectory() - + stringToHexPath(name); + std::string dir; + switch (type) + { + case PLAYER: + dir = Client::getUsersDirectory(); + break; + case NPC: + dir = Client::getNpcsDirectory(); + break; + default: + return; + } + dir += stringToHexPath(name); + logger->log("save to: %s", dir.c_str()); ResourceManager *resman = ResourceManager::getInstance(); resman->saveTextFile(dir, "comment.txt", name + "\n" + comment); } diff --git a/src/being.h b/src/being.h index 76c968451..2c37ffeb5 100644 --- a/src/being.h +++ b/src/being.h @@ -741,10 +741,10 @@ class Being : public ActorSprite, public ConfigListener static void clearCache(); - static std::string loadComment(const std::string &name); + static std::string loadComment(const std::string &name, int type); static void saveComment(const std::string &name, - const std::string &comment); + const std::string &comment, int type); bool isAdvanced() { return mAdvanced; } diff --git a/src/client.cpp b/src/client.cpp index 092f81a93..022bc07d5 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -240,6 +240,7 @@ Client::Client(const Options &options): mOptions(options), mServerConfigDir(""), mUsersDir(""), + mNpcsDir(""), mRootDir(""), mCurrentDialog(0), mQuitDialog(0), @@ -1917,6 +1918,13 @@ void Client::initUsersDir() logger->error(strprintf(_("%s doesn't exist and can't be created! " "Exiting."), mUsersDir.c_str())); } + + mNpcsDir = Client::getServerConfigDirectory() + "/npcs/"; + if (mkdir_r(mNpcsDir.c_str())) + { + logger->error(strprintf(_("%s doesn't exist and can't be created! " + "Exiting."), mNpcsDir.c_str())); + } } void Client::initPacketLimiter() @@ -2137,6 +2145,11 @@ const std::string Client::getUsersDirectory() return instance()->mUsersDir; } +const std::string Client::getNpcsDirectory() +{ + return instance()->mNpcsDir; +} + void Client::setGuiAlpha(float n) { instance()->mGuiAlpha = n; diff --git a/src/client.h b/src/client.h index 75b3c03fe..986e06cfb 100644 --- a/src/client.h +++ b/src/client.h @@ -226,6 +226,8 @@ public: static const std::string getUsersDirectory(); + static const std::string getNpcsDirectory(); + static bool getIsMinimized() { return instance()->mIsMinimized; } @@ -303,6 +305,7 @@ private: std::string mScreenshotDir; std::string mServerConfigDir; std::string mUsersDir; + std::string mNpcsDir; std::string mRootDir; std::string mServerName; diff --git a/src/game.cpp b/src/game.cpp index 40b6896b7..05fb88048 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -556,7 +556,7 @@ void Game::adjustPerfomance() { mNextAdjustTime = cur_time + adjustDelay; } - else if (mNextAdjustTime < cur_time) + else if (mNextAdjustTime < (unsigned)cur_time) { mNextAdjustTime = cur_time + adjustDelay; diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp index e5dc602a0..8d7b26c1b 100644 --- a/src/gui/beingpopup.cpp +++ b/src/gui/beingpopup.cpp @@ -89,6 +89,12 @@ void BeingPopup::show(int x, int y, Being *b) b->updateComment(); + if (b->getType() == Being::NPC && b->getComment().empty()) + { + setVisible(false); + return; + } + mBeingName->setCaption(b->getName() + b->getGenderSignWithSpace()); if (gui) { diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 9cf9e536e..14a326e41 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -22,6 +22,7 @@ #include "gui/popupmenu.h" +#include "actorsprite.h" #include "actorspritemanager.h" #include "being.h" #include "dropshortcut.h" @@ -94,7 +95,8 @@ PopupMenu::PopupMenu(): mSpell(0), mDialog(0), mButton(0), - mNick("") + mNick(""), + mType(Being::UNKNOWN) { mBrowserBox = new BrowserBox; mBrowserBox->setPosition(4, 4); @@ -105,6 +107,7 @@ PopupMenu::PopupMenu(): mRenameListener.setDialog(0); mPlayerListener.setNick(""); mPlayerListener.setDialog(0); + mPlayerListener.setType(Being::UNKNOWN); add(mBrowserBox); } @@ -116,6 +119,7 @@ void PopupMenu::showPopup(int x, int y, Being *being) mBeingId = being->getId(); mNick = being->getName(); + mType = being->getType(); mBrowserBox->clearRows(); const std::string &name = mNick; @@ -278,6 +282,8 @@ void PopupMenu::showPopup(int x, int y, Being *being) mBrowserBox->addRow(strprintf("@@sell|%s@@", _("Sell"))); mBrowserBox->addRow("##3---"); mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move"))); + mBrowserBox->addRow(strprintf("@@addcomment|%s@@", + _("Add comment"))); break; case ActorSprite::MONSTER: @@ -359,6 +365,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) mNick = nick; mBeingId = 0; + mType = Being::PLAYER; mBrowserBox->clearRows(); const std::string &name = mNick; @@ -599,6 +606,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) { mBeingId = being->getId(); mNick = being->getName(); + mType = being->getType(); mBrowserBox->addRow(strprintf("@@trade|%s@@", _("Trade"))); mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack"))); @@ -728,6 +736,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) else { mNick = name; + mType = Being::PLAYER; mBrowserBox->addRow(strprintf( "@@addcomment|%s@@", _("Add comment"))); mBrowserBox->addRow("##3---"); @@ -768,6 +777,7 @@ void PopupMenu::showChangePos(int x, int y) mItem = 0; mMapItem = 0; mNick = ""; + mType = Being::UNKNOWN; setVisible(false); } } @@ -1220,6 +1230,7 @@ void PopupMenu::handleLink(const std::string &link, _("Comment: ")); mPlayerListener.setDialog(dialog); mPlayerListener.setNick(mNick); + mPlayerListener.setType(mType); if (being) { @@ -1228,7 +1239,7 @@ void PopupMenu::handleLink(const std::string &link, } else { - dialog->setText(Being::loadComment(mNick)); + dialog->setText(Being::loadComment(mNick, mType)); } dialog->setActionEventId("ok"); dialog->addActionListener(&mPlayerListener); @@ -1560,6 +1571,7 @@ void PopupMenu::handleLink(const std::string &link, mItemColor = 1; mMapItem = 0; mNick = ""; + mType = Being::UNKNOWN; } void PopupMenu::showPopup(Window *parent, int x, int y, Item *item, @@ -1870,6 +1882,7 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name, return; mNick = name; + mType = Being::MONSTER; mBrowserBox->clearRows(); @@ -2001,7 +2014,8 @@ void RenameListener::action(const gcn::ActionEvent &event) PlayerListener::PlayerListener() : mNick(""), - mDialog(0) + mDialog(0), + mType(Being::UNKNOWN) { } @@ -2011,10 +2025,10 @@ void PlayerListener::action(const gcn::ActionEvent &event) { std::string comment = mDialog->getText(); Being* being = actorSpriteManager->findBeingByName( - mNick, Being::PLAYER); + mNick, (ActorSprite::Type)mType); if (being) being->setComment(comment); - Being::saveComment(mNick, comment); + Being::saveComment(mNick, comment, mType); } mDialog = 0; } diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index afa4bdfa2..3a7f27d4b 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -78,9 +78,13 @@ class PlayerListener : public gcn::ActionListener void setDialog(TextDialog *dialog) { mDialog = dialog; } + void setType(int type) + { mType = type; } + private: std::string mNick; TextDialog *mDialog; + int mType; }; /** @@ -171,6 +175,7 @@ class PopupMenu : public Popup, public LinkHandler TextDialog *mDialog; Button *mButton; std::string mNick; + int mType; /** * Shared code for the various showPopup functions. diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index ba8414699..2ca59f524 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -684,7 +684,8 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED) const int y = getMouseY() + static_cast(mPixelViewY); mHoverBeing = actorSpriteManager->findBeingByPixel(x, y, true); - if (mHoverBeing && mHoverBeing->getType() == Being::PLAYER) + if (mHoverBeing && (mHoverBeing->getType() == Being::PLAYER + || mHoverBeing->getType() == Being::NPC)) { mTextPopup->setVisible(false); if (mShowBeingPopup) -- cgit v1.2.3-70-g09d2 From 383b667c30665377ee5bd5c1167530eb44ce4571 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 12 Aug 2011 03:24:12 +0300 Subject: Allow hide setup window by pressing key "Setup window". --- src/game.cpp | 306 ++++++++++++++++++++++++++++-------------------------- src/gui/setup.cpp | 9 +- src/gui/setup.h | 2 + 3 files changed, 167 insertions(+), 150 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 05fb88048..4332c8e11 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1039,174 +1039,184 @@ void Game::handleInput() if (keyboard.isEnabled() && !chatWindow->isInputFocused() && !NpcDialog::isAnyInputFocused() - && !setupWindow->isVisible() && !player_node->getAwayMode() && !keyboard.isKeyActive(keyboard.KEY_TARGET)) { const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); - // Do not activate shortcuts if tradewindow is visible - if (itemShortcutWindow && !tradeWindow->isVisible() - && !setupWindow->isVisible()) + if (setupWindow->isVisible()) { - int num = itemShortcutWindow->getTabIndex(); - if (num >= 0 && num < SHORTCUT_TABS) + if (tKey == KeyboardConfig::KEY_WINDOW_SETUP) { - // Checks if any item shortcut is pressed. - for (int i = KeyboardConfig::KEY_SHORTCUT_1; - i <= KeyboardConfig::KEY_SHORTCUT_20; - i++) + setupWindow->doCancel(); + used = true; + } + } + else + { + // Do not activate shortcuts if tradewindow is visible + if (itemShortcutWindow && !tradeWindow->isVisible() + && !setupWindow->isVisible()) + { + int num = itemShortcutWindow->getTabIndex(); + if (num >= 0 && num < SHORTCUT_TABS) { - if (tKey == i && !used) + // Checks if any item shortcut is pressed. + for (int i = KeyboardConfig::KEY_SHORTCUT_1; + i <= KeyboardConfig::KEY_SHORTCUT_20; + i ++) { - itemShortcut[num]->useItem( - i - KeyboardConfig::KEY_SHORTCUT_1); - break; + if (tKey == i && !used) + { + itemShortcut[num]->useItem( + i - KeyboardConfig::KEY_SHORTCUT_1); + break; + } } } } - } - switch (tKey) - { - case KeyboardConfig::KEY_PICKUP: - player_node->pickUpItems(); - used = true; - break; - case KeyboardConfig::KEY_SIT: - // Player sit action - if (keyboard.isKeyActive(keyboard.KEY_EMOTE)) - player_node->updateSit(); - else - player_node->toggleSit(); - used = true; - break; - case KeyboardConfig::KEY_HIDE_WINDOWS: - // Hide certain windows - if (!chatWindow->isInputFocused()) - { - statusWindow->setVisible(false); - inventoryWindow->setVisible(false); - shopWindow->setVisible(false); - skillDialog->setVisible(false); - setupWindow->setVisible(false); - equipmentWindow->setVisible(false); - helpWindow->setVisible(false); - debugWindow->setVisible(false); - outfitWindow->setVisible(false); - dropShortcutWindow->setVisible(false); - spellShortcutWindow->setVisible(false); - botCheckerWindow->setVisible(false); - socialWindow->setVisible(false); - } - break; - case KeyboardConfig::KEY_WINDOW_STATUS: - requestedWindow = statusWindow; - break; - case KeyboardConfig::KEY_WINDOW_INVENTORY: - requestedWindow = inventoryWindow; - break; - case KeyboardConfig::KEY_WINDOW_SHOP: - requestedWindow = shopWindow; - break; - case KeyboardConfig::KEY_WINDOW_EQUIPMENT: - requestedWindow = equipmentWindow; - break; - case KeyboardConfig::KEY_WINDOW_SKILL: - requestedWindow = skillDialog; - break; - case KeyboardConfig::KEY_WINDOW_KILLS: - requestedWindow = killStats; - break; - case KeyboardConfig::KEY_WINDOW_MINIMAP: - minimap->toggle(); - break; - case KeyboardConfig::KEY_WINDOW_CHAT: - requestedWindow = chatWindow; - break; - case KeyboardConfig::KEY_WINDOW_SHORTCUT: - requestedWindow = itemShortcutWindow; - break; - case KeyboardConfig::KEY_WINDOW_SETUP: - requestedWindow = setupWindow; - break; - case KeyboardConfig::KEY_WINDOW_DEBUG: - requestedWindow = debugWindow; - break; - case KeyboardConfig::KEY_WINDOW_SOCIAL: - requestedWindow = socialWindow; - break; - case KeyboardConfig::KEY_WINDOW_EMOTE_SHORTCUT: - requestedWindow = emoteShortcutWindow; - break; - case KeyboardConfig::KEY_WINDOW_OUTFIT: - requestedWindow = outfitWindow; - break; - case KeyboardConfig::KEY_WINDOW_DROP: - requestedWindow = dropShortcutWindow; - break; - case KeyboardConfig::KEY_WINDOW_SPELLS: - requestedWindow = spellShortcutWindow; - break; - case KeyboardConfig::KEY_WINDOW_BOT_CHECKER: - requestedWindow = botCheckerWindow; - break; - case KeyboardConfig::KEY_WINDOW_ONLINE: - requestedWindow = whoIsOnline; - break; - case KeyboardConfig::KEY_SCREENSHOT: - // Screenshot (picture, hence the p) - saveScreenshot(); - used = true; - break; - case KeyboardConfig::KEY_PATHFIND: - // Find path to mouse (debug purpose) - if (!player_node->getDisableGameModifiers()) - { - if (viewport) - viewport->toggleDebugPath(); - if (miniStatusWindow) - miniStatusWindow->updateStatus(); - if (mCurrentMap) - mCurrentMap->redrawMap(); - used = true; - } - break; - case KeyboardConfig::KEY_TRADE: + switch (tKey) { - // Toggle accepting of incoming trade requests - unsigned int deflt = player_relations.getDefault(); - if (deflt & PlayerRelation::TRADE) - { - localChatTab->chatLog( - _("Ignoring incoming trade requests"), - BY_SERVER); - deflt &= ~PlayerRelation::TRADE; - } - else + case KeyboardConfig::KEY_PICKUP: + player_node->pickUpItems(); + used = true; + break; + case KeyboardConfig::KEY_SIT: + // Player sit action + if (keyboard.isKeyActive(keyboard.KEY_EMOTE)) + player_node->updateSit(); + else + player_node->toggleSit(); + used = true; + break; + case KeyboardConfig::KEY_HIDE_WINDOWS: + // Hide certain windows + if (!chatWindow->isInputFocused()) + { + statusWindow->setVisible(false); + inventoryWindow->setVisible(false); + shopWindow->setVisible(false); + skillDialog->setVisible(false); + setupWindow->setVisible(false); + equipmentWindow->setVisible(false); + helpWindow->setVisible(false); + debugWindow->setVisible(false); + outfitWindow->setVisible(false); + dropShortcutWindow->setVisible(false); + spellShortcutWindow->setVisible(false); + botCheckerWindow->setVisible(false); + socialWindow->setVisible(false); + } + break; + case KeyboardConfig::KEY_WINDOW_STATUS: + requestedWindow = statusWindow; + break; + case KeyboardConfig::KEY_WINDOW_INVENTORY: + requestedWindow = inventoryWindow; + break; + case KeyboardConfig::KEY_WINDOW_SHOP: + requestedWindow = shopWindow; + break; + case KeyboardConfig::KEY_WINDOW_EQUIPMENT: + requestedWindow = equipmentWindow; + break; + case KeyboardConfig::KEY_WINDOW_SKILL: + requestedWindow = skillDialog; + break; + case KeyboardConfig::KEY_WINDOW_KILLS: + requestedWindow = killStats; + break; + case KeyboardConfig::KEY_WINDOW_MINIMAP: + minimap->toggle(); + break; + case KeyboardConfig::KEY_WINDOW_CHAT: + requestedWindow = chatWindow; + break; + case KeyboardConfig::KEY_WINDOW_SHORTCUT: + requestedWindow = itemShortcutWindow; + break; + case KeyboardConfig::KEY_WINDOW_SETUP: + requestedWindow = setupWindow; + break; + case KeyboardConfig::KEY_WINDOW_DEBUG: + requestedWindow = debugWindow; + break; + case KeyboardConfig::KEY_WINDOW_SOCIAL: + requestedWindow = socialWindow; + break; + case KeyboardConfig::KEY_WINDOW_EMOTE_SHORTCUT: + requestedWindow = emoteShortcutWindow; + break; + case KeyboardConfig::KEY_WINDOW_OUTFIT: + requestedWindow = outfitWindow; + break; + case KeyboardConfig::KEY_WINDOW_DROP: + requestedWindow = dropShortcutWindow; + break; + case KeyboardConfig::KEY_WINDOW_SPELLS: + requestedWindow = spellShortcutWindow; + break; + case KeyboardConfig::KEY_WINDOW_BOT_CHECKER: + requestedWindow = botCheckerWindow; + break; + case KeyboardConfig::KEY_WINDOW_ONLINE: + requestedWindow = whoIsOnline; + break; + case KeyboardConfig::KEY_SCREENSHOT: + // Screenshot (picture, hence the p) + saveScreenshot(); + used = true; + break; + case KeyboardConfig::KEY_PATHFIND: + // Find path to mouse (debug purpose) + if (!player_node->getDisableGameModifiers()) + { + if (viewport) + viewport->toggleDebugPath(); + if (miniStatusWindow) + miniStatusWindow->updateStatus(); + if (mCurrentMap) + mCurrentMap->redrawMap(); + used = true; + } + break; + case KeyboardConfig::KEY_TRADE: { - localChatTab->chatLog( - _("Accepting incoming trade requests"), - BY_SERVER); - deflt |= PlayerRelation::TRADE; - } + // Toggle accepting of incoming trade requests + unsigned int deflt = player_relations.getDefault(); + if (deflt & PlayerRelation::TRADE) + { + localChatTab->chatLog( + _("Ignoring incoming trade requests"), + BY_SERVER); + deflt &= ~PlayerRelation::TRADE; + } + else + { + localChatTab->chatLog( + _("Accepting incoming trade requests"), + BY_SERVER); + deflt |= PlayerRelation::TRADE; + } - player_relations.setDefault(deflt); + player_relations.setDefault(deflt); - used = true; + used = true; + } + break; + default: + break; } - break; - default: - break; } - } - if (requestedWindow) - { - requestedWindow->setVisible(!requestedWindow->isVisible()); - if (requestedWindow->isVisible()) - requestedWindow->requestMoveToTop(); - used = true; + if (requestedWindow) + { + requestedWindow->setVisible(!requestedWindow->isVisible()); + if (requestedWindow->isVisible()) + requestedWindow->requestMoveToTop(); + used = true; + } } } // Active event diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 0b40d8c01..690871189 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -145,8 +145,7 @@ void Setup::action(const gcn::ActionEvent &event) } else if (event.getId() == "Cancel") { - setVisible(false); - for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel)); + doCancel(); } else if (event.getId() == "Store") { @@ -189,4 +188,10 @@ void Setup::registerWindowForReset(Window *window) mWindowsToReset.push_back(window); } +void Setup::doCancel() +{ + setVisible(false); + for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel)); +} + Setup *setupWindow; diff --git a/src/gui/setup.h b/src/gui/setup.h index ad5ba53d9..cdaf7db99 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -71,6 +71,8 @@ class Setup : public Window, public gcn::ActionListener void clearWindowsForReset() { mWindowsToReset.clear(); } + void doCancel(); + private: std::list mTabs; std::list mWindowsToReset; -- cgit v1.2.3-70-g09d2 From 2d45a2ca5480ae0fdc03a807787f622444830d44 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 12 Aug 2011 03:47:28 +0300 Subject: Rename file names log and chatlog to correct logger and chatlogger. --- manaplus.cbp | 8 +- src/CMakeLists.txt | 8 +- src/Makefile.am | 8 +- src/actorsprite.cpp | 2 +- src/actorspritemanager.cpp | 2 +- src/animatedsprite.cpp | 2 +- src/being.cpp | 2 +- src/chatlog.cpp | 204 --------------------------- src/chatlog.h | 79 ----------- src/chatlogger.cpp | 204 +++++++++++++++++++++++++++ src/chatlogger.h | 79 +++++++++++ src/client.cpp | 2 +- src/commandhandler.cpp | 2 +- src/configuration.cpp | 2 +- src/effectmanager.cpp | 2 +- src/filefilter.txt | 2 + src/game.cpp | 2 +- src/graphics.cpp | 2 +- src/gui/changeemaildialog.cpp | 2 +- src/gui/changepassworddialog.cpp | 2 +- src/gui/charselectdialog.cpp | 2 +- src/gui/connectiondialog.cpp | 2 +- src/gui/didyouknowwindow.cpp | 2 +- src/gui/emotepopup.cpp | 2 +- src/gui/gui.cpp | 2 +- src/gui/helpwindow.cpp | 2 +- src/gui/minimap.cpp | 2 +- src/gui/outfitwindow.cpp | 2 +- src/gui/palette.h | 2 +- src/gui/popupmenu.cpp | 2 +- src/gui/register.cpp | 2 +- src/gui/sdlfont.cpp | 2 +- src/gui/serverdialog.cpp | 4 +- src/gui/setup_audio.cpp | 2 +- src/gui/setup_chat.cpp | 2 +- src/gui/setup_other.cpp | 2 +- src/gui/setup_perfomance.cpp | 2 +- src/gui/setup_players.cpp | 2 +- src/gui/setup_relations.cpp | 2 +- src/gui/setup_theme.cpp | 2 +- src/gui/setup_video.cpp | 2 +- src/gui/setupitem.cpp | 2 +- src/gui/skilldialog.cpp | 2 +- src/gui/socialwindow.cpp | 2 +- src/gui/specialswindow.cpp | 2 +- src/gui/theme.cpp | 2 +- src/gui/unregisterdialog.cpp | 2 +- src/gui/updatewindow.cpp | 2 +- src/gui/userpalette.cpp | 2 +- src/gui/widgets/battletab.cpp | 4 +- src/gui/widgets/browserbox.cpp | 2 +- src/gui/widgets/button.cpp | 2 +- src/gui/widgets/chattab.cpp | 4 +- src/gui/widgets/desktop.cpp | 2 +- src/gui/widgets/emoteshortcutcontainer.cpp | 2 +- src/gui/widgets/inventoryfilter.cpp | 2 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/layout.cpp | 2 +- src/gui/widgets/popup.cpp | 2 +- src/gui/widgets/scrollarea.cpp | 2 +- src/gui/widgets/spellshortcutcontainer.cpp | 2 +- src/gui/widgets/tab.cpp | 2 +- src/gui/widgets/tabbedarea.cpp | 2 +- src/gui/widgets/textfield.cpp | 2 +- src/gui/widgets/tradetab.cpp | 4 +- src/gui/widgets/whispertab.cpp | 4 +- src/gui/widgets/window.cpp | 2 +- src/inventory.cpp | 2 +- src/joystick.cpp | 2 +- src/keyboardconfig.cpp | 2 +- src/localplayer.cpp | 2 +- src/log.cpp | 217 ----------------------------- src/log.h | 110 --------------- src/logger.cpp | 217 +++++++++++++++++++++++++++++ src/logger.h | 110 +++++++++++++++ src/main.cpp | 2 +- src/map.cpp | 2 +- src/mumblemanager.cpp | 2 +- src/net/download.cpp | 2 +- src/net/ea/beinghandler.cpp | 2 +- src/net/ea/charserverhandler.cpp | 2 +- src/net/ea/chathandler.cpp | 2 +- src/net/ea/gamehandler.cpp | 2 +- src/net/ea/gui/guildtab.cpp | 2 +- src/net/ea/gui/partytab.cpp | 2 +- src/net/ea/guildhandler.cpp | 2 +- src/net/ea/inventoryhandler.cpp | 2 +- src/net/ea/inventoryhandler.h | 2 +- src/net/ea/loginhandler.cpp | 2 +- src/net/ea/partyhandler.cpp | 2 +- src/net/ea/playerhandler.cpp | 2 +- src/net/ea/specialhandler.cpp | 2 +- src/net/ea/tradehandler.cpp | 2 +- src/net/manaserv/attributes.cpp | 2 +- src/net/manaserv/beinghandler.cpp | 2 +- src/net/manaserv/charhandler.cpp | 2 +- src/net/manaserv/connection.cpp | 2 +- src/net/manaserv/effecthandler.cpp | 2 +- src/net/manaserv/guildhandler.cpp | 2 +- src/net/manaserv/inventoryhandler.cpp | 2 +- src/net/manaserv/itemhandler.cpp | 2 +- src/net/manaserv/loginhandler.cpp | 2 +- src/net/manaserv/network.cpp | 2 +- src/net/manaserv/partyhandler.cpp | 2 +- src/net/manaserv/playerhandler.cpp | 2 +- src/net/messagein.cpp | 2 +- src/net/messageout.cpp | 2 +- src/net/tmwa/adminhandler.cpp | 2 +- src/net/tmwa/beinghandler.cpp | 2 +- src/net/tmwa/charserverhandler.cpp | 2 +- src/net/tmwa/chathandler.cpp | 2 +- src/net/tmwa/gamehandler.cpp | 2 +- src/net/tmwa/generalhandler.cpp | 2 +- src/net/tmwa/gui/guildtab.cpp | 2 +- src/net/tmwa/gui/partytab.cpp | 2 +- src/net/tmwa/guildhandler.cpp | 2 +- src/net/tmwa/inventoryhandler.cpp | 2 +- src/net/tmwa/inventoryhandler.h | 2 +- src/net/tmwa/loginhandler.cpp | 2 +- src/net/tmwa/messagein.cpp | 2 +- src/net/tmwa/messageout.cpp | 2 +- src/net/tmwa/network.cpp | 2 +- src/net/tmwa/partyhandler.cpp | 2 +- src/net/tmwa/playerhandler.cpp | 2 +- src/net/tmwa/specialhandler.cpp | 2 +- src/net/tmwa/tradehandler.cpp | 2 +- src/opengl1graphics.cpp | 2 +- src/openglgraphics.cpp | 2 +- src/particle.cpp | 2 +- src/particleemitter.cpp | 2 +- src/playerinfo.cpp | 2 +- src/properties.h | 2 +- src/resources/animation.cpp | 2 +- src/resources/beinginfo.cpp | 2 +- src/resources/colordb.cpp | 2 +- src/resources/dye.cpp | 2 +- src/resources/emotedb.cpp | 2 +- src/resources/image.cpp | 2 +- src/resources/imageset.cpp | 2 +- src/resources/imagewriter.cpp | 2 +- src/resources/itemdb.cpp | 2 +- src/resources/mapdb.cpp | 2 +- src/resources/mapreader.cpp | 2 +- src/resources/monsterdb.cpp | 2 +- src/resources/music.cpp | 2 +- src/resources/npcdb.cpp | 2 +- src/resources/resource.cpp | 2 +- src/resources/resourcemanager.cpp | 2 +- src/resources/soundeffect.cpp | 2 +- src/resources/specialdb.cpp | 2 +- src/resources/spritedef.cpp | 2 +- src/resources/wallpaper.cpp | 2 +- src/simpleanimation.cpp | 2 +- src/sound.cpp | 2 +- src/spellmanager.cpp | 2 +- src/spellshortcut.h | 2 +- src/statuseffect.cpp | 2 +- src/units.cpp | 2 +- src/utils/mutex.h | 2 +- src/utils/xml.cpp | 2 +- 160 files changed, 777 insertions(+), 775 deletions(-) delete mode 100644 src/chatlog.cpp delete mode 100644 src/chatlog.h create mode 100644 src/chatlogger.cpp create mode 100644 src/chatlogger.h delete mode 100644 src/log.cpp delete mode 100644 src/log.h create mode 100644 src/logger.cpp create mode 100644 src/logger.h (limited to 'src/game.cpp') diff --git a/manaplus.cbp b/manaplus.cbp index e31f4fee9..020e65357 100644 --- a/manaplus.cbp +++ b/manaplus.cbp @@ -117,8 +117,8 @@ - - + + @@ -410,8 +410,8 @@ - - + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9a9d09f97..a48c4f28a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -472,8 +472,8 @@ SET(SRCS being.h spellmanager.cpp spellmanager.h - chatlog.cpp - chatlog.h + chatlogger.cpp + chatlogger.h client.cpp client.h channel.cpp @@ -532,8 +532,8 @@ SET(SRCS listener.h localplayer.cpp localplayer.h - log.cpp - log.h + logger.cpp + logger.h main.cpp main.h map.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 76010cb73..c1287e06c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -479,8 +479,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ being.h \ spellmanager.cpp \ spellmanager.h \ - chatlog.cpp \ - chatlog.h \ + chatlogger.cpp \ + chatlogger.h \ client.cpp \ client.h \ channel.cpp \ @@ -539,8 +539,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ listener.h \ localplayer.cpp \ localplayer.h \ - log.cpp \ - log.h \ + logger.cpp \ + logger.h \ main.cpp \ main.h \ map.cpp\ diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 5f71c6bbb..848e84e0f 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -26,7 +26,7 @@ #include "effectmanager.h" #include "imagesprite.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "simpleanimation.h" #include "sound.h" #include "statuseffect.h" diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 61534c340..e8244bc30 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -24,7 +24,7 @@ #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "playerinfo.h" #include "playerrelations.h" diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 41aabf60c..7414c94bc 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -23,7 +23,7 @@ #include "animatedsprite.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "resources/action.h" #include "resources/animation.h" diff --git a/src/being.cpp b/src/being.cpp index b6f06a75a..7c2a6bf40 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -31,7 +31,7 @@ #include "guild.h" #include "item.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "particle.h" #include "party.h" diff --git a/src/chatlog.cpp b/src/chatlog.cpp deleted file mode 100644 index 99fe317c6..000000000 --- a/src/chatlog.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2009-2010 Andrei Karas - * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "chatlog.h" - -#include -#include -#include - -#include -#include -#include - -#ifdef WIN32 -#include -#elif defined __APPLE__ -#include -#endif - -#include "log.h" -#include "configuration.h" - -#include "utils/stringutils.h" - -#include "debug.h" - -ChatLogger::ChatLogger() -{ -} - -ChatLogger::~ChatLogger() -{ - if (mLogFile.is_open()) - mLogFile.close(); -} - -void ChatLogger::setLogFile(const std::string &logFilename) -{ - if (mLogFile.is_open()) - mLogFile.close(); - - mLogFile.open(logFilename.c_str(), std::ios_base::app); - - if (!mLogFile.is_open()) - { - std::cout << "Warning: error while opening " << logFilename << - " for writing.\n"; - } -} - -void ChatLogger::setLogDir(const std::string &logDir) -{ - mLogDir = logDir; - - if (mLogFile.is_open()) - mLogFile.close(); - - DIR *dir = opendir(mLogDir.c_str()); - if (!dir) - makeDir(mLogDir); - else - closedir(dir); -} - -void ChatLogger::log(std::string str) -{ - std::string dateStr = getDateString(); - if (!mLogFile.is_open() || dateStr != mLogDate) - { - mLogDate = dateStr; - setLogFile(strprintf("%s/%s/#General_%s.log", mLogDir.c_str(), - mServerName.c_str(), dateStr.c_str())); - } - - str = removeColors(str); - writeTo(mLogFile, str); -} - -void ChatLogger::log(std::string name, std::string str) -{ - std::ofstream logFile; - logFile.open(strprintf("%s/%s/%s_%s.log", mLogDir.c_str(), - mServerName.c_str(), secureName(name).c_str(), - getDateString().c_str()).c_str(), std::ios_base::app); - - if (!logFile.is_open()) - return; - - str = removeColors(str); - writeTo(logFile, str); - - if (logFile.is_open()) - logFile.close(); -} - -std::string ChatLogger::getDateString() const -{ - std::string date; - - time_t rawtime; - struct tm *timeinfo; - char buffer [81]; - - time (&rawtime); - timeinfo = localtime(&rawtime); - - strftime(buffer, 79, "%y-%m-%d", timeinfo); - date = buffer; - return date; -} - -std::string ChatLogger::secureName(std::string &name) const -{ - for (unsigned int f = 0; f < name.length(); f ++) - { - if (name[f] < '0' && name[f] > '9' && name[f] < 'a' && name[f] > 'z' - && name[f] < 'A' && name[f] > 'Z' - && name[f] != '-' && name[f] != '+' && name[f] != '=' - && name[f] != '.' && name[f] != ',' && name[f] != ')' - && name[f] != '(' && name[f] != '[' && name[f] != ']') - { - name[f] = '_'; - } - } - return name; -} - -void ChatLogger::writeTo(std::ofstream &file, const std::string &str) const -{ - file << str << std::endl; -} - -void ChatLogger::setServerName(const std::string &serverName) -{ - mServerName = serverName; - if (mServerName == "") - mServerName = config.getStringValue("MostUsedServerName0"); - - if (mLogFile.is_open()) - mLogFile.close(); - - secureName(mServerName); - if (mLogDir != "") - { - DIR *dir = opendir((mLogDir + "/" + mServerName).c_str()); - if (!dir) - makeDir(mLogDir + "/" + mServerName); - else - closedir(dir); - } -} - -void ChatLogger::makeDir(const std::string &dir) -{ -#ifdef WIN32 - mkdir(dir.c_str()); -#else - mkdir(dir.c_str(), 0750); -#endif -} - -void ChatLogger::loadLast(std::string name, std::list &list, - unsigned n) -{ - std::ifstream logFile; - - logFile.open(strprintf("%s/%s/%s_%s.log", mLogDir.c_str(), - mServerName.c_str(), secureName(name).c_str(), - getDateString().c_str()).c_str(), std::ios::in); - - if (!logFile.is_open()) - return; - - char line[710]; - while (logFile.getline(line, 700)) - { - list.push_back(line); - if (list.size() > n) - list.pop_front(); - } - - if (logFile.is_open()) - logFile.close(); -} diff --git a/src/chatlog.h b/src/chatlog.h deleted file mode 100644 index 2e9545b04..000000000 --- a/src/chatlog.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers - * Copyright (C) 2009-2010 Andrei Karas - * - * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef M_CHATLOG_H -#define M_CHATLOG_H - -#include -#include - -class ChatLogger -{ - public: - /** - * Constructor. - */ - ChatLogger(); - - /** - * Destructor, closes log file. - */ - ~ChatLogger(); - - void setLogDir(const std::string &logDir); - - /** - * Enters a message in the log. The message will be timestamped. - */ - void log(std::string str); - - void log(std::string name, std::string str); - - void loadLast(std::string name, std::list &list, - unsigned n); - - std::string getDateString() const; - - std::string secureName(std::string &str) const; - - void setServerName(const std::string &serverName); - - private: - /** - * Sets the file to log to and opens it - */ - void setLogFile(const std::string &logFilename); - - void writeTo(std::ofstream &file, const std::string &str) const; - - void makeDir(const std::string &dir); - - std::ofstream mLogFile; - std::string mLogDir; - std::string mServerName; - std::string mLogDate; -}; - -extern ChatLogger *chatLogger; - -#endif diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp new file mode 100644 index 000000000..067265138 --- /dev/null +++ b/src/chatlogger.cpp @@ -0,0 +1,204 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2009-2010 Andrei Karas + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "chatlogger.h" + +#include +#include +#include + +#include +#include +#include + +#ifdef WIN32 +#include +#elif defined __APPLE__ +#include +#endif + +#include "logger.h" +#include "configuration.h" + +#include "utils/stringutils.h" + +#include "debug.h" + +ChatLogger::ChatLogger() +{ +} + +ChatLogger::~ChatLogger() +{ + if (mLogFile.is_open()) + mLogFile.close(); +} + +void ChatLogger::setLogFile(const std::string &logFilename) +{ + if (mLogFile.is_open()) + mLogFile.close(); + + mLogFile.open(logFilename.c_str(), std::ios_base::app); + + if (!mLogFile.is_open()) + { + std::cout << "Warning: error while opening " << logFilename << + " for writing.\n"; + } +} + +void ChatLogger::setLogDir(const std::string &logDir) +{ + mLogDir = logDir; + + if (mLogFile.is_open()) + mLogFile.close(); + + DIR *dir = opendir(mLogDir.c_str()); + if (!dir) + makeDir(mLogDir); + else + closedir(dir); +} + +void ChatLogger::log(std::string str) +{ + std::string dateStr = getDateString(); + if (!mLogFile.is_open() || dateStr != mLogDate) + { + mLogDate = dateStr; + setLogFile(strprintf("%s/%s/#General_%s.log", mLogDir.c_str(), + mServerName.c_str(), dateStr.c_str())); + } + + str = removeColors(str); + writeTo(mLogFile, str); +} + +void ChatLogger::log(std::string name, std::string str) +{ + std::ofstream logFile; + logFile.open(strprintf("%s/%s/%s_%s.log", mLogDir.c_str(), + mServerName.c_str(), secureName(name).c_str(), + getDateString().c_str()).c_str(), std::ios_base::app); + + if (!logFile.is_open()) + return; + + str = removeColors(str); + writeTo(logFile, str); + + if (logFile.is_open()) + logFile.close(); +} + +std::string ChatLogger::getDateString() const +{ + std::string date; + + time_t rawtime; + struct tm *timeinfo; + char buffer [81]; + + time (&rawtime); + timeinfo = localtime(&rawtime); + + strftime(buffer, 79, "%y-%m-%d", timeinfo); + date = buffer; + return date; +} + +std::string ChatLogger::secureName(std::string &name) const +{ + for (unsigned int f = 0; f < name.length(); f ++) + { + if (name[f] < '0' && name[f] > '9' && name[f] < 'a' && name[f] > 'z' + && name[f] < 'A' && name[f] > 'Z' + && name[f] != '-' && name[f] != '+' && name[f] != '=' + && name[f] != '.' && name[f] != ',' && name[f] != ')' + && name[f] != '(' && name[f] != '[' && name[f] != ']') + { + name[f] = '_'; + } + } + return name; +} + +void ChatLogger::writeTo(std::ofstream &file, const std::string &str) const +{ + file << str << std::endl; +} + +void ChatLogger::setServerName(const std::string &serverName) +{ + mServerName = serverName; + if (mServerName == "") + mServerName = config.getStringValue("MostUsedServerName0"); + + if (mLogFile.is_open()) + mLogFile.close(); + + secureName(mServerName); + if (mLogDir != "") + { + DIR *dir = opendir((mLogDir + "/" + mServerName).c_str()); + if (!dir) + makeDir(mLogDir + "/" + mServerName); + else + closedir(dir); + } +} + +void ChatLogger::makeDir(const std::string &dir) +{ +#ifdef WIN32 + mkdir(dir.c_str()); +#else + mkdir(dir.c_str(), 0750); +#endif +} + +void ChatLogger::loadLast(std::string name, std::list &list, + unsigned n) +{ + std::ifstream logFile; + + logFile.open(strprintf("%s/%s/%s_%s.log", mLogDir.c_str(), + mServerName.c_str(), secureName(name).c_str(), + getDateString().c_str()).c_str(), std::ios::in); + + if (!logFile.is_open()) + return; + + char line[710]; + while (logFile.getline(line, 700)) + { + list.push_back(line); + if (list.size() > n) + list.pop_front(); + } + + if (logFile.is_open()) + logFile.close(); +} diff --git a/src/chatlogger.h b/src/chatlogger.h new file mode 100644 index 000000000..2e9545b04 --- /dev/null +++ b/src/chatlogger.h @@ -0,0 +1,79 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2009-2010 Andrei Karas + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef M_CHATLOG_H +#define M_CHATLOG_H + +#include +#include + +class ChatLogger +{ + public: + /** + * Constructor. + */ + ChatLogger(); + + /** + * Destructor, closes log file. + */ + ~ChatLogger(); + + void setLogDir(const std::string &logDir); + + /** + * Enters a message in the log. The message will be timestamped. + */ + void log(std::string str); + + void log(std::string name, std::string str); + + void loadLast(std::string name, std::list &list, + unsigned n); + + std::string getDateString() const; + + std::string secureName(std::string &str) const; + + void setServerName(const std::string &serverName); + + private: + /** + * Sets the file to log to and opens it + */ + void setLogFile(const std::string &logFilename); + + void writeTo(std::ofstream &file, const std::string &str) const; + + void makeDir(const std::string &dir); + + std::ofstream mLogFile; + std::string mLogDir; + std::string mServerName; + std::string mLogDate; +}; + +extern ChatLogger *chatLogger; + +#endif diff --git a/src/client.cpp b/src/client.cpp index 022bc07d5..e85c5b08f 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -23,7 +23,7 @@ #include "client.h" #include "main.h" -#include "chatlog.h" +#include "chatlogger.h" #include "configuration.h" #include "dropshortcut.h" #include "emoteshortcut.h" diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index dc9a4d1bf..f650ac8d1 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -27,7 +27,7 @@ #include "channel.h" #include "game.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "gui/chatwindow.h" diff --git a/src/configuration.cpp b/src/configuration.cpp index 7d1f41fe5..2524d6b93 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -23,7 +23,7 @@ #include "configuration.h" #include "configlistener.h" -#include "log.h" +#include "logger.h" #include "utils/paths.h" #include "utils/stringutils.h" diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index bb54ced99..36e7aac16 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -21,7 +21,7 @@ #include "being.h" #include "effectmanager.h" -#include "log.h" +#include "logger.h" #include "particle.h" #include "sound.h" diff --git a/src/filefilter.txt b/src/filefilter.txt index b2b1e7d0c..0dde8e90c 100644 --- a/src/filefilter.txt +++ b/src/filefilter.txt @@ -1,5 +1,6 @@ ~ RULE_3_1_A_do_not_start_filename_with_underbar ~ RULE_3_2_CD_do_not_use_special_characters_in_filename +~ RULE_3_2_F_use_representitive_classname_for_cpp_filename ~ RULE_3_2_H_do_not_use_uppercase_for_c_filename ~ RULE_3_3_A_start_function_name_with_lowercase_unix ~ RULE_4_1_A_B_use_space_for_indentation @@ -23,3 +24,4 @@ ~ RULE_8_1_A_provide_file_info_comment ~ RULE_9_1_A_do_not_use_hardcorded_include_path ~ RULE_9_2_D_use_reentrant_function + diff --git a/src/game.cpp b/src/game.cpp index 4332c8e11..4967231b0 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -42,7 +42,7 @@ #include "joystick.h" #include "keyboardconfig.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "particle.h" #include "playerrelations.h" diff --git a/src/graphics.cpp b/src/graphics.cpp index 6a6760c36..a86ac7fd0 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -25,7 +25,7 @@ #include "graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "resources/image.h" diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index d424fff91..c24624bc2 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -23,7 +23,7 @@ #include "gui/changeemaildialog.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "gui/register.h" #include "gui/okdialog.h" diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index dc640841a..30012ae52 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -23,7 +23,7 @@ #include "changepassworddialog.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "gui/register.h" #include "gui/okdialog.h" diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 264df06e3..28c7a083c 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -26,7 +26,7 @@ #include "game.h" #include "localplayer.h" #include "units.h" -#include "log.h" +#include "logger.h" #include "gui/changeemaildialog.h" #include "gui/changepassworddialog.h" diff --git a/src/gui/connectiondialog.cpp b/src/gui/connectiondialog.cpp index 157398297..da98ea5ac 100644 --- a/src/gui/connectiondialog.cpp +++ b/src/gui/connectiondialog.cpp @@ -22,7 +22,7 @@ #include "connectiondialog.h" -#include "log.h" +#include "logger.h" #include "gui/widgets/button.h" #include "gui/widgets/label.h" diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp index 03188907f..4d89bd924 100644 --- a/src/gui/didyouknowwindow.cpp +++ b/src/gui/didyouknowwindow.cpp @@ -22,7 +22,7 @@ #include "gui/didyouknowwindow.h" -#include "log.h" +#include "logger.h" #include "gui/gui.h" #include "gui/setup.h" diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp index 3a754d0e3..348a97952 100644 --- a/src/gui/emotepopup.cpp +++ b/src/gui/emotepopup.cpp @@ -28,7 +28,7 @@ #include "emoteshortcut.h" #include "graphics.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/theme.h" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 0bea1d0d7..3e4ec764f 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -35,7 +35,7 @@ #include "configlistener.h" #include "configuration.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "resources/image.h" #include "resources/imageset.h" diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index ae0a432ea..368049389 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -22,7 +22,7 @@ #include "gui/helpwindow.h" -#include "log.h" +#include "logger.h" #include "gui/gui.h" #include "gui/setup.h" diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 5022f9210..c735eec82 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -27,7 +27,7 @@ #include "configuration.h" #include "graphics.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "gui/userpalette.h" diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 9dd41a643..09e75856f 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -28,7 +28,7 @@ #include "inventory.h" #include "item.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "gui/chatwindow.h" diff --git a/src/gui/palette.h b/src/gui/palette.h index 9409bfc06..1cebe236f 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -24,7 +24,7 @@ #ifndef PALETTE_H #define PALETTE_H -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" #include diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 14a326e41..86ddfda53 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -32,7 +32,7 @@ #include "item.h" #include "itemshortcut.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "party.h" #include "playerinfo.h" diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 80ddb7469..913c958f2 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -24,7 +24,7 @@ #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "gui/logindialog.h" #include "gui/okdialog.h" diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index a0f8699f8..8dd7f929d 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -25,7 +25,7 @@ #include "client.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "resources/image.h" diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 41b0076e1..37870a87f 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -22,10 +22,10 @@ #include "gui/serverdialog.h" -#include "chatlog.h" +#include "chatlogger.h" #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "gui/gui.h" diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index 28e6d8cfa..1737e9004 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -23,7 +23,7 @@ #include "gui/setup_audio.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "sound.h" #include "gui/okdialog.h" diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp index 621f62810..7ce44a552 100644 --- a/src/gui/setup_chat.cpp +++ b/src/gui/setup_chat.cpp @@ -37,7 +37,7 @@ #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "utils/gettext.h" diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp index 3675da4ca..3b603a8ee 100644 --- a/src/gui/setup_other.cpp +++ b/src/gui/setup_other.cpp @@ -29,7 +29,7 @@ #include "gui/widgets/scrollarea.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "utils/gettext.h" diff --git a/src/gui/setup_perfomance.cpp b/src/gui/setup_perfomance.cpp index eaadc7c3a..583f2909a 100644 --- a/src/gui/setup_perfomance.cpp +++ b/src/gui/setup_perfomance.cpp @@ -37,7 +37,7 @@ #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "utils/gettext.h" diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 7490135cd..d2664adbd 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -37,7 +37,7 @@ #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "utils/gettext.h" diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 646d47550..93887b133 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -25,7 +25,7 @@ #include "actorspritemanager.h" #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/editdialog.h" #include "gui/okdialog.h" diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp index 42ed0205c..7a2c66595 100644 --- a/src/gui/setup_theme.cpp +++ b/src/gui/setup_theme.cpp @@ -37,7 +37,7 @@ #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "utils/gettext.h" diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 8979a81e1..03b485097 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -26,7 +26,7 @@ #include "game.h" #include "graphics.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "particle.h" diff --git a/src/gui/setupitem.cpp b/src/gui/setupitem.cpp index 182501e72..defdb4005 100644 --- a/src/gui/setupitem.cpp +++ b/src/gui/setupitem.cpp @@ -22,7 +22,7 @@ #include "configuration.h" #include "main.h" -#include "log.h" +#include "logger.h" #include "gui/editdialog.h" diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 5b47a5494..896f06cab 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -22,7 +22,7 @@ #include "gui/skilldialog.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "configuration.h" diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index adcfe4d70..e3aa69b30 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -25,7 +25,7 @@ #include "guild.h" #include "keyboardconfig.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "party.h" diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index 1c41752f3..a5d95c7ff 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -21,7 +21,7 @@ #include "gui/specialswindow.h" -#include "log.h" +#include "logger.h" #include "gui/setup.h" #include "gui/theme.h" diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 92613a3b3..056eafc0f 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -26,7 +26,7 @@ #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "resources/dye.h" #include "resources/image.h" diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 8f845e746..568e0613e 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -23,7 +23,7 @@ #include "gui/unregisterdialog.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "gui/okdialog.h" #include "gui/register.h" diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index eb5471e2a..895c99121 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -24,7 +24,7 @@ #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "gui/sdlinput.h" diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index 40dddc4f1..eac9559ef 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -25,7 +25,7 @@ #include "configuration.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "gui/gui.h" diff --git a/src/gui/widgets/battletab.cpp b/src/gui/widgets/battletab.cpp index e72c78ee0..c5500e801 100644 --- a/src/gui/widgets/battletab.cpp +++ b/src/gui/widgets/battletab.cpp @@ -22,10 +22,10 @@ #include "gui/widgets/battletab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "gui/theme.h" diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 140a72770..7df70bd04 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -25,7 +25,7 @@ #include "client.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 0570630c3..2d9678a53 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -26,7 +26,7 @@ #include "configuration.h" #include "graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "gui/palette.h" #include "gui/theme.h" diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 42a39a20f..e27af8b25 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -23,11 +23,11 @@ #include "gui/widgets/chattab.h" #include "actorspritemanager.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "sound.h" #include "gui/widgets/browserbox.h" diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 3ade3b37f..cfb757638 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -22,7 +22,7 @@ #include "configuration.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "gui/palette.h" diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index bb5af4b1c..5bb972adc 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -29,7 +29,7 @@ #include "itemshortcut.h" #include "keyboardconfig.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/palette.h" #include "gui/textpopup.h" diff --git a/src/gui/widgets/inventoryfilter.cpp b/src/gui/widgets/inventoryfilter.cpp index 563e37b8c..795f0d31e 100644 --- a/src/gui/widgets/inventoryfilter.cpp +++ b/src/gui/widgets/inventoryfilter.cpp @@ -23,7 +23,7 @@ #include "gui/widgets/horizontcontainer.h" #include "gui/widgets/radiobutton.h" -#include "log.h" +#include "logger.h" #include "debug.h" diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 7818432f8..b79f26226 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -27,7 +27,7 @@ #include "item.h" #include "itemshortcut.h" #include "dropshortcut.h" -#include "log.h" +#include "logger.h" #include "gui/chatwindow.h" #include "gui/itempopup.h" diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index 274c17d61..382d169dc 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -22,7 +22,7 @@ #include "gui/widgets/layout.h" -#include "log.h" +#include "logger.h" #include diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index ea51c146a..38088770b 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -26,7 +26,7 @@ #include "configuration.h" #include "graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "gui/theme.h" #include "gui/viewport.h" diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index df39854da..08f0b5a70 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -26,7 +26,7 @@ #include "configuration.h" #include "graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "gui/theme.h" diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 872ed16c7..8d5b563bb 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -40,7 +40,7 @@ #include "keyboardconfig.h" #include "localplayer.h" #include "spellmanager.h" -#include "log.h" +#include "logger.h" #include "resources/image.h" #include "textcommand.h" diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 1b548a6a3..b7d6b4458 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -26,7 +26,7 @@ #include "configuration.h" #include "graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "gui/palette.h" #include "gui/theme.h" diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index d3539a115..940dad12a 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -25,7 +25,7 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/tab.h" -#include "log.h" +#include "logger.h" #include diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index d3108a77f..f80039650 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -25,7 +25,7 @@ #include "client.h" #include "configuration.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "gui/palette.h" #include "gui/sdlinput.h" diff --git a/src/gui/widgets/tradetab.cpp b/src/gui/widgets/tradetab.cpp index 99a145d86..deec2aea6 100644 --- a/src/gui/widgets/tradetab.cpp +++ b/src/gui/widgets/tradetab.cpp @@ -22,10 +22,10 @@ #include "gui/widgets/tradetab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/theme.h" diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index bee30b969..c99c4e0c5 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -22,10 +22,10 @@ #include "gui/widgets/whispertab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/theme.h" diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 14448ea86..9a7c689e6 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -25,7 +25,7 @@ #include "client.h" #include "configuration.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "gui/gui.h" #include "gui/palette.h" diff --git a/src/inventory.cpp b/src/inventory.cpp index 3ff40374a..acd35efdd 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -22,7 +22,7 @@ #include "inventory.h" #include "item.h" -#include "log.h" +#include "logger.h" #include "net/inventoryhandler.h" #include "net/net.h" diff --git a/src/joystick.cpp b/src/joystick.cpp index f1255c4c0..8f808a2d1 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -22,7 +22,7 @@ #include "configuration.h" #include "joystick.h" -#include "log.h" +#include "logger.h" #include diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index 8ad38ab76..bf58c518a 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -20,7 +20,7 @@ #include "configuration.h" #include "keyboardconfig.h" -#include "log.h" +#include "logger.h" #include "gui/sdlinput.h" #include "gui/setup_keyboard.h" diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 0310bb8ad..a9e9d1f21 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -31,7 +31,7 @@ #include "guild.h" #include "item.h" #include "keyboardconfig.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "party.h" #include "particle.h" diff --git a/src/log.cpp b/src/log.cpp deleted file mode 100644 index 9bcf1ea4f..000000000 --- a/src/log.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-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 . - */ - -#include -#include - -#include "log.h" - -#include "configuration.h" - -#include "gui/widgets/chattab.h" - -#ifdef WIN32 -#include -#elif defined __APPLE__ -#include -#elif __linux__ || __linux -#include -#endif - -#include - -#include "debug.h" - -Logger::Logger(): - mLogToStandardOut(true), - mChatWindow(NULL), - mDebugLog(false) -{ -} - -Logger::~Logger() -{ - if (mLogFile.is_open()) - { - mLogFile.close(); - } -} - -void Logger::setLogFile(const std::string &logFilename) -{ - if (mLogFile.is_open()) - mLogFile.close(); - - mLogFile.open(logFilename.c_str(), std::ios_base::trunc); - - if (!mLogFile.is_open()) - { - std::cout << "Warning: error while opening " << logFilename << - " for writing.\n"; - } -} - -void Logger::log(std::string str) -{ - log("%s", str.c_str()); -} - -void Logger::dlog(std::string str) -{ - if (!mDebugLog) - return; - - // Get the current system time - timeval tv; - gettimeofday(&tv, NULL); - - // Print the log entry - std::stringstream timeStr; - timeStr << "[" - << ((((tv.tv_sec / 60) / 60) % 24 < 10) ? "0" : "") - << static_cast(((tv.tv_sec / 60) / 60) % 24) - << ":" - << (((tv.tv_sec / 60) % 60 < 10) ? "0" : "") - << static_cast((tv.tv_sec / 60) % 60) - << ":" - << ((tv.tv_sec % 60 < 10) ? "0" : "") - << static_cast(tv.tv_sec % 60) - << "." - << (((tv.tv_usec / 10000) % 100) < 10 ? "0" : "") - << static_cast((tv.tv_usec / 10000) % 100) - << "] "; - - if (mLogFile.is_open()) - mLogFile << timeStr.str() << str << std::endl; - - if (mLogToStandardOut) - std::cout << timeStr.str() << str << std::endl; - - if (mChatWindow && debugChatTab) - debugChatTab->chatLog(str, BY_LOGGER); -} - -void Logger::log1(const char *buf) -{ - // Get the current system time - timeval tv; - gettimeofday(&tv, NULL); - - // Print the log entry - std::stringstream timeStr; - timeStr << "[" - << ((((tv.tv_sec / 60) / 60) % 24 < 10) ? "0" : "") - << static_cast(((tv.tv_sec / 60) / 60) % 24) - << ":" - << (((tv.tv_sec / 60) % 60 < 10) ? "0" : "") - << static_cast((tv.tv_sec / 60) % 60) - << ":" - << ((tv.tv_sec % 60 < 10) ? "0" : "") - << static_cast(tv.tv_sec % 60) - << "." - << (((tv.tv_usec / 10000) % 100) < 10 ? "0" : "") - << static_cast((tv.tv_usec / 10000) % 100) - << "] "; - - if (mLogFile.is_open()) - mLogFile << timeStr.str() << buf << std::endl; - - if (mLogToStandardOut) - std::cout << timeStr.str() << buf << std::endl; - - if (mChatWindow && debugChatTab) - debugChatTab->chatLog(buf, BY_LOGGER); -} - -void Logger::log(const char *log_text, ...) -{ - unsigned size = 1024; - char* buf = 0; - if (strlen(log_text) * 3> size) - size = static_cast(strlen(log_text) * 3); - - buf = new char[size + 1]; - va_list ap; - - // Use a temporary buffer to fill in the variables - va_start(ap, log_text); - vsnprintf(buf, size, log_text, ap); - buf[size] = 0; - va_end(ap); - - // Get the current system time - timeval tv; - gettimeofday(&tv, NULL); - - // Print the log entry - std::stringstream timeStr; - timeStr << "[" - << ((((tv.tv_sec / 60) / 60) % 24 < 10) ? "0" : "") - << static_cast(((tv.tv_sec / 60) / 60) % 24) - << ":" - << (((tv.tv_sec / 60) % 60 < 10) ? "0" : "") - << static_cast((tv.tv_sec / 60) % 60) - << ":" - << ((tv.tv_sec % 60 < 10) ? "0" : "") - << static_cast(tv.tv_sec % 60) - << "." - << (((tv.tv_usec / 10000) % 100) < 10 ? "0" : "") - << static_cast((tv.tv_usec / 10000) % 100) - << "] "; - - if (mLogFile.is_open()) - mLogFile << timeStr.str() << buf << std::endl; - - if (mLogToStandardOut) - std::cout << timeStr.str() << buf << std::endl; - - if (mChatWindow && debugChatTab) - debugChatTab->chatLog(buf, BY_LOGGER); - - // Delete temporary buffer - delete[] buf; -} - -void Logger::error(const std::string &error_text) -{ - log("Error: %s", error_text.c_str()); -#ifdef WIN32 - MessageBox(NULL, error_text.c_str(), "Error", MB_ICONERROR | MB_OK); -#elif defined __APPLE__ -// Str255 msg; -// CFStringRef error; -// error = CFStringCreateWithCString(NULL, -// error_text.c_str(), -// kCFStringEncodingMacRoman); -// CFStringGetPascalString(error, msg, 255, kCFStringEncodingMacRoman); -// StandardAlert(kAlertStopAlert, -// (const unsigned char*)"\pError", -// (ConstStr255Param) msg, NULL, NULL); -#elif defined __linux__ || __linux - std::cerr << "Error: " << error_text << std::endl; - std::string msg = "xmessage \"" + error_text + "\""; - system(msg.c_str()); -#else - std::cerr << "Error: " << error_text << std::endl; -#endif - exit(1); -} diff --git a/src/log.h b/src/log.h deleted file mode 100644 index b8517f696..000000000 --- a/src/log.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-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 . - */ - -#ifndef M_LOG_H -#define M_LOG_H - -#include "main.h" -#include - -class ChatWindow; - -#ifdef ENABLEDEBUGLOG -#define DEBUGLOG(msg) logger->dlog(msg) -#else -#define DEBUGLOG(msg) {} -#endif - -/** - * The Log Class : Useful to write debug or info messages - */ -class Logger -{ - public: - /** - * Constructor. - */ - Logger(); - - /** - * Destructor, closes log file. - */ - ~Logger(); - - /** - * Sets the file to log to and opens it - */ - void setLogFile(const std::string &logFilename); - - /** - * Sets whether the log should be written to standard output. - */ - void setLogToStandardOut(bool value) { mLogToStandardOut = value; } - - /** - * Enables logging to chat window - */ - void setChatWindow(ChatWindow *window) { mChatWindow = window; } - - /** - * Enters a message in the log. The message will be timestamped. - */ - void log(const char *log_text, ...) -#ifdef __GNUC__ - __attribute__((__format__(__printf__, 2, 3))) -#endif - ; - - /** - * Enters a message in the log. The message will be timestamped. - */ - void log1(const char *log_text); - - /** - * Enters a message in the log. The message will be timestamped. - */ - void log(std::string str); - - /** - * Enters debug message in the log. The message will be timestamped. - */ - void dlog(std::string str); - - void setDebugLog(bool n) - { mDebugLog = n; } - - /** - * Log an error and quit. The error will pop-up on Windows and Mac, and - * will be printed to standard error everywhere else. - */ - void error(const std::string &error_text) __attribute__ ((noreturn)); - - private: - std::ofstream mLogFile; - bool mLogToStandardOut; - ChatWindow *mChatWindow; - bool mDebugLog; -}; - -extern Logger *logger; - -#endif diff --git a/src/logger.cpp b/src/logger.cpp new file mode 100644 index 000000000..6790d622a --- /dev/null +++ b/src/logger.cpp @@ -0,0 +1,217 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-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 . + */ + +#include +#include + +#include "logger.h" + +#include "configuration.h" + +#include "gui/widgets/chattab.h" + +#ifdef WIN32 +#include +#elif defined __APPLE__ +#include +#elif __linux__ || __linux +#include +#endif + +#include + +#include "debug.h" + +Logger::Logger(): + mLogToStandardOut(true), + mChatWindow(NULL), + mDebugLog(false) +{ +} + +Logger::~Logger() +{ + if (mLogFile.is_open()) + { + mLogFile.close(); + } +} + +void Logger::setLogFile(const std::string &logFilename) +{ + if (mLogFile.is_open()) + mLogFile.close(); + + mLogFile.open(logFilename.c_str(), std::ios_base::trunc); + + if (!mLogFile.is_open()) + { + std::cout << "Warning: error while opening " << logFilename << + " for writing.\n"; + } +} + +void Logger::log(std::string str) +{ + log("%s", str.c_str()); +} + +void Logger::dlog(std::string str) +{ + if (!mDebugLog) + return; + + // Get the current system time + timeval tv; + gettimeofday(&tv, NULL); + + // Print the log entry + std::stringstream timeStr; + timeStr << "[" + << ((((tv.tv_sec / 60) / 60) % 24 < 10) ? "0" : "") + << static_cast(((tv.tv_sec / 60) / 60) % 24) + << ":" + << (((tv.tv_sec / 60) % 60 < 10) ? "0" : "") + << static_cast((tv.tv_sec / 60) % 60) + << ":" + << ((tv.tv_sec % 60 < 10) ? "0" : "") + << static_cast(tv.tv_sec % 60) + << "." + << (((tv.tv_usec / 10000) % 100) < 10 ? "0" : "") + << static_cast((tv.tv_usec / 10000) % 100) + << "] "; + + if (mLogFile.is_open()) + mLogFile << timeStr.str() << str << std::endl; + + if (mLogToStandardOut) + std::cout << timeStr.str() << str << std::endl; + + if (mChatWindow && debugChatTab) + debugChatTab->chatLog(str, BY_LOGGER); +} + +void Logger::log1(const char *buf) +{ + // Get the current system time + timeval tv; + gettimeofday(&tv, NULL); + + // Print the log entry + std::stringstream timeStr; + timeStr << "[" + << ((((tv.tv_sec / 60) / 60) % 24 < 10) ? "0" : "") + << static_cast(((tv.tv_sec / 60) / 60) % 24) + << ":" + << (((tv.tv_sec / 60) % 60 < 10) ? "0" : "") + << static_cast((tv.tv_sec / 60) % 60) + << ":" + << ((tv.tv_sec % 60 < 10) ? "0" : "") + << static_cast(tv.tv_sec % 60) + << "." + << (((tv.tv_usec / 10000) % 100) < 10 ? "0" : "") + << static_cast((tv.tv_usec / 10000) % 100) + << "] "; + + if (mLogFile.is_open()) + mLogFile << timeStr.str() << buf << std::endl; + + if (mLogToStandardOut) + std::cout << timeStr.str() << buf << std::endl; + + if (mChatWindow && debugChatTab) + debugChatTab->chatLog(buf, BY_LOGGER); +} + +void Logger::log(const char *log_text, ...) +{ + unsigned size = 1024; + char* buf = 0; + if (strlen(log_text) * 3> size) + size = static_cast(strlen(log_text) * 3); + + buf = new char[size + 1]; + va_list ap; + + // Use a temporary buffer to fill in the variables + va_start(ap, log_text); + vsnprintf(buf, size, log_text, ap); + buf[size] = 0; + va_end(ap); + + // Get the current system time + timeval tv; + gettimeofday(&tv, NULL); + + // Print the log entry + std::stringstream timeStr; + timeStr << "[" + << ((((tv.tv_sec / 60) / 60) % 24 < 10) ? "0" : "") + << static_cast(((tv.tv_sec / 60) / 60) % 24) + << ":" + << (((tv.tv_sec / 60) % 60 < 10) ? "0" : "") + << static_cast((tv.tv_sec / 60) % 60) + << ":" + << ((tv.tv_sec % 60 < 10) ? "0" : "") + << static_cast(tv.tv_sec % 60) + << "." + << (((tv.tv_usec / 10000) % 100) < 10 ? "0" : "") + << static_cast((tv.tv_usec / 10000) % 100) + << "] "; + + if (mLogFile.is_open()) + mLogFile << timeStr.str() << buf << std::endl; + + if (mLogToStandardOut) + std::cout << timeStr.str() << buf << std::endl; + + if (mChatWindow && debugChatTab) + debugChatTab->chatLog(buf, BY_LOGGER); + + // Delete temporary buffer + delete[] buf; +} + +void Logger::error(const std::string &error_text) +{ + log("Error: %s", error_text.c_str()); +#ifdef WIN32 + MessageBox(NULL, error_text.c_str(), "Error", MB_ICONERROR | MB_OK); +#elif defined __APPLE__ +// Str255 msg; +// CFStringRef error; +// error = CFStringCreateWithCString(NULL, +// error_text.c_str(), +// kCFStringEncodingMacRoman); +// CFStringGetPascalString(error, msg, 255, kCFStringEncodingMacRoman); +// StandardAlert(kAlertStopAlert, +// (const unsigned char*)"\pError", +// (ConstStr255Param) msg, NULL, NULL); +#elif defined __linux__ || __linux + std::cerr << "Error: " << error_text << std::endl; + std::string msg = "xmessage \"" + error_text + "\""; + system(msg.c_str()); +#else + std::cerr << "Error: " << error_text << std::endl; +#endif + exit(1); +} diff --git a/src/logger.h b/src/logger.h new file mode 100644 index 000000000..b8517f696 --- /dev/null +++ b/src/logger.h @@ -0,0 +1,110 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-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 . + */ + +#ifndef M_LOG_H +#define M_LOG_H + +#include "main.h" +#include + +class ChatWindow; + +#ifdef ENABLEDEBUGLOG +#define DEBUGLOG(msg) logger->dlog(msg) +#else +#define DEBUGLOG(msg) {} +#endif + +/** + * The Log Class : Useful to write debug or info messages + */ +class Logger +{ + public: + /** + * Constructor. + */ + Logger(); + + /** + * Destructor, closes log file. + */ + ~Logger(); + + /** + * Sets the file to log to and opens it + */ + void setLogFile(const std::string &logFilename); + + /** + * Sets whether the log should be written to standard output. + */ + void setLogToStandardOut(bool value) { mLogToStandardOut = value; } + + /** + * Enables logging to chat window + */ + void setChatWindow(ChatWindow *window) { mChatWindow = window; } + + /** + * Enters a message in the log. The message will be timestamped. + */ + void log(const char *log_text, ...) +#ifdef __GNUC__ + __attribute__((__format__(__printf__, 2, 3))) +#endif + ; + + /** + * Enters a message in the log. The message will be timestamped. + */ + void log1(const char *log_text); + + /** + * Enters a message in the log. The message will be timestamped. + */ + void log(std::string str); + + /** + * Enters debug message in the log. The message will be timestamped. + */ + void dlog(std::string str); + + void setDebugLog(bool n) + { mDebugLog = n; } + + /** + * Log an error and quit. The error will pop-up on Windows and Mac, and + * will be printed to standard error everywhere else. + */ + void error(const std::string &error_text) __attribute__ ((noreturn)); + + private: + std::ofstream mLogFile; + bool mLogToStandardOut; + ChatWindow *mChatWindow; + bool mDebugLog; +}; + +extern Logger *logger; + +#endif diff --git a/src/main.cpp b/src/main.cpp index faeedadaa..5c13b10ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,7 @@ #include "utils/gettext.h" #include "client.h" -#include "log.h" +#include "logger.h" #include diff --git a/src/map.cpp b/src/map.cpp index 8225aded1..700f6d0d2 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -27,7 +27,7 @@ #include "configuration.h" #include "graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "particle.h" #include "simpleanimation.h" #include "tileset.h" diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp index 456606406..a9a8146b6 100644 --- a/src/mumblemanager.cpp +++ b/src/mumblemanager.cpp @@ -3,7 +3,7 @@ #include "mumblemanager.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "utils/mathutils.h" diff --git a/src/net/download.cpp b/src/net/download.cpp index c93f33c21..93417197e 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -22,7 +22,7 @@ #include "net/download.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "utils/stringutils.h" diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index ee070593f..06e86f8a4 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -31,7 +31,7 @@ #include "guild.h" #include "keyboardconfig.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "party.h" #include "playerrelations.h" #include "configuration.h" diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index c69d8a5be..a0e5b392a 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -23,7 +23,7 @@ #include "net/ea/charserverhandler.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "gui/charcreatedialog.h" #include "gui/okdialog.h" diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index ea9d17798..c188a2204 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -27,7 +27,7 @@ #include "configuration.h" #include "localplayer.h" #include "playerrelations.h" -#include "log.h" +#include "logger.h" #include "gui/chatwindow.h" #include "gui/shopwindow.h" diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index 0b6b8a040..04c13572f 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -26,7 +26,7 @@ #include "event.h" #include "game.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/okdialog.h" diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index 037885fd1..ab030be83 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -22,7 +22,7 @@ #include "net/ea/gui/guildtab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "guild.h" #include "localplayer.h" diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index 02e0910a7..23eab361c 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -22,7 +22,7 @@ #include "net/ea/gui/partytab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "localplayer.h" #include "party.h" diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index bb5cbe94b..0210a76ff 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -25,7 +25,7 @@ #include "guild.h" #include "event.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/socialwindow.h" diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 2e52b85ff..d921b5e2a 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -24,7 +24,7 @@ #include "inventory.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/ministatus.h" diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 1f1f8d296..4be4ddaa6 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -25,7 +25,7 @@ #include "equipment.h" #include "inventory.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "gui/inventorywindow.h" diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 51502895c..9f7a5f07d 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -23,7 +23,7 @@ #include "net/ea/loginhandler.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "configuration.h" #include "utils/dtor.h" diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index f720f9f96..045a2332b 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -22,7 +22,7 @@ #include "actorspritemanager.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/socialwindow.h" diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 05b6cf9e3..4198c14ad 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -22,7 +22,7 @@ #include "net/ea/playerhandler.h" -#include "log.h" +#include "logger.h" #include "party.h" #include "playerinfo.h" #include "units.h" diff --git a/src/net/ea/specialhandler.cpp b/src/net/ea/specialhandler.cpp index 33fea3b27..4f0f22aed 100644 --- a/src/net/ea/specialhandler.cpp +++ b/src/net/ea/specialhandler.cpp @@ -22,7 +22,7 @@ #include "net/ea/specialhandler.h" -#include "log.h" +#include "logger.h" #include "localplayer.h" #include "playerinfo.h" diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index 36a5f8811..a03782db2 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -25,7 +25,7 @@ #include "event.h" #include "inventory.h" #include "item.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "playerrelations.h" diff --git a/src/net/manaserv/attributes.cpp b/src/net/manaserv/attributes.cpp index b48cc9eff..25c75f9d8 100644 --- a/src/net/manaserv/attributes.cpp +++ b/src/net/manaserv/attributes.cpp @@ -21,7 +21,7 @@ #include "net/manaserv/attributes.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "gui/statuswindow.h" diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp index 23aae1f56..d14cdcadf 100644 --- a/src/net/manaserv/beinghandler.cpp +++ b/src/net/manaserv/beinghandler.cpp @@ -27,7 +27,7 @@ #include "client.h" #include "game.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "particle.h" #include "gui/okdialog.h" diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index c2611c64b..3b2306feb 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -24,7 +24,7 @@ #include "client.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/charcreatedialog.h" #include "gui/okdialog.h" diff --git a/src/net/manaserv/connection.cpp b/src/net/manaserv/connection.cpp index 7f51aeb98..33d6f28cf 100644 --- a/src/net/manaserv/connection.cpp +++ b/src/net/manaserv/connection.cpp @@ -22,7 +22,7 @@ #include "net/manaserv/connection.h" -#include "log.h" +#include "logger.h" #include "net/manaserv/internal.h" #include "net/manaserv/messageout.h" diff --git a/src/net/manaserv/effecthandler.cpp b/src/net/manaserv/effecthandler.cpp index 3979a0fde..92cf66302 100644 --- a/src/net/manaserv/effecthandler.cpp +++ b/src/net/manaserv/effecthandler.cpp @@ -24,7 +24,7 @@ #include "actorspritemanager.h" #include "effectmanager.h" -#include "log.h" +#include "logger.h" #include "net/messagein.h" diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp index dc3dbc616..306a15be4 100644 --- a/src/net/manaserv/guildhandler.cpp +++ b/src/net/manaserv/guildhandler.cpp @@ -24,7 +24,7 @@ #include "event.h" #include "guild.h" -#include "log.h" +#include "logger.h" #include "localplayer.h" #include "channel.h" #include "channelmanager.h" diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp index 5e38354fb..ce837b5e1 100644 --- a/src/net/manaserv/inventoryhandler.cpp +++ b/src/net/manaserv/inventoryhandler.cpp @@ -38,7 +38,7 @@ #include "resources/iteminfo.h" -#include "log.h" // <<< REMOVE ME! +#include "logger.h" // <<< REMOVE ME! extern Net::InventoryHandler *inventoryHandler; diff --git a/src/net/manaserv/itemhandler.cpp b/src/net/manaserv/itemhandler.cpp index 0afd12d21..89826a33f 100644 --- a/src/net/manaserv/itemhandler.cpp +++ b/src/net/manaserv/itemhandler.cpp @@ -29,7 +29,7 @@ #include "game.h" #include "map.h" -#include "log.h" +#include "logger.h" namespace ManaServ { diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp index e6109ca28..bf823562f 100644 --- a/src/net/manaserv/loginhandler.cpp +++ b/src/net/manaserv/loginhandler.cpp @@ -23,7 +23,7 @@ #include "net/manaserv/loginhandler.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "net/logindata.h" diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp index e0ab7af78..53e83e4ec 100644 --- a/src/net/manaserv/network.cpp +++ b/src/net/manaserv/network.cpp @@ -22,7 +22,7 @@ #include "net/manaserv/network.h" -#include "log.h" +#include "logger.h" #include "net/manaserv/connection.h" #include "net/manaserv/internal.h" diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp index 0e6af4578..987a40dc5 100644 --- a/src/net/manaserv/partyhandler.cpp +++ b/src/net/manaserv/partyhandler.cpp @@ -23,7 +23,7 @@ #include "net/manaserv/partyhandler.h" #include "event.h" -#include "log.h" +#include "logger.h" #include "localplayer.h" #include "gui/socialwindow.h" diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index ca7fe511f..3dfddb436 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -27,7 +27,7 @@ #include "effectmanager.h" #include "game.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "particle.h" #include "playerinfo.h" #include "configuration.h" diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 8b5f2eee3..5bfeefdb6 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -24,7 +24,7 @@ #include "net/packetcounters.h" -#include "log.h" +#include "logger.h" #include "net.h" #include "utils/stringutils.h" diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index 3cdcb42e0..a8b66f5ae 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -24,7 +24,7 @@ #include "net/packetcounters.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp index a0d996dbf..a332b04fa 100644 --- a/src/net/tmwa/adminhandler.cpp +++ b/src/net/tmwa/adminhandler.cpp @@ -28,7 +28,7 @@ #include "being.h" #include "event.h" #include "game.h" -#include "log.h" +#include "logger.h" #include "playerrelations.h" #include "net/chathandler.h" diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index d6f67f716..17503a406 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -29,7 +29,7 @@ #include "guild.h" #include "keyboardconfig.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "party.h" #include "playerrelations.h" #include "configuration.h" diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index fe803dc62..7aa68e617 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -24,7 +24,7 @@ #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "gui/charcreatedialog.h" diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 0f23f6412..90acf0f90 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -29,7 +29,7 @@ #include "game.h" #include "localplayer.h" #include "playerrelations.h" -#include "log.h" +#include "logger.h" #include "gui/chatwindow.h" #include "gui/shopwindow.h" diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index cc0a37c57..242e9f9de 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -26,7 +26,7 @@ #include "event.h" #include "game.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "net/messagein.h" #include "net/messageout.h" diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index 3e46fa66b..746cb6620 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -24,7 +24,7 @@ #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "gui/charselectdialog.h" #include "gui/inventorywindow.h" diff --git a/src/net/tmwa/gui/guildtab.cpp b/src/net/tmwa/gui/guildtab.cpp index 99b775089..05a93bff8 100644 --- a/src/net/tmwa/gui/guildtab.cpp +++ b/src/net/tmwa/gui/guildtab.cpp @@ -22,7 +22,7 @@ #include "net/tmwa/gui/guildtab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "guild.h" #include "localplayer.h" diff --git a/src/net/tmwa/gui/partytab.cpp b/src/net/tmwa/gui/partytab.cpp index d15f4754f..373fcca31 100644 --- a/src/net/tmwa/gui/partytab.cpp +++ b/src/net/tmwa/gui/partytab.cpp @@ -22,7 +22,7 @@ #include "net/tmwa/gui/partytab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "localplayer.h" #include "party.h" diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index 43583971f..640a6fd78 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -23,7 +23,7 @@ #include "actorspritemanager.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "net/tmwa/messagein.h" diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index ae79f6842..14a15e59f 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -22,7 +22,7 @@ #include "net/tmwa/inventoryhandler.h" -#include "log.h" +#include "logger.h" #include "net/messagein.h" diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h index 405bacc43..9a0978bd0 100644 --- a/src/net/tmwa/inventoryhandler.h +++ b/src/net/tmwa/inventoryhandler.h @@ -23,7 +23,7 @@ #ifndef NET_TA_INVENTORYHANDLER_H #define NET_TA_INVENTORYHANDLER_H -#include "log.h" +#include "logger.h" #include "net/net.h" diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 15ed2f27c..029c379a0 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -23,7 +23,7 @@ #include "net/tmwa/loginhandler.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "configuration.h" #include "net/messagein.h" diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp index 6e2fcc187..fb1986597 100644 --- a/src/net/tmwa/messagein.cpp +++ b/src/net/tmwa/messagein.cpp @@ -24,7 +24,7 @@ #include "net/packetcounters.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp index a904b6bbb..6071e0ab6 100644 --- a/src/net/tmwa/messageout.cpp +++ b/src/net/tmwa/messageout.cpp @@ -26,7 +26,7 @@ #include "net/tmwa/network.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index c2049d3cc..8ecf04d36 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -22,7 +22,7 @@ #include "net/tmwa/network.h" -#include "log.h" +#include "logger.h" #include "net/messagehandler.h" #include "net/messagein.h" diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 5bbf8baf3..7f942a206 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -22,7 +22,7 @@ #include "actorspritemanager.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "net/messagein.h" diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index f20ea64a0..c34c661e8 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -22,7 +22,7 @@ #include "net/tmwa/playerhandler.h" -#include "log.h" +#include "logger.h" #include "net/messagein.h" diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp index b175368bd..509c5ecd1 100644 --- a/src/net/tmwa/specialhandler.cpp +++ b/src/net/tmwa/specialhandler.cpp @@ -22,7 +22,7 @@ #include "net/tmwa/specialhandler.h" -#include "log.h" +#include "logger.h" #include "net/messagein.h" diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp index 108b544a0..2280079ea 100644 --- a/src/net/tmwa/tradehandler.cpp +++ b/src/net/tmwa/tradehandler.cpp @@ -23,7 +23,7 @@ #include "net/tmwa/tradehandler.h" #include "item.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "net/messagein.h" diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp index d40784aff..e93066b96 100644 --- a/src/opengl1graphics.cpp +++ b/src/opengl1graphics.cpp @@ -26,7 +26,7 @@ #include "opengl1graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "resources/image.h" diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index 6081fa6b3..f918a5c0d 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -26,7 +26,7 @@ #include "graphicsvertexes.h" #include "openglgraphics.h" -#include "log.h" +#include "logger.h" #include "resources/image.h" diff --git a/src/particle.cpp b/src/particle.cpp index eca9307ea..7d7a73e9a 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -27,7 +27,7 @@ #include "configuration.h" #include "resources/dye.h" #include "imageparticle.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "particle.h" #include "particleemitter.h" diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index c04b1b36f..caa48a795 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -22,7 +22,7 @@ #include "animationparticle.h" #include "imageparticle.h" -#include "log.h" +#include "logger.h" #include "particle.h" #include "particleemitter.h" #include "rotationalparticle.h" diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index 72b091244..3bb196921 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -26,7 +26,7 @@ #include "event.h" #include "inventory.h" #include "listener.h" -#include "log.h" +#include "logger.h" #include "resources/itemdb.h" #include "resources/iteminfo.h" diff --git a/src/properties.h b/src/properties.h index c65e30c22..19354b9ab 100644 --- a/src/properties.h +++ b/src/properties.h @@ -23,7 +23,7 @@ #ifndef PROPERTIES_H #define PROPERTIES_H -#include "log.h" +#include "logger.h" #include #include #include diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp index ea7f44199..32b57b3b1 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -22,7 +22,7 @@ #include "resources/animation.h" -#include "log.h" +#include "logger.h" #include "utils/dtor.h" diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 6b4f57d81..8beea420d 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -22,7 +22,7 @@ #include "resources/beinginfo.h" -#include "log.h" +#include "logger.h" #include "utils/dtor.h" #include "utils/gettext.h" diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 72a5e4023..ed8c934dc 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -21,7 +21,7 @@ #include "resources/colordb.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "utils/xml.h" diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index fe7d4bcac..a782b6ec1 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -22,7 +22,7 @@ #include "resources/dye.h" -#include "log.h" +#include "logger.h" #include #include diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index 85a2993dd..b7f7d7901 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -21,7 +21,7 @@ #include "resources/emotedb.h" #include "animatedsprite.h" -#include "log.h" +#include "logger.h" #include "utils/xml.h" #include "configuration.h" diff --git a/src/resources/image.cpp b/src/resources/image.cpp index b1f83e258..802f2ee12 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -31,7 +31,7 @@ #endif #include "client.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "utils/stringutils.h" diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp index 1d41c6e63..5cf3e7d82 100644 --- a/src/resources/imageset.cpp +++ b/src/resources/imageset.cpp @@ -22,7 +22,7 @@ #include "resources/imageset.h" -#include "log.h" +#include "logger.h" #include "resources/image.h" diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp index 5d0bd9d94..e6f3c8c27 100644 --- a/src/resources/imagewriter.cpp +++ b/src/resources/imagewriter.cpp @@ -22,7 +22,7 @@ #include "resources/imagewriter.h" -#include "log.h" +#include "logger.h" #if defined __OpenBSD__ #include diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 7919145bd..e60127997 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -23,7 +23,7 @@ #include "resources/itemdb.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "resources/iteminfo.h" #include "resources/resourcemanager.h" diff --git a/src/resources/mapdb.cpp b/src/resources/mapdb.cpp index e8aeaf168..e7288e039 100644 --- a/src/resources/mapdb.cpp +++ b/src/resources/mapdb.cpp @@ -23,7 +23,7 @@ #include "configuration.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "utils/xml.h" diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 35267533f..70c45054f 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -23,7 +23,7 @@ #include "resources/mapreader.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "tileset.h" diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 7a0494fc9..dbf9d3e9a 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -22,7 +22,7 @@ #include "resources/monsterdb.h" -#include "log.h" +#include "logger.h" #include "net/net.h" diff --git a/src/resources/music.cpp b/src/resources/music.cpp index ccd1d9280..5ae9a2202 100644 --- a/src/resources/music.cpp +++ b/src/resources/music.cpp @@ -22,7 +22,7 @@ #include "resources/music.h" -#include "log.h" +#include "logger.h" #include "debug.h" diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index 49eab5bf2..d04a2518f 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -22,7 +22,7 @@ #include "resources/npcdb.h" -#include "log.h" +#include "logger.h" #include "resources/beinginfo.h" diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp index 6e986272a..b180712c1 100644 --- a/src/resources/resource.cpp +++ b/src/resources/resource.cpp @@ -23,7 +23,7 @@ #include "resources/resource.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "resources/resourcemanager.h" diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 92c18fa2a..ee325e253 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -24,7 +24,7 @@ #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "resources/dye.h" diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp index a01bf21a0..49e7adc31 100644 --- a/src/resources/soundeffect.cpp +++ b/src/resources/soundeffect.cpp @@ -22,7 +22,7 @@ #include "resources/soundeffect.h" -#include "log.h" +#include "logger.h" #include "debug.h" diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp index 4ab5e2a91..573ffb2a3 100644 --- a/src/resources/specialdb.cpp +++ b/src/resources/specialdb.cpp @@ -21,7 +21,7 @@ #include "resources/specialdb.h" -#include "log.h" +#include "logger.h" #include "utils/dtor.h" #include "utils/xml.h" diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index b6addba77..dee93e1e7 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -22,7 +22,7 @@ #include "resources/spritedef.h" -#include "log.h" +#include "logger.h" #include "resources/action.h" #include "resources/animation.h" diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 397b87993..09c9f2a04 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -23,7 +23,7 @@ #include "resources/wallpaper.h" #include "resources/resourcemanager.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" #include "configuration.h" diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index e3591f30c..4736b2e57 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -23,7 +23,7 @@ #include "simpleanimation.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" diff --git a/src/sound.cpp b/src/sound.cpp index 92a5eaa6f..0a3c75d11 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -24,7 +24,7 @@ #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "sound.h" #include "resources/resourcemanager.h" diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index 13b8e7b69..a79388350 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -25,7 +25,7 @@ #include "being.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "localplayer.h" #include "playerinfo.h" diff --git a/src/spellshortcut.h b/src/spellshortcut.h index 4d59384bd..047ccdef3 100644 --- a/src/spellshortcut.h +++ b/src/spellshortcut.h @@ -25,7 +25,7 @@ #define SPELLSHORTCUT_H #include "spellmanager.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" class TextCommand; diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 27e351a45..dccf21f46 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -22,7 +22,7 @@ #include "statuseffect.h" -#include "log.h" +#include "logger.h" #include "sound.h" #include "gui/widgets/chattab.h" diff --git a/src/units.cpp b/src/units.cpp index ee0647e2e..db9faadd1 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -22,7 +22,7 @@ #include "units.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" #include "utils/xml.h" diff --git a/src/utils/mutex.h b/src/utils/mutex.h index f23ddc2aa..03dac2e7a 100644 --- a/src/utils/mutex.h +++ b/src/utils/mutex.h @@ -23,7 +23,7 @@ #ifndef MUTEX_H #define MUTEX_H -#include "log.h" +#include "logger.h" #include diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index b31b60ee1..89457a4e8 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -22,7 +22,7 @@ #include "utils/xml.h" -#include "log.h" +#include "logger.h" #include "resources/resourcemanager.h" -- cgit v1.2.3-70-g09d2 From b2c9a0fa784997232141336dca358295bd57a75f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 12 Aug 2011 04:03:26 +0300 Subject: Rename file name ministatus to correct ministatuswindow. --- manaplus.cbp | 4 +- src/CMakeLists.txt | 4 +- src/Makefile.am | 4 +- src/game.cpp | 2 +- src/gui/ministatus.cpp | 473 ---------------------------------------- src/gui/ministatus.h | 127 ----------- src/gui/ministatuswindow.cpp | 473 ++++++++++++++++++++++++++++++++++++++++ src/gui/ministatuswindow.h | 127 +++++++++++ src/gui/popupmenu.cpp | 2 +- src/gui/viewport.cpp | 2 +- src/localplayer.cpp | 2 +- src/net/ea/inventoryhandler.cpp | 2 +- 12 files changed, 611 insertions(+), 611 deletions(-) delete mode 100644 src/gui/ministatus.cpp delete mode 100644 src/gui/ministatus.h create mode 100644 src/gui/ministatuswindow.cpp create mode 100644 src/gui/ministatuswindow.h (limited to 'src/game.cpp') diff --git a/manaplus.cbp b/manaplus.cbp index de71b2947..0083d9c8b 100644 --- a/manaplus.cbp +++ b/manaplus.cbp @@ -196,8 +196,8 @@ - - + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8a0135790..655d4896c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -267,8 +267,8 @@ SET(SRCS gui/logindialog.h gui/minimap.cpp gui/minimap.h - gui/ministatus.cpp - gui/ministatus.h + gui/ministatuswindow.cpp + gui/ministatuswindow.h gui/npcdialog.cpp gui/npcdialog.h gui/npcpostdialog.cpp diff --git a/src/Makefile.am b/src/Makefile.am index e6d84e016..8bacf6803 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -270,8 +270,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/logindialog.h \ gui/minimap.cpp \ gui/minimap.h \ - gui/ministatus.cpp \ - gui/ministatus.h \ + gui/ministatuswindow.cpp \ + gui/ministatuswindow.h \ gui/npcdialog.cpp \ gui/npcdialog.h \ gui/npcpostdialog.cpp \ diff --git a/src/game.cpp b/src/game.cpp index 4967231b0..4e7345340 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -60,7 +60,7 @@ #include "gui/inventorywindow.h" #include "gui/killstats.h" #include "gui/minimap.h" -#include "gui/ministatus.h" +#include "gui/ministatuswindow.h" #include "gui/npcpostdialog.h" #include "gui/okdialog.h" #include "gui/outfitwindow.h" diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp deleted file mode 100644 index 817cd74a5..000000000 --- a/src/gui/ministatus.cpp +++ /dev/null @@ -1,473 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-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 . - */ - -#include "gui/ministatus.h" - -#include "animatedsprite.h" -#include "configuration.h" -#include "graphics.h" -#include "playerinfo.h" - -#include "gui/chatwindow.h" -#include "gui/gui.h" -#include "gui/statuswindow.h" -#include "gui/statuspopup.h" -#include "gui/textpopup.h" -#include "gui/theme.h" -#include "gui/viewport.h" - -#include "gui/widgets/chattab.h" -#include "gui/widgets/label.h" -#include "gui/widgets/progressbar.h" - -#include "net/net.h" -#include "net/playerhandler.h" -#include "net/gamehandler.h" - -#include "utils/dtor.h" -#include "utils/gettext.h" -#include "utils/stringutils.h" - -#include "debug.h" - -extern volatile int tick_time; - -MiniStatusWindow::MiniStatusWindow(): - Popup("MiniStatus") -{ - listen(Mana::CHANNEL_ATTRIBUTES); - - mHpBar = createBar(0, 100, 20, Theme::PROG_HP, "hp bar", _("health bar")); - StatusWindow::updateHPBar(mHpBar); - - if (Net::getGameHandler()->canUseMagicBar()) - { - mMpBar = createBar(0, 100, 20, Net::getPlayerHandler()->canUseMagic() - ? Theme::PROG_MP : Theme::PROG_NO_MP, "mp bar", _("mana bar")); - StatusWindow::updateMPBar(mMpBar); - } - else - { - mMpBar = 0; - } - - int job = Net::getPlayerHandler()->getJobLocation() - && serverConfig.getValueBool("showJob", false); - - mXpBar = createBar(0, 100, 20, Theme::PROG_EXP, - "xp bar", _("experience bar")); - StatusWindow::updateXPBar(mXpBar); - - if (job) - { - mJobBar = createBar(0, 100, 20, Theme::PROG_JOB, "job bar", - _("job bar")); - StatusWindow::updateJobBar(mJobBar); - } - else - { - mJobBar = 0; - } - - mWeightBar = createBar(0, 140, 20, Theme::PROG_WEIGHT, - "weight bar", _("weight bar")); - - mInvSlotsBar = createBar(0, 45, 20, Theme::PROG_INVY_SLOTS, - "inventory slots bar", _("inventory slots bar")); - - mMoneyBar = createBar(0, 130, 20, Theme::PROG_INVY_SLOTS, - "money bar", _("money bar")); - - mArrowsBar = createBar(0, 50, 20, Theme::PROG_INVY_SLOTS, - "arrows bar", _("arrows bar")); - - mStatusBar = createBar(100, 150, 20, Theme::PROG_EXP, - "status bar", _("status bar")); - - loadBars(); - updateBars(); - - setVisible(config.getValueBool(getPopupName() + "Visible", true)); - - mStatusPopup = new StatusPopup(); - mTextPopup = new TextPopup(); - - addMouseListener(this); - Inventory *inv = PlayerInfo::getInventory(); - if (inv) - inv->addInventoyListener(this); - - StatusWindow::updateMoneyBar(mMoneyBar); - StatusWindow::updateArrowsBar(mArrowsBar); - updateStatus(); -} - -MiniStatusWindow::~MiniStatusWindow() -{ - delete mTextPopup; - mTextPopup = 0; - delete mStatusPopup; - mStatusPopup = 0; - delete_all(mIcons); - mIcons.clear(); - - Inventory *inv = PlayerInfo::getInventory(); - if (inv) - inv->removeInventoyListener(this); - - std::vector ::iterator it, it_end; - for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) - { - ProgressBar *bar = *it; - if (!bar) - continue; - if (!bar->isVisible()) - delete bar; - } -} - -ProgressBar *MiniStatusWindow::createBar(float progress, int width, int height, - int color, std::string name, - std::string description) -{ - ProgressBar *bar = new ProgressBar(progress, width, height, color); - bar->setActionEventId(name); - bar->setId(description); - mBars.push_back(bar); - mBarNames[name] = bar; - return bar; -} - -void MiniStatusWindow::updateBars() -{ - int x = 0; - std::vector ::iterator it, it_end; - ProgressBar* lastBar = 0; - for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) - safeRemove(*it); - for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) - { - ProgressBar *bar = *it; - if (!bar) - continue; - if (bar->isVisible()) - { - bar->setPosition(x, 3); - add(bar); - x += bar->getWidth() + 3; - lastBar = bar; - } - } - - if (lastBar) - { - setContentSize(lastBar->getX() + lastBar->getWidth(), - lastBar->getY() + lastBar->getHeight()); - } -} - -void MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite) -{ - if (index >= static_cast(mIcons.size())) - mIcons.resize(index + 1, 0); - - delete mIcons[index]; - - mIcons[index] = sprite; -} - -void MiniStatusWindow::eraseIcon(int index) -{ - if (index < static_cast(mIcons.size())) - { - delete mIcons[index]; - mIcons.erase(mIcons.begin() + index); - } -} - -void MiniStatusWindow::drawIcons(Graphics *graphics) -{ - // Draw icons - int icon_x = mStatusBar->getX() + mStatusBar->getWidth() + 4; - for (unsigned int i = 0; i < mIcons.size(); i++) - { - if (mIcons[i]) - { - mIcons[i]->draw(graphics, icon_x, 3); - icon_x += 2 + mIcons[i]->getWidth(); - } - } -} - -void MiniStatusWindow::event(Mana::Channels channel A_UNUSED, - const Mana::Event &event) -{ - if (event.getName() == Mana::EVENT_UPDATEATTRIBUTE) - { - int id = event.getInt("id"); - if (id == HP || id == MAX_HP) - StatusWindow::updateHPBar(mHpBar); - else if (id == MP || id == MAX_MP) - StatusWindow::updateMPBar(mMpBar); - else if (id == EXP || id == EXP_NEEDED) - StatusWindow::updateXPBar(mXpBar); - else if (id == TOTAL_WEIGHT || id == MAX_WEIGHT) - StatusWindow::updateWeightBar(mWeightBar); - else if (id == MONEY) - StatusWindow::updateMoneyBar(mMoneyBar); - } - else if (event.getName() == Mana::EVENT_UPDATESTAT) - { - StatusWindow::updateMPBar(mMpBar); - StatusWindow::updateJobBar(mJobBar); - } -} - -void MiniStatusWindow::updateStatus() -{ - StatusWindow::updateStatusBar(mStatusBar); - if (mStatusPopup && mStatusPopup->isVisible()) - mStatusPopup->update(); -} - -void MiniStatusWindow::logic() -{ - Popup::logic(); - - for (unsigned int i = 0; i < mIcons.size(); i++) - { - if (mIcons[i]) - mIcons[i]->update(tick_time * 10); - } -} - -void MiniStatusWindow::draw(gcn::Graphics *graphics) -{ - drawChildren(graphics); -} - -void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event) -{ - Popup::mouseMoved(event); - - const int x = event.getX(); - const int y = event.getY(); - - if (event.getSource() == mStatusBar) - { - mStatusPopup->view(x + getX(), y + getY()); - mTextPopup->hide(); - } - else if (event.getSource() == mXpBar) - { - if (PlayerInfo::getAttribute(EXP) - > PlayerInfo::getAttribute(EXP_NEEDED)) - { - mTextPopup->show(x + getX(), y + getY(), - event.getSource()->getId(), - strprintf("%u/%u", PlayerInfo::getAttribute(EXP), - PlayerInfo::getAttribute(EXP_NEEDED))); - } - else - { - mTextPopup->show(x + getX(), y + getY(), - event.getSource()->getId(), - strprintf("%u/%u", PlayerInfo::getAttribute(EXP), - PlayerInfo::getAttribute(EXP_NEEDED)), - strprintf("%s: %u", _("Need"), - PlayerInfo::getAttribute(EXP_NEEDED) - - PlayerInfo::getAttribute(EXP))); - } - mStatusPopup->hide(); - } - else if (event.getSource() == mHpBar) - { - mTextPopup->show(x + getX(), y + getY(), - event.getSource()->getId(), - strprintf("%u/%u", PlayerInfo::getAttribute(HP), - PlayerInfo::getAttribute(MAX_HP))); - mStatusPopup->hide(); - } - else if (event.getSource() == mMpBar) - { - mTextPopup->show(x + getX(), y + getY(), - event.getSource()->getId(), - strprintf("%u/%u", PlayerInfo::getAttribute(MP), - PlayerInfo::getAttribute(MAX_MP))); - mStatusPopup->hide(); - } - else if (event.getSource() == mJobBar) - { - std::pair exp = PlayerInfo::getStatExperience( - Net::getPlayerHandler()->getJobLocation()); - - if (exp.first > exp.second) - { - mTextPopup->show(x + getX(), y + getY(), - event.getSource()->getId(), - strprintf("%u/%u", exp.first, - exp.second)); - } - else - { - mTextPopup->show(x + getX(), y + getY(), - event.getSource()->getId(), - strprintf("%u/%u", exp.first, - exp.second), - strprintf("%s: %u", _("Need"), - exp.second - - exp.first)); - } - mStatusPopup->hide(); - } - else if (event.getSource() == mWeightBar) - { - mTextPopup->show(x + getX(), y + getY(), - event.getSource()->getId(), - strprintf("%u/%u", PlayerInfo::getAttribute(TOTAL_WEIGHT), - PlayerInfo::getAttribute(MAX_WEIGHT))); - mStatusPopup->hide(); - } - else if (event.getSource() == mInvSlotsBar) - { - Inventory *inv = PlayerInfo::getInventory(); - if (inv) - { - const int usedSlots = inv->getNumberOfSlotsUsed(); - const int maxSlots = inv->getSize(); - - mTextPopup->show(x + getX(), y + getY(), - event.getSource()->getId(), - strprintf("%u/%u", usedSlots, maxSlots)); - } - mStatusPopup->hide(); - } - else if (event.getSource() == mMoneyBar) - { - mTextPopup->show(x + getX(), y + getY(), - event.getSource()->getId(), - toString(PlayerInfo::getAttribute(MONEY))); - } - else - { - mTextPopup->hide(); - mStatusPopup->hide(); - } -} - -void MiniStatusWindow::mousePressed(gcn::MouseEvent &event) -{ - if (!viewport) - return; - - if (event.getButton() == gcn::MouseEvent::RIGHT) - { - ProgressBar *bar = dynamic_cast(event.getSource()); - if (!bar) - return; - if (viewport) - { - viewport->showPopup(getX() + event.getX(), - getY() + event.getY(), bar); - } - } -} - -void MiniStatusWindow::mouseExited(gcn::MouseEvent &event) -{ - Popup::mouseExited(event); - - mTextPopup->hide(); - mStatusPopup->hide(); -} - -void MiniStatusWindow::showBar(std::string name, bool isVisible) -{ - ProgressBar *bar = mBarNames[name]; - if (!bar) - return; - bar->setVisible(isVisible); - updateBars(); - saveBars(); -} - -void MiniStatusWindow::loadBars() -{ - if (!config.getValue("ministatussaved", 0)) - { - if (mWeightBar) - mWeightBar->setVisible(false); - if (mInvSlotsBar) - mInvSlotsBar->setVisible(false); - if (mMoneyBar) - mMoneyBar->setVisible(false); - if (mArrowsBar) - mArrowsBar->setVisible(false); - return; - } - - for (int f = 0; f < 10; f ++) - { - std::string str = config.getValue("ministatus" + toString(f), ""); - if (str == "" || str == "status bar") - continue; - ProgressBar *bar = mBarNames[str]; - if (!bar) - continue; - bar->setVisible(false); - } -} - -void MiniStatusWindow::saveBars() -{ - std::vector ::iterator it, it_end; - int i = 0; - for (it = mBars.begin(), it_end = mBars.end(); - it != it_end; ++it) - { - ProgressBar *bar = *it; - if (!bar->isVisible()) - { - config.setValue("ministatus" + toString(i), - bar->getActionEventId()); - i ++; - } - } - for (int f = i; f < 10; f ++) - config.deleteKey("ministatus" + toString(f)); - - config.setValue("ministatussaved", true); -} - -void MiniStatusWindow::slotsChanged(Inventory* inventory) -{ - if (!inventory) - return; - - if (inventory->getType() == Inventory::INVENTORY) - StatusWindow::updateInvSlotsBar(mInvSlotsBar); -} - -void MiniStatusWindow::updateArrows() -{ - StatusWindow::updateArrowsBar(mArrowsBar); -} diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h deleted file mode 100644 index f19055305..000000000 --- a/src/gui/ministatus.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-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 . - */ - -#ifndef MINISTATUS_H -#define MINISTATUS_H - -#include "inventory.h" -#include "listener.h" - -#include "gui/widgets/popup.h" -#include "gui/widgets/window.h" - -#include - -#ifdef __GNUC__ -#define A_UNUSED __attribute__ ((unused)) -#else -#define A_UNUSED -#endif - -class AnimatedSprite; -class Graphics; -class ProgressBar; -class StatusPopup; -class TextPopup; - -/** - * The player mini-status dialog. - * - * \ingroup Interface - */ -class MiniStatusWindow : public Popup, - public InventoryListener, - public Mana::Listener -{ - public: - MiniStatusWindow(); - - ~MiniStatusWindow(); - - /** - * Sets one of the icons. - */ - void setIcon(int index, AnimatedSprite *sprite); - - void eraseIcon(int index); - - void drawIcons(Graphics *graphics); - - void event(Mana::Channels channel, const Mana::Event &event); - - void updateStatus(); - - void logic(); // Updates icons - - void draw(gcn::Graphics *graphics); - - void mouseMoved(gcn::MouseEvent &mouseEvent); - - void mousePressed(gcn::MouseEvent &event); - - void mouseExited(gcn::MouseEvent &event); - - void showBar(std::string name, bool isVisible); - - void updateBars(); - - void updateArrows(); - - void slotsChanged(Inventory* inventory); - - std::vector &getBars() - { return mBars; } - - private: - bool isInBar(ProgressBar *bar, int x, int y) const; - - ProgressBar *createBar(float progress, int width, int height, - int color, std::string name, - std::string description); - - void loadBars(); - - void saveBars(); - - /* - * Mini Status Bars - */ - ProgressBar *mHpBar; - ProgressBar *mMpBar; - ProgressBar *mXpBar; - ProgressBar *mJobBar; - ProgressBar *mWeightBar; - ProgressBar *mInvSlotsBar; - ProgressBar *mMoneyBar; - ProgressBar *mArrowsBar; - ProgressBar *mStatusBar; - TextPopup *mTextPopup; - StatusPopup *mStatusPopup; - std::vector mBars; - std::map mBarNames; - - std::vector mIcons; -}; - -extern MiniStatusWindow *miniStatusWindow; - -#endif diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp new file mode 100644 index 000000000..08e3d0053 --- /dev/null +++ b/src/gui/ministatuswindow.cpp @@ -0,0 +1,473 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-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 . + */ + +#include "gui/ministatuswindow.h" + +#include "animatedsprite.h" +#include "configuration.h" +#include "graphics.h" +#include "playerinfo.h" + +#include "gui/chatwindow.h" +#include "gui/gui.h" +#include "gui/statuswindow.h" +#include "gui/statuspopup.h" +#include "gui/textpopup.h" +#include "gui/theme.h" +#include "gui/viewport.h" + +#include "gui/widgets/chattab.h" +#include "gui/widgets/label.h" +#include "gui/widgets/progressbar.h" + +#include "net/net.h" +#include "net/playerhandler.h" +#include "net/gamehandler.h" + +#include "utils/dtor.h" +#include "utils/gettext.h" +#include "utils/stringutils.h" + +#include "debug.h" + +extern volatile int tick_time; + +MiniStatusWindow::MiniStatusWindow(): + Popup("MiniStatus") +{ + listen(Mana::CHANNEL_ATTRIBUTES); + + mHpBar = createBar(0, 100, 20, Theme::PROG_HP, "hp bar", _("health bar")); + StatusWindow::updateHPBar(mHpBar); + + if (Net::getGameHandler()->canUseMagicBar()) + { + mMpBar = createBar(0, 100, 20, Net::getPlayerHandler()->canUseMagic() + ? Theme::PROG_MP : Theme::PROG_NO_MP, "mp bar", _("mana bar")); + StatusWindow::updateMPBar(mMpBar); + } + else + { + mMpBar = 0; + } + + int job = Net::getPlayerHandler()->getJobLocation() + && serverConfig.getValueBool("showJob", false); + + mXpBar = createBar(0, 100, 20, Theme::PROG_EXP, + "xp bar", _("experience bar")); + StatusWindow::updateXPBar(mXpBar); + + if (job) + { + mJobBar = createBar(0, 100, 20, Theme::PROG_JOB, "job bar", + _("job bar")); + StatusWindow::updateJobBar(mJobBar); + } + else + { + mJobBar = 0; + } + + mWeightBar = createBar(0, 140, 20, Theme::PROG_WEIGHT, + "weight bar", _("weight bar")); + + mInvSlotsBar = createBar(0, 45, 20, Theme::PROG_INVY_SLOTS, + "inventory slots bar", _("inventory slots bar")); + + mMoneyBar = createBar(0, 130, 20, Theme::PROG_INVY_SLOTS, + "money bar", _("money bar")); + + mArrowsBar = createBar(0, 50, 20, Theme::PROG_INVY_SLOTS, + "arrows bar", _("arrows bar")); + + mStatusBar = createBar(100, 150, 20, Theme::PROG_EXP, + "status bar", _("status bar")); + + loadBars(); + updateBars(); + + setVisible(config.getValueBool(getPopupName() + "Visible", true)); + + mStatusPopup = new StatusPopup(); + mTextPopup = new TextPopup(); + + addMouseListener(this); + Inventory *inv = PlayerInfo::getInventory(); + if (inv) + inv->addInventoyListener(this); + + StatusWindow::updateMoneyBar(mMoneyBar); + StatusWindow::updateArrowsBar(mArrowsBar); + updateStatus(); +} + +MiniStatusWindow::~MiniStatusWindow() +{ + delete mTextPopup; + mTextPopup = 0; + delete mStatusPopup; + mStatusPopup = 0; + delete_all(mIcons); + mIcons.clear(); + + Inventory *inv = PlayerInfo::getInventory(); + if (inv) + inv->removeInventoyListener(this); + + std::vector ::iterator it, it_end; + for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) + { + ProgressBar *bar = *it; + if (!bar) + continue; + if (!bar->isVisible()) + delete bar; + } +} + +ProgressBar *MiniStatusWindow::createBar(float progress, int width, int height, + int color, std::string name, + std::string description) +{ + ProgressBar *bar = new ProgressBar(progress, width, height, color); + bar->setActionEventId(name); + bar->setId(description); + mBars.push_back(bar); + mBarNames[name] = bar; + return bar; +} + +void MiniStatusWindow::updateBars() +{ + int x = 0; + std::vector ::iterator it, it_end; + ProgressBar* lastBar = 0; + for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) + safeRemove(*it); + for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) + { + ProgressBar *bar = *it; + if (!bar) + continue; + if (bar->isVisible()) + { + bar->setPosition(x, 3); + add(bar); + x += bar->getWidth() + 3; + lastBar = bar; + } + } + + if (lastBar) + { + setContentSize(lastBar->getX() + lastBar->getWidth(), + lastBar->getY() + lastBar->getHeight()); + } +} + +void MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite) +{ + if (index >= static_cast(mIcons.size())) + mIcons.resize(index + 1, 0); + + delete mIcons[index]; + + mIcons[index] = sprite; +} + +void MiniStatusWindow::eraseIcon(int index) +{ + if (index < static_cast(mIcons.size())) + { + delete mIcons[index]; + mIcons.erase(mIcons.begin() + index); + } +} + +void MiniStatusWindow::drawIcons(Graphics *graphics) +{ + // Draw icons + int icon_x = mStatusBar->getX() + mStatusBar->getWidth() + 4; + for (unsigned int i = 0; i < mIcons.size(); i++) + { + if (mIcons[i]) + { + mIcons[i]->draw(graphics, icon_x, 3); + icon_x += 2 + mIcons[i]->getWidth(); + } + } +} + +void MiniStatusWindow::event(Mana::Channels channel A_UNUSED, + const Mana::Event &event) +{ + if (event.getName() == Mana::EVENT_UPDATEATTRIBUTE) + { + int id = event.getInt("id"); + if (id == HP || id == MAX_HP) + StatusWindow::updateHPBar(mHpBar); + else if (id == MP || id == MAX_MP) + StatusWindow::updateMPBar(mMpBar); + else if (id == EXP || id == EXP_NEEDED) + StatusWindow::updateXPBar(mXpBar); + else if (id == TOTAL_WEIGHT || id == MAX_WEIGHT) + StatusWindow::updateWeightBar(mWeightBar); + else if (id == MONEY) + StatusWindow::updateMoneyBar(mMoneyBar); + } + else if (event.getName() == Mana::EVENT_UPDATESTAT) + { + StatusWindow::updateMPBar(mMpBar); + StatusWindow::updateJobBar(mJobBar); + } +} + +void MiniStatusWindow::updateStatus() +{ + StatusWindow::updateStatusBar(mStatusBar); + if (mStatusPopup && mStatusPopup->isVisible()) + mStatusPopup->update(); +} + +void MiniStatusWindow::logic() +{ + Popup::logic(); + + for (unsigned int i = 0; i < mIcons.size(); i++) + { + if (mIcons[i]) + mIcons[i]->update(tick_time * 10); + } +} + +void MiniStatusWindow::draw(gcn::Graphics *graphics) +{ + drawChildren(graphics); +} + +void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event) +{ + Popup::mouseMoved(event); + + const int x = event.getX(); + const int y = event.getY(); + + if (event.getSource() == mStatusBar) + { + mStatusPopup->view(x + getX(), y + getY()); + mTextPopup->hide(); + } + else if (event.getSource() == mXpBar) + { + if (PlayerInfo::getAttribute(EXP) + > PlayerInfo::getAttribute(EXP_NEEDED)) + { + mTextPopup->show(x + getX(), y + getY(), + event.getSource()->getId(), + strprintf("%u/%u", PlayerInfo::getAttribute(EXP), + PlayerInfo::getAttribute(EXP_NEEDED))); + } + else + { + mTextPopup->show(x + getX(), y + getY(), + event.getSource()->getId(), + strprintf("%u/%u", PlayerInfo::getAttribute(EXP), + PlayerInfo::getAttribute(EXP_NEEDED)), + strprintf("%s: %u", _("Need"), + PlayerInfo::getAttribute(EXP_NEEDED) + - PlayerInfo::getAttribute(EXP))); + } + mStatusPopup->hide(); + } + else if (event.getSource() == mHpBar) + { + mTextPopup->show(x + getX(), y + getY(), + event.getSource()->getId(), + strprintf("%u/%u", PlayerInfo::getAttribute(HP), + PlayerInfo::getAttribute(MAX_HP))); + mStatusPopup->hide(); + } + else if (event.getSource() == mMpBar) + { + mTextPopup->show(x + getX(), y + getY(), + event.getSource()->getId(), + strprintf("%u/%u", PlayerInfo::getAttribute(MP), + PlayerInfo::getAttribute(MAX_MP))); + mStatusPopup->hide(); + } + else if (event.getSource() == mJobBar) + { + std::pair exp = PlayerInfo::getStatExperience( + Net::getPlayerHandler()->getJobLocation()); + + if (exp.first > exp.second) + { + mTextPopup->show(x + getX(), y + getY(), + event.getSource()->getId(), + strprintf("%u/%u", exp.first, + exp.second)); + } + else + { + mTextPopup->show(x + getX(), y + getY(), + event.getSource()->getId(), + strprintf("%u/%u", exp.first, + exp.second), + strprintf("%s: %u", _("Need"), + exp.second + - exp.first)); + } + mStatusPopup->hide(); + } + else if (event.getSource() == mWeightBar) + { + mTextPopup->show(x + getX(), y + getY(), + event.getSource()->getId(), + strprintf("%u/%u", PlayerInfo::getAttribute(TOTAL_WEIGHT), + PlayerInfo::getAttribute(MAX_WEIGHT))); + mStatusPopup->hide(); + } + else if (event.getSource() == mInvSlotsBar) + { + Inventory *inv = PlayerInfo::getInventory(); + if (inv) + { + const int usedSlots = inv->getNumberOfSlotsUsed(); + const int maxSlots = inv->getSize(); + + mTextPopup->show(x + getX(), y + getY(), + event.getSource()->getId(), + strprintf("%u/%u", usedSlots, maxSlots)); + } + mStatusPopup->hide(); + } + else if (event.getSource() == mMoneyBar) + { + mTextPopup->show(x + getX(), y + getY(), + event.getSource()->getId(), + toString(PlayerInfo::getAttribute(MONEY))); + } + else + { + mTextPopup->hide(); + mStatusPopup->hide(); + } +} + +void MiniStatusWindow::mousePressed(gcn::MouseEvent &event) +{ + if (!viewport) + return; + + if (event.getButton() == gcn::MouseEvent::RIGHT) + { + ProgressBar *bar = dynamic_cast(event.getSource()); + if (!bar) + return; + if (viewport) + { + viewport->showPopup(getX() + event.getX(), + getY() + event.getY(), bar); + } + } +} + +void MiniStatusWindow::mouseExited(gcn::MouseEvent &event) +{ + Popup::mouseExited(event); + + mTextPopup->hide(); + mStatusPopup->hide(); +} + +void MiniStatusWindow::showBar(std::string name, bool isVisible) +{ + ProgressBar *bar = mBarNames[name]; + if (!bar) + return; + bar->setVisible(isVisible); + updateBars(); + saveBars(); +} + +void MiniStatusWindow::loadBars() +{ + if (!config.getValue("ministatussaved", 0)) + { + if (mWeightBar) + mWeightBar->setVisible(false); + if (mInvSlotsBar) + mInvSlotsBar->setVisible(false); + if (mMoneyBar) + mMoneyBar->setVisible(false); + if (mArrowsBar) + mArrowsBar->setVisible(false); + return; + } + + for (int f = 0; f < 10; f ++) + { + std::string str = config.getValue("ministatus" + toString(f), ""); + if (str == "" || str == "status bar") + continue; + ProgressBar *bar = mBarNames[str]; + if (!bar) + continue; + bar->setVisible(false); + } +} + +void MiniStatusWindow::saveBars() +{ + std::vector ::iterator it, it_end; + int i = 0; + for (it = mBars.begin(), it_end = mBars.end(); + it != it_end; ++it) + { + ProgressBar *bar = *it; + if (!bar->isVisible()) + { + config.setValue("ministatus" + toString(i), + bar->getActionEventId()); + i ++; + } + } + for (int f = i; f < 10; f ++) + config.deleteKey("ministatus" + toString(f)); + + config.setValue("ministatussaved", true); +} + +void MiniStatusWindow::slotsChanged(Inventory* inventory) +{ + if (!inventory) + return; + + if (inventory->getType() == Inventory::INVENTORY) + StatusWindow::updateInvSlotsBar(mInvSlotsBar); +} + +void MiniStatusWindow::updateArrows() +{ + StatusWindow::updateArrowsBar(mArrowsBar); +} diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h new file mode 100644 index 000000000..19517326b --- /dev/null +++ b/src/gui/ministatuswindow.h @@ -0,0 +1,127 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-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 . + */ + +#ifndef MINISTATUSWINDOW_H +#define MINISTATUSWINDOW_H + +#include "inventory.h" +#include "listener.h" + +#include "gui/widgets/popup.h" +#include "gui/widgets/window.h" + +#include + +#ifdef __GNUC__ +#define A_UNUSED __attribute__ ((unused)) +#else +#define A_UNUSED +#endif + +class AnimatedSprite; +class Graphics; +class ProgressBar; +class StatusPopup; +class TextPopup; + +/** + * The player mini-status dialog. + * + * \ingroup Interface + */ +class MiniStatusWindow : public Popup, + public InventoryListener, + public Mana::Listener +{ + public: + MiniStatusWindow(); + + ~MiniStatusWindow(); + + /** + * Sets one of the icons. + */ + void setIcon(int index, AnimatedSprite *sprite); + + void eraseIcon(int index); + + void drawIcons(Graphics *graphics); + + void event(Mana::Channels channel, const Mana::Event &event); + + void updateStatus(); + + void logic(); // Updates icons + + void draw(gcn::Graphics *graphics); + + void mouseMoved(gcn::MouseEvent &mouseEvent); + + void mousePressed(gcn::MouseEvent &event); + + void mouseExited(gcn::MouseEvent &event); + + void showBar(std::string name, bool isVisible); + + void updateBars(); + + void updateArrows(); + + void slotsChanged(Inventory* inventory); + + std::vector &getBars() + { return mBars; } + + private: + bool isInBar(ProgressBar *bar, int x, int y) const; + + ProgressBar *createBar(float progress, int width, int height, + int color, std::string name, + std::string description); + + void loadBars(); + + void saveBars(); + + /* + * Mini Status Bars + */ + ProgressBar *mHpBar; + ProgressBar *mMpBar; + ProgressBar *mXpBar; + ProgressBar *mJobBar; + ProgressBar *mWeightBar; + ProgressBar *mInvSlotsBar; + ProgressBar *mMoneyBar; + ProgressBar *mArrowsBar; + ProgressBar *mStatusBar; + TextPopup *mTextPopup; + StatusPopup *mStatusPopup; + std::vector mBars; + std::map mBarNames; + + std::vector mIcons; +}; + +extern MiniStatusWindow *miniStatusWindow; + +#endif diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 86ddfda53..c95864396 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -44,7 +44,7 @@ #include "gui/equipmentwindow.h" #include "gui/inventorywindow.h" #include "gui/itemamountwindow.h" -#include "gui/ministatus.h" +#include "gui/ministatuswindow.h" #include "gui/outfitwindow.h" #include "gui/selldialog.h" #include "gui/socialwindow.h" diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 2ca59f524..70d02b016 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -36,7 +36,7 @@ #include "gui/beingpopup.h" #include "gui/chatwindow.h" #include "gui/gui.h" -#include "gui/ministatus.h" +#include "gui/ministatuswindow.h" #include "gui/popupmenu.h" #include "gui/statuspopup.h" #include "gui/textpopup.h" diff --git a/src/localplayer.cpp b/src/localplayer.cpp index a9e9d1f21..9f0a7c5f3 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -46,7 +46,7 @@ #include "gui/gui.h" #include "gui/inventorywindow.h" #include "gui/killstats.h" -#include "gui/ministatus.h" +#include "gui/ministatuswindow.h" #include "gui/okdialog.h" #include "gui/outfitwindow.h" #include "gui/palette.h" diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index d921b5e2a..01000f8f1 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -26,7 +26,7 @@ #include "localplayer.h" #include "logger.h" -#include "gui/ministatus.h" +#include "gui/ministatuswindow.h" #include "net/messagein.h" -- cgit v1.2.3-70-g09d2 From 47f0e16e34cf22701b7c0670297bb7288a55310d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 15 Aug 2011 01:57:55 +0300 Subject: Add option to hide ip addresses on screenshots. --- src/defaults.cpp | 1 + src/game.cpp | 14 +++++++++++- src/graphics.cpp | 3 ++- src/graphics.h | 7 ++++++ src/gui/setup_players.cpp | 3 +++ src/gui/widgets/avatarlistbox.cpp | 46 ++++++++++++++++++++++++++++----------- 6 files changed, 59 insertions(+), 15 deletions(-) (limited to 'src/game.cpp') diff --git a/src/defaults.cpp b/src/defaults.cpp index 3824aafc9..e614a489b 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -214,6 +214,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "disableAdvBeingCaching", false); AddDEF(configData, "disableBeingCaching", false); AddDEF(configData, "enableReorderSprites", true); + AddDEF(configData, "showip", false); return configData; } diff --git a/src/game.cpp b/src/game.cpp index 4e7345340..8457cf079 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -431,8 +431,20 @@ Game::~Game() static bool saveScreenshot() { static unsigned int screenshotCount = 0; + SDL_Surface *screenshot = 0; + + if (!config.getBoolValue("showip")) + { + graphics->setSecure(true); + gui->draw(); + screenshot = graphics->getScreenshot(); + graphics->setSecure(false); + } + else + { + screenshot = graphics->getScreenshot(); + } - SDL_Surface *screenshot = graphics->getScreenshot(); if (!screenshot) return false; diff --git a/src/graphics.cpp b/src/graphics.cpp index a86ac7fd0..c5dc38b72 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -48,7 +48,8 @@ Graphics::Graphics(): mHWAccel(false), mBlitMode(BLIT_NORMAL), mRedraw(false), - mDoubleBuffer(false) + mDoubleBuffer(false), + mSecure(false) { mRect.x = 0; mRect.y = 0; diff --git a/src/graphics.h b/src/graphics.h index 237d16dc2..a2e25b5a8 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -269,6 +269,12 @@ class Graphics : public gcn::SDLGraphics bool getRedraw() { return mRedraw; } + void setSecure(bool n) + { mSecure = n; } + + bool getSecure() + { return mSecure; } + int mWidth; int mHeight; @@ -283,6 +289,7 @@ class Graphics : public gcn::SDLGraphics bool mRedraw; bool mDoubleBuffer; SDL_Rect mRect; + bool mSecure; }; extern Graphics *graphics; diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index d2664adbd..acc6b3d3c 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -75,6 +75,9 @@ Setup_Players::Setup_Players() new SetupItemCheckBox(_("Show statuses"), "", "showPlayersStatus", this, "showPlayersStatusEvent"); + new SetupItemCheckBox(_("Show ip addresses on screenshots"), "", + "showip", this, "showipEvent"); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 5ac6721a5..0d35ad188 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -242,25 +242,45 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) } } - if (mShowGender) + if (graphics->getSecure()) { - switch (a->getGender()) + if (mShowGender) { - case GENDER_FEMALE: - text += strprintf(" \u2640 %s", - a->getAdditionString().c_str()); - break; - case GENDER_MALE: - text += strprintf(" \u2642 %s", - a->getAdditionString().c_str()); - break; - default: - break; + switch (a->getGender()) + { + case GENDER_FEMALE: + text += strprintf(" \u2640 "); + break; + case GENDER_MALE: + text += strprintf(" \u2642 "); + break; + default: + break; + } } } else { - text += a->getAdditionString(); + if (mShowGender) + { + switch (a->getGender()) + { + case GENDER_FEMALE: + text += strprintf(" \u2640 %s", + a->getAdditionString().c_str()); + break; + case GENDER_MALE: + text += strprintf(" \u2642 %s", + a->getAdditionString().c_str()); + break; + default: + break; + } + } + else + { + text += a->getAdditionString(); + } } graphics->setColor(Theme::getThemeColor(Theme::TEXT)); -- cgit v1.2.3-70-g09d2 From 8eb694f537eafa137aaee7111e4971f75358164b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 18 Aug 2011 16:19:01 +0300 Subject: Improve "auto adjust perfomance". --- src/game.cpp | 12 +++++++++++- src/game.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 8457cf079..82f919976 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -338,7 +338,8 @@ Game::Game(): mValidSpeed(true), mLastAction(0), mNextAdjustTime(cur_time + adjustDelay), - mAdjustLevel(0) + mAdjustLevel(0), + mLowerCounter(0) { spellManager = new SpellManager; spellShortcut = new SpellShortcut; @@ -586,6 +587,13 @@ void Game::adjustPerfomance() if (fps < maxFps - 10) { + if (mLowerCounter < 2) + { + mLowerCounter ++; + mNextAdjustTime = cur_time + 1; + return; + } + mLowerCounter = 0; mAdjustLevel ++; switch (mAdjustLevel) { @@ -604,6 +612,7 @@ void Game::adjustPerfomance() else { mNextAdjustTime = cur_time + 1; + mLowerCounter = 2; } break; } @@ -621,6 +630,7 @@ void Game::adjustPerfomance() else { mNextAdjustTime = cur_time + 1; + mLowerCounter = 2; } break; case 3: diff --git a/src/game.h b/src/game.h index 88dc9166b..84dca08e9 100644 --- a/src/game.h +++ b/src/game.h @@ -117,6 +117,7 @@ class Game unsigned mNextAdjustTime; int mAdjustLevel; bool mAdjustPerfomance; + int mLowerCounter; static Game *mInstance; }; -- cgit v1.2.3-70-g09d2