-
Notifications
You must be signed in to change notification settings - Fork 45
Replacing IDs with IdType: Scene IDs #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .idea/ | ||
| *.iml | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| package com.stencyl; | ||
|
|
||
| import haxe.xml.Fast; | ||
| import com.stencyl.models.IdType; | ||
|
|
||
| interface AssetLoader | ||
| { | ||
| function loadResources(resourceMap:Map<String,Dynamic>):Void; | ||
| function loadScenes(scenesXML:Map<Int,String>):Void; | ||
| function loadScenes(scenesXML:Map<IdType,String>):Void; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ import com.stencyl.utils.Utils; | |
| import com.stencyl.models.scene.Autotile; | ||
| import com.stencyl.models.scene.AutotileFormat; | ||
|
|
||
| import com.stencyl.models.IdType.IdUtils; | ||
|
|
||
| import box2D.common.math.B2Vec2; | ||
| import box2D.collision.shapes.B2Shape; | ||
| import box2D.collision.shapes.B2PolygonShape; | ||
|
|
@@ -26,7 +28,7 @@ class GameModel | |
| public var actualHeight:Int; | ||
| public var scale:Int; | ||
|
|
||
| public var defaultSceneID:Int; | ||
| public var defaultSceneID:IdType; | ||
|
|
||
| public var groups:Array<GroupDef>; | ||
| public var groupsCollidesWith:Map<Int,Array<Int>>; | ||
|
|
@@ -36,7 +38,7 @@ class GameModel | |
| public var gameAttributes:Map<String,Dynamic>; | ||
| public var shapes:Map<Int,B2PolygonShape>; | ||
| public var atlases:Map<Int,Atlas>; | ||
| public var scenes:Map<Int,Scene>; | ||
| public var scenes:Map<IdType,Scene>; | ||
| public var autotileFormats:Map<Int, AutotileFormat>; | ||
|
|
||
| public static var INHERIT_ID:Int = -1000; | ||
|
|
@@ -65,11 +67,11 @@ class GameModel | |
| actualWidth = Std.parseInt(xml.att.awidth); | ||
| actualHeight = Std.parseInt(xml.att.aheight); | ||
| scale = Std.parseInt(xml.att.scale); | ||
| defaultSceneID = 0; | ||
| defaultSceneID = IdUtils.INVALID_ID; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not equivalent, but this shouldn't be an issue because if the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's not, but 0 is also wrong, I guess? If I create a game, add two scenes, then delete the first one 0 is not a valid scene either... |
||
|
|
||
| try | ||
| { | ||
| defaultSceneID = Std.parseInt(xml.att.defaultSceneID); | ||
| defaultSceneID = IdUtils.parseXmlId(xml.att.defaultSceneID); | ||
| } | ||
|
|
||
| catch(e:String) | ||
|
|
@@ -164,15 +166,15 @@ class GameModel | |
| scenes = readScenes(Data.get().sceneListXML); | ||
| } | ||
|
|
||
| public function readScenes(list:Fast):Map<Int,Scene> | ||
| public function readScenes(list:Fast):Map<IdType,Scene> | ||
| { | ||
| var map:Map<Int,Scene> = new Map<Int,Scene>(); | ||
| var map = new Map<IdType,Scene>(); | ||
|
|
||
| for(e in list.elements) | ||
| { | ||
| var sceneID = Std.parseInt(e.att.id); | ||
| map.set(Std.parseInt(e.att.id), new Scene(sceneID, e.att.name)); | ||
| var sceneID = IdUtils.parseXmlId(e.att.id); | ||
|
|
||
| map.set(sceneID, new Scene(sceneID, e.att.name)); | ||
| } | ||
|
|
||
| Data.get().scenesXML = null; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.stencyl.models; | ||
|
|
||
| typedef IdType = Int | ||
|
|
||
| class IdUtils { | ||
| public static var INVALID_ID = -1; | ||
|
|
||
| public static function parseXmlId(id: String): IdType { | ||
| return Std.parseInt(id); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't true yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this should be
INVALID_ID