1 | -- MouseControlsMenu.lua |
---|
2 | |
---|
3 | local P = createMenuSheet("MouseControlsMenu") |
---|
4 | |
---|
5 | function P.onLoad() |
---|
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))) |
---|
21 | if derive_active == "true" then |
---|
22 | normal_active = false |
---|
23 | derive_active = true |
---|
24 | P.derivewindow:setSelected(derive_active) |
---|
25 | else |
---|
26 | normal_active = true |
---|
27 | derive_active = false |
---|
28 | P.normalwindow:setSelected(normal_active) |
---|
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) |
---|
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) |
---|
42 | end |
---|
43 | end |
---|
44 | |
---|
45 | function P.MouseControlsMouseNormalScrollbar_started(e) |
---|
46 | P.mousenormalscrollbar_active = true |
---|
47 | end |
---|
48 | |
---|
49 | function P.MouseControlsMouseNormalScrollbar_ended(e) |
---|
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 |
---|
54 | end |
---|
55 | |
---|
56 | function P.MouseControlsMouseDeriveScrollbar_changed(e) |
---|
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) |
---|
61 | end |
---|
62 | end |
---|
63 | |
---|
64 | function P.MouseControlsMouseDeriveScrollbar_started(e) |
---|
65 | P.mousederivescrollbar_active = true |
---|
66 | end |
---|
67 | |
---|
68 | function P.MouseControlsMouseDeriveScrollbar_ended(e) |
---|
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 |
---|
73 | end |
---|
74 | |
---|
75 | function P.MouseNormalButton_clicked(e) |
---|
76 | if P.block == false then |
---|
77 | P.block = true |
---|
78 | P.derivewindow:setSelected(false) |
---|
79 | P.block = false |
---|
80 | orxonox.config("KeyBinder", "bDeriveMouseInput_", 0) |
---|
81 | end |
---|
82 | end |
---|
83 | |
---|
84 | function P.MouseDeriveButton_clicked(e) |
---|
85 | if P.block == false then |
---|
86 | P.block = true |
---|
87 | P.normalwindow:setSelected(false) |
---|
88 | P.block = false |
---|
89 | orxonox.config("KeyBinder", "bDeriveMouseInput_", 1) |
---|
90 | end |
---|
91 | end |
---|
92 | |
---|
93 | function P.MouseInvertCheckbox_clicked(e) |
---|
94 | -- invert mouse |
---|
95 | end |
---|
96 | |
---|
97 | function P.MouseControlsBackButton_clicked(e) |
---|
98 | hideMenuSheet(P.name) |
---|
99 | end |
---|
100 | |
---|
101 | return P |
---|
102 | |
---|