From 1c0be1810b315767bd14b443782f56f0ec0d5cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elm=C4=81rs=20=C4=80boli=C5=86=C5=A1?= Date: Tue, 22 Jun 2021 15:09:31 +0300 Subject: [PATCH] minor cleanup --- conf.lua | 5 --- core/atlas.lua | 6 +++ core/element.lua | 7 ++- core/events.lua | 5 +++ core/input.d.ts | 6 --- core/input.lua | 5 +++ core/scene.lua | 6 +++ core/stack.lua | 7 ++- dummy.lua | 2 +- init.d.ts | 33 --------------- init.lua | 6 +-- loader.lua | 108 ----------------------------------------------- utils.lua | 30 ------------- 13 files changed, 35 insertions(+), 191 deletions(-) delete mode 100644 core/input.d.ts delete mode 100644 init.d.ts delete mode 100644 loader.lua delete mode 100644 utils.lua diff --git a/conf.lua b/conf.lua index b0cd590..c63997a 100644 --- a/conf.lua +++ b/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) } \ No newline at end of file diff --git a/core/atlas.lua b/core/atlas.lua index 7f9be94..55e56d7 100644 --- a/core/atlas.lua +++ b/core/atlas.lua @@ -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 diff --git a/core/element.lua b/core/element.lua index 0f3e305..a0f8727 100644 --- a/core/element.lua +++ b/core/element.lua @@ -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") diff --git a/core/events.lua b/core/events.lua index 221687c..903d006 100644 --- a/core/events.lua +++ b/core/events.lua @@ -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 diff --git a/core/input.d.ts b/core/input.d.ts deleted file mode 100644 index 081eb1d..0000000 --- a/core/input.d.ts +++ /dev/null @@ -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; \ No newline at end of file diff --git a/core/input.lua b/core/input.lua index 3d884d0..086f8d7 100644 --- a/core/input.lua +++ b/core/input.lua @@ -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") diff --git a/core/scene.lua b/core/scene.lua index aebdc07..c72c5b2 100644 --- a/core/scene.lua +++ b/core/scene.lua @@ -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') diff --git a/core/stack.lua b/core/stack.lua index 57b2732..e882255 100644 --- a/core/stack.lua +++ b/core/stack.lua @@ -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') diff --git a/dummy.lua b/dummy.lua index 13e4e72..72fb6e4 100644 --- a/dummy.lua +++ b/dummy.lua @@ -1,2 +1,2 @@ ---thicc +--thicc return {} \ No newline at end of file diff --git a/init.d.ts b/init.d.ts deleted file mode 100644 index 0d3646a..0000000 --- a/init.d.ts +++ /dev/null @@ -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(chunk:(params:T,state:state,view:view)=>()=>void):(params:T, w:number, h:number)=>HeliumElement; diff --git a/init.lua b/init.lua index 48814f0..6902942 100644 --- a/init.lua +++ b/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 diff --git a/loader.lua b/loader.lua deleted file mode 100644 index 75d0b26..0000000 --- a/loader.lua +++ /dev/null @@ -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 \ No newline at end of file diff --git a/utils.lua b/utils.lua deleted file mode 100644 index 7a25fce..0000000 --- a/utils.lua +++ /dev/null @@ -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 \ No newline at end of file