Skip to content

Commit

Permalink
fix backslashes in gamepath bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Exslims committed Oct 24, 2017
1 parent 26d6822 commit 726a18e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 302 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import com.mercury.platform.shared.config.configration.PlainConfigurationService;
import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor;
import com.mercury.platform.shared.config.descriptor.ProfileDescriptor;
import org.apache.commons.lang3.StringUtils;

import java.io.File;


public class ApplicationConfigurationService extends BaseConfigurationService<ApplicationDescriptor> implements PlainConfigurationService<ApplicationDescriptor> {
Expand All @@ -17,6 +20,10 @@ public void validate() {
if (this.selectedProfile.getApplicationDescriptor() == null) {
this.selectedProfile.setApplicationDescriptor(this.getDefault());
}
ApplicationDescriptor applicationDescriptor = this.selectedProfile.getApplicationDescriptor();
if (!StringUtils.substringAfterLast(applicationDescriptor.getGamePath(), "\\").equals("")) {
applicationDescriptor.setGamePath(applicationDescriptor.getGamePath() + File.separatorChar);
}
}

@Override
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

27 changes: 12 additions & 15 deletions app/src/main/java/com/mercury/platform/AppMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,53 @@
import com.mercury.platform.ui.frame.titled.GamePathChooser;
import com.mercury.platform.ui.manager.FramesManager;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.DesktopWindow;
import com.sun.jna.platform.WindowUtils;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.WinDef;
import com.sun.jna.platform.win32.WinUser;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.util.List;

public class AppMain {
public static void main(String[] args) {
System.setProperty("sun.java2d.d3d","false");
System.setProperty("jna.nosys","true");
System.setProperty("sun.java2d.d3d", "false");
System.setProperty("jna.nosys", "true");
new ErrorHandler();
MercuryLoadingFrame mercuryLoadingFrame = new MercuryLoadingFrame();
mercuryLoadingFrame.init();
mercuryLoadingFrame.showComponent();
if(args.length == 0) {
if (args.length == 0) {
new ProdStarter().startApplication();
}else {
} else {
new DevStarter().startApplication();
}
String configGamePath = Configuration.get().applicationConfiguration().get().getGamePath();
if(configGamePath.equals("") || !isValidGamePath(configGamePath)){
if (configGamePath.equals("") || !isValidGamePath(configGamePath)) {
String gamePath = getGamePath();
if(gamePath == null) {
if (gamePath == null) {
MercuryStoreCore.appLoadingSubject.onNext(false);
GamePathChooser gamePathChooser = new GamePathChooser();
gamePathChooser.init();
}else {
} else {
gamePath = gamePath + "\\";
Configuration.get().applicationConfiguration().get().setGamePath(gamePath);
MercuryStoreCore.saveConfigSubject.onNext(true);
new FileMonitor().start();
FramesManager.INSTANCE.start();
MercuryStoreCore.appLoadingSubject.onNext(false);
}
}else {
} else {
new FileMonitor().start();
FramesManager.INSTANCE.start();
MercuryStoreCore.appLoadingSubject.onNext(false);
}
}
private static boolean isValidGamePath(String gamePath){

private static boolean isValidGamePath(String gamePath) {
File file = new File(gamePath + File.separator + "logs" + File.separator + "Client.txt");
return file.exists();
}
private static String getGamePath(){

private static String getGamePath() {
return WindowUtils.getAllWindows(false).stream().filter(window -> {
char[] className = new char[512];
User32.INSTANCE.GetClassName(window.getHWND(), className, 512);
Expand Down

0 comments on commit 726a18e

Please sign in to comment.