OSDN Git Service

連合艦隊表示ビューを追加
authormasakih <masakih@users.sourceforge.jp>
Sun, 22 Nov 2015 12:00:04 +0000 (21:00 +0900)
committermasakih <masakih@users.sourceforge.jp>
Sun, 29 Nov 2015 02:20:18 +0000 (11:20 +0900)
KCD.xcodeproj/project.pbxproj
KCD/HMCombileViewController.h [new file with mode: 0644]
KCD/HMCombileViewController.m [new file with mode: 0644]
KCD/HMCombileViewController.xib [new file with mode: 0644]
KCD/HMUITestWindowController.m
KCD/HMVerticalFleetViewController.h [new file with mode: 0644]
KCD/HMVerticalFleetViewController.m [new file with mode: 0644]
KCD/HMVerticalFleetViewController.xib [new file with mode: 0644]
KCD/ja.lproj/HMUITestWindowController.xib

index 640402d..4fbc8f6 100644 (file)
                F4E7802E18DC3AF00011BC4C /* LocalData.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = F4E7802C18DC3AF00011BC4C /* LocalData.xcdatamodeld */; };
                F4ED5D2A1B78D0CA00D1BDEF /* HMGuardEscapedView.m in Sources */ = {isa = PBXBuildFile; fileRef = F4ED5D291B78D0CA00D1BDEF /* HMGuardEscapedView.m */; };
                F4ED5D2D1B7C677E00D1BDEF /* HMGuardShelterCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4ED5D2C1B7C677E00D1BDEF /* HMGuardShelterCommand.m */; };
+               F4F4791A1BFE223600D0BF69 /* HMCombileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F479181BFE223600D0BF69 /* HMCombileViewController.m */; };
+               F4F4791B1BFE223600D0BF69 /* HMCombileViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4F479191BFE223600D0BF69 /* HMCombileViewController.xib */; };
+               F4F4791F1C01424200D0BF69 /* HMVerticalFleetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F4791D1C01424200D0BF69 /* HMVerticalFleetViewController.m */; };
+               F4F479201C01424200D0BF69 /* HMVerticalFleetViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4F4791E1C01424200D0BF69 /* HMVerticalFleetViewController.xib */; };
                F4F6E8081B2B17E50008B66E /* HMStrengthenListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F6E8061B2B17E50008B66E /* HMStrengthenListViewController.m */; };
                F4F6E8091B2B17E50008B66E /* HMStrengthenListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4F6E8071B2B17E50008B66E /* HMStrengthenListViewController.xib */; };
                F4F6E80C1B2BC81C0008B66E /* HMPeriodicNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F6E80B1B2BC81C0008B66E /* HMPeriodicNotifier.m */; };
                F4ED5D291B78D0CA00D1BDEF /* HMGuardEscapedView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMGuardEscapedView.m; sourceTree = "<group>"; };
                F4ED5D2B1B7C677E00D1BDEF /* HMGuardShelterCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMGuardShelterCommand.h; sourceTree = "<group>"; };
                F4ED5D2C1B7C677E00D1BDEF /* HMGuardShelterCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMGuardShelterCommand.m; sourceTree = "<group>"; };
+               F4F479171BFE223600D0BF69 /* HMCombileViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMCombileViewController.h; sourceTree = "<group>"; };
+               F4F479181BFE223600D0BF69 /* HMCombileViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMCombileViewController.m; sourceTree = "<group>"; };
+               F4F479191BFE223600D0BF69 /* HMCombileViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HMCombileViewController.xib; sourceTree = "<group>"; };
+               F4F4791C1C01424200D0BF69 /* HMVerticalFleetViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMVerticalFleetViewController.h; sourceTree = "<group>"; };
+               F4F4791D1C01424200D0BF69 /* HMVerticalFleetViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMVerticalFleetViewController.m; sourceTree = "<group>"; };
+               F4F4791E1C01424200D0BF69 /* HMVerticalFleetViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HMVerticalFleetViewController.xib; sourceTree = "<group>"; };
                F4F6E8051B2B17E50008B66E /* HMStrengthenListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMStrengthenListViewController.h; sourceTree = "<group>"; };
                F4F6E8061B2B17E50008B66E /* HMStrengthenListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMStrengthenListViewController.m; sourceTree = "<group>"; };
                F4F6E8071B2B17E50008B66E /* HMStrengthenListViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HMStrengthenListViewController.xib; sourceTree = "<group>"; };
                                F4D6BC991AA1FAC600742FEB /* HMUITestWindowController.h */,
                                F4D6BC9A1AA1FAC600742FEB /* HMUITestWindowController.m */,
                                F4BEF0101B11A645004702B8 /* HMUITestWindowController.xib */,
+                               F4F4791C1C01424200D0BF69 /* HMVerticalFleetViewController.h */,
+                               F4F4791D1C01424200D0BF69 /* HMVerticalFleetViewController.m */,
+                               F4F4791E1C01424200D0BF69 /* HMVerticalFleetViewController.xib */,
+                               F4F479171BFE223600D0BF69 /* HMCombileViewController.h */,
+                               F4F479181BFE223600D0BF69 /* HMCombileViewController.m */,
+                               F4F479191BFE223600D0BF69 /* HMCombileViewController.xib */,
                        );
                        name = TestAndDebug;
                        path = KCD;
                                F4B3DC3C18E5C87D0011B4FC /* HMDocksViewController.xib in Resources */,
                                F4B2D02B18F83A2F00542742 /* HMScreenshotWindowController.xib in Resources */,
                                F49688651B3AFE4900D3CEDE /* HMProgressPanel.xib in Resources */,
+                               F4F479201C01424200D0BF69 /* HMVerticalFleetViewController.xib in Resources */,
                                F4B3DC3918E5C8700011B4FC /* HMJSONViewWindowController.xib in Resources */,
                                F4BEF0081B11A5DE004702B8 /* HMShipDetailViewController.xib in Resources */,
                                F4B3DC3318E5C8520011B4FC /* HMShipViewController.xib in Resources */,
                                F4666C6B1B29E974001840DB /* EquipmentStrengthen.plist in Resources */,
                                F4131EDE190FEBDB004F7F9A /* HMSlotItemWindowController.xib in Resources */,
                                F4666C521B1CB2CE001840DB /* HMBrowserContentAdjuster.xib in Resources */,
+                               F4F4791B1BFE223600D0BF69 /* HMCombileViewController.xib in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                F48F7B021907D7B800E78AE1 /* HMPortCommand.m in Sources */,
                                F494DC5F18C30AE100AE97E4 /* HMMissionStatus.m in Sources */,
                                F43F3D4C1A34AC8000D6DAF7 /* HMKCMasterShipObject.m in Sources */,
+                               F4F4791A1BFE223600D0BF69 /* HMCombileViewController.m in Sources */,
                                F4268031194D1B1A00B2C27F /* HMChangeHenseiCommand.m in Sources */,
                                F4BEEFE11B0B6326004702B8 /* HMDummyShipCommand.m in Sources */,
                                F4513EE418B635EA00073552 /* HMDocksViewController.m in Sources */,
                                F4F6E82B1B3045970008B66E /* CustomHTTPProtocol.m in Sources */,
                                F4513EDD18B619B600073552 /* HMCoreDataManager.m in Sources */,
                                F4B3DBCA18DDB9170011B4FC /* HMCreateSlotItemCommand.m in Sources */,
+                               F4F4791F1C01424200D0BF69 /* HMVerticalFleetViewController.m in Sources */,
                                F4131ED8190FA08D004F7F9A /* HMDestroyItem2Command.m in Sources */,
                                F4B3DC2718DF2F360011B4FC /* HMKenzoMark.m in Sources */,
                                F4F6E80F1B2C25D20008B66E /* HMStrengthenListItemCellView.m in Sources */,
diff --git a/KCD/HMCombileViewController.h b/KCD/HMCombileViewController.h
new file mode 100644 (file)
index 0000000..935ec45
--- /dev/null
@@ -0,0 +1,13 @@
+//
+//  HMCombileViewController.h
+//  KCD
+//
+//  Created by Hori,Masaki on 2015/11/20.
+//  Copyright (c) 2015年 Hori,Masaki. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@interface HMCombileViewController : NSViewController
+
+@end
diff --git a/KCD/HMCombileViewController.m b/KCD/HMCombileViewController.m
new file mode 100644 (file)
index 0000000..52744ad
--- /dev/null
@@ -0,0 +1,41 @@
+//
+//  HMCombileViewController.m
+//  KCD
+//
+//  Created by Hori,Masaki on 2015/11/20.
+//  Copyright (c) 2015年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMCombileViewController.h"
+
+#import "HMVerticalFleetViewController.h"
+
+
+@interface HMCombileViewController ()
+
+@property (nonatomic, strong) HMVerticalFleetViewController* fleet1;
+@property (nonatomic, strong) HMVerticalFleetViewController* fleet2;
+
+@property (nonatomic, weak) IBOutlet NSView *placeholder1;
+@property (nonatomic, weak) IBOutlet NSView *placeholder2;
+
+@end
+
+@implementation HMCombileViewController
+
+- (void)awakeFromNib
+{
+       self.fleet1 = [HMVerticalFleetViewController new];
+       [self.fleet1.view setFrame:[self.placeholder1 frame]];
+       [self.fleet1.view setAutoresizingMask:[self.placeholder1 autoresizingMask]];
+       [[self.placeholder1 superview] replaceSubview:self.placeholder1 with:self.fleet1.view];
+       self.fleet1.fleetNumber = 1;
+       
+       self.fleet2 = [HMVerticalFleetViewController new];
+       [self.fleet2.view setFrame:[self.placeholder2 frame]];
+       [self.fleet2.view setAutoresizingMask:[self.placeholder2 autoresizingMask]];
+       [[self.placeholder2 superview] replaceSubview:self.placeholder2 with:self.fleet2.view];
+       self.fleet2.fleetNumber = 2;
+}
+
+@end
diff --git a/KCD/HMCombileViewController.xib b/KCD/HMCombileViewController.xib
new file mode 100644 (file)
index 0000000..4051ac8
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14F1021" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+    <dependencies>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="HMCombileViewController">
+            <connections>
+                <outlet property="placeholder1" destination="wYL-DD-bTM" id="XXt-eK-QY5"/>
+                <outlet property="placeholder2" destination="Dyh-dm-bed" id="ZVI-Dy-yh4"/>
+                <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 id="Hz6-mo-xeY">
+            <rect key="frame" x="0.0" y="0.0" width="213" height="778"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+            <subviews>
+                <customView id="wYL-DD-bTM">
+                    <rect key="frame" x="20" y="394" width="173" height="364"/>
+                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+                </customView>
+                <customView id="Dyh-dm-bed">
+                    <rect key="frame" x="20" y="20" width="173" height="364"/>
+                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+                </customView>
+            </subviews>
+            <point key="canvasLocation" x="268.5" y="381"/>
+        </customView>
+    </objects>
+</document>
index b7ddb03..0b18c0e 100644 (file)
@@ -22,7 +22,7 @@
 
 - (Class)testViewControllerClass
 {
-       return NSClassFromString(@"HMStrengthenListViewController");
+       return NSClassFromString(@"HMCombileViewController");
 }
 
 - (void)windowDidLoad {
diff --git a/KCD/HMVerticalFleetViewController.h b/KCD/HMVerticalFleetViewController.h
new file mode 100644 (file)
index 0000000..d9d540c
--- /dev/null
@@ -0,0 +1,54 @@
+//
+//  HMVerticalFleetViewController.h
+//  KCD
+//
+//  Created by Hori,Masaki on 2015/11/22.
+//  Copyright (c) 2015年 Hori,Masaki. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@class HMKCDeck;
+
+typedef NS_ENUM(NSUInteger, HMFleetViewType) {
+       detailViewType,
+       minimumViewType,
+       miniVierticalType,
+};
+
+typedef NS_ENUM(NSInteger, HMFleetViewShipOrder) {
+       doubleLine = 0,
+       leftToRight = 1,
+};
+
+
+@interface HMVerticalFleetViewController : NSViewController
+
+- (instancetype)initWithViewType:(HMFleetViewType)type;
+
++ (CGFloat)oldStyleFleetViewHeight;
++ (CGFloat)detailViewHeight;
++ (CGFloat)heightDifference;
+
+
+@property (readonly) HMFleetViewType type;
+
+@property (strong) HMKCDeck* fleet;
+@property NSInteger fleetNumber;
+@property HMFleetViewShipOrder shipOrder;
+@property BOOL enableAnimation;
+
+@property (readonly) BOOL canDivide;
+@property (readonly) CGFloat normalHeight;
+@property (readonly) CGFloat upsideHeight;
+
+@property (readonly) NSNumber *totalSakuteki;
+@property (readonly) NSNumber *totalSeiku;
+@property (readonly) NSNumber *totalCalclatedSeiku;
+@property (readonly) NSNumber *totalLevel;
+@property (readonly) NSNumber *totalDrums;
+
+- (IBAction)selectNextFleet:(id)sender;
+- (IBAction)selectPreviousFleet:(id)sender;
+
+@end
diff --git a/KCD/HMVerticalFleetViewController.m b/KCD/HMVerticalFleetViewController.m
new file mode 100644 (file)
index 0000000..9b21ac7
--- /dev/null
@@ -0,0 +1,533 @@
+//
+//  HMVerticalFleetViewController.m
+//  KCD
+//
+//  Created by Hori,Masaki on 2015/11/22.
+//  Copyright (c) 2015年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMVerticalFleetViewController.h"
+#import "HMShipDetailViewController.h"
+#import "HMMinimumShipViewController.h"
+
+#import "HMAppDelegate.h"
+
+#import "HMKCShipObject+Extensions.h"
+#import "HMKCDeck+Extension.h"
+
+#import "HMServerDataStore.h"
+
+#import "HMAnchorageRepairManager.h"
+
+
+static const NSInteger maxFleetNumber = 4;
+
+@interface HMVerticalFleetViewController ()
+
+@property (weak) Class shipViewClass;
+
+@property (readwrite) HMFleetViewType type;
+
+@property (nonatomic, weak) IBOutlet NSView *placeholder01;
+@property (nonatomic, weak) IBOutlet NSView *placeholder02;
+@property (nonatomic, weak) IBOutlet NSView *placeholder03;
+@property (nonatomic, weak) IBOutlet NSView *placeholder04;
+@property (nonatomic, weak) IBOutlet NSView *placeholder05;
+@property (nonatomic, weak) IBOutlet NSView *placeholder06;
+
+@property (strong) HMShipDetailViewController *detail01;
+@property (strong) HMShipDetailViewController *detail02;
+@property (strong) HMShipDetailViewController *detail03;
+@property (strong) HMShipDetailViewController *detail04;
+@property (strong) HMShipDetailViewController *detail05;
+@property (strong) HMShipDetailViewController *detail06;
+@property (strong) NSArray *details;
+
+@property (readonly) NSArray *shipKeys;
+
+
+@property (strong) NSArray *anchorageRepairHolder;
+@property (strong) HMAnchorageRepairManager *anchorageRepair;
+@property (readonly) NSNumber *repairTime;
+@property (readonly) NSNumber *repairableShipCount;
+
+@end
+
+@implementation HMVerticalFleetViewController
+@synthesize fleetNumber = _fleetNumber;
+@synthesize shipOrder = _shipOrder;
+
++ (instancetype)new
+{
+       return [[[self class] alloc] initWithViewType:miniVierticalType];
+}
+
+- (instancetype)initWithViewType:(HMFleetViewType)type
+{
+       Class shipViewClass = Nil;
+       NSString *nibName = nil;
+       switch (type) {
+               case detailViewType:
+                       nibName = NSStringFromClass([self class]);
+                       shipViewClass = [HMShipDetailViewController class];
+                       break;
+               case minimumViewType:
+                       nibName = @"HMFleetMinimumViewController";
+                       shipViewClass = [HMMinimumShipViewController class];
+                       break;
+               case miniVierticalType:
+                       nibName = @"HMVerticalFleetViewController";
+                       shipViewClass = [HMMinimumShipViewController class];
+                       break;
+       }
+       
+       if(!nibName) {
+               self = [super initWithNibName:@"" bundle:nil];
+               NSLog(@"UnknownType");
+               return nil;
+       }
+       
+       self = [super initWithNibName:nibName bundle:nil];
+       if(self) {
+               _type = type;
+               _shipViewClass = shipViewClass;
+               
+               [self buildAnchorageRepairHolder];
+       }
+       return self;
+}
+
+- (void)dealloc
+{
+       for(NSString *key in self.shipKeys) {
+               [self.representedObject removeObserver:self
+                                                                       forKeyPath:key];
+       }
+}
+
+- (void)awakeFromNib
+{
+       NSMutableArray *details = [NSMutableArray new];
+       NSArray *detailKeys = @[@"detail01", @"detail02", @"detail03", @"detail04", @"detail05", @"detail06"];
+       [detailKeys enumerateObjectsUsingBlock:^(id detailKey, NSUInteger idx, BOOL *stop) {
+               HMShipDetailViewController *detail = [self.shipViewClass new];
+               detail.title = [NSString stringWithFormat:@"%ld", idx + 1];
+               [self setValue:detail forKey:detailKey];
+               
+               [details addObject:detail];
+       }];
+       self.details = details;
+       
+       NSArray *placeholderKeys = @[@"placeholder01", @"placeholder02", @"placeholder03", @"placeholder04", @"placeholder05", @"placeholder06"];
+       [placeholderKeys enumerateObjectsUsingBlock:^(id placeholderKey, NSUInteger idx, BOOL *stop) {
+               NSView *view = [self valueForKey:placeholderKey];
+               HMShipDetailViewController *detail = self.details[idx];
+               [detail.view setFrame:[view frame]];
+               [detail.view setAutoresizingMask:[view autoresizingMask]];
+               [[view superview] replaceSubview:view with:detail.view];
+       }];
+       
+       self.fleetNumber = 1;
+}
+
+- (NSArray *)shipKeys
+{
+       static NSArray *shipKeys = nil;
+       if(shipKeys) return shipKeys;
+       
+       shipKeys = @[@"ship_0", @"ship_1", @"ship_2", @"ship_3", @"ship_4", @"ship_5"];
+       return shipKeys;
+}
+
+- (void)setShipOfViewForKey:(NSString *)key
+{
+       NSUInteger index = [self.shipKeys indexOfObject:key];
+       if(index != NSNotFound) {
+               NSUInteger shipID = [[self.fleet valueForKey:key] integerValue];
+               [self setShipID:shipID
+                          toDetail:self.details[index]];
+       }
+}
+
+- (void)setShipID:(NSInteger)shipId toDetail:(HMShipDetailViewController *)detail
+{
+       HMServerDataStore *store = [HMServerDataStore defaultManager];
+       NSError *error = nil;
+       HMKCShipObject *ship = nil;
+       NSArray *array = [store objectsWithEntityName:@"Ship"
+                                                                                       error:&error
+                                                                 predicateFormat:@"id = %ld", shipId];
+       if(error) {
+               NSLog(@"%s error: %@", __PRETTY_FUNCTION__, error);
+       }
+       if(array.count != 0) {
+               ship = array[0];
+       }
+       detail.ship = ship;
+       
+       [self willChangeValueForKey:@"repairableShipCount"];
+       [self didChangeValueForKey:@"repairableShipCount"];
+}
+- (void)setFleet:(HMKCDeck *)fleet
+{
+       for(NSString *key in self.shipKeys) {
+               [self.representedObject removeObserver:self
+                                                                       forKeyPath:key];
+               
+               [fleet addObserver:self
+                               forKeyPath:key
+                                  options:0
+                                  context:NULL];
+       }
+       
+       self.representedObject = fleet;
+       self.title = fleet.name;
+       
+       for(NSString *key in self.shipKeys) {
+               [self setShipOfViewForKey:key];
+       }
+}
+- (HMKCDeck *)fleet
+{
+       return self.representedObject;
+}
+
+- (void)setFleetNumber:(NSInteger)fleetNumber
+{
+       HMServerDataStore *store = [HMServerDataStore defaultManager];
+       NSError *error = nil;
+       NSArray *array = [store objectsWithEntityName:@"Deck"
+                                                                                       error:NULL
+                                                                 predicateFormat:@"id = %ld", fleetNumber];
+       if(error) {
+               NSLog(@"%s error: %@", __PRETTY_FUNCTION__, error);
+               return;
+       }
+       if(array.count == 0) {
+               return;
+       }
+       
+       self.fleet = array[0];
+       _fleetNumber = fleetNumber;
+       
+       self.anchorageRepair = self.anchorageRepairHolder[fleetNumber - 1];
+}
+- (NSInteger)fleetNumber
+{
+       return _fleetNumber;
+}
+
+- (void)setShipOrder:(HMFleetViewShipOrder)shipOrder
+{
+       if(_shipOrder == shipOrder) return;
+       _shipOrder = shipOrder;
+       
+       switch(shipOrder) {
+               case doubleLine:
+                       [self reorderShipToDoubleLine];
+                       break;
+               case leftToRight:
+                       [self reorderShipToLeftToRight];
+                       break;
+       }
+}
+- (HMFleetViewShipOrder)shipOrder
+{
+       return _shipOrder;
+}
+
+- (BOOL)canDivide
+{
+       return self.type == detailViewType;
+}
+- (CGFloat)normalHeight
+{
+//     switch(self.type) {
+//             case detailViewType:
+//                     return HMFleetViewController.detailViewHeight;
+//             case minimumViewType:
+//                     return HMFleetViewController.oldStyleFleetViewHeight;
+//     }
+       return 0;
+}
+- (CGFloat)upsideHeight
+{
+//     switch(self.type) {
+//             case detailViewType:
+//                     return 159;
+//             case minimumViewType:
+//                     return HMFleetViewController.oldStyleFleetViewHeight;
+//     }
+       return 0;
+}
+
++ (CGFloat)oldStyleFleetViewHeight
+{
+       return 128;
+}
++ (CGFloat)detailViewHeight
+{
+       return 288;
+}
++ (CGFloat)heightDifference
+{
+       return self.detailViewHeight - self.oldStyleFleetViewHeight;
+}
+
+
++ (NSSet *)keyPathsForValuesAffectingTotalSakuteki
+{
+       return [NSSet setWithObjects:
+                       @"detail01.ship.sakuteki_0",
+                       @"detail02.ship.sakuteki_0",
+                       @"detail03.ship.sakuteki_0",
+                       @"detail04.ship.sakuteki_0",
+                       @"detail05.ship.sakuteki_0",
+                       @"detail06.ship.sakuteki_0",
+                       nil];
+}
+- (NSNumber *)totalSakuteki
+{
+       NSInteger total = 0;
+       for(HMShipDetailViewController *detail in self.details) {
+               HMKCShipObject *ship = detail.ship;
+               total += ship.sakuteki_0.integerValue;
+       }
+       return @(total);
+}
+
++ (NSSet *)keyPathsForValuesAffectingTotalSeiku
+{
+       return [NSSet setWithObjects:
+                       @"detail01.ship.seiku",
+                       @"detail02.ship.seiku",
+                       @"detail03.ship.seiku",
+                       @"detail04.ship.seiku",
+                       @"detail05.ship.seiku",
+                       @"detail06.ship.seiku",
+                       nil];
+}
+- (NSNumber *)totalSeiku
+{
+       NSInteger total = 0;
+       for(HMShipDetailViewController *detail in self.details) {
+               HMKCShipObject *ship = detail.ship;
+               total += ship.seiku.integerValue;
+       }
+       return @(total);
+}
++ (NSSet *)keyPathsForValuesAffectingTotalCalclatedSeiku
+{
+       return [NSSet setWithObjects:
+                       @"detail01.ship.seiku",
+                       @"detail02.ship.seiku",
+                       @"detail03.ship.seiku",
+                       @"detail04.ship.seiku",
+                       @"detail05.ship.seiku",
+                       @"detail06.ship.seiku",
+                       nil];
+}
+- (NSNumber *)totalCalclatedSeiku
+{
+       NSInteger total = 0;
+       for(HMShipDetailViewController *detail in self.details) {
+               HMKCShipObject *ship = detail.ship;
+               total += ship.seiku.integerValue;
+               total += ship.extraSeiku.integerValue;
+       }
+       return @(total);
+}
++ (NSSet *)keyPathsForValuesAffectingTotalLevel
+{
+       return [NSSet setWithObjects:
+                       @"detail01.ship.lv",
+                       @"detail02.ship.lv",
+                       @"detail03.ship.lv",
+                       @"detail04.ship.lv",
+                       @"detail05.ship.lv",
+                       @"detail06.ship.lv",
+                       nil];
+}
+- (NSNumber *)totalLevel
+{
+       NSInteger total = 0;
+       for(HMShipDetailViewController *detail in self.details) {
+               HMKCShipObject *ship = detail.ship;
+               total += ship.lv.integerValue;
+       }
+       return @(total);
+}
++ (NSSet *)keyPathsForValuesAffectingTotalDrums
+{
+       return [NSSet setWithObjects:
+                       @"detail01.ship.totalDrums",
+                       @"detail02.ship.totalDrums",
+                       @"detail03.ship.totalDrums",
+                       @"detail04.ship.totalDrums",
+                       @"detail05.ship.totalDrums",
+                       @"detail06.ship.totalDrums",
+                       nil];
+}
+- (NSNumber *)totalDrums
+{
+       NSInteger total = 0;
+       for(HMShipDetailViewController *detail in self.details) {
+               HMKCShipObject *ship = detail.ship;
+               total += ship.totalDrums.integerValue;
+       }
+       return @(total);
+}
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+       if([self.shipKeys containsObject:keyPath]) {
+               [self setShipOfViewForKey:keyPath];
+               return;
+       }
+       
+       return [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+}
+
+- (IBAction)selectNextFleet:(id)sender
+{
+       NSInteger next = self.fleetNumber + 1;
+       self.fleetNumber = next <= maxFleetNumber ? next : 1;
+}
+- (IBAction)selectPreviousFleet:(id)sender
+{
+       NSInteger prev = self.fleetNumber - 1;
+       self.fleetNumber = prev > 0 ? prev : 4;
+}
+
+
+- (void)reorderShipToDoubleLine
+{
+       NSView *view02 = self.detail02.view;
+       NSView *view03 = self.detail03.view;
+       NSView *view04 = self.detail04.view;
+       NSView *view05 = self.detail05.view;
+       
+       NSAutoresizingMaskOptions options02 = view02.autoresizingMask;
+       NSAutoresizingMaskOptions options03 = view03.autoresizingMask;
+       NSAutoresizingMaskOptions options04 = view04.autoresizingMask;
+       NSAutoresizingMaskOptions options05 = view05.autoresizingMask;
+       
+       view02.autoresizingMask = options04;
+       view03.autoresizingMask = options02;
+       view04.autoresizingMask = options05;
+       view05.autoresizingMask = options03;
+       
+       NSRect frame02 = view02.frame;
+       NSRect frame03 = view03.frame;
+       NSRect frame04 = view04.frame;
+       NSRect frame05 = view05.frame;
+       
+       if(self.enableAnimation) {
+               view02.animator.frame = frame04;
+               view03.animator.frame = frame02;
+               view04.animator.frame = frame05;
+               view05.animator.frame = frame03;
+       } else {
+               view02.frame = frame04;
+               view03.frame = frame02;
+               view04.frame = frame05;
+               view05.frame = frame03;
+       }
+}
+- (void)reorderShipToLeftToRight
+{
+       NSView *view02 = self.detail02.view;
+       NSView *view03 = self.detail03.view;
+       NSView *view04 = self.detail04.view;
+       NSView *view05 = self.detail05.view;
+       
+       NSAutoresizingMaskOptions options02 = view02.autoresizingMask;
+       NSAutoresizingMaskOptions options03 = view03.autoresizingMask;
+       NSAutoresizingMaskOptions options04 = view04.autoresizingMask;
+       NSAutoresizingMaskOptions options05 = view05.autoresizingMask;
+       
+       view02.autoresizingMask = options03;
+       view03.autoresizingMask = options05;
+       view04.autoresizingMask = options02;
+       view05.autoresizingMask = options04;
+       
+       NSRect frame02 = view02.frame;
+       NSRect frame03 = view03.frame;
+       NSRect frame04 = view04.frame;
+       NSRect frame05 = view05.frame;
+       
+       if(self.enableAnimation) {
+               view02.animator.frame = frame03;
+               view03.animator.frame = frame05;
+               view04.animator.frame = frame02;
+               view05.animator.frame = frame04;
+       } else {
+               view02.frame = frame03;
+               view03.frame = frame05;
+               view04.frame = frame02;
+               view05.frame = frame04;
+       }
+}
+
+
+- (void)buildAnchorageRepairHolder
+{
+       HMServerDataStore *store = [HMServerDataStore defaultManager];
+       NSError *error = nil;
+       NSArray *array = [store objectsWithEntityName:@"Deck"
+                                                                 sortDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"id" ascending:YES]]
+                                                                               predicate:nil
+                                                                                       error:&error];
+       if(error) {
+               NSLog(@"%s error: %@", __PRETTY_FUNCTION__, error);
+               return;
+       }
+       if(array.count == 0) {
+               return;
+       }
+       if(array.count < 4) {
+               NSBeep();
+               NSLog(@"hogehoge");
+               return;
+       }
+       NSMutableArray *anchorageRepairs = [NSMutableArray new];
+       for(HMKCDeck *deck in array) {
+               id anchorageRepair = [[HMAnchorageRepairManager alloc] initWithDeck:deck];
+               [anchorageRepairs addObject:anchorageRepair];
+       }
+       self.anchorageRepairHolder = anchorageRepairs;
+       
+       HMAppDelegate *appDelegate = [[NSApplication sharedApplication] delegate];
+       [appDelegate addCounterUpdateBlock:^{
+               [self willChangeValueForKey:@"repairTime"];
+               [self didChangeValueForKey:@"repairTime"];
+       }];
+}
++ (NSSet *)keyPathsForValuesAffectingRepairTime
+{
+       return [NSSet setWithObjects:@"anchorageRepair.repairTime", @"anchorageRepair", nil];
+}
+- (NSNumber *)repairTime
+{
+       NSDate *compTimeValue = self.anchorageRepair.repairTime;
+       if(!compTimeValue) return nil;
+       
+       NSTimeInterval compTime = [compTimeValue timeIntervalSince1970];
+       NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0];
+       NSTimeInterval diff = compTime - [now timeIntervalSince1970];
+       return @(diff + 20 * 60);
+}
++ (NSSet *)keyPathsForValuesAffectingRepairableShipCount
+{
+       return [NSSet setWithObjects:
+                       @"anchorageRepair.repairableShipCount", @"anchorageRepair",
+                       
+                       
+                       nil];
+}
+- (NSNumber *)repairableShipCount
+{
+       return self.anchorageRepair.repairableShipCount;
+}
+
+@end
diff --git a/KCD/HMVerticalFleetViewController.xib b/KCD/HMVerticalFleetViewController.xib
new file mode 100644 (file)
index 0000000..5711c0e
--- /dev/null
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14F1021" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+    <dependencies>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="HMVerticalFleetViewController">
+            <connections>
+                <outlet property="placeholder01" destination="UHN-X2-Vqj" id="Qt9-ar-I2u"/>
+                <outlet property="placeholder02" destination="YT0-f6-uV0" id="bh1-Dh-t1n"/>
+                <outlet property="placeholder03" destination="9PV-Nb-eAN" id="Kxl-G7-G4t"/>
+                <outlet property="placeholder04" destination="y4K-H8-aet" id="0I1-CN-HiP"/>
+                <outlet property="placeholder05" destination="3xD-KP-9cE" id="l2y-mf-aZ1"/>
+                <outlet property="placeholder06" destination="KbP-BU-FYF" id="AKM-sS-v21"/>
+                <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 id="Hz6-mo-xeY">
+            <rect key="frame" x="0.0" y="0.0" width="173" height="364"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+            <subviews>
+                <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="UHN-X2-Vqj">
+                    <rect key="frame" x="0.0" y="285" width="173" height="58"/>
+                </customView>
+                <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YT0-f6-uV0">
+                    <rect key="frame" x="0.0" y="228" width="173" height="58"/>
+                </customView>
+                <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9PV-Nb-eAN">
+                    <rect key="frame" x="0.0" y="171" width="173" height="58"/>
+                </customView>
+                <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="y4K-H8-aet">
+                    <rect key="frame" x="0.0" y="114" width="173" height="58"/>
+                </customView>
+                <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3xD-KP-9cE">
+                    <rect key="frame" x="0.0" y="57" width="173" height="58"/>
+                </customView>
+                <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KbP-BU-FYF">
+                    <rect key="frame" x="0.0" y="0.0" width="173" height="58"/>
+                </customView>
+                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LGF-6h-ss2">
+                    <rect key="frame" x="-2" y="347" width="177" height="17"/>
+                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="K3r-yr-9c4">
+                        <font key="font" metaFont="system"/>
+                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                    <connections>
+                        <binding destination="-2" name="displayPatternValue1" keyPath="title" id="BJg-3Z-vLc">
+                            <dictionary key="options">
+                                <string key="NSDisplayPattern">【 %{value1}@ 】</string>
+                            </dictionary>
+                        </binding>
+                    </connections>
+                </textField>
+            </subviews>
+            <point key="canvasLocation" x="494.5" y="313"/>
+        </customView>
+    </objects>
+</document>
index 5f22819..a5f839c 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7531" systemVersion="14D131" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14F1021" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7531"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
     </dependencies>
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="HMUITestWindowController">
         <window title="UITestWindow" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
             <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
-            <rect key="contentRect" x="24" y="78" width="282" height="475"/>
+            <rect key="contentRect" x="24" y="78" width="213" height="778"/>
             <rect key="screenRect" x="0.0" y="0.0" width="1440" height="900"/>
             <view key="contentView" id="se5-gp-TjO">
-                <rect key="frame" x="0.0" y="1" width="282" height="475"/>
+                <rect key="frame" x="0.0" y="0.0" width="213" height="778"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <customView id="Lxs-Lw-GIx">
-                        <rect key="frame" x="0.0" y="0.0" width="282" height="475"/>
+                        <rect key="frame" x="0.0" y="0.0" width="213" height="778"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                     </customView>
                 </subviews>
@@ -31,7 +31,7 @@
             <connections>
                 <outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
             </connections>
-            <point key="canvasLocation" x="-586" y="262.5"/>
+            <point key="canvasLocation" x="-549" y="262.5"/>
         </window>
     </objects>
 </document>