Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 23, 2010, 11:41:30 AM (15 years ago)
Author:
rgrieder
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gamestates3/data/gui/scripts/MouseControlsMenu.lua

    r6746 r6773  
    44
    55function 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)))
     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)))
    2021    if derive_active == "true" then
    2122        normal_active = false
    2223        derive_active = true
    23         derivewindow:setSelected(derive_active)
     24        P.derivewindow:setSelected(derive_active)
    2425    else
    2526        normal_active = true
    2627        derive_active = false
    27         normalwindow:setSelected(normal_active)
     28        P.normalwindow:setSelected(normal_active)
    2829    end
    2930    if invert_active == "true" then
     
    3536
    3637function 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)
     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)
    4142    end
    4243end
    4344
    4445function P.MouseControlsMouseNormalScrollbar_started(e)
    45     mousenormalscrollbar_active = true
     46    P.mousenormalscrollbar_active = true
    4647end
    4748
    4849function 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
     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
    5354end
    5455
    5556function 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)
     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)
    6061    end
    6162end
    6263
    6364function P.MouseControlsMouseDeriveScrollbar_started(e)
    64     mousederivescrollbar_active = true
     65    P.mousederivescrollbar_active = true
    6566end
    6667
    6768function 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
     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
    7273end
    7374
    7475function P.MouseNormalButton_clicked(e)
    75     if block == false then
    76         block = true
    77         derivewindow:setSelected(false)
    78         block = false
     76    if P.block == false then
     77        P.block = true
     78        P.derivewindow:setSelected(false)
     79        P.block = false
    7980        orxonox.config("KeyBinder", "bDeriveMouseInput_", 0)
    8081    end
     
    8283
    8384function P.MouseDeriveButton_clicked(e)
    84     if block == false then
    85         block = true
    86         normalwindow:setSelected(false)
    87         block = false
     85    if P.block == false then
     86        P.block = true
     87        P.normalwindow:setSelected(false)
     88        P.block = false
    8889        orxonox.config("KeyBinder", "bDeriveMouseInput_", 1)
    8990    end
Note: See TracChangeset for help on using the changeset viewer.