Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6258 was 6258, checked in by cmueri, 14 years ago

The fullscreen button is now available, but you have to change the filepath in the GraphicsMenu.lua file to use it.

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