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