<commit_before>package de.dakror.launcher.panel;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;

import javax.imageio.ImageIO;
import javax.swing.AbstractAction;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;

import de.dakror.gamesetup.util.Helper;
import de.dakror.launcher.DakrorLauncher;
import de.dakror.launcher.Game;
import de.dakror.launcher.settings.UIStateChange.UIState;

/**
 * @author Dakror
 */
public class TitlePanel extends JPanel
{
	private static final long serialVersionUID = 1L;
	public JLabel userName;
	
	JButton userIcon;
	
	public TitlePanel()
	{
		setSize(1200, 90);
		setLayout(new BorderLayout(0, 0));
		
		Box horizontalBox = Box.createHorizontalBox();
		add(horizontalBox, BorderLayout.EAST);
		
		Box verticalBox = Box.createVerticalBox();
		horizontalBox.add(verticalBox);
		
		userName = new JLabel(DakrorLauncher.username);
		userName.setFont(new Font("SANDBOX", Font.PLAIN, 22));
		verticalBox.add(userName);
		userName.setVerticalTextPosition(SwingConstants.TOP);
		userName.setVerticalAlignment(SwingConstants.TOP);
		userName.setAlignmentY(Component.TOP_ALIGNMENT);
		
		Component verticalStrut = Box.createVerticalStrut(50);
		verticalBox.add(verticalStrut);
		
		Component horizontalStrut_1 = Box.createHorizontalStrut(5);
		horizontalBox.add(horizontalStrut_1);
		
		userIcon = new JButton(new AbstractAction("")
		{
			
			private static final long serialVersionUID = 1L;
			
			@Override
			public void actionPerformed(ActionEvent e)
			{
				String link = JOptionPane.showInputDialog(DakrorLauncher.currentLauncher, "Bitte gib den Link zum gewünschten Bild an.", "Profilbild ändern", JOptionPane.QUESTION_MESSAGE).trim();
				if (!link.startsWith("http")) JOptionPane.showMessageDialog(DakrorLauncher.currentLauncher, "Dies ist kein gültiger Link!", "Ungültiger Link!", JOptionPane.ERROR_MESSAGE);
				else
				{
					try
					{
						if (Helper.getURLContent(new URL("http://dakror.de/mp-api/logo?id=" + DakrorLauncher.userId + "&password=" + <PASSWORD> + "&newlogo=" + link)).contains("true")) loadLogo();
						else JOptionPane.showMessageDialog(DakrorLauncher.currentLauncher, "Profilbild konnte nicht geändert werden!", "Fehler!", JOptionPane.ERROR_MESSAGE);
					}
					catch (MalformedURLException e1)
					{
						e1.printStackTrace();
					}
				}
			}
		});
		horizontalBox.add(userIcon);
		userIcon.setOpaque(false);
		userIcon.setBorder(new LineBorder(new Color(0, 0, 0)));
		userIcon.setFocusPainted(false);
		userIcon.setContentAreaFilled(false);
		userIcon.setPreferredSize(new Dimension(80, 80));
		
		userIcon.setIcon(new ImageIcon(Game.getImage("Monster.png").getScaledInstance(userIcon.getPreferredSize().width, userIcon.getPreferredSize().height, Image.SCALE_SMOOTH)));
		
		Component horizontalStrut_2 = Box.createHorizontalStrut(5);
		horizontalBox.add(horizontalStrut_2);
		<commit_msg>bugfix<commit_after>package de.dakror.launcher.panel;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;

import javax.imageio.ImageIO;
import javax.swing.AbstractAction;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;

import de.dakror.gamesetup.util.Helper;
import de.dakror.launcher.DakrorLauncher;
import de.dakror.launcher.Game;
import de.dakror.launcher.settings.UIStateChange.UIState;

/**
 * @author Dakror
 */
public class TitlePanel extends JPanel
{
	private static final long serialVersionUID = 1L;
	public JLabel userName;
	
	JButton userIcon;
	
	public TitlePanel()
	{
		setSize(1200, 90);
		setLayout(new BorderLayout(0, 0));
		
		Box horizontalBox = Box.createHorizontalBox();
		add(horizontalBox, BorderLayout.EAST);
		
		Box verticalBox = Box.createVerticalBox();
		horizontalBox.add(verticalBox);
		
		userName = new JLabel(DakrorLauncher.username);
		userName.setFont(new Font("SANDBOX", Font.PLAIN, 22));
		verticalBox.add(userName);
		userName.setVerticalTextPosition(SwingConstants.TOP);
		userName.setVerticalAlignment(SwingConstants.TOP);
		userName.setAlignmentY(Component.TOP_ALIGNMENT);
		
		Component verticalStrut = Box.createVerticalStrut(50);
		verticalBox.add(verticalStrut);
		
		Component horizontalStrut_1 = Box.createHorizontalStrut(5);
		horizontalBox.add(horizontalStrut_1);
		
		userIcon = new JButton(new AbstractAction("")
		{
			
			private static final long serialVersionUID = 1L;
			
			@Override
			public void actionPerformed(ActionEvent e)
			{
				String link = JOptionPane.showInputDialog(DakrorLauncher.currentLauncher, "Bitte gib den Link zum gewünschten Bild an.", "Profilbild ändern", JOptionPane.QUESTION_MESSAGE);
				if (link == null) return;
				
				link = link.trim();
				
				if (!link.startsWith("http")) JOptionPane.showMessageDialog(DakrorLauncher.currentLauncher, "Dies ist kein gültiger Link!", "Ungültiger Link!", JOptionPane.ERROR_MESSAGE);
				else
				{
					try
					{
						if (Helper.getURLContent(new URL("http://dakror.de/mp-api/logo?id=" + DakrorLauncher.userId + "&password=" + <PASSWORD> + "&newlogo=" + link)).contains("true")) loadLogo();
						else JOptionPane.showMessageDialog(DakrorLauncher.currentLauncher, "Profilbild konnte nicht geändert werden!", "Fehler!", JOptionPane.ERROR_MESSAGE);
					}
					catch (MalformedURLException e1)
					{
						e1.printStackTrace();
					}
				}
			}
		});
		horizontalBox.add(userIcon);
		userIcon.setOpaque(false);
		userIcon.setBorder(new LineBorder(new Color(0, 0, 0)));
		userIcon.setFocusPainted(false);
		userIcon.setContentAreaFilled(false);
		userIcon.setPreferredSize(new Dimension(80, 80));
		
		userIcon.setIcon(new ImageIcon(Game.getImage("Monster.png").getScaledInstance(userIcon.getPreferredSize().width, userIcon.getPreferredSize().height, Image.SCALE_SMOOTH)));
		
		Component horizontalStrut_2 = Box.createHorizontalStrut(5);
		horizontalBox.add(horizontalStrut_2);
		
{'fraction_non_alphanumeric': 0.1161280579885231, 'fraction_numerical': 0.008758683177287828, 'mean_word_length': 5.149489322191272, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6536969', 'n_tokens_mistral': 2446, 'n_tokens_neox': 2138, 'n_words': 380}