1 | -- GraphicsMenu.lua |
---|
2 | |
---|
3 | local P = createMenuSheet("GraphicsMenu") |
---|
4 | |
---|
5 | P.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 |
---|
19 | 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 |
---|
36 | end |
---|
37 | 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:initButtons(1, 1) |
---|
89 | P:setButton(1, 1, { |
---|
90 | ["button"] = winMgr:getWindow("orxonox/GraphicsBackButton"), |
---|
91 | ["callback"] = P.GraphicsBackButton_clicked |
---|
92 | }) |
---|
93 | |
---|
94 | local dropbox = winMgr:getWindow("orxonox/ThemeDropBox") |
---|
95 | local scheme = orxonox.CommandExecutor:query("getConfig GUIManager guiScheme_") |
---|
96 | for k,v in pairs(P.schemeList) do |
---|
97 | local item = CEGUI.createListboxTextItem(P.schemeList[k]) |
---|
98 | item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") |
---|
99 | CEGUI.toListbox(dropbox):addItem(item) |
---|
100 | if v == scheme then |
---|
101 | dropbox:setItemSelectState(item, true) |
---|
102 | end |
---|
103 | end |
---|
104 | |
---|
105 | end |
---|
106 | |
---|
107 | function P.ThemeDropBox_changed(e) |
---|
108 | local dropbox = winMgr:getWindow("orxonox/ThemeDropBox") |
---|
109 | local listbox = CEGUI.toListbox(dropbox) |
---|
110 | local choice = listbox:getFirstSelectedItem() |
---|
111 | local index = 0 |
---|
112 | if choice ~= nil then |
---|
113 | index = listbox:getItemIndex(choice) |
---|
114 | end |
---|
115 | orxonox.CommandExecutor:execute("config GUIManager guiScheme_ " .. P.schemeList[index+1]) |
---|
116 | end |
---|
117 | |
---|
118 | function P.GraphicsResolutionListbox_changed(e) |
---|
119 | if listboxwindow:isItemSelected(0) then |
---|
120 | resolution = "640 x 480" |
---|
121 | elseif listboxwindow:isItemSelected(1) then |
---|
122 | resolution = "720 x 480" |
---|
123 | elseif listboxwindow:isItemSelected(2) then |
---|
124 | resolution = "720 x 576" |
---|
125 | elseif listboxwindow:isItemSelected(3) then |
---|
126 | resolution = "800 x 480" |
---|
127 | elseif listboxwindow:isItemSelected(4) then |
---|
128 | resolution = "800 x 600" |
---|
129 | elseif listboxwindow:isItemSelected(5) then |
---|
130 | resolution = "1024 x 480" |
---|
131 | elseif listboxwindow:isItemSelected(6) then |
---|
132 | resolution = "1024 x 600" |
---|
133 | elseif listboxwindow:isItemSelected(7) then |
---|
134 | resolution = "1024 x 768" |
---|
135 | elseif listboxwindow:isItemSelected(8) then |
---|
136 | resolution = "1152 x 864" |
---|
137 | elseif listboxwindow:isItemSelected(9) then |
---|
138 | resolution = "1280 x 720" |
---|
139 | elseif listboxwindow:isItemSelected(10) then |
---|
140 | resolution = "1280 x 768" |
---|
141 | elseif listboxwindow:isItemSelected(11) then |
---|
142 | resolution = "1440 x 900" |
---|
143 | end |
---|
144 | search_mode = 0 |
---|
145 | f = io.open(file, "r") |
---|
146 | firstline = f:read("*line") |
---|
147 | text = firstline .. "\n" |
---|
148 | rendersystem = string.sub(firstline, 15) |
---|
149 | for line in f:lines() do |
---|
150 | if search_mode == 0 then |
---|
151 | if string.find(line, rendersystem) ~= nil then |
---|
152 | search_mode = 1 |
---|
153 | end |
---|
154 | end |
---|
155 | if search_mode == 1 then |
---|
156 | if string.sub(line, 1, 10) == "Video Mode" then |
---|
157 | if string.match(line, "@") == "@" then |
---|
158 | line = "Video Mode=" .. resolution .. string.sub(line, string.find(line, "@")-1) |
---|
159 | else |
---|
160 | line = "Video Mode=" .. resolution |
---|
161 | end |
---|
162 | search_mode = 2 |
---|
163 | end |
---|
164 | end |
---|
165 | text = text .. line .. "\n" |
---|
166 | end |
---|
167 | f:close() |
---|
168 | f = io.open(file, "w") |
---|
169 | f:write(text) |
---|
170 | f:close() |
---|
171 | end |
---|
172 | |
---|
173 | function P.GraphicsBrightnessScrollbar_changed(e) |
---|
174 | if scrollbar_active == false then |
---|
175 | -- brightness |
---|
176 | logMessage(0, "event: brightness") |
---|
177 | end |
---|
178 | end |
---|
179 | |
---|
180 | function P.GraphicsBrightnessScrollbar_started(e) |
---|
181 | scrollbar_active = true |
---|
182 | end |
---|
183 | |
---|
184 | function P.GraphicsBrightnessScrollbar_ended(e) |
---|
185 | -- brightness |
---|
186 | logMessage(0, "event: brightness") |
---|
187 | scrollbar_active = false |
---|
188 | end |
---|
189 | |
---|
190 | function P.GraphicsFullscreenCheckbox_clicked(e) |
---|
191 | if block == false then |
---|
192 | search_mode = 0 |
---|
193 | f = io.open(file, "r") |
---|
194 | firstline = f:read("*line") |
---|
195 | text = firstline .. "\n" |
---|
196 | rendersystem = string.sub(firstline, 15) |
---|
197 | for line in f:lines() do |
---|
198 | if search_mode == 0 then |
---|
199 | if string.find(line, rendersystem) ~= nil then |
---|
200 | search_mode = 1 |
---|
201 | end |
---|
202 | end |
---|
203 | if search_mode == 1 then |
---|
204 | if string.sub(line, 1, 11) == "Full Screen" then |
---|
205 | if fullscreen == true then |
---|
206 | line = "Full Screen=No" |
---|
207 | fullscreen = false |
---|
208 | else |
---|
209 | line = "Full Screen=Yes" |
---|
210 | fullscreen = true |
---|
211 | end |
---|
212 | search_mode = 2 |
---|
213 | end |
---|
214 | end |
---|
215 | text = text .. line .. "\n" |
---|
216 | end |
---|
217 | f:close() |
---|
218 | f = io.open(file, "w") |
---|
219 | f:write(text) |
---|
220 | f:close() |
---|
221 | end |
---|
222 | end |
---|
223 | |
---|
224 | function P.GraphicsBackButton_clicked(e) |
---|
225 | hideMenuSheet(P.name) |
---|
226 | end |
---|
227 | |
---|
228 | return P |
---|
229 | |
---|