• Récent
  • Mots-clés
  • Populaire
  • Utilisateurs
  • Groupes
  • S'inscrire
  • Se connecter
  • S'inscrire
  • Se connecter
  • Recherche
  • Récent
  • Mots-clés
  • Populaire
  • Utilisateurs
  • Groupes

Résolu Ajouter un bouton à un GUI

1.7.x
1.7.10
6
63
13.3k
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 Loison
    Benjamin Loison dernière édition par 30 juil. 2015, 14:51

    Mode comme ça ? :')

    ​package fr.altiscraft.altiscraft.common;
    import org.lwjgl.opengl.GL11;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.audio.PositionedSoundRecord;
    import net.minecraft.client.audio.SoundHandler;
    import net.minecraft.client.gui.FontRenderer;
    import net.minecraft.client.gui.GuiButton;
    import net.minecraft.client.renderer.OpenGlHelper;
    import net.minecraft.util.ResourceLocation;
    @SideOnly(Side.CLIENT)
    public class GuiAC extends GuiButton {
    public GuiAC(int p_i1020_1_, int p_i1020_2_, int p_i1020_3_, String p_i1020_4_) {
    super(p_i1020_1_, p_i1020_2_, p_i1020_3_, p_i1020_4_);
    }
    protected static final ResourceLocation buttonTextures = new ResourceLocation(ModAltisCraft.MODID,
    "textures/gui/widgets.png");
    }

    >! 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
    • DiabolicaTrix
      DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par 30 juil. 2015, 15:05

      Essaie comme ça:

      ​package fr.altiscraft.altiscraft.common;
      import org.lwjgl.opengl.GL11;
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      import net.minecraft.client.Minecraft;
      import net.minecraft.client.audio.PositionedSoundRecord;
      import net.minecraft.client.audio.SoundHandler;
      import net.minecraft.client.gui.FontRenderer;
      import net.minecraft.client.gui.GuiButton;
      import net.minecraft.client.renderer.OpenGlHelper;
      import net.minecraft.util.ResourceLocation;
      @SideOnly(Side.CLIENT)
      public class GuiAC extends GuiButton {
      protected static final ResourceLocation buttonTextures = new ResourceLocation(ModAltisCraft.MODID,
      "textures/gui/widgets.png");
      public GuiAC(int p_i1020_1_, int p_i1020_2_, int p_i1020_3_, String p_i1020_4_) {
      super(p_i1020_1_, p_i1020_2_, p_i1020_3_, p_i1020_4_);
      }
      @Override
      public GuiAC(int id, int xPosition, int yPosition, int width, int height, String displayString) {
      this.width = 200;
      this.height = 20;
      this.enabled = true;
      this.visible = true;
      this.id = id;
      this.xPosition = xPosition;
      this.yPosition = yPosition;
      this.width = width;
      this.height = height;
      this.displayString = displayString;
      }
      public void drawButton(Minecraft mc, int x, int y) {
      if (this.visible) {
      FontRenderer fontrenderer = mc.fontRenderer;
      mc.getTextureManager().bindTexture(buttonTextures);
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      this.field_146123_n = x >= this.xPosition && y >= this.yPosition
      && x < this.xPosition + this.width && y < this.yPosition + this.height;
      int k = this.getHoverState(this.field_146123_n);
      GL11.glEnable(GL11.GL_BLEND);
      OpenGlHelper.glBlendFunc(770, 771, 1, 0);
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
      this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
      this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2,
      46 + k * 20, this.width / 2, this.height);
      this.mouseDragged(mc, x, y);
      int l = 14737632;
      if (packedFGColour != 0) {
      l = packedFGColour;
      } else if (!this.enabled) {
      l = 10526880;
      } else if (this.field_146123_n) {
      l = 16777120;
      }
      this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2,
      this.yPosition + (this.height - 8) / 2, l);
      }
      }
      }
      1 réponse Dernière réponse Répondre Citer 0
      • SCAREX
        SCAREX dernière édition par 30 juil. 2015, 15:53

        Non, il faut ré-écrire la fonction où la texture est dessinée.

        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 Loison
          Benjamin Loison dernière édition par 30 juil. 2015, 15:55

          Donc je suis bon SCAREX avec le dernier code que j’ai envoyé ? 🙂

          >! 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
          • SCAREX
            SCAREX dernière édition par 30 juil. 2015, 15:57

            Le “non” était pour ton message, pas pour DiabolicaTrix. Regarde ce qu’a fait DiabolicaTrix.

            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 Loison
              Benjamin Loison dernière édition par 30 juil. 2015, 16:20

              Ah ok :') j’ai pris son code mais :

              The annotation @Override is disallowed for this location

              et toujours cette même erreur : Implicit super constructor GuiButton() is undefined. Must explicity invoke another constructor

              >! 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
              • DiabolicaTrix
                DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par 30 juil. 2015, 16:35

                Elle est où l’erreur?

                1 réponse Dernière réponse Répondre Citer 0
                • robin4002
                  robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par 30 juil. 2015, 17:03

                  En effet il ne devrait pas avoir de @Override sur le constructeur.

                  1 réponse Dernière réponse Répondre Citer 0
                  • DiabolicaTrix
                    DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par 30 juil. 2015, 17:09

                    Je voulais le mettre sur drawButton mais je me suis trompé, quoique je ne sais pas si il le faut vraiment

                    1 réponse Dernière réponse Répondre Citer 0
                    • Benjamin Loison
                      Benjamin Loison dernière édition par 30 juil. 2015, 17:43

                      Toujours cette erreur : [size=x-smallImplicit super constructor GuiButton() is undefined. Must explicity invoke another constructor ligne 25 sur public GuiAC(…) :]

                      ​package fr.altiscraft.altiscraft.common;
                      import org.lwjgl.opengl.GL11;
                      import cpw.mods.fml.relauncher.Side;
                      import cpw.mods.fml.relauncher.SideOnly;
                      import net.minecraft.client.Minecraft;
                      import net.minecraft.client.audio.PositionedSoundRecord;
                      import net.minecraft.client.audio.SoundHandler;
                      import net.minecraft.client.gui.FontRenderer;
                      import net.minecraft.client.gui.GuiButton;
                      import net.minecraft.client.renderer.OpenGlHelper;
                      import net.minecraft.util.ResourceLocation;
                      @SideOnly(Side.CLIENT)
                      public class GuiAC extends GuiButton {
                      protected static final ResourceLocation buttonTextures = new ResourceLocation(ModAltisCraft.MODID,
                      "textures/gui/widgets.png");
                      public GuiAC(int p_i1020_1_, int p_i1020_2_, int p_i1020_3_, String p_i1020_4_) {
                      super(p_i1020_1_, p_i1020_2_, p_i1020_3_, p_i1020_4_);
                      }
                      public GuiAC(int id, int xPosition, int yPosition, int width, int height, String displayString) {
                      this.width = 200;
                      this.height = 20;
                      this.enabled = true;
                      this.visible = true;
                      this.id = id;
                      this.xPosition = xPosition;
                      this.yPosition = yPosition;
                      this.width = width;
                      this.height = height;
                      this.displayString = displayString;
                      }
                      public void drawButton(Minecraft mc, int x, int y) {
                      if (this.visible) {
                      FontRenderer fontrenderer = mc.fontRenderer;
                      mc.getTextureManager().bindTexture(buttonTextures);
                      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                      this.field_146123_n = x >= this.xPosition && y >= this.yPosition
                      && x < this.xPosition + this.width && y < this.yPosition + this.height;
                      int k = this.getHoverState(this.field_146123_n);
                      GL11.glEnable(GL11.GL_BLEND);
                      OpenGlHelper.glBlendFunc(770, 771, 1, 0);
                      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                      this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
                      this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2,
                      46 + k * 20, this.width / 2, this.height);
                      this.mouseDragged(mc, x, y);
                      int l = 14737632;
                      if (packedFGColour != 0) {
                      l = packedFGColour;
                      } else if (!this.enabled) {
                      l = 10526880;
                      } else if (this.field_146123_n) {
                      l = 16777120;
                      }
                      this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2,
                      this.yPosition + (this.height - 8) / 2, l);
                      }
                      }
                      }

                      >! 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
                      • DiabolicaTrix
                        DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par 30 juil. 2015, 18:00

                        Essaie ça:

                        ​package fr.altiscraft.altiscraft.common;
                        import org.lwjgl.opengl.GL11;
                        import cpw.mods.fml.relauncher.Side;
                        import cpw.mods.fml.relauncher.SideOnly;
                        import net.minecraft.client.Minecraft;
                        import net.minecraft.client.audio.PositionedSoundRecord;
                        import net.minecraft.client.audio.SoundHandler;
                        import net.minecraft.client.gui.FontRenderer;
                        import net.minecraft.client.gui.GuiButton;
                        import net.minecraft.client.renderer.OpenGlHelper;
                        import net.minecraft.util.ResourceLocation;
                        @SideOnly(Side.CLIENT)
                        public class GuiAC extends GuiButton {
                        protected static final ResourceLocation buttonTextures = new ResourceLocation(ModAltisCraft.MODID,
                        "textures/gui/widgets.png");
                           public GuiAC(int id, int xPosition, int yPosition, String nomdubouton)
                           {
                               super(id, xPosition, yPosition, longueurdubouton, largeurdubouton, nomdubouton);
                           }
                        public void drawButton(Minecraft mc, int x, int y) {
                        if (this.visible) {
                        FontRenderer fontrenderer = mc.fontRenderer;
                        mc.getTextureManager().bindTexture(buttonTextures);
                        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                        this.field_146123_n = x >= this.xPosition && y >= this.yPosition
                        && x < this.xPosition + this.width && y < this.yPosition + this.height;
                        int k = this.getHoverState(this.field_146123_n);
                        GL11.glEnable(GL11.GL_BLEND);
                        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
                        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                        this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
                        this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2,
                        46 + k * 20, this.width / 2, this.height);
                        this.mouseDragged(mc, x, y);
                        int l = 14737632;
                        if (packedFGColour != 0) {
                        l = packedFGColour;
                        } else if (!this.enabled) {
                        l = 10526880;
                        } else if (this.field_146123_n) {
                        l = 16777120;
                        }
                        this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2,
                        this.yPosition + (this.height - 8) / 2, l);
                        }
                        }
                        }

                        Donc quand tu appelle ça donne: buttonList.add(new GuiAC(0, guiX + 8, guiY + 12 + 5, label));

                        Il faut que tu retire la grandeur du bouton et que tu l’ajoute à la main dans ta classe GuiAC u il est écrit: longueurdubouton, largeurdubouton

                        1 réponse Dernière réponse Répondre Citer 0
                        • Benjamin Loison
                          Benjamin Loison dernière édition par 30 juil. 2015, 20:17

                          C’est bon merci énormément mais sinon j’ai une autre question ^^ comment changer la couleur du message qu’on a mis lorsqu’on passe la souris dessus comme “RETIRER” ?

                          >! 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
                          • DiabolicaTrix
                            DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par 30 juil. 2015, 20:26

                            Que evux-tu dire: “comme “RETIRER”?”?

                            1 réponse Dernière réponse Répondre Citer 0
                            • isador
                              isador Moddeurs confirmés Modérateurs dernière édition par 30 juil. 2015, 20:38

                              tu parle du changement de texture l’ors du mouseOver? dans ce cas la utilise la fonction isMouseOver et tu rebind la texture

                              1 réponse Dernière réponse Répondre Citer 0
                              • DiabolicaTrix
                                DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par 30 juil. 2015, 21:00

                                public int getHoverState(boolean p_146114_1_)
                                {
                                byte b0 = 1;
                                if (!this.enabled)
                                {
                                b0 = 0;
                                }
                                else if (p_146114_1_)
                                {
                                b0 = 2;
                                }
                                return b0;
                                }

                                Essaye de bidouiller avec ça, la fonction retourne 1 si le bouton est désactivé, 2 si le bouton est activé et deux si la souris la “survole”

                                1 réponse Dernière réponse Répondre Citer 0
                                • SCAREX
                                  SCAREX dernière édition par 30 juil. 2015, 21:25

                                  Il faut regarder la position de la souris, regarde dans la classe GuiButton

                                  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
                                  • DiabolicaTrix
                                    DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par 30 juil. 2015, 21:34

                                    J’ai justement envoyé la fonction que GuiButton utilise.

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • SCAREX
                                      SCAREX dernière édition par 30 juil. 2015, 22:02

                                      Pas vraiment, cette fonction ne fait pas tout, il faut changer le draw.

                                      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
                                      • DiabolicaTrix
                                        DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par 30 juil. 2015, 23:09

                                        Ouais je sais mais j’ai dit ce que la fonction faisait, elle retourne 0, 1 ou 2

                                        1 réponse Dernière réponse Répondre Citer 0
                                        • Benjamin Loison
                                          Benjamin Loison dernière édition par 31 juil. 2015, 01:23

                                          Pour faire sur mon code du bouton “RETIRER”.

                                          Bon par exemple mon ATM il est comme ça : 

                                          Et quand on passe la souris sur le bouton “RETIRER” ça prend cette tête :

                                          Mais j’aimerais que si on zoom bien on voit “RETIRER” (le texte) qui a changé de couleur fait à partir d’un montage comment le faire vraiment ?

                                          >! 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
                                          • 3 / 4
                                          46 sur 63
                                          • Premier message
                                            46/63
                                            Dernier message
                                          Design by Woryk
                                          Contact / Mentions Légales

                                          MINECRAFT FORGE FRANCE © 2018

                                          Powered by NodeBB