summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsteban I. RM <me@exio4.xyz>2017-10-15 21:22:22 -0300
committerLoic Blot <loic.blot@unix-experience.fr>2017-10-17 19:22:09 +0200
commit792e013eaf4a572364457b96f6f9c07dafe6fe9a (patch)
tree124e08c9e3cc4704cd2a9ea49803fce96b046275
parent93d185ee5d481c007d7b5569d046471dc60d40b6 (diff)
downloadminetest-792e013eaf4a572364457b96f6f9c07dafe6fe9a.tar.gz
minetest-792e013eaf4a572364457b96f6f9c07dafe6fe9a.tar.bz2
minetest-792e013eaf4a572364457b96f6f9c07dafe6fe9a.zip
don't pass g_settings around, and use it directly
-rw-r--r--builtin/settingtypes.txt4
-rw-r--r--minetest.conf.example6
-rw-r--r--src/chat.cpp12
-rw-r--r--src/chat.h6
-rw-r--r--src/defaultsettings.cpp2
-rw-r--r--src/game.cpp4
-rw-r--r--src/settings_translation_file.cpp2
7 files changed, 19 insertions, 17 deletions
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index 982fe55ef..7ebee9424 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -634,8 +634,8 @@ crosshair_color (Crosshair color) string (255,255,255)
# Crosshair alpha (opaqueness, between 0 and 255).
crosshair_alpha (Crosshair alpha) int 255 0 255
-# Maximum number of recent chat items to show
-recent_chat_size (Recent Chat Messages) int 6 3 99
+# Maximum number of recent chat messages to show
+recent_chat_messages (Recent Chat Messages) int 6 2 20
# Whether node texture animations should be desynchronized per mapblock.
desynchronize_mapblock_texture_animation (Desynchronize block animation) bool true
diff --git a/minetest.conf.example b/minetest.conf.example
index 0677026aa..b4121eb9b 100644
--- a/minetest.conf.example
+++ b/minetest.conf.example
@@ -747,9 +747,9 @@
# type: int min: 0 max: 255
# crosshair_alpha = 255
-# Maximum number of recent chat items to show
-# type: int min: 3 max: 99
-# recent_chat_size = 6
+# Maximum number of recent chat messages to show
+# type: int min: 2 max: 20
+# recent_chat_messages = 6
# Whether node texture animations should be desynchronized per mapblock.
# type: bool
diff --git a/src/chat.cpp b/src/chat.cpp
index 967e159f8..a5d82a649 100644
--- a/src/chat.cpp
+++ b/src/chat.cpp
@@ -369,12 +369,11 @@ s32 ChatBuffer::getBottomScrollPos() const
return formatted_count - rows;
}
-void ChatBuffer::resize(u32 scrollback) {
+void ChatBuffer::resize(u32 scrollback)
+{
m_scrollback = scrollback;
if (m_unformatted.size() > m_scrollback)
- {
deleteOldest(m_unformatted.size() - m_scrollback);
- }
}
@@ -739,8 +738,11 @@ void ChatBackend::clearRecentChat()
}
-void ChatBackend::applySettings(Settings* settings) {
- m_recent_buffer.resize(settings->getU32("recent_chat_size"));
+void ChatBackend::applySettings()
+{
+ u32 recent_lines = g_settings->getU32("recent_chat_messages");
+ recent_lines = rangelim(recent_lines, 2, 20);
+ m_recent_buffer.resize(recent_lines);
}
void ChatBackend::step(float dtime)
diff --git a/src/chat.h b/src/chat.h
index b1b3edcb0..40d9b771d 100644
--- a/src/chat.h
+++ b/src/chat.h
@@ -119,7 +119,7 @@ public:
u32 formatChatLine(const ChatLine& line, u32 cols,
std::vector<ChatFormattedLine>& destination) const;
- void resize(u32 scrollback);
+ void resize(u32 scrollback);
protected:
s32 getTopScrollPos() const;
s32 getBottomScrollPos() const;
@@ -283,8 +283,8 @@ public:
void scrollPageDown();
void scrollPageUp();
- // Resize recent buffer based on settings
- void applySettings(Settings* settings);
+ // Resize recent buffer based on settings
+ void applySettings();
private:
ChatBuffer m_console_buffer;
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index e2a7ea562..1a2656f0e 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -190,7 +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("recent_chat_messages", "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 7f717cb5f..cd4650baf 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2051,8 +2051,8 @@ 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);
+ // Make sure the size of the recent messages buffer is right
+ chat_backend->applySettings();
// Chat backend and console
gui_chat_console = new GUIChatConsole(guienv, guienv->getRootGUIElement(),
diff --git a/src/settings_translation_file.cpp b/src/settings_translation_file.cpp
index b7c80e79b..bd8447c4b 100644
--- a/src/settings_translation_file.cpp
+++ b/src/settings_translation_file.cpp
@@ -310,7 +310,7 @@ fake_function() {
gettext("Crosshair alpha");
gettext("Crosshair alpha (opaqueness, between 0 and 255).");
gettext("Recent Chat Messages");
- gettext("Maximum number of recent chat items to show");
+ gettext("Maximum number of recent chat lines to show");
gettext("Desynchronize block animation");
gettext("Whether node texture animations should be desynchronized per mapblock.");
gettext("Maximum hotbar width");