Commit 239a6eb03a4db2ce3083c6543c6675851f79adda

Authored by Mumfrey
1 parent 0188a6ba

LiteLoader 1.6.4_02 - experimental - remove parent gui reference from config panel container

java/com/mumfrey/liteloader/gui/GuiConfigPanelContainer.java
@@ -28,11 +28,6 @@ public class GuiConfigPanelContainer extends Gui implements ConfigPanelHost @@ -28,11 +28,6 @@ public class GuiConfigPanelContainer extends Gui implements ConfigPanelHost
28 private static final int MARGIN = 12; 28 private static final int MARGIN = 12;
29 29
30 /** 30 /**
31 - * Parent screen  
32 - */  
33 - private GuiScreenModInfo parent;  
34 -  
35 - /**  
36 * Minecraft 31 * Minecraft
37 */ 32 */
38 private Minecraft mc; 33 private Minecraft mc;
@@ -88,17 +83,21 @@ public class GuiConfigPanelContainer extends Gui implements ConfigPanelHost @@ -88,17 +83,21 @@ public class GuiConfigPanelContainer extends Gui implements ConfigPanelHost
88 private int panelTop = TOP; 83 private int panelTop = TOP;
89 84
90 /** 85 /**
  86 + * True if the client wants to close the panel
  87 + */
  88 + private boolean closeRequested;
  89 +
  90 + /**
91 * @param parent 91 * @param parent
92 * @param minecraft 92 * @param minecraft
93 * @param panel 93 * @param panel
94 * @param mod 94 * @param mod
95 */ 95 */
96 - GuiConfigPanelContainer(GuiScreenModInfo parent, Minecraft minecraft, ConfigPanel panel, LiteMod mod) 96 + GuiConfigPanelContainer(ConfigPanel panel, LiteMod mod)
97 { 97 {
98 - this.parent = parent;  
99 - this.mc = minecraft;  
100 - this.panel = panel;  
101 - this.mod = mod; 98 + this.mc = Minecraft.getMinecraft();
  99 + this.panel = panel;
  100 + this.mod = mod;
102 } 101 }
103 102
104 /** 103 /**
@@ -137,14 +136,22 @@ public class GuiConfigPanelContainer extends Gui implements ConfigPanelHost @@ -137,14 +136,22 @@ public class GuiConfigPanelContainer extends Gui implements ConfigPanelHost
137 { 136 {
138 return this.panelHeight; 137 return this.panelHeight;
139 } 138 }
140 - 139 +
141 /* (non-Javadoc) 140 /* (non-Javadoc)
142 * @see com.mumfrey.liteloader.modconfig.ConfigPanelHost#close() 141 * @see com.mumfrey.liteloader.modconfig.ConfigPanelHost#close()
143 */ 142 */
144 @Override 143 @Override
145 public void close() 144 public void close()
146 { 145 {
147 - this.parent.closeConfigPanel(this); 146 + this.closeRequested = true;
  147 + }
  148 +
  149 + /**
  150 + * Get whether the client wants to close the panel
  151 + */
  152 + boolean isCloseRequested()
  153 + {
  154 + return this.closeRequested;
148 } 155 }
149 156
150 /** 157 /**
java/com/mumfrey/liteloader/gui/GuiScreenModInfo.java
@@ -353,24 +353,7 @@ public class GuiScreenModInfo extends GuiScreen @@ -353,24 +353,7 @@ public class GuiScreenModInfo extends GuiScreen
353 } 353 }
354 else 354 else
355 { 355 {
356 - // Draw the header pieces  
357 - glDrawTexturedRect(LEFT_EDGE + MARGIN, 12, 128, 40, 0, 0, 256, 80, 1.0F); // liteloader logo  
358 - glDrawTexturedRect(this.width - 32 - MARGIN, 12, 32, 45, 0, 80, 64, 170, 1.0F); // chicken  
359 -  
360 - // Draw header text  
361 - this.fontRenderer.drawString("Version " + LiteLoader.getVersion(), LEFT_EDGE + MARGIN + 38, 50, 0xFFFFFFFF);  
362 - this.fontRenderer.drawString(this.activeModText, LEFT_EDGE + MARGIN + 38, 60, 0xFFAAAAAA);  
363 -  
364 - // Draw top and bottom horizontal rules  
365 - drawRect(LEFT_EDGE + MARGIN, 80, this.width - MARGIN, 81, 0xFF999999);  
366 - drawRect(LEFT_EDGE + MARGIN, this.height - PANEL_BOTTOM + 2, this.width - MARGIN, this.height - PANEL_BOTTOM + 3, 0xFF999999);  
367 -  
368 - int innerWidth = this.width - LEFT_EDGE - MARGIN - MARGIN - 4;  
369 - int panelWidth = innerWidth / 2;  
370 - int panelHeight = this.height - PANEL_BOTTOM - PANEL_TOP;  
371 -  
372 - this.drawModsList(mouseX, mouseY, partialTicks, panelWidth, panelHeight);  
373 - this.drawSelectedMod(mouseX, mouseY, partialTicks, panelWidth, panelHeight); 356 + this.drawInfoPanel(mouseX, mouseY, partialTicks);
374 357
375 // Draw other controls inside the transform so that they slide properly 358 // Draw other controls inside the transform so that they slide properly
376 super.drawScreen(mouseX, mouseY, partialTicks); 359 super.drawScreen(mouseX, mouseY, partialTicks);
@@ -378,9 +361,8 @@ public class GuiScreenModInfo extends GuiScreen @@ -378,9 +361,8 @@ public class GuiScreenModInfo extends GuiScreen
378 } 361 }
379 else if (this.configPanel != null) 362 else if (this.configPanel != null)
380 { 363 {
381 - this.closeConfigPanel(this.configPanel); 364 + this.closeConfigPanel();
382 } 365 }
383 -  
384 366
385 glPopMatrix(); 367 glPopMatrix();
386 } 368 }
@@ -392,6 +374,12 @@ public class GuiScreenModInfo extends GuiScreen @@ -392,6 +374,12 @@ public class GuiScreenModInfo extends GuiScreen
392 */ 374 */
393 public void drawConfigPanel(int mouseX, int mouseY, float partialTicks) 375 public void drawConfigPanel(int mouseX, int mouseY, float partialTicks)
394 { 376 {
  377 + if (this.configPanel.isCloseRequested())
  378 + {
  379 + this.closeConfigPanel();
  380 + return;
  381 + }
  382 +
395 glPushMatrix(); 383 glPushMatrix();
396 glTranslatef(LEFT_EDGE, 0, 0); 384 glTranslatef(LEFT_EDGE, 0, 0);
397 385
@@ -404,6 +392,33 @@ public class GuiScreenModInfo extends GuiScreen @@ -404,6 +392,33 @@ public class GuiScreenModInfo extends GuiScreen
404 * @param mouseX 392 * @param mouseX
405 * @param mouseY 393 * @param mouseY
406 * @param partialTicks 394 * @param partialTicks
  395 + */
  396 + public void drawInfoPanel(int mouseX, int mouseY, float partialTicks)
  397 + {
  398 + // Draw the header pieces
  399 + glDrawTexturedRect(LEFT_EDGE + MARGIN, 12, 128, 40, 0, 0, 256, 80, 1.0F); // liteloader logo
  400 + glDrawTexturedRect(this.width - 32 - MARGIN, 12, 32, 45, 0, 80, 64, 170, 1.0F); // chicken
  401 +
  402 + // Draw header text
  403 + this.fontRenderer.drawString("Version " + LiteLoader.getVersion(), LEFT_EDGE + MARGIN + 38, 50, 0xFFFFFFFF);
  404 + this.fontRenderer.drawString(this.activeModText, LEFT_EDGE + MARGIN + 38, 60, 0xFFAAAAAA);
  405 +
  406 + // Draw top and bottom horizontal rules
  407 + drawRect(LEFT_EDGE + MARGIN, 80, this.width - MARGIN, 81, 0xFF999999);
  408 + drawRect(LEFT_EDGE + MARGIN, this.height - PANEL_BOTTOM + 2, this.width - MARGIN, this.height - PANEL_BOTTOM + 3, 0xFF999999);
  409 +
  410 + int innerWidth = this.width - LEFT_EDGE - MARGIN - MARGIN - 4;
  411 + int panelWidth = innerWidth / 2;
  412 + int panelHeight = this.height - PANEL_BOTTOM - PANEL_TOP;
  413 +
  414 + this.drawModsList(mouseX, mouseY, partialTicks, panelWidth, panelHeight);
  415 + this.drawSelectedMod(mouseX, mouseY, partialTicks, panelWidth, panelHeight);
  416 + }
  417 +
  418 + /**
  419 + * @param mouseX
  420 + * @param mouseY
  421 + * @param partialTicks
407 * @param width 422 * @param width
408 * @param height 423 * @param height
409 */ 424 */
@@ -672,7 +687,7 @@ public class GuiScreenModInfo extends GuiScreen @@ -672,7 +687,7 @@ public class GuiScreenModInfo extends GuiScreen
672 this.configPanel.onHidden(); 687 this.configPanel.onHidden();
673 } 688 }
674 689
675 - this.configPanel = new GuiConfigPanelContainer(this, this.mc, panel, this.selectedMod.getModInstance()); 690 + this.configPanel = new GuiConfigPanelContainer(panel, this.selectedMod.getModInstance());
676 this.configPanel.setSize(this.width - LEFT_EDGE, this.height); 691 this.configPanel.setSize(this.width - LEFT_EDGE, this.height);
677 this.configPanel.onShown(); 692 this.configPanel.onShown();
678 } 693 }
@@ -682,9 +697,9 @@ public class GuiScreenModInfo extends GuiScreen @@ -682,9 +697,9 @@ public class GuiScreenModInfo extends GuiScreen
682 /* (non-Javadoc) 697 /* (non-Javadoc)
683 * @see com.mumfrey.liteloader.modconfig.ConfigPanelHost#close() 698 * @see com.mumfrey.liteloader.modconfig.ConfigPanelHost#close()
684 */ 699 */
685 - void closeConfigPanel(GuiConfigPanelContainer container) 700 + private void closeConfigPanel()
686 { 701 {
687 - if (this.configPanel != null && (container == null || this.configPanel == container)) 702 + if (this.configPanel != null)
688 { 703 {
689 this.configPanel.onHidden(); 704 this.configPanel.onHidden();
690 this.configPanel = null; 705 this.configPanel = null;