Skip to content

Commit c9902a6

Browse files
feat: revision 0.0.11 (#115)
* feat: add core none * feat: add core lite * feat: add core html5_lite * fix: pause in core-native-html5 * ci: add linter to `cli` * ci: add linter to `lite` * ci: add linter to `repl` * style: refact build * fix: support cli in windows * docs: add topic languages
1 parent 4ade7de commit c9902a6

36 files changed

+735
-207
lines changed

Diff for: .github/workflows/CI.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
4141
4242
version:
43-
if: github.event_name == 'push'
43+
if: github.event_name == 'push' || github.event.pull_request.draft == false
4444
name: test version
4545
runs-on: ubuntu-latest
4646
steps:
@@ -60,7 +60,7 @@ jobs:
6060
strategy:
6161
fail-fast: false
6262
matrix:
63-
core: ['native', 'love']
63+
core: ['cli', 'repl', 'lite', 'native', 'love']
6464
steps:
6565
-
6666
uses: actions/checkout@master

Diff for: .luaurc

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"arg",
77
"bit",
88
"Buffer",
9+
"BOOTSTRAP",
10+
"BOOTSTRAP_DIRS",
11+
"BOOTSTRAP_LIST",
912
"canvas",
1013
"event",
1114
"io",
@@ -14,6 +17,8 @@
1417
"load",
1518
"loadfile",
1619
"love",
20+
"mock_separator",
21+
"native_dict_secret",
1722
"native_dict_game",
1823
"native_dict_http",
1924
"native_dict_json",
@@ -29,6 +34,7 @@
2934
"native_draw_start",
3035
"native_draw_text_tui",
3136
"native_draw_text",
32-
"native_get_system_lang"
37+
"native_get_system_lang",
38+
"package"
3339
]
3440
}

Diff for: Doxyfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Custom Configs
22
DOXYFILE_ENCODING = UTF-8
33
PROJECT_NAME = "Gly Game Engine"
4-
PROJECT_NUMBER = 0.0.10
4+
PROJECT_NUMBER = 0.0.11
55
PROJECT_BRIEF = "Game engine in lua"
66
PROJECT_LOGO = assets/icon80x80.png
77
GENERATE_RTF = NO

Diff for: docs/lang_esc_g.txt

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@defgroup Languages
2+
@{
3+
4+
@defgroup lang_esc_g ESC G
5+
@{
6+
7+
@par Backus–Naur Form
8+
@startebnf
9+
protocol_esc_g = esc, "G", command (* 7 bits *), size (* MSB command\ndefines x1024 *), [ buffer ], checksum (* DJB2 *);
10+
esc = "\x1b";
11+
command = byte;
12+
size = byte;
13+
buffer = 4 * byte | 1024 * byte;
14+
checksum = 4 * byte;
15+
@endebnf
16+
17+
@par Commands
18+
19+
| | command name | parameters | sizes in bytes|
20+
| :-: | :------------- | :-------------- | :------------ |
21+
| 0 | hello | | 0 |
22+
| 1 | hdmi cec | command | 4..20 |
23+
| 2 | press menu key | | 0 |
24+
| 3 | gamepad update | z,x,c,v,w,a,s,d | 8 |
25+
| 44 | set img index | index,type,w,h | 4 or 8 |
26+
| 45 | update image | image | 0..254000 |
27+
| 46 | set text index | index | 4 |
28+
| 47 | update text | text | 0..254000 |
29+
| 48 | draw mode | m1, m2, s1, s2 | 4 |
30+
| 49 | draw color | r, g, b, a | 4 |
31+
| 50 | draw rect | x, y, w, h | 4, 8 or 16 |
32+
| 51 | draw line | x1, y1, x2, y2 | 4, 8 or 16 |
33+
| 52 | draw text | x, y, id, size | 4 |
34+
| 52 | draw image | x, y, id | 4 |
35+
| 64..127 | custom | | 0..254000 |
36+
37+
@par Modes
38+
39+
@li @b 0 tint fill
40+
@li @b 1 tint frame
41+
@li @b 2 tint open
42+
@li @b 4 tint save
43+
@li @b 5 erase fill
44+
@li @b 6 erase frame
45+
@li @b 7 erase open
46+
47+
@par Image Types
48+
49+
@li @b 0 RGB 15bits
50+
@li @b 1 RGBA 32bits
51+
@li @b 2 BMP
52+
@li @b 3 PNG
53+
54+
@par Examples
55+
56+
@li @c std.draw.clear(0xAABBCCDD) @n ESC G 0x48 0x00000003 0x00000000 @n ESC G 0x49 0x01 0xAABBCCDD 0x00000000 @n ESC G 0x50 0x01 0x0000FFFFF 0x00000000
57+
58+
@}
59+
@}

Diff for: ee/engine/core/ginga/main.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local zeebo_module = require('src/lib/engine/raw/module')
1+
local zeebo_module = require('src/lib/common/module')
22
--
33
local core_draw = require('ee/engine/core/ginga/draw')
44
local core_keys = require('ee/engine/core/ginga/keys')

Diff for: src/cli/commands/build.lua

+47-20
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,40 @@ local zeebo_bundler = require('src/lib/cli/bundler')
33
local zeebo_builder = require('src/lib/cli/builder')
44
local zeebo_meta = require('src/lib/cli/meta')
55
local zeebo_fs = require('src/lib/cli/fs')
6+
local util_fs = require('src/lib/util/fs')
67

78
local function build(args)
89
local bundler = ''
910
local screen = args.screen
10-
local dist = args.dist
11+
local dist = util_fs.path(args.dist).get_unix_path()
1112

1213
local core_list = {
14+
none = {
15+
16+
},
1317
repl={
14-
src='src/engine/core/repl/main.lua',
18+
src='src/engine/core/repl',
1519
post_exe='lua dist/main.lua'
1620
},
1721
love={
18-
src='src/engine/core/love/main.lua',
22+
src='src/engine/core/love',
1923
post_exe='love dist -'..'-screen '..screen
2024
},
2125
ginga={
22-
src='ee/engine/core/ginga/main.lua',
26+
src='ee/engine/core/ginga',
2327
post_exe='ginga dist/main.ncl -s '..screen,
2428
extras={
2529
'ee/engine/meta/ginga/main.ncl'
2630
}
2731
},
32+
lite={
33+
src='src/engine/core/lite',
34+
},
2835
native={
29-
src='src/engine/core/native/main.lua',
36+
src='src/engine/core/native',
3037
},
3138
html5_webos={
32-
src='src/engine/core/native/main.lua',
39+
src='src/engine/core/native',
3340
post_exe='webos24 $(pwd)/dist',
3441
pipeline={
3542
zeebo_meta.late(dist..'game.lua'):file(dist..'index.html'):file(dist..'appinfo.json'):pipe()
@@ -44,7 +51,7 @@ local function build(args)
4451
}
4552
},
4653
html5_tizen={
47-
src='src/engine/core/native/main.lua',
54+
src='src/engine/core/native',
4855
pipeline={
4956
zeebo_meta.late(dist..'game.lua'):file(dist..'index.html'):file(dist..'config.xml'):pipe(),
5057
function() os.execute('cd '..dist..';~/tizen-studio/tools/ide/bin/tizen.sh package -t wgt;true') end
@@ -59,8 +66,19 @@ local function build(args)
5966
'assets/icon80x80.png'
6067
}
6168
},
69+
html5_lite={
70+
src='src/engine/core/lite',
71+
pipeline={
72+
zeebo_meta.late(dist..'game.lua'):file(dist..'index.html'):pipe()
73+
},
74+
extras={
75+
'src/engine/core/html5/index.html',
76+
'src/engine/core/html5/driver-wasmoon.js',
77+
'src/engine/core/html5/core-native-html5.js'
78+
}
79+
},
6280
html5={
63-
src='src/engine/core/native/main.lua',
81+
src='src/engine/core/native',
6482
pipeline={
6583
zeebo_meta.late(dist..'game.lua'):file(dist..'index.html'):pipe()
6684
},
@@ -73,7 +91,7 @@ local function build(args)
7391
}
7492

7593
-- clean dist
76-
zeebo_fs.clear(args.dist)
94+
zeebo_fs.clear(dist)
7795

7896
-- check core
7997
if not core_list[args.core] then
@@ -93,27 +111,36 @@ local function build(args)
93111

94112
-- move game
95113
if args.game then
96-
local dir, file = args.game:match("(.*/)([^/]+)$")
97-
zeebo_bundler.build(dir, file, dist..'game.lua')
114+
local game = util_fs.file(args.game)
115+
zeebo_builder.build(game.get_unix_path(), game.get_file(), dist..bundler, 'game.lua', 'game_')
98116
end
99117

100118
-- core move
101-
local index = 1
102119
local core = core_list[args.core]
103-
zeebo_builder.build(core.src, dist..bundler)
104-
if core.extras then
105-
while index <= #core.extras do
106-
local file = core.extras[index]
107-
zeebo_fs.move(file, dist..file:gsub('.*/', ''))
108-
index = index + 1
120+
do
121+
local index = 1
122+
if core.src then
123+
zeebo_builder.build(core.src, 'main.lua', dist..bundler, 'main.lua', 'core_')
124+
end
125+
if core.extras then
126+
while index <= #core.extras do
127+
local file = core.extras[index]
128+
zeebo_fs.move(file, dist..file:gsub('.*/', ''))
129+
index = index + 1
130+
end
109131
end
110132
end
111133

112134
-- combine files
113135
if #bundler > 0 then
114-
zeebo_bundler.build(dist..bundler, 'main.lua', dist..'main.lua')
136+
if core.src then
137+
zeebo_bundler.build(dist..bundler, 'main.lua', dist..'main.lua')
138+
end
139+
if args.game then
140+
zeebo_bundler.build(dist..bundler, 'game.lua', dist..'game.lua')
141+
end
115142
zeebo_fs.clear(dist..bundler)
116-
os.remove(dist..bundler)
143+
zeebo_fs.rmdir(dist..bundler)
117144
end
118145

119146
-- post process

Diff for: src/cli/commands/cli.lua

+3-9
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,14 @@ local function cli_build(args)
2929
return ok, message
3030
end
3131

32-
local function cli_dump(args)
33-
return zeebo_bootstrap.dump(dist)
34-
end
35-
36-
local function cli_init(args)
37-
local project_name = args[1] or 'my_project'
38-
init.init_project(project_name)
32+
local function cli_dump()
33+
return zeebo_bootstrap.dump()
3934
end
4035

4136
local P = {
4237
['cli-build'] = cli_build,
4338
['cli-test'] = cli_test,
44-
['cli-dump'] = cli_dump,
45-
['cli-init'] = cli_init
39+
['cli-dump'] = cli_dump
4640
}
4741

4842
return P

Diff for: src/cli/commands/fs.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ local function vim_xxd_i(args)
4242
end
4343
end
4444

45-
local content, length, column = '', 0, 0
45+
local length, column = 0, 0
4646
local const = args.const and 'const ' or ''
4747
local var_name = args.name or args.file:gsub('[%._/]', '_'):gsub("__+", "_"):gsub('^_', '')
4848

Diff for: src/cli/commands/info.lua

+1-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ local help_message = "Available commands:\n"
4343
.."- To run a game: ./cli.sh run ./examples/asteroids/game.lua " .. "-" .. "-core repl\n"
4444
.."- To display metadata: ./cli.sh meta ./examples/asteroids/game.lua\n"
4545

46-
local version_message = '0.0.10'
46+
local version_message = '0.0.11'
4747

4848
local function help()
4949
return true, help_message
@@ -53,11 +53,6 @@ local function version()
5353
return true, version_message
5454
end
5555

56-
--! @todo show all commands with complete flags
57-
local function show(args)
58-
return false, 'not implemented!'
59-
end
60-
6156
local function meta()
6257
local description = 'not implemented!'
6358
return {

Diff for: src/cli/commands/init.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
local os = require('os')
2+
local util_cmd = require('src/lib/util/cmd')
3+
24
local ok = true
35

46
local function create_file(filepath, content)
@@ -13,7 +15,7 @@ local function create_file(filepath, content)
1315
end
1416

1517
local function create_directory(path)
16-
local success = os.execute("mkdir " .. path)
18+
local success = os.execute(util_cmd.mkdir()..path)
1719
if not success then
1820
print("Error while creating directory: " .. path)
1921
ok = false
@@ -23,7 +25,7 @@ end
2325
local function init_project(args)
2426
local project_name = args.project
2527
local project_template = args.template
26-
local project_gamefile, error_gamefile = io.open(project_template, 'r')
28+
local project_gamefile = io.open(project_template, 'r')
2729

2830
ok = true
2931

Diff for: src/cli/commands/tools.lua

+18-10
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,33 @@ local zeebo_bundler = require('src/lib/cli/bundler')
33
local zeebo_package = require('src/lib/cli/package')
44
local zeebo_filler = require('src/lib/cli/filler')
55
local zeebo_fs = require('src/lib/cli/fs')
6+
local util_fs = require('src/lib/util/fs')
7+
local util_cmd = require('src/lib/util/cmd')
68

79
local function bundler(args)
8-
local path, file = args.file:match("(.-)([^/\\]+)$")
9-
return zeebo_bundler.build(path, file, args.dist..file)
10+
local d = util_fs.path(args.dist)
11+
local f = util_fs.file(args.file)
12+
zeebo_fs.clear(d.get_fullfilepath())
13+
return zeebo_bundler.build(f.get_sys_path(), f.get_file(), d.get_sys_path()..f.get_file())
1014
end
1115

1216
local function compiler(args)
13-
return zeebo_compiler.build(args.file, args.dist)
17+
local file = util_fs.file(args.file).get_fullfilepath()
18+
local dist = util_fs.file(args.dist).get_fullfilepath()
19+
return zeebo_compiler.build(file, dist)
1420
end
1521

1622
local function love_zip(args)
17-
os.execute('mkdir -p '..args.dist..'_love')
18-
os.execute('mv '..args.path..'/* '..args.dist..'_love 2> /dev/null')
19-
local zip_pid = io.popen('cd '..args.dist..'_love && zip -9 -r Game.love .')
23+
local dist = util_fs.path(args.dist).get_fullfilepath()
24+
local path = util_fs.path(args.path).get_fullfilepath()
25+
os.execute(util_cmd.mkdir()..dist..'_love')
26+
os.execute(util_cmd.move()..path..'* '..dist..'_love'..util_cmd.silent())
27+
local zip_pid = io.popen('cd '..dist..'_love && zip -9 -r Game.love .')
2028
local stdout = zip_pid:read('*a')
21-
local ok = zip_pid:close()
22-
zeebo_fs.move(args.dist..'_love/Game.love', args.dist..'Game.love')
23-
zeebo_fs.clear(args.dist..'_love')
24-
os.remove(args.dist..'_love')
29+
local ok = zip_pid:close()
30+
zeebo_fs.move(dist..'_love/Game.love', dist..'Game.love')
31+
zeebo_fs.clear(dist..'_love')
32+
os.remove(dist..'_love')
2533
return ok, stdout
2634
end
2735

0 commit comments

Comments
 (0)