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