5 // Created by Hori,Masaki on 2017/01/01.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
11 enum DamageType: Int {
19 final class DamageView: NSView {
21 dynamic var damageType: Int = 0 {
24 guard let v = DamageType(rawValue: newValue) else {
25 self.print("Can not set damageType")
29 if innerDamageType != v { needsDisplay = true }
35 var controlSize: NSControlSize = .regular
36 private var innerDamageType: DamageType = .none
37 private var color: NSColor? {
39 switch innerDamageType {
44 return #colorLiteral(red: 1.000, green: 0.956, blue: 0.012, alpha: 0.5)
47 return NSColor.orange.withAlphaComponent(0.5)
50 return NSColor.red.withAlphaComponent(0.5)
54 private var borderColor: NSColor? {
56 switch innerDamageType {
61 return NSColor.orange.withAlphaComponent(0.5)
64 return NSColor.orange.withAlphaComponent(0.9)
67 return NSColor.red.withAlphaComponent(0.9)
71 private var path: NSBezierPath? {
82 private var pathForRegular: NSBezierPath? {
84 let height = bounds.height
86 switch innerDamageType {
93 .appended { NSPoint(x: 35.0, y: height - 2.0) }
94 .appended { NSPoint(x: 0.0, y: height - 2.0) }
95 .appended { NSPoint(x: 0.0, y: height - 35.0) }
101 .appended { NSPoint(x: 50.0, y: height - 2.0) }
102 .appended { NSPoint(x: 25.0, y: height - 2.0) }
103 .appended { NSPoint(x: 0.0, y: height - 25.0) }
104 .appended { NSPoint(x: 0.0, y: height - 50.0) }
110 .appended { NSPoint(x: 60.0, y: height - 2.0) }
111 .appended { NSPoint(x: 53.0, y: height - 2.0) }
112 .appended { NSPoint(x: 0.0, y: height - 53.0) }
113 .appended { NSPoint(x: 0.0, y: height - 60.0) }
117 .appended { NSPoint(x: 47.0, y: height - 2.0) }
118 .appended { NSPoint(x: 23.0, y: height - 2.0) }
119 .appended { NSPoint(x: 0.0, y: height - 23.0) }
120 .appended { NSPoint(x: 0.0, y: height - 47.0) }
122 .map { p?.append($0) }
127 private var pathForSmall: NSBezierPath? {
129 let height = bounds.height
131 switch innerDamageType {
138 .appended { NSPoint(x: 35.0, y: height - 2.0) }
139 .appended { NSPoint(x: 0.0, y: height - 2.0) }
140 .appended { NSPoint(x: 0.0, y: height - 35.0) }
146 .appended { NSPoint(x: 50.0, y: height - 2.0) }
147 .appended { NSPoint(x: 25.0, y: height - 2.0) }
148 .appended { NSPoint(x: 0.0, y: height - 25.0) }
149 .appended { NSPoint(x: 0.0, y: height - 50.0) }
155 .appended { NSPoint(x: 55.0, y: height - 2.0) }
156 .appended { NSPoint(x: 48.0, y: height - 2.0) }
157 .appended { NSPoint(x: 0.0, y: height - 48.0) }
158 .appended { NSPoint(x: 0.0, y: height - 55.0) }
162 .appended { NSPoint(x: 42.0, y: height - 2.0) }
163 .appended { NSPoint(x: 20.0, y: height - 2.0) }
164 .appended { NSPoint(x: 0.0, y: height - 20.0) }
165 .appended { NSPoint(x: 0.0, y: height - 42.0) }
167 .map { p?.append($0) }
172 override func draw(_ dirtyRect: NSRect) {
174 super.draw(dirtyRect)
177 borderColor?.setStroke()