Skip to content

Commit

Permalink
3.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
marzent committed Mar 8, 2022
1 parent 9befccd commit 9345153
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 54 deletions.
12 changes: 6 additions & 6 deletions XIV on Mac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = x86_64;
ARCHS = "$(ARCHS_STANDARD)";
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down Expand Up @@ -433,7 +433,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = x86_64;
ARCHS = "$(ARCHS_STANDARD)";
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down Expand Up @@ -494,7 +494,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 18;
CURRENT_PROJECT_VERSION = 19;
DEVELOPMENT_TEAM = TQJJTJ6364;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -512,7 +512,7 @@
"$(PROJECT_DIR)/XIV\\ on\\ Mac/wine/lib",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 2.99.14;
MARKETING_VERSION = 3.0.0;
PRODUCT_BUNDLE_IDENTIFIER = "dezent.XIV-on-Mac";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -531,7 +531,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 18;
CURRENT_PROJECT_VERSION = 19;
DEVELOPMENT_TEAM = TQJJTJ6364;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -549,7 +549,7 @@
"$(PROJECT_DIR)/XIV\\ on\\ Mac/wine/lib",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 2.99.14;
MARKETING_VERSION = 3.0.0;
PRODUCT_BUNDLE_IDENTIFIER = "dezent.XIV-on-Mac";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@
filePath = "XIV on Mac/Launcher/FFXIVLoginServices.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "263"
endingLineNumber = "263"
startingLineNumber = "257"
endingLineNumber = "257"
landmarkName = "getTempSID(storedSID:cookie:completion:)"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -158,8 +158,8 @@
filePath = "XIV on Mac/Launcher/FFXIVLoginServices.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "298"
endingLineNumber = "298"
startingLineNumber = "292"
endingLineNumber = "292"
landmarkName = "getTempSID(storedSID:cookie:completion:)"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -174,8 +174,8 @@
filePath = "XIV on Mac/Launcher/FFXIVLoginServices.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "289"
endingLineNumber = "289"
startingLineNumber = "283"
endingLineNumber = "283"
landmarkName = "getTempSID(storedSID:cookie:completion:)"
landmarkType = "7">
</BreakpointContent>
Expand Down Expand Up @@ -238,8 +238,8 @@
filePath = "XIV on Mac/Launcher/FFXIVLoginServices.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "302"
endingLineNumber = "302"
startingLineNumber = "296"
endingLineNumber = "296"
landmarkName = "getTempSID(storedSID:cookie:completion:)"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -254,8 +254,8 @@
filePath = "XIV on Mac/Launcher/FFXIVLoginServices.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "294"
endingLineNumber = "294"
startingLineNumber = "288"
endingLineNumber = "288"
landmarkName = "getTempSID(storedSID:cookie:completion:)"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -270,8 +270,8 @@
filePath = "XIV on Mac/Launcher/FFXIVLoginServices.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "290"
endingLineNumber = "290"
startingLineNumber = "284"
endingLineNumber = "284"
landmarkName = "getTempSID(storedSID:cookie:completion:)"
landmarkType = "7">
</BreakpointContent>
Expand Down
10 changes: 9 additions & 1 deletion XIV on Mac/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Cocoa
import Sparkle


@main class AppDelegate: NSObject, NSApplicationDelegate {
@main class AppDelegate: NSObject, NSApplicationDelegate, SPUUpdaterDelegate {
var settingsWinController: NSWindowController?
@IBOutlet private var sparkle: SPUStandardUpdaterController!
@IBOutlet private var actAutoLaunch: NSMenuItem!
Expand All @@ -19,13 +19,21 @@ import Sparkle
let storyboard = NSStoryboard(name: "Main", bundle: nil)
actAutoLaunch.state = ACT.autoLaunch ? .on : .off
bhAutoLaunch.state = ACT.autoLaunchBH ? .on : .off
Util.launch(exec: URL(fileURLWithPath: "/usr/sbin/softwareupdate"), args: ["--install-rosetta"])
sparkle.updater.checkForUpdatesInBackground()
if DXVK.shouldUpdate {
DXVK.install()
}
settingsWinController = storyboard.instantiateController(withIdentifier: "SettingsWindow") as? NSWindowController
Util.make(dir: Wine.xomData.path)
Util.make(dir: Util.cache.path)
SocialIntegration.discord.setPresence()
}

func updaterWillRelaunchApplication(_ updater: SPUUpdater) {
DXVK.shouldUpdate = true
}

func applicationWillTerminate(_ aNotification: Notification) {
Wine.kill()
}
Expand Down
8 changes: 6 additions & 2 deletions XIV on Mac/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,11 @@
</connections>
</customObject>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="yc9-Mt-LbV" customClass="SPUStandardUpdaterController"/>
<customObject id="yc9-Mt-LbV" customClass="SPUStandardUpdaterController">
<connections>
<outlet property="updaterDelegate" destination="Voe-Tx-rLC" id="mXy-u1-5Eq"/>
</connections>
</customObject>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="24" y="1058"/>
Expand Down Expand Up @@ -1360,7 +1364,7 @@ Gw
<items>
<menuItem title="Windows" state="on" id="qRO-Pi-PbC"/>
<menuItem title="Mac" id="8gA-hG-foX"/>
<menuItem title="Steam" id="Azf-g8-OxM"/>
<menuItem title="Steam" enabled="NO" id="Azf-g8-OxM"/>
</items>
</menu>
</popUpButtonCell>
Expand Down
11 changes: 11 additions & 0 deletions XIV on Mac/DXVK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@ import Foundation
struct DXVK {
@available(*, unavailable) private init() {}

private static let updateKey = "DXVKShouldUpdate"
static var shouldUpdate: Bool {
get {
return Util.getSetting(settingKey: updateKey, defaultValue: true)
}
set {
UserDefaults.standard.set(newValue, forKey: updateKey)
}
}

static var options = Options()

static func install() {
shouldUpdate = false
let dxvk_path = Bundle.main.url(forResource: "dxvk", withExtension: nil, subdirectory: "")!
let dx_dlls = ["d3d9.dll", "d3d10_1.dll", "d3d10.dll", "d3d10core.dll", "dxgi.dll", "d3d11.dll"]
let system32 = Wine.prefix.appendingPathComponent("drive_c/windows/system32")
Expand Down
14 changes: 6 additions & 8 deletions XIV on Mac/Launcher/FFXIVLoginServices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public enum FFXIVLoginResult {
case protocolError
case networkError
case noInstall
case maintenance
}

private enum FFXIVLoginPageData {
Expand All @@ -207,13 +208,6 @@ struct FFXIVLogin {
return URL(string: "https://ffxiv-login.square-enix.com/oauth/ffxivarr/login/top?lng=en&rgn=\(settings.region.rawValue)&isft=0&cssmode=1&isnew=1&launchver=3\(settings.platform == .steam ? "&issteam=1" : "")")!
}

var frontierURL: URL {
let dateFormatter = DateFormatter()
dateFormatter.timeZone = TimeZone(identifier: "UTC")
dateFormatter.dateFormat = "yyyy-MM-dd-HH"
return URL(string: "https://launcher.finalfantasyxiv.com/v600/index.html?rc_lang=\(settings.language.code)&time=\(dateFormatter.string(from: Date()))")!
}

var patchURL: URL {
let dateFormatter = DateFormatter()
dateFormatter.timeZone = TimeZone(identifier: "UTC")
Expand All @@ -228,7 +222,7 @@ struct FFXIVLogin {
fileprivate func getStored(completion: @escaping ((FFXIVLoginPageData) -> Void)) {
let headers: OrderedDictionary = [
"Accept" : "image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/xaml+xml, application/x-ms-xbap, */*",
"Referer" : frontierURL.absoluteString,
"Referer" : Frontier.referer.absoluteString,
"Accept-Encoding": "gzip, deflate",
//"Accept-Language": ??? TODO: find out how this works and why
"User-Agent" : FFXIVLogin.userAgent,
Expand Down Expand Up @@ -397,6 +391,10 @@ extension FFXIVSettings {
completion(.incorrectCredentials)
return
}
guard Frontier.checkGate() else {
completion(.maintenance)
return
}
let login = FFXIVLogin()
login.getStored() { result in
switch result {
Expand Down
82 changes: 63 additions & 19 deletions XIV on Mac/Launcher/Frontier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,61 @@
//

import Foundation
import OrderedCollections
import SeeURL

class Frontier {

static var squareTime: Int64 {
Int64((Date().timeIntervalSince1970 * 1000.0).rounded())
}

static var referer: URL {
let dateFormatter = DateFormatter()
dateFormatter.timeZone = TimeZone(identifier: "UTC")
dateFormatter.dateFormat = "yyyy-MM-dd-HH"
let time = dateFormatter.string(from: Date())
let lang = FFXIVSettings.language.code
return URL(string: "https://launcher.finalfantasyxiv.com/v600/index.html?rc_lang=\(lang)&time=\(time)")!
}

static var headline: URL {
let lang = FFXIVSettings.language.code
return URL(string: "https://frontier.ffxiv.com/news/headline.json?lang=\(lang)&media=pcapp&\(squareTime)")!
}

static func fetch(url: URL, accept: String? = nil, proxy: String? = nil) -> HTTPClient.Response? {
let headers: OrderedDictionary = [
"User-Agent" : FFXIVLogin.userAgent,
"Accept" : accept,
"Accept-Encoding": "gzip, deflate",
//"Accept-Language": ??? TODO: find out how this works and why
"Origin" : "https://launcher.finalfantasyxiv.com",
"Referer" : Frontier.referer.absoluteString
]
return HTTPClient.fetch(url: url, headers: headers, proxy: proxy)
}

struct Gate: Codable {
let status: Int
}

static func checkGate() -> Bool {
let url = URL(string: "https://frontier.ffxiv.com/worldStatus/gate_status.json?\(squareTime)")!
guard let response = fetch(url: url) else {
return false
}
guard let data = String(decoding: response.body, as: UTF8.self).unescapingUnicodeCharacters.data(using: .utf8) else {
return false
}
let jsonDecoder = JSONDecoder()
do {
return try jsonDecoder.decode(Gate.self, from: data).status == 1
} catch {
return false
}
}

struct Info: Codable {

struct News: Codable {
Expand All @@ -34,26 +86,18 @@ class Frontier {
}

static var info: Info? {
var ret: Info?
let time = Int64((Date().timeIntervalSince1970 * 1000.0).rounded())
let lang = FFXIVSettings.language.code
let url = URL(string: "https://frontier.ffxiv.com/news/headline.json?lang=\(lang)&media=pcapp&\(time)")!
let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: url) { data, response, error in
if let data = data {
let fixedData = String(decoding: data, as: UTF8.self).unescapingUnicodeCharacters.data(using: .utf8)! //thx square
let jsonDecoder = JSONDecoder()
do {
ret = try jsonDecoder.decode(Info.self, from: fixedData)
} catch {
print(error, to: &Util.logger)
}
}
semaphore.signal()
guard let response = fetch(url: headline) else {
return nil
}
guard let data = String(decoding: response.body, as: UTF8.self).unescapingUnicodeCharacters.data(using: .utf8) else {
return nil
}
let jsonDecoder = JSONDecoder()
do {
return try jsonDecoder.decode(Info.self, from: data)
} catch {
return nil
}
task.resume()
semaphore.wait()
return ret
}

}
Expand Down
4 changes: 2 additions & 2 deletions XIV on Mac/Launcher/LaunchController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ class LaunchController: NSViewController, NSWindowDelegate {
}

@IBAction func doLogin(_ sender: Any) {
view.window?.beginSheet(loginSheetWinController!.window!)
FFXIVSettings.credentials = FFXIVLoginCredentials(username: userField.stringValue, password: passwdField.stringValue, oneTimePassword: otpField.stringValue)
doLogin()
}

func doLogin() {
let queue = OperationQueue()
let op = LoginOperation()
view.window?.beginSheet(loginSheetWinController!.window!)
FFXIVSettings.credentials = FFXIVLoginCredentials(username: userField.stringValue, password: passwdField.stringValue, oneTimePassword: otpField.stringValue)
op.completionBlock = {
switch op.loginResult {
case .success(let sid)?:
Expand Down
7 changes: 7 additions & 0 deletions XIV on Mac/Launcher/Login.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ class LoginOperation: AsyncOperation {
alert.messageText = "Network Error"
alert.informativeText = "Check your internet connection, or try again later. Is FFXIV down?"
alert.runModal()
case .maintenance:
let alert = NSAlert()
alert.addButton(withTitle: "Ok")
alert.alertStyle = .critical
alert.messageText = "Maintenance in progress"
alert.informativeText = "Please wait until maintenance finishes before logging in."
alert.runModal()
case .noInstall:
let alert = NSAlert()
alert.addButton(withTitle: "Ok")
Expand Down
12 changes: 12 additions & 0 deletions XIV on Mac/Networking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ import SeeURL

extension HTTPClient {

static func fetch(url: URL, headers: OrderedDictionary<String, String?>? = nil, postBody: Data = Data(), proxy: String? = nil) -> Response? {
var headerDict: OrderedDictionary<String, String> = [:]
if let h = headers {
for (key, value) in h {
if let v = value {
headerDict[key] = v
}
}
}
return fetch(url: url, headers: headerDict, postBody: postBody, proxy: proxy)
}

static func fetch(url: URL, headers: OrderedDictionary<String, String>? = nil, postBody: Data = Data(), proxy: String? = nil) -> Response? {
let headers = headers?.map {key, value in (key,value)} ?? []
let body = [UInt8](postBody)
Expand Down
4 changes: 0 additions & 4 deletions XIV on Mac/Patcher/PatchController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ class PatchController: NSViewController {
installBar.usesThreadedAnimation = true
}

private func toGB(_ number: Double) -> Double {
return Double(round(number * 0.1) / 100)
}

func install(_ patches: [Patch]) {
Wine.kill()
let totalSize = Patch.totalLength(patches)
Expand Down

0 comments on commit 9345153

Please sign in to comment.