-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtranslation_convert.gd
85 lines (71 loc) · 1.62 KB
/
translation_convert.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
extends Control
var s1;
var s2;
var s3;
var s4;
var f1;
var f2;
var f3;
var f4;
func _on_Button_pressed():
$load.popup();
pass # Replace with function body.
func _on_Button2_pressed():
$save.popup();
pass # Replace with function body.
func _on_Button3_pressed():
f1 = File.new();
f1.open(s1, File.READ);
f2 = File.new();
f2.open(s2, File.READ_WRITE);
f2.seek_end();
f3 = File.new();
f3.open(s3, File.WRITE);
var scene = parse_json(f1.get_as_text());
var ff = s1.get_file();
var count = 1;
f3.store_line('[');
for tmp in scene:
if tmp['effect'] == 'text':
var s = tmp['value'];
var s_n = "%s_%d" % [ff, count];
var tr_line = '%s,"%s"' % [s_n, s];
var new_tmp = tmp.duplicate();
new_tmp['value'] = s_n;
f2.store_line(tr_line);
f3.store_line(to_json(new_tmp)+',');
count += 1;
pass
else:
f3.store_line(to_json(tmp)+',');
pass
pass
f3.store_line(']');
print("FINISH");
$load.invalidate();
pass # Replace with function body.
func _on_Button4_pressed():
f1 = File.new();
f1.open(s1, File.READ);
f4 = File.new();
f4.open(s4, File.WRITE);
var scene = parse_json(f1.get_as_text());
for tmp in scene:
if tmp['effect'] == 'text':
tmp.value = tr(tmp.value);
pass
var buf = to_json(scene);
buf = buf.replace('},','},\r\n');
f4.store_string(buf);
print("FINISH");
f4.close();
$load.invalidate();
pass
func _on_load_file_selected(path):
s1 = path;
s3 = s1.get_basename() + '_convert.json';
s4 = s1.get_basename().replace('_convert', '') + '_updated.json';
pass # Replace with function body.
func _on_save_file_selected(path):
s2 = path;
pass # Replace with function body.