MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Perte du textfield lors de redimension de la fenêtre

    Planifier Épinglé Verrouillé Déplacé Sans suite
    1.7.10
    1 Messages 1 Publieurs 925 Vues 1 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • Benjamin LoisonB Hors-ligne
      Benjamin Loison
      dernière édition par

      Bonsoir,

      Sur ce GUI, lorsque que je rentre ce que je veux dans le textfield2, impec’ mais si je met en pleine écran le jeu je perds tout comment régler cela ? 😕

      package diabolicatrix.project;
      
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import org.apache.http.NameValuePair;
      import org.apache.http.client.ClientProtocolException;
      import org.apache.http.client.entity.UrlEncodedFormEntity;
      import org.apache.http.client.methods.CloseableHttpResponse;
      import org.apache.http.client.methods.HttpPost;
      import org.apache.http.impl.client.CloseableHttpClient;
      import org.apache.http.impl.client.HttpClients;
      import org.apache.http.message.BasicNameValuePair;
      import org.lwjgl.opengl.GL11;
      
      import diabolicatrix.project.proxy.ClientProxy;
      import fr.altiscraft.altiscraft.common.GuiCustomMainMenu;
      import net.minecraft.client.Minecraft;
      import net.minecraft.client.gui.GuiButton;
      import net.minecraft.client.gui.GuiScreen;
      import net.minecraft.client.gui.GuiTextField;
      
      public class GuiLogin extends GuiScreen implements IHttpRequest
      {
      
          int guiWidth = 256;
          int guiHeight = 149;
      
          private GuiTextField textfield;
          private GuiTextField textfield2;
      
          public boolean error = false;
      
          public int city = 0;
      
          Random rand = new Random();
      
          public static String selected = null;
      
          public static void setSelected(String selected) {
                  GuiSpawn.selected = selected;
          }
      
          public static String getSelected() {
                  return selected;
          }
      
          @Override
          public void drawScreen(int x, int y, float ticks) {
          this.drawDefaultBackground();
          String str = "Connexion";
          String str2 = "Pseudo:";
          String str3 = "Mot de passe:";
          String str4 = "Invalid !";
                  int guix = this.width / 2;
                  int guiy = this.width / 2;
                  GL11.glColor4f(1, 1, 1, 1);
                  fontRendererObj.drawString(str, guix - (fontRendererObj.getStringWidth(str) / 2), 15, 0xFFFFFF);
                  fontRendererObj.drawString(str2, guix - (fontRendererObj.getStringWidth(str2) / 2), 37, 0xFFFFFF);
                  fontRendererObj.drawString(str3, guix - (fontRendererObj.getStringWidth(str3) / 2), 76, 0xFFFFFF);
                  if(this.error)
                  {
                  fontRendererObj.drawString(str4, guix - (fontRendererObj.getStringWidth(str4) / 2), 26, 0xFF0000);
                  }
                  //this.drawCenteredString(this.fontRendererObj, "Connexion", guix, 15, 0xFFFFFF);
                  this.textfield.drawTextBox();
                  this.textfield2.drawTextBox();
                  super.drawScreen(x, y, ticks);
          }
      
          @Override
          public void initGui() {
                  int guiX = this.width / 2;
                  int guiY = (this.height - guiHeight) / 2;
                  buttonList.clear();
                  buttonList.add(new GuiButton(0, guiX - 52, 115, 104, 20, "Se connecter"));
                  buttonList.add(new GuiButton(1, guiX - 52, 140, 104, 20, "Pas de compte ?"));
                  //buttonList.add(new GuiBAC(1, guiX + 5, guiY + 30, "Pyrgos"));
                  //buttonList.add(new GuiBAC(2, guiX + 5, guiY + 45, "Athira"));
                  //buttonList.add(new GuiBAC(3, guiX + 5, guiY + 60, "Maison/gang"));
                  //buttonList.add(new GuiBAC(4, guiX + 5, guiY + 130, "SPAWN"));
              this.textfield = new GuiTextField(this.fontRendererObj, this.width / 2 - 50, 50, 100, 20);
          textfield.setMaxStringLength(20);
          textfield.setText(Minecraft.getMinecraft().getSession().getUsername());
              this.textfield2 = new GuiTextField(this.fontRendererObj, this.width / 2 - 50, 89, 100, 20);
          textfield2.setMaxStringLength(20);
          textfield2.setText("");
                  super.initGui();
          }
      
      protected void keyTyped(char par1, int par2) {
      super.keyTyped(par1, par2);
      //this.textfield.textboxKeyTyped(par1, par2);
      this.textfield2.textboxKeyTyped(par1, par2);
      }
      
      protected void mouseClicked(int x, int y, int btn) {
      super.mouseClicked(x, y, btn);
      //this.textfield.mouseClicked(x, y, btn);
      this.textfield2.mouseClicked(x, y, btn);
      }
      
          @Override
          protected void actionPerformed(GuiButton btn) {
          switch(btn.id)
          {
          case 0:
              try
              {
                  CloseableHttpResponse response = this.request("http://195.154.194.190/AltisCraftServerAPI/aclog.php", this.textfield.getText(), this.textfield2.getText());
                  try {
      
                  System.out.println(response.getStatusLine().getStatusCode());
                  if(response.getStatusLine().getStatusCode() == 202)
                  {
                  this.error = false;
                  ClientProxy.setLogged(true);
                  /*String path = Minecraft.getMinecraft().mcDataDir.getAbsolutePath().substring(0,Minecraft.getMinecraft().mcDataDir.getAbsolutePath().length()-1) + "AltisCraft\\User\\users.txt";
                  PrintWriter writer = null;
                  try {
                  writer = new PrintWriter(path, "UTF-8");
                  } catch (Exception e) {
                  e.printStackTrace();
                  }
                      writer.println(this.textfield.getText());
                      writer.close();*/
                  Minecraft.getMinecraft().displayGuiScreen(new GuiCustomMainMenu());
                  }
                  else
                  {
                  this.error = true;
                  }
      
                  } finally {
                  response.close();
                  }
              }
              catch(Exception e)
              {
              e.printStackTrace();
              }
          break;
          case 1:
          Minecraft.getMinecraft().displayGuiScreen(new GuiRegister());
          break;
          }
          }
      
          public boolean doesGuiPauseGame() 
          {
          return false;
          }
      
      @Override
      public CloseableHttpResponse request(String url, String username, String password) throws ClientProtocolException, IOException {
      HttpPost post = new HttpPost(url);
      CloseableHttpClient client = HttpClients.createDefault();
      List <namevaluepair>nvps = new ArrayList <namevaluepair>();
      nvps.add(new BasicNameValuePair("username", username));
      nvps.add(new BasicNameValuePair("password", password));
      post.setEntity(new UrlEncodedFormEntity(nvps));
      CloseableHttpResponse response = client.execute(post);
      return response;
      }
      
      }
      
      ```</namevaluepair></namevaluepair>

      >! Développeur de Altis-Life (Arma III) sur Minecraft !
      >! Site web     : https://lemnoslife.com

      1 réponse Dernière réponse Répondre Citer 0
      • 1 / 1
      • Premier message
        Dernier message
      Design by Woryk
      ContactMentions Légales

      MINECRAFT FORGE FRANCE © 2024

      Powered by NodeBB