diff --git a/app-core/pom.xml b/app-core/pom.xml index 7ec54ce4..93bd7f86 100644 --- a/app-core/pom.xml +++ b/app-core/pom.xml @@ -20,8 +20,8 @@ 1.0.0.5 - lc.kra.system - system-hook + com.1stleg + jnativehook net.java.dev.jna diff --git a/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java b/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java index c67fe113..5d560e0f 100644 --- a/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java +++ b/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java @@ -1,7 +1,7 @@ package com.mercury.platform.core; public class MercuryConstants { - public static final String APP_VERSION = "1.0.1.6.1"; + public static final String APP_VERSION = "1.0.1.7.0"; public static final String SERVER_HOST = "exslims.ddns.net"; public static final int PORT = 5555; } diff --git a/app-core/src/main/java/com/mercury/platform/core/misc/WhisperNotifierStatus.java b/app-core/src/main/java/com/mercury/platform/core/misc/WhisperNotifierStatus.java index 7aaa2d52..415347b5 100644 --- a/app-core/src/main/java/com/mercury/platform/core/misc/WhisperNotifierStatus.java +++ b/app-core/src/main/java/com/mercury/platform/core/misc/WhisperNotifierStatus.java @@ -1,33 +1,32 @@ package com.mercury.platform.core.misc; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by Константин on 13.12.2016. - */ public enum WhisperNotifierStatus { - ALWAYS(0), - ALTAB(1), - NONE(2); - - private static final Map lookup - = new HashMap<>(); - static { - for (WhisperNotifierStatus w : EnumSet.allOf(WhisperNotifierStatus.class)){ - lookup.put(w.getCode(),w); + ALWAYS { + @Override + public String asPretty() { + return "Always play a sound"; } - } - private int code; - private WhisperNotifierStatus(int code){ - this.code = code; - } + }, + ALTAB { + @Override + public String asPretty() { + return "Only when tabbed out"; + } + }, + NONE { + @Override + public String asPretty() { + return "Never"; + } + }; - public int getCode() { - return code; - } - public static WhisperNotifierStatus get(int code){ - return lookup.get(code); + public abstract String asPretty(); + public static WhisperNotifierStatus valueOfPretty(String s){ + for (WhisperNotifierStatus status : WhisperNotifierStatus.values()) { + if(status.asPretty().equals(s)){ + return status; + } + } + return null; } } diff --git a/app-core/src/main/java/com/mercury/platform/core/update/core/ClientChannelInitializer.java b/app-core/src/main/java/com/mercury/platform/core/update/core/ClientChannelInitializer.java index 1324bce2..0dcc9810 100644 --- a/app-core/src/main/java/com/mercury/platform/core/update/core/ClientChannelInitializer.java +++ b/app-core/src/main/java/com/mercury/platform/core/update/core/ClientChannelInitializer.java @@ -10,9 +10,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -/** - * Created by Frost on 14.01.2017. - */ public class ClientChannelInitializer extends ChannelInitializer { private static final Logger LOGGER = LogManager.getLogger(ClientChannelInitializer.class.getSimpleName()); diff --git a/app-core/src/main/java/com/mercury/platform/core/update/core/UpdaterClient.java b/app-core/src/main/java/com/mercury/platform/core/update/core/UpdaterClient.java index e2b1c9f9..46340b81 100644 --- a/app-core/src/main/java/com/mercury/platform/core/update/core/UpdaterClient.java +++ b/app-core/src/main/java/com/mercury/platform/core/update/core/UpdaterClient.java @@ -12,11 +12,9 @@ import org.apache.logging.log4j.Logger; import java.net.InetSocketAddress; +import java.util.Random; import java.util.concurrent.TimeUnit; -/** - * Created by Frost on 14.01.2017. - */ public class UpdaterClient { private static final Logger LOGGER = LogManager.getLogger(UpdaterClient.class.getSimpleName()); @@ -71,7 +69,7 @@ public void operationComplete(ChannelFuture future) throws Exception { future.channel().close(); future.channel().eventLoop().schedule(() -> { bootstrap.connect().addListener(this); - },3,TimeUnit.MINUTES); + },new Random().nextInt(5),TimeUnit.MINUTES); } else { channel = future.channel(); connectionEstablished = true; diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/MessageFileHandler.java b/app-core/src/main/java/com/mercury/platform/core/utils/MessageFileHandler.java index a19535fc..13e59383 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/MessageFileHandler.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/MessageFileHandler.java @@ -15,7 +15,7 @@ import java.util.stream.Collectors; public class MessageFileHandler implements AsSubscriber { - private static final String dateRGPattern = "^\\n[0-9]{4}\\/(0[1-9]|1[0-2])\\/(0[1-9]|[1-2][0-9]|3[0-1])\\s([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$"; + private static final String dateRGPattern = "^\\n?[0-9]{4}\\/(0[1-9]|1[0-2])\\/(0[1-9]|[1-2][0-9]|3[0-1])\\s([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$"; private final Logger logger = LogManager.getLogger(MessageFileHandler.class); private String logFilePath; private Date lastMessageDate = new Date(); @@ -68,9 +68,7 @@ public void parse() { .collect(Collectors.toList()); List resultMessages = filteredMessages.stream().filter(message -> { - message = StringUtils.substring(message, 0, 20); - Matcher matcher = datePattern.matcher(message); - if(matcher.find()) { + if(message.contains("2017") || message.contains("2018")) { //todo Date date = new Date(StringUtils.substring(message, 0, 20)); return date.after(lastMessageDate); }else { diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/AdrConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/AdrConfigurationService.java index db5991f0..720a0552 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/AdrConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/AdrConfigurationService.java @@ -1,14 +1,12 @@ package com.mercury.platform.shared.config.configration; -import com.mercury.platform.shared.config.descriptor.adr.AdrTrackerGroupDescriptor; -import com.mercury.platform.shared.config.descriptor.adr.AdrIconDescriptor; -import com.mercury.platform.shared.config.descriptor.adr.AdrProfileDescriptor; -import com.mercury.platform.shared.config.descriptor.adr.AdrProgressBarDescriptor; +import com.mercury.platform.shared.config.descriptor.adr.*; public interface AdrConfigurationService extends ListConfigurationService{ AdrIconDescriptor getDefaultIcon(); AdrProgressBarDescriptor getDefaultProgressBar(); AdrTrackerGroupDescriptor getDefaultIconGroup(); AdrTrackerGroupDescriptor getDefaultPBGroup(); + AdrCaptureDescriptor getDefaultCapture(); } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/KeyValueConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/KeyValueConfigurationService.java index 8a636727..b60dc798 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/KeyValueConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/KeyValueConfigurationService.java @@ -6,4 +6,5 @@ public interface KeyValueConfigurationService { T get(K key); Map getMap(); + void set(Map map); } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/PlainConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/PlainConfigurationService.java index 59a543b2..33f2e84a 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/PlainConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/PlainConfigurationService.java @@ -3,4 +3,5 @@ public interface PlainConfigurationService { T get(); + void set(T descriptor); } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ApplicationConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ApplicationConfigurationService.java index 6dd429b3..9814e580 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ApplicationConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ApplicationConfigurationService.java @@ -27,6 +27,11 @@ public ApplicationDescriptor get() { return this.selectedProfile.getApplicationDescriptor(); } + @Override + public void set(ApplicationDescriptor descriptor) { + this.selectedProfile.setApplicationDescriptor(descriptor); + } + @Override public ApplicationDescriptor getDefault() { ApplicationDescriptor descriptor = new ApplicationDescriptor(); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java index 110a4cbf..2264a062 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java @@ -40,6 +40,11 @@ public Map getMap() { return this.selectedProfile.getFrameDescriptorMap(); } + @Override + public void set(Map map) { + this.selectedProfile.setFrameDescriptorMap(map); + } + @Override public Map getDefault() { return defaultFramesSettings; @@ -77,7 +82,7 @@ private void initDefaultMap() { defaultFramesSettings.put("MessageFrame", new FrameDescriptor(new Point(700, 600), new Dimension(315, 0))); defaultFramesSettings.put("OutMessageFrame", new FrameDescriptor(new Point(200, 500), new Dimension(280, 115))); defaultFramesSettings.put("TestCasesFrame", new FrameDescriptor(new Point(1400, 500), new Dimension(400, 100))); - defaultFramesSettings.put("SettingsFrame", new FrameDescriptor(new Point(600, 600), new Dimension(600,400))); + defaultFramesSettings.put("SettingsFrame", new FrameDescriptor(new Point(600, 600), new Dimension(800,600))); defaultFramesSettings.put("HistoryFrame", new FrameDescriptor(new Point(600, 500), new Dimension(280, 400))); defaultFramesSettings.put("TimerFrame", new FrameDescriptor(new Point(400, 600), new Dimension(240, 102))); defaultFramesSettings.put("ChatFilterFrame", new FrameDescriptor(new Point(400, 600), new Dimension(500, 300))); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeysConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeysConfigurationService.java index 95a42dde..6971f1b8 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeysConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeysConfigurationService.java @@ -7,7 +7,7 @@ import com.mercury.platform.shared.config.descriptor.HotKeyType; import com.mercury.platform.shared.config.descriptor.ProfileDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; -import lc.kra.system.keyboard.event.GlobalKeyEvent; +import org.jnativehook.keyboard.NativeKeyEvent; import java.util.HashMap; import java.util.Map; @@ -20,16 +20,11 @@ public HotKeysConfigurationService(ProfileDescriptor selectedProfile) { @Override public Map getDefault() { Map keyMap = new HashMap<>(); - keyMap.put(HotKeyType.INVITE_PLAYER.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'1',true,false,false,false)); - keyMap.put(HotKeyType.TRADE_PLAYER.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_2,'2',true,false,false,false)); - keyMap.put(HotKeyType.KICK_PLAYER.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_3,'3',true,false,false,false)); - keyMap.put(HotKeyType.STILL_INTERESTING.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_4,'4',true,false,false,false)); - keyMap.put(HotKeyType.CLOSE_NOTIFICATION.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_5,'5',true,false,false,false)); - keyMap.put(HotKeyType.EXPAND_ALL.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'1',false,false,true,false)); - keyMap.put("button_1",new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'1',false,true,false,false)); - keyMap.put("button_2",new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'2',false,true,false,false)); - keyMap.put("button_3",new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'3',false,true,false,false)); - keyMap.put("button_4",new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'4',false,true,false,false)); + keyMap.put(HotKeyType.INVITE_PLAYER.name(),new HotKeyDescriptor("Alt + 1", NativeKeyEvent.VC_1,'1',true,false,false)); + keyMap.put(HotKeyType.TRADE_PLAYER.name(),new HotKeyDescriptor("Alt + 2",NativeKeyEvent.VC_2,'2',true,false,false)); + keyMap.put(HotKeyType.KICK_PLAYER.name(),new HotKeyDescriptor("Alt + 3",NativeKeyEvent.VC_3,'3',true,false,false)); + keyMap.put(HotKeyType.STILL_INTERESTING.name(),new HotKeyDescriptor("Alt + 4",NativeKeyEvent.VC_4,'4',true,false,false)); + keyMap.put(HotKeyType.CLOSE_NOTIFICATION.name(),new HotKeyDescriptor("Alt + 5",NativeKeyEvent.VC_5,'5',true,false,false)); return keyMap; } @@ -52,10 +47,20 @@ public Map getMap() { return this.selectedProfile.getHotKeysDataMap(); } + @Override + public void set(Map map) { + this.selectedProfile.setHotKeysDataMap(map); + } + @Override public void validate() { if (this.selectedProfile.getHotKeysDataMap() == null){ this.selectedProfile.setHotKeysDataMap(this.getDefault()); } + this.getMap().values().forEach(it -> { + if(it.getTitle().equals("")){ + it.setTitle("..."); + } + }); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java index a50dbd40..112c9370 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java @@ -2,6 +2,7 @@ import com.mercury.platform.shared.config.configration.BaseConfigurationService; import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; import com.mercury.platform.shared.config.descriptor.ProfileDescriptor; import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; @@ -20,10 +21,10 @@ public NotificationConfigurationService(ProfileDescriptor selectedProfile) { public NotificationDescriptor getDefault() { NotificationDescriptor notificationDescriptor = new NotificationDescriptor(); List defaultButtons = new ArrayList<>(); - defaultButtons.add(new ResponseButtonDescriptor(0,false,false,"1m","one minute")); - defaultButtons.add(new ResponseButtonDescriptor(1,true,false,"thx","thanks")); - defaultButtons.add(new ResponseButtonDescriptor(2,false,false,"no thx", "no thanks")); - defaultButtons.add(new ResponseButtonDescriptor(3,false,false,"sold", "sold")); + defaultButtons.add(new ResponseButtonDescriptor(0,false,"1m","one minute", new HotKeyDescriptor())); + defaultButtons.add(new ResponseButtonDescriptor(1,true,"thx","thanks",new HotKeyDescriptor())); + defaultButtons.add(new ResponseButtonDescriptor(2,false,"no thx", "no thanks",new HotKeyDescriptor())); + defaultButtons.add(new ResponseButtonDescriptor(3,false,"sold", "sold",new HotKeyDescriptor())); notificationDescriptor.setButtons(defaultButtons); notificationDescriptor.setNotificationEnable(true); notificationDescriptor.setLimitCount(3); @@ -44,10 +45,20 @@ public void validate() { if(this.selectedProfile.getNotificationDescriptor() == null) { this.selectedProfile.setNotificationDescriptor(this.getDefault()); } + this.get().getButtons().forEach(it -> { + if(it.getHotKeyDescriptor() == null) { + it.setHotKeyDescriptor(new HotKeyDescriptor()); + } + }); } @Override public NotificationDescriptor get() { return this.selectedProfile.getNotificationDescriptor(); } + + @Override + public void set(NotificationDescriptor descriptor) { + this.selectedProfile.setNotificationDescriptor(descriptor); + } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScaleConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScaleConfigurationService.java index 5c47d9f1..5574df35 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScaleConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScaleConfigurationService.java @@ -50,4 +50,9 @@ public void toDefault() { public Map getMap() { return this.selectedProfile.getScaleDataMap(); } + + @Override + public void set(Map map) { + this.selectedProfile.setScaleDataMap(map); + } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScannerConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScannerConfigurationService.java index 27d9676d..7a75eb0d 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScannerConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScannerConfigurationService.java @@ -34,4 +34,9 @@ public void validate() { public ScannerDescriptor get() { return this.selectedProfile.getScannerDescriptor(); } + + @Override + public void set(ScannerDescriptor descriptor) { + this.selectedProfile.setScannerDescriptor(descriptor); + } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/SoundConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/SoundConfigurationService.java index 6aebc9b5..ef48e781 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/SoundConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/SoundConfigurationService.java @@ -35,6 +35,11 @@ public Map getMap() { return this.selectedProfile.getSoundDescriptorMap(); } + @Override + public void set(Map map) { + this.selectedProfile.setSoundDescriptorMap(map); + } + @Override public Map getDefault() { Map defaultSettings = new HashMap<>(); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/adr/AdrConfigurationServiceMock.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/adr/AdrConfigurationServiceMock.java index 7080bc89..4c68e058 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/adr/AdrConfigurationServiceMock.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/adr/AdrConfigurationServiceMock.java @@ -3,17 +3,14 @@ import com.mercury.platform.shared.config.configration.AdrConfigurationService; import com.mercury.platform.shared.config.configration.BaseConfigurationService; -import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; import com.mercury.platform.shared.config.descriptor.ProfileDescriptor; import com.mercury.platform.shared.config.descriptor.adr.*; +import com.mercury.platform.shared.config.descriptor.adr.AdrCaptureDescriptor; import com.mercury.platform.shared.config.json.JSONHelper; import java.awt.*; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Random; -import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; public class AdrConfigurationServiceMock extends BaseConfigurationService> implements AdrConfigurationService { @@ -100,4 +97,13 @@ private AdrProfileDescriptor getShowCaseProfile(){ profileDescriptor.setContents(jsonHelper.getJsonAsObjectFromFile("notes/showcase-profile.json")); return profileDescriptor; } + + @Override + public AdrCaptureDescriptor getDefaultCapture() { + AdrCaptureDescriptor descriptor = new AdrCaptureDescriptor(); + descriptor.setTitle("Capture"); + descriptor.setType(AdrComponentType.CAPTURE); + descriptor.setCaptureLocation(new Point(descriptor.getLocation().x + 80,descriptor.getLocation().y)); + return descriptor; + } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ApplicationDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ApplicationDescriptor.java index a19cad8a..8a4036d0 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ApplicationDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ApplicationDescriptor.java @@ -3,10 +3,11 @@ import com.mercury.platform.core.misc.WhisperNotifierStatus; import lombok.Data; +import java.io.Serializable; import java.util.Map; @Data -public class ApplicationDescriptor { +public class ApplicationDescriptor implements Serializable{ private WhisperNotifierStatus notifierStatus; private int minOpacity; private int maxOpacity; diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyDescriptor.java index 477dadb0..69d6dd8c 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyDescriptor.java @@ -10,11 +10,10 @@ @AllArgsConstructor @NoArgsConstructor public class HotKeyDescriptor implements Serializable{ - private String title = ""; + private String title = "..."; private int virtualKeyCode; private char keyChar; private boolean menuPressed; private boolean shiftPressed; private boolean controlPressed; - private boolean extendedKey; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java index bf804c00..682a04ae 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java @@ -1,11 +1,52 @@ package com.mercury.platform.shared.config.descriptor; +import java.util.Arrays; +import java.util.stream.Collectors; + public enum HotKeyType { - INVITE_PLAYER, - TRADE_PLAYER, - KICK_PLAYER, - STILL_INTERESTING, - CLOSE_NOTIFICATION, - EXPAND_ALL + INVITE_PLAYER { + @Override + public String getIconPath() { + return "app/invite.png"; + } + }, + TRADE_PLAYER { + @Override + public String getIconPath() { + return "app/trade.png"; + } + }, + KICK_PLAYER { + @Override + public String getIconPath() { + return "app/kick.png"; + } + }, + STILL_INTERESTING { + @Override + public String getIconPath() { + return "app/still-interesting.png"; + } + }, + CLOSE_NOTIFICATION { + @Override + public String getIconPath() { + return "app/close.png"; + } + }; +// EXPAND_ALL { +// @Override +// public String getIconPath() { +// return null; +// } +// }; + + public abstract String getIconPath(); + public static boolean contains(String entry){ + return Arrays.stream(HotKeyType.values()) + .filter(it -> it.name().equals(entry)) + .collect(Collectors.toList()) + .size() != 0; + } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationDescriptor.java index 998c45b8..bfe78403 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationDescriptor.java @@ -3,10 +3,11 @@ import com.mercury.platform.shared.entity.message.FlowDirections; import lombok.Data; +import java.io.Serializable; import java.util.List; @Data -public class NotificationDescriptor { +public class NotificationDescriptor implements Serializable{ private boolean notificationEnable; private int limitCount; private int unfoldCount; diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ResponseButtonDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ResponseButtonDescriptor.java index d0bb7304..74fad744 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ResponseButtonDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ResponseButtonDescriptor.java @@ -2,15 +2,19 @@ import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; @Data @AllArgsConstructor -public class ResponseButtonDescriptor implements Comparable{ +@NoArgsConstructor +public class ResponseButtonDescriptor implements Comparable,Serializable{ private long id; - private boolean kick; private boolean close; - private String title; - private String responseText; + private String title = "label"; + private String responseText = "response"; + private HotKeyDescriptor hotKeyDescriptor = new HotKeyDescriptor(); @Override public int compareTo(ResponseButtonDescriptor o) { diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/SoundDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/SoundDescriptor.java index efc1bdbc..d9632bea 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/SoundDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/SoundDescriptor.java @@ -4,10 +4,12 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @AllArgsConstructor @NoArgsConstructor -public class SoundDescriptor { +public class SoundDescriptor implements Serializable{ private String wavPath; private Float db; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrCaptureDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrCaptureDescriptor.java new file mode 100644 index 00000000..42104258 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrCaptureDescriptor.java @@ -0,0 +1,15 @@ +package com.mercury.platform.shared.config.descriptor.adr; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.awt.*; +import java.io.Serializable; + +@EqualsAndHashCode(callSuper = true) +@Data +public class AdrCaptureDescriptor extends AdrColoredComponentDescriptor implements Serializable { + private int fps = 5; + private Dimension captureSize = new Dimension(64,64); + private Point captureLocation; +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrColoredComponentDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrColoredComponentDescriptor.java new file mode 100644 index 00000000..9b7b6395 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrColoredComponentDescriptor.java @@ -0,0 +1,16 @@ +package com.mercury.platform.shared.config.descriptor.adr; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.awt.*; +import java.io.Serializable; + +@EqualsAndHashCode(callSuper = true) +@Data +public class AdrColoredComponentDescriptor extends AdrComponentDescriptor implements Serializable{ + private Color backgroundColor = new Color(59, 59, 59); + private Color foregroundColor = new Color(59, 59, 59, 190); + private Color borderColor = new Color(16,110,99); + private int thickness = 1; +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrComponentDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrComponentDescriptor.java index 3081badb..b45995fa 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrComponentDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrComponentDescriptor.java @@ -20,8 +20,6 @@ public class AdrComponentDescriptor implements Serializable{ private AdrComponentType type; private Point location = new Point(new Random().nextInt(600), new Random().nextInt(600)); private Dimension size = new Dimension(64, 64); - private HotKeyDescriptor hotKeyDescriptor = new HotKeyDescriptor(); - private boolean hotKeyRefresh = true; private boolean visible = true; private float scale = 1f; private float opacity = 1f; diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrComponentType.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrComponentType.java index 72f0c4e4..d3a68061 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrComponentType.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrComponentType.java @@ -5,4 +5,5 @@ public enum AdrComponentType { ICON, TRACKER_GROUP, PROGRESS_BAR, + CAPTURE } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrDurationComponentDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrDurationComponentDescriptor.java index f3af440d..db0d5d71 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrDurationComponentDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrDurationComponentDescriptor.java @@ -1,5 +1,6 @@ package com.mercury.platform.shared.config.descriptor.adr; +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -8,7 +9,9 @@ @EqualsAndHashCode(callSuper = true) @Data -public class AdrDurationComponentDescriptor extends AdrComponentDescriptor implements Serializable { +public class AdrDurationComponentDescriptor extends AdrColoredComponentDescriptor implements Serializable { + private HotKeyDescriptor hotKeyDescriptor = new HotKeyDescriptor(); + private boolean hotKeyRefresh = true; private String iconPath = "default_icon.png"; private Double duration = 3.4d; private Double delay = 0d; @@ -22,16 +25,12 @@ public class AdrDurationComponentDescriptor extends AdrComponentDescriptor imple private boolean invertMask; private boolean invertTimer; private String textFormat = "0.0"; - private Color backgroundColor = new Color(59, 59, 59); - private Color foregroundColor = new Color(59, 59, 59, 190); private Color lowValueTextColor = new Color(224,86,60); private Color mediumValueTextColor = new Color(255,211,78); private Color defaultValueTextColor = new Color(255,250,213); - private Color borderColor = new Color(16,110,99); private Double lowValueTextThreshold = 1d; private Double mediumValueTextThreshold = 3d; private Double defaultValueTextThreshold = 5d; - private int thickness = 1; private Insets insets = new Insets(0,0,0,0); private boolean bindToTextColor; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/json/deserializer/AdrComponentJsonAdapter.java b/app-core/src/main/java/com/mercury/platform/shared/config/json/deserializer/AdrComponentJsonAdapter.java index ebbf8eca..b259e57a 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/json/deserializer/AdrComponentJsonAdapter.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/json/deserializer/AdrComponentJsonAdapter.java @@ -23,6 +23,9 @@ public AdrComponentDescriptor deserialize(JsonElement jsonElement, Type type, Js case PROGRESS_BAR: { return gson.fromJson(jsonElement.getAsJsonObject(), AdrProgressBarDescriptor.class); } + case CAPTURE:{ + return gson.fromJson(jsonElement.getAsJsonObject(), AdrCaptureDescriptor.class); + } } return null; } @@ -40,6 +43,9 @@ public JsonElement serialize(AdrComponentDescriptor descriptor, Type type, JsonS case PROGRESS_BAR: { return gson.toJsonTree(descriptor, AdrProgressBarDescriptor.class); } + case CAPTURE:{ + return gson.toJsonTree(descriptor, AdrCaptureDescriptor.class); + } } return null; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/message/FlowDirections.java b/app-core/src/main/java/com/mercury/platform/shared/entity/message/FlowDirections.java index e1f722ff..94cf6d8d 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/entity/message/FlowDirections.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/message/FlowDirections.java @@ -1,5 +1,7 @@ package com.mercury.platform.shared.entity.message; -public enum FlowDirections { +import java.io.Serializable; + +public enum FlowDirections implements Serializable{ UPWARDS, DOWNWARDS } diff --git a/app-core/src/main/java/com/mercury/platform/shared/hotkey/HotKeyAdapter.java b/app-core/src/main/java/com/mercury/platform/shared/hotkey/HotKeyAdapter.java deleted file mode 100644 index 98e7f827..00000000 --- a/app-core/src/main/java/com/mercury/platform/shared/hotkey/HotKeyAdapter.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.mercury.platform.shared.hotkey; - -import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; -import lc.kra.system.keyboard.event.GlobalKeyAdapter; -import lc.kra.system.keyboard.event.GlobalKeyEvent; - -public class HotKeyAdapter extends GlobalKeyAdapter { - @Override - public void keyPressed(GlobalKeyEvent event) { - MercuryStoreCore.hotKeySubject.onNext(this.convert(event)); - } - - private HotKeyDescriptor convert(GlobalKeyEvent event) { - HotKeyDescriptor descriptor = new HotKeyDescriptor(); - descriptor.setKeyChar(event.getKeyChar()); - descriptor.setVirtualKeyCode(event.getVirtualKeyCode()); - descriptor.setControlPressed(event.isControlPressed()); - descriptor.setExtendedKey(event.isExtendedKey()); - descriptor.setMenuPressed(event.isMenuPressed()); - descriptor.setShiftPressed(event.isShiftPressed()); - return descriptor; - } -} diff --git a/app-core/src/main/java/com/mercury/platform/shared/hotkey/HotKeysInterceptor.java b/app-core/src/main/java/com/mercury/platform/shared/hotkey/HotKeysInterceptor.java index 2f48f2dd..28d384d6 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/hotkey/HotKeysInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/hotkey/HotKeysInterceptor.java @@ -1,49 +1,37 @@ package com.mercury.platform.shared.hotkey; +import org.jnativehook.GlobalScreen; +import org.jnativehook.NativeHookException; -import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; -import lc.kra.system.keyboard.GlobalKeyboardHook; -import lc.kra.system.mouse.GlobalMouseHook; -import lc.kra.system.mouse.event.GlobalMouseAdapter; -import lc.kra.system.mouse.event.GlobalMouseEvent; +import java.util.logging.Level; +import java.util.logging.Logger; public class HotKeysInterceptor { public HotKeysInterceptor() { - GlobalKeyboardHook keyboardHook = new GlobalKeyboardHook(false); - keyboardHook.addKeyListener(new HotKeyAdapter()); + Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName()); + logger.setLevel(Level.OFF); - GlobalMouseHook mouseHook = new GlobalMouseHook(false); - mouseHook.addMouseListener(new GlobalMouseAdapter() { - @Override - public void mousePressed(GlobalMouseEvent globalMouseEvent) { - MercuryStoreCore.hotKeySubject.onNext(this.convert(globalMouseEvent)); - } - private HotKeyDescriptor convert(GlobalMouseEvent event) { - HotKeyDescriptor descriptor = new HotKeyDescriptor(); - switch (event.getButton()){ - case 1: { - descriptor.setVirtualKeyCode(1000); - descriptor.setTitle("Mouse left"); - break; - } - case 2: { - descriptor.setVirtualKeyCode(1002); - descriptor.setTitle("Mouse right"); - break; - } - case 16: { - descriptor.setVirtualKeyCode(1016); - descriptor.setTitle("Mouse middle"); - break; - } - } - return descriptor; - } - }); + logger.setUseParentHandlers(false); + try { + GlobalScreen.registerNativeHook(); + } catch (NativeHookException e) { + e.printStackTrace(); + } + GlobalScreen.addNativeKeyListener(new MercuryNativeKeyListener()); + GlobalScreen.addNativeMouseListener(new MercuryNativeMouseListener()); } public static void main(String[] args) { - new HotKeysInterceptor(); +// new HotKeysInterceptor(); + Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName()); + logger.setLevel(Level.OFF); + + logger.setUseParentHandlers(false); + try { + GlobalScreen.registerNativeHook(); + } catch (NativeHookException e) { + e.printStackTrace(); + } + GlobalScreen.addNativeMouseListener(new MercuryNativeMouseListener()); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/hotkey/MercuryNativeKeyListener.java b/app-core/src/main/java/com/mercury/platform/shared/hotkey/MercuryNativeKeyListener.java new file mode 100644 index 00000000..51090bcc --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/hotkey/MercuryNativeKeyListener.java @@ -0,0 +1,74 @@ +package com.mercury.platform.shared.hotkey; + + +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import org.jnativehook.keyboard.NativeKeyEvent; +import org.jnativehook.keyboard.NativeKeyListener; + +public class MercuryNativeKeyListener implements NativeKeyListener{ + private boolean menuPressed; + private boolean shiftPressed; + private boolean ctrlpressed; + @Override + public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) { + switch (nativeKeyEvent.getKeyCode()){ + case 42 : { + this.shiftPressed = true; + break; + } + case 29: { + this.ctrlpressed = true; + break; + } + case 56: { + this.menuPressed = true; + break; + } + default:{ + HotKeyDescriptor hotKeyDescriptor = new HotKeyDescriptor(); + hotKeyDescriptor.setTitle(NativeKeyEvent.getKeyText(nativeKeyEvent.getKeyCode())); + hotKeyDescriptor.setVirtualKeyCode(nativeKeyEvent.getKeyCode()); + hotKeyDescriptor.setControlPressed(this.ctrlpressed); + hotKeyDescriptor.setShiftPressed(this.shiftPressed); + hotKeyDescriptor.setMenuPressed(this.menuPressed); + + hotKeyDescriptor.setTitle(this.getButtonText(hotKeyDescriptor)); + MercuryStoreCore.hotKeySubject.onNext(hotKeyDescriptor); + } + } + } + + @Override + public void nativeKeyReleased(NativeKeyEvent nativeKeyEvent) { + switch (nativeKeyEvent.getKeyCode()){ + case 42 : { + this.shiftPressed = false; + break; + } + case 29: { + this.ctrlpressed = false; + break; + } + case 56: { + this.menuPressed = false; + break; + } + } + } + + @Override + public void nativeKeyTyped(NativeKeyEvent nativeKeyEvent) { + + } + private String getButtonText(HotKeyDescriptor descriptor){ + String text = descriptor.getTitle(); + if(descriptor.isShiftPressed()) + text = "Shift + " + text; + if(descriptor.isMenuPressed()) + text = "Alt + " + text; + if(descriptor.isControlPressed()) + text = "Ctrl + " + text; + return text; + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/hotkey/MercuryNativeMouseListener.java b/app-core/src/main/java/com/mercury/platform/shared/hotkey/MercuryNativeMouseListener.java new file mode 100644 index 00000000..d80943e3 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/shared/hotkey/MercuryNativeMouseListener.java @@ -0,0 +1,53 @@ +package com.mercury.platform.shared.hotkey; + +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import org.jnativehook.mouse.NativeMouseEvent; +import org.jnativehook.mouse.NativeMouseListener; + +public class MercuryNativeMouseListener implements NativeMouseListener { + @Override + public void nativeMouseClicked(NativeMouseEvent nativeMouseEvent) { + } + + @Override + public void nativeMousePressed(NativeMouseEvent nativeMouseEvent) { + HotKeyDescriptor hotKeyDescriptor = new HotKeyDescriptor(); + hotKeyDescriptor.setVirtualKeyCode(nativeMouseEvent.getButton() + 10000); + hotKeyDescriptor.setTitle(this.getModifiersText(nativeMouseEvent.getButton())); + MercuryStoreCore.hotKeySubject.onNext(hotKeyDescriptor); + } + + @Override + public void nativeMouseReleased(NativeMouseEvent nativeMouseEvent) { + } + + private String getModifiersText(int code) { + switch (code) { + case 1: { + return "Mouse left"; + } + case 2: { + return "Mouse right"; + } + case 3: { + return "Mouse middle"; + } + case 4: { + return "Button 4"; + } + case 5: { + return "Button 5"; + } + case 6: { + return "Button 6"; + } + case 7: { + return "Button 7"; + } + default: { + return "Undefined"; + } + } + } +} diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java index ebfae0fb..f2861114 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java @@ -9,7 +9,6 @@ import com.mercury.platform.shared.entity.message.MercuryError; import com.mercury.platform.shared.entity.message.Message; import com.mercury.platform.shared.config.descriptor.SoundDescriptor; -import lc.kra.system.keyboard.event.GlobalKeyEvent; import rx.subjects.PublishSubject; diff --git a/app-core/src/test/java/com/mercury/platform/shared/MainTestKeyHook.java b/app-core/src/test/java/com/mercury/platform/shared/MainTestKeyHook.java new file mode 100644 index 00000000..7a921ab7 --- /dev/null +++ b/app-core/src/test/java/com/mercury/platform/shared/MainTestKeyHook.java @@ -0,0 +1,38 @@ +package com.mercury.platform.shared; + +import com.sun.jna.platform.win32.Kernel32; +import com.sun.jna.platform.win32.User32; +import com.sun.jna.platform.win32.WinDef.HINSTANCE; +import com.sun.jna.platform.win32.WinDef.LPARAM; +import com.sun.jna.platform.win32.WinDef.LRESULT; +import com.sun.jna.platform.win32.WinDef.WPARAM; +import com.sun.jna.platform.win32.WinUser.HOOKPROC; + +public class MainTestKeyHook { + + + public static void main(String[] args) throws Exception { + HOOKPROC hookProc = new HOOKPROC_bg(); + HINSTANCE hInst = Kernel32.INSTANCE.GetModuleHandle(null); + + User32.HHOOK hHook = User32.INSTANCE.SetWindowsHookEx(User32.WH_KEYBOARD_LL, hookProc, hInst, 0); + if (hHook == null) + return; + User32.MSG msg = new User32.MSG(); + System.err.println("Please press any key ...."); + while (true) { + User32.INSTANCE.GetMessage(msg, null, 0, 0); + } + } +} + +class HOOKPROC_bg implements HOOKPROC { + + public HOOKPROC_bg() { + } + + public LRESULT callback(int nCode, WPARAM wParam, LPARAM lParam) { + System.err.println("callback bbbnhkilhjkibh nCode: " + nCode); + return new LRESULT(0); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/AdrManager.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/AdrManager.java index 663144ee..c8204d7c 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/AdrManager.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/AdrManager.java @@ -7,7 +7,12 @@ import com.mercury.platform.shared.config.descriptor.adr.*; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.adr.components.*; +import com.mercury.platform.ui.adr.components.factory.FrameProviderFactory; +import com.mercury.platform.ui.adr.components.factory.frame.FrameProvider; +import com.mercury.platform.ui.adr.components.panel.AdrCaptureOutPanel; +import com.mercury.platform.ui.adr.components.panel.AdrCapturePanel; import com.mercury.platform.ui.adr.components.panel.page.*; +import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.misc.MercuryStoreUI; import lombok.Getter; @@ -15,6 +20,7 @@ import java.awt.*; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; public class AdrManager implements AsSubscriber{ private List frames = new ArrayList<>(); @@ -28,20 +34,24 @@ public class AdrManager implements AsSubscriber{ private AdrPagePanel iconSettingsPanel; private AdrPagePanel progressBarSettingsPanel; private AdrPagePanel> profileSettingsPanel; + private AdrPagePanel captureSettingsPanel; private AdrLoadingPage loadingPage; - private SwingWorker worker; + private FrameProviderFactory frameProviderFactory; @Getter private AdrState state = AdrState.DEFAULT; public void load(){ this.config = Configuration.get().adrConfiguration(); + this.frameProviderFactory = new FrameProviderFactory(); + this.groupSettingsPanel = new AdrGroupPagePanel(); this.mainPanel = new AdrMainPagePanel(this.config); this.iconSettingsPanel = new AdrIconPagePanel(); this.progressBarSettingsPanel = new AdrProgressBarPagePanel(); this.profileSettingsPanel = new AdrProfilePagePanel(); + this.captureSettingsPanel = new AdrCapturePagePanel(); this.loadingPage = new AdrLoadingPage(); @@ -50,12 +60,8 @@ public void load(){ .filter(AdrProfileDescriptor::isSelected) .findAny().orElse(null); this.adrManagerFrame = new AdrManagerFrame(this.selectedProfile); - this.initComponents(); + this.initComponents(false); this.adrManagerFrame.init(); - this.frames.forEach(it -> { - it.init(); - it.disableSettings(); - }); this.subscribe(); @@ -99,23 +105,19 @@ public void subscribe() { case NEW_COMPONENT:{ if(definition.getDescriptor() instanceof AdrTrackerGroupDescriptor){ this.selectedProfile.getContents().add(definition.getDescriptor()); - AdrTrackerGroupFrame adrTrackerGroupFrame = - new AdrTrackerGroupFrame((AdrTrackerGroupDescriptor) definition.getDescriptor()); - adrTrackerGroupFrame.init(); - adrTrackerGroupFrame.showComponent(); - adrTrackerGroupFrame.enableSettings(); - this.frames.add(adrTrackerGroupFrame); + AbstractAdrFrame frame = this.frameProviderFactory + .getProviderFor(definition.getDescriptor()) + .getFrame(true); + this.frames.add(frame); this.groupSettingsPanel.setPayload((AdrTrackerGroupDescriptor) definition.getDescriptor()); this.adrManagerFrame.setPage(this.groupSettingsPanel); } if(definition.getDescriptor() instanceof AdrDurationComponentDescriptor){ if(definition.getParent() == null){ this.selectedProfile.getContents().add(definition.getDescriptor()); - AdrSingleComponentFrame componentFrame = - new AdrSingleComponentFrame((AdrDurationComponentDescriptor) definition.getDescriptor()); - componentFrame.init(); - componentFrame.showComponent(); - componentFrame.enableSettings(); + AbstractAdrFrame componentFrame = this.frameProviderFactory + .getProviderFor(definition.getDescriptor()) + .getFrame(true); this.frames.add(componentFrame); }else { ((AdrTrackerGroupDescriptor)definition.getParent()).getCells().add(definition.getDescriptor()); @@ -130,6 +132,22 @@ public void subscribe() { this.adrManagerFrame.setPage(this.progressBarSettingsPanel); } } + if(definition.getDescriptor() instanceof AdrCaptureDescriptor){ + AdrCaptureDescriptor descriptor = (AdrCaptureDescriptor) definition.getDescriptor(); + this.frames.add(this.frameProviderFactory.getProviderFor(descriptor).getFrame(true)); + + AdrCaptureOutComponentFrame outFrame = new AdrCaptureOutComponentFrame((AdrCaptureDescriptor) descriptor); + outFrame.setPanel(new AdrCaptureOutPanel((AdrCaptureDescriptor) descriptor,new ComponentsFactory())); + outFrame.init(); + outFrame.showComponent(); + outFrame.enableSettings(); + this.frames.add(outFrame); + + this.captureSettingsPanel.setPayload((AdrCaptureDescriptor) definition.getDescriptor()); + this.adrManagerFrame.setPage(this.captureSettingsPanel); + + this.selectedProfile.getContents().add(definition.getDescriptor()); + } this.adrManagerFrame.addNewNode(definition.getDescriptor(),definition.getParent()); MercuryStoreUI.adrSelectSubject.onNext(definition.getDescriptor()); MercuryStoreCore.saveConfigSubject.onNext(true); @@ -151,6 +169,10 @@ public void subscribe() { this.progressBarSettingsPanel.setPayload((AdrProgressBarDescriptor) definition.getDescriptor()); this.adrManagerFrame.setPage(this.progressBarSettingsPanel); } + if(definition.getDescriptor() instanceof AdrCaptureDescriptor){ + this.captureSettingsPanel.setPayload((AdrCaptureDescriptor) definition.getDescriptor()); + this.adrManagerFrame.setPage(this.captureSettingsPanel); + } break; } case DUPLICATE_COMPONENT:{ @@ -169,18 +191,17 @@ public void subscribe() { } }); MercuryStoreUI.adrRemoveComponentSubject.subscribe(descriptor -> { - AbstractAdrFrame targetFrame = + List targetFrames = this.frames.stream() - .filter(it -> it.getDescriptor().equals(descriptor)) - .findAny().orElse(null); - if(targetFrame != null) { + .filter(it -> it.getDescriptor().equals(descriptor)).collect(Collectors.toList()); + targetFrames.forEach(targetFrame -> { targetFrame.onDestroy(); targetFrame.disableSettings(); targetFrame.setVisible(false); this.frames.remove(targetFrame); this.selectedProfile.getContents().remove(descriptor); targetFrame.dispose(); - } + }); this.mainPanel.setFromGroup(false); this.mainPanel.setPayload(null); this.adrManagerFrame.removeNode(descriptor); @@ -224,15 +245,10 @@ private void selectProfile(String profileName){ selectedProfile.setSelected(true); this.selectedProfile = selectedProfile; - this.worker = new SwingWorker() { + SwingWorker worker = new SwingWorker() { @Override protected Void doInBackground() throws Exception { - initComponents(); - frames.forEach(it -> { - it.init(); - it.showComponent(); - it.enableSettings(); - }); + initComponents(true); return null; } @@ -246,27 +262,34 @@ protected void done() { MercuryStoreUI.adrManagerPack.onNext(true); } }; - this.worker.execute(); + worker.execute(); this.adrManagerFrame.setSelectedProfile(selectedProfile); + MercuryStoreCore.saveConfigSubject.onNext(true); } - private void initComponents(){ + private void initComponents(boolean showSettings){ MercuryStoreUI.onDestroySubject.onNext(true); - this.frames.forEach(Window::dispose); + this.frames.forEach(it -> { + it.onDestroy(); + it.disableSettings(); + it.setVisible(false); + it.dispose(); + }); this.frames.clear(); this.selectedProfile.getContents().forEach(component -> { - switch (component.getType()){ - case TRACKER_GROUP: { - this.frames.add(new AdrTrackerGroupFrame((AdrTrackerGroupDescriptor) component)); - break; - } - case PROGRESS_BAR:{ - this.frames.add(new AdrSingleComponentFrame((AdrProgressBarDescriptor) component)); - break; - } - case ICON:{ - this.frames.add(new AdrSingleComponentFrame((AdrIconDescriptor) component)); - break; + if(component instanceof AdrCaptureDescriptor){ + this.frames.add(this.frameProviderFactory.getProviderFor(component).getFrame(showSettings)); + AdrCaptureOutComponentFrame outFrame = new AdrCaptureOutComponentFrame((AdrCaptureDescriptor) component); + outFrame.setPanel(new AdrCaptureOutPanel((AdrCaptureDescriptor) component,new ComponentsFactory())); + outFrame.init(); + if(showSettings) { + outFrame.showComponent(); + outFrame.enableSettings(); + }else { + outFrame.disableSettings(); } + this.frames.add(outFrame); + }else { + this.frames.add(this.frameProviderFactory.getProviderFor(component).getFrame(showSettings)); } }); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AbstractAdrComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AbstractAdrComponentFrame.java index 83a65e5a..977b5574 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AbstractAdrComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AbstractAdrComponentFrame.java @@ -21,9 +21,6 @@ public abstract class AbstractAdrComponentFrame(this.getRootPane(),this.descriptor,false); } - @Override - protected void initialize() { - this.setLocation(descriptor.getLocation()); - this.setOpacity(descriptor.getOpacity()); - this.componentsFactory.setScale(descriptor.getScale()); - } - - @Override - public void subscribe() { - this.adrRepaintSubscription = MercuryStoreUI.adrRepaintSubject.subscribe(state -> { - this.repaint(); - this.pack(); - }); - this.adrVisibleSubscription = MercuryStoreCore.adrVisibleSubject.subscribe(state -> { - switch (state) { - case SHOW: { - this.processingHideEvent = false; - break; - } - case HIDE: { - this.processingHideEvent = true; - break; - } - } - }); - MercuryStoreUI.onDestroySubject.subscribe(state -> this.onDestroy()); - } @Override public void enableSettings() { @@ -79,14 +49,13 @@ public void disableSettings() { @Override public void onDestroy() { + super.onDestroy(); this.mouseOverListener.onDestroy(); - this.adrRepaintSubscription.unsubscribe(); - this.adrVisibleSubscription.unsubscribe(); } @Override protected LayoutManager getFrameLayout() { - return new BorderLayout(); + return new GridLayout(1,1); } public class DraggedFrameMotionListener extends MouseAdapter { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AbstractAdrFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AbstractAdrFrame.java index 3af5e707..34e09184 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AbstractAdrFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AbstractAdrFrame.java @@ -2,13 +2,17 @@ import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; import com.mercury.platform.shared.store.DestroySubscription; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.adr.components.panel.AdrComponentPanel; import com.mercury.platform.ui.frame.AbstractOverlaidFrame; +import com.mercury.platform.ui.misc.MercuryStoreUI; import com.sun.awt.AWTUtilities; import com.sun.jna.Native; import com.sun.jna.platform.win32.User32; import com.sun.jna.platform.win32.WinDef; import com.sun.jna.platform.win32.WinUser; import lombok.Getter; +import rx.Subscription; import java.awt.*; @@ -18,11 +22,41 @@ public abstract class AbstractAdrFrame extends protected T descriptor; private WinDef.HWND componentHwnd; + private Subscription adrRepaintSubscription; + private Subscription adrVisibleSubscription; + protected AbstractAdrFrame(T descriptor) { super(); this.descriptor = descriptor; AWTUtilities.setWindowOpaque(this, false); } + @Override + protected void initialize() { + this.setLocation(descriptor.getLocation()); + this.setOpacity(descriptor.getOpacity()); + this.componentsFactory.setScale(descriptor.getScale()); + } + + @Override + public void subscribe() { + this.adrRepaintSubscription = MercuryStoreUI.adrRepaintSubject.subscribe(state -> { + this.repaint(); + this.pack(); + }); + this.adrVisibleSubscription = MercuryStoreCore.adrVisibleSubject.subscribe(state -> { + switch (state) { + case SHOW: { + this.processingHideEvent = false; + break; + } + case HIDE: { + this.processingHideEvent = true; + break; + } + } + }); + MercuryStoreUI.onDestroySubject.subscribe(state -> this.onDestroy()); + } private void setTransparent(Component w) { this.componentHwnd = getHWnd(w); @@ -38,6 +72,14 @@ private static WinDef.HWND getHWnd(Component w) { return hwnd; } + @Override + public void onDestroy() { + this.adrRepaintSubscription.unsubscribe(); + this.adrVisibleSubscription.unsubscribe(); + } + + public abstract void setPanel(AdrComponentPanel panel); + public void enableSettings() { User32.INSTANCE.SetWindowLong(componentHwnd, WinUser.GWL_EXSTYLE, settingWl); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrCaptureOutComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrCaptureOutComponentFrame.java new file mode 100644 index 00000000..a3059786 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrCaptureOutComponentFrame.java @@ -0,0 +1,137 @@ +package com.mercury.platform.ui.adr.components; + +import com.mercury.platform.shared.config.descriptor.adr.AdrCaptureDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.adr.components.panel.AdrComponentPanel; +import com.mercury.platform.ui.adr.components.panel.tree.AdrMouseOverListener; +import com.mercury.platform.ui.misc.MercuryStoreUI; +import lombok.Getter; +import rx.Subscription; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + + +public class AdrCaptureOutComponentFrame extends AbstractAdrFrame{ + private int x; + private int y; + @Getter + private AdrComponentPanel component; + + private CaptureDraggedFrameMotionListener motionListener; + private CaptureDraggedFrameMouseListener mouseListener; + private AdrMouseOverListener mouseOverListener; + + private Subscription adrReloadSubscription; + public AdrCaptureOutComponentFrame(AdrCaptureDescriptor descriptor) { + super(descriptor); + + this.mouseListener = new CaptureDraggedFrameMouseListener(); + this.motionListener = new CaptureDraggedFrameMotionListener(); + this.mouseOverListener = new AdrMouseOverListener<>(this.getRootPane(),this.descriptor,false); + } + + @Override + public void setPanel(AdrComponentPanel panel) { + this.component = panel; + } + + @Override + protected LayoutManager getFrameLayout() { + return new GridLayout(1,1); + } + + @Override + protected void initialize() { + this.setLocation(descriptor.getCaptureLocation()); + this.componentsFactory.setScale(descriptor.getScale()); + this.setLayout(new GridLayout(1,1)); + this.add(this.component); + this.pack(); + } + @Override + public void subscribe() { + super.subscribe(); + this.adrReloadSubscription = MercuryStoreUI.adrReloadSubject.subscribe(descriptor -> { + if(descriptor.equals(this.descriptor)){ + this.setLocation(this.descriptor.getCaptureLocation()); + this.setPreferredSize(this.descriptor.getCaptureSize()); + this.repaint(); + this.pack(); + } + }); + } + @Override + public void enableSettings() { + super.enableSettings(); + this.component.enableSettings(); + + this.addMouseListener(this.mouseListener); + this.addMouseListener(this.mouseOverListener); + this.addMouseMotionListener(this.motionListener); + + this.component.addMouseListener(this.mouseListener); + this.component.addMouseListener(this.mouseOverListener); + this.component.addMouseMotionListener(this.motionListener); + } + + @Override + public void disableSettings() { + super.disableSettings(); + this.component.disableSettings(); + this.removeMouseListener(this.mouseListener); + this.removeMouseListener(this.mouseOverListener); + this.removeMouseMotionListener(this.motionListener); + + this.component.removeMouseListener(this.mouseListener); + this.component.removeMouseListener(this.mouseOverListener); + this.component.removeMouseMotionListener(this.motionListener); + + this.getRootPane().setBorder(BorderFactory.createEmptyBorder(1,1,1,1)); + this.pack(); + this.repaint(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + this.adrReloadSubscription.unsubscribe(); + this.component.onDestroy(); + } + + + public class CaptureDraggedFrameMotionListener extends MouseAdapter { + @Override + public void mouseDragged(MouseEvent e) { + if(SwingUtilities.isLeftMouseButton(e)) { + e.translatePoint(AdrCaptureOutComponentFrame.this.getLocation().x - x, AdrCaptureOutComponentFrame.this.getLocation().y - y); + Point point = e.getPoint(); + AdrCaptureOutComponentFrame.this.setLocation(point); + } + } + } + public class CaptureDraggedFrameMouseListener extends MouseAdapter{ + @Override + public void mousePressed(MouseEvent e) { + if(SwingUtilities.isLeftMouseButton(e)) { + x = e.getX(); + y = e.getY(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + if(SwingUtilities.isLeftMouseButton(e)) { + Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); + if (getLocationOnScreen().y + getSize().height > dimension.height) { + setLocation(getLocationOnScreen().x, dimension.height - getSize().height); + } + descriptor.setCaptureLocation(getLocationOnScreen()); + MercuryStoreUI.adrUpdateSubject.onNext(descriptor); + MercuryStoreCore.saveConfigSubject.onNext(true); + } + } + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrComponentsFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrComponentsFactory.java index 42eebd27..76f4d383 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrComponentsFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrComponentsFactory.java @@ -80,6 +80,27 @@ public JPanel getComponentSizePanel(AdrComponentDescriptor descriptor, boolean f return root; } + public JPanel getCaptureSizePanel(AdrCaptureDescriptor descriptor){ + JPanel root = this.componentsFactory.getJPanel(new GridLayout(1, 4,4,0)); + root.setBackground(AppThemeColor.SLIDE_BG); + JLabel widthLabel = this.componentsFactory.getTextLabel("Width:"); + JLabel heightLabel = this.componentsFactory.getTextLabel("Height:"); + JTextField widthField = this.getSmartField(descriptor.getCaptureSize().width, new IntegerFieldValidator(10,2000), value -> { + descriptor.setCaptureSize(new Dimension(value, descriptor.getCaptureSize().height)); + MercuryStoreUI.adrReloadSubject.onNext(descriptor); + }); + JTextField heightField = this.getSmartField(descriptor.getCaptureSize().height, new IntegerFieldValidator(10,1000), value -> { + descriptor.setCaptureSize(new Dimension(descriptor.getCaptureSize().width,value)); + MercuryStoreUI.adrReloadSubject.onNext(descriptor); + }); + + root.add(widthLabel); + root.add(widthField); + root.add(heightLabel); + root.add(heightField); + return root; + } + public JPanel getLocationPanel(AdrComponentDescriptor descriptor, boolean fromGroup){ JPanel root = this.componentsFactory.getJPanel(new GridLayout(1, 4,4,0)); root.setBackground(AppThemeColor.SLIDE_BG); @@ -121,8 +142,35 @@ public JPanel getLocationPanel(AdrComponentDescriptor descriptor, boolean fromGr return root; } - public JButton getHotKeyButton(AdrComponentDescriptor descriptor) { - JButton button = this.componentsFactory.getBorderedButton(this.getButtonText(descriptor.getHotKeyDescriptor())); + public JPanel getCaptureLocationPanel(AdrCaptureDescriptor descriptor){ + JPanel root = this.componentsFactory.getJPanel(new GridLayout(1, 4,4,0)); + root.setBackground(AppThemeColor.SLIDE_BG); + JLabel xLabel = this.componentsFactory.getTextLabel("X:"); + JLabel yLabel = this.componentsFactory.getTextLabel("Y:"); + JTextField xField = this.getSmartField(descriptor.getCaptureLocation().x,new IntegerFieldValidator(0,10000),value -> { + descriptor.setCaptureLocation(new Point(value, descriptor.getCaptureLocation().y)); + MercuryStoreUI.adrReloadSubject.onNext(descriptor); + }); + JTextField yField = this.getSmartField(descriptor.getCaptureLocation().y,new IntegerFieldValidator(0,5000),value -> { + descriptor.setCaptureLocation(new Point(descriptor.getCaptureLocation().x,value)); + MercuryStoreUI.adrReloadSubject.onNext(descriptor); + }); + root.add(xLabel); + root.add(xField); + root.add(yLabel); + root.add(yField); + + MercuryStoreUI.adrUpdateSubject.subscribe(source -> { + if(source.equals(descriptor)){ + xField.setText(String.valueOf(descriptor.getCaptureLocation().x)); + yField.setText(String.valueOf(descriptor.getCaptureLocation().y)); + } + }); + return root; + } + + public JButton getHotKeyButton(AdrDurationComponentDescriptor descriptor) { + JButton button = this.componentsFactory.getBorderedButton(descriptor.getHotKeyDescriptor().getTitle()); button.setFont(this.componentsFactory.getFont(FontStyle.BOLD, 18f)); MouseAdapter mouseAdapter = new MouseAdapter() { @Override @@ -144,7 +192,7 @@ public void mousePressed(MouseEvent e) { } else { descriptor.setHotKeyDescriptor(hotKey); } - button.setText(getButtonText(descriptor.getHotKeyDescriptor())); + button.setText(hotKey.getTitle()); allowed = false; MercuryStoreUI.adrReloadSubject.onNext(descriptor); button.addMouseListener(mouseAdapter); @@ -153,7 +201,7 @@ public void mousePressed(MouseEvent e) { return button; } - public JPanel getHotKeyPanel(AdrComponentDescriptor descriptor){ + public JPanel getHotKeyPanel(AdrDurationComponentDescriptor descriptor){ JButton hotKeyButton = this.getHotKeyButton(descriptor); JPanel hotKeyPanel = this.componentsFactory.getJPanel(new BorderLayout()); hotKeyPanel.setBackground(AppThemeColor.SLIDE_BG); @@ -354,6 +402,18 @@ public void mouseReleased(MouseEvent e) { }); return opacitySlider; } + public JSlider getFpsSlider(AdrCaptureDescriptor descriptor){ + JSlider opacitySlider = this.componentsFactory.getSlider(1,60, descriptor.getFps()); + opacitySlider.setBackground(AppThemeColor.SLIDE_BG); + opacitySlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + descriptor.setFps(opacitySlider.getValue()); + MercuryStoreUI.adrReloadSubject.onNext(descriptor); + } + }); + return opacitySlider; + } public JTextField getFontSizeField(AdrDurationComponentDescriptor descriptor){ return this.getSmartField(descriptor.getFontSize(), new IntegerFieldValidator(4, 1000), value -> { descriptor.setFontSize(value); @@ -821,22 +881,6 @@ private JColorChooser getColorChooser(){ } return colorChooser; } - private String getButtonText(HotKeyDescriptor descriptor){ - if(!descriptor.getTitle().equals("")){ - return descriptor.getTitle(); - } - if(descriptor.getKeyChar() == '\u0000') { - return "..."; - } - String text = String.valueOf(descriptor.getKeyChar()); - if(descriptor.isShiftPressed()) - text = "Shift + " + text; - if(descriptor.isMenuPressed()) - text = "Alt + " + text; - if(descriptor.isControlPressed()) - text = "Ctrl + " + text; - return text; - } private class ColorChooserMouseListener extends MouseAdapter { private JPanel panel; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrSingleComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrSingleComponentFrame.java index 1285f775..12113523 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrSingleComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrSingleComponentFrame.java @@ -1,30 +1,32 @@ package com.mercury.platform.ui.adr.components; -import com.mercury.platform.shared.config.descriptor.adr.AdrDurationComponentDescriptor; -import com.mercury.platform.ui.adr.components.panel.AdrCellPanel; -import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; +import com.mercury.platform.ui.adr.components.panel.AdrComponentPanel; import com.mercury.platform.ui.misc.MercuryStoreUI; +import lombok.Getter; import rx.Subscription; import javax.swing.*; import java.awt.*; -public class AdrSingleComponentFrame extends AbstractAdrComponentFrame { - private AdrCellPanel component; +public class AdrSingleComponentFrame extends AbstractAdrComponentFrame { + @Getter + private AdrComponentPanel component; private Subscription adrReloadSubscription; - public AdrSingleComponentFrame(AdrDurationComponentDescriptor descriptor) { + public AdrSingleComponentFrame(AdrComponentDescriptor descriptor) { super(descriptor); } + @Override + public void setPanel(AdrComponentPanel panel) { + this.component = panel; + } + @Override protected void initialize() { super.initialize(); - - JPanel root = this.componentsFactory.getTransparentPanel(new GridLayout(1,1)); - this.component = new AdrCellPanel(this.descriptor, this.componentsFactory); - root.add(this.component); - this.add(root,BorderLayout.CENTER); + this.add(this.component); this.pack(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrTrackerGroupFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrTrackerGroupFrame.java index cdff31ee..fa9e734b 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrTrackerGroupFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/AdrTrackerGroupFrame.java @@ -1,6 +1,7 @@ package com.mercury.platform.ui.adr.components; import com.mercury.platform.shared.config.descriptor.adr.*; +import com.mercury.platform.ui.adr.components.panel.AdrComponentPanel; import com.mercury.platform.ui.adr.components.panel.AdrTrackerGroupPanel; import com.mercury.platform.ui.misc.MercuryStoreUI; import lombok.NonNull; @@ -17,11 +18,15 @@ public AdrTrackerGroupFrame(@NonNull AdrTrackerGroupDescriptor descriptor) { super(descriptor); } + @Override + public void setPanel(AdrComponentPanel panel) { + this.trackerGroupPanel = new AdrTrackerGroupPanel(this.descriptor,this.componentsFactory); + } + @Override protected void initialize() { super.initialize(); - this.trackerGroupPanel = new AdrTrackerGroupPanel(this.descriptor,this.componentsFactory); - this.add(this.trackerGroupPanel,BorderLayout.CENTER); + this.add(this.trackerGroupPanel); this.pack(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/FrameProviderFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/FrameProviderFactory.java new file mode 100644 index 00000000..0dcf8051 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/FrameProviderFactory.java @@ -0,0 +1,26 @@ +package com.mercury.platform.ui.adr.components.factory; + + +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; +import com.mercury.platform.ui.adr.components.factory.frame.*; + +import java.util.ArrayList; +import java.util.List; + +public class FrameProviderFactory { + private List providers = new ArrayList<>(); + + public FrameProviderFactory() { + this.providers.add(new IconFrameProvider()); + this.providers.add(new PBFrameProvider()); + this.providers.add(new TrackerGroupFrameProvider()); + this.providers.add(new CaptureInFrameProvider()); + } + + public FrameProvider getProviderFor(AdrComponentDescriptor descriptor){ + return this.providers + .stream() + .filter(it -> it.isSuitable(descriptor)) + .findAny().orElse(null); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/CaptureInFrameProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/CaptureInFrameProvider.java new file mode 100644 index 00000000..947af6e0 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/CaptureInFrameProvider.java @@ -0,0 +1,22 @@ +package com.mercury.platform.ui.adr.components.factory.frame; + +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentType; +import com.mercury.platform.shared.config.descriptor.adr.AdrCaptureDescriptor; +import com.mercury.platform.ui.adr.components.panel.AdrCapturePanel; +import com.mercury.platform.ui.adr.components.panel.AdrComponentPanel; +import com.mercury.platform.ui.components.ComponentsFactory; + + +public class CaptureInFrameProvider extends SingleFrameProvider { + @Override + public boolean isSuitable(AdrComponentDescriptor descriptor) { + this.descriptor = descriptor; + return descriptor.getType().equals(AdrComponentType.CAPTURE); + } + + @Override + public AdrComponentPanel getPanel() { + return new AdrCapturePanel((AdrCaptureDescriptor) this.descriptor,new ComponentsFactory()); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/FrameProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/FrameProvider.java new file mode 100644 index 00000000..151ca55a --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/FrameProvider.java @@ -0,0 +1,12 @@ +package com.mercury.platform.ui.adr.components.factory.frame; + + +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; +import com.mercury.platform.ui.adr.components.AbstractAdrFrame; +import com.mercury.platform.ui.adr.components.panel.AdrComponentPanel; + +public interface FrameProvider { + boolean isSuitable(AdrComponentDescriptor descriptor); + AbstractAdrFrame getFrame(boolean showSettings); + AdrComponentPanel getPanel(); +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/IconFrameProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/IconFrameProvider.java new file mode 100644 index 00000000..12cf8725 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/IconFrameProvider.java @@ -0,0 +1,13 @@ +package com.mercury.platform.ui.adr.components.factory.frame; + +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentType; + + +public class IconFrameProvider extends SingleFrameProvider { + @Override + public boolean isSuitable(AdrComponentDescriptor descriptor) { + this.descriptor = descriptor; + return descriptor.getType().equals(AdrComponentType.ICON); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/PBFrameProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/PBFrameProvider.java new file mode 100644 index 00000000..c2037e49 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/PBFrameProvider.java @@ -0,0 +1,12 @@ +package com.mercury.platform.ui.adr.components.factory.frame; + +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentType; + +public class PBFrameProvider extends SingleFrameProvider { + @Override + public boolean isSuitable(AdrComponentDescriptor descriptor) { + this.descriptor = descriptor; + return descriptor.getType().equals(AdrComponentType.PROGRESS_BAR); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/SingleFrameProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/SingleFrameProvider.java new file mode 100644 index 00000000..b49bcd9a --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/SingleFrameProvider.java @@ -0,0 +1,31 @@ +package com.mercury.platform.ui.adr.components.factory.frame; + +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; +import com.mercury.platform.shared.config.descriptor.adr.AdrDurationComponentDescriptor; +import com.mercury.platform.ui.adr.components.AbstractAdrFrame; +import com.mercury.platform.ui.adr.components.AdrSingleComponentFrame; +import com.mercury.platform.ui.adr.components.panel.AdrComponentPanel; +import com.mercury.platform.ui.adr.components.panel.AdrDurationCellPanel; +import com.mercury.platform.ui.components.ComponentsFactory; + +public abstract class SingleFrameProvider implements FrameProvider{ + protected AdrComponentDescriptor descriptor; + @Override + public AbstractAdrFrame getFrame(boolean showSettings) { + AdrSingleComponentFrame frame = new AdrSingleComponentFrame(descriptor); + frame.setPanel(this.getPanel()); + frame.init(); + if(showSettings) { + frame.showComponent(); + frame.enableSettings(); + }else { + frame.disableSettings(); + } + return frame; + } + + @Override + public AdrComponentPanel getPanel() { + return new AdrDurationCellPanel((AdrDurationComponentDescriptor) this.descriptor,new ComponentsFactory()); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/TrackerGroupFrameProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/TrackerGroupFrameProvider.java new file mode 100644 index 00000000..877e60c3 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/factory/frame/TrackerGroupFrameProvider.java @@ -0,0 +1,40 @@ +package com.mercury.platform.ui.adr.components.factory.frame; + +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentType; +import com.mercury.platform.shared.config.descriptor.adr.AdrTrackerGroupDescriptor; +import com.mercury.platform.ui.adr.components.AbstractAdrFrame; +import com.mercury.platform.ui.adr.components.AdrTrackerGroupFrame; +import com.mercury.platform.ui.adr.components.panel.AdrComponentPanel; +import com.mercury.platform.ui.adr.components.panel.AdrTrackerGroupPanel; +import com.mercury.platform.ui.components.ComponentsFactory; + + +public class TrackerGroupFrameProvider implements FrameProvider { + private AdrComponentDescriptor descriptor; + @Override + public boolean isSuitable(AdrComponentDescriptor descriptor) { + this.descriptor = descriptor; + return descriptor.getType().equals(AdrComponentType.TRACKER_GROUP); + } + + @Override + public AbstractAdrFrame getFrame(boolean showSettings) { + AdrTrackerGroupFrame adrTrackerGroupFrame = + new AdrTrackerGroupFrame((AdrTrackerGroupDescriptor) descriptor); + adrTrackerGroupFrame.setPanel(this.getPanel()); + adrTrackerGroupFrame.init(); + if(showSettings) { + adrTrackerGroupFrame.showComponent(); + adrTrackerGroupFrame.enableSettings(); + }else { + adrTrackerGroupFrame.disableSettings(); + } + return adrTrackerGroupFrame; + } + + @Override + public AdrComponentPanel getPanel() { + return new AdrTrackerGroupPanel((AdrTrackerGroupDescriptor) this.descriptor,new ComponentsFactory()); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCaptureOutPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCaptureOutPanel.java new file mode 100644 index 00000000..b5bf0b61 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCaptureOutPanel.java @@ -0,0 +1,51 @@ +package com.mercury.platform.ui.adr.components.panel; + +import com.mercury.platform.shared.config.descriptor.adr.AdrCaptureDescriptor; +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; + +import javax.swing.*; +import java.awt.*; + + +public class AdrCaptureOutPanel extends AdrComponentPanel { + public AdrCaptureOutPanel(AdrCaptureDescriptor descriptor, ComponentsFactory componentsFactory) { + super(descriptor, componentsFactory); + } + + @Override + public void createUI() { + this.setLayout(new GridLayout(1,1)); + this.setPreferredSize(this.descriptor.getCaptureSize()); + this.setBackground(AppThemeColor.ADR_CAPTURE_BG); + this.setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER,4)); + MercuryStoreUI.adrRepaintSubject.onNext(true); + } + @Override + public void enableSettings() { + super.enableSettings(); + this.setVisible(true); + } + + @Override + public void disableSettings() { + super.disableSettings(); + this.setVisible(false); + } + + @Override + public void onSelect() { + + } + + @Override + public void onUnSelect() { + + } + + @Override + protected void onUpdate() { + this.setVisible(this.descriptor.isVisible()); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCapturePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCapturePanel.java new file mode 100644 index 00000000..318b4aa8 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCapturePanel.java @@ -0,0 +1,90 @@ +package com.mercury.platform.ui.adr.components.panel; + +import com.mercury.platform.shared.config.descriptor.adr.AdrCaptureDescriptor; +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; +import org.imgscalr.Scalr; +import org.pushingpixels.trident.Timeline; +import org.pushingpixels.trident.callback.TimelineCallbackAdapter; + +import javax.swing.*; +import java.awt.*; +import java.awt.image.BufferedImage; + + +public class AdrCapturePanel extends AdrComponentPanel{ + private Timeline progressTl; + private JLabel captureLabel; + public AdrCapturePanel(AdrCaptureDescriptor groupDescriptor, ComponentsFactory componentsFactory) { + super(groupDescriptor, componentsFactory); + } + + @Override + public void createUI() { + this.setLayout(new GridLayout(1,1)); + this.setPreferredSize(this.descriptor.getSize()); + this.captureLabel = new JLabel(); + this.setBackground(AppThemeColor.ADR_CAPTURE_BG); + this.setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER,1)); + this.progressTl = new Timeline(this); + this.progressTl.addPropertyToInterpolate("captureCount",0,this.descriptor.getFps()); + this.captureLabel.setIcon(new ImageIcon(Scalr.resize(getCapture(),descriptor.getSize().width,descriptor.getSize().height))); + this.progressTl.addCallback(new TimelineCallbackAdapter(){ + @Override + public void onTimelineStateChanged(Timeline.TimelineState oldState, Timeline.TimelineState newState, float durationFraction, float timelinePosition) { + captureLabel.setIcon(new ImageIcon(Scalr.resize(getCapture(),descriptor.getSize().width,descriptor.getSize().height))); + } + }); + this.progressTl.setDuration(1000 / this.descriptor.getFps()); + + this.add(this.captureLabel); + MercuryStoreUI.adrRepaintSubject.onNext(true); + } + + + @Override + public void enableSettings() { + super.enableSettings(); + this.setVisible(true); + this.progressTl.abort(); + } + + @Override + public void disableSettings() { + super.disableSettings(); + this.progressTl.playLoop(Timeline.RepeatBehavior.LOOP); + this.setVisible(this.descriptor.isVisible()); + } + @Override + public void onSelect() { + this.progressTl.playLoop(Timeline.RepeatBehavior.LOOP); + } + + @Override + public void onUnSelect() { + this.progressTl.abort(); + } + + @Override + protected void onUpdate() { + this.setVisible(this.descriptor.isVisible()); + this.progressTl.abort(); + this.progressTl.setDuration(1000 / this.descriptor.getFps()); + this.progressTl.playLoop(Timeline.RepeatBehavior.LOOP); + } + + public void setCaptureCount(int captureCount) { + } + private BufferedImage getCapture(){ + try { + Robot robot = new Robot(); + Dimension size = this.descriptor.getCaptureSize(); + Point location = this.descriptor.getCaptureLocation(); + return robot.createScreenCapture(new Rectangle(location.x +5, location.y+5, size.width-10, size.height-10)); + } catch (AWTException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrComponentPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrComponentPanel.java index 10097b4f..6b9a0107 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrComponentPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrComponentPanel.java @@ -21,7 +21,6 @@ public abstract class AdrComponentPanel extend private Subscription adrReloadSubscription; private Subscription adrSelectSubscription; - private Subscription adrHotKeySubscription; public AdrComponentPanel(T descriptor, ComponentsFactory componentsFactory) { this.descriptor = descriptor; this.componentsFactory = componentsFactory; @@ -44,13 +43,6 @@ public void subscribe() { this.onUnSelect(); } }); - this.adrHotKeySubscription = MercuryStoreCore.hotKeySubject.subscribe(hotKey -> { - if(this.descriptor.getHotKeyDescriptor() != null) { - if (this.descriptor.getHotKeyDescriptor().equals(hotKey) && !this.inSettings) { - this.onHotKeyPressed(); - } - } - }); } public void enableSettings() { @@ -61,13 +53,11 @@ public void disableSettings() { } public abstract void onSelect(); public abstract void onUnSelect(); - protected abstract void onHotKeyPressed(); protected abstract void onUpdate(); @Override public void onDestroy() { this.adrReloadSubscription.unsubscribe(); this.adrSelectSubscription.unsubscribe(); - this.adrHotKeySubscription.unsubscribe(); } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCellPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationCellPanel.java similarity index 92% rename from app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCellPanel.java rename to app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationCellPanel.java index f682c786..d291a0c4 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrCellPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationCellPanel.java @@ -13,11 +13,10 @@ import java.awt.*; import java.util.Random; -public class AdrCellPanel extends AdrComponentPanel{ +public class AdrDurationCellPanel extends AdrDurationComponentPanel{ private MercuryTracker tracker; - public AdrCellPanel(AdrDurationComponentDescriptor cellDescriptor, ComponentsFactory componentsFactory) { + public AdrDurationCellPanel(AdrDurationComponentDescriptor cellDescriptor, ComponentsFactory componentsFactory) { super(cellDescriptor,componentsFactory); - this.setLayout(new GridLayout(1,1)); this.setBackground(AppThemeColor.TRANSPARENT); this.setBorder(null); this.setVisible(false); @@ -76,9 +75,10 @@ protected void onUpdate() { @Override public void createUI() { + this.setLayout(new GridLayout(1,1)); this.setPreferredSize(this.descriptor.getSize()); this.tracker = new MercuryTracker(this.descriptor); - this.add(this.tracker, BorderLayout.CENTER); + this.add(this.tracker); this.tracker.addTimelineCallback(new TimelineCallbackAdapter() { @Override public void onTimelineStateChanged(Timeline.TimelineState oldState, Timeline.TimelineState newState, float durationFraction, float timelinePosition) { @@ -92,7 +92,7 @@ public void onTimelineStateChanged(Timeline.TimelineState oldState, Timeline.Tim MercuryStoreUI.adrRepaintSubject.onNext(true); }else if(newState.equals(Timeline.TimelineState.PLAYING_FORWARD)){ setVisible(true); - JFrame parent = (JFrame) SwingUtilities.getWindowAncestor(AdrCellPanel.this); + JFrame parent = (JFrame) SwingUtilities.getWindowAncestor(AdrDurationCellPanel.this); parent.pack(); } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationComponentPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationComponentPanel.java new file mode 100644 index 00000000..c3726a41 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationComponentPanel.java @@ -0,0 +1,33 @@ +package com.mercury.platform.ui.adr.components.panel; + +import com.mercury.platform.shared.config.descriptor.adr.AdrDurationComponentDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.ComponentsFactory; +import rx.Subscription; + + +public abstract class AdrDurationComponentPanel extends AdrComponentPanel{ + private Subscription adrHotKeySubscription; + public AdrDurationComponentPanel(T descriptor, ComponentsFactory componentsFactory) { + super(descriptor, componentsFactory); + } + + @Override + public void subscribe() { + super.subscribe(); + this.adrHotKeySubscription = MercuryStoreCore.hotKeySubject.subscribe(hotKey -> { + if(this.descriptor.getHotKeyDescriptor() != null) { + if (this.descriptor.getHotKeyDescriptor().equals(hotKey) && !this.inSettings) { + this.onHotKeyPressed(); + } + } + }); + } + protected abstract void onHotKeyPressed(); + + @Override + public void onDestroy() { + super.onDestroy(); + this.adrHotKeySubscription.unsubscribe(); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrTrackerGroupPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrTrackerGroupPanel.java index d59b4add..05995cfa 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrTrackerGroupPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrTrackerGroupPanel.java @@ -72,11 +72,11 @@ public void createUI() { this.cells = new ArrayList<>(); this.setLayout(new GridLayout()); this.descriptor.getCells().forEach(component -> { - AdrCellPanel adrCellPanel = new AdrCellPanel((AdrDurationComponentDescriptor) component, this.componentsFactory); - this.add(adrCellPanel); - this.cells.add(adrCellPanel); + AdrDurationCellPanel adrDurationCellPanel = new AdrDurationCellPanel((AdrDurationComponentDescriptor) component, this.componentsFactory); + this.add(adrDurationCellPanel); + this.cells.add(adrDurationCellPanel); if(inSettings){ - adrCellPanel.enableSettings(); + adrDurationCellPanel.enableSettings(); } }); this.init(); @@ -103,11 +103,6 @@ public void onSelect() { public void onUnSelect() { } - @Override - protected void onHotKeyPressed() { - - } - @Override protected void onUpdate() { this.init(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrCapturePagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrCapturePagePanel.java new file mode 100644 index 00000000..7cff5d34 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrCapturePagePanel.java @@ -0,0 +1,92 @@ +package com.mercury.platform.ui.adr.components.panel.page; + +import com.mercury.platform.shared.config.descriptor.adr.AdrCaptureDescriptor; +import com.mercury.platform.ui.components.panel.VerticalScrollContainer; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + + +public class AdrCapturePagePanel extends AdrPagePanel { + @Override + protected void init() { + JPanel container = new VerticalScrollContainer(); + container.setBackground(AppThemeColor.FRAME); + container.setLayout(new BoxLayout(container,BoxLayout.Y_AXIS)); + JScrollPane verticalContainer = this.componentsFactory.getVerticalContainer(container); + + JLabel titleLabel = this.componentsFactory.getTextLabel("Title:"); + JLabel opacityLabel = this.componentsFactory.getTextLabel("Opacity:"); + JLabel sizeLabel = this.componentsFactory.getTextLabel("Size:"); + JLabel locationLabel = this.componentsFactory.getTextLabel("Location:"); + JLabel sectorSizeLabel = this.componentsFactory.getTextLabel("Sector size:"); + JLabel sectorLocationLabel = this.componentsFactory.getTextLabel("Sector location:"); + JLabel fpsLabel = this.componentsFactory.getTextLabel("Fps: high value can cause a drop fps"); + + JTextField titleField = this.adrComponentsFactory.getTitleField(this.payload); + JSlider opacitySlider = this.adrComponentsFactory.getOpacitySlider(this.payload); + JPanel componentSizePanel = this.adrComponentsFactory.getComponentSizePanel(this.payload, false); + JPanel locationPanel = this.adrComponentsFactory.getLocationPanel(this.payload, false); + JPanel sectorSizePanel = this.adrComponentsFactory.getCaptureSizePanel(this.payload); + JPanel sectorLocationPanel = this.adrComponentsFactory.getCaptureLocationPanel(this.payload); + JSlider fpsSlider = this.adrComponentsFactory.getFpsSlider(this.payload); + + JPanel generalPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2,0,6)); + JPanel specPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2,0,6)); + generalPanel.setBackground(AppThemeColor.SLIDE_BG); + generalPanel.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.BORDER_DARK), + BorderFactory.createEmptyBorder(4,2,4,2))); + + specPanel.setBackground(AppThemeColor.SLIDE_BG); + specPanel.setBorder(BorderFactory.createEmptyBorder(0,0,4,2)); + + generalPanel.add(titleLabel); + generalPanel.add(titleField); + generalPanel.add(sizeLabel); + generalPanel.add(componentSizePanel); + generalPanel.add(locationLabel); + generalPanel.add(locationPanel); + generalPanel.add(sectorSizeLabel); + generalPanel.add(sectorSizePanel); + generalPanel.add(sectorLocationLabel); + generalPanel.add(sectorLocationPanel); + generalPanel.add(fpsLabel); + generalPanel.add(fpsSlider); + + specPanel.add(opacityLabel); + specPanel.add(opacitySlider); + + specPanel.setVisible(this.advancedExpanded); + + specPanel.addComponentListener(new ComponentAdapter() { + @Override + public void componentShown(ComponentEvent e) { + advancedExpanded = specPanel.isVisible(); + } + + @Override + public void componentHidden(ComponentEvent e) { + advancedExpanded = specPanel.isVisible(); + } + }); + + JPanel advancedPanel = this.adrComponentsFactory.getCounterPanel(specPanel, "Advanced:", AppThemeColor.ADR_BG,this.advancedExpanded); + advancedPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + + container.add(this.componentsFactory.wrapToSlide(generalPanel)); + container.add(this.componentsFactory.wrapToSlide(advancedPanel)); + container.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + requestFocus(); + } + }); + this.add(verticalContainer,BorderLayout.CENTER); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java index 879449bc..4643a9fc 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java @@ -60,6 +60,17 @@ public void mouseClicked(MouseEvent e) { ); } }); + JPanel createCaptureComponent = this.getButton( + "app/adr/create_pb_group.png", + "Capture"); + createCaptureComponent.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + MercuryStoreUI.adrComponentStateSubject.onNext( + new AdrComponentDefinition(config.getDefaultCapture(), AdrComponentOperations.NEW_COMPONENT,payload) + ); + } + }); JPanel createIcon = this.getButton( "app/adr/create_icon.png", TooltipConstants.ADR_CREATE_ICON); @@ -116,6 +127,7 @@ public void mouseClicked(MouseEvent e) { container.add(this.componentsFactory.wrapToSlide(createIconsGroup)); container.add(this.componentsFactory.wrapToSlide(createPbGroup)); } +// container.add(this.componentsFactory.wrapToSlide(createCaptureComponent)); container.add(this.componentsFactory.wrapToSlide(importButton)); this.add(verticalContainer,BorderLayout.CENTER); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogCaptureNodePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogCaptureNodePanel.java new file mode 100644 index 00000000..cfbc5874 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogCaptureNodePanel.java @@ -0,0 +1,42 @@ +package com.mercury.platform.ui.adr.components.panel.tree.dialog; + +import com.mercury.platform.shared.config.descriptor.adr.AdrCaptureDescriptor; +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; +import com.mercury.platform.ui.adr.components.panel.tree.AdrNodePanel; +import com.mercury.platform.ui.adr.components.panel.tree.model.AdrTreeNode; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; + + +public class AdrDialogCaptureNodePanel extends AdrNodePanel{ + private JLabel titleLabel; + public AdrDialogCaptureNodePanel(AdrTreeNode treeNode) { + super(treeNode); + this.mouseListener.setProcessSelect(false); + } + + @Override + public void createUI() { + JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); + root.setPreferredSize(new Dimension(180, 30)); + root.setBackground(AppThemeColor.ADR_BG); + this.titleLabel = this.componentsFactory.getTextLabel(this.descriptor.getTitle()); + this.titleLabel.setForeground(AppThemeColor.TEXT_DEFAULT); + this.titleLabel.setFont(componentsFactory.getFont(FontStyle.REGULAR, 16)); + this.titleLabel.setBorder(BorderFactory.createEmptyBorder(0,4,0,0)); + + JLabel iconLabel = this.componentsFactory.getIconLabel("app/adr/capture_icon.png",44); + + root.add(iconLabel,BorderLayout.LINE_START); + root.add(titleLabel,BorderLayout.CENTER); + this.add(root,BorderLayout.CENTER); + } + + @Override + protected void update() { + this.titleLabel.setText(this.descriptor.getTitle()); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogTreeNodeRenderer.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogTreeNodeRenderer.java index 86073f76..ba8f1738 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogTreeNodeRenderer.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/dialog/AdrDialogTreeNodeRenderer.java @@ -25,6 +25,9 @@ public JPanel getViewOf(AdrTreeNode node) { case TRACKER_GROUP: { return this.componentsFactory.wrapToAdrSlide(new AdrDialogGroupNodePanel(node), 2, 4, 2, 4); } + case CAPTURE:{ + return this.componentsFactory.wrapToAdrSlide(new AdrDialogCaptureNodePanel(node), 2, 4, 2, 4); + } } return new JPanel(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrCaptureNodePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrCaptureNodePanel.java new file mode 100644 index 00000000..745256a7 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrCaptureNodePanel.java @@ -0,0 +1,43 @@ +package com.mercury.platform.ui.adr.components.panel.tree.main; + +import com.mercury.platform.shared.config.descriptor.adr.AdrCaptureDescriptor; +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentDescriptor; +import com.mercury.platform.ui.adr.components.panel.tree.AdrNodePanel; +import com.mercury.platform.ui.adr.components.panel.tree.model.AdrTreeNode; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; + + +public class AdrCaptureNodePanel extends AdrNodePanel { + private JLabel titleLabel; + public AdrCaptureNodePanel(AdrTreeNode treeNode) { + super(treeNode); + } + + @Override + public void createUI() { + JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); + root.setBackground(AppThemeColor.ADR_BG); + this.titleLabel = this.componentsFactory.getTextLabel(this.descriptor.getTitle()); + this.titleLabel.setForeground(AppThemeColor.TEXT_DEFAULT); + this.titleLabel.setFont(componentsFactory.getFont(FontStyle.REGULAR, 16)); + this.titleLabel.setBorder(BorderFactory.createEmptyBorder(0,4,0,0)); + + JLabel iconLabel = this.componentsFactory.getIconLabel("app/adr/capture_icon.png",44); + + root.add(iconLabel,BorderLayout.LINE_START); + root.add(titleLabel,BorderLayout.CENTER); + this.add(this.adrComponentsFactory.getLeftComponentOperationsPanel(this.treeNode),BorderLayout.LINE_START); + this.add(this.adrComponentsFactory + .getRightComponentOperationsPanel(this.descriptor),BorderLayout.LINE_END); + this.add(root,BorderLayout.CENTER); + } + + @Override + protected void update() { + this.titleLabel.setText(this.descriptor.getTitle()); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrMainTreeNodeRenderer.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrMainTreeNodeRenderer.java index 14697552..595aa0d8 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrMainTreeNodeRenderer.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/tree/main/AdrMainTreeNodeRenderer.java @@ -25,6 +25,9 @@ public JPanel getViewOf(AdrTreeNode treeNode) { case TRACKER_GROUP: { return this.componentsFactory.wrapToAdrSlide(new AdrGroupNodePanel(treeNode), 2, 4, 2, 4); } + case CAPTURE:{ + return this.componentsFactory.wrapToSlide(new AdrCaptureNodePanel(treeNode),2,4,2,4); + } } return new JPanel(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java index bb49dee0..5ee670bb 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java @@ -1,6 +1,7 @@ package com.mercury.platform.ui.components; import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.fields.style.MercuryComboBoxUI; import com.mercury.platform.ui.components.fields.font.FontStyle; @@ -52,6 +53,9 @@ public ComponentsFactory() { this.scale = 1.0f; // UIManager.getDefaults().put("Slider.horizontalThumbIcon",this.getImage("app/slider_thumb.png")); + UIManager.put("ComboBox.selectionBackground", AppThemeColor.HEADER); + UIManager.put("ComboBox.selectionForeground", AppThemeColor.ADR_POPUP_BG); + UIManager.put("ComboBox.disabledForeground", AppThemeColor.ADR_FOOTER_BG); } /** @@ -305,6 +309,9 @@ public JLabel getTextLabel(String text){ public JLabel getTextLabel(String text, FontStyle style){ return getTextLabel(style,AppThemeColor.TEXT_DEFAULT,TextAlignment.LEFTOP,scale*15f,text); } + public JLabel getTextLabel(String text, FontStyle style,Color color){ + return getTextLabel(style,color,TextAlignment.LEFTOP,scale*15f,text); + } public JLabel getTextLabel(String text, FontStyle style, float size){ return getTextLabel(style,AppThemeColor.TEXT_DEFAULT,TextAlignment.LEFTOP,size,text); } @@ -615,6 +622,11 @@ public JPanel getJPanel(LayoutManager layoutManager) { panel.setBackground(AppThemeColor.FRAME_RGB); return panel; } + public JPanel getJPanel(LayoutManager layoutManager,Color bg) { + JPanel panel = new JPanel(layoutManager); + panel.setBackground(bg); + return panel; + } public JPanel wrapToSlide(JComponent panel){ JPanel wrapper = this.getJPanel(new BorderLayout()); wrapper.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/HistoryMessagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/HistoryMessagePanel.java new file mode 100644 index 00000000..845a610b --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/HistoryMessagePanel.java @@ -0,0 +1,7 @@ +package com.mercury.platform.ui.components.panel.message; + +/** + * Created by Константин on 10.08.2017. + */ +public class HistoryMessagePanel { +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/InMessagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/InMessagePanel.java new file mode 100644 index 00000000..bc018b19 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/InMessagePanel.java @@ -0,0 +1,571 @@ +package com.mercury.platform.ui.components.panel.message; + +import com.mercury.platform.shared.AsSubscriber; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.KeyValueConfigurationService; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; +import com.mercury.platform.shared.config.descriptor.HotKeyType; +import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; +import com.mercury.platform.shared.entity.message.CurrencyMessage; +import com.mercury.platform.shared.entity.message.ItemMessage; +import com.mercury.platform.shared.entity.message.Message; +import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.fields.font.TextAlignment; +import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.frame.movable.container.MessageFrame; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.HasHotkey; +import com.mercury.platform.ui.misc.MercuryStoreUI; +import com.mercury.platform.ui.misc.TooltipConstants; +import lombok.Getter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import javax.swing.*; +import javax.swing.Timer; +import javax.swing.border.Border; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EmptyBorder; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.text.DecimalFormat; +import java.util.*; +import java.util.List; + + +public class InMessagePanel extends JPanel implements AsSubscriber, HasUI,HasHotkey{ + private static final Logger logger = LogManager.getLogger(InMessagePanel.class.getSimpleName()); + + private ComponentsFactory componentsFactory; + private PlainConfigurationService notificationService; + private MessagePanelController controller; + private MessagePanelStyle style; + + private String whisper; + private JLabel whisperLabel; + private JButton tradeButton; + private JButton expandButton; + + @Getter + private Message message; + + private Timer timeAgo; + private String cachedTime = "0m"; + private JLabel timeLabel; + private Color cachedWhisperColor = AppThemeColor.TEXT_NICKNAME; + private JPanel whisperPanel; + private JPanel messagePanel; + private JPanel customButtonsPanel; + + private boolean expanded = false; + + private InMessagePanel(Message message, MessagePanelStyle style) { + super(new BorderLayout()); + this.message = message; + this.style = style; + this.whisper = message.getWhisperNickname(); + this.notificationService = Configuration.get().notificationConfiguration(); + if(!style.equals(MessagePanelStyle.HISTORY)) { + this.initHotKeyListeners(); + } + } + public InMessagePanel(Message message, MessagePanelStyle style, MessagePanelController controller, ComponentsFactory componentsFactory){ + this(message,style); + this.componentsFactory = componentsFactory; + this.controller = controller; + createUI(); + } + + @Override + public void createUI() { + this.setBackground(AppThemeColor.FRAME); + this.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,1), + BorderFactory.createLineBorder(AppThemeColor.BORDER, 1))); + init(); + subscribe(); + setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); + setMinimumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); + } + private void init(){ + this.removeAll(); + this.whisperPanel = getWhisperPanel(); + this.messagePanel = getFormattedMessagePanel(); + this.customButtonsPanel = getButtonsPanel(); + whisperPanel.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createMatteBorder(1, 0, 1, 0, AppThemeColor.MSG_HEADER_BORDER), + BorderFactory.createEmptyBorder(-6, 0, -6, 0))); + if(style.equals(MessagePanelStyle.IN_DOWNWARDS) || + style.equals(MessagePanelStyle.HISTORY) || style.equals(MessagePanelStyle.RELOADED)) { + this.add(whisperPanel,BorderLayout.PAGE_START); + this.add(messagePanel,BorderLayout.CENTER); + this.add(customButtonsPanel,BorderLayout.PAGE_END); + }else { + this.add(customButtonsPanel,BorderLayout.PAGE_START); + this.add(messagePanel,BorderLayout.CENTER); + this.add(whisperPanel,BorderLayout.PAGE_END); + } + switch (style){ + case IN_DOWNWARDS:{ + messagePanel.setVisible(expanded); + customButtonsPanel.setVisible(expanded); + break; + } + case IN_UPWARDS:{ + messagePanel.setVisible(expanded); + customButtonsPanel.setVisible(expanded); + break; + } + case HISTORY:{ + messagePanel.setVisible(true); + customButtonsPanel.setVisible(false); + break; + } + case RELOADED:{ + messagePanel.setVisible(true); + customButtonsPanel.setVisible(true); + } + } + this.repaint(); + } + + private JPanel getFormattedMessagePanel(){ + JPanel labelsPanel = new JPanel(); + labelsPanel.setLayout(new BoxLayout(labelsPanel,BoxLayout.Y_AXIS)); + labelsPanel.setBackground(AppThemeColor.TRANSPARENT); + + JPanel tradePanel = new JPanel(new BorderLayout()); + tradePanel.setBackground(AppThemeColor.TRANSPARENT); + tradePanel.setBorder(BorderFactory.createEmptyBorder(-11,2,-11,0)); + if(message instanceof ItemMessage) { + JButton itemButton = componentsFactory.getButton( + FontStyle.BOLD, + AppThemeColor.BUTTON, + BorderFactory.createEmptyBorder(0,4,0,2), + ((ItemMessage) message).getItemName(), 17f); + + itemButton.setForeground(AppThemeColor.TEXT_IMPORTANT); + itemButton.setBackground(AppThemeColor.TRANSPARENT); + itemButton.setHorizontalAlignment(SwingConstants.LEFT); + itemButton.setContentAreaFilled(false); + itemButton.setRolloverEnabled(false); + itemButton.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + controller.showITH(); + } + + @Override + public void mouseReleased(MouseEvent e) { + MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); + } + + @Override + public void mouseEntered(MouseEvent e) { + itemButton.setBorder(new CompoundBorder( + BorderFactory.createMatteBorder(0,1,0,1,AppThemeColor.BORDER), + BorderFactory.createEmptyBorder(0,3,0,1))); + MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); + } + + @Override + public void mouseExited(MouseEvent e) { + itemButton.setBorder(BorderFactory.createEmptyBorder(0,4,0,2)); + MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); + } + }); + tradePanel.add(itemButton,BorderLayout.CENTER); + }else if(message instanceof CurrencyMessage){ + JPanel fromPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + fromPanel.setBackground(AppThemeColor.TRANSPARENT); + CurrencyMessage message = (CurrencyMessage) this.message; + + String curCount = message.getCurrForSaleCount() % 1 == 0 ? + String.valueOf(message.getCurrForSaleCount().intValue()) : + String.valueOf(message.getCurrForSaleCount()); + JPanel curCountPanel = getCurrencyPanel(curCount); + JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + message.getCurrForSaleTitle() + ".png", 26); + JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + curPanel.setBackground(AppThemeColor.TRANSPARENT); + curPanel.add(curCountPanel); + curPanel.add(currencyLabel); + curPanel.add(getCurrencyRatePanel()); + fromPanel.add(curPanel); + tradePanel.add(fromPanel,BorderLayout.CENTER); + } + + JPanel forPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + forPanel.setBackground(AppThemeColor.TRANSPARENT); + + JLabel separator = componentsFactory.getTextLabel( + FontStyle.BOLD, + AppThemeColor.TEXT_MESSAGE, + TextAlignment.CENTER, + 18f, + "=>"); + separator.setHorizontalAlignment(SwingConstants.CENTER); + String curCount = " "; + if(message.getCurCount() > 0) { + curCount = message.getCurCount() % 1 == 0 ? + String.valueOf(message.getCurCount().intValue()) : + String.valueOf(message.getCurCount()); + } + String currency = message.getCurrency(); + if(!Objects.equals(curCount, "") && currency != null) { + JPanel curCountPanel = getCurrencyPanel(curCount); + JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + currency + ".png", 26); + JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + curPanel.setBackground(AppThemeColor.TRANSPARENT); + curPanel.add(separator); + curPanel.add(curCountPanel); + curPanel.add(currencyLabel); + forPanel.add(curPanel); + } + tradePanel.add(forPanel,BorderLayout.LINE_END); + labelsPanel.add(tradePanel); + String offer = message.getOffer(); + if(offer != null && offer.trim().length() > 0) { + JLabel offerLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 17f, offer); + offerLabel.setAlignmentY(Component.TOP_ALIGNMENT); + labelsPanel.add(offerLabel); + } + return labelsPanel; + } + private JPanel getCurrencyPanel(String curCount){ + JPanel curCountPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + curCountPanel.setBackground(AppThemeColor.TRANSPARENT); + + JLabel priceLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER,17f,null, curCount); + curCountPanel.add(priceLabel); + curCountPanel.setPreferredSize(new Dimension((int)(componentsFactory.getScale() * 40),curCountPanel.getPreferredSize().height)); + return curCountPanel; + } + private JPanel getCurrencyRatePanel(){ + CurrencyMessage message = (CurrencyMessage) this.message; + Double currForSaleCount = message.getCurrForSaleCount(); + Double curCount = message.getCurCount(); + double rate = curCount / currForSaleCount; + DecimalFormat decimalFormat = new DecimalFormat("#.####"); + JPanel ratePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); + ratePanel.add(componentsFactory. + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,"(")); + JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + message.getCurrency() + ".png", 26); + currencyLabel.setBorder(null); + ratePanel.add(currencyLabel); + ratePanel.add(componentsFactory. + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,decimalFormat.format(rate))); + ratePanel.add(componentsFactory. + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,")")); + ratePanel.setBorder(BorderFactory.createEmptyBorder(-5,0,-5,0)); + return ratePanel; + } + private JPanel getWhisperPanel(){ + JPanel topPanel = new JPanel(new BorderLayout()); + topPanel.setBackground(AppThemeColor.MSG_HEADER); + + whisperLabel = componentsFactory.getTextLabel(FontStyle.BOLD,cachedWhisperColor, TextAlignment.LEFTOP,15f,getNicknameLabel()); + Border border = whisperLabel.getBorder(); + whisperLabel.setBorder(new CompoundBorder(border,new EmptyBorder(0,0,0,5))); + whisperLabel.setVerticalAlignment(SwingConstants.CENTER); + + JPanel nickNamePanel = componentsFactory.getTransparentPanel(new BorderLayout()); + if(style.equals(MessagePanelStyle.HISTORY)){ + nickNamePanel.add(whisperLabel,BorderLayout.CENTER); + }else { + JPanel buttonWrapper = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); + buttonWrapper.setBorder(BorderFactory.createEmptyBorder(2,0,0,0)); + buttonWrapper.add(getExpandButton()); + if(!style.equals(MessagePanelStyle.RELOADED)) { + nickNamePanel.add(buttonWrapper, BorderLayout.LINE_START); + } + nickNamePanel.add(whisperLabel,BorderLayout.CENTER); + } + topPanel.add(nickNamePanel,BorderLayout.CENTER); + + JPanel interactionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + interactionPanel.setBorder(BorderFactory.createEmptyBorder(1,0,1,0)); + interactionPanel.setBackground(AppThemeColor.TRANSPARENT); + interactionPanel.add(getTimePanel()); + if(!style.equals(MessagePanelStyle.HISTORY)) { + JButton inviteButton = componentsFactory.getIconButton("app/invite.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); + inviteButton.addActionListener(e -> controller.performInvite()); + JButton kickButton = componentsFactory.getIconButton("app/kick.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); + kickButton.addActionListener(e -> { + controller.performKick(); + if(this.notificationService.get().isDismissAfterKick() && !style.equals(MessagePanelStyle.RELOADED)){ + controller.performHide(); + } + }); + tradeButton = componentsFactory.getIconButton("app/trade.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); + tradeButton.addActionListener(e -> controller.performOfferTrade()); + interactionPanel.add(inviteButton); + interactionPanel.add(kickButton); + interactionPanel.add(tradeButton); + interactionPanel.add(getStillInterestedButton()); + }else { + JButton reloadButton = componentsFactory.getIconButton("app/reload-history.png", 14, AppThemeColor.MSG_HEADER, "Restore"); + reloadButton.addActionListener(e -> controller.reloadMessage(this)); + interactionPanel.add(reloadButton); + } + JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); + openChatButton.setToolTipText("Open chat"); + openChatButton.addActionListener(e -> controller.performOpenChat()); + + interactionPanel.add(openChatButton); + JButton hideButton = componentsFactory.getIconButton("app/close.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); + hideButton.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if(SwingUtilities.isLeftMouseButton(e)) { + controller.performHide(); + } + } + }); + if(!style.equals(MessagePanelStyle.HISTORY) && !style.equals(MessagePanelStyle.RELOADED)) { + interactionPanel.add(hideButton); + } + + topPanel.add(interactionPanel,BorderLayout.LINE_END); + return topPanel; + } + private String getNicknameLabel(){ + String whisperNickname = message.getWhisperNickname(); + String result = whisperNickname + ":"; + if(this.notificationService.get().isShowLeague()) { + if (message.getLeague() != null) { + String league = message.getLeague().trim(); + if (league.length() == 0) { + return result; + } + if (league.contains("Hardcore")) { + if (league.equals("Hardcore")) { + result = "HC " + result; + } else { + result = String.valueOf(league.split(" ")[1].charAt(0)) + "HC " + result; + } + } else if (league.contains("Standard")) { + result = "Standard " + result; + } else { + result = String.valueOf(league.charAt(0)) + "SC " + result; + } + } + } + return result; + } + private JPanel getTimePanel(){ + JPanel panel = new JPanel(); + panel.setBackground(AppThemeColor.TRANSPARENT); + timeLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MISC, TextAlignment.CENTER, 14, cachedTime); + if(timeAgo == null) { + timeAgo = new Timer(60000, new ActionListener() { + private int minute = 0; + private int hours = 0; + private int day = 0; + + @Override + public void actionPerformed(ActionEvent e) { + String labelText = ""; + minute++; + if (minute > 60) { + hours++; + minute = 0; + if (hours > 24) { + day++; + hours = 0; + } + } + if (hours == 0 && day == 0) { + labelText = minute + "m"; + } else if (hours > 0) { + labelText = hours + "h " + minute + "m"; + } else if (day > 0) { + labelText = day + "d " + hours + "h " + minute + "m"; + } + timeLabel.setText(labelText); + MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); + } + }); + timeAgo.start(); + } + panel.add(timeLabel); + return panel; + } + public void disableTime(){ + if(timeAgo != null) { + timeAgo.stop(); + timeLabel.setText(""); + } + } + private JButton getExpandButton(){ + String iconPath = "app/default-mp.png"; + if(expanded){ + if(style.equals(MessagePanelStyle.IN_DOWNWARDS)){ + iconPath = "app/expand-mp.png"; + }else { + iconPath = "app/collapse-mp.png"; + } + } + expandButton = componentsFactory.getIconButton(iconPath, 18f, AppThemeColor.MSG_HEADER,""); + expandButton.setBorder(BorderFactory.createEmptyBorder(4,4,4,0)); + expandButton.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if(SwingUtilities.isLeftMouseButton(e)) { + if (!messagePanel.isVisible()) { + expand(); + } else { + collapse(); + } + } + } + }); + return expandButton; + } + public void expand(){ + expanded = true; + if(style.equals(MessagePanelStyle.IN_DOWNWARDS)) { + expandButton.setIcon(componentsFactory.getIcon("app/expand-mp.png", 18f)); + messagePanel.setVisible(true); + customButtonsPanel.setVisible(true); + }else { + expandButton.setIcon(componentsFactory.getIcon("app/collapse-mp.png", 18f)); + messagePanel.setVisible(true); + customButtonsPanel.setVisible(true); + } + setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); + setMinimumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); + MercuryStoreUI.expandMessageSubject.onNext(true); + MercuryStoreUI.packSubject.onNext(MessageFrame.class); + } + public void collapse(){ + expanded = false; + if(style.equals(MessagePanelStyle.IN_DOWNWARDS)) { + expandButton.setIcon(componentsFactory.getIcon("app/default-mp.png", 18)); + messagePanel.setVisible(false); + customButtonsPanel.setVisible(false); + }else { + expandButton.setIcon(componentsFactory.getIcon("app/default-mp.png", 18)); + messagePanel.setVisible(false); + customButtonsPanel.setVisible(false); + } + setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); + setMinimumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); + MercuryStoreUI.collapseMessageSubject.onNext(true); + MercuryStoreUI.packSubject.onNext(MessageFrame.class); + } + + public boolean isExpanded() { + return expanded; + } + + public void setStyle(MessagePanelStyle style) { + this.style = style; + this.cachedTime = timeLabel.getText(); + init(); + setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); + setMinimumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); + } + + public MessagePanelStyle getStyle() { + return style; + } + private JPanel getButtonsPanel(){ + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + panel.setBackground(AppThemeColor.TRANSPARENT); + initResponseButtons(panel); + return panel; + } + @Override + public void subscribe() { + MercuryStoreCore.playerJoinSubject.subscribe(nickname -> { + if(nickname.equals(whisper)){ + whisperLabel.setForeground(AppThemeColor.TEXT_SUCCESS); + cachedWhisperColor = AppThemeColor.TEXT_SUCCESS; + if(!style.equals(MessagePanelStyle.HISTORY)) { + tradeButton.setEnabled(true); + } + MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); + } + }); + MercuryStoreCore.playerLeftSubject.subscribe(nickname -> { + if (nickname.equals(whisper)) { + whisperLabel.setForeground(AppThemeColor.TEXT_DISABLE); + cachedWhisperColor = AppThemeColor.TEXT_DISABLE; + if (!style.equals(MessagePanelStyle.HISTORY)) { + tradeButton.setEnabled(false); + } + MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); + } + }); + MercuryStoreCore.buttonsChangedSubject.subscribe(state -> { + this.customButtonsPanel.removeAll(); + initResponseButtons(customButtonsPanel); + MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); + }); + } + private void initResponseButtons(JPanel panel){ + List buttonsConfig = this.notificationService.get().getButtons(); + Collections.sort(buttonsConfig); + buttonsConfig.forEach((buttonConfig)->{ + JButton button = componentsFactory.getBorderedButton(buttonConfig.getTitle(),15f); + button.addActionListener(e -> { + controller.performResponse(buttonConfig.getResponseText()); + if(buttonConfig.isClose() && !style.equals(MessagePanelStyle.RELOADED)){ + controller.performHide(); + } + }); + panel.add(button); + }); + } + private JButton getStillInterestedButton(){ + JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.STILL_INTERESTED); + + String curCount = message.getCurCount() % 1 == 0 ? + String.valueOf(message.getCurCount().intValue()) : + String.valueOf(message.getCurCount()); + String responseText = "Hi, are you still interested in "; + if(message instanceof ItemMessage){ + ItemMessage message = (ItemMessage) this.message; + if(message.getCurrency().equals("???")){ + responseText += message.getItemName() + "?"; + }else { + responseText += message.getItemName() + + " for " + curCount + " " + message.getCurrency() + "?"; + } + }else { + CurrencyMessage message = (CurrencyMessage) this.message; + String curForSaleCount = message.getCurCount() % 1 == 0 ? + String.valueOf(message.getCurrForSaleCount().intValue()) : + String.valueOf(message.getCurrForSaleCount()); + responseText += curForSaleCount + " " + message.getCurrForSaleTitle() + " for " + + curCount + " " + message.getCurrency() + "?"; + } + String finalResponseText = responseText; // hate java + stillIntButton.addActionListener( + (action)->controller.performResponse(finalResponseText) + ); + return stillIntButton; + } + + public void setComponentsFactory(ComponentsFactory componentsFactory) { + this.componentsFactory = componentsFactory; + } + + @Override + public void initHotKeyListeners() { + KeyValueConfigurationService config = Configuration.get().hotKeysConfiguration(); + MercuryStoreCore.hotKeySubject.subscribe(descriptor -> { + HotKeyDescriptor hotKeyDescriptor = config.get(HotKeyType.CLOSE_NOTIFICATION.name()); + if(descriptor.equals(hotKeyDescriptor)) { + this.controller.performHide(); + } + }); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanel.java index 03c17cd6..b44f42bd 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanel.java @@ -1,571 +1,16 @@ package com.mercury.platform.ui.components.panel.message; + import com.mercury.platform.shared.AsSubscriber; -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.configration.KeyValueConfigurationService; import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; -import com.mercury.platform.shared.config.descriptor.HotKeyType; import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; -import com.mercury.platform.shared.entity.message.CurrencyMessage; -import com.mercury.platform.shared.entity.message.ItemMessage; -import com.mercury.platform.shared.entity.message.Message; -import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.ComponentsFactory; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.fields.font.TextAlignment; import com.mercury.platform.ui.components.panel.misc.HasUI; -import com.mercury.platform.ui.frame.movable.container.MessageFrame; -import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.HasHotkey; -import com.mercury.platform.ui.misc.MercuryStoreUI; -import com.mercury.platform.ui.misc.TooltipConstants; -import lombok.Getter; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import javax.swing.*; -import javax.swing.Timer; -import javax.swing.border.Border; -import javax.swing.border.CompoundBorder; -import javax.swing.border.EmptyBorder; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.text.DecimalFormat; -import java.util.*; -import java.util.List; - - -public class MessagePanel extends JPanel implements AsSubscriber, HasUI,HasHotkey{ - private static final Logger logger = LogManager.getLogger(MessagePanel.class.getSimpleName()); - - private ComponentsFactory componentsFactory; - private PlainConfigurationService notificationService; - private MessagePanelController controller; - private MessagePanelStyle style; - - private String whisper; - private JLabel whisperLabel; - private JButton tradeButton; - private JButton expandButton; - - @Getter - private Message message; - - private Timer timeAgo; - private String cachedTime = "0m"; - private JLabel timeLabel; - private Color cachedWhisperColor = AppThemeColor.TEXT_NICKNAME; - private JPanel whisperPanel; - private JPanel messagePanel; - private JPanel customButtonsPanel; - - private boolean expanded = false; - - private MessagePanel(Message message, MessagePanelStyle style) { - super(new BorderLayout()); - this.message = message; - this.style = style; - this.whisper = message.getWhisperNickname(); - this.notificationService = Configuration.get().notificationConfiguration(); - if(!style.equals(MessagePanelStyle.HISTORY)) { - this.initHotKeyListeners(); - } - } - public MessagePanel(Message message, MessagePanelStyle style, MessagePanelController controller, ComponentsFactory componentsFactory){ - this(message,style); - this.componentsFactory = componentsFactory; - this.controller = controller; - createUI(); - } - - @Override - public void createUI() { - this.setBackground(AppThemeColor.FRAME); - this.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,1), - BorderFactory.createLineBorder(AppThemeColor.BORDER, 1))); - init(); - subscribe(); - setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - setMinimumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - } - private void init(){ - this.removeAll(); - this.whisperPanel = getWhisperPanel(); - this.messagePanel = getFormattedMessagePanel(); - this.customButtonsPanel = getButtonsPanel(); - whisperPanel.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createMatteBorder(1, 0, 1, 0, AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(-6, 0, -6, 0))); - if(style.equals(MessagePanelStyle.DOWNWARDS_SMALL) || - style.equals(MessagePanelStyle.HISTORY) || style.equals(MessagePanelStyle.SP_MODE)) { - this.add(whisperPanel,BorderLayout.PAGE_START); - this.add(messagePanel,BorderLayout.CENTER); - this.add(customButtonsPanel,BorderLayout.PAGE_END); - }else { - this.add(customButtonsPanel,BorderLayout.PAGE_START); - this.add(messagePanel,BorderLayout.CENTER); - this.add(whisperPanel,BorderLayout.PAGE_END); - } - switch (style){ - case DOWNWARDS_SMALL:{ - messagePanel.setVisible(expanded); - customButtonsPanel.setVisible(expanded); - break; - } - case UPWARDS_SMALL:{ - messagePanel.setVisible(expanded); - customButtonsPanel.setVisible(expanded); - break; - } - case HISTORY:{ - messagePanel.setVisible(true); - customButtonsPanel.setVisible(false); - break; - } - case SP_MODE:{ - messagePanel.setVisible(true); - customButtonsPanel.setVisible(true); - } - } - this.repaint(); - } - - private JPanel getFormattedMessagePanel(){ - JPanel labelsPanel = new JPanel(); - labelsPanel.setLayout(new BoxLayout(labelsPanel,BoxLayout.Y_AXIS)); - labelsPanel.setBackground(AppThemeColor.TRANSPARENT); - - JPanel tradePanel = new JPanel(new BorderLayout()); - tradePanel.setBackground(AppThemeColor.TRANSPARENT); - tradePanel.setBorder(BorderFactory.createEmptyBorder(-11,2,-11,0)); - if(message instanceof ItemMessage) { - JButton itemButton = componentsFactory.getButton( - FontStyle.BOLD, - AppThemeColor.BUTTON, - BorderFactory.createEmptyBorder(0,4,0,2), - ((ItemMessage) message).getItemName(), 17f); - - itemButton.setForeground(AppThemeColor.TEXT_IMPORTANT); - itemButton.setBackground(AppThemeColor.TRANSPARENT); - itemButton.setHorizontalAlignment(SwingConstants.LEFT); - itemButton.setContentAreaFilled(false); - itemButton.setRolloverEnabled(false); - itemButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - controller.showITH(); - } - - @Override - public void mouseReleased(MouseEvent e) { - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - } - - @Override - public void mouseEntered(MouseEvent e) { - itemButton.setBorder(new CompoundBorder( - BorderFactory.createMatteBorder(0,1,0,1,AppThemeColor.BORDER), - BorderFactory.createEmptyBorder(0,3,0,1))); - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - } - - @Override - public void mouseExited(MouseEvent e) { - itemButton.setBorder(BorderFactory.createEmptyBorder(0,4,0,2)); - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - } - }); - tradePanel.add(itemButton,BorderLayout.CENTER); - }else if(message instanceof CurrencyMessage){ - JPanel fromPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - fromPanel.setBackground(AppThemeColor.TRANSPARENT); - CurrencyMessage message = (CurrencyMessage) this.message; - - String curCount = message.getCurrForSaleCount() % 1 == 0 ? - String.valueOf(message.getCurrForSaleCount().intValue()) : - String.valueOf(message.getCurrForSaleCount()); - JPanel curCountPanel = getCurrencyPanel(curCount); - JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + message.getCurrForSaleTitle() + ".png", 26); - JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - curPanel.setBackground(AppThemeColor.TRANSPARENT); - curPanel.add(curCountPanel); - curPanel.add(currencyLabel); - curPanel.add(getCurrencyRatePanel()); - fromPanel.add(curPanel); - tradePanel.add(fromPanel,BorderLayout.CENTER); - } - - JPanel forPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - forPanel.setBackground(AppThemeColor.TRANSPARENT); - - JLabel separator = componentsFactory.getTextLabel( - FontStyle.BOLD, - AppThemeColor.TEXT_MESSAGE, - TextAlignment.CENTER, - 18f, - "=>"); - separator.setHorizontalAlignment(SwingConstants.CENTER); - String curCount = " "; - if(message.getCurCount() > 0) { - curCount = message.getCurCount() % 1 == 0 ? - String.valueOf(message.getCurCount().intValue()) : - String.valueOf(message.getCurCount()); - } - String currency = message.getCurrency(); - if(!Objects.equals(curCount, "") && currency != null) { - JPanel curCountPanel = getCurrencyPanel(curCount); - JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + currency + ".png", 26); - JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - curPanel.setBackground(AppThemeColor.TRANSPARENT); - curPanel.add(separator); - curPanel.add(curCountPanel); - curPanel.add(currencyLabel); - forPanel.add(curPanel); - } - tradePanel.add(forPanel,BorderLayout.LINE_END); - labelsPanel.add(tradePanel); - String offer = message.getOffer(); - if(offer != null && offer.trim().length() > 0) { - JLabel offerLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 17f, offer); - offerLabel.setAlignmentY(Component.TOP_ALIGNMENT); - labelsPanel.add(offerLabel); - } - return labelsPanel; - } - private JPanel getCurrencyPanel(String curCount){ - JPanel curCountPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - curCountPanel.setBackground(AppThemeColor.TRANSPARENT); - - JLabel priceLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER,17f,null, curCount); - curCountPanel.add(priceLabel); - curCountPanel.setPreferredSize(new Dimension((int)(componentsFactory.getScale() * 40),curCountPanel.getPreferredSize().height)); - return curCountPanel; - } - private JPanel getCurrencyRatePanel(){ - CurrencyMessage message = (CurrencyMessage) this.message; - Double currForSaleCount = message.getCurrForSaleCount(); - Double curCount = message.getCurCount(); - double rate = curCount / currForSaleCount; - DecimalFormat decimalFormat = new DecimalFormat("#.####"); - JPanel ratePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,"(")); - JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + message.getCurrency() + ".png", 26); - currencyLabel.setBorder(null); - ratePanel.add(currencyLabel); - ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,decimalFormat.format(rate))); - ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MESSAGE, TextAlignment.CENTER, 18f, null,")")); - ratePanel.setBorder(BorderFactory.createEmptyBorder(-5,0,-5,0)); - return ratePanel; - } - private JPanel getWhisperPanel(){ - JPanel topPanel = new JPanel(new BorderLayout()); - topPanel.setBackground(AppThemeColor.MSG_HEADER); - - whisperLabel = componentsFactory.getTextLabel(FontStyle.BOLD,cachedWhisperColor, TextAlignment.LEFTOP,15f,getNicknameLabel()); - Border border = whisperLabel.getBorder(); - whisperLabel.setBorder(new CompoundBorder(border,new EmptyBorder(0,0,0,5))); - whisperLabel.setVerticalAlignment(SwingConstants.CENTER); - - JPanel nickNamePanel = componentsFactory.getTransparentPanel(new BorderLayout()); - if(style.equals(MessagePanelStyle.HISTORY)){ - nickNamePanel.add(whisperLabel,BorderLayout.CENTER); - }else { - JPanel buttonWrapper = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); - buttonWrapper.setBorder(BorderFactory.createEmptyBorder(2,0,0,0)); - buttonWrapper.add(getExpandButton()); - if(!style.equals(MessagePanelStyle.SP_MODE)) { - nickNamePanel.add(buttonWrapper, BorderLayout.LINE_START); - } - nickNamePanel.add(whisperLabel,BorderLayout.CENTER); - } - topPanel.add(nickNamePanel,BorderLayout.CENTER); - - JPanel interactionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - interactionPanel.setBorder(BorderFactory.createEmptyBorder(1,0,1,0)); - interactionPanel.setBackground(AppThemeColor.TRANSPARENT); - interactionPanel.add(getTimePanel()); - if(!style.equals(MessagePanelStyle.HISTORY)) { - JButton inviteButton = componentsFactory.getIconButton("app/invite.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); - inviteButton.addActionListener(e -> controller.performInvite()); - JButton kickButton = componentsFactory.getIconButton("app/kick.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); - kickButton.addActionListener(e -> { - controller.performKick(); - if(this.notificationService.get().isDismissAfterKick() && !style.equals(MessagePanelStyle.SP_MODE)){ - controller.performHide(); - } - }); - tradeButton = componentsFactory.getIconButton("app/trade.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); - tradeButton.addActionListener(e -> controller.performOfferTrade()); - interactionPanel.add(inviteButton); - interactionPanel.add(kickButton); - interactionPanel.add(tradeButton); - interactionPanel.add(getStillInterestedButton()); - }else { - JButton reloadButton = componentsFactory.getIconButton("app/reload-history.png", 14, AppThemeColor.MSG_HEADER, "Restore"); - reloadButton.addActionListener(e -> controller.reloadMessage(this)); - interactionPanel.add(reloadButton); - } - JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); - openChatButton.setToolTipText("Open chat"); - openChatButton.addActionListener(e -> controller.performOpenChat()); - - interactionPanel.add(openChatButton); - JButton hideButton = componentsFactory.getIconButton("app/close.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); - hideButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - controller.performHide(); - } - } - }); - if(!style.equals(MessagePanelStyle.HISTORY) && !style.equals(MessagePanelStyle.SP_MODE)) { - interactionPanel.add(hideButton); - } - - topPanel.add(interactionPanel,BorderLayout.LINE_END); - return topPanel; - } - private String getNicknameLabel(){ - String whisperNickname = message.getWhisperNickname(); - String result = whisperNickname + ":"; - if(this.notificationService.get().isShowLeague()) { - if (message.getLeague() != null) { - String league = message.getLeague().trim(); - if (league.length() == 0) { - return result; - } - if (league.contains("Hardcore")) { - if (league.equals("Hardcore")) { - result = "HC " + result; - } else { - result = String.valueOf(league.split(" ")[1].charAt(0)) + "HC " + result; - } - } else if (league.contains("Standard")) { - result = "Standard " + result; - } else { - result = String.valueOf(league.charAt(0)) + "SC " + result; - } - } - } - return result; - } - private JPanel getTimePanel(){ - JPanel panel = new JPanel(); - panel.setBackground(AppThemeColor.TRANSPARENT); - timeLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MISC, TextAlignment.CENTER, 14, cachedTime); - if(timeAgo == null) { - timeAgo = new Timer(60000, new ActionListener() { - private int minute = 0; - private int hours = 0; - private int day = 0; - - @Override - public void actionPerformed(ActionEvent e) { - String labelText = ""; - minute++; - if (minute > 60) { - hours++; - minute = 0; - if (hours > 24) { - day++; - hours = 0; - } - } - if (hours == 0 && day == 0) { - labelText = minute + "m"; - } else if (hours > 0) { - labelText = hours + "h " + minute + "m"; - } else if (day > 0) { - labelText = day + "d " + hours + "h " + minute + "m"; - } - timeLabel.setText(labelText); - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - } - }); - timeAgo.start(); - } - panel.add(timeLabel); - return panel; - } - public void disableTime(){ - if(timeAgo != null) { - timeAgo.stop(); - timeLabel.setText(""); - } - } - private JButton getExpandButton(){ - String iconPath = "app/default-mp.png"; - if(expanded){ - if(style.equals(MessagePanelStyle.DOWNWARDS_SMALL)){ - iconPath = "app/expand-mp.png"; - }else { - iconPath = "app/collapse-mp.png"; - } - } - expandButton = componentsFactory.getIconButton(iconPath, 18f, AppThemeColor.MSG_HEADER,""); - expandButton.setBorder(BorderFactory.createEmptyBorder(4,4,4,0)); - expandButton.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - if (!messagePanel.isVisible()) { - expand(); - } else { - collapse(); - } - } - } - }); - return expandButton; - } - public void expand(){ - expanded = true; - if(style.equals(MessagePanelStyle.DOWNWARDS_SMALL)) { - expandButton.setIcon(componentsFactory.getIcon("app/expand-mp.png", 18f)); - messagePanel.setVisible(true); - customButtonsPanel.setVisible(true); - }else { - expandButton.setIcon(componentsFactory.getIcon("app/collapse-mp.png", 18f)); - messagePanel.setVisible(true); - customButtonsPanel.setVisible(true); - } - setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - setMinimumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - MercuryStoreUI.expandMessageSubject.onNext(true); - MercuryStoreUI.packSubject.onNext(MessageFrame.class); - } - public void collapse(){ - expanded = false; - if(style.equals(MessagePanelStyle.DOWNWARDS_SMALL)) { - expandButton.setIcon(componentsFactory.getIcon("app/default-mp.png", 18)); - messagePanel.setVisible(false); - customButtonsPanel.setVisible(false); - }else { - expandButton.setIcon(componentsFactory.getIcon("app/default-mp.png", 18)); - messagePanel.setVisible(false); - customButtonsPanel.setVisible(false); - } - setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - setMinimumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - MercuryStoreUI.collapseMessageSubject.onNext(true); - MercuryStoreUI.packSubject.onNext(MessageFrame.class); - } - - public boolean isExpanded() { - return expanded; - } - - public void setStyle(MessagePanelStyle style) { - this.style = style; - this.cachedTime = timeLabel.getText(); - init(); - setMaximumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - setMinimumSize(new Dimension(Integer.MAX_VALUE,getPreferredSize().height)); - } - - public MessagePanelStyle getStyle() { - return style; - } - private JPanel getButtonsPanel(){ - JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - panel.setBackground(AppThemeColor.TRANSPARENT); - initResponseButtons(panel); - return panel; - } - @Override - public void subscribe() { - MercuryStoreCore.playerJoinSubject.subscribe(nickname -> { - if(nickname.equals(whisper)){ - whisperLabel.setForeground(AppThemeColor.TEXT_SUCCESS); - cachedWhisperColor = AppThemeColor.TEXT_SUCCESS; - if(!style.equals(MessagePanelStyle.HISTORY)) { - tradeButton.setEnabled(true); - } - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - } - }); - MercuryStoreCore.playerLeftSubject.subscribe(nickname -> { - if (nickname.equals(whisper)) { - whisperLabel.setForeground(AppThemeColor.TEXT_DISABLE); - cachedWhisperColor = AppThemeColor.TEXT_DISABLE; - if (!style.equals(MessagePanelStyle.HISTORY)) { - tradeButton.setEnabled(false); - } - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - } - }); - MercuryStoreCore.buttonsChangedSubject.subscribe(state -> { - this.customButtonsPanel.removeAll(); - initResponseButtons(customButtonsPanel); - MercuryStoreUI.repaintSubject.onNext(MessageFrame.class); - }); - } - private void initResponseButtons(JPanel panel){ - List buttonsConfig = this.notificationService.get().getButtons(); - Collections.sort(buttonsConfig); - buttonsConfig.forEach((buttonConfig)->{ - JButton button = componentsFactory.getBorderedButton(buttonConfig.getTitle(),15f); - button.addActionListener(e -> { - controller.performResponse(buttonConfig.getResponseText()); - if(buttonConfig.isClose() && !style.equals(MessagePanelStyle.SP_MODE)){ - controller.performHide(); - } - }); - panel.add(button); - }); - } - private JButton getStillInterestedButton(){ - JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.STILL_INTERESTED); - - String curCount = message.getCurCount() % 1 == 0 ? - String.valueOf(message.getCurCount().intValue()) : - String.valueOf(message.getCurCount()); - String responseText = "Hi, are you still interested in "; - if(message instanceof ItemMessage){ - ItemMessage message = (ItemMessage) this.message; - if(message.getCurrency().equals("???")){ - responseText += message.getItemName() + "?"; - }else { - responseText += message.getItemName() + - " for " + curCount + " " + message.getCurrency() + "?"; - } - }else { - CurrencyMessage message = (CurrencyMessage) this.message; - String curForSaleCount = message.getCurCount() % 1 == 0 ? - String.valueOf(message.getCurrForSaleCount().intValue()) : - String.valueOf(message.getCurrForSaleCount()); - responseText += curForSaleCount + " " + message.getCurrForSaleTitle() + " for " + - curCount + " " + message.getCurrency() + "?"; - } - String finalResponseText = responseText; // hate java - stillIntButton.addActionListener( - (action)->controller.performResponse(finalResponseText) - ); - return stillIntButton; - } - - public void setComponentsFactory(ComponentsFactory componentsFactory) { - this.componentsFactory = componentsFactory; - } - @Override - public void initHotKeyListeners() { - KeyValueConfigurationService config = Configuration.get().hotKeysConfiguration(); - MercuryStoreCore.hotKeySubject.subscribe(descriptor -> { - HotKeyDescriptor hotKeyDescriptor = config.get(HotKeyType.CLOSE_NOTIFICATION.name()); - if(descriptor.equals(hotKeyDescriptor)) { - this.controller.performHide(); - } - }); - } +public abstract class MessagePanel extends JPanel implements AsSubscriber, HasUI { + protected ComponentsFactory componentsFactory; + protected PlainConfigurationService notificationService; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelBuilder.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelBuilder.java index 0225fa0b..da5a667f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelBuilder.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelBuilder.java @@ -2,5 +2,5 @@ public class MessagePanelBuilder { - + private MessagePanelStyle style; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelController.java index c0135d80..5fd05539 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelController.java @@ -14,5 +14,5 @@ public interface MessagePanelController { * Show Item Stash Highlights */ void showITH(); - void reloadMessage(@NonNull MessagePanel panel); + void reloadMessage(@NonNull InMessagePanel panel); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelFactory.java new file mode 100644 index 00000000..36c0bb5b --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelFactory.java @@ -0,0 +1,5 @@ +package com.mercury.platform.ui.components.panel.message; + + +public class MessagePanelFactory { +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelProvider.java new file mode 100644 index 00000000..ed7d2e26 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelProvider.java @@ -0,0 +1,7 @@ +package com.mercury.platform.ui.components.panel.message; + + +public interface MessagePanelProvider { + boolean isSuitable(MessagePanelStyle style); + +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelStyle.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelStyle.java index 6c65d4c1..0c549a83 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelStyle.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/MessagePanelStyle.java @@ -1,8 +1,5 @@ package com.mercury.platform.ui.components.panel.message; -/** - * Created by Константин on 24.12.2016. - */ public enum MessagePanelStyle { - DOWNWARDS_SMALL, UPWARDS_SMALL,HISTORY, SP_MODE + OUT_MESSAGE, IN_DOWNWARDS, IN_UPWARDS,HISTORY, RELOADED } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/NotificationMessageController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/NotificationMessageController.java index ce122b04..12fc186c 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/NotificationMessageController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/NotificationMessageController.java @@ -3,7 +3,6 @@ import com.mercury.platform.shared.entity.message.ItemMessage; import com.mercury.platform.shared.entity.message.Message; import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.frame.movable.container.MessageFrame; import com.mercury.platform.ui.misc.MercuryStoreUI; import lombok.NonNull; import org.apache.logging.log4j.LogManager; @@ -64,7 +63,7 @@ public void showITH() { } @Override - public void reloadMessage(MessagePanel panel) { + public void reloadMessage(InMessagePanel panel) { MercuryStoreUI.reloadMessageSubject.onNext(panel); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/OutMessagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/OutMessagePanel.java new file mode 100644 index 00000000..e617bd57 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/message/OutMessagePanel.java @@ -0,0 +1,7 @@ +package com.mercury.platform.ui.components.panel.message; + +/** + * Created by Константин on 10.08.2017. + */ +public class OutMessagePanel { +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java deleted file mode 100644 index d71a8c56..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java +++ /dev/null @@ -1,216 +0,0 @@ -package com.mercury.platform.ui.components.panel.settings; - -import com.mercury.platform.core.misc.WhisperNotifierStatus; -import com.mercury.platform.core.update.core.holder.ApplicationHolder; -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.frame.titled.NotesFrame; -import com.mercury.platform.ui.frame.titled.SettingsFrame; -import com.mercury.platform.ui.frame.titled.TestCasesFrame; -import com.mercury.platform.ui.manager.FramesManager; -import com.mercury.platform.ui.manager.HideSettingsManager; -import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.MercuryStoreUI; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionAdapter; -import java.io.File; - -public class GeneralSettings extends ConfigurationPanel { - private PlainConfigurationService applicationConfig; - private JSlider minSlider; - private JSlider maxSlider; - private JSlider fadeTimeSlider; - private JComboBox notifierStatusPicker; - private JCheckBox checkEnable; - private JTextField gamePathField; - private WrongGamePathListener poeFolderTooltipListener; - public GeneralSettings() { - super(); - this.applicationConfig = Configuration.get().applicationConfiguration(); - this.createUI(); - } - - @Override - public void createUI() { - verticalScrollContainer.add(getSettingsSlidePanel()); - verticalScrollContainer.add(getSettingsPanel()); - } - private JPanel getSettingsPanel() { - JPanel root = componentsFactory.getTransparentPanel(new GridLayout(7,2,4,4)); - root.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); - root.setBackground(AppThemeColor.SLIDE_BG); - - this.checkEnable = new JCheckBox(); - this.checkEnable.setBackground(AppThemeColor.TRANSPARENT); - this.checkEnable.setSelected(this.applicationConfig.get().isCheckOutUpdate()); - - this.fadeTimeSlider = this.componentsFactory.getSlider(0,10, this.applicationConfig.get().getFadeTime(),AppThemeColor.SLIDE_BG); - this.fadeTimeSlider.addChangeListener(e -> { - MercuryStoreUI.repaintSubject.onNext(SettingsFrame.class); - }); - - this.minSlider = this.componentsFactory.getSlider(40,100,this.applicationConfig.get().getMinOpacity(),AppThemeColor.SLIDE_BG); - this.minSlider.addChangeListener(e -> { - if(!(this.minSlider.getValue() > this.maxSlider.getValue())) { - MercuryStoreUI.repaintSubject.onNext(SettingsFrame.class); - }else { - minSlider.setValue(minSlider.getValue()-1); - } - }); - - this.maxSlider = this.componentsFactory.getSlider(40,100,this.applicationConfig.get().getMaxOpacity(),AppThemeColor.SLIDE_BG); - this.maxSlider.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - if(minSlider.getValue() > maxSlider.getValue()){ - minSlider.setValue(maxSlider.getValue()); - } - } - }); - - this.notifierStatusPicker = this.componentsFactory.getComboBox(new String[]{"Always play a sound", "Only when tabbed out","Never"}); - WhisperNotifierStatus whisperNotifier = this.applicationConfig.get().getNotifierStatus(); - this.notifierStatusPicker.setSelectedIndex(whisperNotifier.getCode()); - - this.gamePathField = this.componentsFactory.getTextField(this.applicationConfig.get().getGamePath()); - this.gamePathField.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.BORDER,1), - BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2) - )); - - JPanel poeFolderPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - poeFolderPanel.add(this.gamePathField); - JButton changeButton = this.componentsFactory.getBorderedButton("Change"); - poeFolderPanel.add(changeButton); - - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - changeButton.addActionListener(e -> { - int returnVal = fileChooser.showOpenDialog(this); - if(returnVal == JFileChooser.APPROVE_OPTION) { - this.gamePathField.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.BORDER,1), - BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2) - )); - this.gamePathField.setText(fileChooser.getSelectedFile().getPath()); - this.gamePathField.removeMouseListener(poeFolderTooltipListener); - this.poeFolderTooltipListener = null; - this.repaint(); - } - }); - - root.add(this.componentsFactory.getTextLabel("Notify me when an update is available", FontStyle.REGULAR)); - root.add(this.checkEnable); - root.add(this.componentsFactory.getTextLabel("Component fade out time: ", FontStyle.REGULAR)); - root.add(this.fadeTimeSlider); - root.add(this.componentsFactory.getTextLabel("Min opacity: ", FontStyle.REGULAR)); - root.add(this.minSlider); - root.add(this.componentsFactory.getTextLabel("Max opacity: ", FontStyle.REGULAR)); - root.add(this.maxSlider); - root.add(this.componentsFactory.getTextLabel("Notification sound alerts: ", FontStyle.REGULAR)); - root.add(this.notifierStatusPicker); - root.add(this.componentsFactory.getTextLabel("Path of Exile folder: ", FontStyle.REGULAR)); - root.add(poeFolderPanel); - return root; - } - private JPanel getSettingsSlidePanel(){ - JPanel root = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); - JButton openTutorial = - componentsFactory.getIconButton("app/tutorial.png", - 30, - AppThemeColor.TRANSPARENT, - "Open tutorial"); - openTutorial.addActionListener(action -> { - FramesManager.INSTANCE.hideFrame(SettingsFrame.class); - FramesManager.INSTANCE.preShowFrame(NotesFrame.class); - }); - JButton checkUpdates = - componentsFactory.getIconButton("app/check-update.png", - 30, - AppThemeColor.TRANSPARENT, - "Check for updates"); - checkUpdates.addActionListener(action -> { - ApplicationHolder.getInstance().setManualRequest(true); - MercuryStoreCore.requestPatchSubject.onNext(true); - }); - JButton openTests = - componentsFactory.getIconButton("app/open-tests.png", - 30, - AppThemeColor.TRANSPARENT, - "Open tests"); - openTests.addActionListener(action -> { - FramesManager.INSTANCE.hideFrame(SettingsFrame.class); - FramesManager.INSTANCE.preShowFrame(TestCasesFrame.class); - }); - root.addMouseMotionListener(new MouseMotionAdapter() { - @Override - public void mouseMoved(MouseEvent e) { - MercuryStoreUI.repaintSubject.onNext(SettingsFrame.class); - } - }); - root.add(openTutorial); - root.add(checkUpdates); - root.add(openTests); - return root; - } - @Override - public boolean processAndSave() { - int minOpacity = this.minSlider.getValue(); - int maxOpacity = this.maxSlider.getValue(); - int timeToDelay= this.fadeTimeSlider.getValue(); - HideSettingsManager.INSTANCE.apply(timeToDelay,minOpacity,maxOpacity); - this.applicationConfig.get().setNotifierStatus(WhisperNotifierStatus.get(this.notifierStatusPicker.getSelectedIndex())); - this.applicationConfig.get().setCheckOutUpdate(this.checkEnable.isSelected()); - if (this.isValidGamePath(this.gamePathField.getText())){ - this.applicationConfig.get().setGamePath(this.gamePathField.getText()+ File.separator); - MercuryStoreCore.poeFolderChangedSubject.onNext(true); - } else { - this.gamePathField.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.TEXT_IMPORTANT,1), - BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2) - )); - if(poeFolderTooltipListener == null){ - this.poeFolderTooltipListener = new WrongGamePathListener(); - this.gamePathField.addMouseListener(poeFolderTooltipListener); - } - return false; - } - return true; - } - - private boolean isValidGamePath(String gamePath){ - File file = new File(gamePath + File.separator + "logs" + File.separator + "Client.txt"); - return file.exists(); - } - - @Override - public void restore() { - this.verticalScrollContainer.removeAll(); - this.createUI(); - } - - private class WrongGamePathListener extends MouseAdapter{ - @Override - public void mouseEntered(MouseEvent e) { - MercuryStoreCore.tooltipSubject.onNext( - "Wrong Path of Exile folder! Open Task Manager (CTRL + Shift + ESC) and check the path here!"); - } - - @Override - public void mouseExited(MouseEvent e) { - MercuryStoreCore.tooltipSubject.onNext(null); - } - - @Override - public void mousePressed(MouseEvent e) { - MercuryStoreCore.tooltipSubject.onNext(null); - } - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuAction.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuAction.java new file mode 100644 index 00000000..b819eeab --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuAction.java @@ -0,0 +1,6 @@ +package com.mercury.platform.ui.components.panel.settings; + + +public interface MenuAction { + void onClick(); +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuEntry.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuEntry.java new file mode 100644 index 00000000..8da4026c --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuEntry.java @@ -0,0 +1,14 @@ +package com.mercury.platform.ui.components.panel.settings; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import javax.swing.*; + +@Data +@AllArgsConstructor +public class MenuEntry { + private String text; + private MenuAction action; + private ImageIcon imageIcon; +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuListRenderer.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuListRenderer.java new file mode 100644 index 00000000..437352b4 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuListRenderer.java @@ -0,0 +1,38 @@ +package com.mercury.platform.ui.components.panel.settings; + + + +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; + +public class MenuListRenderer extends JButton implements ListCellRenderer { + private ComponentsFactory componentsFactory = new ComponentsFactory(); + @Override + public Component getListCellRendererComponent(JList list, MenuEntry value, int index, boolean isSelected, boolean cellHasFocus) { + JButton button = this.componentsFactory.getButton(value.getText()); + button.setForeground(AppThemeColor.TEXT_DEFAULT); + button.setHorizontalAlignment(SwingConstants.LEFT); + button.setBackground(AppThemeColor.FRAME); + button.setFont(this.componentsFactory.getFont(FontStyle.BOLD,16f)); + button.setPreferredSize(new Dimension(220,50)); + button.setIcon(value.getImageIcon()); + if(isSelected){ + button.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createEmptyBorder(0,14,0,0), + BorderFactory.createMatteBorder(0,0,0,4,AppThemeColor.TEXT_DEFAULT))); + button.setBackground(AppThemeColor.ADR_BG); + }else { + button.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createMatteBorder(0,0,0,1,AppThemeColor.ADR_PANEL_BORDER), + BorderFactory.createEmptyBorder(0,10,0,3))); + } + button.addActionListener(action -> { + value.getAction().onClick(); + }); + return button; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuPanel.java new file mode 100644 index 00000000..8086984b --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuPanel.java @@ -0,0 +1,75 @@ +package com.mercury.platform.ui.components.panel.settings; + +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.manager.routing.SettingsPage; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class MenuPanel extends JPanel implements HasUI { + private ComponentsFactory componentsFactory = new ComponentsFactory(); + public MenuPanel() { + super(); + this.setBackground(AppThemeColor.FRAME); + this.setPreferredSize(new Dimension(220, 20)); + this.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, AppThemeColor.ADR_PANEL_BORDER)); + this.createUI(); + } + @Override + public void createUI() { + JList list = new JList<>(getEntries()); + list.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + list.setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + @Override + public void mouseExited(MouseEvent e) { + list.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + }); + list.setCellRenderer(new MenuListRenderer()); + list.setBackground(AppThemeColor.FRAME); + list.setSelectedIndex(0); + list.addListSelectionListener(e -> + list.getSelectedValue().getAction().onClick()); + + JLabel appIcon = this.componentsFactory.getTextLabel("MercuryTrade", FontStyle.BOLD, 22); + appIcon.setIcon(this.componentsFactory.getIcon("app/app-icon.png", 50)); + appIcon.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); + appIcon.setBackground(AppThemeColor.FRAME); + this.add(appIcon, BorderLayout.PAGE_START); + this.add(list, BorderLayout.CENTER); + } + + @SuppressWarnings("all") + private MenuEntry[] getEntries() { + return new MenuEntry[]{ + new MenuEntry("General", () -> { + MercuryStoreUI.settingsStateSubject.onNext(SettingsPage.GENERAL_SETTINGS); + }, this.componentsFactory.getIcon("app/general_settings.png", 22)), + new MenuEntry("Sound", () -> { + MercuryStoreUI.settingsStateSubject.onNext(SettingsPage.SOUND_SETTING); + }, this.componentsFactory.getIcon("app/sound_settings.png", 22)), + new MenuEntry("Notification panel", () -> { + MercuryStoreUI.settingsStateSubject.onNext(SettingsPage.NOTIFICATION_SETTINGS); + }, this.componentsFactory.getIcon("app/notification_panel_settings.png", 22)), + new MenuEntry("Task bar", () -> { + MercuryStoreUI.settingsStateSubject.onNext(SettingsPage.TASK_BAR_SETTINGS); + }, this.componentsFactory.getIcon("app/task_bar_settings.png", 22)), + new MenuEntry("Support", () -> { + MercuryStoreUI.settingsStateSubject.onNext(SettingsPage.SUPPORT); + }, this.componentsFactory.getIcon("app/support_settings.png", 22)), + new MenuEntry("About", () -> { + MercuryStoreUI.settingsStateSubject.onNext(SettingsPage.ABOUT); + }, this.componentsFactory.getIcon("app/app-icon_sepia.png", 22)), + }; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/NotificationPanelSettings.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/NotificationPanelSettings.java deleted file mode 100644 index 1a244ed8..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/NotificationPanelSettings.java +++ /dev/null @@ -1,266 +0,0 @@ -package com.mercury.platform.ui.components.panel.settings; - -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; -import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.frame.titled.SettingsFrame; -import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.MercuryStoreUI; - -import javax.swing.*; -import javax.swing.border.CompoundBorder; -import javax.swing.border.EmptyBorder; -import java.awt.*; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.*; -import java.util.List; - - -public class NotificationPanelSettings extends ConfigurationPanel{ - private List inputs; - private JPanel buttonsTable; - private JCheckBox dismissCheckBox; - private JCheckBox showLeagueCheckBox; - private PlainConfigurationService notificationService; - private int id; - - public NotificationPanelSettings() { - super(); - this.notificationService = Configuration.get().notificationConfiguration(); - this.createUI(); - } - - @Override - public boolean processAndSave() { - List buttons = new ArrayList<>(); - id = 0; - inputs.forEach(pair -> { - buttons.add(new ResponseButtonDescriptor( - id, - pair.kick.isSelected(), - pair.close.isSelected(), - pair.title.getText(), - pair.response.getText())); - id++; - }); - this.notificationService.get().setButtons(buttons); - this.notificationService.get().setDismissAfterKick(this.dismissCheckBox.isSelected()); - this.notificationService.get().setShowLeague(this.showLeagueCheckBox.isSelected()); - MercuryStoreCore.buttonsChangedSubject.onNext(true); - return true; - } - - @Override - public void restore() { - verticalScrollContainer.removeAll(); - createUI(); - } - - @Override - public void createUI() { - JPanel otherSettings = componentsFactory.getTransparentPanel(new BorderLayout()); - JLabel settingLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Customization"); - settingLabel.setBorder(new CompoundBorder(BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - new EmptyBorder(3,5,3,5))); - - otherSettings.add(settingLabel,BorderLayout.PAGE_START); - otherSettings.add(closeOnKickPanel(),BorderLayout.CENTER); - - - JPanel responseButtons = componentsFactory.getTransparentPanel(new BorderLayout()); - JLabel responseLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Response buttons"); - responseLabel.setBorder(new CompoundBorder(BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - new EmptyBorder(3,5,3,5))); - responseButtons.add(responseLabel,BorderLayout.PAGE_START); - responseButtons.add(getButtonsTable(),BorderLayout.CENTER); - - verticalScrollContainer.add(otherSettings); - verticalScrollContainer.add(responseButtons); - } - private JPanel closeOnKickPanel() { - JPanel topPanel = componentsFactory.getTransparentPanel(new GridLayout(2,2)); - topPanel.add(componentsFactory.getTextLabel("Close Notification panel on Kick:", FontStyle.REGULAR)); - dismissCheckBox = this.componentsFactory.getCheckBox(this.notificationService.get().isDismissAfterKick()); - topPanel.add(dismissCheckBox); - - topPanel.add(componentsFactory.getTextLabel("Show league:", FontStyle.REGULAR)); - showLeagueCheckBox = this.componentsFactory.getCheckBox(this.notificationService.get().isShowLeague()); - topPanel.add(showLeagueCheckBox); - - topPanel.setBorder(new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,0,3,0))); - topPanel.setBackground(AppThemeColor.SETTINGS_BG); - return topPanel; - } - private JPanel getButtonsTable() { - buttonsTable = componentsFactory.getTransparentPanel(new GridBagLayout()); - buttonsTable.setBackground(AppThemeColor.SETTINGS_BG); - inputs = new ArrayList<>(); - List buttonsConfig = this.notificationService.get().getButtons(); - Collections.sort(buttonsConfig); - GridBagConstraints titleColumn = new GridBagConstraints(); - GridBagConstraints valueColumn = new GridBagConstraints(); - GridBagConstraints kickColumn = new GridBagConstraints(); - GridBagConstraints closeColumn = new GridBagConstraints(); - GridBagConstraints utilColumn = new GridBagConstraints(); - - setUpGBConstants(titleColumn,valueColumn,kickColumn,closeColumn,utilColumn); - - JLabel titleLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,"Label"); - titleLabel.setHorizontalAlignment(SwingConstants.CENTER); - - JLabel valueLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,"Response text"); - valueLabel.setHorizontalAlignment(SwingConstants.CENTER); - - JLabel closeLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,"Close"); - closeLabel.setHorizontalAlignment(SwingConstants.CENTER); - - buttonsTable.add(titleLabel, titleColumn); - titleColumn.gridy++; - buttonsTable.add(valueLabel,valueColumn); - valueColumn.gridy++; - buttonsTable.add(closeLabel,closeColumn); - closeColumn.gridy++; - buttonsTable.add(componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,""),utilColumn); - utilColumn.gridy++; - - buttonsConfig.forEach(button ->{ - addNewRow(button.getTitle(),button.getResponseText(),button.isKick(),button.isClose(),titleColumn,valueColumn,kickColumn,closeColumn,utilColumn); - }); - - JButton addNew = componentsFactory.getBorderedButton("Add"); - addNew.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - if (inputs.size() <= 12) { - buttonsTable.remove(addNew); - addNewRow("expl", "example",false,false, titleColumn, valueColumn,kickColumn,closeColumn, utilColumn); - buttonsTable.add(addNew, utilColumn); - - MercuryStoreUI.packSubject.onNext(SettingsFrame.class); - } - } - } - }); - buttonsTable.add(addNew,utilColumn); - return buttonsTable; - } - private void addNewRow(String title, String value, boolean kick, - boolean close, - GridBagConstraints tC, - GridBagConstraints vC, - GridBagConstraints kC, - GridBagConstraints cC, - GridBagConstraints uC){ - JTextField titleFiled = componentsFactory.getTextField(title,FontStyle.REGULAR,15f); - titleFiled.addKeyListener(new KeyAdapter() { - @Override - public void keyTyped(KeyEvent e) { - if(titleFiled.getText().length() > 10){ - e.consume(); - } - } - }); - - buttonsTable.add(titleFiled,tC); - tC.gridy++; - - JTextField valueField = componentsFactory.getTextField(value,FontStyle.REGULAR,15f); - buttonsTable.add(valueField,vC); - vC.gridy++; - - JPanel kickWrapper = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); - JCheckBox kickCheckBox = this.componentsFactory.getCheckBox(kick); - kickCheckBox.setBackground(AppThemeColor.TRANSPARENT); - kickWrapper.add(kickCheckBox); - kC.gridy++; - - JCheckBox closeCheckBox = componentsFactory.getCheckBox(close,"Close notification panel on click"); - closeCheckBox.setPreferredSize(new Dimension(32,32)); - buttonsTable.add(closeCheckBox,cC); - cC.gridy++; - ValuePair pair = new ValuePair(titleFiled, valueField, kickCheckBox, closeCheckBox); - inputs.add(pair); - - - JButton remove = componentsFactory.getBorderedButton("x"); - remove.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - inputs.remove(pair); - buttonsTable.remove(titleFiled); - buttonsTable.remove(valueField); - buttonsTable.remove(closeCheckBox); - buttonsTable.remove(remove); - - MercuryStoreUI.packSubject.onNext(SettingsFrame.class); - } - } - }); - buttonsTable.add(remove,uC); - uC.gridy++; - } - private void setUpGBConstants(GridBagConstraints titleColumn, - GridBagConstraints valueColumn, - GridBagConstraints kickColumn, - GridBagConstraints closeColumn, - GridBagConstraints utilColumn){ - titleColumn.fill = GridBagConstraints.HORIZONTAL; - valueColumn.fill = GridBagConstraints.HORIZONTAL; - kickColumn.fill = GridBagConstraints.HORIZONTAL; - closeColumn.fill = GridBagConstraints.HORIZONTAL; - utilColumn.fill = GridBagConstraints.HORIZONTAL; - - titleColumn.weightx = 0.09f; - valueColumn.weightx = 0.9f; - kickColumn.weightx = 0.002f; - closeColumn.weightx = 0.002f; - utilColumn.weightx = 0.002f; - - titleColumn.anchor = GridBagConstraints.NORTHWEST; - valueColumn.anchor = GridBagConstraints.NORTHWEST; - kickColumn.anchor = GridBagConstraints.NORTHWEST; - closeColumn.anchor = GridBagConstraints.NORTHWEST; - utilColumn.anchor = GridBagConstraints.NORTHWEST; - - titleColumn.gridy = 0; - titleColumn.gridx = 1; - valueColumn.gridy = 0; - valueColumn.gridx = 2; - kickColumn.gridy = 0; - kickColumn.gridx = 3; - closeColumn.gridy = 0; - closeColumn.gridx = 4; - utilColumn.gridy = 0; - utilColumn.gridx = 5; - - utilColumn.insets = new Insets(3,2,3,0); - titleColumn.insets = new Insets(3,2,3,0); - kickColumn.insets = new Insets(3,2,3,0); - closeColumn.insets = new Insets(3,2,3,0); - valueColumn.insets = new Insets(3,2,3,0); - } - private class ValuePair { - private JTextField title; - private JTextField response; - private JCheckBox kick; - private JCheckBox close; - - public ValuePair(JTextField title, JTextField response, JCheckBox kick, JCheckBox close) { - this.title = title; - this.response = response; - this.kick = kick; - this.close = close; - } - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java deleted file mode 100644 index 392c0812..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.mercury.platform.ui.components.panel.settings; - -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.descriptor.SoundDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.misc.AppThemeColor; - -import javax.swing.*; -import javax.swing.border.CompoundBorder; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.HashMap; -import java.util.Map; - -public class SoundSettingsPanel extends ConfigurationPanel { - private Map wavPaths; - - private JSlider notificationSlider; - private JSlider chatScannerSlider; - private JSlider clicksSlider; - private JSlider updateSlider; - - public SoundSettingsPanel() { - super(); - this.wavPaths = new HashMap<>(); - this.wavPaths.put("notification","app/notification.wav"); - this.wavPaths.put("chat_scanner","app/chat-filter.wav"); - this.wavPaths.put("clicks","app/sounds/click1/button-pressed-10.wav"); - this.wavPaths.put("update","app/patch_tone.wav"); - this.createUI(); - } - - @Override - public void createUI() { - verticalScrollContainer.add(getVolumePanel()); - verticalScrollContainer.add(getSoundPickerPanel()); - } - - private JPanel getVolumePanel(){ - Map map = Configuration.get().soundConfiguration().getMap(); - - JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); - - JLabel volumeLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Volume"); - volumeLabel.setBorder( - new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,5,3,5))); - - - JPanel container = componentsFactory.getTransparentPanel(new GridLayout(4, 2)); - container.setBackground(AppThemeColor.SETTINGS_BG); - container.setBorder(new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,0,3,0))); - - notificationSlider = componentsFactory.getSlider(-40, 6, map.get("notification").getDb().intValue(),AppThemeColor.SETTINGS_BG); - notificationSlider.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( - wavPaths.get("notification"), - notificationSlider.getValue() == -40 ? -80f : (float)notificationSlider.getValue() - )); - } - }); - chatScannerSlider = componentsFactory.getSlider(-40, 6, map.get("chat_scanner").getDb().intValue(),AppThemeColor.SETTINGS_BG); - chatScannerSlider.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( - wavPaths.get("chat_scanner"), - chatScannerSlider.getValue() == -40 ? -80f : (float)chatScannerSlider.getValue() - )); - } - }); - clicksSlider = componentsFactory.getSlider(-40, 6, map.get("clicks").getDb().intValue(),AppThemeColor.SETTINGS_BG); - clicksSlider.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( - wavPaths.get("clicks"), - clicksSlider.getValue() == -40 ? -80f : (float)clicksSlider.getValue() - )); - } - }); - updateSlider = componentsFactory.getSlider(-40, 6, map.get("update").getDb().intValue(),AppThemeColor.SETTINGS_BG); - updateSlider.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( - wavPaths.get("update"), - updateSlider.getValue() == -40 ? -80f : (float)updateSlider.getValue() - )); - } - }); - container.add(componentsFactory.getTextLabel("Notification:",FontStyle.REGULAR)); - container.add(notificationSlider); - container.add(componentsFactory.getTextLabel("Chat Scanner",FontStyle.REGULAR)); - container.add(chatScannerSlider); - container.add(componentsFactory.getTextLabel("Clicks",FontStyle.REGULAR)); - container.add(clicksSlider); - container.add(componentsFactory.getTextLabel("Update notification",FontStyle.REGULAR)); - container.add(updateSlider); - - root.add(volumeLabel,BorderLayout.PAGE_START); - root.add(container,BorderLayout.CENTER); - return root; - } - - private JPanel getSoundPickerPanel(){ - JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); - - JLabel soundLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Sound (in next update)"); - soundLabel.setBorder( - new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,5,3,5))); - -// JPanel container = componentsFactory.getTransparentPanel(new GridLayout(2, 2,0,1)); -// container.setBackground(AppThemeColor.SETTINGS_BG); -// container.setBorder(new CompoundBorder( -// BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), -// BorderFactory.createEmptyBorder(3,0,3,0))); -// -// JComboBox notificationComboBox = componentsFactory.getComboBox(new String[]{"Mercury Notification", "Mercury Chat Scanner", "Browse"}); -// notificationComboBox.addItemListener(e -> { -// switch (e.getStateChange()){ -// case ItemEvent.SELECTED: { -// if(notificationComboBox.getSelectedItem().equals("Browse")){ -// JFileChooser fileChooser = new JFileChooser(); -// fileChooser.setFileFilter(new FileNameExtensionFilter("*.wav","wav")); -// int returnVal = fileChooser.showOpenDialog(null); -// if(returnVal == JFileChooser.APPROVE_OPTION) { -// System.out.println(fileChooser.getSelectedFile().getPath()); -// } -// } -// break; -// } -// } -// }); -// -// -// JComboBox chatScannerComboBox = componentsFactory.getComboBox(new String[]{"Mercury Notification", "Mercury Chat Scanner", "Browse"}); -// -// -// container.add(componentsFactory.getTextLabel("Notification:",FontStyle.REGULAR)); -// container.add(notificationComboBox); -// container.add(componentsFactory.getTextLabel("Chat Scanner",FontStyle.REGULAR)); -// container.add(chatScannerComboBox); - root.add(soundLabel,BorderLayout.PAGE_START); -// root.add(container,BorderLayout.CENTER); - - return root; - } - - - @Override - public boolean processAndSave() { - Map map = Configuration.get().soundConfiguration().getMap(); - map.get("notification") - .setDb((float)notificationSlider.getValue()); - map.get("chat_scanner") - .setDb((float)chatScannerSlider.getValue()); - map.get("clicks") - .setDb((float)clicksSlider.getValue()); - map.get("update") - .setDb((float)updateSlider.getValue()); - MercuryStoreCore.saveConfigSubject.onNext(true); - return true; - } - - @Override - public void restore() { - Map map = Configuration.get().soundConfiguration().getMap(); - notificationSlider.setValue( - map.get("notification").getDb().intValue()); - chatScannerSlider.setValue( - map.get("chat_scanner").getDb().intValue()); - clicksSlider.setValue( - map.get("clicks").getDb().intValue()); - updateSlider.setValue( - map.get("update").getDb().intValue()); - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/TaskBarSettingsPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/TaskBarSettingsPanel.java deleted file mode 100644 index c4206a53..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/TaskBarSettingsPanel.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.mercury.platform.ui.components.panel.settings; - -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.misc.AppThemeColor; - -import javax.swing.*; -import javax.swing.border.CompoundBorder; -import java.awt.*; - -public class TaskBarSettingsPanel extends ConfigurationPanel{ - private PlainConfigurationService applicationConfig; - private JTextField responseField; - private JCheckBox enableInGameDND; - - public TaskBarSettingsPanel() { - super(); - this.applicationConfig = Configuration.get().applicationConfiguration(); - this.createUI(); - } - @Override - public void createUI() { - JPanel root = componentsFactory.getTransparentPanel(new GridLayout(1, 1)); - JPanel dndSettings = componentsFactory.getTransparentPanel(new BorderLayout()); - JLabel dndLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "DND mode"); - dndLabel.setBorder( - new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,5,3,5))); - - dndSettings.add(dndLabel,BorderLayout.PAGE_START); - dndSettings.add(getDNDPanel(),BorderLayout.CENTER); - root.add(dndSettings); - verticalScrollContainer.add(root, BorderLayout.PAGE_START); - } - private JPanel getDNDPanel(){ - JPanel topPanel = componentsFactory.getTransparentPanel(new GridLayout(2,2)); - topPanel.add(componentsFactory.getTextLabel("Enable in-game dnd:", FontStyle.REGULAR), BorderLayout.LINE_START); - enableInGameDND = new JCheckBox(); - enableInGameDND.setBackground(AppThemeColor.TRANSPARENT); - enableInGameDND.setSelected(this.applicationConfig.get().isInGameDnd()); - responseField = componentsFactory.getTextField(this.applicationConfig.get().getDndResponseText(), FontStyle.REGULAR, 16f); - responseField.setEnabled(this.applicationConfig.get().isInGameDnd()); - componentsFactory.setUpToggleCallbacks(enableInGameDND, - () -> responseField.setEnabled(false), - () -> responseField.setEnabled(true),this.applicationConfig.get().isInGameDnd()); - - topPanel.add(enableInGameDND, BorderLayout.CENTER); - - topPanel.add(componentsFactory.getTextLabel("DND response:", FontStyle.REGULAR)); - topPanel.add(responseField); - - topPanel.setBorder(new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,0,3,0))); - topPanel.setBackground(AppThemeColor.SETTINGS_BG); - return topPanel; - } - @Override - public void restore() { - this.verticalScrollContainer.removeAll(); - this.createUI(); - } - - @Override - public boolean processAndSave() { - this.applicationConfig.get().setInGameDnd(enableInGameDND.isSelected()); - this.applicationConfig.get().setDndResponseText(responseField.getText()); - return true; - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/data/DataActionListener.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/data/DataActionListener.java deleted file mode 100644 index 9f2fd56d..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/data/DataActionListener.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.mercury.platform.ui.components.panel.settings.data; - - -public interface DataActionListener { - void onSave(); -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/data/DataBindListenerPool.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/data/DataBindListenerPool.java deleted file mode 100644 index d95cc7f5..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/data/DataBindListenerPool.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mercury.platform.ui.components.panel.settings.data; - - -import java.util.ArrayList; -import java.util.List; - -public class DataBindListenerPool { - private List listeners = new ArrayList<>(); - private void add(DataActionListener listener){ - this.listeners.add(listener); - } - private void save(){ - this.listeners.forEach(DataActionListener::onSave); - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/AboutPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/AboutPagePanel.java similarity index 80% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/AboutPanel.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/AboutPagePanel.java index ea6294fe..5f7ecd6f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/AboutPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/AboutPagePanel.java @@ -1,57 +1,42 @@ -package com.mercury.platform.ui.components.panel.settings; +package com.mercury.platform.ui.components.panel.settings.page; + import com.mercury.platform.core.MercuryConstants; -import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.components.panel.misc.HasUI; import com.mercury.platform.ui.misc.AppThemeColor; import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.io.IOException; import java.net.URI; -import java.net.URISyntaxException; - -/** - * Created by Константин on 05.01.2017. - */ -public class AboutPanel extends JPanel implements HasUI { - private ComponentsFactory componentsFactory; - public AboutPanel() { - super(); - componentsFactory = new ComponentsFactory(); - this.setBackground(AppThemeColor.TRANSPARENT); - createUI(); - } +public class AboutPagePanel extends SettingsPagePanel { @Override public void createUI() { + super.createUI(); this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); JPanel imgPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); imgPanel.add(componentsFactory.getIconLabel("app/app-icon-big.png")); - this.add(imgPanel); - - JPanel aboutPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - aboutPanel.add(getInfoPanel()); - - this.add(aboutPanel); +// this.add(imgPanel,BorderLayout.CENTER); + this.container.add(this.componentsFactory.wrapToSlide(getInfoPanel())); } private JPanel getInfoPanel(){ JPanel panel = componentsFactory.getTransparentPanel(); + panel.setBackground(AppThemeColor.ADR_BG); + panel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS)); JPanel titlePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - titlePanel.add(componentsFactory.getTextLabel("MercuryTrade", FontStyle.REGULAR)); + titlePanel.add(componentsFactory.getTextLabel("MercuryTrade", FontStyle.REGULAR,15)); panel.add(titlePanel); JPanel versionPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - versionPanel.add(componentsFactory.getTextLabel("App version: " + MercuryConstants.APP_VERSION, FontStyle.REGULAR)); + versionPanel.add(componentsFactory.getTextLabel("App version: " + MercuryConstants.APP_VERSION, FontStyle.REGULAR,15)); panel.add(versionPanel); - JLabel redditButton = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_MESSAGE, TextAlignment.LEFTOP,16f,"Reddit"); + JLabel redditButton = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_MESSAGE, TextAlignment.LEFTOP,16f,"Reddit"); redditButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -115,7 +100,7 @@ public void mouseExited(MouseEvent e) { }); JPanel feedbackPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - feedbackPanel.add(componentsFactory.getTextLabel("Feedback & Suggestions: ", FontStyle.REGULAR)); + feedbackPanel.add(componentsFactory.getTextLabel("Feedback & Suggestions: ", FontStyle.REGULAR,15)); feedbackPanel.add(redditButton); feedbackPanel.add(githubButton); feedbackPanel.add(discordButton); @@ -123,4 +108,12 @@ public void mouseExited(MouseEvent e) { panel.add(feedbackPanel); return panel; } + + @Override + public void onSave() { + } + + @Override + public void restore() { + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GeneralSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GeneralSettingsPagePanel.java new file mode 100644 index 00000000..5ca752e5 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GeneralSettingsPagePanel.java @@ -0,0 +1,129 @@ +package com.mercury.platform.ui.components.panel.settings.page; + + +import com.mercury.platform.core.misc.WhisperNotifierStatus; +import com.mercury.platform.shared.CloneHelper; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.frame.titled.SettingsFrame; +import com.mercury.platform.ui.manager.HideSettingsManager; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class GeneralSettingsPagePanel extends SettingsPagePanel { + private PlainConfigurationService applicationConfig; + private ApplicationDescriptor applicationSnapshot; + + private JSlider minSlider; + private JSlider maxSlider; + @Override + public void createUI() { + super.createUI(); + this.applicationConfig = Configuration.get().applicationConfiguration(); + this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); + + JPanel root = componentsFactory.getJPanel(new GridLayout(0,2,4,4)); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + root.setBackground(AppThemeColor.ADR_BG); + + JCheckBox checkEnable = this.componentsFactory.getCheckBox(this.applicationSnapshot.isCheckOutUpdate()); + checkEnable.addActionListener(action -> { + this.applicationSnapshot.setCheckOutUpdate(checkEnable.isSelected()); + }); + JSlider fadeTimeSlider = this.componentsFactory.getSlider(0,10, this.applicationSnapshot.getFadeTime(),AppThemeColor.SLIDE_BG); + fadeTimeSlider.addChangeListener(e -> { + this.applicationSnapshot.setFadeTime(fadeTimeSlider.getValue()); + }); + + this.minSlider = this.componentsFactory.getSlider(40,100,this.applicationSnapshot.getMinOpacity(),AppThemeColor.SLIDE_BG); + this.minSlider.addChangeListener(e -> { + if(!(this.minSlider.getValue() > this.maxSlider.getValue())) { + this.applicationSnapshot.setMinOpacity(this.minSlider.getValue()); + }else { + minSlider.setValue(minSlider.getValue()-1); + } + }); + + this.maxSlider = this.componentsFactory.getSlider(40,100,this.applicationSnapshot.getMaxOpacity(),AppThemeColor.SLIDE_BG); + this.maxSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + if(minSlider.getValue() > maxSlider.getValue()){ + minSlider.setValue(maxSlider.getValue()); + } + applicationSnapshot.setMaxOpacity(maxSlider.getValue()); + } + }); + + JComboBox notifierStatusPicker = this.componentsFactory.getComboBox(new String[]{"Always play a sound", "Only when tabbed out","Never"}); + notifierStatusPicker.setSelectedItem(this.applicationSnapshot.getNotifierStatus().asPretty()); + notifierStatusPicker.addActionListener(action -> { + this.applicationSnapshot.setNotifierStatus(WhisperNotifierStatus.valueOfPretty((String) notifierStatusPicker.getSelectedItem())); + }); + + JTextField gamePathField = this.componentsFactory.getTextField(this.applicationSnapshot.getGamePath()); + gamePathField.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.BORDER,1), + BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2) + )); + gamePathField.addKeyListener(new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + applicationSnapshot.setGamePath(gamePathField.getText()); + } + }); + + JPanel poeFolderPanel = componentsFactory.getTransparentPanel(new BorderLayout(4,4)); + poeFolderPanel.add(gamePathField, BorderLayout.CENTER); + JButton changeButton = this.componentsFactory.getBorderedButton("Change"); + poeFolderPanel.add(changeButton, BorderLayout.LINE_END); + + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + changeButton.addActionListener(e -> { + int returnVal = fileChooser.showOpenDialog(this); + if(returnVal == JFileChooser.APPROVE_OPTION) { + gamePathField.setText(fileChooser.getSelectedFile().getPath()); + applicationSnapshot.setGamePath(fileChooser.getSelectedFile().getPath()); + } + }); + + root.add(this.componentsFactory.getTextLabel("Notify me when an update is available", FontStyle.REGULAR,16)); + root.add(checkEnable); + root.add(this.componentsFactory.getTextLabel("Component fade out time: ", FontStyle.REGULAR,16)); + root.add(fadeTimeSlider); + root.add(this.componentsFactory.getTextLabel("Min opacity: ", FontStyle.REGULAR,16)); + root.add(this.minSlider); + root.add(this.componentsFactory.getTextLabel("Max opacity: ", FontStyle.REGULAR,16)); + root.add(this.maxSlider); + root.add(this.componentsFactory.getTextLabel("Notification sound alerts: ", FontStyle.REGULAR,16)); + root.add(this.componentsFactory.wrapToSlide(notifierStatusPicker,AppThemeColor.ADR_BG,0,0,0,2)); + root.add(this.componentsFactory.getTextLabel("Path of Exile folder: ", FontStyle.REGULAR,16)); + root.add(this.componentsFactory.wrapToSlide(poeFolderPanel,AppThemeColor.ADR_BG,0,0,2,2)); + + this.container.add(this.componentsFactory.wrapToSlide(root)); + } + + @Override + public void onSave() { + HideSettingsManager.INSTANCE.apply(applicationSnapshot.getFadeTime(),applicationSnapshot.getMinOpacity(),applicationSnapshot.getMaxOpacity()); + this.applicationConfig.set(CloneHelper.cloneObject(this.applicationSnapshot)); + } + + @Override + public void restore() { + this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); + this.removeAll(); + this.createUI(); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java new file mode 100644 index 00000000..aa3c0ff0 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java @@ -0,0 +1,278 @@ +package com.mercury.platform.ui.components.panel.settings.page; + +import com.mercury.platform.shared.CloneHelper; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.KeyValueConfigurationService; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; +import com.mercury.platform.shared.config.descriptor.HotKeyType; +import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; +import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; +import com.mercury.platform.shared.entity.message.FlowDirections; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.util.Map; + +public class NotificationSettingsPagePanel extends SettingsPagePanel { + private PlainConfigurationService notificationService; + private KeyValueConfigurationService hotKeyService; + private NotificationDescriptor generalSnapshot; + private Map hotKeySnapshot; + private JPanel buttonsTable; + + @Override + public void createUI() { + super.createUI(); + this.notificationService = Configuration.get().notificationConfiguration(); + this.hotKeyService = Configuration.get().hotKeysConfiguration(); + this.generalSnapshot = CloneHelper.cloneObject(notificationService.get()); + this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.getMap()); + + JPanel inPanel = this.adrComponentsFactory.getCounterPanel(this.getIncomingPanel(), "Incoming notification:", AppThemeColor.ADR_BG,true); + inPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + JPanel outPanel = this.adrComponentsFactory.getCounterPanel(this.getOutgoingPanel(), "Outgoing notification:", AppThemeColor.ADR_BG,true); + outPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + this.container.add(this.componentsFactory.wrapToSlide(inPanel)); +// this.container.add(this.componentsFactory.wrapToSlide(outPanel)); + } + + @Override + public void onSave() { + this.notificationService.set(CloneHelper.cloneObject(this.generalSnapshot)); + this.hotKeyService.set(CloneHelper.cloneObject(this.hotKeySnapshot)); + MercuryStoreCore.buttonsChangedSubject.onNext(true); + } + + @Override + public void restore() { + this.generalSnapshot = CloneHelper.cloneObject(notificationService.get()); + this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.getMap()); + this.removeAll(); + this.createUI(); + } + + private JPanel getIncomingPanel() { + JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG); + JPanel propertiesPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.ADR_BG); + JCheckBox enabled = this.componentsFactory.getCheckBox(this.generalSnapshot.isNotificationEnable()); + enabled.addActionListener(action -> { + this.generalSnapshot.setNotificationEnable(enabled.isSelected()); + }); + JCheckBox dismiss = this.componentsFactory.getCheckBox(this.generalSnapshot.isDismissAfterKick()); + dismiss.addActionListener(action -> { + this.generalSnapshot.setDismissAfterKick(dismiss.isSelected()); + }); + JCheckBox showLeague = this.componentsFactory.getCheckBox(this.generalSnapshot.isShowLeague()); + showLeague.addActionListener(action -> { + this.generalSnapshot.setShowLeague(showLeague.isSelected()); + }); + JComboBox flowDirectionPicker = componentsFactory.getComboBox(new String[]{"Upwards", "Downwards"}); + flowDirectionPicker.addActionListener(e -> { + switch ((String)flowDirectionPicker.getSelectedItem()){ + case "Upwards":{ + this.generalSnapshot.setFlowDirections(FlowDirections.UPWARDS); + break; + } + case "Downwards":{ + this.generalSnapshot.setFlowDirections(FlowDirections.DOWNWARDS); + break; + } + } + }); + JSlider limitSlider = componentsFactory.getSlider(2, 20, this.generalSnapshot.getLimitCount(),AppThemeColor.ADR_BG); + limitSlider.addChangeListener(e -> { + this.generalSnapshot.setLimitCount(limitSlider.getValue()); + }); + JSlider unfoldSlider = componentsFactory.getSlider(0, 20, this.generalSnapshot.getUnfoldCount(),AppThemeColor.ADR_BG); + unfoldSlider.addChangeListener(e -> { + this.generalSnapshot.setUnfoldCount(unfoldSlider.getValue()); + }); + flowDirectionPicker.setSelectedIndex(this.generalSnapshot.getFlowDirections().ordinal()); + propertiesPanel.add(this.componentsFactory.getTextLabel("Enabled:", FontStyle.REGULAR,16)); + propertiesPanel.add(enabled); + propertiesPanel.add(this.componentsFactory.getTextLabel("Close panel on kick:", FontStyle.REGULAR,16)); + propertiesPanel.add(dismiss); + propertiesPanel.add(this.componentsFactory.getTextLabel("Show league:", FontStyle.REGULAR,16)); + propertiesPanel.add(showLeague); +// propertiesPanel.add(this.componentsFactory.getTextLabel("Flow direction:", FontStyle.REGULAR,16)); +// propertiesPanel.add(flowDirectionPicker); +// propertiesPanel.add(this.componentsFactory.getTextLabel("Pre-group limit:", FontStyle.REGULAR,16)); +// propertiesPanel.add(limitSlider); +// propertiesPanel.add(this.componentsFactory.getTextLabel("Unfold by default:", FontStyle.REGULAR,16)); +// propertiesPanel.add(unfoldSlider); + root.add(propertiesPanel,BorderLayout.PAGE_START); + root.add(this.componentsFactory.wrapToSlide(this.getResponseButtonsPanel(),AppThemeColor.ADR_BG),BorderLayout.CENTER); +// root.add(this.componentsFactory.wrapToSlide(this.getInNotificationHotKeysPanel(),AppThemeColor.ADR_BG),BorderLayout.PAGE_END); + return root; + } + private JPanel getResponseButtonsPanel(){ + JPanel root = this.componentsFactory.getJPanel(new BorderLayout(4,4), AppThemeColor.SETTINGS_BG); + this.buttonsTable = this.componentsFactory.getJPanel(new GridLayout(0, 1, 4, 4),AppThemeColor.SETTINGS_BG); + buttonsTable.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); + + JPanel headerPanel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.SETTINGS_BG); + + JLabel titleLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,"Label"); + titleLabel.setHorizontalAlignment(SwingConstants.CENTER); + titleLabel.setPreferredSize(new Dimension(120,26)); + JLabel valueLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,"Response text"); + valueLabel.setHorizontalAlignment(SwingConstants.CENTER); + + JLabel hotKeyLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,""); + hotKeyLabel.setHorizontalAlignment(SwingConstants.CENTER); + hotKeyLabel.setPreferredSize(new Dimension(130,20)); + + JLabel closeLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,""); + closeLabel.setHorizontalAlignment(SwingConstants.CENTER); + + headerPanel.add(titleLabel,BorderLayout.LINE_START); + headerPanel.add(valueLabel,BorderLayout.CENTER); + + JPanel miscPanel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.SETTINGS_BG); + miscPanel.add(hotKeyLabel,BorderLayout.CENTER); + miscPanel.add(closeLabel,BorderLayout.LINE_END); + headerPanel.add(miscPanel,BorderLayout.LINE_END); + + this.buttonsTable.add(headerPanel); + + this.generalSnapshot.getButtons().forEach(it -> { + this.buttonsTable.add(this.getResponseRow(it)); + }); + root.add(this.buttonsTable,BorderLayout.CENTER); + JButton addButton = this.componentsFactory.getIconButton("app/add_button.png", 24, AppThemeColor.HEADER, "Add button"); + addButton.setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER)); + addButton.addActionListener(action -> { + ResponseButtonDescriptor descriptor = new ResponseButtonDescriptor(); + int size = this.generalSnapshot.getButtons().size(); + descriptor.setId(++size); + this.generalSnapshot.getButtons().add(descriptor); + this.buttonsTable.add(this.getResponseRow(descriptor)); + MercuryStoreUI.settingsRepaintSubject.onNext(true); + MercuryStoreUI.settingsPackSubject.onNext(true); + }); + root.add(addButton,BorderLayout.PAGE_END); + return root; + } + private JPanel getResponseRow(ResponseButtonDescriptor descriptor){ + JPanel root = this.componentsFactory.getJPanel(new BorderLayout(4,4), AppThemeColor.SETTINGS_BG); + JTextField titleField = this.componentsFactory.getTextField(descriptor.getTitle(), FontStyle.REGULAR, 15f); + titleField.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + descriptor.setTitle(titleField.getText()); + System.out.println(".qwe"); + } + }); + titleField.setPreferredSize(new Dimension(120,26)); + JTextField responseField = this.componentsFactory.getTextField(descriptor.getResponseText(), FontStyle.REGULAR, 15f); + responseField.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + descriptor.setResponseText(responseField.getText()); + } + }); + root.add(titleField,BorderLayout.LINE_START); + root.add(responseField,BorderLayout.CENTER); + + JPanel miscPanel = this.componentsFactory.getJPanel(new BorderLayout(4, 4),AppThemeColor.SETTINGS_BG); + JCheckBox checkBox = this.componentsFactory.getCheckBox(descriptor.isClose(),"Close notification panel after click?"); + checkBox.addActionListener(action -> { + descriptor.setClose(checkBox.isSelected()); + }); + miscPanel.add(checkBox, BorderLayout.LINE_START); +// miscPanel.add(new HotKeyPanel(descriptor.getHotKeyDescriptor()),BorderLayout.CENTER); + + JButton removeButton = this.componentsFactory.getIconButton("app/adr/remove_node.png", 17, AppThemeColor.SETTINGS_BG, "Remove button"); + removeButton.addActionListener(action -> { + this.buttonsTable.remove(root); + this.generalSnapshot.getButtons().remove(descriptor); + MercuryStoreUI.settingsPackSubject.onNext(true); + MercuryStoreUI.settingsRepaintSubject.onNext(true); + }); + miscPanel.add(removeButton,BorderLayout.LINE_END); + + root.add(miscPanel,BorderLayout.LINE_END); + return root; + } + private JPanel getInNotificationHotKeysPanel(){ + JPanel root = this.componentsFactory.getJPanel(new GridLayout(0, 4, 4, 4),AppThemeColor.SETTINGS_BG); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); + this.hotKeySnapshot.forEach((key, value) -> { + if(HotKeyType.contains(key)) { + JLabel iconLabel = this.componentsFactory.getIconLabel(HotKeyType.valueOf(key).getIconPath(), 18); + iconLabel.setHorizontalAlignment(SwingConstants.CENTER); + root.add(iconLabel); + root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(value),AppThemeColor.SETTINGS_BG,1,4,1,1)); + } + }); + return root; + } + private JPanel getOutgoingPanel() { + JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG); + JPanel propertiesPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.ADR_BG); + JCheckBox enabled = this.componentsFactory.getCheckBox(this.generalSnapshot.isNotificationEnable()); + enabled.addActionListener(action -> { + this.generalSnapshot.setNotificationEnable(enabled.isSelected()); + }); + propertiesPanel.add(this.componentsFactory.getTextLabel("Enabled:", FontStyle.REGULAR,16)); + propertiesPanel.add(enabled); + root.add(propertiesPanel,BorderLayout.PAGE_START); + return root; + } + + private class HotKeyPanel extends JPanel { + private HotKeyDescriptor descriptor; + private boolean hotKeyAllowed; + private ComponentsFactory componentsFactory = new ComponentsFactory(); + public HotKeyPanel(HotKeyDescriptor descriptor) { + super(new BorderLayout()); + this.descriptor = descriptor; + this.setPreferredSize(new Dimension(130,26)); + + JButton button = this.componentsFactory.getBorderedButton(this.descriptor.getTitle()); + button.setFont(this.componentsFactory.getFont(FontStyle.BOLD, 18f)); + MouseAdapter mouseAdapter = new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if(SwingUtilities.isLeftMouseButton(e)) { + button.setBackground(AppThemeColor.ADR_BG); + button.setText("Press any key"); + hotKeyAllowed = true; + button.removeMouseListener(this); + } + } + }; + button.addMouseListener(mouseAdapter); + MercuryStoreCore.hotKeySubject.subscribe(hotKey -> { + if (hotKeyAllowed) { + button.setBackground(AppThemeColor.BUTTON); + if (hotKey.getVirtualKeyCode() == 27) { + this.descriptor.setTitle("..."); + this.descriptor.setVirtualKeyCode(0); + this.descriptor.setMenuPressed(false); + this.descriptor.setShiftPressed(false); + this.descriptor.setControlPressed(false); + } else { + this.descriptor.setTitle(hotKey.getTitle()); + this.descriptor.setVirtualKeyCode(hotKey.getVirtualKeyCode()); + this.descriptor.setMenuPressed(hotKey.isMenuPressed()); + this.descriptor.setShiftPressed(hotKey.isShiftPressed()); + this.descriptor.setControlPressed(hotKey.isControlPressed()); + this.descriptor.setKeyChar(hotKey.getKeyChar()); + } + button.setText(hotKey.getTitle()); + hotKeyAllowed = false; + button.addMouseListener(mouseAdapter); + } + }); + this.add(button,BorderLayout.CENTER); + } + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SettingsPagePanel.java new file mode 100644 index 00000000..f874b49c --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SettingsPagePanel.java @@ -0,0 +1,36 @@ +package com.mercury.platform.ui.components.panel.settings.page; + + +import com.mercury.platform.ui.adr.components.AdrComponentsFactory; +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.panel.VerticalScrollContainer; +import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; + +public abstract class SettingsPagePanel extends JPanel implements HasUI{ + protected ComponentsFactory componentsFactory = new ComponentsFactory(); + protected AdrComponentsFactory adrComponentsFactory = new AdrComponentsFactory(this.componentsFactory); + protected JPanel container; + + public SettingsPagePanel() { + this.setLayout(new BorderLayout()); + this.setBackground(AppThemeColor.FRAME); + + this.createUI(); + } + + @Override + public void createUI() { + this.container = new VerticalScrollContainer(); + this.container.setBackground(AppThemeColor.FRAME); + this.container.setLayout(new BoxLayout(container,BoxLayout.Y_AXIS)); + JScrollPane verticalContainer = this.componentsFactory.getVerticalContainer( this.container); + this.add(verticalContainer,BorderLayout.CENTER); + } + + public abstract void onSave(); + public abstract void restore(); +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SoundSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SoundSettingsPagePanel.java new file mode 100644 index 00000000..2e127160 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SoundSettingsPagePanel.java @@ -0,0 +1,124 @@ +package com.mercury.platform.ui.components.panel.settings.page; + + +import com.mercury.platform.shared.CloneHelper; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.KeyValueConfigurationService; +import com.mercury.platform.shared.config.descriptor.SoundDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import javax.swing.border.CompoundBorder; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.Map; + +public class SoundSettingsPagePanel extends SettingsPagePanel { + private Map wavPaths; + + private JSlider notificationSlider; + private JSlider chatScannerSlider; + private JSlider clicksSlider; + private JSlider updateSlider; + + Map soundSnapshot; + KeyValueConfigurationService soundConfiguration; + @Override + public void createUI() { + super.createUI(); + this.wavPaths = new HashMap<>(); + this.wavPaths.put("notification","app/notification.wav"); + this.wavPaths.put("chat_scanner","app/chat-filter.wav"); + this.wavPaths.put("clicks","app/sounds/click1/button-pressed-10.wav"); + this.wavPaths.put("update","app/patch_tone.wav"); + this.soundConfiguration = Configuration.get().soundConfiguration(); + this.soundSnapshot = CloneHelper.cloneObject(this.soundConfiguration.getMap()); + + JPanel vPanel = this.getVolumePanel(); + JPanel volumePanel = this.adrComponentsFactory.getCounterPanel(vPanel, "Volume:", AppThemeColor.ADR_BG,true); + volumePanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + this.container.add(this.componentsFactory.wrapToSlide(volumePanel)); + } + + private JPanel getVolumePanel(){ + JPanel container = componentsFactory.getTransparentPanel(new GridLayout(0, 2,0,4)); + container.setBackground(AppThemeColor.ADR_BG); + container.setBorder(new CompoundBorder( + BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), + BorderFactory.createEmptyBorder(3,0,3,0))); + + notificationSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("notification").getDb().intValue(),AppThemeColor.SETTINGS_BG); + notificationSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( + wavPaths.get("notification"), + notificationSlider.getValue() == -40 ? -80f : (float)notificationSlider.getValue() + )); + } + }); + chatScannerSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("chat_scanner").getDb().intValue(),AppThemeColor.SETTINGS_BG); + chatScannerSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( + wavPaths.get("chat_scanner"), + chatScannerSlider.getValue() == -40 ? -80f : (float)chatScannerSlider.getValue() + )); + } + }); + clicksSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("clicks").getDb().intValue(),AppThemeColor.SETTINGS_BG); + clicksSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( + wavPaths.get("clicks"), + clicksSlider.getValue() == -40 ? -80f : (float)clicksSlider.getValue() + )); + } + }); + updateSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("update").getDb().intValue(),AppThemeColor.SETTINGS_BG); + updateSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( + wavPaths.get("update"), + updateSlider.getValue() == -40 ? -80f : (float)updateSlider.getValue() + )); + } + }); + container.add(componentsFactory.getTextLabel("Notification:",FontStyle.REGULAR,16)); + container.add(notificationSlider); + container.add(componentsFactory.getTextLabel("Chat Scanner",FontStyle.REGULAR,16)); + container.add(chatScannerSlider); + container.add(componentsFactory.getTextLabel("Clicks",FontStyle.REGULAR,16)); + container.add(clicksSlider); + container.add(componentsFactory.getTextLabel("Update notification",FontStyle.REGULAR,16)); + container.add(updateSlider); + return container; + } + + @Override + public void onSave() { + soundSnapshot.get("notification") + .setDb((float)notificationSlider.getValue()); + soundSnapshot.get("chat_scanner") + .setDb((float)chatScannerSlider.getValue()); + soundSnapshot.get("clicks") + .setDb((float)clicksSlider.getValue()); + soundSnapshot.get("update") + .setDb((float)updateSlider.getValue()); + this.soundConfiguration.set(CloneHelper.cloneObject(this.soundSnapshot)); + } + + @Override + public void restore() { + this.soundSnapshot = CloneHelper.cloneObject(this.soundConfiguration.getMap()); + this.removeAll(); + this.createUI(); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SupportPagePanel.java similarity index 70% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SupportPagePanel.java index 8af1d5bb..03f9c7e1 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SupportPagePanel.java @@ -1,10 +1,9 @@ -package com.mercury.platform.ui.components.panel.settings; +package com.mercury.platform.ui.components.panel.settings.page; + -import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; -import com.mercury.platform.ui.components.panel.misc.HasUI; import com.mercury.platform.ui.frame.titled.SettingsFrame; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; @@ -18,22 +17,13 @@ import java.util.*; import java.util.List; -public class SupportPanel extends JPanel implements HasUI{ - private ComponentsFactory componentsFactory; - public SupportPanel() { - super(); - componentsFactory = new ComponentsFactory(); - this.setBackground(AppThemeColor.SLIDE_BG); - this.createUI(); - } - +public class SupportPagePanel extends SettingsPagePanel{ @Override public void createUI() { - this.setLayout(new BorderLayout()); - JPanel donatePanel = componentsFactory.getTransparentPanel(); - donatePanel.setLayout(new BoxLayout(donatePanel,BoxLayout.Y_AXIS)); - donatePanel.setBackground(AppThemeColor.SLIDE_BG); + donatePanel.setBackground(AppThemeColor.ADR_BG); + donatePanel.setLayout(new GridLayout(0,1,5,5)); + donatePanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); JButton donate = componentsFactory.getIconifiedTransparentButton("app/paypal.png","Donate"); donate.setBorder(BorderFactory.createEmptyBorder(1,1,1,1)); @@ -58,22 +48,26 @@ public void mousePressed(MouseEvent e) { } } }); - JTextArea donateText = componentsFactory.getSimpleTextArea("We aimed to create a convenience tool in form of an easy-to-use application, primarily for trading purposes. If MercuryTrade successfully managed to save your time or improve your experience, you can thank us by donating and telling your friends."); + JTextArea donateText = componentsFactory.getSimpleTextArea("We aimed to create a convenience tool in form of an easy-to-use application, primarily for trading purposes. If MercuryTrade successfully managed to save your time or improve your experience, you can thank us by donating or telling your friends. If you want your name to be featured in our in-app Hall of Fame please provide this information within the transaction!"); donateText.setPreferredSize(new Dimension(300,150)); - JPanel donateTextPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); JPanel donateButtonPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); - donateButtonPanel.setBorder(BorderFactory.createEmptyBorder(30,0,0,0)); - donateTextPanel.add(donateText); + donateButtonPanel.setBorder(BorderFactory.createEmptyBorder(60,0,0,0)); donateButtonPanel.add(donate); donatePanel.add(donateButtonPanel); - donatePanel.add(donateTextPanel); - this.add(donatePanel,BorderLayout.CENTER); - this.add(getDonationsPanel(),BorderLayout.LINE_END); + donatePanel.add(this.componentsFactory.wrapToSlide(donateText,AppThemeColor.ADR_BG,4,14,4,14)); + + JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); + root.setBackground(AppThemeColor.FRAME); + root.add(this.componentsFactory.wrapToSlide(donatePanel),BorderLayout.CENTER); + root.add(this.componentsFactory.wrapToSlide(getDonationsPanel()),BorderLayout.LINE_END); + this.add(root,BorderLayout.CENTER); } + private JPanel getDonationsPanel() { JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); - root.setBorder(BorderFactory.createEmptyBorder(20,0,10,20)); - root.add(componentsFactory.getTextLabel("Thanks a lot for support: "),BorderLayout.PAGE_START); + root.setBackground(AppThemeColor.ADR_BG); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + root.add(componentsFactory.getTextLabel("Thanks a lot for support:"),BorderLayout.PAGE_START); JPanel donationsList = new VerticalScrollContainer(); donationsList.setBackground(AppThemeColor.TRANSPARENT); @@ -101,8 +95,7 @@ public void mouseWheelMoved(MouseWheelEvent e) { getDonations().forEach(pair -> { JPanel item = componentsFactory.getTransparentPanel(new BorderLayout()); - item.add(componentsFactory.getTextLabel(pair.name, FontStyle.REGULAR),BorderLayout.CENTER); -// item.add(componentsFactory.getTextLabel(pair.value.intValue() + "$", FontStyle.REGULAR),BorderLayout.LINE_END); + item.add(componentsFactory.getTextLabel(pair.name, FontStyle.REGULAR,pair.color),BorderLayout.CENTER); donationsList.add(item); }); @@ -111,18 +104,30 @@ public void mouseWheelMoved(MouseWheelEvent e) { } private List getDonations(){ List donations = new ArrayList<>(); - donations.add(new DonationPair("StubenZocker",0d)); - donations.add(new DonationPair("SirKultan",0d)); + donations.add(new DonationPair("222Craft",AppThemeColor.TEXT_DEFAULT)); + donations.add(new DonationPair("Blightsand",AppThemeColor.TEXT_DEFAULT)); + donations.add(new DonationPair("StubenZocker",AppThemeColor.TEXT_DEFAULT)); + donations.add(new DonationPair("SirKultan",AppThemeColor.TEXT_DEFAULT)); return donations; } private class DonationPair{ private String name; - private Double value; + private Color color; - DonationPair(String name, Double value) { + DonationPair(String name, Color color) { this.name = name; - this.value = value; + this.color = color; } } + + @Override + public void onSave() { + + } + + @Override + public void restore() { + + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java new file mode 100644 index 00000000..6854396a --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java @@ -0,0 +1,52 @@ +package com.mercury.platform.ui.components.panel.settings.page; + +import com.mercury.platform.shared.CloneHelper; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; + + +public class TaskBarSettingsPagePanel extends SettingsPagePanel { + private PlainConfigurationService applicationConfig; + private ApplicationDescriptor applicationSnapshot; + + @Override + public void createUI() { + super.createUI(); + this.applicationConfig = Configuration.get().applicationConfiguration(); + this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); + + JPanel root = componentsFactory.getJPanel(new GridLayout(0,2),AppThemeColor.ADR_BG); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + + JTextField responseField = componentsFactory.getTextField(this.applicationConfig.get().getDndResponseText(), FontStyle.REGULAR, 16f); + responseField.setEnabled(this.applicationConfig.get().isInGameDnd()); + JCheckBox inGameDND = this.componentsFactory.getCheckBox(this.applicationSnapshot.isInGameDnd()); + inGameDND.addActionListener(action -> { + this.applicationSnapshot.setInGameDnd(inGameDND.isSelected()); + responseField.setEnabled(inGameDND.isSelected()); + }); + root.add(componentsFactory.getTextLabel("Enable in-game dnd:", FontStyle.REGULAR)); + root.add(inGameDND); + root.add(componentsFactory.getTextLabel("DND response:", FontStyle.REGULAR)); + root.add(this.componentsFactory.wrapToSlide(responseField,AppThemeColor.ADR_BG)); + this.container.add(this.componentsFactory.wrapToSlide(root)); + } + + @Override + public void onSave() { + this.applicationConfig.set(CloneHelper.cloneObject(this.applicationSnapshot)); + } + + @Override + public void restore() { + this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); + this.removeAll(); + this.createUI(); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java index 78981a7b..b6c13f5f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java @@ -106,6 +106,9 @@ public void onLocationChange(Point location){ frameDescriptor.setFrameLocation(location); MercuryStoreCore.saveConfigSubject.onNext(true); } + public void onSizeChange(){ + MercuryStoreCore.saveConfigSubject.onNext(true); + } protected void onFrameDragged(Point location){ this.setLocation(location); } @@ -166,12 +169,12 @@ public void mouseReleased(MouseEvent e) { }else { frameDescriptor.setFrameSize(size); } - MercuryStoreCore.saveConfigSubject.onNext(true); + onSizeChange(); }else if(SEResizeSpace){ AbstractComponentFrame.this.setMinimumSize(size); AbstractComponentFrame.this.setMaximumSize(size); frameDescriptor.setFrameSize(AbstractComponentFrame.this.getSize()); - MercuryStoreCore.saveConfigSubject.onNext(true); + onSizeChange(); } EResizeSpace = false; SEResizeSpace = false; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java index 05073f5c..b869485c 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java @@ -12,7 +12,7 @@ import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.components.panel.message.MessagePanel; +import com.mercury.platform.ui.components.panel.message.InMessagePanel; import com.mercury.platform.ui.components.panel.message.MessagePanelController; import com.mercury.platform.ui.components.panel.message.NotificationMessageController; import com.mercury.platform.ui.components.panel.message.MessagePanelStyle; @@ -34,7 +34,7 @@ import java.util.stream.Collectors; public class MessageFrame extends AbstractMovableComponentFrame implements MessagesContainer { - private List currentMessages = new ArrayList<>(); + private List currentMessages = new ArrayList<>(); private PlainConfigurationService notificationConfig; private boolean wasVisible; private FlowDirections flowDirections; @@ -112,7 +112,7 @@ public void subscribe() { } }); MercuryStoreCore.messageSubject.subscribe(message -> SwingUtilities.invokeLater(()-> { - List collect = this.currentMessages.stream() + List collect = this.currentMessages.stream() .filter(panel -> panel.getMessage().equals(message)) .collect(Collectors.toList()); if(collect.size() == 0) { @@ -120,29 +120,33 @@ public void subscribe() { } })); MercuryStoreUI.closeMessage.subscribe(message -> { - MessagePanel messagePanel = this.currentMessages.stream() + List panels = this.currentMessages.stream() .filter(panel -> panel.getMessage().equals(message)) - .collect(Collectors.toList()).get(0); - if(messagePanel.isExpanded()){ - this.currentUnfoldCount--; - if(this.currentUnfoldCount < 0){ - this.currentUnfoldCount = 0; + .collect(Collectors.toList()); + if(panels.size() > 0) { + InMessagePanel inMessagePanel = panels.get(0); + if (inMessagePanel.isExpanded()) { + this.currentUnfoldCount--; + if (this.currentUnfoldCount < 0) { + this.currentUnfoldCount = 0; + } } - } - this.remove(messagePanel); - this.currentMessages.remove(messagePanel); + this.remove(inMessagePanel); + this.currentMessages.remove(inMessagePanel); - if (this.currentMessages.size() == 0) { - this.setVisible(false); - } else if (this.currentMessages.size() >= this.limitMsgCount) { - if(this.currentMessages.size() == this.limitMsgCount) { - this.expandAllFrame.setVisible(false); + if (this.currentMessages.size() == 0) { + this.setVisible(false); + } else if (this.currentMessages.size() >= this.limitMsgCount) { + if (this.currentMessages.size() == this.limitMsgCount) { + this.expandAllFrame.setVisible(false); + } + this.currentMessages.get(this.limitMsgCount - 1).setVisible(true); + this.expandAllFrame.decMessageCount(); } - this.currentMessages.get(this.limitMsgCount - 1).setVisible(true); - this.expandAllFrame.decMessageCount(); + this.pack(); + this.repaint(); + this.setUpExpandButton(); } - this.pack(); - this.setUpExpandButton(); }); MercuryStoreUI.expandMessageSubject.subscribe(state -> this.onExpandMessage()); MercuryStoreUI.collapseMessageSubject.subscribe(state -> this.onCollapseMessage()); @@ -150,8 +154,8 @@ public void subscribe() { private void addMessage(Message message){ MessagePanelStyle style = flowDirections.equals(FlowDirections.DOWNWARDS)? - MessagePanelStyle.DOWNWARDS_SMALL: MessagePanelStyle.UPWARDS_SMALL; - MessagePanel messagePanel = new MessagePanel( + MessagePanelStyle.IN_DOWNWARDS : MessagePanelStyle.IN_UPWARDS; + InMessagePanel inMessagePanel = new InMessagePanel( message, style, new NotificationMessageController(message), @@ -162,18 +166,19 @@ private void addMessage(Message message){ this.prevState = FrameVisibleState.SHOW; } if (flowDirections.equals(FlowDirections.UPWARDS)) { - this.mainContainer.add(messagePanel, 1); + this.mainContainer.add(inMessagePanel, 1); } else { - this.mainContainer.add(messagePanel); + this.mainContainer.add(inMessagePanel); } - this.currentMessages.add(messagePanel); + this.currentMessages.add(inMessagePanel); this.pack(); + this.repaint(); if (this.currentUnfoldCount < this.unfoldCount) { - messagePanel.expand(); + inMessagePanel.expand(); } if(this.currentMessages.size() > this.limitMsgCount){ if(!expanded) { - messagePanel.setVisible(false); + inMessagePanel.setVisible(false); } if(ProdStarter.APP_STATUS == FrameVisibleState.SHOW) { this.setUpExpandButton(); @@ -247,7 +252,7 @@ protected JPanel getPanelForPINSettings() { 18f, "Notification panel"); labelPanel.add(headerLabel,BorderLayout.CENTER); - JButton enableButton = this.componentsFactory.getBorderedButton(this.notificationConfig.get().isNotificationEnable() ? "Disable" : "Enable"); + JButton enableButton = this.componentsFactory.getBorderedButton(this.notificationConfig.get().isNotificationEnable() ? "Switch-off" : "Switch-on"); enableButton.addActionListener(action -> { boolean notificationEnable = this.notificationConfig.get().isNotificationEnable(); this.notificationConfig.get().setNotificationEnable(!notificationEnable); @@ -256,7 +261,7 @@ protected JPanel getPanelForPINSettings() { }else { headerLabel.setForeground(AppThemeColor.TEXT_DISABLE); } - enableButton.setText(!notificationEnable ? "Disable" : "Enable"); + enableButton.setText(!notificationEnable ? "Switch-off" : "Switch-on"); MercuryStoreCore.saveConfigSubject.onNext(true); }); enableButton.setFont(this.componentsFactory.getFont(FontStyle.BOLD,18f)); @@ -320,7 +325,7 @@ private void onLimitCountChange(){ private void onExpandedCountChange(){ this.currentUnfoldCount = 0; - this.currentMessages.forEach(MessagePanel::collapse); + this.currentMessages.forEach(InMessagePanel::collapse); this.currentUnfoldCount = 0; this.currentMessages.stream().limit(this.unfoldCount).forEach(panel -> { panel.expand(); @@ -410,7 +415,7 @@ private void changeDirectionTo(FlowDirections direction){ this.mainContainer.remove(this.buffer); Component[] components = this.mainContainer.getComponents(); for (Component component : components) { - ((MessagePanel) component).setStyle(MessagePanelStyle.DOWNWARDS_SMALL); + ((InMessagePanel) component).setStyle(MessagePanelStyle.IN_DOWNWARDS); this.mainContainer.remove(component); this.mainContainer.add(component, 0); } @@ -420,7 +425,7 @@ private void changeDirectionTo(FlowDirections direction){ this.mainContainer.add(buffer,0); Component[] components = this.mainContainer.getComponents(); for (int i = 1; i < components.length; i++) { - ((MessagePanel) components[i]).setStyle(MessagePanelStyle.UPWARDS_SMALL); + ((InMessagePanel) components[i]).setStyle(MessagePanelStyle.IN_UPWARDS); this.mainContainer.remove(components[i]); this.mainContainer.add(components[i], 1); } @@ -535,11 +540,11 @@ public void performHide() {} @Override public void showITH() {} @Override - public void reloadMessage(MessagePanel panel1) {} + public void reloadMessage(InMessagePanel panel1) {} }; - MessagePanel messagePanel = new MessagePanel(message, MessagePanelStyle.DOWNWARDS_SMALL, stubController, factory); - messagePanel.expand(); - panel.add(messagePanel); + InMessagePanel inMessagePanel = new InMessagePanel(message, MessagePanelStyle.IN_DOWNWARDS, stubController, factory); + inMessagePanel.expand(); + panel.add(inMessagePanel); return panel; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java index 2e0d5d5f..b52eaa19 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java @@ -1,94 +1,167 @@ package com.mercury.platform.ui.frame.titled; +import com.mercury.platform.core.update.core.holder.ApplicationHolder; +import com.mercury.platform.shared.config.descriptor.FrameDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.fields.MercuryTabbedPane; +import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.panel.settings.*; +import com.mercury.platform.ui.manager.FramesManager; import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; +import com.mercury.platform.ui.misc.note.Note; +import com.mercury.platform.ui.misc.note.NotesLoader; import javax.swing.*; import java.awt.*; -import java.util.*; -import java.util.List; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; public class SettingsFrame extends AbstractTitledComponentFrame { - private List innerPanels; - private boolean successfullySaved = true; + private JPanel currentPanel; + private MenuPanel menuPanel; + private JPanel root; public SettingsFrame(){ super(); this.setFocusable(true); this.setFocusableWindowState(true); this.setAlwaysOnTop(false); - this.innerPanels = new ArrayList<>(); this.processingHideEvent = false; this.processHideEffect = false; +// FrameDescriptor frameDescriptor = this.framesConfig.get(this.getClass().getSimpleName()); + this.setPreferredSize(new Dimension(1000,600)); } @Override protected void initialize() { super.initialize(); - this.initContainer(); + this.root = new JPanel(new BorderLayout()); + this.menuPanel = new MenuPanel(); + JPanel leftPanel = this.componentsFactory.getJPanel(new BorderLayout()); + leftPanel.add(this.menuPanel,BorderLayout.CENTER); + leftPanel.add(this.getOperationsButtons(),BorderLayout.PAGE_END); + this.add(leftPanel,BorderLayout.LINE_START); + this.add(this.root,BorderLayout.CENTER); + this.add(this.getBottomPanel(),BorderLayout.PAGE_END); this.pack(); } - private void initContainer() { - - MercuryTabbedPane tabbedPane = new MercuryTabbedPane(this); - - ConfigurationPanel generalSettings = new GeneralSettings(); - this.innerPanels.add(generalSettings); - ConfigurationPanel cbSettings = new NotificationPanelSettings(); - this.innerPanels.add(cbSettings); - ConfigurationPanel taskBarSettings = new TaskBarSettingsPanel(); - this.innerPanels.add(taskBarSettings); - ConfigurationPanel soundSettings = new SoundSettingsPanel(); - this.innerPanels.add(soundSettings); - - tabbedPane.addTab("General",generalSettings); - tabbedPane.addTab("Sound",soundSettings); - tabbedPane.addTab("Notification panel",cbSettings); - tabbedPane.addTab("Task panel",taskBarSettings); -// tabbedPane.addTab("Help",new HelpPanel()); - tabbedPane.addTab("Support",new SupportPanel()); - tabbedPane.addTab("About",new AboutPanel()); + @Override + public void onSizeChange() { + super.onSizeChange(); + FrameDescriptor frameDescriptor = this.framesConfig.get(this.getClass().getSimpleName()); + this.setPreferredSize(frameDescriptor.getFrameSize()); + } - this.add(tabbedPane, BorderLayout.CENTER); - this.add(getBottomPanel(), BorderLayout.PAGE_END); + public void setContentPanel(JPanel panel){ + if(currentPanel != null){ + this.root.remove(currentPanel); + } + this.root.add(panel,BorderLayout.CENTER); + this.currentPanel = panel; + this.pack(); + this.repaint(); + } + private JPanel getBottomPanel(){ + JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); + root.setBorder(BorderFactory.createMatteBorder(1,0,0,0,AppThemeColor.MSG_HEADER_BORDER)); + root.setBackground(AppThemeColor.ADR_FOOTER_BG); + root.add(this.getSaveButtonPanel(), BorderLayout.LINE_END); + return root; + } + private JPanel getSaveButtonPanel(){ + JPanel root = componentsFactory.getTransparentPanel(new GridLayout(1,0)); + JButton saveButton = componentsFactory.getBorderedButton("Save",16); + saveButton.addActionListener(e -> { + MercuryStoreCore.showingDelaySubject.onNext(true); + this.hideComponent(); + MercuryStoreUI.settingsSaveSubject.onNext(true); + }); + JButton cancelButton = componentsFactory.getButton( + FontStyle.BOLD, + AppThemeColor.FRAME, + BorderFactory.createLineBorder(AppThemeColor.BORDER), + "Cancel", + 16f); + cancelButton.addActionListener(e -> { + MercuryStoreCore.showingDelaySubject.onNext(true); + this.hideComponent(); + MercuryStoreUI.settingsRestoreSubject.onNext(true); + }); + saveButton.setPreferredSize(new Dimension(110, 26)); + cancelButton.setPreferredSize(new Dimension(110, 26)); + root.add(this.componentsFactory.wrapToSlide(saveButton,AppThemeColor.HEADER,2,2,2,2)); + root.add(this.componentsFactory.wrapToSlide(cancelButton,AppThemeColor.HEADER,2,2,2,2)); + return root; } - private JPanel getBottomPanel() { - JPanel panel = new JPanel(); - panel.setBackground(AppThemeColor.HEADER); + private JPanel getOperationsButtons(){ + JPanel root = componentsFactory.getTransparentPanel(new GridLayout(0,1,4,2)); + root.setBorder(BorderFactory.createMatteBorder(0,0,0,1,AppThemeColor.BORDER)); + JButton openTutorial = this.getOperationButton("Open tutorial","app/tutorial.png"); + openTutorial.addActionListener(action -> { + FramesManager.INSTANCE.hideFrame(SettingsFrame.class); + FramesManager.INSTANCE.preShowFrame(NotesFrame.class); + }); + JButton checkUpdates = this.getOperationButton("Check for updates", "app/check-update.png"); + checkUpdates.addActionListener(action -> { + ApplicationHolder.getInstance().setManualRequest(true); + MercuryStoreCore.requestPatchSubject.onNext(true); + }); + JButton openTests = this.getOperationButton("Open tests","app/open-tests.png"); + openTests.addActionListener(action -> { + FramesManager.INSTANCE.hideFrame(SettingsFrame.class); + FramesManager.INSTANCE.preShowFrame(TestCasesFrame.class); + }); + root.add(this.componentsFactory.wrapToSlide(openTutorial)); + root.add(this.componentsFactory.wrapToSlide(checkUpdates)); + root.add(this.componentsFactory.wrapToSlide(openTests)); - JButton save = componentsFactory.getBorderedButton("Save"); - save.addActionListener(e -> { - innerPanels.forEach(settingsPanel -> { - if(!settingsPanel.processAndSave()){ - successfullySaved = false; + JButton patchNotes = componentsFactory.getBorderedButton("Open patch notes"); + patchNotes.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if(SwingUtilities.isLeftMouseButton(e)){ + NotesLoader notesLoader = new NotesLoader(); + java.util.List patchNotes = notesLoader.getPatchNotes(); + if(patchNotes.size() != 0){ + NotesFrame patchNotesFrame = new NotesFrame(patchNotes, NotesFrame.NotesType.PATCH); + patchNotesFrame.init(); + patchNotesFrame.showComponent(); + } } - }); - if(successfullySaved) { - MercuryStoreCore.saveConfigSubject.onNext(true); - hideComponent(); - }else { - successfullySaved = true; } }); - JButton close = componentsFactory.getBorderedButton("Close"); - close.addActionListener(e -> { - innerPanels.forEach(ConfigurationPanel::restore); - pack(); - hideComponent(); - }); - save.setPreferredSize(new Dimension(80, 26)); - close.setPreferredSize(new Dimension(80, 26)); - panel.add(save); - panel.add(close); - return panel; +// root.add(patchNotes); + return root; + } + + private JButton getOperationButton(String title, String iconPath){ + JButton button = this.componentsFactory.getButton(title); + button.setPreferredSize(new Dimension(210,35)); + button.setForeground(AppThemeColor.TEXT_DEFAULT); + button.setHorizontalAlignment(SwingConstants.LEFT); + button.setBackground(AppThemeColor.ADR_BG); + button.setFont(this.componentsFactory.getFont(FontStyle.BOLD,16f)); + button.setIcon(this.componentsFactory.getIcon(iconPath,22)); + button.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createMatteBorder(1,1,1,1,AppThemeColor.ADR_PANEL_BORDER), + BorderFactory.createEmptyBorder(2,10,2,2))); + return button; } @Override public void subscribe() { + MercuryStoreUI.settingsRepaintSubject.subscribe(state -> { + this.repaint(); + }); + MercuryStoreUI.settingsPackSubject.subscribe(state -> { + this.pack(); + }); + MercuryStoreUI.adrManagerRepaint.subscribe(state -> { + this.repaint(); + }); } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryContainer.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryContainer.java index 48af7ff7..f5b2be32 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryContainer.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryContainer.java @@ -1,7 +1,7 @@ package com.mercury.platform.ui.frame.titled.container; -import com.mercury.platform.ui.components.panel.message.MessagePanel; +import com.mercury.platform.ui.components.panel.message.InMessagePanel; public interface HistoryContainer { - void onReloadMessage(MessagePanel messagePanel); + void onReloadMessage(InMessagePanel inMessagePanel); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java index 4dabe623..b495a9be 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/container/HistoryFrame.java @@ -6,7 +6,7 @@ import com.mercury.platform.shared.entity.message.Message; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; -import com.mercury.platform.ui.components.panel.message.MessagePanel; +import com.mercury.platform.ui.components.panel.message.InMessagePanel; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; import com.mercury.platform.ui.components.panel.message.NotificationMessageController; import com.mercury.platform.ui.components.panel.message.MessagePanelStyle; @@ -64,13 +64,13 @@ public void mouseWheelMoved(MouseWheelEvent e) { MessageParser parser = new MessageParser(); Message parsedMessage = parser.parse(message); if(parsedMessage != null) { - MessagePanel messagePanel = new MessagePanel( + InMessagePanel inMessagePanel = new InMessagePanel( parsedMessage, MessagePanelStyle.HISTORY, new NotificationMessageController(parsedMessage), this.componentsFactory); - messagePanel.disableTime(); - mainContainer.add(messagePanel); + inMessagePanel.disableTime(); + mainContainer.add(inMessagePanel); } } this.miscPanel.add(getClearButton(),0); @@ -83,13 +83,13 @@ public void mouseWheelMoved(MouseWheelEvent e) { MessageParser parser = new MessageParser(); Message parsedMessage = parser.parse(message); if(parsedMessage != null) { - MessagePanel messagePanel = new MessagePanel( + InMessagePanel inMessagePanel = new InMessagePanel( parsedMessage, MessagePanelStyle.HISTORY, new NotificationMessageController(parsedMessage), this.componentsFactory); - messagePanel.disableTime(); - this.mainContainer.add(messagePanel, 0); + inMessagePanel.disableTime(); + this.mainContainer.add(inMessagePanel, 0); } vBar.setValue(vBar.getValue() + 100); } @@ -124,12 +124,12 @@ protected String getFrameTitle() { public void subscribe() { MercuryStoreCore.messageSubject.subscribe(message -> SwingUtilities.invokeLater(()-> { HistoryManager.INSTANCE.add(message); - MessagePanel messagePanel = new MessagePanel( + InMessagePanel inMessagePanel = new InMessagePanel( message, MessagePanelStyle.HISTORY, new NotificationMessageController(message), this.componentsFactory); - this.mainContainer.add(messagePanel); + this.mainContainer.add(inMessagePanel); this.trimContainer(); this.pack(); })); @@ -145,9 +145,9 @@ private void trimContainer(){ } @Override - public void onReloadMessage(MessagePanel messagePanel) { - messagePanel.setStyle(MessagePanelStyle.SP_MODE); - messagePanel.setPreferredSize(new Dimension(this.getWidth()-10,messagePanel.getPreferredSize().height)); + public void onReloadMessage(InMessagePanel inMessagePanel) { + inMessagePanel.setStyle(MessagePanelStyle.RELOADED); + inMessagePanel.setPreferredSize(new Dimension(this.getWidth()-10, inMessagePanel.getPreferredSize().height)); this.pack(); this.repaint(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java index 43b5f155..27dcc682 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java @@ -22,6 +22,7 @@ import com.mercury.platform.ui.frame.other.SetUpLocationFrame; import com.mercury.platform.ui.frame.titled.chat.ChatFilterFrame; import com.mercury.platform.ui.frame.titled.container.HistoryFrame; +import com.mercury.platform.ui.manager.routing.SettingsRoutManager; import com.mercury.platform.ui.misc.MercuryStoreUI; import com.mercury.platform.ui.misc.note.Note; import com.mercury.platform.ui.misc.note.NotesLoader; @@ -73,7 +74,8 @@ public void start(){ this.framesMap.put(NotesFrame.class, new NotesFrame(notesOnFirstStart, NotesFrame.NotesType.INFO)); this.framesMap.put(HistoryFrame.class,new HistoryFrame()); - this.framesMap.put(SettingsFrame.class,new SettingsFrame()); + SettingsFrame settingsFrame = new SettingsFrame(); + this.framesMap.put(SettingsFrame.class,settingsFrame); this.framesMap.put(TestCasesFrame.class,new TestCasesFrame()); this.framesMap.put(TooltipFrame.class,new TooltipFrame()); this.framesMap.put(NotificationFrame.class,new NotificationFrame()); @@ -98,6 +100,7 @@ public void start(){ } } }); + new SettingsRoutManager(settingsFrame); this.subscribe(); this.adrManager.load(); MercuryStoreCore.uiLoadedSubject.onNext(true); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/routing/SettingsPage.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/routing/SettingsPage.java new file mode 100644 index 00000000..ea8d9b89 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/routing/SettingsPage.java @@ -0,0 +1,10 @@ +package com.mercury.platform.ui.manager.routing; + +public enum SettingsPage { + GENERAL_SETTINGS, + SOUND_SETTING, + NOTIFICATION_SETTINGS, + TASK_BAR_SETTINGS, + SUPPORT, + ABOUT +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/routing/SettingsRoutManager.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/routing/SettingsRoutManager.java new file mode 100644 index 00000000..4a447a58 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/routing/SettingsRoutManager.java @@ -0,0 +1,82 @@ +package com.mercury.platform.ui.manager.routing; + +import com.mercury.platform.shared.AsSubscriber; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.panel.settings.page.*; +import com.mercury.platform.ui.frame.titled.SettingsFrame; +import com.mercury.platform.ui.misc.MercuryStoreUI; + +public class SettingsRoutManager implements AsSubscriber{ + private SettingsPagePanel generalSettings; + private SettingsPagePanel soundSettings; + private SettingsPagePanel notificationSettings; + private SettingsPagePanel taskBarSettings; + private SettingsPagePanel supportPanel; + private SettingsPagePanel aboutPanel; + + private SettingsFrame settingsFrame; + + + public SettingsRoutManager(SettingsFrame settingsFrame) { + this.settingsFrame = settingsFrame; + + this.generalSettings = new GeneralSettingsPagePanel(); + this.soundSettings = new SoundSettingsPagePanel(); + this.generalSettings = new GeneralSettingsPagePanel(); + this.notificationSettings = new NotificationSettingsPagePanel(); + this.taskBarSettings = new TaskBarSettingsPagePanel(); + this.supportPanel = new SupportPagePanel(); + this.aboutPanel = new AboutPagePanel(); + + this.settingsFrame.setContentPanel(this.generalSettings); + this.subscribe(); + } + + @Override + public void subscribe() { + MercuryStoreUI.settingsStateSubject.subscribe(state -> { + switch (state){ + case GENERAL_SETTINGS:{ + this.settingsFrame.setContentPanel(this.generalSettings); + break; + } + case SOUND_SETTING:{ + this.settingsFrame.setContentPanel(this.soundSettings); + break; + } + case NOTIFICATION_SETTINGS:{ + this.settingsFrame.setContentPanel(this.notificationSettings); + break; + } + case TASK_BAR_SETTINGS:{ + this.settingsFrame.setContentPanel(this.taskBarSettings); + break; + } + case SUPPORT:{ + this.settingsFrame.setContentPanel(this.supportPanel); + break; + } + case ABOUT:{ + this.settingsFrame.setContentPanel(this.aboutPanel); + break; + } + } + }); + MercuryStoreUI.settingsRestoreSubject.subscribe(state -> { + this.generalSettings.restore(); + this.notificationSettings.restore(); + this.soundSettings.restore(); + this.taskBarSettings.restore(); + this.settingsFrame.repaint(); + this.settingsFrame.pack(); + }); + MercuryStoreUI.settingsSaveSubject.subscribe(state -> { + this.generalSettings.onSave(); + this.notificationSettings.onSave(); + this.soundSettings.onSave(); + this.taskBarSettings.onSave(); + MercuryStoreCore.saveConfigSubject.onNext(true); + MercuryStoreUI.settingsPostSubject.onNext(true); + }); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java index 24a2fa8a..d4192e09 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java @@ -34,4 +34,5 @@ public class AppThemeColor { public static final Color ADR_PANEL_BORDER = new Color(23, 103, 115); public static final Color ADR_TEXT_ARE_BG = new Color(50, 52, 51); public static final Color ADR_FOOTER_BG = new Color(55,65,64); + public static final Color ADR_CAPTURE_BG = new Color(42, 44, 43,1); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java index 67bf946d..0f697b96 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java @@ -9,8 +9,9 @@ import com.mercury.platform.ui.adr.routing.AdrPageDefinition; import com.mercury.platform.ui.components.panel.grid.ItemInfoPanel; import com.mercury.platform.ui.components.panel.grid.TabInfoPanel; -import com.mercury.platform.ui.components.panel.message.MessagePanel; +import com.mercury.platform.ui.components.panel.message.InMessagePanel; import com.mercury.platform.ui.dialog.DialogCallback; +import com.mercury.platform.ui.manager.routing.SettingsPage; import rx.subjects.PublishSubject; import java.util.Map; @@ -22,7 +23,7 @@ public class MercuryStoreUI { public static final PublishSubject dismissTabInfoPanelSubject = PublishSubject.create(); public static final PublishSubject expandMessageSubject = PublishSubject.create(); public static final PublishSubject itemCellStateSubject = PublishSubject.create(); - public static final PublishSubject reloadMessageSubject = PublishSubject.create(); + public static final PublishSubject reloadMessageSubject = PublishSubject.create(); //Scale public static final PublishSubject> saveScaleSubject = PublishSubject.create(); public static final PublishSubject notificationScaleSubject = PublishSubject.create(); @@ -52,5 +53,12 @@ public class MercuryStoreUI { public static final PublishSubject adrUpdateSubject = PublishSubject.create(); public static final PublishSubject> adrOpenIconSelectSubject = PublishSubject.create(); + public static final PublishSubject settingsStateSubject = PublishSubject.create(); + public static final PublishSubject settingsRepaintSubject = PublishSubject.create(); + public static final PublishSubject settingsPackSubject = PublishSubject.create(); + public static final PublishSubject settingsSaveSubject = PublishSubject.create(); + public static final PublishSubject settingsRestoreSubject = PublishSubject.create(); + public static final PublishSubject settingsPostSubject = PublishSubject.create(); + public static final PublishSubject onDestroySubject = PublishSubject.create(); } diff --git a/app-ui/src/main/resources/app/add_button.png b/app-ui/src/main/resources/app/add_button.png new file mode 100644 index 00000000..38fe7dd1 Binary files /dev/null and b/app-ui/src/main/resources/app/add_button.png differ diff --git a/app-ui/src/main/resources/app/adr/capture_group_icon.png b/app-ui/src/main/resources/app/adr/capture_group_icon.png new file mode 100644 index 00000000..34151de8 Binary files /dev/null and b/app-ui/src/main/resources/app/adr/capture_group_icon.png differ diff --git a/app-ui/src/main/resources/app/adr/capture_icon.png b/app-ui/src/main/resources/app/adr/capture_icon.png new file mode 100644 index 00000000..34151de8 Binary files /dev/null and b/app-ui/src/main/resources/app/adr/capture_icon.png differ diff --git a/app-ui/src/main/resources/app/adr_readme_logo.png b/app-ui/src/main/resources/app/adr_readme_logo.png deleted file mode 100644 index a9b2db7a..00000000 Binary files a/app-ui/src/main/resources/app/adr_readme_logo.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/adr_showcase_logo.png b/app-ui/src/main/resources/app/adr_showcase_logo.png deleted file mode 100644 index 692db0bf..00000000 Binary files a/app-ui/src/main/resources/app/adr_showcase_logo.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/app-icon-donate.png b/app-ui/src/main/resources/app/app-icon-donate.png deleted file mode 100644 index fdc22731..00000000 Binary files a/app-ui/src/main/resources/app/app-icon-donate.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/app-icon_sepia.png b/app-ui/src/main/resources/app/app-icon_sepia.png new file mode 100644 index 00000000..d9512521 Binary files /dev/null and b/app-ui/src/main/resources/app/app-icon_sepia.png differ diff --git a/app-ui/src/main/resources/app/arrows/down-arrow.png b/app-ui/src/main/resources/app/arrows/down-arrow.png deleted file mode 100644 index 5aeff5d7..00000000 Binary files a/app-ui/src/main/resources/app/arrows/down-arrow.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/arrows/left-arrow.png b/app-ui/src/main/resources/app/arrows/left-arrow.png deleted file mode 100644 index b5a19cec..00000000 Binary files a/app-ui/src/main/resources/app/arrows/left-arrow.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/arrows/right-arrow.png b/app-ui/src/main/resources/app/arrows/right-arrow.png deleted file mode 100644 index b3540c23..00000000 Binary files a/app-ui/src/main/resources/app/arrows/right-arrow.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/arrows/up-arrow.png b/app-ui/src/main/resources/app/arrows/up-arrow.png deleted file mode 100644 index aa747a8f..00000000 Binary files a/app-ui/src/main/resources/app/arrows/up-arrow.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/chatFilter.png b/app-ui/src/main/resources/app/chatFilter.png deleted file mode 100644 index 044333c5..00000000 Binary files a/app-ui/src/main/resources/app/chatFilter.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/clear-trades.png b/app-ui/src/main/resources/app/clear-trades.png deleted file mode 100644 index c94616d0..00000000 Binary files a/app-ui/src/main/resources/app/clear-trades.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/clear_trades.pdn b/app-ui/src/main/resources/app/clear_trades.pdn deleted file mode 100644 index a5c3f652..00000000 Binary files a/app-ui/src/main/resources/app/clear_trades.pdn and /dev/null differ diff --git a/app-ui/src/main/resources/app/collapse.png b/app-ui/src/main/resources/app/collapse.png deleted file mode 100644 index da77da0c..00000000 Binary files a/app-ui/src/main/resources/app/collapse.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/expand.png b/app-ui/src/main/resources/app/expand.png deleted file mode 100644 index 9824abc0..00000000 Binary files a/app-ui/src/main/resources/app/expand.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/general_settings.png b/app-ui/src/main/resources/app/general_settings.png new file mode 100644 index 00000000..5ec319bc Binary files /dev/null and b/app-ui/src/main/resources/app/general_settings.png differ diff --git a/app-ui/src/main/resources/app/logo.png b/app-ui/src/main/resources/app/logo.png deleted file mode 100644 index e5ffb8ab..00000000 Binary files a/app-ui/src/main/resources/app/logo.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/mercury_logo.pdn b/app-ui/src/main/resources/app/mercury_logo.pdn deleted file mode 100644 index 9290b5fd..00000000 Binary files a/app-ui/src/main/resources/app/mercury_logo.pdn and /dev/null differ diff --git a/app-ui/src/main/resources/app/notification_panel_settings.png b/app-ui/src/main/resources/app/notification_panel_settings.png new file mode 100644 index 00000000..f0acb17f Binary files /dev/null and b/app-ui/src/main/resources/app/notification_panel_settings.png differ diff --git a/app-ui/src/main/resources/app/paypal.png b/app-ui/src/main/resources/app/paypal.png index 2ee6b569..5d51eff7 100644 Binary files a/app-ui/src/main/resources/app/paypal.png and b/app-ui/src/main/resources/app/paypal.png differ diff --git a/app-ui/src/main/resources/app/reload.gif b/app-ui/src/main/resources/app/reload.gif deleted file mode 100644 index 9408387f..00000000 Binary files a/app-ui/src/main/resources/app/reload.gif and /dev/null differ diff --git a/app-ui/src/main/resources/app/rw-resize.png b/app-ui/src/main/resources/app/rw-resize.png deleted file mode 100644 index d7b22fe6..00000000 Binary files a/app-ui/src/main/resources/app/rw-resize.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/sound_settings.png b/app-ui/src/main/resources/app/sound_settings.png new file mode 100644 index 00000000..904c43ab Binary files /dev/null and b/app-ui/src/main/resources/app/sound_settings.png differ diff --git a/app-ui/src/main/resources/app/standard-mode.png b/app-ui/src/main/resources/app/standard-mode.png deleted file mode 100644 index c7afdb88..00000000 Binary files a/app-ui/src/main/resources/app/standard-mode.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/supertrade-mode.png b/app-ui/src/main/resources/app/supertrade-mode.png deleted file mode 100644 index ebbf1f60..00000000 Binary files a/app-ui/src/main/resources/app/supertrade-mode.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/support_settings.png b/app-ui/src/main/resources/app/support_settings.png new file mode 100644 index 00000000..aa091888 Binary files /dev/null and b/app-ui/src/main/resources/app/support_settings.png differ diff --git a/app-ui/src/main/resources/app/task_bar_settings.png b/app-ui/src/main/resources/app/task_bar_settings.png new file mode 100644 index 00000000..357089b9 Binary files /dev/null and b/app-ui/src/main/resources/app/task_bar_settings.png differ diff --git a/app-ui/src/main/resources/app/timer-pause.png b/app-ui/src/main/resources/app/timer-pause.png deleted file mode 100644 index e04474ef..00000000 Binary files a/app-ui/src/main/resources/app/timer-pause.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/timer-play.png b/app-ui/src/main/resources/app/timer-play.png deleted file mode 100644 index b3461f7f..00000000 Binary files a/app-ui/src/main/resources/app/timer-play.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/timer-reset.png b/app-ui/src/main/resources/app/timer-reset.png deleted file mode 100644 index eea401c0..00000000 Binary files a/app-ui/src/main/resources/app/timer-reset.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/timer-stop.png b/app-ui/src/main/resources/app/timer-stop.png deleted file mode 100644 index 65d39f02..00000000 Binary files a/app-ui/src/main/resources/app/timer-stop.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/timer.png b/app-ui/src/main/resources/app/timer.png deleted file mode 100644 index bceeb2cd..00000000 Binary files a/app-ui/src/main/resources/app/timer.png and /dev/null differ diff --git a/app-ui/src/main/resources/app/tutorial.png b/app-ui/src/main/resources/app/tutorial.png index f059d465..04d857af 100644 Binary files a/app-ui/src/main/resources/app/tutorial.png and b/app-ui/src/main/resources/app/tutorial.png differ diff --git a/app-ui/src/main/resources/notes/patch/patch-notes.json b/app-ui/src/main/resources/notes/patch/patch-notes.json index e2572952..dc762584 100644 --- a/app-ui/src/main/resources/notes/patch/patch-notes.json +++ b/app-ui/src/main/resources/notes/patch/patch-notes.json @@ -1,9 +1,9 @@ { - "version":"1.0.1.6.1", + "version":"1.0.1.7.0", "notes":[ { - "title" : "Hotfix", - "text" : "Overseer:\n- Fixed a bug with tracker not working properly with multiple simultanious key presses.\n- Fixed a bug with components not being removed properly.\n- Improved the icon selection dialog performance.\n- Now you can bind left/midle/right mouse buttons as a hotkey.\n\nThanks for your fast feedback and support. New features are coming soon!", + "title" : "Update", + "text" : "More than 5000 unique users this week! Here is an update for you!\n-Completely reworked Settings GUI.\n-All the issues with non-English keyboard layouts should be gone. Also now you can bind absolutely any mouse / keyboard button you have.\n-Fixed an issue when you couldn't close Notification panel.\n-Now components are cleaned up properly on a profile switch.\nCheck out the Overseer channel on Discord - post your setups, share profiles and converse!\n\nStay with us as there are more mind-blowing features to come. And don't forget to support the app, judging from all the activity looks like it's probably worth some!", "image" : "", "layout" : "VERTICAL" } diff --git a/pom.xml b/pom.xml index b0d4db48..2c20f0eb 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ 1.0.0.5 - 3.1 + 2.0.2 4.4.0 2.5 4.12 @@ -42,16 +42,16 @@ - - lc.kra.system - system-hook - ${systemhook.version} - net.jodah expiringmap ${expiringmap.version} + + com.1stleg + jnativehook + ${jnativehook.version} + net.java.dev.jna jna @@ -144,16 +144,6 @@ - - - system-hook-mvn-repo - https://raw.github.com/kristian/system-hook/mvn-repo/ - - true - always - - -