5 // Created by Hori,Masaki on 2017/01/02.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
11 private var pShipStatusContext: Int = 0
13 final class SuppliesView: NSControl {
15 private let suppliesCell: SuppliesCell
17 private var fuelObservation: NSKeyValueObservation?
18 private var maxFuelObservation: NSKeyValueObservation?
19 private var bullObservation: NSKeyValueObservation?
20 private var maxBullObservation: NSKeyValueObservation?
22 override init(frame: NSRect) {
24 suppliesCell = SuppliesCell()
26 super.init(frame: frame)
28 self.cell = suppliesCell
31 required init?(coder: NSCoder) {
33 suppliesCell = SuppliesCell()
35 super.init(coder: coder)
37 self.cell = suppliesCell
41 @objc var ship: Ship? {
43 get { return suppliesCell.ship }
45 suppliesCell.ship = newValue
47 fuelObservation = suppliesCell.ship?.observe(\Ship.fuel, changeHandler: updateDisplay)
48 maxFuelObservation = suppliesCell.ship?.observe(\Ship.maxFuel, changeHandler: updateDisplay)
49 bullObservation = suppliesCell.ship?.observe(\Ship.bull, changeHandler: updateDisplay)
50 maxBullObservation = suppliesCell.ship?.observe(\Ship.maxBull, changeHandler: updateDisplay)
56 private func updateDisplay(ship: Ship, _: Any) {