F4F9F8A51C78596900D0EE76 /* HMAnchorageRepairManager.m */,
F448F9901B6FBF80004901AD /* HMResourceHistoryManager.h */,
F448F9911B6FBF80004901AD /* HMResourceHistoryManager.m */,
+ F4F9F8991C6CB7D400D0EE76 /* HMFleet.h */,
+ F4F9F89A1C6CB7D400D0EE76 /* HMFleet.m */,
F4F9F8A11C70AFB600D0EE76 /* HMFleetManager.h */,
F4F9F8A21C70AFB600D0EE76 /* HMFleetManager.m */,
F4D2CBBF18ACE7D7000EBC59 /* Command */,
F4D6BC991AA1FAC600742FEB /* HMUITestWindowController.h */,
F4D6BC9A1AA1FAC600742FEB /* HMUITestWindowController.m */,
F4BEF0101B11A645004702B8 /* HMUITestWindowController.xib */,
- F4F9F8991C6CB7D400D0EE76 /* HMFleet.h */,
- F4F9F89A1C6CB7D400D0EE76 /* HMFleet.m */,
F4F9F89C1C6CBFF400D0EE76 /* HMFleetTestViewController.h */,
F4F9F89D1C6CBFF400D0EE76 /* HMFleetTestViewController.m */,
F4F9F89E1C6CBFF400D0EE76 /* HMFleetTestViewController.xib */,
@property (strong) NSObjectController *deckController;
@property (weak) HMKCDeck *deck;
+@property (readonly) NSArray<NSString *> *deckObserveKeys;
+
+@property (strong) NSArray<HMKCShipObject *> *ships;
+@property (readonly) NSArray<NSString *> *shipObserveKeys;
+
@end
@implementation HMFleet
error:NULL];
self.deck = _deckController.content;
+ for(NSString *key in self.deckObserveKeys) {
+ [_deckController addObserver:self
+ forKeyPath:key
+ options:0
+ context:(__bridge void * _Nullable)(_deck)];
+ }
}
return self;
}
+- (void)dealloc
+{
+ for(NSString *key in self.deckObserveKeys) {
+ [_deckController removeObserver:self forKeyPath:key];
+ }
+ for(HMKCShipObject *ship in _ships) {
+ for(NSString *key in self.shipObserveKeys) {
+ [ship removeObserver:self forKeyPath:key];
+ }
+ }
+}
- (instancetype)self
{
return self;
}
+- (NSArray<NSString *> *)deckObserveKeys
+{
+ return [NSArray arrayWithObjects:
+ @"selection.ship_0",
+ @"selection.ship_1",
+ @"selection.ship_2",
+ @"selection.ship_3",
+ @"selection.ship_4",
+ @"selection.ship_5",
+ nil];
+}
+-(NSArray<NSString *> *)shipObserveKeys
+{
+ return [NSArray arrayWithObjects:
+ @"sakuteki_0",
+ @"seiku",
+ @"lv",
+ @"totalDrums",
+ nil];
+}
+
- (HMKCShipObject *)objectAtIndexedSubscript:(NSUInteger)idx
{
return self.deck[idx];
}
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
+{
+ id obj = (__bridge id)(context);
+ if(obj == _deck) {
+
+ for(HMKCShipObject *ship in _ships) {
+ for(NSString *key in self.shipObserveKeys) {
+ [ship removeObserver:self forKeyPath:key];
+ }
+ }
+
+ NSMutableArray<HMKCShipObject *> *result = [NSMutableArray array];
+
+ for(NSUInteger i = 0; i < 6; i++) {
+ HMKCShipObject *ship = self[i];
+ if(ship) {
+ [result addObject:ship];
+ }
+ }
+ self.ships = result;
+
+
+ for(HMKCShipObject *ship in _ships) {
+ for(NSString *key in self.shipObserveKeys) {
+ [ship addObserver:self
+ forKeyPath:key
+ options:0
+ context:(__bridge void * _Nullable)(_ships)];
+ }
+ }
+
+ return;
+ }
+
+ if(obj == _ships) {
+ if([keyPath isEqualToString:@"sakuteki_0"]) {
+ [self willChangeValueForKey:@"totalSakuteki"];
+ [self didChangeValueForKey:@"totalSakuteki"];
+ }
+ if([keyPath isEqualToString:@"seiku"]) {
+ [self willChangeValueForKey:@"totalSeiku"];
+ [self didChangeValueForKey:@"totalSeiku"];
+
+ [self willChangeValueForKey:@"totalCalclatedSeiku"];
+ [self didChangeValueForKey:@"totalCalclatedSeiku"];
+ }
+ if([keyPath isEqualToString:@"lv"]) {
+ [self willChangeValueForKey:@"totalLevel"];
+ [self didChangeValueForKey:@"totalLevel"];
+ }
+ if([keyPath isEqualToString:@"totalDrums"]) {
+ [self willChangeValueForKey:@"totalDrums"];
+ [self didChangeValueForKey:@"totalDrums"];
+ }
+
+ return;
+ }
+
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+}
+
+ (NSSet *)keyPathsForValuesAffectingFlagShip
{
return [NSSet setWithObject:@"deck.ship_0"];
return self[5];
}
-+ (NSSet *)keyPathsForValuesAffectingShips
-{
- return [NSSet setWithObjects:
- @"deck",
- @"deck.ship_0",
- @"deck.ship_1",
- @"deck.ship_2",
- @"deck.ship_3",
- @"deck.ship_4",
- @"deck.ship_5",
- nil];
-}
-- (NSArray<HMKCShipObject *> *)ships
-{
- NSMutableArray<HMKCShipObject *> *result = [NSMutableArray array];
-
- for(NSUInteger i = 0; i < 6; i++) {
- HMKCShipObject *ship = self[i];
- if(ship) {
- [result addObject:ship];
- }
- }
- return result;
-}
-
+ (NSSet *)keyPathsForValuesAffectingName
{
return [NSSet setWithObject:@"deck.name"];
return name;
}
- +(NSSet *)keyPathsForValuesAffectingId
++ (NSSet *)keyPathsForValuesAffectingId
{
return [NSSet setWithObject:@"deck.id"];
}
return self.deck.id;
}
-+ (NSSet *)keyPathsForValuesAffectingTotalSakuteki
-{
- return [NSSet setWithObjects:
- @"flagShip.sakuteki_0",
- @"secondShip.sakuteki_0",
- @"thirdShip.sakuteki_0",
- @"fourthShip.sakuteki_0",
- @"fifthShip.sakuteki_0",
- @"sixthShip.sakuteki_0",
- nil];
-}
- (NSNumber *)totalSakuteki
{
NSInteger total = 0;
return @(total);
}
-+ (NSSet *)keyPathsForValuesAffectingTotalSeiku
-{
- return [NSSet setWithObjects:
- @"flagShip.seiku",
- @"secondShip.seiku",
- @"thirdShip.seiku",
- @"fourthShip.seiku",
- @"fifthShip.seiku",
- @"sixthShip.seiku",
- nil];
-}
- (NSNumber *)totalSeiku
{
NSInteger total = 0;
}
return @(total);
}
-+ (NSSet *)keyPathsForValuesAffectingTotalCalclatedSeiku
-{
- return [NSSet setWithObjects:
- @"flagShip.seiku",
- @"secondShip.seiku",
- @"thirdShip.seiku",
- @"fourthShip.seiku",
- @"fifthShip.seiku",
- @"sixthShip.seiku",
- nil];
-}
+
- (NSNumber *)totalCalclatedSeiku
{
NSInteger total = 0;
}
return @(total);
}
-+ (NSSet *)keyPathsForValuesAffectingTotalLevel
-{
- return [NSSet setWithObjects:
- @"flagShip.lv",
- @"secondShip.lv",
- @"thirdShip.lv",
- @"fourthShip.lv",
- @"fifthShip.lv",
- @"sixthShip.lv",
- nil];
-}
+
- (NSNumber *)totalLevel
{
NSInteger total = 0;
}
return @(total);
}
-+ (NSSet *)keyPathsForValuesAffectingTotalDrums
-{
- return [NSSet setWithObjects:
- @"flagShip.totalDrums",
- @"secondShip.totalDrums",
- @"thirdShip.totalDrums",
- @"fourthShip.totalDrums",
- @"fifthShip.totalDrums",
- @"sixthShip.totalDrums",
- nil];
-}
+
- (NSNumber *)totalDrums
{
NSInteger total = 0;
</textFieldCell>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont13" id="YGt-l5-CEm"/>
- <binding destination="-2" name="value" keyPath="totalSakuteki" id="bfC-4h-Kty"/>
+ <binding destination="gCv-EU-Vnz" name="value" keyPath="selection.totalSakuteki" id="lEf-ph-nP1"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="M1a-LI-gu8">
</textFieldCell>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont13" id="sWc-ye-BZI"/>
- <binding destination="-2" name="value" keyPath="totalSeiku" id="8cZ-nQ-cKa"/>
+ <binding destination="gCv-EU-Vnz" name="value" keyPath="selection.totalSeiku" id="K0E-f6-4K6"/>
</connections>
</textField>
<customView id="OS9-eb-ikq">
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
- <binding destination="-2" name="displayPatternValue1" keyPath="title" id="oKO-eH-fc6">
+ <binding destination="gCv-EU-Vnz" name="displayPatternValue1" keyPath="selection.title" id="2HA-iK-192">
<dictionary key="options">
<string key="NSDisplayPattern">【 %{value1}@ 】</string>
</dictionary>
</column>
</cells>
<connections>
- <binding destination="-2" name="selectedTag" keyPath="fleetNumber" id="491-wW-IIh"/>
+ <binding destination="gCv-EU-Vnz" name="selectedTag" keyPath="selection.fleetNumber" id="CO4-5V-IgZ"/>
</connections>
</matrix>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="358-6d-um3">
</textFieldCell>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont11" id="vqv-f1-c1R"/>
- <binding destination="-2" name="value" keyPath="repairTime" id="WBa-ln-wqJ"/>
<binding destination="-2" name="hidden" keyPath="repairable" id="v9O-cV-MtY">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
+ <binding destination="gCv-EU-Vnz" name="value" keyPath="selection.repairTime" id="ji6-MJ-aDf"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="BWI-Rq-wLq">
</textFieldCell>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont13" id="EA7-DS-uA0"/>
- <binding destination="-2" name="displayPatternValue1" keyPath="totalCalclatedSeiku" id="ypd-Ik-qlQ">
+ <binding destination="gCv-EU-Vnz" name="displayPatternValue1" keyPath="selection.totalCalclatedSeiku" id="l9V-Jl-gAR">
<dictionary key="options">
<string key="NSDisplayPattern">(%{value1}@)</string>
</dictionary>
</textFieldCell>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont13" id="evB-kA-hbO"/>
- <binding destination="-2" name="value" keyPath="totalLevel" id="FO1-5z-GWZ"/>
+ <binding destination="gCv-EU-Vnz" name="value" keyPath="selection.totalLevel" id="lNL-Cf-88e"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Iqq-0w-7fM">
</textFieldCell>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont13" id="hgF-tA-AMg"/>
- <binding destination="-2" name="value" keyPath="totalDrums" id="JOK-6g-the"/>
+ <binding destination="gCv-EU-Vnz" name="value" keyPath="selection.totalDrums" id="vGG-2E-ugY"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="6t4-zJ-l1x">
</subviews>
<point key="canvasLocation" x="139.5" y="169"/>
</customView>
+ <objectController id="gCv-EU-Vnz">
+ <connections>
+ <binding destination="-2" name="contentObject" keyPath="self" id="w6d-fp-7LO"/>
+ </connections>
+ </objectController>
</objects>
</document>
</column>
</cells>
<connections>
- <binding destination="-2" name="selectedTag" keyPath="fleetNumber" id="4gQ-71-HFy"/>
+ <binding destination="MYB-8m-P41" name="selectedTag" keyPath="selection.fleetNumber" id="M2a-NH-QOd"/>
</connections>
</matrix>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="GMS-aA-S7M">
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
- <binding destination="-2" name="displayPatternValue1" keyPath="title" id="QcF-tz-knF">
+ <binding destination="MYB-8m-P41" name="displayPatternValue1" keyPath="selection.title" id="gra-MV-rb1">
<dictionary key="options">
<string key="NSDisplayPattern">【 %{value1}@ 】</string>
</dictionary>
</textFieldCell>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont13" id="PF0-ou-K6v"/>
- <binding destination="-2" name="value" keyPath="totalSakuteki" id="1H9-FR-9Aw"/>
+ <binding destination="MYB-8m-P41" name="value" keyPath="selection.totalSakuteki" id="JRu-FL-yUV"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="ee5-Xk-4iW">
</textFieldCell>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont13" id="r57-yZ-zBo"/>
- <binding destination="-2" name="displayPatternValue2" keyPath="totalCalclatedSeiku" previousBinding="ucj-A3-qBe" id="VyW-d3-E9s">
+ <binding destination="MYB-8m-P41" name="displayPatternValue1" keyPath="selection.totalSeiku" id="7Sq-iR-bBg">
<dictionary key="options">
<string key="NSDisplayPattern">%{value1}@ (%{value2}@)</string>
</dictionary>
</binding>
- <binding destination="-2" name="displayPatternValue1" keyPath="totalSeiku" id="ucj-A3-qBe">
+ <binding destination="MYB-8m-P41" name="displayPatternValue2" keyPath="selection.totalCalclatedSeiku" previousBinding="7Sq-iR-bBg" id="70Q-az-J1k">
<dictionary key="options">
<string key="NSDisplayPattern">%{value1}@ (%{value2}@)</string>
</dictionary>
</textFieldCell>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont11" id="D3c-11-4qp"/>
- <binding destination="-2" name="value" keyPath="repairTime" id="Rpx-gC-Nbh"/>
- <binding destination="-2" name="hidden" keyPath="repairable" id="Cw6-c1-lcW">
+ <binding destination="MYB-8m-P41" name="hidden" keyPath="selection.repairable" id="6p5-99-GUi">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
+ <binding destination="MYB-8m-P41" name="value" keyPath="selection.repairTime" id="L7t-yF-hnS"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" id="1Fs-NZ-L8n">
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
- <binding destination="-2" name="hidden" keyPath="repairable" id="fmc-Sd-Loi">
+ <binding destination="MYB-8m-P41" name="hidden" keyPath="selection.repairable" id="xl5-3h-df3">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</textFieldCell>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont11" id="gvk-Hk-6Vj"/>
- <binding destination="-2" name="value" keyPath="totalLevel" id="qCE-qb-nrX"/>
+ <binding destination="MYB-8m-P41" name="value" keyPath="selection.totalLevel" id="C5N-Lk-Z6F"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="psc-iQ-sNL">
</textFieldCell>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont11" id="1wd-PW-Ssy"/>
- <binding destination="-2" name="value" keyPath="totalDrums" id="jQv-Sw-nHS"/>
+ <binding destination="MYB-8m-P41" name="value" keyPath="selection.totalDrums" id="SpP-yR-CpU"/>
</connections>
</textField>
</subviews>
<point key="canvasLocation" x="334.5" y="485"/>
</customView>
+ <objectController id="MYB-8m-P41">
+ <connections>
+ <binding destination="-2" name="contentObject" keyPath="self" id="Ab7-TR-6Tv"/>
+ </connections>
+ </objectController>
</objects>
</document>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
- <binding destination="-2" name="displayPatternValue1" keyPath="title" id="BJg-3Z-vLc">
+ <binding destination="hh2-zf-ptT" name="displayPatternValue1" keyPath="selection.title" id="8bk-nf-7BY">
<dictionary key="options">
<string key="NSDisplayPattern">【 %{value1}@ 】</string>
</dictionary>
</subviews>
<point key="canvasLocation" x="494.5" y="313"/>
</customView>
+ <objectController id="hh2-zf-ptT">
+ <connections>
+ <binding destination="-2" name="contentObject" keyPath="self" id="PYZ-Cq-yCe"/>
+ </connections>
+ </objectController>
</objects>
</document>