Skip to content

Commit

Permalink
Merge pull request #114 from NeverScapeAlone/2.6.0-alpha
Browse files Browse the repository at this point in the history
v2.6.0-alpha
  • Loading branch information
Ferrariic committed Aug 11, 2022
2 parents 56abc46 + 1eee062 commit 149a09d
Show file tree
Hide file tree
Showing 7 changed files with 560 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/neverscapealone/NeverScapeAlonePlugin.java
Expand Up @@ -532,6 +532,7 @@ public void createMatchStart(ActionEvent actionEvent) {
String accounts = panel.account_type.getSelectedItem().toString();
String regions = panel.region.getSelectedItem().toString();
String group_passcode = panel.passcode.getText();
String group_notes = panel.notes.getText();

if (checkPasscode(group_passcode)) {
panel.passcode.setBackground(Color.green.darker().darker().darker());
Expand All @@ -541,6 +542,7 @@ public void createMatchStart(ActionEvent actionEvent) {
panel.passcode.setToolTipText("Your passcode contains invalid characters. Try the help button to the right!");
return;
}

panel.connectingPanelManager();
updateDiscordInformation();
websocket.connect(username, NeverScapeAlonePlugin.discordUsername, NeverScapeAlonePlugin.discord_id, config.authToken(), "0", null);
Expand All @@ -553,6 +555,7 @@ public void createMatchStart(ActionEvent actionEvent) {
sub_request.addProperty("accounts", accounts);
sub_request.addProperty("regions", regions);
sub_request.addProperty("group_passcode", group_passcode);
sub_request.addProperty("notes", group_notes);

JsonObject create_request = new JsonObject();
create_request.addProperty("detail", "create_match");
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/neverscapealone/enums/MatchData.java
Expand Up @@ -50,6 +50,9 @@ public class MatchData {
@SerializedName("isPrivate")
@Expose
private Boolean isPrivate;
@SerializedName("notes")
@Expose
private String notes;
@SerializedName("ban_list")
@Expose
private List<Integer> banList;
Expand Down Expand Up @@ -177,4 +180,15 @@ public MatchData withPlayers(List<Player> players) {
return this;
}

public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public MatchData withNotes(String notes) {
this.notes = notes;
return this;
}

}
439 changes: 439 additions & 0 deletions src/main/java/com/neverscapealone/enums/RegionName.java

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/main/java/com/neverscapealone/enums/SearchMatchData.java
Expand Up @@ -60,6 +60,9 @@ public class SearchMatchData {
@SerializedName("party_leader")
@Expose
private String partyLeader;
@SerializedName("notes")
@Expose
private String notes;

public String getId() {
return id;
Expand Down Expand Up @@ -191,4 +194,15 @@ public SearchMatchData withPartyLeader(String partyLeader) {
return this;
}

public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public SearchMatchData withNotes(String notes) {
this.notes = notes;
return this;
}

}
1 change: 1 addition & 0 deletions src/main/java/com/neverscapealone/ui/Icons.java
Expand Up @@ -36,6 +36,7 @@ public class Icons {
// web links and references
public static final ImageIcon COORDINATE_ICON = new ImageIcon(ImageUtil.loadImageResource(PLUGIN_CLASS, "/coordinate.png"));
public static final ImageIcon WORLD_ICON = new ImageIcon(ImageUtil.loadImageResource(PLUGIN_CLASS, "/world.png"));
public static final ImageIcon NOTES_ICON = new ImageIcon(ImageUtil.loadImageResource(PLUGIN_CLASS, "/notes.png"));
public static final ImageIcon SAFETY_ICON = new ImageIcon(ImageUtil.loadImageResource(PLUGIN_CLASS, "/safety.png"));
public static final ImageIcon PROFILE_ICON = new ImageIcon(ImageUtil.loadImageResource(PLUGIN_CLASS, "/profile.png"));
public static final ImageIcon HELP_ICON = new ImageIcon(ImageUtil.loadImageResource(PLUGIN_CLASS, "/help.png"));
Expand Down
97 changes: 89 additions & 8 deletions src/main/java/com/neverscapealone/ui/NeverScapeAlonePanel.java
Expand Up @@ -51,11 +51,14 @@
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Map;
import java.util.Objects;

@Slf4j
Expand All @@ -77,24 +80,26 @@ public class NeverScapeAlonePanel extends PluginPanel {
public static final int SUB_PANEL_SEPARATION_HEIGHT = 7;

public JButton profile_player = new JButton();
public JButton promote_party_leader = new JButton();;
public JButton favorite = new JButton();;
public JButton dislike_button = new JButton();;
public JButton like_button = new JButton();;
public JButton kick = new JButton();;
public JButton promote_party_leader = new JButton();
public JButton favorite = new JButton();
public JButton dislike_button = new JButton();
public JButton like_button = new JButton();
public JButton kick = new JButton();
public final JButton member_count_help_button = new JButton();
public final JButton experience_help_button = new JButton();
public final JButton split_help_button = new JButton();
public final JButton accounts_help_button = new JButton();
public final JButton region_help_button = new JButton();
public final JButton passcode_help_button = new JButton();
public final JButton notes_help_button = new JButton();
SpinnerNumberModel player_size_model = new SpinnerNumberModel(2, 2, 1000, 1);
public final JSpinner party_member_count = new JSpinner(player_size_model);
public final JComboBox<String> experience_level = new JComboBox(new String[]{"Flexible", "Novice", "Average", "Experienced"});
public final JComboBox<String> party_loot = new JComboBox(new String[]{"FFA", "Split"});
public final JComboBox<String> account_type = new JComboBox(new String[]{"ANY", "NORMAL", "IM", "HCIM", "UIM", "GIM", "HCGIM", "UGIM"});
public final JComboBox<String> region = new JComboBox(new String[]{"All Regions", "United States", "North Europe", "Central Europe", "Australia"});
public final JTextField passcode = new JTextField();
public final JTextField notes = new JTextField();
// PANELS
private final JPanel linksPanel;
private final JPanel switchMenuPanel;
Expand Down Expand Up @@ -122,6 +127,9 @@ public class NeverScapeAlonePanel extends PluginPanel {
// GLOBAL VARIABLES
public String step1_activity = "";

// region references
Map<Integer, String> regionReference = RegionName.regionReference();

private static boolean rating_selected = true;
private static boolean discord_selected = true;
private static boolean location_selected = true;
Expand Down Expand Up @@ -365,9 +373,16 @@ private void setMatchPanel(MatchData matchdata) {
}

matchID.setFont(FontManager.getRunescapeBoldFont());
matchID.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
StringSelection selection = new StringSelection(matchdata.getId());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);
}
});
match_ID_panel.add(matchID, cm);
mp.add(match_ID_panel, c);

mp.add(Box.createVerticalStrut(5), c);
c.gridy += 1;

Expand Down Expand Up @@ -473,6 +488,17 @@ private void setMatchPanel(MatchData matchdata) {
current_activity_panel.add(region_label, ca);
ca.gridy +=1;

if (matchdata.getNotes() != null){
current_activity_panel.add(Box.createVerticalStrut(1), ca);
ca.gridy += 1;

JLabel notes_label = new JLabel("Hover for Match Notes");
notes_label.setIcon(Icons.NOTES_ICON);
notes_label.setToolTipText(matchdata.getNotes());
current_activity_panel.add(notes_label, ca);
ca.gridy += 1;
}

c.gridy += 1;
mp.add(current_activity_panel, c);

Expand Down Expand Up @@ -614,6 +640,14 @@ public void mousePressed(MouseEvent e) {
}
}
player_name.setToolTipText("ID: " + String.valueOf(player.getUserId()));
player_name.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
StringSelection selection = new StringSelection(player.getLogin());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);
}
});
player_name_panel.add(player_name, pnp);
player_panel.add(player_name_panel, cp);
cp.gridy += 1;
Expand Down Expand Up @@ -707,8 +741,12 @@ public void mousePressed(MouseEvent e) {
player_location.add(world_label, cs);

JLabel coordinate_label = new JLabel();
coordinate_label.setText("("+String.valueOf(x)+", "+String.valueOf(y)+")");
coordinate_label.setToolTipText("Player's current coordinate");
String region = regionReference.get(regionID);
if (region == null){
region = "Unknown";
}
coordinate_label.setText(region);
coordinate_label.setToolTipText("("+String.valueOf(x)+", "+String.valueOf(y)+")");
coordinate_label.setIcon(Icons.COORDINATE_ICON);
cs.gridx = 2;
player_location.add(coordinate_label, cs);
Expand Down Expand Up @@ -1455,9 +1493,41 @@ private JPanel createSelectionPanel() {
c.weightx = 1;
c.gridy += 1;


c.gridx = 0;
createSelectionPanel.add(header("Notes"), c);
c.gridx = 1;
notes.setToolTipText("Add some notes for your group! Let others know what you're looking for.");
createSelectionPanel.add(notes, c);
c.gridx = 2;
c.weightx = 0;
notes_help_button.setIcon(Icons.NOTES_ICON);
notes_help_button.setSize(16, 16);
notes_help_button.setToolTipText("Click here for help!");
notes_help_button.addActionListener(this::notes_help_button_panel);
notes_help_button.setBorderPainted(false);
notes_help_button.setFocusPainted(false);
notes_help_button.setContentAreaFilled(false);
createSelectionPanel.add(notes_help_button, c);
c.weightx = 1;
c.gridy += 1;


return createSelectionPanel;
}

private void notes_help_button_panel(ActionEvent actionEvent) {
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
String message = "Notes Help" + "\n" +
"The Notes description can be used to add key information" + "\n"+
"that other players should know about your group!" + "\n"+
"Note that offensive language will be censored, and you may" + "\n"+
"be banned from using the plugin on severe offenses" + "\n"+
"Please follow the Rules of RuneScape when describing your group.";
JOptionPane.showMessageDialog(frame, message);
}

private void count_help_button_panel(ActionEvent actionEvent) {
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Expand Down Expand Up @@ -1690,6 +1760,17 @@ public void setSearchPanel(SearchMatches searchMatches) {
sMatch.add(region_label, cMatch);
cMatch.gridy += 1;

if (match.getNotes() != null){
sMatch.add(Box.createVerticalStrut(1), cMatch);
cMatch.gridy += 1;

JLabel notes_label = new JLabel("Hover for Match Notes");
notes_label.setIcon(Icons.NOTES_ICON);
notes_label.setToolTipText(match.getNotes());
sMatch.add(notes_label, cMatch);
cMatch.gridy += 1;
}

/// end match code
c.gridy += 1;
searchMatchPanel.add(Box.createVerticalStrut(5), c);
Expand Down
Binary file added src/main/resources/notes.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 149a09d

Please sign in to comment.