allow to change graphics engine in options

This commit is contained in:
Eduardo Bart
2012-06-02 18:41:20 -03:00
parent e6d2e877f0
commit 079b7a5c41
10 changed files with 107 additions and 27 deletions

View File

@@ -1,4 +1,25 @@
Panel
Label
!text: tr('Graphics Engine:')
anchors.left: parent.left
anchors.top: parent.top
ButtonBox
anchors.left: prev.right
anchors.verticalCenter: prev.verticalCenter
id: opengl1
text: OpenGL 1
size: 80 20
margin-left: 6
ButtonBox
anchors.left: prev.right
anchors.verticalCenter: prev.verticalCenter
id: opengl2
text: OpenGL 2
size: 80 20
margin-left: 4
OptionCheckBox
id: vsync
!text: tr('Enable vertical synchronization')

View File

@@ -13,6 +13,33 @@ local options = { vsync = true,
showTimestampsInConsole = true,
showLevelsInConsole = true,
showPrivateMessagesInConsole = false }
local generalPanel
local graphicsPanel
local function setupGraphicsEngines()
local enginesRadioGroup = RadioGroup.create()
local ogl1 = graphicsPanel:getChildById('opengl1')
local ogl2 = graphicsPanel:getChildById('opengl2')
enginesRadioGroup:addWidget(ogl1)
enginesRadioGroup:addWidget(ogl2)
if g_graphics.getPainterEngine() == 2 then
enginesRadioGroup:selectWidget(ogl2)
else
enginesRadioGroup:selectWidget(ogl1)
end
ogl1:setEnabled(g_graphics.isPainterEngineAvailable(1))
ogl2:setEnabled(g_graphics.isPainterEngineAvailable(2))
enginesRadioGroup.onSelectionChange = function(self, selected)
if selected == ogl1 then
g_graphics.selectPainterEngine(1)
elseif selected == ogl2 then
g_graphics.selectPainterEngine(2)
end
end
end
function Options.init()
-- load options
@@ -31,8 +58,14 @@ function Options.init()
optionsButton = TopMenu.addLeftButton('optionsButton', tr('Options') .. ' (Ctrl+P)', 'options.png', Options.toggle)
optionsTabBar = optionsWindow:getChildById('optionsTabBar')
optionsTabBar:setContentWidget(optionsWindow:getChildById('optionsTabContent'))
optionsTabBar:addTab(tr('General'), loadUI('general.otui'))
optionsTabBar:addTab(tr('Graphics'), loadUI('graphics.otui'))
generalPanel = loadUI('general.otui')
optionsTabBar:addTab(tr('General'), generalPanel)
graphicsPanel = loadUI('graphics.otui')
optionsTabBar:addTab(tr('Graphics'), graphicsPanel)
setupGraphicsEngines()
end
function Options.terminate()
@@ -43,6 +76,8 @@ function Options.terminate()
optionsButton:destroy()
optionsButton = nil
optionsTabBar = nil
generalPanel = nil
graphicsPanel = nil
Options = nil
end

View File

@@ -17,7 +17,7 @@ OptionCheckBox < CheckBox
MainWindow
id: optionsWindow
!text: tr('Options')
size: 350 230
size: 350 240
@onEnter: Options.hide()
@onEscape: Options.hide()

View File

@@ -57,5 +57,5 @@ ButtonBox < UICheckBox
color: #80c7f8
$disabled:
color: #f0ad4d88
color: #666666ff
image-color: #ffffff88