@@ -13,7 +13,6 @@ using UndertaleModLib.Decompiler;
13
13
14
14
int progress = 0 ;
15
15
string projFolder = GetFolder ( FilePath ) + "Export_Project" + Path . DirectorySeparatorChar ;
16
- var context = new DecompileContext ( Data , true ) ;
17
16
TextureWorker worker = new TextureWorker ( ) ;
18
17
ThreadLocal < DecompileContext > DECOMPILE_CONTEXT = new ThreadLocal < DecompileContext > ( ( ) => new DecompileContext ( Data , false ) ) ;
19
18
string gmxDeclaration = "This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!" ;
@@ -28,47 +27,45 @@ Directory.CreateDirectory(projFolder);
28
27
29
28
// --------------- Start exporting ---------------
30
29
31
- var resourceNum = 10 ;
30
+ var resourceNum = Data . Sprites . Count +
31
+ Data . Backgrounds . Count +
32
+ Data . GameObjects . Count +
33
+ Data . Rooms . Count +
34
+ Data . Sounds . Count +
35
+ Data . Scripts . Count +
36
+ Data . Fonts . Count +
37
+ Data . Paths . Count +
38
+ Data . Timelines . Count ;
32
39
33
40
// Export sprites
34
- UpdateProgressBar ( null , "Exporting sprites..." , progress ++ , resourceNum ) ;
35
41
await ExportSprites ( ) ;
36
42
37
43
// Export backgrounds
38
- UpdateProgressBar ( null , "Exporting backgrounds..." , progress ++ , resourceNum ) ;
39
44
await ExportBackground ( ) ;
40
45
41
46
// Export objects
42
- UpdateProgressBar ( null , "Exporting objects..." , progress ++ , resourceNum ) ;
43
47
await ExportGameObjects ( ) ;
44
48
45
49
// Export rooms
46
- UpdateProgressBar ( null , "Exporting rooms..." , progress ++ , resourceNum ) ;
47
50
await ExportRooms ( ) ;
48
51
49
52
// Export sounds
50
- UpdateProgressBar ( null , "Exporting sounds..." , progress ++ , resourceNum ) ;
51
53
await ExportSounds ( ) ;
52
54
53
55
// Export scripts
54
- UpdateProgressBar ( null , "Exporting scripts..." , progress ++ , resourceNum ) ;
55
56
await ExportScripts ( ) ;
56
57
57
58
// Export fonts
58
- UpdateProgressBar ( null , "Exporting fonts..." , progress ++ , resourceNum ) ;
59
59
await ExportFonts ( ) ;
60
60
61
61
// Export paths
62
- UpdateProgressBar ( null , "Exporting paths..." , progress ++ , resourceNum ) ;
63
62
await ExportPaths ( ) ;
64
63
65
64
// Export timelines
66
- UpdateProgressBar ( null , "Exporting timelines..." , progress ++ , resourceNum ) ;
67
65
await ExportTimelines ( ) ;
68
66
69
67
// Generate project file
70
- UpdateProgressBar ( null , "Generating project file..." , progress ++ , resourceNum ) ;
71
- ExportProjectFile ( ) ;
68
+ GenerateProjectFile ( ) ;
72
69
73
70
// --------------- Export completed ---------------
74
71
worker . Cleanup ( ) ;
@@ -93,6 +90,8 @@ async Task ExportSprites()
93
90
}
94
91
void ExportSprite ( UndertaleSprite sprite )
95
92
{
93
+ UpdateProgressBar ( null , $ "Exporting sprite: { sprite . Name . Content } ", progress ++ , resourceNum ) ;
94
+
96
95
// Save the sprite GMX
97
96
var gmx = new XDocument (
98
97
new XComment ( gmxDeclaration ) ,
@@ -163,6 +162,8 @@ async Task ExportBackground()
163
162
}
164
163
void ExportBackground ( UndertaleBackground background )
165
164
{
165
+ UpdateProgressBar ( null , $ "Exporting background: { background . Name . Content } ", progress ++ , resourceNum ) ;
166
+
166
167
// Save the backgound GMX
167
168
var gmx = new XDocument (
168
169
new XComment ( gmxDeclaration ) ,
@@ -199,6 +200,8 @@ async Task ExportGameObjects()
199
200
}
200
201
void ExportGameObject ( UndertaleGameObject gameObject )
201
202
{
203
+ UpdateProgressBar ( null , $ "Exporting object: { gameObject . Name . Content } ", progress ++ , resourceNum ) ;
204
+
202
205
// Save the object GMX
203
206
var gmx = new XDocument (
204
207
new XComment ( gmxDeclaration ) ,
@@ -286,6 +289,8 @@ async Task ExportRooms()
286
289
}
287
290
void ExportRoom ( UndertaleRoom room )
288
291
{
292
+ UpdateProgressBar ( null , $ "Exporting room: { room . Name . Content } ", progress ++ , resourceNum ) ;
293
+
289
294
// Save the room GMX
290
295
var gmx = new XDocument (
291
296
new XComment ( gmxDeclaration ) ,
@@ -299,7 +304,7 @@ void ExportRoom(UndertaleRoom room)
299
304
new XElement ( "speed" , room . Speed . ToString ( ) ) ,
300
305
new XElement ( "persistent" , BoolToString ( room . Persistent ) ) ,
301
306
new XElement ( "colour" , room . BackgroundColor . ToString ( ) ) ,
302
- new XElement ( "code" , room . CreationCodeId is null ? "" : Decompiler . Decompile ( room . CreationCodeId , context ) ) ,
307
+ new XElement ( "code" , room . CreationCodeId != null ? Decompiler . Decompile ( room . CreationCodeId , DECOMPILE_CONTEXT . Value ) : "" ) ,
303
308
new XElement ( "enableViews" , BoolToString ( room . Flags . HasFlag ( UndertaleRoom . RoomEntryFlags . EnableViews ) ) ) ,
304
309
new XElement ( "clearViewBackground" , BoolToString ( room . Flags . HasFlag ( UndertaleRoom . RoomEntryFlags . ShowColor ) ) ) ,
305
310
new XElement ( "clearDisplayBuffer" , BoolToString ( room . Flags . HasFlag ( UndertaleRoom . RoomEntryFlags . ClearDisplayBuffer ) ) )
@@ -407,6 +412,8 @@ async Task ExportSounds()
407
412
}
408
413
void ExportSound ( UndertaleSound sound )
409
414
{
415
+ UpdateProgressBar ( null , $ "Exporting sound: { sound . Name . Content } ", progress ++ , resourceNum ) ;
416
+
410
417
// Save the sound GMX
411
418
var gmx = new XDocument (
412
419
new XComment ( gmxDeclaration ) ,
@@ -451,6 +458,8 @@ async Task ExportScripts()
451
458
}
452
459
void ExportScript ( UndertaleScript script )
453
460
{
461
+ UpdateProgressBar ( null , $ "Exporting script: { script . Name . Content } ", progress ++ , resourceNum ) ;
462
+
454
463
// Save GML files
455
464
File . WriteAllText ( projFolder + "/scripts/" + script . Name . Content + ".gml" , ( script . Code != null ? Decompiler . Decompile ( script . Code , DECOMPILE_CONTEXT . Value ) : "" ) ) ;
456
465
}
@@ -463,6 +472,8 @@ async Task ExportFonts()
463
472
}
464
473
void ExportFont ( UndertaleFont font )
465
474
{
475
+ UpdateProgressBar ( null , $ "Exporting font: { font . Name . Content } ", progress ++ , resourceNum ) ;
476
+
466
477
// Save the font GMX
467
478
var gmx = new XDocument (
468
479
new XComment ( gmxDeclaration ) ,
@@ -516,6 +527,8 @@ async Task ExportPaths()
516
527
}
517
528
void ExportPath ( UndertalePath path )
518
529
{
530
+ UpdateProgressBar ( null , $ "Exporting path: { path . Name . Content } ", progress ++ , resourceNum ) ;
531
+
519
532
// Save the path GMX
520
533
var gmx = new XDocument (
521
534
new XComment ( gmxDeclaration ) ,
@@ -548,6 +561,8 @@ async Task ExportTimelines()
548
561
}
549
562
void ExportTimeline ( UndertaleTimeline timeline )
550
563
{
564
+ UpdateProgressBar ( null , $ "Exporting timeline: { timeline . Name . Content } ", progress ++ , resourceNum ) ;
565
+
551
566
// Save the timeline GMX
552
567
var gmx = new XDocument (
553
568
new XComment ( gmxDeclaration ) ,
@@ -591,8 +606,10 @@ void ExportTimeline(UndertaleTimeline timeline)
591
606
592
607
593
608
// --------------- Generate project file ---------------
594
- void ExportProjectFile ( )
609
+ void GenerateProjectFile ( )
595
610
{
611
+ UpdateProgressBar ( null , $ "Generating project file...", progress ++ , resourceNum ) ;
612
+
596
613
var gmx = new XDocument (
597
614
new XComment ( gmxDeclaration ) ,
598
615
new XElement ( "assets" )
0 commit comments