[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 |
---|
[7924] | 34 | |
---|
| 35 | P:initButtons(1, 1) |
---|
| 36 | P:setButton(1, 1, { |
---|
| 37 | ["button"] = winMgr:getWindow("orxonox/MouseControlsBackButton"), |
---|
| 38 | ["callback"] = P.MouseControlsBackButton_clicked |
---|
| 39 | }) |
---|
[6363] | 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) |
---|
[6746] | 103 | hideMenuSheet(P.name) |
---|
[6363] | 104 | end |
---|
| 105 | |
---|
| 106 | return P |
---|
| 107 | |
---|