drakkon 0.0.7 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/drakkon/build.rb +61 -4
  3. data/lib/drakkon/cli.rb +3 -1
  4. data/lib/drakkon/gem/bundle.rb +86 -17
  5. data/lib/drakkon/gem/cli.rb +2 -0
  6. data/lib/drakkon/gem/helpers/modules.rb +5 -0
  7. data/lib/drakkon/init.rb +23 -15
  8. data/lib/drakkon/lib/fonts/fonts.rb +88 -0
  9. data/lib/drakkon/lib/hub.rb +4 -3
  10. data/lib/drakkon/lib/images/biggest.rb +8 -6
  11. data/lib/drakkon/lib/images/bulk_rename.rb +1 -13
  12. data/lib/drakkon/lib/images/cli.rb +35 -19
  13. data/lib/drakkon/lib/images/compress.rb +60 -0
  14. data/lib/drakkon/lib/images/double.rb +77 -0
  15. data/lib/drakkon/lib/images/downcase_normalize.rb +70 -0
  16. data/lib/drakkon/lib/images/hue_modulation.rb +71 -0
  17. data/lib/drakkon/lib/images/index.rb +43 -20
  18. data/lib/drakkon/lib/images/layers.rb +55 -0
  19. data/lib/drakkon/lib/images/resize.rb +3 -2
  20. data/lib/drakkon/lib/images/split.rb +4 -4
  21. data/lib/drakkon/lib/images/spritesheet.rb +52 -13
  22. data/lib/drakkon/lib/images/text.rb +4 -1
  23. data/lib/drakkon/lib/images/trim.rb +7 -6
  24. data/lib/drakkon/lib/manifest.rb +24 -16
  25. data/lib/drakkon/lib/pastel.rb +1 -1
  26. data/lib/drakkon/lib/platform_compat.rb +27 -0
  27. data/lib/drakkon/lib/settings.rb +68 -5
  28. data/lib/drakkon/lib/sounds/sounds.rb +126 -0
  29. data/lib/drakkon/lib/utils/cli.rb +38 -0
  30. data/lib/drakkon/lib/utils/rename_normalize.rb +75 -0
  31. data/lib/drakkon/lib/version.rb +17 -2
  32. data/lib/drakkon/release.rb +1 -1
  33. data/lib/drakkon/run/commands/utils.rb +14 -0
  34. data/lib/drakkon/run/helpers.rb +15 -4
  35. data/lib/drakkon/run/reader_shim.rb +9 -5
  36. data/lib/drakkon/run/tty.rb +1 -1
  37. data/lib/drakkon/run.rb +6 -2
  38. data/lib/drakkon/skeleton/deploy.rb +4 -1
  39. data/lib/drakkon/web.rb +16 -44
  40. data/lib/drakkon.rb +10 -7
  41. metadata +32 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22dc052674cbdeb00139240538434c5098c27f5b4daa59ecc35ba3fd30fc6219
4
- data.tar.gz: e705e6edc55b2b979761da02ad021d4d0ae427b6b03144fc8d20835f3a89f496
3
+ metadata.gz: 20674edb1e5357b6971a88c0dd4b222274ee75bb65bed6f8840530f8d9a804ec
4
+ data.tar.gz: 530c12ba7dedaa85213710fe7fd46f2b220feb02526002c21bac9450687d5cc6
5
5
  SHA512:
6
- metadata.gz: f02cc623e83d177b61e9043d4852571b5be61c9ac3fea8aa73009e2469fe90636c2da8976829209342cbbd8c6358033586f1c1994bf2a3814157ebb0b19cbfe7
7
- data.tar.gz: 582b9944ca4aeec1d5963fd92190f4330b97cdbcc1f99892f725dbe3629290c523bc3926e4f89ac111f96b874422a6503b2a40bde396fe606a393237cbe69033
6
+ metadata.gz: f52deb9d5a66285535f3cd03089575a8a7f1831923a6a7f37d688f008468711e759fe25aa7841012e499fa8f7e89f082f3fe318dcede83579f9a77ae0266635c
7
+ data.tar.gz: 065b90c52e8d60a35a0c3a4b1f141056a8fac63df483c074dec858bb41471ea975f67fe20a41a2fc75f27fcdec19806e3fa7a52b7a91c1ab4f52a0d166f1370b
data/lib/drakkon/build.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  module Drakkon
2
2
  # Run Command for CLI
3
3
  module Build
4
+ extend PlatformCompat
5
+
4
6
  def self.args(raw = nil)
5
7
  @args ||= raw
6
8
 
@@ -15,6 +17,9 @@ module Drakkon
15
17
 
16
18
  Settings.update(:platforms, platform_setup) unless Settings.platforms?
17
19
 
20
+ # Run Index if configured
21
+ Manifest.index if Settings.config[:manifest]
22
+
18
23
  builder = if args.empty?
19
24
  Settings.platforms
20
25
  else
@@ -40,8 +45,12 @@ module Drakkon
40
45
  # Clean Up Accidental Leftovers
41
46
  FileUtils.rm_r(context_name) if Dir.exist? context_name
42
47
 
43
- # DragonRuby Publish doesn't like symlinks or PATH...
44
- FileUtils.cp_r(context, context_name)
48
+ if Settings.manifest_compile?
49
+ manifest_compile(context, context_name)
50
+ else
51
+ # DragonRuby Publish doesn't like symlinks or PATH...
52
+ FileUtils.cp_r(context, context_name)
53
+ end
45
54
 
46
55
  # Clean Builds Dir
47
56
  FileUtils.rm_r(Dir['builds/*'])
@@ -50,7 +59,8 @@ module Drakkon
50
59
  FileUtils.rm_r("#{context_name}/builds") if Dir.exist? "#{context_name}/builds"
51
60
 
52
61
  # Execute
53
- system build!(list, context_name, publish)
62
+ io = IO.popen(build_env, build!(list, context_name, publish))
63
+ output(io)
54
64
 
55
65
  # Preflight
56
66
  FileUtils.mkdir_p("#{context}/builds")
@@ -73,13 +83,52 @@ module Drakkon
73
83
  end
74
84
  # rubocop:enable Metrics/AbcSize
75
85
 
86
+ # Send output to console
87
+ def self.output(io)
88
+ loop do
89
+ next unless io.ready?
90
+ end
91
+ rescue SystemExit, Interrupt, EOFError
92
+ LogBot.info('Build', 'Exiting')
93
+ end
94
+
95
+ def self.manifest_compile(context, context_name)
96
+ # Base Folders
97
+ Dir.mkdir context_name
98
+ Dir.mkdir "#{context_name}/app"
99
+
100
+ # Copy Directories that are not being managed
101
+ FileUtils.cp_r("#{context}/fonts", "#{context_name}/fonts")
102
+ FileUtils.cp_r("#{context}/sprites", "#{context_name}/sprites")
103
+ FileUtils.cp_r("#{context}/sounds", "#{context_name}/sounds")
104
+ FileUtils.cp_r("#{context}/metadata", "#{context_name}/metadata")
105
+
106
+ # Copy over base files
107
+ FileUtils.cp("#{context}/app/main.rb", "#{context_name}/app/main.rb")
108
+ FileUtils.cp_r("#{context}/app/drakkon", "#{context_name}/app/drakkon")
109
+
110
+ # Compile into Manifest
111
+ File.open("#{context_name}/app/drakkon/manifest.rb", 'w') do |f|
112
+ Manifest.index.reverse.each do |file|
113
+ f << File.read("#{context}/#{file}")
114
+ end
115
+ end
116
+ end
117
+
76
118
  def self.metadata_version(context)
77
119
  File.read("#{context}/metadata/game_metadata.txt").split("\n").find { |y| y.include? 'version' }.split('=').last
78
120
  end
79
121
 
80
122
  # DEW THE BUILD
81
123
  def self.build!(list, context, package = '--package')
82
- "PATH=#{version_dir}:$PATH dragonruby-publish #{package} --platforms=#{list} #{context}"
124
+ # 5.25 not liking the blank package flag
125
+ cmd = []
126
+ cmd.push './dragonruby-publish'
127
+ cmd.push package unless package.nil? || package.empty?
128
+ cmd.push "--platforms=#{list}"
129
+ cmd.push context
130
+
131
+ cmd
83
132
  end
84
133
 
85
134
  def self.version_dir
@@ -90,6 +139,14 @@ module Drakkon
90
139
  args.include?('images')
91
140
  end
92
141
 
142
+ def self.force_fonts?
143
+ args.include?('fonts')
144
+ end
145
+
146
+ def self.force_sounds?
147
+ args.include?('sounds')
148
+ end
149
+
93
150
  def self.force_manifest?
94
151
  args.include?('manifest')
95
152
  end
data/lib/drakkon/cli.rb CHANGED
@@ -21,6 +21,7 @@ module Drakkon
21
21
  when :build then Build.go!(args)
22
22
  when :publish then Build.go!([], '')
23
23
  when :images then Images::CLI.run!(args)
24
+ when :utils then Utils::CLI.run!(args)
24
25
  when :install then Version.install!(args)
25
26
  when :gem then Gems::CLI.init!(args)
26
27
  when :skeleton then Skeleton::CLI.init!(args)
@@ -48,7 +49,8 @@ module Drakkon
48
49
  menu.choice name: 'build', value: :build
49
50
  menu.choice name: 'publish', value: :publish
50
51
  menu.choice name: 'install (DragonRuby Versions)', value: :install
51
- menu.choice name: 'images', value: :images
52
+ menu.choice name: 'Image Helpers [images]', value: :images
53
+ menu.choice name: 'Utilities [utils]', value: :utils
52
54
  menu.choice name: 'gem (Shared Code)', value: :gem
53
55
  menu.choice name: 'skeleton (Templates)', value: :skeleton
54
56
  menu.choice name: 'console (pry)', value: :console
@@ -3,11 +3,12 @@ module Drakkon
3
3
  # Run Command for CLI
4
4
  module Bundle
5
5
  def self.build!(args, context)
6
- return if Settings.gems.empty?
6
+ # Gems are not required
7
+ # return if Settings.gems.empty?
7
8
 
8
9
  @context = context
9
10
 
10
- if Settings.config[:bundle_digest] == digest && !args.include?('bundle')
11
+ if Settings.config[:bundle_digest] == digest && !args.include?('bundle') && File.exist?(bundle_file)
11
12
  LogBot.info('Gems Bundle', 'Nothing New')
12
13
  return unless args.include?('bundle')
13
14
  else
@@ -16,14 +17,64 @@ module Drakkon
16
17
 
17
18
  idx = collect
18
19
 
19
- do_the_bundle(idx)
20
+ if Settings.bundle_compile?
21
+ LogBot.info('Gems Bundle', 'Compile')
22
+ compiled_bundle(idx)
23
+ else
24
+ LogBot.info('Gems Bundle', 'Expand')
25
+ expand_bundle(idx)
26
+ end
20
27
 
21
28
  Settings.update(:bundle_digest, digest)
22
29
  rescue TTY::Reader::InputInterrupt
23
30
  exit 0
24
31
  end
25
32
 
26
- def self.do_the_bundle(idx)
33
+ # Including files without merging them
34
+ def self.expand_bundle(idx)
35
+ # Make Directory `app/drakkon` if it doesn't exist
36
+ FileUtils.mkdir_p('app/drakkon') unless File.directory?('app/drakkon')
37
+
38
+ # Create Sub Directory to make switching to compile / eaiser
39
+ # Always clear to ensure fresh directory
40
+ FileUtils.rm_rf(unbundle_dir) if File.directory?(unbundle_dir)
41
+ FileUtils.mkdir_p(unbundle_dir)
42
+
43
+ # Touch the file if it doesn't exist
44
+ FileUtils.touch(bundle_file) unless File.exist?(bundle_file)
45
+
46
+ File.open(bundle_file, 'w') do |f|
47
+ idx.keys.sort.reverse.each do |i|
48
+ idx[i].each do |file_data|
49
+ file = file_data[:path]
50
+ unless File.exist?(file)
51
+ LogBot.fatal('Bundle', "File not found #{file.pastel(:red)}")
52
+ next
53
+ end
54
+
55
+ file_path = "#{unbundle_dir}/#{File.basename(file_data[:safe_name])}.rb"
56
+
57
+ FileUtils.cp(file, file_path)
58
+ f << "require '#{file_path}'\n"
59
+ end
60
+ end
61
+
62
+ # Include other files
63
+ f << "require 'app/drakkon/image_index.rb' \n" if Settings.image_index?
64
+ f << "require 'app/drakkon/font_index.rb' \n" if Settings.font_index?
65
+ f << "require 'app/drakkon/sound_index.rb' \n" if Settings.sound_index?
66
+ f << "require 'app/drakkon/manifest.rb' \n" if Settings.manifest?
67
+
68
+ # File Close
69
+ end
70
+
71
+ # FileUtils.cp(bundle_file, "#{drakkon_dir}/bundle/#{Time.now.to_i}.rb")
72
+ end
73
+
74
+ def self.compiled_bundle(idx)
75
+ # Always clear to ensure fresh directory
76
+ FileUtils.rm_rf(unbundle_dir) if File.directory?(unbundle_dir)
77
+
27
78
  # Make Directory `app/drakkon` if it doesn't exist
28
79
  FileUtils.mkdir_p('app/drakkon') unless File.directory?('app/drakkon')
29
80
 
@@ -33,7 +84,9 @@ module Drakkon
33
84
  File.open(bundle_file, 'w') do |f|
34
85
  # Index Writer
35
86
  idx.keys.sort.reverse.each do |i|
36
- idx[i].each do |file|
87
+ idx[i].each do |file_data|
88
+ file = file_data[:path]
89
+
37
90
  unless File.exist?(file)
38
91
  LogBot.fatal('Bundle', "File not found #{file.pastel(:red)}")
39
92
  next
@@ -45,6 +98,8 @@ module Drakkon
45
98
 
46
99
  # Include other files
47
100
  f << "require 'app/drakkon/image_index.rb' \n" if Settings.image_index?
101
+ f << "require 'app/drakkon/font_index.rb' \n" if Settings.font_index?
102
+ f << "require 'app/drakkon/sound_index.rb' \n" if Settings.sound_index?
48
103
  f << "require 'app/drakkon/manifest.rb' \n" if Settings.manifest?
49
104
 
50
105
  # File Close
@@ -53,7 +108,8 @@ module Drakkon
53
108
 
54
109
  def self.collect
55
110
  idx = {}
56
- Settings.gems.each_value do |gem|
111
+ Settings.gems.each do |gem_name, gem|
112
+ gem[:name] = gem_name.to_s.downcase
57
113
  case gem[:source].to_sym
58
114
  when :local then collect_local_source(idx, gem)
59
115
  else
@@ -68,17 +124,22 @@ module Drakkon
68
124
  path = gem[:data][:path]
69
125
 
70
126
  # Modules
71
- gem[:data][:modules].each do |mod|
72
- idx[mod.weight] ||= []
73
- mod.files.each do |file|
74
- file_name = "#{path}/#{file}.rb"
75
- unless File.exist?(file_name)
76
- LogBot.fatal('Bundle',
77
- "Module File not found #{mod.name.pastel(:bright_blue)}, #{file_name.pastel(:red)}")
78
- next
79
- end
127
+ if gem[:data].key?(:modules)
128
+ gem[:data][:modules].each do |mod|
129
+ idx[mod.weight] ||= []
130
+ mod.files.each do |file|
131
+ file_name = "#{path}/#{file}.rb"
132
+ unless File.exist?(file_name)
133
+ LogBot.fatal('Bundle',
134
+ "Module File not found #{mod.name.pastel(:bright_blue)}, #{file_name.pastel(:red)}")
135
+ next
136
+ end
137
+
138
+ # Convert full file path into single string / relative naming (no directories)
139
+ safe_name = "#{gem.name}_#{file.gsub('/', '_')}"
80
140
 
81
- idx[mod.weight].push file_name
141
+ idx[mod.weight].push(path: file_name, name: file, safe_name: safe_name)
142
+ end
82
143
  end
83
144
  end
84
145
 
@@ -86,7 +147,10 @@ module Drakkon
86
147
  if gem[:data].key?(:files)
87
148
  gem[:data][:files].each_value do |f|
88
149
  idx[f.weight] ||= []
89
- idx[f.weight].push "#{path}/#{f.file}"
150
+ # idx[f.weight].push "#{path}/#{f.file}"
151
+ safe_name = "#{gem.name}_#{f.file.gsub('/', '_')}"
152
+
153
+ idx[f.weight].push(path: "#{path}/#{f.file}", name: f.file, safe_name: safe_name)
90
154
  end
91
155
 
92
156
  end
@@ -105,6 +169,11 @@ module Drakkon
105
169
  "#{@context}/app/drakkon"
106
170
  end
107
171
 
172
+ # Directory for uncompiled files / Relative
173
+ def self.unbundle_dir
174
+ 'app/drakkon/unbundle'
175
+ end
176
+
108
177
  def self.prompt
109
178
  TTY::Prompt.new(active_color: :cyan, interrupt: :exit)
110
179
  end
@@ -10,6 +10,8 @@ module Drakkon
10
10
 
11
11
  # General Run
12
12
  def self.init!(raw)
13
+ Settings.ready?
14
+
13
15
  args(raw)
14
16
  cmd = args.shift
15
17
 
@@ -3,6 +3,8 @@ module Drakkon
3
3
  # General Helpers for Gem Class
4
4
  module GemHelpers
5
5
  def select_modules
6
+ return if (data[:modules].nil? || data[:modules].empty?) && modules.empty?
7
+
6
8
  data[:modules] = prompt_modules.map do |selected|
7
9
  modules.find { |x| x[:name] == selected }
8
10
  end
@@ -13,6 +15,9 @@ module Drakkon
13
15
  valid_structure?
14
16
  load_modules
15
17
 
18
+ # Ignore if no modules
19
+ return if data[:modules].nil? || data[:modules].empty?
20
+
16
21
  data[:modules] = data[:modules].map(&:name).map do |selected|
17
22
  modules.find { |x| x[:name] == selected }
18
23
  end
data/lib/drakkon/init.rb CHANGED
@@ -27,15 +27,30 @@ module Drakkon
27
27
  metadata
28
28
 
29
29
  # TODO: Validate / Confirm
30
- File.write('app/main.rb', main_tick)
30
+ try_write('app/main.rb') do |to|
31
+ File.write(to, main_tick)
32
+ end
33
+ end
34
+
35
+ def self.try_write(to, &blk)
36
+ if File.exist?(to)
37
+ LogBot.warn('Init', "- Tried to create #{to} but it already exists")
38
+ else
39
+ LogBot.info('Init', "- Created #{to}")
40
+ blk.call(to)
41
+ end
31
42
  end
32
43
 
33
44
  def self.metadata
34
45
  # Icon is required for build
35
- FileUtils.cp(metdata_dir('icon.png'), 'metadata/')
46
+ try_write('metadata/icon.png') do |to|
47
+ FileUtils.cp(metdata_dir('icon.png'), to)
48
+ end
36
49
 
37
50
  # Copy metdata files
38
- FileUtils.cp(metdata_dir('game_metadata.txt'), 'metadata/')
51
+ try_write('metadata/game_metadata.txt') do |to|
52
+ FileUtils.cp(metdata_dir('game_metadata.txt'), to)
53
+ end
39
54
  end
40
55
 
41
56
  def self.metdata_dir(file_name = nil)
@@ -45,18 +60,11 @@ module Drakkon
45
60
  def self.settings
46
61
  LogBot.info('Init', 'Settings Setup')
47
62
 
48
- opts = {
49
- platforms: [],
50
- version: Hub.version_latest,
51
- image_index: true,
52
- manifest: true,
53
- gems: {}
54
- }
55
-
56
- # TODO: Be better, this is lazy...
57
- opts.each do |key, value|
58
- Settings.update(key, value)
59
- end
63
+ # If we're here, it means Settings.init? returned false,
64
+ # which eans the config file doesn't exist.
65
+ # As a happy accident, accessing Settings.config for the first time also
66
+ # writes out a default config file
67
+ Settings.config
60
68
  end
61
69
 
62
70
  def self.directories
@@ -0,0 +1,88 @@
1
+ module Drakkon
2
+ module Fonts
3
+ # General Font Index Helper
4
+ module Index
5
+ def self.index
6
+ @index ||= {}
7
+
8
+ @index
9
+ end
10
+
11
+ def self.context
12
+ @context ||= Dir.pwd
13
+
14
+ @context
15
+ end
16
+
17
+ def self.digest
18
+ list = Dir["#{fonts_directory}/**/*"].select { |file| File.file?(file) }
19
+ Digest::MD5.hexdigest(list.map { |x| Digest::MD5.file(x).hexdigest }.join)
20
+ end
21
+
22
+ def self.fonts_directory
23
+ "#{context}/fonts"
24
+ end
25
+
26
+ def self.run!(force: false, dir: nil)
27
+ @context = dir || Dir.pwd
28
+
29
+ # Create Directory if sprites directory is missing
30
+ FileUtils.mkdir_p(fonts_directory)
31
+
32
+ if Settings.config[:font_digest] == digest && File.exist?("#{context}/app/drakkon/font_index.rb")
33
+ LogBot.info('Fonts Index', 'Nothing New')
34
+ return unless force
35
+ end
36
+
37
+ build_index
38
+
39
+ Settings.update(:font_digest, digest)
40
+
41
+ File.write("#{context}/app/drakkon/font_index.rb", result)
42
+ end
43
+
44
+ def self.build_index
45
+ check fonts_directory
46
+ end
47
+
48
+ def self.result
49
+ <<~RB
50
+ module Drakkon
51
+ module Fonts
52
+ def self.index
53
+ #{index.inspect}
54
+ end
55
+ end
56
+ end
57
+ RB
58
+ end
59
+
60
+ # Recursively Go through
61
+ def self.check(dir = nil)
62
+ LogBot.info('Font Index', "Check: #{dir}")
63
+
64
+ # Collect Fonts
65
+ list = Dir["#{dir}/*"]
66
+
67
+ # Ignore Empties
68
+ return if list.empty?
69
+
70
+ # Do other things
71
+ Dir["#{dir}/*"].each do |file|
72
+ next if File.directory?(file)
73
+
74
+ process(file)
75
+ end
76
+
77
+ :done
78
+ end
79
+
80
+ def self.process(file = nil)
81
+ name = File.basename(file, File.extname(file))
82
+ index[name] = file.gsub(fonts_directory, '')[1..]
83
+ end
84
+ # =========================================================
85
+ end
86
+ # =========================================================
87
+ end
88
+ end
@@ -68,13 +68,14 @@ module Drakkon
68
68
 
69
69
  def self.config
70
70
  # Write Default
71
- File.write(config_file, Oj.dump({})) unless File.exist?(config_file)
71
+ File.write(config_file, JSON.pretty_generate({})) unless File.exist?(config_file)
72
72
 
73
73
  @config ||= JSON.parse(File.read(config_file), { symbolize_names: true })
74
74
 
75
75
  # TODO: Optimize this a bit more
76
76
  config_defaults.each do |key, value|
77
- @config[key] ||= value
77
+ # ||= Is problematic with falses
78
+ @config[key] = value unless @config.key?(key)
78
79
  end
79
80
 
80
81
  @config
@@ -92,7 +93,7 @@ module Drakkon
92
93
 
93
94
  def self.write
94
95
  # LogBot.debug('Hub', "Writing Config: #{config_file}")
95
- File.write(config_file, Oj.dump(config))
96
+ File.write(config_file, JSON.pretty_generate(config))
96
97
  end
97
98
 
98
99
  def self.log_file
@@ -7,16 +7,17 @@ module Drakkon
7
7
  end
8
8
 
9
9
  def self.start
10
- index = []
11
10
  LogBot.info('Image Biggest Index')
12
- images.each do |img|
13
- index.push process(img)
11
+ index = images.map do |img|
12
+ process(img)
14
13
  end
15
14
 
16
- w = index.max_by(&:w).w
17
- h = index.max_by(&:h).h
15
+ img_w = index.max_by(&:w)
16
+ img_h = index.max_by(&:h)
18
17
 
19
- puts "Largest Size is: { w: #{w}, h: #{h} }"
18
+ puts "Largest Sizes: { w: #{img_w.w}, h: #{img_h.h} }"
19
+ puts " Width: #{img_w}"
20
+ puts " Height: #{img_h}"
20
21
  end
21
22
 
22
23
  def self.process(file)
@@ -24,6 +25,7 @@ module Drakkon
24
25
  img = MiniMagick::Image.open(file)
25
26
 
26
27
  {
28
+ file: File.basename(file),
27
29
  w: img.width,
28
30
  h: img.height
29
31
  }
@@ -58,22 +58,10 @@ module Drakkon
58
58
  end
59
59
  end
60
60
 
61
- def self.process(file, filter, size)
62
- image = MiniMagick::Image.open(file)
63
-
64
- # Ignore if the same for w/h
65
- return if image.width == size.split('x', 2).first.to_i && image.height == size.split('x', 2).last.to_i
66
-
67
- LogBot.info('Image Resize', "Resizing: #{file}: #{size}")
68
- image.filter filter
69
- image.resize size
70
- image.write file
71
- end
72
-
73
61
  def self.images
74
62
  # Dir["#{Dir.pwd}/*.png"].sort_by(&:File.basename)
75
63
 
76
- Dir["#{Dir.pwd}/*.png"].sort_by { |x| File.mtime(x) }
64
+ Dir["#{Dir.pwd}/*.png"]
77
65
  end
78
66
 
79
67
  def self.prompt
@@ -25,50 +25,66 @@ module Drakkon
25
25
  when :flip_flop then Images::FlipFlop.run!(args)
26
26
  when :rotate then Images::Rotate.run!(args)
27
27
  when :canvas then Images::Canvas.run!(args)
28
+ when :desaturate then Images::Desaturate.run!(args)
28
29
  when :blur then Images::Blur.run!(args)
29
30
  when :split then Images::SplitSpriteSheet.run!(args)
30
31
  when :combine then Images::SpriteSheetCombine.run!(args)
32
+ when :double then Images::Double.run!(args)
31
33
  when :trim then Images::Trim.run!(args)
32
34
  when :gif_split then Images::GifSplit.run!(args)
33
35
  when :sepia then Images::Sepia.run!(args)
34
36
  when :modulate then Images::Modulate.run!(args)
37
+ when :layers then Images::Layers.run!(args)
38
+ when :hue_modulate then Images::HueModulate.run!(args)
35
39
  when :bulk_rename then Images::BulkRename.run!(args)
40
+ when :downcase_norm then Images::DowncaseNormalize.run!(args)
36
41
  when :text_to_image then Images::TextToImage.run!(args)
42
+ when :compress then Images::Compress.run!(args)
37
43
  when :index then Images::Index.run!(force: true)
38
44
  when :exit then exit(0)
39
45
  else
40
46
  start(menu, args)
41
47
  end
48
+ rescue TTY::Reader::InputInterrupt
49
+ exit 0
42
50
  end
43
51
  # rubocop:enable Metrics/CyclomaticComplexity
44
52
 
53
+ # rubocop:disable Metrics/BlockLength
45
54
  def self.menu
46
55
  prompt.select('Image Helpers:', filter: true, per_page: 20) do |menu|
47
56
  menu.choice name: 'Listing; Filter', value: :list
48
- menu.choice name: 'Biggest: Find largest dimensions', value: :biggest
49
- menu.choice name: 'Convert alpha to white', value: :white
50
- menu.choice name: 'Resize WxH', value: :resize
51
- menu.choice name: 'Scale', value: :scale
52
- menu.choice name: 'Shift (Splice/Gravity)', value: :shift
53
- menu.choice name: 'Roll', value: :roll
54
- menu.choice name: 'Flip/Flop', value: :flip_flop
55
- menu.choice name: 'Rotate', value: :rotate
56
- menu.choice name: 'Canvas (Change/Retain)', value: :canvas
57
- menu.choice name: 'Desaturate (Grey Colorspace)', value: :desaturate
58
- menu.choice name: 'Blur', value: :blur
59
- menu.choice name: 'Split SpriteSheet (split)', value: :split
60
- menu.choice name: 'Create SpriteSheet (combine)', value: :combine
61
- menu.choice name: 'Trim Transparency (trim)', value: :trim
62
- menu.choice name: 'Gif Split (gif_split)', value: :gif_split
63
- menu.choice name: 'Sepia', value: :sepia
64
- menu.choice name: 'Modulate', value: :modulate
65
- menu.choice name: 'TextToImage', value: :text_to_image
66
- menu.choice name: 'Index (Re-run Index)', value: :index
57
+ menu.choice name: 'Biggest: Find largest dimensions [biggest]', value: :biggest
58
+ menu.choice name: 'Convert alpha to white [white]', value: :white
59
+ menu.choice name: 'Resize WxH [resize]', value: :resize
60
+ menu.choice name: 'Scale [scale]', value: :scale
61
+ menu.choice name: 'Shift (Splice/Gravity) [shift]', value: :shift
62
+ menu.choice name: 'Roll [roll]', value: :roll
63
+ menu.choice name: 'Flip/Flop [flip_flop]', value: :flip_flop
64
+ menu.choice name: 'Rotate [rotate]', value: :rotate
65
+ menu.choice name: 'Canvas (Change/Retain) [canvas]', value: :canvas
66
+ menu.choice name: 'Desaturate (Grey Colorspace) [desaturate]', value: :desaturate
67
+ menu.choice name: 'Blur [blur]', value: :blur
68
+ menu.choice name: 'Split SpriteSheet [split]', value: :split
69
+ menu.choice name: 'Create SpriteSheet [combine]', value: :combine
70
+ menu.choice name: 'Double Image [double]', value: :double
71
+ menu.choice name: 'Trim Transparency (:trim]', value: :trim
72
+ menu.choice name: 'Gif Split [gif_split]', value: :gif_split
73
+ menu.choice name: 'Sepia [sepia]', value: :sepia
74
+ menu.choice name: 'Modulate [modulate]', value: :modulate
75
+ menu.choice name: 'Layers [layers]', value: :layers
76
+ menu.choice name: 'Bulk Rename [bulk_rename]', value: :bulk_rename
77
+ menu.choice name: 'Downcase Normalize [downcase_norm]', value: :downcase_norm
78
+ menu.choice name: 'Hue Modulate [hue_modulate]', value: :hue_modulate
79
+ menu.choice name: 'TextToImage [text_to_image]', value: :text_to_image
80
+ menu.choice name: 'Compress (file size) [compress]', value: :compress
81
+ menu.choice name: 'Index (Re-run Index) [index]', value: :index
67
82
  menu.choice name: 'exit', value: :exit
68
83
  end
69
84
  rescue TTY::Reader::InputInterrupt
70
85
  exit 0
71
86
  end
87
+ # rubocop:enable Metrics/BlockLength
72
88
 
73
89
  def self.prompt
74
90
  TTY::Prompt.new(active_color: :cyan, interrupt: :exit)