don't pass g_settings around, and use it directly

This commit is contained in:
Esteban I. RM 2017-10-15 21:22:22 -03:00 committed by Loic Blot
parent 93d185ee5d
commit 792e013eaf
No known key found for this signature in database
GPG Key ID: EFAA458E8C153987
7 changed files with 19 additions and 17 deletions

View File

@ -634,8 +634,8 @@ crosshair_color (Crosshair color) string (255,255,255)
# Crosshair alpha (opaqueness, between 0 and 255). # Crosshair alpha (opaqueness, between 0 and 255).
crosshair_alpha (Crosshair alpha) int 255 0 255 crosshair_alpha (Crosshair alpha) int 255 0 255
# Maximum number of recent chat items to show # Maximum number of recent chat messages to show
recent_chat_size (Recent Chat Messages) int 6 3 99 recent_chat_messages (Recent Chat Messages) int 6 2 20
# Whether node texture animations should be desynchronized per mapblock. # Whether node texture animations should be desynchronized per mapblock.
desynchronize_mapblock_texture_animation (Desynchronize block animation) bool true desynchronize_mapblock_texture_animation (Desynchronize block animation) bool true

View File

@ -747,9 +747,9 @@
# type: int min: 0 max: 255 # type: int min: 0 max: 255
# crosshair_alpha = 255 # crosshair_alpha = 255
# Maximum number of recent chat items to show # Maximum number of recent chat messages to show
# type: int min: 3 max: 99 # type: int min: 2 max: 20
# recent_chat_size = 6 # recent_chat_messages = 6
# Whether node texture animations should be desynchronized per mapblock. # Whether node texture animations should be desynchronized per mapblock.
# type: bool # type: bool

View File

@ -369,13 +369,12 @@ s32 ChatBuffer::getBottomScrollPos() const
return formatted_count - rows; return formatted_count - rows;
} }
void ChatBuffer::resize(u32 scrollback) { void ChatBuffer::resize(u32 scrollback)
{
m_scrollback = scrollback; m_scrollback = scrollback;
if (m_unformatted.size() > m_scrollback) if (m_unformatted.size() > m_scrollback)
{
deleteOldest(m_unformatted.size() - m_scrollback); deleteOldest(m_unformatted.size() - m_scrollback);
} }
}
ChatPrompt::ChatPrompt(const std::wstring &prompt, u32 history_limit): ChatPrompt::ChatPrompt(const std::wstring &prompt, u32 history_limit):
@ -739,8 +738,11 @@ void ChatBackend::clearRecentChat()
} }
void ChatBackend::applySettings(Settings* settings) { void ChatBackend::applySettings()
m_recent_buffer.resize(settings->getU32("recent_chat_size")); {
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) void ChatBackend::step(float dtime)

View File

@ -284,7 +284,7 @@ public:
void scrollPageUp(); void scrollPageUp();
// Resize recent buffer based on settings // Resize recent buffer based on settings
void applySettings(Settings* settings); void applySettings();
private: private:
ChatBuffer m_console_buffer; ChatBuffer m_console_buffer;

View File

@ -190,7 +190,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("node_highlighting", "box"); settings->setDefault("node_highlighting", "box");
settings->setDefault("crosshair_color", "(255,255,255)"); settings->setDefault("crosshair_color", "(255,255,255)");
settings->setDefault("crosshair_alpha", "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("hud_scaling", "1.0");
settings->setDefault("gui_scaling", "1.0"); settings->setDefault("gui_scaling", "1.0");
settings->setDefault("gui_scaling_filter", "false"); settings->setDefault("gui_scaling_filter", "false");

View File

@ -2052,7 +2052,7 @@ bool Game::initGui()
chat_backend->clearRecentChat(); chat_backend->clearRecentChat();
// Make sure the size of the recent messages buffer is right // Make sure the size of the recent messages buffer is right
chat_backend->applySettings(g_settings); chat_backend->applySettings();
// Chat backend and console // Chat backend and console
gui_chat_console = new GUIChatConsole(guienv, guienv->getRootGUIElement(), gui_chat_console = new GUIChatConsole(guienv, guienv->getRootGUIElement(),

View File

@ -310,7 +310,7 @@ fake_function() {
gettext("Crosshair alpha"); gettext("Crosshair alpha");
gettext("Crosshair alpha (opaqueness, between 0 and 255)."); gettext("Crosshair alpha (opaqueness, between 0 and 255).");
gettext("Recent Chat Messages"); 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("Desynchronize block animation");
gettext("Whether node texture animations should be desynchronized per mapblock."); gettext("Whether node texture animations should be desynchronized per mapblock.");
gettext("Maximum hotbar width"); gettext("Maximum hotbar width");