Skip to content

Commit

Permalink
fix: Update folder assignment to handle root level resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
shichen85 authored and adam-coster committed Oct 1, 2020
1 parent 6350afa commit ebad310
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 4 deletions.
5 changes: 4 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
+ ~~Add methods to update version in files~~
+ ~~Add requirement that working directory be clean (i.e. things are safely packed away into a Git commit)~~
+ ~~Separately identify case where Git is not even available so that error message is more useful.~~
+ ~~Add CLI commands~~

<b style="color:red">⚠ NOT YET IMPLEMENTED ⚠</b>

+ Add git pre-commit hook to convert all .yy and .yyp files to plain JSON to minimize conflicts.
+ Add CLI commands
+ Spine! Where does the file go?
+ Figure out the per-platform flags that GMS2 uses for masks
1 change: 1 addition & 0 deletions sample-project/sample-project.yyp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"resources": [
{"id":{"name":"Sprite2","path":"sprites/Sprite2/Sprite2.yy",},"order":17,},
{"id":{"name":"object","path":"objects/object/object.yy",},"order":4,},
{"id":{"name":"sprite","path":"sprites/sprite/sprite.yy",},"order":12,},
{"id":{"name":"conflictingFont","path":"fonts/conflictingFont/conflictingFont.yy",},"order":0,},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions sample-project/sprites/Sprite2/Sprite2.yy
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"bboxMode": 0,
"collisionKind": 1,
"type": 0,
"origin": 0,
"preMultiplyAlpha": false,
"edgeFiltering": false,
"collisionTolerance": 0,
"swfPrecision": 2.525,
"bbox_left": 14,
"bbox_right": 41,
"bbox_top": 20,
"bbox_bottom": 39,
"HTile": false,
"VTile": false,
"For3D": false,
"width": 64,
"height": 64,
"textureGroupId": {
"name": "Default",
"path": "texturegroups/Default",
},
"swatchColours": null,
"gridX": 0,
"gridY": 0,
"frames": [
{"compositeImage":{"FrameId":{"name":"9da4434d-3c24-4958-b3cd-1bd466bfa2e4","path":"sprites/Sprite2/Sprite2.yy",},"LayerId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMSpriteBitmap",},"images":[
{"FrameId":{"name":"9da4434d-3c24-4958-b3cd-1bd466bfa2e4","path":"sprites/Sprite2/Sprite2.yy",},"LayerId":{"name":"a3d43c4c-295b-46cc-b8d4-bb9ba2bf5d26","path":"sprites/Sprite2/Sprite2.yy",},"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMSpriteBitmap",},
],"parent":{"name":"Sprite2","path":"sprites/Sprite2/Sprite2.yy",},"resourceVersion":"1.0","name":"9da4434d-3c24-4958-b3cd-1bd466bfa2e4","tags":[],"resourceType":"GMSpriteFrame",},
],
"sequence": {
"spriteId": {"name":"Sprite2","path":"sprites/Sprite2/Sprite2.yy",},
"timeUnits": 1,
"playback": 1,
"playbackSpeed": 30.0,
"playbackSpeedType": 0,
"autoRecord": true,
"volume": 1.0,
"length": 1.0,
"events": {"Keyframes":[],"resourceVersion":"1.0","resourceType":"KeyframeStore<MessageEventKeyframe>",},
"moments": {"Keyframes":[],"resourceVersion":"1.0","resourceType":"KeyframeStore<MomentsEventKeyframe>",},
"tracks": [
{"name":"frames","spriteId":null,"keyframes":{"Keyframes":[
{"id":"6bb2af56-ec32-439e-a4c6-31be67e0282c","Key":0.0,"Length":1.0,"Stretch":false,"Disabled":false,"IsCreationKey":false,"Channels":{"0":{"Id":{"name":"9da4434d-3c24-4958-b3cd-1bd466bfa2e4","path":"sprites/Sprite2/Sprite2.yy",},"resourceVersion":"1.0","resourceType":"SpriteFrameKeyframe",},},"resourceVersion":"1.0","resourceType":"Keyframe<SpriteFrameKeyframe>",},
],"resourceVersion":"1.0","resourceType":"KeyframeStore<SpriteFrameKeyframe>",},"trackColour":0,"inheritsTrackColour":true,"builtinName":0,"traits":0,"interpolation":1,"tracks":[],"events":[],"modifiers":[],"isCreationTrack":false,"resourceVersion":"1.0","tags":[],"resourceType":"GMSpriteFramesTrack",},
],
"visibleRange": null,
"lockOrigin": false,
"showBackdrop": true,
"showBackdropImage": false,
"backdropImagePath": "",
"backdropImageOpacity": 0.5,
"backdropWidth": 1366,
"backdropHeight": 768,
"backdropXOffset": 0.0,
"backdropYOffset": 0.0,
"xorigin": 0,
"yorigin": 0,
"eventToFunction": {},
"eventStubScript": null,
"parent": {"name":"Sprite2","path":"sprites/Sprite2/Sprite2.yy",},
"resourceVersion": "1.3",
"name": "Sprite2",
"tags": [],
"resourceType": "GMSequence",
},
"layers": [
{"visible":true,"isLocked":false,"blendMode":0,"opacity":100.0,"displayName":"default","resourceVersion":"1.0","name":"a3d43c4c-295b-46cc-b8d4-bb9ba2bf5d26","tags":[],"resourceType":"GMImageLayer",},
],
"parent": {
"name": "sample-project",
"path": "sample-project.yyp",
},
"resourceVersion": "1.0",
"name": "Sprite2",
"tags": [],
"resourceType": "GMSprite",
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 14 additions & 3 deletions src/lib/components/resources/Gms2ResourceBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,26 @@ export class Gms2ResourceBase {

/** The folder containing this resource (as viewed via the IDE) */
get folder(){
return this.yyData.parent.path.replace(/^folders\/(.*).yy$/,"$1");
return this.yyData.parent.path.replace(/^folders\/(.*)\.yy$/,"$1");
}
/**
* Set the parent folder for this resource. Note that you may
* run into errors if this folder doesn't already exist.
*/
set folder(folderName:string){
this.yyData.parent.name = folderName;
this.yyData.parent.path = `folders/${folderName}.yy`;
if (folderName.match(/\.yyp/g)){
//This means the resource should be at the root level of the project, such as
// "parent": {
// "name": "sample-project",
// "path": "sample-project.yyp",
// },
this.yyData.parent.name = folderName.replace(/\.yyp/g, "");
this.yyData.parent.path = folderName;
}
else{
this.yyData.parent.name = folderName;
this.yyData.parent.path = `folders/${folderName}.yy`;
}
this.save();
}

Expand Down

0 comments on commit ebad310

Please sign in to comment.