Skip to content

Commit

Permalink
Reworked settings gui + bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Exslims committed Aug 13, 2017
1 parent 7d9550d commit e13cae0
Show file tree
Hide file tree
Showing 53 changed files with 1,204 additions and 952 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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<Integer, WhisperNotifierStatus> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
public interface KeyValueConfigurationService<K, T> {
T get(K key);
Map<K,T> getMap();
void set(Map<K,T> map);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

public interface PlainConfigurationService<T> {
T get();
void set(T descriptor);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public Map<String, FrameDescriptor> getMap() {
return this.selectedProfile.getFrameDescriptorMap();
}

@Override
public void set(Map<String, FrameDescriptor> map) {
this.selectedProfile.setFrameDescriptorMap(map);
}

@Override
public Map<String, FrameDescriptor> getDefault() {
return defaultFramesSettings;
Expand Down Expand Up @@ -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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,16 +21,11 @@ public HotKeysConfigurationService(ProfileDescriptor selectedProfile) {
@Override
public Map<String, HotKeyDescriptor> getDefault() {
Map<String, HotKeyDescriptor> 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;
}

Expand All @@ -52,10 +48,20 @@ public Map<String, HotKeyDescriptor> getMap() {
return this.selectedProfile.getHotKeysDataMap();
}

@Override
public void set(Map<String, HotKeyDescriptor> 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("...");
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,10 +21,10 @@ public NotificationConfigurationService(ProfileDescriptor selectedProfile) {
public NotificationDescriptor getDefault() {
NotificationDescriptor notificationDescriptor = new NotificationDescriptor();
List<ResponseButtonDescriptor> 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);
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ public void toDefault() {
public Map<String, Float> getMap() {
return this.selectedProfile.getScaleDataMap();
}

@Override
public void set(Map<String, Float> map) {
this.selectedProfile.setScaleDataMap(map);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ public void validate() {
public ScannerDescriptor get() {
return this.selectedProfile.getScannerDescriptor();
}

@Override
public void set(ScannerDescriptor descriptor) {
this.selectedProfile.setScannerDescriptor(descriptor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public Map<String, SoundDescriptor> getMap() {
return this.selectedProfile.getSoundDescriptorMap();
}

@Override
public void set(Map<String, SoundDescriptor> map) {
this.selectedProfile.setSoundDescriptorMap(map);
}

@Override
public Map<String, SoundDescriptor> getDefault() {
Map<String,SoundDescriptor> defaultSettings = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
public class ResponseButtonDescriptor implements Comparable<ResponseButtonDescriptor>{
@NoArgsConstructor
public class ResponseButtonDescriptor implements Comparable<ResponseButtonDescriptor>,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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit e13cae0

Please sign in to comment.