From 29470d29e60c170faca30e588f68ae989bb18eb2 Mon Sep 17 00:00:00 2001 From: masakih Date: Sun, 20 Apr 2014 12:38:45 +0900 Subject: [PATCH] =?utf8?q?=E7=8F=BE=E5=9C=A8=E3=81=AE=E8=89=A6=E9=9A=8A?= =?utf8?q?=E8=A1=A8=E7=A4=BA=E3=81=8A=E3=82=88=E3=81=B2=E3=82=99=E5=B0=8F?= =?utf8?q?=E3=80=81=E4=B8=AD=E3=80=81=E5=A4=A7=E7=A0=B4=E8=A1=A8=E7=A4=BA?= =?utf8?q?=20#50214=20#50205?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- KCD.xcodeproj/project.pbxproj | 24 ++ KCD/HMBroserWindowController.h | 3 + KCD/HMBroserWindowController.m | 9 +- KCD/HMDeckViewController.h | 26 +++ KCD/HMDeckViewController.m | 96 ++++++++ KCD/HMKCShipObject.h | 2 + KCD/HMKCShipObject.m | 31 +++ KCD/HMStrokeTextFieldCell.h | 13 ++ KCD/HMStrokeTextFieldCell.m | 73 ++++++ KCD/ja.lproj/HMBroserWindowController.xib | 15 +- KCD/ja.lproj/HMDeckViewController.xib | 364 ++++++++++++++++++++++++++++++ 11 files changed, 650 insertions(+), 6 deletions(-) create mode 100644 KCD/HMDeckViewController.h create mode 100644 KCD/HMDeckViewController.m create mode 100644 KCD/HMStrokeTextFieldCell.h create mode 100644 KCD/HMStrokeTextFieldCell.m create mode 100644 KCD/ja.lproj/HMDeckViewController.xib diff --git a/KCD.xcodeproj/project.pbxproj b/KCD.xcodeproj/project.pbxproj index c8be24fe..cb22f96d 100644 --- a/KCD.xcodeproj/project.pbxproj +++ b/KCD.xcodeproj/project.pbxproj @@ -29,7 +29,10 @@ F494DC6718C8BA6400AE97E4 /* HMPowerUpSupportViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F494DC6618C8BA6400AE97E4 /* HMPowerUpSupportViewController.m */; }; F494DC6A18C8BAB900AE97E4 /* HMPowerUpSupportViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F494DC6818C8BAB900AE97E4 /* HMPowerUpSupportViewController.xib */; }; F494DC6D18CC054800AE97E4 /* HMNyukyoDockStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = F494DC6C18CC054800AE97E4 /* HMNyukyoDockStatus.m */; }; + F49828FC1902A226000D6BBE /* HMStrokeTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F49828FB1902A226000D6BBE /* HMStrokeTextFieldCell.m */; }; F4B2D02B18F83A2F00542742 /* HMScreenshotWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4B2D02D18F83A2F00542742 /* HMScreenshotWindowController.xib */; }; + F4B2D03118F83CBB00542742 /* HMDeckViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B2D02F18F83CBB00542742 /* HMDeckViewController.m */; }; + F4B2D03318F83CC800542742 /* HMDeckViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4B2D03518F83CC800542742 /* HMDeckViewController.xib */; }; F4B3DBCA18DDB9170011B4FC /* HMCreateSlotItemCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B3DBC918DDB9170011B4FC /* HMCreateSlotItemCommand.m */; }; F4B3DC1B18DEAB5E0011B4FC /* HMKaihatuHistory.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B3DC1A18DEAB5E0011B4FC /* HMKaihatuHistory.m */; }; F4B3DC1E18DEB8C70011B4FC /* HMKenzoHistory.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B3DC1D18DEB8C70011B4FC /* HMKenzoHistory.m */; }; @@ -140,7 +143,12 @@ F494DC6918C8BAB900AE97E4 /* ja */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ja; path = ja.lproj/HMPowerUpSupportViewController.xib; sourceTree = ""; }; F494DC6B18CC054800AE97E4 /* HMNyukyoDockStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMNyukyoDockStatus.h; sourceTree = ""; }; F494DC6C18CC054800AE97E4 /* HMNyukyoDockStatus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMNyukyoDockStatus.m; sourceTree = ""; }; + F49828FA1902A226000D6BBE /* HMStrokeTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMStrokeTextFieldCell.h; sourceTree = ""; }; + F49828FB1902A226000D6BBE /* HMStrokeTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMStrokeTextFieldCell.m; sourceTree = ""; }; F4B2D02C18F83A2F00542742 /* ja */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ja; path = ja.lproj/HMScreenshotWindowController.xib; sourceTree = ""; }; + F4B2D02E18F83CBB00542742 /* HMDeckViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMDeckViewController.h; sourceTree = ""; }; + F4B2D02F18F83CBB00542742 /* HMDeckViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMDeckViewController.m; sourceTree = ""; }; + F4B2D03418F83CC800542742 /* ja */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ja; path = ja.lproj/HMDeckViewController.xib; sourceTree = ""; }; F4B3DBC818DDB9170011B4FC /* HMCreateSlotItemCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMCreateSlotItemCommand.h; sourceTree = ""; }; F4B3DBC918DDB9170011B4FC /* HMCreateSlotItemCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMCreateSlotItemCommand.m; sourceTree = ""; }; F4B3DC1918DEAB5E0011B4FC /* HMKaihatuHistory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMKaihatuHistory.h; sourceTree = ""; }; @@ -428,6 +436,11 @@ F4B3DC4F18F150CD0011B4FC /* HMScreenshotWindowController.h */, F4B3DC5018F150CD0011B4FC /* HMScreenshotWindowController.m */, F4B2D02D18F83A2F00542742 /* HMScreenshotWindowController.xib */, + F4B2D02E18F83CBB00542742 /* HMDeckViewController.h */, + F4B2D02F18F83CBB00542742 /* HMDeckViewController.m */, + F4B2D03518F83CC800542742 /* HMDeckViewController.xib */, + F49828FA1902A226000D6BBE /* HMStrokeTextFieldCell.h */, + F49828FB1902A226000D6BBE /* HMStrokeTextFieldCell.m */, ); name = UI; sourceTree = ""; @@ -580,6 +593,7 @@ F4BDEB51187252F30069D0CE /* InfoPlist.strings in Resources */, F43E67B918BE060E0087E5B6 /* LevelUpExp.plist in Resources */, F4B3DC3018E5C81E0011B4FC /* HMHistoryWindowController.xib in Resources */, + F4B2D03318F83CC800542742 /* HMDeckViewController.xib in Resources */, F4B3DC3618E5C8650011B4FC /* HMShipWindowController.xib in Resources */, F4B3DC3C18E5C87D0011B4FC /* HMDocksViewController.xib in Resources */, F4B2D02B18F83A2F00542742 /* HMScreenshotWindowController.xib in Resources */, @@ -647,7 +661,9 @@ F4B3DC4718EEEB920011B4FC /* HMCompositMapCommand.m in Sources */, F4513EDD18B619B600073552 /* HMCoreDataManager.m in Sources */, F4B3DBCA18DDB9170011B4FC /* HMCreateSlotItemCommand.m in Sources */, + F4B2D03118F83CBB00542742 /* HMDeckViewController.m in Sources */, F4B3DC2718DF2F360011B4FC /* HMKenzoMark.m in Sources */, + F49828FC1902A226000D6BBE /* HMStrokeTextFieldCell.m in Sources */, F4B414E918B09A4B00468DAF /* HMMasterMapAreaCommand.m in Sources */, F4C3957418CDDFE500A1E918 /* HMKenzoDockStatus.m in Sources */, F4C118FB18A67B1C005D5B25 /* CanonicalRequest.m in Sources */, @@ -701,6 +717,14 @@ name = HMScreenshotWindowController.xib; sourceTree = ""; }; + F4B2D03518F83CC800542742 /* HMDeckViewController.xib */ = { + isa = PBXVariantGroup; + children = ( + F4B2D03418F83CC800542742 /* ja */, + ); + name = HMDeckViewController.xib; + sourceTree = ""; + }; F4B3DC3218E5C81E0011B4FC /* HMHistoryWindowController.xib */ = { isa = PBXVariantGroup; children = ( diff --git a/KCD/HMBroserWindowController.h b/KCD/HMBroserWindowController.h index a5ff9514..c925568a 100644 --- a/KCD/HMBroserWindowController.h +++ b/KCD/HMBroserWindowController.h @@ -27,6 +27,9 @@ @property (nonatomic, readonly) NSString *flagShipName; +@property (nonatomic, weak) IBOutlet NSView *deckPlaceholder; + + - (IBAction)reloadContent:(id)sender; - (IBAction)selectView:(id)sender; diff --git a/KCD/HMBroserWindowController.m b/KCD/HMBroserWindowController.m index 1a306516..d43c0483 100644 --- a/KCD/HMBroserWindowController.m +++ b/KCD/HMBroserWindowController.m @@ -11,6 +11,7 @@ #import "HMDocksViewController.h" #import "HMShipViewController.h" #import "HMPowerUpSupportViewController.h" +#import "HMDeckViewController.h" #import "HMScreenshotWindowController.h" @@ -34,6 +35,8 @@ typedef NS_ENUM(NSInteger, ViewType) { @property (strong) HMScreenshotWindowController *screenshotWindowController; +@property (strong) HMDeckViewController *deckViewController; + @end @implementation HMBroserWindowController @@ -67,6 +70,10 @@ typedef NS_ENUM(NSInteger, ViewType) { [[self.docksPlaceholder superview] replaceSubview:self.docksPlaceholder with:self.selectedViewController.view]; [self.controllers setObject:self.selectedViewController forKey:@0]; + self.deckViewController = [HMDeckViewController new]; + [self.deckViewController.view setFrame:[self.deckPlaceholder frame]]; + [self.deckViewController.view setAutoresizingMask:[self.deckPlaceholder autoresizingMask]]; + [[self.deckPlaceholder superview] replaceSubview:self.deckPlaceholder with:self.deckViewController.view]; [[[self.webView mainFrame] frameView] setAllowsScrolling:NO]; @@ -127,7 +134,7 @@ typedef NS_ENUM(NSInteger, ViewType) { - (IBAction)reloadContent:(id)sender { id /*NSClipView * */ clip = [self.webView superview]; - [clip scrollToPoint:NSMakePoint(70, 425)]; + [clip scrollToPoint:NSMakePoint(70, 445)]; NSString *prevReloadDateString = [[NSUserDefaults standardUserDefaults] stringForKey:prevReloadDateStringKey]; if(prevReloadDateString) { diff --git a/KCD/HMDeckViewController.h b/KCD/HMDeckViewController.h new file mode 100644 index 00000000..5aea8472 --- /dev/null +++ b/KCD/HMDeckViewController.h @@ -0,0 +1,26 @@ +// +// HMDeckViewController.h +// KCD +// +// Created by Hori,Masaki on 2014/04/12. +// Copyright (c) 2014年 Hori,Masaki. All rights reserved. +// + +#import + +@interface HMDeckViewController : NSViewController + +@property (readonly) NSManagedObjectContext *manageObjectContext; + +@property (weak, nonatomic) IBOutlet NSArrayController *deckController; +@property (weak, nonatomic) IBOutlet NSArrayController *shipsController; + +@property (weak, nonatomic) IBOutlet NSArrayController *ship1Controller; +@property (weak, nonatomic) IBOutlet NSArrayController *ship2Controller; +@property (weak, nonatomic) IBOutlet NSArrayController *ship3Controller; +@property (weak, nonatomic) IBOutlet NSArrayController *ship4Controller; +@property (weak, nonatomic) IBOutlet NSArrayController *ship5Controller; +@property (weak, nonatomic) IBOutlet NSArrayController *ship6Controller; + +@property NSInteger selectedDeck; +@end diff --git a/KCD/HMDeckViewController.m b/KCD/HMDeckViewController.m new file mode 100644 index 00000000..0b2dce44 --- /dev/null +++ b/KCD/HMDeckViewController.m @@ -0,0 +1,96 @@ +// +// HMDeckViewController.m +// KCD +// +// Created by Hori,Masaki on 2014/04/12. +// Copyright (c) 2014年 Hori,Masaki. All rights reserved. +// + +#import "HMDeckViewController.h" + +#import "HMServerDataStore.h" + + +@interface HMDeckViewController () + +@end + +@implementation HMDeckViewController +@synthesize selectedDeck = _selectedDeck; + +- (id)init +{ + self = [super initWithNibName:NSStringFromClass([self class]) bundle:nil]; + return self; +} + +- (NSManagedObjectContext *)manageObjectContext +{ + return [[HMServerDataStore defaultManager] managedObjectContext]; +} + + +- (void)awakeFromNib +{ + self.selectedDeck = 1; + + [self.deckController addObserver:self + forKeyPath:@"selection.ship_0" + options:0 + context:@"0"]; + [self.deckController addObserver:self + forKeyPath:@"selection.ship_1" + options:0 + context:@"1"]; + [self.deckController addObserver:self + forKeyPath:@"selection.ship_2" + options:0 + context:@"2"]; + [self.deckController addObserver:self + forKeyPath:@"selection.ship_3" + options:0 + context:@"3"]; + [self.deckController addObserver:self + forKeyPath:@"selection.ship_4" + options:0 + context:@"4"]; + [self.deckController addObserver:self + forKeyPath:@"selection.ship_5" + options:0 + context:@"5"]; + +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + id contextObject = (__bridge id)context; + + if([contextObject isKindOfClass:[NSString class]]) { + NSInteger number = [contextObject integerValue]; + NSArray *controllers = @[self.ship1Controller, self.ship2Controller, self.ship3Controller, self.ship4Controller, self.ship5Controller, self.ship6Controller]; + NSArrayController *target = controllers[number]; + NSString *key = [NSString stringWithFormat:@"selection.ship_%ld", number]; + id shipID = [self.deckController valueForKeyPath:key]; + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"id = %@", shipID]; + [target setFetchPredicate:predicate]; + + return; + } + + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; +} + +- (void)setSelectedDeck:(NSInteger)selectedDeck +{ + if(selectedDeck == _selectedDeck) return; + _selectedDeck = selectedDeck; + + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"id = %ld", selectedDeck]; + [self.deckController setFetchPredicate:predicate]; +} +- (NSInteger)selectedDeck +{ + return _selectedDeck; +} + +@end diff --git a/KCD/HMKCShipObject.h b/KCD/HMKCShipObject.h index 44936d86..fea046a1 100644 --- a/KCD/HMKCShipObject.h +++ b/KCD/HMKCShipObject.h @@ -10,4 +10,6 @@ @interface HMKCShipObject : HMKCManagedObject +@property (readonly) NSColor *statusColor; +@property (readonly) NSColor *conditionColor; @end diff --git a/KCD/HMKCShipObject.m b/KCD/HMKCShipObject.m index 9c0a085a..d95ea014 100644 --- a/KCD/HMKCShipObject.m +++ b/KCD/HMKCShipObject.m @@ -33,6 +33,15 @@ static NSArray *levelUpExps = nil; }); } ++ (NSSet *)keyPathsForValuesAffectingStatusColor +{ + return [NSSet setWithObjects:@"nowhp", @"maxph", nil]; +} ++ (NSSet *)keyPathsForValuesAffectingConditionColor +{ + return [NSSet setWithObjects:@"cond", nil]; +} + - (NSNumber *)master_sortno { return nil; @@ -96,4 +105,26 @@ static NSArray *levelUpExps = nil; return [NSNumber numberWithInteger:nextExp - [[self valueForKey:@"exp"] integerValue]]; } +- (NSColor *)statusColor +{ + NSInteger maxhp = [[self valueForKey:@"maxhp"] integerValue]; + CGFloat nowhp = [[self valueForKey:@"nowhp"] integerValue]; + CGFloat status = nowhp / maxhp; + if(status <= 0.25) { + return [NSColor redColor]; + } + if(status <= 0.5) { + return [NSColor orangeColor]; + } + if(status <= 0.75) { + return [NSColor yellowColor]; + + } + return [NSColor controlTextColor]; +} +- (NSColor *)conditionColor +{ + return [NSColor controlTextColor]; +} + @end diff --git a/KCD/HMStrokeTextFieldCell.h b/KCD/HMStrokeTextFieldCell.h new file mode 100644 index 00000000..d7f8e930 --- /dev/null +++ b/KCD/HMStrokeTextFieldCell.h @@ -0,0 +1,13 @@ +// +// HMStrokeTextFieldCell.h +// KCD +// +// Created by Hori,Masaki on 2014/04/19. +// Copyright (c) 2014年 Hori,Masaki. All rights reserved. +// + +#import + +@interface HMStrokeTextFieldCell : NSTextFieldCell + +@end diff --git a/KCD/HMStrokeTextFieldCell.m b/KCD/HMStrokeTextFieldCell.m new file mode 100644 index 00000000..f66cb322 --- /dev/null +++ b/KCD/HMStrokeTextFieldCell.m @@ -0,0 +1,73 @@ +// +// HMStrokeTextFieldCell.m +// KCD +// +// Created by Hori,Masaki on 2014/04/19. +// Copyright (c) 2014年 Hori,Masaki. All rights reserved. +// + +#import "HMStrokeTextFieldCell.h" + +const CGFloat boarderWidth = 2.0; + +@interface HMStrokeTextFieldCell () +@property (strong, nonatomic) NSLayoutManager *layoutManager; +@property (strong, nonatomic) NSTextContainer *textContainer; +@end + +@implementation HMStrokeTextFieldCell + +- (id)initWithCoder:(NSCoder *)aDecoder +{ + self = [super initWithCoder:aDecoder]; + if(self) { + _layoutManager = [NSLayoutManager new]; + _textContainer = [NSTextContainer new]; + [self.layoutManager addTextContainer:self.textContainer]; + } + return self; +} + +- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView +{ + NSAttributedString *attributedString = self.attributedStringValue; + NSDictionary *attribute = [attributedString attributesAtIndex:0 effectiveRange:NULL]; + NSColor *forgroundColor = [attribute objectForKey:NSForegroundColorAttributeName]; + if(!forgroundColor) return; + if([forgroundColor isEqual:[NSColor controlTextColor]]) { + [super drawInteriorWithFrame:cellFrame inView:controlView]; + return; + } + + NSTextStorage *textStorage = [[NSTextStorage alloc] initWithString:attributedString.string attributes:attribute]; + [textStorage addLayoutManager:self.layoutManager]; + + NSRange range = [self.layoutManager glyphRangeForTextContainer:self.textContainer]; + NSGlyph glyph[range.length]; + NSUInteger glyphLength = [self.layoutManager getGlyphs:glyph range:range]; + + NSFont *font = [attribute objectForKey:NSFontAttributeName]; + NSPoint point = {boarderWidth,0}; + point.y -= [font descender]; + if([controlView isFlipped]) { + point.y -= [controlView frame].size.height; + } + + NSBezierPath *path = [NSBezierPath new]; + [path moveToPoint:point]; + [path appendBezierPathWithGlyphs:glyph count:glyphLength inFont:font]; + [path setLineWidth:boarderWidth]; + [path setLineJoinStyle:NSRoundLineJoinStyle]; + if([controlView isFlipped]) { + NSAffineTransform *affineTransform = [NSAffineTransform transform]; + [affineTransform scaleXBy:1 yBy:-1]; + [path transformUsingAffineTransform:affineTransform]; + } + + [[NSColor blackColor] set]; + [path stroke]; + + [forgroundColor set]; + [path fill]; +} +@end diff --git a/KCD/ja.lproj/HMBroserWindowController.xib b/KCD/ja.lproj/HMBroserWindowController.xib index 48e48320..e8fef288 100644 --- a/KCD/ja.lproj/HMBroserWindowController.xib +++ b/KCD/ja.lproj/HMBroserWindowController.xib @@ -9,6 +9,7 @@ + @@ -35,20 +36,20 @@ - + - + - + - + - + @@ -323,6 +324,10 @@ + + + + diff --git a/KCD/ja.lproj/HMDeckViewController.xib b/KCD/ja.lproj/HMDeckViewController.xib new file mode 100644 index 00000000..757f7eea --- /dev/null +++ b/KCD/ja.lproj/HMDeckViewController.xib @@ -0,0 +1,364 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 空席 + 空席 + + + + + + + + + + + + + + + + %{value1}@/%{value2}@ + - + - + + + + + %{value1}@/%{value2}@ + - + - + + + + + + + + + + + + + + + + + + 空席 + 空席 + + + + + + + + + + + + + + + + %{value1}@/%{value2}@ + - + - + + + + + %{value1}@/%{value2}@ + - + - + + + + + + + + + + + + + + + + + + 空席 + 空席 + + + + + + + + + + + + + + + + %{value1}@/%{value2}@ + - + - + + + + + %{value1}@/%{value2}@ + - + - + + + + + + + + + + + + + + + + + + 空席 + 空席 + + + + + + + + + + + + + + + + %{value1}@/%{value2}@ + - + - + + + + + %{value1}@/%{value2}@ + - + - + + + + + + + + + + + + + + + + + + 空席 + 空席 + + + + + + + + + + + + + + + + %{value1}@/%{value2}@ + - + - + + + + + %{value1}@/%{value2}@ + - + - + + + + + + + + + + + + + + + + + + 空席 + 空席 + + + + + + + + + + + + + + + + %{value1}@/%{value2}@ + - + - + + + + + %{value1}@/%{value2}@ + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.11.0