2 // HMDamageValueTransformer.m
5 // Created by Hori,Masaki on 2016/02/23.
6 // Copyright © 2016年 Hori,Masaki. All rights reserved.
9 #import "HMDamageValueTransformer.h"
11 @implementation HMDamageValueTransformer
14 static dispatch_once_t onceToken;
15 dispatch_once(&onceToken, ^{
16 [NSValueTransformer setValueTransformer:[self new] forName:@"HMDamageValueTransformer"];
19 + (Class)transformedValueClass
21 return [NSAttributedString class];
23 + (BOOL)allowsReverseTransformation
28 - (NSParagraphStyle *)paragraphStyle
30 static NSParagraphStyle *style = nil;
32 NSMutableParagraphStyle *s = [NSMutableParagraphStyle new];
33 s.alignment = NSTextAlignmentCenter;
39 - (id)transformedValue:(id)value
41 NSInteger damage = [value integerValue];
44 NSDictionary *attr = nil;
54 NSForegroundColorAttributeName:
55 [NSColor colorWithCalibratedRed:1.000 green:0.925 blue:0.000 alpha:1.000],
56 NSParagraphStyleAttributeName: self.paragraphStyle
62 NSForegroundColorAttributeName:
63 [NSColor colorWithCalibratedRed:1.000 green:0.392 blue:0.000 alpha:1.000],
64 NSParagraphStyleAttributeName: self.paragraphStyle
70 NSForegroundColorAttributeName:
71 [NSColor colorWithCalibratedRed:0.870 green:0.000 blue:0.036 alpha:1.000],
72 NSParagraphStyleAttributeName: self.paragraphStyle
76 NSLog(@"Unknown status");
81 NSMutableAttributedString *result = [[NSMutableAttributedString alloc] initWithString:mark