NotificationCenter.default.removeObserver(self)
damageView.unbind(NSBindingName(#keyPath(DamageView.damageType)))
- supply.unbind(NSBindingName(#keyPath(SuppliesView.shipStatus)))
+ supply.unbind(NSBindingName(#keyPath(SuppliesView.ship)))
[slot00Field, slot01Field, slot02Field, slot03Field]
.forEach { $0?.unbind(NSBindingName(#keyPath(SlotItemLevelView.slotItemID))) }
to: shipController,
withKeyPath: "selection.status", options: nil)
- supply.bind(NSBindingName(#keyPath(SuppliesView.shipStatus)),
+ supply.bind(NSBindingName(#keyPath(SuppliesView.ship)),
to: shipController,
withKeyPath: "selection.self", options: nil)
private let borderColor = NSColor(calibratedWhite: 0.632, alpha: 1.0)
private let backgroundColor = NSColor(calibratedWhite: 0.948, alpha: 1.0)
- @objc dynamic var shipStatus: Ship?
+ @objc dynamic var ship: Ship?
private var fuelStatusColor: NSColor {
- guard let s = shipStatus else { return redColor }
+ guard let s = ship else { return redColor }
return statusColor(withValue: s.fuel, max: s.maxFuel)
}
private var bullStatusColor: NSColor {
- guard let s = shipStatus else { return redColor }
+ guard let s = ship else { return redColor }
return statusColor(withValue: s.bull, max: s.maxBull)
}
private var numberOfFuelColoredCell: Int {
- guard let s = shipStatus else { return 0 }
+ guard let s = ship else { return 0 }
return numberOfColoredCell(withValue: s.fuel, max: s.maxFuel)
}
- private var numberOgBullColoredCell: Int {
+ private var numberOfBullColoredCell: Int {
- guard let s = shipStatus else { return 0 }
+ guard let s = ship else { return 0 }
return numberOfColoredCell(withValue: s.bull, max: s.maxBull)
}
let height = (cellFrame.height - 3.0) / 2.0
let width = (cellFrame.width - CGFloat(numberOfCell) - 1.0) / CGFloat(numberOfCell)
- let y = type == .fuel ? height + 2.0 : 1.0
+ let y = (type == .fuel ? height + 2.0 : 1.0)
(0...numberOfCell).forEach {
private func drawBullInterior(withFrame cellFrame: NSRect) {
- drawResource(withFrame: cellFrame, border: numberOgBullColoredCell, type: .bull)
+ drawResource(withFrame: cellFrame, border: numberOfBullColoredCell, type: .bull)
}
private func numberOfColoredCell(withValue value: Int, max: Int) -> Int {
observeKeys.forEach {
- suppliesCell.shipStatus?.removeObserver(self, forKeyPath: $0)
+ suppliesCell.ship?.removeObserver(self, forKeyPath: $0)
}
}
- @objc var shipStatus: Ship? {
+ @objc var ship: Ship? {
- get { return suppliesCell.shipStatus }
+ get { return suppliesCell.ship }
set {
observeKeys.forEach {
- suppliesCell.shipStatus?.removeObserver(self, forKeyPath: $0)
+ suppliesCell.ship?.removeObserver(self, forKeyPath: $0)
}
- suppliesCell.shipStatus = newValue
+ suppliesCell.ship = newValue
observeKeys.forEach {
- suppliesCell.shipStatus?.addObserver(self, forKeyPath: $0, context: &pShipStatusContext)
+ suppliesCell.ship?.addObserver(self, forKeyPath: $0, context: &pShipStatusContext)
}
needsDisplay = true
}