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