From 80bc441904c50e30713f27f709e6e401f1f3287d Mon Sep 17 00:00:00 2001 From: Exslims Date: Thu, 24 Aug 2017 23:33:49 +0400 Subject: [PATCH] Bug fixes and improvements part 2 --- .../impl/HotKeyConfigurationService.java | 13 +- .../shared/config/descriptor/HotKeyType.java | 6 + .../adr/AdrDurationComponentDescriptor.java | 2 + .../message/NotificationDescriptor.java | 3 + .../panel/ui/BasicMercuryIconTrackerUI.java | 3 + .../ui/components/ComponentsFactory.java | 4 + .../CurrencyOutNotificationPanel.java | 47 --- ...=> CurrencyTradeIncNotificationPanel.java} | 48 +-- .../CurrencyTradeOutNotificationPanel.java | 68 ++++ .../IncomingNotificationPanel.java | 300 ------------------ .../ItemOutNotificationPanel.java | 32 -- ...ava => ItemTradeIncNotificationPanel.java} | 10 +- .../ItemTradeOutNotificationPanel.java | 44 +++ .../panel/notification/NotificationPanel.java | 15 +- .../OutgoingNotificationPanel.java | 200 ------------ .../ScannerNotificationPanel.java | 25 +- .../TradeIncNotificationPanel.java | 123 +++++++ .../notification/TradeNotificationPanel.java | 207 ++++++++++++ .../TradeOutNotificationPanel.java | 123 +++++++ .../factory/CurrencyIncPanelProvider.java | 4 +- .../factory/CurrencyOutPanelProvider.java | 4 +- .../factory/ItemIncPanelProvider.java | 4 +- .../factory/ItemOutPanelProvider.java | 4 +- .../ui/frame/movable/NotificationFrame.java | 6 +- .../ui/frame/other/ChatHistoryDefinition.java | 15 + .../ui/frame/other/ChatHistoryFrame.java | 105 ++++++ .../ui/frame/titled/SettingsFrame.java | 44 ++- .../ui/frame/titled/TestCasesFrame.java | 24 +- .../platform/ui/frame/titled/TestEngine.java | 50 ++- .../platform/ui/manager/FramesManager.java | 1 + .../platform/ui/misc/AppThemeColor.java | 4 + .../platform/ui/misc/MercuryStoreUI.java | 4 + app-ui/src/main/resources/app/leave.png | Bin 1393 -> 1719 bytes .../src/main/resources/app/visiteHideout.png | Bin 750 -> 1104 bytes 34 files changed, 908 insertions(+), 634 deletions(-) delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyOutNotificationPanel.java rename app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/{CurrencyIncNotificationPanel.java => CurrencyTradeIncNotificationPanel.java} (51%) create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeOutNotificationPanel.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemOutNotificationPanel.java rename app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/{ItemIncNotificationPanel.java => ItemTradeIncNotificationPanel.java} (89%) create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeOutNotificationPanel.java delete mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeIncNotificationPanel.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeNotificationPanel.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeOutNotificationPanel.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/frame/other/ChatHistoryDefinition.java create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/frame/other/ChatHistoryFrame.java 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 61a9614a..ef8659ee 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 @@ -22,7 +22,6 @@ public HotKeysSettingsDescriptor getDefault() { incNDataList.add(new HotKeyPair(HotKeyType.N_KICK_PLAYER, new HotKeyDescriptor())); incNDataList.add(new HotKeyPair(HotKeyType.N_STILL_INTERESTING, new HotKeyDescriptor())); incNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT, new HotKeyDescriptor())); - incNDataList.add(new HotKeyPair(HotKeyType.N_SWITCH_CHAT, new HotKeyDescriptor())); incNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION, new HotKeyDescriptor())); List outNDataList = new ArrayList<>(); @@ -30,6 +29,7 @@ public HotKeysSettingsDescriptor getDefault() { outNDataList.add(new HotKeyPair(HotKeyType.N_TRADE_PLAYER, new HotKeyDescriptor())); outNDataList.add(new HotKeyPair(HotKeyType.N_LEAVE, new HotKeyDescriptor())); outNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT, new HotKeyDescriptor())); + outNDataList.add(new HotKeyPair(HotKeyType.N_REPEAT_MESSAGE, new HotKeyDescriptor())); outNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION, new HotKeyDescriptor())); List scannerNDataList = new ArrayList<>(); @@ -56,6 +56,17 @@ 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())); + } } @Override diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java index cd4958b7..2abe067a 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java @@ -43,6 +43,12 @@ public String getIconPath() { return "app/still-interesting.png"; } }, + N_REPEAT_MESSAGE { + @Override + public String getIconPath() { + return "app/reload-history.png"; + } + }, N_SWITCH_CHAT { @Override public String getIconPath() { diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrDurationComponentDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrDurationComponentDescriptor.java index 3cc93b5b..75ccf886 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrDurationComponentDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/adr/AdrDurationComponentDescriptor.java @@ -11,6 +11,8 @@ @Data public class AdrDurationComponentDescriptor extends AdrColoredComponentDescriptor implements Serializable { private HotKeyDescriptor hotKeyDescriptor = new HotKeyDescriptor(); + private String customText = ""; + private boolean customTextEnable; private boolean hotKeyRefresh = true; private String iconPath = "default_icon.png"; private Double duration = 3.4d; 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 e842b226..0a3f70fa 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 @@ -2,7 +2,9 @@ import lombok.Data; +import java.util.ArrayList; import java.util.Date; +import java.util.List; @Data public class NotificationDescriptor { @@ -10,4 +12,5 @@ public class NotificationDescriptor { 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/ui/BasicMercuryIconTrackerUI.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/ui/BasicMercuryIconTrackerUI.java index 57ce19d9..d44082b6 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/ui/BasicMercuryIconTrackerUI.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/ui/BasicMercuryIconTrackerUI.java @@ -45,6 +45,9 @@ protected void paintString(Graphics g, int x, int y, int width, int height, int Graphics2D g2 = this.prepareAdapter(g); DecimalFormat decimalFormat = new DecimalFormat(descriptor.getTextFormat()); String progressString = String.valueOf(decimalFormat.format(value)); + if (descriptor.isCustomTextEnable()) { + progressString = String.valueOf(descriptor.getCustomText()); + } g2.setFont(tracker.getFont()); Point renderLocation = getStringPlacement(g2, progressString, x, y, width, height); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java index 522945cc..8df04ae4 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java @@ -368,6 +368,10 @@ public JLabel getTextLabel(String text, FontStyle style, float size) { return getTextLabel(style, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, size, text); } + public JLabel getTextLabel(String text, FontStyle style, Color color, float size) { + return getTextLabel(style, color, TextAlignment.LEFTOP, size, text); + } + /** * Get label with icon * diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyOutNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyOutNotificationPanel.java deleted file mode 100644 index 8c8cc7cb..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyOutNotificationPanel.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.mercury.platform.ui.components.panel.notification; - -import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.misc.AppThemeColor; - -import javax.swing.*; -import java.awt.*; -import java.text.DecimalFormat; - - -public class CurrencyOutNotificationPanel extends OutgoingNotificationPanel { - @Override - protected JPanel getContentPanel() { - JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); - root.add(this.getFromPanel(), BorderLayout.LINE_START); - root.add(this.getForPanel(), BorderLayout.CENTER); - return root; - } - - private JPanel getForPanel() { - JPanel fromPanel = this.componentsFactory.getJPanel(new FlowLayout(FlowLayout.LEFT, 0, 0), AppThemeColor.FRAME); - fromPanel.add(this.getCurrencyPanel(this.data.getCurrForSaleCount(), this.data.getCurrForSaleTitle())); - fromPanel.add(getCurrencyRatePanel()); - return fromPanel; - } - - private JPanel getCurrencyRatePanel() { - Double currForSaleCount = this.data.getCurrForSaleCount(); - Double curCount = this.data.getCurCount(); - double rate = curCount / currForSaleCount; - DecimalFormat decimalFormat = new DecimalFormat("#.####"); - JPanel ratePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, "(")); - JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + this.data.getCurrency() + ".png", 26); - currencyLabel.setBorder(null); - ratePanel.add(currencyLabel); - ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, decimalFormat.format(rate))); - ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, ")")); - ratePanel.setBorder(BorderFactory.createEmptyBorder(-5, 0, -5, 0)); - return ratePanel; - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeIncNotificationPanel.java similarity index 51% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeIncNotificationPanel.java index 9af2af1c..bb96320f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeIncNotificationPanel.java @@ -1,5 +1,6 @@ package com.mercury.platform.ui.components.panel.notification; +import com.mercury.platform.shared.config.descriptor.HotKeyType; import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; @@ -11,26 +12,39 @@ import java.text.DecimalFormat; -public class CurrencyIncNotificationPanel extends IncomingNotificationPanel { +public class CurrencyTradeIncNotificationPanel extends TradeIncNotificationPanel { @Override protected JPanel getMessagePanel() { JPanel labelsPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); - JPanel tradePanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); - tradePanel.add(this.getFromPanel(), BorderLayout.CENTER); - tradePanel.add(this.getForPanel(), BorderLayout.LINE_END); - labelsPanel.add(tradePanel, BorderLayout.CENTER); + JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.FRAME, TooltipConstants.OPEN_CHAT); + openChatButton.addActionListener(e -> controller.performOpenChat()); + JButton stillInterestedButton = this.getStillInterestedButton(); + JPanel buttons = this.componentsFactory.getJPanel(new GridLayout(1, 0, 5, 0), AppThemeColor.FRAME); + buttons.add(stillInterestedButton); + buttons.add(openChatButton); + + JPanel miscPanel = this.componentsFactory.getJPanel(new GridLayout(1, 0, 4, 0), AppThemeColor.FRAME); + miscPanel.add(this.getFromPanel(), BorderLayout.CENTER); JLabel offerLabel = this.getOfferLabel(); if (offerLabel != null) { - labelsPanel.add(offerLabel, BorderLayout.PAGE_END); + 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); return labelsPanel; } private JPanel getFromPanel() { - JPanel fromPanel = this.componentsFactory.getJPanel(new FlowLayout(FlowLayout.LEFT, 0, 0), AppThemeColor.FRAME); - fromPanel.add(this.getCurrencyPanel(this.data.getCurrForSaleCount(), this.data.getCurrForSaleTitle())); - fromPanel.add(getCurrencyRatePanel()); + JPanel fromPanel = this.componentsFactory.getJPanel(new BorderLayout(4, 0), AppThemeColor.FRAME); + JPanel currencyPanel = this.getCurrencyPanel(this.data.getCurrForSaleCount(), this.data.getCurrForSaleTitle()); + currencyPanel.setBackground(AppThemeColor.FRAME); + fromPanel.add(currencyPanel, BorderLayout.LINE_START); + fromPanel.add(getCurrencyRatePanel(), BorderLayout.CENTER); return fromPanel; } @@ -39,23 +53,21 @@ private JPanel getCurrencyRatePanel() { Double curCount = this.data.getCurCount(); double rate = curCount / currForSaleCount; DecimalFormat decimalFormat = new DecimalFormat("#.####"); - JPanel ratePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel ratePanel = componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, "(")); + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, "("), BorderLayout.LINE_START); JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + this.data.getCurrency() + ".png", 26); + currencyLabel.setFont(this.componentsFactory.getFont(FontStyle.BOLD, 18f)); + currencyLabel.setForeground(AppThemeColor.TEXT_DEFAULT); + currencyLabel.setText(decimalFormat.format(rate) + ")"); currencyLabel.setBorder(null); - ratePanel.add(currencyLabel); - ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, decimalFormat.format(rate))); - ratePanel.add(componentsFactory. - getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, ")")); - ratePanel.setBorder(BorderFactory.createEmptyBorder(-5, 0, -5, 0)); + ratePanel.add(currencyLabel, BorderLayout.CENTER); return ratePanel; } @Override protected JButton getStillInterestedButton() { - JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.STILL_INTERESTED); + JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.FRAME, TooltipConstants.STILL_INTERESTED); stillIntButton.addActionListener(action -> { String curCount = this.data.getCurCount().toString(); String responseText = "Hi, are you still interested in "; 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 new file mode 100644 index 00000000..735fe056 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeOutNotificationPanel.java @@ -0,0 +1,68 @@ +package com.mercury.platform.ui.components.panel.notification; + +import com.mercury.platform.shared.config.descriptor.HotKeyType; +import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; +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.*; +import java.text.DecimalFormat; + + +public class CurrencyTradeOutNotificationPanel extends TradeOutNotificationPanel { + @Override + 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()); + JButton repeatButton = this.getRepeatButton(); + JPanel buttons = this.componentsFactory.getJPanel(new GridLayout(1, 0, 5, 0), AppThemeColor.FRAME); + buttons.add(repeatButton); + buttons.add(openChatButton); + + JPanel miscPanel = this.componentsFactory.getJPanel(new GridLayout(1, 0, 4, 0), AppThemeColor.FRAME); + miscPanel.add(this.getFromPanel(), BorderLayout.CENTER); + JLabel offerLabel = this.getOfferLabel(); + 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); + labelsPanel.add(buttons, BorderLayout.LINE_END); + return labelsPanel; + } + + private JPanel getFromPanel() { + JPanel fromPanel = this.componentsFactory.getJPanel(new BorderLayout(4, 0), AppThemeColor.FRAME); + JPanel currencyPanel = this.getCurrencyPanel(this.data.getCurrForSaleCount(), this.data.getCurrForSaleTitle()); + currencyPanel.setBackground(AppThemeColor.FRAME); + fromPanel.add(currencyPanel, BorderLayout.LINE_START); + fromPanel.add(getCurrencyRatePanel(), BorderLayout.CENTER); + return fromPanel; + } + + private JPanel getCurrencyRatePanel() { + Double currForSaleCount = this.data.getCurrForSaleCount(); + Double curCount = this.data.getCurCount(); + double rate = curCount / currForSaleCount; + DecimalFormat decimalFormat = new DecimalFormat("#.####"); + JPanel ratePanel = componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); + ratePanel.add(componentsFactory. + getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, "("), BorderLayout.LINE_START); + JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + this.data.getCurrency() + ".png", 26); + currencyLabel.setFont(this.componentsFactory.getFont(FontStyle.BOLD, 18f)); + currencyLabel.setForeground(AppThemeColor.TEXT_DEFAULT); + currencyLabel.setText(decimalFormat.format(rate) + ")"); + currencyLabel.setBorder(null); + ratePanel.add(currencyLabel, BorderLayout.CENTER); + return ratePanel; + } + +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java deleted file mode 100644 index fcde5645..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/IncomingNotificationPanel.java +++ /dev/null @@ -1,300 +0,0 @@ -package com.mercury.platform.ui.components.panel.notification; - - -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.*; -import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; -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.components.panel.VerticalScrollContainer; -import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; -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.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -public abstract class IncomingNotificationPanel extends NotificationPanel { - protected PlainConfigurationService config; - private PlainConfigurationService hotKeysConfig; - private JPanel responseButtonsPanel; - private Subscription chatSubscription; - - @Override - public void onViewInit() { - super.onViewInit(); - this.config = Configuration.get().notificationConfiguration(); - this.hotKeysConfig = Configuration.get().hotKeysConfiguration(); - this.responseButtonsPanel = this.componentsFactory.getJPanel(new FlowLayout(FlowLayout.CENTER, 5, 2), AppThemeColor.FRAME); - this.chatPanel = this.getChatPanel(); - this.chatPanel.setVisible(false); - this.contentPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); - switch (config.get().getFlowDirections()) { - case DOWNWARDS: { - this.add(this.getHeader(), BorderLayout.PAGE_START); - this.contentPanel.add(this.responseButtonsPanel, BorderLayout.PAGE_END); - break; - } - case UPWARDS: { - this.add(this.getHeader(), BorderLayout.PAGE_END); - this.contentPanel.add(this.responseButtonsPanel, BorderLayout.PAGE_START); - break; - } - } - this.contentPanel.add(this.getMessagePanel(), BorderLayout.CENTER); - this.add(this.contentPanel, BorderLayout.CENTER); - this.updateHotKeyPool(); - } - - private JPanel getHeader() { - JPanel root = new JPanel(new BorderLayout()); - root.setBackground(AppThemeColor.MSG_HEADER); - root.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); - - JPanel nickNamePanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.MSG_HEADER); - JLabel nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP, 15f, this.getNicknameText()); - nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 5)); - nickNamePanel.add(this.getExpandButton(), BorderLayout.LINE_START); - nickNamePanel.add(nicknameLabel, BorderLayout.CENTER); - nickNamePanel.add(this.getForPanel(), BorderLayout.LINE_END); - root.add(nickNamePanel, BorderLayout.CENTER); - - JPanel opPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.MSG_HEADER); - JPanel interactionPanel = new JPanel(new GridLayout(1, 0, 4, 0)); - interactionPanel.setBackground(AppThemeColor.MSG_HEADER); - JButton inviteButton = componentsFactory.getIconButton("app/invite.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); - inviteButton.addActionListener(e -> { - this.controller.performInvite(); - root.setBorder(BorderFactory.createLineBorder(AppThemeColor.HEADER_SELECTED_BORDER)); - }); - JButton kickButton = componentsFactory.getIconButton("app/kick.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); - kickButton.addActionListener(e -> { - this.controller.performKick(); - if (this.config.get().isDismissAfterKick()) { - this.controller.performHide(); - } - }); - JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); - tradeButton.addActionListener(e -> { - this.controller.performOfferTrade(); - }); - JButton showChatButton = componentsFactory.getIconButton("app/chat_history.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.SWITCH_CHAT); - showChatButton.addActionListener(e -> { - if (this.chatPanel.isVisible()) { - this.chatPanel.setVisible(false); - this.remove(this.chatPanel); - this.add(this.contentPanel, BorderLayout.CENTER); - } else { - this.remove(this.contentPanel); - this.chatPanel.setVisible(true); - this.add(this.chatPanel, BorderLayout.CENTER); - } - SwingUtilities.getWindowAncestor(IncomingNotificationPanel.this).pack(); - }); - 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(); - }); - JButton stillInterestedButton = getStillInterestedButton(); - interactionPanel.add(inviteButton); - interactionPanel.add(tradeButton); - interactionPanel.add(kickButton); -// interactionPanel.add(stillInterestedButton); - interactionPanel.add(showChatButton); -// 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_STILL_INTERESTING, stillInterestedButton); - this.interactButtonMap.put(HotKeyType.N_SWITCH_CHAT, showChatButton); - this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT, openChatButton); - this.interactButtonMap.put(HotKeyType.N_CLOSE_NOTIFICATION, hideButton); - - JPanel timePanel = this.getTimePanel(); - opPanel.add(timePanel, BorderLayout.CENTER); - opPanel.add(interactionPanel, BorderLayout.LINE_END); - - root.add(opPanel, BorderLayout.LINE_END); - return root; - } - - @Override - protected void updateHotKeyPool() { - this.hotKeysPool.clear(); - this.interactButtonMap.forEach((type, button) -> { - HotKeyPair hotKeyPair = this.hotKeysConfig.get() - .getIncNHotKeysList() - .stream() - .filter(it -> it.getType().equals(type)) - .findAny().orElse(null); - if (!hotKeyPair.getDescriptor().getTitle().equals("...")) { - this.hotKeysPool.put(hotKeyPair.getDescriptor(), button); - } - }); - this.initResponseButtonsPanel(); - Window windowAncestor = SwingUtilities.getWindowAncestor(IncomingNotificationPanel.this); - if (windowAncestor != null) { - windowAncestor.pack(); - } - } - - @Override - public void subscribe() { - super.subscribe(); - this.chatSubscription = MercuryStoreCore.plainMessageSubject.subscribe(message -> { - if (this.data.getWhisperNickname().equals(message.getNickName())) { - this.chatContainer.add(this.componentsFactory.getTextLabel((message.isIncoming() ? "From: " : "To: ") + message.getMessage())); - SwingUtilities.getWindowAncestor(IncomingNotificationPanel.this).pack(); - } - }); - } - - @Override - public void onViewDestroy() { - super.onViewDestroy(); - this.chatSubscription.unsubscribe(); - } - - private JPanel getChatPanel() { - this.chatContainer = new VerticalScrollContainer(); - this.chatContainer.setLayout(new BoxLayout(this.chatContainer, BoxLayout.Y_AXIS)); - this.chatContainer.setBackground(AppThemeColor.FRAME); - this.chatContainer.add(this.componentsFactory.getTextLabel("From:" + StringUtils.substringAfter(this.data.getSourceString(), this.data.getWhisperNickname() + ":"))); - return this.componentsFactory.wrapToSlide(this.chatContainer, AppThemeColor.FRAME); - } - - protected JPanel getForPanel() { - JPanel forPanel = new JPanel(new BorderLayout()); -// forPanel.setPreferredSize(new Dimension((int) (110 * this.componentsFactory.getScale()),(int) (36 * this.componentsFactory.getScale()))); - forPanel.setBackground(AppThemeColor.MSG_HEADER); - JLabel separator = componentsFactory.getTextLabel( - FontStyle.BOLD, - AppThemeColor.TEXT_DEFAULT, - TextAlignment.CENTER, - 18f, - "=>"); - forPanel.add(separator, BorderLayout.CENTER); - separator.setHorizontalAlignment(SwingConstants.CENTER); - JPanel currencyPanel = this.getCurrencyPanel(this.data.getCurCount(), this.data.getCurrency()); - if (currencyPanel != null) { - forPanel.add(currencyPanel, BorderLayout.LINE_END); - } - return forPanel; - } - - protected JPanel getCurrencyPanel(Double curCount, String curIconPath) { - String curCountStr = " "; - if (curCount > 0) { - curCountStr = curCount % 1 == 0 ? - String.valueOf(curCount.intValue()) : - String.valueOf(curCount); - } - if (!Objects.equals(curCountStr, "") && curIconPath != null) { - JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + curIconPath + ".png", 26); - JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 4, 0)); - curPanel.setPreferredSize(new Dimension((int) (this.componentsFactory.getScale() * 66), (int) (this.componentsFactory.getScale() * 26))); - curPanel.setBackground(AppThemeColor.MSG_HEADER); - curPanel.add(this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 17f, null, curCountStr)); - curPanel.add(currencyLabel); - return curPanel; - } - return null; - } - - protected JLabel getOfferLabel() { - String offer = this.data.getOffer(); - if (offer != null && offer.trim().length() > 0) { - JLabel offerLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 16f, offer); - offerLabel.setHorizontalAlignment(SwingConstants.CENTER); - return offerLabel; - } - return null; - } - - protected abstract JPanel getMessagePanel(); - - protected abstract JButton getStillInterestedButton(); - - private void initResponseButtonsPanel() { - this.responseButtonsPanel.removeAll(); - List buttonsConfig = this.config.get().getButtons(); - Collections.sort(buttonsConfig); - buttonsConfig.forEach((buttonConfig) -> { - JButton button = componentsFactory.getBorderedButton(buttonConfig.getTitle(), 16f, AppThemeColor.RESPONSE_BUTTON, AppThemeColor.RESPONSE_BUTTON_BORDER, AppThemeColor.RESPONSE_BUTTON); - button.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1), - BorderFactory.createMatteBorder(3, 9, 3, 9, AppThemeColor.RESPONSE_BUTTON) - )); - button.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - button.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1), - BorderFactory.createMatteBorder(3, 9, 3, 9, AppThemeColor.RESPONSE_BUTTON) - )); - } - - @Override - public void mouseExited(MouseEvent e) { - button.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1), - BorderFactory.createMatteBorder(3, 9, 3, 9, AppThemeColor.RESPONSE_BUTTON) - )); - } - }); - button.addActionListener(action -> { - button.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1), - BorderFactory.createMatteBorder(3, 9, 3, 9, AppThemeColor.RESPONSE_BUTTON) - )); - }); - button.addActionListener(e -> { - this.controller.performResponse(buttonConfig.getResponseText()); - if (buttonConfig.isClose()) { - this.controller.performHide(); - } - }); - this.hotKeysPool.put(buttonConfig.getHotKeyDescriptor(), button); - this.responseButtonsPanel.add(button); - }); - } - - private String getNicknameText() { - String whisperNickname = data.getWhisperNickname(); - String result = whisperNickname + ":"; - if (this.config.get().isShowLeague()) { - if (data.getLeague() != null) { - String league = data.getLeague().trim(); - if (league.length() == 0) { - return result; - } - if (league.contains("Hardcore")) { - if (league.equals("Hardcore")) { - result = "HC " + result; - } else { - result = String.valueOf(league.split(" ")[1].charAt(0)) + "HC " + result; - } - } else if (league.contains("Standard")) { - result = "Standard " + result; - } else { - result = String.valueOf(league.charAt(0)) + "SC " + result; - } - } - } - return result; - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemOutNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemOutNotificationPanel.java deleted file mode 100644 index 84f3cc6e..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemOutNotificationPanel.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.mercury.platform.ui.components.panel.notification; - -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 javax.swing.*; -import java.awt.*; - - -public class ItemOutNotificationPanel extends OutgoingNotificationPanel { - @Override - protected JPanel getContentPanel() { - JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); - JButton itemButton = componentsFactory.getButton( - FontStyle.BOLD, - AppThemeColor.BUTTON, - BorderFactory.createEmptyBorder(0, 4, 0, 2), - this.data.getItemName(), 16f); - - itemButton.setForeground(AppThemeColor.TEXT_IMPORTANT); - itemButton.setBackground(AppThemeColor.TRANSPARENT); - itemButton.setHorizontalAlignment(SwingConstants.LEFT); - itemButton.setContentAreaFilled(false); - itemButton.setRolloverEnabled(false); - itemButton.addActionListener(action -> { - }); - root.add(this.getFromPanel(), BorderLayout.LINE_START); - root.add(itemButton, BorderLayout.CENTER); - return root; - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeIncNotificationPanel.java similarity index 89% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeIncNotificationPanel.java index 7deac9ef..59c21036 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeIncNotificationPanel.java @@ -1,5 +1,6 @@ package com.mercury.platform.ui.components.panel.notification; +import com.mercury.platform.shared.config.descriptor.HotKeyType; import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.fields.font.FontStyle; @@ -10,9 +11,8 @@ import java.awt.*; -public class ItemIncNotificationPanel extends IncomingNotificationPanel { +public class ItemTradeIncNotificationPanel extends TradeIncNotificationPanel { private JPanel labelsPanel; - @Override protected JPanel getMessagePanel() { this.labelsPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); @@ -34,7 +34,7 @@ protected JPanel getMessagePanel() { JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.FRAME, TooltipConstants.OPEN_CHAT); openChatButton.addActionListener(e -> controller.performOpenChat()); - JButton stillInterestedButton = getStillInterestedButton(); + JButton stillInterestedButton = this.getStillInterestedButton(); JPanel buttons = this.componentsFactory.getJPanel(new GridLayout(1, 0, 5, 0), AppThemeColor.FRAME); buttons.add(stillInterestedButton); buttons.add(openChatButton); @@ -45,6 +45,10 @@ protected JPanel getMessagePanel() { if (offerLabel != null) { 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); this.labelsPanel.add(buttons, BorderLayout.LINE_END); return labelsPanel; 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 new file mode 100644 index 00000000..edb56c6f --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeOutNotificationPanel.java @@ -0,0 +1,44 @@ +package com.mercury.platform.ui.components.panel.notification; + +import com.mercury.platform.shared.config.descriptor.HotKeyType; +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.*; + + +public class ItemTradeOutNotificationPanel extends TradeOutNotificationPanel { + @Override + protected JPanel getMessagePanel() { + JPanel labelsPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); + + JLabel itemLabel = componentsFactory.getTextLabel( + this.data.getItemName(), + FontStyle.BOLD, + AppThemeColor.TEXT_IMPORTANT, 16f); + + JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.FRAME, TooltipConstants.OPEN_CHAT); + openChatButton.addActionListener(e -> controller.performOpenChat()); + JButton repeatButton = this.getRepeatButton(); + JPanel buttons = this.componentsFactory.getJPanel(new GridLayout(1, 0, 5, 0), AppThemeColor.FRAME); + buttons.add(repeatButton); + buttons.add(openChatButton); + + JPanel miscPanel = this.componentsFactory.getJPanel(new GridLayout(1, 0, 4, 0), AppThemeColor.FRAME); + miscPanel.add(itemLabel); + JLabel offerLabel = this.getOfferLabel(); + 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); + labelsPanel.add(buttons, BorderLayout.LINE_END); + return labelsPanel; + } +} 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 76e74c2a..49a0008f 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 @@ -2,8 +2,13 @@ import com.mercury.platform.shared.AsSubscriber; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; import com.mercury.platform.shared.config.descriptor.HotKeyType; +import com.mercury.platform.shared.config.descriptor.HotKeysSettingsDescriptor; +import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor; +import com.mercury.platform.shared.entity.message.FlowDirections; import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; @@ -24,6 +29,8 @@ import java.util.Map; public abstract class NotificationPanel extends JPanel implements AsSubscriber, ViewInit, ViewDestroy { + protected PlainConfigurationService notificationConfig; + protected PlainConfigurationService hotKeysConfig; @Setter @Getter protected T data; @@ -38,8 +45,6 @@ public abstract class NotificationPanel extends JPanel implements AsSubscr protected boolean blurReverse; @Setter protected boolean duplicate; - protected JPanel chatPanel; - protected JPanel chatContainer; protected JPanel contentPanel; @Setter private float paintAlphaValue = 1f; @@ -52,6 +57,8 @@ public void onViewInit() { this.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(1, 1, 1, 1), BorderFactory.createLineBorder(AppThemeColor.MSG_HEADER_BORDER, 1))); + this.notificationConfig = Configuration.get().notificationConfiguration(); + this.hotKeysConfig = Configuration.get().hotKeysConfiguration(); } public void setComponentsFactory(ComponentsFactory factory) { @@ -119,7 +126,7 @@ public void actionPerformed(ActionEvent e) { } protected JButton getExpandButton() { - String iconPath = "app/expand-mp.png"; + String iconPath = this.notificationConfig.get().getFlowDirections().equals(FlowDirections.UPWARDS) ? "app/collapse-mp.png" : "app/expand-mp.png"; JButton expandButton = componentsFactory.getIconButton(iconPath, 18f, AppThemeColor.MSG_HEADER, ""); expandButton.addActionListener(action -> { NotificationFrame frame = (NotificationFrame) SwingUtilities.getWindowAncestor(NotificationPanel.this); @@ -129,7 +136,7 @@ protected JButton getExpandButton() { frame.changeBufferSize(this.contentPanel.getPreferredSize().height); } else { this.contentPanel.setVisible(true); - expandButton.setIcon(this.componentsFactory.getIcon("app/expand-mp.png", 18f)); + expandButton.setIcon(this.componentsFactory.getIcon(iconPath, 18f)); frame.changeBufferSize(-this.contentPanel.getPreferredSize().height); } frame.pack(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java deleted file mode 100644 index a3871cbd..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/OutgoingNotificationPanel.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.mercury.platform.ui.components.panel.notification; - -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.*; -import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.components.panel.notification.controller.OutgoingPanelController; -import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.TooltipConstants; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -public abstract class OutgoingNotificationPanel extends NotificationPanel { - private PlainConfigurationService config; - private PlainConfigurationService hotKeysConfig; - private JPanel responseButtonsPanel; - - @Override - public void onViewInit() { - super.onViewInit(); - this.config = Configuration.get().notificationConfiguration(); - this.hotKeysConfig = Configuration.get().hotKeysConfiguration(); - this.add(this.getHeader(), BorderLayout.PAGE_START); - - this.responseButtonsPanel = new JPanel(new GridLayout(1, 0, 0, 5)); - this.responseButtonsPanel.setBackground(AppThemeColor.FRAME); - this.contentPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); - this.contentPanel.add(this.getContentPanel(), BorderLayout.CENTER); - this.contentPanel.add(this.componentsFactory.wrapToSlide(this.responseButtonsPanel, AppThemeColor.FRAME), BorderLayout.LINE_END); - this.add(contentPanel, BorderLayout.CENTER); - this.updateHotKeyPool(); - } - - private JPanel getHeader() { - JPanel root = new JPanel(new BorderLayout()); - root.setBackground(AppThemeColor.MSG_HEADER); - - JPanel nickNamePanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.MSG_HEADER); - JLabel nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP, 15f, this.data.getWhisperNickname()); - nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); - nickNamePanel.add(this.getExpandButton(), BorderLayout.LINE_START); - nickNamePanel.add(nicknameLabel, BorderLayout.CENTER); - root.add(nickNamePanel, BorderLayout.CENTER); - - JPanel interactionPanel = new JPanel(new GridLayout(1, 0, 6, 0)); - interactionPanel.setBackground(AppThemeColor.MSG_HEADER); - JButton visiteHideout = componentsFactory.getIconButton("app/visiteHideout.png", 17, 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); - leaveButton.addActionListener(e -> { - this.controller.performLeave(this.config.get().getPlayerNickname()); - if (this.config.get().isDismissAfterLeave()) { - this.controller.performHide(); - } - }); -// JButton backToHo = componentsFactory.getIconButton("app/backToHideout.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.OPEN_CHAT); -// backToHo.addActionListener(e -> controller.backToHideout()); - 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(); - }); - interactionPanel.add(visiteHideout); - interactionPanel.add(tradeButton); - interactionPanel.add(leaveButton); -// interactionPanel.add(backToHo); - 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_BACK_TO_HIDEOUT,backToHo); - this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT, openChatButton); - this.interactButtonMap.put(HotKeyType.N_CLOSE_NOTIFICATION, hideButton); - - root.add(interactionPanel, BorderLayout.LINE_END); - return root; - } - - @Override - protected void updateHotKeyPool() { - this.hotKeysPool.clear(); - this.interactButtonMap.forEach((type, button) -> { - HotKeyPair hotKeyPair = this.hotKeysConfig.get() - .getOutNHotKeysList() - .stream() - .filter(it -> it.getType().equals(type)) - .findAny().orElse(null); - if (!hotKeyPair.getDescriptor().getTitle().equals("...")) { - this.hotKeysPool.put(hotKeyPair.getDescriptor(), button); - } - }); - this.initResponseButtonPanel(); - Window windowAncestor = SwingUtilities.getWindowAncestor(OutgoingNotificationPanel.this); - if (windowAncestor != null) { - windowAncestor.pack(); - } - } - - private void initResponseButtonPanel() { - this.responseButtonsPanel.removeAll(); - List buttonsConfig = this.config.get().getOutButtons(); - Collections.sort(buttonsConfig); - buttonsConfig.forEach((buttonConfig) -> { - JButton button = componentsFactory.getBorderedButton(buttonConfig.getTitle(), 16f, AppThemeColor.RESPONSE_BUTTON, AppThemeColor.RESPONSE_BUTTON_BORDER, AppThemeColor.RESPONSE_BUTTON); - button.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - button.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1), - BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON, 3) - )); - } - - @Override - public void mouseExited(MouseEvent e) { - button.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1), - BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON, 3) - )); - } - }); - button.addActionListener(action -> { - button.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1), - BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON, 3) - )); - }); - button.addActionListener(e -> { - this.controller.performResponse(buttonConfig.getResponseText()); - if (buttonConfig.isClose()) { - this.controller.performHide(); - } - }); - this.responseButtonsPanel.add(button); - this.hotKeysPool.put(buttonConfig.getHotKeyDescriptor(), button); - }); - } - - protected JPanel getFromPanel() { - JPanel forPanel = new JPanel(new BorderLayout()); - forPanel.setBackground(AppThemeColor.FRAME); - JPanel currencyPanel = this.getCurrencyPanel(this.data.getCurCount(), this.data.getCurrency()); - if (currencyPanel != null) { - currencyPanel.setPreferredSize(new Dimension(70, 36)); - forPanel.add(currencyPanel, BorderLayout.LINE_START); - } - JLabel separator = componentsFactory.getTextLabel( - FontStyle.BOLD, - AppThemeColor.TEXT_DEFAULT, - TextAlignment.CENTER, - 18f, - "=>"); - forPanel.add(separator, BorderLayout.CENTER); - separator.setHorizontalAlignment(SwingConstants.CENTER); - return forPanel; - } - - protected JPanel getCurrencyPanel(Double curCount, String curIconPath) { - String curCountStr = " "; - if (curCount > 0) { - curCountStr = curCount % 1 == 0 ? - String.valueOf(curCount.intValue()) : - String.valueOf(curCount); - } - if (!Objects.equals(curCountStr, "") && curIconPath != null) { - JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + curIconPath + ".png", 28); - JPanel curPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - curPanel.setBackground(AppThemeColor.FRAME); - curPanel.add(this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, null, curCountStr)); - curPanel.add(currencyLabel); - return curPanel; - } - return null; - } - - @Override - public void subscribe() { - super.subscribe(); - } - - protected abstract JPanel getContentPanel(); - - @Override - public void onViewDestroy() { - super.onViewDestroy(); - } -} 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 d286dc60..1460d866 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 @@ -2,7 +2,9 @@ import com.mercury.platform.shared.config.Configuration; import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.*; +import com.mercury.platform.shared.config.descriptor.HotKeyPair; +import com.mercury.platform.shared.config.descriptor.HotKeyType; +import com.mercury.platform.shared.config.descriptor.ScannerDescriptor; import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; @@ -16,21 +18,26 @@ public class ScannerNotificationPanel extends NotificationPanel { private PlainConfigurationService config; - private PlainConfigurationService nConfig; - private PlainConfigurationService hotKeysConfig; @Override public void onViewInit() { super.onViewInit(); this.config = Configuration.get().scannerConfiguration(); - this.nConfig = Configuration.get().notificationConfiguration(); - this.hotKeysConfig = Configuration.get().hotKeysConfiguration(); - this.add(this.getHeader(), BorderLayout.PAGE_START); JLabel sourceLabel = this.componentsFactory.getTextLabel(this.data.getMessage(), FontStyle.REGULAR, 17f); sourceLabel.setBackground(AppThemeColor.FRAME); sourceLabel.setHorizontalAlignment(SwingConstants.LEFT); sourceLabel.setVerticalAlignment(SwingConstants.TOP); this.contentPanel = this.componentsFactory.wrapToSlide(sourceLabel, AppThemeColor.FRAME, 2, 2, 2, 2); + switch (this.notificationConfig.get().getFlowDirections()) { + case DOWNWARDS: { + this.add(this.getHeader(), BorderLayout.PAGE_START); + break; + } + case UPWARDS: { + this.add(this.getHeader(), BorderLayout.PAGE_END); + break; + } + } this.add(this.contentPanel, BorderLayout.CENTER); this.updateHotKeyPool(); } @@ -56,8 +63,8 @@ private JPanel getHeader() { tradeButton.addActionListener(e -> this.controller.performOfferTrade()); JButton leaveButton = componentsFactory.getIconButton("app/leave.png", 17, AppThemeColor.MSG_HEADER, TooltipConstants.LEAVE); leaveButton.addActionListener(e -> { - this.controller.performLeave(this.nConfig.get().getPlayerNickname()); - if (this.nConfig.get().isDismissAfterLeave()) { + this.controller.performLeave(this.notificationConfig.get().getPlayerNickname()); + if (this.notificationConfig.get().isDismissAfterLeave()) { this.controller.performHide(); } }); @@ -71,7 +78,6 @@ private JPanel getHeader() { interactionPanel.add(visiteHideout); interactionPanel.add(tradeButton); interactionPanel.add(leaveButton); -// interactionPanel.add(backToHo); interactionPanel.add(openChatButton); interactionPanel.add(hideButton); @@ -80,7 +86,6 @@ private JPanel getHeader() { 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_BACK_TO_HIDEOUT,backToHo); this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT, openChatButton); this.interactButtonMap.put(HotKeyType.N_CLOSE_NOTIFICATION, hideButton); 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 new file mode 100644 index 00000000..21e824d8 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeIncNotificationPanel.java @@ -0,0 +1,123 @@ +package com.mercury.platform.ui.components.panel.notification; + +import com.mercury.platform.shared.config.descriptor.HotKeyPair; +import com.mercury.platform.shared.config.descriptor.HotKeyType; +import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; +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.components.panel.notification.controller.IncomingPanelController; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.TooltipConstants; +import rx.Subscription; + +import javax.swing.*; +import java.awt.*; + + +public abstract class TradeIncNotificationPanel extends TradeNotificationPanel { + private JLabel nicknameLabel; + private Subscription playerJoinSubscription; + private Subscription playerLeaveSubscription; + + protected JPanel getHeader() { + JPanel root = new JPanel(new BorderLayout()); + root.setBackground(AppThemeColor.MSG_HEADER); + root.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); + + JPanel nickNamePanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.MSG_HEADER); + this.nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP, 15f, this.getNicknameText()); + nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 5)); + nickNamePanel.add(this.getExpandButton(), BorderLayout.LINE_START); + nickNamePanel.add(this.nicknameLabel, BorderLayout.CENTER); + nickNamePanel.add(this.getForPanel("app/incoming_arrow.png"), BorderLayout.LINE_END); + root.add(nickNamePanel, BorderLayout.CENTER); + + JPanel opPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.MSG_HEADER); + JPanel interactionPanel = new JPanel(new GridLayout(1, 0, 4, 0)); + interactionPanel.setBackground(AppThemeColor.MSG_HEADER); + JButton inviteButton = componentsFactory.getIconButton("app/invite.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE); + inviteButton.addActionListener(e -> { + this.controller.performInvite(); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.HEADER_SELECTED_BORDER)); + }); + JButton kickButton = componentsFactory.getIconButton("app/kick.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.KICK); + kickButton.addActionListener(e -> { + this.controller.performKick(); + if (this.notificationConfig.get().isDismissAfterKick()) { + this.controller.performHide(); + } + }); + JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE); + tradeButton.addActionListener(e -> { + this.controller.performOfferTrade(); + }); + JLabel historyLabel = this.getHistoryButton(); + JButton hideButton = componentsFactory.getIconButton("app/close.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); + hideButton.addActionListener(action -> { + this.controller.performHide(); + }); + interactionPanel.add(inviteButton); + interactionPanel.add(tradeButton); + interactionPanel.add(kickButton); + interactionPanel.add(historyLabel); + 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_CLOSE_NOTIFICATION, hideButton); + + JPanel timePanel = this.getTimePanel(); + opPanel.add(timePanel, BorderLayout.CENTER); + opPanel.add(interactionPanel, BorderLayout.LINE_END); + + root.add(opPanel, BorderLayout.LINE_END); + return root; + } + + @Override + public void subscribe() { + super.subscribe(); + this.playerJoinSubscription = MercuryStoreCore.playerJoinSubject.subscribe(nickname -> { + if (this.data.getWhisperNickname().equals(nickname)) { + this.nicknameLabel.setForeground(AppThemeColor.TEXT_SUCCESS); + } + }); + this.playerLeaveSubscription = MercuryStoreCore.playerLeftSubject.subscribe(nickname -> { + if (this.data.getWhisperNickname().equals(nickname)) { + this.nicknameLabel.setForeground(AppThemeColor.TEXT_DISABLE); + } + }); + } + + @Override + public void onViewDestroy() { + super.onViewDestroy(); + this.playerLeaveSubscription.unsubscribe(); + this.playerJoinSubscription.unsubscribe(); + } + + protected abstract JButton getStillInterestedButton(); + + @Override + protected void updateHotKeyPool() { + this.hotKeysPool.clear(); + this.interactButtonMap.forEach((type, button) -> { + HotKeyPair hotKeyPair = this.hotKeysConfig.get() + .getIncNHotKeysList() + .stream() + .filter(it -> it.getType().equals(type)) + .findAny().orElse(null); + if (!hotKeyPair.getDescriptor().getTitle().equals("...")) { + this.hotKeysPool.put(hotKeyPair.getDescriptor(), button); + } + }); + this.initResponseButtonsPanel(this.notificationConfig.get().getButtons()); + Window windowAncestor = SwingUtilities.getWindowAncestor(TradeIncNotificationPanel.this); + if (windowAncestor != null) { + windowAncestor.pack(); + } + } +} 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 new file mode 100644 index 00000000..2845d89f --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeNotificationPanel.java @@ -0,0 +1,207 @@ +package com.mercury.platform.ui.components.panel.notification; + + +import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; +import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; +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.components.panel.notification.controller.NotificationController; +import com.mercury.platform.ui.frame.other.ChatHistoryDefinition; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; +import rx.Subscription; + +import javax.swing.*; +import javax.swing.border.Border; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +public abstract class TradeNotificationPanel extends NotificationPanel { + protected JPanel responseButtonsPanel; + private Subscription chatSubscription; + + @Override + public void onViewInit() { + super.onViewInit(); + this.responseButtonsPanel = this.componentsFactory.getJPanel(new FlowLayout(FlowLayout.CENTER, 5, 2), AppThemeColor.FRAME); + this.contentPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME); + switch (notificationConfig.get().getFlowDirections()) { + case DOWNWARDS: { + this.add(this.getHeader(), BorderLayout.PAGE_START); + this.contentPanel.add(this.responseButtonsPanel, BorderLayout.PAGE_END); + break; + } + case UPWARDS: { + this.add(this.getHeader(), BorderLayout.PAGE_END); + this.contentPanel.add(this.responseButtonsPanel, BorderLayout.PAGE_START); + break; + } + } + this.contentPanel.add(this.getMessagePanel(), BorderLayout.CENTER); + this.add(this.contentPanel, BorderLayout.CENTER); + this.updateHotKeyPool(); + } + + protected abstract JPanel getHeader(); + + protected abstract JPanel getMessagePanel(); + + protected void initResponseButtonsPanel(List buttonsConfig) { + this.responseButtonsPanel.removeAll(); + Collections.sort(buttonsConfig); + buttonsConfig.forEach((buttonConfig) -> { + JButton button = componentsFactory.getBorderedButton(buttonConfig.getTitle(), 16f, AppThemeColor.RESPONSE_BUTTON, AppThemeColor.RESPONSE_BUTTON_BORDER, AppThemeColor.RESPONSE_BUTTON); + button.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1), + BorderFactory.createMatteBorder(3, 9, 3, 9, AppThemeColor.RESPONSE_BUTTON) + )); + button.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + button.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1), + BorderFactory.createMatteBorder(3, 9, 3, 9, AppThemeColor.RESPONSE_BUTTON) + )); + } + + @Override + public void mouseExited(MouseEvent e) { + button.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.RESPONSE_BUTTON_BORDER, 1), + BorderFactory.createMatteBorder(3, 9, 3, 9, AppThemeColor.RESPONSE_BUTTON) + )); + } + }); + button.addActionListener(action -> { + button.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1), + BorderFactory.createMatteBorder(3, 9, 3, 9, AppThemeColor.RESPONSE_BUTTON) + )); + }); + button.addActionListener(e -> { + this.controller.performResponse(buttonConfig.getResponseText()); + if (buttonConfig.isClose()) { + this.controller.performHide(); + } + }); + this.hotKeysPool.put(buttonConfig.getHotKeyDescriptor(), button); + this.responseButtonsPanel.add(button); + }); + } + + @Override + public void subscribe() { + super.subscribe(); + this.chatSubscription = MercuryStoreCore.plainMessageSubject.subscribe(message -> { + if (this.data.getWhisperNickname().equals(message.getNickName())) { + this.data.getRelatedMessages().add(message); + } + }); + } + + @Override + public void onViewDestroy() { + super.onViewDestroy(); + this.chatSubscription.unsubscribe(); + } + + protected JLabel getHistoryButton() { + JLabel chatHistory = componentsFactory.getIconLabel("app/chat_history.png", 15); + chatHistory.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); + chatHistory.addMouseListener(new MouseAdapter() { + Border prevBorder; + + @Override + public void mouseEntered(MouseEvent e) { + prevBorder = chatHistory.getBorder(); + chatHistory.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER), + BorderFactory.createEmptyBorder(3, 3, 3, 3))); + chatHistory.setCursor(new Cursor(Cursor.HAND_CURSOR)); + MercuryStoreUI.showChatHistorySubject.onNext(new ChatHistoryDefinition(data.getRelatedMessages(), e.getLocationOnScreen())); + } + + @Override + public void mouseExited(MouseEvent e) { + chatHistory.setBorder(prevBorder); + chatHistory.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + MercuryStoreUI.hideChatHistorySubject.onNext(true); + } + }); + return chatHistory; + } + + protected JPanel getForPanel(String signIconPath) { + JPanel forPanel = new JPanel(new BorderLayout()); + forPanel.setBackground(AppThemeColor.MSG_HEADER); + JLabel separator = componentsFactory.getIconLabel(signIconPath, 16); + forPanel.add(separator, BorderLayout.CENTER); + separator.setHorizontalAlignment(SwingConstants.CENTER); + JPanel currencyPanel = this.getCurrencyPanel(this.data.getCurCount(), this.data.getCurrency()); + if (currencyPanel != null) { + forPanel.add(currencyPanel, BorderLayout.LINE_END); + } + return forPanel; + } + + protected JPanel getCurrencyPanel(Double curCount, String curIconPath) { + String curCountStr = " "; + if (curCount > 0) { + curCountStr = curCount % 1 == 0 ? + String.valueOf(curCount.intValue()) : + String.valueOf(curCount); + } + 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.setBackground(AppThemeColor.MSG_HEADER); + JLabel countLabel = this.componentsFactory.getTextLabel(curCountStr, FontStyle.BOLD, 17f); + countLabel.setHorizontalAlignment(SwingConstants.RIGHT); + curPanel.add(countLabel, BorderLayout.CENTER); + curPanel.add(currencyLabel, BorderLayout.LINE_END); + return curPanel; + } + return null; + } + + protected JLabel getOfferLabel() { + String offer = this.data.getOffer(); + if (offer != null && offer.trim().length() > 0) { + JLabel offerLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 16f, offer); + offerLabel.setHorizontalAlignment(SwingConstants.CENTER); + return offerLabel; + } + return null; + } + + protected String getNicknameText() { + String whisperNickname = data.getWhisperNickname(); + String result = whisperNickname + ":"; + if (this.notificationConfig.get().isShowLeague()) { + if (data.getLeague() != null) { + String league = data.getLeague().trim(); + if (league.length() == 0) { + return result; + } + if (league.contains("Hardcore")) { + if (league.equals("Hardcore")) { + result = "HC " + result; + } else { + result = String.valueOf(league.split(" ")[1].charAt(0)) + "HC " + result; + } + } else if (league.contains("Standard")) { + result = "Standard " + result; + } else { + result = String.valueOf(league.charAt(0)) + "SC " + result; + } + } + } + return result; + } +} 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 new file mode 100644 index 00000000..2cac4834 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeOutNotificationPanel.java @@ -0,0 +1,123 @@ +package com.mercury.platform.ui.components.panel.notification; + +import com.mercury.platform.shared.config.descriptor.HotKeyPair; +import com.mercury.platform.shared.config.descriptor.HotKeyType; +import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; +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.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.*; +import java.awt.*; + + +public abstract class TradeOutNotificationPanel extends TradeNotificationPanel { + private JLabel nicknameLabel; + private Subscription playerJoinSubscription; + private Subscription playerLeaveSubscription; + + @Override + protected JPanel getHeader() { + JPanel root = new JPanel(new BorderLayout()); + root.setBackground(AppThemeColor.MSG_HEADER); + + JPanel nickNamePanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.MSG_HEADER); + this.nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP, 15f, this.data.getWhisperNickname()); + nickNamePanel.add(this.getExpandButton(), BorderLayout.LINE_START); + nickNamePanel.add(this.nicknameLabel, BorderLayout.CENTER); + nickNamePanel.add(this.getForPanel("app/outgoing_arrow.png"), BorderLayout.LINE_END); + root.add(nickNamePanel, BorderLayout.CENTER); + + JPanel opPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.MSG_HEADER); + JPanel interactionPanel = new JPanel(new GridLayout(1, 0, 3, 0)); + interactionPanel.setBackground(AppThemeColor.MSG_HEADER); + 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", 16, AppThemeColor.MSG_HEADER, TooltipConstants.LEAVE); + leaveButton.addActionListener(e -> { + this.controller.performLeave(this.notificationConfig.get().getPlayerNickname()); + if (this.notificationConfig.get().isDismissAfterLeave()) { + this.controller.performHide(); + } + }); + JLabel historyLabel = this.getHistoryButton(); + JButton hideButton = componentsFactory.getIconButton("app/close.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.HIDE_PANEL); + hideButton.addActionListener(action -> { + this.controller.performHide(); + }); + interactionPanel.add(visiteHideout); + interactionPanel.add(tradeButton); + interactionPanel.add(leaveButton); + interactionPanel.add(historyLabel); + 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_CLOSE_NOTIFICATION, hideButton); + + JPanel timePanel = this.getTimePanel(); + opPanel.add(timePanel, BorderLayout.CENTER); + opPanel.add(interactionPanel, BorderLayout.LINE_END); + + root.add(opPanel, BorderLayout.LINE_END); + return root; + } + + @Override + public void subscribe() { + super.subscribe(); + this.playerJoinSubscription = MercuryStoreCore.playerJoinSubject.subscribe(nickname -> { + if (this.data.getWhisperNickname().equals(nickname)) { + this.nicknameLabel.setForeground(AppThemeColor.TEXT_SUCCESS); + } + }); + this.playerLeaveSubscription = MercuryStoreCore.playerLeftSubject.subscribe(nickname -> { + if (this.data.getWhisperNickname().equals(nickname)) { + this.nicknameLabel.setForeground(AppThemeColor.TEXT_DISABLE); + } + }); + } + + @Override + public void onViewDestroy() { + super.onViewDestroy(); + this.playerLeaveSubscription.unsubscribe(); + this.playerJoinSubscription.unsubscribe(); + } + + protected JButton getRepeatButton() { + JButton repeatButton = componentsFactory.getIconButton("app/reload-history.png", 15, AppThemeColor.FRAME, TooltipConstants.STILL_INTERESTED); + repeatButton.addActionListener(action -> { + this.controller.performResponse(StringUtils.substringAfter(this.data.getSourceString(), ":")); + }); + return repeatButton; + } + + @Override + protected void updateHotKeyPool() { + this.hotKeysPool.clear(); + this.interactButtonMap.forEach((type, button) -> { + HotKeyPair hotKeyPair = this.hotKeysConfig.get() + .getOutNHotKeysList() + .stream() + .filter(it -> it.getType().equals(type)) + .findAny().orElse(null); + if (hotKeyPair != null && !hotKeyPair.getDescriptor().getTitle().equals("...")) { + this.hotKeysPool.put(hotKeyPair.getDescriptor(), button); + } + }); + this.initResponseButtonsPanel(this.notificationConfig.get().getOutButtons()); + Window windowAncestor = SwingUtilities.getWindowAncestor(TradeOutNotificationPanel.this); + if (windowAncestor != null) { + windowAncestor.pack(); + } + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java index 9a98d31c..b5807278 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyIncPanelProvider.java @@ -2,7 +2,7 @@ import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationType; -import com.mercury.platform.ui.components.panel.notification.CurrencyIncNotificationPanel; +import com.mercury.platform.ui.components.panel.notification.CurrencyTradeIncNotificationPanel; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; import com.mercury.platform.ui.components.panel.notification.controller.NotificationIncomingController; @@ -15,7 +15,7 @@ public boolean isSuitable(NotificationType type) { @Override protected NotificationPanel getPanel() { - CurrencyIncNotificationPanel panel = new CurrencyIncNotificationPanel(); + CurrencyTradeIncNotificationPanel panel = new CurrencyTradeIncNotificationPanel(); panel.setController(new NotificationIncomingController(this.data)); return panel; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyOutPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyOutPanelProvider.java index 37995b7b..6a6eb20e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyOutPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/CurrencyOutPanelProvider.java @@ -2,7 +2,7 @@ import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationType; -import com.mercury.platform.ui.components.panel.notification.CurrencyOutNotificationPanel; +import com.mercury.platform.ui.components.panel.notification.CurrencyTradeOutNotificationPanel; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; import com.mercury.platform.ui.components.panel.notification.controller.NotificationOutgoingController; import com.mercury.platform.ui.components.panel.notification.controller.OutgoingPanelController; @@ -16,7 +16,7 @@ public boolean isSuitable(NotificationType type) { @Override protected NotificationPanel getPanel() { - CurrencyOutNotificationPanel panel = new CurrencyOutNotificationPanel(); + CurrencyTradeOutNotificationPanel panel = new CurrencyTradeOutNotificationPanel(); panel.setController(new NotificationOutgoingController(this.data)); return panel; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java index 4e626d52..81555bc8 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemIncPanelProvider.java @@ -2,7 +2,7 @@ import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationType; -import com.mercury.platform.ui.components.panel.notification.ItemIncNotificationPanel; +import com.mercury.platform.ui.components.panel.notification.ItemTradeIncNotificationPanel; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController; import com.mercury.platform.ui.components.panel.notification.controller.NotificationIncomingController; @@ -16,7 +16,7 @@ public boolean isSuitable(NotificationType type) { @Override protected NotificationPanel getPanel() { - ItemIncNotificationPanel panel = new ItemIncNotificationPanel(); + ItemTradeIncNotificationPanel panel = new ItemTradeIncNotificationPanel(); panel.setController(new NotificationIncomingController(this.data)); return panel; } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemOutPanelProvider.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemOutPanelProvider.java index 1163082a..70130035 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemOutPanelProvider.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/factory/ItemOutPanelProvider.java @@ -2,7 +2,7 @@ import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.shared.entity.message.NotificationType; -import com.mercury.platform.ui.components.panel.notification.ItemOutNotificationPanel; +import com.mercury.platform.ui.components.panel.notification.ItemTradeOutNotificationPanel; import com.mercury.platform.ui.components.panel.notification.NotificationPanel; import com.mercury.platform.ui.components.panel.notification.controller.NotificationOutgoingController; import com.mercury.platform.ui.components.panel.notification.controller.OutgoingPanelController; @@ -16,7 +16,7 @@ public boolean isSuitable(NotificationType type) { @Override protected NotificationPanel getPanel() { - ItemOutNotificationPanel panel = new ItemOutNotificationPanel(); + ItemTradeOutNotificationPanel panel = new ItemTradeOutNotificationPanel(); panel.setController(new NotificationOutgoingController(this.data)); return panel; } 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 1c2dc170..334f47d8 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 @@ -107,9 +107,6 @@ public void subscribe() { this.addNotification(notificationPanel); Timer packTimer = new Timer(5, action -> { this.pack(); - if (this.notificationPanels.size() > 1 && this.config.get().getFlowDirections().equals(FlowDirections.UPWARDS)) { - this.setLocation(new Point(this.getLocation().x, this.getLocation().y - notificationPanel.getSize().height)); - } }); packTimer.setRepeats(false); packTimer.start(); @@ -213,6 +210,9 @@ private void removeNotification(NotificationPanel notificationPanel) { this.root.remove(this.expandPanel); this.root.add(this.stubExpandPanel, BorderLayout.LINE_START); } + if (this.notificationPanels.size() == 0) { + this.buffer.setPreferredSize(new Dimension(10, BUFFER_DEFAULT_HEIGHT)); + } this.pack(); this.repaint(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/other/ChatHistoryDefinition.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/ChatHistoryDefinition.java new file mode 100644 index 00000000..0f94c710 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/ChatHistoryDefinition.java @@ -0,0 +1,15 @@ +package com.mercury.platform.ui.frame.other; + +import com.mercury.platform.shared.entity.message.PlainMessageDescriptor; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.awt.*; +import java.util.List; + +@Data +@AllArgsConstructor +public class ChatHistoryDefinition { + private List messages; + private Point location; +} 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 new file mode 100644 index 00000000..8a1a724f --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/other/ChatHistoryFrame.java @@ -0,0 +1,105 @@ +package com.mercury.platform.ui.frame.other; + + +import com.mercury.platform.ui.components.panel.VerticalScrollContainer; +import com.mercury.platform.ui.frame.AbstractOverlaidFrame; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class ChatHistoryFrame extends AbstractOverlaidFrame { + private VerticalScrollContainer chatContainer; + private Timer showTimer; + private Timer hideTimer; + + public ChatHistoryFrame() { + super(); + } + + @Override + protected void initialize() { + + } + + @Override + public void onViewInit() { + this.setBackground(AppThemeColor.TRANSPARENT); + this.setOpacity(this.applicationConfig.get().getMaxOpacity() / 100f); + + 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))); + root.add(this.getChatPanel(), BorderLayout.CENTER); + this.add(root, BorderLayout.CENTER); + this.pack(); + } + + private JComponent getChatPanel() { + this.chatContainer = new VerticalScrollContainer(); + this.chatContainer.setBackground(AppThemeColor.FRAME); + this.chatContainer.setLayout(new BoxLayout(this.chatContainer, BoxLayout.Y_AXIS)); + + this.chatContainer.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + hideTimer.stop(); + } + + @Override + public void mouseExited(MouseEvent e) { + hideChat(); + } + }); + + JScrollPane verticalContainer = this.componentsFactory.getVerticalContainer(this.chatContainer); + return verticalContainer; + } + + @Override + public void subscribe() { + MercuryStoreUI.showChatHistorySubject.subscribe(definition -> { + if (this.showTimer != null) { + this.showTimer.stop(); + } + if (this.hideTimer != null) { + this.hideTimer.stop(); + } + this.showTimer = new Timer(300, action -> { + this.setLocation(new Point(definition.getLocation().x + 10, definition.getLocation().y)); + this.chatContainer.removeAll(); + definition.getMessages().forEach(it -> { + this.chatContainer.add(this.componentsFactory.getTextLabel((it.isIncoming() ? "From: " : "To: ") + it.getMessage())); + }); + this.pack(); + this.setVisible(true); + }); + this.showTimer.setRepeats(false); + this.showTimer.start(); + }); + MercuryStoreUI.hideChatHistorySubject.subscribe(state -> { + this.hideChat(); + }); + } + + private void hideChat() { + this.showTimer.stop(); + this.hideTimer = new Timer(500, action -> { + this.setVisible(false); + }); + this.hideTimer.setRepeats(false); + this.hideTimer.start(); + } + + @Override + protected LayoutManager getFrameLayout() { + return new BorderLayout(); + } + + +} 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 cf931b6d..4b655dd8 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 @@ -3,7 +3,11 @@ import com.mercury.platform.core.update.core.holder.ApplicationHolder; import com.mercury.platform.shared.config.descriptor.FrameDescriptor; +import com.mercury.platform.shared.config.descriptor.adr.AdrComponentType; +import com.mercury.platform.shared.config.descriptor.adr.AdrDurationComponentDescriptor; +import com.mercury.platform.shared.config.descriptor.adr.AdrProgressBarDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; +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.manager.FramesManager; @@ -16,10 +20,10 @@ import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.net.URI; public class SettingsFrame extends AbstractTitledComponentFrame { private JPanel currentPanel; - private MenuPanel menuPanel; private JPanel root; public SettingsFrame() { @@ -29,7 +33,6 @@ public SettingsFrame() { this.setAlwaysOnTop(false); this.processingHideEvent = false; this.processHideEffect = false; -// FrameDescriptor frameDescriptor = this.framesConfig.get(this.getClass().getSimpleName()); this.setPreferredSize(new Dimension(1000, 600)); } @@ -42,9 +45,9 @@ protected void initialize() { @Override public void onViewInit() { this.root = new JPanel(new BorderLayout()); - this.menuPanel = new MenuPanel(); + MenuPanel menuPanel = new MenuPanel(); JPanel leftPanel = this.componentsFactory.getJPanel(new BorderLayout()); - leftPanel.add(this.menuPanel, BorderLayout.CENTER); + leftPanel.add(menuPanel, BorderLayout.CENTER); leftPanel.add(this.getOperationsButtons(), BorderLayout.PAGE_END); this.add(leftPanel, BorderLayout.LINE_START); this.add(this.root, BorderLayout.CENTER); @@ -73,6 +76,27 @@ private JPanel getBottomPanel() { JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); root.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, AppThemeColor.MSG_HEADER_BORDER)); root.setBackground(AppThemeColor.ADR_FOOTER_BG); + + AdrDurationComponentDescriptor donateDescriptor = new AdrProgressBarDescriptor(); + donateDescriptor.setIconEnable(false); + donateDescriptor.setDuration(10d); + donateDescriptor.setSize(new Dimension(100, 20)); + donateDescriptor.setType(AdrComponentType.PROGRESS_BAR); + donateDescriptor.setCustomTextEnable(true); + donateDescriptor.setCustomText("5$/150$"); + donateDescriptor.setFontSize(21); + donateDescriptor.setLowValueTextColor(AppThemeColor.TEXT_DEFAULT); + donateDescriptor.setMediumValueTextColor(AppThemeColor.TEXT_DEFAULT); + donateDescriptor.setDefaultValueTextColor(AppThemeColor.TEXT_DEFAULT); + donateDescriptor.setBorderColor(AppThemeColor.ADR_DEFAULT_BORDER); + donateDescriptor.setBackgroundColor(AppThemeColor.FRAME); + donateDescriptor.setForegroundColor(AppThemeColor.BUTTON); + MercuryTracker tracker = new MercuryTracker(donateDescriptor); + float percent = 150 * (5 / 100f); + tracker.setValue((int) (percent * 100)); + tracker.setPreferredSize(donateDescriptor.getSize()); + root.add(this.componentsFactory.getTextLabel("Monthly donations:", FontStyle.BOLD, 16), BorderLayout.LINE_START); + root.add(this.componentsFactory.wrapToSlide(tracker, AppThemeColor.ADR_FOOTER_BG, 2, 2, 2, 1), BorderLayout.CENTER); root.add(this.getSaveButtonPanel(), BorderLayout.LINE_END); return root; } @@ -96,8 +120,20 @@ private JPanel getSaveButtonPanel() { this.hideComponent(); MercuryStoreUI.settingsRestoreSubject.onNext(true); }); + JButton donate = componentsFactory.getIconButton("app/paypal.png", 70f, AppThemeColor.ADR_FOOTER_BG, "Donate"); + donate.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + try { + Desktop.getDesktop().browse(new URI("https://www.paypal.me/mercurytrade")); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + }); saveButton.setPreferredSize(new Dimension(110, 26)); cancelButton.setPreferredSize(new Dimension(110, 26)); + root.add(this.componentsFactory.wrapToSlide(donate, AppThemeColor.HEADER, 0, 2, 0, 2)); root.add(this.componentsFactory.wrapToSlide(cancelButton, AppThemeColor.HEADER, 2, 2, 2, 2)); root.add(this.componentsFactory.wrapToSlide(saveButton, AppThemeColor.HEADER, 2, 2, 2, 2)); return root; 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 bec85d61..6d8ad1b4 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.shared.entity.message.NotificationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.misc.AppThemeColor; @@ -95,8 +96,29 @@ private JPanel getTestCasesPanel() { JLabel chatScannerLabel = componentsFactory.getTextLabel("Random chat scanner message"); testPanel.add(chatScannerLabel, titleColumn); titleColumn.gridy++; - testPanel.setBackground(AppThemeColor.TRANSPARENT); + JButton accessibilityStatusButton = componentsFactory.getBorderedButton("Click"); + accessibilityStatusButton.addActionListener(action -> { + NotificationDescriptor randomItemIncMessage = this.testEngine.getRandomItemIncMessage(); + MercuryStoreCore.newNotificationSubject.onNext(randomItemIncMessage); + Timer timer = new Timer(1000, event -> { + MercuryStoreCore.playerJoinSubject.onNext(randomItemIncMessage.getWhisperNickname()); + }); + Timer timer2 = new Timer(2000, event -> { + MercuryStoreCore.playerLeftSubject.onNext(randomItemIncMessage.getWhisperNickname()); + }); + timer.setRepeats(false); + timer2.setRepeats(false); + timer.start(); + timer2.start(); + }); + testPanel.add(accessibilityStatusButton, buttonColumn); + buttonColumn.gridy++; + JLabel accessibilityStatusLabel = componentsFactory.getTextLabel("Accessibility status test"); + testPanel.add(accessibilityStatusLabel, titleColumn); + titleColumn.gridy++; + + testPanel.setBackground(AppThemeColor.TRANSPARENT); return testPanel; } 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 8a816e8f..23aa6c64 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 @@ -104,11 +104,11 @@ public TestEngine() { currency.add("xoph's breachstone"); currency.add("yriel's"); - nickNames.add("Example1"); + nickNames.add(" Example1"); nickNames.add("Example2"); - nickNames.add("Example3"); + nickNames.add(" Example3"); nickNames.add("Example4"); - nickNames.add("Example5"); + nickNames.add(" Example5"); nickNames.add("Example6"); offer.add("offer"); @@ -142,6 +142,7 @@ public NotificationDescriptor getRandomItemIncMessage() { random.nextInt(12) + 1, offer.get(random.nextInt(offer.size())) )); + notificationDescriptor.setRelatedMessages(this.getChatHistory()); return notificationDescriptor; } @@ -155,6 +156,7 @@ public NotificationDescriptor getRandomCurrencyIncMessage() { leagues.get(random.nextInt(leagues.size())), offer.get(random.nextInt(offer.size())) )); + notificationDescriptor.setRelatedMessages(this.getChatHistory()); return notificationDescriptor; } @@ -170,6 +172,7 @@ public NotificationDescriptor getRandomItemOutMessage() { random.nextInt(12) + 1, offer.get(random.nextInt(offer.size())) )); + notificationDescriptor.setRelatedMessages(this.getChatHistory()); notificationDescriptor.setType(NotificationType.OUT_ITEM_MESSAGE); return notificationDescriptor; } @@ -184,6 +187,7 @@ public NotificationDescriptor getRandomCurrencyOutMessage() { leagues.get(random.nextInt(leagues.size())), offer.get(random.nextInt(offer.size())) )); + notificationDescriptor.setRelatedMessages(this.getChatHistory()); notificationDescriptor.setType(NotificationType.OUT_CURRENCY_MESSAGE); return notificationDescriptor; } @@ -206,4 +210,44 @@ public PlainMessageDescriptor getRandomScannerMessage() { return descriptor; } + private List getChatHistory() { + List list = new ArrayList<>(); + PlainMessageDescriptor descriptor = new PlainMessageDescriptor(); + descriptor.setMessage("offer 1c"); + descriptor.setIncoming(true); + + PlainMessageDescriptor descriptor1 = new PlainMessageDescriptor(); + descriptor1.setMessage("nope"); + + PlainMessageDescriptor descriptor2 = new PlainMessageDescriptor(); + descriptor2.setMessage("offer 2c"); + descriptor2.setIncoming(true); + + PlainMessageDescriptor descriptor3 = new PlainMessageDescriptor(); + descriptor3.setMessage("nope"); + + PlainMessageDescriptor descriptor6 = new PlainMessageDescriptor(); + descriptor6.setMessage("wtf man"); + descriptor6.setIncoming(true); + + PlainMessageDescriptor descriptor7 = new PlainMessageDescriptor(); + descriptor7.setMessage("nope"); + + PlainMessageDescriptor descriptor4 = new PlainMessageDescriptor(); + descriptor4.setMessage("offer 100c"); + descriptor4.setIncoming(true); + + PlainMessageDescriptor descriptor5 = new PlainMessageDescriptor(); + descriptor5.setMessage("deal"); + list.add(descriptor); + list.add(descriptor1); + list.add(descriptor2); + list.add(descriptor3); + list.add(descriptor6); + list.add(descriptor7); + list.add(descriptor4); + list.add(descriptor5); + return list; + } + } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java index 2fa62141..0c226b4b 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java @@ -72,6 +72,7 @@ public void start() { this.framesMap.put(SettingsFrame.class, settingsFrame); this.framesMap.put(TestCasesFrame.class, new TestCasesFrame()); this.framesMap.put(TooltipFrame.class, new TooltipFrame()); + this.framesMap.put(ChatHistoryFrame.class, new ChatHistoryFrame()); this.framesMap.put(NotificationAlertFrame.class, new NotificationAlertFrame()); this.framesMap.put(MercuryLoadingFrame.class, new MercuryLoadingFrame()); this.framesMap.put(ChatScannerFrame.class, new ChatScannerFrame()); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java index 0df10659..0e857400 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/AppThemeColor.java @@ -27,9 +27,13 @@ public class AppThemeColor { public static final Color MSG_HEADER = new Color(52, 62, 61); public static final Color MSG_HEADER_BORDER = new Color(62, 73, 72); + public static final Color RESPONSE_BUTTON = new Color(70, 80, 79); public static final Color RESPONSE_BUTTON_BORDER = new Color(96, 106, 105); + public static final Color INC_PANEL_ARROW = new Color(111, 173, 39); + public static final Color OUT_PANEL_ARROW = new Color(0, 156, 222); + public static final Color ADR_SELECTED_BORDER = new Color(198, 193, 154); public static final Color ADR_POPUP_BG = new Color(212, 207, 171); public static final Color ADR_MOUSE_OVER_BORDER = new Color(155, 150, 120); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java index d7fba864..8a831068 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java @@ -10,6 +10,7 @@ import com.mercury.platform.ui.components.panel.grid.ItemInfoPanel; import com.mercury.platform.ui.components.panel.grid.TabInfoPanel; import com.mercury.platform.ui.dialog.DialogCallback; +import com.mercury.platform.ui.frame.other.ChatHistoryDefinition; import com.mercury.platform.ui.manager.routing.SettingsPage; import rx.subjects.PublishSubject; @@ -59,4 +60,7 @@ public class MercuryStoreUI { public static final PublishSubject settingsPostSubject = PublishSubject.create(); public static final PublishSubject onDestroySubject = PublishSubject.create(); + + public static final PublishSubject showChatHistorySubject = PublishSubject.create(); + public static final PublishSubject hideChatHistorySubject = PublishSubject.create(); } diff --git a/app-ui/src/main/resources/app/leave.png b/app-ui/src/main/resources/app/leave.png index 0a28e5a14c4d5aafabf1c0b30fdf03f3d669437c..1de6fc0ea5b3ebce6618493c613599ab16fcf833 100644 GIT binary patch delta 1651 zcmV-(28{Xf3bzd*iBL{Q4GJ0x0000DNk~Le0000t0000$2nGNE0KWY1Kan9>e+DN> zL_t(&L+x5yY!p=(J{S-Y1)@=rs8O^SXm~Oe6(cH|m}p4Rm>AO#qDeKzhz}Yg(g%&U znr`il-JRW;hgKwt26-?TeK3?*u`Ru9FWcSe%ua&_ye2$YkU|x|f9Di-cFu06-P!F- z(l7ZkXZBqF|C@8>od29zHm^{Of5qSpSzHM&;w5|t#US3vf+H{C+F@a2Y(JCKN~Evj zrF{lDbq9-TUo%;sfQXA0%Bc(BY2-KH{(4@+Cs2$s7SX=52oh0Fork~=kY2%SdK`*z zB@4#ivWUpXsHU-S;sIXU<4}ydF%fsP^p`dv*)-QVS~jlc zHGKj(1%Y}Sod3-(N|tJZs)Z;4#ijsZeguM zjc_~;$N#bj%BGx}K$$4gt9c6^gkszT?qQ*L8{V5Umz;Ob-Ml4_Krybu%vX-}>um_? zL@)fC<*;*x;wswOz+0Y2&=8W;DzDN|@)Aq4*!@!P}7L#)}On;w1HVJoygRGWbJUq^OJ&(&Q2xISi5Oxb-3< zpSVzb45He3ym%kde_aKMBhr2@IPxvhYq$qRME;(8o|mF>6fX{D)m(m9BT z<~F4z7C>5LTuh2V>wkPDU3Vs=himF(*4SGEJ4bMzXc16Nwe|z zaa_ehL?m&NN)K%bx8e-6C9>Mz1Qua&pN3*Qfr;Q8f39L7xhSV%SfID^Ry+zhRSC{* zBP;8@5cm+%i+O7vLu230^e_`S?}V~GjEUn(q-Qroiw+v^EioD53faTaCU?ktLsT*D z0tYP4W^y*7WxWpqA3@q9JvfuNaN-yi<5R*s5vd0i<6hqSJR{J(k%g0*&Bs}*3eT9ht}erIP)QCIJpZwBR-goYBb5vTDFXZ z64e-XwCLK)S?RL4aN^T+!;*Ryd$KWzqyLQbv*v*o*3@5x`)#;?7_={zim@+USH#vK ziXO~=0#V(F`W)ICvy`#ZWpRO@da?|dq?0IffBm9Qxo22IcPHY!THMpu&&NUfrj}b= zRQrlsFhS*I{aLh`Z};t@IK{XhJvQ5D{vvu|60zO@dirN!zR54RmCK+WG>-{#)pJ$c zu8fA=V^o`j@EUH#3R7UNK-)!ejlJ{_IgydVD5>M@@BASh?b?|A3`vgP#0JcBfEYOueUheme x;8}5QU_qQ;u^`T`SPte+002ovPDHLkV1f+98!7+* delta 1323 zcmV+`1=RYt4e<&giBL{Q4GJ0x0000DNk~Le00012000152nGNE0L@m)vXLQKe+1!4 zL_t(|UhSM~PZL2DhWFR_!GGef0;80h7udE?DjGFWq6txBG@1yAf>*RHRs?LC7>!1a z(HQlMAM~8gZrg3o&d%(1%3jW!yg7x=PG=s@&d$tku~@8NEjABt~D>Jw(3Y>W-E z7=t-`Nkz+A*POki7_LDvT!Uh`2E}jqwo{9x1TK00*N`;vx_6jI? z{w}}01d+2gPzXtHqB-M>1s7`J z)x9n#gRxz$K+ItFVyDZEqi_*wcz_Jr_!*gyo29drB3z_?c_5f_zV;1binF%^b*J6w zVR~-oI>eL##ts!;ow5qse?L5(Js79#;)WffJ34&Z)n^b>l)Z6+i!L{gIW0?p;s$r_ z^>2tN$=f#?)`cs^MLgyRyng3-Z;-Yt&mkrpunOFK?F*c) zQ}7zgiVla(cpWEx^`-`?e~L5=xM;ij0b=KmnkdB`uIu?X%McR=e>g1MnHTd!IkU#$ z38!j_fgBcYZf&injJ}I?yemP!Cv&m>v$gjj+K!GX>@aY#Gh#kUmDTYqjH%(D%5jae zmg&vQklCkOd(E+d9S*L_F)9{WHweI9_n&D8qJx6lz0HVmup99ShMTX=5M}f{`S6-k zn-BsPH!bP%dQLFhfARG@L>WDo_Hs^b9U)-+tmrGhgu+Dtc(ta>>DV6teukLWQpc${ zv2df0x59D&ZWb5oce{>Jb%x;$iJ;uj3fQ#m#!x{HW@qSsp_K1AHf8YL4uw9GIb6sU+jxAiZEHh&{ z6m`H1*JCl82)TKz(-(wE(7o;yrw#+?%e&m&L;#b zwQwo*e*(wV9WFw2p1&>DPdK#&D^qa&)D7LP&I0fi32=274A)29!0|f~xwQ>zY(?*X zE;3w$Vz>sya1Dy#8Wh7dD28iL4A-C-u0b(egJQS_#c&OZ;TjafH7JH_Pz=|gdN=23 ht8Zbl;wsDf56G1_ol&Q;>Hq)$07*qoM6N<$0fITPdszSg diff --git a/app-ui/src/main/resources/app/visiteHideout.png b/app-ui/src/main/resources/app/visiteHideout.png index a40a55c65ab163086ef31be8d85f153e49a36105..59931b6f12dc9e0bc335a2ef98e56204583b2552 100644 GIT binary patch delta 1031 zcmV+i1o->z1<(i~iBL{Q4GJ0x0000DNk~Le0000$0000$2nGNE0IF$m-jN|$e*?ft zL_t(|UhSH@PZUuUhk+$L0s*14Q+5|kd=wTMZGq0pjs)mXU|F!yibfOv0xi@Ah`dBA z3cO~dY>X4e#yDYYj1yI{iHF_oe=q@SFe%4+s$y0(0VuX({C;|h&##b^Pd)C?E)}t= z2r#~!ZqF>Hr?L;yzqI%*Dt_=R|HB`$uGPUYJI7l7ni zNA4xFT&?%c?=$FyI!(>9?OFhtjC=7c3A~U*s*U79KIibu5@A;Ye=tcSFD&QTkzYEK zs5X+1b^Qe_cK*NWPLc{t9$yN!!d-00t!3P)_k^d6W;hm!XbTsRuuyC2pBf z06Nuv?mAW{t)l$s@(D4ZO&U0Np#(;YfsYmLfzN1>|b^+*= zVD~)DZvSTI;QfTuCw1Z{3IcFY$B8~ptUEjJS4J07>pUj=e+mK&-aK@0c)Dw2zufbs zkUEE_lN-(zP!IA(C4ZxH<0cpbMwDA%sv}QtK>#ntfGn6MiYi%6-PNoBRsbu26`+y= zJOTOBw^yXUDUMenC%`-uzK0hx`U%qC6vr!801fAARsbu26~GE$1+W5G0raSZNx&Tw zl*1pjE!-^*cc~_jd8-*7$0&q{{hH4@P$Zw@1p@s3roGr-TCmrII^fq{Y7)59eQNQZzh2OE%-$rd;`Q8BWfDbCZyF{C2y?W{nr z!wwQH)uIb~w|}}C#Ur<{{X^`Ppoxp}msmtNWuezTvxw#VeM%V4Q{?qH|L)qJB>%M-~UaG(C+8;IsnHvwq z%gjDYG8A0cv~0uXjp=I@MIT`1~bmNl@4eZB4Zrtp#VtC+aC{||H%+C;U zN3awqb%UXSRaR59%xn)M1NT%;v9fxzXA9*|fJugoS2M_a%9aPY7e|9L@9Rpo^#DpPt|CQS@5I?4U^((hF~7rQ4{ zh)dNl+=-6tZUjpRdAT{A^w5w*QB6S5c+~~H{i?a%AM$ky^HX)%{?>h7snN9vf@C&F b{9(8%SFr8u)Fbl1WXIs?>gTe~DWM4feFh#f