Widget to avoid super fast, or blocked camera, after middle mouse button is pressed without being held, above the map

Widget to avoid super fast, or blocked camera, after middle mouse button is pressed without being held, above the map

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
tulipe
Posts: 6
Joined: 30 Mar 2018, 10:17

Widget to avoid super fast, or blocked camera, after middle mouse button is pressed without being held, above the map

Post by tulipe »

If I remenber correctly, from many years, sometimes, I had the camera blocked with only few capacity to move or super fast camera (blocked or fast, it seemed it depended on the engine and camera type).(This behaviour of "blocked camera" could occur with overhead camera mode or fps camera mode or rot overhead camera mode, and if middle mouse button is not held.) :!:

This widget should avoid this behaviour of camera, for middle mouse button. But by enabling this widget, it should disable the possibility, at least in overhead camera mode, to navigate on map by holding middle mouse button. Above the minimap, this widget shouldn't disable the capacity to navigate with middle mouse button (maintained pressed or not).

(For installation of this widget, please see for example https://springrts.com/wiki/Lua_Widgets.)
(Code of this widget:

Code: Select all

function widget:GetInfo()
    return {
        name = "Disable middle mouse click above the map",
        desc = "A widget to avoid camera like blocked or super fast, atfer an unmaintained middle click above the map",
        author = "",
        version = "2",
        date = "2020",
        license = "",
        layer = 90051,
        enabled = true,
    }
end

function widget:MousePress(mx, my, button)
    if (button == 2) and (not Spring.IsAboveMiniMap(mx, my)) then
        return true
    end
    return false
end
)

(Another way to fix this behaviour and in addition to retaining the ability to navigate by holding middle mouse button pressed, could be if an argument "isRepeat" is added to "addon.MousePress(x, y, button)" (https://springrts.com/wiki/Lua:Callins) as there is already one for addon.KeyPress (addon.KeyPress(key, mods, isRepeat)).)
(edit: in this widget, unsure line "return false" is needed.)

Edit: widget upgraded to version 2, may 27, 2020: at least name and description of the widget changed.
Attachments
cmd_disable_middle_mouse_click_above_the_map.lua
A widget to avoid camera like blocked or super fast, atfer an unmaintained middle click above the map
(540 Bytes) Downloaded 1 time
Post Reply

Return to “Lua Scripts”