Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.Vekorax.macro;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.io.UnsupportedEncodingException;
- import java.util.List;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.gui.GuiButton;
- import net.minecraft.client.gui.GuiScreen;
- import net.minecraft.client.gui.GuiTextField;
- import net.minecraft.client.resources.I18n;
- import net.minecraft.util.EnumChatFormatting;
- import org.lwjgl.input.Keyboard;
- public class GUIMacroCustom
- extends GuiScreen
- {
- private GuiTextField textc1;
- private GuiTextField textc2;
- private GuiTextField textc3;
- private GuiButton c1;
- private GuiButton c2;
- private GuiButton c3;
- private GuiButton save;
- private GuiButton leave;
- private GuiScreen lastGui;
- private String m = "c1";
- private int nb = 0;
- private String info;
- private String info2;
- private String Macro1;
- private String Macro2;
- private String Macro3;
- private File saveFile;
- private static final String UTF8 = "UTF-8";
- public GUIMacroCustom(GuiScreen gui)
- {
- this.info = (EnumChatFormatting.GOLD + "Vous n'avez pas besoin de rajoutez le " + EnumChatFormatting.RED + "/ " + EnumChatFormatting.GOLD + "!");
- this.lastGui = gui;
- }
- public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
- {
- drawDefaultBackground();
- this.textc1.drawTextBox();
- this.textc2.drawTextBox();
- this.textc3.drawTextBox();
- drawString(this.fontRendererObj, this.info2, width / 2 - 160, height / 2 - 50, 16777215);
- drawString(this.fontRendererObj, this.info, width / 2 - 100, height / 2 - 94, 16777215);
- drawString(this.fontRendererObj, this.Macro1, width / 2 - 150, height / 2 - 15, 16777215);
- drawString(this.fontRendererObj, this.Macro2, width / 2 - 42, height / 2 - 15, 16777215);
- drawString(this.fontRendererObj, this.Macro3, width / 2 + 63, height / 2 - 15, 16777215);
- super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
- this.Macro1 = "MacroCustom 1";
- this.Macro2 = "MacroCustom 2";
- this.Macro3 = "MacroCustom 3";
- }
- public void onGuiClosed()
- {
- Keyboard.enableRepeatEvents(false);
- }
- public void initGui()
- {
- Keyboard.enableRepeatEvents(true);
- this.buttonList.clear();
- this.textc1 = new GuiTextField(this.fontRendererObj, width / 2 - 155, height / 2, 100, 20);
- ////MACRO 1 ////
- FileInputStream var111 = null;
- try {
- var111 = new FileInputStream(Minecraft.Macro1);
- } catch (FileNotFoundException e1) {
- e1.printStackTrace();
- }
- BufferedReader var112 = new BufferedReader(new InputStreamReader(var111));
- String var113 = null;
- try {
- var113 = var112.readLine();
- } catch (IOException e) {
- e.printStackTrace();
- }
- this.textc1.setFocused(true);
- this.textc1.setText(var113);
- //this.textc1.func_146203_f(32767);
- this.textc2 = new GuiTextField(this.fontRendererObj, width / 2 - 50, height / 2, 100, 20);
- ////MACRO 2 ////
- FileInputStream var114 = null;
- try {
- var114 = new FileInputStream(Minecraft.Macro2);
- } catch (FileNotFoundException e1) {
- e1.printStackTrace();
- }
- BufferedReader var115 = new BufferedReader(new InputStreamReader(var114));
- String var116 = null;
- try {
- var116 = var115.readLine();
- } catch (IOException e) {
- e.printStackTrace();
- }
- this.textc2.setText(var116);
- //this.textc2.func_146203_f(32767);
- this.textc2.setFocused(true);
- this.textc3 = new GuiTextField(this.fontRendererObj, width / 2 + 55, height / 2, 100, 20);
- //// MACRO 3 ////
- FileInputStream var117 = null;
- try {
- var117 = new FileInputStream(Minecraft.Macro3);
- } catch (FileNotFoundException e3) {
- e3.printStackTrace();
- }
- BufferedReader var118 = new BufferedReader(new InputStreamReader(var117));
- String var119 = null;
- try {
- var119 = var118.readLine();
- } catch (IOException e) {
- e.printStackTrace();
- }
- this.textc3.setText(var119);
- //this.textc3.func_146203_f(32767);
- this.textc3.setFocused(true);
- this.buttonList.add(new GuiButton(3, width / 2, height / 2 + 50, 98, 20, I18n.format(EnumChatFormatting.RED + "Sauvegarder!", new Object[0])));
- this.buttonList.add(new GuiButton(4, width / 2 - 100, height / 2 + 50, 98, 20, I18n.format(EnumChatFormatting.RED + "Retour", new Object[0])));
- }
- public void mouseClicked(int i, int j, int k)
- {
- super.mouseClicked(i, j, k);
- this.textc1.mouseClicked(i, j, k);
- this.textc2.mouseClicked(i, j, k);
- this.textc3.mouseClicked(i, j, k);
- }
- protected void keyTyped(char c, int i)
- {
- if (c != '/') {
- if (this.textc1.isFocused()) {
- this.textc1.textboxKeyTyped(c, i);
- } else if (this.textc2.isFocused()) {
- this.textc2.textboxKeyTyped(c, i);
- } else if (this.textc3.isFocused()) {
- this.textc3.textboxKeyTyped(c, i);
- }
- }
- }
- protected void actionPerformed(GuiButton b)
- {
- switch (b.id)
- {
- case 3:
- if ((this.textc1.getText().isEmpty()) && (this.textc2.getText().isEmpty()) && (this.textc3.getText().isEmpty())) {
- this.info2 = "�2�3Erreur, veuillez rentrez les commandes voulu pour vos macros...";
- } else {
- try
- {
- this.mc.displayGuiScreen(this.lastGui);
- if ((!this.textc1.getText().isEmpty())) {
- FileWriter e1 = new FileWriter(Minecraft.Macro1);
- BufferedWriter bw1 = new BufferedWriter(e1);
- bw1.write(this.textc1.getText());
- bw1.close();
- }
- if ((!this.textc2.getText().isEmpty())) {
- FileWriter e2 = new FileWriter(Minecraft.Macro2);
- BufferedWriter bw2 = new BufferedWriter(e2);
- bw2.write(this.textc2.getText());
- bw2.close();
- }
- if ((!this.textc3.getText().isEmpty())) {
- FileWriter e3 = new FileWriter(Minecraft.Macro3);
- BufferedWriter bw3 = new BufferedWriter(e3);
- bw3.write(this.textc3.getText());
- bw3.close();
- }
- }
- catch (IOException var4)
- {
- var4.printStackTrace();
- }
- }
- break;
- case 4:
- this.mc.displayGuiScreen(this.lastGui);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement