@@ -11,8 +11,9 @@ using UndertaleModLib.Models;
11
11
using UndertaleModLib . Util ;
12
12
using UndertaleModLib . Decompiler ;
13
13
14
+ string GameName = Data . GeneralInfo . Name . ToString ( ) . Replace ( @"""" , "" ) ; //Name == "Project" -> Project
14
15
int progress = 0 ;
15
- string projFolder = GetFolder ( FilePath ) + "Export_Project " + Path . DirectorySeparatorChar ;
16
+ string projFolder = GetFolder ( FilePath ) + GameName + ".gmx " + Path . DirectorySeparatorChar ;
16
17
TextureWorker worker = new TextureWorker ( ) ;
17
18
ThreadLocal < DecompileContext > DECOMPILE_CONTEXT = new ThreadLocal < DecompileContext > ( ( ) => new DecompileContext ( Data , false ) ) ;
18
19
string gmxDeclaration = "This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!" ;
@@ -213,10 +214,36 @@ void ExportGameObject(UndertaleGameObject gameObject)
213
214
new XElement ( "persistent" , BoolToString ( gameObject . Persistent ) ) ,
214
215
new XElement ( "parentName" , gameObject . ParentId is null ? "<undefined>" : gameObject . ParentId . Name . Content ) ,
215
216
new XElement ( "maskName" , gameObject . TextureMaskId is null ? "<undefined>" : gameObject . TextureMaskId . Name . Content ) ,
216
- new XElement ( "events" )
217
+ new XElement ( "events" ) ,
218
+
219
+ //Physics
220
+ new XElement ( "PhysicsObject" , BoolToString ( gameObject . UsesPhysics ) ) ,
221
+ new XElement ( "PhysicsObjectSensor" , BoolToString ( gameObject . IsSensor ) ) ,
222
+ new XElement ( "PhysicsObjectShape" , ( uint ) gameObject . CollisionShape ) ,
223
+ new XElement ( "PhysicsObjectDensity" , gameObject . Density ) ,
224
+ new XElement ( "PhysicsObjectRestitution" , gameObject . Restitution ) ,
225
+ new XElement ( "PhysicsObjectGroup" , gameObject . Group ) ,
226
+ new XElement ( "PhysicsObjectLinearDamping" , gameObject . LinearDamping ) ,
227
+ new XElement ( "PhysicsObjectAngularDamping" , gameObject . AngularDamping ) ,
228
+ new XElement ( "PhysicsObjectFriction" , gameObject . Friction ) ,
229
+ new XElement ( "PhysicsObjectAwake" , BoolToString ( gameObject . Awake ) ) ,
230
+ new XElement ( "PhysicsObjectKinematic" , BoolToString ( gameObject . Kinematic ) ) ,
231
+ new XElement ( "PhysicsShapePoints" )
217
232
)
218
233
) ;
219
234
235
+
236
+
237
+ // Loop through PhysicsShapePoints List
238
+ for ( int _point = 0 ; _point < gameObject . PhysicsVertices . Count ; _point ++ )
239
+ {
240
+ var _x = gameObject . PhysicsVertices [ _point ] . X ;
241
+ var _y = gameObject . PhysicsVertices [ _point ] . Y ;
242
+
243
+ var physicsPointsNode = gmx . Element ( "object" ) . Element ( "PhysicsShapePoints" ) ;
244
+ physicsPointsNode . Add ( new XElement ( "points" , _x . ToString ( ) + "," + _y . ToString ( ) ) ) ;
245
+ }
246
+
220
247
// Traversing the event type list
221
248
for ( int i = 0 ; i < gameObject . Events . Count ; i ++ )
222
249
{
@@ -273,12 +300,11 @@ void ExportGameObject(UndertaleGameObject gameObject)
273
300
eventNode . Add ( actionNode ) ;
274
301
eventsNode . Add ( eventNode ) ;
275
302
276
- // TODO:Physics
277
303
}
278
304
}
279
305
}
280
306
281
- File . WriteAllText ( projFolder + "/objects/" + gameObject . Name . Content + ".object.gmx" , gmx . ToString ( ) ) ;
307
+ File . WriteAllText ( projFolder + "/objects/" + gameObject . Name . Content + ".object.gmx" , gmx . ToString ( ) + " \n " ) ;
282
308
}
283
309
284
310
// --------------- Export Room ---------------
@@ -307,10 +333,25 @@ void ExportRoom(UndertaleRoom room)
307
333
new XElement ( "code" , room . CreationCodeId != null ? Decompiler . Decompile ( room . CreationCodeId , DECOMPILE_CONTEXT . Value ) : "" ) ,
308
334
new XElement ( "enableViews" , BoolToString ( room . Flags . HasFlag ( UndertaleRoom . RoomEntryFlags . EnableViews ) ) ) ,
309
335
new XElement ( "clearViewBackground" , BoolToString ( room . Flags . HasFlag ( UndertaleRoom . RoomEntryFlags . ShowColor ) ) ) ,
310
- new XElement ( "clearDisplayBuffer" , BoolToString ( room . Flags . HasFlag ( UndertaleRoom . RoomEntryFlags . ClearDisplayBuffer ) ) )
336
+ new XElement ( "clearDisplayBuffer" , BoolToString ( room . Flags . HasFlag ( UndertaleRoom . RoomEntryFlags . ClearDisplayBuffer ) ) ) ,
337
+ new XElement ( "makerSettings" ,
338
+ new XElement ( "isSet" , 0 ) ,
339
+ new XElement ( "w" , 0 ) ,
340
+ new XElement ( "h" , 0 ) ,
341
+ new XElement ( "showGrid" , 0 ) ,
342
+ new XElement ( "showObjects" , 0 ) ,
343
+ new XElement ( "showTiles" , 0 ) ,
344
+ new XElement ( "showBackgrounds" , 0 ) ,
345
+ new XElement ( "showForegrounds" , 0 ) ,
346
+ new XElement ( "showViews" , 0 ) ,
347
+ new XElement ( "deleteUnderlyingObj" , 0 ) ,
348
+ new XElement ( "deleteUnderlyingTiles" , 0 ) ,
349
+ new XElement ( "page" , 0 ) ,
350
+ new XElement ( "xoffset" , 0 ) ,
351
+ new XElement ( "yoffset" , 0 )
352
+ )
311
353
)
312
354
) ;
313
- // TODO:MakerSettings
314
355
315
356
// Room backgrounds
316
357
var backgroundsNode = new XElement ( "backgrounds" ) ;
@@ -399,9 +440,20 @@ void ExportRoom(UndertaleRoom room)
399
440
}
400
441
gmx . Element ( "room" ) . Add ( tilesNode ) ;
401
442
402
- // TODO:Room physics
403
-
404
- File . WriteAllText ( projFolder + "/rooms/" + room . Name . Content + ".room.gmx" , gmx . ToString ( ) ) ;
443
+ //Room Physics
444
+
445
+ gmx . Element ( "room" ) . Add (
446
+ new XElement ( "PhysicsWorld" , room . World ) ,
447
+ new XElement ( "PhysicsWorldTop" , room . Top ) ,
448
+ new XElement ( "PhysicsWorldLeft" , room . Left ) ,
449
+ new XElement ( "PhysicsWorldRight" , room . Right ) ,
450
+ new XElement ( "PhysicsWorldBottom" , room . Bottom ) ,
451
+ new XElement ( "PhysicsWorldGravityX" , room . GravityX ) ,
452
+ new XElement ( "PhysicsWorldGravityY" , room . GravityY ) ,
453
+ new XElement ( "PhysicsWorldPixToMeters" , room . MetersPerPixel )
454
+ ) ;
455
+
456
+ File . WriteAllText ( projFolder + "/rooms/" + room . Name . Content + ".room.gmx" , gmx . ToString ( ) + "\n " ) ;
405
457
}
406
458
407
459
// --------------- Export Sound ---------------
@@ -422,9 +474,13 @@ void ExportSound(UndertaleSound sound)
422
474
new XElement ( "extension" , Path . GetExtension ( sound . File . Content ) ) ,
423
475
new XElement ( "origname" , "sound\\ audio\\ " + sound . File . Content ) ,
424
476
new XElement ( "effects" , sound . Effects . ToString ( ) ) ,
425
- new XElement ( "volume" , sound . Volume . ToString ( ) ) ,
477
+ new XElement ( "volume" ,
478
+ new XElement ( "volume" , sound . Volume . ToString ( ) )
479
+ ) ,
426
480
new XElement ( "pan" , "0" ) ,
427
- new XElement ( "bitRates" , "192" ) ,
481
+ new XElement ( "bitRates" ,
482
+ new XElement ( "bitRate" , "192" )
483
+ ) ,
428
484
new XElement ( "sampleRates" ,
429
485
new XElement ( "sampleRate" , "44100" )
430
486
) ,
@@ -443,7 +499,7 @@ void ExportSound(UndertaleSound sound)
443
499
)
444
500
) ;
445
501
446
- File . WriteAllText ( projFolder + "/sound/" + sound . Name . Content + ".sound.gmx" , gmx . ToString ( ) ) ;
502
+ File . WriteAllText ( projFolder + "/sound/" + sound . Name . Content + ".sound.gmx" , gmx . ToString ( ) + " \n " ) ;
447
503
448
504
// Save sound files
449
505
if ( sound . AudioFile != null )
@@ -626,7 +682,7 @@ void GenerateProjectFile()
626
682
WriteIndexes < UndertalePath > ( gmx . Element ( "assets" ) , "paths" , "paths" , Data . Paths , "path" , "paths\\ " ) ;
627
683
WriteIndexes < UndertaleTimeline > ( gmx . Element ( "assets" ) , "timelines" , "timelines" , Data . Timelines , "timeline" , "timelines\\ " ) ;
628
684
629
- File . WriteAllText ( projFolder + "Export_Project .project.gmx", gmx . ToString ( ) ) ;
685
+ File . WriteAllText ( projFolder + GameName + " .project.gmx", gmx . ToString ( ) ) ;
630
686
}
631
687
632
688
void WriteIndexes < T > ( XElement rootNode , string elementName , string attributeName , IList < T > dataList , string oneName , string resourcePath , string fileExtension = "" )
0 commit comments