Revisión | 646b3d68cf4350de634ac4a309975d10f9041b82 (tree) |
---|---|
Tiempo | 2018-04-18 22:28:50 |
Autor | masakih <masakih@user...> |
Commiter | masakih |
コーディング規約を変更した
@@ -164,7 +164,7 @@ | ||
164 | 164 | F4EF18A71B4D36E60021BF8D /* Project object */ = { |
165 | 165 | isa = PBXProject; |
166 | 166 | attributes = { |
167 | - LastUpgradeCheck = 0810; | |
167 | + LastUpgradeCheck = 0930; | |
168 | 168 | ORGANIZATIONNAME = "Hori,Masaki"; |
169 | 169 | TargetAttributes = { |
170 | 170 | F4EF18AE1B4D36E60021BF8D = { |
@@ -285,14 +285,22 @@ | ||
285 | 285 | CLANG_CXX_LIBRARY = "libc++"; |
286 | 286 | CLANG_ENABLE_MODULES = YES; |
287 | 287 | CLANG_ENABLE_OBJC_ARC = YES; |
288 | + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | |
288 | 289 | CLANG_WARN_BOOL_CONVERSION = YES; |
290 | + CLANG_WARN_COMMA = YES; | |
289 | 291 | CLANG_WARN_CONSTANT_CONVERSION = YES; |
292 | + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | |
290 | 293 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; |
291 | 294 | CLANG_WARN_EMPTY_BODY = YES; |
292 | 295 | CLANG_WARN_ENUM_CONVERSION = YES; |
293 | 296 | CLANG_WARN_INFINITE_RECURSION = YES; |
294 | 297 | CLANG_WARN_INT_CONVERSION = YES; |
298 | + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | |
299 | + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; | |
300 | + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | |
295 | 301 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; |
302 | + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | |
303 | + CLANG_WARN_STRICT_PROTOTYPES = YES; | |
296 | 304 | CLANG_WARN_SUSPICIOUS_MOVE = YES; |
297 | 305 | CLANG_WARN_UNREACHABLE_CODE = YES; |
298 | 306 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; |
@@ -333,14 +341,22 @@ | ||
333 | 341 | CLANG_CXX_LIBRARY = "libc++"; |
334 | 342 | CLANG_ENABLE_MODULES = YES; |
335 | 343 | CLANG_ENABLE_OBJC_ARC = YES; |
344 | + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | |
336 | 345 | CLANG_WARN_BOOL_CONVERSION = YES; |
346 | + CLANG_WARN_COMMA = YES; | |
337 | 347 | CLANG_WARN_CONSTANT_CONVERSION = YES; |
348 | + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | |
338 | 349 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; |
339 | 350 | CLANG_WARN_EMPTY_BODY = YES; |
340 | 351 | CLANG_WARN_ENUM_CONVERSION = YES; |
341 | 352 | CLANG_WARN_INFINITE_RECURSION = YES; |
342 | 353 | CLANG_WARN_INT_CONVERSION = YES; |
354 | + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | |
355 | + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; | |
356 | + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | |
343 | 357 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; |
358 | + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | |
359 | + CLANG_WARN_STRICT_PROTOTYPES = YES; | |
344 | 360 | CLANG_WARN_SUSPICIOUS_MOVE = YES; |
345 | 361 | CLANG_WARN_UNREACHABLE_CODE = YES; |
346 | 362 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; |
@@ -14,6 +14,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { | ||
14 | 14 | var mainWindowController: KCBFOMainWindowController! |
15 | 15 | |
16 | 16 | func applicationDidFinishLaunching(_ aNotification: Notification) { |
17 | + | |
17 | 18 | mainWindowController = KCBFOMainWindowController.makeInstance() |
18 | 19 | mainWindowController.showWindow(nil) |
19 | 20 | } |
@@ -19,11 +19,13 @@ class KCBFOMainWindowController: NSWindowController { | ||
19 | 19 | let gamePageURL = "http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/" |
20 | 20 | |
21 | 21 | class func makeInstance() -> KCBFOMainWindowController { |
22 | + | |
22 | 23 | return KCBFOMainWindowController(windowNibName: "KCBFOMainWindowController") |
23 | 24 | } |
24 | 25 | |
25 | 26 | |
26 | 27 | override func windowDidLoad() { |
28 | + | |
27 | 29 | super.windowDidLoad() |
28 | 30 | |
29 | 31 | let pref = WKPreferences() |
@@ -40,7 +42,7 @@ class KCBFOMainWindowController: NSWindowController { | ||
40 | 42 | let script = WKUserScript(source: js, injectionTime: .atDocumentEnd, forMainFrameOnly: false) |
41 | 43 | config.userContentController.addUserScript(script) |
42 | 44 | |
43 | - let frame = CGRect(x: 0, y: 0, width: 2000, height: 2_000) | |
45 | + let frame = CGRect(x: 0, y: 0, width: 2_000, height: 2_000) | |
44 | 46 | webView = WKWebView(frame: frame, configuration: config) |
45 | 47 | webView.navigationDelegate = self |
46 | 48 |
@@ -56,6 +58,7 @@ class KCBFOMainWindowController: NSWindowController { | ||
56 | 58 | } |
57 | 59 | |
58 | 60 | func loadURLString(urlString: String) { |
61 | + | |
59 | 62 | guard let url = URL(string: urlString) else { return } |
60 | 63 | let req = URLRequest(url: url) |
61 | 64 | webView.load(req) |
@@ -63,14 +66,18 @@ class KCBFOMainWindowController: NSWindowController { | ||
63 | 66 | |
64 | 67 | |
65 | 68 | @IBAction func reloadContent(_ sender: AnyObject?) { |
66 | - guard let _ = webView.url | |
67 | - else { | |
69 | + | |
70 | + guard let _ = webView.url else { | |
71 | + | |
68 | 72 | loadURLString(urlString: gamePageURL) |
73 | + | |
69 | 74 | return |
70 | 75 | } |
71 | 76 | // ゲームページでない場合はゲームページを表示する |
72 | 77 | if let url = webView?.url, url.absoluteString != gamePageURL { |
78 | + | |
73 | 79 | loadURLString(urlString: gamePageURL) |
80 | + | |
74 | 81 | return |
75 | 82 | } |
76 | 83 |
@@ -80,11 +87,13 @@ class KCBFOMainWindowController: NSWindowController { | ||
80 | 87 | |
81 | 88 | } |
82 | 89 | @IBAction func reloadAndRecache(_ sender: AnyObject?) { |
90 | + | |
83 | 91 | URLCache.shared.removeAllCachedResponses() |
84 | 92 | reloadContent(sender) |
85 | 93 | } |
86 | 94 | |
87 | 95 | func adjustFlash() { |
96 | + | |
88 | 97 | clipView.scroll(to: flashTopLeft) |
89 | 98 | } |
90 | 99 |
@@ -99,16 +108,21 @@ class KCBFOMainWindowController: NSWindowController { | ||
99 | 108 | WebMenuItemTagReload] |
100 | 109 | |
101 | 110 | func webView(_ sender: WebView!, contextMenuItemsForElement element: [AnyHashable: Any]!, defaultMenuItems: [AnyObject]!) -> [Any]! { |
111 | + | |
102 | 112 | return defaultMenuItems.flatMap() { |
113 | + | |
103 | 114 | if ignoreTags.contains($0.tag) { |
115 | + | |
104 | 116 | return [] |
105 | 117 | } |
118 | + | |
106 | 119 | return [$0] |
107 | 120 | } |
108 | 121 | } |
109 | 122 | } |
110 | 123 | |
111 | 124 | extension KCBFOMainWindowController: WKNavigationDelegate { |
125 | + | |
112 | 126 | func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { |
113 | 127 | |
114 | 128 | webView.evaluateJavaScript( |
@@ -128,6 +142,7 @@ extension KCBFOMainWindowController: WKNavigationDelegate { | ||
128 | 142 | "dict;"] |
129 | 143 | .reduce("", +) |
130 | 144 | ) { (dict, error) in |
145 | + | |
131 | 146 | error.map { print($0) } |
132 | 147 | |
133 | 148 | guard let param = dict as? [String: Any] else { |
@@ -146,10 +161,13 @@ extension KCBFOMainWindowController: WKNavigationDelegate { | ||
146 | 161 | } |
147 | 162 | guard let top = param["top"] as? Int, |
148 | 163 | let left = param["left"] as? Int, |
149 | - let width = param["width"] as? Int | |
150 | - else { return } | |
164 | + let width = param["width"] as? Int else { | |
165 | + | |
166 | + return | |
167 | + } | |
151 | 168 | |
152 | 169 | DispatchQueue.main.async { [weak self] in |
170 | + | |
153 | 171 | guard let `self` = self else { return } |
154 | 172 | |
155 | 173 | self.flashTopLeft = NSPoint(x: CGFloat(left + (width - 800) / 2), |