OSDN Git Service

HMResourceViewControllerをSwiftに変換した
authormasakih <masakih@users.sourceforge.jp>
Sun, 25 Dec 2016 04:18:19 +0000 (13:18 +0900)
committermasakih <masakih@users.sourceforge.jp>
Sun, 25 Dec 2016 04:18:19 +0000 (13:18 +0900)
KCD.xcodeproj/project.pbxproj
KCD/HMBroserWindowController.m
KCD/HMResourceViewController.h [deleted file]
KCD/HMResourceViewController.m [deleted file]
KCD/HMResourceViewController.swift [new file with mode: 0644]

index 2f2f83c..657ec69 100644 (file)
                F4D05BD41E0F4F8500688D66 /* HMShipDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4D05BD31E0F4F8500688D66 /* HMShipDetailViewController.swift */; };
                F4D05BD71E0F696C00688D66 /* HMRepairListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4D05BD61E0F696C00688D66 /* HMRepairListViewController.swift */; };
                F4D05BD91E0F748900688D66 /* HMQuestListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4D05BD81E0F748900688D66 /* HMQuestListViewController.swift */; };
+               F4D05BDB1E0F76A800688D66 /* HMResourceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4D05BDA1E0F76A800688D66 /* HMResourceViewController.swift */; };
                F4D2CBC218AD0E1A000EBC59 /* HMMasterSTypeCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D2CBC118AD0E1A000EBC59 /* HMMasterSTypeCommand.m */; };
                F4D2CBC518AE2AE2000EBC59 /* HMCompositCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D2CBC418AE2AE2000EBC59 /* HMCompositCommand.m */; };
                F4D2CBC818B0555A000EBC59 /* HMKCManagedObject.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D2CBC718B0555A000EBC59 /* HMKCManagedObject.m */; };
                F4ED5D2A1B78D0CA00D1BDEF /* HMGuardEscapedView.m in Sources */ = {isa = PBXBuildFile; fileRef = F4ED5D291B78D0CA00D1BDEF /* HMGuardEscapedView.m */; };
                F4ED5D2D1B7C677E00D1BDEF /* HMGuardShelterCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4ED5D2C1B7C677E00D1BDEF /* HMGuardShelterCommand.m */; };
                F4F388BD1C13D63B00508549 /* HMGameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F388BB1C13D63B00508549 /* HMGameViewController.m */; };
-               F4F388C21C140AFB00508549 /* HMResourceViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F388C01C140AFB00508549 /* HMResourceViewController.m */; };
                F4F479261C074E9900D0BF69 /* HMCombinedCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F479251C074E9900D0BF69 /* HMCombinedCommand.m */; };
                F4F6E8081B2B17E50008B66E /* HMStrengthenListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F6E8061B2B17E50008B66E /* HMStrengthenListViewController.m */; };
                F4F6E80C1B2BC81C0008B66E /* HMPeriodicNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = F4F6E80B1B2BC81C0008B66E /* HMPeriodicNotifier.m */; };
                F4D05BD51E0F605400688D66 /* TemporaryEnumDefined.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TemporaryEnumDefined.h; sourceTree = "<group>"; };
                F4D05BD61E0F696C00688D66 /* HMRepairListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMRepairListViewController.swift; sourceTree = "<group>"; };
                F4D05BD81E0F748900688D66 /* HMQuestListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMQuestListViewController.swift; sourceTree = "<group>"; };
+               F4D05BDA1E0F76A800688D66 /* HMResourceViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMResourceViewController.swift; sourceTree = "<group>"; };
                F4D2CBC018AD0E1A000EBC59 /* HMMasterSTypeCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMMasterSTypeCommand.h; sourceTree = "<group>"; };
                F4D2CBC118AD0E1A000EBC59 /* HMMasterSTypeCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMMasterSTypeCommand.m; sourceTree = "<group>"; };
                F4D2CBC318AE2AE2000EBC59 /* HMCompositCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMCompositCommand.h; sourceTree = "<group>"; };
                F4ED5D2C1B7C677E00D1BDEF /* HMGuardShelterCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMGuardShelterCommand.m; sourceTree = "<group>"; };
                F4F388BA1C13D63B00508549 /* HMGameViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMGameViewController.h; sourceTree = "<group>"; };
                F4F388BB1C13D63B00508549 /* HMGameViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMGameViewController.m; sourceTree = "<group>"; };
-               F4F388BF1C140AFB00508549 /* HMResourceViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMResourceViewController.h; sourceTree = "<group>"; };
-               F4F388C01C140AFB00508549 /* HMResourceViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMResourceViewController.m; sourceTree = "<group>"; };
                F4F479241C074E9900D0BF69 /* HMCombinedCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMCombinedCommand.h; sourceTree = "<group>"; };
                F4F479251C074E9900D0BF69 /* HMCombinedCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMCombinedCommand.m; sourceTree = "<group>"; };
                F4F6E8051B2B17E50008B66E /* HMStrengthenListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMStrengthenListViewController.h; sourceTree = "<group>"; };
                                F49AABC51DF70BAE00E0B24F /* HMMainTabVIewItemViewController.h */,
                                F49AABC61DF70BAE00E0B24F /* HMMainTabVIewItemViewController.m */,
                                F4B3DC4118E5C8870011B4FC /* HMBroserWindowController.xib */,
-                               F4F388BF1C140AFB00508549 /* HMResourceViewController.h */,
-                               F4F388C01C140AFB00508549 /* HMResourceViewController.m */,
+                               F4D05BDA1E0F76A800688D66 /* HMResourceViewController.swift */,
                                F4C6686B1C5451C800601AFB /* HMResourceViewController.xib */,
                                F4253D801C8B307800CDA2A6 /* HMAncherageRepairTimerViewController.h */,
                                F4253D811C8B307800CDA2A6 /* HMAncherageRepairTimerViewController.m */,
                                F4C5A2261C36C68C00533FB6 /* HMStrengthenListItemView.m in Sources */,
                                F4C86B921C1C445D00F260FE /* HMUpgradeShipExcludeColorTransformer.m in Sources */,
                                F46FCB291BD933C600304DE7 /* HMSlotItemShortNameTransformer.m in Sources */,
+                               F4D05BDB1E0F76A800688D66 /* HMResourceViewController.swift in Sources */,
                                F4A3AD82199F529700FDBF80 /* HMCombinedBattleCommand.m in Sources */,
                                F4AA05FE192B932E00844688 /* HMTemporaryDataStore.m in Sources */,
                                F48A705C1DE58A38005DFC0B /* HMKCAirBase+CoreDataClass.m in Sources */,
-                               F4F388C21C140AFB00508549 /* HMResourceViewController.m in Sources */,
                                F4B414F818B1D35800468DAF /* HMMasterMissionCommand.m in Sources */,
                                F45F3BE31E06A60A0009434E /* HMUpgradableShipsWindowController.swift in Sources */,
                                F4E33B5818BF5F67005B8C07 /* HMMemberSlotItemCommand.m in Sources */,
index c984b21..5328499 100644 (file)
@@ -19,7 +19,6 @@
 #import "HMGameViewController.h"
 #import "HMCombinedCommand.h"
 #import "HMFleetViewController.h"
-#import "HMResourceViewController.h"
 #import "HMAncherageRepairTimerViewController.h"
 
 
diff --git a/KCD/HMResourceViewController.h b/KCD/HMResourceViewController.h
deleted file mode 100644 (file)
index c9f49ec..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-//  HMResourceViewController.h
-//  KCD
-//
-//  Created by Hori,Masaki on 2015/12/06.
-//  Copyright (c) 2015年 Hori,Masaki. All rights reserved.
-//
-
-#import <Cocoa/Cocoa.h>
-
-@interface HMResourceViewController : NSViewController
-
-@end
diff --git a/KCD/HMResourceViewController.m b/KCD/HMResourceViewController.m
deleted file mode 100644 (file)
index dfab37a..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-//
-//  HMResourceViewController.m
-//  KCD
-//
-//  Created by Hori,Masaki on 2015/12/06.
-//  Copyright (c) 2015年 Hori,Masaki. All rights reserved.
-//
-
-#import "HMResourceViewController.h"
-
-#import "HMUserDefaults.h"
-
-#import "HMServerDataStore.h"
-
-@interface HMResourceViewController ()
-@property (readonly) NSManagedObjectContext *managedObjectContext;
-
-@property (nonatomic, strong) IBOutlet NSArrayController *shipController;
-@property (nonatomic, strong) IBOutlet NSObjectController *basicController;
-@property (nonatomic, strong) NSNumber *maxChara;
-@property (nonatomic, strong) NSNumber *shipCount;
-@property (readonly) NSColor *shipNumberColor;
-@property NSInteger minimumColoredShipCount;
-@end
-
-@implementation HMResourceViewController
-
-- (id)init
-{
-       self = [super initWithNibName:NSStringFromClass([self class]) bundle:nil];
-       return self;
-}
-
-- (void)awakeFromNib
-{
-       [self bind:@"maxChara" toObject:self.basicController withKeyPath:@"selection.max_chara" options:nil];
-       [self bind:@"shipCount" toObject:self.shipController withKeyPath:@"arrangedObjects.@count" options:nil];
-}
-
-+ (NSSet *)keyPathsForValuesAffectingShipNumberColor
-{
-       return [NSSet setWithObjects:@"maxChara", @"shipCount", @"minimumColoredShipCount", nil];
-}
-
-- (NSManagedObjectContext *)managedObjectContext
-{
-       return [HMServerDataStore defaultManager].managedObjectContext;
-}
-
-- (NSColor *)shipNumberColor
-{
-       NSInteger max = self.maxChara.integerValue;
-       NSInteger current = self.shipCount.integerValue;
-       
-       if(current > max - self.minimumColoredShipCount) {
-               return [NSColor orangeColor];
-       }
-       
-       return [NSColor controlTextColor];
-}
-- (void)setMinimumColoredShipCount:(NSInteger)minimumColoredShipCount
-{
-       HMStandardDefaults.minimumColoredShipCount = minimumColoredShipCount;
-}
-- (NSInteger)minimumColoredShipCount
-{
-       return HMStandardDefaults.minimumColoredShipCount;
-}
-@end
diff --git a/KCD/HMResourceViewController.swift b/KCD/HMResourceViewController.swift
new file mode 100644 (file)
index 0000000..61238d7
--- /dev/null
@@ -0,0 +1,53 @@
+//
+//  HMResourceViewController.swift
+//  KCD
+//
+//  Created by Hori,Masaki on 2016/12/25.
+//  Copyright © 2016年 Hori,Masaki. All rights reserved.
+//
+
+import Cocoa
+
+class HMResourceViewController: NSViewController {
+    override var nibName: String! {
+        return "HMResourceViewController"
+    }
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        
+        bind("maxChara", to: basicController, withKeyPath: "selection.max_chara", options: nil)
+        bind("shipCount", to: shipController, withKeyPath: "arrangedObjects.@count", options: nil)
+    }
+    deinit {
+        unbind("maxChara")
+        unbind("shipCount")
+    }
+    
+    let managedObjectContext = HMServerDataStore.default().managedObjectContext
+    
+    @IBOutlet var shipController: NSArrayController!
+    @IBOutlet var basicController: NSObjectController!
+    
+    dynamic var maxChara: Int = 0
+    dynamic var shipCount: Int = 0
+    dynamic var shipNumberColor: NSColor {
+        get {
+            if shipCount > maxChara - minimumColoredShipCount {
+                return NSColor.orange
+            }
+            return NSColor.controlTextColor
+        }
+    }
+    dynamic var minimumColoredShipCount: Int {
+        get {
+            return HMStandardDefaults.minimumColoredShipCount
+        }
+        set {
+            HMStandardDefaults.minimumColoredShipCount = newValue
+        }
+    }
+    
+    class func keyPathsForValuesAffectingShipNumberColor() -> NSSet {
+        return NSSet(objects: "maxChara", "shipCount", "minimumColoredShipCount")
+    }
+}