}
static let oldStyleFleetViewHeight: CGFloat = 128.0
- static let detailViewHeight: CGFloat = 288.0
+ static let detailViewHeight: CGFloat = 320.0
static let heightDifference: CGFloat = detailViewHeight - oldStyleFleetViewHeight
private static let maxFleetNumber: Int = 4
private let fleetController = NSObjectController()
private let shipObserveKeys = [#keyPath(Ship.seiku), #keyPath(Ship.lv), #keyPath(Ship.equippedItem)]
+ private var notificationObserver = NotificationObserver()
+
init?(viewType: FleetViewType) {
type = viewType
fatalError("init(coder:) has not been implemented")
}
- deinit {
-
- NotificationCenter.default.removeObserver(self)
- }
-
- @IBOutlet weak var placeholder01: NSView!
- @IBOutlet weak var placeholder02: NSView!
- @IBOutlet weak var placeholder03: NSView!
- @IBOutlet weak var placeholder04: NSView!
- @IBOutlet weak var placeholder05: NSView!
- @IBOutlet weak var placeholder06: NSView!
+ @IBOutlet private weak var placeholder01: NSView!
+ @IBOutlet private weak var placeholder02: NSView!
+ @IBOutlet private weak var placeholder03: NSView!
+ @IBOutlet private weak var placeholder04: NSView!
+ @IBOutlet private weak var placeholder05: NSView!
+ @IBOutlet private weak var placeholder06: NSView!
@objc dynamic var fleetNumber: Int = 1 {
}
}
- var extDetail: ShipDetailViewController?
- var extShipAnimating: Bool = false
+ private var extDetail: ShipDetailViewController?
+ private var extShipAnimating: Bool = false
weak var delegate: FleetViewControllerDelegate?
var enableAnimation: Bool = false
var upsideHeight: CGFloat {
switch type {
- case .detailViewType: return 159.0
+ case .detailViewType: return 175.0
case .minimumViewType: return FleetViewController.oldStyleFleetViewHeight
case .miniVierticalType: return 0.0
}
}
}
- @objc var totalSakuteki: Double { return sakutekiCalculator.calculate(ships) }
+ @objc private var totalSakuteki: Double { return sakutekiCalculator.calculate(ships) }
@objc var totalSeiku: Int { return ships.reduce(0) { $0 + $1.seiku } }
@objc var totalCalclatedSeiku: Int { return ships.reduce(0) { $0 + totalSeiku(of: $1) } }
- @objc var totalLevel: Int { return ships.reduce(0) { $0 + $1.lv } }
- @objc var totalDrums: Int { return ships.reduce(0) { $0 + totalDrums(of: $1) } }
+ @objc private var totalLevel: Int { return ships.reduce(0) { $0 + $1.lv } }
+ @objc private var totalDrums: Int { return ships.reduce(0) { $0 + totalDrums(of: $1) } }
@objc var totalTPValue: Int {
return ships
.map { ShipTPValueCalculator($0).value }
.reduce(0, +)
}
+ @objc private var totalBRankTPValue: Int { return Int(floor(Double(totalTPValue) * 0.7)) }
- func totalSeiku(of ship: Ship) -> Int {
+ private func totalSeiku(of ship: Ship) -> Int {
return SeikuCalclator(ship: ship).totalSeiku
}
- func totalDrums(of ship: Ship) -> Int {
+ private func totalDrums(of ship: Ship) -> Int {
- return (0...4).flatMap(ship.slotItem).filter { $0.slotitem_id == 75 }.count
+ return (0...4).compactMap(ship.slotItem).filter { $0.slotitem_id == 75 }.count
}
private var ships: [Ship] = [] {
sakutekiCalculator = Formula33(Int(factor))
}
- fleetController.bind(NSBindingName(#keyPath(NSArrayController.content)), to: self, withKeyPath: #keyPath(fleet), options: nil)
+ fleetController.bind(NSBindingName(#keyPath(NSArrayController.content)), to: self, withKeyPath: #keyPath(fleet))
fleetController.addObserver(self, forKeyPath: "selection.name", context: nil)
shipKeys.forEach {
buildAnchorageRepairHolder()
- [placeholder01, placeholder02, placeholder03, placeholder04, placeholder05, placeholder06]
- .enumerated()
- .forEach {
+ zip([placeholder01, placeholder02, placeholder03, placeholder04, placeholder05, placeholder06], details)
+ .forEach { view, detail in
- guard let view = $0.element else { return }
+ guard let view = view else { return }
- let detail = details[$0.offset]
detail.view.frame = view.frame
detail.view.autoresizingMask = view.autoresizingMask
self.view.replaceSubview(view, with: detail.view)
+
}
fleetNumber = 1
// 初回起動時などデータがまだない時はportAPIを受信後設定する
NotificationCenter.default
- .addObserverOnce(forName: .PortAPIReceived, object: nil, queue: nil) { [weak self] _ in
+ .addObserverOnce(forName: .PortAPIReceived, object: nil, queue: .main) { [weak self] _ in
if let current = self?.fleetNumber {
}
}
- NotificationCenter
- .default
- .addObserver(forName: .DidUpdateGuardEscape, object: nil, queue: nil) { [weak self] _ in
+ notificationObserver
+ .addObserver(forName: .DidUpdateGuardEscape, object: nil, queue: .main) { [weak self] _ in
self?.notifyChangeValue(forKey: #keyPath(totalSeiku))
self?.notifyChangeValue(forKey: #keyPath(totalCalclatedSeiku))
self?.notifyChangeValue(forKey: #keyPath(totalSakuteki))
self?.notifyChangeValue(forKey: #keyPath(totalDrums))
self?.notifyChangeValue(forKey: #keyPath(totalTPValue))
+ self?.notifyChangeValue(forKey: #keyPath(totalBRankTPValue))
}
}
notifyChangeValue(forKey: #keyPath(totalDrums))
notifyChangeValue(forKey: #keyPath(totalCalclatedSeiku))
notifyChangeValue(forKey: #keyPath(totalTPValue))
-
+ notifyChangeValue(forKey: #keyPath(totalBRankTPValue))
+
case #keyPath(Ship.seiku):
notifyChangeValue(forKey: #keyPath(totalSeiku))
notifyChangeValue(forKey: #keyPath(totalCalclatedSeiku))
let extShip = fleet?[6]
extShip.map { extDetail?.ship = $0 }
- ships = array.flatMap { $0 } + [extShip].flatMap { $0 }
+ ships = array.compactMap { $0 } + [extShip].compactMap { $0 }
[#keyPath(totalSakuteki), #keyPath(totalSeiku), #keyPath(totalCalclatedSeiku),
#keyPath(totalLevel), #keyPath(totalDrums), #keyPath(repairable),
- #keyPath(totalTPValue)]
+ #keyPath(totalTPValue), #keyPath(totalBRankTPValue)]
.forEach(notifyChangeValue(forKey:))
}
}
extension FleetViewController {
- func buildAnchorageRepairHolder() {
+ private func buildAnchorageRepairHolder() {
AppDelegate.shared.addCounterUpdate { [weak self] in
private var repairShipIds: [Int] { return [19] }
- @objc dynamic var repairable: Bool {
+ @objc private dynamic var repairable: Bool {
guard let flagShip = fleet?[0] else { return false }
var frame = view.frame
frame.size.width += width
+ extDetail.view.alphaValue = 0.0
+ extDetail.view.animator().alphaValue = 1.0
+
extDetail.view.frame = details[5].view.frame
view.addSubview(extDetail.view, positioned: .below, relativeTo: details[5].view)
view.animator().frame = frame
NSAnimationContext.runAnimationGroup({ _ in
+ extDetail.view.animator().alphaValue = 0.0
+
var frame = view.frame
frame.size.width -= extDetail.view.frame.width - 1
view.animator().frame = frame