-
Notifications
You must be signed in to change notification settings - Fork 7
/
Custom.gd
184 lines (160 loc) · 5.48 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
181
182
183
184
extends Node
const SUPPORTER_PACK = 2232850
var hitsparks = {
"bash": "res://fx/HitEffect1.tscn",
"bash2": "res://fx/hitsparks/HitEffect1Alt.tscn",
"bash3": "res://fx/hitsparks/HitEffect2Alt.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",
"dust": "res://fx/hitsparks/DustHitEffect.tscn",
"acid": "res://fx/hitsparks/AcidHitEffect.tscn",
"elec": "res://fx/hitsparks/ElectricHitEffect.tscn",
}
#var hitspark_dlc = {
# "bash": false,
# "bash2": false,
# "hearts": true,
#}
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 !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 !(color is Color):
return !(Color(color) in simple_colors)
return !(color in simple_colors)
func is_outline_dlc(color):
if color == null:
return false
if !(color is Color):
return !(Color(color) in simple_outlines)
return !(color in simple_outlines)
func hitspark_to_dlc(spark_name):
# if spark_name in hitspark_dlc:
# return hitspark_dlc[spark_name]
return 0
func can_use_style(player_id, style):
if !requires_dlc(style):
return Global.full_version()
return true
# if !Network.multiplayer_active:
## return Global.has_supporter_pack()
# return true
# elif SteamHustle.STARTED:
# if SteamLobby.SPECTATING:
# return true
# if player_id == SteamLobby.PLAYER_SIDE:
# var has_supporter_pack = SteamHustle.has_supporter_pack(SteamHustle.STEAM_ID)
# if has_supporter_pack:
# print("You have the supporter pack.")
# else:
# print("You do not have the supporter pack.")
# return has_supporter_pack
# elif SteamLobby.OPPONENT_ID != 0:
# var has_supporter_pack = SteamHustle.has_supporter_pack(SteamLobby.OPPONENT_ID)
# if has_supporter_pack:
# print("Your opponent has the supporter pack.")
# else:
# print("Your opponent does not have the supporter pack.")
# return has_supporter_pack
func requires_dlc(data):
# return false
# if data == null:
# return false
# if data.show_aura:
# return true
# if is_color_dlc(data.character_color):
# return true
# if data.use_outline and is_outline_dlc(data.outline_color):
# return true
# if data.use_outline and !is_combo_simple(data.character_color, data.outline_color):
# return true
# if hitspark_to_dlc(data.hitspark):
# return true
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 !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)
# print(dir.get_current_dir())
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 file in files:
# print(get_style_name(file))
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)