[6206] | 1 | -- GraphicsMenu.lua |
---|
| 2 | |
---|
| 3 | BasicGUI = require("BasicGUI") |
---|
| 4 | local P = BasicGUI:new() --inherit everything from the gui package |
---|
| 5 | if _REQUIREDNAME == nil then |
---|
| 6 | GraphicsMenu = P |
---|
| 7 | else |
---|
| 8 | _G[_REQUIREDNAME] = P |
---|
| 9 | end |
---|
| 10 | |
---|
| 11 | P.filename = "GraphicsMenu" |
---|
| 12 | P.layoutString = "GraphicsMenu.layout" |
---|
| 13 | |
---|
| 14 | function P:init() |
---|
[6258] | 15 | file = "C:\\Games\\Orxonox\\menu\\build\\config\\Debug\\" .. orxonox.getConfig("GraphicsManager", "ogreConfigFile_") |
---|
| 16 | search_mode = 0 |
---|
| 17 | f = io.open(file, "r") |
---|
| 18 | firstline = f:read("*line") |
---|
| 19 | rendersystem = string.sub(firstline, 15) |
---|
| 20 | for line in f:lines() do |
---|
| 21 | if search_mode == 0 then |
---|
| 22 | if string.find(line, rendersystem) ~= nil then |
---|
| 23 | search_mode = 1 |
---|
| 24 | end |
---|
| 25 | end |
---|
| 26 | if search_mode == 1 then |
---|
| 27 | if string.sub(line, 1, 11) == "Full Screen" then |
---|
| 28 | if string.sub(line, 13) == "Yes" then |
---|
| 29 | fullscreen = true |
---|
| 30 | else |
---|
| 31 | fullscreen = false |
---|
| 32 | end |
---|
| 33 | break |
---|
| 34 | end |
---|
| 35 | end |
---|
| 36 | end |
---|
| 37 | f:close() |
---|
| 38 | local fullscreenwindow = tolua.cast(winMgr:getWindow("orxonox/FullscreenCheckbox"),"CEGUI::Checkbox") |
---|
| 39 | fullscreenwindow:setSelected(fullscreen) |
---|
[6206] | 40 | dropdown = winMgr:getWindow("orxonox/ResolutionCombobox") |
---|
| 41 | local resolutionList = {} |
---|
| 42 | table.insert(resolutionList, "800 x 600 (4:3)") |
---|
| 43 | table.insert(resolutionList, "1024 x 640 (16:10)") |
---|
| 44 | table.insert(resolutionList, "1024 x 768 (4:3)") |
---|
| 45 | table.insert(resolutionList, "1280 x 800 (16:10)") |
---|
| 46 | table.insert(resolutionList, "1280 x 960 (4:3)") |
---|
| 47 | table.insert(resolutionList, "1440 x 900 (16:10)") |
---|
| 48 | table.insert(resolutionList, "1600 x 1200 (4:3)") |
---|
| 49 | table.insert(resolutionList, "1680 x 1050 (16:10)") |
---|
| 50 | for k,v in pairs(resolutionList) do |
---|
| 51 | item = CEGUI.createListboxTextItem(v) |
---|
| 52 | item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush") |
---|
| 53 | CEGUI.toCombobox(dropdown):addItem(item) |
---|
| 54 | end |
---|
| 55 | local scrollbar_active = false |
---|
| 56 | end |
---|
| 57 | |
---|
| 58 | function P.GraphicsResolutionCombobox_changed(e) |
---|
| 59 | -- resolution |
---|
| 60 | debug("event: resolution") |
---|
| 61 | end |
---|
| 62 | |
---|
| 63 | function P.GraphicsBrightnessScrollbar_changed(e) |
---|
| 64 | if scrollbar_active == false then |
---|
| 65 | -- brightness |
---|
| 66 | debug("event: brightness") |
---|
| 67 | end |
---|
| 68 | end |
---|
| 69 | |
---|
| 70 | function P.GraphicsBrightnessScrollbar_started(e) |
---|
| 71 | scrollbar_active = true |
---|
| 72 | end |
---|
| 73 | |
---|
| 74 | function P.GraphicsBrightnessScrollbar_ended(e) |
---|
| 75 | -- brightness |
---|
| 76 | debug("event: brightness") |
---|
| 77 | scrollbar_active = false |
---|
| 78 | end |
---|
| 79 | |
---|
| 80 | function P.GraphicsFullscreenCheckbox_clicked(e) |
---|
[6258] | 81 | search_mode = 0 |
---|
| 82 | f = io.open(file, "r") |
---|
| 83 | firstline = f:read("*line") |
---|
| 84 | text = firstline .. "\n" |
---|
| 85 | rendersystem = string.sub(firstline, 15) |
---|
| 86 | for line in f:lines() do |
---|
| 87 | if search_mode == 0 then |
---|
| 88 | if string.find(line, rendersystem) ~= nil then |
---|
| 89 | search_mode = 1 |
---|
| 90 | end |
---|
| 91 | end |
---|
| 92 | if search_mode == 1 then |
---|
| 93 | if string.sub(line, 1, 11) == "Full Screen" then |
---|
| 94 | if fullscreen == true then |
---|
| 95 | line = "Full Screen=No" |
---|
| 96 | fullscreen = false |
---|
| 97 | else |
---|
| 98 | line = "Full Screen=Yes" |
---|
| 99 | fullscreen = true |
---|
| 100 | end |
---|
| 101 | debug(line) |
---|
| 102 | search_mode = 2 |
---|
| 103 | end |
---|
| 104 | end |
---|
| 105 | text = text .. line .. "\n" |
---|
| 106 | end |
---|
| 107 | f:close() |
---|
| 108 | f = io.open(file, "w") |
---|
| 109 | f:write(text) |
---|
| 110 | f:close() |
---|
[6206] | 111 | end |
---|
| 112 | |
---|
| 113 | function P.GraphicsBackButton_clicked(e) |
---|
| 114 | hideGUI(P.filename) |
---|
| 115 | end |
---|
| 116 | |
---|
| 117 | return P |
---|
| 118 | |
---|