OSDN Git Service

ColorSetを変更
authormasakih <masakih@users.sourceforge.jp>
Mon, 2 Jul 2018 12:20:42 +0000 (21:20 +0900)
committermasakih <masakih@users.sourceforge.jp>
Mon, 2 Jul 2018 12:20:42 +0000 (21:20 +0900)
KCD/AirPlanInfoView.swift
KCD/ColorSet.swift
KCD/DamageView.swift
KCD/SlotItemLevelView.swift
KCD/SuppliesCell.swift

index f4d9edb..e1a1b15 100644 (file)
@@ -61,11 +61,11 @@ final class AirPlanInfoView: NSTableCellView {
         
         switch cond {
             
-        case .normal: return ColorSet.current[.airPlanInforViewNormal]
+        case .normal: return ColorSetManager.current[.airPlanInforViewNormal]
             
-        case .tired: return ColorSet.current[.airPlanInforViewTired]
+        case .tired: return ColorSetManager.current[.airPlanInforViewTired]
             
-        case .bad: return ColorSet.current[.airPlanInforViewBad]
+        case .bad: return ColorSetManager.current[.airPlanInforViewBad]
             
         }
     }
@@ -74,11 +74,11 @@ final class AirPlanInfoView: NSTableCellView {
         
         switch cond {
             
-        case .normal: return ColorSet.current[.airPlanInforViewBoarderNormal]
+        case .normal: return ColorSetManager.current[.airPlanInforViewBoarderNormal]
             
-        case .tired: return ColorSet.current[.airPlanInforViewBoarderTired]
+        case .tired: return ColorSetManager.current[.airPlanInforViewBoarderTired]
             
-        case .bad: return ColorSet.current[.airPlanInforViewBoarderBad]
+        case .bad: return ColorSetManager.current[.airPlanInforViewBoarderBad]
             
         }
     }
index 3ddaccc..1050ac9 100644 (file)
@@ -65,7 +65,13 @@ extension ColorName {
     static let slotItemLevelViewHighAirLevelShadow = ColorName("SlotItemLevelView.airLevel.high.shadow")
 }
 
-class ColorSet {
+protocol ColorSet {
+    
+    subscript(named: ColorName) -> NSColor { get }
+}
+
+
+struct ColorSetManager {
     
     static var current: ColorSet {
         
@@ -74,12 +80,13 @@ class ColorSet {
             return HighContrastColorSet.shared
         }
         
-        return ColorSet.shared
+        return DefaultColorSet.shared
     }
+}
+
+private struct DefaultColorSet: ColorSet {
     
-    class var shared: ColorSet { return _shared }
-    
-    private static let _shared = ColorSet()
+    static let shared = DefaultColorSet()
     
     subscript(named: ColorName) -> NSColor {
         
@@ -141,13 +148,12 @@ class ColorSet {
 }
 
 
-class HighContrastColorSet: ColorSet {
+private struct HighContrastColorSet: ColorSet {
     
-    override class var shared: ColorSet { return _shared }
     
-    private static let _shared = HighContrastColorSet()
+    static let shared = HighContrastColorSet()
     
-    override subscript(named: ColorName) -> NSColor {
+    subscript(named: ColorName) -> NSColor {
         
         switch named {
             
@@ -157,22 +163,20 @@ class HighContrastColorSet: ColorSet {
             
         case .damageViewBoarderBadly: return .red
             
-        default: return super[named]
+        default: return DefaultColorSet.shared[named]
         }
     }
 }
 
-class DarkModeColorSet: ColorSet {
+private struct DarkModeColorSet: ColorSet {
     
-    override class var shared: ColorSet { return _shared }
+    private static let shared = DarkModeColorSet()
     
-    private static let _shared = DarkModeColorSet()
-    
-    override subscript(named: ColorName) -> NSColor {
+    subscript(named: ColorName) -> NSColor {
         
         switch named {
             
-        default: return super[named]
+        default: return DefaultColorSet.shared[named]
         }
     }
 }
index 5ff47c9..5f5e076 100644 (file)
@@ -46,11 +46,11 @@ final class DamageView: NSView {
             
         case .none: return nil
             
-        case .slightly: return ColorSet.current[.damageViewInnerSlightly]
+        case .slightly: return ColorSetManager.current[.damageViewInnerSlightly]
             
-        case .modest: return ColorSet.current[.damageViewInnerModest]
+        case .modest: return ColorSetManager.current[.damageViewInnerModest]
             
-        case .badly: return ColorSet.current[.damageViewInnerBadly]
+        case .badly: return ColorSetManager.current[.damageViewInnerBadly]
             
         }
     }
@@ -61,11 +61,11 @@ final class DamageView: NSView {
             
         case .none: return nil
             
-        case .slightly: return ColorSet.current[.damageViewBoarderSlightly]
+        case .slightly: return ColorSetManager.current[.damageViewBoarderSlightly]
             
-        case .modest: return ColorSet.current[.damageViewBoarderModest]
+        case .modest: return ColorSetManager.current[.damageViewBoarderModest]
             
-        case .badly: return ColorSet.current[.damageViewBoarderBadly]
+        case .badly: return ColorSetManager.current[.damageViewBoarderBadly]
             
         }
     }
index 3ac3c98..9560138 100644 (file)
@@ -213,7 +213,7 @@ final class SlotItemLevelView: NSTextField {
     
     private var levelColor: NSColor {
         
-        return ColorSet.current[.slotItemLevelViewLevel]
+        return ColorSetManager.current[.slotItemLevelViewLevel]
         
         
     }
@@ -264,9 +264,9 @@ final class SlotItemLevelView: NSTextField {
         
         switch level {
             
-        case 1, 2, 3: return ColorSet.current[.slotItemLevelViewLowAirLevel]
+        case 1, 2, 3: return ColorSetManager.current[.slotItemLevelViewLowAirLevel]
             
-        case 4, 5, 6, 7: return ColorSet.current[.slotItemLevelViewHighAirLevel]
+        case 4, 5, 6, 7: return ColorSetManager.current[.slotItemLevelViewHighAirLevel]
             
         default: return nil
             
@@ -279,14 +279,14 @@ final class SlotItemLevelView: NSTextField {
             
         case 1, 2, 3:
             let shadow = NSShadow()
-            shadow.shadowColor = ColorSet.current[.slotItemLevelViewLowAirLevelShadow]
+            shadow.shadowColor = ColorSetManager.current[.slotItemLevelViewLowAirLevelShadow]
             shadow.shadowBlurRadius = 4.0
             
             return shadow
             
         case 4, 5, 6, 7:
             let shadow = NSShadow()
-            shadow.shadowColor = ColorSet.current[.slotItemLevelViewHighAirLevelShadow]
+            shadow.shadowColor = ColorSetManager.current[.slotItemLevelViewHighAirLevelShadow]
             shadow.shadowBlurRadius = 3.0
             
             return shadow
index be3b53b..7632604 100644 (file)
@@ -21,27 +21,27 @@ final class SuppliesCell: NSCell {
     
     private var greenColor: NSColor {
         
-        return ColorSet.current[.suppliesCellGreen]
+        return ColorSetManager.current[.suppliesCellGreen]
     }
     private var yellowColor: NSColor {
         
-        return ColorSet.current[.suppliesCellYellow]
+        return ColorSetManager.current[.suppliesCellYellow]
     }
     private var orangeColor: NSColor {
         
-        return ColorSet.current[.suppliesCellOrange]
+        return ColorSetManager.current[.suppliesCellOrange]
     }
     private var redColor: NSColor {
         
-        return ColorSet.current[.suppliesCellRedColor]
+        return ColorSetManager.current[.suppliesCellRedColor]
     }
     private var borderColor: NSColor {
         
-        return ColorSet.current[.suppliesCellBorder]
+        return ColorSetManager.current[.suppliesCellBorder]
     }
     private var backgroundColor: NSColor {
         
-        return ColorSet.current[.suppliesCellBackground]
+        return ColorSetManager.current[.suppliesCellBackground]
     }
     
     @objc dynamic var ship: Ship?