Skip to content

Commit

Permalink
remove swiftlint build phase
Browse files Browse the repository at this point in the history
  • Loading branch information
mfessenden committed Aug 31, 2017
1 parent bbb1939 commit b0148de
Show file tree
Hide file tree
Showing 22 changed files with 29 additions and 195 deletions.
45 changes: 11 additions & 34 deletions Demo/SKTiledDemoScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ public class SKTiledDemoScene: SKTiledScene {
var result: [SKNode] = []
let nodes = self.nodes(at: point)
for node in nodes {
if let tile = node as? SKTile {
if node is SKTile {
result.append(node)
}

if let object = node as? SKTileObject {
if node is SKTileObject {
result.append(node)
}
}
Expand Down Expand Up @@ -183,34 +183,17 @@ public class SKTiledDemoScene: SKTiledScene {
switch fileNamed {

case "dungeon-16x16.tmx":

if let upperGraphLayer = tilemap.tileLayers(named: "Graph-Upper").first {
upperGraphLayer.initializeGraph(walkable: walkableTiles)
_ = upperGraphLayer.initializeGraph(walkable: walkableTiles)
}

if let lowerGraphLayer = tilemap.tileLayers(named: "Graph-Lower").first {
lowerGraphLayer.initializeGraph(walkable: walkableTiles)
}

let lowerGraph = graphs["Graph-Lower"]!
let upperGraph = graphs["Graph-Upper"]!

let lowerBridge = lowerGraph.node(atGridPosition: int2(17, 8))!
let upperBridge = upperGraph.node(atGridPosition: int2(17, 7))!

lowerBridge.addConnections(to: [upperBridge], bidirectional: true)


case "mountains-hex-65x65.tmx":
let tileset = tilemap.getTileset(named: "hex1-65x65-65x230")!
let grassTiles = tilemap.getTiles(globalID: 1)
for tile in grassTiles {
tile.alpha = 0.2
_ = lowerGraphLayer.initializeGraph(walkable: walkableTiles)
}

case "graphtest-8x8.tmx":
if let graphLayer = tilemap.tileLayers(named: "Graph").first {
graphLayer.initializeGraph(walkable: walkableTiles)
_ = graphLayer.initializeGraph(walkable: walkableTiles)
}

case "pacman.tmx":
Expand Down Expand Up @@ -325,11 +308,10 @@ public class SKTiledDemoScene: SKTiledScene {
let startPoint = graphCoordinates.first!.toVec2
let endPoint = graphCoordinates[1].toVec2

for (graphKey, graph) in graphs {
for (_, graph) in graphs {
if let startNode = graph.node(atGridPosition: startPoint) {
if let endNode = graph.node(atGridPosition: endPoint) {
currentPath = startNode.findPath(to: endNode) as! [GKGridGraphNode]

}
}
}
Expand Down Expand Up @@ -497,18 +479,13 @@ extension SKTiledDemoScene {
cameraNode.mouseDown(with: event)
let defaultLayer = tilemap.defaultLayer

// get the position relative as drawn by the
let positionInScene = event.location(in: self)
let positionInLayer = defaultLayer.mouseLocation(event: event)
let coord = defaultLayer.coordinateAtMouseEvent(event: event)

let tileShapesUnderCursor = nodes(at: positionInScene).filter { $0 as? TileShape != nil } as! [TileShape]
let tileShapesUnderCursor = tileShapesAt(event: event)

for tile in tileShapesUnderCursor where tile.role == .coordinate {
tile.interactions += 1
}


if (liveMode == true) && (isPaused == false) {

if (event.clickCount > 1) {
Expand Down Expand Up @@ -565,7 +542,7 @@ extension SKTiledDemoScene {
if let view = view {
let viewSize = view.bounds.size

var positionInWindow = event.locationInWindow
let positionInWindow = event.locationInWindow
let xpos = positionInWindow.x
let ypos = positionInWindow.y

Expand Down Expand Up @@ -632,7 +609,7 @@ extension SKTiledDemoScene {

if (tileShapesUnderCursor.isEmpty) {
if (liveMode == true) && (isPaused == false) {
let tile = self.addTileToWorld(Int(coord.x), Int(coord.y), role: .highlight)
_ = self.addTileToWorld(Int(coord.x), Int(coord.y), role: .highlight)
}
}

Expand Down Expand Up @@ -758,7 +735,7 @@ internal class MouseTracker: SKNode {
}

func setOffset(dx: CGFloat, dy: CGFloat) {
var vector = (1 / -dy) * (fabs(dy) * 2)
let vector = (1 / -dy) * (fabs(dy) * 2)
label.position.y = vector * (scaleSize * 2)
}

Expand Down Expand Up @@ -865,7 +842,7 @@ extension SKTiledDemoScene {
guard let view = view,
let cameraNode = cameraNode,
let tilemap = tilemap,
let worldNode = worldNode else {
let _ = worldNode else {
return
}

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

**SKTiled** is a Swift framework for using [Tiled](http://www.mapeditor.org) content with [Apple's SpriteKit][spritekit-url], allowing the creation of game assets from Tiled's .tmx files. Inspired by [TilemapKit](http://tilemapkit.com) and written purely in Swift, I began working on this after the development of TilemapKit was halted, primarily to learn Apple's new programming language. I've decided to open-source it in case others find it helpful.


Current release is Swift 3/macOS 10.11/iOS 10+. For Swift 4/Xcode 9, see the [**swift4**][swift4-url] branch.


Expand Down Expand Up @@ -42,7 +43,7 @@ Check out the [Official Documentation](https://mfessenden.github.io/SKTiled).
## Requirements

- iOS 9+
- macOS 10.12+
- macOS 10.11+
- Xcode 8+

## Installation
Expand Down
120 changes: 0 additions & 120 deletions SKTiled.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 4C1774911D909740000C0AFD /* Build configuration list for PBXNativeTarget "Demo - macOS" */;
buildPhases = (
4CA4006B1F4721ED0032CD21 /* Run Swiftlint */,
4CABC4D71DAEE1F900ACA1A4 /* Run xattr */,
4C4184A71F34D57B004E392A /* Todo Tags */,
4C17747B1D909740000C0AFD /* Sources */,
4C17747C1D909740000C0AFD /* Frameworks */,
4C17747D1D909740000C0AFD /* Resources */,
Expand All @@ -737,8 +735,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 4C41A5E71F437118001622FF /* Build configuration list for PBXNativeTarget "SKTiled-macOS" */;
buildPhases = (
4CA400691F47214B0032CD21 /* Run Swiftlint */,
4C2FCE5E1F437A39004AD742 /* Todo Tags */,
4C41A5DB1F437118001622FF /* Sources */,
4C41A5DC1F437118001622FF /* Frameworks */,
4C41A5DD1F437118001622FF /* Headers */,
Expand All @@ -757,8 +753,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 4C41A6021F43739C001622FF /* Build configuration list for PBXNativeTarget "SKTiled-iOS" */;
buildPhases = (
4CA4006A1F4721770032CD21 /* Run Swiftlint */,
4C2FCE5F1F437A45004AD742 /* Todo Tags */,
4C41A5F81F43739C001622FF /* Sources */,
4C41A5F91F43739C001622FF /* Frameworks */,
4C41A5FA1F43739C001622FF /* Headers */,
Expand All @@ -777,9 +771,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 4CBA617B1D8A048300B31FC1 /* Build configuration list for PBXNativeTarget "Demo - iOS" */;
buildPhases = (
4CA4006C1F4722040032CD21 /* Run Swiftlint */,
4C3496881EA513D9003900C8 /* Run xattr */,
4C4184A81F34D592004E392A /* Todo Tags */,
4CBA61611D8A048200B31FC1 /* Sources */,
4CBA61621D8A048200B31FC1 /* Frameworks */,
4CBA61631D8A048200B31FC1 /* Resources */,
Expand Down Expand Up @@ -1056,34 +1048,6 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
4C2FCE5E1F437A39004AD742 /* Todo Tags */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Todo Tags";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "TAGS=\"TODO:|FIXME:|CLEANUP:\"\necho \"searching ${SRCROOT} for ${TAGS}\"\nfind \"${SRCROOT}\" \\( -name \"*.swift\" \\) -print0 | xargs -0 egrep --with-filename --line-number --only-matching \"($TAGS).*\\$\" | perl -p -e \"s/($TAGS)/ warning: \\$1/\"";
};
4C2FCE5F1F437A45004AD742 /* Todo Tags */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Todo Tags";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "TAGS=\"TODO:|FIXME:|CLEANUP:\"\necho \"searching ${SRCROOT} for ${TAGS}\"\nfind \"${SRCROOT}\" \\( -name \"*.swift\" \\) -print0 | xargs -0 egrep --with-filename --line-number --only-matching \"($TAGS).*\\$\" | perl -p -e \"s/($TAGS)/ warning: \\$1/\"";
};
4C3496881EA513D9003900C8 /* Run xattr */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -1098,90 +1062,6 @@
shellPath = /bin/sh;
shellScript = "xattr -rc $PROJECT_DIR\n";
};
4C4184A71F34D57B004E392A /* Todo Tags */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Todo Tags";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "TAGS=\"TODO:|FIXME:|CLEANUP:\"\necho \"searching ${SRCROOT} for ${TAGS}\"\nfind \"${SRCROOT}\" \\( -name \"*.swift\" \\) -print0 | xargs -0 egrep --with-filename --line-number --only-matching \"($TAGS).*\\$\" | perl -p -e \"s/($TAGS)/ warning: \\$1/\"";
};
4C4184A81F34D592004E392A /* Todo Tags */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Todo Tags";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "TAGS=\"TODO:|FIXME:|CLEANUP:\"\necho \"searching ${SRCROOT} for ${TAGS}\"\nfind \"${SRCROOT}\" \\( -name \"*.swift\" \\) -print0 | xargs -0 egrep --with-filename --line-number --only-matching \"($TAGS).*\\$\" | perl -p -e \"s/($TAGS)/ warning: \\$1/\"";
};
4CA400691F47214B0032CD21 /* Run Swiftlint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Run Swiftlint";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
4CA4006A1F4721770032CD21 /* Run Swiftlint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Run Swiftlint";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
4CA4006B1F4721ED0032CD21 /* Run Swiftlint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Run Swiftlint";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
4CA4006C1F4722040032CD21 /* Run Swiftlint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Run Swiftlint";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
4CABC4D71DAEE1F900ACA1A4 /* Run xattr */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Sources/SKTileObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ open class SKTileObject: SKShapeNode, SKTiledObject {
*/
required public init(layer: SKObjectGroup) {
super.init()
layer.addObject(self)
_ = layer.addObject(self)
drawObject()
}

Expand Down
5 changes: 1 addition & 4 deletions Sources/SKTiled+Debug.swift
Original file line number Diff line number Diff line change
Expand Up @@ -512,15 +512,12 @@ public class TileShape: SKShapeNode {
baseColor = SKColor.gray
case 11...200:
baseColor = TiledObjectColors.dandelion
case 201...FLT_MAX:
case 201...Float.greatestFiniteMagnitude:
baseColor = TiledObjectColors.english
default:
baseColor = SKColor.gray
}




baseOpacity = 0.8
self.strokeColor = baseColor.withAlphaComponent(baseOpacity * 2)
self.fillColor = baseColor.withAlphaComponent(baseOpacity * 1.5)
Expand Down
18 changes: 8 additions & 10 deletions Sources/SKTiled+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,6 @@ internal func drawLayerGraph(_ layer: SKTiledLayerObject,

guard let graph = layer.graph else { return }

let innerColor = layer.gridColor
// line width should be at least 1 for larger tile sizes
let lineWidth: CGFloat = defaultLineWidth
context.setLineWidth(lineWidth)
Expand All @@ -1396,21 +1395,20 @@ internal func drawLayerGraph(_ layer: SKTiledLayerObject,
if let tiledNode = node as? SKTiledGraphNode {

switch tiledNode.weight {
case (-205)...(-101):
fillColor = TiledObjectColors.obsidian
case -100...0:
fillColor = TiledObjectColors.azure
case 10...100:
fillColor = TiledObjectColors.dandelion
case 101...250:
case (-2000)...(-1):
fillColor = TiledObjectColors.lime
case 251...500:
case 0...10:
fillColor = SKColor.gray
case 11...200:
fillColor = TiledObjectColors.tangerine
case 201...Float.greatestFiniteMagnitude:
fillColor = TiledObjectColors.english
default:
break
fillColor = SKColor.gray
}
}


let screenPosition = layer.tileToScreenCoords(CGPoint(x: col, y: row))

var xpos: CGFloat = screenPosition.x * imageScale
Expand Down
2 changes: 1 addition & 1 deletion Sources/SKTiledSceneCamera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public class SKTiledSceneCamera: SKCameraNode, Loggable {
let usableHeight: CGFloat = newSize.height * screenScaleHeight
let scaleFactor = (isPortrait == true) ? usableWidth / tilemapSize.width : usableHeight / tilemapSize.height

let heightOffset: CGFloat = (usableHeight / 20)
//let heightOffset: CGFloat = (usableHeight / 20)
let focusPoint = CGPoint(x: tilemapCenter.x, y: tilemapCenter.y) // -heightOffset

centerOn(scenePoint: focusPoint)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SKTilemap+Properties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public extension SKTileset {
if (ignoreProperties == true) { return }
if (self.type == nil) { self.type = properties.removeValue(forKey: "type") }

for (attr, value) in properties {
for (attr, _) in properties {
let lattr = attr.lowercased()
if (lattr == "walkable") {
if (keyValuePair(key: attr) != nil) {
Expand Down
Loading

0 comments on commit b0148de

Please sign in to comment.