-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
85 lines (68 loc) · 3.14 KB
/
app.py
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
import os
from resource_wrangler.gui_builder import detect_regions, build_gui
from resource_wrangler.main import run
minor_versions = {
'fanver': [16, 15, 12, 11, 10, 8, 7, 6, 5],
'jstr': [5, 6, 7, 8, 9, 10, 12, 16],
'faithful': [5, 6, 7, 8, 10, 11, 12, 16]
}
def test_gui_builder():
template_dir = "/Users/michael/graphics/fanver/Resource-Wrangler/resource_wrangler/configs/gui_templates/"
test_path = "/Users/michael/graphics/fanver/Templates/python_package/app_test.png"
colossal_gui_path = "/Users/michael/graphics/default/Modded-1.15.x/Colossal_Chests/assets/colossalchests/textures/gui/colossal_chest.png"
default_template_dir = os.path.join(template_dir, "default")
fanver_wood_template_dir = os.path.join(template_dir, "fanver_wood")
regions, size = detect_regions(
default_gui_path=colossal_gui_path,
default_template_dir=default_template_dir,
debug_path=test_path)
output_image = build_gui(
regions=regions,
size=size,
resource_template_dir=fanver_wood_template_dir)
output_image.save(test_path)
def port_complete_graph(resource_pack_name):
import itertools
import timeit
# reverse-order so that newer textures get priority
mc_versions = [f'1.{minor_version}.x' for minor_version in reversed(sorted(minor_versions[resource_pack_name]))]
pipeline = []
for from_version, to_version in itertools.combinations_with_replacement(mc_versions, r=2):
pipeline.append({
"task": "port_patches",
"default_prior": f"default-modded-{from_version}",
"default_post": f"default-modded-{to_version}",
"resource_prior": f"{resource_pack_name}-modded-{from_version}",
"resource_post": f"{resource_pack_name}-modded-{to_version}",
"action": "copy",
"all_patch": resource_pack_name == 'faithful'
})
if resource_pack_name != 'faithful':
pipeline.append({
'task': 'merge_patches',
'resource': f'{resource_pack_name}-modded-{to_version}'
})
if from_version != to_version:
pipeline.append({
"task": "port_patches",
"default_prior": f"default-modded-{to_version}",
"default_post": f"default-modded-{from_version}",
"resource_prior": f"{resource_pack_name}-modded-{to_version}",
"resource_post": f"{resource_pack_name}-modded-{from_version}",
"action": "copy",
"all_patch": resource_pack_name == 'faithful'
})
if resource_pack_name != 'faithful':
pipeline.append({
'task': 'merge_patches',
'resource': f'{resource_pack_name}-modded-{from_version}'
})
elapsed_time = timeit.Timer(
lambda: run(
f"{resource_pack_name}_complete_port",
pipelines={f"{resource_pack_name}_complete_port": pipeline}), 'gc.enable()'
).timeit(number=1)
print(f"Elapsed time: {elapsed_time}")
# port_complete_graph("fanver")
# port_complete_graph("jstr")
# port_complete_graph("faithful")