@gamely/gly-engine-micro 0.2.7 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.lua +72 -50
  2. package/package.json +1 -1
package/dist/main.lua CHANGED
@@ -1,26 +1,26 @@
1
- local b145d = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
2
- local r145d = function(i, f)
1
+ local b14b3 = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
2
+ local r14b3 = function(i, f)
3
3
  return function()
4
4
  local c = f()
5
- b145d[i] = function() return c end
5
+ b14b3[i] = function() return c end
6
6
  return c
7
7
  end
8
8
  end
9
9
  local math = ((function() local x, y = pcall(require, 'math'); return x and y end)()) or _G.math
10
- local function m145d()
11
- local version = b145d[1]('source_version')
12
- local engine_game = b145d[2]('source_engine_api_system_app')
13
- local engine_key = b145d[3]('source_engine_api_system_key')
14
- local engine_math = b145d[4]('source_engine_api_math_basic')
15
- local engine_math_clib = b145d[5]('source_engine_api_math_clib')
16
- local engine_math_random = b145d[6]('source_engine_api_math_random')
17
- local engine_array = b145d[7]('source_engine_api_data_array')
18
- local engine_api_draw_text = b145d[8]('source_engine_api_draw_text')
19
- local engine_api_draw_poly = b145d[9]('source_engine_api_draw_poly')
20
- local engine_raw_memory = b145d[10]('source_engine_api_raw_memory')
21
- local color = b145d[11]('source_engine_api_system_color')
22
- local std = b145d[12]('source_shared_var_object_std')
23
- local eval_code = b145d[13]('source_shared_string_eval_code')
10
+ local function m14b3()
11
+ local version = b14b3[1]('source_version')
12
+ local engine_game = b14b3[2]('source_engine_api_system_app')
13
+ local engine_key = b14b3[3]('source_engine_api_system_key')
14
+ local engine_math = b14b3[4]('source_engine_api_math_basic')
15
+ local engine_math_clib = b14b3[5]('source_engine_api_math_clib')
16
+ local engine_math_random = b14b3[6]('source_engine_api_math_random')
17
+ local engine_array = b14b3[7]('source_engine_api_data_array')
18
+ local engine_api_draw_text = b14b3[8]('source_engine_api_draw_text')
19
+ local engine_api_draw_poly = b14b3[9]('source_engine_api_draw_poly')
20
+ local engine_raw_memory = b14b3[10]('source_engine_api_raw_memory')
21
+ local color = b14b3[11]('source_engine_api_system_color')
22
+ local std = b14b3[12]('source_shared_var_object_std')
23
+ local eval_code = b14b3[13]('source_shared_string_eval_code')
24
24
  local f=function(a,b)end
25
25
  local engine={keyboard=f}
26
26
  local application={
@@ -135,29 +135,35 @@ version=version
135
135
  }
136
136
  return P
137
137
  end
138
- b145d[1] = r145d(1, function()
139
- return '0.2.7'
138
+ b14b3[1] = r14b3(1, function()
139
+ return '0.3.1'
140
140
  end)
141
- b145d[2] = r145d(2, function()
142
- local util_decorator = b145d[14]('source_shared_functional_decorator')
141
+ b14b3[2] = r14b3(2, function()
143
142
  local function reset(std, engine)
144
143
  if std.node then
144
+ return function()
145
145
  std.bus.emit('exit')
146
146
  std.bus.emit('init')
147
- else
147
+ end
148
+ end
149
+ return function()
148
150
  engine.root.callbacks.exit(engine.root.data, std)
149
151
  engine.root.callbacks.init(engine.root.data, std)
150
152
  end
151
153
  end
152
154
  local function exit(std)
155
+ return function()
153
156
  std.bus.emit('exit')
154
157
  std.bus.emit('quit')
155
158
  end
156
- local function title(func, window_name)
159
+ end
160
+ local function title(func)
161
+ return function(window_name)
157
162
  if func then
158
163
  func(window_name)
159
164
  end
160
165
  end
166
+ end
161
167
  local function install(std, engine, config)
162
168
  std = std or {}
163
169
  config = config or {}
@@ -167,9 +173,9 @@ if config.quit then
167
173
  config.quit()
168
174
  end
169
175
  end)
170
- std.app.title = util_decorator.prefix1(config.set_title, title)
171
- std.app.exit = util_decorator.prefix1(std, exit)
172
- std.app.reset = util_decorator.prefix2(std, engine, reset)
176
+ std.app.title = title(config.set_title)
177
+ std.app.exit = exit(std)
178
+ std.app.reset = reset(std, engine)
173
179
  std.app.get_fps = config.get_fps
174
180
  return std.app
175
181
  end
@@ -178,10 +184,15 @@ install=install
178
184
  }
179
185
  return P
180
186
  end)
181
- b145d[3] = r145d(3, function()
187
+ b14b3[3] = r14b3(3, function()
182
188
  local function real_key(std, engine, rkey, rvalue)
183
- local value = rvalue == 1 or rvalue == true
189
+ local value = (rvalue == 1 or rvalue == true) or false
184
190
  local key = engine.key_bindings[rkey] or (std.key.axis[rkey] and rkey)
191
+ local key_media = std.key.media and std.key.media[rkey] ~= nil and rkey
192
+ if key_media then
193
+ std.key.media[key_media] = value
194
+ std.bus.emit('key_media')
195
+ end
185
196
  if key then
186
197
  std.key.axis[key] = value and 1 or 0
187
198
  std.key.press[key] = value
@@ -202,19 +213,27 @@ end
202
213
  local function real_keyup(std, engine, key)
203
214
  real_key(std, engine, key, 0)
204
215
  end
205
- local function install(std, engine, key_bindings)
206
- engine.key_bindings = key_bindings or {}
216
+ local function install(std, engine, config)
217
+ config = config or {}
218
+ engine.key_bindings = config.bindings or {}
207
219
  engine.keyboard = real_key
220
+ if config.has_media then
221
+ std.key.media = {
222
+ ch_up = false,
223
+ ch_down = false,
224
+ vol_up = false,
225
+ vol_down = false
226
+ }
227
+ end
208
228
  std.bus.listen_std_engine('rkey', real_key)
209
229
  std.bus.listen_std_engine('rkey1', real_keydown)
210
230
  std.bus.listen_std_engine('rkey0', real_keyup)
211
231
  end
212
- local P = {
232
+ return {
213
233
  install = install
214
234
  }
215
- return P
216
235
  end)
217
- b145d[4] = r145d(4, function()
236
+ b14b3[4] = r14b3(4, function()
218
237
  local function abs(value)
219
238
  if value < 0 then
220
239
  return -value
@@ -312,7 +331,7 @@ install = install
312
331
  }
313
332
  return P
314
333
  end)
315
- b145d[5] = r145d(5, function()
334
+ b14b3[5] = r14b3(5, function()
316
335
  local function install(std)
317
336
  assert(math and (1/2 ~= 0))
318
337
  std.math = std.math or {}
@@ -347,7 +366,7 @@ install = install
347
366
  }
348
367
  return P
349
368
  end)
350
- b145d[6] = r145d(6, function()
369
+ b14b3[6] = r14b3(6, function()
351
370
  local function install(std)
352
371
  assert(math and (1/2 ~= 0))
353
372
  std.math = std.math or {}
@@ -363,8 +382,8 @@ install = install
363
382
  }
364
383
  return P
365
384
  end)
366
- b145d[7] = r145d(7, function()
367
- local util_decorator = b145d[14]('source_shared_functional_decorator')
385
+ b14b3[7] = r14b3(7, function()
386
+ local util_decorator = b14b3[15]('source_shared_functional_decorator')
368
387
  local function array_map(array, func)
369
388
  local res = {}
370
389
  local index = 1
@@ -524,9 +543,9 @@ install = install
524
543
  }
525
544
  return P
526
545
  end)
527
- b145d[8] = r145d(8, function()
528
- local util_decorator = b145d[14]('source_shared_functional_decorator')
529
- local function text_put(std, engine, font_previous, pos_x, pos_y, text, size)
546
+ b14b3[8] = r14b3(8, function()
547
+ local function text_put(std, engine, font_previous)
548
+ return function(pos_x, pos_y, text, size)
530
549
  size = size or 2
531
550
  local hem = engine.current.data.width / 80
532
551
  local vem = engine.current.data.height / 24
@@ -536,24 +555,27 @@ std.text.font_size(font_size)
536
555
  std.text.print(pos_x * hem, pos_y * vem, text)
537
556
  font_previous()
538
557
  end
539
- local function text_print_ex(std, engine, x, y, text, align_x, align_y)
558
+ end
559
+ local function text_print_ex(std, engine)
560
+ return function(x, y, text, align_x, align_y)
540
561
  local w, h = std.text.mensure(text)
541
562
  local aligns_x, aligns_y = {w, w/2, 0}, {h, h/2, 0}
542
563
  std.text.print(x - aligns_x[(align_x or 1) + 2], y - aligns_y[(align_y or 1) + 2], text)
543
564
  return w, h
544
565
  end
566
+ end
545
567
  local function install(std, engine, config)
546
568
  std.text.font_previous = config.font_previous
547
569
  std.text.is_tui = config.is_tui or function() return false end
548
- std.text.print_ex = util_decorator.prefix2(std, engine, text_print_ex)
549
- std.text.put = util_decorator.prefix3(std, engine, config.font_previous, text_put)
570
+ std.text.print_ex = text_print_ex(std, engine)
571
+ std.text.put = text_put(std, engine, config.font_previous)
550
572
  end
551
573
  local P = {
552
574
  install=install
553
575
  }
554
576
  return P
555
577
  end)
556
- b145d[9] = r145d(9, function()
578
+ b14b3[9] = r14b3(9, function()
557
579
  local function decorator_poo(object, func)
558
580
  if not object or not func then return func end
559
581
  return function(a, b, c, d)
@@ -659,7 +681,7 @@ install=install
659
681
  }
660
682
  return P
661
683
  end)
662
- b145d[10] = r145d(10, function()
684
+ b14b3[10] = r14b3(10, function()
663
685
  local memory_dict_unload = {}
664
686
  local memory_dict = {}
665
687
  local memory_list = {}
@@ -713,7 +735,7 @@ install=install
713
735
  }
714
736
  return P
715
737
  end)
716
- b145d[11] = r145d(11, function()
738
+ b14b3[11] = r14b3(11, function()
717
739
  local function install(std)
718
740
  std.color = std.color or {}
719
741
  std.color.white = 0xFFFFFFFF
@@ -747,7 +769,7 @@ install = install
747
769
  }
748
770
  return P
749
771
  end)
750
- b145d[12] = r145d(12, function()
772
+ b14b3[12] = r14b3(12, function()
751
773
  local P = {
752
774
  milis = 0,
753
775
  delta = 0,
@@ -814,7 +836,7 @@ any=false
814
836
  }
815
837
  return P;
816
838
  end)
817
- b145d[13] = r145d(13, function()
839
+ b14b3[13] = r14b3(13, function()
818
840
  local function script(src)
819
841
  local loader = loadstring or load
820
842
  if not loader then
@@ -834,7 +856,7 @@ script = script,
834
856
  }
835
857
  return P
836
858
  end)
837
- b145d[14] = r145d(14, function()
859
+ b14b3[15] = r14b3(15, function()
838
860
  local function decorator_prefix3(zig, zag, zom, func)
839
861
  return function (a, b, c, d, e, f)
840
862
  return func(zig, zag, zom, a, b, c, d, e, f)
@@ -891,4 +913,4 @@ prefix1_t = table_prefix1
891
913
  }
892
914
  return P
893
915
  end)
894
- return m145d()
916
+ return m14b3()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamely/gly-engine-micro",
3
- "version": "0.2.7",
3
+ "version": "0.3.1",
4
4
  "author": "RodrigoDornelles",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.gamely.com.br",