use GLSL shaders

This commit is contained in:
Eduardo Bart
2011-12-06 22:31:55 -02:00
parent cf0aab6d4d
commit 7eead50806
64 changed files with 1219 additions and 630 deletions

View File

@@ -0,0 +1,5 @@
function dumpWidgets()
for i=1,UI.root:getChildCount() do
print(UI.root:getChildByIndex(i):getId())
end
end

View File

@@ -34,7 +34,7 @@ local function completeCommand()
local cursorPos = commandLineEdit:getCursorPos()
if cursorPos == 0 then return end
local commandBegin = string.sub(commandLineEdit:getText(), 1, cursorPos)
local commandBegin = commandLineEdit:getText():sub(1, cursorPos)
local possibleCommands = {}
-- create a list containing all globals
@@ -43,7 +43,7 @@ local function completeCommand()
-- match commands
for k,v in pairs(allVars) do
if string.sub(k, 1, cursorPos) == commandBegin then
if k:sub(1, cursorPos) == commandBegin then
table.insert(possibleCommands, k)
end
end
@@ -63,9 +63,9 @@ local function completeCommand()
if #possibleCommands[1] < cursorPos then
break
end
expandedComplete = commandBegin .. string.sub(possibleCommands[1], cursorPos, cursorPos)
expandedComplete = commandBegin .. possibleCommands[1]:sub(cursorPos, cursorPos)
for i,v in ipairs(possibleCommands) do
if string.sub(v, 1, #expandedComplete) ~= expandedComplete then
if v:sub(1, #expandedComplete) ~= expandedComplete then
done = true
end
end

View File

@@ -8,11 +8,9 @@ Module
autoLoad: true
autoLoadPriority: 20
dependencies:
- core
onLoad: |
require 'console'
require 'commands'
Console.init()
return true

View File

@@ -3,7 +3,7 @@ Client = { }
-- TODO: load and save configurations
function Client.init()
g_window.move({ x=220, y=220 })
g_window.resize({ width=800, height=600 })
g_window.resize({ width=800, height=480 })
g_window.setTitle('OTClient')
g_window.setIcon('clienticon.png')
return true

View File

@@ -23,8 +23,8 @@ local function onError(protocol, error)
end
local function onMotd(protocol, motd)
motdNumber = tonumber(string.sub(motd, 0, string.find(motd, "\n")))
motdMessage = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd))
motdNumber = tonumber(motd:sub(0, motd:find("\n")))
motdMessage = motd:sub(motd:find("\n") + 1, #motd)
TopMenu.getButton('motdButton'):show()
end

View File

@@ -7,7 +7,7 @@ local vsyncEnabled = false
function getConfig(name, default)
if g_configs.exists(name) then
local val = string.trim(g_configs.get(name))
local val = g_configs.get(name):trim()
if val == 'true' or val == 'false' then
return toboolean(val)
else

View File

@@ -1,4 +1,3 @@
-- AnchorEdge
AnchorNone = 0
AnchorTop = 1
AnchorBottom = 2
@@ -15,9 +14,6 @@ LogFatal = 4
ActiveFocusReason = 2
EmptyFunction = function() end
-- KeyCodes
KeyUnknown = 0
KeyEscape = 1
KeyTab = 2
@@ -57,7 +53,7 @@ KeyLeftParen = 40 -- (
KeyRightParen = 41 -- )
KeyAsterisk = 42 -- *
KeyPlus = 43 -- +
KeyComma = 44 --
KeyComma = 44 -- ,
KeyMinus = 45 -- -
KeyPeriod = 46 -- .
KeySlash = 47 -- /

View File

@@ -7,10 +7,14 @@ Module
onLoad: |
require 'ext/table'
require 'ext/string'
require 'constants'
require 'util/point'
require 'util/size'
require 'util/color'
require 'util/rect'
require 'const'
require 'util'
require 'dispatcher'
require 'widget'
require 'ui'
require 'gfx'
require 'effects'
return true

View File

@@ -1,43 +1,33 @@
local eventId = 0
local eventsTable = { }
local orig = { scheduleEvent = scheduleEvent,
addEvent = addEvent }
local eventList = {}
-- fix original scheduleEvent
function scheduleEvent(func, delay)
eventId = eventId + 1
local id = eventId
local function proxyFunc()
if eventsTable[id] then
func()
eventsTable[id] = nil
if eventList[id] then
if eventList[id].active then
func()
end
eventList[id] = nil
end
end
eventsTable[id] = proxyFunc
orig.scheduleEvent(proxyFunc, delay)
eventList[id] = { func = proxyFunc, active = true }
if delay and delay > 0 then
g_dispatcher.scheduleEvent(proxyFunc, delay)
else
g_dispatcher.addEvent(proxyFunc, false)
end
return id
end
-- FIXME: the event function can be collected
-- and the dispatcher would call an invalid function, generating an warning
function addEvent(func)
return scheduleEvent(func, 0)
end
function removeEvent(id)
if id and eventsTable[id] then
eventsTable[id] = nil
if id and eventList[id] then
eventList[id].active = false
return true
end
end
-- fix original addEvent
function addEvent(func)
eventId = eventId + 1
local id = eventId
local function proxyFunc()
if eventsTable[id] then
func()
eventsTable[id] = nil
end
end
eventsTable[id] = proxyFunc
orig.addEvent(proxyFunc)
return id
end

View File

@@ -1,6 +1,6 @@
GFX = { }
Effects = {}
function GFX.fadeIn(widget, time, elapsed)
function Effects.fadeIn(widget, time, elapsed)
if not elapsed then elapsed = 0 end
if not time then time = 250 end
widget:setOpacity(math.min((255*elapsed)/time, 255))
@@ -11,7 +11,7 @@ function GFX.fadeIn(widget, time, elapsed)
end
end
function GFX.fadeOut(widget, time, elapsed)
function Effects.fadeOut(widget, time, elapsed)
if not elapsed then elapsed = 0 end
if not time then time = 250 end
widget:setOpacity((255*(time - elapsed))/time)

View File

@@ -13,12 +13,12 @@ function string:starts(start)
return self:sub(1, #start) == start
end
function string.trim(str)
return str:match'^%s*(.*%S)' or ''
function string:trim()
return self:match('^%s*(.*%S)') or ''
end
function toboolean(str)
str = string.trim(str)
str = str:trim()
if str == '1' or str == 'true' then
return true
end

View File

@@ -1,7 +1,7 @@
function table.dump(t, depth)
if not depth then depth = 0 end
for k,v in pairs(t) do
str = string.rep(' ', depth * 2) .. k .. ': '
str = (' '):rep(depth * 2) .. k .. ': '
if type(v) ~= "table" then
print(str .. tostring(v))
else

View File

@@ -6,10 +6,8 @@ function print(...)
Logger.log(LogInfo, msg)
end
function createEnvironment()
local env = { }
setmetatable(env, { __index = _G} )
return env
function fatal(msg)
Logger.log(LogFatal, msg)
end
function connect(object, signalsAndSlots, pushFront)
@@ -28,10 +26,10 @@ function connect(object, signalsAndSlots, pushFront)
end
end
function dumpWidgets()
for i=1,UI.root:getChildCount() do
print(UI.root:getChildByIndex(i):getId())
end
function createEnvironment()
local env = { }
setmetatable(env, { __index = _G} )
return env
end
function getCallingScriptSourcePath(depth)

View File

@@ -16,4 +16,4 @@ function UIWidget:setMargin(...)
self:setMarginBottom(params[3])
self:setMarginLeft(params[4])
end
end
end

View File

@@ -28,7 +28,7 @@ function MessageBox.create(title, text, flags)
if flags == MessageBoxOk then
buttonRight:setText("Ok")
box.onOk = EmptyFunction
box.onOk = function() end
buttonRight.onClick = function()
box.onOk()
box:destroy()
@@ -37,7 +37,7 @@ function MessageBox.create(title, text, flags)
window.onEscape = buttonRight.onClick
elseif flags == MessageBoxCancel then
buttonRight:setText("Cancel")
box.onCancel = EmptyFunction
box.onCancel = function() end
buttonRight.onClick = function()
box.onCancel()
box:destroy()

View File

@@ -28,7 +28,7 @@ function ToolTip.display(text)
local size = label:getSize()
size.width = size.width + 4
size.height = size.height + 4
currentToolTip:setSize(size)
currentToolTip:resize(size)
moveToolTip(currentToolTip)
end
end