艦娘をちゅーちゅーします
Révision | b38cde491eb89907472ec80029316634bf2fe21a (tree) |
---|---|
l'heure | 2017-08-06 16:25:55 |
Auteur | masakih <masakih@user...> |
Commiter | masakih |
とりあえず動くようになった
@@ -13,8 +13,27 @@ | ||
13 | 13 | F4EAFCC51F369E71007B7506 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F4EAFCC31F369E71007B7506 /* Main.storyboard */; }; |
14 | 14 | F4EAFCCD1F36A28C007B7506 /* pickup.rb in Resources */ = {isa = PBXBuildFile; fileRef = F4EAFCCC1F36A28B007B7506 /* pickup.rb */; }; |
15 | 15 | F4EAFCCF1F36B8FE007B7506 /* PickUpSWF.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EAFCCE1F36B8FE007B7506 /* PickUpSWF.swift */; }; |
16 | + F4EAFCD61F36D786007B7506 /* KanColleGraphicDivider in Resources */ = {isa = PBXBuildFile; fileRef = F4EAFCD51F36D786007B7506 /* KanColleGraphicDivider */; }; | |
17 | + F4EAFCE01F36D9E5007B7506 /* ExtractKanmusu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EAFCDF1F36D9E5007B7506 /* ExtractKanmusu.swift */; }; | |
16 | 18 | /* End PBXBuildFile section */ |
17 | 19 | |
20 | +/* Begin PBXContainerItemProxy section */ | |
21 | + F4EAFCDB1F36D7C7007B7506 /* PBXContainerItemProxy */ = { | |
22 | + isa = PBXContainerItemProxy; | |
23 | + containerPortal = F4EAFCD71F36D7C6007B7506 /* KanColleGraphicDivider.xcodeproj */; | |
24 | + proxyType = 2; | |
25 | + remoteGlobalIDString = F44C14B71D84F07300ADE497; | |
26 | + remoteInfo = KanColleGraphicDivider; | |
27 | + }; | |
28 | + F4EAFCDD1F36D7D7007B7506 /* PBXContainerItemProxy */ = { | |
29 | + isa = PBXContainerItemProxy; | |
30 | + containerPortal = F4EAFCD71F36D7C6007B7506 /* KanColleGraphicDivider.xcodeproj */; | |
31 | + proxyType = 1; | |
32 | + remoteGlobalIDString = F44C14B61D84F07300ADE497; | |
33 | + remoteInfo = KanColleGraphicDivider; | |
34 | + }; | |
35 | +/* End PBXContainerItemProxy section */ | |
36 | + | |
18 | 37 | /* Begin PBXFileReference section */ |
19 | 38 | F4EAFCBA1F369E71007B7506 /* ExtractKanMusu.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExtractKanMusu.app; sourceTree = BUILT_PRODUCTS_DIR; }; |
20 | 39 | F4EAFCBD1F369E71007B7506 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; |
@@ -24,6 +43,10 @@ | ||
24 | 43 | F4EAFCC61F369E71007B7506 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; |
25 | 44 | F4EAFCCC1F36A28B007B7506 /* pickup.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = pickup.rb; sourceTree = "<group>"; }; |
26 | 45 | F4EAFCCE1F36B8FE007B7506 /* PickUpSWF.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickUpSWF.swift; sourceTree = "<group>"; }; |
46 | + F4EAFCD21F36D6C2007B7506 /* KanColleGraphicDivider */ = {isa = PBXFileReference; lastKnownFileType = text; name = KanColleGraphicDivider; path = KanColleGraphicDivider/build/Debug/KanColleGraphicDivider; sourceTree = "<group>"; }; | |
47 | + F4EAFCD51F36D786007B7506 /* KanColleGraphicDivider */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; path = KanColleGraphicDivider; sourceTree = BUILT_PRODUCTS_DIR; }; | |
48 | + F4EAFCD71F36D7C6007B7506 /* KanColleGraphicDivider.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = KanColleGraphicDivider.xcodeproj; path = KanColleGraphicDivider/KanColleGraphicDivider.xcodeproj; sourceTree = "<group>"; }; | |
49 | + F4EAFCDF1F36D9E5007B7506 /* ExtractKanmusu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExtractKanmusu.swift; sourceTree = "<group>"; }; | |
27 | 50 | /* End PBXFileReference section */ |
28 | 51 | |
29 | 52 | /* Begin PBXFrameworksBuildPhase section */ |
@@ -40,8 +63,11 @@ | ||
40 | 63 | F4EAFCB11F369E71007B7506 = { |
41 | 64 | isa = PBXGroup; |
42 | 65 | children = ( |
66 | + F4EAFCD71F36D7C6007B7506 /* KanColleGraphicDivider.xcodeproj */, | |
67 | + F4EAFCD51F36D786007B7506 /* KanColleGraphicDivider */, | |
43 | 68 | F4EAFCBC1F369E71007B7506 /* ExtractKanMusu */, |
44 | 69 | F4EAFCBB1F369E71007B7506 /* Products */, |
70 | + F4EAFCD11F36D6C1007B7506 /* Frameworks */, | |
45 | 71 | ); |
46 | 72 | sourceTree = "<group>"; |
47 | 73 | }; |
@@ -60,6 +86,7 @@ | ||
60 | 86 | F4EAFCBD1F369E71007B7506 /* AppDelegate.swift */, |
61 | 87 | F4EAFCBF1F369E71007B7506 /* ViewController.swift */, |
62 | 88 | F4EAFCCE1F36B8FE007B7506 /* PickUpSWF.swift */, |
89 | + F4EAFCDF1F36D9E5007B7506 /* ExtractKanmusu.swift */, | |
63 | 90 | F4EAFCC11F369E71007B7506 /* Assets.xcassets */, |
64 | 91 | F4EAFCC31F369E71007B7506 /* Main.storyboard */, |
65 | 92 | F4EAFCC61F369E71007B7506 /* Info.plist */, |
@@ -67,6 +94,22 @@ | ||
67 | 94 | path = ExtractKanMusu; |
68 | 95 | sourceTree = "<group>"; |
69 | 96 | }; |
97 | + F4EAFCD11F36D6C1007B7506 /* Frameworks */ = { | |
98 | + isa = PBXGroup; | |
99 | + children = ( | |
100 | + F4EAFCD21F36D6C2007B7506 /* KanColleGraphicDivider */, | |
101 | + ); | |
102 | + name = Frameworks; | |
103 | + sourceTree = "<group>"; | |
104 | + }; | |
105 | + F4EAFCD81F36D7C6007B7506 /* Products */ = { | |
106 | + isa = PBXGroup; | |
107 | + children = ( | |
108 | + F4EAFCDC1F36D7C7007B7506 /* KanColleGraphicDivider */, | |
109 | + ); | |
110 | + name = Products; | |
111 | + sourceTree = "<group>"; | |
112 | + }; | |
70 | 113 | /* End PBXGroup section */ |
71 | 114 | |
72 | 115 | /* Begin PBXNativeTarget section */ |
@@ -81,6 +124,7 @@ | ||
81 | 124 | buildRules = ( |
82 | 125 | ); |
83 | 126 | dependencies = ( |
127 | + F4EAFCDE1F36D7D7007B7506 /* PBXTargetDependency */, | |
84 | 128 | ); |
85 | 129 | name = ExtractKanMusu; |
86 | 130 | productName = ExtractKanMusu; |
@@ -114,6 +158,12 @@ | ||
114 | 158 | mainGroup = F4EAFCB11F369E71007B7506; |
115 | 159 | productRefGroup = F4EAFCBB1F369E71007B7506 /* Products */; |
116 | 160 | projectDirPath = ""; |
161 | + projectReferences = ( | |
162 | + { | |
163 | + ProductGroup = F4EAFCD81F36D7C6007B7506 /* Products */; | |
164 | + ProjectRef = F4EAFCD71F36D7C6007B7506 /* KanColleGraphicDivider.xcodeproj */; | |
165 | + }, | |
166 | + ); | |
117 | 167 | projectRoot = ""; |
118 | 168 | targets = ( |
119 | 169 | F4EAFCB91F369E71007B7506 /* ExtractKanMusu */, |
@@ -121,11 +171,22 @@ | ||
121 | 171 | }; |
122 | 172 | /* End PBXProject section */ |
123 | 173 | |
174 | +/* Begin PBXReferenceProxy section */ | |
175 | + F4EAFCDC1F36D7C7007B7506 /* KanColleGraphicDivider */ = { | |
176 | + isa = PBXReferenceProxy; | |
177 | + fileType = "compiled.mach-o.executable"; | |
178 | + path = KanColleGraphicDivider; | |
179 | + remoteRef = F4EAFCDB1F36D7C7007B7506 /* PBXContainerItemProxy */; | |
180 | + sourceTree = BUILT_PRODUCTS_DIR; | |
181 | + }; | |
182 | +/* End PBXReferenceProxy section */ | |
183 | + | |
124 | 184 | /* Begin PBXResourcesBuildPhase section */ |
125 | 185 | F4EAFCB81F369E71007B7506 /* Resources */ = { |
126 | 186 | isa = PBXResourcesBuildPhase; |
127 | 187 | buildActionMask = 2147483647; |
128 | 188 | files = ( |
189 | + F4EAFCD61F36D786007B7506 /* KanColleGraphicDivider in Resources */, | |
129 | 190 | F4EAFCCD1F36A28C007B7506 /* pickup.rb in Resources */, |
130 | 191 | F4EAFCC21F369E71007B7506 /* Assets.xcassets in Resources */, |
131 | 192 | F4EAFCC51F369E71007B7506 /* Main.storyboard in Resources */, |
@@ -141,12 +202,21 @@ | ||
141 | 202 | files = ( |
142 | 203 | F4EAFCC01F369E71007B7506 /* ViewController.swift in Sources */, |
143 | 204 | F4EAFCCF1F36B8FE007B7506 /* PickUpSWF.swift in Sources */, |
205 | + F4EAFCE01F36D9E5007B7506 /* ExtractKanmusu.swift in Sources */, | |
144 | 206 | F4EAFCBE1F369E71007B7506 /* AppDelegate.swift in Sources */, |
145 | 207 | ); |
146 | 208 | runOnlyForDeploymentPostprocessing = 0; |
147 | 209 | }; |
148 | 210 | /* End PBXSourcesBuildPhase section */ |
149 | 211 | |
212 | +/* Begin PBXTargetDependency section */ | |
213 | + F4EAFCDE1F36D7D7007B7506 /* PBXTargetDependency */ = { | |
214 | + isa = PBXTargetDependency; | |
215 | + name = KanColleGraphicDivider; | |
216 | + targetProxy = F4EAFCDD1F36D7D7007B7506 /* PBXContainerItemProxy */; | |
217 | + }; | |
218 | +/* End PBXTargetDependency section */ | |
219 | + | |
150 | 220 | /* Begin PBXVariantGroup section */ |
151 | 221 | F4EAFCC31F369E71007B7506 /* Main.storyboard */ = { |
152 | 222 | isa = PBXVariantGroup; |
@@ -296,6 +366,7 @@ | ||
296 | 366 | F4EAFCCB1F369E71007B7506 /* Release */, |
297 | 367 | ); |
298 | 368 | defaultConfigurationIsVisible = 0; |
369 | + defaultConfigurationName = Release; | |
299 | 370 | }; |
300 | 371 | /* End XCConfigurationList section */ |
301 | 372 | }; |
@@ -689,7 +689,7 @@ | ||
689 | 689 | <pathControl verticalHuggingPriority="750" fixedFrame="YES" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="71Q-c3-4la"> |
690 | 690 | <rect key="frame" x="63" y="132" width="399" height="22"/> |
691 | 691 | <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> |
692 | - <pathCell key="cell" selectable="YES" editable="YES" alignment="left" id="k0s-i9-gmv"> | |
692 | + <pathCell key="cell" selectable="YES" alignment="left" id="k0s-i9-gmv"> | |
693 | 693 | <font key="font" metaFont="system"/> |
694 | 694 | <url key="url" string="file:///Applications/"/> |
695 | 695 | </pathCell> |
@@ -703,12 +703,8 @@ | ||
703 | 703 | <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> |
704 | 704 | </textFieldCell> |
705 | 705 | </textField> |
706 | - <box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="GBd-0D-yCZ"> | |
707 | - <rect key="frame" x="11" y="121" width="451" height="5"/> | |
708 | - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> | |
709 | - </box> | |
710 | 706 | <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="B7G-JY-X3z"> |
711 | - <rect key="frame" x="22" y="98" width="89" height="17"/> | |
707 | + <rect key="frame" x="20" y="97" width="89" height="17"/> | |
712 | 708 | <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> |
713 | 709 | <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="出力フォルダ:" id="vkJ-JL-Cez"> |
714 | 710 | <font key="font" size="13" name=".HiraKakuInterface-W3"/> |
@@ -719,7 +715,7 @@ | ||
719 | 715 | <pathControl verticalHuggingPriority="750" fixedFrame="YES" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gH1-Rc-sXz"> |
720 | 716 | <rect key="frame" x="63" y="70" width="397" height="22"/> |
721 | 717 | <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> |
722 | - <pathCell key="cell" selectable="YES" editable="YES" alignment="left" id="HrL-3G-mlv"> | |
718 | + <pathCell key="cell" selectable="YES" alignment="left" id="HrL-3G-mlv"> | |
723 | 719 | <font key="font" metaFont="system"/> |
724 | 720 | <url key="url" string="file:///Applications/"/> |
725 | 721 | </pathCell> |
@@ -746,10 +742,6 @@ | ||
746 | 742 | <action selector="chooseOutputFOlder:" target="XfG-lQ-9wD" id="Wjd-XM-nE7"/> |
747 | 743 | </connections> |
748 | 744 | </button> |
749 | - <box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="nsa-b3-99H"> | |
750 | - <rect key="frame" x="11" y="59" width="451" height="5"/> | |
751 | - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> | |
752 | - </box> | |
753 | 745 | <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6Iw-pN-vkY"> |
754 | 746 | <rect key="frame" x="353" y="13" width="113" height="32"/> |
755 | 747 | <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> |
@@ -761,6 +753,23 @@ | ||
761 | 753 | <action selector="extract:" target="XfG-lQ-9wD" id="nhf-pF-bQk"/> |
762 | 754 | </connections> |
763 | 755 | </button> |
756 | + <box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="wCq-gn-ahC"> | |
757 | + <rect key="frame" x="13" y="121" width="449" height="5"/> | |
758 | + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> | |
759 | + </box> | |
760 | + <box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="WCG-o6-Xgb"> | |
761 | + <rect key="frame" x="13" y="59" width="449" height="5"/> | |
762 | + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> | |
763 | + </box> | |
764 | + <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Mse-3Q-V9C"> | |
765 | + <rect key="frame" x="20" y="14" width="323" height="33"/> | |
766 | + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> | |
767 | + <textFieldCell key="cell" sendsActionOnEndEditing="YES" title="ちゅーちゅーするとすごく時間がかかるし、Macがうなりだすよ。 それでもちゅーちゅーする?" id="v0k-Ou-jCB"> | |
768 | + <font key="font" metaFont="system"/> | |
769 | + <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> | |
770 | + <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> | |
771 | + </textFieldCell> | |
772 | + </textField> | |
764 | 773 | </subviews> |
765 | 774 | </view> |
766 | 775 | <connections> |
@@ -0,0 +1,48 @@ | ||
1 | +// | |
2 | +// ExtractKanmusu.swift | |
3 | +// ExtractKanMusu | |
4 | +// | |
5 | +// Created by Hori,Masaki on 2017/08/06. | |
6 | +// Copyright © 2017年 Hori,Masaki. All rights reserved. | |
7 | +// | |
8 | + | |
9 | +import Foundation | |
10 | + | |
11 | + | |
12 | +enum ExtractKanmusu: Error { | |
13 | + | |
14 | + case commandNotFound | |
15 | + | |
16 | + case commandError(Int32) | |
17 | +} | |
18 | + | |
19 | +func extractKanmusu(swf: URL, to dir: URL) throws { | |
20 | + | |
21 | + guard let divider = Bundle.main.path(forResource: "KanColleGraphicDivider", ofType: nil) | |
22 | + else { | |
23 | + | |
24 | + throw ExtractKanmusu.commandNotFound | |
25 | + } | |
26 | + | |
27 | + let process = Process() | |
28 | + process.launchPath = divider | |
29 | + | |
30 | + process.arguments = [ | |
31 | + "-o", | |
32 | + "\(dir.path)", | |
33 | + "-c", | |
34 | + "17,19", | |
35 | + swf.path | |
36 | + ] | |
37 | + | |
38 | + process.environment = ["LC_ALL": "ja_JP.utf8"] | |
39 | + | |
40 | + process.launch() | |
41 | + | |
42 | + process.waitUntilExit() | |
43 | + | |
44 | + guard process.terminationStatus == 0 else { | |
45 | + | |
46 | + throw ExtractKanmusu.commandError(process.terminationStatus) | |
47 | + } | |
48 | +} |
@@ -139,7 +139,7 @@ extension ViewController { | ||
139 | 139 | existOriginalDir |
140 | 140 | else { return } |
141 | 141 | |
142 | - guard let destinationDir = cachePathField.url, | |
142 | + guard let destinationDir = outputFolderField.url, | |
143 | 143 | let existDestinationDir = try? destinationDir.checkResourceIsReachable(), |
144 | 144 | existDestinationDir |
145 | 145 | else { return } |
@@ -173,8 +173,46 @@ extension ViewController { | ||
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - | |
177 | - | |
176 | + do { | |
177 | + | |
178 | + let tempURL = originalDir.appendingPathComponent("___temp_chu-chu-_ship___") | |
179 | + let destURL = destinationDir.appendingPathComponent("ちゅーちゅー") | |
180 | + | |
181 | + let swfs = try FileManager.default | |
182 | + .contentsOfDirectory(at: tempURL, includingPropertiesForKeys: nil) | |
183 | + .filter { $0.pathExtension == "swf" } | |
184 | + | |
185 | + let semaphone = DispatchSemaphore(value: 4) | |
186 | + let group = DispatchGroup() | |
187 | + let queue = DispatchQueue(label: "extract", attributes: .concurrent) | |
188 | + | |
189 | + swfs.forEach { swf in | |
190 | + | |
191 | + queue.async(group: group) { | |
192 | + | |
193 | + semaphone.wait() | |
194 | + | |
195 | + do { | |
196 | + | |
197 | + try extractKanmusu(swf: swf, to: destURL) | |
198 | + | |
199 | + } catch { | |
200 | + | |
201 | + print(error) | |
202 | + } | |
203 | + | |
204 | + semaphone.signal() | |
205 | + } | |
206 | + } | |
207 | + | |
208 | + group.wait() | |
209 | + | |
210 | + | |
211 | + } catch { | |
212 | + | |
213 | + print(error) | |
214 | + | |
215 | + } | |
178 | 216 | } |
179 | 217 | |
180 | 218 | @IBAction func extract(_ : Any?) { |