Skip to content

Commit

Permalink
Chat scanner improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Exslims committed Apr 15, 2017
1 parent cec2da6 commit 9b8d7a5
Show file tree
Hide file tree
Showing 18 changed files with 163 additions and 62 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.2";
public static final String APP_VERSION = "1.0.1.3";
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
Expand Up @@ -77,6 +77,8 @@ private static class ConfigManagerHolder {
private String dndResponseText = "Response text";
@Getter
private String defaultWords = "!wtb, uber, boss, perandus";
@Getter
private String quickResponse = "invite me pls";

public ConfigManager() {
minimumFrameSize = new HashMap<>();
Expand All @@ -87,7 +89,7 @@ public ConfigManager() {
minimumFrameSize.put("SettingsFrame",new Dimension(540,400));
minimumFrameSize.put("HistoryFrame",new Dimension(280,400));
minimumFrameSize.put("TimerFrame",new Dimension(240,102));
minimumFrameSize.put("ChatFilterFrame",new Dimension(400,200));
minimumFrameSize.put("ChatFilterFrame",new Dimension(400,100));
minimumFrameSize.put("ItemsGridFrame",new Dimension(150,150));
minimumFrameSize.put("NotesFrame",new Dimension(540,100));
minimumFrameSize.put("ChatFilterSettingsFrame",new Dimension(300,200));
Expand All @@ -113,6 +115,7 @@ public ConfigManager() {
defaultAppSettings.put("showLeague",false);
defaultAppSettings.put("dndResponseText","Response text");
defaultAppSettings.put("defaultWords","!wtb, uber, boss, perandus");
defaultAppSettings.put("quickResponse","invite me pls");

}

Expand Down Expand Up @@ -157,6 +160,7 @@ public void load() {
saveProperty("inGameDnd", String.valueOf(defaultAppSettings.get("inGameDnd")));
saveProperty("dndResponseText", defaultAppSettings.get("dndResponseText"));
saveProperty("defaultWords", defaultAppSettings.get("defaultWords"));
saveProperty("quickResponse", defaultAppSettings.get("quickResponse"));
saveProperty("scaleData", defaultAppSettings.get("scaleData"));
saveProperty("showLeague", String.valueOf(defaultAppSettings.get("showLeague")));

Expand Down Expand Up @@ -218,6 +222,7 @@ private void loadConfigFile(){
showLeague = Boolean.valueOf(loadProperty("showLeague"));
dndResponseText = loadProperty("dndResponseText");
defaultWords = loadProperty("defaultWords");
quickResponse = loadProperty("quickResponse");
} catch (Exception e) {
logger.error("Error in loadConfigFile: ",e);
}
Expand Down Expand Up @@ -465,6 +470,10 @@ public void setDefaultWords(String defaultWords) {
this.defaultWords = defaultWords;
saveProperty("defaultWords",defaultWords);
}
public void setQuickResponse(String quickResponse) {
this.quickResponse = quickResponse;
saveProperty("quickResponse",quickResponse);
}

private List<ResponseButton> getDefaultButtons(){
List<ResponseButton> defaultButtons = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

import java.io.File;

/**
* Created by Константин on 21.02.2017.
*/
public class UpdateManager {
private final static Logger logger = LogManager.getLogger(UpdateManager.class.getSimpleName());
private final static String LOCAL_UPDATER_PATH = System.getenv("USERPROFILE") + "\\AppData\\Local\\MercuryTrade\\local-updater.jar";
Expand All @@ -19,6 +16,7 @@ public void doUpdate(){
logger.debug("Execute local updater, source path: {}",path);
if(new File(JAR_FILE_PATH).exists()) {
Runtime.getRuntime().exec("java -jar " + LOCAL_UPDATER_PATH + " " + "\"" + path + "\"");
System.exit(0);
}
} catch (Exception e1) {
logger.error("Error while execute local-updater: ", e1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ public JTextField getTextField(String text, FontStyle style, float fontSize){
textField.setFont(getSelectedFont(style).deriveFont(scale*fontSize));
}
textField.setForeground(AppThemeColor.TEXT_DEFAULT);
textField.setCaretColor(AppThemeColor.TEXT_DEFAULT);
textField.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(AppThemeColor.TEXT_DEFAULT,1),
BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT,3)
Expand Down Expand Up @@ -541,7 +542,7 @@ public ImageIcon getImage(String iconPath){
public Dimension convertSize(Dimension initialSize){
return new Dimension((int)(initialSize.width * scale),(int)(initialSize.height*scale));
}
public JTextArea getSimpleTextAre(String text){
public JTextArea getSimpleTextArea(String text){
JTextArea area = new JTextArea(text);
area.setEditable(false);
area.setWrapStyleWord(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mercury.platform.ui.components.panel.chat;

import com.mercury.platform.shared.events.EventRouter;
import com.mercury.platform.shared.ConfigManager;
import com.mercury.platform.shared.store.MercuryStore;
import com.mercury.platform.ui.components.ComponentsFactory;
import com.mercury.platform.ui.components.fields.font.FontStyle;
Expand Down Expand Up @@ -45,12 +45,12 @@ public void createUI() {
JPanel miscPanel = componentsFactory.getTransparentPanel(new BorderLayout());
JPanel operationsPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT));

JButton invite = componentsFactory.getIconButton("app/invite.png", 16, AppThemeColor.SLIDE_BG, TooltipConstants.INVITE);
invite.addMouseListener(new MouseAdapter() {
JButton quickResponse = componentsFactory.getIconButton("app/chat_scanner_response.png", 17, AppThemeColor.SLIDE_BG, "Quick response");
quickResponse.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if(SwingUtilities.isLeftMouseButton(e)) {
MercuryStore.INSTANCE.chatCommandSubject.onNext("/invite " + nickName);
MercuryStore.INSTANCE.chatCommandSubject.onNext("@" + nickName + " " + ConfigManager.INSTANCE.getQuickResponse());
}
}
});
Expand All @@ -73,9 +73,9 @@ public void mousePressed(MouseEvent e) {
nickName);
nicknameLabel.setPreferredSize(new Dimension(75,nicknameLabel.getPreferredSize().height));
nicknameLabel.setBorder(null);
invite.setBorder(null);
quickResponse.setBorder(null);
openChat.setBorder(null);
operationsPanel.add(invite);
operationsPanel.add(quickResponse);
operationsPanel.add(openChat);

JPanel nicknamePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ public HtmlMessageBuilder() {
* @param message source message
* @return html equivalent
*/
//<html><font color=red>RED</font> - <font color=navy>Navy</font></html>
public String build(String message) {
List<String> resultStrs = new ArrayList<>();
resultStrs.add("<html>");
String[] words = message.split("((?<= )|(?= )|(?<=\\.)|(?=\\.)|(?<=,)|(?<=\\?)|(?=\\?)|(?=,)|(?<=!)|(?=!)|(?<=/)|(?=/)|(?<=>)|(?=>))");
String[] words = message.split("((?<=\\s)|(?=\\s)|(?<=\\.)|(?=\\.)|(?<=,)|(?<=\\?)|(?=\\?)|(?=,)|(?<=!)|(?=!)|(?<=/)|(?=/)|(?<=>)|(?=>))");
Arrays.stream(words).forEach(word -> {
if(chunkStrings.stream().noneMatch(word::equalsIgnoreCase)){
resultStrs.add(word);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,45 +116,45 @@ public void mouseReleased(MouseEvent e) {
private JPanel getSoundPickerPanel(){
JPanel root = componentsFactory.getTransparentPanel(new BorderLayout());

JLabel soundLabel = componentsFactory.getTextLabel(FontStyle.REGULAR, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, 17f, "Sound");
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);
// 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);
// root.add(container,BorderLayout.CENTER);

return root;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void mousePressed(MouseEvent e) {
}
}
});
JTextArea donateText = componentsFactory.getSimpleTextAre("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 and telling your friends.");
donateText.setPreferredSize(new Dimension(300,150));
JPanel donateTextPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER));
JPanel donateButtonPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected void initialize() {
JPanel root = componentsFactory.getTransparentPanel(new BorderLayout());
root.setBorder(BorderFactory.createLineBorder(AppThemeColor.HEADER));
root.setBackground(AppThemeColor.SLIDE_BG);
root.add(componentsFactory.getSimpleTextAre("Panels UNLOCKED Move them and click Lock when done."),BorderLayout.CENTER);
root.add(componentsFactory.getSimpleTextArea("Panels UNLOCKED Move them and click Lock when done."),BorderLayout.CENTER);

JPanel miscPanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.CENTER));
JButton restoreDefault = componentsFactory.getBorderedButton("Restore defaults");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void initHandlers() {
JLabel tooltipLabel = componentsFactory.getTextLabel(FontStyle.REGULAR,AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP,16f,tooltip);
this.add(tooltipLabel,BorderLayout.CENTER);
}else {
JTextArea tooltipArea = componentsFactory.getSimpleTextAre("");
JTextArea tooltipArea = componentsFactory.getSimpleTextArea("");
this.add(tooltipArea,BorderLayout.CENTER);
tooltipArea.setText(tooltip);
if(tooltip.toCharArray().length < 120){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
* Created by Константин on 18.01.2017.
*/
public abstract class AbstractTitledComponentFrame extends AbstractComponentFrame {
protected JPanel miscPanel;
protected JButton hideButton;
protected JPanel headerPanel;
private JLabel frameTitleLabel;
protected AbstractTitledComponentFrame(String title) {
super(title);
miscPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
miscPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
}

@Override
Expand All @@ -28,7 +26,7 @@ protected void initialize() {

private void initHeaderPanel(){
if(layout instanceof BorderLayout) {
JPanel headerPanel = new JPanel(new BorderLayout());
headerPanel = new JPanel(new BorderLayout());
headerPanel.setBackground(AppThemeColor.HEADER);
headerPanel.setPreferredSize(new Dimension(100,26));
headerPanel.setBorder(BorderFactory.createMatteBorder(0,0,1,0,AppThemeColor.MSG_HEADER_BORDER));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private void renderCurrentNote(){
innerContent.setPreferredSize(new Dimension(530,270));

JLabel image = componentsFactory.getIconLabel(note.getImagePath());
JTextArea textArea = componentsFactory.getSimpleTextAre(note.getText());
JTextArea textArea = componentsFactory.getSimpleTextArea(note.getText());
switch (note.getLayout()){
case VERTICAL:{
innerContent.setLayout(new BoxLayout(innerContent,BoxLayout.Y_AXIS));
Expand Down
Loading

0 comments on commit 9b8d7a5

Please sign in to comment.