summaryrefslogtreecommitdiff
path: root/src/gui/widgets/tabs/chat/chattab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/tabs/chat/chattab.cpp')
-rw-r--r--src/gui/widgets/tabs/chat/chattab.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp
index ec9042694..b09e57585 100644
--- a/src/gui/widgets/tabs/chat/chattab.cpp
+++ b/src/gui/widgets/tabs/chat/chattab.cpp
@@ -1,11 +1,11 @@
/*
- * The ManaPlus Client
+ * The ManaVerse Client
* Copyright (C) 2008-2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
* Copyright (C) 2011-2020 The ManaPlus Developers
- * Copyright (C) 2020-2023 The ManaVerse Developers
+ * Copyright (C) 2020-2025 The ManaVerse Developers
*
- * This file is part of The ManaPlus Client.
+ * This file is part of The ManaVerse 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
@@ -38,6 +38,7 @@
#include "gui/windows/chatwindow.h"
#include "gui/windows/helpwindow.h"
+#include "gui/widgets/browserbox.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/itemlinkhandler.h"
#include "gui/widgets/tabbedarea.h"
@@ -51,9 +52,9 @@
#include "utils/delete2.h"
#include "utils/gettext.h"
-#ifdef WIN32
+#ifdef _WIN32
#include <sys/time.h>
-#endif // WIN32
+#endif // _WIN32
#include <sstream>
@@ -97,6 +98,10 @@ ChatTab::ChatTab(const Widget2 *const widget,
if (chatWindow != nullptr)
chatWindow->addTab(this);
mTextOutput->updateSize(true);
+
+ const int maxLines = config.getIntValue("loadChatHistoryLines");
+ if (maxLines > 0)
+ loadFromLogFile(logName, maxLines);
}
ChatTab::~ChatTab()
@@ -228,7 +233,7 @@ void ChatTab::chatLog(std::string line,
// if configured, move magic messages log to debug chat tab
if (Net::getNetworkType() == ServerType::TMWATHENA
- && (localChatTab != nullptr) && this == localChatTab
+ && this == localChatTab
&& ((config.getBoolValue("showMagicInDebug")
&& own == ChatMsgType::BY_PLAYER
&& tmp.text.length() > 1
@@ -433,6 +438,16 @@ void ChatTab::clearText()
mTextOutput->clearRows();
}
+const std::list<std::string> &ChatTab::getRows() const
+{
+ return mTextOutput->getRows();
+}
+
+bool ChatTab::hasRows() const
+{
+ return mTextOutput->hasRows();
+}
+
void ChatTab::handleInput(const std::string &msg)
{
if (chatHandler)
@@ -510,12 +525,13 @@ void ChatTab::addRow(std::string &line)
false);
}
-void ChatTab::loadFromLogFile(const std::string &name)
+void ChatTab::loadFromLogFile(const std::string &name,
+ const unsigned maxLines)
{
if (chatLogger != nullptr)
{
std::list<std::string> list;
- chatLogger->loadLast(name, list, 5);
+ chatLogger->loadLast(name, list, maxLines);
std::list<std::string>::const_iterator i = list.begin();
while (i != list.end())
{