2012-07-24 07:30:08 +02:00
|
|
|
HOTKEY = 'Ctrl+X'
|
|
|
|
MAP_SHADERS = {
|
2012-06-16 00:18:30 +02:00
|
|
|
{ name = 'Default', frag = 'shaders/default.frag' },
|
|
|
|
{ name = 'Bloom', frag = 'shaders/bloom.frag'},
|
|
|
|
{ name = 'Sepia', frag ='shaders/sepia.frag' },
|
|
|
|
{ name = 'Grayscale', frag ='shaders/grayscale.frag' },
|
|
|
|
{ name = 'Pulse', frag = 'shaders/pulse.frag' },
|
|
|
|
{ name = 'Old Tv', frag = 'shaders/oldtv.frag' },
|
|
|
|
{ name = 'Fog', frag = 'shaders/fog.frag', tex1 = 'images/clouds.png' },
|
|
|
|
{ name = 'Party', frag = 'shaders/party.frag' },
|
|
|
|
{ name = 'Radial Blur', frag ='shaders/radialblur.frag' },
|
|
|
|
{ name = 'Zomg', frag ='shaders/zomg.frag' },
|
|
|
|
{ name = 'Heat', frag ='shaders/heat.frag' },
|
|
|
|
{ name = 'Noise', frag ='shaders/noise.frag' },
|
|
|
|
}
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
ITEM_SHADERS = {
|
2012-06-16 00:18:30 +02:00
|
|
|
{ name = 'Fake 3D', vert = 'shaders/fake3d.vert' }
|
2012-06-14 20:26:55 +02:00
|
|
|
}
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
shadersPanel = nil
|
2012-06-14 20:26:55 +02:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function init()
|
2012-06-26 00:13:30 +02:00
|
|
|
g_ui.importStyle('shaders.otui')
|
2012-06-14 20:26:55 +02:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
g_keyboard.bindKeyDown(HOTKEY, toggle)
|
2012-06-14 20:26:55 +02:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
shadersPanel = g_ui.createWidget('ShadersPanel', modules.game_interface.getMapPanel())
|
2012-06-14 20:26:55 +02:00
|
|
|
shadersPanel:hide()
|
|
|
|
|
|
|
|
local mapComboBox = shadersPanel:getChildById('mapComboBox')
|
|
|
|
mapComboBox.onOptionChange = function(combobox, option)
|
2012-07-24 07:30:08 +02:00
|
|
|
local map = modules.game_interface.getMapPanel()
|
2012-06-14 20:26:55 +02:00
|
|
|
map:setMapShader(g_shaders.getShader(option))
|
|
|
|
end
|
|
|
|
|
2012-06-19 01:58:56 +02:00
|
|
|
if not g_graphics.canUseShaders() then return end
|
|
|
|
|
2012-06-16 00:18:30 +02:00
|
|
|
for _i,opts in pairs(MAP_SHADERS) do
|
|
|
|
local shader = g_shaders.createFragmentShader(opts.name, opts.frag)
|
2012-06-14 20:26:55 +02:00
|
|
|
|
2012-06-16 00:18:30 +02:00
|
|
|
if opts.tex1 then
|
|
|
|
shader:addMultiTexture(opts.tex1)
|
2012-06-14 20:26:55 +02:00
|
|
|
end
|
2012-06-16 00:18:30 +02:00
|
|
|
if opts.tex2 then
|
|
|
|
shader:addMultiTexture(opts.tex2)
|
|
|
|
end
|
|
|
|
|
|
|
|
mapComboBox:addOption(opts.name)
|
2012-06-14 20:26:55 +02:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
local map = modules.game_interface.getMapPanel()
|
2012-06-14 20:26:55 +02:00
|
|
|
map:setMapShader(g_shaders.getShader('Default'))
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function terminate()
|
2012-06-26 00:13:30 +02:00
|
|
|
g_keyboard.unbindKeyDown(HOTKEY)
|
2012-06-14 20:26:55 +02:00
|
|
|
shadersPanel:destroy()
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function toggle()
|
2012-06-14 20:26:55 +02:00
|
|
|
shadersPanel:setVisible(not shadersPanel:isVisible())
|
|
|
|
end
|