Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6773 for code/branches


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).

Location:
code/branches/gamestates3/data
Files:
13 edited

Legend:

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

    r6746 r6773  
    44
    55function P.onLoad()
    6     soundMgr = orxonox.SoundManager:getInstance()
    7     block = false
    8     masterscrollbar_active = false
    9     musicscrollbar_active = false
    10     effectsscrollbar_active = false
    11     mastervolume = soundMgr:getVolume(orxonox.SoundType.All)
    12     musicvolume = soundMgr:getVolume(orxonox.SoundType.Music)
    13     effectsvolume = soundMgr:getVolume(orxonox.SoundType.Effects)
    14     mastermute = soundMgr:getMute(orxonox.SoundType.All)
    15     musicmute = soundMgr:getMute(orxonox.SoundType.Music)
    16     effectsmute = soundMgr:getMute(orxonox.SoundType.Effects)
    17     masterscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
    18     musicscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
    19     effectsscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
    20     mastermutewindow = tolua.cast(winMgr:getWindow("orxonox/MasterCheckbox"),"CEGUI::Checkbox")
    21     musicmutewindow = tolua.cast(winMgr:getWindow("orxonox/MusicCheckbox"),"CEGUI::Checkbox")
    22     effectsmutewindow = tolua.cast(winMgr:getWindow("orxonox/EffectsCheckbox"),"CEGUI::Checkbox")
    23     masterscrollbarwindow:setScrollPosition(mastervolume)
    24     musicscrollbarwindow:setScrollPosition(musicvolume)
    25     effectsscrollbarwindow:setScrollPosition(effectsvolume)
    26     mastermutewindow:setSelected(mastermute)
    27     musicmutewindow:setSelected(musicmute)
    28     effectsmutewindow:setSelected(effectsmute)
    29     choice = "Default"
    30     listboxwindow = winMgr:getWindow("orxonox/AudioThemeListbox")
     6    P.soundMgr = orxonox.SoundManager:getInstance()
     7    P.block = false
     8    P.masterscrollbar_active = false
     9    P.musicscrollbar_active = false
     10    P.effectsscrollbar_active = false
     11    P.mastervolume = P.soundMgr:getVolume(orxonox.SoundType.All)
     12    P.musicvolume = P.soundMgr:getVolume(orxonox.SoundType.Music)
     13    P.effectsvolume = P.soundMgr:getVolume(orxonox.SoundType.Effects)
     14    P.mastermute = P.soundMgr:getMute(orxonox.SoundType.All)
     15    P.musicmute = P.soundMgr:getMute(orxonox.SoundType.Music)
     16    P.effectsmute = P.soundMgr:getMute(orxonox.SoundType.Effects)
     17    P.masterscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
     18    P.musicscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
     19    P.effectsscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
     20    P.mastermutewindow = tolua.cast(winMgr:getWindow("orxonox/MasterCheckbox"),"CEGUI::Checkbox")
     21    P.musicmutewindow = tolua.cast(winMgr:getWindow("orxonox/MusicCheckbox"),"CEGUI::Checkbox")
     22    P.effectsmutewindow = tolua.cast(winMgr:getWindow("orxonox/EffectsCheckbox"),"CEGUI::Checkbox")
     23    P.masterscrollbarwindow:setScrollPosition(P.mastervolume)
     24    P.musicscrollbarwindow:setScrollPosition(P.musicvolume)
     25    P.effectsscrollbarwindow:setScrollPosition(P.effectsvolume)
     26    P.mastermutewindow:setSelected(P.mastermute)
     27    P.musicmutewindow:setSelected(P.musicmute)
     28    P.effectsmutewindow:setSelected(P.effectsmute)
     29    local choice = "Default"
     30    P.listboxwindow = winMgr:getWindow("orxonox/AudioThemeListbox")
    3131    local themeList = {}
    3232    table.insert(themeList, "Default")
    3333    table.insert(themeList, "Drum n' Bass")
    3434    for k,v in pairs(themeList) do
    35         item = CEGUI.createListboxTextItem(v)
     35        local item = CEGUI.createListboxTextItem(v)
    3636        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    37         CEGUI.toListbox(listboxwindow):addItem(item)
     37        CEGUI.toListbox(P.listboxwindow):addItem(item)
    3838    end
    3939    if orxonox.getConfig("MoodManager", "mood_") == "dnb" then
    40         listboxwindow:setItemSelectState(1,true)
     40        P.listboxwindow:setItemSelectState(1,true)
    4141    else
    42         listboxwindow:setItemSelectState(0,true)
     42        P.listboxwindow:setItemSelectState(0,true)
    4343    end
    4444end
    4545
    4646function P.AudioMasterScrollbar_changed(e)
    47     if mastermute then
    48         block = true
    49         mastermutewindow:setSelected(false)
    50         block = false
    51         mastermute = false
     47    if P.mastermute then
     48        P.block = true
     49        P.mastermutewindow:setSelected(false)
     50        P.block = false
     51        P.mastermute = false
    5252    end
    53     if masterscrollbar_active == false then
    54         mastervolume = masterscrollbarwindow:getScrollPosition()
    55         orxonox.config("SoundManager", "soundVolume_", mastervolume)
     53    if P.masterscrollbar_active == false then
     54        P.mastervolume = P.masterscrollbarwindow:getScrollPosition()
     55        orxonox.config("SoundManager", "soundVolume_", P.mastervolume)
    5656    end
    5757end
    5858
    5959function P.AudioMasterScrollbar_started(e)
    60     masterscrollbar_active = true
     60    P.masterscrollbar_active = true
    6161end
    6262
    6363function P.AudioMasterScrollbar_ended(e)
    64     mastervolume = masterscrollbarwindow:getScrollPosition()
    65     orxonox.config("SoundManager", "soundVolume_", mastervolume)
    66     masterscrollbar_active = false
     64    P.mastervolume = P.masterscrollbarwindow:getScrollPosition()
     65    orxonox.config("SoundManager", "soundVolume_", P.mastervolume)
     66    P.masterscrollbar_active = false
    6767end
    6868
    6969function P.AudioMusicScrollbar_changed(e)
    70     if musicmute then
    71         block = true
    72         musicmutewindow:setSelected(false)
    73         block = false
    74         musicmute = false
     70    if P.musicmute then
     71        P.block = true
     72        P.musicmutewindow:setSelected(false)
     73        P.block = false
     74        P.musicmute = false
    7575    end
    76     if musicscrollbar_active == false then
    77         musicvolume = musicscrollbarwindow:getScrollPosition()
    78         orxonox.config("SoundManager", "ambientVolume_", musicvolume)
     76    if P.musicscrollbar_active == false then
     77        P.musicvolume = P.musicscrollbarwindow:getScrollPosition()
     78        orxonox.config("SoundManager", "ambientVolume_", P.musicvolume)
    7979    end
    8080end
    8181
    8282function P.AudioMusicScrollbar_started(e)
    83     musicscrollbar_active = true
     83    P.musicscrollbar_active = true
    8484end
    8585
    8686function P.AudioMusicScrollbar_ended(e)
    87     musicmutewindow:setSelected(false)
    88     musicvolume = musicscrollbarwindow:getScrollPosition()
    89     orxonox.config("SoundManager", "ambientVolume_", musicvolume)
    90     musicscrollbar_active = false
     87    P.musicmutewindow:setSelected(false)
     88    P.musicvolume = P.musicscrollbarwindow:getScrollPosition()
     89    orxonox.config("SoundManager", "ambientVolume_", P.musicvolume)
     90    P.musicscrollbar_active = false
    9191end
    9292
    9393function P.AudioEffectsScrollbar_changed(e)
    94     if effectsmute then
    95         block = true
    96         effectsmutewindow:setSelected(false)
    97         block = false
    98         effectsmute = false
     94    if P.effectsmute then
     95        P.block = true
     96        P.effectsmutewindow:setSelected(false)
     97        P.block = false
     98        P.effectsmute = false
    9999    end
    100     if effectsscrollbar_active == false then
    101         effectsvolume = effectsscrollbarwindow:getScrollPosition()
    102         orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
     100    if P.effectsscrollbar_active == false then
     101        P.effectsvolume = P.effectsscrollbarwindow:getScrollPosition()
     102        orxonox.config("SoundManager", "effectsVolume_", P.effectsvolume)
    103103    end
    104104end
    105105
    106106function P.AudioEffectsScrollbar_started(e)
    107     effectsscrollbar_active = true
     107    P.effectsscrollbar_active = true
    108108end
    109109
    110110function P.AudioEffectsScrollbar_ended(e)
    111     effectsmutewindow:setSelected(false)
    112     effectsvolume = effectsscrollbarwindow:getScrollPosition()
    113     orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
    114     effectsscrollbar_active = false
     111    P.effectsmutewindow:setSelected(false)
     112    P.effectsvolume = P.effectsscrollbarwindow:getScrollPosition()
     113    orxonox.config("SoundManager", "effectsVolume_", P.effectsvolume)
     114    P.effectsscrollbar_active = false
    115115end
    116116
    117117function P.AudioMuteMasterCheckbox_clicked(e)
    118     if block == false then
    119         if mastermute then
    120             masterscrollbarwindow:setScrollPosition(mastervolume)
    121             mastermute = false
     118    if P.block == false then
     119        if P.mastermute then
     120            P.masterscrollbarwindow:setScrollPosition(P.mastervolume)
     121            P.mastermute = false
    122122        else
    123             temp = masterscrollbarwindow:getScrollPosition()
    124             masterscrollbarwindow:setScrollPosition(0)
    125             mastervolume = temp
    126             mastermute = true
     123            temp = P.masterscrollbarwindow:getScrollPosition()
     124            P.masterscrollbarwindow:setScrollPosition(0)
     125            P.mastervolume = temp
     126            P.mastermute = true
    127127        end
    128128    end
    129     soundMgr:toggleMute(orxonox.SoundType.All)
     129    P.soundMgr:toggleMute(orxonox.SoundType.All)
    130130end
    131131
    132132function P.AudioMuteMusicCheckbox_clicked(e)
    133     if block == false then
    134         if musicmute then
    135             musicscrollbarwindow:setScrollPosition(musicvolume)
    136             musicmute = false
     133    if P.block == false then
     134        if P.musicmute then
     135            P.musicscrollbarwindow:setScrollPosition(P.musicvolume)
     136            P.musicmute = false
    137137        else
    138             temp = musicscrollbarwindow:getScrollPosition()
    139             musicscrollbarwindow:setScrollPosition(0)
    140             musicvolume = temp
    141             musicmute = true
     138            temp = P.musicscrollbarwindow:getScrollPosition()
     139            P.musicscrollbarwindow:setScrollPosition(0)
     140            P.musicvolume = temp
     141            P.musicmute = true
    142142        end
    143143    end
    144     soundMgr:toggleMute(orxonox.SoundType.Music)
     144    P.soundMgr:toggleMute(orxonox.SoundType.Music)
    145145end
    146146
    147147function P.AudioMuteEffectsCheckbox_clicked(e)
    148     if block == false then
    149         if effectsmute then
    150             effectsscrollbarwindow:setScrollPosition(effectsvolume)
    151             effectsmute = false
     148    if P.block == false then
     149        if P.effectsmute then
     150            P.effectsscrollbarwindow:setScrollPosition(P.effectsvolume)
     151            P.effectsmute = false
    152152        else
    153             temp = effectsscrollbarwindow:getScrollPosition()
    154             effectsscrollbarwindow:setScrollPosition(0)
    155             effectsvolume = temp
    156             effectsmute = true
     153            temp = P.effectsscrollbarwindow:getScrollPosition()
     154            P.effectsscrollbarwindow:setScrollPosition(0)
     155            P.effectsvolume = temp
     156            P.effectsmute = true
    157157        end
    158158    end
    159     soundMgr:toggleMute(orxonox.SoundType.Effects)
     159    P.soundMgr:toggleMute(orxonox.SoundType.Effects)
    160160end
    161161
    162162function P.AudioThemeListbox_changed(e)
    163     if listboxwindow:isItemSelected(1) then
     163    if P.listboxwindow:isItemSelected(1) then
    164164        orxonox.config("MoodManager", "mood_", "dnb")
    165165    else
  • code/branches/gamestates3/data/gui/scripts/GUITools.lua

    r6746 r6773  
    33function createMenuSheet(name, bHidePrevious, tShowCursor, tUseKeyboard, bBlockJoyStick)
    44    local sheet = require("MenuSheet").new(name, bHidePrevious, tShowCursor, tUseKeyboard, bBlockJoyStick)
     5    global(sheet.name)
    56    _G[sheet.name] = sheet -- Global access required because of the event handlers
    67    return sheet
  • code/branches/gamestates3/data/gui/scripts/GameplayMenu.lua

    r6746 r6773  
    44
    55function P.onLoad()
    6     dropdown = winMgr:getWindow("orxonox/ThemeCombobox")
     6    local dropdown = winMgr:getWindow("orxonox/ThemeCombobox")
    77    local themeList = {}
    88    table.insert(themeList, "Theme 1")
  • code/branches/gamestates3/data/gui/scripts/GraphicsMenu.lua

    r6746 r6773  
    44
    55function P.onLoad()
    6     block = true
    7     file = orxonox.PathConfig:getConfigPathString() .. orxonox.getConfig("GraphicsManager", "ogreConfigFile_")
    8     search_mode = 0
    9     f = io.open(file, "r")
    10     firstline = f:read("*line")
    11     rendersystem = string.sub(firstline, 15)
     6    P.block = true
     7    P.file = orxonox.PathConfig:getConfigPathString() .. orxonox.getConfig("GraphicsManager", "ogreConfigFile_")
     8    P.search_mode = 0
     9    local f = io.open(P.file, "r")
     10    local firstline = f:read("*line")
     11    local rendersystem = string.sub(firstline, 15)
    1212    for line in f:lines() do
    13         if search_mode == 0 then
     13        if P.search_mode == 0 then
    1414            if string.find(line, rendersystem) ~= nil then
    15                 search_mode = 1
     15                P.search_mode = 1
    1616            end
    1717        end
    18         if search_mode == 1 then
     18        if P.search_mode == 1 then
    1919            if string.sub(line, 1, 11) == "Full Screen" then
    2020                if string.sub(line, 13) == "Yes" then
    21                     fullscreen = true
     21                    P.fullscreen = true
    2222                else
    23                     fullscreen = false
     23                    P.fullscreen = false
    2424                end
    2525            end
    2626            if string.sub(line, 1, 10) == "Video Mode" then
    2727                if string.match(line, "@") == "@" then
    28                     resolution = string.sub(line, 12, string.find(line, "@")-2)
     28                    P.resolution = string.sub(line, 12, string.find(line, "@")-2)
    2929                else
    30                     resolution = string.sub(line, 12)
     30                    P.resolution = string.sub(line, 12)
    3131                end
    3232                break
     
    3636    f:close()
    3737    local fullscreenwindow = tolua.cast(winMgr:getWindow("orxonox/FullscreenCheckbox"),"CEGUI::Checkbox")
    38     fullscreenwindow:setSelected(fullscreen)
    39     listboxwindow = winMgr:getWindow("orxonox/ResolutionListbox")
     38    fullscreenwindow:setSelected(P.fullscreen)
     39    P.listboxwindow = winMgr:getWindow("orxonox/ResolutionListbox")
    4040    local resolutionList = {}
    4141    table.insert(resolutionList, "640 x 480")
     
    5252    table.insert(resolutionList, "1440 x 900")
    5353    for k,v in pairs(resolutionList) do
    54         item = CEGUI.createListboxTextItem(v)
     54        local item = CEGUI.createListboxTextItem(v)
    5555        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    56         CEGUI.toListbox(listboxwindow):addItem(item)
     56        CEGUI.toListbox(P.listboxwindow):addItem(item)
    5757    end
    58     if resolution == "640 x 480" then
    59         listboxwindow:setItemSelectState(0,true)
    60     elseif resolution == "720 x 480" then
    61         listboxwindow:setItemSelectState(1,true)
    62     elseif resolution == "720 x 576" then
    63         listboxwindow:setItemSelectState(2,true)
    64     elseif resolution == "800 x 480" then
    65         listboxwindow:setItemSelectState(3,true)
    66     elseif resolution == "800 x 600" then
    67         listboxwindow:setItemSelectState(4,true)
    68     elseif resolution == "1024 x 480" then
    69         listboxwindow:setItemSelectState(5,true)
    70     elseif resolution == "1024 x 600" then
    71         listboxwindow:setItemSelectState(6,true)
    72     elseif resolution == "1024 x 768" then
    73         listboxwindow:setItemSelectState(7,true)
    74     elseif resolution == "1152 x 864" then
    75         listboxwindow:setItemSelectState(8,true)
    76     elseif resolution == "1280 x 720" then
    77         listboxwindow:setItemSelectState(9,true)
    78     elseif resolution == "1280 x 768" then
    79         listboxwindow:setItemSelectState(10,true)
    80     elseif resolution == "1440 x 900" then
    81         listboxwindow:setItemSelectState(11,true)
     58    if P.resolution == "640 x 480" then
     59        P.listboxwindow:setItemSelectState(0,true)
     60    elseif P.resolution == "720 x 480" then
     61        P.listboxwindow:setItemSelectState(1,true)
     62    elseif P.resolution == "720 x 576" then
     63        P.listboxwindow:setItemSelectState(2,true)
     64    elseif P.resolution == "800 x 480" then
     65        P.listboxwindow:setItemSelectState(3,true)
     66    elseif P.resolution == "800 x 600" then
     67        P.listboxwindow:setItemSelectState(4,true)
     68    elseif P.resolution == "1024 x 480" then
     69        P.listboxwindow:setItemSelectState(5,true)
     70    elseif P.resolution == "1024 x 600" then
     71        P.listboxwindow:setItemSelectState(6,true)
     72    elseif P.resolution == "1024 x 768" then
     73        P.listboxwindow:setItemSelectState(7,true)
     74    elseif P.resolution == "1152 x 864" then
     75        P.listboxwindow:setItemSelectState(8,true)
     76    elseif P.resolution == "1280 x 720" then
     77        P.listboxwindow:setItemSelectState(9,true)
     78    elseif P.resolution == "1280 x 768" then
     79        P.listboxwindow:setItemSelectState(10,true)
     80    elseif P.resolution == "1440 x 900" then
     81        P.listboxwindow:setItemSelectState(11,true)
    8282    end
    83     scrollbar_active = false
    84     block = false
     83    P.scrollbar_active = false
     84    P.block = false
    8585end
    8686
    8787function P.GraphicsResolutionListbox_changed(e)
    88     if listboxwindow:isItemSelected(0) then
    89         resolution = "640 x 480"
    90     elseif listboxwindow:isItemSelected(1) then
    91         resolution = "720 x 480"
    92     elseif listboxwindow:isItemSelected(2) then
    93         resolution = "720 x 576"
    94     elseif listboxwindow:isItemSelected(3) then
    95         resolution = "800 x 480"
    96     elseif listboxwindow:isItemSelected(4) then
    97         resolution = "800 x 600"
    98     elseif listboxwindow:isItemSelected(5) then
    99         resolution = "1024 x 480"
    100     elseif listboxwindow:isItemSelected(6) then
    101         resolution = "1024 x 600"
    102     elseif listboxwindow:isItemSelected(7) then
    103         resolution = "1024 x 768"
    104     elseif listboxwindow:isItemSelected(8) then
    105         resolution = "1152 x 864"
    106     elseif listboxwindow:isItemSelected(9) then
    107         resolution = "1280 x 720"
    108     elseif listboxwindow:isItemSelected(10) then
    109         resolution = "1280 x 768"
    110     elseif listboxwindow:isItemSelected(11) then
    111         resolution = "1440 x 900"
     88    if P.listboxwindow:isItemSelected(0) then
     89        P.resolution = "640 x 480"
     90    elseif P.listboxwindow:isItemSelected(1) then
     91        P.resolution = "720 x 480"
     92    elseif P.listboxwindow:isItemSelected(2) then
     93        P.resolution = "720 x 576"
     94    elseif P.listboxwindow:isItemSelected(3) then
     95        P.resolution = "800 x 480"
     96    elseif P.listboxwindow:isItemSelected(4) then
     97        P.resolution = "800 x 600"
     98    elseif P.listboxwindow:isItemSelected(5) then
     99        P.resolution = "1024 x 480"
     100    elseif P.listboxwindow:isItemSelected(6) then
     101        P.resolution = "1024 x 600"
     102    elseif P.listboxwindow:isItemSelected(7) then
     103        P.resolution = "1024 x 768"
     104    elseif P.listboxwindow:isItemSelected(8) then
     105        P.resolution = "1152 x 864"
     106    elseif P.listboxwindow:isItemSelected(9) then
     107        P.resolution = "1280 x 720"
     108    elseif P.listboxwindow:isItemSelected(10) then
     109        P.resolution = "1280 x 768"
     110    elseif P.listboxwindow:isItemSelected(11) then
     111        P.resolution = "1440 x 900"
    112112    end
    113     search_mode = 0
    114     f = io.open(file, "r")
    115     firstline = f:read("*line")
    116     text = firstline .. "\n"
    117     rendersystem = string.sub(firstline, 15)
     113    P.search_mode = 0
     114    local f = io.open(P.file, "r")
     115    local firstline = f:read("*line")
     116    local text = firstline .. "\n"
     117    local rendersystem = string.sub(firstline, 15)
    118118    for line in f:lines() do
    119         if search_mode == 0 then
     119        if P.search_mode == 0 then
    120120            if string.find(line, rendersystem) ~= nil then
    121                 search_mode = 1
     121                P.search_mode = 1
    122122            end
    123123        end
    124         if search_mode == 1 then
     124        if P.search_mode == 1 then
    125125            if string.sub(line, 1, 10) == "Video Mode" then
    126126                if string.match(line, "@") == "@" then
    127                     line = "Video Mode=" .. resolution .. string.sub(line, string.find(line, "@")-1)
     127                    line = "Video Mode=" .. P.resolution .. string.sub(line, string.find(line, "@")-1)
    128128                else
    129                     line = "Video Mode=" .. resolution
     129                    line = "Video Mode=" .. P.resolution
    130130                end
    131                 search_mode = 2
     131                P.search_mode = 2
    132132            end
    133133        end
     
    135135    end
    136136    f:close()
    137     f = io.open(file, "w")
     137    f = io.open(P.file, "w")
    138138    f:write(text)
    139139    f:close()
     
    141141
    142142function P.GraphicsBrightnessScrollbar_changed(e)
    143     if scrollbar_active == false then
     143    if P.scrollbar_active == false then
    144144        -- brightness
    145145        logMessage(0, "event: brightness")
     
    148148
    149149function P.GraphicsBrightnessScrollbar_started(e)
    150     scrollbar_active = true
     150    P.scrollbar_active = true
    151151end
    152152
     
    154154    -- brightness
    155155    logMessage(0, "event: brightness")
    156     scrollbar_active = false
     156    P.scrollbar_active = false
    157157end
    158158
    159159function P.GraphicsFullscreenCheckbox_clicked(e)
    160     if block == false then
    161         search_mode = 0
    162         f = io.open(file, "r")
    163         firstline = f:read("*line")
    164         text = firstline .. "\n"
    165         rendersystem = string.sub(firstline, 15)
     160    if P.block == false then
     161        P.search_mode = 0
     162        local f = io.open(P.file, "r")
     163        local firstline = f:read("*line")
     164        local text = firstline .. "\n"
     165        local rendersystem = string.sub(firstline, 15)
    166166        for line in f:lines() do
    167             if search_mode == 0 then
     167            if P.search_mode == 0 then
    168168                if string.find(line, rendersystem) ~= nil then
    169                     search_mode = 1
     169                    P.search_mode = 1
    170170                end
    171171            end
    172             if search_mode == 1 then
     172            if P.search_mode == 1 then
    173173                if string.sub(line, 1, 11) == "Full Screen" then
    174                     if fullscreen == true then
     174                    if P.fullscreen == true then
    175175                        line = "Full Screen=No"
    176                         fullscreen = false
     176                        P.fullscreen = false
    177177                    else
    178178                        line = "Full Screen=Yes"
    179                         fullscreen = true
     179                        P.fullscreen = true
    180180                    end
    181                     search_mode = 2
     181                    P.search_mode = 2
    182182                end
    183183            end
     
    185185        end
    186186        f:close()
    187         f = io.open(file, "w")
     187        f = io.open(P.file, "w")
    188188        f:write(text)
    189189        f:close()
  • code/branches/gamestates3/data/gui/scripts/HUDSheet.lua

    • Property svn:eol-style set to native
  • code/branches/gamestates3/data/gui/scripts/InfoPopup.lua

    r6746 r6773  
    1818
    1919function P.setCloseButton(closeButton)
    20     close = winMgr:getWindow("orxonox/InfoPopup_close")
     20    local close = winMgr:getWindow("orxonox/InfoPopup_close")
    2121    close:setVisible(closeButton)
    2222    if(not closeButton) then
  • code/branches/gamestates3/data/gui/scripts/KeyBindMenu.lua

    r6748 r6773  
    66function P.onLoad()
    77
    8     commandList = {}
    9     table.insert(commandList, "fire 0")
    10     table.insert(commandList, "fire 1 | unfire")
    11     table.insert(commandList, "onpress fire 2")
    12     table.insert(commandList, "scale 1 moveFrontBack")
    13     table.insert(commandList, "scale -1 moveFrontBack")
    14     table.insert(commandList, "boost")
    15     table.insert(commandList, "scale 1 moveRightLeft")
    16     table.insert(commandList, "scale -1 moveRightLeft")
    17     table.insert(commandList, "scale 1 moveUpDown")
    18     table.insert(commandList, "scale -1 moveUpDown")
    19     table.insert(commandList, "scale -1 rotateRoll")
    20     table.insert(commandList, "scale 1 rotateRoll")
    21     table.insert(commandList, "scale 1 rotateYaw")
    22     table.insert(commandList, "scale -1 rotateYaw")
    23     table.insert(commandList, "scale 1 rotatePitch")
    24     table.insert(commandList, "scale -1 rotatePitch")
    25     table.insert(commandList, "NewHumanController changeMode")
    26     table.insert(commandList, "switchCamera")
    27     table.insert(commandList, "openConsole")
    28     table.insert(commandList, "OverlayGroup toggleVisibility Debug")
    29     table.insert(commandList, "OverlayGroup toggleVisibility Stats")
    30     table.insert(commandList, "mouseLook")
    31     table.insert(commandList, "pause")
    32 
    33     nameList = {}
    34     table.insert(nameList, "Primary Fire")
    35     table.insert(nameList, "Secondary Fire")
    36     table.insert(nameList, "Fire Rocket")
    37     table.insert(nameList, "Accelerate")
    38     table.insert(nameList, "Break")
    39     table.insert(nameList, "Boost")
    40     table.insert(nameList, "Move Right")
    41     table.insert(nameList, "Move Left")
    42     table.insert(nameList, "Move Up")
    43     table.insert(nameList, "Move Down")
    44     table.insert(nameList, "Roll Right")
    45     table.insert(nameList, "Roll Left")
    46     table.insert(nameList, "Yaw Left")
    47     table.insert(nameList, "Yaw Right")
    48     table.insert(nameList, "Pitch Up")
    49     table.insert(nameList, "Pitch Down")
    50     table.insert(nameList, "Switch Input Mode")
    51     table.insert(nameList, "Switch Camera")
    52     table.insert(nameList, "Open Console")
    53     table.insert(nameList, "Show Debug")
    54     table.insert(nameList, "Show Stats")
    55     table.insert(nameList, "Look Around")
    56     table.insert(nameList, "Pause")
    57 
    58     linesList = {}
     8    P.commandList = {}
     9    table.insert(P.commandList, "fire 0")
     10    table.insert(P.commandList, "fire 1 | unfire")
     11    table.insert(P.commandList, "onpress fire 2")
     12    table.insert(P.commandList, "scale 1 moveFrontBack")
     13    table.insert(P.commandList, "scale -1 moveFrontBack")
     14    table.insert(P.commandList, "boost")
     15    table.insert(P.commandList, "scale 1 moveRightLeft")
     16    table.insert(P.commandList, "scale -1 moveRightLeft")
     17    table.insert(P.commandList, "scale 1 moveUpDown")
     18    table.insert(P.commandList, "scale -1 moveUpDown")
     19    table.insert(P.commandList, "scale -1 rotateRoll")
     20    table.insert(P.commandList, "scale 1 rotateRoll")
     21    table.insert(P.commandList, "scale 1 rotateYaw")
     22    table.insert(P.commandList, "scale -1 rotateYaw")
     23    table.insert(P.commandList, "scale 1 rotatePitch")
     24    table.insert(P.commandList, "scale -1 rotatePitch")
     25    table.insert(P.commandList, "NewHumanController changeMode")
     26    table.insert(P.commandList, "switchCamera")
     27    table.insert(P.commandList, "openConsole")
     28    table.insert(P.commandList, "OverlayGroup toggleVisibility Debug")
     29    table.insert(P.commandList, "OverlayGroup toggleVisibility Stats")
     30    table.insert(P.commandList, "mouseLook")
     31    table.insert(P.commandList, "pause")
     32
     33    P.nameList = {}
     34    table.insert(P.nameList, "Primary Fire")
     35    table.insert(P.nameList, "Secondary Fire")
     36    table.insert(P.nameList, "Fire Rocket")
     37    table.insert(P.nameList, "Accelerate")
     38    table.insert(P.nameList, "Break")
     39    table.insert(P.nameList, "Boost")
     40    table.insert(P.nameList, "Move Right")
     41    table.insert(P.nameList, "Move Left")
     42    table.insert(P.nameList, "Move Up")
     43    table.insert(P.nameList, "Move Down")
     44    table.insert(P.nameList, "Roll Right")
     45    table.insert(P.nameList, "Roll Left")
     46    table.insert(P.nameList, "Yaw Left")
     47    table.insert(P.nameList, "Yaw Right")
     48    table.insert(P.nameList, "Pitch Up")
     49    table.insert(P.nameList, "Pitch Down")
     50    table.insert(P.nameList, "Switch Input Mode")
     51    table.insert(P.nameList, "Switch Camera")
     52    table.insert(P.nameList, "Open Console")
     53    table.insert(P.nameList, "Show Debug")
     54    table.insert(P.nameList, "Show Stats")
     55    table.insert(P.nameList, "Look Around")
     56    table.insert(P.nameList, "Pause")
     57
     58    P.linesList = {}
    5959
    6060    --Calculate design parameters:
    61     sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/KeyBindPane/SampleWindow")
    62     sampleWindow:setText("SampleText")
    63 
    64     local size = getMinTextSize(sampleWindow)
    65     lineHeight = size[1]
    66 
    67     commandWidth = 0
    68     for k,v in pairs(commandList) do
    69         sampleWindow:setText(nameList[k])
    70         size = getMinTextSize(sampleWindow)
    71         if size[2] > commandWidth then
    72             commandWidth = size[2]
     61    P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/KeyBindPane/SampleWindow")
     62    P.sampleWindow:setText("SampleText")
     63
     64    local size = getMinTextSize(P.sampleWindow)
     65    P.lineHeight = size[1]
     66
     67    P.commandWidth = 0
     68    for k,v in pairs(P.commandList) do
     69        P.sampleWindow:setText(P.nameList[k])
     70        size = getMinTextSize(P.sampleWindow)
     71        if size[2] > P.commandWidth then
     72            P.commandWidth = size[2]
    7373        end
    7474    end
    7575
    76     sampleWindow:setText("add")
    77     size = getMinTextSize(sampleWindow)
    78     addWidth = size[2]
    79 
    80     sampleWindow:setText("X")
    81     size = getMinTextSize(sampleWindow)
    82     clearWidth = size[2]
    83 
    84     spaceWidth = math.floor(1/14*commandWidth)
    85 
    86     buttonWidth = 145
     76    P.sampleWindow:setText("add")
     77    size = getMinTextSize(P.sampleWindow)
     78    P.addWidth = size[2]
     79
     80    P.sampleWindow:setText("X")
     81    size = getMinTextSize(P.sampleWindow)
     82    P.clearWidth = size[2]
     83
     84    P.spaceWidth = math.floor(1/14*P.commandWidth)
     85
     86    P.buttonWidth = 145
    8787
    8888    P.createLines()
     
    113113    local offset = 0
    114114    local line = winMgr:createWindow("DefaultWindow", "orxonox/KeyBindPane/Binding" .. k)
    115     line:setHeight(CEGUI.UDim(0, lineHeight))
    116     line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, lineHeight*(k-1))))
     115    line:setHeight(CEGUI.UDim(0, P.lineHeight))
     116    line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1))))
    117117
    118118    local command = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command")
    119     command:setText(nameList[k])
    120     command:setSize(CEGUI.UVector2(CEGUI.UDim(0, commandWidth), CEGUI.UDim(1, 0)))
     119    command:setText(P.nameList[k])
     120    command:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.commandWidth), CEGUI.UDim(1, 0)))
    121121    command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0, 0)))
    122122    line:addChildWindow(command)
    123     offset = offset + commandWidth + spaceWidth
     123    offset = offset + P.commandWidth + P.spaceWidth
    124124
    125125    local plus = winMgr:createWindow("MenuWidgets/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Plus")
    126     plus:setSize(CEGUI.UVector2(CEGUI.UDim(0, addWidth), CEGUI.UDim(0.7, 0)))
     126    plus:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.addWidth), CEGUI.UDim(0.7, 0)))
    127127    plus:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
    128128    plus:setText("add")
    129129    orxonox.GUIManager:subscribeEventHelper(plus, "Clicked", P.name .. ".KeyBindPlus_clicked")
    130130    line:addChildWindow(plus)
    131     offset = offset + addWidth + spaceWidth
    132 
    133     local numButtons = orxonox.KeyBinderManager:getInstance():getCurrent():getNumberOfBindings(commandList[k]);
     131    offset = offset + P.addWidth + P.spaceWidth
     132
     133    local numButtons = orxonox.KeyBinderManager:getInstance():getCurrent():getNumberOfBindings(P.commandList[k]);
    134134    for i=0,(numButtons-1) do
    135135        local button = winMgr:createWindow("MenuWidgets/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Button" .. i)
    136         local name = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[k],i)
     136        local name = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(P.commandList[k],i)
    137137        name = P.KeyNameNiceifier(name)
    138138        button:setText(name)
    139         sampleWindow:setText(name)
    140         local size = getMinTextSize(sampleWindow)
     139        P.sampleWindow:setText(name)
     140        local size = getMinTextSize(P.sampleWindow)
    141141        local buttonWidth = size[2]
    142142        button:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0.7, 0)))
     
    148148
    149149        local clear = winMgr:createWindow("MenuWidgets/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Clear" .. i)
    150         clear:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(0.7, 0)))
     150        clear:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.clearWidth), CEGUI.UDim(0.7, 0)))
    151151        clear:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
    152152        clear:setText("X")
    153153        orxonox.GUIManager:subscribeEventHelper(clear, "Clicked", P.name .. ".KeyBindClear_clicked")
    154154        line:addChildWindow(clear)
    155         offset = offset + clearWidth + spaceWidth
    156     end
    157 
    158     line:setWidth(CEGUI.UDim(0, offset+clearWidth))
     155        offset = offset + P.clearWidth + P.spaceWidth
     156    end
     157
     158    line:setWidth(CEGUI.UDim(0, offset+P.clearWidth))
    159159
    160160    return line
     
    164164    local window = winMgr:getWindow("orxonox/KeyBindPane")
    165165
    166     for k,v in pairs(commandList) do
     166    for k,v in pairs(P.commandList) do
    167167        local line = P.createLine(k)
    168         table.insert(linesList, line)
     168        table.insert(P.linesList, line)
    169169        window:addChildWindow(line)
    170170    end
    171171
    172     pane = tolua.cast(window, "CEGUI::ScrollablePane")
     172    local pane = tolua.cast(window, "CEGUI::ScrollablePane")
    173173    pane:setVerticalStepSize(getScrollingStepSize(window))
    174174end
     
    208208    local buttonNr = tonumber(match())
    209209
    210     local str = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[commandNr], buttonNr)
     210    local str = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(P.commandList[commandNr], buttonNr)
    211211    orxonox.KeyBinderManager:getInstance():unbind(str)
    212212
     
    218218    local buttonNr = arguments[2]
    219219    if buttonNr ~= nil then
    220         local str = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[commandNr], buttonNr)
     220        local str = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(P.commandList[commandNr], buttonNr)
    221221        orxonox.KeyBinderManager:getInstance():unbind(str)
    222222    end
    223223
    224     orxonox.KeyBinderManager:getInstance():keybind(commandList[commandNr])
     224    orxonox.KeyBinderManager:getInstance():keybind(P.commandList[commandNr])
    225225end
    226226
     
    228228    local pane = tolua.cast(winMgr:getWindow("orxonox/KeyBindPane"), "CEGUI::ScrollablePane")
    229229    local position = pane:getVerticalScrollPosition()
    230     while table.getn(linesList) ~= 0 do
    231         if linesList[1] ~= nil then
    232             winMgr:destroyWindow(linesList[1]:getName())
     230    while table.getn(P.linesList) ~= 0 do
     231        if P.linesList[1] ~= nil then
     232            winMgr:destroyWindow(P.linesList[1]:getName())
    233233        end
    234         table.remove(linesList, 1)
    235     end
    236 
    237     linesList = {}
     234        table.remove(P.linesList, 1)
     235    end
     236
     237    P.linesList = {}
    238238
    239239    P.createLines()
  • code/branches/gamestates3/data/gui/scripts/MenuSheet.lua

    • Property svn:eol-style set to native
    r6746 r6773  
    1111-- Parameters:
    1212-- Except for _name, you can provide nil. Then the default value will be used.
    13 -- For _tShowCusor and _tUseKeyboard you can specify TriBool.Dontcare if the value doesn't matter at all. Then the value of the underlaying sheet will be used.
     13-- For _tShowCursor and _tUseKeyboard you can specify TriBool.Dontcare if the value doesn't matter at all. Then the value of the underlaying sheet will be used.
    1414function P.new(_name, _bHidePrevious, _tShowCursor, _tUseKeyboard, _bBlockJoyStick)
    1515    local newSheet = GUISheet.new(_name)
    1616    newSheet.bHidePrevious  = handleDefArg(_bHidePrevious,  true)
    17     newSheet.tShowCursor    = handleDefArg(_tShowCusor,     TriBool.True)
     17    newSheet.tShowCursor    = handleDefArg(_tShowCursor,    TriBool.True)
    1818    newSheet.tUseKeyboard   = handleDefArg(_tUseKeyboard,   TriBool.Dontcare)
    1919    newSheet.bBlockJoyStick = handleDefArg(_bBlockJoyStick, false)
  • 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
  • code/branches/gamestates3/data/gui/scripts/MultiplayerMenu.lua

    r6746 r6773  
    44
    55function P.onLoad()
    6     listbox = winMgr:getWindow("orxonox/MultiplayerLevelListbox")
    7     preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
     6    local listbox = winMgr:getWindow("orxonox/MultiplayerLevelListbox")
     7    local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
    88    orxonox.LevelManager:getInstance():compileAvailableLevelList()
    99    local levelList = {}
     
    2020    table.sort(levelList)
    2121    for k,v in pairs(levelList) do
    22         item = CEGUI.createListboxTextItem(v)
     22        local item = CEGUI.createListboxTextItem(v)
    2323        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    2424        CEGUI.toListbox(listbox):addItem(item)
     
    2727        end
    2828    end
    29     local multiplayerMode = "startClient"
    30     if multiplayerMode == "startClient" then
    31         window = winMgr:getWindow("orxonox/MultiplayerJoinButton")
    32         button = tolua.cast(window,"CEGUI::RadioButton")
     29    P.multiplayerMode = "startClient"
     30    if P.multiplayerMode == "startClient" then
     31        local window = winMgr:getWindow("orxonox/MultiplayerJoinButton")
     32        local button = tolua.cast(window,"CEGUI::RadioButton")
    3333        button:setSelected(true)
    3434    end
    35     if multiplayerMode == "startServer" then
    36         window = winMgr:getWindow("orxonox/MultiplayerHostButton")
    37         button = tolua.cast(window,"CEGUI::RadioButton")
     35    if P.multiplayerMode == "startServer" then
     36        local window = winMgr:getWindow("orxonox/MultiplayerHostButton")
     37        local button = tolua.cast(window,"CEGUI::RadioButton")
    3838        button:setSelected(true)
    3939    end
    40     if multiplayerMode == "startDedicated" then
    41         window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton")
    42         button = tolua.cast(window,"CEGUI::RadioButton")
     40    if P.multiplayerMode == "startDedicated" then
     41        local window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton")
     42        local button = tolua.cast(window,"CEGUI::RadioButton")
    4343        button:setSelected(true)
    4444    end
     
    4646
    4747function P.MultiplayerJoinButton_clicked(e)
    48     multiplayerMode = "startClient"
     48    P.multiplayerMode = "startClient"
    4949end
    5050
    5151function P.MultiplayerHostButton_clicked(e)
    52     multiplayerMode = "startServer"
     52    P.multiplayerMode = "startServer"
    5353end
    5454
    5555function P.MultiplayerDedicatedButton_clicked(e)
    56     multiplayerMode = "startDedicated"
     56    P.multiplayerMode = "startDedicated"
    5757end
    5858
     
    6161    if choice then
    6262        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
    63         orxonox.execute(multiplayerMode)
     63        orxonox.execute(P.multiplayerMode)
    6464        hideAllMenuSheets()
    6565    end
  • code/branches/gamestates3/data/gui/scripts/PickupInventory.lua

    r6750 r6773  
    88
    99function P.onLoad()
    10     carrierList = {}
    1110end
    1211
  • code/branches/gamestates3/data/gui/scripts/SingleplayerMenu.lua

    r6754 r6773  
    44
    55function P.onLoad()
    6     listbox = winMgr:getWindow("orxonox/SingleplayerLevelListbox")
    7     preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
     6    local listbox = winMgr:getWindow("orxonox/SingleplayerLevelListbox")
     7    local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
    88    orxonox.LevelManager:getInstance():compileAvailableLevelList()
    99    local levelList = {}
     
    2020    table.sort(levelList)
    2121    for k,v in pairs(levelList) do
    22         item = CEGUI.createListboxTextItem(v)
     22        local item = CEGUI.createListboxTextItem(v)
    2323        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    2424        CEGUI.toListbox(listbox):addItem(item)
  • code/branches/gamestates3/data/lua/LuaStateInit.lua

    r6746 r6773  
    1 -- Note: luaState is a pointer to the LuaState instance that created this lua state
     1-- LuaStateInit.lua
     2
     3-- Note: 'luaState' is a pointer to the LuaState instance that created this lua state
    24
    35-- Redirect print to the C++ print function
    46original_print = print
    5 print = function(s)
     7function print(s)
    68  luaState:luaPrint(s)
    79end
    810
    911-- Create function to log text like COUT, but always prints a line!
    10 logMessage = function(level, message)
     12function logMessage(level, message)
    1113  luaState:luaLog(level, message)
    1214end
     
    1517-- Redirect dofile in order to load with the resource manager
    1618original_dofile = dofile
    17 dofile = function(filename)
     19function dofile(filename)
    1820  if not luaState:doFile(filename) then
    1921    error("Error propagation. Do not display")
     
    2628-- Create includeFile function that preparses the file according
    2729-- to a function provided to the LuaState constructor (in C++)
    28 include = function(filename)
     30function include(filename)
    2931  if not luaState:includeFile(filename) then
    3032    error("Error propagation. Do not display")
     
    3739-- The loaded modules are then stored with their names (where name has no .lua extension)
    3840-- Furthermore the ".lua" extension is appended to the moduleName parameter when looking for the file
     41_LOADED = {}
     42_LOADED_RETURN_VALUES = {}
     43_REQUIREDNAME = nil
    3944original_require = require
    40 _REQUIREDNAME = ""
    41 LuaStateReturnValue = true
    42 require = function(moduleName)
     45function require(moduleName)
    4346  if not luaState:fileExists(moduleName .. ".lua") then
    4447    logMessage(2, "Warning: Lua function require() could not find file '" .. moduleName .. ".lua' ")
    4548    return nil
    46   end
    47 
    48   if not _LOADED then
    49     _LOADED = {}
    50   end
    51   if not _LOADED_RETURN_VALUES then
    52       _LOADED_RETURN_VALUES = {}
    5349  end
    5450
     
    6965    _REQUIREDNAME = _REQUIREDNAME_OLD
    7066  end
    71   local asdf = _LOADED_RETURN_VALUES[moduleName]
    72   return asdf
     67  return _LOADED_RETURN_VALUES[moduleName]
    7368end
    74 
    7569
    7670-- Load useful tool functions (like handleDefaultArgument)
    7771require("Tools")
    78 
    7972
    8073-- Include command line debugger for lua 5.1
     
    8477else
    8578  -- Fallback pause function
    86   pause = function()
     79  function pause()
    8780    logMessage(2, [["Warning: debug() called in Lua, but Debugger is not active.
    8881Do you have the IOConsole disabled and are you using Lua version 5.1?"]])
     
    9184
    9285-- General error handler that gets called whenever an error happens at runtime
    93 errorHandler = function(err)
     86function errorHandler(err)
    9487  if type(err) == "string" then
    9588    -- Simply return if the error has already been handled
     
    112105end
    113106
    114 
    115107-- Convenience function for console commands
    116108orxonox.execute = function(command)
Note: See TracChangeset for help on using the changeset viewer.