minor cleanup
This commit is contained in:
parent
36cccb9984
commit
1c0be1810b
5
conf.lua
5
conf.lua
@ -1,9 +1,4 @@
|
||||
return {
|
||||
HOTSWAP = true, --Deprecated
|
||||
AUTO_RUN = true, --Replaces the default love.run
|
||||
DEBUG = true, --Reserved for later
|
||||
PURE_G = true, --whether to keep _G pure
|
||||
HARD_ERROR = true, --Whether to display element errors inside or hard cras
|
||||
AUTO_CACHING = true, --Enable for cache money
|
||||
CACHING_CANVASES = 2, --How many fullscreen atlas canvases to create (change if auto_caching is enabled, to suit your needs, more means more texturememory)
|
||||
}
|
||||
@ -1,3 +1,9 @@
|
||||
--[[--------------------------------------------------
|
||||
Helium UI by qfx (qfluxstudios@gmail.com)
|
||||
Copyright (c) 2021 Elmārs Āboliņš
|
||||
https://github.com/qeffects/helium
|
||||
----------------------------------------------------]]
|
||||
|
||||
local atlas = {}
|
||||
atlas.__index = atlas
|
||||
---@class atlases
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
--[[ Element superclass ]]
|
||||
--[[ Love is currently a hard dependency, although not in many places ]]
|
||||
--[[--------------------------------------------------
|
||||
Helium UI by qfx (qfluxstudios@gmail.com)
|
||||
Copyright (c) 2021 Elmārs Āboliņš
|
||||
https://github.com/qeffects/helium
|
||||
----------------------------------------------------]]
|
||||
local path = string.sub(..., 1, string.len(...) - string.len(".core.element"))
|
||||
local helium = require(path .. ".dummy")
|
||||
local context = require(path.. ".core.stack")
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
--[[--------------------------------------------------
|
||||
Helium UI by qfx (qfluxstudios@gmail.com)
|
||||
Copyright (c) 2021 Elmārs Āboliņš
|
||||
https://github.com/qeffects/helium
|
||||
----------------------------------------------------]]
|
||||
local eventClass = {}
|
||||
eventClass.__index = eventClass
|
||||
|
||||
|
||||
6
core/input.d.ts
vendored
6
core/input.d.ts
vendored
@ -1,6 +0,0 @@
|
||||
interface Subscription{
|
||||
on():void;
|
||||
off():void;
|
||||
}
|
||||
|
||||
export default function input(it:string,cb:(x?:number,y?:number)=>void,doff?:boolean,x?:number,y?:number,w?:number,h?:number): Subscription;
|
||||
@ -1,3 +1,8 @@
|
||||
--[[--------------------------------------------------
|
||||
Helium UI by qfx (qfluxstudios@gmail.com)
|
||||
Copyright (c) 2021 Elmārs Āboliņš
|
||||
https://github.com/qeffects/helium
|
||||
----------------------------------------------------]]
|
||||
local path = string.sub(..., 1, string.len(...) - string.len(".core.input"))
|
||||
local stack = require(path .. ".core.stack")
|
||||
local helium = require(path .. ".dummy")
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
--[[--------------------------------------------------
|
||||
Helium UI by qfx (qfluxstudios@gmail.com)
|
||||
Copyright (c) 2021 Elmārs Āboliņš
|
||||
https://github.com/qeffects/helium
|
||||
----------------------------------------------------]]
|
||||
|
||||
local path = string.sub(..., 1, string.len(...) - string.len(".core.scene"))
|
||||
|
||||
local atlas = require(path..'.core.atlas')
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
--Builds the element stack basically
|
||||
|
||||
--[[--------------------------------------------------
|
||||
Helium UI by qfx (qfluxstudios@gmail.com)
|
||||
Copyright (c) 2021 Elmārs Āboliņš
|
||||
https://github.com/qeffects/helium
|
||||
----------------------------------------------------]]
|
||||
local path = string.sub(..., 1, string.len(...) - string.len(".core.stack"))
|
||||
local helium = require(path .. ".dummy")
|
||||
local event = require(path..'.core.events')
|
||||
|
||||
33
init.d.ts
vendored
33
init.d.ts
vendored
@ -1,33 +0,0 @@
|
||||
export interface parameters{
|
||||
[index: string]: any;
|
||||
[index: number]: any;
|
||||
}
|
||||
|
||||
export interface view{
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
lock?: boolean;
|
||||
onChange?(): null;
|
||||
}
|
||||
|
||||
export interface state{
|
||||
[index: string]: any;
|
||||
[index: number]: any;
|
||||
}
|
||||
|
||||
interface HeliumElement{
|
||||
view: view;
|
||||
state: state;
|
||||
parameters: parameters;
|
||||
draw(this,x:number,y:number): null;
|
||||
undraw(this): null;
|
||||
}
|
||||
|
||||
declare function HeliumLoader(filepath:string):(params:parameters, w:number, h:number)=>HeliumElement;
|
||||
|
||||
export module helium{
|
||||
export let input: typeof import("./core/input") ;
|
||||
}
|
||||
export function helium<T>(chunk:(params:T,state:state,view:view)=>()=>void):(params:T, w:number, h:number)=>HeliumElement;
|
||||
6
init.lua
6
init.lua
@ -1,10 +1,10 @@
|
||||
--[[--------------------------------------------------
|
||||
Helium UI by qfx (qfluxstudios@gmail.com)
|
||||
Copyright (c) 2019 Elmārs Āboliņš
|
||||
gitlab.com/project link here
|
||||
https://github.com/qeffects/helium
|
||||
----------------------------------------------------]]
|
||||
local path = ...
|
||||
local helium = require(path..".dummy")
|
||||
local helium = require(path..'.dummy')
|
||||
|
||||
local defaultConf = require(path..".conf")
|
||||
helium.conf = {}
|
||||
@ -16,11 +16,9 @@ else
|
||||
helium.conf = defaultConf
|
||||
end
|
||||
|
||||
helium.utils = require(path..".utils")
|
||||
helium.scene = require(path..".core.scene")
|
||||
helium.element = require(path..".core.element")
|
||||
helium.input = require(path..".core.input")
|
||||
helium.loader = require(path..".loader")
|
||||
helium.stack = require(path..".core.stack")
|
||||
helium.atlas = require(path..".core.atlas")
|
||||
helium.__index = helium
|
||||
|
||||
108
loader.lua
108
loader.lua
@ -1,108 +0,0 @@
|
||||
|
||||
local path = string.sub(..., 1, string.len(...) - string.len(".loader"))
|
||||
local helium = require(path..'.dummy')
|
||||
local elements = {}
|
||||
local debugLoader = {}
|
||||
--Return level: 1--string; 2--chunk; 3--return value; default: element factory
|
||||
local function loader(path)
|
||||
local succ = true
|
||||
|
||||
--File string
|
||||
local fileContents, err = love.filesystem.read(path)
|
||||
|
||||
if fileContents==nil then
|
||||
print('Error loading ',path,':',tostring(err),', will continue watching!')
|
||||
succ = false
|
||||
end
|
||||
|
||||
local t, lastLoaded
|
||||
if succ then
|
||||
t = love.filesystem.getInfo(path)
|
||||
lastLoaded = t['modtime']
|
||||
end
|
||||
|
||||
--Chunk
|
||||
local status, err
|
||||
if succ then
|
||||
status, err = pcall(loadstring,fileContents)
|
||||
end
|
||||
|
||||
if status==false or status==nil then
|
||||
print('Error compiling ',path,':',tostring(err),', will continue watching!')
|
||||
succ = false
|
||||
end
|
||||
|
||||
--Return values
|
||||
local ret
|
||||
if succ then
|
||||
succ, ret = pcall(err,path)
|
||||
if not succ then
|
||||
print('Error calling ',path,':',tostring(ret))
|
||||
end
|
||||
end
|
||||
|
||||
return fileContents, err, ret, lastLoaded
|
||||
end
|
||||
|
||||
debugLoader.loader = function(path,returnLevel)
|
||||
local level = returnLevel or 6
|
||||
if elements[path] then
|
||||
return elements[path][level]
|
||||
end
|
||||
|
||||
local setfuncs = {}
|
||||
|
||||
local fileContents, func, ret, lastLoaded = loader(path)
|
||||
local reloader = function(setFunc)
|
||||
setfuncs[#setfuncs+1] = setFunc
|
||||
end
|
||||
|
||||
local factory = function(param,w,h)
|
||||
return helium.element(ret, reloader, w, h, param)
|
||||
end
|
||||
|
||||
elements[path] = {fileContents, func, ret, path, lastLoaded, factory, setfuncs = setfuncs}
|
||||
return elements[path][level]
|
||||
end
|
||||
|
||||
local counter = 0
|
||||
function debugLoader.update(dt)
|
||||
counter = counter+dt
|
||||
if counter>2 then
|
||||
for ind, elem in pairs(elements) do
|
||||
--Get the current last save time
|
||||
local t = love.filesystem.getInfo(elem[4])
|
||||
local ll = t['modtime']
|
||||
if ll ~= elem[5] then
|
||||
--If last save time differs then start reload sequence
|
||||
local _, _, ret, lastLoaded = loader(elem[4])
|
||||
|
||||
|
||||
local setfuncs = {}
|
||||
|
||||
local reloader = function(setFunc)
|
||||
setfuncs[#setfuncs+1] = setFunc
|
||||
end
|
||||
|
||||
local factory = function()
|
||||
return helium.element(ret, reloader)
|
||||
end
|
||||
|
||||
elem[5] = lastLoaded
|
||||
|
||||
elem[6] = factory
|
||||
|
||||
for i, func in ipairs(elem.setfuncs) do
|
||||
func(ret)
|
||||
end
|
||||
end
|
||||
end
|
||||
counter = 0
|
||||
end
|
||||
end
|
||||
|
||||
if helium.conf.PURE_G then
|
||||
HeliumLoader = debugLoader.loader
|
||||
end
|
||||
|
||||
return debugLoader
|
||||
30
utils.lua
30
utils.lua
@ -1,30 +0,0 @@
|
||||
local utils = {}
|
||||
|
||||
function utils.ArrayRemove(t, fnKeep)
|
||||
local j, n = 1, #t;
|
||||
|
||||
for i=1,n do
|
||||
if fnKeep(t, i, j) then
|
||||
-- Move i's kept value to j's position, if it's not already there.
|
||||
if i ~= j then
|
||||
t[j] = t[i];
|
||||
--t[i] = nil;
|
||||
end
|
||||
j = j + 1; -- Increment position of where we'll place the next kept value.
|
||||
end --else
|
||||
t[i] = nil; -- in both if cases you nil it sooooo
|
||||
--end
|
||||
end
|
||||
|
||||
return t;
|
||||
end
|
||||
|
||||
function utils.tableMerge(t, bt)
|
||||
for k, v in pairs(t) do
|
||||
if v ~= bt[k] then
|
||||
bt[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return utils
|
||||
Loading…
x
Reference in New Issue
Block a user