Skip to content

Commit

Permalink
UI优化UI optimization
Browse files Browse the repository at this point in the history
Remove the GUI that you don't need
Remove the same GUI
Update the GUI interface of the factory
Update the color of the configuration slot

--中文--
移除不需要的GUI
去掉相同的GUI
更新工厂的GUI界面
更新配置插槽的颜色
  • Loading branch information
sddsd2332 committed Jan 24, 2023
1 parent 33d1f1b commit 4786e13
Show file tree
Hide file tree
Showing 144 changed files with 467 additions and 398 deletions.
2 changes: 1 addition & 1 deletion src/main/java/mekanism/client/gui/GuiDynamicTank.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected void drawGuiContainerBackgroundLayer(int xAxis, int yAxis) {

@Override
protected ResourceLocation getGuiLocation() {
return MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png");
return MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix_DynamicTank.png");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mekanism/client/gui/GuiEnergyCube.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {

@Override
protected ResourceLocation getGuiLocation() {
return MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png");
return MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png");
}
}
173 changes: 131 additions & 42 deletions src/main/java/mekanism/client/gui/GuiFactory.java

Large diffs are not rendered by default.

17 changes: 6 additions & 11 deletions src/main/java/mekanism/client/gui/GuiGasTank.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,19 @@ public GuiGasTank(InventoryPlayer inventory, TileEntityGasTank tile) {

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
String stored = "" + (tileEntity.gasTank.getStored() == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite")
: tileEntity.gasTank.getStored());
String capacityInfo = stored + " / "
+ (tileEntity.tier.getStorage() == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite")
: tileEntity.tier.getStorage());
fontRenderer.drawString(tileEntity.getName(),
(xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040);
String stored = "" + (tileEntity.gasTank.getStored() == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : tileEntity.gasTank.getStored());
String capacityInfo = stored + " / " + (tileEntity.tier.getStorage() == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : tileEntity.tier.getStorage());
fontRenderer.drawString(tileEntity.getName(), (xSize / 2) - (fontRenderer.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040);
fontRenderer.drawString(capacityInfo, 45, 40, 0x33ff99);
renderScaledText(LangUtils.localize("gui.gas") + ": "
+ (tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName()
: LangUtils.localize("gui.none")),
45, 49, 0x33ff99, 112);
renderScaledText(LangUtils.localize("gui.gas") + ": " + (tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName()
: LangUtils.localize("gui.none")), 45, 49, 0x33ff99, 112);
fontRenderer.drawString(LangUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040);
String name = LangUtils.localize(tileEntity.dumping.getLangKey());
fontRenderer.drawString(name, 156 - fontRenderer.getStringWidth(name), 73, 0x404040);
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}


@Override
protected void drawGuiContainerBackgroundLayer(int xAxis, int yAxis) {
super.drawGuiContainerBackgroundLayer(xAxis, yAxis);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mekanism/client/gui/GuiInductionMatrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected void drawGuiContainerBackgroundLayer(int xAxis, int yAxis) {

@Override
protected ResourceLocation getGuiLocation() {
return MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png");
return MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix_DynamicTank.png");
}

public void displayGauge(int xPos, int yPos, int scale, int side /*0-left, 1-right*/) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public double getProgress() {

@Override
protected ResourceLocation getGuiLocation() {
return MekanismUtils.getResource(ResourceType.GUI, "GuiIsotopicCentrifuge.png");
return MekanismUtils.getResource(ResourceType.GUI, "GuiChemical.png");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public double getProgress() {

@Override
protected ResourceLocation getGuiLocation() {
return MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png");
return MekanismUtils.getResource(ResourceType.GUI, "GuiChemical.png");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public double getProgress() {

@Override
protected ResourceLocation getGuiLocation() {
return MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png");
return MekanismUtils.getResource(ResourceType.GUI, "GuiChemical.png");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public double getProgress() {

@Override
protected ResourceLocation getGuiLocation() {
return MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png");
return MekanismUtils.getResource(ResourceType.GUI, "GuiChemical.png");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public double getProgress() {

@Override
protected ResourceLocation getGuiLocation() {
return MekanismUtils.getResource(ResourceType.GUI, "GuiNutritionalLiquifier.png");
return MekanismUtils.getResource(ResourceType.GUI, "GuiChemical.png");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected boolean inBounds(int xAxis, int yAxis) {
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) {
mc.renderEngine.bindTexture(RESOURCE);
guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 138, 0, 0, 26, 26);

mc.renderEngine.bindTexture(defaultLocation);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/mekanism/client/gui/element/GuiHeatInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void preMouseClicked(int xAxis, int yAxis, int button) {
public void mouseClicked(int xAxis, int yAxis, int button) {
if (button == 0 && inBounds(xAxis, yAxis)) {
MekanismConfig.current().general.tempUnit.set(TempType.values()[(MekanismConfig.current().general.tempUnit.val().ordinal() + 1) % TempType.values().length]);

}
}
}
10 changes: 5 additions & 5 deletions src/main/java/mekanism/client/gui/element/GuiRecipeType2.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@
public class GuiRecipeType2 extends GuiTileEntityElement<TileEntityFactory> {

public GuiRecipeType2(IGuiWrapper gui, TileEntityFactory tile, ResourceLocation def) {
super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRecipeType2.png"), gui, def, tile);
super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRecipeType.png"), gui, def, tile);
}

@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight) {
return new Rectangle4i(guiWidth + 176, guiHeight + 90, 26, 63);
return new Rectangle4i(guiWidth + 176 + 34, guiHeight + 70, 26, 63);
}

@Override
protected boolean inBounds(int xAxis, int yAxis) {
return xAxis >= 180 && xAxis <= 196 && (yAxis >= 95 && yAxis <= 111 || yAxis >= 132 && yAxis <= 148);
return xAxis >= 180 + 34 && xAxis <= 196 + 34 && (yAxis >= 75 && yAxis <= 91 || yAxis >= 112 && yAxis <= 128);
}

@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) {
mc.renderEngine.bindTexture(RESOURCE);
guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 90, 0, 0, 26, 63);
guiObj.drawTexturedRect(guiWidth + 176 + 34, guiHeight + 70, 0, 0, 26, 63);
int displayInt = tileEntity.getScaledRecipeProgress(15);
guiObj.drawTexturedRect(guiWidth + 181, guiHeight + 114, 26, 0, 10, displayInt);
guiObj.drawTexturedRect(guiWidth + 181 + 34, guiHeight + 94, 26, 0, 10, displayInt);
mc.renderEngine.bindTexture(defaultLocation);
}

Expand Down
54 changes: 54 additions & 0 deletions src/main/java/mekanism/client/gui/element/GuiRecipeType3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package mekanism.client.gui.element;

import mekanism.client.gui.IGuiWrapper;
import mekanism.common.tile.TileEntityFactory;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class GuiRecipeType3 extends GuiTileEntityElement<TileEntityFactory> {

public GuiRecipeType3(IGuiWrapper gui, TileEntityFactory tile, ResourceLocation def) {
super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRecipeType.png"), gui, def, tile);
}

@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight) {
return new Rectangle4i(guiWidth + 176 + 72, guiHeight + 70, 26, 63);
}

@Override
protected boolean inBounds(int xAxis, int yAxis) {
return xAxis >= 180 + 72 && xAxis <= 196 + 72 && (yAxis >= 75 && yAxis <= 91 || yAxis >= 112 && yAxis <= 128);
}

@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) {
mc.renderEngine.bindTexture(RESOURCE);
guiObj.drawTexturedRect(guiWidth + 176 + 72, guiHeight + 70, 0, 0, 26, 63);
int displayInt = tileEntity.getScaledRecipeProgress(15);
guiObj.drawTexturedRect(guiWidth + 181 + 72, guiHeight + 94, 26, 0, 10, displayInt);
mc.renderEngine.bindTexture(defaultLocation);
}

@Override
public void renderForeground(int xAxis, int yAxis) {
}

@Override
public void preMouseClicked(int xAxis, int yAxis, int button) {
if (button == 0 && inBounds(xAxis, yAxis)) {
offsetX(26);
}
}

@Override
public void mouseClicked(int xAxis, int yAxis, int button) {
if (button == 0 && inBounds(xAxis, yAxis)) {
offsetX(-26);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@
public class GuiRedstoneControl2 extends GuiTileEntityElement<TileEntity> {

public GuiRedstoneControl2(IGuiWrapper gui, TileEntity tile, ResourceLocation def) {
super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRedstoneControl2.png"), gui, def, tile);
super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRedstoneControl.png"), gui, def, tile);
}

@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight) {
return new Rectangle4i(guiWidth + 176, guiHeight + 138 , 26, 26);
return new Rectangle4i(guiWidth + 176 + 34, guiHeight + 138, 26, 26);
}

@Override
protected boolean inBounds(int xAxis, int yAxis) {
return xAxis >= 179 && xAxis <= 197 && yAxis >= 142 + +10 && yAxis <= 160 + +10 ;
return xAxis >= 179 + 34&& xAxis <= 197 + 34 && yAxis >= 142 && yAxis <= 160;
}

@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) {
mc.renderEngine.bindTexture(RESOURCE);
guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 148 , 0, 0, 26, 26);
guiObj.drawTexturedRect(guiWidth + 176 + 34, guiHeight + 138, 0, 0, 26, 26);
IRedstoneControl control = (IRedstoneControl) tileEntity;
int renderX = 26 + (18 * control.getControlType().ordinal());
guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 152 , renderX, inBounds(xAxis, yAxis) ? 0 : 18, 18, 18);
guiObj.drawTexturedRect(guiWidth + 179 + 34, guiHeight + 142, renderX, inBounds(xAxis, yAxis) ? 0 : 18, 18, 18);
mc.renderEngine.bindTexture(defaultLocation);
}

Expand Down Expand Up @@ -71,5 +71,4 @@ public void mouseClicked(int xAxis, int yAxis, int button) {
Mekanism.packetHandler.sendToServer(new RedstoneControlMessage(Coord4D.get(tileEntity), RedstoneControl.values()[ordinalToSet]));
}
}

}
74 changes: 74 additions & 0 deletions src/main/java/mekanism/client/gui/element/GuiRedstoneControl3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package mekanism.client.gui.element;

import mekanism.api.Coord4D;
import mekanism.client.gui.IGuiWrapper;
import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism;
import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.IRedstoneControl.RedstoneControl;
import mekanism.common.network.PacketRedstoneControl.RedstoneControlMessage;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.init.SoundEvents;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class GuiRedstoneControl3 extends GuiTileEntityElement<TileEntity> {

public GuiRedstoneControl3(IGuiWrapper gui, TileEntity tile, ResourceLocation def) {
super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRedstoneControl.png"), gui, def, tile);
}

@Override
public Rectangle4i getBounds(int guiWidth, int guiHeight) {
return new Rectangle4i(guiWidth + 176 + 72, guiHeight + 138, 26, 26);
}

@Override
protected boolean inBounds(int xAxis, int yAxis) {
return xAxis >= 179 + 72&& xAxis <= 197 + 72 && yAxis >= 142 && yAxis <= 160;
}

@Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) {
mc.renderEngine.bindTexture(RESOURCE);
guiObj.drawTexturedRect(guiWidth + 176 + 72, guiHeight + 138, 0, 0, 26, 26);
IRedstoneControl control = (IRedstoneControl) tileEntity;
int renderX = 26 + (18 * control.getControlType().ordinal());
guiObj.drawTexturedRect(guiWidth + 179 + 72, guiHeight + 142, renderX, inBounds(xAxis, yAxis) ? 0 : 18, 18, 18);
mc.renderEngine.bindTexture(defaultLocation);
}

@Override
public void renderForeground(int xAxis, int yAxis) {
mc.renderEngine.bindTexture(RESOURCE);
IRedstoneControl control = (IRedstoneControl) tileEntity;
if (inBounds(xAxis, yAxis)) {
displayTooltip(control.getControlType().getDisplay(), xAxis, yAxis);
}
mc.renderEngine.bindTexture(defaultLocation);
}

@Override
public void preMouseClicked(int xAxis, int yAxis, int button) {
}

@Override
public void mouseClicked(int xAxis, int yAxis, int button) {
IRedstoneControl control = (IRedstoneControl) tileEntity;

if (button == 0 && inBounds(xAxis, yAxis)) {
RedstoneControl current = control.getControlType();
int ordinalToSet = current.ordinal() < (RedstoneControl.values().length - 1) ? current.ordinal() + 1 : 0;
if (ordinalToSet == RedstoneControl.PULSE.ordinal() && !control.canPulse()) {
ordinalToSet = 0;
}

SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK);
Mekanism.packetHandler.sendToServer(new RedstoneControlMessage(Coord4D.get(tileEntity), RedstoneControl.values()[ordinalToSet]));
}
}
}
Loading

0 comments on commit 4786e13

Please sign in to comment.