Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/usability/data/gui/scripts/MouseControlsMenu.lua @ 7924

Last change on this file since 7924 was 7924, checked in by landauf, 14 years ago
  • the "back" button of MultiplayerMenu and SettingsMenu now fills the whole row at the bottom, so it can be accessed from both columns by pressing 'down'
  • added keyboard support for KeyBindMenu, MiscConfigMenu, and MouseControlsMenu
  • Property svn:eol-style set to native
File size: 3.8 KB
RevLine 
[6363]1-- MouseControlsMenu.lua
2
[6746]3local P = createMenuSheet("MouseControlsMenu")
[6363]4
[6746]5function P.onLoad()
[6363]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
[7924]34
35    P:initButtons(1, 1)
36    P:setButton(1, 1, {
37            ["button"] = winMgr:getWindow("orxonox/MouseControlsBackButton"),
38            ["callback"]  = P.MouseControlsBackButton_clicked
39    })
[6363]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
[6403]46        orxonox.config("KeyBinder", "mouseSensitivity_", mousenormalsensitivity)
[6363]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
[6403]57    orxonox.config("KeyBinder", "mouseSensitivity_", mousenormalsensitivity)
[6363]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
[6403]65        orxonox.config("KeyBinder", "mouseSensitivityDerived_", mousederivesensitivity)
[6363]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
[6403]76    orxonox.config("KeyBinder", "mouseSensitivityDerived_", mousederivesensitivity)
[6363]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
[6403]85        orxonox.config("KeyBinder", "bDeriveMouseInput_", 0)
[6363]86    end
87end
88
89function P.MouseDeriveButton_clicked(e)
90    if block == false then
91        block = true
92        normalwindow:setSelected(false)
93        block = false
[6403]94        orxonox.config("KeyBinder", "bDeriveMouseInput_", 1)
[6363]95    end
96end
97
98function P.MouseInvertCheckbox_clicked(e)
99    -- invert mouse
100end
101
102function P.MouseControlsBackButton_clicked(e)
[6746]103    hideMenuSheet(P.name)
[6363]104end
105
106return P
107
Note: See TracBrowser for help on using the repository browser.