Widget to avoid some camera behaviour after middle mouse button is pressed without being held, above the map

Widget to avoid some camera behaviour 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...)

Moderators: Moderators, Moderators

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

Widget to avoid some camera behaviour 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 = "Middle mouse button",
        desc = "A widget for avoid some camera behaviour after middle mouse button is pressed",
        author = "",
        version = "",
        date = "2020",
        license = "",
        layer = 90050,
        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.)
Attachments
cmd_middle_mouse_button.lua
Widget to avoid some camera behaviour after middle mouse button is pressed without being held, above the map
(494 Bytes) Downloaded 5 times
0 x

Post Reply

Return to “Lua Scripts”