Skip to content

Commit

Permalink
Bug fixes and improvements part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Exslims committed Aug 24, 2017
1 parent 9372ffd commit 80bc441
Show file tree
Hide file tree
Showing 34 changed files with 908 additions and 634 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public HotKeysSettingsDescriptor getDefault() {
incNDataList.add(new HotKeyPair(HotKeyType.N_KICK_PLAYER, new HotKeyDescriptor()));
incNDataList.add(new HotKeyPair(HotKeyType.N_STILL_INTERESTING, new HotKeyDescriptor()));
incNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT, new HotKeyDescriptor()));
incNDataList.add(new HotKeyPair(HotKeyType.N_SWITCH_CHAT, new HotKeyDescriptor()));
incNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION, new HotKeyDescriptor()));

List<HotKeyPair> outNDataList = new ArrayList<>();
outNDataList.add(new HotKeyPair(HotKeyType.N_VISITE_HIDEOUT, new HotKeyDescriptor()));
outNDataList.add(new HotKeyPair(HotKeyType.N_TRADE_PLAYER, new HotKeyDescriptor()));
outNDataList.add(new HotKeyPair(HotKeyType.N_LEAVE, new HotKeyDescriptor()));
outNDataList.add(new HotKeyPair(HotKeyType.N_OPEN_CHAT, new HotKeyDescriptor()));
outNDataList.add(new HotKeyPair(HotKeyType.N_REPEAT_MESSAGE, new HotKeyDescriptor()));
outNDataList.add(new HotKeyPair(HotKeyType.N_CLOSE_NOTIFICATION, new HotKeyDescriptor()));

List<HotKeyPair> scannerNDataList = new ArrayList<>();
Expand All @@ -56,6 +56,17 @@ public void validate() {
if (this.selectedProfile.getHotKeysSettingsDescriptor() == null) {
this.selectedProfile.setHotKeysSettingsDescriptor(this.getDefault());
}
List<HotKeyPair> stubNList = new ArrayList<>(this.selectedProfile.getHotKeysSettingsDescriptor().getIncNHotKeysList());
stubNList.forEach(it -> {
if (it.getType().equals(HotKeyType.N_SWITCH_CHAT)) {
this.selectedProfile.getHotKeysSettingsDescriptor().getIncNHotKeysList().remove(it);
}
});
List<HotKeyPair> stubOList = new ArrayList<>(this.selectedProfile.getHotKeysSettingsDescriptor().getOutNHotKeysList());
HotKeyPair hotKeyPair = stubOList.stream().filter(it -> it.getType().equals(HotKeyType.N_REPEAT_MESSAGE)).findAny().orElse(null);
if (hotKeyPair == null) {
this.selectedProfile.getHotKeysSettingsDescriptor().getOutNHotKeysList().add(new HotKeyPair(HotKeyType.N_REPEAT_MESSAGE, new HotKeyDescriptor()));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public String getIconPath() {
return "app/still-interesting.png";
}
},
N_REPEAT_MESSAGE {
@Override
public String getIconPath() {
return "app/reload-history.png";
}
},
N_SWITCH_CHAT {
@Override
public String getIconPath() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
@Data
public class AdrDurationComponentDescriptor extends AdrColoredComponentDescriptor implements Serializable {
private HotKeyDescriptor hotKeyDescriptor = new HotKeyDescriptor();
private String customText = "";
private boolean customTextEnable;
private boolean hotKeyRefresh = true;
private String iconPath = "default_icon.png";
private Double duration = 3.4d;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class NotificationDescriptor {
private String sourceString;
private Date messageDate;
private String whisperNickname;
private NotificationType type;
private List<PlainMessageDescriptor> relatedMessages = new ArrayList<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ protected void paintString(Graphics g, int x, int y, int width, int height, int
Graphics2D g2 = this.prepareAdapter(g);
DecimalFormat decimalFormat = new DecimalFormat(descriptor.getTextFormat());
String progressString = String.valueOf(decimalFormat.format(value));
if (descriptor.isCustomTextEnable()) {
progressString = String.valueOf(descriptor.getCustomText());
}
g2.setFont(tracker.getFont());
Point renderLocation = getStringPlacement(g2, progressString,
x, y, width, height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ public JLabel getTextLabel(String text, FontStyle style, float size) {
return getTextLabel(style, AppThemeColor.TEXT_DEFAULT, TextAlignment.LEFTOP, size, text);
}

public JLabel getTextLabel(String text, FontStyle style, Color color, float size) {
return getTextLabel(style, color, TextAlignment.LEFTOP, size, text);
}

/**
* Get label with icon
*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mercury.platform.ui.components.panel.notification;

import com.mercury.platform.shared.config.descriptor.HotKeyType;
import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor;
import com.mercury.platform.ui.components.fields.font.FontStyle;
import com.mercury.platform.ui.components.fields.font.TextAlignment;
Expand All @@ -11,26 +12,39 @@
import java.text.DecimalFormat;


public class CurrencyIncNotificationPanel extends IncomingNotificationPanel<CurrencyTradeNotificationDescriptor> {
public class CurrencyTradeIncNotificationPanel extends TradeIncNotificationPanel<CurrencyTradeNotificationDescriptor> {
@Override
protected JPanel getMessagePanel() {
JPanel labelsPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME);
JPanel tradePanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME);

tradePanel.add(this.getFromPanel(), BorderLayout.CENTER);
tradePanel.add(this.getForPanel(), BorderLayout.LINE_END);
labelsPanel.add(tradePanel, BorderLayout.CENTER);
JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.FRAME, TooltipConstants.OPEN_CHAT);
openChatButton.addActionListener(e -> controller.performOpenChat());
JButton stillInterestedButton = this.getStillInterestedButton();
JPanel buttons = this.componentsFactory.getJPanel(new GridLayout(1, 0, 5, 0), AppThemeColor.FRAME);
buttons.add(stillInterestedButton);
buttons.add(openChatButton);

JPanel miscPanel = this.componentsFactory.getJPanel(new GridLayout(1, 0, 4, 0), AppThemeColor.FRAME);
miscPanel.add(this.getFromPanel(), BorderLayout.CENTER);
JLabel offerLabel = this.getOfferLabel();
if (offerLabel != null) {
labelsPanel.add(offerLabel, BorderLayout.PAGE_END);
miscPanel.add(offerLabel);
}

this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT, openChatButton);
this.interactButtonMap.put(HotKeyType.N_STILL_INTERESTING, stillInterestedButton);

labelsPanel.add(miscPanel, BorderLayout.CENTER);
labelsPanel.add(buttons, BorderLayout.LINE_END);
return labelsPanel;
}

private JPanel getFromPanel() {
JPanel fromPanel = this.componentsFactory.getJPanel(new FlowLayout(FlowLayout.LEFT, 0, 0), AppThemeColor.FRAME);
fromPanel.add(this.getCurrencyPanel(this.data.getCurrForSaleCount(), this.data.getCurrForSaleTitle()));
fromPanel.add(getCurrencyRatePanel());
JPanel fromPanel = this.componentsFactory.getJPanel(new BorderLayout(4, 0), AppThemeColor.FRAME);
JPanel currencyPanel = this.getCurrencyPanel(this.data.getCurrForSaleCount(), this.data.getCurrForSaleTitle());
currencyPanel.setBackground(AppThemeColor.FRAME);
fromPanel.add(currencyPanel, BorderLayout.LINE_START);
fromPanel.add(getCurrencyRatePanel(), BorderLayout.CENTER);
return fromPanel;
}

Expand All @@ -39,23 +53,21 @@ private JPanel getCurrencyRatePanel() {
Double curCount = this.data.getCurCount();
double rate = curCount / currForSaleCount;
DecimalFormat decimalFormat = new DecimalFormat("#.####");
JPanel ratePanel = componentsFactory.getTransparentPanel(new FlowLayout(FlowLayout.LEFT));
JPanel ratePanel = componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME);
ratePanel.add(componentsFactory.
getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, "("));
getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, "("), BorderLayout.LINE_START);
JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + this.data.getCurrency() + ".png", 26);
currencyLabel.setFont(this.componentsFactory.getFont(FontStyle.BOLD, 18f));
currencyLabel.setForeground(AppThemeColor.TEXT_DEFAULT);
currencyLabel.setText(decimalFormat.format(rate) + ")");
currencyLabel.setBorder(null);
ratePanel.add(currencyLabel);
ratePanel.add(componentsFactory.
getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, decimalFormat.format(rate)));
ratePanel.add(componentsFactory.
getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, ")"));
ratePanel.setBorder(BorderFactory.createEmptyBorder(-5, 0, -5, 0));
ratePanel.add(currencyLabel, BorderLayout.CENTER);
return ratePanel;
}

@Override
protected JButton getStillInterestedButton() {
JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.MSG_HEADER, TooltipConstants.STILL_INTERESTED);
JButton stillIntButton = componentsFactory.getIconButton("app/still-interesting.png", 14, AppThemeColor.FRAME, TooltipConstants.STILL_INTERESTED);
stillIntButton.addActionListener(action -> {
String curCount = this.data.getCurCount().toString();
String responseText = "Hi, are you still interested in ";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.mercury.platform.ui.components.panel.notification;

import com.mercury.platform.shared.config.descriptor.HotKeyType;
import com.mercury.platform.shared.entity.message.CurrencyTradeNotificationDescriptor;
import com.mercury.platform.ui.components.fields.font.FontStyle;
import com.mercury.platform.ui.components.fields.font.TextAlignment;
import com.mercury.platform.ui.misc.AppThemeColor;
import com.mercury.platform.ui.misc.TooltipConstants;

import javax.swing.*;
import java.awt.*;
import java.text.DecimalFormat;


public class CurrencyTradeOutNotificationPanel extends TradeOutNotificationPanel<CurrencyTradeNotificationDescriptor> {
@Override
protected JPanel getMessagePanel() {
JPanel labelsPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME);

JButton openChatButton = componentsFactory.getIconButton("app/openChat.png", 15, AppThemeColor.FRAME, TooltipConstants.OPEN_CHAT);
openChatButton.addActionListener(e -> controller.performOpenChat());
JButton repeatButton = this.getRepeatButton();
JPanel buttons = this.componentsFactory.getJPanel(new GridLayout(1, 0, 5, 0), AppThemeColor.FRAME);
buttons.add(repeatButton);
buttons.add(openChatButton);

JPanel miscPanel = this.componentsFactory.getJPanel(new GridLayout(1, 0, 4, 0), AppThemeColor.FRAME);
miscPanel.add(this.getFromPanel(), BorderLayout.CENTER);
JLabel offerLabel = this.getOfferLabel();
if (offerLabel != null) {
miscPanel.add(offerLabel);
}

this.interactButtonMap.put(HotKeyType.N_OPEN_CHAT, openChatButton);
this.interactButtonMap.put(HotKeyType.N_REPEAT_MESSAGE, repeatButton);

labelsPanel.add(miscPanel, BorderLayout.CENTER);
labelsPanel.add(buttons, BorderLayout.LINE_END);
return labelsPanel;
}

private JPanel getFromPanel() {
JPanel fromPanel = this.componentsFactory.getJPanel(new BorderLayout(4, 0), AppThemeColor.FRAME);
JPanel currencyPanel = this.getCurrencyPanel(this.data.getCurrForSaleCount(), this.data.getCurrForSaleTitle());
currencyPanel.setBackground(AppThemeColor.FRAME);
fromPanel.add(currencyPanel, BorderLayout.LINE_START);
fromPanel.add(getCurrencyRatePanel(), BorderLayout.CENTER);
return fromPanel;
}

private JPanel getCurrencyRatePanel() {
Double currForSaleCount = this.data.getCurrForSaleCount();
Double curCount = this.data.getCurCount();
double rate = curCount / currForSaleCount;
DecimalFormat decimalFormat = new DecimalFormat("#.####");
JPanel ratePanel = componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.FRAME);
ratePanel.add(componentsFactory.
getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_DEFAULT, TextAlignment.CENTER, 18f, null, "("), BorderLayout.LINE_START);
JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + this.data.getCurrency() + ".png", 26);
currencyLabel.setFont(this.componentsFactory.getFont(FontStyle.BOLD, 18f));
currencyLabel.setForeground(AppThemeColor.TEXT_DEFAULT);
currencyLabel.setText(decimalFormat.format(rate) + ")");
currencyLabel.setBorder(null);
ratePanel.add(currencyLabel, BorderLayout.CENTER);
return ratePanel;
}

}
Loading

0 comments on commit 80bc441

Please sign in to comment.