Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestates3/data/gui/scripts/MouseControlsMenu.lua @ 11297

Last change on this file since 11297 was 6773, checked in by rgrieder, 15 years ago

Eliminated all unnecessary global Lua variables and replaced them either with a local or a instance variable (P.myVar).

  • Property svn:eol-style set to native
File size: 3.7 KB
Line 
1-- MouseControlsMenu.lua
2
3local P = createMenuSheet("MouseControlsMenu")
4
5function 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
35end
36
37function 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
43end
44
45function P.MouseControlsMouseNormalScrollbar_started(e)
46    P.mousenormalscrollbar_active = true
47end
48
49function 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
54end
55
56function 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
62end
63
64function P.MouseControlsMouseDeriveScrollbar_started(e)
65    P.mousederivescrollbar_active = true
66end
67
68function 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
73end
74
75function 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
82end
83
84function 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
91end
92
93function P.MouseInvertCheckbox_clicked(e)
94    -- invert mouse
95end
96
97function P.MouseControlsBackButton_clicked(e)
98    hideMenuSheet(P.name)
99end
100
101return P
102
Note: See TracBrowser for help on using the repository browser.