-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustom.gd
180 lines (113 loc) · 4.03 KB
/
Custom.gd
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
extends Node
const SUPPORTER_PACK = 2232850
var hitsparks = {
"bash":"res://fx/HitEffect1.tscn",
"bash2":"res://fx/hitsparks/HitEffect1Alt.tscn",
"fire":"res://fx/hitsparks/FireHitEffect.tscn",
"hearts":"res://fx/hitsparks/HeartHitEffect.tscn",
"petals":"res://fx/hitsparks/PetalHitEffect.tscn",
"coins":"res://fx/hitsparks/CoinHitEffect.tscn",
}
var p1_selected_style = null
var p2_selected_style = null
var simple_colors = ["94e4ff", "ffc1a1", "ecffa4", "fec2ff", "6e8696", "ffea5d", "04579a", "85001f", "008561", "9f42ba", "343537", "ff9444"]
var simple_outlines = ["04579a", "85001f", "008561", "9f42ba", "343537", "ff9444", "94e4ff", "ffc1a1", "ecffa4", "fec2ff", "6e8696", "ffea5d"]
func _ready():
for i in range(simple_colors.size()):
simple_colors[i] = Color(simple_colors[i])
simple_outlines[i] = Color(simple_outlines[i])
make_custom_folder()
func make_custom_folder():
var dir = Directory.new()
if not dir.dir_exists("user://custom"):
dir.make_dir("user://custom")
func apply_style_to_material(style, material:ShaderMaterial, force_extras = false):
if style.character_color != null:
material.set_shader_param("color", style.character_color)
material.set_shader_param("use_outline", style.use_outline)
if style.outline_color != null:
material.set_shader_param("outline_color", style.outline_color)
if style.get("extra_color_1") != null:
material.set_shader_param("extra_color_1", style.extra_color_1)
if force_extras:
material.set_shader_param("use_extra_color_1", true)
else :
material.set_shader_param("use_extra_color_1", false)
if style.get("extra_color_2") != null:
material.set_shader_param("extra_color_2", style.extra_color_2)
if force_extras:
material.set_shader_param("use_extra_color_2", true)
else :
material.set_shader_param("use_extra_color_2", false)
pass
func is_combo_simple(color, outline):
return simple_colors.find(color) == simple_outlines.find(outline)
func is_color_dlc(color):
if color == null:
return false
if not (color is Color):
return not (Color(color) in simple_colors)
return not (color in simple_colors)
func is_outline_dlc(color):
if color == null:
return false
if not (color is Color):
return not (Color(color) in simple_outlines)
return not (color in simple_outlines)
func hitspark_to_dlc(spark_name):
return 0
func can_use_style(player_id, style):
if not requires_dlc(style):
return Global.full_version()
return true
func requires_dlc(data):
return false
func save_style(style):
make_custom_folder()
var file = File.new()
var filename_ = "user://custom/" + style.style_name + ".style"
file.open(filename_, File.WRITE)
file.store_var(style, true)
file.close()
return filename_
func save_style_workshop(style):
var dir = Directory.new()
var file = File.new()
var folder_path = "user://custom/" + style.style_name
if not dir.dir_exists(folder_path):
dir.make_dir(folder_path)
var filename_ = folder_path + "/" + style.style_name + ".style"
file.open(filename_, File.WRITE)
file.store_var(style, true)
file.close()
return folder_path
func load_all_styles():
make_custom_folder()
var dir = Directory.new()
var files = []
var _directories = []
var styles = []
dir.open("user://custom")
dir.list_dir_begin(false, true)
Global.add_dir_contents(dir, files, _directories, false, ".style")
if SteamHustle.STARTED and SteamHustle.WORKSHOP_ENABLED:
var workshop = SteamWorkshop.new()
for item in Steam.getSubscribedItems():
var info:Dictionary
info = workshop.get_item_install_info(item)
if info.ret:
dir.open(info.folder)
dir.list_dir_begin(false, true)
Global.add_dir_contents(dir, files, _directories, false, ".style")
files.sort_custom(self, "sort_styles")
for path in files:
var file = File.new()
file.open(path, File.READ)
var data:Dictionary = file.get_var()
styles.append(data)
file.close()
return [styles, files]
func get_style_name(path):
return path.get_file().split(".")[0].strip_edges()
func sort_styles(a:String, b:String):
return get_style_name(a) < get_style_name(b)