Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rit;
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import java.awt.GridBagLayout;
- import java.awt.FlowLayout;
- import javax.swing.JComboBox;
- import java.awt.GridBagConstraints;
- import java.awt.Insets;
- import java.awt.GridLayout;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.util.HashMap;
- import java.util.Vector;
- import javax.swing.JButton;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.JPanel;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import javax.swing.JTextField;
- import javax.swing.JTextArea;
- public class GUI
- {
- private JFrame frmRit;
- private HashMap<String, Integer> items = new HashMap<String, Integer>();
- private Vector<String> itemValues = new Vector<String>();
- private Vector<String> champions = new Vector<String>();
- private final String PATH = "C:/Riot Games/League of Legends/RADS/solutions/lol_game_client_sln/releases/0.0.0.71/deploy/DATA/Characters/";
- private JTextField textField;
- private JTextArea textArea;
- private String result = "";
- // 0 = champ
- // 1 = mode
- // 2-7 = items
- private String[] selectedItems = new String[8];
- private String selectedChampion = "Akali";;
- private String mode = "Classic";
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- GUI window = new GUI();
- window.frmRit.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- */
- public GUI()
- {
- LoadChampions("data/champions.txt");
- LoadItems("data/itamz.txt");
- // 0 = champ
- // 1 = mode
- // 2-7 = items
- selectedItems[0] = "Akali";
- selectedItems[1] = "Classic";
- selectedItems[2] = "Mercury's Treads";
- selectedItems[3] = "Rylai's Crystal Scepter";
- selectedItems[4] = "Hextech Gunblade";
- selectedItems[5] = "Rabadon's Deathcap";
- selectedItems[6] = "Banshee's Veil";
- selectedItems[7] = "Lich Bane";
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- private void initialize()
- {
- frmRit = new JFrame();
- frmRit.setTitle("RIT");
- frmRit.setBounds(100, 100, 412, 343);
- frmRit.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- GridBagLayout gridBagLayout = new GridBagLayout();
- gridBagLayout.columnWidths = new int[]{72, 0};
- gridBagLayout.rowHeights = new int[]{1, 0, 0, 0, 0, 0, 0, 0, 0};
- gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
- gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, Double.MIN_VALUE};
- frmRit.getContentPane().setLayout(gridBagLayout);
- JPanel panel_1 = new JPanel();
- GridBagConstraints gbc_panel_1 = new GridBagConstraints();
- gbc_panel_1.gridheight = 2;
- gbc_panel_1.anchor = GridBagConstraints.WEST;
- gbc_panel_1.insets = new Insets(0, 0, 5, 0);
- gbc_panel_1.fill = GridBagConstraints.VERTICAL;
- gbc_panel_1.gridx = 0;
- gbc_panel_1.gridy = 0;
- frmRit.getContentPane().add(panel_1, gbc_panel_1);
- panel_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
- final JComboBox<String> champs = new JComboBox<String>(champions);
- champs.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- selectedChampion = champs.getSelectedItem().toString();
- textField.setText(CreatePath());
- }
- });
- panel_1.add(champs);
- final JComboBox gameMode = new JComboBox();
- gameMode.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e)
- {
- mode = gameMode.getSelectedItem().toString();
- textField.setText(CreatePath());
- }
- });
- panel_1.add(gameMode);
- gameMode.setModel(new DefaultComboBoxModel(new String[] {"Classic", "Dominion"}));
- JPanel panel_2 = new JPanel();
- GridBagConstraints gbc_panel_2 = new GridBagConstraints();
- gbc_panel_2.insets = new Insets(0, 0, 5, 0);
- gbc_panel_2.fill = GridBagConstraints.HORIZONTAL;
- gbc_panel_2.gridx = 0;
- gbc_panel_2.gridy = 2;
- frmRit.getContentPane().add(panel_2, gbc_panel_2);
- panel_2.setLayout(new GridLayout(1, 0, 0, 0));
- final JComboBox<String> item1 = new JComboBox<String>(itemValues);
- item1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e)
- {
- selectedItems[2] = item1.getSelectedItem().toString();
- textArea.setText(CreateOutput());
- }
- });
- panel_2.add(item1);
- final JComboBox<String> item2 = new JComboBox<String>(itemValues);
- item2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- selectedItems[3] = item2.getSelectedItem().toString();
- textArea.setText(CreateOutput());
- }
- });
- panel_2.add(item2);
- final JComboBox<String> item3 = new JComboBox<String>(itemValues);
- item3.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- selectedItems[4] = item3.getSelectedItem().toString();
- textArea.setText(CreateOutput());
- }
- });
- panel_2.add(item3);
- JPanel panel = new JPanel();
- GridBagConstraints gbc_panel = new GridBagConstraints();
- gbc_panel.insets = new Insets(0, 0, 5, 0);
- gbc_panel.fill = GridBagConstraints.HORIZONTAL;
- gbc_panel.gridx = 0;
- gbc_panel.gridy = 3;
- frmRit.getContentPane().add(panel, gbc_panel);
- panel.setLayout(new GridLayout(1, 0, 0, 0));
- final JComboBox<String> item4 = new JComboBox<String>(itemValues);
- item4.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- selectedItems[5] = item4.getSelectedItem().toString();
- textArea.setText(CreateOutput());
- }
- });
- panel.add(item4);
- final JComboBox<String> item5 = new JComboBox<String>(itemValues);
- item5.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- selectedItems[6] = item5.getSelectedItem().toString();
- textArea.setText(CreateOutput());
- }
- });
- panel.add(item5);
- final JComboBox<String> item6 = new JComboBox<String>(itemValues);
- item6.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- selectedItems[7] = item6.getSelectedItem().toString();
- textArea.setText(CreateOutput());
- }
- });
- panel.add(item6);
- textField = new JTextField();
- GridBagConstraints gbc_textField = new GridBagConstraints();
- gbc_textField.insets = new Insets(0, 0, 5, 0);
- gbc_textField.fill = GridBagConstraints.HORIZONTAL;
- gbc_textField.gridx = 0;
- gbc_textField.gridy = 4;
- frmRit.getContentPane().add(textField, gbc_textField);
- textField.setColumns(10);
- JButton btnSave = new JButton("Save");
- GridBagConstraints gbc_btnSave = new GridBagConstraints();
- gbc_btnSave.anchor = GridBagConstraints.EAST;
- gbc_btnSave.insets = new Insets(0, 0, 5, 0);
- gbc_btnSave.gridx = 0;
- gbc_btnSave.gridy = 5;
- frmRit.getContentPane().add(btnSave, gbc_btnSave);
- btnSave.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- try
- {
- SaveFile();
- }
- catch(IOException e)
- {
- System.out.println(e);
- }
- }
- });
- textArea = new JTextArea();
- textArea.setEditable(false);
- GridBagConstraints gbc_textArea = new GridBagConstraints();
- gbc_textArea.insets = new Insets(0, 0, 5, 0);
- gbc_textArea.fill = GridBagConstraints.BOTH;
- gbc_textArea.gridx = 0;
- gbc_textArea.gridy = 6;
- frmRit.getContentPane().add(textArea, gbc_textArea);
- JPanel panel_3 = new JPanel();
- GridBagConstraints gbc_panel_3 = new GridBagConstraints();
- gbc_panel_3.anchor = GridBagConstraints.NORTHEAST;
- gbc_panel_3.gridx = 0;
- gbc_panel_3.gridy = 7;
- frmRit.getContentPane().add(panel_3, gbc_panel_3);
- panel_3.setLayout(new GridLayout(0, 1, 0, 0));
- }
- public void LoadItems(String filename)
- {
- BufferedReader in = null;
- try
- {
- in = new BufferedReader(new FileReader(filename));
- }
- catch(Exception e)
- {
- System.out.println(e);
- }
- String line;
- try
- {
- while((line = in.readLine()) != null)
- {
- String[] tokens = line.split("\\s+");
- String itemName = "";
- for(int i = 1; i < tokens.length; i++)
- {
- itemName += tokens[i];
- if(i < tokens.length-1)
- {
- itemName += " ";
- }
- }
- items.put(itemName, Integer.parseInt(tokens[0]));
- itemValues.add(itemName);
- System.out.println(tokens[0] + itemName);
- }
- }
- catch(IOException e)
- {
- System.out.println(e);
- }
- try
- {
- in.close();
- }
- catch(IOException e)
- {
- System.out.println(e);
- }
- }
- public void LoadChampions(String filename)
- {
- BufferedReader in = null;
- try
- {
- in = new BufferedReader(new FileReader(filename));
- }
- catch(Exception e)
- {
- System.out.println(e);
- }
- String line;
- try
- {
- while((line = in.readLine()) != null)
- {
- champions.add(line);
- System.out.println(line);
- }
- }
- catch(IOException e)
- {
- System.out.println(e);
- }
- try
- {
- in.close();
- }
- catch(IOException e)
- {
- System.out.println(e);
- }
- }
- public String CreateOutput()
- {
- String s = "";
- String a = System.getProperty("line.separator");
- s += "[ItemSet1]" + a;
- s+= "SetName=Set1" + a;
- s+= "RecItem1=" + items.get(selectedItems[2]) + a;
- s+= "RecItem2=" + items.get(selectedItems[3]) + a;
- s+= "RecItem3=" + items.get(selectedItems[4]) + a;
- s+= "RecItem4=" + items.get(selectedItems[5]) + a;
- s+= "RecItem5=" + items.get(selectedItems[6]) + a;
- s+= "RecItem6=" + items.get(selectedItems[7]) + a;
- return s;
- }
- public void SaveFile() throws IOException
- {
- String fullPath = PATH + selectedChampion + "/";
- File f = new File(fullPath);
- f.mkdirs();
- fullPath += "RecItems";
- if(mode == "Classic")
- fullPath += "CLASSIC.ini";
- else if(mode == "Dominion")
- fullPath += "ODIN.ini";
- FileWriter fstream = new FileWriter(fullPath);
- BufferedWriter out = new BufferedWriter(fstream);
- out.write(CreateOutput());
- out.close();
- }
- public String CreatePath()
- {
- String fullPath = PATH + selectedChampion + "/";
- fullPath += "RecItems";
- if(mode == "Classic")
- fullPath += "CLASSIC.ini";
- else if(mode == "Dominion")
- fullPath += "ODIN.ini";
- return fullPath;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement