Skip to content

Commit

Permalink
feat: add core html5_webos and cmd meta (#17)
Browse files Browse the repository at this point in the history
* chore: optmize std.math.max
* feat: std.math.min
* feat: std.math.dis2
* fix: correction in fps_show ginga
* chore: rename core ginga_html5 to html5_ginga #15
* docs: upgrade plataform support list
* feat: add core htm5_webos #15
* feat: add command meta
* chore: small improves in repo
* docs: std math
* docs: move Plataform Support to README.md
  • Loading branch information
RodrigoDornelles authored Jul 18, 2024
1 parent 1adfd78 commit 9af3e6e
Show file tree
Hide file tree
Showing 13 changed files with 365 additions and 64 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.html linguist-generated
*.css linguist-generated
*.sh linguist-generated
*.bat linguist-generated
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ luacov.*
vendor/
dist/
html/
latex/
latex/
.out
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,26 @@ Need a web server to work, use live server in your vscode for development and gi
$ ./cli.sh build ./examples/asteroids/game.lua --core html5
```

Platform Support List
=====================

| core | tier | native | plataform |
| :------------- | :----: | :----: | --------: |
| ginga | tier 1 | yes | TV |
| love | tier 1 | no | Library |
| repl | tier 1 | yes | PC |
| curses | tier ? | yes | PC |
| html5 | tier 2 | no | Browser |
| html5_webos | tier 2 | no | TV |
| html5_tizen | tier 2 | no | TV |
| html5_ginga | tier ? | no | TV |
| esp32 | tier ? | yes | Embed |
| roblox | tier ? | no | Game |
| arkos | tier ? | yes | Console |
| odroid | tier ? | yes | Console |
| raylib | tier ? | no | Library |
| Nintendo GBA | tier ? | yes | Console |
| Nintendo WII | tier ? | yes | Console |

---
This game engine is **open source** and **free** for all uses, focusing on promoting content for our **commercial platform**.
27 changes: 0 additions & 27 deletions SUPPORT.md

This file was deleted.

44 changes: 41 additions & 3 deletions src/cli/main.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local os = require('os')
local zeebo_args = require('src/shared/args')
local zeebo_meta = require('src/cli/meta')
local zeebo_fs = require('src/cli/fs')

--! @cond
Expand Down Expand Up @@ -30,18 +31,38 @@ local core_list = {
'src/lib/ginga/main.ncl'
}
},
ginga_html5={
html5_webos={
src='src/lib/html5/main.lua',
post_exe='webos24 $(pwd)/dist',
pipeline={
zeebo_meta.late(game):file(dist..'index.html'):file(dist..'appinfo.json'):pipe()
},
extras={
'src/lib/html5_webos/appinfo.json',
'src/lib/html5_webos/icon.png',
'src/lib/html5/index.html',
'src/lib/html5/index.html',
'src/lib/html5/engine.js',
}
},
html5_ginga={
src='src/lib/html5/main.lua',
post_exe='ginga dist/main.ncl -s '..screen,
pipeline={
zeebo_meta.late(game):file(dist..'index.html'):pipe()
},
extras={
'src/lib/ginga_html5/main.ncl',
'src/lib/html5_ginga/main.ncl',
'src/lib/html5/index.html',
'src/lib/html5/index.html',
'src/lib/html5/engine.js',
}
},
html5={
src='src/lib/html5/main.lua',
pipeline={
zeebo_meta.late(game):file(dist..'index.html'):pipe()
},
extras={
'src/lib/html5/index.html',
'src/lib/html5/engine.js'
Expand All @@ -57,6 +78,11 @@ if command == 'run' then
os.exit(os.execute(core_list[core].exe) and 0 or 1)
elseif command == 'clear' then
zeebo_fs.clear(dist)
elseif command == 'meta' then
if core == 'ginga' then
core = '{{title}} {{version}}'
end
zeebo_meta.current(game):stdout(core):run()
elseif command == 'bundler' then
local path, file = game:match("(.-)([^/\\]+)$")
zeebo_fs.bundler(path, file, dist..file)
Expand Down Expand Up @@ -116,10 +142,22 @@ elseif command == 'build' then
zeebo_fs.clear(dist..bundler)
end

-- post process
if core.pipeline then
local index = 1
while index <= #core.pipeline do
local eval = core.pipeline[index]
while type(eval) == 'function' do
eval = eval()
end
index = index + 1
end
end

if run then
if not core.post_exe then
print('this core cannot be runned after build!')
exit(1)
os.exit(1)
end
os.exit(os.execute(core.post_exe) and 0 or 1)
end
Expand Down
104 changes: 104 additions & 0 deletions src/cli/meta.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
local application_default = require('src/object/application')

local function replace(src, meta, default)
if src and #src > 0 then
return (src
:gsub('{{id}}', meta.id or default.id)
:gsub('{{title}}', meta.title or default.title)
:gsub('{{company}}', meta.company or default.company)
:gsub('{{version}}', meta.version or default.version)
:gsub('{{description}}', meta.description or default.description)
)
end
return ''
end

local function file(self, file)
local file_copy = string.format("%s", file)
self.pipeline[#self.pipeline + 1] = function()
if not self.loaded then return self end

local file_meta = io.open(file_copy, 'r')
local file_temp = io.open(file_copy..'.tmp', 'w')

repeat
local line = file_meta:read()
file_temp:write(replace(line, self.meta, application_default.meta), '\n')
until not line

file_meta:close()
file_temp:close()

os.remove(file_copy)
os.rename(file_copy..'.tmp', file_copy)
end
return self
end

local function stdout(self, format)
local format_copy = string.format("%s", format)
if format_copy == 'json' then
format_copy = '{"id":"{{id}}","title":"{{title}}","company":"{{company}}",'
format_copy = format_copy..'"version":"{{version}}","description":"{{description}}"}'
end
self.pipeline[#self.pipeline + 1] = function()
if not self.loaded then return self end
print(replace(format_copy, self.meta, application_default.meta))
end
return self
end

local function pipe(self)
return function()
self:run()
end
end

local function run(self)
local index = 1
while index <= #self.pipeline do
self.pipeline[index]()
index = index + 1
end
return self
end

local function current(game, application)
local metadata = game and #game > 0 and dofile(game)

if not application then
application = {
meta = application_default.meta,
pipeline={},
file=file,
stdout=stdout,
pipe=pipe,
run=run
}
end

if metadata then
application.loaded = true
application.meta = metadata.meta
end

return application
end

local function late(game)
local game_copy = string.format("%s", game)
local application = current()
local eval = application.run
application.run = function()
current(game_copy, application)
eval(application)
end
return application
end

local P = {
current = current,
late = late
}

return P
Loading

0 comments on commit 9af3e6e

Please sign in to comment.