diff --git a/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java b/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java index c67fe113..5d560e0f 100644 --- a/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java +++ b/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java @@ -1,7 +1,7 @@ package com.mercury.platform.core; public class MercuryConstants { - public static final String APP_VERSION = "1.0.1.6.1"; + public static final String APP_VERSION = "1.0.1.7.0"; public static final String SERVER_HOST = "exslims.ddns.net"; public static final int PORT = 5555; } diff --git a/app-core/src/main/java/com/mercury/platform/core/misc/WhisperNotifierStatus.java b/app-core/src/main/java/com/mercury/platform/core/misc/WhisperNotifierStatus.java index 7aaa2d52..415347b5 100644 --- a/app-core/src/main/java/com/mercury/platform/core/misc/WhisperNotifierStatus.java +++ b/app-core/src/main/java/com/mercury/platform/core/misc/WhisperNotifierStatus.java @@ -1,33 +1,32 @@ package com.mercury.platform.core.misc; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by Константин on 13.12.2016. - */ public enum WhisperNotifierStatus { - ALWAYS(0), - ALTAB(1), - NONE(2); - - private static final Map lookup - = new HashMap<>(); - static { - for (WhisperNotifierStatus w : EnumSet.allOf(WhisperNotifierStatus.class)){ - lookup.put(w.getCode(),w); + ALWAYS { + @Override + public String asPretty() { + return "Always play a sound"; } - } - private int code; - private WhisperNotifierStatus(int code){ - this.code = code; - } + }, + ALTAB { + @Override + public String asPretty() { + return "Only when tabbed out"; + } + }, + NONE { + @Override + public String asPretty() { + return "Never"; + } + }; - public int getCode() { - return code; - } - public static WhisperNotifierStatus get(int code){ - return lookup.get(code); + public abstract String asPretty(); + public static WhisperNotifierStatus valueOfPretty(String s){ + for (WhisperNotifierStatus status : WhisperNotifierStatus.values()) { + if(status.asPretty().equals(s)){ + return status; + } + } + return null; } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/KeyValueConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/KeyValueConfigurationService.java index 8a636727..b60dc798 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/KeyValueConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/KeyValueConfigurationService.java @@ -6,4 +6,5 @@ public interface KeyValueConfigurationService { T get(K key); Map getMap(); + void set(Map map); } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/PlainConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/PlainConfigurationService.java index 59a543b2..33f2e84a 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/PlainConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/PlainConfigurationService.java @@ -3,4 +3,5 @@ public interface PlainConfigurationService { T get(); + void set(T descriptor); } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ApplicationConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ApplicationConfigurationService.java index 6dd429b3..9814e580 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ApplicationConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ApplicationConfigurationService.java @@ -27,6 +27,11 @@ public ApplicationDescriptor get() { return this.selectedProfile.getApplicationDescriptor(); } + @Override + public void set(ApplicationDescriptor descriptor) { + this.selectedProfile.setApplicationDescriptor(descriptor); + } + @Override public ApplicationDescriptor getDefault() { ApplicationDescriptor descriptor = new ApplicationDescriptor(); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java index 110a4cbf..2264a062 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/FramesConfigurationServiceImpl.java @@ -40,6 +40,11 @@ public Map getMap() { return this.selectedProfile.getFrameDescriptorMap(); } + @Override + public void set(Map map) { + this.selectedProfile.setFrameDescriptorMap(map); + } + @Override public Map getDefault() { return defaultFramesSettings; @@ -77,7 +82,7 @@ private void initDefaultMap() { defaultFramesSettings.put("MessageFrame", new FrameDescriptor(new Point(700, 600), new Dimension(315, 0))); defaultFramesSettings.put("OutMessageFrame", new FrameDescriptor(new Point(200, 500), new Dimension(280, 115))); defaultFramesSettings.put("TestCasesFrame", new FrameDescriptor(new Point(1400, 500), new Dimension(400, 100))); - defaultFramesSettings.put("SettingsFrame", new FrameDescriptor(new Point(600, 600), new Dimension(600,400))); + defaultFramesSettings.put("SettingsFrame", new FrameDescriptor(new Point(600, 600), new Dimension(800,600))); defaultFramesSettings.put("HistoryFrame", new FrameDescriptor(new Point(600, 500), new Dimension(280, 400))); defaultFramesSettings.put("TimerFrame", new FrameDescriptor(new Point(400, 600), new Dimension(240, 102))); defaultFramesSettings.put("ChatFilterFrame", new FrameDescriptor(new Point(400, 600), new Dimension(500, 300))); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeysConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeysConfigurationService.java index 6389f0d2..46a9dccb 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeysConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/HotKeysConfigurationService.java @@ -8,6 +8,7 @@ import com.mercury.platform.shared.config.descriptor.ProfileDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import lc.kra.system.keyboard.event.GlobalKeyEvent; +import org.jnativehook.keyboard.NativeKeyEvent; import java.util.HashMap; import java.util.Map; @@ -20,16 +21,11 @@ public HotKeysConfigurationService(ProfileDescriptor selectedProfile) { @Override public Map getDefault() { Map keyMap = new HashMap<>(); - keyMap.put(HotKeyType.INVITE_PLAYER.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'1',true,false,false)); - keyMap.put(HotKeyType.TRADE_PLAYER.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_2,'2',true,false,false)); - keyMap.put(HotKeyType.KICK_PLAYER.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_3,'3',true,false,false)); - keyMap.put(HotKeyType.STILL_INTERESTING.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_4,'4',true,false,false)); - keyMap.put(HotKeyType.CLOSE_NOTIFICATION.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_5,'5',true,false,false)); - keyMap.put(HotKeyType.EXPAND_ALL.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'1',false,false,true)); - keyMap.put("button_1",new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'1',false,true,false)); - keyMap.put("button_2",new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'2',false,true,false)); - keyMap.put("button_3",new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'3',false,true,false)); - keyMap.put("button_4",new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'4',false,true,false)); + keyMap.put(HotKeyType.INVITE_PLAYER.name(),new HotKeyDescriptor("Alt + 1", NativeKeyEvent.VC_1,'1',true,false,false)); + keyMap.put(HotKeyType.TRADE_PLAYER.name(),new HotKeyDescriptor("Alt + 2",NativeKeyEvent.VC_2,'2',true,false,false)); + keyMap.put(HotKeyType.KICK_PLAYER.name(),new HotKeyDescriptor("Alt + 3",NativeKeyEvent.VC_3,'3',true,false,false)); + keyMap.put(HotKeyType.STILL_INTERESTING.name(),new HotKeyDescriptor("Alt + 4",NativeKeyEvent.VC_4,'4',true,false,false)); + keyMap.put(HotKeyType.CLOSE_NOTIFICATION.name(),new HotKeyDescriptor("Alt + 5",NativeKeyEvent.VC_5,'5',true,false,false)); return keyMap; } @@ -52,10 +48,20 @@ public Map getMap() { return this.selectedProfile.getHotKeysDataMap(); } + @Override + public void set(Map map) { + this.selectedProfile.setHotKeysDataMap(map); + } + @Override public void validate() { if (this.selectedProfile.getHotKeysDataMap() == null){ this.selectedProfile.setHotKeysDataMap(this.getDefault()); } + this.getMap().values().forEach(it -> { + if(it.getTitle().equals("")){ + it.setTitle("..."); + } + }); } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java index a50dbd40..112c9370 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/NotificationConfigurationService.java @@ -2,6 +2,7 @@ import com.mercury.platform.shared.config.configration.BaseConfigurationService; import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; import com.mercury.platform.shared.config.descriptor.ProfileDescriptor; import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; @@ -20,10 +21,10 @@ public NotificationConfigurationService(ProfileDescriptor selectedProfile) { public NotificationDescriptor getDefault() { NotificationDescriptor notificationDescriptor = new NotificationDescriptor(); List defaultButtons = new ArrayList<>(); - defaultButtons.add(new ResponseButtonDescriptor(0,false,false,"1m","one minute")); - defaultButtons.add(new ResponseButtonDescriptor(1,true,false,"thx","thanks")); - defaultButtons.add(new ResponseButtonDescriptor(2,false,false,"no thx", "no thanks")); - defaultButtons.add(new ResponseButtonDescriptor(3,false,false,"sold", "sold")); + defaultButtons.add(new ResponseButtonDescriptor(0,false,"1m","one minute", new HotKeyDescriptor())); + defaultButtons.add(new ResponseButtonDescriptor(1,true,"thx","thanks",new HotKeyDescriptor())); + defaultButtons.add(new ResponseButtonDescriptor(2,false,"no thx", "no thanks",new HotKeyDescriptor())); + defaultButtons.add(new ResponseButtonDescriptor(3,false,"sold", "sold",new HotKeyDescriptor())); notificationDescriptor.setButtons(defaultButtons); notificationDescriptor.setNotificationEnable(true); notificationDescriptor.setLimitCount(3); @@ -44,10 +45,20 @@ public void validate() { if(this.selectedProfile.getNotificationDescriptor() == null) { this.selectedProfile.setNotificationDescriptor(this.getDefault()); } + this.get().getButtons().forEach(it -> { + if(it.getHotKeyDescriptor() == null) { + it.setHotKeyDescriptor(new HotKeyDescriptor()); + } + }); } @Override public NotificationDescriptor get() { return this.selectedProfile.getNotificationDescriptor(); } + + @Override + public void set(NotificationDescriptor descriptor) { + this.selectedProfile.setNotificationDescriptor(descriptor); + } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScaleConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScaleConfigurationService.java index 5c47d9f1..5574df35 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScaleConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScaleConfigurationService.java @@ -50,4 +50,9 @@ public void toDefault() { public Map getMap() { return this.selectedProfile.getScaleDataMap(); } + + @Override + public void set(Map map) { + this.selectedProfile.setScaleDataMap(map); + } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScannerConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScannerConfigurationService.java index 27d9676d..7a75eb0d 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScannerConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/ScannerConfigurationService.java @@ -34,4 +34,9 @@ public void validate() { public ScannerDescriptor get() { return this.selectedProfile.getScannerDescriptor(); } + + @Override + public void set(ScannerDescriptor descriptor) { + this.selectedProfile.setScannerDescriptor(descriptor); + } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/SoundConfigurationService.java b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/SoundConfigurationService.java index 6aebc9b5..ef48e781 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/SoundConfigurationService.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/configration/impl/SoundConfigurationService.java @@ -35,6 +35,11 @@ public Map getMap() { return this.selectedProfile.getSoundDescriptorMap(); } + @Override + public void set(Map map) { + this.selectedProfile.setSoundDescriptorMap(map); + } + @Override public Map getDefault() { Map defaultSettings = new HashMap<>(); diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ApplicationDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ApplicationDescriptor.java index a19cad8a..8a4036d0 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ApplicationDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ApplicationDescriptor.java @@ -3,10 +3,11 @@ import com.mercury.platform.core.misc.WhisperNotifierStatus; import lombok.Data; +import java.io.Serializable; import java.util.Map; @Data -public class ApplicationDescriptor { +public class ApplicationDescriptor implements Serializable{ private WhisperNotifierStatus notifierStatus; private int minOpacity; private int maxOpacity; diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java index bf804c00..682a04ae 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/HotKeyType.java @@ -1,11 +1,52 @@ package com.mercury.platform.shared.config.descriptor; +import java.util.Arrays; +import java.util.stream.Collectors; + public enum HotKeyType { - INVITE_PLAYER, - TRADE_PLAYER, - KICK_PLAYER, - STILL_INTERESTING, - CLOSE_NOTIFICATION, - EXPAND_ALL + INVITE_PLAYER { + @Override + public String getIconPath() { + return "app/invite.png"; + } + }, + TRADE_PLAYER { + @Override + public String getIconPath() { + return "app/trade.png"; + } + }, + KICK_PLAYER { + @Override + public String getIconPath() { + return "app/kick.png"; + } + }, + STILL_INTERESTING { + @Override + public String getIconPath() { + return "app/still-interesting.png"; + } + }, + CLOSE_NOTIFICATION { + @Override + public String getIconPath() { + return "app/close.png"; + } + }; +// EXPAND_ALL { +// @Override +// public String getIconPath() { +// return null; +// } +// }; + + public abstract String getIconPath(); + public static boolean contains(String entry){ + return Arrays.stream(HotKeyType.values()) + .filter(it -> it.name().equals(entry)) + .collect(Collectors.toList()) + .size() != 0; + } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationDescriptor.java index 998c45b8..bfe78403 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/NotificationDescriptor.java @@ -3,10 +3,11 @@ import com.mercury.platform.shared.entity.message.FlowDirections; import lombok.Data; +import java.io.Serializable; import java.util.List; @Data -public class NotificationDescriptor { +public class NotificationDescriptor implements Serializable{ private boolean notificationEnable; private int limitCount; private int unfoldCount; diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ResponseButtonDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ResponseButtonDescriptor.java index d0bb7304..74fad744 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ResponseButtonDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/ResponseButtonDescriptor.java @@ -2,15 +2,19 @@ import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; @Data @AllArgsConstructor -public class ResponseButtonDescriptor implements Comparable{ +@NoArgsConstructor +public class ResponseButtonDescriptor implements Comparable,Serializable{ private long id; - private boolean kick; private boolean close; - private String title; - private String responseText; + private String title = "label"; + private String responseText = "response"; + private HotKeyDescriptor hotKeyDescriptor = new HotKeyDescriptor(); @Override public int compareTo(ResponseButtonDescriptor o) { diff --git a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/SoundDescriptor.java b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/SoundDescriptor.java index efc1bdbc..d9632bea 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/SoundDescriptor.java +++ b/app-core/src/main/java/com/mercury/platform/shared/config/descriptor/SoundDescriptor.java @@ -4,10 +4,12 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + @Data @AllArgsConstructor @NoArgsConstructor -public class SoundDescriptor { +public class SoundDescriptor implements Serializable{ private String wavPath; private Float db; } diff --git a/app-core/src/main/java/com/mercury/platform/shared/entity/message/FlowDirections.java b/app-core/src/main/java/com/mercury/platform/shared/entity/message/FlowDirections.java index e1f722ff..94cf6d8d 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/entity/message/FlowDirections.java +++ b/app-core/src/main/java/com/mercury/platform/shared/entity/message/FlowDirections.java @@ -1,5 +1,7 @@ package com.mercury.platform.shared.entity.message; -public enum FlowDirections { +import java.io.Serializable; + +public enum FlowDirections implements Serializable{ UPWARDS, DOWNWARDS } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java index bc8cc5b5..4643a9fc 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/adr/components/panel/page/AdrMainPagePanel.java @@ -127,7 +127,7 @@ public void mouseClicked(MouseEvent e) { container.add(this.componentsFactory.wrapToSlide(createIconsGroup)); container.add(this.componentsFactory.wrapToSlide(createPbGroup)); } - container.add(this.componentsFactory.wrapToSlide(createCaptureComponent)); +// container.add(this.componentsFactory.wrapToSlide(createCaptureComponent)); container.add(this.componentsFactory.wrapToSlide(importButton)); this.add(verticalContainer,BorderLayout.CENTER); } 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 e0bea5ba..5ee670bb 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java @@ -1,6 +1,7 @@ package com.mercury.platform.ui.components; import com.mercury.platform.core.misc.SoundType; +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.components.fields.style.MercuryComboBoxUI; import com.mercury.platform.ui.components.fields.font.FontStyle; @@ -52,6 +53,9 @@ public ComponentsFactory() { this.scale = 1.0f; // UIManager.getDefaults().put("Slider.horizontalThumbIcon",this.getImage("app/slider_thumb.png")); + UIManager.put("ComboBox.selectionBackground", AppThemeColor.HEADER); + UIManager.put("ComboBox.selectionForeground", AppThemeColor.ADR_POPUP_BG); + UIManager.put("ComboBox.disabledForeground", AppThemeColor.ADR_FOOTER_BG); } /** @@ -618,6 +622,11 @@ public JPanel getJPanel(LayoutManager layoutManager) { panel.setBackground(AppThemeColor.FRAME_RGB); return panel; } + public JPanel getJPanel(LayoutManager layoutManager,Color bg) { + JPanel panel = new JPanel(layoutManager); + panel.setBackground(bg); + return panel; + } public JPanel wrapToSlide(JComponent panel){ JPanel wrapper = this.getJPanel(new BorderLayout()); wrapper.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java deleted file mode 100644 index d71a8c56..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/GeneralSettings.java +++ /dev/null @@ -1,216 +0,0 @@ -package com.mercury.platform.ui.components.panel.settings; - -import com.mercury.platform.core.misc.WhisperNotifierStatus; -import com.mercury.platform.core.update.core.holder.ApplicationHolder; -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.frame.titled.NotesFrame; -import com.mercury.platform.ui.frame.titled.SettingsFrame; -import com.mercury.platform.ui.frame.titled.TestCasesFrame; -import com.mercury.platform.ui.manager.FramesManager; -import com.mercury.platform.ui.manager.HideSettingsManager; -import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.MercuryStoreUI; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionAdapter; -import java.io.File; - -public class GeneralSettings extends ConfigurationPanel { - private PlainConfigurationService applicationConfig; - private JSlider minSlider; - private JSlider maxSlider; - private JSlider fadeTimeSlider; - private JComboBox notifierStatusPicker; - private JCheckBox checkEnable; - private JTextField gamePathField; - private WrongGamePathListener poeFolderTooltipListener; - public GeneralSettings() { - super(); - this.applicationConfig = Configuration.get().applicationConfiguration(); - this.createUI(); - } - - @Override - public void createUI() { - verticalScrollContainer.add(getSettingsSlidePanel()); - verticalScrollContainer.add(getSettingsPanel()); - } - private JPanel getSettingsPanel() { - JPanel root = componentsFactory.getTransparentPanel(new GridLayout(7,2,4,4)); - root.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); - root.setBackground(AppThemeColor.SLIDE_BG); - - this.checkEnable = new JCheckBox(); - this.checkEnable.setBackground(AppThemeColor.TRANSPARENT); - this.checkEnable.setSelected(this.applicationConfig.get().isCheckOutUpdate()); - - this.fadeTimeSlider = this.componentsFactory.getSlider(0,10, this.applicationConfig.get().getFadeTime(),AppThemeColor.SLIDE_BG); - this.fadeTimeSlider.addChangeListener(e -> { - MercuryStoreUI.repaintSubject.onNext(SettingsFrame.class); - }); - - this.minSlider = this.componentsFactory.getSlider(40,100,this.applicationConfig.get().getMinOpacity(),AppThemeColor.SLIDE_BG); - this.minSlider.addChangeListener(e -> { - if(!(this.minSlider.getValue() > this.maxSlider.getValue())) { - MercuryStoreUI.repaintSubject.onNext(SettingsFrame.class); - }else { - minSlider.setValue(minSlider.getValue()-1); - } - }); - - this.maxSlider = this.componentsFactory.getSlider(40,100,this.applicationConfig.get().getMaxOpacity(),AppThemeColor.SLIDE_BG); - this.maxSlider.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - if(minSlider.getValue() > maxSlider.getValue()){ - minSlider.setValue(maxSlider.getValue()); - } - } - }); - - this.notifierStatusPicker = this.componentsFactory.getComboBox(new String[]{"Always play a sound", "Only when tabbed out","Never"}); - WhisperNotifierStatus whisperNotifier = this.applicationConfig.get().getNotifierStatus(); - this.notifierStatusPicker.setSelectedIndex(whisperNotifier.getCode()); - - this.gamePathField = this.componentsFactory.getTextField(this.applicationConfig.get().getGamePath()); - this.gamePathField.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.BORDER,1), - BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2) - )); - - JPanel poeFolderPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - poeFolderPanel.add(this.gamePathField); - JButton changeButton = this.componentsFactory.getBorderedButton("Change"); - poeFolderPanel.add(changeButton); - - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - changeButton.addActionListener(e -> { - int returnVal = fileChooser.showOpenDialog(this); - if(returnVal == JFileChooser.APPROVE_OPTION) { - this.gamePathField.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.BORDER,1), - BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2) - )); - this.gamePathField.setText(fileChooser.getSelectedFile().getPath()); - this.gamePathField.removeMouseListener(poeFolderTooltipListener); - this.poeFolderTooltipListener = null; - this.repaint(); - } - }); - - root.add(this.componentsFactory.getTextLabel("Notify me when an update is available", FontStyle.REGULAR)); - root.add(this.checkEnable); - root.add(this.componentsFactory.getTextLabel("Component fade out time: ", FontStyle.REGULAR)); - root.add(this.fadeTimeSlider); - root.add(this.componentsFactory.getTextLabel("Min opacity: ", FontStyle.REGULAR)); - root.add(this.minSlider); - root.add(this.componentsFactory.getTextLabel("Max opacity: ", FontStyle.REGULAR)); - root.add(this.maxSlider); - root.add(this.componentsFactory.getTextLabel("Notification sound alerts: ", FontStyle.REGULAR)); - root.add(this.notifierStatusPicker); - root.add(this.componentsFactory.getTextLabel("Path of Exile folder: ", FontStyle.REGULAR)); - root.add(poeFolderPanel); - return root; - } - private JPanel getSettingsSlidePanel(){ - JPanel root = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); - JButton openTutorial = - componentsFactory.getIconButton("app/tutorial.png", - 30, - AppThemeColor.TRANSPARENT, - "Open tutorial"); - openTutorial.addActionListener(action -> { - FramesManager.INSTANCE.hideFrame(SettingsFrame.class); - FramesManager.INSTANCE.preShowFrame(NotesFrame.class); - }); - JButton checkUpdates = - componentsFactory.getIconButton("app/check-update.png", - 30, - AppThemeColor.TRANSPARENT, - "Check for updates"); - checkUpdates.addActionListener(action -> { - ApplicationHolder.getInstance().setManualRequest(true); - MercuryStoreCore.requestPatchSubject.onNext(true); - }); - JButton openTests = - componentsFactory.getIconButton("app/open-tests.png", - 30, - AppThemeColor.TRANSPARENT, - "Open tests"); - openTests.addActionListener(action -> { - FramesManager.INSTANCE.hideFrame(SettingsFrame.class); - FramesManager.INSTANCE.preShowFrame(TestCasesFrame.class); - }); - root.addMouseMotionListener(new MouseMotionAdapter() { - @Override - public void mouseMoved(MouseEvent e) { - MercuryStoreUI.repaintSubject.onNext(SettingsFrame.class); - } - }); - root.add(openTutorial); - root.add(checkUpdates); - root.add(openTests); - return root; - } - @Override - public boolean processAndSave() { - int minOpacity = this.minSlider.getValue(); - int maxOpacity = this.maxSlider.getValue(); - int timeToDelay= this.fadeTimeSlider.getValue(); - HideSettingsManager.INSTANCE.apply(timeToDelay,minOpacity,maxOpacity); - this.applicationConfig.get().setNotifierStatus(WhisperNotifierStatus.get(this.notifierStatusPicker.getSelectedIndex())); - this.applicationConfig.get().setCheckOutUpdate(this.checkEnable.isSelected()); - if (this.isValidGamePath(this.gamePathField.getText())){ - this.applicationConfig.get().setGamePath(this.gamePathField.getText()+ File.separator); - MercuryStoreCore.poeFolderChangedSubject.onNext(true); - } else { - this.gamePathField.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createLineBorder(AppThemeColor.TEXT_IMPORTANT,1), - BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2) - )); - if(poeFolderTooltipListener == null){ - this.poeFolderTooltipListener = new WrongGamePathListener(); - this.gamePathField.addMouseListener(poeFolderTooltipListener); - } - return false; - } - return true; - } - - private boolean isValidGamePath(String gamePath){ - File file = new File(gamePath + File.separator + "logs" + File.separator + "Client.txt"); - return file.exists(); - } - - @Override - public void restore() { - this.verticalScrollContainer.removeAll(); - this.createUI(); - } - - private class WrongGamePathListener extends MouseAdapter{ - @Override - public void mouseEntered(MouseEvent e) { - MercuryStoreCore.tooltipSubject.onNext( - "Wrong Path of Exile folder! Open Task Manager (CTRL + Shift + ESC) and check the path here!"); - } - - @Override - public void mouseExited(MouseEvent e) { - MercuryStoreCore.tooltipSubject.onNext(null); - } - - @Override - public void mousePressed(MouseEvent e) { - MercuryStoreCore.tooltipSubject.onNext(null); - } - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuAction.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuAction.java new file mode 100644 index 00000000..b819eeab --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuAction.java @@ -0,0 +1,6 @@ +package com.mercury.platform.ui.components.panel.settings; + + +public interface MenuAction { + void onClick(); +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuEntry.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuEntry.java new file mode 100644 index 00000000..8da4026c --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuEntry.java @@ -0,0 +1,14 @@ +package com.mercury.platform.ui.components.panel.settings; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import javax.swing.*; + +@Data +@AllArgsConstructor +public class MenuEntry { + private String text; + private MenuAction action; + private ImageIcon imageIcon; +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuListRenderer.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuListRenderer.java new file mode 100644 index 00000000..437352b4 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuListRenderer.java @@ -0,0 +1,38 @@ +package com.mercury.platform.ui.components.panel.settings; + + + +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; + +public class MenuListRenderer extends JButton implements ListCellRenderer { + private ComponentsFactory componentsFactory = new ComponentsFactory(); + @Override + public Component getListCellRendererComponent(JList list, MenuEntry value, int index, boolean isSelected, boolean cellHasFocus) { + JButton button = this.componentsFactory.getButton(value.getText()); + button.setForeground(AppThemeColor.TEXT_DEFAULT); + button.setHorizontalAlignment(SwingConstants.LEFT); + button.setBackground(AppThemeColor.FRAME); + button.setFont(this.componentsFactory.getFont(FontStyle.BOLD,16f)); + button.setPreferredSize(new Dimension(220,50)); + button.setIcon(value.getImageIcon()); + if(isSelected){ + button.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createEmptyBorder(0,14,0,0), + BorderFactory.createMatteBorder(0,0,0,4,AppThemeColor.TEXT_DEFAULT))); + button.setBackground(AppThemeColor.ADR_BG); + }else { + button.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createMatteBorder(0,0,0,1,AppThemeColor.ADR_PANEL_BORDER), + BorderFactory.createEmptyBorder(0,10,0,3))); + } + button.addActionListener(action -> { + value.getAction().onClick(); + }); + return button; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuPanel.java new file mode 100644 index 00000000..8086984b --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/MenuPanel.java @@ -0,0 +1,75 @@ +package com.mercury.platform.ui.components.panel.settings; + +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.manager.routing.SettingsPage; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class MenuPanel extends JPanel implements HasUI { + private ComponentsFactory componentsFactory = new ComponentsFactory(); + public MenuPanel() { + super(); + this.setBackground(AppThemeColor.FRAME); + this.setPreferredSize(new Dimension(220, 20)); + this.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, AppThemeColor.ADR_PANEL_BORDER)); + this.createUI(); + } + @Override + public void createUI() { + JList list = new JList<>(getEntries()); + list.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + list.setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + @Override + public void mouseExited(MouseEvent e) { + list.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + }); + list.setCellRenderer(new MenuListRenderer()); + list.setBackground(AppThemeColor.FRAME); + list.setSelectedIndex(0); + list.addListSelectionListener(e -> + list.getSelectedValue().getAction().onClick()); + + JLabel appIcon = this.componentsFactory.getTextLabel("MercuryTrade", FontStyle.BOLD, 22); + appIcon.setIcon(this.componentsFactory.getIcon("app/app-icon.png", 50)); + appIcon.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); + appIcon.setBackground(AppThemeColor.FRAME); + this.add(appIcon, BorderLayout.PAGE_START); + this.add(list, BorderLayout.CENTER); + } + + @SuppressWarnings("all") + private MenuEntry[] getEntries() { + return new MenuEntry[]{ + new MenuEntry("General", () -> { + MercuryStoreUI.settingsStateSubject.onNext(SettingsPage.GENERAL_SETTINGS); + }, this.componentsFactory.getIcon("app/general_settings.png", 22)), + new MenuEntry("Sound", () -> { + MercuryStoreUI.settingsStateSubject.onNext(SettingsPage.SOUND_SETTING); + }, this.componentsFactory.getIcon("app/sound_settings.png", 22)), + new MenuEntry("Notification panel", () -> { + MercuryStoreUI.settingsStateSubject.onNext(SettingsPage.NOTIFICATION_SETTINGS); + }, this.componentsFactory.getIcon("app/notification_panel_settings.png", 22)), + new MenuEntry("Task bar", () -> { + MercuryStoreUI.settingsStateSubject.onNext(SettingsPage.TASK_BAR_SETTINGS); + }, this.componentsFactory.getIcon("app/task_bar_settings.png", 22)), + new MenuEntry("Support", () -> { + MercuryStoreUI.settingsStateSubject.onNext(SettingsPage.SUPPORT); + }, this.componentsFactory.getIcon("app/support_settings.png", 22)), + new MenuEntry("About", () -> { + MercuryStoreUI.settingsStateSubject.onNext(SettingsPage.ABOUT); + }, this.componentsFactory.getIcon("app/app-icon_sepia.png", 22)), + }; + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/NotificationPanelSettings.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/NotificationPanelSettings.java deleted file mode 100644 index 1a244ed8..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/NotificationPanelSettings.java +++ /dev/null @@ -1,266 +0,0 @@ -package com.mercury.platform.ui.components.panel.settings; - -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; -import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.frame.titled.SettingsFrame; -import com.mercury.platform.ui.misc.AppThemeColor; -import com.mercury.platform.ui.misc.MercuryStoreUI; - -import javax.swing.*; -import javax.swing.border.CompoundBorder; -import javax.swing.border.EmptyBorder; -import java.awt.*; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.*; -import java.util.List; - - -public class NotificationPanelSettings extends ConfigurationPanel{ - private List inputs; - private JPanel buttonsTable; - private JCheckBox dismissCheckBox; - private JCheckBox showLeagueCheckBox; - private PlainConfigurationService notificationService; - private int id; - - public NotificationPanelSettings() { - super(); - this.notificationService = Configuration.get().notificationConfiguration(); - this.createUI(); - } - - @Override - public boolean processAndSave() { - List buttons = new ArrayList<>(); - id = 0; - inputs.forEach(pair -> { - buttons.add(new ResponseButtonDescriptor( - id, - pair.kick.isSelected(), - pair.close.isSelected(), - pair.title.getText(), - pair.response.getText())); - id++; - }); - this.notificationService.get().setButtons(buttons); - this.notificationService.get().setDismissAfterKick(this.dismissCheckBox.isSelected()); - this.notificationService.get().setShowLeague(this.showLeagueCheckBox.isSelected()); - MercuryStoreCore.buttonsChangedSubject.onNext(true); - return true; - } - - @Override - public void restore() { - verticalScrollContainer.removeAll(); - createUI(); - } - - @Override - public void createUI() { - JPanel otherSettings = componentsFactory.getTransparentPanel(new BorderLayout()); - JLabel settingLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Customization"); - settingLabel.setBorder(new CompoundBorder(BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - new EmptyBorder(3,5,3,5))); - - otherSettings.add(settingLabel,BorderLayout.PAGE_START); - otherSettings.add(closeOnKickPanel(),BorderLayout.CENTER); - - - JPanel responseButtons = componentsFactory.getTransparentPanel(new BorderLayout()); - JLabel responseLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Response buttons"); - responseLabel.setBorder(new CompoundBorder(BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - new EmptyBorder(3,5,3,5))); - responseButtons.add(responseLabel,BorderLayout.PAGE_START); - responseButtons.add(getButtonsTable(),BorderLayout.CENTER); - - verticalScrollContainer.add(otherSettings); - verticalScrollContainer.add(responseButtons); - } - private JPanel closeOnKickPanel() { - JPanel topPanel = componentsFactory.getTransparentPanel(new GridLayout(2,2)); - topPanel.add(componentsFactory.getTextLabel("Close Notification panel on Kick:", FontStyle.REGULAR)); - dismissCheckBox = this.componentsFactory.getCheckBox(this.notificationService.get().isDismissAfterKick()); - topPanel.add(dismissCheckBox); - - topPanel.add(componentsFactory.getTextLabel("Show league:", FontStyle.REGULAR)); - showLeagueCheckBox = this.componentsFactory.getCheckBox(this.notificationService.get().isShowLeague()); - topPanel.add(showLeagueCheckBox); - - topPanel.setBorder(new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,0,3,0))); - topPanel.setBackground(AppThemeColor.SETTINGS_BG); - return topPanel; - } - private JPanel getButtonsTable() { - buttonsTable = componentsFactory.getTransparentPanel(new GridBagLayout()); - buttonsTable.setBackground(AppThemeColor.SETTINGS_BG); - inputs = new ArrayList<>(); - List buttonsConfig = this.notificationService.get().getButtons(); - Collections.sort(buttonsConfig); - GridBagConstraints titleColumn = new GridBagConstraints(); - GridBagConstraints valueColumn = new GridBagConstraints(); - GridBagConstraints kickColumn = new GridBagConstraints(); - GridBagConstraints closeColumn = new GridBagConstraints(); - GridBagConstraints utilColumn = new GridBagConstraints(); - - setUpGBConstants(titleColumn,valueColumn,kickColumn,closeColumn,utilColumn); - - JLabel titleLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,"Label"); - titleLabel.setHorizontalAlignment(SwingConstants.CENTER); - - JLabel valueLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,"Response text"); - valueLabel.setHorizontalAlignment(SwingConstants.CENTER); - - JLabel closeLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,"Close"); - closeLabel.setHorizontalAlignment(SwingConstants.CENTER); - - buttonsTable.add(titleLabel, titleColumn); - titleColumn.gridy++; - buttonsTable.add(valueLabel,valueColumn); - valueColumn.gridy++; - buttonsTable.add(closeLabel,closeColumn); - closeColumn.gridy++; - buttonsTable.add(componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,""),utilColumn); - utilColumn.gridy++; - - buttonsConfig.forEach(button ->{ - addNewRow(button.getTitle(),button.getResponseText(),button.isKick(),button.isClose(),titleColumn,valueColumn,kickColumn,closeColumn,utilColumn); - }); - - JButton addNew = componentsFactory.getBorderedButton("Add"); - addNew.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - if (inputs.size() <= 12) { - buttonsTable.remove(addNew); - addNewRow("expl", "example",false,false, titleColumn, valueColumn,kickColumn,closeColumn, utilColumn); - buttonsTable.add(addNew, utilColumn); - - MercuryStoreUI.packSubject.onNext(SettingsFrame.class); - } - } - } - }); - buttonsTable.add(addNew,utilColumn); - return buttonsTable; - } - private void addNewRow(String title, String value, boolean kick, - boolean close, - GridBagConstraints tC, - GridBagConstraints vC, - GridBagConstraints kC, - GridBagConstraints cC, - GridBagConstraints uC){ - JTextField titleFiled = componentsFactory.getTextField(title,FontStyle.REGULAR,15f); - titleFiled.addKeyListener(new KeyAdapter() { - @Override - public void keyTyped(KeyEvent e) { - if(titleFiled.getText().length() > 10){ - e.consume(); - } - } - }); - - buttonsTable.add(titleFiled,tC); - tC.gridy++; - - JTextField valueField = componentsFactory.getTextField(value,FontStyle.REGULAR,15f); - buttonsTable.add(valueField,vC); - vC.gridy++; - - JPanel kickWrapper = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); - JCheckBox kickCheckBox = this.componentsFactory.getCheckBox(kick); - kickCheckBox.setBackground(AppThemeColor.TRANSPARENT); - kickWrapper.add(kickCheckBox); - kC.gridy++; - - JCheckBox closeCheckBox = componentsFactory.getCheckBox(close,"Close notification panel on click"); - closeCheckBox.setPreferredSize(new Dimension(32,32)); - buttonsTable.add(closeCheckBox,cC); - cC.gridy++; - ValuePair pair = new ValuePair(titleFiled, valueField, kickCheckBox, closeCheckBox); - inputs.add(pair); - - - JButton remove = componentsFactory.getBorderedButton("x"); - remove.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - inputs.remove(pair); - buttonsTable.remove(titleFiled); - buttonsTable.remove(valueField); - buttonsTable.remove(closeCheckBox); - buttonsTable.remove(remove); - - MercuryStoreUI.packSubject.onNext(SettingsFrame.class); - } - } - }); - buttonsTable.add(remove,uC); - uC.gridy++; - } - private void setUpGBConstants(GridBagConstraints titleColumn, - GridBagConstraints valueColumn, - GridBagConstraints kickColumn, - GridBagConstraints closeColumn, - GridBagConstraints utilColumn){ - titleColumn.fill = GridBagConstraints.HORIZONTAL; - valueColumn.fill = GridBagConstraints.HORIZONTAL; - kickColumn.fill = GridBagConstraints.HORIZONTAL; - closeColumn.fill = GridBagConstraints.HORIZONTAL; - utilColumn.fill = GridBagConstraints.HORIZONTAL; - - titleColumn.weightx = 0.09f; - valueColumn.weightx = 0.9f; - kickColumn.weightx = 0.002f; - closeColumn.weightx = 0.002f; - utilColumn.weightx = 0.002f; - - titleColumn.anchor = GridBagConstraints.NORTHWEST; - valueColumn.anchor = GridBagConstraints.NORTHWEST; - kickColumn.anchor = GridBagConstraints.NORTHWEST; - closeColumn.anchor = GridBagConstraints.NORTHWEST; - utilColumn.anchor = GridBagConstraints.NORTHWEST; - - titleColumn.gridy = 0; - titleColumn.gridx = 1; - valueColumn.gridy = 0; - valueColumn.gridx = 2; - kickColumn.gridy = 0; - kickColumn.gridx = 3; - closeColumn.gridy = 0; - closeColumn.gridx = 4; - utilColumn.gridy = 0; - utilColumn.gridx = 5; - - utilColumn.insets = new Insets(3,2,3,0); - titleColumn.insets = new Insets(3,2,3,0); - kickColumn.insets = new Insets(3,2,3,0); - closeColumn.insets = new Insets(3,2,3,0); - valueColumn.insets = new Insets(3,2,3,0); - } - private class ValuePair { - private JTextField title; - private JTextField response; - private JCheckBox kick; - private JCheckBox close; - - public ValuePair(JTextField title, JTextField response, JCheckBox kick, JCheckBox close) { - this.title = title; - this.response = response; - this.kick = kick; - this.close = close; - } - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java deleted file mode 100644 index 392c0812..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SoundSettingsPanel.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.mercury.platform.ui.components.panel.settings; - -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.descriptor.SoundDescriptor; -import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.misc.AppThemeColor; - -import javax.swing.*; -import javax.swing.border.CompoundBorder; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.HashMap; -import java.util.Map; - -public class SoundSettingsPanel extends ConfigurationPanel { - private Map wavPaths; - - private JSlider notificationSlider; - private JSlider chatScannerSlider; - private JSlider clicksSlider; - private JSlider updateSlider; - - public SoundSettingsPanel() { - super(); - this.wavPaths = new HashMap<>(); - this.wavPaths.put("notification","app/notification.wav"); - this.wavPaths.put("chat_scanner","app/chat-filter.wav"); - this.wavPaths.put("clicks","app/sounds/click1/button-pressed-10.wav"); - this.wavPaths.put("update","app/patch_tone.wav"); - this.createUI(); - } - - @Override - public void createUI() { - verticalScrollContainer.add(getVolumePanel()); - verticalScrollContainer.add(getSoundPickerPanel()); - } - - private JPanel getVolumePanel(){ - Map map = Configuration.get().soundConfiguration().getMap(); - - JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); - - JLabel volumeLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Volume"); - volumeLabel.setBorder( - new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,5,3,5))); - - - JPanel container = componentsFactory.getTransparentPanel(new GridLayout(4, 2)); - container.setBackground(AppThemeColor.SETTINGS_BG); - container.setBorder(new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,0,3,0))); - - notificationSlider = componentsFactory.getSlider(-40, 6, map.get("notification").getDb().intValue(),AppThemeColor.SETTINGS_BG); - notificationSlider.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( - wavPaths.get("notification"), - notificationSlider.getValue() == -40 ? -80f : (float)notificationSlider.getValue() - )); - } - }); - chatScannerSlider = componentsFactory.getSlider(-40, 6, map.get("chat_scanner").getDb().intValue(),AppThemeColor.SETTINGS_BG); - chatScannerSlider.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( - wavPaths.get("chat_scanner"), - chatScannerSlider.getValue() == -40 ? -80f : (float)chatScannerSlider.getValue() - )); - } - }); - clicksSlider = componentsFactory.getSlider(-40, 6, map.get("clicks").getDb().intValue(),AppThemeColor.SETTINGS_BG); - clicksSlider.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( - wavPaths.get("clicks"), - clicksSlider.getValue() == -40 ? -80f : (float)clicksSlider.getValue() - )); - } - }); - updateSlider = componentsFactory.getSlider(-40, 6, map.get("update").getDb().intValue(),AppThemeColor.SETTINGS_BG); - updateSlider.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( - wavPaths.get("update"), - updateSlider.getValue() == -40 ? -80f : (float)updateSlider.getValue() - )); - } - }); - container.add(componentsFactory.getTextLabel("Notification:",FontStyle.REGULAR)); - container.add(notificationSlider); - container.add(componentsFactory.getTextLabel("Chat Scanner",FontStyle.REGULAR)); - container.add(chatScannerSlider); - container.add(componentsFactory.getTextLabel("Clicks",FontStyle.REGULAR)); - container.add(clicksSlider); - container.add(componentsFactory.getTextLabel("Update notification",FontStyle.REGULAR)); - container.add(updateSlider); - - root.add(volumeLabel,BorderLayout.PAGE_START); - root.add(container,BorderLayout.CENTER); - return root; - } - - private JPanel getSoundPickerPanel(){ - JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); - - JLabel soundLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Sound (in next update)"); - soundLabel.setBorder( - new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,5,3,5))); - -// JPanel container = componentsFactory.getTransparentPanel(new GridLayout(2, 2,0,1)); -// container.setBackground(AppThemeColor.SETTINGS_BG); -// container.setBorder(new CompoundBorder( -// BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), -// BorderFactory.createEmptyBorder(3,0,3,0))); -// -// JComboBox notificationComboBox = componentsFactory.getComboBox(new String[]{"Mercury Notification", "Mercury Chat Scanner", "Browse"}); -// notificationComboBox.addItemListener(e -> { -// switch (e.getStateChange()){ -// case ItemEvent.SELECTED: { -// if(notificationComboBox.getSelectedItem().equals("Browse")){ -// JFileChooser fileChooser = new JFileChooser(); -// fileChooser.setFileFilter(new FileNameExtensionFilter("*.wav","wav")); -// int returnVal = fileChooser.showOpenDialog(null); -// if(returnVal == JFileChooser.APPROVE_OPTION) { -// System.out.println(fileChooser.getSelectedFile().getPath()); -// } -// } -// break; -// } -// } -// }); -// -// -// JComboBox chatScannerComboBox = componentsFactory.getComboBox(new String[]{"Mercury Notification", "Mercury Chat Scanner", "Browse"}); -// -// -// container.add(componentsFactory.getTextLabel("Notification:",FontStyle.REGULAR)); -// container.add(notificationComboBox); -// container.add(componentsFactory.getTextLabel("Chat Scanner",FontStyle.REGULAR)); -// container.add(chatScannerComboBox); - root.add(soundLabel,BorderLayout.PAGE_START); -// root.add(container,BorderLayout.CENTER); - - return root; - } - - - @Override - public boolean processAndSave() { - Map map = Configuration.get().soundConfiguration().getMap(); - map.get("notification") - .setDb((float)notificationSlider.getValue()); - map.get("chat_scanner") - .setDb((float)chatScannerSlider.getValue()); - map.get("clicks") - .setDb((float)clicksSlider.getValue()); - map.get("update") - .setDb((float)updateSlider.getValue()); - MercuryStoreCore.saveConfigSubject.onNext(true); - return true; - } - - @Override - public void restore() { - Map map = Configuration.get().soundConfiguration().getMap(); - notificationSlider.setValue( - map.get("notification").getDb().intValue()); - chatScannerSlider.setValue( - map.get("chat_scanner").getDb().intValue()); - clicksSlider.setValue( - map.get("clicks").getDb().intValue()); - updateSlider.setValue( - map.get("update").getDb().intValue()); - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/TaskBarSettingsPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/TaskBarSettingsPanel.java deleted file mode 100644 index c4206a53..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/TaskBarSettingsPanel.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.mercury.platform.ui.components.panel.settings; - -import com.mercury.platform.shared.config.Configuration; -import com.mercury.platform.shared.config.configration.PlainConfigurationService; -import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor; -import com.mercury.platform.ui.components.fields.font.FontStyle; -import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.misc.AppThemeColor; - -import javax.swing.*; -import javax.swing.border.CompoundBorder; -import java.awt.*; - -public class TaskBarSettingsPanel extends ConfigurationPanel{ - private PlainConfigurationService applicationConfig; - private JTextField responseField; - private JCheckBox enableInGameDND; - - public TaskBarSettingsPanel() { - super(); - this.applicationConfig = Configuration.get().applicationConfiguration(); - this.createUI(); - } - @Override - public void createUI() { - JPanel root = componentsFactory.getTransparentPanel(new GridLayout(1, 1)); - JPanel dndSettings = componentsFactory.getTransparentPanel(new BorderLayout()); - JLabel dndLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "DND mode"); - dndLabel.setBorder( - new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,5,3,5))); - - dndSettings.add(dndLabel,BorderLayout.PAGE_START); - dndSettings.add(getDNDPanel(),BorderLayout.CENTER); - root.add(dndSettings); - verticalScrollContainer.add(root, BorderLayout.PAGE_START); - } - private JPanel getDNDPanel(){ - JPanel topPanel = componentsFactory.getTransparentPanel(new GridLayout(2,2)); - topPanel.add(componentsFactory.getTextLabel("Enable in-game dnd:", FontStyle.REGULAR), BorderLayout.LINE_START); - enableInGameDND = new JCheckBox(); - enableInGameDND.setBackground(AppThemeColor.TRANSPARENT); - enableInGameDND.setSelected(this.applicationConfig.get().isInGameDnd()); - responseField = componentsFactory.getTextField(this.applicationConfig.get().getDndResponseText(), FontStyle.REGULAR, 16f); - responseField.setEnabled(this.applicationConfig.get().isInGameDnd()); - componentsFactory.setUpToggleCallbacks(enableInGameDND, - () -> responseField.setEnabled(false), - () -> responseField.setEnabled(true),this.applicationConfig.get().isInGameDnd()); - - topPanel.add(enableInGameDND, BorderLayout.CENTER); - - topPanel.add(componentsFactory.getTextLabel("DND response:", FontStyle.REGULAR)); - topPanel.add(responseField); - - topPanel.setBorder(new CompoundBorder( - BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), - BorderFactory.createEmptyBorder(3,0,3,0))); - topPanel.setBackground(AppThemeColor.SETTINGS_BG); - return topPanel; - } - @Override - public void restore() { - this.verticalScrollContainer.removeAll(); - this.createUI(); - } - - @Override - public boolean processAndSave() { - this.applicationConfig.get().setInGameDnd(enableInGameDND.isSelected()); - this.applicationConfig.get().setDndResponseText(responseField.getText()); - return true; - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/data/DataActionListener.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/data/DataActionListener.java deleted file mode 100644 index 9f2fd56d..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/data/DataActionListener.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.mercury.platform.ui.components.panel.settings.data; - - -public interface DataActionListener { - void onSave(); -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/data/DataBindListenerPool.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/data/DataBindListenerPool.java deleted file mode 100644 index d95cc7f5..00000000 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/data/DataBindListenerPool.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mercury.platform.ui.components.panel.settings.data; - - -import java.util.ArrayList; -import java.util.List; - -public class DataBindListenerPool { - private List listeners = new ArrayList<>(); - private void add(DataActionListener listener){ - this.listeners.add(listener); - } - private void save(){ - this.listeners.forEach(DataActionListener::onSave); - } -} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/AboutPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/AboutPagePanel.java similarity index 80% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/AboutPanel.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/AboutPagePanel.java index ea6294fe..5f7ecd6f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/AboutPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/AboutPagePanel.java @@ -1,57 +1,42 @@ -package com.mercury.platform.ui.components.panel.settings; +package com.mercury.platform.ui.components.panel.settings.page; + import com.mercury.platform.core.MercuryConstants; -import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.font.TextAlignment; -import com.mercury.platform.ui.components.panel.misc.HasUI; import com.mercury.platform.ui.misc.AppThemeColor; import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.io.IOException; import java.net.URI; -import java.net.URISyntaxException; - -/** - * Created by Константин on 05.01.2017. - */ -public class AboutPanel extends JPanel implements HasUI { - private ComponentsFactory componentsFactory; - public AboutPanel() { - super(); - componentsFactory = new ComponentsFactory(); - this.setBackground(AppThemeColor.TRANSPARENT); - createUI(); - } +public class AboutPagePanel extends SettingsPagePanel { @Override public void createUI() { + super.createUI(); this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); JPanel imgPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); imgPanel.add(componentsFactory.getIconLabel("app/app-icon-big.png")); - this.add(imgPanel); - - JPanel aboutPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - aboutPanel.add(getInfoPanel()); - - this.add(aboutPanel); +// this.add(imgPanel,BorderLayout.CENTER); + this.container.add(this.componentsFactory.wrapToSlide(getInfoPanel())); } private JPanel getInfoPanel(){ JPanel panel = componentsFactory.getTransparentPanel(); + panel.setBackground(AppThemeColor.ADR_BG); + panel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS)); JPanel titlePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - titlePanel.add(componentsFactory.getTextLabel("MercuryTrade", FontStyle.REGULAR)); + titlePanel.add(componentsFactory.getTextLabel("MercuryTrade", FontStyle.REGULAR,15)); panel.add(titlePanel); JPanel versionPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - versionPanel.add(componentsFactory.getTextLabel("App version: " + MercuryConstants.APP_VERSION, FontStyle.REGULAR)); + versionPanel.add(componentsFactory.getTextLabel("App version: " + MercuryConstants.APP_VERSION, FontStyle.REGULAR,15)); panel.add(versionPanel); - JLabel redditButton = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_MESSAGE, TextAlignment.LEFTOP,16f,"Reddit"); + JLabel redditButton = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_MESSAGE, TextAlignment.LEFTOP,16f,"Reddit"); redditButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -115,7 +100,7 @@ public void mouseExited(MouseEvent e) { }); JPanel feedbackPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT)); - feedbackPanel.add(componentsFactory.getTextLabel("Feedback & Suggestions: ", FontStyle.REGULAR)); + feedbackPanel.add(componentsFactory.getTextLabel("Feedback & Suggestions: ", FontStyle.REGULAR,15)); feedbackPanel.add(redditButton); feedbackPanel.add(githubButton); feedbackPanel.add(discordButton); @@ -123,4 +108,12 @@ public void mouseExited(MouseEvent e) { panel.add(feedbackPanel); return panel; } + + @Override + public void onSave() { + } + + @Override + public void restore() { + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GeneralSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GeneralSettingsPagePanel.java new file mode 100644 index 00000000..5ca752e5 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/GeneralSettingsPagePanel.java @@ -0,0 +1,129 @@ +package com.mercury.platform.ui.components.panel.settings.page; + + +import com.mercury.platform.core.misc.WhisperNotifierStatus; +import com.mercury.platform.shared.CloneHelper; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.frame.titled.SettingsFrame; +import com.mercury.platform.ui.manager.HideSettingsManager; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class GeneralSettingsPagePanel extends SettingsPagePanel { + private PlainConfigurationService applicationConfig; + private ApplicationDescriptor applicationSnapshot; + + private JSlider minSlider; + private JSlider maxSlider; + @Override + public void createUI() { + super.createUI(); + this.applicationConfig = Configuration.get().applicationConfiguration(); + this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); + + JPanel root = componentsFactory.getJPanel(new GridLayout(0,2,4,4)); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + root.setBackground(AppThemeColor.ADR_BG); + + JCheckBox checkEnable = this.componentsFactory.getCheckBox(this.applicationSnapshot.isCheckOutUpdate()); + checkEnable.addActionListener(action -> { + this.applicationSnapshot.setCheckOutUpdate(checkEnable.isSelected()); + }); + JSlider fadeTimeSlider = this.componentsFactory.getSlider(0,10, this.applicationSnapshot.getFadeTime(),AppThemeColor.SLIDE_BG); + fadeTimeSlider.addChangeListener(e -> { + this.applicationSnapshot.setFadeTime(fadeTimeSlider.getValue()); + }); + + this.minSlider = this.componentsFactory.getSlider(40,100,this.applicationSnapshot.getMinOpacity(),AppThemeColor.SLIDE_BG); + this.minSlider.addChangeListener(e -> { + if(!(this.minSlider.getValue() > this.maxSlider.getValue())) { + this.applicationSnapshot.setMinOpacity(this.minSlider.getValue()); + }else { + minSlider.setValue(minSlider.getValue()-1); + } + }); + + this.maxSlider = this.componentsFactory.getSlider(40,100,this.applicationSnapshot.getMaxOpacity(),AppThemeColor.SLIDE_BG); + this.maxSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + if(minSlider.getValue() > maxSlider.getValue()){ + minSlider.setValue(maxSlider.getValue()); + } + applicationSnapshot.setMaxOpacity(maxSlider.getValue()); + } + }); + + JComboBox notifierStatusPicker = this.componentsFactory.getComboBox(new String[]{"Always play a sound", "Only when tabbed out","Never"}); + notifierStatusPicker.setSelectedItem(this.applicationSnapshot.getNotifierStatus().asPretty()); + notifierStatusPicker.addActionListener(action -> { + this.applicationSnapshot.setNotifierStatus(WhisperNotifierStatus.valueOfPretty((String) notifierStatusPicker.getSelectedItem())); + }); + + JTextField gamePathField = this.componentsFactory.getTextField(this.applicationSnapshot.getGamePath()); + gamePathField.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createLineBorder(AppThemeColor.BORDER,1), + BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,2) + )); + gamePathField.addKeyListener(new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + applicationSnapshot.setGamePath(gamePathField.getText()); + } + }); + + JPanel poeFolderPanel = componentsFactory.getTransparentPanel(new BorderLayout(4,4)); + poeFolderPanel.add(gamePathField, BorderLayout.CENTER); + JButton changeButton = this.componentsFactory.getBorderedButton("Change"); + poeFolderPanel.add(changeButton, BorderLayout.LINE_END); + + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + changeButton.addActionListener(e -> { + int returnVal = fileChooser.showOpenDialog(this); + if(returnVal == JFileChooser.APPROVE_OPTION) { + gamePathField.setText(fileChooser.getSelectedFile().getPath()); + applicationSnapshot.setGamePath(fileChooser.getSelectedFile().getPath()); + } + }); + + root.add(this.componentsFactory.getTextLabel("Notify me when an update is available", FontStyle.REGULAR,16)); + root.add(checkEnable); + root.add(this.componentsFactory.getTextLabel("Component fade out time: ", FontStyle.REGULAR,16)); + root.add(fadeTimeSlider); + root.add(this.componentsFactory.getTextLabel("Min opacity: ", FontStyle.REGULAR,16)); + root.add(this.minSlider); + root.add(this.componentsFactory.getTextLabel("Max opacity: ", FontStyle.REGULAR,16)); + root.add(this.maxSlider); + root.add(this.componentsFactory.getTextLabel("Notification sound alerts: ", FontStyle.REGULAR,16)); + root.add(this.componentsFactory.wrapToSlide(notifierStatusPicker,AppThemeColor.ADR_BG,0,0,0,2)); + root.add(this.componentsFactory.getTextLabel("Path of Exile folder: ", FontStyle.REGULAR,16)); + root.add(this.componentsFactory.wrapToSlide(poeFolderPanel,AppThemeColor.ADR_BG,0,0,2,2)); + + this.container.add(this.componentsFactory.wrapToSlide(root)); + } + + @Override + public void onSave() { + HideSettingsManager.INSTANCE.apply(applicationSnapshot.getFadeTime(),applicationSnapshot.getMinOpacity(),applicationSnapshot.getMaxOpacity()); + this.applicationConfig.set(CloneHelper.cloneObject(this.applicationSnapshot)); + } + + @Override + public void restore() { + this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); + this.removeAll(); + this.createUI(); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java new file mode 100644 index 00000000..aa3c0ff0 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/NotificationSettingsPagePanel.java @@ -0,0 +1,278 @@ +package com.mercury.platform.ui.components.panel.settings.page; + +import com.mercury.platform.shared.CloneHelper; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.KeyValueConfigurationService; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor; +import com.mercury.platform.shared.config.descriptor.HotKeyType; +import com.mercury.platform.shared.config.descriptor.NotificationDescriptor; +import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; +import com.mercury.platform.shared.entity.message.FlowDirections; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.util.Map; + +public class NotificationSettingsPagePanel extends SettingsPagePanel { + private PlainConfigurationService notificationService; + private KeyValueConfigurationService hotKeyService; + private NotificationDescriptor generalSnapshot; + private Map hotKeySnapshot; + private JPanel buttonsTable; + + @Override + public void createUI() { + super.createUI(); + this.notificationService = Configuration.get().notificationConfiguration(); + this.hotKeyService = Configuration.get().hotKeysConfiguration(); + this.generalSnapshot = CloneHelper.cloneObject(notificationService.get()); + this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.getMap()); + + JPanel inPanel = this.adrComponentsFactory.getCounterPanel(this.getIncomingPanel(), "Incoming notification:", AppThemeColor.ADR_BG,true); + inPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + JPanel outPanel = this.adrComponentsFactory.getCounterPanel(this.getOutgoingPanel(), "Outgoing notification:", AppThemeColor.ADR_BG,true); + outPanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + this.container.add(this.componentsFactory.wrapToSlide(inPanel)); +// this.container.add(this.componentsFactory.wrapToSlide(outPanel)); + } + + @Override + public void onSave() { + this.notificationService.set(CloneHelper.cloneObject(this.generalSnapshot)); + this.hotKeyService.set(CloneHelper.cloneObject(this.hotKeySnapshot)); + MercuryStoreCore.buttonsChangedSubject.onNext(true); + } + + @Override + public void restore() { + this.generalSnapshot = CloneHelper.cloneObject(notificationService.get()); + this.hotKeySnapshot = CloneHelper.cloneObject(hotKeyService.getMap()); + this.removeAll(); + this.createUI(); + } + + private JPanel getIncomingPanel() { + JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG); + JPanel propertiesPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.ADR_BG); + JCheckBox enabled = this.componentsFactory.getCheckBox(this.generalSnapshot.isNotificationEnable()); + enabled.addActionListener(action -> { + this.generalSnapshot.setNotificationEnable(enabled.isSelected()); + }); + JCheckBox dismiss = this.componentsFactory.getCheckBox(this.generalSnapshot.isDismissAfterKick()); + dismiss.addActionListener(action -> { + this.generalSnapshot.setDismissAfterKick(dismiss.isSelected()); + }); + JCheckBox showLeague = this.componentsFactory.getCheckBox(this.generalSnapshot.isShowLeague()); + showLeague.addActionListener(action -> { + this.generalSnapshot.setShowLeague(showLeague.isSelected()); + }); + JComboBox flowDirectionPicker = componentsFactory.getComboBox(new String[]{"Upwards", "Downwards"}); + flowDirectionPicker.addActionListener(e -> { + switch ((String)flowDirectionPicker.getSelectedItem()){ + case "Upwards":{ + this.generalSnapshot.setFlowDirections(FlowDirections.UPWARDS); + break; + } + case "Downwards":{ + this.generalSnapshot.setFlowDirections(FlowDirections.DOWNWARDS); + break; + } + } + }); + JSlider limitSlider = componentsFactory.getSlider(2, 20, this.generalSnapshot.getLimitCount(),AppThemeColor.ADR_BG); + limitSlider.addChangeListener(e -> { + this.generalSnapshot.setLimitCount(limitSlider.getValue()); + }); + JSlider unfoldSlider = componentsFactory.getSlider(0, 20, this.generalSnapshot.getUnfoldCount(),AppThemeColor.ADR_BG); + unfoldSlider.addChangeListener(e -> { + this.generalSnapshot.setUnfoldCount(unfoldSlider.getValue()); + }); + flowDirectionPicker.setSelectedIndex(this.generalSnapshot.getFlowDirections().ordinal()); + propertiesPanel.add(this.componentsFactory.getTextLabel("Enabled:", FontStyle.REGULAR,16)); + propertiesPanel.add(enabled); + propertiesPanel.add(this.componentsFactory.getTextLabel("Close panel on kick:", FontStyle.REGULAR,16)); + propertiesPanel.add(dismiss); + propertiesPanel.add(this.componentsFactory.getTextLabel("Show league:", FontStyle.REGULAR,16)); + propertiesPanel.add(showLeague); +// propertiesPanel.add(this.componentsFactory.getTextLabel("Flow direction:", FontStyle.REGULAR,16)); +// propertiesPanel.add(flowDirectionPicker); +// propertiesPanel.add(this.componentsFactory.getTextLabel("Pre-group limit:", FontStyle.REGULAR,16)); +// propertiesPanel.add(limitSlider); +// propertiesPanel.add(this.componentsFactory.getTextLabel("Unfold by default:", FontStyle.REGULAR,16)); +// propertiesPanel.add(unfoldSlider); + root.add(propertiesPanel,BorderLayout.PAGE_START); + root.add(this.componentsFactory.wrapToSlide(this.getResponseButtonsPanel(),AppThemeColor.ADR_BG),BorderLayout.CENTER); +// root.add(this.componentsFactory.wrapToSlide(this.getInNotificationHotKeysPanel(),AppThemeColor.ADR_BG),BorderLayout.PAGE_END); + return root; + } + private JPanel getResponseButtonsPanel(){ + JPanel root = this.componentsFactory.getJPanel(new BorderLayout(4,4), AppThemeColor.SETTINGS_BG); + this.buttonsTable = this.componentsFactory.getJPanel(new GridLayout(0, 1, 4, 4),AppThemeColor.SETTINGS_BG); + buttonsTable.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); + + JPanel headerPanel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.SETTINGS_BG); + + JLabel titleLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,"Label"); + titleLabel.setHorizontalAlignment(SwingConstants.CENTER); + titleLabel.setPreferredSize(new Dimension(120,26)); + JLabel valueLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,"Response text"); + valueLabel.setHorizontalAlignment(SwingConstants.CENTER); + + JLabel hotKeyLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,""); + hotKeyLabel.setHorizontalAlignment(SwingConstants.CENTER); + hotKeyLabel.setPreferredSize(new Dimension(130,20)); + + JLabel closeLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, null,15f,""); + closeLabel.setHorizontalAlignment(SwingConstants.CENTER); + + headerPanel.add(titleLabel,BorderLayout.LINE_START); + headerPanel.add(valueLabel,BorderLayout.CENTER); + + JPanel miscPanel = this.componentsFactory.getJPanel(new BorderLayout(),AppThemeColor.SETTINGS_BG); + miscPanel.add(hotKeyLabel,BorderLayout.CENTER); + miscPanel.add(closeLabel,BorderLayout.LINE_END); + headerPanel.add(miscPanel,BorderLayout.LINE_END); + + this.buttonsTable.add(headerPanel); + + this.generalSnapshot.getButtons().forEach(it -> { + this.buttonsTable.add(this.getResponseRow(it)); + }); + root.add(this.buttonsTable,BorderLayout.CENTER); + JButton addButton = this.componentsFactory.getIconButton("app/add_button.png", 24, AppThemeColor.HEADER, "Add button"); + addButton.setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER)); + addButton.addActionListener(action -> { + ResponseButtonDescriptor descriptor = new ResponseButtonDescriptor(); + int size = this.generalSnapshot.getButtons().size(); + descriptor.setId(++size); + this.generalSnapshot.getButtons().add(descriptor); + this.buttonsTable.add(this.getResponseRow(descriptor)); + MercuryStoreUI.settingsRepaintSubject.onNext(true); + MercuryStoreUI.settingsPackSubject.onNext(true); + }); + root.add(addButton,BorderLayout.PAGE_END); + return root; + } + private JPanel getResponseRow(ResponseButtonDescriptor descriptor){ + JPanel root = this.componentsFactory.getJPanel(new BorderLayout(4,4), AppThemeColor.SETTINGS_BG); + JTextField titleField = this.componentsFactory.getTextField(descriptor.getTitle(), FontStyle.REGULAR, 15f); + titleField.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + descriptor.setTitle(titleField.getText()); + System.out.println(".qwe"); + } + }); + titleField.setPreferredSize(new Dimension(120,26)); + JTextField responseField = this.componentsFactory.getTextField(descriptor.getResponseText(), FontStyle.REGULAR, 15f); + responseField.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + descriptor.setResponseText(responseField.getText()); + } + }); + root.add(titleField,BorderLayout.LINE_START); + root.add(responseField,BorderLayout.CENTER); + + JPanel miscPanel = this.componentsFactory.getJPanel(new BorderLayout(4, 4),AppThemeColor.SETTINGS_BG); + JCheckBox checkBox = this.componentsFactory.getCheckBox(descriptor.isClose(),"Close notification panel after click?"); + checkBox.addActionListener(action -> { + descriptor.setClose(checkBox.isSelected()); + }); + miscPanel.add(checkBox, BorderLayout.LINE_START); +// miscPanel.add(new HotKeyPanel(descriptor.getHotKeyDescriptor()),BorderLayout.CENTER); + + JButton removeButton = this.componentsFactory.getIconButton("app/adr/remove_node.png", 17, AppThemeColor.SETTINGS_BG, "Remove button"); + removeButton.addActionListener(action -> { + this.buttonsTable.remove(root); + this.generalSnapshot.getButtons().remove(descriptor); + MercuryStoreUI.settingsPackSubject.onNext(true); + MercuryStoreUI.settingsRepaintSubject.onNext(true); + }); + miscPanel.add(removeButton,BorderLayout.LINE_END); + + root.add(miscPanel,BorderLayout.LINE_END); + return root; + } + private JPanel getInNotificationHotKeysPanel(){ + JPanel root = this.componentsFactory.getJPanel(new GridLayout(0, 4, 4, 4),AppThemeColor.SETTINGS_BG); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_DEFAULT_BORDER)); + this.hotKeySnapshot.forEach((key, value) -> { + if(HotKeyType.contains(key)) { + JLabel iconLabel = this.componentsFactory.getIconLabel(HotKeyType.valueOf(key).getIconPath(), 18); + iconLabel.setHorizontalAlignment(SwingConstants.CENTER); + root.add(iconLabel); + root.add(this.componentsFactory.wrapToSlide(new HotKeyPanel(value),AppThemeColor.SETTINGS_BG,1,4,1,1)); + } + }); + return root; + } + private JPanel getOutgoingPanel() { + JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG); + JPanel propertiesPanel = this.componentsFactory.getJPanel(new GridLayout(0, 2, 4, 4),AppThemeColor.ADR_BG); + JCheckBox enabled = this.componentsFactory.getCheckBox(this.generalSnapshot.isNotificationEnable()); + enabled.addActionListener(action -> { + this.generalSnapshot.setNotificationEnable(enabled.isSelected()); + }); + propertiesPanel.add(this.componentsFactory.getTextLabel("Enabled:", FontStyle.REGULAR,16)); + propertiesPanel.add(enabled); + root.add(propertiesPanel,BorderLayout.PAGE_START); + return root; + } + + private class HotKeyPanel extends JPanel { + private HotKeyDescriptor descriptor; + private boolean hotKeyAllowed; + private ComponentsFactory componentsFactory = new ComponentsFactory(); + public HotKeyPanel(HotKeyDescriptor descriptor) { + super(new BorderLayout()); + this.descriptor = descriptor; + this.setPreferredSize(new Dimension(130,26)); + + JButton button = this.componentsFactory.getBorderedButton(this.descriptor.getTitle()); + button.setFont(this.componentsFactory.getFont(FontStyle.BOLD, 18f)); + MouseAdapter mouseAdapter = new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if(SwingUtilities.isLeftMouseButton(e)) { + button.setBackground(AppThemeColor.ADR_BG); + button.setText("Press any key"); + hotKeyAllowed = true; + button.removeMouseListener(this); + } + } + }; + button.addMouseListener(mouseAdapter); + MercuryStoreCore.hotKeySubject.subscribe(hotKey -> { + if (hotKeyAllowed) { + button.setBackground(AppThemeColor.BUTTON); + if (hotKey.getVirtualKeyCode() == 27) { + this.descriptor.setTitle("..."); + this.descriptor.setVirtualKeyCode(0); + this.descriptor.setMenuPressed(false); + this.descriptor.setShiftPressed(false); + this.descriptor.setControlPressed(false); + } else { + this.descriptor.setTitle(hotKey.getTitle()); + this.descriptor.setVirtualKeyCode(hotKey.getVirtualKeyCode()); + this.descriptor.setMenuPressed(hotKey.isMenuPressed()); + this.descriptor.setShiftPressed(hotKey.isShiftPressed()); + this.descriptor.setControlPressed(hotKey.isControlPressed()); + this.descriptor.setKeyChar(hotKey.getKeyChar()); + } + button.setText(hotKey.getTitle()); + hotKeyAllowed = false; + button.addMouseListener(mouseAdapter); + } + }); + this.add(button,BorderLayout.CENTER); + } + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SettingsPagePanel.java new file mode 100644 index 00000000..f874b49c --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SettingsPagePanel.java @@ -0,0 +1,36 @@ +package com.mercury.platform.ui.components.panel.settings.page; + + +import com.mercury.platform.ui.adr.components.AdrComponentsFactory; +import com.mercury.platform.ui.components.ComponentsFactory; +import com.mercury.platform.ui.components.panel.VerticalScrollContainer; +import com.mercury.platform.ui.components.panel.misc.HasUI; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; + +public abstract class SettingsPagePanel extends JPanel implements HasUI{ + protected ComponentsFactory componentsFactory = new ComponentsFactory(); + protected AdrComponentsFactory adrComponentsFactory = new AdrComponentsFactory(this.componentsFactory); + protected JPanel container; + + public SettingsPagePanel() { + this.setLayout(new BorderLayout()); + this.setBackground(AppThemeColor.FRAME); + + this.createUI(); + } + + @Override + public void createUI() { + this.container = new VerticalScrollContainer(); + this.container.setBackground(AppThemeColor.FRAME); + this.container.setLayout(new BoxLayout(container,BoxLayout.Y_AXIS)); + JScrollPane verticalContainer = this.componentsFactory.getVerticalContainer( this.container); + this.add(verticalContainer,BorderLayout.CENTER); + } + + public abstract void onSave(); + public abstract void restore(); +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SoundSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SoundSettingsPagePanel.java new file mode 100644 index 00000000..2e127160 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SoundSettingsPagePanel.java @@ -0,0 +1,124 @@ +package com.mercury.platform.ui.components.panel.settings.page; + + +import com.mercury.platform.shared.CloneHelper; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.KeyValueConfigurationService; +import com.mercury.platform.shared.config.descriptor.SoundDescriptor; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import javax.swing.border.CompoundBorder; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.Map; + +public class SoundSettingsPagePanel extends SettingsPagePanel { + private Map wavPaths; + + private JSlider notificationSlider; + private JSlider chatScannerSlider; + private JSlider clicksSlider; + private JSlider updateSlider; + + Map soundSnapshot; + KeyValueConfigurationService soundConfiguration; + @Override + public void createUI() { + super.createUI(); + this.wavPaths = new HashMap<>(); + this.wavPaths.put("notification","app/notification.wav"); + this.wavPaths.put("chat_scanner","app/chat-filter.wav"); + this.wavPaths.put("clicks","app/sounds/click1/button-pressed-10.wav"); + this.wavPaths.put("update","app/patch_tone.wav"); + this.soundConfiguration = Configuration.get().soundConfiguration(); + this.soundSnapshot = CloneHelper.cloneObject(this.soundConfiguration.getMap()); + + JPanel vPanel = this.getVolumePanel(); + JPanel volumePanel = this.adrComponentsFactory.getCounterPanel(vPanel, "Volume:", AppThemeColor.ADR_BG,true); + volumePanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + this.container.add(this.componentsFactory.wrapToSlide(volumePanel)); + } + + private JPanel getVolumePanel(){ + JPanel container = componentsFactory.getTransparentPanel(new GridLayout(0, 2,0,4)); + container.setBackground(AppThemeColor.ADR_BG); + container.setBorder(new CompoundBorder( + BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER), + BorderFactory.createEmptyBorder(3,0,3,0))); + + notificationSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("notification").getDb().intValue(),AppThemeColor.SETTINGS_BG); + notificationSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( + wavPaths.get("notification"), + notificationSlider.getValue() == -40 ? -80f : (float)notificationSlider.getValue() + )); + } + }); + chatScannerSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("chat_scanner").getDb().intValue(),AppThemeColor.SETTINGS_BG); + chatScannerSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( + wavPaths.get("chat_scanner"), + chatScannerSlider.getValue() == -40 ? -80f : (float)chatScannerSlider.getValue() + )); + } + }); + clicksSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("clicks").getDb().intValue(),AppThemeColor.SETTINGS_BG); + clicksSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( + wavPaths.get("clicks"), + clicksSlider.getValue() == -40 ? -80f : (float)clicksSlider.getValue() + )); + } + }); + updateSlider = componentsFactory.getSlider(-40, 6, soundSnapshot.get("update").getDb().intValue(),AppThemeColor.SETTINGS_BG); + updateSlider.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + MercuryStoreCore.soundSettingsSubject.onNext(new SoundDescriptor( + wavPaths.get("update"), + updateSlider.getValue() == -40 ? -80f : (float)updateSlider.getValue() + )); + } + }); + container.add(componentsFactory.getTextLabel("Notification:",FontStyle.REGULAR,16)); + container.add(notificationSlider); + container.add(componentsFactory.getTextLabel("Chat Scanner",FontStyle.REGULAR,16)); + container.add(chatScannerSlider); + container.add(componentsFactory.getTextLabel("Clicks",FontStyle.REGULAR,16)); + container.add(clicksSlider); + container.add(componentsFactory.getTextLabel("Update notification",FontStyle.REGULAR,16)); + container.add(updateSlider); + return container; + } + + @Override + public void onSave() { + soundSnapshot.get("notification") + .setDb((float)notificationSlider.getValue()); + soundSnapshot.get("chat_scanner") + .setDb((float)chatScannerSlider.getValue()); + soundSnapshot.get("clicks") + .setDb((float)clicksSlider.getValue()); + soundSnapshot.get("update") + .setDb((float)updateSlider.getValue()); + this.soundConfiguration.set(CloneHelper.cloneObject(this.soundSnapshot)); + } + + @Override + public void restore() { + this.soundSnapshot = CloneHelper.cloneObject(this.soundConfiguration.getMap()); + this.removeAll(); + this.createUI(); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SupportPagePanel.java similarity index 77% rename from app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java rename to app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SupportPagePanel.java index 0911c78e..03f9c7e1 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/SupportPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/SupportPagePanel.java @@ -1,10 +1,9 @@ -package com.mercury.platform.ui.components.panel.settings; +package com.mercury.platform.ui.components.panel.settings.page; + -import com.mercury.platform.ui.components.ComponentsFactory; import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.fields.style.MercuryScrollBarUI; import com.mercury.platform.ui.components.panel.VerticalScrollContainer; -import com.mercury.platform.ui.components.panel.misc.HasUI; import com.mercury.platform.ui.frame.titled.SettingsFrame; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; @@ -18,22 +17,13 @@ import java.util.*; import java.util.List; -public class SupportPanel extends JPanel implements HasUI{ - private ComponentsFactory componentsFactory; - public SupportPanel() { - super(); - componentsFactory = new ComponentsFactory(); - this.setBackground(AppThemeColor.SLIDE_BG); - this.createUI(); - } - +public class SupportPagePanel extends SettingsPagePanel{ @Override public void createUI() { - this.setLayout(new BorderLayout()); - JPanel donatePanel = componentsFactory.getTransparentPanel(); - donatePanel.setLayout(new BoxLayout(donatePanel,BoxLayout.Y_AXIS)); - donatePanel.setBackground(AppThemeColor.SLIDE_BG); + donatePanel.setBackground(AppThemeColor.ADR_BG); + donatePanel.setLayout(new GridLayout(0,1,5,5)); + donatePanel.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); JButton donate = componentsFactory.getIconifiedTransparentButton("app/paypal.png","Donate"); donate.setBorder(BorderFactory.createEmptyBorder(1,1,1,1)); @@ -58,22 +48,26 @@ public void mousePressed(MouseEvent e) { } } }); - JTextArea donateText = componentsFactory.getSimpleTextArea("We aimed to create a convenience tool in form of an easy-to-use application, primarily for trading purposes. If MercuryTrade successfully managed to save your time or improve your experience, you can thank us by donating and telling your friends."); + JTextArea donateText = componentsFactory.getSimpleTextArea("We aimed to create a convenience tool in form of an easy-to-use application, primarily for trading purposes. If MercuryTrade successfully managed to save your time or improve your experience, you can thank us by donating or telling your friends. If you want your name to be featured in our in-app Hall of Fame please provide this information within the transaction!"); donateText.setPreferredSize(new Dimension(300,150)); - JPanel donateTextPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); JPanel donateButtonPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER)); - donateButtonPanel.setBorder(BorderFactory.createEmptyBorder(30,0,0,0)); - donateTextPanel.add(donateText); + donateButtonPanel.setBorder(BorderFactory.createEmptyBorder(60,0,0,0)); donateButtonPanel.add(donate); donatePanel.add(donateButtonPanel); - donatePanel.add(donateTextPanel); - this.add(donatePanel,BorderLayout.CENTER); - this.add(getDonationsPanel(),BorderLayout.LINE_END); + donatePanel.add(this.componentsFactory.wrapToSlide(donateText,AppThemeColor.ADR_BG,4,14,4,14)); + + JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); + root.setBackground(AppThemeColor.FRAME); + root.add(this.componentsFactory.wrapToSlide(donatePanel),BorderLayout.CENTER); + root.add(this.componentsFactory.wrapToSlide(getDonationsPanel()),BorderLayout.LINE_END); + this.add(root,BorderLayout.CENTER); } + private JPanel getDonationsPanel() { JPanel root = componentsFactory.getTransparentPanel(new BorderLayout()); - root.setBorder(BorderFactory.createEmptyBorder(20,0,10,20)); - root.add(componentsFactory.getTextLabel("Thanks a lot for support: "),BorderLayout.PAGE_START); + root.setBackground(AppThemeColor.ADR_BG); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + root.add(componentsFactory.getTextLabel("Thanks a lot for support:"),BorderLayout.PAGE_START); JPanel donationsList = new VerticalScrollContainer(); donationsList.setBackground(AppThemeColor.TRANSPARENT); @@ -110,7 +104,8 @@ public void mouseWheelMoved(MouseWheelEvent e) { } private List getDonations(){ List donations = new ArrayList<>(); - donations.add(new DonationPair("222Craft",AppThemeColor.TEXT_IMPORTANT)); + donations.add(new DonationPair("222Craft",AppThemeColor.TEXT_DEFAULT)); + donations.add(new DonationPair("Blightsand",AppThemeColor.TEXT_DEFAULT)); donations.add(new DonationPair("StubenZocker",AppThemeColor.TEXT_DEFAULT)); donations.add(new DonationPair("SirKultan",AppThemeColor.TEXT_DEFAULT)); return donations; @@ -125,4 +120,14 @@ private class DonationPair{ this.color = color; } } + + @Override + public void onSave() { + + } + + @Override + public void restore() { + + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java new file mode 100644 index 00000000..6854396a --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/settings/page/TaskBarSettingsPagePanel.java @@ -0,0 +1,52 @@ +package com.mercury.platform.ui.components.panel.settings.page; + +import com.mercury.platform.shared.CloneHelper; +import com.mercury.platform.shared.config.Configuration; +import com.mercury.platform.shared.config.configration.PlainConfigurationService; +import com.mercury.platform.shared.config.descriptor.ApplicationDescriptor; +import com.mercury.platform.ui.components.fields.font.FontStyle; +import com.mercury.platform.ui.misc.AppThemeColor; + +import javax.swing.*; +import java.awt.*; + + +public class TaskBarSettingsPagePanel extends SettingsPagePanel { + private PlainConfigurationService applicationConfig; + private ApplicationDescriptor applicationSnapshot; + + @Override + public void createUI() { + super.createUI(); + this.applicationConfig = Configuration.get().applicationConfiguration(); + this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); + + JPanel root = componentsFactory.getJPanel(new GridLayout(0,2),AppThemeColor.ADR_BG); + root.setBorder(BorderFactory.createLineBorder(AppThemeColor.ADR_PANEL_BORDER)); + + JTextField responseField = componentsFactory.getTextField(this.applicationConfig.get().getDndResponseText(), FontStyle.REGULAR, 16f); + responseField.setEnabled(this.applicationConfig.get().isInGameDnd()); + JCheckBox inGameDND = this.componentsFactory.getCheckBox(this.applicationSnapshot.isInGameDnd()); + inGameDND.addActionListener(action -> { + this.applicationSnapshot.setInGameDnd(inGameDND.isSelected()); + responseField.setEnabled(inGameDND.isSelected()); + }); + root.add(componentsFactory.getTextLabel("Enable in-game dnd:", FontStyle.REGULAR)); + root.add(inGameDND); + root.add(componentsFactory.getTextLabel("DND response:", FontStyle.REGULAR)); + root.add(this.componentsFactory.wrapToSlide(responseField,AppThemeColor.ADR_BG)); + this.container.add(this.componentsFactory.wrapToSlide(root)); + } + + @Override + public void onSave() { + this.applicationConfig.set(CloneHelper.cloneObject(this.applicationSnapshot)); + } + + @Override + public void restore() { + this.applicationSnapshot = CloneHelper.cloneObject(this.applicationConfig.get()); + this.removeAll(); + this.createUI(); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java index 78981a7b..b6c13f5f 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/AbstractComponentFrame.java @@ -106,6 +106,9 @@ public void onLocationChange(Point location){ frameDescriptor.setFrameLocation(location); MercuryStoreCore.saveConfigSubject.onNext(true); } + public void onSizeChange(){ + MercuryStoreCore.saveConfigSubject.onNext(true); + } protected void onFrameDragged(Point location){ this.setLocation(location); } @@ -166,12 +169,12 @@ public void mouseReleased(MouseEvent e) { }else { frameDescriptor.setFrameSize(size); } - MercuryStoreCore.saveConfigSubject.onNext(true); + onSizeChange(); }else if(SEResizeSpace){ AbstractComponentFrame.this.setMinimumSize(size); AbstractComponentFrame.this.setMaximumSize(size); frameDescriptor.setFrameSize(AbstractComponentFrame.this.getSize()); - MercuryStoreCore.saveConfigSubject.onNext(true); + onSizeChange(); } EResizeSpace = false; SEResizeSpace = false; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java index 19a5fc36..b869485c 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/container/MessageFrame.java @@ -120,29 +120,33 @@ public void subscribe() { } })); MercuryStoreUI.closeMessage.subscribe(message -> { - InMessagePanel inMessagePanel = this.currentMessages.stream() + List panels = this.currentMessages.stream() .filter(panel -> panel.getMessage().equals(message)) - .collect(Collectors.toList()).get(0); - if(inMessagePanel.isExpanded()){ - this.currentUnfoldCount--; - if(this.currentUnfoldCount < 0){ - this.currentUnfoldCount = 0; + .collect(Collectors.toList()); + if(panels.size() > 0) { + InMessagePanel inMessagePanel = panels.get(0); + if (inMessagePanel.isExpanded()) { + this.currentUnfoldCount--; + if (this.currentUnfoldCount < 0) { + this.currentUnfoldCount = 0; + } } - } - this.remove(inMessagePanel); - this.currentMessages.remove(inMessagePanel); + this.remove(inMessagePanel); + this.currentMessages.remove(inMessagePanel); - if (this.currentMessages.size() == 0) { - this.setVisible(false); - } else if (this.currentMessages.size() >= this.limitMsgCount) { - if(this.currentMessages.size() == this.limitMsgCount) { - this.expandAllFrame.setVisible(false); + if (this.currentMessages.size() == 0) { + this.setVisible(false); + } else if (this.currentMessages.size() >= this.limitMsgCount) { + if (this.currentMessages.size() == this.limitMsgCount) { + this.expandAllFrame.setVisible(false); + } + this.currentMessages.get(this.limitMsgCount - 1).setVisible(true); + this.expandAllFrame.decMessageCount(); } - this.currentMessages.get(this.limitMsgCount - 1).setVisible(true); - this.expandAllFrame.decMessageCount(); + this.pack(); + this.repaint(); + this.setUpExpandButton(); } - this.pack(); - this.setUpExpandButton(); }); MercuryStoreUI.expandMessageSubject.subscribe(state -> this.onExpandMessage()); MercuryStoreUI.collapseMessageSubject.subscribe(state -> this.onCollapseMessage()); @@ -168,6 +172,7 @@ private void addMessage(Message message){ } this.currentMessages.add(inMessagePanel); this.pack(); + this.repaint(); if (this.currentUnfoldCount < this.unfoldCount) { inMessagePanel.expand(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java index 2e0d5d5f..cbb32087 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/titled/SettingsFrame.java @@ -1,94 +1,147 @@ package com.mercury.platform.ui.frame.titled; +import com.mercury.platform.core.update.core.holder.ApplicationHolder; +import com.mercury.platform.shared.config.descriptor.FrameDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; -import com.mercury.platform.ui.components.fields.MercuryTabbedPane; +import com.mercury.platform.ui.components.fields.font.FontStyle; import com.mercury.platform.ui.components.panel.settings.*; +import com.mercury.platform.ui.manager.FramesManager; import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.MercuryStoreUI; import javax.swing.*; import java.awt.*; -import java.util.*; -import java.util.List; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; public class SettingsFrame extends AbstractTitledComponentFrame { - private List innerPanels; - private boolean successfullySaved = true; + private JPanel currentPanel; + private MenuPanel menuPanel; + private JPanel root; public SettingsFrame(){ super(); this.setFocusable(true); this.setFocusableWindowState(true); this.setAlwaysOnTop(false); - this.innerPanels = new ArrayList<>(); this.processingHideEvent = false; this.processHideEffect = false; +// FrameDescriptor frameDescriptor = this.framesConfig.get(this.getClass().getSimpleName()); + this.setPreferredSize(new Dimension(1000,600)); } @Override protected void initialize() { super.initialize(); - this.initContainer(); + this.root = new JPanel(new BorderLayout()); + this.menuPanel = new MenuPanel(); + JPanel leftPanel = this.componentsFactory.getJPanel(new BorderLayout()); + leftPanel.add(this.menuPanel,BorderLayout.CENTER); + leftPanel.add(this.getOperationsButtons(),BorderLayout.PAGE_END); + this.add(leftPanel,BorderLayout.LINE_START); + this.add(this.root,BorderLayout.CENTER); + this.add(this.getBottomPanel(),BorderLayout.PAGE_END); this.pack(); } - private void initContainer() { - - MercuryTabbedPane tabbedPane = new MercuryTabbedPane(this); - - ConfigurationPanel generalSettings = new GeneralSettings(); - this.innerPanels.add(generalSettings); - ConfigurationPanel cbSettings = new NotificationPanelSettings(); - this.innerPanels.add(cbSettings); - ConfigurationPanel taskBarSettings = new TaskBarSettingsPanel(); - this.innerPanels.add(taskBarSettings); - ConfigurationPanel soundSettings = new SoundSettingsPanel(); - this.innerPanels.add(soundSettings); - - tabbedPane.addTab("General",generalSettings); - tabbedPane.addTab("Sound",soundSettings); - tabbedPane.addTab("Notification panel",cbSettings); - tabbedPane.addTab("Task panel",taskBarSettings); -// tabbedPane.addTab("Help",new HelpPanel()); - tabbedPane.addTab("Support",new SupportPanel()); - tabbedPane.addTab("About",new AboutPanel()); - - this.add(tabbedPane, BorderLayout.CENTER); - this.add(getBottomPanel(), BorderLayout.PAGE_END); + @Override + public void onSizeChange() { + super.onSizeChange(); + FrameDescriptor frameDescriptor = this.framesConfig.get(this.getClass().getSimpleName()); + this.setPreferredSize(frameDescriptor.getFrameSize()); } - private JPanel getBottomPanel() { - JPanel panel = new JPanel(); - panel.setBackground(AppThemeColor.HEADER); + public void setContentPanel(JPanel panel){ + if(currentPanel != null){ + this.root.remove(currentPanel); + } + this.root.add(panel,BorderLayout.CENTER); + this.currentPanel = panel; + this.pack(); + this.repaint(); + } + private JPanel getBottomPanel(){ + JPanel root = this.componentsFactory.getJPanel(new BorderLayout()); + root.setBorder(BorderFactory.createMatteBorder(1,0,0,0,AppThemeColor.MSG_HEADER_BORDER)); + root.setBackground(AppThemeColor.ADR_FOOTER_BG); + root.add(this.getSaveButtonPanel(), BorderLayout.LINE_END); + return root; + } + private JPanel getSaveButtonPanel(){ + JPanel root = componentsFactory.getTransparentPanel(new GridLayout(1,0)); + JButton saveButton = componentsFactory.getBorderedButton("Save",16); + saveButton.addActionListener(e -> { + MercuryStoreCore.showingDelaySubject.onNext(true); + this.hideComponent(); + MercuryStoreUI.settingsSaveSubject.onNext(true); + }); + JButton cancelButton = componentsFactory.getButton( + FontStyle.BOLD, + AppThemeColor.FRAME, + BorderFactory.createLineBorder(AppThemeColor.BORDER), + "Cancel", + 16f); + cancelButton.addActionListener(e -> { + MercuryStoreCore.showingDelaySubject.onNext(true); + this.hideComponent(); + MercuryStoreUI.settingsRestoreSubject.onNext(true); + }); + saveButton.setPreferredSize(new Dimension(110, 26)); + cancelButton.setPreferredSize(new Dimension(110, 26)); + root.add(this.componentsFactory.wrapToSlide(saveButton,AppThemeColor.HEADER,2,2,2,2)); + root.add(this.componentsFactory.wrapToSlide(cancelButton,AppThemeColor.HEADER,2,2,2,2)); + return root; + } - JButton save = componentsFactory.getBorderedButton("Save"); - save.addActionListener(e -> { - innerPanels.forEach(settingsPanel -> { - if(!settingsPanel.processAndSave()){ - successfullySaved = false; - } - }); - if(successfullySaved) { - MercuryStoreCore.saveConfigSubject.onNext(true); - hideComponent(); - }else { - successfullySaved = true; - } + private JPanel getOperationsButtons(){ + JPanel root = componentsFactory.getTransparentPanel(new GridLayout(0,1,4,2)); + root.setBorder(BorderFactory.createMatteBorder(0,0,0,1,AppThemeColor.BORDER)); + JButton openTutorial = this.getOperationButton("Open tutorial","app/tutorial.png"); + openTutorial.addActionListener(action -> { + FramesManager.INSTANCE.hideFrame(SettingsFrame.class); + FramesManager.INSTANCE.preShowFrame(NotesFrame.class); }); - JButton close = componentsFactory.getBorderedButton("Close"); - close.addActionListener(e -> { - innerPanels.forEach(ConfigurationPanel::restore); - pack(); - hideComponent(); + JButton checkUpdates = this.getOperationButton("Check for updates", "app/check-update.png"); + checkUpdates.addActionListener(action -> { + ApplicationHolder.getInstance().setManualRequest(true); + MercuryStoreCore.requestPatchSubject.onNext(true); }); - save.setPreferredSize(new Dimension(80, 26)); - close.setPreferredSize(new Dimension(80, 26)); - panel.add(save); - panel.add(close); - return panel; + JButton openTests = this.getOperationButton("Open tests","app/open-tests.png"); + openTests.addActionListener(action -> { + FramesManager.INSTANCE.hideFrame(SettingsFrame.class); + FramesManager.INSTANCE.preShowFrame(TestCasesFrame.class); + }); + root.add(this.componentsFactory.wrapToSlide(openTutorial)); + root.add(this.componentsFactory.wrapToSlide(checkUpdates)); + root.add(this.componentsFactory.wrapToSlide(openTests)); + return root; + } + + private JButton getOperationButton(String title, String iconPath){ + JButton button = this.componentsFactory.getButton(title); + button.setPreferredSize(new Dimension(210,35)); + button.setForeground(AppThemeColor.TEXT_DEFAULT); + button.setHorizontalAlignment(SwingConstants.LEFT); + button.setBackground(AppThemeColor.ADR_BG); + button.setFont(this.componentsFactory.getFont(FontStyle.BOLD,16f)); + button.setIcon(this.componentsFactory.getIcon(iconPath,22)); + button.setBorder(BorderFactory.createCompoundBorder( + BorderFactory.createMatteBorder(1,1,1,1,AppThemeColor.ADR_PANEL_BORDER), + BorderFactory.createEmptyBorder(2,10,2,2))); + return button; } @Override public void subscribe() { + MercuryStoreUI.settingsRepaintSubject.subscribe(state -> { + this.repaint(); + }); + MercuryStoreUI.settingsPackSubject.subscribe(state -> { + this.pack(); + }); + MercuryStoreUI.adrManagerRepaint.subscribe(state -> { + this.repaint(); + }); } @Override diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java index 43b5f155..27dcc682 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/FramesManager.java @@ -22,6 +22,7 @@ import com.mercury.platform.ui.frame.other.SetUpLocationFrame; import com.mercury.platform.ui.frame.titled.chat.ChatFilterFrame; import com.mercury.platform.ui.frame.titled.container.HistoryFrame; +import com.mercury.platform.ui.manager.routing.SettingsRoutManager; import com.mercury.platform.ui.misc.MercuryStoreUI; import com.mercury.platform.ui.misc.note.Note; import com.mercury.platform.ui.misc.note.NotesLoader; @@ -73,7 +74,8 @@ public void start(){ this.framesMap.put(NotesFrame.class, new NotesFrame(notesOnFirstStart, NotesFrame.NotesType.INFO)); this.framesMap.put(HistoryFrame.class,new HistoryFrame()); - this.framesMap.put(SettingsFrame.class,new SettingsFrame()); + SettingsFrame settingsFrame = new SettingsFrame(); + this.framesMap.put(SettingsFrame.class,settingsFrame); this.framesMap.put(TestCasesFrame.class,new TestCasesFrame()); this.framesMap.put(TooltipFrame.class,new TooltipFrame()); this.framesMap.put(NotificationFrame.class,new NotificationFrame()); @@ -98,6 +100,7 @@ public void start(){ } } }); + new SettingsRoutManager(settingsFrame); this.subscribe(); this.adrManager.load(); MercuryStoreCore.uiLoadedSubject.onNext(true); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/routing/SettingsPage.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/routing/SettingsPage.java new file mode 100644 index 00000000..ea8d9b89 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/routing/SettingsPage.java @@ -0,0 +1,10 @@ +package com.mercury.platform.ui.manager.routing; + +public enum SettingsPage { + GENERAL_SETTINGS, + SOUND_SETTING, + NOTIFICATION_SETTINGS, + TASK_BAR_SETTINGS, + SUPPORT, + ABOUT +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/manager/routing/SettingsRoutManager.java b/app-ui/src/main/java/com/mercury/platform/ui/manager/routing/SettingsRoutManager.java new file mode 100644 index 00000000..4a447a58 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/manager/routing/SettingsRoutManager.java @@ -0,0 +1,82 @@ +package com.mercury.platform.ui.manager.routing; + +import com.mercury.platform.shared.AsSubscriber; +import com.mercury.platform.shared.store.MercuryStoreCore; +import com.mercury.platform.ui.components.panel.settings.page.*; +import com.mercury.platform.ui.frame.titled.SettingsFrame; +import com.mercury.platform.ui.misc.MercuryStoreUI; + +public class SettingsRoutManager implements AsSubscriber{ + private SettingsPagePanel generalSettings; + private SettingsPagePanel soundSettings; + private SettingsPagePanel notificationSettings; + private SettingsPagePanel taskBarSettings; + private SettingsPagePanel supportPanel; + private SettingsPagePanel aboutPanel; + + private SettingsFrame settingsFrame; + + + public SettingsRoutManager(SettingsFrame settingsFrame) { + this.settingsFrame = settingsFrame; + + this.generalSettings = new GeneralSettingsPagePanel(); + this.soundSettings = new SoundSettingsPagePanel(); + this.generalSettings = new GeneralSettingsPagePanel(); + this.notificationSettings = new NotificationSettingsPagePanel(); + this.taskBarSettings = new TaskBarSettingsPagePanel(); + this.supportPanel = new SupportPagePanel(); + this.aboutPanel = new AboutPagePanel(); + + this.settingsFrame.setContentPanel(this.generalSettings); + this.subscribe(); + } + + @Override + public void subscribe() { + MercuryStoreUI.settingsStateSubject.subscribe(state -> { + switch (state){ + case GENERAL_SETTINGS:{ + this.settingsFrame.setContentPanel(this.generalSettings); + break; + } + case SOUND_SETTING:{ + this.settingsFrame.setContentPanel(this.soundSettings); + break; + } + case NOTIFICATION_SETTINGS:{ + this.settingsFrame.setContentPanel(this.notificationSettings); + break; + } + case TASK_BAR_SETTINGS:{ + this.settingsFrame.setContentPanel(this.taskBarSettings); + break; + } + case SUPPORT:{ + this.settingsFrame.setContentPanel(this.supportPanel); + break; + } + case ABOUT:{ + this.settingsFrame.setContentPanel(this.aboutPanel); + break; + } + } + }); + MercuryStoreUI.settingsRestoreSubject.subscribe(state -> { + this.generalSettings.restore(); + this.notificationSettings.restore(); + this.soundSettings.restore(); + this.taskBarSettings.restore(); + this.settingsFrame.repaint(); + this.settingsFrame.pack(); + }); + MercuryStoreUI.settingsSaveSubject.subscribe(state -> { + this.generalSettings.onSave(); + this.notificationSettings.onSave(); + this.soundSettings.onSave(); + this.taskBarSettings.onSave(); + MercuryStoreCore.saveConfigSubject.onNext(true); + MercuryStoreUI.settingsPostSubject.onNext(true); + }); + } +} diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java index a13c88b9..0f697b96 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/MercuryStoreUI.java @@ -11,6 +11,7 @@ import com.mercury.platform.ui.components.panel.grid.TabInfoPanel; import com.mercury.platform.ui.components.panel.message.InMessagePanel; import com.mercury.platform.ui.dialog.DialogCallback; +import com.mercury.platform.ui.manager.routing.SettingsPage; import rx.subjects.PublishSubject; import java.util.Map; @@ -52,5 +53,12 @@ public class MercuryStoreUI { public static final PublishSubject adrUpdateSubject = PublishSubject.create(); public static final PublishSubject> adrOpenIconSelectSubject = PublishSubject.create(); + public static final PublishSubject settingsStateSubject = PublishSubject.create(); + public static final PublishSubject settingsRepaintSubject = PublishSubject.create(); + public static final PublishSubject settingsPackSubject = PublishSubject.create(); + public static final PublishSubject settingsSaveSubject = PublishSubject.create(); + public static final PublishSubject settingsRestoreSubject = PublishSubject.create(); + public static final PublishSubject settingsPostSubject = PublishSubject.create(); + public static final PublishSubject onDestroySubject = PublishSubject.create(); } diff --git a/app-ui/src/main/resources/app/add_button.png b/app-ui/src/main/resources/app/add_button.png new file mode 100644 index 00000000..38fe7dd1 Binary files /dev/null and b/app-ui/src/main/resources/app/add_button.png differ diff --git a/app-ui/src/main/resources/app/adr/capture_group_icon.png b/app-ui/src/main/resources/app/adr/capture_group_icon.png new file mode 100644 index 00000000..34151de8 Binary files /dev/null and b/app-ui/src/main/resources/app/adr/capture_group_icon.png differ diff --git a/app-ui/src/main/resources/app/adr/capture_icon.png b/app-ui/src/main/resources/app/adr/capture_icon.png new file mode 100644 index 00000000..34151de8 Binary files /dev/null and b/app-ui/src/main/resources/app/adr/capture_icon.png differ diff --git a/app-ui/src/main/resources/app/app-icon_sepia.png b/app-ui/src/main/resources/app/app-icon_sepia.png new file mode 100644 index 00000000..d9512521 Binary files /dev/null and b/app-ui/src/main/resources/app/app-icon_sepia.png differ diff --git a/app-ui/src/main/resources/app/general_settings.png b/app-ui/src/main/resources/app/general_settings.png new file mode 100644 index 00000000..5ec319bc Binary files /dev/null and b/app-ui/src/main/resources/app/general_settings.png differ diff --git a/app-ui/src/main/resources/app/notification_panel_settings.png b/app-ui/src/main/resources/app/notification_panel_settings.png new file mode 100644 index 00000000..f0acb17f Binary files /dev/null and b/app-ui/src/main/resources/app/notification_panel_settings.png differ diff --git a/app-ui/src/main/resources/app/sound_settings.png b/app-ui/src/main/resources/app/sound_settings.png new file mode 100644 index 00000000..904c43ab Binary files /dev/null and b/app-ui/src/main/resources/app/sound_settings.png differ diff --git a/app-ui/src/main/resources/app/support_settings.png b/app-ui/src/main/resources/app/support_settings.png new file mode 100644 index 00000000..aa091888 Binary files /dev/null and b/app-ui/src/main/resources/app/support_settings.png differ diff --git a/app-ui/src/main/resources/app/task_bar_settings.png b/app-ui/src/main/resources/app/task_bar_settings.png new file mode 100644 index 00000000..357089b9 Binary files /dev/null and b/app-ui/src/main/resources/app/task_bar_settings.png differ diff --git a/app-ui/src/main/resources/app/tutorial.png b/app-ui/src/main/resources/app/tutorial.png index f059d465..04d857af 100644 Binary files a/app-ui/src/main/resources/app/tutorial.png and b/app-ui/src/main/resources/app/tutorial.png differ