From b50da63852f2a2360d07cc2f1e29fc6844b15ccc Mon Sep 17 00:00:00 2001 From: Jeija Date: Fri, 4 Jan 2013 15:19:16 +0100 Subject: [PATCH] Repeated right clicking when holding the right mouse button Configure using repeat_rightclick_time in minetest.conf --- minetest.conf.example | 3 +++ src/defaultsettings.cpp | 1 + src/game.cpp | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/minetest.conf.example b/minetest.conf.example index 34a2aceb..5fb4244b 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -146,6 +146,9 @@ # (1: low level shaders; not implemented) # 2: enable high level shaders #enable_shaders = 2 +# The time in seconds it takes between repeated +# right clicks when holding the right mouse button +#repeat_rightclick_time = 0.25 # will only work for servers which use remote_media setting # and only for clients compiled with cURL diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index f9c94259..cac3e568 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -121,6 +121,7 @@ void set_default_settings(Settings *settings) settings->setDefault("trilinear_filter", "false"); settings->setDefault("preload_item_visuals", "true"); settings->setDefault("enable_shaders", "2"); + settings->setDefault("repeat_rightclick_time", "0.25"); settings->setDefault("media_fetch_threads", "8"); diff --git a/src/game.cpp b/src/game.cpp index 42863ff3..fdb083ff 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1335,6 +1335,8 @@ void the_game( float time_of_day = 0; float time_of_day_smooth = 0; + float repeat_rightclick_timer = 0; + /* Shader constants */ @@ -2266,6 +2268,9 @@ void the_game( bool left_punch = false; soundmaker.m_player_leftpunch_sound.name = ""; + if(input->getRightState()) + repeat_rightclick_timer += dtime; + if(playeritem_usable && input->getLeftState()) { if(input->getLeftClicked()) @@ -2406,8 +2411,10 @@ void the_game( camera.setDigging(0); // left click animation } - if(input->getRightClicked()) + if(input->getRightClicked() || + repeat_rightclick_timer >= g_settings->getFloat("repeat_rightclick_time")) { + repeat_rightclick_timer = 0; infostream<<"Ground right-clicked"<