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 3927ed0a..639a22a3 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 @@ -34,6 +34,7 @@ public MessageFileHandler(String logFilePath) { this.interceptors.add(new PlainMessageInterceptor()); this.interceptors.add(new PlayerJoinInterceptor()); this.interceptors.add(new PlayerLeftInterceptor()); + this.interceptors.add(new PlayerInaccessibleInterceptor()); this.subscribe(); } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/MessageInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/MessageInterceptor.java index a51db34b..534d22b1 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/MessageInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/MessageInterceptor.java @@ -1,15 +1,15 @@ package com.mercury.platform.core.utils.interceptor; -import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; +import com.mercury.platform.core.utils.interceptor.filter.MessageMatcher; /** * Created by Константин on 11.01.2017. */ public abstract class MessageInterceptor { - protected MessageFilter filter; + protected MessageMatcher filter; public MessageInterceptor() { - filter = getFilter(); + filter = match(); } public boolean match(String message) { @@ -22,5 +22,5 @@ public boolean match(String message) { protected abstract void process(String message); - protected abstract MessageFilter getFilter(); + protected abstract MessageMatcher match(); } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlainMessageInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlainMessageInterceptor.java index 6531c748..db7a93f2 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlainMessageInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlainMessageInterceptor.java @@ -1,15 +1,13 @@ package com.mercury.platform.core.utils.interceptor; -import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; +import com.mercury.platform.core.utils.interceptor.filter.MessageMatcher; +import com.mercury.platform.core.utils.interceptor.plain.*; import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; -import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; public class PlainMessageInterceptor extends MessageInterceptor { private List clients = new ArrayList<>(); @@ -31,172 +29,18 @@ protected void process(String message) { .filter(matcher -> matcher.isSuitableFor(message)) .findAny().orElse(null); if (localizationMatcher != null) { - localizationMatcher.processMessage(message); + PlainMessageDescriptor plainMessage = localizationMatcher.getPlainMessage(message); + if (plainMessage != null) { + MercuryStoreCore.plainMessageSubject.onNext(plainMessage); + } } } @Override - protected MessageFilter getFilter() { + protected MessageMatcher match() { return message -> this.clients.stream() .filter(matcher -> matcher.isSuitableFor(message)) .findAny().orElse(null) != null; } - - private abstract class LocalizationMatcher { - public abstract boolean isSuitableFor(String message); - - public abstract boolean isIncoming(); - - public abstract String trimString(String message); - - public void processMessage(String message) { - Pattern pattern = Pattern.compile("^(\\<.+?\\>)?\\s?(.+?):(.+)$"); - Matcher matcher = pattern.matcher(this.trimString(message)); - if (matcher.find()) { - PlainMessageDescriptor descriptor = new PlainMessageDescriptor(); - descriptor.setNickName(matcher.group(2)); - descriptor.setMessage(matcher.group(3)); - descriptor.setIncoming(this.isIncoming()); - MercuryStoreCore.plainMessageSubject.onNext(descriptor); - } - } - } - - private class EngIncLocalizationMatcher extends LocalizationMatcher { - @Override - public boolean isSuitableFor(String message) { - return message.contains("@From"); - } - - @Override - public boolean isIncoming() { - return true; - } - - @Override - public String trimString(String message) { - return StringUtils.substringAfter(message, "@From "); - } - } - - private class EngOutLocalizationMatcher extends LocalizationMatcher { - @Override - public boolean isSuitableFor(String message) { - return message.contains("@To"); - } - - @Override - public boolean isIncoming() { - return false; - } - - @Override - public String trimString(String message) { - return StringUtils.substringAfter(message, "@To "); - } - } - - private class RuIncLocalizationMatcher extends LocalizationMatcher { - @Override - public boolean isSuitableFor(String message) { - return message.contains("@От кого"); - } - - @Override - public boolean isIncoming() { - return true; - } - - @Override - public String trimString(String message) { - return StringUtils.substringAfter(message, "@От кого "); - } - } - - private class RuOutLocalizationMatcher extends LocalizationMatcher { - @Override - public boolean isSuitableFor(String message) { - return message.contains("@Кому"); - } - - @Override - public boolean isIncoming() { - return false; - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@Кому "); - } - - } - - private class ArabicInLocalizationMatcher extends LocalizationMatcher { - @Override - public boolean isSuitableFor(String message) { - return message.contains("@จาก"); - } - - @Override - public boolean isIncoming() { - return true; - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@จาก"); - } - } - - private class ArabicOutLocalizationMatcher extends LocalizationMatcher { - @Override - public boolean isSuitableFor(String message) { - return message.contains("@ถึง"); - } - - @Override - public boolean isIncoming() { - return false; - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@ถึง"); - } - } - - private class BZIncLocalizationMatcher extends LocalizationMatcher { - @Override - public boolean isSuitableFor(String message) { - return message.contains("@De"); - } - - @Override - public boolean isIncoming() { - return true; - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@De"); - } - } - - private class BZOutLocalizationMatcher extends LocalizationMatcher { - @Override - public boolean isSuitableFor(String message) { - return message.contains("@Para"); - } - - @Override - public boolean isIncoming() { - return false; - } - - @Override - public String trimString(String src) { - return StringUtils.substringAfter(src, "@Para"); - } - } } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlayerInaccessibleInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlayerInaccessibleInterceptor.java new file mode 100644 index 00000000..a0c5497b --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlayerInaccessibleInterceptor.java @@ -0,0 +1,28 @@ +package com.mercury.platform.core.utils.interceptor; + +import com.mercury.platform.core.utils.interceptor.filter.MessageMatcher; +import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import org.apache.commons.lang3.StringUtils; + + +public class PlayerInaccessibleInterceptor extends MessageInterceptor { + private PlainMessageDescriptor lastPlainMessage; + + public PlayerInaccessibleInterceptor() { + MercuryStoreCore.plainMessageSubject.subscribe(message -> { + this.lastPlainMessage = message; + }); + } + + @Override + protected void process(String message) { + this.lastPlainMessage.setMessage(StringUtils.substringAfter(message, " : ")); + MercuryStoreCore.plainMessageSubject.onNext(this.lastPlainMessage); + } + + @Override + protected MessageMatcher match() { + return message -> message.contains("That character is not online."); + } +} diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlayerJoinInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlayerJoinInterceptor.java index 9776f9c9..66be41ab 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlayerJoinInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlayerJoinInterceptor.java @@ -1,6 +1,6 @@ package com.mercury.platform.core.utils.interceptor; -import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; +import com.mercury.platform.core.utils.interceptor.filter.MessageMatcher; import com.mercury.platform.shared.store.MercuryStoreCore; import org.apache.commons.lang3.StringUtils; @@ -11,7 +11,7 @@ protected void process(String message) { } @Override - protected MessageFilter getFilter() { + protected MessageMatcher match() { return message -> message.contains("has joined the area."); } } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlayerLeftInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlayerLeftInterceptor.java index 8c838eb5..ce27e706 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlayerLeftInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/PlayerLeftInterceptor.java @@ -1,6 +1,6 @@ package com.mercury.platform.core.utils.interceptor; -import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; +import com.mercury.platform.core.utils.interceptor.filter.MessageMatcher; import com.mercury.platform.shared.store.MercuryStoreCore; import org.apache.commons.lang3.StringUtils; @@ -12,7 +12,7 @@ protected void process(String message) { } @Override - protected MessageFilter getFilter() { + protected MessageMatcher match() { return message -> message.contains("has left the area."); } } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java index 30f76030..6022d474 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeIncMessagesInterceptor.java @@ -1,27 +1,21 @@ package com.mercury.platform.core.utils.interceptor; -import com.mercury.platform.core.misc.SoundType; -import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; +import com.mercury.platform.core.utils.interceptor.filter.MessageMatcher; import com.mercury.platform.shared.MessageParser; import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; -import net.jodah.expiringmap.ExpiringMap; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.TimeUnit; public class TradeIncMessagesInterceptor extends MessageInterceptor { private MessageParser messageParser = new MessageParser(); private PlainConfigurationService config; private List clients = new ArrayList<>(); - private Map expiresMessages; public TradeIncMessagesInterceptor() { this.config = Configuration.get().notificationConfiguration(); @@ -29,12 +23,6 @@ public TradeIncMessagesInterceptor() { this.clients.add(new RuIncLocalizationMatcher()); this.clients.add(new ArabicInLocalizationMatcher()); this.clients.add(new BZIncLocalizationMatcher()); - this.expiresMessages = ExpiringMap.builder() - .expiration(1, TimeUnit.HOURS) - .build(); - MercuryStoreCore.expiredNotificationSubject.subscribe(notificationDescriptor -> { - this.expiresMessages.put(UUID.randomUUID().toString(), StringUtils.substringAfter(notificationDescriptor.getSourceString(), ":")); - }); } @Override @@ -50,7 +38,7 @@ protected void process(String message) { } @Override - protected MessageFilter getFilter() { + protected MessageMatcher match() { return message -> this.clients.stream() .filter(matcher -> matcher.isSuitableFor(message)) @@ -73,10 +61,7 @@ public NotificationDescriptor getDescriptor(String message) { public void processMessage(String message) { NotificationDescriptor notificationDescriptor = this.getDescriptor(message); if (notificationDescriptor != null) { - if (!expiresMessages.containsValue(StringUtils.substringAfter(notificationDescriptor.getSourceString(), ":"))) { - MercuryStoreCore.soundSubject.onNext(SoundType.MESSAGE); - MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); - } + MercuryStoreCore.newNotificationSubject.onNext(notificationDescriptor); } } } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeOutMessagesInterceptor.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeOutMessagesInterceptor.java index 19bbaa90..e6e14d0f 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeOutMessagesInterceptor.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/TradeOutMessagesInterceptor.java @@ -1,6 +1,6 @@ package com.mercury.platform.core.utils.interceptor; -import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; +import com.mercury.platform.core.utils.interceptor.filter.MessageMatcher; import com.mercury.platform.shared.MessageParser; import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; @@ -40,7 +40,7 @@ protected void process(String message) { } @Override - protected MessageFilter getFilter() { + protected MessageMatcher match() { return message -> this.clients.stream() .filter(matcher -> matcher.isSuitableFor(message)) diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/filter/MessageFilter.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/filter/MessageMatcher.java similarity index 75% rename from app-core/src/main/java/com/mercury/platform/core/utils/interceptor/filter/MessageFilter.java rename to app-core/src/main/java/com/mercury/platform/core/utils/interceptor/filter/MessageMatcher.java index 36b52841..51e2720a 100644 --- a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/filter/MessageFilter.java +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/filter/MessageMatcher.java @@ -1,6 +1,6 @@ package com.mercury.platform.core.utils.interceptor.filter; -public interface MessageFilter { +public interface MessageMatcher { boolean isMatching(String message); } diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/ArabicInLocalizationMatcher.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/ArabicInLocalizationMatcher.java new file mode 100644 index 00000000..e672ae2d --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/ArabicInLocalizationMatcher.java @@ -0,0 +1,20 @@ +package com.mercury.platform.core.utils.interceptor.plain; + +import org.apache.commons.lang3.StringUtils; + +public class ArabicInLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@จาก"); + } + + @Override + public boolean isIncoming() { + return true; + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@จาก"); + } +} diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/ArabicOutLocalizationMatcher.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/ArabicOutLocalizationMatcher.java new file mode 100644 index 00000000..5d3c1483 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/ArabicOutLocalizationMatcher.java @@ -0,0 +1,20 @@ +package com.mercury.platform.core.utils.interceptor.plain; + +import org.apache.commons.lang3.StringUtils; + +public class ArabicOutLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@ถึง"); + } + + @Override + public boolean isIncoming() { + return false; + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@ถึง"); + } +} diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/BZIncLocalizationMatcher.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/BZIncLocalizationMatcher.java new file mode 100644 index 00000000..3234f22b --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/BZIncLocalizationMatcher.java @@ -0,0 +1,20 @@ +package com.mercury.platform.core.utils.interceptor.plain; + +import org.apache.commons.lang3.StringUtils; + +public class BZIncLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@De"); + } + + @Override + public boolean isIncoming() { + return true; + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@De"); + } +} diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/BZOutLocalizationMatcher.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/BZOutLocalizationMatcher.java new file mode 100644 index 00000000..6a47f790 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/BZOutLocalizationMatcher.java @@ -0,0 +1,20 @@ +package com.mercury.platform.core.utils.interceptor.plain; + +import org.apache.commons.lang3.StringUtils; + +public class BZOutLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@Para"); + } + + @Override + public boolean isIncoming() { + return false; + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@Para"); + } +} diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/EngIncLocalizationMatcher.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/EngIncLocalizationMatcher.java new file mode 100644 index 00000000..6fc48355 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/EngIncLocalizationMatcher.java @@ -0,0 +1,20 @@ +package com.mercury.platform.core.utils.interceptor.plain; + +import org.apache.commons.lang3.StringUtils; + +public class EngIncLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@From"); + } + + @Override + public boolean isIncoming() { + return true; + } + + @Override + public String trimString(String message) { + return StringUtils.substringAfter(message, "@From "); + } +} \ No newline at end of file diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/EngOutLocalizationMatcher.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/EngOutLocalizationMatcher.java new file mode 100644 index 00000000..d2065c31 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/EngOutLocalizationMatcher.java @@ -0,0 +1,20 @@ +package com.mercury.platform.core.utils.interceptor.plain; + +import org.apache.commons.lang3.StringUtils; + +public class EngOutLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@To"); + } + + @Override + public boolean isIncoming() { + return false; + } + + @Override + public String trimString(String message) { + return StringUtils.substringAfter(message, "@To "); + } +} \ No newline at end of file diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/LocalizationMatcher.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/LocalizationMatcher.java new file mode 100644 index 00000000..e1f38150 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/LocalizationMatcher.java @@ -0,0 +1,28 @@ +package com.mercury.platform.core.utils.interceptor.plain; + + +import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public abstract class LocalizationMatcher { + public abstract boolean isSuitableFor(String message); + + public abstract boolean isIncoming(); + + public abstract String trimString(String message); + + public PlainMessageDescriptor getPlainMessage(String message) { + Pattern pattern = Pattern.compile("^(\\<.+?\\>)?\\s?(.+?):(.+)$"); + Matcher matcher = pattern.matcher(this.trimString(message)); + if (matcher.find()) { + PlainMessageDescriptor descriptor = new PlainMessageDescriptor(); + descriptor.setNickName(matcher.group(2)); + descriptor.setMessage(matcher.group(3)); + descriptor.setIncoming(this.isIncoming()); + return descriptor; + } + return null; + } +} \ No newline at end of file diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/RuIncLocalizationMatcher.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/RuIncLocalizationMatcher.java new file mode 100644 index 00000000..05a75e1a --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/RuIncLocalizationMatcher.java @@ -0,0 +1,20 @@ +package com.mercury.platform.core.utils.interceptor.plain; + +import org.apache.commons.lang3.StringUtils; + +public class RuIncLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@От кого"); + } + + @Override + public boolean isIncoming() { + return true; + } + + @Override + public String trimString(String message) { + return StringUtils.substringAfter(message, "@От кого "); + } +} diff --git a/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/RuOutLocalizationMatcher.java b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/RuOutLocalizationMatcher.java new file mode 100644 index 00000000..08604f49 --- /dev/null +++ b/app-core/src/main/java/com/mercury/platform/core/utils/interceptor/plain/RuOutLocalizationMatcher.java @@ -0,0 +1,21 @@ +package com.mercury.platform.core.utils.interceptor.plain; + +import org.apache.commons.lang3.StringUtils; + +public class RuOutLocalizationMatcher extends LocalizationMatcher { + @Override + public boolean isSuitableFor(String message) { + return message.contains("@Кому"); + } + + @Override + public boolean isIncoming() { + return false; + } + + @Override + public String trimString(String src) { + return StringUtils.substringAfter(src, "@Кому "); + } + +} \ No newline at end of file diff --git a/app-core/src/main/java/com/mercury/platform/shared/MessageParser.java b/app-core/src/main/java/com/mercury/platform/shared/MessageParser.java index 37eb4e69..bc3bbf4c 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/MessageParser.java +++ b/app-core/src/main/java/com/mercury/platform/shared/MessageParser.java @@ -9,10 +9,10 @@ import java.util.regex.Pattern; public class MessageParser { - private final static String poeTradeStashTabPattern = "^(.*\\s)?(.+):.+ to buy your\\s+?(.+?)(\\s+?listed for\\s+?([\\d\\.]+?)\\s+?(.+))?\\s+?in\\s+?(.+?)\\s+?\\(stash tab \"(.*)\"; position: left (\\d+), top (\\d+)\\)\\s*?(.*)$"; - private final static String poeTradePattern = "^(.*\\s)?(.+):.+ to buy your\\s+?(.+?)(\\s+?listed for\\s+?([\\d\\.]+?)\\s+?(.+))?\\s+?in\\s+?(.*?)$"; - private final static String poeAppPattern = "^(.*\\s)?(.+):\\s*?wtb\\s+?(.+?)(\\s+?listed for\\s+?([\\d\\.]+?)\\s+?(.+))?\\s+?in\\s+?(.+?)\\s+?\\(stash\\s+?\"(.*?)\";\\s+?left\\s+?(\\d+?),\\s+?top\\s+(\\d+?)\\)\\s*?(.*)$"; - private final static String poeCurrencyPattern = "^(.*\\s)?(.+):.+ to buy your (\\d+(\\.\\d+)?)? (.+) for my (\\d+(\\.\\d+)?)? (.+) in (.*?)\\.\\s*(.*)$"; + private final static String poeTradeStashTabPattern = "^(.*\\s)?(.+): (.+ to buy your\\s+?(.+?)(\\s+?listed for\\s+?([\\d\\.]+?)\\s+?(.+))?\\s+?in\\s+?(.+?)\\s+?\\(stash tab \"(.*)\"; position: left (\\d+), top (\\d+)\\)\\s*?(.*))$"; + private final static String poeTradePattern = "^(.*\\s)?(.+): (.+ to buy your\\s+?(.+?)(\\s+?listed for\\s+?([\\d\\.]+?)\\s+?(.+))?\\s+?in\\s+?(.*?))$"; + private final static String poeAppPattern = "^(.*\\s)?(.+): (\\s*?wtb\\s+?(.+?)(\\s+?listed for\\s+?([\\d\\.]+?)\\s+?(.+))?\\s+?in\\s+?(.+?)\\s+?\\(stash\\s+?\"(.*?)\";\\s+?left\\s+?(\\d+?),\\s+?top\\s+(\\d+?)\\)\\s*?(.*))$"; + private final static String poeCurrencyPattern = "^(.*\\s)?(.+): (.+ to buy your (\\d+(\\.\\d+)?)? (.+) for my (\\d+(\\.\\d+)?)? (.+) in (.*?)\\.\\s*(.*))$"; private Pattern poeAppItemPattern; private Pattern poeTradeStashItemPattern; private Pattern poeTradeItemPattern; @@ -29,75 +29,75 @@ public NotificationDescriptor parse(String fullMessage) { Matcher poeAppItemMatcher = poeAppItemPattern.matcher(fullMessage); if (poeAppItemMatcher.find()) { ItemTradeNotificationDescriptor tradeNotification = new ItemTradeNotificationDescriptor(); - tradeNotification.setSourceString(fullMessage); tradeNotification.setWhisperNickname(poeAppItemMatcher.group(2)); - tradeNotification.setItemName(poeAppItemMatcher.group(3)); + tradeNotification.setSourceString(poeAppItemMatcher.group(3)); + tradeNotification.setItemName(poeAppItemMatcher.group(4)); if (poeAppItemMatcher.group(5) != null) { - tradeNotification.setCurCount(Double.parseDouble(poeAppItemMatcher.group(5))); - tradeNotification.setCurrency(poeAppItemMatcher.group(6)); + tradeNotification.setCurCount(Double.parseDouble(poeAppItemMatcher.group(6))); + tradeNotification.setCurrency(poeAppItemMatcher.group(7)); } else { tradeNotification.setCurCount(0d); tradeNotification.setCurrency("???"); } - tradeNotification.setLeague(poeAppItemMatcher.group(7)); - if (poeAppItemMatcher.group(8) != null) { - tradeNotification.setTabName(poeAppItemMatcher.group(8)); - tradeNotification.setLeft(Integer.parseInt(poeAppItemMatcher.group(9))); - tradeNotification.setTop(Integer.parseInt(poeAppItemMatcher.group(10))); + tradeNotification.setLeague(poeAppItemMatcher.group(8)); + if (poeAppItemMatcher.group(9) != null) { + tradeNotification.setTabName(poeAppItemMatcher.group(9)); + tradeNotification.setLeft(Integer.parseInt(poeAppItemMatcher.group(10))); + tradeNotification.setTop(Integer.parseInt(poeAppItemMatcher.group(11))); } - tradeNotification.setOffer(poeAppItemMatcher.group(11)); + tradeNotification.setOffer(poeAppItemMatcher.group(12)); tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE); return tradeNotification; } Matcher poeTradeStashItemMatcher = poeTradeStashItemPattern.matcher(fullMessage); if (poeTradeStashItemMatcher.find()) { ItemTradeNotificationDescriptor tradeNotification = new ItemTradeNotificationDescriptor(); - tradeNotification.setSourceString(fullMessage); tradeNotification.setWhisperNickname(poeTradeStashItemMatcher.group(2)); - tradeNotification.setItemName(poeTradeStashItemMatcher.group(3)); - if (poeTradeStashItemMatcher.group(4) != null) { - tradeNotification.setCurCount(Double.parseDouble(poeTradeStashItemMatcher.group(5))); - tradeNotification.setCurrency(poeTradeStashItemMatcher.group(6)); + tradeNotification.setSourceString(poeTradeStashItemMatcher.group(3)); + tradeNotification.setItemName(poeTradeStashItemMatcher.group(4)); + if (poeTradeStashItemMatcher.group(6) != null) { + tradeNotification.setCurCount(Double.parseDouble(poeTradeStashItemMatcher.group(6))); + tradeNotification.setCurrency(poeTradeStashItemMatcher.group(7)); } else { tradeNotification.setCurCount(0d); tradeNotification.setCurrency("???"); } - tradeNotification.setLeague(poeTradeStashItemMatcher.group(7)); - tradeNotification.setTabName(poeTradeStashItemMatcher.group(8)); - tradeNotification.setLeft(Integer.parseInt(poeTradeStashItemMatcher.group(9))); - tradeNotification.setTop(Integer.parseInt(poeTradeStashItemMatcher.group(10))); - tradeNotification.setOffer(poeTradeStashItemMatcher.group(11)); + tradeNotification.setLeague(poeTradeStashItemMatcher.group(8)); + tradeNotification.setTabName(poeTradeStashItemMatcher.group(9)); + tradeNotification.setLeft(Integer.parseInt(poeTradeStashItemMatcher.group(10))); + tradeNotification.setTop(Integer.parseInt(poeTradeStashItemMatcher.group(11))); + tradeNotification.setOffer(poeTradeStashItemMatcher.group(12)); tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE); return tradeNotification; } Matcher poeTradeCurrencyMatcher = poeTradeCurrencyPattern.matcher(fullMessage); if (poeTradeCurrencyMatcher.find()) { CurrencyTradeNotificationDescriptor tradeNotification = new CurrencyTradeNotificationDescriptor(); - tradeNotification.setSourceString(fullMessage); tradeNotification.setWhisperNickname(poeTradeCurrencyMatcher.group(2)); - tradeNotification.setCurrForSaleCount(Double.parseDouble(poeTradeCurrencyMatcher.group(3))); - tradeNotification.setCurrForSaleTitle(poeTradeCurrencyMatcher.group(5)); - tradeNotification.setCurCount(Double.parseDouble(poeTradeCurrencyMatcher.group(6))); - tradeNotification.setCurrency(poeTradeCurrencyMatcher.group(8)); - tradeNotification.setLeague(poeTradeCurrencyMatcher.group(9)); - tradeNotification.setOffer(poeTradeCurrencyMatcher.group(10)); + tradeNotification.setSourceString(poeTradeCurrencyMatcher.group(3)); + tradeNotification.setCurrForSaleCount(Double.parseDouble(poeTradeCurrencyMatcher.group(4))); + tradeNotification.setCurrForSaleTitle(poeTradeCurrencyMatcher.group(6)); + tradeNotification.setCurCount(Double.parseDouble(poeTradeCurrencyMatcher.group(7))); + tradeNotification.setCurrency(poeTradeCurrencyMatcher.group(9)); + tradeNotification.setLeague(poeTradeCurrencyMatcher.group(10)); + tradeNotification.setOffer(poeTradeCurrencyMatcher.group(11)); tradeNotification.setType(NotificationType.INC_CURRENCY_MESSAGE); return tradeNotification; } Matcher poeTradeItemMatcher = poeTradeItemPattern.matcher(fullMessage); if (poeTradeItemMatcher.find()) { ItemTradeNotificationDescriptor tradeNotification = new ItemTradeNotificationDescriptor(); - tradeNotification.setSourceString(fullMessage); tradeNotification.setWhisperNickname(poeTradeItemMatcher.group(2)); - tradeNotification.setItemName(poeTradeItemMatcher.group(3)); - if (poeTradeItemMatcher.group(4) != null) { - tradeNotification.setCurCount(Double.parseDouble(poeTradeItemMatcher.group(5))); - tradeNotification.setCurrency(poeTradeItemMatcher.group(6)); + tradeNotification.setSourceString(poeTradeItemMatcher.group(3)); + tradeNotification.setItemName(poeTradeItemMatcher.group(4)); + if (poeTradeItemMatcher.group(5) != null) { + tradeNotification.setCurCount(Double.parseDouble(poeTradeItemMatcher.group(6))); + tradeNotification.setCurrency(poeTradeItemMatcher.group(7)); } else { tradeNotification.setCurCount(0d); tradeNotification.setCurrency("???"); } - tradeNotification.setLeague(poeTradeItemMatcher.group(7)); + tradeNotification.setLeague(poeTradeItemMatcher.group(8)); tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE); return tradeNotification; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java index ef8659ee..33ff0e4f 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeyConfigurationService.java @@ -48,34 +48,23 @@ public HotKeysSettingsDescriptor getDefault() { @Override public void toDefault() { - this.selectedProfile.setHotKeysSettingsDescriptor(this.getDefault()); + this.selectedProfile.setHotkeysSettingsDescriptor(this.getDefault()); } @Override public void validate() { - if (this.selectedProfile.getHotKeysSettingsDescriptor() == null) { - this.selectedProfile.setHotKeysSettingsDescriptor(this.getDefault()); - } - List stubNList = new ArrayList<>(this.selectedProfile.getHotKeysSettingsDescriptor().getIncNHotKeysList()); - stubNList.forEach(it -> { - if (it.getType().equals(HotKeyType.N_SWITCH_CHAT)) { - this.selectedProfile.getHotKeysSettingsDescriptor().getIncNHotKeysList().remove(it); - } - }); - List stubOList = new ArrayList<>(this.selectedProfile.getHotKeysSettingsDescriptor().getOutNHotKeysList()); - HotKeyPair hotKeyPair = stubOList.stream().filter(it -> it.getType().equals(HotKeyType.N_REPEAT_MESSAGE)).findAny().orElse(null); - if (hotKeyPair == null) { - this.selectedProfile.getHotKeysSettingsDescriptor().getOutNHotKeysList().add(new HotKeyPair(HotKeyType.N_REPEAT_MESSAGE, new HotKeyDescriptor())); + if (this.selectedProfile.getHotkeysSettingsDescriptor() == null) { + this.selectedProfile.setHotkeysSettingsDescriptor(this.getDefault()); } } @Override public HotKeysSettingsDescriptor get() { - return this.selectedProfile.getHotKeysSettingsDescriptor(); + return this.selectedProfile.getHotkeysSettingsDescriptor(); } @Override public void set(HotKeysSettingsDescriptor descriptor) { - this.selectedProfile.setHotKeysSettingsDescriptor(descriptor); + this.selectedProfile.setHotkeysSettingsDescriptor(descriptor); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ProfileDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ProfileDescriptor.java index dbd7b4de..293a8586 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ProfileDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ProfileDescriptor.java @@ -17,7 +17,7 @@ public class ProfileDescriptor { private TaskBarDescriptor taskBarDescriptor; private ScannerDescriptor scannerDescriptor; private Map scaleDataMap; - private HotKeysSettingsDescriptor hotKeysSettingsDescriptor; + private HotKeysSettingsDescriptor hotkeysSettingsDescriptor; private List stashTabDescriptors; private List adrProfileDescriptorList; private List iconBundleList; diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationDescriptor.java index 0a3f70fa..b18e30b4 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/message/NotificationDescriptor.java @@ -1,15 +1,15 @@ package com.mercury.platform.shared.entity.message; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.ArrayList; -import java.util.Date; import java.util.List; @Data +@EqualsAndHashCode(exclude = {"relatedMessages"}) public class NotificationDescriptor { private String sourceString; - private Date messageDate; private String whisperNickname; private NotificationType type; private List relatedMessages = new ArrayList<>(); 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 85641dcd..8d616b92 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 @@ -31,7 +31,7 @@ public AdrComponentPanel(T descriptor, ComponentsFactory componentsFactory) { @Override public void subscribe() { this.adrReloadSubscription = MercuryStoreUI.adrReloadSubject.subscribe(it -> { - if (this.descriptor.equals(it)) { + if (this.descriptor.equals(it) && this.inSettings) { this.onUpdate(); this.onSelect(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationCellPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationCellPanel.java index 0f0a8f5c..4653c5ee 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationCellPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/AdrDurationCellPanel.java @@ -70,6 +70,8 @@ protected void onHotKeyPressed() { @Override protected void onUpdate() { + this.tracker.abort(); + this.tracker.setVisible(false); this.remove(this.tracker); this.onViewInit(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeIncNotificationPanel.java index bb96320f..030efcc5 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeIncNotificationPanel.java @@ -2,6 +2,7 @@ import com.mercury.platform.shared.config.descriptor.HotKeyType; import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; +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; @@ -13,16 +14,16 @@ public class CurrencyTradeIncNotificationPanel extends TradeIncNotificationPanel { + private JPanel labelsPanel; @Override protected JPanel getMessagePanel() { - JPanel labelsPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); + this.labelsPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); - JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.FRAME, TooltipConstants.OPEN_CHAT); - openChatButton.addActionListener(e -> controller.performOpenChat()); + JLabel historyLabel = this.getHistoryButton(); JButton stillInterestedButton = this.getStillInterestedButton(); JPanel buttons = this.componentsFactory.getJPanel(new GridLayout(1, 0, 5, 0), AppThemeColor.FRAME); buttons.add(stillInterestedButton); - buttons.add(openChatButton); + buttons.add(historyLabel); JPanel miscPanel = this.componentsFactory.getJPanel(new GridLayout(1, 0, 4, 0), AppThemeColor.FRAME); miscPanel.add(this.getFromPanel(), BorderLayout.CENTER); @@ -31,11 +32,10 @@ protected JPanel getMessagePanel() { miscPanel.add(offerLabel); } - this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT, openChatButton); this.interactButtonMap.put(HotKeyType.N_STILL_INTERESTING, stillInterestedButton); - labelsPanel.add(miscPanel, BorderLayout.CENTER); - labelsPanel.add(buttons, BorderLayout.LINE_END); + this.labelsPanel.add(miscPanel, BorderLayout.CENTER); + this.labelsPanel.add(buttons, BorderLayout.LINE_END); return labelsPanel; } @@ -78,4 +78,15 @@ protected JButton getStillInterestedButton() { }); return stillIntButton; } + + public void setDuplicate(boolean duplicate) { + if (duplicate) { + JButton ignoreButton = componentsFactory.getIconButton("app/adr/visible_node_off.png", 15, AppThemeColor.FRAME, "Ignore item 1 hour"); + ignoreButton.addActionListener(e -> { + MercuryStoreCore.expiredNotificationSubject.onNext(this.data); + this.controller.performHide(); + }); + this.labelsPanel.add(ignoreButton, BorderLayout.LINE_START); + } + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeOutNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeOutNotificationPanel.java index 735fe056..f7973d4f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeOutNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeOutNotificationPanel.java @@ -5,7 +5,6 @@ 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 com.mercury.platform.ui.misc.TooltipConstants; import javax.swing.*; import java.awt.*; @@ -17,12 +16,11 @@ public class CurrencyTradeOutNotificationPanel extends TradeOutNotificationPanel protected JPanel getMessagePanel() { JPanel labelsPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); - JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.FRAME, TooltipConstants.OPEN_CHAT); - openChatButton.addActionListener(e -> controller.performOpenChat()); + JLabel historyLabel = this.getHistoryButton(); JButton repeatButton = this.getRepeatButton(); JPanel buttons = this.componentsFactory.getJPanel(new GridLayout(1, 0, 5, 0), AppThemeColor.FRAME); buttons.add(repeatButton); - buttons.add(openChatButton); + buttons.add(historyLabel); JPanel miscPanel = this.componentsFactory.getJPanel(new GridLayout(1, 0, 4, 0), AppThemeColor.FRAME); miscPanel.add(this.getFromPanel(), BorderLayout.CENTER); @@ -30,8 +28,6 @@ protected JPanel getMessagePanel() { if (offerLabel != null) { miscPanel.add(offerLabel); } - - this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT, openChatButton); this.interactButtonMap.put(HotKeyType.N_REPEAT_MESSAGE, repeatButton); labelsPanel.add(miscPanel, BorderLayout.CENTER); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryNotificationPanel.java index 6c8c4f9a..fcfc5a7c 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/HistoryNotificationPanel.java @@ -6,7 +6,6 @@ import com.mercury.platform.ui.components.panel.notification.controller.HistoryController; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.TooltipConstants; -import org.apache.commons.lang3.StringUtils; import javax.swing.*; import java.awt.*; @@ -17,7 +16,7 @@ public class HistoryNotificationPanel extends NotificationPanel { this.controller.reload(); }); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeIncNotificationPanel.java index 59c21036..b27b91d7 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeIncNotificationPanel.java @@ -19,7 +19,7 @@ protected JPanel getMessagePanel() { JButton itemButton = componentsFactory.getButton( FontStyle.BOLD, - AppThemeColor.BUTTON, + AppThemeColor.TEXT_IMPORTANT, BorderFactory.createEmptyBorder(4, 4, 4, 4), this.data.getItemName(), 16f); @@ -32,12 +32,11 @@ protected JPanel getMessagePanel() { this.controller.showITH(); }); - JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.FRAME, TooltipConstants.OPEN_CHAT); - openChatButton.addActionListener(e -> controller.performOpenChat()); JButton stillInterestedButton = this.getStillInterestedButton(); + JLabel historyLabel = this.getHistoryButton(); JPanel buttons = this.componentsFactory.getJPanel(new GridLayout(1, 0, 5, 0), AppThemeColor.FRAME); buttons.add(stillInterestedButton); - buttons.add(openChatButton); + buttons.add(historyLabel); JPanel miscPanel = this.componentsFactory.getJPanel(new GridLayout(1, 0, 4, 0), AppThemeColor.FRAME); miscPanel.add(itemButton); @@ -46,7 +45,6 @@ protected JPanel getMessagePanel() { miscPanel.add(offerLabel); } - this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT, openChatButton); this.interactButtonMap.put(HotKeyType.N_STILL_INTERESTING, stillInterestedButton); this.labelsPanel.add(miscPanel, BorderLayout.CENTER); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeOutNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeOutNotificationPanel.java index edb56c6f..7dbaa31a 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeOutNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeOutNotificationPanel.java @@ -4,7 +4,6 @@ import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.TooltipConstants; import javax.swing.*; import java.awt.*; @@ -18,14 +17,13 @@ protected JPanel getMessagePanel() { JLabel itemLabel = componentsFactory.getTextLabel( this.data.getItemName(), FontStyle.BOLD, - AppThemeColor.TEXT_IMPORTANT, 16f); + AppThemeColor.INC_PANEL_ARROW, 16f); - JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.FRAME, TooltipConstants.OPEN_CHAT); - openChatButton.addActionListener(e -> controller.performOpenChat()); + JLabel historyLabel = this.getHistoryButton(); JButton repeatButton = this.getRepeatButton(); JPanel buttons = this.componentsFactory.getJPanel(new GridLayout(1, 0, 5, 0), AppThemeColor.FRAME); buttons.add(repeatButton); - buttons.add(openChatButton); + buttons.add(historyLabel); JPanel miscPanel = this.componentsFactory.getJPanel(new GridLayout(1, 0, 4, 0), AppThemeColor.FRAME); miscPanel.add(itemLabel); @@ -34,7 +32,6 @@ protected JPanel getMessagePanel() { miscPanel.add(offerLabel); } - this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT, openChatButton); this.interactButtonMap.put(HotKeyType.N_REPEAT_MESSAGE, repeatButton); labelsPanel.add(miscPanel, BorderLayout.CENTER); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java index 49a0008f..44960ef1 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/NotificationPanel.java @@ -63,8 +63,6 @@ public void onViewInit() { public void setComponentsFactory(ComponentsFactory factory) { this.componentsFactory = factory; - this.removeAll(); - this.onViewInit(); } public void onHotKeyPressed(HotKeyDescriptor descriptor) { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java index 1460d866..fcc90769 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ScannerNotificationPanel.java @@ -38,6 +38,7 @@ public void onViewInit() { break; } } + this.contentPanel.setPreferredSize(new Dimension(10, (int) (60 * this.componentsFactory.getScale()))); this.add(this.contentPanel, BorderLayout.CENTER); this.updateHotKeyPool(); } @@ -53,15 +54,15 @@ private JPanel getHeader() { nickNamePanel.add(nicknameLabel, BorderLayout.CENTER); root.add(nickNamePanel, BorderLayout.CENTER); - JPanel interactionPanel = new JPanel(new GridLayout(1, 0, 6, 0)); + JPanel interactionPanel = new JPanel(new GridLayout(1, 0, 3, 0)); interactionPanel.setBackground(AppThemeColor.MSG_HEADER); - JButton inviteMeButton = componentsFactory.getIconButton("app/chat_scanner_response.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.QUICK_RESPONSE); + JButton inviteMeButton = componentsFactory.getIconButton("app/chat_scanner_response.png", 16, AppThemeColor.MSG_HEADER, TooltipConstants.QUICK_RESPONSE); inviteMeButton.addActionListener(e -> this.controller.performResponse(this.config.get().getResponseMessage())); - JButton visiteHideout = componentsFactory.getIconButton("app/visiteHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.VISIT_HO); + JButton visiteHideout = componentsFactory.getIconButton("app/visiteHideout.png", 16, AppThemeColor.MSG_HEADER, TooltipConstants.VISIT_HO); visiteHideout.addActionListener(e -> this.controller.visitHideout()); JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); tradeButton.addActionListener(e -> this.controller.performOfferTrade()); - JButton leaveButton = componentsFactory.getIconButton("app/leave.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.LEAVE); + JButton leaveButton = componentsFactory.getIconButton("app/leave.png", 16, AppThemeColor.MSG_HEADER, TooltipConstants.LEAVE); leaveButton.addActionListener(e -> { this.controller.performLeave(this.notificationConfig.get().getPlayerNickname()); if (this.notificationConfig.get().isDismissAfterLeave()) { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeIncNotificationPanel.java index 21e824d8..2b9e061e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeIncNotificationPanel.java @@ -52,7 +52,8 @@ protected JPanel getHeader() { tradeButton.addActionListener(e -> { this.controller.performOfferTrade(); }); - JLabel historyLabel = this.getHistoryButton(); + JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); + openChatButton.addActionListener(e -> controller.performOpenChat()); JButton hideButton = componentsFactory.getIconButton("app/close.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); hideButton.addActionListener(action -> { this.controller.performHide(); @@ -60,13 +61,14 @@ protected JPanel getHeader() { interactionPanel.add(inviteButton); interactionPanel.add(tradeButton); interactionPanel.add(kickButton); - interactionPanel.add(historyLabel); + interactionPanel.add(openChatButton); interactionPanel.add(hideButton); this.interactButtonMap.clear(); this.interactButtonMap.put(HotKeyType.N_INVITE_PLAYER, inviteButton); this.interactButtonMap.put(HotKeyType.N_TRADE_PLAYER, tradeButton); this.interactButtonMap.put(HotKeyType.N_KICK_PLAYER, kickButton); + this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT, openChatButton); this.interactButtonMap.put(HotKeyType.N_CLOSE_NOTIFICATION, hideButton); JPanel timePanel = this.getTimePanel(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeNotificationPanel.java index 2845d89f..9b4c0729 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeNotificationPanel.java @@ -100,6 +100,11 @@ public void subscribe() { this.chatSubscription = MercuryStoreCore.plainMessageSubject.subscribe(message -> { if (this.data.getWhisperNickname().equals(message.getNickName())) { this.data.getRelatedMessages().add(message); + if (message.getMessage().contains("This player has DND mode enabled") + || message.getMessage().contains("That character is not online.") + || message.getMessage().contains("This player is AFK.")) { + this.controller.performHide(); + } } }); } @@ -159,7 +164,7 @@ protected JPanel getCurrencyPanel(Double curCount, String curIconPath) { if (!Objects.equals(curCountStr, "") && curIconPath != null) { JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + curIconPath + ".png", 26); JPanel curPanel = new JPanel(new BorderLayout()); - curPanel.setPreferredSize(new Dimension((int) (this.componentsFactory.getScale() * 66), (int) (this.componentsFactory.getScale() * 26))); + curPanel.setPreferredSize(new Dimension((int) (this.componentsFactory.getScale() * 70), (int) (this.componentsFactory.getScale() * 26))); curPanel.setBackground(AppThemeColor.MSG_HEADER); JLabel countLabel = this.componentsFactory.getTextLabel(curCountStr, FontStyle.BOLD, 17f); countLabel.setHorizontalAlignment(SwingConstants.RIGHT); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeOutNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeOutNotificationPanel.java index 2cac4834..bf7eec83 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeOutNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeOutNotificationPanel.java @@ -9,7 +9,6 @@ import com.mercury.platform.ui.components.panel.notification.controller.OutgoingPanelController; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.TooltipConstants; -import org.apache.commons.lang3.StringUtils; import rx.Subscription; import javax.swing.*; @@ -47,7 +46,8 @@ protected JPanel getHeader() { this.controller.performHide(); } }); - JLabel historyLabel = this.getHistoryButton(); + JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); + openChatButton.addActionListener(e -> controller.performOpenChat()); JButton hideButton = componentsFactory.getIconButton("app/close.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); hideButton.addActionListener(action -> { this.controller.performHide(); @@ -55,12 +55,13 @@ protected JPanel getHeader() { interactionPanel.add(visiteHideout); interactionPanel.add(tradeButton); interactionPanel.add(leaveButton); - interactionPanel.add(historyLabel); + interactionPanel.add(openChatButton); interactionPanel.add(hideButton); this.interactButtonMap.clear(); this.interactButtonMap.put(HotKeyType.N_VISITE_HIDEOUT, visiteHideout); this.interactButtonMap.put(HotKeyType.N_TRADE_PLAYER, tradeButton); this.interactButtonMap.put(HotKeyType.N_LEAVE, leaveButton); + this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT, openChatButton); this.interactButtonMap.put(HotKeyType.N_CLOSE_NOTIFICATION, hideButton); JPanel timePanel = this.getTimePanel(); @@ -94,9 +95,15 @@ public void onViewDestroy() { } protected JButton getRepeatButton() { - JButton repeatButton = componentsFactory.getIconButton("app/reload-history.png", 15, AppThemeColor.FRAME, TooltipConstants.STILL_INTERESTED); + JButton repeatButton = componentsFactory.getIconButton("app/reload-history.png", 15, AppThemeColor.FRAME, TooltipConstants.REPEAT_MESSAGE); repeatButton.addActionListener(action -> { - this.controller.performResponse(StringUtils.substringAfter(this.data.getSourceString(), ":")); + this.controller.performResponse(this.data.getSourceString()); + repeatButton.setEnabled(false); + Timer timer = new Timer(5000, event -> { + repeatButton.setEnabled(true); + }); + timer.setRepeats(false); + timer.start(); }); return repeatButton; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/HistoryPanelController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/HistoryPanelController.java new file mode 100644 index 00000000..12059aa6 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/HistoryPanelController.java @@ -0,0 +1,23 @@ +package com.mercury.platform.ui.components.panel.notification.controller; + + +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; + +public class HistoryPanelController implements HistoryController { + private NotificationDescriptor descriptor; + + public HistoryPanelController(NotificationDescriptor descriptor) { + this.descriptor = descriptor; + } + + @Override + public void reload() { + MercuryStoreCore.newNotificationSubject.onNext(this.descriptor); + } + + @Override + public void performOpenChat() { + MercuryStoreCore.openChatSubject.onNext(this.descriptor.getWhisperNickname()); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/HistoryPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/HistoryPanelProvider.java index 1f72e7ce..cda142cb 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/HistoryPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/HistoryPanelProvider.java @@ -2,10 +2,10 @@ import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationType; -import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.panel.notification.HistoryNotificationPanel; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; import com.mercury.platform.ui.components.panel.notification.controller.HistoryController; +import com.mercury.platform.ui.components.panel.notification.controller.HistoryPanelController; public class HistoryPanelProvider extends NotificationPanelProvider { @@ -17,17 +17,7 @@ public boolean isSuitable(NotificationType type) { @Override protected NotificationPanel getPanel() { HistoryNotificationPanel panel = new HistoryNotificationPanel(); - panel.setController(new HistoryController() { - @Override - public void reload() { - MercuryStoreCore.newNotificationSubject.onNext(data); - } - - @Override - public void performOpenChat() { - MercuryStoreCore.openChatSubject.onNext(data.getWhisperNickname()); - } - }); + panel.setController(new HistoryPanelController(this.data)); return panel; } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GlobalHotkeyGroup.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GlobalHotkeyGroup.java new file mode 100644 index 00000000..0c6cd190 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GlobalHotkeyGroup.java @@ -0,0 +1,40 @@ +package com.mercury.platform.ui.components.panel.settings.page; + + +import java.util.ArrayList; +import java.util.List; + +public class GlobalHotkeyGroup { + public static GlobalHotkeyGroup INSTANCE = GlobalHotkeyGroupHolder.HOLDER_INSTANCE; + private List groups = new ArrayList<>(); + + public void registerGroup(HotKeyGroup group) { + this.groups.add(group); + } + + public void onHotKeyChange(HotKeyGroup group, HotKeyPanel panel) { + this.groups.forEach(it -> { + if (!it.equals(group)) { + if (it.isGlobal()) { + it.onHotKeyCheck(panel); + } + } + }); + } + + public void onGlobalHotKeyChange(HotKeyGroup group, HotKeyPanel panel) { + this.groups.forEach(it -> { + if (!it.equals(group)) { + it.onHotKeyCheck(panel); + } + }); + } + + public void clear() { + this.groups.clear(); + } + + private static class GlobalHotkeyGroupHolder { + static final GlobalHotkeyGroup HOLDER_INSTANCE = new GlobalHotkeyGroup(); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/HotKeyGroup.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/HotKeyGroup.java new file mode 100644 index 00000000..298f23e5 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/HotKeyGroup.java @@ -0,0 +1,48 @@ +package com.mercury.platform.ui.components.panel.settings.page; + + +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; + +public class HotKeyGroup { + private List hotKeyPanels = new ArrayList<>(); + @Getter + private boolean global; + + public HotKeyGroup(boolean global) { + this.global = global; + GlobalHotkeyGroup.INSTANCE.registerGroup(this); + } + + public HotKeyGroup() { + this(false); + } + + public void registerHotkey(HotKeyPanel panel) { + panel.setMyGroup(this); + this.hotKeyPanels.add(panel); + } + + public void onHotKeyChange(HotKeyPanel panel) { + if (this.global) { + GlobalHotkeyGroup.INSTANCE.onGlobalHotKeyChange(this, panel); + } else { + GlobalHotkeyGroup.INSTANCE.onHotKeyChange(this, panel); + } + this.hotKeyPanels.forEach(it -> { + if (!it.equals(panel) && it.getDescriptor().equals(panel.getDescriptor()) && it.getDescriptor().getVirtualKeyCode() != -1) { + it.toDefaultHotkey(); + } + }); + } + + public void onHotKeyCheck(HotKeyPanel panel) { + this.hotKeyPanels.forEach(it -> { + if (!it.equals(panel) && it.getDescriptor().equals(panel.getDescriptor()) && it.getDescriptor().getVirtualKeyCode() != -1) { + it.toDefaultHotkey(); + } + }); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/HotKeyPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/HotKeyPanel.java index fee1b217..92a861d7 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/HotKeyPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/HotKeyPanel.java @@ -5,6 +5,8 @@ import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.misc.AppThemeColor; +import lombok.Getter; +import lombok.Setter; import javax.swing.*; import java.awt.*; @@ -13,8 +15,12 @@ public class HotKeyPanel extends JPanel { + @Getter private HotKeyDescriptor descriptor; private boolean hotKeyAllowed; + @Setter + private HotKeyGroup myGroup; + private JButton button; public HotKeyPanel(HotKeyDescriptor descriptor) { super(new BorderLayout()); @@ -22,8 +28,8 @@ public HotKeyPanel(HotKeyDescriptor descriptor) { this.setPreferredSize(new Dimension(110, 26)); ComponentsFactory componentsFactory = new ComponentsFactory(); - JButton button = componentsFactory.getBorderedButton(this.descriptor.getTitle()); - button.setFont(componentsFactory.getFont(FontStyle.BOLD, 17f)); + this.button = componentsFactory.getBorderedButton(this.descriptor.getTitle()); + this.button.setFont(componentsFactory.getFont(FontStyle.BOLD, 17f)); MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { @@ -35,10 +41,10 @@ public void mousePressed(MouseEvent e) { } } }; - button.addMouseListener(mouseAdapter); + this.button.addMouseListener(mouseAdapter); MercuryStoreCore.hotKeySubject.subscribe(hotKey -> { if (hotKeyAllowed) { - button.setBackground(AppThemeColor.BUTTON); + this.button.setBackground(AppThemeColor.BUTTON); if (hotKey.getVirtualKeyCode() == 1) { this.descriptor.setTitle("..."); this.descriptor.setVirtualKeyCode(-1); @@ -54,9 +60,20 @@ public void mousePressed(MouseEvent e) { } button.setText(this.descriptor.getTitle()); hotKeyAllowed = false; + this.myGroup.onHotKeyChange(this); button.addMouseListener(mouseAdapter); } }); this.add(button, BorderLayout.CENTER); } + + public void toDefaultHotkey() { + this.descriptor.setTitle("..."); + this.descriptor.setVirtualKeyCode(-1); + this.descriptor.setMenuPressed(false); + this.descriptor.setShiftPressed(false); + this.descriptor.setControlPressed(false); + + button.setText(this.descriptor.getTitle()); + } } 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 index 962b0c5f..b7aca667 100644 --- 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 @@ -24,6 +24,10 @@ public class NotificationSettingsPagePanel extends SettingsPagePanel { private List outHotKeySnapshot; private List scannerHotKeySnapshot; + private HotKeyGroup incHotkeyGroup; + private HotKeyGroup outHotkeyGroup; + private HotKeyGroup scannerHotkeyGroup; + @Override public void onViewInit() { super.onViewInit(); @@ -33,6 +37,11 @@ public void onViewInit() { this.incHotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get().getIncNHotKeysList()); this.outHotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get().getOutNHotKeysList()); this.scannerHotKeySnapshot = CloneHelper.cloneObject(hotKeyService.get().getScannerNHotKeysList()); + + this.incHotkeyGroup = new HotKeyGroup(); + this.outHotkeyGroup = new HotKeyGroup(); + this.scannerHotkeyGroup = new HotKeyGroup(); + JPanel inPanel = this.adrComponentsFactory.getCounterPanel(this.getIncomingPanel(), "Incoming notification:", AppThemeColor.ADR_BG, false); inPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); JPanel outPanel = this.adrComponentsFactory.getCounterPanel(this.getOutgoingPanel(), "Outgoing notification:", AppThemeColor.ADR_BG, false); @@ -131,7 +140,7 @@ private JPanel getIncomingPanel() { propertiesPanel.add(showLeague); root.add(propertiesPanel, BorderLayout.PAGE_START); - ResponseButtonsPanel responseButtonsPanel = new ResponseButtonsPanel(this.generalSnapshot.getButtons()); + ResponseButtonsPanel responseButtonsPanel = new ResponseButtonsPanel(this.generalSnapshot.getButtons(), this.incHotkeyGroup); responseButtonsPanel.onViewInit(); root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(responseButtonsPanel, AppThemeColor.ADR_BG), "Response buttons:"), BorderLayout.CENTER); root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(this.getInNotificationHotKeysPanel(), AppThemeColor.ADR_BG), "Hotkeys"), BorderLayout.PAGE_END); @@ -151,8 +160,9 @@ private JPanel getInNotificationHotKeysPanel() { root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); this.incHotKeySnapshot.forEach(pair -> { root.add(this.componentsFactory.getIconLabel(pair.getType().getIconPath(), 18, SwingConstants.CENTER)); - root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(pair.getDescriptor()), AppThemeColor.SETTINGS_BG, 2, 4, 1, 1)); - + HotKeyPanel hotKeyPanel = new HotKeyPanel(pair.getDescriptor()); + this.incHotkeyGroup.registerHotkey(hotKeyPanel); + root.add(this.componentsFactory.wrapToSlide(hotKeyPanel, AppThemeColor.SETTINGS_BG, 2, 4, 1, 1)); }); return root; } @@ -162,7 +172,9 @@ private JPanel getOutNotificationHotKeysPanel() { root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); this.outHotKeySnapshot.forEach(pair -> { root.add(this.componentsFactory.getIconLabel(pair.getType().getIconPath(), 18, SwingConstants.CENTER)); - root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(pair.getDescriptor()), AppThemeColor.SETTINGS_BG, 2, 4, 1, 1)); + HotKeyPanel hotKeyPanel = new HotKeyPanel(pair.getDescriptor()); + this.outHotkeyGroup.registerHotkey(hotKeyPanel); + root.add(this.componentsFactory.wrapToSlide(hotKeyPanel, AppThemeColor.SETTINGS_BG, 2, 4, 1, 1)); }); return root; } @@ -172,8 +184,9 @@ private JPanel getScannerNotificationHotKeysPanel() { root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); this.scannerHotKeySnapshot.forEach(pair -> { root.add(this.componentsFactory.getIconLabel(pair.getType().getIconPath(), 18, SwingConstants.CENTER)); - root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(pair.getDescriptor()), AppThemeColor.SETTINGS_BG, 2, 4, 1, 1)); - + HotKeyPanel hotKeyPanel = new HotKeyPanel(pair.getDescriptor()); + this.scannerHotkeyGroup.registerHotkey(hotKeyPanel); + root.add(this.componentsFactory.wrapToSlide(hotKeyPanel, AppThemeColor.SETTINGS_BG, 2, 4, 1, 1)); }); return root; } @@ -194,7 +207,7 @@ private JPanel getOutgoingPanel() { }); propertiesPanel.add(closeAfterLeave); - ResponseButtonsPanel responseButtonsPanel = new ResponseButtonsPanel(this.generalSnapshot.getOutButtons()); + ResponseButtonsPanel responseButtonsPanel = new ResponseButtonsPanel(this.generalSnapshot.getOutButtons(), this.outHotkeyGroup); responseButtonsPanel.onViewInit(); root.add(propertiesPanel, BorderLayout.PAGE_START); root.add(this.wrapToCounter(this.componentsFactory.wrapToSlide(responseButtonsPanel, AppThemeColor.ADR_BG), "Response buttons:"), BorderLayout.CENTER); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/ResponseButtonsPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/ResponseButtonsPanel.java index f2eaf6f9..6a02db60 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/ResponseButtonsPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/ResponseButtonsPanel.java @@ -17,9 +17,11 @@ public class ResponseButtonsPanel extends JPanel implements ViewInit { private List buttons; private ComponentsFactory componentsFactory = new ComponentsFactory(); + private HotKeyGroup hotKeyGroup; - public ResponseButtonsPanel(List buttons) { + public ResponseButtonsPanel(List buttons, HotKeyGroup hotKeyGroup) { super(new BorderLayout(4, 4)); + this.hotKeyGroup = hotKeyGroup; this.buttons = buttons; } @@ -101,7 +103,9 @@ public void focusLost(FocusEvent e) { descriptor.setClose(checkBox.isSelected()); }); miscPanel.add(checkBox, BorderLayout.LINE_START); - miscPanel.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(descriptor.getHotKeyDescriptor()), AppThemeColor.SETTINGS_BG, 0, 0, 2, 0), BorderLayout.CENTER); + HotKeyPanel hotKeyPanel = new HotKeyPanel(descriptor.getHotKeyDescriptor()); + this.hotKeyGroup.registerHotkey(hotKeyPanel); + miscPanel.add(this.componentsFactory.wrapToSlide(hotKeyPanel, AppThemeColor.SETTINGS_BG, 0, 0, 2, 0), BorderLayout.CENTER); JButton removeButton = this.componentsFactory.getIconButton("app/adr/remove_node.png", 17, AppThemeColor.SETTINGS_BG, "Remove button"); removeButton.addActionListener(action -> { 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 index f7e41c29..ec591c27 100644 --- 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 @@ -52,7 +52,7 @@ private JPanel getVolumePanel() { 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 = componentsFactory.getSlider(-40, 6, soundSnapshot.get("notification").getDb().intValue(), AppThemeColor.ADR_BG); notificationSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { @@ -62,7 +62,7 @@ public void mouseReleased(MouseEvent e) { )); } }); - chatScannerSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("chat_scanner").getDb().intValue(), AppThemeColor.SETTINGS_BG); + chatScannerSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("chat_scanner").getDb().intValue(), AppThemeColor.ADR_BG); chatScannerSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { @@ -72,7 +72,7 @@ public void mouseReleased(MouseEvent e) { )); } }); - clicksSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("clicks").getDb().intValue(), AppThemeColor.SETTINGS_BG); + clicksSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("clicks").getDb().intValue(), AppThemeColor.ADR_BG); clicksSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { @@ -82,7 +82,7 @@ public void mouseReleased(MouseEvent e) { )); } }); - updateSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("update").getDb().intValue(), AppThemeColor.SETTINGS_BG); + updateSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("update").getDb().intValue(), AppThemeColor.ADR_BG); updateSlider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { 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 index bc9acbb2..be773d67 100644 --- 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 @@ -14,7 +14,6 @@ public class TaskBarSettingsPagePanel extends SettingsPagePanel { private PlainConfigurationService taskBarService; private TaskBarDescriptor taskBarSnapshot; - @Override public void onViewInit() { super.onViewInit(); @@ -39,7 +38,10 @@ public void onViewInit() { JPanel hotKeysPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4), AppThemeColor.SETTINGS_BG); hotKeysPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); root.add(this.componentsFactory.getIconLabel("app/hideout.png", 24, SwingConstants.CENTER)); - root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(this.taskBarSnapshot.getHideoutHotkey()), AppThemeColor.SETTINGS_BG, 2, 4, 1, 1)); + HotKeyGroup hotKeyGroup = new HotKeyGroup(true); + HotKeyPanel hotKeyPanel = new HotKeyPanel(this.taskBarSnapshot.getHideoutHotkey()); + hotKeyGroup.registerHotkey(hotKeyPanel); + root.add(this.componentsFactory.wrapToSlide(hotKeyPanel, AppThemeColor.SETTINGS_BG, 2, 4, 1, 1)); this.container.add(this.componentsFactory.wrapToSlide(root)); this.container.add(this.componentsFactory.wrapToSlide(hotKeysPanel)); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java index 334f47d8..79f7c9a2 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java @@ -1,6 +1,7 @@ package com.mercury.platform.ui.frame.movable; import com.mercury.platform.core.ProdStarter; +import com.mercury.platform.core.misc.SoundType; import com.mercury.platform.shared.FrameVisibleState; import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; @@ -19,7 +20,6 @@ import com.mercury.platform.ui.frame.titled.TestEngine; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; -import org.apache.commons.lang3.StringUtils; import javax.swing.*; import java.awt.*; @@ -31,15 +31,16 @@ public class NotificationFrame extends AbstractMovableComponentFrame { private static int BUFFER_DEFAULT_HEIGHT = 1500; private List notificationPanels; - private List currentOffers; private PlainConfigurationService config; private NotificationPanelFactory providersFactory; + private NotificationPreProcessor preProcessor; private JPanel container; private JPanel expandPanel; private JPanel stubExpandPanel; private JPanel root; private boolean expanded; private FlowDirections flowDirections; + private boolean dnd; private JPanel buffer; @@ -49,17 +50,17 @@ protected void initialize() { this.processSEResize = false; this.notificationPanels = new ArrayList<>(); this.config = Configuration.get().notificationConfiguration(); + this.flowDirections = this.config.get().getFlowDirections(); this.componentsFactory.setScale(this.scaleConfig.get("notification")); this.stubComponentsFactory.setScale(this.scaleConfig.get("notification")); this.providersFactory = new NotificationPanelFactory(); + this.preProcessor = new NotificationPreProcessor(); } @Override public void onViewInit() { this.getRootPane().setBorder(null); this.setBackground(AppThemeColor.TRANSPARENT); - this.flowDirections = this.config.get().getFlowDirections(); - this.currentOffers = new ArrayList<>(); this.container = new JPanel(); this.container.setBackground(AppThemeColor.TRANSPARENT); this.container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS)); @@ -83,19 +84,36 @@ public void onViewInit() { @Override @SuppressWarnings("all") public void subscribe() { + MercuryStoreCore.dndSubject.subscribe(state -> { + this.dnd = state; + if (!this.dnd && this.notificationPanels.size() > 0) { + this.setVisible(true); + } else { + this.setVisible(false); + } + }); + MercuryStoreCore.expiredNotificationSubject.subscribe(notification -> { + List stubList = new ArrayList<>(this.notificationPanels); + String descriptorData = this.preProcessor.getDescriptorData(notification); + stubList.forEach(it -> { + if (this.preProcessor.getDescriptorData((NotificationDescriptor) it.getData()).equals(descriptorData)) { + MercuryStoreCore.removeNotificationSubject.onNext((NotificationDescriptor) it.getData()); + } + }); + }); MercuryStoreCore.newNotificationSubject.subscribe(notification -> { SwingUtilities.invokeLater(() -> { NotificationPanel notificationPanel = this.providersFactory.getProviderFor(notification.getType()) .setData(notification) .setComponentsFactory(this.componentsFactory) .build(); - String message = StringUtils.substringAfter(notification.getSourceString(), ":"); - if (this.currentOffers.contains(message)) { + if (preProcessor.isDuplicate(notification)) { notificationPanel.setDuplicate(true); - } else { - this.currentOffers.add(message); } - this.addNotification(notificationPanel); + if (this.preProcessor.isAllowed(notification)) { + MercuryStoreCore.soundSubject.onNext(SoundType.MESSAGE); + this.addNotification(notificationPanel); + } }); }); MercuryStoreCore.newScannerMessageSubject.subscribe(message -> { @@ -105,11 +123,6 @@ public void subscribe() { .setComponentsFactory(this.componentsFactory) .build(); this.addNotification(notificationPanel); - Timer packTimer = new Timer(5, action -> { - this.pack(); - }); - packTimer.setRepeats(false); - packTimer.start(); }); }); MercuryStoreCore.removeNotificationSubject.subscribe(notification -> { @@ -117,7 +130,6 @@ public void subscribe() { NotificationPanel notificationPanel = this.notificationPanels.stream() .filter(it -> it.getData().equals(notification)) .findAny().orElse(null); - this.currentOffers.remove(StringUtils.substringAfter(notification.getSourceString(), ":")); if (notificationPanel != null) { this.removeNotification(notificationPanel); } @@ -226,9 +238,18 @@ protected void onScaleLock() { this.remove(var); this.add(this.expandPanel, BorderLayout.LINE_START); } + if (this.getLocation().y > 0) { + this.setLocation(new Point(this.getLocation().x, this.getLocation().y - BUFFER_DEFAULT_HEIGHT)); + } super.onScaleLock(); } + @Override + protected void onScaleUnlock() { + this.setLocation(this.framesConfig.get(this.getClass().getSimpleName()).getFrameLocation()); + super.onScaleUnlock(); + } + public void changeBufferSize(int delta) { if (this.flowDirections.equals(FlowDirections.UPWARDS)) { this.buffer.setPreferredSize(new Dimension(10, this.buffer.getPreferredSize().height + delta)); @@ -270,9 +291,7 @@ protected void registerDirectScaleHandler() { @Override protected void performScaling(Map scaleData) { this.componentsFactory.setScale(scaleData.get("notification")); - this.notificationPanels.forEach(it -> { - it.setComponentsFactory(this.componentsFactory); - }); + this.validateContainer(); this.pack(); this.repaint(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationPreProcessor.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationPreProcessor.java new file mode 100644 index 00000000..7237dcb5 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationPreProcessor.java @@ -0,0 +1,73 @@ +package com.mercury.platform.ui.frame.movable; + + +import com.mercury.platform.shared.AsSubscriber; +import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; +import com.mercury.platform.shared.entity.message.NotificationDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import net.jodah.expiringmap.ExpiringMap; + +import java.util.*; +import java.util.concurrent.TimeUnit; + +public class NotificationPreProcessor implements AsSubscriber { + private List currentMessages; + private Map expiresMessages; + + public NotificationPreProcessor() { + this.currentMessages = new ArrayList<>(); + this.expiresMessages = ExpiringMap.builder() + .expiration(1, TimeUnit.HOURS) + .build(); + this.subscribe(); + } + + public boolean isAllowed(NotificationDescriptor descriptor) { + String descriptorData = this.getDescriptorData(descriptor); + if (expiresMessages.containsValue(descriptorData)) { + return false; + } + if (!this.currentMessages.contains(descriptor)) { + this.currentMessages.add(descriptor); + return true; + } + return false; + } + + public boolean isDuplicate(NotificationDescriptor descriptor) { + String descriptorData = this.getDescriptorData(descriptor); + return this.currentMessages.stream().filter(it -> + this.getDescriptorData(it).equals(descriptorData)) + .findAny() + .orElse(null) != null; + } + + @Override + public void subscribe() { + MercuryStoreCore.expiredNotificationSubject.subscribe(notificationDescriptor -> { + this.expiresMessages.put(UUID.randomUUID().toString(), this.getDescriptorData(notificationDescriptor)); + }); + MercuryStoreCore.removeNotificationSubject.subscribe(notification -> { + this.currentMessages.remove(notification); + }); + } + + public String getDescriptorData(NotificationDescriptor notificationDescriptor) { + switch (notificationDescriptor.getType()) { + case INC_ITEM_MESSAGE: { + ItemTradeNotificationDescriptor descriptor = (ItemTradeNotificationDescriptor) notificationDescriptor; + if (Objects.nonNull(descriptor.getTabName())) { + return descriptor.getItemName() + ":" + descriptor.getTabName() + ":" + descriptor.getLeft() + ":" + descriptor.getTop(); + } else { + return descriptor.getItemName(); + } + } + case INC_CURRENCY_MESSAGE: { + CurrencyTradeNotificationDescriptor descriptor = (CurrencyTradeNotificationDescriptor) notificationDescriptor; + return descriptor.getCurrForSaleTitle(); + } + } + return UUID.randomUUID().toString(); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/ChatHistoryFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/ChatHistoryFrame.java index 8a1a724f..2c6becd8 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/ChatHistoryFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/ChatHistoryFrame.java @@ -22,16 +22,15 @@ public ChatHistoryFrame() { @Override protected void initialize() { - + this.componentsFactory.setScale(this.scaleConfig.get("notification")); } @Override public void onViewInit() { this.setBackground(AppThemeColor.TRANSPARENT); this.setOpacity(this.applicationConfig.get().getMaxOpacity() / 100f); - + this.setPreferredSize(new Dimension((int) (300 * this.componentsFactory.getScale()), (int) (150 * this.componentsFactory.getScale()))); JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); - root.setPreferredSize(new Dimension(300, 150)); root.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(AppThemeColor.BORDER, 1), BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT, 2))); @@ -71,10 +70,17 @@ public void subscribe() { this.hideTimer.stop(); } this.showTimer = new Timer(300, action -> { - this.setLocation(new Point(definition.getLocation().x + 10, definition.getLocation().y)); + Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); + if (definition.getLocation().y + this.getPreferredSize().height > dim.height) { + this.setLocation(definition.getLocation().x + 4, definition.getLocation().y - this.getPreferredSize().height); + } else { + this.setLocation(new Point(definition.getLocation().x + 4, definition.getLocation().y)); + } this.chatContainer.removeAll(); + this.componentsFactory.setScale(this.scaleConfig.get("notification")); + this.setPreferredSize(new Dimension((int) (300 * this.componentsFactory.getScale()), (int) (150 * this.componentsFactory.getScale()))); definition.getMessages().forEach(it -> { - this.chatContainer.add(this.componentsFactory.getTextLabel((it.isIncoming() ? "From: " : "To: ") + it.getMessage())); + this.chatContainer.add(this.componentsFactory.getTextLabel((it.isIncoming() ? "> " : "") + it.getMessage())); }); this.pack(); this.setVisible(true); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatScannerFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatScannerFrame.java index 1e87f16b..73432411 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatScannerFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/ChatScannerFrame.java @@ -2,9 +2,10 @@ import com.mercury.platform.core.misc.SoundType; import com.mercury.platform.core.utils.interceptor.MessageInterceptor; -import com.mercury.platform.core.utils.interceptor.filter.MessageFilter; +import com.mercury.platform.core.utils.interceptor.filter.MessageMatcher; import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.HotKeyType; import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; import com.mercury.platform.shared.config.descriptor.ScannerDescriptor; import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; @@ -18,6 +19,8 @@ import javax.swing.*; import java.awt.*; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -99,6 +102,24 @@ public void onViewInit() { root.add(setupArea, BorderLayout.CENTER); root.add(getMemo(), BorderLayout.LINE_END); + JPanel propertiesPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); + + JLabel quickResponseLabel = this.componentsFactory.getIconLabel(HotKeyType.N_QUICK_RESPONSE.getIconPath(), 18); + quickResponseLabel.setFont(this.componentsFactory.getFont(FontStyle.REGULAR, 16)); + quickResponseLabel.setForeground(AppThemeColor.TEXT_DEFAULT); + quickResponseLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); + quickResponseLabel.setText("Response message:"); + propertiesPanel.add(quickResponseLabel, BorderLayout.LINE_START); + JTextField quickResponseField = this.componentsFactory.getTextField(this.scannerService.get().getResponseMessage(), FontStyle.BOLD, 15f); + quickResponseField.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + scannerService.get().setResponseMessage(quickResponseField.getText()); + } + }); + propertiesPanel.add(this.componentsFactory.wrapToSlide(quickResponseField, AppThemeColor.FRAME, 0, 4, 0, 4), BorderLayout.CENTER); + + root.add(propertiesPanel, BorderLayout.PAGE_END); this.add(root, BorderLayout.CENTER); this.add(navBar, BorderLayout.PAGE_END); this.pack(); @@ -180,7 +201,7 @@ protected void process(String stubMessage) { } @Override - protected MessageFilter getFilter() { + protected MessageMatcher match() { return message -> { if (!message.contains("] $") && !message.contains("] #")) { return false; 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 4b655dd8..89cba2ec 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 @@ -10,6 +10,7 @@ import com.mercury.platform.ui.adr.components.panel.ui.MercuryTracker; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.panel.settings.MenuPanel; +import com.mercury.platform.ui.components.panel.settings.page.GlobalHotkeyGroup; import com.mercury.platform.ui.manager.FramesManager; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; @@ -83,7 +84,7 @@ private JPanel getBottomPanel() { donateDescriptor.setSize(new Dimension(100, 20)); donateDescriptor.setType(AdrComponentType.PROGRESS_BAR); donateDescriptor.setCustomTextEnable(true); - donateDescriptor.setCustomText("5$/150$"); + donateDescriptor.setCustomText("5$"); donateDescriptor.setFontSize(21); donateDescriptor.setLowValueTextColor(AppThemeColor.TEXT_DEFAULT); donateDescriptor.setMediumValueTextColor(AppThemeColor.TEXT_DEFAULT); @@ -116,6 +117,7 @@ private JPanel getSaveButtonPanel() { "Cancel", 16f); cancelButton.addActionListener(e -> { + GlobalHotkeyGroup.INSTANCE.clear(); MercuryStoreCore.showingDelaySubject.onNext(true); this.hideComponent(); MercuryStoreUI.settingsRestoreSubject.onNext(true); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java index 6d8ad1b4..0d852e32 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestCasesFrame.java @@ -1,5 +1,6 @@ package com.mercury.platform.ui.frame.titled; +import com.mercury.platform.core.misc.SoundType; import com.mercury.platform.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.misc.AppThemeColor; @@ -90,6 +91,7 @@ private JPanel getTestCasesPanel() { JButton chatScannerButton = componentsFactory.getBorderedButton("Click"); chatScannerButton.addActionListener(action -> { MercuryStoreCore.newScannerMessageSubject.onNext(this.testEngine.getRandomScannerMessage()); + MercuryStoreCore.soundSubject.onNext(SoundType.CHAT_SCANNER); }); testPanel.add(chatScannerButton, buttonColumn); buttonColumn.gridy++; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestEngine.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestEngine.java index 23aa6c64..135b8680 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestEngine.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/TestEngine.java @@ -6,7 +6,6 @@ import com.mercury.platform.shared.entity.message.NotificationType; import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; import com.mercury.platform.ui.components.panel.chat.HtmlMessageBuilder; -import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.Arrays; @@ -205,7 +204,7 @@ public PlainMessageDescriptor getRandomScannerMessage() { offer.get(random.nextInt(offer.size())) )); PlainMessageDescriptor descriptor = new PlainMessageDescriptor(); - descriptor.setMessage(messageBuilder.build(StringUtils.substringAfter(notificationDescriptor.getSourceString(), notificationDescriptor.getWhisperNickname() + ":"))); + descriptor.setMessage(messageBuilder.build(notificationDescriptor.getSourceString())); descriptor.setNickName(notificationDescriptor.getWhisperNickname()); return descriptor; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/TooltipConstants.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/TooltipConstants.java index 8ba1ce4b..71e0447d 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/TooltipConstants.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/TooltipConstants.java @@ -26,6 +26,7 @@ public class TooltipConstants { //MessagePanel tooltips public static final String INVITE = "Invite player"; public static final String STILL_INTERESTED = "Still interested?"; + public static final String REPEAT_MESSAGE = "Repeat message"; public static final String KICK = "Kick player"; public static final String TRADE = "Offer Trade"; public static final String EXPAND_COLLAPSE = "Expand / collapse"; @@ -35,6 +36,7 @@ public class TooltipConstants { public static final String LEAVE = "Leave from party"; public static final String QUICK_RESPONSE = "Quick response"; public static final String HIDE_PANEL = "Close"; + public static final String HISTORY_RELOAD = "Restore message"; //OutMessage tooltips public static final String HO_IN = "Travel to this player's hideout"; diff --git a/app-ui/src/main/resources/app/leave.png b/app-ui/src/main/resources/app/leave.png index 1de6fc0e..c90798cf 100644 Binary files a/app-ui/src/main/resources/app/leave.png and b/app-ui/src/main/resources/app/leave.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 9d8338ba..d7c468e0 100644 --- a/app-ui/src/main/resources/notes/patch/patch-notes.json +++ b/app-ui/src/main/resources/notes/patch/patch-notes.json @@ -1,5 +1,5 @@ { - "version":"1.0.1.8.1", + "version": "1.0.1.9.0", "notes":[ { "title" : "Hotfix",