@gamely/gly-engine-nano 0.3.0 → 0.3.2

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 +46 -87
  2. package/package.json +1 -1
package/dist/main.lua CHANGED
@@ -1,19 +1,19 @@
1
- local bc9d = {0,0,0,0,0,0,0,0}
2
- local rc9d = function(i, f)
1
+ local bc3c = {0,0,0,0,0,0,0}
2
+ local rc3c = function(i, f)
3
3
  return function()
4
4
  local c = f()
5
- bc9d[i] = function() return c end
5
+ bc3c[i] = function() return c end
6
6
  return c
7
7
  end
8
8
  end
9
- local function mc9d()
10
- local version = bc9d[1]('source_version')
11
- local engine_key = bc9d[2]('source_engine_api_system_key')
12
- local engine_api_draw_text = bc9d[3]('source_engine_api_draw_text')
13
- local engine_api_draw_poly = bc9d[4]('source_engine_api_draw_poly')
14
- local color = bc9d[5]('source_engine_api_system_color')
15
- local std = bc9d[6]('source_shared_var_object_std')
16
- local eval_code = bc9d[7]('source_shared_string_eval_code')
9
+ local function mc3c()
10
+ local version = bc3c[1]('source_version')
11
+ local engine_key = bc3c[2]('source_engine_api_system_key')
12
+ local engine_api_draw_text = bc3c[3]('source_engine_api_draw_text')
13
+ local engine_api_draw_poly = bc3c[4]('source_engine_api_draw_poly')
14
+ local color = bc3c[5]('source_engine_api_system_color')
15
+ local std = bc3c[6]('source_shared_var_object_std')
16
+ local eval_code = bc3c[7]('source_shared_string_eval_code')
17
17
  local f=function(a,b)end
18
18
  local engine={keyboard=f}
19
19
  local application={
@@ -115,13 +115,18 @@ version=version
115
115
  }
116
116
  return P
117
117
  end
118
- bc9d[1] = rc9d(1, function()
119
- return '0.3.0'
118
+ bc3c[1] = rc3c(1, function()
119
+ return '0.3.2'
120
120
  end)
121
- bc9d[2] = rc9d(2, function()
121
+ bc3c[2] = rc3c(2, function()
122
122
  local function real_key(std, engine, rkey, rvalue)
123
- local value = rvalue == 1 or rvalue == true
123
+ local value = (rvalue == 1 or rvalue == true) or false
124
124
  local key = engine.key_bindings[rkey] or (std.key.axis[rkey] and rkey)
125
+ local key_media = std.key.media and std.key.media[rkey] ~= nil and rkey
126
+ if key_media then
127
+ std.key.media[key_media] = value
128
+ std.bus.emit('key_media')
129
+ end
125
130
  if key then
126
131
  std.key.axis[key] = value and 1 or 0
127
132
  std.key.press[key] = value
@@ -142,21 +147,29 @@ end
142
147
  local function real_keyup(std, engine, key)
143
148
  real_key(std, engine, key, 0)
144
149
  end
145
- local function install(std, engine, key_bindings)
146
- engine.key_bindings = key_bindings or {}
150
+ local function install(std, engine, config)
151
+ config = config or {}
152
+ engine.key_bindings = config.bindings or {}
147
153
  engine.keyboard = real_key
154
+ if config.has_media then
155
+ std.key.media = {
156
+ ch_up = false,
157
+ ch_down = false,
158
+ vol_up = false,
159
+ vol_down = false
160
+ }
161
+ end
148
162
  std.bus.listen_std_engine('rkey', real_key)
149
163
  std.bus.listen_std_engine('rkey1', real_keydown)
150
164
  std.bus.listen_std_engine('rkey0', real_keyup)
151
165
  end
152
- local P = {
166
+ return {
153
167
  install = install
154
168
  }
155
- return P
156
169
  end)
157
- bc9d[3] = rc9d(3, function()
158
- local util_decorator = bc9d[8]('source_shared_functional_decorator')
159
- local function text_put(std, engine, font_previous, pos_x, pos_y, text, size)
170
+ bc3c[3] = rc3c(3, function()
171
+ local function text_put(std, engine, font_previous)
172
+ return function(pos_x, pos_y, text, size)
160
173
  size = size or 2
161
174
  local hem = engine.current.data.width / 80
162
175
  local vem = engine.current.data.height / 24
@@ -166,24 +179,27 @@ std.text.font_size(font_size)
166
179
  std.text.print(pos_x * hem, pos_y * vem, text)
167
180
  font_previous()
168
181
  end
169
- local function text_print_ex(std, engine, x, y, text, align_x, align_y)
182
+ end
183
+ local function text_print_ex(std, engine)
184
+ return function(x, y, text, align_x, align_y)
170
185
  local w, h = std.text.mensure(text)
171
186
  local aligns_x, aligns_y = {w, w/2, 0}, {h, h/2, 0}
172
187
  std.text.print(x - aligns_x[(align_x or 1) + 2], y - aligns_y[(align_y or 1) + 2], text)
173
188
  return w, h
174
189
  end
190
+ end
175
191
  local function install(std, engine, config)
176
192
  std.text.font_previous = config.font_previous
177
193
  std.text.is_tui = config.is_tui or function() return false end
178
- std.text.print_ex = util_decorator.prefix2(std, engine, text_print_ex)
179
- std.text.put = util_decorator.prefix3(std, engine, config.font_previous, text_put)
194
+ std.text.print_ex = text_print_ex(std, engine)
195
+ std.text.put = text_put(std, engine, config.font_previous)
180
196
  end
181
197
  local P = {
182
198
  install=install
183
199
  }
184
200
  return P
185
201
  end)
186
- bc9d[4] = rc9d(4, function()
202
+ bc3c[4] = rc3c(4, function()
187
203
  local function decorator_poo(object, func)
188
204
  if not object or not func then return func end
189
205
  return function(a, b, c, d)
@@ -289,7 +305,7 @@ install=install
289
305
  }
290
306
  return P
291
307
  end)
292
- bc9d[5] = rc9d(5, function()
308
+ bc3c[5] = rc3c(5, function()
293
309
  local function install(std)
294
310
  std.color = std.color or {}
295
311
  std.color.white = 0xFFFFFFFF
@@ -323,7 +339,7 @@ install = install
323
339
  }
324
340
  return P
325
341
  end)
326
- bc9d[6] = rc9d(6, function()
342
+ bc3c[6] = rc3c(6, function()
327
343
  local P = {
328
344
  milis = 0,
329
345
  delta = 0,
@@ -390,7 +406,7 @@ any=false
390
406
  }
391
407
  return P;
392
408
  end)
393
- bc9d[7] = rc9d(7, function()
409
+ bc3c[7] = rc3c(7, function()
394
410
  local function script(src)
395
411
  local loader = loadstring or load
396
412
  if not loader then
@@ -410,61 +426,4 @@ script = script,
410
426
  }
411
427
  return P
412
428
  end)
413
- bc9d[8] = rc9d(8, function()
414
- local function decorator_prefix3(zig, zag, zom, func)
415
- return function (a, b, c, d, e, f)
416
- return func(zig, zag, zom, a, b, c, d, e, f)
417
- end
418
- end
419
- local function decorator_prefix2(zig, zag, func)
420
- return function (a, b, c, d, e, f)
421
- return func(zig, zag, a, b, c, d, e, f)
422
- end
423
- end
424
- local function decorator_prefix1(zig, func)
425
- return function (a, b, c, d, e, f)
426
- return func(zig, a, b, c, d, e, f)
427
- end
428
- end
429
- local function decorator_offset_xy2(object, func)
430
- return function(a, b, c, d, e, f)
431
- local x = object.offset_x + (b or 0)
432
- local y = object.offset_y + (c or 0)
433
- return func(a, x, y, d, e, f)
434
- end
435
- end
436
- local function decorator_offset_xyxy1(object, func)
437
- return function(a, b, c, d, e, f)
438
- local x1 = object.offset_x + a
439
- local y1 = object.offset_y + b
440
- local x2 = object.offset_x + c
441
- local y2 = object.offset_y + d
442
- return func(x1, y1, x2, y2, e, f)
443
- end
444
- end
445
- local function decorator_offset_xy1(object, func)
446
- return function(a, b, c, d, e, f)
447
- local x = object.offset_x + a
448
- local y = object.offset_y + b
449
- return func(x, y, c, d, e, f)
450
- end
451
- end
452
- local function table_prefix1(prefix, fn_table)
453
- local new_table = {}
454
- for name, fn in pairs(fn_table) do
455
- new_table[name] = decorator_prefix1(prefix, fn)
456
- end
457
- return new_table
458
- end
459
- local P = {
460
- offset_xy1 = decorator_offset_xy1,
461
- offset_xy2 = decorator_offset_xy2,
462
- offset_xyxy1 = decorator_offset_xyxy1,
463
- prefix3 = decorator_prefix3,
464
- prefix2 = decorator_prefix2,
465
- prefix1 = decorator_prefix1,
466
- prefix1_t = table_prefix1
467
- }
468
- return P
469
- end)
470
- return mc9d()
429
+ return mc3c()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamely/gly-engine-nano",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "author": "RodrigoDornelles",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.gamely.com.br",