-
Notifications
You must be signed in to change notification settings - Fork 117
/
ForgedAlliancePrefs.java
203 lines (165 loc) · 6.15 KB
/
ForgedAlliancePrefs.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
package com.faforever.client.preferences;
import com.sun.jna.platform.win32.Shell32Util;
import com.sun.jna.platform.win32.ShlObj;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import java.nio.file.Path;
import java.nio.file.Paths;
public class ForgedAlliancePrefs {
public static final Path GPG_FA_PATH;
public static final Path STEAM_FA_PATH;
public static final Path LOCAL_FA_DATA_PATH;
public static final String INIT_FILE_NAME = "init.lua";
static {
if (org.bridj.Platform.isWindows()) {
GPG_FA_PATH = Paths.get(Shell32Util.getFolderPath(ShlObj.CSIDL_PERSONAL), "My Games", "Gas Powered Games", "Supreme Commander Forged Alliance");
//If steam is every swapped to a 64x client, needs to be updated to proper directory or handling must be put in place.
STEAM_FA_PATH = Paths.get(Shell32Util.getFolderPath(ShlObj.CSIDL_PROGRAM_FILESX86), "Steam", "SteamApps", "common", "Supreme Commander Forged Alliance");
LOCAL_FA_DATA_PATH = Paths.get(Shell32Util.getFolderPath(ShlObj.CSIDL_LOCAL_APPDATA), "Gas Powered Games", "Supreme Commander Forged Alliance");
} else {
String userHome = System.getProperty("user.home");
GPG_FA_PATH = Paths.get(userHome, "My Games", "Gas Powered Games", "Supreme Commander Forged Alliance");
STEAM_FA_PATH = Paths.get(".");
LOCAL_FA_DATA_PATH = Paths.get(userHome, ".wine", "drive_c", "users", System.getProperty("user.name"), "Application Data", "Gas Powered Games", "Supreme Commander Forged Alliance");
}
}
/**
* @deprecated use {@code installationPath} instead.
*/
@Deprecated
private final ObjectProperty<Path> path;
private final ObjectProperty<Path> installationPath;
private final ObjectProperty<Path> customMapsDirectory;
private final ObjectProperty<Path> preferencesFile;
private final ObjectProperty<Path> officialMapsDirectory;
private final ObjectProperty<Path> modsDirectory;
private final IntegerProperty port;
private final BooleanProperty autoDownloadMaps;
/**
* String format to use when building the launch command. Takes exact one parameter; the executable path. <p>
* Example:
* <pre>wine "%s"</pre>
* Results in:
* <pre>wine "C:\Game\ForgedAlliance.exe"</pre>
* </p>
*/
private final StringProperty executableDecorator;
private final ObjectProperty<Path> executionDirectory;
public ForgedAlliancePrefs() {
port = new SimpleIntegerProperty(6112);
path = new SimpleObjectProperty<>();
installationPath = new SimpleObjectProperty<>();
customMapsDirectory = new SimpleObjectProperty<>(GPG_FA_PATH.resolve("Maps"));
officialMapsDirectory = new SimpleObjectProperty<>(STEAM_FA_PATH.resolve("Maps"));
modsDirectory = new SimpleObjectProperty<>(GPG_FA_PATH.resolve("Mods"));
preferencesFile = new SimpleObjectProperty<>(LOCAL_FA_DATA_PATH.resolve("Game.prefs"));
autoDownloadMaps = new SimpleBooleanProperty(true);
executableDecorator = new SimpleStringProperty("\"%s\"");
executionDirectory = new SimpleObjectProperty<>();
}
public Path getPreferencesFile() {
return preferencesFile.get();
}
public void setPreferencesFile(Path preferencesFile) {
this.preferencesFile.set(preferencesFile);
}
public ObjectProperty<Path> preferencesFileProperty() {
return preferencesFile;
}
public Path getOfficialMapsDirectory() {
return officialMapsDirectory.get();
}
public void setOfficialMapsDirectory(Path officialMapsDirectory) {
this.officialMapsDirectory.set(officialMapsDirectory);
}
/**
* @deprecated use {@code installationPath} instead.
*/
@Deprecated
public Path getPath() {
return path.get();
}
/**
* @deprecated use {@code installationPath} instead.
*/
@Deprecated
public void setPath(Path path) {
this.path.set(path);
this.installationPath.set(path);
}
public ObjectProperty<Path> pathProperty() {
return path;
}
public int getPort() {
return port.get();
}
public void setPort(int port) {
this.port.set(port);
}
public IntegerProperty portProperty() {
return port;
}
public boolean getAutoDownloadMaps() {
return autoDownloadMaps.get();
}
public void setAutoDownloadMaps(boolean autoDownloadMaps) {
this.autoDownloadMaps.set(autoDownloadMaps);
}
public BooleanProperty autoDownloadMapsProperty() {
return autoDownloadMaps;
}
public Path getModsDirectory() {
return modsDirectory.get();
}
public void setModsDirectory(Path modsDirectory) {
this.modsDirectory.set(modsDirectory);
}
public ObjectProperty<Path> modsDirectoryProperty() {
return modsDirectory;
}
public Path getCustomMapsDirectory() {
return customMapsDirectory.get();
}
public void setCustomMapsDirectory(Path customMapsDirectory) {
this.customMapsDirectory.set(customMapsDirectory);
}
public ObjectProperty<Path> customMapsDirectoryProperty() {
return customMapsDirectory;
}
public ObjectProperty<Path> officialMapsDirectoryProperty() {
return officialMapsDirectory;
}
public String getExecutableDecorator() {
return executableDecorator.get();
}
public void setExecutableDecorator(String executableDecorator) {
this.executableDecorator.set(executableDecorator);
}
public StringProperty executableDecoratorProperty() {
return executableDecorator;
}
public Path getExecutionDirectory() {
return executionDirectory.get();
}
public void setExecutionDirectory(Path executionDirectory) {
this.executionDirectory.set(executionDirectory);
}
public ObjectProperty<Path> executionDirectoryProperty() {
return executionDirectory;
}
public Path getInstallationPath() {
return installationPath.get();
}
public void setInstallationPath(Path installationPath) {
this.installationPath.set(installationPath);
}
public ObjectProperty<Path> installationPathProperty() {
return installationPath;
}
}