Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation2/data/gui/scripts/GraphicsMenu.lua @ 6259

Last change on this file since 6259 was 6259, checked in by scheusso, 14 years ago

menu automatically reads ogre config path

File size: 3.6 KB
Line 
1-- GraphicsMenu.lua
2
3BasicGUI = require("BasicGUI")
4local P = BasicGUI:new() --inherit everything from the gui package
5if _REQUIREDNAME == nil then
6    GraphicsMenu = P
7else
8    _G[_REQUIREDNAME] = P
9end
10
11P.filename = "GraphicsMenu"
12P.layoutString = "GraphicsMenu.layout"
13
14function P:init()
15    file = orxonox.PathConfig:getConfigPathString() .. orxonox.getConfig("GraphicsManager", "ogreConfigFile_")
16    --file = "C:\\Games\\Orxonox\\menu\\build\\config\\Debug\\" .. orxonox.getConfig("GraphicsManager", "ogreConfigFile_")
17    search_mode = 0
18    f = io.open(file, "r")
19    firstline = f:read("*line")
20    rendersystem = string.sub(firstline, 15)
21    for line in f:lines() do
22        if search_mode == 0 then
23            if string.find(line, rendersystem) ~= nil then
24                search_mode = 1
25            end
26        end
27        if search_mode == 1 then
28            if string.sub(line, 1, 11) == "Full Screen" then
29                if string.sub(line, 13) == "Yes" then
30                    fullscreen = true
31                else
32                    fullscreen = false
33                end
34                break
35            end
36        end
37    end
38    f:close()
39    local fullscreenwindow = tolua.cast(winMgr:getWindow("orxonox/FullscreenCheckbox"),"CEGUI::Checkbox")
40    fullscreenwindow:setSelected(fullscreen)
41    dropdown = winMgr:getWindow("orxonox/ResolutionCombobox")
42    local resolutionList = {}
43    table.insert(resolutionList, "800 x 600  (4:3)")
44    table.insert(resolutionList, "1024 x 640  (16:10)")
45    table.insert(resolutionList, "1024 x 768  (4:3)")
46    table.insert(resolutionList, "1280 x 800  (16:10)")
47    table.insert(resolutionList, "1280 x 960  (4:3)")
48    table.insert(resolutionList, "1440 x 900  (16:10)")
49    table.insert(resolutionList, "1600 x 1200  (4:3)")
50    table.insert(resolutionList, "1680 x 1050  (16:10)")
51    for k,v in pairs(resolutionList) do
52        item = CEGUI.createListboxTextItem(v)       
53        item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
54        CEGUI.toCombobox(dropdown):addItem(item)
55    end
56    local scrollbar_active = false
57end
58
59function P.GraphicsResolutionCombobox_changed(e)
60    -- resolution
61    debug("event: resolution")
62end
63
64function P.GraphicsBrightnessScrollbar_changed(e)
65    if scrollbar_active == false then
66        -- brightness
67        debug("event: brightness")
68    end
69end
70
71function P.GraphicsBrightnessScrollbar_started(e)
72    scrollbar_active = true
73end
74
75function P.GraphicsBrightnessScrollbar_ended(e)
76    -- brightness
77    debug("event: brightness")
78    scrollbar_active = false
79end
80
81function P.GraphicsFullscreenCheckbox_clicked(e)
82    search_mode = 0
83    f = io.open(file, "r")
84    firstline = f:read("*line")
85    text = firstline .. "\n"
86    rendersystem = string.sub(firstline, 15)
87    for line in f:lines() do
88        if search_mode == 0 then
89            if string.find(line, rendersystem) ~= nil then
90                search_mode = 1
91            end
92        end
93        if search_mode == 1 then
94            if string.sub(line, 1, 11) == "Full Screen" then
95                if fullscreen == true then
96                    line = "Full Screen=No"
97                    fullscreen = false
98                else
99                    line = "Full Screen=Yes"
100                    fullscreen = true
101                end
102                debug(line)
103                search_mode = 2
104            end
105        end
106        text = text .. line .. "\n"
107    end
108    f:close()
109    f = io.open(file, "w")
110    f:write(text)
111    f:close()
112end
113
114function P.GraphicsBackButton_clicked(e)
115    hideGUI(P.filename)
116end
117
118return P
119
Note: See TracBrowser for help on using the repository browser.