OSDN Git Service

簡略表示でも退避と損傷状態を表示するようにした
authormasakih <masakih@users.sourceforge.jp>
Sat, 24 Oct 2015 15:10:43 +0000 (00:10 +0900)
committermasakih <masakih@users.sourceforge.jp>
Sat, 24 Oct 2015 15:10:43 +0000 (00:10 +0900)
KCD/HMDamageView.h
KCD/HMDamageView.m
KCD/HMGuardEscapedView.h
KCD/HMGuardEscapedView.m
KCD/HMMinimumShipViewController.m

index f8d393b..9886784 100644 (file)
@@ -18,5 +18,6 @@ typedef NS_ENUM(NSInteger, HMDamageType) {
 @interface HMDamageView : NSView
 
 @property (nonatomic) HMDamageType damageType;
+@property NSControlSize controlSize;
 
 @end
index e4a970a..0774bf2 100644 (file)
@@ -42,9 +42,8 @@
                        return nil;
                        break;
                case slightly:
-                       color = [NSColor yellowColor];
+                       color = [NSColor colorWithCalibratedRed:1.000 green:0.956 blue:0.012 alpha:1.000];
                        color = [color colorWithAlphaComponent:0.5];
-//                     color = [NSColor colorWithCalibratedRed:0.99 green:0.9 blue:0.0 alpha:0.5];
                        break;
                case modest:
                        color = [NSColor orangeColor];
@@ -67,7 +66,6 @@
                        return nil;
                        break;
                case slightly:
-//                     color = [NSColor yellowColor];
                        color = [NSColor orangeColor];
                        color = [color colorWithAlphaComponent:0.50];
                        break;
 
 - (NSBezierPath *)path
 {
+       NSBezierPath *path = nil;
+       
+       switch(self.controlSize) {
+               case NSRegularControlSize:
+                       path = [self pathForRegular];
+                       break;
+               case NSSmallControlSize:
+               case NSMiniControlSize:
+                       path = [self pathForSmall];
+                       break;
+       }
+       return path;
+}
+
+- (NSBezierPath *)pathForRegular
+{
+       NSRect bounds = self.bounds;
+       NSSize boundsSize = bounds.size;
+       NSBezierPath *path = nil;
+       
+       switch(self.damageType) {
+               case none:
+                       return nil;
+                       break;
+               case slightly:
+                       path = [NSBezierPath bezierPath];
+                       [path moveToPoint:NSMakePoint(35.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 35.0)];
+                       [path closePath];
+                       break;
+               case modest:
+                       path = [NSBezierPath bezierPath];
+                       [path moveToPoint:NSMakePoint(50.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(25.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 25.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 50.0)];
+                       [path closePath];
+                       break;
+               case badly:
+                       path = [NSBezierPath bezierPath];
+                       [path moveToPoint:NSMakePoint(60.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(53.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 53.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 60.0)];
+                       [path closePath];
+                       
+                       [path moveToPoint:NSMakePoint(47.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(23.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 23.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 47.0)];
+                       [path closePath];
+                       break;
+       }
+       
+       return path;
+}
+
+- (NSBezierPath *)pathForSmall
+{
        NSRect bounds = self.bounds;
        NSSize boundsSize = bounds.size;
        NSBezierPath *path = nil;
                        break;
                case slightly:
                        path = [NSBezierPath bezierPath];
-                       [path moveToPoint:NSMakePoint(boundsSize.width - 35.0, 0.0)];
-                       [path lineToPoint:NSMakePoint(boundsSize.width - 2, 0.0)];
-                       [path lineToPoint:NSMakePoint(boundsSize.width - 2, 35.0)];
+                       [path moveToPoint:NSMakePoint(35.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 35.0)];
                        [path closePath];
                        break;
                case modest:
                        path = [NSBezierPath bezierPath];
-                       [path moveToPoint:NSMakePoint(boundsSize.width - 50.0, 0.0)];
-                       [path lineToPoint:NSMakePoint(boundsSize.width - 25.0, 0.0)];
-                       [path lineToPoint:NSMakePoint(boundsSize.width - 2, 25.0)];
-                       [path lineToPoint:NSMakePoint(boundsSize.width - 2, 50.0)];
+                       [path moveToPoint:NSMakePoint(50.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(25.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 25.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 50.0)];
                        [path closePath];
                        break;
                case badly:
                        path = [NSBezierPath bezierPath];
-                       [path moveToPoint:NSMakePoint(boundsSize.width - 60.0, 0.0)];
-                       [path lineToPoint:NSMakePoint(boundsSize.width - 55.0, 0.0)];
-                       [path lineToPoint:NSMakePoint(boundsSize.width - 2, 55.0)];
-                       [path lineToPoint:NSMakePoint(boundsSize.width - 2, 60.0)];
+                       [path moveToPoint:NSMakePoint(55.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(48.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 48.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 55.0)];
                        [path closePath];
                        
-                       [path moveToPoint:NSMakePoint(boundsSize.width - 50.0, 0.0)];
-                       [path lineToPoint:NSMakePoint(boundsSize.width - 25.0, 0.0)];
-                       [path lineToPoint:NSMakePoint(boundsSize.width - 2, 25.0)];
-                       [path lineToPoint:NSMakePoint(boundsSize.width - 2, 50.0)];
+                       [path moveToPoint:NSMakePoint(42.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(20.0, boundsSize.height - 2.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 20.0)];
+                       [path lineToPoint:NSMakePoint(0.0, boundsSize.height - 42.0)];
                        [path closePath];
                        break;
        }
index 995a76e..58c9b2b 100644 (file)
@@ -10,4 +10,6 @@
 
 @interface HMGuardEscapedView : NSView
 
+@property NSControlSize controlSize;
+
 @end
index 62f77df..ebc79c9 100644 (file)
@@ -53,7 +53,15 @@ static NSString *hiString = nil;
        [[NSColor colorWithCalibratedWhite:0.9 alpha:0.8] set];
        [fillPath fill];
        
-       [self drawTaihiInrect:bounds];
+       switch(self.controlSize) {
+               case NSRegularControlSize:
+                       [self drawTaihiInrect:bounds];
+                       break;
+               case NSSmallControlSize:
+               case NSMiniControlSize:
+                       [self drawSmallTaihiInrect:bounds];
+                       break;
+       }
 }
 
 - (void)drawTaihiInrect:(NSRect)bounds
@@ -100,4 +108,43 @@ static NSString *hiString = nil;
        [hi drawInRect:rect];
 }
 
+- (void)drawSmallTaihiInrect:(NSRect)bounds
+{
+       const CGFloat width = 100;
+       const CGFloat height = 50;
+       NSRect rect = NSMakeRect(
+                                                        (NSInteger)((bounds.size.width - width) * 0.5),
+                                                        (NSInteger)((bounds.size.height - height) * 0.5),
+                                                        width, height);
+       
+       NSBezierPath *path = [NSBezierPath bezierPathWithRect:rect];
+       
+       [[NSColor whiteColor] set];
+       [path fill];
+       
+       [[NSColor blackColor] set];
+       [path stroke];
+       
+       rect = NSInsetRect(rect, 3, 3);
+       path = [NSBezierPath bezierPathWithRect:rect];
+       path.lineWidth = 2;
+       [path stroke];
+       
+       NSDictionary *taiAttr = @{
+                                                         NSForegroundColorAttributeName : [NSColor lightGrayColor],
+                                                         NSFontAttributeName : [NSFont boldSystemFontOfSize:height - 14],
+                                                         };
+       NSAttributedString *tai = [[NSAttributedString alloc] initWithString:taiString attributes:taiAttr];
+       
+       NSAttributedString *hi = [[NSAttributedString alloc] initWithString:hiString attributes:taiAttr];
+       
+       rect = NSInsetRect(rect, 2, 2);
+       rect.origin.y += 4;
+       rect.origin.x += 4;
+       rect.size.height -= 2;
+       [tai drawInRect:rect];
+       rect.origin.x += rect.size.width * 0.5;
+       [hi drawInRect:rect];
+}
+
 @end
index ef0cfe2..c0738ae 100644 (file)
@@ -57,6 +57,7 @@
 - (void)awakeFromNib
 {
        [self.damageView setFrameOrigin:NSZeroPoint];
+       self.damageView.controlSize = NSSmallControlSize;
        [self.view addSubview:self.damageView];
        [self.damageView bind:@"damageType"
                                 toObject:self.shipController
@@ -66,6 +67,7 @@
                                                        }];
        
        [self.guardEscapedView setFrameOrigin:NSZeroPoint];
+       self.guardEscapedView.controlSize = NSSmallControlSize;
        [self.view addSubview:self.guardEscapedView];
 }