Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Exslims committed Sep 3, 2017
1 parent c70c1da commit 997e934
Show file tree
Hide file tree
Showing 18 changed files with 197 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public NotificationSettingsDescriptor getDefault() {
defaultOutButtons.add(new ResponseButtonDescriptor(0, false, "thanks", "thanks", new HotKeyDescriptor()));
notificationSettingsDescriptor.setButtons(defaultButtons);
notificationSettingsDescriptor.setOutButtons(defaultOutButtons);

List<String> autoCloseTriggers = new ArrayList<>();
autoCloseTriggers.add("This player has DND mode enabled");
autoCloseTriggers.add("That character is not online.");
autoCloseTriggers.add("This player is AFK.");
notificationSettingsDescriptor.setAutoCloseTriggers(autoCloseTriggers);
return notificationSettingsDescriptor;
}

Expand All @@ -49,6 +55,11 @@ public void validate() {
if (this.get().getOutButtons().size() == 0) {
this.get().getOutButtons().add(new ResponseButtonDescriptor(0, false, "thanks", "thanks", new HotKeyDescriptor()));
}
if (this.get().getAutoCloseTriggers().size() == 0) {
this.get().getAutoCloseTriggers().add("This player has DND mode enabled");
this.get().getAutoCloseTriggers().add("That character is not online.");
this.get().getAutoCloseTriggers().add("This player is AFK.");
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,87 +11,157 @@ public enum HotKeyType implements Serializable {
public String getIconPath() {
return "app/trade.png";
}

@Override
public String getTooltip() {
return "Offer trade";
}
},
N_OPEN_CHAT {
@Override
public String getIconPath() {
return "app/openChat.png";
}

@Override
public String getTooltip() {
return "Message this player";
}
},
N_CLOSE_NOTIFICATION {
@Override
public String getIconPath() {
return "app/close.png";
}

@Override
public String getTooltip() {
return "Close notification";
}
},
//Incoming notification
N_INVITE_PLAYER {
@Override
public String getIconPath() {
return "app/invite.png";
}

@Override
public String getTooltip() {
return "Invite player";
}
},
N_KICK_PLAYER {
@Override
public String getIconPath() {
return "app/kick.png";
}

@Override
public String getTooltip() {
return "Kick player";
}
},
N_STILL_INTERESTING {
@Override
public String getIconPath() {
return "app/still-interesting.png";
}

@Override
public String getTooltip() {
return "Still interested button";
}
},
N_REPEAT_MESSAGE {
@Override
public String getIconPath() {
return "app/reload-history.png";
}

@Override
public String getTooltip() {
return "Repeat message";
}
},
N_SWITCH_CHAT {
@Override
public String getIconPath() {
return "app/chat_history.png";
}

@Override
public String getTooltip() {
return "Chat history";
}
},
//Outgoing/scanner notification
N_VISITE_HIDEOUT {
@Override
public String getIconPath() {
return "app/visiteHideout.png";
}

@Override
public String getTooltip() {
return "Visit player hideout";
}
},
N_LEAVE {
@Override
public String getIconPath() {
return "app/leave.png";
}

@Override
public String getTooltip() {
return "Leave from party";
}
},
N_BACK_TO_HIDEOUT {
@Override
public String getIconPath() {
return "app/backToHideout.png";
}

@Override
public String getTooltip() {
return null;
}
},
//scanner
N_QUICK_RESPONSE {
@Override
public String getIconPath() {
return "app/chat_scanner_response.png";
}

@Override
public String getTooltip() {
return "Quick response";
}
},
T_TO_HIDEOUT {
@Override
public String getIconPath() {
return "app/hideout.png";
}

@Override
public String getTooltip() {
return "To hideout";
}
},
T_DND {
@Override
public String getIconPath() {
return "app/visible-dnd-mode.png";
}

@Override
public String getTooltip() {
return "Dnd";
}
};

public static boolean contains(HotKeyType entry) {
Expand All @@ -102,4 +172,6 @@ public static boolean contains(HotKeyType entry) {
}

public abstract String getIconPath();

public abstract String getTooltip();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ public class NotificationSettingsDescriptor implements Serializable {
private List<ResponseButtonDescriptor> buttons = new ArrayList<>();
private List<ResponseButtonDescriptor> outButtons = new ArrayList<>();
private String playerNickname = "Set up your nickname in settings";
private List<String> autoCloseTriggers = new ArrayList<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,14 @@ public JLabel getIconLabel(URL url, int size) {
return iconLabel;
}

public JLabel getIconLabel(String iconPath, int size, String tooltip) {
public JLabel getIconLabel(String iconPath, int size, int alignment, String tooltip) {
JLabel iconLabel = new JLabel();
try {
iconLabel.setIcon(getIcon(iconPath, (int) (scale * size)));
} catch (Exception e) {
return getTextLabel(StringUtils.substringBetween(iconPath, "/", "."));
}
iconLabel.setHorizontalAlignment(alignment);
iconLabel.addMouseListener(new TooltipMouseListener(tooltip));
return iconLabel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void paint(Graphics g) {

protected JPanel getTimePanel() {
JPanel root = new JPanel(new BorderLayout());
root.setPreferredSize(new Dimension((int) (46 * this.componentsFactory.getScale()), (int) (26 * this.componentsFactory.getScale())));
root.setPreferredSize(new Dimension((int) (38 * this.componentsFactory.getScale()), (int) (26 * this.componentsFactory.getScale())));
root.setBackground(AppThemeColor.MSG_HEADER);
JLabel timeLabel = componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_MISC, TextAlignment.CENTER, 14, "0s");
Timer timeAgo = new Timer(1000, new ActionListener() {
Expand All @@ -114,7 +114,15 @@ protected JPanel getTimePanel() {
@Override
public void actionPerformed(ActionEvent e) {
seconds++;
String labelText = seconds + "s ";
String labelText = seconds + "s";
if (seconds > 59) {
int minutes = seconds / 60;
if (minutes > 59) {
labelText = minutes / 60 + "h";
} else {
labelText = seconds / 60 + "m";
}
}
timeLabel.setText(labelText);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ private JPanel getHeader() {
interactionPanel.setBackground(AppThemeColor.MSG_HEADER);
JButton inviteMeButton = componentsFactory.getIconButton("app/chat_scanner_response.png", 16, AppThemeColor.MSG_HEADER, TooltipConstants.QUICK_RESPONSE);
inviteMeButton.addActionListener(e -> this.controller.performResponse(this.config.get().getResponseMessage()));
JButton inviteButton = componentsFactory.getIconButton("app/invite.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.INVITE);
inviteButton.addActionListener(e -> {
this.controller.performInvite();
root.setBorder(BorderFactory.createLineBorder(AppThemeColor.HEADER_SELECTED_BORDER));
});
JButton visiteHideout = componentsFactory.getIconButton("app/visiteHideout.png", 16, AppThemeColor.MSG_HEADER, TooltipConstants.VISIT_HO);
visiteHideout.addActionListener(e -> this.controller.visitHideout());
JButton tradeButton = componentsFactory.getIconButton("app/trade.png", 15, AppThemeColor.MSG_HEADER, TooltipConstants.TRADE);
Expand All @@ -76,6 +81,7 @@ private JPanel getHeader() {
this.controller.performHide();
});
interactionPanel.add(inviteMeButton);
interactionPanel.add(inviteButton);
interactionPanel.add(visiteHideout);
interactionPanel.add(tradeButton);
interactionPanel.add(leaveButton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,17 @@
import com.mercury.platform.shared.config.descriptor.HotKeyPair;
import com.mercury.platform.shared.config.descriptor.HotKeyType;
import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor;
import com.mercury.platform.shared.store.MercuryStoreCore;
import com.mercury.platform.ui.components.fields.font.FontStyle;
import com.mercury.platform.ui.components.fields.font.TextAlignment;
import com.mercury.platform.ui.components.panel.notification.controller.IncomingPanelController;
import com.mercury.platform.ui.misc.AppThemeColor;
import com.mercury.platform.ui.misc.TooltipConstants;
import rx.Subscription;

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


public abstract class TradeIncNotificationPanel<T extends TradeNotificationDescriptor> extends TradeNotificationPanel<T, IncomingPanelController> {
private JLabel nicknameLabel;
private Subscription playerJoinSubscription;
private Subscription playerLeaveSubscription;

protected JPanel getHeader() {
JPanel root = new JPanel(new BorderLayout());
root.setBackground(AppThemeColor.MSG_HEADER);
Expand All @@ -29,8 +23,10 @@ protected JPanel getHeader() {
this.nicknameLabel = this.componentsFactory.getTextLabel(FontStyle.BOLD, AppThemeColor.TEXT_NICKNAME, TextAlignment.LEFTOP, 15f, this.getNicknameText());
nicknameLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 5));
nickNamePanel.add(this.getExpandButton(), BorderLayout.LINE_START);
nickNamePanel.add(this.nicknameLabel, BorderLayout.CENTER);
nickNamePanel.add(this.getForPanel("app/incoming_arrow.png"), BorderLayout.LINE_END);
JPanel headerPanel = this.componentsFactory.getJPanel(new GridLayout(1, 0, 3, 0), AppThemeColor.MSG_HEADER);
headerPanel.add(this.nicknameLabel);
headerPanel.add(this.getForPanel("app/incoming_arrow.png"));
nickNamePanel.add(headerPanel, BorderLayout.CENTER);
root.add(nickNamePanel, BorderLayout.CENTER);

JPanel opPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.MSG_HEADER);
Expand Down Expand Up @@ -79,27 +75,6 @@ protected JPanel getHeader() {
return root;
}

@Override
public void subscribe() {
super.subscribe();
this.playerJoinSubscription = MercuryStoreCore.playerJoinSubject.subscribe(nickname -> {
if (this.data.getWhisperNickname().equals(nickname)) {
this.nicknameLabel.setForeground(AppThemeColor.TEXT_SUCCESS);
}
});
this.playerLeaveSubscription = MercuryStoreCore.playerLeftSubject.subscribe(nickname -> {
if (this.data.getWhisperNickname().equals(nickname)) {
this.nicknameLabel.setForeground(AppThemeColor.TEXT_DISABLE);
}
});
}

@Override
public void onViewDestroy() {
super.onViewDestroy();
this.playerLeaveSubscription.unsubscribe();
this.playerJoinSubscription.unsubscribe();
}

protected abstract JButton getStillInterestedButton();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@

public abstract class TradeNotificationPanel<T extends TradeNotificationDescriptor, C extends NotificationController> extends NotificationPanel<T, C> {
protected JPanel responseButtonsPanel;
private Subscription chatSubscription;
protected JLabel nicknameLabel;

private Subscription chatSubscription;
private Subscription playerJoinSubscription;
private Subscription playerLeaveSubscription;
@Override
public void onViewInit() {
super.onViewInit();
Expand Down Expand Up @@ -100,11 +103,16 @@ public void subscribe() {
this.chatSubscription = MercuryStoreCore.plainMessageSubject.subscribe(message -> {
if (this.data.getWhisperNickname().equals(message.getNickName())) {
this.data.getRelatedMessages().add(message);
if (message.getMessage().contains("This player has DND mode enabled")
|| message.getMessage().contains("That character is not online.")
|| message.getMessage().contains("This player is AFK.")) {
this.controller.performHide();
}
}
});
this.playerJoinSubscription = MercuryStoreCore.playerJoinSubject.subscribe(nickname -> {
if (this.data.getWhisperNickname().equals(nickname)) {
this.nicknameLabel.setForeground(AppThemeColor.TEXT_SUCCESS);
}
});
this.playerLeaveSubscription = MercuryStoreCore.playerLeftSubject.subscribe(nickname -> {
if (this.data.getWhisperNickname().equals(nickname)) {
this.nicknameLabel.setForeground(AppThemeColor.TEXT_DISABLE);
}
});
}
Expand All @@ -113,6 +121,8 @@ public void subscribe() {
public void onViewDestroy() {
super.onViewDestroy();
this.chatSubscription.unsubscribe();
this.playerLeaveSubscription.unsubscribe();
this.playerJoinSubscription.unsubscribe();
}

protected JLabel getHistoryButton() {
Expand Down Expand Up @@ -145,11 +155,11 @@ protected JPanel getForPanel(String signIconPath) {
JPanel forPanel = new JPanel(new BorderLayout());
forPanel.setBackground(AppThemeColor.MSG_HEADER);
JLabel separator = componentsFactory.getIconLabel(signIconPath, 16);
forPanel.add(separator, BorderLayout.CENTER);
forPanel.add(separator, BorderLayout.LINE_START);
separator.setHorizontalAlignment(SwingConstants.CENTER);
JPanel currencyPanel = this.getCurrencyPanel(this.data.getCurCount(), this.data.getCurrency());
if (currencyPanel != null) {
forPanel.add(currencyPanel, BorderLayout.LINE_END);
forPanel.add(currencyPanel, BorderLayout.CENTER);
}
return forPanel;
}
Expand All @@ -163,13 +173,13 @@ protected JPanel getCurrencyPanel(Double curCount, String curIconPath) {
}
if (!Objects.equals(curCountStr, "") && curIconPath != null) {
JLabel currencyLabel = componentsFactory.getIconLabel("currency/" + curIconPath + ".png", 26);
JPanel curPanel = new JPanel(new BorderLayout());
JPanel curPanel = this.componentsFactory.getJPanel(new GridLayout(1, 0, 4, 0), AppThemeColor.MSG_HEADER);
curPanel.setAlignmentX(SwingConstants.LEFT);
curPanel.setPreferredSize(new Dimension((int) (this.componentsFactory.getScale() * 70), (int) (this.componentsFactory.getScale() * 26)));
curPanel.setBackground(AppThemeColor.MSG_HEADER);
JLabel countLabel = this.componentsFactory.getTextLabel(curCountStr, FontStyle.BOLD, 17f);
countLabel.setHorizontalAlignment(SwingConstants.RIGHT);
curPanel.add(countLabel, BorderLayout.CENTER);
curPanel.add(currencyLabel, BorderLayout.LINE_END);
curPanel.add(countLabel);
curPanel.add(currencyLabel);
return curPanel;
}
return null;
Expand Down
Loading

0 comments on commit 997e934

Please sign in to comment.