[6363] | 1 | -- MouseControlsMenu.lua |
---|
| 2 | |
---|
| 3 | BasicGUI = require("BasicGUI") |
---|
[6595] | 4 | local P = BasicGUI:new("MouseControlsMenu") |
---|
[6363] | 5 | if _REQUIREDNAME == nil then |
---|
| 6 | MouseControlsMenu = P |
---|
| 7 | else |
---|
| 8 | _G[_REQUIREDNAME] = P |
---|
| 9 | end |
---|
| 10 | |
---|
| 11 | function P:init() |
---|
| 12 | block = false |
---|
| 13 | mousenormalscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MouseNormalScrollbar"),"CEGUI::Scrollbar") |
---|
| 14 | mousederivescrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MouseDeriveScrollbar"),"CEGUI::Scrollbar") |
---|
| 15 | normalwindow = tolua.cast(winMgr:getWindow("orxonox/MouseNormalButton"),"CEGUI::RadioButton") |
---|
| 16 | derivewindow = tolua.cast(winMgr:getWindow("orxonox/MouseDeriveButton"),"CEGUI::RadioButton") |
---|
| 17 | invertwindow = tolua.cast(winMgr:getWindow("orxonox/MouseInvertCheckbox"),"CEGUI::Checkbox") |
---|
| 18 | mousenormalscrollbar_active = false |
---|
| 19 | mousederivescrollbar_active = false |
---|
| 20 | derive_active = orxonox.getConfig("KeyBinder","bDeriveMouseInput_") |
---|
| 21 | invert_active = false |
---|
| 22 | mousenormalsensitivity = orxonox.getConfig("KeyBinder","mouseSensitivity_") |
---|
| 23 | mousederivesensitivity = orxonox.getConfig("KeyBinder","mouseSensitivityDerived_") |
---|
| 24 | mousenormalscrollbarwindow:setScrollPosition((math.log(14*mousenormalsensitivity-6))/(6*math.log(2))) |
---|
| 25 | mousederivescrollbarwindow:setScrollPosition((math.log(14*mousederivesensitivity-6))/(6*math.log(2))) |
---|
| 26 | if derive_active == "true" then |
---|
| 27 | normal_active = false |
---|
| 28 | derive_active = true |
---|
| 29 | derivewindow:setSelected(derive_active) |
---|
| 30 | else |
---|
| 31 | normal_active = true |
---|
| 32 | derive_active = false |
---|
| 33 | normalwindow:setSelected(normal_active) |
---|
| 34 | end |
---|
| 35 | if invert_active == "true" then |
---|
| 36 | invert_active = true |
---|
| 37 | else |
---|
| 38 | invert_active = false |
---|
| 39 | end |
---|
| 40 | end |
---|
| 41 | |
---|
| 42 | function P.MouseControlsMouseNormalScrollbar_changed(e) |
---|
| 43 | if mousenormalscrollbar_active == false then |
---|
| 44 | scrollposition = mousenormalscrollbarwindow:getScrollPosition() |
---|
| 45 | mousenormalsensitivity = (math.pow(64,scrollposition)+6)/14 |
---|
[6403] | 46 | orxonox.config("KeyBinder", "mouseSensitivity_", mousenormalsensitivity) |
---|
[6363] | 47 | end |
---|
| 48 | end |
---|
| 49 | |
---|
| 50 | function P.MouseControlsMouseNormalScrollbar_started(e) |
---|
| 51 | mousenormalscrollbar_active = true |
---|
| 52 | end |
---|
| 53 | |
---|
| 54 | function P.MouseControlsMouseNormalScrollbar_ended(e) |
---|
| 55 | scrollposition = mousenormalscrollbarwindow:getScrollPosition() |
---|
| 56 | mousenormalsensitivity = (math.pow(64,scrollposition)+6)/14 |
---|
[6403] | 57 | orxonox.config("KeyBinder", "mouseSensitivity_", mousenormalsensitivity) |
---|
[6363] | 58 | mousenormalscrollbar_active = false |
---|
| 59 | end |
---|
| 60 | |
---|
| 61 | function P.MouseControlsMouseDeriveScrollbar_changed(e) |
---|
| 62 | if mousederivescrollbar_active == false then |
---|
| 63 | scrollposition = mousederivescrollbarwindow:getScrollPosition() |
---|
| 64 | mousederivesensitivity = (math.pow(64,scrollposition)+6)/14 |
---|
[6403] | 65 | orxonox.config("KeyBinder", "mouseSensitivityDerived_", mousederivesensitivity) |
---|
[6363] | 66 | end |
---|
| 67 | end |
---|
| 68 | |
---|
| 69 | function P.MouseControlsMouseDeriveScrollbar_started(e) |
---|
| 70 | mousederivescrollbar_active = true |
---|
| 71 | end |
---|
| 72 | |
---|
| 73 | function P.MouseControlsMouseDeriveScrollbar_ended(e) |
---|
| 74 | scrollposition = mousederivescrollbarwindow:getScrollPosition() |
---|
| 75 | mousederivesensitivity = (math.pow(64,scrollposition)+6)/14 |
---|
[6403] | 76 | orxonox.config("KeyBinder", "mouseSensitivityDerived_", mousederivesensitivity) |
---|
[6363] | 77 | mousederivescrollbar_active = false |
---|
| 78 | end |
---|
| 79 | |
---|
| 80 | function P.MouseNormalButton_clicked(e) |
---|
| 81 | if block == false then |
---|
| 82 | block = true |
---|
| 83 | derivewindow:setSelected(false) |
---|
| 84 | block = false |
---|
[6403] | 85 | orxonox.config("KeyBinder", "bDeriveMouseInput_", 0) |
---|
[6363] | 86 | end |
---|
| 87 | end |
---|
| 88 | |
---|
| 89 | function P.MouseDeriveButton_clicked(e) |
---|
| 90 | if block == false then |
---|
| 91 | block = true |
---|
| 92 | normalwindow:setSelected(false) |
---|
| 93 | block = false |
---|
[6403] | 94 | orxonox.config("KeyBinder", "bDeriveMouseInput_", 1) |
---|
[6363] | 95 | end |
---|
| 96 | end |
---|
| 97 | |
---|
| 98 | function P.MouseInvertCheckbox_clicked(e) |
---|
| 99 | -- invert mouse |
---|
| 100 | end |
---|
| 101 | |
---|
| 102 | function P.MouseControlsBackButton_clicked(e) |
---|
| 103 | hideGUI(P.filename) |
---|
| 104 | end |
---|
| 105 | |
---|
| 106 | return P |
---|
| 107 | |
---|