summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorpecksin <pexin@protonmail.com>2021-03-18 16:47:36 -0400
committerpecksin <pexin@protonmail.com>2021-03-18 16:47:36 -0400
commitb6c8761e108eade0d1451580fbacf1e3d3f6a957 (patch)
tree27f9503a76261a37a8cc286b18fc17c17cc5a9b6 /src/gui
parent1d64e6537c3fb048e0d0594680d1c727a80c30d8 (diff)
downloadminetest-b6c8761e108eade0d1451580fbacf1e3d3f6a957.tar.gz
minetest-b6c8761e108eade0d1451580fbacf1e3d3f6a957.tar.bz2
minetest-b6c8761e108eade0d1451580fbacf1e3d3f6a957.zip
re-apply everything manually because git
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/guiChatConsole.cpp32
-rw-r--r--src/gui/guiChatConsole.h3
2 files changed, 34 insertions, 1 deletions
diff --git a/src/gui/guiChatConsole.cpp b/src/gui/guiChatConsole.cpp
index ef471106d..f5336e3ad 100644
--- a/src/gui/guiChatConsole.cpp
+++ b/src/gui/guiChatConsole.cpp
@@ -90,6 +90,8 @@ GUIChatConsole::GUIChatConsole(
// set default cursor options
setCursor(true, true, 2.0, 0.1);
+
+ m_cache_clickable_chat_weblinks = g_settings->getBool("clickable_chat_weblinks");
}
GUIChatConsole::~GUIChatConsole()
@@ -321,6 +323,7 @@ void GUIChatConsole::drawText()
#if USE_FREETYPE
if (m_font->getType() == irr::gui::EGFT_CUSTOM) {
+
// Draw colored text if FreeType is enabled
irr::gui::CGUITTFont *tmp = dynamic_cast<irr::gui::CGUITTFont *>(m_font);
tmp->draw(
@@ -404,9 +407,24 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
{
ChatPrompt &prompt = m_chat_backend->getPrompt();
+ static bool isctrldown; // track this for mouse event
- if(event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown)
+ if(event.EventType == EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
{
+ // CTRL up
+ if(event.KeyInput.Key == KEY_LCONTROL || event.KeyInput.Key == KEY_RCONTROL || !event.KeyInput.Control)
+ {
+ isctrldown = false;
+ }
+ }
+ else if(event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown)
+ {
+ // CTRL down
+ if(event.KeyInput.Key == KEY_LCONTROL || event.KeyInput.Key == KEY_RCONTROL || event.KeyInput.Control)
+ {
+ isctrldown = true;
+ }
+
// Key input
if (KeyPress(event.KeyInput) == getKeySetting("keymap_console")) {
closeConsole();
@@ -624,6 +642,18 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
s32 rows = myround(-3.0 * event.MouseInput.Wheel);
m_chat_backend->scroll(rows);
}
+ // Middle click opens weblink, if enabled in config
+ else if(m_cache_clickable_chat_weblinks && (
+ event.MouseInput.Event == EMIE_MMOUSE_PRESSED_DOWN ||
+ (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN && isctrldown)
+ ))
+ {
+ // because console prompt and hardcoded margins
+ if(event.MouseInput.Y / m_fontsize.Y < (m_height / m_fontsize.Y) - 1 )
+ {
+ m_chat_backend->middleClick(event.MouseInput.X / m_fontsize.X, event.MouseInput.Y / m_fontsize.Y);
+ }
+ }
}
return Parent ? Parent->OnEvent(event) : false;
diff --git a/src/gui/guiChatConsole.h b/src/gui/guiChatConsole.h
index 896342ab0..501bf50cb 100644
--- a/src/gui/guiChatConsole.h
+++ b/src/gui/guiChatConsole.h
@@ -124,4 +124,7 @@ private:
// font
gui::IGUIFont *m_font = nullptr;
v2u32 m_fontsize;
+
+ // Enable clickable chat weblinks
+ bool m_cache_clickable_chat_weblinks;
};