[6363] | 1 | -- GraphicsMenu.lua |
---|
| 2 | |
---|
[6746] | 3 | local P = createMenuSheet("GraphicsMenu") |
---|
[6363] | 4 | |
---|
[6746] | 5 | function P.onLoad() |
---|
[6773] | 6 | P.block = true |
---|
| 7 | P.file = orxonox.PathConfig:getConfigPathString() .. orxonox.getConfig("GraphicsManager", "ogreConfigFile_") |
---|
| 8 | P.search_mode = 0 |
---|
| 9 | local f = io.open(P.file, "r") |
---|
| 10 | local firstline = f:read("*line") |
---|
| 11 | local rendersystem = string.sub(firstline, 15) |
---|
[6363] | 12 | for line in f:lines() do |
---|
[6773] | 13 | if P.search_mode == 0 then |
---|
[6363] | 14 | if string.find(line, rendersystem) ~= nil then |
---|
[6773] | 15 | P.search_mode = 1 |
---|
[6363] | 16 | end |
---|
| 17 | end |
---|
[6773] | 18 | if P.search_mode == 1 then |
---|
[6363] | 19 | if string.sub(line, 1, 11) == "Full Screen" then |
---|
| 20 | if string.sub(line, 13) == "Yes" then |
---|
[6773] | 21 | P.fullscreen = true |
---|
[6363] | 22 | else |
---|
[6773] | 23 | P.fullscreen = false |
---|
[6363] | 24 | end |
---|
| 25 | end |
---|
| 26 | if string.sub(line, 1, 10) == "Video Mode" then |
---|
| 27 | if string.match(line, "@") == "@" then |
---|
[6773] | 28 | P.resolution = string.sub(line, 12, string.find(line, "@")-2) |
---|
[6363] | 29 | else |
---|
[6773] | 30 | P.resolution = string.sub(line, 12) |
---|
[6363] | 31 | end |
---|
| 32 | break |
---|
| 33 | end |
---|
| 34 | end |
---|
| 35 | end |
---|
| 36 | f:close() |
---|
| 37 | local fullscreenwindow = tolua.cast(winMgr:getWindow("orxonox/FullscreenCheckbox"),"CEGUI::Checkbox") |
---|
[6773] | 38 | fullscreenwindow:setSelected(P.fullscreen) |
---|
| 39 | P.listboxwindow = winMgr:getWindow("orxonox/ResolutionListbox") |
---|
[6363] | 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 |
---|
[6773] | 54 | local item = CEGUI.createListboxTextItem(v) |
---|
[6746] | 55 | item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") |
---|
[6773] | 56 | CEGUI.toListbox(P.listboxwindow):addItem(item) |
---|
[6363] | 57 | end |
---|
[6773] | 58 | if P.resolution == "640 x 480" then |
---|
| 59 | P.listboxwindow:setItemSelectState(0,true) |
---|
| 60 | elseif P.resolution == "720 x 480" then |
---|
| 61 | P.listboxwindow:setItemSelectState(1,true) |
---|
| 62 | elseif P.resolution == "720 x 576" then |
---|
| 63 | P.listboxwindow:setItemSelectState(2,true) |
---|
| 64 | elseif P.resolution == "800 x 480" then |
---|
| 65 | P.listboxwindow:setItemSelectState(3,true) |
---|
| 66 | elseif P.resolution == "800 x 600" then |
---|
| 67 | P.listboxwindow:setItemSelectState(4,true) |
---|
| 68 | elseif P.resolution == "1024 x 480" then |
---|
| 69 | P.listboxwindow:setItemSelectState(5,true) |
---|
| 70 | elseif P.resolution == "1024 x 600" then |
---|
| 71 | P.listboxwindow:setItemSelectState(6,true) |
---|
| 72 | elseif P.resolution == "1024 x 768" then |
---|
| 73 | P.listboxwindow:setItemSelectState(7,true) |
---|
| 74 | elseif P.resolution == "1152 x 864" then |
---|
| 75 | P.listboxwindow:setItemSelectState(8,true) |
---|
| 76 | elseif P.resolution == "1280 x 720" then |
---|
| 77 | P.listboxwindow:setItemSelectState(9,true) |
---|
| 78 | elseif P.resolution == "1280 x 768" then |
---|
| 79 | P.listboxwindow:setItemSelectState(10,true) |
---|
| 80 | elseif P.resolution == "1440 x 900" then |
---|
| 81 | P.listboxwindow:setItemSelectState(11,true) |
---|
[6363] | 82 | end |
---|
[6773] | 83 | P.scrollbar_active = false |
---|
| 84 | P.block = false |
---|
[6363] | 85 | end |
---|
| 86 | |
---|
| 87 | function P.GraphicsResolutionListbox_changed(e) |
---|
[6773] | 88 | if P.listboxwindow:isItemSelected(0) then |
---|
| 89 | P.resolution = "640 x 480" |
---|
| 90 | elseif P.listboxwindow:isItemSelected(1) then |
---|
| 91 | P.resolution = "720 x 480" |
---|
| 92 | elseif P.listboxwindow:isItemSelected(2) then |
---|
| 93 | P.resolution = "720 x 576" |
---|
| 94 | elseif P.listboxwindow:isItemSelected(3) then |
---|
| 95 | P.resolution = "800 x 480" |
---|
| 96 | elseif P.listboxwindow:isItemSelected(4) then |
---|
| 97 | P.resolution = "800 x 600" |
---|
| 98 | elseif P.listboxwindow:isItemSelected(5) then |
---|
| 99 | P.resolution = "1024 x 480" |
---|
| 100 | elseif P.listboxwindow:isItemSelected(6) then |
---|
| 101 | P.resolution = "1024 x 600" |
---|
| 102 | elseif P.listboxwindow:isItemSelected(7) then |
---|
| 103 | P.resolution = "1024 x 768" |
---|
| 104 | elseif P.listboxwindow:isItemSelected(8) then |
---|
| 105 | P.resolution = "1152 x 864" |
---|
| 106 | elseif P.listboxwindow:isItemSelected(9) then |
---|
| 107 | P.resolution = "1280 x 720" |
---|
| 108 | elseif P.listboxwindow:isItemSelected(10) then |
---|
| 109 | P.resolution = "1280 x 768" |
---|
| 110 | elseif P.listboxwindow:isItemSelected(11) then |
---|
| 111 | P.resolution = "1440 x 900" |
---|
[6363] | 112 | end |
---|
[6773] | 113 | P.search_mode = 0 |
---|
| 114 | local f = io.open(P.file, "r") |
---|
| 115 | local firstline = f:read("*line") |
---|
| 116 | local text = firstline .. "\n" |
---|
| 117 | local rendersystem = string.sub(firstline, 15) |
---|
[6363] | 118 | for line in f:lines() do |
---|
[6773] | 119 | if P.search_mode == 0 then |
---|
[6363] | 120 | if string.find(line, rendersystem) ~= nil then |
---|
[6773] | 121 | P.search_mode = 1 |
---|
[6363] | 122 | end |
---|
| 123 | end |
---|
[6773] | 124 | if P.search_mode == 1 then |
---|
[6363] | 125 | if string.sub(line, 1, 10) == "Video Mode" then |
---|
| 126 | if string.match(line, "@") == "@" then |
---|
[6773] | 127 | line = "Video Mode=" .. P.resolution .. string.sub(line, string.find(line, "@")-1) |
---|
[6363] | 128 | else |
---|
[6773] | 129 | line = "Video Mode=" .. P.resolution |
---|
[6363] | 130 | end |
---|
[6773] | 131 | P.search_mode = 2 |
---|
[6363] | 132 | end |
---|
| 133 | end |
---|
| 134 | text = text .. line .. "\n" |
---|
| 135 | end |
---|
| 136 | f:close() |
---|
[6773] | 137 | f = io.open(P.file, "w") |
---|
[6363] | 138 | f:write(text) |
---|
| 139 | f:close() |
---|
| 140 | end |
---|
| 141 | |
---|
| 142 | function P.GraphicsBrightnessScrollbar_changed(e) |
---|
[6773] | 143 | if P.scrollbar_active == false then |
---|
[6363] | 144 | -- brightness |
---|
[6746] | 145 | logMessage(0, "event: brightness") |
---|
[6363] | 146 | end |
---|
| 147 | end |
---|
| 148 | |
---|
| 149 | function P.GraphicsBrightnessScrollbar_started(e) |
---|
[6773] | 150 | P.scrollbar_active = true |
---|
[6363] | 151 | end |
---|
| 152 | |
---|
| 153 | function P.GraphicsBrightnessScrollbar_ended(e) |
---|
| 154 | -- brightness |
---|
[6746] | 155 | logMessage(0, "event: brightness") |
---|
[6773] | 156 | P.scrollbar_active = false |
---|
[6363] | 157 | end |
---|
| 158 | |
---|
| 159 | function P.GraphicsFullscreenCheckbox_clicked(e) |
---|
[6773] | 160 | if P.block == false then |
---|
| 161 | P.search_mode = 0 |
---|
| 162 | local f = io.open(P.file, "r") |
---|
| 163 | local firstline = f:read("*line") |
---|
| 164 | local text = firstline .. "\n" |
---|
| 165 | local rendersystem = string.sub(firstline, 15) |
---|
[6363] | 166 | for line in f:lines() do |
---|
[6773] | 167 | if P.search_mode == 0 then |
---|
[6363] | 168 | if string.find(line, rendersystem) ~= nil then |
---|
[6773] | 169 | P.search_mode = 1 |
---|
[6363] | 170 | end |
---|
| 171 | end |
---|
[6773] | 172 | if P.search_mode == 1 then |
---|
[6363] | 173 | if string.sub(line, 1, 11) == "Full Screen" then |
---|
[6773] | 174 | if P.fullscreen == true then |
---|
[6363] | 175 | line = "Full Screen=No" |
---|
[6773] | 176 | P.fullscreen = false |
---|
[6363] | 177 | else |
---|
| 178 | line = "Full Screen=Yes" |
---|
[6773] | 179 | P.fullscreen = true |
---|
[6363] | 180 | end |
---|
[6773] | 181 | P.search_mode = 2 |
---|
[6363] | 182 | end |
---|
| 183 | end |
---|
| 184 | text = text .. line .. "\n" |
---|
| 185 | end |
---|
| 186 | f:close() |
---|
[6773] | 187 | f = io.open(P.file, "w") |
---|
[6363] | 188 | f:write(text) |
---|
| 189 | f:close() |
---|
| 190 | end |
---|
| 191 | end |
---|
| 192 | |
---|
| 193 | function P.GraphicsBackButton_clicked(e) |
---|
[6746] | 194 | hideMenuSheet(P.name) |
---|
[6363] | 195 | end |
---|
| 196 | |
---|
| 197 | return P |
---|
| 198 | |
---|