chichilku3 15.0.0 → 15.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 127c8432ac9100685276e0e64d1c9b369097a9054af00f623ee1be4676631e25
4
- data.tar.gz: bf40ad04d8a83fd5e1098ebce5db2c74602a56b67c98c024f99e961d7c862259
3
+ metadata.gz: 31045c6431444e15f1e7b4ae51bcbe4be2a3c9caeafa0807c99fa538ac098b5c
4
+ data.tar.gz: aa82eab01ecb488acd3c0526736eff6492eb9398bf7f2ee922225a8dc5b95690
5
5
  SHA512:
6
- metadata.gz: 243aeacbe9733668029365e292cfdc7c4b1525de2a9f1dd18fd8c95a3c28c1613499a981831e245984a025b884987beb1c5d0cbda69b89717902753a796317ec
7
- data.tar.gz: 5535a25b59c663ef8cd8d3d2afb41d2fd116bc28dba633ef97500f529f7da7deec215dbb18af1147636fee81ffa1dc5ded9e3c5a35d31d7b9e2fcc9c2059a6b0
6
+ metadata.gz: 7c2d2bba3f95541b65a3d07d1935c3d0911587df1f12e6bc13d797484a8045407fdac9ad3ee6682793d0c5860306f8a5b0bab9961e46a86d28235074e234a8f3
7
+ data.tar.gz: a902ddd4f25e47fa636c937e235534752e2e6b1b65fb63bc6f0f80ca0cd8aa32e480eb1f493289f10fb317e8bccbe4b02d166042620dfc60d05e20a29421f045
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ # https://github.com/gosu/gosu-examples/blob/master/examples/text_input.rb
4
+ # Gosu is released under the MIT license.
5
+ require 'gosu'
6
+
7
+ # Input text boxes
8
+ class TextField < Gosu::TextInput
9
+ FONT = Gosu::Font.new(60)
10
+ WIDTH = 800
11
+ LENGTH_LIMIT = 20
12
+ PADDING = 5
13
+
14
+ INACTIVE_COLOR = 0xcc_666666
15
+ ACTIVE_COLOR = 0xcc_555555
16
+ SELECTION_COLOR = 0xcc_444444
17
+ CARET_COLOR = 0xff_ffffff
18
+
19
+ attr_reader :x, :y
20
+
21
+ def initialize(window, x, y)
22
+ # It's important to call the inherited constructor.
23
+ super()
24
+
25
+ @window = window
26
+ @x = x
27
+ @y = y
28
+
29
+ # Start with a self-explanatory text in each field.
30
+ self.text = 'Click to edit'
31
+ end
32
+
33
+ # In this example, we use the filter method to prevent the user from entering a text that exceeds
34
+ # the length limit. However, you can also use this to blacklist certain characters, etc.
35
+ def filter(new_text)
36
+ allowed_length = [LENGTH_LIMIT - text.length, 0].max
37
+ new_text[0, allowed_length]
38
+ end
39
+
40
+ def draw(z)
41
+ # Change the background colour if this is the currently selected text field.
42
+ color = if @window.text_input == self
43
+ ACTIVE_COLOR
44
+ else
45
+ INACTIVE_COLOR
46
+ end
47
+ # ChillerDragon's epic shadow to at least have edited the stolen sample a lil bit
48
+ Gosu.draw_rect (x - PADDING) + 5, (y - PADDING) + 5, WIDTH + 2 * PADDING, height + 2 * PADDING, INACTIVE_COLOR, z
49
+ Gosu.draw_rect x - PADDING, y - PADDING, WIDTH + 2 * PADDING, height + 2 * PADDING, color, z
50
+ Gosu.draw_rect x - PADDING, y - PADDING, WIDTH + 2 * PADDING, height + 2 * PADDING, color, z
51
+
52
+ # Calculate the position of the caret and the selection start.
53
+ pos_x = x + FONT.text_width(text[0...caret_pos])
54
+ sel_x = x + FONT.text_width(text[0...selection_start])
55
+ sel_w = pos_x - sel_x
56
+
57
+ # Draw the selection background, if any. (If not, sel_x and pos_x will be
58
+ # the same value, making this a no-op call.)
59
+ Gosu.draw_rect sel_x, y, sel_w, height, SELECTION_COLOR, z
60
+
61
+ # Draw the caret if this is the currently selected field.
62
+ Gosu.draw_line pos_x, y, CARET_COLOR, pos_x, y + height, CARET_COLOR, z if @window.text_input == self
63
+
64
+ # Finally, draw the text itself!
65
+ FONT.draw_text text, x, y, z
66
+ end
67
+
68
+ def height
69
+ FONT.height
70
+ end
71
+
72
+ # Hit-test for selecting a text field with the mouse.
73
+ def under_mouse?
74
+ @window.mouse_x > x - PADDING and @window.mouse_x < x + WIDTH + PADDING and
75
+ @window.mouse_y > y - PADDING and @window.mouse_y < y + height + PADDING
76
+ end
77
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ # https://github.com/rubyzip/rubyzip/blob/9d891f7353e66052283562d3e252fe380bb4b199/samples/example_recursive.rb
4
+ # http://www.ruby-lang.org/en/about/license.txt
5
+ require 'zip'
6
+
7
+ # This is a simple example which uses rubyzip to
8
+ # recursively generate a zip file from the contents of
9
+ # a specified directory. The directory itself is not
10
+ # included in the archive, rather just its contents.
11
+ #
12
+ # Usage:
13
+ # directory_to_zip = "/tmp/input"
14
+ # output_file = "/tmp/out.zip"
15
+ # zf = ZipFileGenerator.new(directory_to_zip, output_file)
16
+ # zf.write()
17
+ class ZipFileGenerator
18
+ # Initialize with the directory to zip and the location of the output archive.
19
+ def initialize(input_dir, output_file)
20
+ @input_dir = input_dir
21
+ @output_file = output_file
22
+ end
23
+
24
+ # Zip the input directory.
25
+ def write
26
+ entries = Dir.entries(@input_dir) - %w[. ..]
27
+
28
+ ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile|
29
+ write_entries entries, '', zipfile
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ # A helper method to make the recursion work.
36
+ def write_entries(entries, path, zipfile)
37
+ entries.each do |e|
38
+ zipfile_path = path == '' ? e : File.join(path, e)
39
+ disk_file_path = File.join(@input_dir, zipfile_path)
40
+
41
+ if File.directory? disk_file_path
42
+ recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)
43
+ else
44
+ put_into_archive(disk_file_path, zipfile, zipfile_path)
45
+ end
46
+ end
47
+ end
48
+
49
+ def recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)
50
+ zipfile.mkdir zipfile_path
51
+ subdir = Dir.entries(disk_file_path) - %w[. ..]
52
+ write_entries subdir, zipfile_path, zipfile
53
+ end
54
+
55
+ def put_into_archive(disk_file_path, zipfile, zipfile_path)
56
+ zipfile.add(zipfile_path, disk_file_path)
57
+ end
58
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chichilku3
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.0.0
4
+ version: 15.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ChillerDragon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-03 00:00:00.000000000 Z
11
+ date: 2022-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fileutils
@@ -132,6 +132,8 @@ files:
132
132
  - lib/client/keys.rb
133
133
  - lib/client/particles.rb
134
134
  - lib/client/scoreboard.rb
135
+ - lib/external/gosu/text.rb
136
+ - lib/external/rubyzip/recursive.rb
135
137
  - lib/server/chichilku3_server.rb
136
138
  - lib/server/gamelogic.rb
137
139
  - lib/server/server_cfg.rb