-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssetDisplayer.csx
147 lines (123 loc) · 3.97 KB
/
AssetDisplayer.csx
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
using System;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Collections.Generic;
// Ensure data is loaded
EnsureDataLoaded();
// the path that the script operates in
string datapath = $"{Path.GetDirectoryName(FilePath)}\\exported_assets\\";
// create directory if it doesnt exist
if (!Directory.Exists(datapath))
Directory.CreateDirectory(datapath);
public class GMConstants
{
public static Dictionary<int, string> Colors { get; } = new()
{
{ 16776960, "c_aqua" },
{ 0, "c_black" },
{ 16711680, "c_blue" },
{ 4210752, "c_dkgray" },
{ 16711935, "c_fuchsia" },
{ 8421504, "c_gray" },
{ 32768, "c_green" },
{ 65280, "c_lime" },
{ 12632256, "c_ltgray" },
{ 128, "c_maroon" },
{ 8388608, "c_navy" },
{ 32896, "c_olive" },
{ 4235519, "c_orange" },
{ 8388736, "c_purple" },
{ 255, "c_red" },
{ 8421376, "c_teal" },
{ 16777215, "c_white" },
{ 65535, "c_yellow" }
};
public static Dictionary<int, string> InstanceKeywords { get; } = new()
{
{ -1, "self" },
{ -2, "other" },
{ -3, "all" },
{ -4, "noone" }
};
// TODO: add more constants
}
// every important asset type including their place in Data
var assets = new List<(string filename, dynamic data)>
{
("audiogroups", Data.AudioGroups),
("sounds", Data.Sounds),
("sprites", Data.Sprites),
("tilesets", Data.Backgrounds),
("paths", Data.Paths),
("scripts", Data.Scripts),
("shaders", Data.Shaders),
("fonts", Data.Fonts),
("timelines", Data.Timelines),
("objects", Data.GameObjects),
("rooms", Data.Rooms),
("extensions", Data.Extensions)
};
var constants = new List<(string filename, dynamic data)>
{
("colors", GMConstants.Colors),
("instancekeywords", GMConstants.InstanceKeywords)
};
void DumpIDS()
{
// loop through assets
foreach (var asset in assets)
{
// create name for the text file
string txtfile = $"{datapath}{asset.filename}.txt";
// clear the text file.
File.WriteAllText(txtfile, String.Empty);
// streamwriter automatically creates and writes to the text file
using (StreamWriter sw = new StreamWriter(txtfile, true, Encoding.Default))
{
// loop through each asset
for (var i = 0; i < asset.data.Count; i++)
{
// append a new line to the streamwriter and therefore the text file
sw.WriteLine($"{i} : {asset.data[i].Name.ToString().Replace("\"", "")},"); // turn the asset name into a normal string, and then remove the quotes
}
}
}
}
// seperate from other ID's because theyre constants, not assets
// I hate repeating code :(
void DumpConstants()
{
string constants_path = $"{datapath}constants\\";
// create directory if it doesnt exist
if (!Directory.Exists(constants_path))
Directory.CreateDirectory(constants_path);
// loop through constants
foreach (var dict in constants)
{
// create name for the text file
string txtfile = $"{constants_path}{dict.filename}.txt";
// clear the text file.
File.WriteAllText(txtfile, String.Empty);
// streamwriter automatically creates and writes to the text file
using (StreamWriter sw = new StreamWriter(txtfile, true, Encoding.Default))
{
// loop through each constant
foreach (var kvp in dict.data)
{
// append a new line to the streamwriter and therefore the text file
sw.WriteLine($"{kvp.Key} : {kvp.Value}");
}
}
}
}
bool dump_ids = (ScriptQuestion("Dump ID's?"));
bool dump_constants = (ScriptQuestion("Dump Constants?"));
// run the methods
if (dump_ids)
DumpIDS();
if (dump_constants)
DumpConstants();
// this displays when the script is over
MessageBox.Show("Done!");