F421850F1DF4518000256590 /* BroswerTouchBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = F421850E1DF4518000256590 /* BroswerTouchBar.xib */; };
F42185111DF461A600256590 /* ScreenshotTouchBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = F42185101DF461A600256590 /* ScreenshotTouchBar.xib */; };
F42539E21EB4A7950083EB9D /* AirPlanInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42539E11EB4A7950083EB9D /* AirPlanInfoView.swift */; };
+ F42546921EF8002E00BE297E /* EquitType.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42546911EF8002E00BE297E /* EquitType.swift */; };
+ F42546931EFBE0D300BE297E /* EquitType.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42546911EF8002E00BE297E /* EquitType.swift */; };
F42A8FCC1E3DA4DF0099DC1D /* MasterMission.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42A8FCB1E3DA4DF0099DC1D /* MasterMission.swift */; };
F42A8FCE1E3DA7E90099DC1D /* MasterShip.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42A8FCD1E3DA7E90099DC1D /* MasterShip.swift */; };
F42A8FD01E3DB49A0099DC1D /* MasterSlotItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42A8FCF1E3DB49A0099DC1D /* MasterSlotItem.swift */; };
F42CFE281E3D9A02000B4F9B /* MasterMapInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42CFE271E3D9A02000B4F9B /* MasterMapInfo.swift */; };
F43E67B718BE02A10087E5B6 /* STypeShortName.plist in Resources */ = {isa = PBXBuildFile; fileRef = F43E67B618BE02A10087E5B6 /* STypeShortName.plist */; };
F43E67B918BE060E0087E5B6 /* LevelUpExp.plist in Resources */ = {isa = PBXBuildFile; fileRef = F43E67B818BE060E0087E5B6 /* LevelUpExp.plist */; };
+ F44775891EF6AAD900287572 /* SakutekiCalculator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44775881EF6AAD900287572 /* SakutekiCalculator.swift */; };
F44AA2671E814A4400EED8BE /* ManagedObjectContextGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44AA2661E814A4400EED8BE /* ManagedObjectContextGenerator.swift */; };
F44AA26B1E82AD2E00EED8BE /* NSObjectExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44AA26A1E82AD2E00EED8BE /* NSObjectExtension.swift */; };
F44BC6C11E221293004644E3 /* AirCorpsChangeNameCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44BC6C01E221293004644E3 /* AirCorpsChangeNameCommand.swift */; };
F4BEF00B1B11A628004702B8 /* ShipMasterDetailWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4BEF00D1B11A628004702B8 /* ShipMasterDetailWindowController.xib */; };
F4BEF00E1B11A645004702B8 /* UITestWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4BEF0101B11A645004702B8 /* UITestWindowController.xib */; };
F4C041BA1875CAF5009273EB /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4C041B91875CAF5009273EB /* JavaScriptCore.framework */; };
+ F4C3D1BF1F13A32D0084D0CA /* CalculateConditionPanelController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4C3D1BD1F13A32D0084D0CA /* CalculateConditionPanelController.swift */; };
+ F4C3D1C01F13A32D0084D0CA /* CalculateConditionPanelController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4C3D1BE1F13A32D0084D0CA /* CalculateConditionPanelController.xib */; };
F4C5A22C1C37B8DB00533FB6 /* RequiredEquipmentSet.txt in Resources */ = {isa = PBXBuildFile; fileRef = F4C5A22B1C37B8DB00533FB6 /* RequiredEquipmentSet.txt */; };
F4C5A22E1C37CB5100533FB6 /* EnhancementListItem.txt in Resources */ = {isa = PBXBuildFile; fileRef = F4C5A22D1C37CB5100533FB6 /* EnhancementListItem.txt */; };
F4C5A23E1C380E0400533FB6 /* HMEnhancementListItem.plist in Resources */ = {isa = PBXBuildFile; fileRef = F4C5A23D1C380E0400533FB6 /* HMEnhancementListItem.plist */; };
F421850E1DF4518000256590 /* BroswerTouchBar.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BroswerTouchBar.xib; sourceTree = "<group>"; };
F42185101DF461A600256590 /* ScreenshotTouchBar.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ScreenshotTouchBar.xib; sourceTree = "<group>"; };
F42539E11EB4A7950083EB9D /* AirPlanInfoView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AirPlanInfoView.swift; sourceTree = "<group>"; };
+ F42546911EF8002E00BE297E /* EquitType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EquitType.swift; sourceTree = "<group>"; };
F42A8FCB1E3DA4DF0099DC1D /* MasterMission.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MasterMission.swift; sourceTree = "<group>"; };
F42A8FCD1E3DA7E90099DC1D /* MasterShip.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MasterShip.swift; sourceTree = "<group>"; };
F42A8FCF1E3DB49A0099DC1D /* MasterSlotItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MasterSlotItem.swift; sourceTree = "<group>"; };
F42CFE271E3D9A02000B4F9B /* MasterMapInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MasterMapInfo.swift; sourceTree = "<group>"; };
F43E67B618BE02A10087E5B6 /* STypeShortName.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = STypeShortName.plist; sourceTree = "<group>"; };
F43E67B818BE060E0087E5B6 /* LevelUpExp.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = LevelUpExp.plist; sourceTree = "<group>"; };
+ F44775881EF6AAD900287572 /* SakutekiCalculator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SakutekiCalculator.swift; sourceTree = "<group>"; };
F44AA2661E814A4400EED8BE /* ManagedObjectContextGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManagedObjectContextGenerator.swift; sourceTree = "<group>"; };
F44AA26A1E82AD2E00EED8BE /* NSObjectExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSObjectExtension.swift; sourceTree = "<group>"; };
F44BC6C01E221293004644E3 /* AirCorpsChangeNameCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AirCorpsChangeNameCommand.swift; sourceTree = "<group>"; };
F4BEEEA418D211500006F70C /* ja */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; name = ja; path = ja.lproj/Makefile; sourceTree = "<group>"; };
F4BEEEA718D323520006F70C /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = SOURCE_ROOT; };
F4C041B91875CAF5009273EB /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
+ F4C3D1BD1F13A32D0084D0CA /* CalculateConditionPanelController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalculateConditionPanelController.swift; sourceTree = "<group>"; };
+ F4C3D1BE1F13A32D0084D0CA /* CalculateConditionPanelController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CalculateConditionPanelController.xib; sourceTree = "<group>"; };
F4C5A22B1C37B8DB00533FB6 /* RequiredEquipmentSet.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RequiredEquipmentSet.txt; sourceTree = "<group>"; };
F4C5A22D1C37CB5100533FB6 /* EnhancementListItem.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EnhancementListItem.txt; sourceTree = "<group>"; };
F4C5A2331C37F87500533FB6 /* EquipmentEnhancementListBuilder */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = EquipmentEnhancementListBuilder; sourceTree = BUILT_PRODUCTS_DIR; };
F40F97701E68536400AE81BB /* FileManagerExtension.swift */,
F491A4BB1E4B523C00D1E067 /* ApplicationDirecrories.swift */,
F44AA26A1E82AD2E00EED8BE /* NSObjectExtension.swift */,
+ F44775881EF6AAD900287572 /* SakutekiCalculator.swift */,
+ F42546911EF8002E00BE297E /* EquitType.swift */,
F4BEEFE21B0CD39B004702B8 /* Transformar&Formatter */,
F4C118F318A67B05005D5B25 /* CustomHTTPProtocol */,
F47215A11E1F38280083D3BC /* Queue.swift */,
F490978C1E1BA64E0085A45D /* GuardEscapedView.swift */,
F45FBB911E129BAE000E72B9 /* FleetViewController.swift */,
F4BEF0071B11A5D3004702B8 /* FleetViewController.xib */,
+ F4C3D1BD1F13A32D0084D0CA /* CalculateConditionPanelController.swift */,
+ F4C3D1BE1F13A32D0084D0CA /* CalculateConditionPanelController.xib */,
F4BEF0041B11A5CC004702B8 /* FleetMinimumViewController.xib */,
F4C668711C54524900601AFB /* VerticalFleetViewController.xib */,
F4D05BD11E0F3C4E00688D66 /* CombileViewController.swift */,
F4B3DC3618E5C8650011B4FC /* ShipWindowController.xib in Resources */,
F4C6685A1C54510E00601AFB /* BookmarkEditorViewController.xib in Resources */,
F4B3DC3C18E5C87D0011B4FC /* DocksViewController.xib in Resources */,
+ F4C3D1C01F13A32D0084D0CA /* CalculateConditionPanelController.xib in Resources */,
F4C668631C54518F00601AFB /* ProgressPanel.xib in Resources */,
F41465741DB4F1A700D68C97 /* ScreenshotListWindowController.xib in Resources */,
F4C6686F1C54524900601AFB /* VerticalFleetViewController.xib in Resources */,
F4E5FF061E1523900026868C /* ScreenshotCollectionViewItem.swift in Sources */,
F4D3D9551E8544B90085A389 /* StrengthenListItem.swift in Sources */,
F44BC6DF1E228770004644E3 /* QuestListCommand.swift in Sources */,
+ F42546921EF8002E00BE297E /* EquitType.swift in Sources */,
F44BC7331E2A25E4004644E3 /* Start2Command.swift in Sources */,
F44BC6E31E230577004644E3 /* SlotDepriveCommand.swift in Sources */,
F42A8FCE1E3DA7E90099DC1D /* MasterShip.swift in Sources */,
F44BC73F1E2B1AD4004644E3 /* DummyShipCommand.swift in Sources */,
F44BC73D1E2A5D39004644E3 /* DropShipHistoryCommand.swift in Sources */,
F45771231E1BCC7C008A9215 /* PeriodicNotifier.swift in Sources */,
+ F4C3D1BF1F13A32D0084D0CA /* CalculateConditionPanelController.swift in Sources */,
F44AA2671E814A4400EED8BE /* ManagedObjectContextGenerator.swift in Sources */,
F44BC6C91E22314B004644E3 /* UnknownComand.swift in Sources */,
F47B06DD1E97ECD4006711D9 /* WindowManager.swift in Sources */,
F44BC71D1E29DF32004644E3 /* MemberNDockCommand.swift in Sources */,
F42CFE1E1E3CCCC2000B4F9B /* Resource.swift in Sources */,
F4D05BCE1E0D50D300688D66 /* BrowserContentAdjuster.swift in Sources */,
+ F44775891EF6AAD900287572 /* SakutekiCalculator.swift in Sources */,
F47C3EBE1E62718E00D97449 /* BattleCommand.swift in Sources */,
F47C3EB61E60766000D97449 /* BasicMapper.swift in Sources */,
F4D05BD01E0D667600688D66 /* BookmarkListViewController.swift in Sources */,
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ F42546931EFBE0D300BE297E /* EquitType.swift in Sources */,
F4CF25DF1E3A1D4100C02A66 /* EnhancementListItem.swift in Sources */,
F4CF25DC1E376D6600C02A66 /* main.swift in Sources */,
);
// swiftlint:disable force_cast
return NSApplication.shared().delegate as! AppDelegate
}
- let appNameForUserAgent: String = "Version/10.0.3 Safari/602.4.8"
+// let appNameForUserAgent: String = "Version/10.0.3 Safari/603.2.4"
+ let appNameForUserAgent: String = "KCD(1.9b11) is not Safari/603.2.4"
let fleetManager: FleetManager = FleetManager()
let windowManager = WindowManager()
private var browserWindowControllers: [ExternalBrowserWindowController] = []
private var updaters: [() -> Void] = []
fileprivate var logedJSONViewWindowController: JSONViewWindowController?
- private var isLoadedMainMenu = false
+ private var didLoadedMainMenu = false
var screenShotSaveDirectory: String {
get {
// MARK: - Function
override func awakeFromNib() {
- if isLoadedMainMenu { return }
- isLoadedMainMenu = true
+ if didLoadedMainMenu { return }
+ didLoadedMainMenu = true
ValueTransformerRegister.registerAll()
UserDefaults.registerAllDefaults()
import Foundation
+private func supportDirName() -> String {
+ let main = Bundle.main
+ return main.bundleIdentifier
+ ?? main.infoDictionary?["CFBundleName"] as? String
+ ?? main.infoDictionary?["CFBundleExecutable"] as? String
+ ?? "UnknownAppliation"
+}
+
struct ApplicationDirecrories {
- static let support: URL = {
- let url = FileManager
- .default
- .urls(for: .applicationSupportDirectory,
- in: .userDomainMask).last ?? URL(fileURLWithPath: NSHomeDirectory())
- return url.appendingPathComponent("com.masakih.KCD")
- }()
- static let documents = FileManager
- .default
- .urls(for: .documentDirectory,
- in: .userDomainMask).last ?? URL(fileURLWithPath: NSHomeDirectory())
- static let pictures = FileManager
- .default
- .urls(for: .picturesDirectory,
- in: .userDomainMask).last ?? URL(fileURLWithPath: NSHomeDirectory())
+ static let support = searchedURL(for: .applicationSupportDirectory)
+ .appendingPathComponent(supportDirName())
+
+ static let documents = searchedURL(for: .documentDirectory)
+
+ static let pictures = searchedURL(for: .picturesDirectory)
+
+ private static func searchedURL(for directory: FileManager.SearchPathDirectory) -> URL {
+
+ return FileManager.default.urls(for: directory,
+ in: .userDomainMask)
+ .last
+ ?? URL(fileURLWithPath: NSHomeDirectory())
+ }
}
func checkDirectory(_ url: URL) -> Bool {
<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment identifier="macosx"/>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</customView>
<matrix verticalHuggingPriority="750" allowsEmptySelection="NO" autorecalculatesCellSize="YES" id="EJt-sg-Fk4">
- <rect key="frame" x="0.0" y="262" width="264" height="18"/>
+ <rect key="frame" x="0.0" y="262" width="256" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
- <size key="cellSize" width="63" height="18"/>
+ <size key="cellSize" width="64" height="18"/>
<buttonCell key="prototype" type="radio" title="Radio" imagePosition="left" alignment="left" controlSize="small" inset="2" id="NXm-mD-8zQ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="smallSystem"/>
<binding destination="MYB-8m-P41" name="selectedTag" keyPath="selection.fleetNumber" id="M2a-NH-QOd"/>
</connections>
</matrix>
- <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="GMS-aA-S7M">
- <rect key="frame" x="261" y="263" width="201" height="17"/>
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" allowsCharacterPickerTouchBarItem="YES" id="GMS-aA-S7M">
+ <rect key="frame" x="255" y="263" width="201" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="【 てすとてすとてすとてすと 】" id="pRI-rA-JGD">
<font key="font" metaFont="system"/>
</binding>
</connections>
</textField>
- <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" id="1Fs-NZ-L8n">
- <rect key="frame" x="461" y="264" width="48" height="14"/>
+ <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" misplaced="YES" setsMaxLayoutWidthAtFirstLayout="YES" allowsCharacterPickerTouchBarItem="YES" id="1Fs-NZ-L8n">
+ <rect key="frame" x="456" y="264" width="48" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" title="泊地修理" id="KSI-N3-t1H">
<font key="font" metaFont="smallSystem"/>
</binding>
</connections>
</textField>
- <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="tzQ-Ab-vcB">
- <rect key="frame" x="505" y="264" width="63" height="14"/>
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" allowsCharacterPickerTouchBarItem="YES" id="tzQ-Ab-vcB">
+ <rect key="frame" x="500" y="264" width="63" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" placeholderString="" id="cM2-uj-Gqv">
<customFormatter key="formatter" id="S2g-ox-pjV" customClass="TimerCountFormatter" customModule="KCD"/>
</textFieldCell>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont11" id="D3c-11-4qp"/>
+ <binding destination="MYB-8m-P41" name="value" keyPath="selection.repairTime" id="rHD-2V-hJy"/>
<binding destination="MYB-8m-P41" name="hidden" keyPath="selection.repairable" id="6p5-99-GUi">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
- <binding destination="MYB-8m-P41" name="value" keyPath="selection.repairTime" id="rHD-2V-hJy"/>
</connections>
</textField>
- <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="2jU-EL-j7s">
- <rect key="frame" x="569" y="264" width="19" height="14"/>
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" allowsCharacterPickerTouchBarItem="YES" id="2jU-EL-j7s">
+ <rect key="frame" x="564" y="264" width="19" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Lv." id="w4a-v0-R0W">
<font key="font" metaFont="smallSystem"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
- <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="UYu-21-82G">
- <rect key="frame" x="585" y="264" width="24" height="14"/>
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" allowsCharacterPickerTouchBarItem="YES" id="UYu-21-82G">
+ <rect key="frame" x="580" y="264" width="24" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="999" id="ohp-DY-8Su">
<numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="lBM-sa-I2G"/>
<binding destination="MYB-8m-P41" name="value" keyPath="selection.totalLevel" id="C5N-Lk-Z6F"/>
</connections>
</textField>
- <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="psc-iQ-sNL">
- <rect key="frame" x="610" y="264" width="19" height="14"/>
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" allowsCharacterPickerTouchBarItem="YES" id="psc-iQ-sNL">
+ <rect key="frame" x="605" y="264" width="19" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Dr." id="Eso-k3-sCk">
<font key="font" metaFont="smallSystem"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
- <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="UWt-im-IIK">
- <rect key="frame" x="626" y="264" width="18" height="14"/>
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" allowsCharacterPickerTouchBarItem="YES" id="UWt-im-IIK">
+ <rect key="frame" x="621" y="264" width="18" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="99" id="I6D-UD-3HA">
<numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="edz-Bk-fZV"/>
<binding destination="MYB-8m-P41" name="value" keyPath="selection.totalDrums" id="SpP-yR-CpU"/>
</connections>
</textField>
- <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="f8W-G4-mOr">
- <rect key="frame" x="647" y="264" width="30" height="14"/>
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" allowsCharacterPickerTouchBarItem="YES" id="f8W-G4-mOr">
+ <rect key="frame" x="638" y="264" width="30" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="索敵:" id="vA3-9F-FLk">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
+ <connections>
+ <outlet property="menu" destination="MVi-nq-KTn" id="eJf-LQ-qdD"/>
+ </connections>
</textField>
- <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="mUy-1k-ALk">
- <rect key="frame" x="674" y="263" width="29" height="17"/>
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" allowsCharacterPickerTouchBarItem="YES" id="mUy-1k-ALk">
+ <rect key="frame" x="665" y="263" width="38" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
- <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="999" id="HeX-Wd-ikA">
- <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="ntt-Mj-4hA"/>
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="-30.6" id="HeX-Wd-ikA">
+ <numberFormatter key="formatter" formatterBehavior="custom10_4" usesGroupingSeparator="NO" roundingMode="down" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" maximumFractionDigits="1" id="ntt-Mj-4hA"/>
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<connections>
<binding destination="-3" name="font" keyPath="delegate.monospaceSystemFont13" id="PF0-ou-K6v"/>
<binding destination="MYB-8m-P41" name="value" keyPath="selection.totalSakuteki" id="4Cv-OM-5Cq"/>
+ <outlet property="menu" destination="MVi-nq-KTn" id="gOM-qF-06U"/>
</connections>
</textField>
- <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="ee5-Xk-4iW">
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="ee5-Xk-4iW">
<rect key="frame" x="703" y="264" width="30" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="制空:" id="dS3-tO-y1s">
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
- <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Jhy-EA-ust">
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" id="Jhy-EA-ust">
<rect key="frame" x="730" y="263" width="66" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="999 (999)" id="ytq-FR-96e">
<binding destination="-2" name="contentObject" keyPath="self" id="Ab7-TR-6Tv"/>
</connections>
</objectController>
+ <menu id="MVi-nq-KTn">
+ <items>
+ <menuItem title="合計" id="TZP-Xd-NUJ">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="changeSakutekiCalculator:" target="-2" id="uJh-lF-Rts"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="n49-cg-s7h"/>
+ <menuItem title="判定式 (33) - 1" tag="101" id="9EY-4x-vHD">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="changeSakutekiCalculator:" target="-2" id="Pua-CY-iQK"/>
+ </connections>
+ </menuItem>
+ <menuItem title="判定式 (33) - 3" tag="103" id="wGq-nj-4qv">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="changeSakutekiCalculator:" target="-2" id="bac-3V-Oz4"/>
+ </connections>
+ </menuItem>
+ <menuItem title="判定式 (33) - 4" tag="104" id="bRf-uR-a6S">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="changeSakutekiCalculator:" target="-2" id="3Ld-Mc-xMJ"/>
+ </connections>
+ </menuItem>
+ <menuItem title="判定式 (33) ..." tag="100" id="ZVj-b0-dsM">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="changeSakutekiCalculator:" target="-2" id="5uy-jT-sQb"/>
+ </connections>
+ </menuItem>
+ </items>
+ <point key="canvasLocation" x="305" y="195"/>
+ </menu>
</objects>
</document>
<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
<action selector="selectView:" target="-1" id="OF1-i2-gu7"/>
</connections>
</menuItem>
+ <menuItem isSeparatorItem="YES" id="PrJ-hR-VPS"/>
+ <menuItem title="SakutekiCalculator" id="CX5-5M-bhh">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <menu key="submenu" title="SakutekiCalculator" id="IW2-De-KIB">
+ <items>
+ <menuItem title="Total" id="VGS-nL-KMm">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="changeSakutekiCalculator:" target="-1" id="17h-aq-gRB"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="3Kl-fr-klK"/>
+ <menuItem title="Formula33_1" tag="101" id="r8d-Rp-kGg">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="changeSakutekiCalculator:" target="-1" id="3UQ-xm-jCG"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Formula33_3" tag="103" id="lsR-ab-DRG">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="changeSakutekiCalculator:" target="-1" id="xjT-R2-c1b"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Formula33_4" tag="104" id="wbG-TI-Ox5">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="changeSakutekiCalculator:" target="-1" id="sqd-Dg-NDO"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Formula33 ..." tag="100" id="z7j-YG-JPw">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="changeSakutekiCalculator:" target="-1" id="c21-fb-5bo"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
<menuItem isSeparatorItem="YES" id="k5I-au-tcW"/>
<menuItem title="Select Next Fleet" keyEquivalent="" id="zEh-tr-mhX">
<modifierMask key="keyEquivalentModifierMask"/>
static let reorderToLeftToRight = #selector(BroserWindowController.reorderToLeftToRight(_:))
static let selectNextFleet = #selector(BroserWindowController.selectNextFleet(_:))
static let selectPreviousFleet = #selector(BroserWindowController.selectPreviousFleet(_:))
+ static let changeSakutekiCalculator = #selector(BroserWindowController.changeSakutekiCalculator(_:))
}
class BroserWindowController: NSWindowController {
@IBAction func selectPreviousFleet(_ sender: AnyObject?) {
fleetViewController.selectPreviousFleet(sender)
}
+ @IBAction func changeSakutekiCalculator(_ sender: Any?) {
+ fleetViewController.changeSakutekiCalculator(sender)
+ }
override func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
guard let action: Selector = menuItem.action else { return false }
return true
case Selector.toggleAnchorageSize:
return true
+ case Selector.changeSakutekiCalculator:
+ return fleetViewController.validateMenuItem(menuItem)
default:
return false
}
--- /dev/null
+//
+// CalculateConditionPanelController.swift
+// KCD
+//
+// Created by Hori,Masaki on 2017/07/10.
+// Copyright © 2017年 Hori,Masaki. All rights reserved.
+//
+
+import Cocoa
+
+class CalculateConditionPanelController: NSWindowController {
+
+ override var windowNibName: String {
+ return String(describing: type(of: self))
+ }
+
+ dynamic var condition: Double = 1
+
+ private var originalCondition: Double = 1
+
+ @IBAction func ok(_ sender: Any?) {
+
+ exitModal()
+ }
+
+ @IBAction func cancel(_ sender: Any?) {
+
+ condition = originalCondition
+
+ exitModal()
+ }
+
+ private func exitModal() {
+
+ self.window?.sheetParent?.endSheet(self.window!)
+ }
+
+ func beginModal(for mainWindow: NSWindow, completeHander handler: @escaping (Double) -> Void) {
+
+ guard let window = self.window else { return }
+
+ mainWindow.beginSheet(window) { _ in
+
+ handler(self.condition)
+ }
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct">
+ <dependencies>
+ <deployment identifier="macosx"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/>
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+ </dependencies>
+ <objects>
+ <customObject id="-2" userLabel="File's Owner" customClass="CalculateConditionPanelController" customModule="KCD" customModuleProvider="target">
+ <connections>
+ <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
+ </connections>
+ </customObject>
+ <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+ <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+ <window title="分岐点係数の設定" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
+ <windowStyleMask key="styleMask" titled="YES"/>
+ <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+ <rect key="contentRect" x="196" y="240" width="212" height="101"/>
+ <rect key="screenRect" x="0.0" y="0.0" width="1680" height="1050"/>
+ <view key="contentView" wantsLayer="YES" misplaced="YES" id="se5-gp-TjO">
+ <rect key="frame" x="0.0" y="0.0" width="212" height="101"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <subviews>
+ <button verticalHuggingPriority="750" misplaced="YES" id="yl3-A9-Cwb">
+ <rect key="frame" x="117" y="13" width="81" height="32"/>
+ <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+ <buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="XE5-YR-xdE">
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+ <font key="font" metaFont="system"/>
+ <string key="keyEquivalent" base64-UTF8="YES">
+DQ
+</string>
+ </buttonCell>
+ <connections>
+ <action selector="ok:" target="-2" id="lX7-Rj-dVv"/>
+ </connections>
+ </button>
+ <button verticalHuggingPriority="750" misplaced="YES" id="5iS-oe-pNi">
+ <rect key="frame" x="36" y="13" width="81" height="32"/>
+ <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+ <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="RQK-YR-dbi">
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+ <font key="font" metaFont="system"/>
+ <string key="keyEquivalent">.</string>
+ <modifierMask key="keyEquivalentModifierMask" command="YES"/>
+ </buttonCell>
+ <connections>
+ <action selector="cancel:" target="-2" id="TuA-cY-XGF"/>
+ </connections>
+ </button>
+ <textField verticalHuggingPriority="750" misplaced="YES" allowsCharacterPickerTouchBarItem="NO" id="4il-F8-oMF">
+ <rect key="frame" x="96" y="59" width="96" height="22"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" drawsBackground="YES" id="njn-hu-iga">
+ <numberFormatter key="formatter" formatterBehavior="custom10_4" localizesFormat="NO" allowsFloats="NO" usesGroupingSeparator="NO" lenient="YES" groupingSize="0" minimumIntegerDigits="1" maximumIntegerDigits="4" maximumFractionDigits="3" id="UiU-86-rhn">
+ <real key="minimum" value="0.0"/>
+ </numberFormatter>
+ <font key="font" metaFont="system"/>
+ <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ <connections>
+ <binding destination="-2" name="value" keyPath="condition" id="KBo-g4-yK8"/>
+ </connections>
+ </textField>
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" allowsCharacterPickerTouchBarItem="NO" id="ddV-eB-QYO">
+ <rect key="frame" x="18" y="62" width="77" height="17"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="分岐点係数:" id="yca-Jz-0Pq">
+ <font key="font" metaFont="system"/>
+ <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ </textField>
+ </subviews>
+ </view>
+ <connections>
+ <outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
+ </connections>
+ <point key="canvasLocation" x="5" y="77.5"/>
+ </window>
+ </objects>
+</document>
import Cocoa
-@objc
-enum EquipmentType: Int {
- case unknown = -1
-
- case smallCaliberMainGun = 1
- case mediumCaliberMainGun = 2
- case largeCaliberMainGun = 3
- case secondaryGun = 4
- case torpedo = 5
- case fighter = 6
- case bomber = 7
- case attacker = 8
- case searcher = 9
- case airplaneSearcher = 10
- case airplaneBomber = 11
- case smallRadar = 12
- case largeRadar = 13
- case sonar = 14
- case depthCharge = 15
- case armorPiercingShell = 16
- case EngineImprovement = 17
- case AAShell = 18
- case APShell = 19
- case vt = 20
- case antiAircraftGun = 21
- case specialSubmarine = 22
- case damageControl = 23
- case LandingCraft = 24
- case autoGyro = 25
- case antiSunmrinerSercher = 26
- case armorPiercingShellMiddle = 27
- case armorPiercingShellLarge = 28
- case searchlight = 29
- case caryer = 30
- case repiarer = 31
- case submarinTorpedo = 32
- case chaf = 33
- case headquaters = 34
- case pilot = 35
- case antiAircraftSystem = 36
- case antiLandSystem = 37
- case largeCaliberMainGunII = 38
- case shipPersonnel = 39
- case largeSonar = 40
- case largeAirplane = 41
- case largeSearchlight = 42
- case onigiri = 43
- case supply = 44
- case airplaneFighter = 45
- case tankShip = 46
- case landAttecker = 47
- case localFighter = 48
-
- case blank01 = 49
- case TransportationMaterial = 50
- case SubmarineEquipment = 51
- case blank04 = 52
- case blank05 = 53
- case blank06 = 54
- case blank07 = 55
-
- case jetFighter = 56
- case jetBomber = 57
- case jetAttacker = 58
- case jetSearcher = 59
-
- case blank08 = 60
- case blank09 = 61
- case blank10 = 62
- case blank11 = 63
- case blank12 = 64
-
- case largeLadarII = 93
- case searcherII = 94
-
- case blank13 = 95
- case blank14 = 96
- case blank15 = 97
- case blank16 = 98
- case blank17 = 99
- case blank18 = 100
-}
-
class EnhancementListItem: NSObject, NSCoding, NSCopying {
let identifier: String
let weekday: Int
--- /dev/null
+//
+// EquitType.swift
+// KCD
+//
+// Created by Hori,Masaki on 2017/06/19.
+// Copyright © 2017年 Hori,Masaki. All rights reserved.
+//
+
+import Foundation
+
+@objc
+enum EquipmentType: Int {
+ case unknown = -1
+
+ case smallCaliberMainGun = 1
+ case mediumCaliberMainGun = 2
+ case largeCaliberMainGun = 3
+ case secondaryGun = 4
+ case torpedo = 5
+ case fighter = 6
+ case bomber = 7
+ case attacker = 8
+ case searcher = 9
+ case airplaneSearcher = 10
+ case airplaneBomber = 11
+ case smallRadar = 12
+ case largeRadar = 13
+ case sonar = 14
+ case depthCharge = 15
+ case armorPiercingShell = 16
+ case engineImprovement = 17
+ case aAShell = 18
+ case aPShell = 19
+ case vt = 20
+ case antiAircraftGun = 21
+ case specialSubmarine = 22
+ case damageControl = 23
+ case landingCraft = 24
+ case autoGyro = 25
+ case antiSunmrinerSercher = 26
+ case armorPiercingShellMiddle = 27
+ case armorPiercingShellLarge = 28
+ case searchlight = 29
+ case caryer = 30
+ case repiarer = 31
+ case submarinTorpedo = 32
+ case chaf = 33
+ case headquaters = 34
+ case pilot = 35
+ case antiAircraftSystem = 36
+ case antiLandSystem = 37
+ case largeCaliberMainGunII = 38
+ case shipPersonnel = 39
+ case largeSonar = 40
+ case largeAirplane = 41
+ case largeSearchlight = 42
+ case onigiri = 43
+ case supply = 44
+ case airplaneFighter = 45
+ case tankShip = 46
+ case landAttecker = 47
+ case localFighter = 48
+
+// case blank01 = 49
+ case transportationMaterial = 50
+ case submarineEquipment = 51
+// case blank04 = 52
+// case blank05 = 53
+// case blank06 = 54
+// case blank07 = 55
+
+ case jetFighter = 56
+ case jetBomber = 57
+ case jetAttacker = 58
+ case jetSearcher = 59
+
+// case blank08 = 60
+// case blank09 = 61
+// case blank10 = 62
+// case blank11 = 63
+// case blank12 = 64
+
+ case largeLadarII = 93
+ case searcherII = 94
+
+// case blank13 = 95
+// case blank14 = 96
+// case blank15 = 97
+// case blank16 = 98
+// case blank17 = 99
+// case blank18 = 100
+}
case leftToRight = 1
}
+ enum SakutekiType: Int {
+ case adding = 0
+
+ case formula33 = 100
+ case formula33_1 = 101
+ case formula33_3 = 103
+ case formula33_4 = 104
+
+ }
+
static let oldStyleFleetViewHeight: CGFloat = 128.0
static let detailViewHeight: CGFloat = 288.0
static let heightDifference: CGFloat = detailViewHeight - oldStyleFleetViewHeight
private let shipKeys = ["ship_0", "ship_1", "ship_2", "ship_3", "ship_4", "ship_5"]
private let type: FleetViewType
private let fleetController = NSObjectController()
- private let shipObserveKeys = ["sakuteki_0", "seiku", "totalSeiku", "lv", "totalDrums"]
+ private let shipObserveKeys = ["seiku", "lv", "equippedItem"]
init?(viewType: FleetViewType) {
type = viewType
case .miniVierticalType: return 0.0
}
}
- var totalSakuteki: Int { return ships.reduce(0) { $0 + $1.sakuteki_0 } }
+ var sakutekiCalculator: SakutekiCalculator = SimpleCalculator() {
+ didSet {
+ switch sakutekiCalculator {
+ case _ as SimpleCalculator:
+ UserDefaults.standard.sakutekiCalclationSterategy = .total
+ case let f as Formula33:
+ UserDefaults.standard.sakutekiCalclationSterategy = .formula33
+ UserDefaults.standard.formula33Factor = Double(f.condition)
+ default: ()
+ }
+ }
+ }
+ var totalSakuteki: Double { return sakutekiCalculator.calculate(ships) }
var totalSeiku: Int { return ships.reduce(0) { $0 + $1.seiku } }
var totalCalclatedSeiku: Int { return ships.reduce(0) { $0 + $1.totalSeiku } }
var totalLevel: Int { return ships.reduce(0) { $0 + $1.lv } }
var totalDrums: Int { return ships.reduce(0) { $0 + $1.totalDrums } }
+
fileprivate var ships: [Ship] = [] {
willSet {
ships.forEach { ship in
override func viewDidLoad() {
super.viewDidLoad()
+ switch UserDefaults.standard.sakutekiCalclationSterategy {
+ case .total:
+ sakutekiCalculator = SimpleCalculator()
+ case .formula33:
+ let factor = UserDefaults.standard.formula33Factor
+ sakutekiCalculator = Formula33(Int(factor))
+ }
+
fleetController.bind("content", to:self, withKeyPath:#keyPath(fleet), options:nil)
fleetController.addObserver(self, forKeyPath:"selection.name", context:nil)
shipKeys.forEach {
buildAnchorageRepairHolder()
- [NSView?]()
- .appended { placeholder01 }
- .appended { placeholder02 }
- .appended { placeholder03 }
- .appended { placeholder04 }
- .appended { placeholder05 }
- .appended { placeholder06 }
+ [placeholder01, placeholder02, placeholder03,
+ placeholder04, placeholder05, placeholder06]
.enumerated()
.forEach {
guard let view = $0.element else { return }
+
let detail = details[$0.offset]
detail.view.frame = view.frame
detail.view.autoresizingMask = view.autoresizingMask
if let keyPath = keyPath {
if context == &shipsContext {
switch keyPath {
- case "sakuteki_0":
+ case "equippedItem":
notifyChangeValue(forKey: #keyPath(totalSakuteki))
+ notifyChangeValue(forKey: #keyPath(totalDrums))
case "seiku":
notifyChangeValue(forKey: #keyPath(totalSeiku))
- case "totalSeiku":
- notifyChangeValue(forKey: #keyPath(totalCalclatedSeiku))
case "lv":
notifyChangeValue(forKey: #keyPath(totalLevel))
- case "totalDrums":
- notifyChangeValue(forKey: #keyPath(totalDrums))
default: break
}
return
fleetNumber = prev > 0 ? prev : 4
}
+ @IBAction func changeSakutekiCalculator(_ sender: Any?) {
+
+ guard let menuItem = sender as? NSMenuItem
+ else { return }
+
+ switch menuItem.tag {
+ case 0:
+ sakutekiCalculator = SimpleCalculator()
+ case 101...199:
+ sakutekiCalculator = Formula33(menuItem.tag - 100)
+ case 100:
+ askCalcutaionTurnPoint()
+ default: return
+ }
+
+ notifyChangeValue(forKey: #keyPath(totalSakuteki))
+ }
+
+ private func askCalcutaionTurnPoint() {
+
+ guard let window = self.view.window else { return }
+
+ let current = (sakutekiCalculator as? Formula33)?.condition ?? 1
+
+ let wc = CalculateConditionPanelController()
+ wc.condition = Double(current)
+ wc.beginModal(for: window) {
+
+ self.sakutekiCalculator = Formula33(Int($0))
+
+ self.notifyChangeValue(forKey: #keyPath(totalSakuteki))
+ }
+ }
+
private func setupShips() {
let array: [Ship?] = (0..<6).map { fleet?[$0] }
zip(details, array).forEach { $0.0.ship = $0.1 }
ships = array.flatMap { $0 }
- [String]()
- .appended { #keyPath(totalSakuteki) }
- .appended { #keyPath(totalSeiku) }
- .appended { #keyPath(totalCalclatedSeiku) }
- .appended { #keyPath(totalLevel) }
- .appended { #keyPath(totalDrums) }
- .appended { #keyPath(repairable) }
+ [#keyPath(totalSakuteki), #keyPath(totalSeiku), #keyPath(totalCalclatedSeiku),
+ #keyPath(totalLevel), #keyPath(totalDrums), #keyPath(repairable)]
.forEach { notifyChangeValue(forKey: $0) }
}
}
extension FleetViewController {
+
+ override func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
+
+ guard let action = menuItem.action
+ else { return false }
+
+ switch action {
+
+ case #selector(changeSakutekiCalculator(_:)):
+
+ if let _ = sakutekiCalculator as? SimpleCalculator {
+
+ menuItem.state = menuItem.tag == 0 ? NSOnState : NSOffState
+ return true
+
+ } else if let sakuObj = sakutekiCalculator as? Formula33 {
+
+ let cond = 100 + sakuObj.condition
+
+ menuItem.state = menuItem.tag == cond ? NSOnState : NSOffState
+ return true
+ }
+
+ default: ()
+ }
+
+ return false
+ }
+}
+
+extension FleetViewController {
private func reorder(order: [Int]) {
guard order.count == 6 else {
print("FleetViewController: order count is not 6.")
--- /dev/null
+//
+// SakutekiCalculator.swift
+// KCD
+//
+// Created by Hori,Masaki on 2017/06/18.
+// Copyright © 2017年 Hori,Masaki. All rights reserved.
+//
+
+import Foundation
+
+protocol SakutekiCalculator {
+ func calculate(_ ships: [Ship]) -> Double
+}
+
+class SimpleCalculator: SakutekiCalculator {
+ func calculate(_ ships: [Ship]) -> Double {
+ return Double(ships.reduce(0) { $0.0 + $0.1.sakuteki_0 })
+ }
+}
+
+class Formula33: SakutekiCalculator {
+
+ let condition: Int
+
+ init(_ condition: Int = 1) {
+ self.condition = condition
+ }
+
+ private func printShipData(_ ship: Ship) {
+
+ let shipData = "\(ship.name)\t\(normalSakuteki(ship))"
+ let itemNames = ship
+ .equippedItem
+ .array
+ .flatMap { $0 as? SlotItem }
+ .reduce("") {
+
+ let saku = $0.1.master_slotItem.saku ?? 0
+ let ratio = typeRatio($0.1)
+ let bounus = levelBounus($0.1)
+ let culcSaku = ratio * (Double(saku) + bounus)
+
+ return $0.0 + "\n\t\($0.1.name)\tLv.\($0.1.level)\t\t\(saku)\t\(ratio)\t\(bounus)\t\(culcSaku)"
+ }
+
+ print("\(shipData)\(itemNames)\n")
+
+ }
+
+ func calculate(_ ships: [Ship]) -> Double {
+
+ Debug.excute(level: .debug) {
+ ships.forEach(printShipData)
+ }
+
+ let saku1 = ships
+ .map(normalSakuteki)
+ .map { sqrt($0) }
+ .reduce(0, +)
+
+ let saku2 = ships
+ .map(equipsSakuteki)
+ .reduce(0, +)
+
+ let saku3 = shireiSakuteki()
+
+ let saku4 = 2 * (6 - ships.count)
+
+ return saku1 + saku2 - saku3 + Double(saku4)
+ }
+
+ private func normalSakuteki(_ ship: Ship) -> Double {
+
+ let eqSakuteki = ship
+ .equippedItem
+ .array
+ .flatMap { $0 as? SlotItem }
+ .flatMap { $0.master_slotItem.saku as? Double }
+ .reduce(0, +)
+ return Double(ship.sakuteki_0) - eqSakuteki
+ }
+
+ private func equipsSakuteki(_ ship: Ship) -> Double {
+
+ let saku = ship
+ .equippedItem
+ .array
+ .flatMap { $0 as? SlotItem }
+ .map(equipSakuteki)
+ .reduce(0, +)
+
+ return Double(condition) * saku
+ }
+
+ private func equipSakuteki(_ item: SlotItem) -> Double {
+
+ guard let saku = item.master_slotItem.saku as? Double else { return 0 }
+
+ let lvBounus = levelBounus(item)
+
+ let ratio = typeRatio(item)
+
+ return Double(condition) * ratio * (saku + lvBounus)
+ }
+ private func typeRatio(_ item: SlotItem) -> Double {
+
+ let type2 = item.master_slotItem.type_2
+ guard let eqType = EquipmentType(rawValue: type2)
+ else { return 1 }
+
+ switch eqType {
+ case .fighter: return 0.6
+ case .bomber: return 0.6
+ case .attacker: return 0.8
+ case .searcher: return 1
+ case .airplaneSearcher: return 1.2
+ case .airplaneBomber: return 1.1
+ case .smallRadar: return 0.6
+ case .largeRadar: return 0.6
+ case .antiSunmrinerSercher: return 0.6
+ case .searchlight: return 0.6
+ case .headquaters: return 0.6
+ case .pilot: return 0.6
+ case .shipPersonnel: return 0.6
+ case .largeSonar: return 0.6
+ case .largeAirplane: return 0.6
+ case .largeSearchlight: return 0.6
+ case .airplaneFighter: return 0.6
+ case .searcherII: return 1
+ case .jetBomber: return 0.6
+ default: return 0
+ }
+ }
+ private func levelBounus(_ item: SlotItem) -> Double {
+
+ let level = item.level
+
+ let ratio = levelRatio(item)
+
+ return ratio * sqrt(Double(level))
+ }
+ private func levelRatio(_ item: SlotItem) -> Double {
+
+ let type2 = item.master_slotItem.type_2
+ guard let eqType = EquipmentType(rawValue: type2)
+ else { return 1 }
+
+ switch eqType {
+ case .smallRadar: return 1.25
+ case .largeRadar: return 1.4
+ case .airplaneSearcher, .searcher: return 1.2
+ default: return 0
+ }
+ }
+
+ private func shireiSakuteki() -> Double {
+
+ guard let basic = ServerDataStore.default.basic()
+ else { return 0 }
+
+ return ceil(0.4 * Double(basic.level))
+ }
+
+}
return (0...4).map(normalSeiku).map { Int($0) }.reduce(0, +)
}
- class func keyPathsForValuesAffectingExtraSeiku() -> Set<String> {
- return ["seiku"]
- }
- dynamic var extraSeiku: Int {
+ var extraSeiku: Int {
return (0...4).map(extraSeiku).map { Int($0) }.reduce(0, +)
}
class func keyPathsForValuesAffectingTotalSeiku() -> Set<String> {
- return ["seiku", "extraSeiku"]
+ return ["seiku"]
}
- dynamic var totalSeiku: Int {
+ var totalSeiku: Int {
return (0...4).map(seiku).reduce(0, +)
}
- class func keyPathsForValuesAffectingTotalDrums() -> Set<String> {
- return ["slot_0", "slot_1", "slot_2", "slot_3", "slot_4"]
- }
- dynamic var totalDrums: Int {
+ var totalDrums: Int {
return (0...4).flatMap(slotItem).filter { $0.slotitem_id == 75 }.count
}
.searcherII]
static let radarType: [EquipmentType] = [.smallRadar, .largeRadar,
.sonar, .depthCharge,
- .SubmarineEquipment]
+ .submarineEquipment]
static let otherType: [EquipmentType] = {
return allType
.filter { !canonType.contains($0) }
"screenshotEditorColumnCount": 2,
"cleanSiceDays": 90,
"notifyTimeSignal": false,
- "notifyTimeBeforeTimeSignal": 5
+ "notifyTimeBeforeTimeSignal": 5,
+ "formula33Factor": 1.0
]
)
}
set { set(newValue, forKey: "playNotifyTimeSignalSound") }
}
+ // MARK: - Sakuteki Calculate
+ enum SakutekiCalclationSterategy: Int {
+ case total
+ case formula33
+ }
+ var sakutekiCalclationSterategy: SakutekiCalclationSterategy {
+ get {
+ let value = integer(forKey: "sakutekiCalclationSterategy")
+ return SakutekiCalclationSterategy(rawValue: value) ?? .total
+ }
+ set { set(newValue.rawValue, forKey: "sakutekiCalclationSterategy") }
+ }
+ var formula33Factor: Double {
+ get { return double(forKey: "formula33Factor") }
+ set { set(newValue, forKey: "formula33Factor") }
+ }
+
// MARK: - Debug print
var degugPrintLevel: Debug.Level {
return Debug.Level(rawValue: integer(forKey: "DebugPrintLevel")) ?? .none
"tuF-Zr-OZU.title" = "スクリーンショットボタンの大きさを切り替え";
+"CX5-5M-bhh.title" = "索敵値計算式";
+"VGS-nL-KMm.title" = "合計";
+"r8d-Rp-kGg.title" = "判定式 (33) - 1";
+"lsR-ab-DRG.title" = "判定式 (33) - 3";
+"wbG-TI-Ox5.title" = "判定式 (33) - 4";
+"z7j-YG-JPw.title" = "判定式 (33) ...";
+
+
+
+
+