mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
Merge branch 'revgraphics'
Conflicts: src/framework/CMakeLists.txt src/framework/application.cpp src/framework/graphics/graphics.cpp
This commit is contained in:
5
modules/addon_console/commands.lua
Normal file
5
modules/addon_console/commands.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
function dumpWidgets()
|
||||
for i=1,UI.root:getChildCount() do
|
||||
print(UI.root:getChildByIndex(i):getId())
|
||||
end
|
||||
end
|
@@ -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
|
||||
|
@@ -8,11 +8,9 @@ Module
|
||||
autoLoad: true
|
||||
autoLoadPriority: 20
|
||||
|
||||
dependencies:
|
||||
- core
|
||||
|
||||
onLoad: |
|
||||
require 'console'
|
||||
require 'commands'
|
||||
Console.init()
|
||||
return true
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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 -- /
|
@@ -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
|
||||
|
@@ -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
|
@@ -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)
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
@@ -16,4 +16,4 @@ function UIWidget:setMargin(...)
|
||||
self:setMarginBottom(params[3])
|
||||
self:setMarginLeft(params[4])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -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()
|
||||
|
@@ -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
|
||||
|
49
modules/outfit.frag
Normal file
49
modules/outfit.frag
Normal file
@@ -0,0 +1,49 @@
|
||||
uniform float opacity;
|
||||
uniform vec4 color;
|
||||
uniform float ticks;
|
||||
|
||||
uniform sampler2D texture; // outfit texture
|
||||
varying vec2 textureCoords; // outfit texture coords
|
||||
uniform sampler2D maskTexture; // outfit color mask
|
||||
|
||||
uniform vec4 headColor;
|
||||
uniform vec4 bodyColor;
|
||||
uniform vec4 legsColor;
|
||||
uniform vec4 feetColor;
|
||||
|
||||
vec4 calcPixel(vec2 texCoord)
|
||||
{
|
||||
vec4 pixel = texture2D(texture, texCoord);
|
||||
vec4 maskColor = texture2D(maskTexture, texCoord);
|
||||
|
||||
vec4 outColor = vec4(0);
|
||||
if(maskColor.r == 1.0 && maskColor.g == 1.0) {
|
||||
outColor = headColor;
|
||||
} else if(maskColor.r == 1.0) {
|
||||
outColor = bodyColor;
|
||||
} else if(maskColor.g == 1.0) {
|
||||
outColor = legsColor;
|
||||
} else if(maskColor.b == 1.0) {
|
||||
outColor = feetColor;
|
||||
}
|
||||
|
||||
if(outColor.a != 0.0)
|
||||
pixel = pixel * outColor;
|
||||
return pixel;
|
||||
}
|
||||
void main()
|
||||
{
|
||||
vec4 pixel = calcPixel(textureCoords);
|
||||
int num = 16;
|
||||
|
||||
vec4 sum = vec4(0);
|
||||
int i, j;
|
||||
for(i=-num/2;i<num/2;++i) {
|
||||
for(j=-num/2;j<num/2;++j) {
|
||||
sum += calcPixel(textureCoords + vec2(i+1, j+1)*0.005) * 1.0/(num*num);
|
||||
}
|
||||
}
|
||||
sum = sin(ticks/500.0)*sum;
|
||||
|
||||
gl_FragColor = pixel * color * opacity + sum;
|
||||
}
|
123
modules/shadertest.frag
Normal file
123
modules/shadertest.frag
Normal file
@@ -0,0 +1,123 @@
|
||||
varying vec2 textureCoords;
|
||||
uniform float opacity;
|
||||
uniform vec4 color;
|
||||
uniform float ticks;
|
||||
uniform sampler2D texture;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(texture, textureCoords) * color * opacity;
|
||||
}
|
||||
|
||||
/*
|
||||
varying vec2 textureCoords;
|
||||
uniform vec4 color;
|
||||
uniform float ticks;
|
||||
uniform sampler2D texture;
|
||||
|
||||
void main()
|
||||
{
|
||||
int num = 4;
|
||||
vec4 sum = vec4(0);
|
||||
int i, j;
|
||||
for(i=-num/2;i<num/2;++i) {
|
||||
for(j=-num/2;j<num/2;++j) {
|
||||
sum += texture2D(texture, textureCoords + vec2(i+1, j+1)*0.001) * 1.0/(num*num);
|
||||
}
|
||||
}
|
||||
|
||||
float period = ticks/1000.0;
|
||||
float a = (sin(period)+1.0)/2.0;
|
||||
sum.a = 0;
|
||||
gl_FragColor = vec4(1,1,1,2) - texture2D(texture, textureCoords);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
uniform sampler2D texture;
|
||||
varying vec2 textureCoords;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sum = vec4(0);
|
||||
vec2 texcoord = textureCoords;
|
||||
int j;
|
||||
int i;
|
||||
|
||||
for( i= -4 ;i < 4; i++)
|
||||
{
|
||||
for (j = -3; j < 3; j++)
|
||||
{
|
||||
sum += texture2D(texture, texcoord + vec2(j, i)*0.004) * 0.25;
|
||||
}
|
||||
}
|
||||
if (texture2D(texture, texcoord).r < 0.3)
|
||||
{
|
||||
gl_FragColor = sum*sum*0.012 + texture2D(texture, texcoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (texture2D(texture, texcoord).r < 0.5)
|
||||
{
|
||||
gl_FragColor = sum*sum*0.009 + texture2D(texture, texcoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_FragColor = sum*sum*0.0075 + texture2D(texture, texcoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
uniform sampler2D texture;
|
||||
varying vec2 textureCoords;
|
||||
uniform vec4 color;
|
||||
uniform float opacity;
|
||||
|
||||
uniform float ticks;
|
||||
uniform float rt_w = 18*32;
|
||||
uniform float rt_h = 14*32;
|
||||
|
||||
uniform float radius = 300.0;
|
||||
uniform float angle = 0.2;
|
||||
uniform vec2 center = vec2(8*32, 5*32);
|
||||
|
||||
vec4 PostFX(sampler2D tex, vec2 uv, float time)
|
||||
{
|
||||
vec2 texSize = vec2(rt_w, rt_h);
|
||||
vec2 tc = uv * texSize;
|
||||
tc -= center;
|
||||
float dist = length(tc);
|
||||
if (dist < radius)
|
||||
{
|
||||
float percent = (radius - dist) / radius;
|
||||
float theta = percent * percent * ((int)ticks % 1000)/1000.0 * 8.0;
|
||||
float s = sin(theta);
|
||||
float c = cos(theta);
|
||||
tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c)));
|
||||
}
|
||||
tc += center;
|
||||
vec3 color = texture2D(texture, tc / texSize).rgb;
|
||||
return vec4(color, 1.0);
|
||||
}
|
||||
|
||||
void main (void)
|
||||
{
|
||||
vec2 uv = textureCoords.st;
|
||||
gl_FragColor = PostFX(texture, uv, ticks) * opacity;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
uniform float opacity;
|
||||
vec4 calculatePixel();
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = calculatePixel() * opacity;
|
||||
}
|
||||
|
||||
varying vec2 textureCoords;
|
||||
uniform vec4 color;
|
||||
uniform sampler2D texture;
|
||||
vec4 calculatePixel() {
|
||||
return texture2D(texture, textureCoords) * color;
|
||||
}
|
||||
*/
|
Reference in New Issue
Block a user