line-em-up 2.0.0 → 2.0.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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/vendors/lib/luit.rb +481 -0
  3. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7ab411416d21726d2c0e5bbc52b6432a765c3b3
4
- data.tar.gz: 9d63371403a4bc9b12a192891d7ec4cc80d2f3d7
3
+ metadata.gz: ab8a2b6f72c019ac45a4df38b4e56c2239646c04
4
+ data.tar.gz: cae5d31fd414ddb83898588a948c4e520a14ff0b
5
5
  SHA512:
6
- metadata.gz: 3d71a41dadf48523a227b964ce971459c7517382fc3ba2d57a96676fbba26b7280c8f6de461aa9ff74bb3967a9db85fd6c4b32cbce2cc70cc10c0234d66af82f
7
- data.tar.gz: e7a0965624b497028586b7c383c0f22b446f9030abd77ee833dd770d0f4877f9d4ee57759bbabb8f63f7403da87e495d8643c3609cd7fa2632629b1832bbf607
6
+ metadata.gz: 581b26a09ed7bac975a290f70bde5612240c90d58f30ede916b1506899d7bb65464a26a7c04a136962a0eb3e07d1969de615266a7be8e0bd9b4957c115c6190e
7
+ data.tar.gz: f61f5666766ef66fee57304beb1dbc1d3366707909e6af33b8aa7aad1d1c029e6c3b21c02a5b266b1e276d9a36b2c9ded9a4ab542072191d25b961a20cc946ba
@@ -0,0 +1,481 @@
1
+ # # # Leddys UI Toolkit, LUIT
2
+ # # # Copyrigth 2017 Martin Larsson
3
+ # # # martin.99.larsson@telia.com
4
+ # # #
5
+ # # # a holder is the object wich will recieve a callback when something happens to an element
6
+ # # # this could be button presse, or other similar events
7
+ # # # the id is assigned by the holder to know wich element called the callback method
8
+
9
+ # require 'gosu'
10
+
11
+ # module LUIT
12
+ # class << self
13
+ # attr_accessor :uiColor, :uiColorLight, :touchDown
14
+ # attr_reader :window, :z
15
+ # end
16
+
17
+ # def self.config(window:, uiColor: 0xff_555555, uiColorLight: 0xff_888888, z: 100)
18
+ # @window = window
19
+ # @uiColor = uiColor
20
+ # @uiColorLight = uiColorLight
21
+ # @z = z
22
+ # @touchDown = false
23
+ # end
24
+
25
+ # def self.mX
26
+ # @window.mouse_x
27
+ # end
28
+
29
+ # def self.mY
30
+ # @window.mouse_y
31
+ # end
32
+
33
+ # #Raspberry pi touchscreen hack
34
+ # def self.updateTouch()
35
+ # if @touchDown
36
+ # @window.mouse_x = 0
37
+ # @window.mouse_y = 0
38
+ # @touchDown = false
39
+ # else
40
+ # if @window.mouse_x != 0 or @window.mouse_y != 0
41
+ # @touchDown = true
42
+ # end
43
+ # end
44
+ # end
45
+
46
+ # class LUITElement
47
+ # attr_reader :id, :x, :y, :w, :h, :hover
48
+ # def initialize(holder, id, x, y, w, h)
49
+ # @holder = holder
50
+ # @id = id
51
+ # @x = x
52
+ # @y = y
53
+ # @w = w
54
+ # @h = h
55
+ # @msDown = false
56
+ # @hover = true
57
+ # end
58
+
59
+ # def draw(x = 0, y = 0)
60
+ # end
61
+
62
+ # def draw_rel(x = 0, y = 0)
63
+ # draw(x - (@w/2), y - (@h/2))
64
+ # end
65
+
66
+ # def updateHover(x, y)
67
+ # @hover = LUIT.mX.between?(x, x + @w) && LUIT.mY.between?(y, y + @h)
68
+ # end
69
+
70
+ # def update(x = 0, y = 0)
71
+ # if Gosu::button_down?(Gosu::MsLeft) or LUIT.touchDown
72
+ # if !@msDown
73
+ # button_down(Gosu::MsLeft)
74
+ # end
75
+ # @msDown = true
76
+ # else
77
+ # @msDown = false
78
+ # end
79
+ # end
80
+
81
+ # def update_rel(x = 0, y = 0)
82
+ # update(x - (@w/2), y - (@h/2))
83
+ # end
84
+
85
+ # def button_down(id)
86
+ # if id == Gosu::MsLeft && @hover
87
+ # @holder.onClick(@id)
88
+ # end
89
+ # end
90
+ # end
91
+
92
+ # class ClickArea < LUITElement
93
+ # def initialize(holder, id, x, y, w = 0, h = 0)
94
+ # h = [1, h].max
95
+ # w = [1, w].max
96
+ # super(holder, id, x, y, w, h)
97
+ # end
98
+
99
+ # def draw(x = 0, y = 0)
100
+ # Gosu::draw_rect(@x + x, @y + y, @w, @h, @hover ? LUIT.uiColorLight : LUIT.uiColor)
101
+ # end
102
+
103
+ # def update(x = 0, y = 0)
104
+ # x += @x
105
+ # y += @y
106
+ # updateHover(x, y)
107
+ # super(x, y)
108
+ # end
109
+ # end
110
+
111
+ # class TextArea < LUITElement
112
+ # attr_reader :field
113
+ # def initialize(holder, id, x, y, maxChar, h)
114
+ # h = [10, h].max
115
+ # @font = Gosu::Font.new(h)
116
+ # w = @font.text_width("W" * maxChar) + 20
117
+ # @maxChar = maxChar
118
+ # super(holder, id, x, y, w, h + 20)
119
+ # @typing = false
120
+ # @field = Gosu::TextInput.new
121
+ # puts "WINDOW HERE: "
122
+ # @window = LUIT.window
123
+ # puts @window
124
+ # end
125
+
126
+ # def text
127
+ # return @field.text
128
+ # end
129
+
130
+ # def button_down(id)
131
+ # if @hover
132
+ # @typing = true
133
+ # else
134
+ # if @typing
135
+ # @typing = false
136
+ # @holder.onClick(@id)
137
+ # end
138
+ # end
139
+ # end
140
+
141
+ # def draw(x = 0, y = 0)
142
+ # x = x + @x
143
+ # y = y + @y
144
+ # Gosu::draw_rect(x, y, @w, @h, @typing ? 0xffffffff : LUIT.uiColor, LUIT.z)
145
+ # @font.draw(@field.text, x + 10, y + 10, LUIT.z + 1, 1, 1, 0xff000000)
146
+ # end
147
+
148
+ # def update(x = 0, y = 0)
149
+ # super
150
+ # x += @x
151
+ # y += @y
152
+ # updateHover(x, y)
153
+ # if @field.text.size > @maxChar
154
+ # @field.text = @field.text[0..@maxChar]
155
+ # end
156
+ # if @typing
157
+ # @window.text_input = @field
158
+ # elsif @window.text_input == @field
159
+ # @window.text_input = nil
160
+ # end
161
+ # if Gosu::button_down?(Gosu::KbReturn) && @typing
162
+ # @typing = false
163
+ # @window.text_input = nil
164
+ # @holder.onClick(@id)
165
+ # end
166
+ # end
167
+ # end
168
+
169
+ # class ScannerInput
170
+ # attr_reader :scanning, :field
171
+ # def initialize(holder, id)
172
+ # @field = Gosu::TextInput.new
173
+ # @window = LUIT.window
174
+ # @holder = holder
175
+ # @id = id
176
+ # end
177
+
178
+ # def stop
179
+ # @scaning = false
180
+ # @window.text_input = nil if @window.text_input == @field
181
+ # end
182
+
183
+ # def scan
184
+ # @scaning = true
185
+ # @window.text_input = @field
186
+ # end
187
+ # end
188
+
189
+ # class ClickPoint < LUITElement
190
+ # def initialize(holder, id, x, y, r)
191
+ # @r = [1, r].max
192
+ # super(holder, id, x - @r, y - @r, @r * 2, @r * 2)
193
+ # end
194
+
195
+ # def update(x = 0, y = 0)
196
+ # if Gosu::distance($mx, $my, x, y) <= @r
197
+ # @hover = true
198
+ # else
199
+ # @hover = false
200
+ # end
201
+ # end
202
+ # end
203
+
204
+ # class Button < LUITElement
205
+ # #w and h will auto adjust to the text size + 10px padding if its not set (or set lower than acceptable)
206
+ # def initialize(holder, id, x, y, text, w = 0, h = 0)
207
+ # h = [50, h].max
208
+ # @text = text
209
+ # @buttonColor = LUIT.uiColor
210
+ # @font = Gosu::Font.new(h - 20)
211
+ # @textW = @font.text_width(@text)
212
+ # w = @textW + 20 if w < @textW + 20
213
+ # super(holder, id, x, y, w, h)
214
+ # end
215
+
216
+ # def draw(x = 0, y = 0)
217
+ # Gosu::draw_rect(x + @x, y + @y, @w, @h, @hover ? LUIT.uiColorLight : LUIT.uiColor, LUIT.z)
218
+ # @font.draw_rel(@text, @x + x + @w / 2, @y + y + @h / 2, LUIT.z + 1, 0.5, 0.5)
219
+ # end
220
+
221
+ # def update(x = 0, y = 0)
222
+ # x += @x
223
+ # y += @y
224
+ # updateHover(x, y)
225
+ # super(x, y)
226
+ # end
227
+ # end
228
+
229
+ # class Slider < LUITElement
230
+ # attr_accessor :value
231
+ # def initialize(holder, id, x, y, range)
232
+ # super(holder, id, x, y, range + 10, 30)
233
+ # @range = range
234
+ # @value = 0
235
+ # @buttonColor = LUIT.uiColor
236
+ # end
237
+
238
+ # def draw(x = 0, y = 0)
239
+ # Gosu::draw_rect(@x + x, @y + y + 10, @w, 10, @buttonColor, LUIT.z)
240
+ # Gosu::draw_rect(@x + x + @value, @y + y, 10, @h, @buttonColor, LUIT.z + 1)
241
+ # end
242
+
243
+ # def updateHover(x, y)
244
+ # @hover = LUIT.mX.between?(x - 10, x + @w + 20) && LUIT.mY.between?(y - 10, y + @h + 20)
245
+ # end
246
+
247
+ # def update(x = 0, y = 0)
248
+ # x += @x
249
+ # y += @y
250
+ # updateHover(x, y)
251
+ # if @hover && (Gosu::button_down?(Gosu::MsLeft) or LUIT.touchDown)
252
+ # @value = LUIT.mX - (x + 5)
253
+ # @value = 0 if @value < 0
254
+ # @value = @range if @value > @range
255
+ # end
256
+ # @buttonColor = @hover ? LUIT.uiColorLight : LUIT.uiColor
257
+ # end
258
+
259
+ # def button_down(id)
260
+ # end
261
+ # end
262
+
263
+ # class VerticalSlider < LUITElement
264
+ # attr_accessor :value
265
+ # def initialize(holder, id, x, y, range)
266
+ # super(holder, id, x, y, 30, range + 10)
267
+ # @range = range
268
+ # @value = 0
269
+ # @buttonColor = LUIT.uiColor
270
+ # end
271
+
272
+ # def draw(x = 0, y = 0)
273
+ # Gosu::draw_rect(@x + x + 10, @y + y, 10, @h, @buttonColor, LUIT.z)
274
+ # Gosu::draw_rect(@x + x, @y + y + @value, @w, 10, @buttonColor, LUIT.z + 1)
275
+ # end
276
+
277
+ # def updateHover(x, y)
278
+ # @hover = LUIT.mX.between?(x - 10, x + @w + 20) && LUIT.mY.between?(y - 10, y + @h + 20)
279
+ # end
280
+
281
+ # def update(x = 0, y = 0)
282
+ # x += @x
283
+ # y += @y
284
+ # updateHover(x, y)
285
+ # if @hover && (Gosu::button_down?(Gosu::MsLeft) or LUIT.touchDown)
286
+ # @value = LUIT.mY - (y + 5)
287
+ # @value = 0 if @value < 0
288
+ # @value = @range if @value > @range
289
+ # end
290
+ # @buttonColor = @hover ? LUIT.uiColorLight : LUIT.uiColor
291
+ # end
292
+
293
+ # def button_down(id)
294
+ # end
295
+ # end
296
+
297
+ # class Toggle < LUITElement
298
+ # attr_accessor :value
299
+ # def initialize(holder, id, x, y, size = 30)
300
+ # h = [30, size].max
301
+ # w = h * 2
302
+ # super(holder, id, x, y, w, h)
303
+ # @buttonColor = LUIT.uiColor
304
+ # @value = false
305
+ # end
306
+
307
+ # def draw(x = 0, y = 0)
308
+ # x += @x
309
+ # y += @y
310
+ # Gosu::draw_rect(x, y, @w, @h, @buttonColor, LUIT.z)
311
+ # @value ? v = 1 : v = 0
312
+ # Gosu::draw_rect(x + 4 + (@h * v), y + 4, @h - 8, @h - 8, @value ? 0xff_ffffff : 0xff_000000, LUIT.z + 1)
313
+ # end
314
+
315
+ # def update(x = 0, y = 0)
316
+ # x += @x
317
+ # y += @y
318
+ # updateHover(x, y)
319
+ # @buttonColor = @hover ? LUIT.uiColorLight : LUIT.uiColor
320
+ # super
321
+ # end
322
+
323
+ # def button_down(id)
324
+ # if id == Gosu::MsLeft && @hover
325
+ # @value = !@value
326
+ # @holder.onClick(@id)
327
+ # end
328
+ # end
329
+ # end
330
+
331
+ # class List < LUITElement
332
+ # attr_reader :contents
333
+ # def initialize(holder, id, x, y, h, s = 10)
334
+ # super(holder, id, x, y, 50, h)
335
+ # @spaceing = s
336
+ # @contents = []
337
+ # @totalh = 0
338
+ # @focus = 0
339
+ # @scrollbar = VerticalSlider.new(self, "scroll", 0, 0, @h - 10)
340
+ # end
341
+
342
+ # def <<(item)
343
+ # @contents << item
344
+ # @totalh += item.h + @spaceing
345
+ # @w = @contents.max_by{|x| x.w}.w
346
+ # end
347
+
348
+ # def draw(x = 0, y = 0)
349
+ # x += @x
350
+ # y += @y
351
+ # prevh = 0
352
+ # @contents.each do |item|
353
+ # if !((prevh - @focus + item.h) <= 0 || (prevh - @focus) >= @h)
354
+ # item.draw(x + 30, y + prevh - @focus)
355
+ # end
356
+ # prevh += item.h + @spaceing
357
+ # end
358
+ # @scrollbar.draw(x, y)
359
+ # end
360
+
361
+ # def update(x = 0, y = 0)
362
+ # x += @x
363
+ # y += @y
364
+ # prevh = 0
365
+ # @contents.each do |item|
366
+ # if !((prevh - @focus + item.h) < 0 || (prevh - @focus) > @h)
367
+ # item.update(x + 30, y + prevh - @focus)
368
+ # end
369
+ # prevh += item.h + @spaceing
370
+ # end
371
+ # @scrollbar.update(x, y)
372
+ # if @totalh > @h
373
+ # v = @scrollbar.value / (@h - 10)
374
+ # @focus = (@totalh - @h) * v
375
+ # else
376
+ # @focus = 0
377
+ # end
378
+ # end
379
+ # end
380
+
381
+ # class Icon
382
+ # attr_reader :x, :y, :w, :h
383
+ # def initialize(path, x, y, w, h)
384
+ # @icon = Gosu::Image.new(path)
385
+ # @scalex = (w / @icon.width)
386
+ # @scaley = (h / @icon.height)
387
+ # @x = x
388
+ # @y = y
389
+ # @w = w
390
+ # @h = h
391
+ # end
392
+
393
+ # def draw(x = 0, y = 0)
394
+ # @icon.draw(@x + x, @y + y, 1, @scalex, @scaley)
395
+ # end
396
+
397
+ # def update(x = 0, y = 0)
398
+ # end
399
+ # end
400
+
401
+ # @decimalValue = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
402
+ # @romanNumeral = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
403
+ # def self.to_roman(number)
404
+ # return '0' if number == 0
405
+ # romanized = ''
406
+ # for index in 0...@decimalValue.length do
407
+ # while @decimalValue[index] <= number do
408
+ # romanized += @romanNumeral[index]
409
+ # number -= @decimalValue[index]
410
+ # end
411
+ # end
412
+ # return romanized
413
+ # end
414
+ # end
415
+
416
+ # #run file directly to run test window
417
+ # if __FILE__ == $0
418
+ # class Test < Gosu::Window
419
+ # def initialize
420
+ # super(1000, 1000, false)
421
+
422
+ # LUIT.config(window: self)
423
+
424
+ # @LUITElements = []
425
+ # @LUITElements << LUIT::Button.new(self, 1, 0, 0, "Test")
426
+ # @LUITElements << LUIT::Button.new(self, 2, 111, 111, "Big button", 200, 70)
427
+ # @LUITElements << LUIT::Slider.new(self, 3, 300, 300, 300)
428
+ # @vslider = LUIT::VerticalSlider.new(self, 3, 250, 250, 300)
429
+ # @LUITElements << @vslider
430
+ # @LUITElements << LUIT::Toggle.new(self, 4, 500, 500)
431
+ # @LUITElements << LUIT::ClickArea.new(self, "click", 900, 900, 100, 100)
432
+ # @texter = LUIT::TextArea.new(self, "text", 300, 100, 32, 20)
433
+ # @LUITElements << @texter
434
+ # @LUITElements << LUIT::TextArea.new(self, "text2", 300, 200, 32, 20)
435
+ # @list = LUIT::List.new(self, "list", 0, 200, 300, 0)
436
+ # @LUITElements << @list
437
+ # 20.times do
438
+ # @list << LUIT::Button.new(self, 1, 0, 0, "Test", 0, 50)
439
+ # end
440
+ # @font = Gosu::Font.new(30)
441
+ # @scanner = LUIT::ScannerInput.new(self, "dik")
442
+ # end
443
+
444
+ # def draw
445
+ # @LUITElements.each {|e| e.draw}
446
+ # @font.draw(LUIT::to_roman(@vslider.value), 600, 250, 2)
447
+ # end
448
+
449
+ # def update
450
+ # @LUITElements.each {|e| e.update}
451
+ # @scanner.scan
452
+ # end
453
+
454
+ # def button_down(id)
455
+ # case id
456
+ # when Gosu::KbSpace
457
+ # @list << LUIT::Button.new(self, 1, 0, 0, "Test", 0, 50)
458
+ # when Gosu::KbReturn
459
+ # puts @scanner.field.text
460
+ # @scanner.field.text = ""
461
+ # end
462
+ # end
463
+
464
+ # def onScan(text)
465
+ # puts text
466
+ # @scanner.scan
467
+ # end
468
+
469
+ # def onClick(id)
470
+ # puts id
471
+ # if id == "text"
472
+ # puts @texter.text
473
+ # end
474
+ # end
475
+
476
+ # def needs_cursor?
477
+ # return true
478
+ # end
479
+ # end
480
+ # Test.new.show
481
+ # end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: line-em-up
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Dana
@@ -356,6 +356,7 @@ files:
356
356
  - line-em-up/models/small_explosion.rb
357
357
  - line-em-up/models/star.rb
358
358
  - menu_launcher.rb
359
+ - vendors/lib/luit.rb
359
360
  homepage: https://github.com/danabr75/line-em-up
360
361
  licenses:
361
362
  - MIT