Skip to content

Commit

Permalink
Refactor all wine stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
marzent committed Feb 2, 2022
1 parent 74b8dba commit 3a19062
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ Network Trash Folder
Temporary Items
.apdisk

wine/
wine
8 changes: 6 additions & 2 deletions XIV on Mac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
50E5387B2779CF5C0038521A /* SettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E5387A2779CF5C0038521A /* SettingsController.swift */; };
50ED0DB32773C619002E9854 /* Setup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50ED0DB22773C619002E9854 /* Setup.swift */; };
50ED0DB52773CA8C002E9854 /* FileDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50ED0DB42773CA8C002E9854 /* FileDownloader.swift */; };
50F6CBAA27A975A000013301 /* Wine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F6CBA927A975A000013301 /* Wine.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -41,6 +42,7 @@
50E5387A2779CF5C0038521A /* SettingsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsController.swift; sourceTree = "<group>"; };
50ED0DB22773C619002E9854 /* Setup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Setup.swift; sourceTree = "<group>"; };
50ED0DB42773CA8C002E9854 /* FileDownloader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileDownloader.swift; sourceTree = "<group>"; };
50F6CBA927A975A000013301 /* Wine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Wine.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -77,6 +79,7 @@
isa = PBXGroup;
children = (
505C0D9A277333920008A344 /* Util.swift */,
50F6CBA927A975A000013301 /* Wine.swift */,
50511EC42770E085003A1E9F /* AppDelegate.swift */,
50511EC62770E085003A1E9F /* InstallerController.swift */,
50E5387A2779CF5C0038521A /* SettingsController.swift */,
Expand Down Expand Up @@ -201,6 +204,7 @@
files = (
2B7C95D2277C6C6000A3CA89 /* SocialIntegration.swift in Sources */,
50BD278727785418002B0D1F /* Notifications.swift in Sources */,
50F6CBAA27A975A000013301 /* Wine.swift in Sources */,
505C0D9B277333920008A344 /* Util.swift in Sources */,
50511EC72770E085003A1E9F /* InstallerController.swift in Sources */,
50E5387B2779CF5C0038521A /* SettingsController.swift in Sources */,
Expand Down Expand Up @@ -369,7 +373,7 @@
"$(PROJECT_DIR)/XIV\\ on\\ Mac/wine/lib",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 2.3;
MARKETING_VERSION = 2.4;
PRODUCT_BUNDLE_IDENTIFIER = "dezent.XIV-on-Mac";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -404,7 +408,7 @@
"$(PROJECT_DIR)/XIV\\ on\\ Mac/wine/lib",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 2.3;
MARKETING_VERSION = 2.4;
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 @@ -14,8 +14,8 @@
filePath = "XIV on Mac/Util.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "72"
endingLineNumber = "72"
startingLineNumber = "68"
endingLineNumber = "68"
landmarkName = "launch(exec:args:blocking:)"
landmarkType = "7">
</BreakpointContent>
Expand Down
31 changes: 15 additions & 16 deletions XIV on Mac/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
settingsWinController = storyboard.instantiateController(withIdentifier: "SettingsWindow") as? NSWindowController
installerWinController = storyboard.instantiateController(withIdentifier: "InstallerWindow") as? NSWindowController
Util.make(dir: Util.prefix.path)
Util.make(dir: Wine.prefix.path)
Util.make(dir: Util.cache.path)
if Util.getSetting(settingKey: licenseSettingKey, defaultValue: "Mac") == "Mac" {
macLicense()
Expand All @@ -31,24 +31,23 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
SocialIntegration.discord.setPresence()
if FileManager.default.fileExists(atPath: Util.launchPath) {
Util.launchWine(args: ["wineboot", "-u"], blocking: true)
Util.launchGame()
Util.launchExec()
}
else {
installerWinController?.showWindow(self)
}
}

func applicationWillTerminate(_ aNotification: Notification) {
Util.killWine()
Wine.kill()
}

func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}

func application(_ sender: NSApplication, openFile filename: String) -> Bool {
Util.launchWine(args: [filename])
Wine.launch(args: [filename])
return true
}

Expand Down Expand Up @@ -76,7 +75,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

func winLicense() {
Util.launchWine(args: ["reg", "add", "HKEY_CURRENT_USER\\Software\\Wine", "/v", "HideWineExports", "/d", "1", "/f"])
Wine.addReg(key: "HKEY_CURRENT_USER\\Software\\Wine", value: "HideWineExports", data: "1")
macButton.state = .off
winButton.state = .on
UserDefaults.standard.set("Win", forKey: licenseSettingKey)
Expand All @@ -88,14 +87,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

func macLicense() {
Util.launchWine(args: ["reg", "add", "HKEY_CURRENT_USER\\Software\\Wine", "/v", "HideWineExports", "/d", "0", "/f"])
Wine.addReg(key: "HKEY_CURRENT_USER\\Software\\Wine", value: "HideWineExports", data: "0")
macButton.state = .on
winButton.state = .off
UserDefaults.standard.set("Mac", forKey: licenseSettingKey)
}

@IBAction func play(_ sender: Any) {
Util.launchGame()
Util.launchExec(terminating: false)
}

@IBAction func installDXVK(_ sender: Any) {
Expand Down Expand Up @@ -153,8 +152,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
args: ["-n", "-b", "com.apple.Terminal",
Bundle.main.url(forResource: "install_gshade", withExtension: "sh", subdirectory: "GShade")!.path,
"--env", "WINEPATH=\( Bundle.main.url(forResource: "bin", withExtension: nil, subdirectory: "wine")!.path)",
"--env", "WINEESYNC=\(Util.esync ? "1" : "0")",
"--env", "WINEPREFIX=\(Util.prefix.path)"])
"--env", "WINEESYNC=\(Wine.esync ? "1" : "0")",
"--env", "WINEPREFIX=\(Wine.prefix.path)"])
} else {
let alert = NSAlert()
alert.messageText = "Catalina is not supported by the automatic GShade installer"
Expand All @@ -171,8 +170,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
args: ["-n", "-b", "com.apple.Terminal",
Bundle.main.url(forResource: "manual_gshade", withExtension: "sh", subdirectory: "GShade")!.path,
"--env", "WINEPATH=\( Bundle.main.url(forResource: "bin", withExtension: nil, subdirectory: "wine")!.path)",
"--env", "WINEESYNC=\(Util.esync ? "1" : "0")",
"--env", "WINEPREFIX=\(Util.prefix.path)"])
"--env", "WINEESYNC=\(Wine.esync ? "1" : "0")",
"--env", "WINEPREFIX=\(Wine.prefix.path)"])
} else {
let alert = NSAlert()
alert.messageText = "When running Catalina you must have wine or CrossOver installed"
Expand All @@ -188,19 +187,19 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

@IBAction func regedit(_ sender: Any) {
Util.launchWine(args: ["regedit"])
Wine.launch(args: ["regedit"])
}

@IBAction func winecfg(_ sender: Any) {
Util.launchWine(args: ["winecfg"])
Wine.launch(args: ["winecfg"])
}

@IBAction func explorer(_ sender: Any) {
Util.launchWine(args: ["explorer"])
Wine.launch(args: ["explorer"])
}

@IBAction func cmd(_ sender: Any) {
Util.launchWine(args: ["wineconsole"])
Wine.launch(args: ["wineconsole"])
}

@IBAction func dxvkSettings(_ sender: Any) {
Expand Down
15 changes: 13 additions & 2 deletions XIV on Mac/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ Gw
</connections>
</button>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qGE-fd-l1u">
<rect key="frame" x="294" y="19" width="314" height="21"/>
<rect key="frame" x="407" y="19" width="201" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="Wfl-gF-eSY">
<font key="font" metaFont="system"/>
Expand All @@ -1292,14 +1292,25 @@ Gw
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bVO-QG-s4L">
<rect key="frame" x="206" y="22" width="82" height="16"/>
<rect key="frame" x="325" y="21" width="82" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Wine Debug:" id="nXs-Qb-iRe">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="buc-8R-1Wp">
<rect key="frame" x="174" y="21" width="64" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Retina" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="7vx-YJ-IUo">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="saveState:" target="GIg-v3-M8h" id="HeB-xt-rJP"/>
</connections>
</button>
</subviews>
</view>
</box>
Expand Down
2 changes: 1 addition & 1 deletion XIV on Mac/InstallerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class InstallerController: NSViewController {
let validBoot = FileManager.default.fileExists(atPath: boot)
let components = gamePath.split(separator: "/")
let trimmedComponents = components[...min(components.count - 1, 5)]
if "/" + trimmedComponents.map(String.init).joined(separator: "/") == Util.prefix.path {
if "/" + trimmedComponents.map(String.init).joined(separator: "/") == Wine.prefix.path {
return false // do not allow game directories from the prefix itself
}
return (validGame && validBoot)
Expand Down
8 changes: 4 additions & 4 deletions XIV on Mac/SettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class SettingsController: NSViewController {
maxFPSField.stringValue = String(Util.dxvkOptions.maxFramerate)
discord.state = SocialIntegration.discord.enabled ? NSControl.StateValue.on : NSControl.StateValue.off
scale.doubleValue = Util.dxvkOptions.hudScale
esync.state = Util.esync ? NSControl.StateValue.on : NSControl.StateValue.off
wineDebugField.stringValue = Util.wineDebug
esync.state = Wine.esync ? NSControl.StateValue.on : NSControl.StateValue.off
wineDebugField.stringValue = Wine.debug
}

func saveState() {
Expand All @@ -98,8 +98,8 @@ class SettingsController: NSViewController {
Util.dxvkOptions.hudScale = scale.doubleValue
Util.dxvkOptions.save()

Util.esync = (esync.state == NSControl.StateValue.on) ? true : false
Util.wineDebug = wineDebugField.stringValue
Wine.esync = (esync.state == NSControl.StateValue.on) ? true : false
Wine.debug = wineDebugField.stringValue

SocialIntegration.discord.enabled = (discord.state == NSControl.StateValue.on) ? true : false
SocialIntegration.discord.save()
Expand Down
Loading

0 comments on commit 3a19062

Please sign in to comment.