Perte du textfield lors de redimension de la fenêtre



  • 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>