Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.71 KB | None | 0 0
  1. package net.minecraft.client.gui;
  2.  
  3. import java.awt.Desktop;
  4. import java.io.BufferedReader;
  5. import java.io.IOException;
  6. import java.io.InputStreamReader;
  7. import java.net.URI;
  8. import java.util.ArrayList;
  9. import java.util.Calendar;
  10. import java.util.Date;
  11. import java.util.Random;
  12.  
  13. import org.apache.commons.io.Charsets;
  14. import org.apache.logging.log4j.LogManager;
  15. import org.apache.logging.log4j.Logger;
  16. import org.lwjgl.opengl.GL11;
  17. import org.lwjgl.opengl.GLContext;
  18.  
  19. import net.minecraft.client.ApiInfo;
  20. import net.minecraft.client.Minecraft;
  21. import net.minecraft.client.renderer.OpenGlHelper;
  22. import net.minecraft.client.renderer.Tessellator;
  23. import net.minecraft.client.renderer.texture.DynamicTexture;
  24. import net.minecraft.client.resources.I18n;
  25. import net.minecraft.realms.RealmsBridge;
  26. import net.minecraft.realms.RealmsScreen;
  27. import net.minecraft.util.EnumChatFormatting;
  28. import net.minecraft.util.MathHelper;
  29. import net.minecraft.util.ResourceLocation;
  30. import net.minecraft.world.demo.DemoWorldServer;
  31. import net.minecraft.world.storage.ISaveFormat;
  32. import net.minecraft.world.storage.WorldInfo;
  33.  
  34. public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback
  35. {
  36.  
  37. private ApiInfo infos = new ApiInfo("Vanadia", "vanadia.fr:28000");
  38.  
  39. private static final Logger logger = LogManager.getLogger();
  40.  
  41. /** The RNG used by the Main Menu Screen. */
  42. private static final Random rand = new Random();
  43.  
  44. /** Counts the number of screen updates. */
  45. private float updateCounter;
  46.  
  47. /** The splash message. */
  48. private String splashText;
  49. private GuiButton buttonResetDemo;
  50.  
  51. /** Timer used to rotate the panorama, increases every tick. */
  52. private int panoramaTimer;
  53.  
  54. /**
  55. * Texture allocated for the current viewport of the main menu's panorama background.
  56. */
  57. private DynamicTexture viewportTexture;
  58. private final Object field_104025_t = new Object();
  59. private String field_92025_p;
  60. private String field_146972_A;
  61. private String field_104024_v;
  62. private static final ResourceLocation splashTexts = new ResourceLocation("texts/splashes.txt");
  63.  
  64. /** An array of all the paths to the panorama pictures. */
  65. private final ResourceLocation backGround = new ResourceLocation("textures/gui/title/back.png");
  66. public static final String field_96138_a = "Please click " + EnumChatFormatting.UNDERLINE + "here" + EnumChatFormatting.RESET + " for more information.";
  67. private int field_92024_r;
  68. private int field_92023_s;
  69. private int field_92022_t;
  70. private int field_92021_u;
  71. private int field_92020_v;
  72. private int field_92019_w;
  73. private ResourceLocation field_110351_G;
  74. private static final String __OBFID = "CL_00001154";
  75.  
  76. public GuiMainMenu()
  77. {
  78. infos.pre_init();
  79. this.field_146972_A = field_96138_a;
  80. this.splashText = "";
  81. BufferedReader var1 = null;
  82.  
  83. try
  84. {
  85. ArrayList var2 = new ArrayList();
  86. var1 = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(splashTexts).getInputStream(), Charsets.UTF_8));
  87. String var3;
  88.  
  89. while ((var3 = var1.readLine()) != null)
  90. {
  91. var3 = var3.trim();
  92.  
  93. if (!var3.isEmpty())
  94. {
  95. var2.add(var3);
  96. }
  97. }
  98.  
  99. if (!var2.isEmpty())
  100. {
  101. do
  102. {
  103. this.splashText = (String)var2.get(rand.nextInt(var2.size()));
  104. }
  105. while (this.splashText.hashCode() == 125780783);
  106. }
  107. }
  108. catch (IOException var12)
  109. {
  110. ;
  111. }
  112. finally
  113. {
  114. if (var1 != null)
  115. {
  116. try
  117. {
  118. var1.close();
  119. }
  120. catch (IOException var11)
  121. {
  122. ;
  123. }
  124. }
  125. }
  126.  
  127. this.updateCounter = rand.nextFloat();
  128. this.field_92025_p = "";
  129.  
  130. if (!GLContext.getCapabilities().OpenGL20 && !OpenGlHelper.func_153193_b())
  131. {
  132. this.field_92025_p = I18n.format("title.oldgl1", new Object[0]);
  133. this.field_146972_A = I18n.format("title.oldgl2", new Object[0]);
  134. this.field_104024_v = "https://help.mojang.com/customer/portal/articles/325948?ref=game";
  135. }
  136. }
  137.  
  138. /**
  139. * Called from the main game loop to update the screen.
  140. */
  141. public void updateScreen()
  142. {
  143. ++this.panoramaTimer;
  144. infos.refresh();
  145. }
  146.  
  147. public void onGuiClosed()
  148. {
  149. infos.close();
  150. super.onGuiClosed();
  151. }
  152. /**
  153. * Returns true if this GUI should pause the game when it is displayed in single-player
  154. */
  155. public boolean doesGuiPauseGame()
  156. {
  157. return false;
  158. }
  159.  
  160. /**
  161. * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
  162. */
  163. protected void keyTyped(char p_73869_1_, int p_73869_2_) {}
  164.  
  165. /**
  166. * Adds the buttons (and other controls) to the screen in question.
  167. */
  168. public void initGui()
  169. {
  170. this.viewportTexture = new DynamicTexture(256, 256);
  171. this.field_110351_G = this.mc.getTextureManager().getDynamicTextureLocation("background", this.viewportTexture);
  172. Calendar var1 = Calendar.getInstance();
  173. var1.setTime(new Date());
  174.  
  175. if (var1.get(2) + 1 == 11 && var1.get(5) == 9)
  176. {
  177. this.splashText = "Happy birthday, ez!";
  178. }
  179. else if (var1.get(2) + 1 == 6 && var1.get(5) == 1)
  180. {
  181. this.splashText = "Happy birthday, Notch!";
  182. }
  183. else if (var1.get(2) + 1 == 12 && var1.get(5) == 24)
  184. {
  185. this.splashText = "Merry X-mas!";
  186. }
  187. else if (var1.get(2) + 1 == 1 && var1.get(5) == 1)
  188. {
  189. this.splashText = "Happy new year!";
  190. }
  191. else if (var1.get(2) + 1 == 10 && var1.get(5) == 31)
  192. {
  193. this.splashText = "OOoooOOOoooo! Spooky!";
  194. }
  195.  
  196. boolean var2 = true;
  197. int var3 = this.height / 4 + 48;
  198.  
  199. if (this.mc.isDemo())
  200. {
  201. this.addDemoButtons(var3, 24);
  202. }
  203. else
  204. {
  205. this.addSingleplayerMultiplayerButtons(var3, 24);
  206. }
  207.  
  208. this.buttonList.add(new GuiButton(0, this.width / 2 - 100, var3 + 72 + 0, 98, 20, I18n.format("menu.options", new Object[0])));
  209. this.buttonList.add(new GuiButton(4, this.width / 2 + 2, var3 + 72 + 0, 98, 20, I18n.format("menu.quit", new Object[0])));
  210.  
  211. //-------------------------------------------------------------------------------
  212.  
  213. //Boutons
  214.  
  215. this.buttonList.add(new GuiButton(80, this.width / 2 + -100, var3 + 72 + -24, 98, 20, I18n.format("\u00A79Site", new Object[0])));
  216. this.buttonList.add(new GuiButton(81, this.width / 2 + 2, var3 + 72 + -24, 98, 20, I18n.format("\u00A79Teamspeak", new Object[0])));
  217.  
  218. //-------------------------------------------------------------------------------
  219.  
  220.  
  221. Object var4 = this.field_104025_t;
  222.  
  223. synchronized (this.field_104025_t)
  224. {
  225. this.field_92023_s = this.fontRendererObj.getStringWidth(this.field_92025_p);
  226. this.field_92024_r = this.fontRendererObj.getStringWidth(this.field_146972_A);
  227. int var5 = Math.max(this.field_92023_s, this.field_92024_r);
  228. this.field_92022_t = (this.width - var5) / 2;
  229. this.field_92021_u = ((GuiButton)this.buttonList.get(0)).field_146129_i - 24;
  230. this.field_92020_v = this.field_92022_t + var5;
  231. this.field_92019_w = this.field_92021_u + 24;
  232. }
  233. }
  234.  
  235. /**
  236. * Adds Singleplayer and Multiplayer buttons on Main Menu for players who have bought the game.
  237. */
  238. private void addSingleplayerMultiplayerButtons(int p_73969_1_, int p_73969_2_)
  239. {
  240. this.buttonList.add(new GuiButton(2, this.width / 2 - 100, p_73969_1_, I18n.format("\u00A7a Se connecter sur Vanadia", new Object[0])));
  241. this.buttonList.add(new GuiButton(1, this.width / 2 - 100, p_73969_1_ + p_73969_2_ * 1, I18n.format("\u00A76 Monde solo", new Object[0])));
  242. }
  243.  
  244. /**
  245. * Adds Demo buttons on Main Menu for players who are playing Demo.
  246. */
  247. private void addDemoButtons(int p_73972_1_, int p_73972_2_)
  248. {
  249. this.buttonList.add(new GuiButton(11, this.width / 2 - 100, p_73972_1_, I18n.format("menu.playdemo", new Object[0])));
  250. this.buttonList.add(this.buttonResetDemo = new GuiButton(12, this.width / 2 - 100, p_73972_1_ + p_73972_2_ * 1, I18n.format("menu.resetdemo", new Object[0])));
  251. ISaveFormat var3 = this.mc.getSaveLoader();
  252. WorldInfo var4 = var3.getWorldInfo("Demo_World");
  253.  
  254. if (var4 == null)
  255. {
  256. this.buttonResetDemo.enabled = false;
  257. }
  258. }
  259.  
  260. protected void actionPerformed(GuiButton p_146284_1_)
  261. {
  262. if (p_146284_1_.id == 0)
  263. {
  264. this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
  265. }
  266.  
  267. if (p_146284_1_.id == 5)
  268. {
  269. this.mc.displayGuiScreen(new GuiLanguage(this, this.mc.gameSettings, this.mc.getLanguageManager()));
  270. }
  271.  
  272. if (p_146284_1_.id == 1)
  273. {
  274. this.mc.displayGuiScreen(new GuiSelectWorld(this));
  275. }
  276.  
  277. if (p_146284_1_.id == 2)
  278. {
  279. this.mc.displayGuiScreen(new GuiLoadingScreen()); }
  280.  
  281. if (p_146284_1_.id == 14)
  282. {
  283. this.func_140005_i();
  284. }
  285.  
  286. if (p_146284_1_.id == 4)
  287. {
  288. this.mc.shutdown();
  289. }
  290.  
  291. //-----------------------------------------------------------------------------------------------------
  292.  
  293. //Boutons
  294.  
  295. if (p_146284_1_.id == 80)
  296. {
  297.  
  298. URI u = URI.create("http://vanadia.fr");
  299. try{
  300.  
  301. Desktop.getDesktop().browse(u);
  302.  
  303. } catch(IOException e) {
  304.  
  305. e.printStackTrace();
  306.  
  307. }
  308. }
  309.  
  310. if (p_146284_1_.id == 81)
  311. {
  312. URI u = URI.create("ts3server://ts.vanadia.fr?port=PORT");
  313. try{
  314.  
  315. Desktop.getDesktop().browse(u);
  316.  
  317. } catch(IOException e) {
  318.  
  319. e.printStackTrace();
  320.  
  321. }
  322. }
  323.  
  324. //-----------------------------------------------------------------------------------------------------
  325.  
  326. if (p_146284_1_.id == 11)
  327. {
  328. this.mc.launchIntegratedServer("Demo_World", "Demo_World", DemoWorldServer.demoWorldSettings);
  329. }
  330.  
  331. if (p_146284_1_.id == 12)
  332. {
  333. ISaveFormat var2 = this.mc.getSaveLoader();
  334. WorldInfo var3 = var2.getWorldInfo("Demo_World");
  335.  
  336. if (var3 != null)
  337. {
  338. GuiYesNo var4 = GuiSelectWorld.func_152129_a(this, var3.getWorldName(), 12);
  339. this.mc.displayGuiScreen(var4);
  340. }
  341. }
  342. }
  343.  
  344. private void func_140005_i()
  345. {
  346. RealmsBridge var1 = new RealmsBridge();
  347. var1.switchToRealms(this);
  348. }
  349.  
  350. public void confirmClicked(boolean p_73878_1_, int p_73878_2_)
  351. {
  352. if (p_73878_1_ && p_73878_2_ == 12)
  353. {
  354. ISaveFormat var6 = this.mc.getSaveLoader();
  355. var6.flushCache();
  356. var6.deleteWorldDirectory("Demo_World");
  357. this.mc.displayGuiScreen(this);
  358. }
  359. else if (p_73878_2_ == 13)
  360. {
  361. if (p_73878_1_)
  362. {
  363. try
  364. {
  365. Class var3 = Class.forName("java.awt.Desktop");
  366. Object var4 = var3.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
  367. var3.getMethod("browse", new Class[] {URI.class}).invoke(var4, new Object[] {new URI(this.field_104024_v)});
  368. }
  369. catch (Throwable var5)
  370. {
  371. logger.error("Couldn\'t open link", var5);
  372. }
  373. }
  374.  
  375. this.mc.displayGuiScreen(this);
  376. }
  377. }
  378.  
  379. private void renderBackGround()
  380. {
  381. GL11.glViewport(0, 0, 256, 256);
  382. this.mc.getTextureManager().bindTexture(backGround);
  383. GL11.glDisable(GL11.GL_TEXTURE_2D);
  384. GL11.glEnable(GL11.GL_TEXTURE_2D);
  385. GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
  386. Tessellator tessellator = Tessellator.instance;
  387. tessellator.startDrawingQuads();
  388. GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
  389. GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
  390. tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F);
  391. int k = this.width;
  392. int l = this.height;
  393. tessellator.addVertexWithUV(0, 0, this.zLevel, 0, 0);
  394. tessellator.addVertexWithUV(0, l, this.zLevel, 0, 1);
  395. tessellator.addVertexWithUV(k, l, this.zLevel, 1, 1);
  396. tessellator.addVertexWithUV(k, 0, this.zLevel, 1, 0);
  397. tessellator.draw();
  398. }
  399.  
  400.  
  401. /**
  402. * Draws the screen and all the components in it.
  403. */
  404. public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
  405. {
  406.  
  407. GL11.glDisable(GL11.GL_ALPHA_TEST);
  408. this.renderBackGround();
  409. GL11.glEnable(GL11.GL_ALPHA_TEST);
  410. Tessellator var4 = Tessellator.instance;
  411. short var5 = 274;
  412. int var6 = this.width / 2 - var5 / 2;
  413. byte var7 = 30;
  414.  
  415. int x = this.width / 2 + 0;
  416. int y = this.height / 2 + 35;
  417. int var53 = this.height - 144;
  418.  
  419.  
  420.  
  421.  
  422. var4.setColorOpaque_I(-1);
  423. GL11.glPushMatrix();
  424. GL11.glTranslatef((float)(this.width / 2 + 90), 70.0F, 0.0F);
  425. GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F);
  426. float var8 = 1.8F - MathHelper.abs(MathHelper.sin((float)(Minecraft.getSystemTime() % 1000L) / 1000.0F * (float)Math.PI * 2.0F) * 0.1F);
  427. var8 = var8 * 100.0F / (float)(this.fontRendererObj.getStringWidth(this.splashText) + 32);
  428. GL11.glScalef(var8, var8, var8);
  429. this.drawCenteredString(this.fontRendererObj, this.splashText, 0, -8, -256);
  430. GL11.glPopMatrix();
  431. drawPlayerSkin(this.mc.getSession().getUsername(), 10, var53, 4);
  432.  
  433.  
  434.  
  435.  
  436. if (this.field_92025_p != null && this.field_92025_p.length() > 0)
  437. {
  438. drawRect(this.field_92022_t - 2, this.field_92021_u - 2, this.field_92020_v + 2, this.field_92019_w - 1, 1428160512);
  439. this.drawString(this.fontRendererObj, this.field_92025_p, this.field_92022_t, this.field_92021_u, -1);
  440. this.drawString(this.fontRendererObj, this.field_146972_A, (this.width - this.field_92024_r) / 2, ((GuiButton)this.buttonList.get(0)).field_146129_i - 12, -1);
  441. }
  442. this.drawRectangle();
  443.  
  444. super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
  445.  
  446. int var50 = this.width / 2;
  447. int var51 = this.height / 4 + 48;
  448.  
  449. String infoServ;
  450. if (infos.getPopulation().equals("???")){
  451. infoServ = "§eChargement...";
  452. }
  453. else if (infos.getPopulation().equals("")){
  454. infoServ = "§cServeur Fermé";
  455. }
  456. else{
  457. infoServ = ("§7Il y a actuellement " + infos.getPopulation()+ " joueurs de connecté(s) !");
  458. }
  459.  
  460. int titleLen = this.fontRendererObj.getStringWidth("§7" + "@Copyright Vanadia");
  461. int titleLen2 = this.fontRendererObj.getStringWidth(infoServ);
  462. int titleLen3 = this.fontRendererObj.getStringWidth("§7" + "Vanadia V1 - 1.7.10");
  463. int titleLen4 = this.fontRendererObj.getStringWidth("§7" + "Informations concernant le serveur:");
  464.  
  465.  
  466.  
  467.  
  468. this.drawString(this.fontRendererObj, "§7" + "@Copyright Vanadia", var50 - titleLen / 2 ,var51 +118 , 0xffffff);
  469. this.drawString(this.fontRendererObj, "§7" + "Informations concernant le serveur:", var50 - titleLen4 / 2 ,var51 -40 , 0xffffff);
  470. this.drawString(this.fontRendererObj, infoServ, var50 -titleLen2 / 2, var51 -30 , 0xffffff);
  471. this.drawString(this.fontRendererObj, "§7" + "Vanadia V1 - 1.7.10", var50 - titleLen3 / 2, var51 -20 , 0xffffff);
  472. // pour le ping infos.drawIconPing(this, 85, 20, true);
  473. super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
  474. }
  475.  
  476.  
  477. public void drawPlayerSkin(String username, int x, int y, float scale)
  478. {
  479. RealmsScreen.bindFace(username);
  480. GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
  481. GL11.glPushMatrix();
  482.  
  483. GL11.glTranslatef(x, y, 0.0f);
  484.  
  485. GL11.glScalef(scale, scale, 0.0f);
  486.  
  487. // Tête
  488. this.drawTexturedModalRectSkin(4, 0, 8, 8, 8, 8);
  489.  
  490. // Corps
  491. this.drawTexturedModalRectSkin(4, 8, 20, 20, 8, 12);
  492.  
  493. // Bras G
  494. this.drawTexturedModalRectSkin(0, 8, 44, 20, 4, 12);
  495.  
  496. // Bras D
  497. this.drawTexturedModalRectSkin(12, 8, 52, 20, 4, 12);
  498.  
  499. // Jambe G
  500. this.drawTexturedModalRectSkin(8, 20, 12, 20, 4, 12);
  501.  
  502. // Jambe D
  503. this.drawTexturedModalRectSkin(4, 20, 4, 20, 4, 12);
  504.  
  505. GL11.glPopMatrix();
  506. }
  507.  
  508. public void drawRectangle(){
  509.  
  510. int var3 = this.height / 4 + 48;
  511. int xx = this.width / 2 - 120, widthX = this.width / 2 + 120; //milieu
  512. int yy = var3 + 116, heightY = var3 - 12;
  513. drawRect(xx, heightY, widthX, yy, 0x99000000);
  514.  
  515. int x2 = this.width / 2 - 134, widthX2 = this.width / 2 + 134; //haut
  516. int y2 = var3 - 12, heightY2 = var3 - 48;
  517. drawRect(x2, heightY2, widthX2, y2, 0x99000000);
  518.  
  519. int x3 = this.width / 2 - 50, widthX3 = this.width / 2 + 50; //bas
  520. int y3 = var3 + 116, heightY3 = var3 + 130;
  521. drawRect(x3, heightY3, widthX3, y3, 0x99000000);
  522. }
  523.  
  524. public void drawTexturedModalRectSkin(int x, int y, int u, int v, int width, int height)
  525. {
  526. // La taille de la texture change
  527. float var7 = 0.015625f;
  528. float var8 = 0.03125f;
  529. Tessellator var9 = Tessellator.instance;
  530. var9.startDrawingQuads();
  531. var9.addVertexWithUV((double) (x + 0), (double) (y + height), (double) this.zLevel, (double) ((float) (u + 0) * var7), (double) ((float) (v + height) * var8));
  532. var9.addVertexWithUV((double) (x + width), (double) (y + height), (double) this.zLevel, (double) ((float) (u + width) * var7), (double) ((float) (v + height) * var8));
  533. var9.addVertexWithUV((double) (x + width), (double) (y + 0), (double) this.zLevel, (double) ((float) (u + width) * var7), (double) ((float) (v + 0) * var8));
  534. var9.addVertexWithUV((double) (x + 0), (double) (y + 0), (double) this.zLevel, (double) ((float) (u + 0) * var7), (double) ((float) (v + 0) * var8));
  535. var9.draw();
  536. }
  537.  
  538. /**
  539. * Called when the mouse is clicked.
  540. */
  541. protected void mouseClicked(int p_73864_1_, int p_73864_2_, int p_73864_3_)
  542. {
  543. super.mouseClicked(p_73864_1_, p_73864_2_, p_73864_3_);
  544. Object var4 = this.field_104025_t;
  545.  
  546. synchronized (this.field_104025_t)
  547. {
  548. if (this.field_92025_p.length() > 0 && p_73864_1_ >= this.field_92022_t && p_73864_1_ <= this.field_92020_v && p_73864_2_ >= this.field_92021_u && p_73864_2_ <= this.field_92019_w)
  549. {
  550. GuiConfirmOpenLink var5 = new GuiConfirmOpenLink(this, this.field_104024_v, 13, true);
  551. var5.func_146358_g();
  552. this.mc.displayGuiScreen(var5);
  553. }
  554. }
  555. }
  556. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement