OSDN Git Service

リファクタリング
authormasakih <masakih@users.sourceforge.jp>
Sun, 27 Aug 2017 02:56:18 +0000 (11:56 +0900)
committermasakih <masakih@users.sourceforge.jp>
Sun, 27 Aug 2017 02:56:18 +0000 (11:56 +0900)
艦載機数の処理はShipDetailViewControllerしか使用しないので移動

KCD/Base.lproj/ShipDetailViewController.xib
KCD/Ship.swift
KCD/ShipDetailViewController.swift

index faac13d..3e43762 100644 (file)
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
     <dependencies>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/>
         <capability name="box content view" minToolsVersion="7.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -33,7 +34,7 @@
                 <rect key="frame" x="1" y="1" width="265" height="127"/>
                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                 <subviews>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Y34-Rg-VIJ">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="Y34-Rg-VIJ">
                         <rect key="frame" x="17" y="106" width="109" height="19"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Prinz Eugen改" id="W58-Ho-kVQ">
@@ -49,7 +50,7 @@
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Mgo-sm-Ba0">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="Mgo-sm-Ba0">
                         <rect key="frame" x="126" y="107" width="47" height="17"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Lv.123" id="mT8-P9-jjK">
@@ -68,7 +69,7 @@
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="ceM-oU-ohy">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="ceM-oU-ohy">
                         <rect key="frame" x="4" y="92" width="37" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="火力:" id="vfx-Mz-g7z">
@@ -77,7 +78,7 @@
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="fsg-0d-8Lp">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="fsg-0d-8Lp">
                         <rect key="frame" x="36" y="92" width="25" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="555" id="97X-rl-6bJ">
@@ -95,7 +96,7 @@
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Ktf-5r-pLo">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="Ktf-5r-pLo">
                         <rect key="frame" x="232" y="91" width="29" height="17"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="555" id="D74-dY-yKV">
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="ugl-Cj-bSp">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="ugl-Cj-bSp">
                         <rect key="frame" x="172" y="107" width="61" height="17"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="999/999" id="YS8-Um-wf7">
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="MRY-hC-9uC">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="MRY-hC-9uC">
                         <rect key="frame" x="4" y="77" width="37" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="装甲:" id="1bJ-In-ICf">
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Zc7-ue-oHw">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="Zc7-ue-oHw">
                         <rect key="frame" x="36" y="77" width="25" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="555" id="EPQ-6S-lJx">
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="1eR-iS-CUN">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="1eR-iS-CUN">
                         <rect key="frame" x="4" y="62" width="37" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="雷装:" id="Z2k-cU-r7c">
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="3vv-f8-sgy">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="3vv-f8-sgy">
                         <rect key="frame" x="36" y="62" width="25" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="555" id="uwB-xu-rsd">
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="zCj-y8-C5T">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="zCj-y8-C5T">
                         <rect key="frame" x="4" y="47" width="37" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="回避:" id="yD4-WS-iLS">
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="5Ue-SK-Xt8">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="5Ue-SK-Xt8">
                         <rect key="frame" x="36" y="47" width="25" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="555" id="RJ9-Qo-ubz">
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="qU8-6G-9gY">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="qU8-6G-9gY">
                         <rect key="frame" x="4" y="32" width="37" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="対空:" id="Dnw-0c-eLj">
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="0RU-Pe-4LX">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="0RU-Pe-4LX">
                         <rect key="frame" x="36" y="32" width="25" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="555" id="iHj-Mu-ZLf">
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="lOg-nu-f26">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="lOg-nu-f26">
                         <rect key="frame" x="4" y="17" width="37" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="対潜:" id="7vx-dP-eGj">
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="axH-d5-h9D">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="axH-d5-h9D">
                         <rect key="frame" x="36" y="17" width="25" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="555" id="Efe-Ci-C3T">
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="iXP-03-yRZ">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="iXP-03-yRZ">
                         <rect key="frame" x="4" y="2" width="37" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="索敵:" id="vOt-zO-K4A">
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="VMu-qn-8NI">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="VMu-qn-8NI">
                         <rect key="frame" x="36" y="2" width="25" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="555" id="Mg7-8k-79L">
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="McZ-6v-GDF">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="McZ-6v-GDF">
                         <rect key="frame" x="66" y="92" width="37" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="運:" id="DSB-48-575">
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="hKw-ov-b75">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="hKw-ov-b75">
                         <rect key="frame" x="98" y="92" width="25" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="555" id="Xqe-Bx-Ooz">
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="U7o-v0-l1J">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="U7o-v0-l1J">
                         <rect key="frame" x="128" y="92" width="37" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="速力:" id="Spz-5K-xfv">
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="e8z-uk-5Kj">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="e8z-uk-5Kj">
                         <rect key="frame" x="160" y="92" width="35" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="高速+" id="Olc-Xu-clL">
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="8GG-wV-a8e">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="8GG-wV-a8e">
                         <rect key="frame" x="128" y="77" width="37" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="射程:" id="8HX-j5-jq0">
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Zhh-D8-R6Y">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="Zhh-D8-R6Y">
                         <rect key="frame" x="160" y="77" width="30" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="超長" id="F1x-Yu-yre">
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Jiw-hE-AJM">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="Jiw-hE-AJM">
                         <rect key="frame" x="66" y="77" width="37" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="搭載:" id="SP3-pD-Caa">
                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                         </textFieldCell>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Cn3-Yw-zgh">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="Cn3-Yw-zgh">
                         <rect key="frame" x="98" y="77" width="25" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="555" id="0Vj-2t-qLU">
                             </binding>
                         </connections>
                     </textField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="8el-1C-ACV">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="8el-1C-ACV">
                         <rect key="frame" x="200" y="92" width="37" height="14"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="制空:" id="fvf-MP-0qU">
                             <rect key="frame" x="1" y="1" width="189" height="67"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="9ct-MC-zEi" customClass="SlotItemLevelView" customModule="KCD">
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="9ct-MC-zEi" customClass="SlotItemLevelView" customModule="KCD">
                                     <rect key="frame" x="41" y="52" width="147" height="14"/>
                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="10cm連装高角砲+高射装置" id="1lW-BG-Ev2">
                                         </binding>
                                     </connections>
                                 </textField>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="WPW-1R-1aV" customClass="SlotItemLevelView" customModule="KCD">
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="WPW-1R-1aV" customClass="SlotItemLevelView" customModule="KCD">
                                     <rect key="frame" x="41" y="35" width="147" height="14"/>
                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="12.7cm連装高角砲(後期型)" id="1uW-vl-74P">
                                         </binding>
                                     </connections>
                                 </textField>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="4qS-ds-Fe5" customClass="SlotItemLevelView" customModule="KCD">
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="4qS-ds-Fe5" customClass="SlotItemLevelView" customModule="KCD">
                                     <rect key="frame" x="41" y="18" width="147" height="14"/>
                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="35.6cm連装砲(ダズル迷彩)" id="qp5-M3-ZJi">
                                         </binding>
                                     </connections>
                                 </textField>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="uE8-Fk-T3P" customClass="SlotItemLevelView" customModule="KCD">
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="uE8-Fk-T3P" customClass="SlotItemLevelView" customModule="KCD">
                                     <rect key="frame" x="41" y="1" width="147" height="14"/>
                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="10cm連装高角砲+高射装置" id="fcc-QI-18E">
                                         </binding>
                                     </connections>
                                 </textField>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Jo0-C2-Coa">
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="Jo0-C2-Coa">
                                     <rect key="frame" x="0.0" y="1" width="38" height="14"/>
                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="99/99" id="XHs-C6-7hc">
                                     </textFieldCell>
                                     <connections>
                                         <binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont11" id="mFd-Yt-QLh"/>
-                                        <binding destination="LyA-xZ-gxq" name="value" keyPath="selection.planeString3" id="xIK-54-52H">
+                                        <binding destination="-2" name="textColor" keyPath="planeString3Color" id="gZe-bT-enR"/>
+                                        <binding destination="-2" name="value" keyPath="planeString3" id="js3-nV-iBS">
                                             <dictionary key="options">
                                                 <string key="NSNoSelectionPlaceholder" base64-UTF8="YES">
 IA
 </string>
                                             </dictionary>
                                         </binding>
-                                        <binding destination="LyA-xZ-gxq" name="textColor" keyPath="selection.planeString3Color" id="Chy-2e-Lmi"/>
                                     </connections>
                                 </textField>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="WhO-fO-H5s">
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="WhO-fO-H5s">
                                     <rect key="frame" x="0.0" y="18" width="38" height="14"/>
                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="99/99" id="3nX-18-ISc">
@@ -521,17 +522,17 @@ IA
                                     </textFieldCell>
                                     <connections>
                                         <binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont11" id="kul-5E-0xA"/>
-                                        <binding destination="LyA-xZ-gxq" name="value" keyPath="selection.planeString2" id="uFu-EH-LYM">
+                                        <binding destination="-2" name="textColor" keyPath="planeString2Color" id="92B-9I-0X1"/>
+                                        <binding destination="-2" name="value" keyPath="planeString2" id="qkZ-9N-oqy">
                                             <dictionary key="options">
                                                 <string key="NSNoSelectionPlaceholder" base64-UTF8="YES">
 IA
 </string>
                                             </dictionary>
                                         </binding>
-                                        <binding destination="LyA-xZ-gxq" name="textColor" keyPath="selection.planeString2Color" id="buT-xh-Ibg"/>
                                     </connections>
                                 </textField>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="RcS-au-uGU">
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="RcS-au-uGU">
                                     <rect key="frame" x="0.0" y="35" width="38" height="14"/>
                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="99/99" id="I80-Vv-z3M">
@@ -541,17 +542,17 @@ IA
                                     </textFieldCell>
                                     <connections>
                                         <binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont11" id="UGQ-Lq-cIy"/>
-                                        <binding destination="LyA-xZ-gxq" name="value" keyPath="selection.planeString1" id="lL8-wA-VaA">
+                                        <binding destination="-2" name="textColor" keyPath="planeString1Color" id="yLs-nI-6Eh"/>
+                                        <binding destination="-2" name="value" keyPath="planeString1" id="WxT-dq-WOY">
                                             <dictionary key="options">
                                                 <string key="NSNoSelectionPlaceholder" base64-UTF8="YES">
 IA
 </string>
                                             </dictionary>
                                         </binding>
-                                        <binding destination="LyA-xZ-gxq" name="textColor" keyPath="selection.planeString1Color" id="fQG-fy-OXE"/>
                                     </connections>
                                 </textField>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Fv0-MW-cv7">
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="Fv0-MW-cv7">
                                     <rect key="frame" x="0.0" y="52" width="38" height="14"/>
                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="99/99" id="Fyg-Sb-gUy">
@@ -561,14 +562,14 @@ IA
                                     </textFieldCell>
                                     <connections>
                                         <binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont11" id="IHy-kj-CyW"/>
-                                        <binding destination="LyA-xZ-gxq" name="value" keyPath="selection.planeString0" id="uGt-PK-qg0">
+                                        <binding destination="-2" name="textColor" keyPath="planeString0Color" id="gra-3k-OxL"/>
+                                        <binding destination="-2" name="value" keyPath="planeString0" id="pzf-s3-KKv">
                                             <dictionary key="options">
                                                 <string key="NSNoSelectionPlaceholder" base64-UTF8="YES">
 IA
 </string>
                                             </dictionary>
                                         </binding>
-                                        <binding destination="LyA-xZ-gxq" name="textColor" keyPath="selection.planeString0Color" id="qi5-CC-ewP"/>
                                     </connections>
                                 </textField>
                             </subviews>
@@ -576,7 +577,7 @@ IA
                         <color key="borderColor" name="gridColor" catalog="System" colorSpace="catalog"/>
                         <color key="fillColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                     </box>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="qbZ-eV-gqf">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="qbZ-eV-gqf">
                         <rect key="frame" x="232" y="109" width="29" height="17"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="555" id="JVG-Dt-axT">
@@ -601,7 +602,7 @@ IA
                             <rect key="frame" x="1" y="1" width="30" height="14"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="3He-Ij-QMC">
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="3He-Ij-QMC">
                                     <rect key="frame" x="1" y="0.0" width="26" height="14"/>
                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="女神" id="aOL-vK-iPi">
@@ -632,7 +633,7 @@ IA
                             </binding>
                         </connections>
                     </box>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="yeA-LB-gv0">
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="yeA-LB-gv0">
                         <rect key="frame" x="4" y="109" width="13" height="17"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="6" id="f1f-Lx-lTx">
index 336ab28..c771837 100644 (file)
@@ -289,8 +289,6 @@ extension Ship {
     }
 }
 
-fileprivate let allPlaneTypes: [Int] = [6, 7, 8, 9, 10, 11, 25, 26, 41, 45, 56, 57, 58, 59]
-
 extension Ship {
     
     func setItem(_ id: Int, for slot: Int) {
@@ -329,7 +327,7 @@ extension Ship {
         }
     }
     
-    private func slotItemMax(_ index: Int) -> Int {
+    func slotItemMax(_ index: Int) -> Int {
         
         switch index {
         case 0: return master_ship.maxeq_0
@@ -341,7 +339,7 @@ extension Ship {
         }
     }
     
-    private func slotItem(_ index: Int) -> SlotItem? {
+    func slotItem(_ index: Int) -> SlotItem? {
         
         return ServerDataStore.default.slotItem(by: slotItemId(index))
     }
@@ -361,11 +359,7 @@ extension Ship {
         return SeikuCalclator(ship: self).seiku
     }
     
-    class func keyPathsForValuesAffectingTotalSeiku() -> Set<String> {
-        
-        return ["seiku"]
-    }
-    dynamic var totalSeiku: Int {
+    var totalSeiku: Int {
         
         return SeikuCalclator(ship: self).totalSeiku
     }
@@ -375,109 +369,4 @@ extension Ship {
         return (0...4).flatMap(slotItem).filter { $0.slotitem_id == 75 }.count
     }
     
-    // MARK: - Plane count strings
-    private enum PlaneState {
-        
-        case cannotEquip
-        case notEquip(Int)
-        case equiped(Int, Int)
-    }
-    
-    private func planState(_ index: Int) -> PlaneState {
-        
-        let itemId = slotItemId(index)
-        let maxCount = slotItemMax(index)
-        
-        if maxCount == 0 { return .cannotEquip }
-        if itemId == -1 { return .notEquip(maxCount) }
-        
-        if let item = slotItem(index),
-            allPlaneTypes.contains(item.master_slotItem.type_2) {
-            
-            return .equiped(slotItemCount(index), maxCount)
-        }
-        
-        return .notEquip(maxCount)
-    }
-    
-    private func planeString(_ index: Int) -> String? {
-        
-        switch planState(index) {
-        case .cannotEquip:
-            return nil
-        case .notEquip(let max):
-            return "\(max)"
-        case .equiped(let count, let max):
-            return "\(count)/\(max)"
-        }
-    }
-    
-    class func keyPathsForValuesAffectingPlaneString0() -> Set<String> {
-        
-        return ["onslot_0", "master_ship.maxeq_0", "equippedItem"]
-    }
-    dynamic var planeString0: String? { return planeString(0) }
-    
-    class func keyPathsForValuesAffectingPlaneString1() -> Set<String> {
-        
-        return ["onslot_1", "master_ship.maxeq_1", "equippedItem"]
-    }
-    dynamic var planeString1: String? { return planeString(1) }
-    
-    class func keyPathsForValuesAffectingPlaneString2() -> Set<String> {
-        
-        return ["onslot_2", "master_ship.maxeq_2", "equippedItem"]
-    }
-    dynamic var planeString2: String? { return planeString(2) }
-    
-    class func keyPathsForValuesAffectingPlaneString3() -> Set<String> {
-        
-        return ["onslot_3", "master_ship.maxeq_3", "equippedItem"]
-    }
-    dynamic var planeString3: String? { return planeString(3) }
-    
-    class func keyPathsForValuesAffectingPlaneString4() -> Set<String> {
-        
-        return ["onslot_4", "master_ship.maxeq_4", "equippedItem"]
-    }
-    dynamic var planeString4: String? { return planeString(4) }
-    
-    // MARK: - Plane count string color
-    private func planeStringColor(_ index: Int) -> NSColor {
-        switch planState(index) {
-        case .cannotEquip: return NSColor.controlTextColor
-        case .notEquip: return NSColor.disabledControlTextColor
-        case .equiped: return NSColor.controlTextColor
-        }
-    }
-    
-    class func keyPathsForValuesAffectingPlaneString0Color() -> Set<String> {
-        
-        return ["onslot_0", "master_ship.maxeq_0", "equippedItem"]
-    }
-    dynamic var planeString0Color: NSColor { return planeStringColor(0) }
-    
-    class func keyPathsForValuesAffectingPlaneString1Color() -> Set<String> {
-        
-        return ["onslot_1", "master_ship.maxeq_1", "equippedItem"]
-    }
-    dynamic var planeString1Color: NSColor { return planeStringColor(1) }
-    
-    class func keyPathsForValuesAffectingPlaneString2Color() -> Set<String> {
-        
-        return ["onslot_2", "master_ship.maxeq_2", "equippedItem"]
-    }
-    dynamic var planeString2Color: NSColor { return planeStringColor(2) }
-    
-    class func keyPathsForValuesAffectingPlaneString3Color() -> Set<String> {
-        
-        return ["onslot_3", "master_ship.maxeq_3", "equippedItem"]
-    }
-    dynamic var planeString3Color: NSColor { return planeStringColor(3) }
-    
-    class func keyPathsForValuesAffectingPlaneString4Color() -> Set<String> {
-        
-        return ["onslot_4", "master_ship.maxeq_4", "equippedItem"]
-    }
-    dynamic var planeString4Color: NSColor { return planeStringColor(4) }
 }
index f9178e3..5a04c8a 100644 (file)
@@ -24,6 +24,13 @@ private func nibNameFor(_ type: ShipDetailViewType) -> String {
     }
 }
 
+fileprivate var shipContext: Int = 0
+fileprivate var equippedItem0Context: Int = 0
+fileprivate var equippedItem1Context: Int = 0
+fileprivate var equippedItem2Context: Int = 0
+fileprivate var equippedItem3Context: Int = 0
+fileprivate var equippedItem4Context: Int = 0
+
 final class ShipDetailViewController: NSViewController {
     
     let type: ShipDetailViewType
@@ -57,6 +64,8 @@ final class ShipDetailViewController: NSViewController {
         supply.unbind(#keyPath(SuppliesView.shipStatus))
         [slot00Field, slot01Field, slot02Field, slot03Field]
             .forEach { $0?.unbind(#keyPath(SlotItemLevelView.slotItemID)) }
+        
+        shipController.removeObject(self)
     }
     
     
@@ -80,6 +89,7 @@ final class ShipDetailViewController: NSViewController {
         
         get { return shipController.content as? Ship }
         set {
+            
             shipController.fetchPredicate = NSPredicate(format: "id = %ld", newValue?.id ?? 0)
         }
     }
@@ -113,5 +123,162 @@ final class ShipDetailViewController: NSViewController {
             
             $0.0?.bind(#keyPath(SlotItemLevelView.slotItemID), to: shipController, withKeyPath: $0.1, options: nil)
         }
+        
+        // observe slotitems count
+        shipController.addObserver(self, forKeyPath: "selection", context: &shipContext)
+        
+        shipController.addObserver(self, forKeyPath: "selection.slot_0", context: &equippedItem0Context)
+        shipController.addObserver(self, forKeyPath: "selection.onslot_0", context: &equippedItem0Context)
+        shipController.addObserver(self, forKeyPath: "selection.master_ship.maxeq_0", context: &equippedItem0Context)
+        
+        shipController.addObserver(self, forKeyPath: "selection.slot_1", context: &equippedItem1Context)
+        shipController.addObserver(self, forKeyPath: "selection.onslot_1", context: &equippedItem1Context)
+        shipController.addObserver(self, forKeyPath: "selection.master_ship.maxeq_1", context: &equippedItem1Context)
+        
+        shipController.addObserver(self, forKeyPath: "selection.slot_2", context: &equippedItem2Context)
+        shipController.addObserver(self, forKeyPath: "selection.onslot_2", context: &equippedItem2Context)
+        shipController.addObserver(self, forKeyPath: "selection.master_ship.maxeq_2", context: &equippedItem2Context)
+        
+        shipController.addObserver(self, forKeyPath: "selection.slot_3", context: &equippedItem3Context)
+        shipController.addObserver(self, forKeyPath: "selection.onslot_3", context: &equippedItem3Context)
+        shipController.addObserver(self, forKeyPath: "selection.master_ship.maxeq_3", context: &equippedItem3Context)
+        
+        shipController.addObserver(self, forKeyPath: "selection.slot_4", context: &equippedItem4Context)
+        shipController.addObserver(self, forKeyPath: "selection.onslot_4", context: &equippedItem4Context)
+        shipController.addObserver(self, forKeyPath: "selection.master_ship.maxeq_4", context: &equippedItem4Context)
+        
+    }
+    
+    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
+        
+        if context == &shipContext {
+            
+            notifyChangeValue(forKey: "planeString0")
+            notifyChangeValue(forKey: "planeString0Color")
+            notifyChangeValue(forKey: "planeString1")
+            notifyChangeValue(forKey: "planeString1Color")
+            notifyChangeValue(forKey: "planeString2")
+            notifyChangeValue(forKey: "planeString2Color")
+            notifyChangeValue(forKey: "planeString3")
+            notifyChangeValue(forKey: "planeString3Color")
+            notifyChangeValue(forKey: "planeString4")
+            notifyChangeValue(forKey: "planeString4Color")
+            
+            return
+        }
+        if context == &equippedItem0Context {
+            
+            notifyChangeValue(forKey: "planeString0")
+            notifyChangeValue(forKey: "planeString0Color")
+            
+            return
+        }
+        if context == &equippedItem1Context {
+            
+            notifyChangeValue(forKey: "planeString1")
+            notifyChangeValue(forKey: "planeString1Color")
+            
+            return
+        }
+        if context == &equippedItem2Context {
+            
+            notifyChangeValue(forKey: "planeString2")
+            notifyChangeValue(forKey: "planeString2Color")
+            
+            return
+        }
+        if context == &equippedItem3Context {
+            
+            notifyChangeValue(forKey: "planeString3")
+            notifyChangeValue(forKey: "planeString3Color")
+            
+            return
+        }
+        if context == &equippedItem4Context {
+            
+            notifyChangeValue(forKey: "planeString4")
+            notifyChangeValue(forKey: "planeString4Color")
+            
+            return
+        }
+        
+        super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
     }
 }
+
+
+fileprivate let allPlaneTypes: [Int] = [6, 7, 8, 9, 10, 11, 25, 26, 41, 45, 56, 57, 58, 59]
+
+
+extension ShipDetailViewController {
+    
+    // MARK: - Plane count strings
+    private enum PlaneState {
+        
+        case cannotEquip
+        case notEquip(Int)
+        case equiped(Int, Int)
+    }
+    
+    private func planState(_ index: Int) -> PlaneState {
+        
+        guard let ship = ship
+            else { return .cannotEquip }
+        
+        let itemId = ship.slotItemId(index)
+        let maxCount = ship.slotItemMax(index)
+        
+        if maxCount == 0 { return .cannotEquip }
+        if itemId == -1 { return .notEquip(maxCount) }
+        
+        if let item = ship.slotItem(index),
+            allPlaneTypes.contains(item.master_slotItem.type_2) {
+            
+            return .equiped(ship.slotItemCount(index), maxCount)
+        }
+        
+        return .notEquip(maxCount)
+    }
+    
+    private func planeString(_ index: Int) -> String? {
+        
+        switch planState(index) {
+        case .cannotEquip:
+            return nil
+        case .notEquip(let max):
+            return "\(max)"
+        case .equiped(let count, let max):
+            return "\(count)/\(max)"
+        }
+    }
+    
+    dynamic var planeString0: String? { return planeString(0) }
+    
+    dynamic var planeString1: String? { return planeString(1) }
+    
+    dynamic var planeString2: String? { return planeString(2) }
+    
+    dynamic var planeString3: String? { return planeString(3) }
+    
+    dynamic var planeString4: String? { return planeString(4) }
+    
+    // MARK: - Plane count string color
+    private func planeStringColor(_ index: Int) -> NSColor {
+        
+        switch planState(index) {
+        case .cannotEquip: return NSColor.controlTextColor
+        case .notEquip: return NSColor.disabledControlTextColor
+        case .equiped: return NSColor.controlTextColor
+        }
+    }
+    
+    dynamic var planeString0Color: NSColor { return planeStringColor(0) }
+    
+    dynamic var planeString1Color: NSColor { return planeStringColor(1) }
+    
+    dynamic var planeString2Color: NSColor { return planeStringColor(2) }
+    
+    dynamic var planeString3Color: NSColor { return planeStringColor(3) }
+    
+    dynamic var planeString4Color: NSColor { return planeStringColor(4) }
+}