| 1 | -- MouseControlsMenu.lua | 
|---|
| 2 |  | 
|---|
| 3 | local P = createMenuSheet("MouseControlsMenu") | 
|---|
| 4 |  | 
|---|
| 5 | function P.onLoad() | 
|---|
| 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 | 
|---|
| 34 |  | 
|---|
| 35 |     P:setButton(1, 1, { | 
|---|
| 36 |             ["button"] = winMgr:getWindow("orxonox/MouseControlsBackButton"), | 
|---|
| 37 |             ["callback"]  = P.MouseControlsBackButton_clicked | 
|---|
| 38 |     }) | 
|---|
| 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 | 
|---|
| 45 |         orxonox.config("KeyBinder", "mouseSensitivity_", mousenormalsensitivity) | 
|---|
| 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 | 
|---|
| 56 |     orxonox.config("KeyBinder", "mouseSensitivity_", mousenormalsensitivity) | 
|---|
| 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 | 
|---|
| 64 |         orxonox.config("KeyBinder", "mouseSensitivityDerived_", mousederivesensitivity) | 
|---|
| 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 | 
|---|
| 75 |     orxonox.config("KeyBinder", "mouseSensitivityDerived_", mousederivesensitivity) | 
|---|
| 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 | 
|---|
| 84 |         orxonox.config("KeyBinder", "bDeriveMouseInput_", 0) | 
|---|
| 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 | 
|---|
| 93 |         orxonox.config("KeyBinder", "bDeriveMouseInput_", 1) | 
|---|
| 94 |     end | 
|---|
| 95 | end | 
|---|
| 96 |  | 
|---|
| 97 | function P.MouseInvertCheckbox_clicked(e) | 
|---|
| 98 |     -- invert mouse | 
|---|
| 99 | end | 
|---|
| 100 |  | 
|---|
| 101 | function P.MouseControlsBackButton_clicked(e) | 
|---|
| 102 |     hideMenuSheet(P.name) | 
|---|
| 103 | end | 
|---|
| 104 |  | 
|---|
| 105 | return P | 
|---|
| 106 |  | 
|---|