GuiCustomMainMenu
-
rien ne vaut une image pour comprendre :
a votre avis pourquois ça ne marche pas ? ma class et une question c’est quoi le gui qui gére les broadcast ?package menu.client.custommenu; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.SideOnly; import ma.Yeyvo.scandicraft.common.MainClass; import java.awt.Desktop; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Method; import java.net.URI; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiLanguage; import net.minecraft.client.gui.GuiOptions; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiSelectWorld; import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.resources.IResourceManager; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Session; import net.minecraft.world.demo.DemoWorldServer; import net.minecraft.world.storage.ISaveFormat; import net.minecraft.world.storage.WorldInfo; import org.apache.commons.io.Charsets; import org.lwjgl.opengl.GL11; import org.lwjgl.util.glu.Project; @SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) public class GuiCustomMainMenu extends GuiScreen { private static final Random rand = new Random(); private float updateCounter; private String splashText = "missingno"; private GuiButton buttonResetDemo; private int panoramaTimer; private DynamicTexture viewportTexture; private boolean field_96141_q = true; private static boolean field_96140_r; private static boolean field_96139_s; private final Object field_104025_t = new Object(); private String noticeMessage; private String noticeLink; private static final ResourceLocation splashTexts = new ResourceLocation("texts/splashes.txt"); private final ResourceLocation minecraftTitleTextures = new ResourceLocation(MainClass.MODID, "textures/gui/title.png"); private final ResourceLocation backGround = new ResourceLocation(MainClass.MODID, "textures/gui/menu.png"); public static final String noticeMessageInformation = " sur ScandiCraft! "; private int field_92024_r; private int field_92023_s; private int field_92022_t; private int field_92021_u; private int field_92020_v; private int field_92019_w; private ResourceLocation field_110351_G; private GuiButton minecraftRealmsButton; /* 67 */ private GuiButton fmlModButton = null; public GuiCustomMainMenu() { /* 71 */ BufferedReader bufferedreader = null; try { /* 76 */ ArrayList arraylist = new ArrayList(); /* 77 */ bufferedreader = new BufferedReader(new InputStreamReader( Minecraft.getMinecraft().getResourceManager().getResource(splashTexts).getInputStream(), Charsets.UTF_8)); String s; /* 79 */ while ((s = bufferedreader.readLine()) != null) { /* 81 */ s = s.trim(); /* 83 */ if (!s.isEmpty()) { /* 85 */ arraylist.add(s); } } do { /* 91 */ this.splashText = ((String) arraylist.get(rand.nextInt(arraylist.size()))); } /* 93 */ while (this.splashText.hashCode() == 125780783); /* 101 */ if (bufferedreader != null) { try { /* 105 */ bufferedreader.close(); } catch (IOException localIOException) { } } /* 114 */ this.updateCounter = rand.nextFloat(); } catch (IOException localIOException1) { } finally { /* 101 */ if (bufferedreader != null) { try { /* 105 */ bufferedreader.close(); } catch (IOException localIOException3) { } } } /* 115 */ this.noticeMessage = (" Bienvenue " + Minecraft.getMinecraft().getSession().getUsername()); /* 116 */ String s1 = System.getProperty("os_architecture"); /* 117 */ String s = System.getProperty("java_version"); /* 119 */ if ("ppc".equalsIgnoreCase(s1)) { /* 121 */ this.noticeMessage = ("" + EnumChatFormatting.BOLD + "Notice!" + EnumChatFormatting.RESET + " PowerPC compatibility will be dropped in Minecraft 1.6"); /* 122 */ this.noticeLink = "http://tinyurl.com/javappc"; } /* 124 */ else if ((s != null) && (s.startsWith("1.5"))) { /* 126 */ this.noticeMessage = ("" + EnumChatFormatting.BOLD + "Notice!" + EnumChatFormatting.RESET + " Java 1.5 compatibility will be dropped in Minecraft 1.6"); /* 127 */ this.noticeLink = "http://tinyurl.com/javappc"; } } public void updateScreen() { /* 136 */ this.panoramaTimer += 1; } public boolean doesGuiPauseGame() { /* 144 */ return false; } protected void keyTyped(char par1, int par2) { } public void initGui() { /* 157 */ this.viewportTexture = new DynamicTexture(256, 256); /* 158 */ this.field_110351_G = this.mc.getTextureManager().getDynamicTextureLocation("background", this.viewportTexture); /* 159 */ Calendar calendar = Calendar.getInstance(); /* 160 */ calendar.setTime(new Date()); /* 166 */ if ((calendar.get(2) + 1 == 6) && (calendar.get(5) == 1)) { /* 168 */ this.splashText = "Happy birthday, Notch!"; } /* 170 */ else if ((calendar.get(2) + 1 == 12) && (calendar.get(5) == 24)) { /* 172 */ this.splashText = "Rejoind nous"; } /* 178 */ else if ((calendar.get(2) + 1 == 1) && (calendar.get(5) == 1)) { /* 180 */ this.splashText = "Yeyvooo!"; } /* 183 */ boolean flag = true; /* 184 */ int i = this.height / 4 + 48; /* 186 */ if (this.mc.isDemo()) { /* 188 */ addDemoButtons(i, 24); } else { /* 192 */ addSingleplayerMultiplayerButtons(i, 24); } /* 195 */ this.buttonList .add(new GuiButton(0, this.width / 2 - 100, i + 65, 98, 20, EnumChatFormatting.GOLD + "" + "Options")); /* 196 */ this.buttonList .add(new GuiButton(4, this.width / 2 + 2, i + 65, 98, 20, EnumChatFormatting.RED + "" + "Quitter")); /* 198 */ Object object = this.field_104025_t; /* 200 */ synchronized (this.field_104025_t) { /* 202 */ this.field_92023_s = this.fontRendererObj.getStringWidth(this.noticeMessage); /* 203 */ this.field_92024_r = this.fontRendererObj.getStringWidth(" sur ScandiCraft! "); /* 204 */ int j = Math.max(this.field_92023_s, this.field_92024_r); /* 205 */ this.field_92022_t = ((this.width - j) / 2); /* 206 */ this.field_92021_u = (((GuiButton) this.buttonList.get(0)).yPosition - 24); /* 207 */ this.field_92020_v = (this.field_92022_t + j); /* 208 */ this.field_92019_w = (this.field_92021_u + 24); } } private void addSingleplayerMultiplayerButtons(int par1, int par2) { this.buttonList.add( new GuiButton(25, this.width - 115, par1 * 1 + 30, 98, 20, EnumChatFormatting.YELLOW + "" + "Site")); this.buttonList.add( new GuiButton(40, this.width - 115, par1 * 1 + 55, 98, 20, EnumChatFormatting.BLUE + "" + "Forum")); this.buttonList.add(new GuiButton(26, this.width - 115, par1 * 1 + 80, 98, 20, EnumChatFormatting.GREEN + "" + "Teamspeak")); this.buttonList.add( new GuiButton(48, this.width / 2 - 100, par1 - 10 + par2 * 2, EnumChatFormatting.AQUA + "" + "Jouer")); } private void addDemoButtons(int par1, int par2) { /* 241 */ this.buttonList.add(new GuiButton(11, this.width / 2 - 100, par1, "menu.playdemo")); /* 242 */ this.buttonList .add(this.buttonResetDemo = new GuiButton(12, this.width / 2 - 100, par1 + par2 * 1, "menu.resetdemo")); /* 243 */ ISaveFormat isaveformat = this.mc.getSaveLoader(); /* 244 */ WorldInfo worldinfo = isaveformat.getWorldInfo("Demo_World"); /* 246 */ if (worldinfo == null) { /* 248 */ this.buttonResetDemo.enabled = false; } } protected void actionPerformed(GuiButton button) { /* 257 */ if (button.id == 0) { /* 259 */ this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings)); } /* 262 */ if (button.id == 5) { /* 264 */ this.mc .displayGuiScreen(new GuiLanguage(this, this.mc.gameSettings, this.mc.getLanguageManager())); } /* 280 */ if (button.id == 28) { this.mc.displayGuiScreen(new GuiSelectWorld(this)); } /* 288 */ if (button.id == 48) { /* 291 */ FMLClientHandler.instance().setupServerList(); /* 292 */ FMLClientHandler.instance().connectToServer(this, new ServerData("Jouer", "ip et port du serv")); } /* 301 */ if (button.id == 4) { /* 303 */ this.mc.shutdown(); } /* 311 */ if (button.id == 26) { /* 313 */ Desktop desktop = null; try { /* 316 */ URI url = new URI("ts3server://ts.scandicraft.net:10203"); /* 317 */ if (Desktop.isDesktopSupported()) { /* 319 */ desktop = Desktop.getDesktop(); /* 320 */ desktop.browse(url); } } catch (Exception localException) { localException.printStackTrace(); } } if (button.id == 26) { /* 313 */ Desktop desktop = null; try { /* 316 */ URI url = new URI("http://scandi.franceserv.com/Forum/index.php"); /* 317 */ if (Desktop.isDesktopSupported()) { /* 319 */ desktop = Desktop.getDesktop(); /* 320 */ desktop.browse(url); } } catch (Exception localException) { localException.printStackTrace(); } } /* 326 */ if (button.id == 25) { /* 328 */ Desktop desktop = null; try { /* 331 */ URI url = new URI("http://www.scandicraft.net/"); /* 332 */ if (Desktop.isDesktopSupported()) { /* 334 */ desktop = Desktop.getDesktop(); /* 335 */ desktop.browse(url); } } catch (Exception localException1) { localException1.printStackTrace(); } } } private void func_140005_i() { } public void confirmClicked(boolean par1, int par2) { /* 426 */ if ((par1) && (par2 == 12)) { /* 428 */ ISaveFormat isaveformat = this.mc.getSaveLoader(); /* 429 */ isaveformat.flushCache(); /* 430 */ isaveformat.deleteWorldDirectory("Demo_World"); /* 431 */ this.mc.displayGuiScreen(this); } /* 433 */ else if (par2 == 13) { /* 435 */ if (par1) { try { /* 439 */ Class oclass = Class.forName("java.awt.Desktop"); /* 440 */ Object object = oclass.getMethod("getDesktop", new Class[0]).invoke(null, new Object[0]); /* 441 */ oclass.getMethod("browse", new Class[] { URI.class }).invoke(object, new Object[] { new URI(this.noticeLink) }); } catch (Throwable throwable) { /* 445 */ throwable.printStackTrace(); } } /* 449 */ this.mc.displayGuiScreen(this); } } private void renderBackGround() { GL11.glViewport(0, 0, 256, 256); this.mc.getTextureManager().bindTexture(backGround); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); int k = this.width; int l = this.height; tessellator.addVertexWithUV(0, 0, this.zLevel, 0, 0); tessellator.addVertexWithUV(0, l, this.zLevel, 0, 1); tessellator.addVertexWithUV(k, l, this.zLevel, 1, 1); tessellator.addVertexWithUV(k, 0, this.zLevel, 1, 0); tessellator.draw(); } public void drawScreen(int par1, int par2, float par3) { /* 612 */ this.renderBackGround(); /* 613 */ Tessellator tessellator = Tessellator.instance; /* 614 */ short short1 = 274; /* 615 */ int k = this.width / 2 - short1 / 2; /* 616 */ byte b0 = 30; /* 617 */ drawGradientRect(0, 0, this.width, this.height, -2130706433, 16777215); /* 618 */ drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); /* 619 */ this.mc.getTextureManager().bindTexture(minecraftTitleTextures); /* 620 */ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); /* 622 */ if (this.updateCounter < 1.0E-4D) { /* 624 */ drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 99, 44); /* 625 */ drawTexturedModalRect(k + 99, b0 + 0, 129, 0, 27, 44); /* 626 */ drawTexturedModalRect(k + 99 + 26, b0 + 0, 126, 0, 3, 44); /* 627 */ drawTexturedModalRect(k + 99 + 26 + 3, b0 + 0, 99, 0, 26, 44); /* 628 */ drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44); } else { /* 632 */ drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 155, 44); /* 633 */ drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44); } /* 636 */ tessellator.setColorOpaque_I(16777215); /* 637 */ GL11.glPushMatrix(); /* 638 */ GL11.glTranslatef(this.width / 2 + 90, 70.0F, 0.0F); /* 639 */ GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F); /* 640 */ float f1 = 1.8F - MathHelper .abs(MathHelper.sin((float) (Minecraft.getSystemTime() % 1000L) / 1000.0F * 3.1415927F * 2.0F) * 0.1F); /* 641 */ GL11.glScalef(f1, f1, f1); /* 642 */ GL11.glPopMatrix(); /* 643 */ String s = ""; /* 645 */ if (this.mc.isDemo()) { /* 647 */ s = s + " Demo"; } /* 650 */ String s1 = "Created By Yeyvo"; /* 651 */ drawString(this.fontRendererObj, s1, this.width - this.fontRendererObj.getStringWidth(s1) - 2, this.height - 10, 13898001); String s2 = "Scandicraft V4.0"; /* 651 */ drawString(this.fontRendererObj, s2, this.width - this.fontRendererObj.getStringWidth(s2) - 300, this.height - 10, 13898001); /* 653 */ if ((this.noticeMessage != null) && (this.noticeMessage.length() > 0)) { /* 655 */ drawRect(this.field_92022_t - 2, this.field_92021_u - 2, this.field_92020_v + 2, this.field_92019_w - 1, 1428160512); /* 656 */ drawString(this.fontRendererObj, this.noticeMessage, this.field_92022_t, this.field_92021_u, 16777215); /* 657 */ drawString(this.fontRendererObj, " sur ScandiCraft! ", (this.width - this.field_92024_r) / 2, ((GuiButton) this.buttonList.get(0)).yPosition - 12, 16777215); } /* 660 */ super.drawScreen(par1, par2, par3); } protected void mouseClicked(int par1, int par2, int par3) { /* 668 */ super.mouseClicked(par1, par2, par3); /* 669 */ Object object = this.field_104025_t; /* 671 */ synchronized (this.field_104025_t) { /* 673 */ if ((this.noticeMessage.length() <= 0) || (par1 < this.field_92022_t) || (par1 > this.field_92020_v) || (par2 < this.field_92021_u) || (par2 > this.field_92019_w)) { } } } static Minecraft func_110348_a(GuiCustomMainMenu menu) { /* 683 */ return menu.mc; } static boolean func_110349_a(boolean par0) { /* 688 */ field_96139_s = par0; /* 689 */ return par0; } static Minecraft func_130018_c(GuiCustomMainMenu menu) { /* 694 */ return menu.mc; } static Minecraft func_130019_d(GuiCustomMainMenu menu) { /* 699 */ return menu.mc; } }
-
Ça serait bien d’expliquer clairement quel est le problème.
Car pour le coup non ton image ne suffit pas.D’ailleurs le copyrigth de Mojang il est passé où ? Et c’est quoi ce code qui ressemble à du code décompilé avec JD-gui ?
-
Le problème est en haut à droite de l’image. Son image semble 4 fois trop grande et déborder de l’affichage prévu
-
Pourquoi avoir décompilé le menu principale de ScandiCraft, à moins que tu ne fasses partie de leur staff (me suis pas renseigné + que ça), ce n’est pas superbe venant de quelqu’un comme toi, hein ? Surtout un menu principale….Une des choses les + basiques _
-
Je viens de comencé (je n’ais pas fait grand chose car il on l’aire de bien aimé) , Oui je fait partie du staff en tant que dev
Le copyrigth je vais l’ajouté la je les enlevé pour voir le rendusDescription du problème
Mon image ne se vois que a un quart -
Les coordonnées uv indiqué lors du draw ne sont pas bonne.
Il faut juste les changer.
J’avais expliqué comment faire dans le tutoriel sur le gui et container en vidéo. -
Je viens de comencé (je n’ais pas fait grand chose car il on l’aire de bien aimé) , Oui je fait partie du staff en tant que dev
D’accord, autant pour moi ! Bonne chance alors !
-
Merci mais se que j’ai découvert c’est que l’image en elle même est trop grande elle fait du 1600*xxx
-
Génial pour la mémoire xD
-
Il y a une fonction du gui (drawModelRectWithCustomSizedTexture si je me trompe pas) qui redimensionne l’image à la taille souhaitée.
Ou tu la redimensionnes avec paint.NET (ou autre), ce qui serait plus simple ^^ -
Ouais mais c’est pas top pour la résolution et la netteté du logo après. Si il s’oblige à la faire tenir dans du 256x256…
Si tu veux dépasser cette “restriction” 256x256, tu peux suivre ce tuto si tu veux : https://www.bukkit.fr/topic/1826-125-afficher-une-image-hd-ou-ld/
Ce qui reviendra au même que d’utiliser la méthode citée par mon VDD