Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into master-local
Browse files Browse the repository at this point in the history
  • Loading branch information
Exslims committed Mar 12, 2017
2 parents 5bac846 + fdb0b73 commit 0863779
Show file tree
Hide file tree
Showing 64 changed files with 316 additions and 1,770 deletions.
10 changes: 5 additions & 5 deletions app-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<dependency>
<groupId>com.home.mercury</groupId>
<artifactId>app-shared</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>lc.kra.system</groupId>
<artifactId>system-hook</artifactId>
<version>1.0.0.1</version>
</dependency>
<!--<dependency>-->
<!--<groupId>lc.kra.system</groupId>-->
<!--<artifactId>system-hook</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>com.sun.jna</groupId>
<artifactId>jna</artifactId>
Expand Down
116 changes: 62 additions & 54 deletions app-core/src/main/java/com/mercury/platform/core/ChatHelper.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.mercury.platform.core;

import com.mercury.platform.shared.ConfigManager;
import com.mercury.platform.shared.HasEventHandlers;
import com.mercury.platform.shared.events.EventRouter;
import com.mercury.platform.shared.events.custom.ChatCommandEvent;
import com.mercury.platform.shared.events.custom.DndModeEvent;
import com.mercury.platform.shared.events.custom.OpenChatEvent;
import com.sun.jna.Native;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -30,65 +32,61 @@ public ChatHelper() {
}

private void executeMessage(String message) {
new Thread(() -> {
StringSelection selection = new StringSelection(message);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, null);

gameToFront();

robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);

robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_A);

robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);

robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}).start();
StringSelection selection = new StringSelection(message);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, null);

gameToFront();

robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);

robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_A);

robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);

robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}
private void openChat(String whisper){
new Thread(() -> {
gameToFront();

StringSelection selection = new StringSelection("@" + whisper);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);

robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);

robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_A);

robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);

robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
}).start();
private void openChat(String whisper) {
gameToFront();

StringSelection selection = new StringSelection("@" + whisper);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);

robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);

robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_A);

robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);

robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
}

/**
* NEED REFACTORING
*/
private void gameToFront(){
List<String> titles = new ArrayList<>();
titles.add("Path of Exile");
titles.add("PathOfExile");
titles.add("PathOfExile_64");
user32.EnumWindows((hWnd, arg1) -> {
byte[] windowText = new byte[512];
user32.GetWindowTextA(hWnd, windowText, 512);
Expand All @@ -113,5 +111,15 @@ public void initHandlers() {
EventRouter.INSTANCE.registerHandler(OpenChatEvent.class, event -> {
openChat(((OpenChatEvent) event).getWhisper());
});
EventRouter.INSTANCE.registerHandler(DndModeEvent.class, event -> {
boolean dnd = ((DndModeEvent) event).isDnd();
if(ConfigManager.INSTANCE.isInGameDnd()){
if(dnd) {
executeMessage("/dnd " + ConfigManager.INSTANCE.getDndResponseText());
}else {
executeMessage("/dnd");
}
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created by Константин on 29.01.2017.
*/
public class MercuryConstants {
public static final String APP_VERSION = "1.0.0.3";
public static final String APP_VERSION = "1.0.0.4";
public static final String SERVER_HOST = "exslims.ddns.net";
public static final int PORT = 5555;
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ private static class ConfigManagerHolder {
private boolean itemsGridEnable = true;
private boolean checkUpdateOnStartUp = true;
private boolean dismissAfterKick = false;
private boolean inGameDnd = false;
private String dndResponseText = "Response text";

public ConfigManager() {
minimumFrameSize = new HashMap<>();
minimumFrameSize.put("TaskBarFrame",new Dimension(109,20));
minimumFrameSize.put("IncMessageFrame",new Dimension(315,10));
minimumFrameSize.put("OutMessageFrame",new Dimension(280,115));
minimumFrameSize.put("TestCasesFrame",new Dimension(400,100));
minimumFrameSize.put("SettingsFrame",new Dimension(540,100));
minimumFrameSize.put("SettingsFrame",new Dimension(540,400));
minimumFrameSize.put("HistoryFrame",new Dimension(280,400));
minimumFrameSize.put("TimerFrame",new Dimension(240,102));
minimumFrameSize.put("ChatScannerFrame",new Dimension(200,100));
Expand All @@ -85,6 +87,8 @@ public ConfigManager() {
defaultAppSettings.put("itemsGridEnable",true);
defaultAppSettings.put("checkUpdateOnStartUp",true);
defaultAppSettings.put("dismissAfterKick",false);
defaultAppSettings.put("inGameDnd",false);
defaultAppSettings.put("dndResponseText","Response text");

}

Expand Down Expand Up @@ -126,6 +130,8 @@ public void load() {
saveProperty("itemsGridEnable", String.valueOf(defaultAppSettings.get("itemsGridEnable")));
saveProperty("checkUpdateOnStartUp", String.valueOf(defaultAppSettings.get("checkUpdateOnStartUp")));
saveProperty("dismissAfterKick", String.valueOf(defaultAppSettings.get("dismissAfterKick")));
saveProperty("inGameDnd", String.valueOf(defaultAppSettings.get("inGameDnd")));
saveProperty("dndResponseText", defaultAppSettings.get("dndResponseText"));

} catch (Exception e) {
logger.error(e);
Expand Down Expand Up @@ -181,6 +187,8 @@ private void loadConfigFile(){
itemsGridEnable = Boolean.valueOf(loadProperty("itemsGridEnable"));
checkUpdateOnStartUp = Boolean.valueOf(loadProperty("checkUpdateOnStartUp"));
dismissAfterKick = Boolean.valueOf(loadProperty("dismissAfterKick"));
inGameDnd = Boolean.valueOf(loadProperty("inGameDnd"));
dndResponseText = loadProperty("dndResponseText");
} catch (Exception e) {
logger.error("Error in loadConfigFile: ",e);
}
Expand Down Expand Up @@ -390,6 +398,25 @@ public void setItemsGridEnable(boolean itemsGridEnable) {
this.itemsGridEnable = itemsGridEnable;
saveProperty("itemsGridEnable",String.valueOf(this.itemsGridEnable));
}

public boolean isInGameDnd() {
return inGameDnd;
}

public void setInGameDnd(boolean inGameDnd) {
this.inGameDnd = inGameDnd;
saveProperty("inGameDnd",String.valueOf(this.inGameDnd));
}

public String getDndResponseText() {
return dndResponseText;
}

public void setDndResponseText(String dndResponseText) {
this.dndResponseText = dndResponseText;
saveProperty("dndResponseText",dndResponseText);
}

private List<ResponseButton> getDefaultButtons(){
List<ResponseButton> defaultButtons = new ArrayList<>();
defaultButtons.add(new ResponseButton(0,"1m","one minute",false,false));
Expand All @@ -404,7 +431,7 @@ public Map<String,FrameSettings> getDefaultFramesSettings(){
defaultFramesSettings.put("IncMessageFrame",new FrameSettings(new Point(700, 600),new Dimension(315,0)));
defaultFramesSettings.put("OutMessageFrame",new FrameSettings(new Point(200, 500),new Dimension(280,115)));
defaultFramesSettings.put("TestCasesFrame",new FrameSettings(new Point(1400, 500),new Dimension(400,100)));
defaultFramesSettings.put("SettingsFrame",new FrameSettings(new Point(600, 600),new Dimension(540,100)));
defaultFramesSettings.put("SettingsFrame",new FrameSettings(new Point(600, 600),new Dimension(540,500)));
defaultFramesSettings.put("HistoryFrame",new FrameSettings(new Point(600, 500),new Dimension(280,400)));
defaultFramesSettings.put("TimerFrame",new FrameSettings(new Point(400, 600),new Dimension(240,102)));
defaultFramesSettings.put("ChatScannerFrame",new FrameSettings(new Point(400, 600),new Dimension(500,250)));
Expand Down
8 changes: 2 additions & 6 deletions app-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.home.mercury</groupId>
<artifactId>MercuryTrade</artifactId>
<version>${project.version}</version>
</parent>

<groupId>com.home.mercury</groupId>
<artifactId>app-shared</artifactId>
<version>1.0.0.4</version>
<packaging>jar</packaging>
<dependencies>

Expand Down
113 changes: 0 additions & 113 deletions app-socket-server/pom.xml

This file was deleted.

Loading

0 comments on commit 0863779

Please sign in to comment.