Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/doc/data/gui/scripts/GraphicsMenu.lua @ 7308

Last change on this file since 7308 was 6746, checked in by rgrieder, 15 years ago

Merged gamestates2 branch back to trunk.
This brings in some heavy changes in the GUI framework.
It should also fix problems with triggered asserts in the InputManager.

Note: PickupInventory does not seem to work —> Segfault when showing because before, the owner in GUIOverlay::setGUIName is already NULL.
I haven't tested it before, so I can't tell whether it's my changes.

  • Property svn:eol-style set to native
File size: 6.6 KB
Line 
1-- GraphicsMenu.lua
2
3local P = createMenuSheet("GraphicsMenu")
4
5function 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)
12    for line in f:lines() do
13        if search_mode == 0 then
14            if string.find(line, rendersystem) ~= nil then
15                search_mode = 1
16            end
17        end
18        if search_mode == 1 then
19            if string.sub(line, 1, 11) == "Full Screen" then
20                if string.sub(line, 13) == "Yes" then
21                    fullscreen = true
22                else
23                    fullscreen = false
24                end
25            end
26            if string.sub(line, 1, 10) == "Video Mode" then
27                if string.match(line, "@") == "@" then
28                    resolution = string.sub(line, 12, string.find(line, "@")-2)
29                else
30                    resolution = string.sub(line, 12)
31                end
32                break
33            end
34        end
35    end
36    f:close()
37    local fullscreenwindow = tolua.cast(winMgr:getWindow("orxonox/FullscreenCheckbox"),"CEGUI::Checkbox")
38    fullscreenwindow:setSelected(fullscreen)
39    listboxwindow = winMgr:getWindow("orxonox/ResolutionListbox")
40    local resolutionList = {}
41    table.insert(resolutionList, "640 x 480")
42    table.insert(resolutionList, "720 x 480")
43    table.insert(resolutionList, "720 x 576")
44    table.insert(resolutionList, "800 x 480")
45    table.insert(resolutionList, "800 x 600")
46    table.insert(resolutionList, "1024 x 480")
47    table.insert(resolutionList, "1024 x 600")
48    table.insert(resolutionList, "1024 x 768")
49    table.insert(resolutionList, "1152 x 864")
50    table.insert(resolutionList, "1280 x 720")
51    table.insert(resolutionList, "1280 x 768")
52    table.insert(resolutionList, "1440 x 900")
53    for k,v in pairs(resolutionList) do
54        item = CEGUI.createListboxTextItem(v)
55        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
56        CEGUI.toListbox(listboxwindow):addItem(item)
57    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)
82    end
83    scrollbar_active = false
84    block = false
85end
86
87function 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"
112    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)
118    for line in f:lines() do
119        if search_mode == 0 then
120            if string.find(line, rendersystem) ~= nil then
121                search_mode = 1
122            end
123        end
124        if search_mode == 1 then
125            if string.sub(line, 1, 10) == "Video Mode" then
126                if string.match(line, "@") == "@" then
127                    line = "Video Mode=" .. resolution .. string.sub(line, string.find(line, "@")-1)
128                else
129                    line = "Video Mode=" .. resolution
130                end
131                search_mode = 2
132            end
133        end
134        text = text .. line .. "\n"
135    end
136    f:close()
137    f = io.open(file, "w")
138    f:write(text)
139    f:close()
140end
141
142function P.GraphicsBrightnessScrollbar_changed(e)
143    if scrollbar_active == false then
144        -- brightness
145        logMessage(0, "event: brightness")
146    end
147end
148
149function P.GraphicsBrightnessScrollbar_started(e)
150    scrollbar_active = true
151end
152
153function P.GraphicsBrightnessScrollbar_ended(e)
154    -- brightness
155    logMessage(0, "event: brightness")
156    scrollbar_active = false
157end
158
159function 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)
166        for line in f:lines() do
167            if search_mode == 0 then
168                if string.find(line, rendersystem) ~= nil then
169                    search_mode = 1
170                end
171            end
172            if search_mode == 1 then
173                if string.sub(line, 1, 11) == "Full Screen" then
174                    if fullscreen == true then
175                        line = "Full Screen=No"
176                        fullscreen = false
177                    else
178                        line = "Full Screen=Yes"
179                        fullscreen = true
180                    end
181                    search_mode = 2
182                end
183            end
184            text = text .. line .. "\n"
185        end
186        f:close()
187        f = io.open(file, "w")
188        f:write(text)
189        f:close()
190    end
191end
192
193function P.GraphicsBackButton_clicked(e)
194    hideMenuSheet(P.name)
195end
196
197return P
198
Note: See TracBrowser for help on using the repository browser.