aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEsteban I. RM <me@exio4.xyz>2017-10-15 20:28:42 -0300
committerLoic Blot <loic.blot@unix-experience.fr>2017-10-17 19:21:32 +0200
commit0e8ee84d7477416dce4ad0d3fdde893676a9df6f (patch)
treef9361f25bf87cd38d52882f01b52963f0a90d4f7 /src
parent46f7fe91a2d404397115c3b970fa3b73f006519d (diff)
downloadminetest-0e8ee84d7477416dce4ad0d3fdde893676a9df6f.tar.gz
minetest-0e8ee84d7477416dce4ad0d3fdde893676a9df6f.tar.bz2
minetest-0e8ee84d7477416dce4ad0d3fdde893676a9df6f.zip
Implement #6096
Diffstat (limited to 'src')
-rw-r--r--src/chat.cpp12
-rw-r--r--src/chat.h5
-rw-r--r--src/defaultsettings.cpp1
-rw-r--r--src/game.cpp3
4 files changed, 21 insertions, 0 deletions
diff --git a/src/chat.cpp b/src/chat.cpp
index fd0718707..967e159f8 100644
--- a/src/chat.cpp
+++ b/src/chat.cpp
@@ -369,6 +369,13 @@ s32 ChatBuffer::getBottomScrollPos() const
return formatted_count - rows;
}
+void ChatBuffer::resize(u32 scrollback) {
+ m_scrollback = scrollback;
+ if (m_unformatted.size() > m_scrollback)
+ {
+ deleteOldest(m_unformatted.size() - m_scrollback);
+ }
+}
ChatPrompt::ChatPrompt(const std::wstring &prompt, u32 history_limit):
@@ -731,6 +738,11 @@ void ChatBackend::clearRecentChat()
m_recent_buffer.clear();
}
+
+void ChatBackend::applySettings(Settings* settings) {
+ m_recent_buffer.resize(settings->getU32("recent_chat_size"));
+}
+
void ChatBackend::step(float dtime)
{
m_recent_buffer.step(dtime);
diff --git a/src/chat.h b/src/chat.h
index 38727c668..b1b3edcb0 100644
--- a/src/chat.h
+++ b/src/chat.h
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes.h"
#include "util/enriched_string.h"
+#include "settings.h"
// Chat console related classes
@@ -118,6 +119,7 @@ public:
u32 formatChatLine(const ChatLine& line, u32 cols,
std::vector<ChatFormattedLine>& destination) const;
+ void resize(u32 scrollback);
protected:
s32 getTopScrollPos() const;
s32 getBottomScrollPos() const;
@@ -281,6 +283,9 @@ public:
void scrollPageDown();
void scrollPageUp();
+ // Resize recent buffer based on settings
+ void applySettings(Settings* settings);
+
private:
ChatBuffer m_console_buffer;
ChatBuffer m_recent_buffer;
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 7612ceb44..e2a7ea562 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -190,6 +190,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("node_highlighting", "box");
settings->setDefault("crosshair_color", "(255,255,255)");
settings->setDefault("crosshair_alpha", "255");
+ settings->setDefault("recent_chat_size", "6");
settings->setDefault("hud_scaling", "1.0");
settings->setDefault("gui_scaling", "1.0");
settings->setDefault("gui_scaling_filter", "false");
diff --git a/src/game.cpp b/src/game.cpp
index 8da789a9e..7f717cb5f 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2051,6 +2051,9 @@ bool Game::initGui()
// Remove stale "recent" chat messages from previous connections
chat_backend->clearRecentChat();
+ // Make sure the size of the recent messages buffer is right
+ chat_backend->applySettings(g_settings);
+
// Chat backend and console
gui_chat_console = new GUIChatConsole(guienv, guienv->getRootGUIElement(),
-1, chat_backend, client, &g_menumgr);