<commit_before>package mlga.ui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import javax.swing.JPanel;
import javax.swing.JWindow;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import mlga.io.Preferences;
import mlga.io.Settings;

public class Overlay extends JPanel {
	private static final long serialVersionUID = -470849574354121503L;

	private boolean frameMove = false;
	private boolean mode = false; //true for killer, false for surv
	private int killerAddr = 0;
	private long killerPing = 0;
	private HashMap<Integer, Long> survivors = new HashMap<Integer, Long>();
	private final Font roboto = Font.createFont(Font.TRUETYPE_FONT, ClassLoader.getSystemClassLoader().getResourceAsStream("resources/Roboto-Medium.ttf")).deriveFont(15f);;

	public Overlay() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, FontFormatException, IOException{
		Preferences.init();
		
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		this.setOpaque(false);
		final JWindow frame = new JWindow();
		frame.setBackground(new Color(0, 0, 0, 0));
		frame.setFocusableWindowState(false);

		frame.add(this);
		frame.setAlwaysOnTop(true);
		frame.addMouseListener(new MouseListener(){
			@Override
			public void mouseClicked(MouseEvent e){
				if(e.getClickCount() >= 2 && !SwingUtilities.isRightMouseButton(e)){
					frameMove = !frameMove;
					Settings.set("frame_x", frame.getLocationOnScreen().x);
					Settings.set("frame_y", frame.getLocationOnScreen().y);
					frame.setFocusableWindowState(frameMove);
				}else if(SwingUtilities.isRightMouseButton(e)){
					if(!e.isShiftDown()){ //Change between Killer/Survivor Mode
						killerPing = 0;
						if(!survivors.isEmpty())
							survivors.clear();
						mode = !mode;
					}else{ //Blocking
						boolean ctrlDown = e.isControlDown();
						boolean altDown = e.isAltDown();
						/*if(mode){ //Killer Mode - TODO Fix Positions
							System.out.println("Pos: "+ e.getX()+","+e.getY());
							int yPos = e.getY();
							short selection = 0;
							Set<String> survAddresses = survivors.keySet();

							if(yPos >= 0 && yPos < 26 && survivors.keySet().size() >= 1) {
								selection = 0;
							}
							else if(yPos >= 56 && survivors.keySet().size() >= 4){
								selection = 3;
							}else if(yPos >= 26 && yPos < 39 && survivors.keySet().size() >= 2){
								selection = 1;
							}else if(yPos >= 39 && yPos < 56 && survivors.keySet().size() >= 3){
								selection = 2;
							}

							if(!ctrlDown){
								if(altDown){
									System.out.println("Removed Survivor "+selection);
									//Preferences.remove(survAddresses.toArray()[selection]);
								}else{
									System.out.println("Blocked Survivor "+selection);
									//Preferences.set(survAddresses.toArray()[selection], false);
								}
							}else{
								System.out.println("Loved Survivor "+selection);
								//Preferences.set(survAddresses.toArray()[selection], true);
							}
						}*/
						if(!ctrlDown){
							if(altDown){
								Preferences.remove(killerAddr);
							}else{
								Preferences.set(killerAddr, false);
							}
						}else{
							Preferences.set(killerAddr, true);
						}
					}
				}
			}<commit_msg>Removed commented code that would've allowed killers to do BLOCK/LOVE, as it wouldn't be user friendly in any state.<commit_after>package mlga.ui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import javax.swing.JPanel;
import javax.swing.JWindow;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import mlga.io.Preferences;
import mlga.io.Settings;

public class Overlay extends JPanel {
	private static final long serialVersionUID = -470849574354121503L;

	private boolean frameMove = false;
	private boolean mode = false; //true for killer, false for surv
	private int killerAddr = 0;
	private long killerPing = 0;
	private HashMap<Integer, Long> survivors = new HashMap<Integer, Long>();
	private final Font roboto = Font.createFont(Font.TRUETYPE_FONT, ClassLoader.getSystemClassLoader().getResourceAsStream("resources/Roboto-Medium.ttf")).deriveFont(15f);;

	public Overlay() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, FontFormatException, IOException{
		Preferences.init();
		
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		this.setOpaque(false);
		final JWindow frame = new JWindow();
		frame.setBackground(new Color(0, 0, 0, 0));
		frame.setFocusableWindowState(false);

		frame.add(this);
		frame.setAlwaysOnTop(true);
		frame.addMouseListener(new MouseListener(){
			@Override
			public void mouseClicked(MouseEvent e){
				if(e.getClickCount() >= 2 && !SwingUtilities.isRightMouseButton(e)){
					frameMove = !frameMove;
					Settings.set("frame_x", frame.getLocationOnScreen().x);
					Settings.set("frame_y", frame.getLocationOnScreen().y);
					frame.setFocusableWindowState(frameMove);
				}else if(SwingUtilities.isRightMouseButton(e)){
					if(!e.isShiftDown()){ //Change between Killer/Survivor Mode
						killerPing = 0;
						if(!survivors.isEmpty())
							survivors.clear();
						mode = !mode;
					}else{ //Blocking
						boolean ctrlDown = e.isControlDown();
						boolean altDown = e.isAltDown();
						
						if(!ctrlDown){
							if(altDown){
								Preferences.remove(killerAddr);
							}else{
								Preferences.set(killerAddr, false);
							}
						}else{
							Preferences.set(killerAddr, true);
						}
					}
				}
			}
{'fraction_non_alphanumeric': 0.12436143039591316, 'fraction_numerical': 0.01277139208173691, 'mean_word_length': 3.875486381322957, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2066612', 'n_tokens_mistral': 2437, 'n_tokens_neox': 1913, 'n_words': 402}