Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 9, 2011, 11:27:05 AM (14 years ago)
Author:
dafrick
Message:

Merging latest changes in usability branch into tutorial branch.

Location:
code/branches/tutorial
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutorial

  • code/branches/tutorial/data/gui/scripts/GUISheet.lua

    r7928 r8051  
    2828end
    2929
     30-- Override this function if you want to react on keystrokes
     31function P:onKeyPressed(mode)
     32end
     33
     34-- Override this function if you want to update the gui after the window was resized
     35function P:onWindowResized()
     36end
     37
    3038-- show function for the GUI
    3139function P:show()
     
    7785
    7886-- Handles key pressed while the gui sheed is displayed
    79 function P:keyPressed()
     87function P:keyPressed(mode)
    8088    if self.buttons then
    81         if code == "208" then     -- key down
     89        if mode == "down" then     -- key down
    8290            self:moveSelectionRow(1)
    83         elseif code == "200" then -- key up
     91        elseif mode == "up" then -- key up
    8492            self:moveSelectionRow(-1)
    85         elseif code == "205" then -- key right
     93        elseif mode == "right" then -- key right
    8694            self:moveSelectionColumn(1)
    87         elseif code == "203" then -- key left
     95        elseif mode == "left" then -- key left
    8896            self:moveSelectionColumn(-1)
    89         elseif code == "28"  then -- key enter
     97        elseif mode == "enter" then -- key enter or key numpad enter
    9098            self:pressSelectedButton()
    9199        end
    92100    end
    93101
    94     self.onKeyPressed()
    95 end
    96 
    97 -- Override this function if you want to ract on keystrokes
    98 function P:onKeyPressed()
     102    self:onKeyPressed(mode)
     103end
     104
     105function P:windowResized()
     106    self:onWindowResized()
    99107end
    100108
  • code/branches/tutorial/data/gui/scripts/GraphicsMenu.lua

    r7928 r8051  
    11-- GraphicsMenu.lua
    22
    3 local P = createMenuSheet("GraphicsMenu")
    4 
     3local P = createMenuSheet("GraphicsMenu", true, TriBool.True, TriBool.True)
     4
     5P.resolutionList = {"custom", "640 x 480", "720 x 480", "720 x 576", "800 x 600", "1024 x 600", "1024 x 768", "1152 x 864", "1280 x 720", "1280 x 800", "1280 x 960", "1280 x 1024", "1360 x 768", "1440 x 900", "1600 x 900", "1600 x 1200", "1680 x 1050"}
    56P.schemeList = {"TaharezGreen", "Orxonox"}
    6 
    7 function P.onLoad()
    8     block = true
    9     file = orxonox.PathConfig:getConfigPathString() .. orxonox.getConfig("GraphicsManager", "ogreConfigFile_")
    10     search_mode = 0
    11     f = io.open(file, "r")
    12     firstline = f:read("*line")
    13     rendersystem = string.sub(firstline, 15)
    14     for line in f:lines() do
    15         if search_mode == 0 then
    16             if string.find(line, rendersystem) ~= nil then
    17                 search_mode = 1
    18             end
     7P.fsaaList = {"0", "2", "4", "8", "8 [Quality]"}
     8P.particleLodList = {"None", "Low", "Normal", "High"}
     9
     10function P:onLoad()
     11    -------------------
     12    -- Button matrix --
     13    -------------------
     14
     15    P:setButton(1, 1, {
     16            ["button"] = winMgr:getWindow("orxonox/GraphicsOkButton"),
     17            ["callback"]  = P.callback_Ok_Clicked
     18    })
     19
     20    P:setButton(1, 2, {
     21            ["button"] = winMgr:getWindow("orxonox/GraphicsCancelButton"),
     22            ["callback"]  = P.callback_Cancel_Clicked
     23    })
     24
     25    -- place apply button at the bottom in the matrix, even though it's in fact at the top, to make the OK button highlighted by default
     26    P:setButton(2, 1, {
     27            ["button"] = winMgr:getWindow("orxonox/Display/Resolution/Apply"),
     28            ["callback"]  = P.callback_Apply_Clicked
     29    })
     30
     31    -----------------
     32    -- Combo boxes --
     33    -----------------
     34
     35    -- resolution combobox
     36    local resolutionCombobox = winMgr:getWindow("orxonox/Display/Resolution/Combobox")
     37    CEGUI.toCombobox(resolutionCombobox):setReadOnly(true)
     38
     39    for k,v in pairs(P.resolutionList) do
     40        local item = CEGUI.createListboxTextItem(v)
     41        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     42        resolutionCombobox:addItem(item)
     43    end
     44
     45    -- themes combobox
     46    local themeCombobox = winMgr:getWindow("orxonox/Display/Theme/Combobox")
     47    CEGUI.toCombobox(themeCombobox):setReadOnly(true)
     48
     49    for k,v in pairs(P.schemeList) do
     50        local item = CEGUI.createListboxTextItem(v)
     51        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     52        themeCombobox:addItem(item)
     53    end
     54
     55    -- fsaa combobox
     56    local fsaaCombobox = winMgr:getWindow("orxonox/Display/More/FSAA")
     57    CEGUI.toCombobox(fsaaCombobox):setReadOnly(true)
     58
     59    for k,v in pairs(P.fsaaList) do
     60        local item = CEGUI.createListboxTextItem(v)
     61        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     62        fsaaCombobox:addItem(item)
     63    end
     64
     65    -- particle lod combobox
     66    local particleLodCombobox = winMgr:getWindow("orxonox/Settings/ParticleLodCombobox")
     67    CEGUI.toCombobox(particleLodCombobox):setReadOnly(true)
     68
     69    for k,v in pairs(P.particleLodList) do
     70        local item = CEGUI.createListboxTextItem(v)
     71        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     72        particleLodCombobox:addItem(item)
     73    end
     74end
     75
     76function P:onShow()
     77    -----------------
     78    -- Display tab --
     79    -----------------
     80
     81    -- fullscreen checkbox / resolution combobox / resolution editboxes
     82    self:onWindowResized()
     83
     84    -- apply button
     85    self.updateApplyButton()
     86
     87    -- aspect ratio editbox
     88    local aspectRatioEditbox = winMgr:getWindow("orxonox/Display/Resolution/AspectRatio")
     89    local currentAspectRatio = orxonox.CommandExecutor:query("getConfig Camera aspectRatio_")
     90    aspectRatioEditbox:setText(currentAspectRatio)
     91
     92    -- themes combobox
     93    local themeCombobox = winMgr:getWindow("orxonox/Display/Theme/Combobox")
     94    local currentTheme = orxonox.CommandExecutor:query("getConfig GUIManager guiScheme_")
     95
     96    for i = 0, themeCombobox:getDropList():getItemCount() - 1 do
     97        local item = themeCombobox:getListboxItemFromIndex(i)
     98        themeCombobox:setItemSelectState(item, (item:getText() == currentTheme))
     99    end
     100
     101    -- vsync checkbox
     102    local vsyncCheckbox = winMgr:getWindow("orxonox/Display/More/VSync")
     103    local hasVSync = orxonox.GraphicsManager:getInstance():hasVSyncEnabled()
     104    CEGUI.toCheckbox(vsyncCheckbox):setSelected(hasVSync)
     105
     106    -- fsaa combobox
     107    local fsaaCombobox = winMgr:getWindow("orxonox/Display/More/FSAA")
     108    local currentFSAAMode = orxonox.GraphicsManager:getInstance():getFSAAMode()
     109
     110    for i = 0, fsaaCombobox:getDropList():getItemCount() - 1 do
     111        local item = fsaaCombobox:getListboxItemFromIndex(i)
     112        fsaaCombobox:setItemSelectState(item, (item:getText() == currentFSAAMode))
     113    end
     114
     115    -- notice
     116    self:updateRedLabel()
     117
     118    ------------------
     119    -- Settings tab --
     120    ------------------
     121
     122    -- fov editbox
     123    local fovEditbox = winMgr:getWindow("orxonox/Settings/Fov")
     124    local currentFov = orxonox.CommandExecutor:query("getConfig Camera fov_")
     125    fovEditbox:setText(currentFov)
     126
     127    -- fps limit editbox
     128    local fpsEditbox = winMgr:getWindow("orxonox/Settings/FpsLimit")
     129    local currentFpsLimit = orxonox.CommandExecutor:query("getConfig GraphicsSettings fpsLimit")
     130    fpsEditbox:setText(currentFpsLimit)
     131
     132    -- particle lod combobox
     133    local particleLodCombobox = winMgr:getWindow("orxonox/Settings/ParticleLodCombobox")
     134    local currentParticleLod = orxonox.CommandExecutor:query("getConfig GraphicsSettings particlesDetailLevel")
     135
     136    if currentParticleLod == "" then
     137        particleLodCombobox:disable()
     138    else
     139        particleLodCombobox:enable()
     140
     141        for i = 0, particleLodCombobox:getDropList():getItemCount() - 1 do
     142            local item = particleLodCombobox:getListboxItemFromIndex(i)
     143            particleLodCombobox:setItemSelectState(item, (tostring(i) == currentParticleLod))
    19144        end
    20         if search_mode == 1 then
    21             if string.sub(line, 1, 11) == "Full Screen" then
    22                 if string.sub(line, 13) == "Yes" then
    23                     fullscreen = true
    24                 else
    25                     fullscreen = false
    26                 end
    27             end
    28             if string.sub(line, 1, 10) == "Video Mode" then
    29                 if string.match(line, "@") == "@" then
    30                     resolution = string.sub(line, 12, string.find(line, "@")-2)
    31                 else
    32                     resolution = string.sub(line, 12)
    33                 end
    34                 break
    35             end
     145    end
     146
     147    -- mesh lod checkbox
     148    local meshLodCheckbox = winMgr:getWindow("orxonox/Settings/MeshLodCheckbox")
     149    local hasMeshLod = orxonox.CommandExecutor:query("getConfig GraphicsSettings enableMeshLoD")
     150    if hasMeshLod == "true" then
     151        hasMeshLod = true
     152    elseif hasMeshLod == "false" then
     153        hasMeshLod = false
     154    end
     155    CEGUI.toCheckbox(meshLodCheckbox):setSelected(hasMeshLod)
     156
     157    -- motion blur checkbox
     158    local motionBlurCheckbox = winMgr:getWindow("orxonox/Settings/MotionBlurCheckbox")
     159    local hasMotionBlur = orxonox.CommandExecutor:query("getConfig GraphicsSettings enableMotionBlur")
     160    if hasMotionBlur == "true" then
     161        hasMotionBlur = true
     162    elseif hasMotionBlur == "false" then
     163        hasMotionBlur = false
     164    end
     165    CEGUI.toCheckbox(motionBlurCheckbox):setSelected(hasMotionBlur)
     166end
     167
     168function P:onWindowResized()
     169    -- fullscreen checkbox
     170    local fullscreenCheckbox = winMgr:getWindow("orxonox/Display/Resolution/Fullscreen")
     171    local isFullscreen = orxonox.GraphicsManager:getInstance():isFullScreen()
     172    CEGUI.toCheckbox(fullscreenCheckbox):setSelected(isFullscreen)
     173
     174    -- resolution combobox
     175    local resolutionCombobox = winMgr:getWindow("orxonox/Display/Resolution/Combobox")
     176
     177    local currentWidth = orxonox.GraphicsManager:getInstance():getWindowWidth()
     178    local currentHeight = orxonox.GraphicsManager:getInstance():getWindowHeight()
     179
     180    if P.forceResolutionEditboxes then
     181        currentWidth = P.newWidth
     182        currentHeight = P.newHeight
     183        P.forceResolutionEditboxes = false
     184    end
     185
     186    local currentResolution = currentWidth .. " x " .. currentHeight
     187
     188    for i = 0, resolutionCombobox:getDropList():getItemCount() - 1 do
     189        local item = resolutionCombobox:getListboxItemFromIndex(i)
     190        resolutionCombobox:setItemSelectState(item, item:getText() == currentResolution)
     191    end
     192
     193    -- resolution editboxes
     194    self.updateResolutionEditboxes()
     195end
     196
     197----------------------
     198-- Helper functions --
     199----------------------
     200
     201-- updates the text of the resolution checkboxes and checks if they should be enabled (only if the "custom" resolution was selected)
     202function P.updateResolutionEditboxes()
     203    -- resolution combobox
     204    local resolutionCombobox = winMgr:getWindow("orxonox/Display/Resolution/Combobox")
     205
     206    local currentWidth = orxonox.GraphicsManager:getInstance():getWindowWidth()
     207    local currentHeight = orxonox.GraphicsManager:getInstance():getWindowHeight()
     208
     209    -- resolution editboxes
     210    local widthEditbox = winMgr:getWindow("orxonox/Display/Resolution/EditboxWidth")
     211    local heightEditbox = winMgr:getWindow("orxonox/Display/Resolution/EditboxHeight")
     212    widthEditbox:disable()
     213    heightEditbox:disable()
     214
     215    -- selected combobox item
     216    local item = resolutionCombobox:getSelectedItem()
     217    if item then
     218        local itemText = item:getText()
     219        if itemText ~= "custom" then
     220            currentWidth = string.sub(itemText, 1, string.find(itemText, "x") - 2)
     221            currentHeight = string.sub(itemText, string.find(itemText, "x") + 2)
     222        else
     223            widthEditbox:enable()
     224            heightEditbox:enable()
    36225        end
    37226    end
    38     f:close()
    39     local fullscreenwindow = tolua.cast(winMgr:getWindow("orxonox/FullscreenCheckbox"),"CEGUI::Checkbox")
    40     fullscreenwindow:setSelected(fullscreen)
    41     listboxwindow = winMgr:getWindow("orxonox/ResolutionListbox")
    42     local resolutionList = {}
    43     table.insert(resolutionList, "640 x 480")
    44     table.insert(resolutionList, "720 x 480")
    45     table.insert(resolutionList, "720 x 576")
    46     table.insert(resolutionList, "800 x 480")
    47     table.insert(resolutionList, "800 x 600")
    48     table.insert(resolutionList, "1024 x 480")
    49     table.insert(resolutionList, "1024 x 600")
    50     table.insert(resolutionList, "1024 x 768")
    51     table.insert(resolutionList, "1152 x 864")
    52     table.insert(resolutionList, "1280 x 720")
    53     table.insert(resolutionList, "1280 x 768")
    54     table.insert(resolutionList, "1440 x 900")
    55     for k,v in pairs(resolutionList) do
    56         item = CEGUI.createListboxTextItem(v)
    57         item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    58         CEGUI.toListbox(listboxwindow):addItem(item)
    59     end
    60     if resolution == "640 x 480" then
    61         listboxwindow:setItemSelectState(0,true)
    62     elseif resolution == "720 x 480" then
    63         listboxwindow:setItemSelectState(1,true)
    64     elseif resolution == "720 x 576" then
    65         listboxwindow:setItemSelectState(2,true)
    66     elseif resolution == "800 x 480" then
    67         listboxwindow:setItemSelectState(3,true)
    68     elseif resolution == "800 x 600" then
    69         listboxwindow:setItemSelectState(4,true)
    70     elseif resolution == "1024 x 480" then
    71         listboxwindow:setItemSelectState(5,true)
    72     elseif resolution == "1024 x 600" then
    73         listboxwindow:setItemSelectState(6,true)
    74     elseif resolution == "1024 x 768" then
    75         listboxwindow:setItemSelectState(7,true)
    76     elseif resolution == "1152 x 864" then
    77         listboxwindow:setItemSelectState(8,true)
    78     elseif resolution == "1280 x 720" then
    79         listboxwindow:setItemSelectState(9,true)
    80     elseif resolution == "1280 x 768" then
    81         listboxwindow:setItemSelectState(10,true)
    82     elseif resolution == "1440 x 900" then
    83         listboxwindow:setItemSelectState(11,true)
    84     end
    85     scrollbar_active = false
    86     block = false
    87 
    88     P:setButton(1, 1, {
    89             ["button"] = winMgr:getWindow("orxonox/GraphicsBackButton"),
    90             ["callback"]  = P.GraphicsBackButton_clicked
    91     })
    92 
    93     local dropbox = winMgr:getWindow("orxonox/ThemeDropBox")
    94     local scheme = orxonox.CommandExecutor:query("getConfig GUIManager guiScheme_")
    95     for k,v in pairs(P.schemeList) do
    96         local item = CEGUI.createListboxTextItem(P.schemeList[k])
    97         item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    98         CEGUI.toListbox(dropbox):addItem(item)
    99         if v == scheme then
    100             dropbox:setItemSelectState(item, true)
    101         end
    102     end
    103 
    104 end
    105 
    106 function P.ThemeDropBox_changed(e)
    107     local dropbox = winMgr:getWindow("orxonox/ThemeDropBox")
    108     local listbox = CEGUI.toListbox(dropbox)
    109     local choice = listbox:getFirstSelectedItem()
    110     local index = 0
    111     if choice ~= nil then
    112         index = listbox:getItemIndex(choice)
    113     end
    114     orxonox.CommandExecutor:execute("config GUIManager guiScheme_ " .. P.schemeList[index+1])
    115 end
    116 
    117 function P.GraphicsResolutionListbox_changed(e)
    118     if listboxwindow:isItemSelected(0) then
    119         resolution = "640 x 480"
    120     elseif listboxwindow:isItemSelected(1) then
    121         resolution = "720 x 480"
    122     elseif listboxwindow:isItemSelected(2) then
    123         resolution = "720 x 576"
    124     elseif listboxwindow:isItemSelected(3) then
    125         resolution = "800 x 480"
    126     elseif listboxwindow:isItemSelected(4) then
    127         resolution = "800 x 600"
    128     elseif listboxwindow:isItemSelected(5) then
    129         resolution = "1024 x 480"
    130     elseif listboxwindow:isItemSelected(6) then
    131         resolution = "1024 x 600"
    132     elseif listboxwindow:isItemSelected(7) then
    133         resolution = "1024 x 768"
    134     elseif listboxwindow:isItemSelected(8) then
    135         resolution = "1152 x 864"
    136     elseif listboxwindow:isItemSelected(9) then
    137         resolution = "1280 x 720"
    138     elseif listboxwindow:isItemSelected(10) then
    139         resolution = "1280 x 768"
    140     elseif listboxwindow:isItemSelected(11) then
    141         resolution = "1440 x 900"
    142     end
    143     search_mode = 0
    144     f = io.open(file, "r")
    145     firstline = f:read("*line")
    146     text = firstline .. "\n"
    147     rendersystem = string.sub(firstline, 15)
    148     for line in f:lines() do
    149         if search_mode == 0 then
    150             if string.find(line, rendersystem) ~= nil then
    151                 search_mode = 1
    152             end
    153         end
    154         if search_mode == 1 then
    155             if string.sub(line, 1, 10) == "Video Mode" then
    156                 if string.match(line, "@") == "@" then
    157                     line = "Video Mode=" .. resolution .. string.sub(line, string.find(line, "@")-1)
    158                 else
    159                     line = "Video Mode=" .. resolution
    160                 end
    161                 search_mode = 2
    162             end
    163         end
    164         text = text .. line .. "\n"
    165     end
    166     f:close()
    167     f = io.open(file, "w")
    168     f:write(text)
    169     f:close()
    170 end
    171 
    172 function P.GraphicsBrightnessScrollbar_changed(e)
    173     if scrollbar_active == false then
    174         -- brightness
    175         logMessage(0, "event: brightness")
    176     end
    177 end
    178 
    179 function P.GraphicsBrightnessScrollbar_started(e)
    180     scrollbar_active = true
    181 end
    182 
    183 function P.GraphicsBrightnessScrollbar_ended(e)
    184     -- brightness
    185     logMessage(0, "event: brightness")
    186     scrollbar_active = false
    187 end
    188 
    189 function P.GraphicsFullscreenCheckbox_clicked(e)
    190     if block == false then
    191         search_mode = 0
    192         f = io.open(file, "r")
    193         firstline = f:read("*line")
    194         text = firstline .. "\n"
    195         rendersystem = string.sub(firstline, 15)
    196         for line in f:lines() do
    197             if search_mode == 0 then
    198                 if string.find(line, rendersystem) ~= nil then
    199                     search_mode = 1
    200                 end
    201             end
    202             if search_mode == 1 then
    203                 if string.sub(line, 1, 11) == "Full Screen" then
    204                     if fullscreen == true then
    205                         line = "Full Screen=No"
    206                         fullscreen = false
    207                     else
    208                         line = "Full Screen=Yes"
    209                         fullscreen = true
    210                     end
    211                     search_mode = 2
    212                 end
    213             end
    214             text = text .. line .. "\n"
    215         end
    216         f:close()
    217         f = io.open(file, "w")
    218         f:write(text)
    219         f:close()
    220     end
    221 end
    222 
    223 function P.GraphicsBackButton_clicked(e)
     227
     228    widthEditbox:setText(currentWidth)
     229    heightEditbox:setText(currentHeight)
     230end
     231
     232-- checks if the apply button should be enabled or disabled (only enabled if the current settings are different from the selected values)
     233function P.updateApplyButton()
     234    -- fullscreen checkbox
     235    local fullscreenCheckbox = winMgr:getWindow("orxonox/Display/Resolution/Fullscreen")
     236    local isFullscreen = orxonox.GraphicsManager:getInstance():isFullScreen()
     237    local fullscreenChanged = (isFullscreen ~= CEGUI.toCheckbox(fullscreenCheckbox):isSelected())
     238
     239    -- resolution editboxes
     240    local widthEditbox = winMgr:getWindow("orxonox/Display/Resolution/EditboxWidth")
     241    local heightEditbox = winMgr:getWindow("orxonox/Display/Resolution/EditboxHeight")
     242    local currentWidth = tostring(orxonox.GraphicsManager:getInstance():getWindowWidth())
     243    local currentHeight = tostring(orxonox.GraphicsManager:getInstance():getWindowHeight())
     244    local widthChanged = (currentWidth ~= widthEditbox:getText())
     245    local heightChanged = (currentHeight ~= heightEditbox:getText())
     246    local resolutionEditboxesEnabled = not widthEditbox:isDisabled()
     247
     248    -- apply button
     249    local applyButton = winMgr:getWindow("orxonox/Display/Resolution/Apply")
     250
     251    if fullscreenChanged or widthChanged or heightChanged or resolutionEditboxesEnabled then
     252        applyButton:enable()
     253    else
     254        applyButton:disable()
     255    end
     256end
     257
     258function P.updateRedLabel()
     259    -- theme
     260    local themeCombobox = winMgr:getWindow("orxonox/Display/Theme/Combobox")
     261    local currentTheme = orxonox.CommandExecutor:query("getConfig GUIManager guiScheme_")
     262    local themeChanged = (currentTheme ~= themeCombobox:getText())
     263
     264    -- vsync
     265    local vsyncCheckbox = winMgr:getWindow("orxonox/Display/More/VSync")
     266    local hasVSync = orxonox.GraphicsManager:getInstance():hasVSyncEnabled()
     267    local vsyncChanged = (hasVSync ~= CEGUI.toCheckbox(vsyncCheckbox):isSelected())
     268
     269    -- fsaa
     270    local fsaaCombobox = winMgr:getWindow("orxonox/Display/More/FSAA")
     271    local currentFSAAMode = orxonox.GraphicsManager:getInstance():getFSAAMode()
     272    local fsaaChanged = (currentFSAAMode ~= fsaaCombobox:getText())
     273
     274    local needRestart = themeChanged or vsyncChanged or fsaaChanged
     275
     276    local notice = winMgr:getWindow("orxonox/Display/Notice")
     277    notice:setVisible(not needRestart)
     278    local noticeRed = winMgr:getWindow("orxonox/Display/NoticeRed")
     279    noticeRed:setVisible(needRestart)
     280end
     281
     282---------------------
     283-- Event callbacks --
     284---------------------
     285
     286-- resolution
     287
     288function P.callback_FullscreenCheckbox_CheckStateChanged(e)
     289    P.updateApplyButton()
     290end
     291
     292function P.callback_ResolutionCombobox_ListSelectionAccepted(e)
     293    P.updateResolutionEditboxes()
     294end
     295
     296function P.callback_ResolutionEditboxWidth_TextChanged(e)
     297    P.updateApplyButton()
     298end
     299
     300function P.callback_ResolutionEditboxHeight_TextChanged(e)
     301    P.updateApplyButton()
     302end
     303
     304-- theme
     305
     306function P.callback_ThemeCombobox_ListSelectionAccepted(e)
     307    P.updateRedLabel()
     308end
     309
     310-- vsync
     311
     312function P.callback_VSyncCheckbox_CheckStateChanged(e)
     313    P.updateRedLabel()
     314end
     315
     316-- fsaa
     317
     318function P.callback_FSAACombobox_ListSelectionAccepted(e)
     319    P.updateRedLabel()
     320end
     321
     322-- buttons
     323
     324function P.callback_Apply_Clicked(e)
     325    -- resolution
     326    local fullscreenCheckbox = winMgr:getWindow("orxonox/Display/Resolution/Fullscreen")
     327    local checkedFullscreen = tostring(CEGUI.toCheckbox(fullscreenCheckbox):isSelected())
     328
     329    local widthEditbox = winMgr:getWindow("orxonox/Display/Resolution/EditboxWidth")
     330    local heightEditbox = winMgr:getWindow("orxonox/Display/Resolution/EditboxHeight")
     331
     332    P.newWidth = widthEditbox:getText()
     333    P.newHeight = heightEditbox:getText()
     334    P.forceResolutionEditboxes = true
     335
     336    -- start revert timer
     337    P.oldWidth = orxonox.GraphicsManager:getInstance():getWindowWidth()
     338    P.oldHeight = orxonox.GraphicsManager:getInstance():getWindowHeight()
     339    P.oldFullscreen = orxonox.GraphicsManager:getInstance():isFullScreen()
     340
     341    P.revertTimerHandle = orxonox.CommandExecutor:query("delayreal 10 {hideGUI DecisionPopup; GraphicsManager setScreenResolution " .. P.oldWidth .. " " .. P.oldHeight .. " " .. tostring(P.oldFullscreen) .. "; config Core lastLevelTimestamp_ [expr [getConfig Core ogreConfigTimestamp_] + 1]}")
     342
     343    -- change settings
     344    orxonox.CommandExecutor:execute("GraphicsManager setScreenResolution " .. P.newWidth .. " " .. P.newHeight .. " " .. checkedFullscreen)
     345
     346    P.updateApplyButton()
     347
     348    -- prompt for confirmation
     349    openDecisionPopup("Do you want to keep these settings? (Settings will be reverted in 10 seconds if not accepted)", GraphicsMenu.callback_ApplyDecisionPopup)
     350    if checkedFullscreen then
     351        showCursor()
     352    end
     353end
     354
     355function P.callback_ApplyDecisionPopup(pressedOK)
     356    orxonox.CommandExecutor:execute("killdelay " .. P.revertTimerHandle)
     357
     358    if not pressedOK then
     359        orxonox.CommandExecutor:execute("GraphicsManager setScreenResolution " .. P.oldWidth .. " " .. P.oldHeight .. " " .. tostring(P.oldFullscreen))
     360        P:onShow()
     361    end
     362
     363    -- update timestamp to avoid showing the ogre config dialog again after the user accepted or reverted the resolution
     364    orxonox.CommandExecutor:execute("config Core lastLevelTimestamp_ [expr [getConfig Core ogreConfigTimestamp_] + 1]")
     365end
     366
     367function P.callback_Ok_Clicked(e)
     368    -- aspect ratio
     369    local aspectRatioEditbox = winMgr:getWindow("orxonox/Display/Resolution/AspectRatio")
     370    orxonox.CommandExecutor:execute("config Camera aspectRatio_ " .. aspectRatioEditbox:getText())
     371
     372    -- theme
     373    local themeCombobox = winMgr:getWindow("orxonox/Display/Theme/Combobox")
     374    orxonox.CommandExecutor:execute("config GUIManager guiScheme_ " .. themeCombobox:getText())
     375
     376    -- vsync
     377    local vsyncCheckbox = winMgr:getWindow("orxonox/Display/More/VSync")
     378    local hasVSync = orxonox.GraphicsManager:getInstance():hasVSyncEnabled()
     379    if hasVSync ~= CEGUI.toCheckbox(vsyncCheckbox):isSelected() then
     380        orxonox.CommandExecutor:execute("GraphicsManager setVSync " .. tostring(CEGUI.toCheckbox(vsyncCheckbox):isSelected()))
     381    end
     382
     383    -- fsaa
     384    local fsaaCombobox = winMgr:getWindow("orxonox/Display/More/FSAA")
     385    local currentFSAAMode = orxonox.GraphicsManager:getInstance():getFSAAMode()
     386    if currentFSAAMode ~= fsaaCombobox:getText() then
     387        orxonox.CommandExecutor:execute("GraphicsManager setFSAA {" .. fsaaCombobox:getText() .. "}") -- enclose argument in { ... } because it can contain [brackets] (conflicts with tcl)
     388    end
     389
     390    -- fov
     391    local fovEditbox = winMgr:getWindow("orxonox/Settings/Fov")
     392    orxonox.CommandExecutor:execute("config Camera fov_ " .. fovEditbox:getText())
     393
     394    -- fps limit
     395    local fpsEditbox = winMgr:getWindow("orxonox/Settings/FpsLimit")
     396    orxonox.CommandExecutor:execute("config GraphicsSettings fpsLimit " .. fpsEditbox:getText())
     397
     398    -- particle lod
     399    local particleLodCombobox = winMgr:getWindow("orxonox/Settings/ParticleLodCombobox")
     400    local item = particleLodCombobox:getSelectedItem()
     401    if item then
     402        orxonox.CommandExecutor:execute("config GraphicsSettings particlesDetailLevel " .. particleLodCombobox:getItemIndex(item))
     403    end
     404
     405    -- mesh lod
     406    local meshLodCheckbox = winMgr:getWindow("orxonox/Settings/MeshLodCheckbox")
     407    orxonox.CommandExecutor:execute("config GraphicsSettings enableMeshLoD " .. tostring(CEGUI.toCheckbox(meshLodCheckbox):isSelected()))
     408
     409    -- motion blur
     410    local motionBlurCheckbox = winMgr:getWindow("orxonox/Settings/MotionBlurCheckbox")
     411    orxonox.CommandExecutor:execute("config GraphicsSettings enableMotionBlur " .. tostring(CEGUI.toCheckbox(motionBlurCheckbox):isSelected()))
     412
    224413    hideMenuSheet(P.name)
    225414end
    226415
     416function P.callback_Cancel_Clicked(e)
     417    hideMenuSheet(P.name)
     418end
     419
    227420return P
    228421
  • code/branches/tutorial/data/gui/scripts/HostMenu.lua

    r7928 r8051  
    2828
    2929function P.onShow()
     30    if P.showAll ~= orxonox.GUIManager:inDevMode() then
     31        local window = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
     32        local button = tolua.cast(window,"CEGUI::Checkbox")
     33        P.showAll = not P.showAll
     34        button:setSelected(P.showAll)
     35    end
     36
    3037    if P.multiplayerMode == "startServer" then
    3138        local window = winMgr:getWindow("orxonox/HostMenuHostButton")
  • code/branches/tutorial/data/gui/scripts/KeyBindMenu.lua

    r7928 r8051  
    2626    table.insert(commandList, "NewHumanController changeMode")
    2727    table.insert(commandList, "switchCamera")
    28     table.insert(commandList, "openConsole")
     28    table.insert(commandList, "InGameConsole openConsole")
    2929    table.insert(commandList, "OverlayGroup toggleVisibility Debug")
    3030    table.insert(commandList, "OverlayGroup toggleVisibility Stats")
  • code/branches/tutorial/data/gui/scripts/MenuSheet.lua

    r7689 r8051  
    1616    newSheet.bHidePrevious  = handleDefArg(_bHidePrevious,  true)
    1717    newSheet.tShowCursor    = handleDefArg(_tShowCusor,     TriBool.True)
    18     newSheet.tUseKeyboard   = handleDefArg(_tUseKeyboard,   TriBool.True)
     18    newSheet.tUseKeyboard   = handleDefArg(_tUseKeyboard,   TriBool.Dontcare)
    1919    newSheet.bBlockJoyStick = handleDefArg(_bBlockJoyStick, false)
    2020
  • code/branches/tutorial/data/gui/scripts/MiscConfigMenu.lua

    r7928 r8051  
    3535    table.insert(P.commandList, "HumanPlayer nick_")
    3636    table.insert(P.commandList, "ChatOverlay displayTime_")
     37    table.insert(P.commandList, "Core bDevMode_")
    3738
    3839    P.nameList = {}
     
    5455    table.insert(P.nameList, "Playername")
    5556    table.insert(P.nameList, "Chat: display time")
     57    table.insert(P.nameList, "Developer's Mode")
    5658
    5759    P.linesList = {}
  • code/branches/tutorial/data/gui/scripts/SheetManager.lua

    r8015 r8051  
    55local activeMenuSheets = {size = 0, topSheetTuple = nil}
    66local menuSheetsRoot = guiMgr:getMenuRootWindow()
    7 local bInGameConsoleClosed = false
    87local mainMenuLoaded = false
    9 orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
    10 
    11 -----------------------
    12 --- Local functions ---
    13 -----------------------
    14 
    15 local function hideCursor()
    16     if cursor:isVisible() then
    17         cursor:hide()
    18     end
    19 end
    20 
    21 local function showCursor()
    22     if not cursor:isVisible() and inputMgr:isMouseExclusive() then
    23         cursor:show()
    24     end
    25 end
    26 
     8--orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
     9orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "Sized", "windowResized")
    2710
    2811------------------------
    2912--- Global functions ---
    3013------------------------
     14
     15function hideCursor()
     16    if cursor:isVisible() then
     17        cursor:hide()
     18    end
     19end
     20
     21function showCursor()
     22    if not cursor:isVisible() and inputMgr:isMouseExclusive() then
     23        cursor:show()
     24    end
     25end
    3126
    3227-- Loads the GUI with the specified name
     
    9388        ["sheet"]          = menuSheet,
    9489        ["bHidePrevious"]  = bHidePrevious,
    95         ["bNoInput"]       = bNoInput
     90        ["bNoInput"]       = bNoInput,
     91        ["name"]           = name
    9692    }
    9793    table.insert(activeMenuSheets, sheetTuple) -- indexed array access
     
    135131    if previous and previous.pressedEnter and menuSheet:hasSelection() == false then
    136132        menuSheet:setSelectionNear(1, 1)
     133    end
     134
     135    if activeMenuSheets.size > 0 then
     136        guiMgr:guisActiveChanged(true)
    137137    end
    138138
     
    207207    end
    208208
     209    if activeMenuSheets.size == 0 then
     210        guiMgr:guisActiveChanged(false)
     211    end
     212
    209213    sheetTuple.sheet:quit()
    210214end
     
    220224    -- HUGE, very HUGE hacks!
    221225
    222     -- If the InGameConsole is active, ignore the ESC command.
    223     if bInGameConsoleClosed == true then
    224         bInGameConsoleClosed = false
    225         return
    226     end
    227 
    228     -- Count the number of sheets that don't need input till the first that does.
     226    -- Count the number of sheets that don't need input until the first that does.
    229227    local counter = noInputSheetIndex()
    230228
     
    240238end
    241239
    242 function keyPressed(e)
    243     local we = tolua.cast(e, "CEGUI::KeyEventArgs")
     240-- Function to navigate the GUI, is called by the GUIManager, whenever a relevant key is pressed.
     241-- The mode specifies the action to be taken.
     242function navigateGUI(mode)
    244243    local sheet = activeMenuSheets[activeMenuSheets.size]
    245     code = tostring(we.scancode)
    246     -- Some preprocessing
    247     if not mainMenuLoaded and not sheet.bNoInput then
    248         if code == "1" then
    249             keyESC()
    250         elseif code == "0"then
    251             orxonox.CommandExecutor:execute("openConsole")
    252         end
    253     end
    254     sheet.sheet:keyPressed()
     244    sheet.sheet:keyPressed(mode)
     245end
     246
     247function windowResized(e)
     248    for name, sheet in pairs(loadedSheets) do
     249        if orxonox.GraphicsManager:getInstance():isFullScreen() or sheet.tShowCursor == TriBool.False then
     250            inputMgr:setMouseExclusive(sheet.inputState, TriBool.True)
     251        else
     252            inputMgr:setMouseExclusive(sheet.inputState, TriBool.False)
     253        end
     254    end
     255    local sheetTuple = activeMenuSheets[activeMenuSheets.size]
     256    if sheetTuple then
     257        if orxonox.GraphicsManager:getInstance():isFullScreen() and sheetTuple.sheet.tShowCursor ~= TriBool.False then
     258            showCursor()
     259        else
     260            hideCursor()
     261        end
     262        sheetTuple.sheet:windowResized()
     263    end
    255264end
    256265
     
    279288end
    280289
    281 function inGameConsoleClosed()
    282     bInGameConsoleClosed = not bInGameConsoleClosed;
     290function getGUIFirstActive(name, bHidePrevious, bNoInput)
     291    local sheet = activeMenuSheets.topSheetTuple
     292    -- If the topmost gui sheet has the input name
     293    if sheet ~= nil and sheet.name == name then
     294        guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, false);
     295    else
     296        guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, true);
     297    end
    283298end
    284299
  • code/branches/tutorial/data/gui/scripts/SingleplayerMenu.lua

    r7928 r8051  
    2525end
    2626
     27function P.onShow()
     28    if P.showAll ~= orxonox.GUIManager:inDevMode() then
     29        local window = winMgr:getWindow("orxonox/SingleplayerShowAllCheckbox")
     30        local button = tolua.cast(window,"CEGUI::Checkbox")
     31        P.showAll = not P.showAll
     32        button:setSelected(P.showAll)
     33        P.createLevelList()
     34    end
     35end
     36
    2737function P.createLevelList()
    2838    P.levelList = {}
     
    4454        index = index + 1
    4555    end
    46     --TODO: Reintroduce sorting, if needed. At the moment it's sorted by filename.
    47     --table.sort(levelList)
    4856    for k,v in pairs(P.levelList) do
    4957        local item = CEGUI.createListboxTextItem(v:getName())
Note: See TracChangeset for help on using the changeset viewer.