Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestate/data/gui/scripts/MouseControlsMenu.lua @ 6544

Last change on this file since 6544 was 6459, checked in by rgrieder, 15 years ago

Simplified BasicGUI construction. Just give the name of the GUI as argument. The rest will be deduced.

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