OSDN Git Service

情報タブをInformationTabViewControllerとして分離
authormasakih <masakih@users.sourceforge.jp>
Tue, 6 Feb 2018 13:07:43 +0000 (22:07 +0900)
committermasakih <masakih@users.sourceforge.jp>
Tue, 6 Feb 2018 13:36:51 +0000 (22:36 +0900)
KCD.xcodeproj/project.pbxproj
KCD/Base.lproj/BroserWindowController.xib
KCD/BroserWindowController.swift
KCD/BroswerTouchBar.xib
KCD/InformationTabViewController.swift [new file with mode: 0644]
KCD/InformationTabViewController.xib [new file with mode: 0644]
KCD/MainTabVIewItemViewController.swift
KCD/PowerUpSupportViewController.swift
KCD/ShipViewController.swift

index be32347..28d2666 100644 (file)
                F4A0D7151E2FB11F00224DCE /* MapStartCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A0D7141E2FB11F00224DCE /* MapStartCommand.swift */; };
                F4A0D7191E2FBE1600224DCE /* JSONViewCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A0D7181E2FBE1600224DCE /* JSONViewCommand.swift */; };
                F4A0D71B1E30D77B00224DCE /* JSONCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A0D71A1E30D77B00224DCE /* JSONCommand.swift */; };
+               F4A0F7EE20269536001DAFE3 /* InformationTabViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A0F7EC20269535001DAFE3 /* InformationTabViewController.swift */; };
+               F4A0F7EF20269536001DAFE3 /* InformationTabViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4A0F7ED20269536001DAFE3 /* InformationTabViewController.xib */; };
                F4A2AF581A0930160024BD9E /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4A2AF571A0930160024BD9E /* Quartz.framework */; };
                F4A3AD9419BDDE5500FDBF80 /* PreferencePanelController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4A3AD9619BDDE5500FDBF80 /* PreferencePanelController.xib */; };
                F4A9B8D41B975029005786C2 /* SlotItemShortName.plist in Resources */ = {isa = PBXBuildFile; fileRef = F4A9B8D21B975029005786C2 /* SlotItemShortName.plist */; };
                F4A0D7141E2FB11F00224DCE /* MapStartCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapStartCommand.swift; sourceTree = "<group>"; };
                F4A0D7181E2FBE1600224DCE /* JSONViewCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONViewCommand.swift; sourceTree = "<group>"; };
                F4A0D71A1E30D77B00224DCE /* JSONCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONCommand.swift; sourceTree = "<group>"; };
+               F4A0F7EC20269535001DAFE3 /* InformationTabViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InformationTabViewController.swift; sourceTree = "<group>"; };
+               F4A0F7ED20269536001DAFE3 /* InformationTabViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = InformationTabViewController.xib; sourceTree = "<group>"; };
                F4A2AF571A0930160024BD9E /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; };
                F4A9B8D31B975029005786C2 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = ja; path = ja.lproj/SlotItemShortName.plist; sourceTree = "<group>"; };
                F4A9B8D61B99D5B7005786C2 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text; name = ja; path = ja.lproj/Taihi.txt; sourceTree = "<group>"; };
                                F4E5FF131E17F93B0026868C /* BroserWindowController.swift */,
                                F4B3DC4118E5C8870011B4FC /* BroserWindowController.xib */,
                                F45FBB721E116F53000E72B9 /* MainTabVIewItemViewController.swift */,
+                               F4A0F7EC20269535001DAFE3 /* InformationTabViewController.swift */,
+                               F4A0F7ED20269536001DAFE3 /* InformationTabViewController.xib */,
                                F4D05BDA1E0F76A800688D66 /* ResourceViewController.swift */,
                                F4C6686B1C5451C800601AFB /* ResourceViewController.xib */,
                                F4E5FF011E150A850026868C /* AncherageRepairTimerViewController.swift */,
                                F49688671B3EA16800D3CEDE /* RemoveDatabaseFileAndRestart.app in Resources */,
                                F494DC6A18C8BAB900AE97E4 /* PowerUpSupportViewController.xib in Resources */,
                                F49AABE61DFC48F300E0B24F /* MainTouchBar.xib in Resources */,
+                               F4A0F7EF20269536001DAFE3 /* InformationTabViewController.xib in Resources */,
                                F4BDEB51187252F30069D0CE /* InfoPlist.strings in Resources */,
                                F43E67B918BE060E0087E5B6 /* LevelUpExp.plist in Resources */,
                                F4A9B8D71B99D5B7005786C2 /* Taihi.txt in Resources */,
                                F4AA59421E1E2854001667AF /* OrderedSetToArrayTransformer.swift in Sources */,
                                F4A0D7191E2FBE1600224DCE /* JSONViewCommand.swift in Sources */,
                                F47C3EBC1E61AEC500D97449 /* AirBaseMapper.swift in Sources */,
+                               F4A0F7EE20269536001DAFE3 /* InformationTabViewController.swift in Sources */,
                                F4AA59441E1E300B001667AF /* ActinKindTransformer.swift in Sources */,
                                F4D05BCC1E0D274100688D66 /* BookmarkEditorViewController.swift in Sources */,
                                F49097871E1A85F70085A45D /* ImageView.swift in Sources */,
index 2d3f8f6..382c38d 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13529"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -12,7 +12,7 @@
                 <outlet property="combinedViewPlaceholder" destination="ErU-NG-s3I" id="6hE-wI-Ikk"/>
                 <outlet property="deckContoller" destination="eqP-ex-UzI" id="8n5-Er-BIF"/>
                 <outlet property="deckPlaceholder" destination="tIf-gd-MhY" id="aXM-5K-Uwd"/>
-                <outlet property="informations" destination="fK1-fC-Xdm" id="why-oJ-aEb"/>
+                <outlet property="informationsPlaceholder" destination="jOr-vI-BKr" id="pmY-Qo-olr"/>
                 <outlet property="placeholder" destination="raX-C4-fMW" id="T7y-R7-3qy"/>
                 <outlet property="resourcePlaceholder" destination="Ztc-Gd-Ipf" id="mUG-AG-FqW"/>
                 <outlet property="stokerContainer" destination="vbb-UC-aXs" id="eae-Ze-5ug"/>
                         <rect key="frame" x="8" y="9" width="800" height="288"/>
                         <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
                     </customView>
-                    <tabView initialItem="ETl-Gs-mBL" id="fK1-fC-Xdm">
-                        <rect key="frame" x="813" y="176" width="343" height="600"/>
-                        <autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/>
-                        <font key="font" metaFont="system"/>
-                        <tabViewItems>
-                            <tabViewItem label="状況" identifier="1" id="ETl-Gs-mBL">
-                                <view key="view" id="nff-Ek-C9h">
-                                    <rect key="frame" x="10" y="33" width="323" height="554"/>
-                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                </view>
-                            </tabViewItem>
-                            <tabViewItem label="編成支援" identifier="2" id="vnl-eb-0bM">
-                                <view key="view" id="HTH-7g-xfp">
-                                    <rect key="frame" x="10" y="33" width="323" height="554"/>
-                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                </view>
-                            </tabViewItem>
-                            <tabViewItem label="近代化" identifier="3" id="Ops-Am-LiF">
-                                <view key="view" id="ytJ-Qj-RCn">
-                                    <rect key="frame" x="10" y="33" width="323" height="547"/>
-                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                </view>
-                            </tabViewItem>
-                            <tabViewItem label="改修工廠" identifier="4" id="Ls3-Cp-5p4">
-                                <view key="view" id="6ia-4I-aBI">
-                                    <rect key="frame" x="10" y="33" width="323" height="547"/>
-                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                </view>
-                            </tabViewItem>
-                            <tabViewItem label=" 修復" identifier="5" id="GgO-z3-Sgk">
-                                <view key="view" id="C3D-UU-4z6">
-                                    <rect key="frame" x="10" y="33" width="323" height="547"/>
-                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                </view>
-                            </tabViewItem>
-                        </tabViewItems>
-                        <connections>
-                            <binding destination="-2" name="selectedIndex" keyPath="selectedMainTabIndex" id="bvs-iv-JKe"/>
-                        </connections>
-                    </tabView>
                     <customView misplaced="YES" id="vbb-UC-aXs">
                         <rect key="frame" x="808" y="9" width="352" height="178"/>
                         <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
                             </customView>
                         </subviews>
                     </customView>
+                    <customView misplaced="YES" id="jOr-vI-BKr">
+                        <rect key="frame" x="808" y="187" width="352" height="591"/>
+                        <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" heightSizable="YES"/>
+                    </customView>
                 </subviews>
             </view>
             <connections>
                 </binding>
                 <outlet property="delegate" destination="-2" id="4"/>
             </connections>
-            <point key="canvasLocation" x="180.5" y="-663"/>
+            <point key="canvasLocation" x="188.5" y="-705"/>
         </window>
         <arrayController mode="entity" entityName="Deck" fetchPredicateFormat="id = 1" editable="NO" automaticallyPreparesContent="YES" id="eqP-ex-UzI" userLabel="Deck">
             <connections>
index b7db603..63f0983 100644 (file)
@@ -41,7 +41,7 @@ final class BroserWindowController: NSWindowController {
     @IBOutlet private weak var stokerContainer: NSView!
     @IBOutlet private weak var resourcePlaceholder: NSView!
     @IBOutlet private weak var ancherageRepariTimerPlaceholder: NSView!
-    @IBOutlet private weak var informations: NSTabView!
+    @IBOutlet private weak var informationsPlaceholder: NSView!
     @IBOutlet private var deckContoller: NSArrayController!
     
     override var windowNibName: NSNib.Name {
@@ -53,24 +53,12 @@ final class BroserWindowController: NSWindowController {
     @objc var flagShipName: String? {
         return ServerDataStore.default.ship(by: flagShipID)?.name
     }
-    var changeMainTabHandler: ((Int) -> Void)?
-    @objc dynamic var selectedMainTabIndex: Int = 0 {
-        
-        didSet {
-            changeMainTabHandler?(selectedMainTabIndex)
-        }
-    }
     
     private var gameViewController: GameViewController!
     private var fleetViewController: FleetViewController!
-    private var tabViewItemViewControllers: [MainTabVIewItemViewController] = []
+    @objc private var informantionViewController = InformationTabViewController()
     private var ancherageRepariTimerViewController: AncherageRepairTimerViewController!
     private var resourceViewController: ResourceViewController!
-    private var docksViewController: DocksViewController!
-    private var shipViewController: ShipViewController!
-    private var powerUpViewController: PowerUpSupportViewController!
-    private var strengthedListViewController: StrengthenListViewController!
-    private var repairListViewController: RepairListViewController!
     private var combinedViewController: CombileViewController!
     
     private var fleetViewPosition: FleetViewPosition = .above
@@ -85,6 +73,8 @@ final class BroserWindowController: NSWindowController {
         gameViewController = GameViewController()
         replace(view: placeholder, with: gameViewController)
         
+        replace(view: informationsPlaceholder, with: informantionViewController)
+        
         resourceViewController = ResourceViewController()
         replace(view: resourcePlaceholder, with: resourceViewController)
         
@@ -92,20 +82,6 @@ final class BroserWindowController: NSWindowController {
         replace(view: ancherageRepariTimerPlaceholder, with: ancherageRepariTimerViewController)
         if UserDefaults.standard[.screenshotButtonSize] == .small { toggleAnchorageSize(nil) }
         
-        tabViewItemViewControllers = [
-            DocksViewController(),
-            ShipViewController(),
-            PowerUpSupportViewController(),
-            StrengthenListViewController(),
-            RepairListViewController()
-        ]
-        tabViewItemViewControllers.enumerated().forEach {
-            
-            _ = $0.element.view
-            let item = informations.tabViewItem(at: $0.offset)
-            item.viewController = $0.element
-        }
-        
         fleetViewController = FleetViewController(viewType: .detailViewType)
         replace(view: deckPlaceholder, with: fleetViewController)
         setFleetView(position: UserDefaults.standard[.fleetViewPosition], animate: false)
@@ -202,7 +178,7 @@ extension BroserWindowController {
     
     private func showView(number: Int) {
         
-        informations.selectTabViewItem(at: number)
+        informantionViewController.selectionIndex = number
     }
     
     @IBAction func reloadContent(_ sender: AnyObject?) {
@@ -257,10 +233,10 @@ extension BroserWindowController {
         }()
         ancherageRepariTimerViewController.controlSize = newSize
         
-        var frame = informations.frame
+        var frame = informantionViewController.view.frame
         frame.size.height -= diff
         frame.origin.y += diff
-        informations.frame = frame
+        informantionViewController.view.frame = frame
         
         UserDefaults.standard[.screenshotButtonSize] = newSize
     }
@@ -547,10 +523,10 @@ extension BroserWindowController: FleetViewControllerDelegate {
             // hide
             let diffHeight = fleetViewController.shipViewSize.height
             
-            var iFrame = informations.frame
+            var iFrame = informantionViewController.view.frame
             iFrame.origin.y -= diffHeight
             iFrame.size.height += diffHeight
-            informations.animator().frame = iFrame
+            informantionViewController.view.animator().frame = iFrame
             
             var sFrame = stokerContainer.frame
             sFrame.origin.y -= diffHeight
@@ -563,10 +539,10 @@ extension BroserWindowController: FleetViewControllerDelegate {
             //show
             let diffHeight = fleetViewController.shipViewSize.height
             
-            var iFrame = informations.frame
+            var iFrame = informantionViewController.view.frame
             iFrame.origin.y += diffHeight
             iFrame.size.height -= diffHeight
-            informations.animator().frame = iFrame
+            informantionViewController.view.animator().frame = iFrame
             
             var sFrame = stokerContainer.frame
             sFrame.origin.y += diffHeight
@@ -612,26 +588,22 @@ extension BroserWindowController {
         Bundle.main.loadNibNamed(NSNib.Name("BroswerTouchBar"), owner: self, topLevelObjects: nil)
         
         shipTypeSegment.bind(.selectedIndex,
-                             to: tabViewItemViewControllers[0],
-                             withKeyPath: #keyPath(MainTabVIewItemViewController.selectedShipType),
+                             to: informantionViewController,
+                             withKeyPath: #keyPath(InformationTabViewController.selectedShipType),
                              options: nil)
-        let o = selectedMainTabIndex
-        selectedMainTabIndex = o
         
-        changeMainTabHandler = { [weak self] in
+        informantionViewController.selectionDidChangeHandler = { [weak self] in
             
             guard let `self` = self else { return }
             
             self.shipTypeButton.dismissPopover(nil)
-            self.shipTypeSegment.unbind(.selectedIndex)
             
             guard let button = self.shipTypeButton.view as? NSButton else { return }
+            button.isHidden = !self.informantionViewController.hasShipTypeSelector
             
-            let vc = self.tabViewItemViewControllers[$0]
-            button.isHidden = !vc.hasShipTypeSelector
             self.shipTypeSegment.bind(.selectedIndex,
-                                      to: vc,
-                                      withKeyPath: #keyPath(MainTabVIewItemViewController.selectedShipType),
+                                      to: self.informantionViewController,
+                                      withKeyPath: #keyPath(InformationTabViewController.selectedShipType),
                                       options: nil)
         }
         
index ece0544..af6329a 100644 (file)
@@ -36,7 +36,7 @@
                             </segmentedCell>
                             <connections>
                                 <action selector="changeMainTab:" target="-2" id="Rk4-So-gqY"/>
-                                <binding destination="-2" name="selectedIndex" keyPath="selectedMainTabIndex" id="b2F-bE-3gb"/>
+                                <binding destination="-2" name="selectedIndex" keyPath="informantionViewController.selectionIndex" id="8tv-lN-wYI"/>
                             </connections>
                         </segmentedControl>
                     </viewController>
diff --git a/KCD/InformationTabViewController.swift b/KCD/InformationTabViewController.swift
new file mode 100644 (file)
index 0000000..2464d19
--- /dev/null
@@ -0,0 +1,112 @@
+//
+//  InformationTabViewController.swift
+//  KCD
+//
+//  Created by Hori,Masaki on 2018/02/04.
+//  Copyright © 2018年 Hori,Masaki. All rights reserved.
+//
+
+import Cocoa
+
+@objc
+enum ShipTabType: Int {
+    
+    case all = 0
+    case destroyer = 1
+    case lightCruiser = 2
+    case heavyCruiser = 3
+    case aircraftCarrier = 4
+    case battleShip = 5
+    case submarine = 6
+    case other = 7
+}
+
+private let shipTypeCategories: [[Int]] = [
+    [0],    // dummy
+    [2],    // destoryer
+    [3, 4], // leght cruiser
+    [5, 6], // heavy crusier
+    [7, 11, 16, 18],    // aircraft carrier
+    [8, 9, 10, 12], // battle ship
+    [13, 14],   // submarine
+    [1, 15, 17, 19, 20, 21, 22]
+]
+
+func shipTypePredicte(for type: ShipTabType) -> NSPredicate? {
+    
+    switch type {
+    case .all:
+        return nil
+        
+    case .destroyer, .lightCruiser, .heavyCruiser,
+         .aircraftCarrier, .battleShip, .submarine:
+        return NSPredicate(#keyPath(Ship.master_ship.stype.id), valuesIn: shipTypeCategories[type.rawValue])
+        
+    case .other:
+        let omitTypes = shipTypeCategories
+            .lazy
+            .enumerated()
+            .filter { $0.offset != 0 && $0.offset != 7 }
+            .flatMap { $0.element }
+        return .not(NSPredicate(#keyPath(Ship.master_ship.stype.id), valuesIn: omitTypes))
+    }
+}
+
+class InformationTabViewController: NSViewController {
+    
+    @objc private(set) dynamic var hasShipTypeSelector: Bool = false
+    @objc private(set) dynamic var selectedShipType: ShipTabType = .all {
+        
+        didSet {
+            guard case 0..<tabViewItemViewControllers.count = selectionIndex else { return }
+            tabViewItemViewControllers[selectionIndex].selectedShipType = selectedShipType
+        }
+    }
+    @objc dynamic var selectionIndex: Int = 0 {
+        
+        willSet {
+            unbind(NSBindingName("selectedShipType"))
+        }
+
+        didSet {
+            guard case 0..<tabViewItemViewControllers.count = selectionIndex else { return }
+            hasShipTypeSelector = tabViewItemViewControllers[selectionIndex].hasShipTypeSelector
+
+            bind(NSBindingName("selectedShipType"),
+                 to: tabViewItemViewControllers[selectionIndex],
+                 withKeyPath: #keyPath(MainTabVIewItemViewController.selectedShipType))
+            
+            selectionDidChangeHandler?()
+        }
+    }
+    
+    @IBOutlet private var informations: NSTabView!
+    
+    var selectionDidChangeHandler: (() -> Void)?
+    
+    private var tabViewItemViewControllers: [MainTabVIewItemViewController] = []
+    
+    override var nibName: NSNib.Name {
+        
+        return .nibName(instanceOf: self)
+    }
+    
+    override func viewDidLoad() {
+        
+        super.viewDidLoad()
+        
+        tabViewItemViewControllers = [
+            DocksViewController(),
+            ShipViewController(),
+            PowerUpSupportViewController(),
+            StrengthenListViewController(),
+            RepairListViewController()
+        ]
+        tabViewItemViewControllers.enumerated().forEach {
+            
+            _ = $0.element.view
+            let item = informations.tabViewItem(at: $0.offset)
+            item.viewController = $0.element
+        }
+    }
+}
diff --git a/KCD/InformationTabViewController.xib b/KCD/InformationTabViewController.xib
new file mode 100644 (file)
index 0000000..407b407
--- /dev/null
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct">
+    <dependencies>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="InformationTabViewController" customModule="KCD" customModuleProvider="target">
+            <connections>
+                <outlet property="informations" destination="XXO-Jm-qNi" id="WLm-74-M67"/>
+                <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
+            </connections>
+        </customObject>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <customView misplaced="YES" id="Hz6-mo-xeY">
+            <rect key="frame" x="0.0" y="0.0" width="352" height="591"/>
+            <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" heightSizable="YES"/>
+            <subviews>
+                <tabView misplaced="YES" initialItem="63s-iU-P1n" id="XXO-Jm-qNi">
+                    <rect key="frame" x="5" y="-10" width="342" height="599"/>
+                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/>
+                    <font key="font" metaFont="system"/>
+                    <tabViewItems>
+                        <tabViewItem label="状況" identifier="1" id="63s-iU-P1n">
+                            <view key="view" id="V3C-69-IYR">
+                                <rect key="frame" x="10" y="33" width="322" height="553"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                            </view>
+                        </tabViewItem>
+                        <tabViewItem label="編成支援" identifier="2" id="sAf-pN-skj">
+                            <view key="view" id="S7q-fM-diX">
+                                <rect key="frame" x="10" y="33" width="323" height="554"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                            </view>
+                        </tabViewItem>
+                        <tabViewItem label="近代化" identifier="3" id="O5B-9q-O5H">
+                            <view key="view" id="OTx-NG-cmb">
+                                <rect key="frame" x="10" y="33" width="323" height="547"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                            </view>
+                        </tabViewItem>
+                        <tabViewItem label="改修工廠" identifier="4" id="wjg-Nl-MKX">
+                            <view key="view" id="7Hp-a3-U1s">
+                                <rect key="frame" x="10" y="33" width="322" height="553"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                            </view>
+                        </tabViewItem>
+                        <tabViewItem label="修復" identifier="5" id="x5Y-pu-Vw9">
+                            <view key="view" id="FAk-KK-iV7">
+                                <rect key="frame" x="10" y="33" width="322" height="553"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                            </view>
+                        </tabViewItem>
+                    </tabViewItems>
+                    <connections>
+                        <binding destination="-2" name="selectedIndex" keyPath="selectionIndex" id="2Ad-2D-mhT"/>
+                        <outlet property="delegate" destination="-2" id="UqD-gC-JlG"/>
+                    </connections>
+                </tabView>
+            </subviews>
+            <point key="canvasLocation" x="114.5" y="26"/>
+        </customView>
+        <userDefaultsController representsSharedInstance="YES" id="bev-M2-zJ3"/>
+    </objects>
+</document>
index ffdb005..238bc52 100644 (file)
@@ -8,52 +8,8 @@
 
 import Cocoa
 
-@objc
-enum ShipTabType: Int {
-    
-    case all = 0
-    case destroyer = 1
-    case lightCruiser = 2
-    case heavyCruiser = 3
-    case aircraftCarrier = 4
-    case battleShip = 5
-    case submarine = 6
-    case other = 7
-}
-
 class MainTabVIewItemViewController: NSViewController {
     
-    let shipTypeCategories: [[Int]] = [
-        [0],    // dummy
-        [2],    // destoryer
-        [3, 4], // leght cruiser
-        [5, 6], // heavy crusier
-        [7, 11, 16, 18],    // aircraft carrier
-        [8, 9, 10, 12], // battle ship
-        [13, 14],   // submarine
-        [1, 15, 17, 19, 20, 21, 22]
-    ]
-    
     @objc dynamic var hasShipTypeSelector: Bool { return false }
     @objc dynamic var selectedShipType: ShipTabType = .all
-    
-    var shipTypePredicte: NSPredicate? {
-        
-        switch selectedShipType {
-        case .all:
-            return nil
-            
-        case .destroyer, .lightCruiser, .heavyCruiser,
-             .aircraftCarrier, .battleShip, .submarine:
-            return NSPredicate(#keyPath(Ship.master_ship.stype.id), valuesIn: shipTypeCategories[selectedShipType.rawValue])
-            
-        case .other:
-            let omitTypes = shipTypeCategories
-                .lazy
-                .enumerated()
-                .filter { $0.offset != 0 && $0.offset != 7 }
-                .flatMap { $0.element }
-            return .not(NSPredicate(#keyPath(Ship.master_ship.stype.id), valuesIn: omitTypes))
-        }
-    }
 }
index 31c6c03..88bf307 100644 (file)
@@ -71,7 +71,7 @@ final class PowerUpSupportViewController: MainTabVIewItemViewController {
     
     private func customPredicate() -> NSPredicate? {
         
-        switch (shipTypePredicte, omitPredicate) {
+        switch (shipTypePredicte(for: selectedShipType), omitPredicate) {
             
         case let (s?, o?): return .and([o, s])
         case let (s?, nil): return s
index b84377c..7c2413f 100644 (file)
@@ -41,7 +41,7 @@ final class ShipViewController: MainTabVIewItemViewController {
     override var selectedShipType: ShipTabType {
         
         didSet {
-            shipController.filterPredicate = shipTypePredicte
+            shipController.filterPredicate = shipTypePredicte(for: selectedShipType)
             shipController.rearrangeObjects()
         }
     }