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 | end |
---|
35 | |
---|
36 | function P.MouseControlsMouseNormalScrollbar_changed(e) |
---|
37 | if mousenormalscrollbar_active == false then |
---|
38 | scrollposition = mousenormalscrollbarwindow:getScrollPosition() |
---|
39 | mousenormalsensitivity = (math.pow(64,scrollposition)+6)/14 |
---|
40 | orxonox.config("KeyBinder", "mouseSensitivity_", mousenormalsensitivity) |
---|
41 | end |
---|
42 | end |
---|
43 | |
---|
44 | function P.MouseControlsMouseNormalScrollbar_started(e) |
---|
45 | mousenormalscrollbar_active = true |
---|
46 | end |
---|
47 | |
---|
48 | function P.MouseControlsMouseNormalScrollbar_ended(e) |
---|
49 | scrollposition = mousenormalscrollbarwindow:getScrollPosition() |
---|
50 | mousenormalsensitivity = (math.pow(64,scrollposition)+6)/14 |
---|
51 | orxonox.config("KeyBinder", "mouseSensitivity_", mousenormalsensitivity) |
---|
52 | mousenormalscrollbar_active = false |
---|
53 | end |
---|
54 | |
---|
55 | function P.MouseControlsMouseDeriveScrollbar_changed(e) |
---|
56 | if mousederivescrollbar_active == false then |
---|
57 | scrollposition = mousederivescrollbarwindow:getScrollPosition() |
---|
58 | mousederivesensitivity = (math.pow(64,scrollposition)+6)/14 |
---|
59 | orxonox.config("KeyBinder", "mouseSensitivityDerived_", mousederivesensitivity) |
---|
60 | end |
---|
61 | end |
---|
62 | |
---|
63 | function P.MouseControlsMouseDeriveScrollbar_started(e) |
---|
64 | mousederivescrollbar_active = true |
---|
65 | end |
---|
66 | |
---|
67 | function P.MouseControlsMouseDeriveScrollbar_ended(e) |
---|
68 | scrollposition = mousederivescrollbarwindow:getScrollPosition() |
---|
69 | mousederivesensitivity = (math.pow(64,scrollposition)+6)/14 |
---|
70 | orxonox.config("KeyBinder", "mouseSensitivityDerived_", mousederivesensitivity) |
---|
71 | mousederivescrollbar_active = false |
---|
72 | end |
---|
73 | |
---|
74 | function P.MouseNormalButton_clicked(e) |
---|
75 | if block == false then |
---|
76 | block = true |
---|
77 | derivewindow:setSelected(false) |
---|
78 | block = false |
---|
79 | orxonox.config("KeyBinder", "bDeriveMouseInput_", 0) |
---|
80 | end |
---|
81 | end |
---|
82 | |
---|
83 | function P.MouseDeriveButton_clicked(e) |
---|
84 | if block == false then |
---|
85 | block = true |
---|
86 | normalwindow:setSelected(false) |
---|
87 | block = false |
---|
88 | orxonox.config("KeyBinder", "bDeriveMouseInput_", 1) |
---|
89 | end |
---|
90 | end |
---|
91 | |
---|
92 | function P.MouseInvertCheckbox_clicked(e) |
---|
93 | -- invert mouse |
---|
94 | end |
---|
95 | |
---|
96 | function P.MouseControlsBackButton_clicked(e) |
---|
97 | hideMenuSheet(P.name) |
---|
98 | end |
---|
99 | |
---|
100 | return P |
---|
101 | |
---|