@@ -2,7 +2,7 @@ import wasmFile from 'wasmoon/dist/glue.wasm';
2
2
import { LuaFactory , LuaMultiReturn } from 'wasmoon'
3
3
import { editor } from 'monaco-editor'
4
4
import gly from '@gamely/core-native-html5'
5
- import gly_engine from '@gamely/gly-engine/dist/main.lua'
5
+ import gly_engine from '@gamely/gly-engine-lite /dist/main.lua'
6
6
import defaultScript from './default.lua'
7
7
8
8
let monacoTimeout ;
@@ -30,11 +30,6 @@ document.addEventListener('DOMContentLoaded', async () => {
30
30
const lua = await factory . createEngine ( )
31
31
await lua . doString ( gly_engine )
32
32
33
- gly . global . set ( 'native_callback_init' , lua . global . get ( 'native_callback_init' ) )
34
- gly . global . set ( 'native_callback_loop' , lua . global . get ( 'native_callback_loop' ) )
35
- gly . global . set ( 'native_callback_draw' , lua . global . get ( 'native_callback_draw' ) )
36
- gly . global . set ( 'native_callback_resize' , lua . global . get ( 'native_callback_resize' ) )
37
- gly . global . set ( 'native_callback_keyboard' , lua . global . get ( 'native_callback_keyboard' ) )
38
33
lua . global . set ( 'native_draw_start' , gly . global . get ( 'native_draw_start' ) )
39
34
lua . global . set ( 'native_draw_flush' , gly . global . get ( 'native_draw_flush' ) )
40
35
lua . global . set ( 'native_draw_clear' , gly . global . get ( 'native_draw_clear' ) )
@@ -46,19 +41,30 @@ document.addEventListener('DOMContentLoaded', async () => {
46
41
lua . global . set ( 'native_dict_http' , gly . global . get ( 'native_dict_http' ) )
47
42
lua . global . set ( 'native_dict_json' , gly . global . get ( 'native_dict_json' ) )
48
43
lua . global . set ( 'native_dict_poly' , gly . global . get ( 'native_dict_poly' ) )
49
- lua . global . set ( 'native_draw_text' , ( x , y , text ) => {
50
- const native_draw_text = gly . global . get ( 'native_draw_text' )
44
+ lua . global . set ( 'native_text_print' , gly . global . get ( 'native_text_print' ) )
45
+ lua . global . set ( 'native_text_font_size' , gly . global . get ( 'native_text_font_size' ) )
46
+ lua . global . set ( 'native_text_font_name' , gly . global . get ( 'native_text_font_name' ) )
47
+ lua . global . set ( 'native_text_font_default' , gly . global . get ( 'native_text_font_default' ) )
48
+ lua . global . set ( 'native_text_font_previous' , gly . global . get ( 'native_text_font_previous' ) )
49
+ lua . global . set ( 'native_text_mensure' , ( x , y , text ) => {
50
+ const native_draw_text = gly . global . get ( 'native_text_mensure' )
51
51
return LuaMultiReturn . from ( native_draw_text ( x , y , text ) )
52
52
} )
53
53
54
+ await lua . doString ( gly_engine )
55
+
56
+ gly . global . set ( 'native_callback_init' , lua . global . get ( 'native_callback_init' ) )
57
+ gly . global . set ( 'native_callback_loop' , lua . global . get ( 'native_callback_loop' ) )
58
+ gly . global . set ( 'native_callback_draw' , lua . global . get ( 'native_callback_draw' ) )
59
+ gly . global . set ( 'native_callback_resize' , lua . global . get ( 'native_callback_resize' ) )
60
+
54
61
gly . error ( 'canvas' )
55
- gly . init ( '#gameCanvas' )
62
+ gly . init ( elCanvas )
56
63
57
64
const apply = ( ) => {
58
65
const code = monacoEditor . getValue ( )
59
- gly . load ( `return {draw=function(std)\nprint('oi')\n${ code } \nend}` )
60
- elCanvas . width = elInpWidth . value ;
61
- elCanvas . height = elInpHeight . value ;
66
+ gly . load ( `return {init=function()end,loop=function()end,draw=function(std)\n${ code } \nend}` )
67
+ gly . resize ( elInpWidth . value , elInpHeight . value )
62
68
window . requestAnimationFrame ( gly . update )
63
69
}
64
70
0 commit comments