If a second SteamAPI DLL has been found, it will now automatically be patched too.
Now handles error if file chooser was canceled. Now handles error if cream_api.ini file was not found, which would be the case if CreamAPI is going to be set up for the first time.
This commit is contained in:
parent
a03246a98f
commit
c76ad989f9
@ -35,6 +35,10 @@ Download the latest release and extract it into any folder (e.g. `%USERPROFILE%\
|
|||||||
* Select a language and tick the options if needed.
|
* Select a language and tick the options if needed.
|
||||||
* Click on *"Save"*.
|
* Click on *"Save"*.
|
||||||
|
|
||||||
|
### Java 11
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Auto-CreamAPI itself is licensed under the GNU General Public License v3.0
|
Auto-CreamAPI itself is licensed under the GNU General Public License v3.0
|
||||||
|
@ -37,6 +37,7 @@ import java.io.InputStream;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -283,12 +284,15 @@ public class Controller {
|
|||||||
state_label.setText("Ready.");
|
state_label.setText("Ready.");
|
||||||
} catch (ConfigurationException | IOException e) {
|
} catch (ConfigurationException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
System.err.println("Could not set config file location! Did you cancel the file chooser?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if creamapi version of dll is there, if not, rename original to steam_api(64)_o.dll and copy
|
* check if creamapi version of dll is there, if not, rename original to steam_api(64)_o.dll and copy
|
||||||
* creamapi one to the path.
|
* creamapi dll to the path. also looks for alternative steam dll (which means it patches both 64 and 32 bit
|
||||||
|
* dlls at once if found)
|
||||||
*
|
*
|
||||||
* @throws IOException If file is missing or not accessible/modifiable.
|
* @throws IOException If file is missing or not accessible/modifiable.
|
||||||
*/
|
*/
|
||||||
@ -299,6 +303,22 @@ public class Controller {
|
|||||||
if (path.endsWith("steam_api64.dll")) {
|
if (path.endsWith("steam_api64.dll")) {
|
||||||
is64Bit = true;
|
is64Bit = true;
|
||||||
}
|
}
|
||||||
|
copyDllFile(is64Bit, path);
|
||||||
|
findAdditionalDll(is64Bit, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void findAdditionalDll(boolean is64Bit, Path path) throws IOException {
|
||||||
|
String secondDllString = is64Bit ? "\\steam_api.dll" : "\\steam_api64.dll";
|
||||||
|
Path dir = path.getParent();
|
||||||
|
Path secondDll = Paths.get(dir.toString() + secondDllString);
|
||||||
|
if (Files.exists(secondDll)) {
|
||||||
|
System.out.println("Alternative DLL found!");
|
||||||
|
copyDllFile(!is64Bit, secondDll);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copyDllFile(boolean is64Bit, Path path) throws IOException {
|
||||||
InputStream is = Files.newInputStream(path);
|
InputStream is = Files.newInputStream(path);
|
||||||
String md5 = DigestUtils.md5Hex(is);
|
String md5 = DigestUtils.md5Hex(is);
|
||||||
boolean isSameFile = Objects.equals(md5, handler.getDllMd5(is64Bit));
|
boolean isSameFile = Objects.equals(md5, handler.getDllMd5(is64Bit));
|
||||||
@ -310,12 +330,18 @@ public class Controller {
|
|||||||
Path pathOrig = Paths.get(pathOrigString);
|
Path pathOrig = Paths.get(pathOrigString);
|
||||||
if (!Files.exists(pathOrig)) {
|
if (!Files.exists(pathOrig)) {
|
||||||
Files.move(path, pathOrig);
|
Files.move(path, pathOrig);
|
||||||
|
} else {
|
||||||
|
String pathBakString = steamApiPathString;
|
||||||
|
pathBakString =
|
||||||
|
pathBakString
|
||||||
|
.replaceFirst(REGEX, is64Bit ? "steam_api64.dll.backup" : "steam_api.dll.backup");
|
||||||
|
Path pathBak = Paths.get(pathBakString);
|
||||||
|
Files.move(path, pathBak, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
Files.deleteIfExists(path);
|
//Files.deleteIfExists(path);
|
||||||
Files.copy(handler.getDllPath(is64Bit), path);
|
Files.copy(handler.getDllPath(is64Bit), path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void setDisableAllButtons(boolean b) {
|
private void setDisableAllButtons(boolean b) {
|
||||||
reset_button.setDisable(b);
|
reset_button.setDisable(b);
|
||||||
|
@ -70,6 +70,7 @@ public class CreamApiConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void read() throws NullPointerException {
|
public void read() throws NullPointerException {
|
||||||
|
try {
|
||||||
appId = config.getInt("steam.appid");
|
appId = config.getInt("steam.appid");
|
||||||
language = config.getString("steam.language");
|
language = config.getString("steam.language");
|
||||||
if (language == null) {
|
if (language == null) {
|
||||||
@ -80,6 +81,10 @@ public class CreamApiConfig {
|
|||||||
forceOffline = config.getBoolean("steam.forceoffline");
|
forceOffline = config.getBoolean("steam.forceoffline");
|
||||||
final SubnodeConfiguration dlc_section = config.getSection("dlc");
|
final SubnodeConfiguration dlc_section = config.getSection("dlc");
|
||||||
dlc_section.getKeys().forEachRemaining(k -> dlc.put(Integer.parseInt(k), dlc_section.getString(k)));
|
dlc_section.getKeys().forEachRemaining(k -> dlc.put(Integer.parseInt(k), dlc_section.getString(k)));
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
System.err.println("Error reading cream_api.ini! " +
|
||||||
|
"This can be ignored if setting up CreamAPI for the first time.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sync() throws ConfigurationException {
|
public void sync() throws ConfigurationException {
|
||||||
|
Loading…
Reference in New Issue
Block a user