MFF

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

    Ajouter un bouton à un GUI

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    63 Messages 6 Publieurs 14.0k 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.
    • robin4002R Hors-ligne
      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
      dernière édition par

      Tu override la fonction draw du button et tu bind une autre texture.

      1 réponse Dernière réponse Répondre Citer 0
      • SCAREXS Hors-ligne
        SCAREX
        dernière édition par

        Ou tu peux faire un GL11.glColor4f pour colorer la texture en jaune.

        Site web contenant mes scripts : http://SCAREXgaming.github.io

        Pas de demandes de support par MP ni par skype SVP.
        Je n'accepte sur skype que l…

        1 réponse Dernière réponse Répondre Citer 0
        • Benjamin LoisonB Hors-ligne
          Benjamin Loison
          dernière édition par

          Juste c’est normal qu’avec ça :

          ​ @Override
          public void initGui() {
          super.initGui();
          this.buttonList.add(new GuiButton(0, 0, 0, 50, 20, "Pierre"));
          }
          

          Il n’y a aucun bouton ?

          >! 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
          • DiabolicaTrixD Hors-ligne
            DiabolicaTrix Correcteurs Moddeurs confirmés
            dernière édition par

            Perso, j’utilise ça:

            buttonList.add(tradeButton = new GuiButton(0, guiX + 8, guiY + 12 + 5, 98, 20, label));
            

            et ça fonctionne parfaitement.

            EDIT: mets le super.initGui(); après le add

            1 réponse Dernière réponse Répondre Citer 0
            • Benjamin LoisonB Hors-ligne
              Benjamin Loison
              dernière édition par

              Merci de ton aide et sinon j’ai ça :

              ​ @Override
              public void initGui() {
              this.buttonList.add(new GuiButton(0, 0, 0, 50, 20, "Pierre"));
              super.initGui(); 
              }
              

              et ça ne marche toujours pas et pour ton code tu mets quoi comme arguments ?

              >! 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
              • robin4002R Hors-ligne
                robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                dernière édition par

                Avec les coordonnées que tu as mit ton bouton devrait apparaitre tout en haut à gauche.

                1 réponse Dernière réponse Répondre Citer 0
                • Benjamin LoisonB Hors-ligne
                  Benjamin Loison
                  dernière édition par

                  Bas je peux envoyer un screen à part si les coordonnées sont codés de façon à ce que l’extrémité bas droite est tout en haut à gauche et là il n’est pas sur l’écran mais marche…

                  Voilà ma classe complète :

                  ​package fr.altiscraft.altiscraft.common;
                  
                  import java.util.ArrayList;
                  import java.util.List;
                  
                  import org.lwjgl.opengl.GL11;
                  
                  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.util.ResourceLocation;
                  
                  public class GuiATM extends GuiScreen {
                  
                  int guiWidth = 250;
                  int guiHeight = 250;
                  
                  protected List buttonList = new ArrayList();
                  
                  private GuiTextField text;
                  
                  int i = this.height / 4 + 48;
                  
                  @Override
                  public void drawScreen(int x, int y, float ticks) {
                  int guix = (width - guiWidth) / 2;
                  int guiy = (height - guiHeight) / 2;
                  mc.renderEngine.bindTexture(new ResourceLocation(ModAltisCraft.MODID, "textures/gui/Fond.png"));
                  drawTexturedModalRect(guix, guiy, 0, 0, guiWidth, guiHeight);
                  GL11.glColor4f(1, 1, 1, 1);
                  fontRendererObj.drawString("ATM", guix + 120, guiy - 10, 0xFFFF00);
                  super.drawScreen(x, y, ticks);
                  }
                  
                  protected void actionPerformed(GuiButton button) {
                  if (button.id == 0) {
                  }
                  }
                  
                  @Override
                  public boolean doesGuiPauseGame() {
                  return false;
                  }
                  
                  @Override
                  public void initGui() {
                  this.buttonList.add(new GuiButton(0, 0, 0, 50, 20, "Pierre"));
                  super.initGui(); 
                  }
                  
                  }
                  

                  et voilà mon GUI IG : 

                  >! 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
                  • robin4002R Hors-ligne
                    robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                    dernière édition par

                    Surement car ton button est en dehors du gui.
                    Mets comme coordonnées this.guiLeft et this.guiTop

                    1 réponse Dernière réponse Répondre Citer 0
                    • Benjamin LoisonB Hors-ligne
                      Benjamin Loison
                      dernière édition par

                      this.guiLeft, this.guiTop ne marche pas comme ce n’est pas un GUI container comment le convertir ?

                      >! 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
                      • robin4002R Hors-ligne
                        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                        dernière édition par

                        Essayes de mettre ton bouton au centre pour voir s’il s’affiche.

                        1 réponse Dernière réponse Répondre Citer 0
                        • Benjamin LoisonB Hors-ligne
                          Benjamin Loison
                          dernière édition par

                          Toujours rien avec la position de mon texte…

                          ​package fr.altiscraft.altiscraft.common;
                          
                          import java.util.ArrayList;
                          import java.util.List;
                          
                          import org.lwjgl.opengl.GL11;
                          
                          import net.minecraft.client.gui.GuiButton;
                          import net.minecraft.client.gui.GuiScreen;
                          import net.minecraft.client.gui.GuiTextField;
                          import net.minecraft.util.ResourceLocation;
                          
                          public class GuiATM extends GuiScreen {
                          
                          int guiWidth = 140;
                          int guiHeight = 180;
                          
                          protected List buttonList = new ArrayList();
                          
                          private GuiTextField text;
                          
                          int i = this.height / 4 + 48;
                          
                          @Override
                          public void drawScreen(int x, int y, float ticks) {
                          int guix = (width - guiWidth) / 2;
                          int guiy = (height - guiHeight) / 2;
                          mc.renderEngine.bindTexture(new ResourceLocation(ModAltisCraft.MODID, "textures/gui/Fond.png"));
                          drawTexturedModalRect(guix, guiy, 0, 0, guiWidth, guiHeight);
                          GL11.glColor4f(1, 1, 1, 1);
                          fontRendererObj.drawString("Gestion du Compte Bancaire", guix + 2, guiy + 5, 0xFFFFFF);
                          super.drawScreen(x, y, ticks);
                          }
                          
                          protected void actionPerformed(GuiButton button) {
                          if (button.id == 0) {
                          }
                          }
                          
                          @Override
                          public boolean doesGuiPauseGame() {
                          return false;
                          }
                          
                          @Override
                          public void initGui() {
                          int guix = (width - guiWidth) / 2;
                          int guiy = (height - guiHeight) / 2;
                          this.buttonList.add(new GuiButton(0, guix + 2, guiy + 5, 50, 20, "Cobble"));
                          super.initGui(); 
                          }
                          }
                          

                          >! 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
                          • Benjamin LoisonB Hors-ligne
                            Benjamin Loison
                            dernière édition par

                            Toujours rien avec la position de mon texte…

                            ​package fr.altiscraft.altiscraft.common;
                            
                            import java.util.ArrayList;
                            import java.util.List;
                            
                            import org.lwjgl.opengl.GL11;
                            
                            import net.minecraft.client.gui.GuiButton;
                            import net.minecraft.client.gui.GuiScreen;
                            import net.minecraft.client.gui.GuiTextField;
                            import net.minecraft.util.ResourceLocation;
                            
                            public class GuiATM extends GuiScreen {
                            
                            int guiWidth = 140;
                            int guiHeight = 180;
                            
                            protected List buttonList = new ArrayList();
                            
                            private GuiTextField text;
                            
                            int i = this.height / 4 + 48;
                            
                            @Override
                            public void drawScreen(int x, int y, float ticks) {
                            int guix = (width - guiWidth) / 2;
                            int guiy = (height - guiHeight) / 2;
                            mc.renderEngine.bindTexture(new ResourceLocation(ModAltisCraft.MODID, "textures/gui/Fond.png"));
                            drawTexturedModalRect(guix, guiy, 0, 0, guiWidth, guiHeight);
                            GL11.glColor4f(1, 1, 1, 1);
                            fontRendererObj.drawString("Gestion du Compte Bancaire", guix + 2, guiy + 5, 0xFFFFFF);
                            super.drawScreen(x, y, ticks);
                            }
                            
                            protected void actionPerformed(GuiButton button) {
                            if (button.id == 0) {
                            }
                            }
                            
                            @Override
                            public boolean doesGuiPauseGame() {
                            return false;
                            }
                            
                            @Override
                            public void initGui() {
                            int guix = (width - guiWidth) / 2;
                            int guiy = (height - guiHeight) / 2;
                            this.buttonList.add(new GuiButton(0, guix + 2, guiy + 5, 50, 20, "Cobble"));
                            super.initGui(); 
                            }
                            }
                            

                            >! 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
                            • robin4002R Hors-ligne
                              robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                              dernière édition par

                              Mets le GL11.glColor4f(1, 1, 1, 1); avant la fonction drawTexturedModalRect pour voir ?

                              1 réponse Dernière réponse Répondre Citer 0
                              • Benjamin LoisonB Hors-ligne
                                Benjamin Loison
                                dernière édition par

                                Aucun changement…

                                >! 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
                                • robin4002R Hors-ligne
                                  robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                  dernière édition par

                                  Aucune idée dans ce cas 😕

                                  1 réponse Dernière réponse Répondre Citer 0
                                  • Benjamin LoisonB Hors-ligne
                                    Benjamin Loison
                                    dernière édition par

                                    😕 tu n’as pas un code d’un GUI avec un bouton ? à part un container…

                                    >! 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
                                    • robin4002R Hors-ligne
                                      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                      dernière édition par

                                      Non, pas sur mes projets publics.

                                      1 réponse Dernière réponse Répondre Citer 0
                                      • Benjamin LoisonB Hors-ligne
                                        Benjamin Loison
                                        dernière édition par

                                        😞 Quelqu’un d’autre a de l’aide à apporter ?

                                        >! 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
                                        • DiabolicaTrixD Hors-ligne
                                          DiabolicaTrix Correcteurs Moddeurs confirmés
                                          dernière édition par

                                          Perso, j’utilise ça:

                                          package diabolicatrix.base;
                                          
                                          import org.lwjgl.opengl.GL11;
                                          
                                          import ibxm.Player;
                                          import net.minecraft.client.Minecraft;
                                          import net.minecraft.client.gui.GuiButton;
                                          import net.minecraft.client.gui.GuiLabel;
                                          import net.minecraft.client.gui.GuiScreen;
                                          import net.minecraft.util.ResourceLocation;
                                          
                                          public class GuiMouseOver extends GuiScreen {
                                          
                                          int guiWidth = 114;
                                          int guiHeight = 44;
                                          GuiButton tradeButton;
                                          String label = "player";
                                          
                                          public void drawScreen(int x, int y, float tick) {
                                          int guiX = (this.width - guiWidth) / 2;
                                          int guiY = (this.height - guiHeight) / 2;
                                          GL11.glColor4f(1, 1, 1, 1);
                                          drawDefaultBackground();
                                          mc.renderEngine.bindTexture(new ResourceLocation("t4:textures/gui/guiotherplayer.png"));
                                          drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);
                                          fontRendererObj.drawString("Player Menu", (int) (guiX + 25), guiY + 6, 0x000000);
                                          super.drawScreen(x, y, tick);
                                          }
                                          
                                          @Override
                                          public void initGui()
                                          {
                                          int guiX = (this.width - guiWidth) / 2;
                                          int guiY = (this.height - guiHeight) / 2;
                                          buttonList.clear();
                                          buttonList.add(new GuiButton(0, guiX + 8, guiY + 12 + 5, 98, 20, label));
                                          super.initGui();
                                          }
                                          
                                          @Override
                                          protected void actionPerformed(GuiButton btn)
                                          {
                                          switch(btn.id){
                                          case 0:
                                          System.out.println("Trade!");
                                          }
                                          }
                                          }
                                          

                                          et ça donne ça:

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • Benjamin LoisonB Hors-ligne
                                            Benjamin Loison
                                            dernière édition par

                                            C’est bon merci à toi et sinon pour mon bouton orange je fais comment ?

                                            SCAREX avec ta technique,

                                            ​package fr.altiscraft.altiscraft.common;
                                            
                                            import org.lwjgl.opengl.GL11;
                                            
                                            import net.minecraft.client.gui.FontRenderer;
                                            import net.minecraft.client.gui.GuiButton;
                                            import net.minecraft.client.gui.GuiScreen;
                                            import net.minecraft.client.gui.GuiTextField;
                                            import net.minecraft.util.ResourceLocation;
                                            
                                            public class GuiATM extends GuiScreen {
                                            
                                            int guiWidth = 140;
                                            int guiHeight = 220;
                                            GuiButton tradeButton;
                                            String label = "RETIRER";
                                            String labele = "DEPOSER";
                                            String labelee = "TRANSFERER";
                                            String labeleee = "DEPOSER POUR LE GANG";
                                            String labeleeee = "FERMER";
                                            
                                            private GuiTextField textfield;
                                            private GuiTextField textefield;
                                            
                                            public void drawScreen(int x, int y, float tick) {
                                            int guiX = (this.width - guiWidth) / 2;
                                            int guiY = (this.height - guiHeight) / 2;
                                            GL11.glColor4f(1, 1, 1, 1);
                                            mc.renderEngine.bindTexture(new ResourceLocation(ModAltisCraft.MODID, "textures/gui/Fond.png"));
                                            drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);
                                            fontRendererObj.drawString("Gestion du Compte Bancaire", guiX + 2, guiY + 5, 0xFFFFFF);
                                            fontRendererObj.drawString("654 346 €", guiX + 45, guiY + 25, 0xFFFFFF);
                                            fontRendererObj.drawString("21 838 €", guiX + 45, guiY + 42, 0xFFFFFF);
                                            this.textfield.drawTextBox();
                                            this.textefield.drawTextBox();
                                            super.drawScreen(x, y, tick);
                                            }
                                            
                                            @Override
                                            public void initGui() {
                                            int guiX = (this.width - guiWidth) / 2;
                                            int guiY = (this.height - guiHeight) / 2;
                                            buttonList.clear();
                                            buttonList.add(new GuiButton(0, guiX + 20, guiY + 72 + 5, 98, 20, label));
                                            GL11.glColor4f(255, 255, 255, 255);
                                            buttonList.add(new GuiButton(1, guiX + 20, guiY + 95 + 5, 98, 20, labele));
                                            buttonList.add(new GuiButton(2, guiX + 20, guiY + 138 + 5, 98, 20, labelee));
                                            buttonList.add(new GuiButton(3, guiX + 5, guiY + 165 + 5, 130, 20, labeleee));
                                            buttonList.add(new GuiButton(4, guiX + 5, guiY + 190 + 5, 50, 20, labeleeee));
                                            this.textfield = new GuiTextField(this.fontRendererObj, this.width / 2 - 50, this.height / 2 - 55, 98, 20);
                                            textfield.setMaxStringLength(12);
                                            textfield.setText("");
                                            ((GuiTextField) this.textfield).setFocused(true);
                                            this.textefield = new GuiTextField(this.fontRendererObj, this.width / 2 - 50, this.height / 2 + 12, 98, 20);
                                            textefield.setMaxStringLength(20);
                                            textefield.setText("");
                                            ((GuiTextField) this.textefield).setFocused(true);
                                            super.initGui();
                                            }
                                            
                                            protected void keyTyped(char par1, int par2) {
                                            super.keyTyped(par1, par2);
                                            this.textfield.textboxKeyTyped(par1, par2);
                                            this.textefield.textboxKeyTyped(par1, par2);
                                            }
                                            
                                            protected void mouseClicked(int x, int y, int btn) {
                                            super.mouseClicked(x, y, btn);
                                            this.textfield.mouseClicked(x, y, btn);
                                            this.textefield.mouseClicked(x, y, btn);
                                            }
                                            
                                            @Override
                                            protected void actionPerformed(GuiButton btn) {
                                            switch (btn.id) {
                                            case 0:
                                            System.out.println("Trade !");
                                            }
                                            }
                                            }
                                            

                                            et ça donne ce crash-report : http://pastebin.com/yuG0BG6A

                                            EDIT : et pour robin j’ai fais ça :

                                            ​package fr.altiscraft.altiscraft.common;
                                            
                                            import org.lwjgl.opengl.GL11;
                                            
                                            import net.minecraft.client.gui.FontRenderer;
                                            import net.minecraft.client.gui.GuiButton;
                                            import net.minecraft.client.gui.GuiScreen;
                                            import net.minecraft.client.gui.GuiTextField;
                                            import net.minecraft.util.ResourceLocation;
                                            
                                            public class GuiATM extends GuiScreen {
                                            
                                            int guiWidth = 140;
                                            int guiHeight = 220;
                                            GuiButton tradeButton;
                                            String label = "RETIRER";
                                            String labele = "DEPOSER";
                                            String labelee = "TRANSFERER";
                                            String labeleee = "DEPOSER POUR LE GANG";
                                            String labeleeee = "FERMER";
                                            
                                            private GuiTextField textfield;
                                            private GuiTextField textefield;
                                            
                                            public void drawScreen(int x, int y, float tick) {
                                            int guiX = (this.width - guiWidth) / 2;
                                            int guiY = (this.height - guiHeight) / 2;
                                            GL11.glColor4f(1, 1, 1, 1);
                                            mc.renderEngine.bindTexture(new ResourceLocation(ModAltisCraft.MODID, "textures/gui/Fond.png"));
                                            drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);
                                            fontRendererObj.drawString("Gestion du Compte Bancaire", guiX + 2, guiY + 5, 0xFFFFFF);
                                            fontRendererObj.drawString("654 346 €", guiX + 45, guiY + 25, 0xFFFFFF);
                                            fontRendererObj.drawString("21 838 €", guiX + 45, guiY + 42, 0xFFFFFF);
                                            this.textfield.drawTextBox();
                                            this.textefield.drawTextBox();
                                            super.drawScreen(x, y, tick);
                                            }
                                            
                                            @Override
                                            public void initGui() {
                                            int guiX = (this.width - guiWidth) / 2;
                                            int guiY = (this.height - guiHeight) / 2;
                                            buttonList.clear();
                                            buttonList.add(new GuiButton(0, guiX + 20, guiY + 72 + 5, 98, 20, label));
                                            mc.renderEngine.bindTexture(new ResourceLocation(ModAltisCraft.MODID, "textures/gui/widgets.png"));
                                            buttonList.add(new GuiButton(1, guiX + 20, guiY + 95 + 5, 98, 20, labele));
                                            buttonList.add(new GuiButton(2, guiX + 20, guiY + 138 + 5, 98, 20, labelee));
                                            buttonList.add(new GuiButton(3, guiX + 5, guiY + 165 + 5, 130, 20, labeleee));
                                            buttonList.add(new GuiButton(4, guiX + 5, guiY + 190 + 5, 50, 20, labeleeee));
                                            this.textfield = new GuiTextField(this.fontRendererObj, this.width / 2 - 50, this.height / 2 - 55, 98, 20);
                                            textfield.setMaxStringLength(12);
                                            textfield.setText("");
                                            ((GuiTextField) this.textfield).setFocused(true);
                                            this.textefield = new GuiTextField(this.fontRendererObj, this.width / 2 - 50, this.height / 2 + 12, 98, 20);
                                            textefield.setMaxStringLength(20);
                                            textefield.setText("");
                                            ((GuiTextField) this.textefield).setFocused(true);
                                            super.initGui();
                                            }
                                            
                                            protected void keyTyped(char par1, int par2) {
                                            super.keyTyped(par1, par2);
                                            this.textfield.textboxKeyTyped(par1, par2);
                                            this.textefield.textboxKeyTyped(par1, par2);
                                            }
                                            
                                            protected void mouseClicked(int x, int y, int btn) {
                                            super.mouseClicked(x, y, btn);
                                            this.textfield.mouseClicked(x, y, btn);
                                            this.textefield.mouseClicked(x, y, btn);
                                            }
                                            
                                            @Override
                                            protected void actionPerformed(GuiButton btn) {
                                            switch (btn.id) {
                                            case 0:
                                            System.out.println("Trade !");
                                            }
                                            }
                                            }
                                            

                                            mais j’ai ça : http://pastebin.com/u63yRzCt

                                            >! 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
                                            • 2
                                            • 3
                                            • 4
                                            • 2 / 4
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB