-
Notifications
You must be signed in to change notification settings - Fork 1
/
rakefile
executable file
·104 lines (84 loc) · 2.38 KB
/
rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
require "./environment.rb"
require "./properties.rb"
require 'find'
def dds_files
FileList['textures/*.png'].map do |file_name|
file_name.gsub(/\.png$/, '.dds')
end
end
def compression_methods
{
'_albedo' => 'bc1',
'_albedo_opacity' => 'bc3',
'_metal_gloss_ao' => 'bc1',
'_normal' => 'bc5'
}
end
def compression_method_by_file_ending(file_name)
compression_methods.each do |file_ending, compression_method|
if file_name.end_with?("#{file_ending}.png") then
return compression_method
end
end
null
end
def mod_name
author_prefix + '_' + technical_name + '_' + version_postfix.to_s()
end
def version_postfix
properties[:major_version]
end
def author_prefix
properties[:author_prefix]
end
def technical_name
properties[:technical_name]
end
def transport_fever_mod_path
environment[:transport_fever_path] + '/mods'
end
def staging_area
environment[:staging_area]
end
def staging_area_path
staging_area + '/' + mod_name
end
task push: [] do
puts 'pushing mod to staging area'
sh "cp -R ./mod/. #{staging_area_path}/"
end
task :clean_staging_area do
puts 'cleal staging area'
sh "rm -rf #{staging_area_path}/"
end
task :remove_tests do
puts 'removing test files'
sh "rm #{staging_area_path}/res/scripts/*_spec.lua"
sh "rm #{staging_area_path}/res/scripts/motras_testutils.lua"
end
task :remove_debug do
puts 'removing debug stuff'
sh "rm #{staging_area_path}/res/scripts/inspect.lua"
sh "rm #{staging_area_path}/res/scripts/env.lua"
sh "rm -rf #{staging_area_path}/res/models/model/vehicle"
end
task cleanpush: [:clean_staging_area, :push]
task release: [:cleanpush, :remove_debug, :remove_tests]
task pull: [] do
puts 'pulling mod from staging area'
sh "cp -R #{staging_area_path}/. ./mod"
end
task dds: [:textures] do
sh "cp ./textures/*.dds ./mod/res/textures"
end
file "textures" => dds_files
rule '.dds' => ['.png'] do |t|
compression = compression_method_by_file_ending(t.source)
if !compression then
puts 'Unknown file ending'
return null
end
sh "magick #{t.source} -flip -size #{properties[:texture_resolution]} temp.png"
sh "nvcompress -color -#{compression} temp.png #{t.name}"
sh "rm temp.png"
end