help
This commit is contained in:
parent
90ba400380
commit
87551314cc
@ -202,8 +202,8 @@ helium.input
|
|||||||
```
|
```
|
||||||
|
|
||||||
## All the user intended interfaces, classes and methods
|
## All the user intended interfaces, classes and methods
|
||||||
|
-> is return value
|
||||||
## User facing functions
|
values with Capital are classes
|
||||||
```lua
|
```lua
|
||||||
helium.element(function,reloader,w,h,parameters)
|
helium.element(function,reloader,w,h,parameters)
|
||||||
->Element --Creates a new element
|
->Element --Creates a new element
|
||||||
|
|||||||
4
conf.lua
4
conf.lua
@ -1,6 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
HOTSWAP = true, --Turns on hotswap, disable this once it's deployed
|
HOTSWAP = true, --Turns on hotswap, disable this once you're deploying a project
|
||||||
AUTO_RUN = true, --Replaces the default love.run
|
AUTO_RUN = true, --Replaces the default love.run
|
||||||
DEBUG = true, --Reserved for later
|
DEBUG = true, --Reserved for later
|
||||||
PURE_G = true, --whether to set HeliumLoader global
|
PURE_G = true, --whether to keep _G pure
|
||||||
}
|
}
|
||||||
@ -104,6 +104,8 @@ function element:new(w, h, param)
|
|||||||
pendingUpdate = true,
|
pendingUpdate = true,
|
||||||
needsRendering = true,
|
needsRendering = true,
|
||||||
calculatedDimensions = true,
|
calculatedDimensions = true,
|
||||||
|
--Stabilize the internal canvas, draw it twice on first load
|
||||||
|
stabilize = true,
|
||||||
inserted = false
|
inserted = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,6 +270,11 @@ local draw = love.graphics.draw
|
|||||||
function element:externalRender()
|
function element:externalRender()
|
||||||
self.context:set()
|
self.context:set()
|
||||||
|
|
||||||
|
if self.settings.stabilize and not self.settings.needsRendering then
|
||||||
|
self.settings.stabilize = false
|
||||||
|
self.settings.needsRendering = true
|
||||||
|
end
|
||||||
|
|
||||||
if self.settings.needsRendering then
|
if self.settings.needsRendering then
|
||||||
self:renderWrapper()
|
self:renderWrapper()
|
||||||
self.settings.needsRendering = false
|
self.settings.needsRendering = false
|
||||||
|
|||||||
@ -59,7 +59,13 @@ function context:set()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function context:update()
|
function context:update()
|
||||||
|
if self.parentCtx then
|
||||||
|
self.absX = self.parentCtx.absX + self.elem.view.x
|
||||||
|
self.absY = self.parentCtx.absY + self.elem.view.y
|
||||||
|
end
|
||||||
|
for i, e in ipairs(self.childContexts) do
|
||||||
|
e:update()
|
||||||
|
end
|
||||||
for i, sub in ipairs(self.subs) do
|
for i, sub in ipairs(self.subs) do
|
||||||
sub:contextUpdate(self.absX,self.absY,self)
|
sub:contextUpdate(self.absX,self.absY,self)
|
||||||
end
|
end
|
||||||
@ -93,8 +99,26 @@ end
|
|||||||
function subscription.create(x, y, w, h, eventType, callback, doff)
|
function subscription.create(x, y, w, h, eventType, callback, doff)
|
||||||
local sub
|
local sub
|
||||||
if activeContext then
|
if activeContext then
|
||||||
local wratio = w/activeContext.elem.view.w
|
local wratio,hratio,xratio,yratio
|
||||||
local hratio = h/activeContext.elem.view.h
|
if x<=1 and x~=0 then
|
||||||
|
xratio = x
|
||||||
|
x = activeContext.elem.view.w * x
|
||||||
|
end
|
||||||
|
|
||||||
|
if y<=1 and y~=0 then
|
||||||
|
yratio = y
|
||||||
|
y = activeContext.elem.view.h * y
|
||||||
|
end
|
||||||
|
|
||||||
|
if w<=1 and w~=0 then
|
||||||
|
wratio = w
|
||||||
|
w = activeContext.elem.view.w * w
|
||||||
|
end
|
||||||
|
|
||||||
|
if h<=1 and h~=0 then
|
||||||
|
hratio = h
|
||||||
|
h = activeContext.elem.view.h * h
|
||||||
|
end
|
||||||
|
|
||||||
sub = setmetatable({
|
sub = setmetatable({
|
||||||
x = activeContext.absX + x,
|
x = activeContext.absX + x,
|
||||||
@ -103,6 +127,8 @@ function subscription.create(x, y, w, h, eventType, callback, doff)
|
|||||||
h = h,
|
h = h,
|
||||||
wratio = wratio,
|
wratio = wratio,
|
||||||
hratio = hratio,
|
hratio = hratio,
|
||||||
|
xratio = xratio,
|
||||||
|
yratio = yratio,
|
||||||
ix = x,
|
ix = x,
|
||||||
iy = y,
|
iy = y,
|
||||||
eventType = eventType,
|
eventType = eventType,
|
||||||
@ -146,10 +172,22 @@ function subscription:destroy()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function subscription:contextUpdate(absX, absY,activeContext)
|
function subscription:contextUpdate(absX, absY,activeContext)
|
||||||
|
if self.xratio then
|
||||||
|
self.x = absX + activeContext.elem.view.w * self.xratio
|
||||||
|
else
|
||||||
self.x = absX + self.ix
|
self.x = absX + self.ix
|
||||||
|
end
|
||||||
|
if self.yratio then
|
||||||
|
self.y = absY + activeContext.elem.view.h * self.yratio
|
||||||
|
else
|
||||||
self.y = absY + self.iy
|
self.y = absY + self.iy
|
||||||
self.w = activeContext.elem.view.w * self.wratio
|
end
|
||||||
|
if self.hratio then
|
||||||
self.h = activeContext.elem.view.h * self.hratio
|
self.h = activeContext.elem.view.h * self.hratio
|
||||||
|
end
|
||||||
|
if self.wratio then
|
||||||
|
self.w = activeContext.elem.view.w * self.wratio
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function subscription:update(x, y, w, h)
|
function subscription:update(x, y, w, h)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user