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