Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/skybox2/data/gui/scripts/GraphicsMenu.lua @ 7063

Last change on this file since 7063 was 6417, checked in by rgrieder, 15 years ago

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
  • Property svn:eol-style set to native
File size: 6.8 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    block = true
16    file = orxonox.PathConfig:getConfigPathString() .. 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            end
35            if string.sub(line, 1, 10) == "Video Mode" then
36                if string.match(line, "@") == "@" then
37                    resolution = string.sub(line, 12, string.find(line, "@")-2)
38                else
39                    resolution = string.sub(line, 12)
40                end
41                break
42            end
43        end
44    end
45    f:close()
46    local fullscreenwindow = tolua.cast(winMgr:getWindow("orxonox/FullscreenCheckbox"),"CEGUI::Checkbox")
47    fullscreenwindow:setSelected(fullscreen)
48    listboxwindow = winMgr:getWindow("orxonox/ResolutionListbox")
49    local resolutionList = {}
50    table.insert(resolutionList, "640 x 480")
51    table.insert(resolutionList, "720 x 480")
52    table.insert(resolutionList, "720 x 576")
53    table.insert(resolutionList, "800 x 480")
54    table.insert(resolutionList, "800 x 600")
55    table.insert(resolutionList, "1024 x 480")
56    table.insert(resolutionList, "1024 x 600")
57    table.insert(resolutionList, "1024 x 768")
58    table.insert(resolutionList, "1152 x 864")
59    table.insert(resolutionList, "1280 x 720")
60    table.insert(resolutionList, "1280 x 768")
61    table.insert(resolutionList, "1440 x 900")
62    for k,v in pairs(resolutionList) do
63        item = CEGUI.createListboxTextItem(v)
64        item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
65        CEGUI.toListbox(listboxwindow):addItem(item)
66    end
67    if resolution == "640 x 480" then
68        listboxwindow:setItemSelectState(0,true)
69    elseif resolution == "720 x 480" then
70        listboxwindow:setItemSelectState(1,true)
71    elseif resolution == "720 x 576" then
72        listboxwindow:setItemSelectState(2,true)
73    elseif resolution == "800 x 480" then
74        listboxwindow:setItemSelectState(3,true)
75    elseif resolution == "800 x 600" then
76        listboxwindow:setItemSelectState(4,true)
77    elseif resolution == "1024 x 480" then
78        listboxwindow:setItemSelectState(5,true)
79    elseif resolution == "1024 x 600" then
80        listboxwindow:setItemSelectState(6,true)
81    elseif resolution == "1024 x 768" then
82        listboxwindow:setItemSelectState(7,true)
83    elseif resolution == "1152 x 864" then
84        listboxwindow:setItemSelectState(8,true)
85    elseif resolution == "1280 x 720" then
86        listboxwindow:setItemSelectState(9,true)
87    elseif resolution == "1280 x 768" then
88        listboxwindow:setItemSelectState(10,true)
89    elseif resolution == "1440 x 900" then
90        listboxwindow:setItemSelectState(11,true)
91    end
92    scrollbar_active = false
93    block = false
94end
95
96function P.GraphicsResolutionListbox_changed(e)
97    if listboxwindow:isItemSelected(0) then
98        resolution = "640 x 480"
99    elseif listboxwindow:isItemSelected(1) then
100        resolution = "720 x 480"
101    elseif listboxwindow:isItemSelected(2) then
102        resolution = "720 x 576"
103    elseif listboxwindow:isItemSelected(3) then
104        resolution = "800 x 480"
105    elseif listboxwindow:isItemSelected(4) then
106        resolution = "800 x 600"
107    elseif listboxwindow:isItemSelected(5) then
108        resolution = "1024 x 480"
109    elseif listboxwindow:isItemSelected(6) then
110        resolution = "1024 x 600"
111    elseif listboxwindow:isItemSelected(7) then
112        resolution = "1024 x 768"
113    elseif listboxwindow:isItemSelected(8) then
114        resolution = "1152 x 864"
115    elseif listboxwindow:isItemSelected(9) then
116        resolution = "1280 x 720"
117    elseif listboxwindow:isItemSelected(10) then
118        resolution = "1280 x 768"
119    elseif listboxwindow:isItemSelected(11) then
120        resolution = "1440 x 900"
121    end
122    search_mode = 0
123    f = io.open(file, "r")
124    firstline = f:read("*line")
125    text = firstline .. "\n"
126    rendersystem = string.sub(firstline, 15)
127    for line in f:lines() do
128        if search_mode == 0 then
129            if string.find(line, rendersystem) ~= nil then
130                search_mode = 1
131            end
132        end
133        if search_mode == 1 then
134            if string.sub(line, 1, 10) == "Video Mode" then
135                if string.match(line, "@") == "@" then
136                    line = "Video Mode=" .. resolution .. string.sub(line, string.find(line, "@")-1)
137                else
138                    line = "Video Mode=" .. resolution
139                end
140                search_mode = 2
141            end
142        end
143        text = text .. line .. "\n"
144    end
145    f:close()
146    f = io.open(file, "w")
147    f:write(text)
148    f:close()
149end
150
151function P.GraphicsBrightnessScrollbar_changed(e)
152    if scrollbar_active == false then
153        -- brightness
154        debug("event: brightness")
155    end
156end
157
158function P.GraphicsBrightnessScrollbar_started(e)
159    scrollbar_active = true
160end
161
162function P.GraphicsBrightnessScrollbar_ended(e)
163    -- brightness
164    debug("event: brightness")
165    scrollbar_active = false
166end
167
168function P.GraphicsFullscreenCheckbox_clicked(e)
169    if block == false then
170        search_mode = 0
171        f = io.open(file, "r")
172        firstline = f:read("*line")
173        text = firstline .. "\n"
174        rendersystem = string.sub(firstline, 15)
175        for line in f:lines() do
176            if search_mode == 0 then
177                if string.find(line, rendersystem) ~= nil then
178                    search_mode = 1
179                end
180            end
181            if search_mode == 1 then
182                if string.sub(line, 1, 11) == "Full Screen" then
183                    if fullscreen == true then
184                        line = "Full Screen=No"
185                        fullscreen = false
186                    else
187                        line = "Full Screen=Yes"
188                        fullscreen = true
189                    end
190                    search_mode = 2
191                end
192            end
193            text = text .. line .. "\n"
194        end
195        f:close()
196        f = io.open(file, "w")
197        f:write(text)
198        f:close()
199    end
200end
201
202function P.GraphicsBackButton_clicked(e)
203    hideGUI(P.filename)
204end
205
206return P
207
Note: See TracBrowser for help on using the repository browser.