OSDN Git Service

Doutaku を 1.0 にアップデート
[kcd/KCD.git] / KCD / DefaultKeys.swift
1 /*
2  DefaultKeys.swift
3  
4  Copyright (c) 2017, Hori, Masaki.
5  All rights reserved.
6  
7  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8  
9  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10  
11  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
12  
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14  
15  */
16
17 /*
18  
19  DefaultKeys.swift
20  
21  CotEditor
22  https://coteditor.com
23  
24  Created by 1024jp on 2017-02-14.
25  
26  ------------------------------------------------------------------------------
27  
28  © 2016-2017 1024jp
29  
30  Licensed under the Apache License, Version 2.0 (the "License");
31  you may not use this file except in compliance with the License.
32  You may obtain a copy of the License at
33  
34  https://www.apache.org/licenses/LICENSE-2.0
35  
36  Unless required by applicable law or agreed to in writing, software
37  distributed under the License is distributed on an "AS IS" BASIS,
38  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39  See the License for the specific language governing permissions and
40  limitations under the License.
41  
42  */
43
44 import Foundation
45 import AppKit.NSColor
46 import AppKit.NSControl
47
48
49 func rangeReguletor<T>(_ range: ClosedRange<T>) -> (T) -> T {
50     
51     return {
52         
53         let min = range.lowerBound
54         let max = range.upperBound
55         
56         switch $0 {
57             
58         case let v where v < min: return min
59             
60         case let v where v > max: return max
61             
62         default: return $0
63             
64         }
65     }
66 }
67
68
69 extension DefaultKeys {
70     
71     // Table sort descriptor
72     static let slotItemSortDescriptors = DefaultKey<[NSSortDescriptor]>("slotItemSortKey2")
73     static let shipviewSortDescriptors = DefaultKey<[NSSortDescriptor]>("shipviewsortdescriptor")
74     static let powerupSupportSortDecriptors = DefaultKey<[NSSortDescriptor]>("powerupsupportsortdecriptor")
75     
76     // Debugging
77     static let showsDebugMenu = DefaultKey<Bool>("ShowsDebugMenu")
78     static let degugPrintLevel = DefaultKey<Debug.Level>("DebugPrintLevel", alternative: .none)
79     
80     // Main Window
81     static let prevReloadDate = DefaultKey<Date>("previousReloadDate", alternative: .distantPast)
82     
83     // PowerUpSupport
84     static let hideMaxKaryoku = DefaultKey<Bool>("hideMaxKaryoku")
85     static let hideMaxLucky = DefaultKey<Bool>("hideMaxLucky")
86     static let hideMaxRaisou = DefaultKey<Bool>("hideMaxRaisou")
87     static let hideMaxSoukou = DefaultKey<Bool>("hideMaxSoukou")
88     static let hideMaxTaiku = DefaultKey<Bool>("hideMaxTaiku")
89     
90     // Plan Color
91     static let showsPlanColor = DefaultKey<Bool>("showsPlanColor")
92     static let plan01Color = DefaultKey<NSColor>("plan01Color", alternative: #colorLiteral(red: 0.000, green: 0.043, blue: 0.518, alpha: 1))
93     static let plan02Color = DefaultKey<NSColor>("plan02Color", alternative: #colorLiteral(red: 0.800, green: 0.223, blue: 0.000, alpha: 1))
94     static let plan03Color = DefaultKey<NSColor>("plan03Color", alternative: #colorLiteral(red: 0.539, green: 0.012, blue: 0.046, alpha: 1))
95     static let plan04Color = DefaultKey<NSColor>("plan04Color", alternative: #colorLiteral(red: 0.000, green: 0.535, blue: 0.535, alpha: 1))
96     static let plan05Color = DefaultKey<NSColor>("plan05Color", alternative: #colorLiteral(red: 0.376, green: 0.035, blue: 0.535, alpha: 1))
97     static let plan06Color = DefaultKey<NSColor>("plan06Color", alternative: #colorLiteral(red: 0.535, green: 0.535, blue: 0.000, alpha: 1))
98     
99     // Resource View
100     static let minimumColoredShipCount = DefaultKey<Int>("minimumColoredShipCount", regulator: rangeReguletor(0...9))
101
102     // Notifiy Sound
103     static let playFinishMissionSound = DefaultKey<Bool>("playFinishMissionSound")
104     static let playFinishNyukyoSound = DefaultKey<Bool>("playFinishNyukyoSound")
105     static let playFinishKenzoSound = DefaultKey<Bool>("playFinishKenzoSound")
106     
107     // Upgradable List
108     static let showLevelOneShipInUpgradableList = DefaultKey<Bool>("showLevelOneShipInUpgradableList")
109     static let showsExcludedShipInUpgradableList = DefaultKey<Bool>("showsExcludedShipInUpgradableList")
110     
111     // Equipment List
112     static let showEquipmentType = DefaultKey<SlotItemWindowController.ShowType>("showEquipmentType", alternative: .all)
113     
114     // FleetView
115     static let fleetViewPosition = DefaultKey<BroserWindowController.FleetViewPosition>("fleetViewPosition", alternative: .above)
116     static let fleetViewShipOrder = DefaultKey<FleetViewController.ShipOrder>("fleetViewShipOrder", alternative: .doubleLine)
117     static let repairTime = DefaultKey<Date>("repairTime", alternative: .distantPast)
118     
119     // Combined View
120     static let lastHasCombinedView = DefaultKey<Bool>("lastHasCombinedView")
121     static let autoCombinedView = DefaultKey<Bool>("autoCombinedView")
122     static let useSwipeChangeCombinedView = DefaultKey<Bool>("useSwipeChangeCombinedView")
123     
124     // Screenshos
125     static let appendKanColleTag = DefaultKey<Bool>("appendKanColleTag")
126     static let showsListWindowAtScreenshot = DefaultKey<Bool>("showsListWindowAtScreenshot")
127     static let screenshotPreviewZoomValue = DefaultKey<Double>("screenshotPreviewZoomValue", regulator: rangeReguletor(0.2...0.99))
128     static let screenshotEditorColumnCount = DefaultKey<Int>("screenshotEditorColumnCount", regulator: rangeReguletor(1...50))
129     static let scrennshotEditorType = DefaultKey<Int>("scrennshotEditorType")
130     static let screenshotButtonSize = DefaultKey<NSControl.ControlSize>("screenshotButtonSize", alternative: .regular)
131     static let useMask = DefaultKey<Bool>("useMask")
132     static let screenShotBorderWidth = DefaultKey<CGFloat>("screenShotBorderWidth", regulator: rangeReguletor(0.0...20.0))
133     static let screenShotSaveDirectory = DefaultKey<String?>("screenShotSaveDirectory")
134     
135     // Old History Item Clean
136     static let cleanOldHistoryItems = DefaultKey<Bool>("cleanOldHistoryItems")
137     static let cleanSinceDays = DefaultKey<Int>("cleanSiceDays", regulator: rangeReguletor(1...Int.max))
138     
139     // Notify time signal
140     static let notifyTimeSignal = DefaultKey<Bool>("notifyTimeSignal")
141     static let notifyTimeBeforeTimeSignal = DefaultKey<Int>("notifyTimeBeforeTimeSignal", regulator: rangeReguletor(1...59))
142     static let playNotifyTimeSignalSound = DefaultKey<Bool>("playNotifyTimeSignalSound")
143     
144     // Sakuteki Calculate
145     static let sakutekiCalclationSterategy = DefaultKey<FleetViewController.SakutekiCalclationSterategy>("sakutekiCalclationSterategy", alternative: .total)
146     static let formula33Factor = DefaultKey<Double>("formula33Factor")
147     
148 }