Fixed a few accessors I missed:
Server RailLogic.getNAdjacentTracks public Server TileEntityFurnace.getItemBurnTime static New GUIControls change, Made it into a scroll panel instead of a static position window. This just makes things look better when multiple mods with KeyBindings are installed
This commit is contained in:
parent
078d3c2750
commit
43a89e61e9
4 changed files with 255 additions and 1 deletions
|
@ -0,0 +1,123 @@
|
|||
package net.minecraft.src.forge;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.GameSettings;
|
||||
import net.minecraft.src.GuiControls;
|
||||
import net.minecraft.src.GuiSlot;
|
||||
import net.minecraft.src.KeyBinding;
|
||||
import net.minecraft.src.Tessellator;
|
||||
|
||||
public class GuiControlsScrollPanel extends GuiSlot
|
||||
{
|
||||
private GuiControls controls;
|
||||
private GameSettings options;
|
||||
private Minecraft mc;
|
||||
private String[] message;
|
||||
private int mouseX;
|
||||
private int mouseY;
|
||||
private int selected = -1;
|
||||
|
||||
public GuiControlsScrollPanel(GuiControls controls, GameSettings options, Minecraft mc)
|
||||
{
|
||||
super(mc, controls.width, controls.height, 16, (controls.height - 32) + 4, 25);
|
||||
this.controls = controls;
|
||||
this.options = options;
|
||||
this.mc = mc;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSize() {
|
||||
return options.keyBindings.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void elementClicked(int i, boolean flag)
|
||||
{
|
||||
if (!flag)
|
||||
{
|
||||
if (selected == -1)
|
||||
{
|
||||
selected = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
options.setKeyBinding(selected, -100);
|
||||
selected = -1;
|
||||
KeyBinding.resetKeyBindingArrayAndHash();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSelected(int i)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground() {}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mX, int mY, float f)
|
||||
{
|
||||
mouseX = mX;
|
||||
mouseY = mY;
|
||||
|
||||
if (selected != -1 && !Mouse.isButtonDown(0) && Mouse.getDWheel() == 0)
|
||||
{
|
||||
if (Mouse.next() && Mouse.getEventButtonState())
|
||||
{
|
||||
System.out.println(Mouse.getEventButton());
|
||||
options.setKeyBinding(selected, -100 + Mouse.getEventButton());
|
||||
selected = -1;
|
||||
KeyBinding.resetKeyBindingArrayAndHash();
|
||||
}
|
||||
}
|
||||
|
||||
super.drawScreen(mX, mY, f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawSlot(int index, int xPosition, int yPosition, int l, Tessellator tessellator)
|
||||
{
|
||||
int width = 70;
|
||||
int height = 20;
|
||||
xPosition -= 20;
|
||||
boolean flag = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width && mouseY < yPosition + height;
|
||||
int k = (flag ? 2 : 1);
|
||||
|
||||
GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, mc.renderEngine.getTexture("/gui/gui.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
controls.drawTexturedModalRect(xPosition, yPosition, 0, 46 + k * 20, width / 2, height);
|
||||
controls.drawTexturedModalRect(xPosition + width / 2, yPosition, 200 - width / 2, 46 + k * 20, width / 2, height);
|
||||
controls.drawString(mc.fontRenderer, options.getKeyBindingDescription(index), xPosition + width + 4, yPosition + 6, 0xFFFFFFFF);
|
||||
|
||||
boolean conflict = false;
|
||||
for (int x = 0; x < options.keyBindings.length; x++)
|
||||
{
|
||||
if (x != index && options.keyBindings[x].keyCode == options.keyBindings[index].keyCode)
|
||||
{
|
||||
conflict = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String str = (conflict ? "\247c" : "") + options.getOptionDisplayString(index);
|
||||
str = (index == selected ? "\247f> \247e??? \247f<" : str);
|
||||
controls.drawCenteredString(mc.fontRenderer, str, xPosition + (width / 2), yPosition + (height - 8) / 2, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
public boolean keyTyped(char c, int i)
|
||||
{
|
||||
if (selected != -1)
|
||||
{
|
||||
options.setKeyBinding(selected, i);
|
||||
selected = -1;
|
||||
KeyBinding.resetKeyBindingArrayAndHash();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
122
forge/patches/minecraft/net/minecraft/src/GuiControls.java.patch
Normal file
122
forge/patches/minecraft/net/minecraft/src/GuiControls.java.patch
Normal file
|
@ -0,0 +1,122 @@
|
|||
--- ../src_base/minecraft/net/minecraft/src/GuiControls.java 0000-00-00 00:00:00.000000000 -0000
|
||||
+++ ../src_work/minecraft/net/minecraft/src/GuiControls.java 0000-00-00 00:00:00.000000000 -0000
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
+import net.minecraft.src.forge.GuiControlsScrollPanel;
|
||||
|
||||
public class GuiControls extends GuiScreen
|
||||
{
|
||||
@@ -9,6 +10,7 @@
|
||||
protected String screenTitle;
|
||||
private GameSettings options;
|
||||
private int buttonId;
|
||||
+ private GuiControlsScrollPanel scrollPane;
|
||||
|
||||
public GuiControls(GuiScreen guiscreen, GameSettings gamesettings)
|
||||
{
|
||||
@@ -25,60 +27,30 @@
|
||||
|
||||
public void initGui()
|
||||
{
|
||||
+ scrollPane = new GuiControlsScrollPanel(this, options, mc);
|
||||
StringTranslate stringtranslate = StringTranslate.getInstance();
|
||||
int i = func_20080_j();
|
||||
- for (int j = 0; j < options.keyBindings.length; j++)
|
||||
- {
|
||||
- controlList.add(new GuiSmallButton(j, i + (j % 2) * 160, height / 6 + 24 * (j >> 1), 70, 20, options.getOptionDisplayString(j)));
|
||||
- }
|
||||
-
|
||||
- controlList.add(new GuiButton(200, width / 2 - 100, height / 6 + 168, stringtranslate.translateKey("gui.done")));
|
||||
+ controlList.add(new GuiButton(200, width / 2 - 100, height - 28, stringtranslate.translateKey("gui.done")));
|
||||
+ scrollPane.registerScrollButtons(controlList, 7, 8);
|
||||
screenTitle = stringtranslate.translateKey("controls.title");
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
- for (int i = 0; i < options.keyBindings.length; i++)
|
||||
- {
|
||||
- ((GuiButton)controlList.get(i)).displayString = options.getOptionDisplayString(i);
|
||||
- }
|
||||
-
|
||||
if (guibutton.id == 200)
|
||||
{
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
}
|
||||
- else
|
||||
- {
|
||||
- buttonId = guibutton.id;
|
||||
- guibutton.displayString = (new StringBuilder()).append("> ").append(options.getOptionDisplayString(guibutton.id)).append(" <").toString();
|
||||
- }
|
||||
}
|
||||
|
||||
protected void mouseClicked(int i, int j, int k)
|
||||
{
|
||||
- if (buttonId >= 0)
|
||||
- {
|
||||
- options.setKeyBinding(buttonId, -100 + k);
|
||||
- ((GuiButton)controlList.get(buttonId)).displayString = options.getOptionDisplayString(buttonId);
|
||||
- buttonId = -1;
|
||||
- KeyBinding.resetKeyBindingArrayAndHash();
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- super.mouseClicked(i, j, k);
|
||||
- }
|
||||
+ super.mouseClicked(i, j, k);
|
||||
}
|
||||
|
||||
protected void keyTyped(char c, int i)
|
||||
{
|
||||
- if (buttonId >= 0)
|
||||
- {
|
||||
- options.setKeyBinding(buttonId, i);
|
||||
- ((GuiButton)controlList.get(buttonId)).displayString = options.getOptionDisplayString(buttonId);
|
||||
- buttonId = -1;
|
||||
- KeyBinding.resetKeyBindingArrayAndHash();
|
||||
- }
|
||||
- else
|
||||
+ if (scrollPane.keyTyped(c, i))
|
||||
{
|
||||
super.keyTyped(c, i);
|
||||
}
|
||||
@@ -87,35 +59,8 @@
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
drawDefaultBackground();
|
||||
- drawCenteredString(fontRenderer, screenTitle, width / 2, 20, 0xffffff);
|
||||
- int k = func_20080_j();
|
||||
- for (int l = 0; l < options.keyBindings.length; l++)
|
||||
- {
|
||||
- boolean flag = false;
|
||||
- for (int i1 = 0; i1 < options.keyBindings.length; i1++)
|
||||
- {
|
||||
- if (i1 != l && options.keyBindings[l].keyCode == options.keyBindings[i1].keyCode)
|
||||
- {
|
||||
- flag = true;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- int j1 = l;
|
||||
- if (buttonId == l)
|
||||
- {
|
||||
- ((GuiButton)controlList.get(j1)).displayString = "\247f> \247e??? \247f<";
|
||||
- }
|
||||
- else if (flag)
|
||||
- {
|
||||
- ((GuiButton)controlList.get(j1)).displayString = (new StringBuilder()).append("\247c").append(options.getOptionDisplayString(j1)).toString();
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- ((GuiButton)controlList.get(j1)).displayString = options.getOptionDisplayString(j1);
|
||||
- }
|
||||
- drawString(fontRenderer, options.getKeyBindingDescription(l), k + (l % 2) * 160 + 70 + 6, height / 6 + 24 * (l >> 1) + 7, -1);
|
||||
- }
|
||||
-
|
||||
+ scrollPane.drawScreen(i, j, f);
|
||||
+ drawCenteredString(fontRenderer, screenTitle, width / 2, 4, 0xffffff);
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
}
|
|
@ -76,3 +76,12 @@
|
|||
{
|
||||
if (BlockRail.isRailBlockAt(worldObj, trackX + 1, trackY + 1, trackZ))
|
||||
{
|
||||
@@ -428,7 +425,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- static int getNAdjacentTracks(RailLogic raillogic)
|
||||
+ public static int getNAdjacentTracks(RailLogic raillogic)
|
||||
{
|
||||
return raillogic.getAdjacentTracks();
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
}
|
||||
|
||||
- private int getItemBurnTime(ItemStack itemstack)
|
||||
+ public int getItemBurnTime(ItemStack itemstack)
|
||||
+ public static int getItemBurnTime(ItemStack itemstack)
|
||||
{
|
||||
if (itemstack == null)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue