More gui fixes for slots

This commit is contained in:
modmuss50 2017-12-28 14:01:33 +00:00
parent 04b4fa2b88
commit fbd31e1177
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
6 changed files with 57 additions and 26 deletions

View file

@ -24,8 +24,6 @@
package techreborn.client.gui;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
@ -35,6 +33,8 @@ import techreborn.client.gui.widget.GuiButtonUpDown;
import techreborn.packets.PacketAesu;
import techreborn.tiles.storage.TileAdjustableSU;
import java.io.IOException;
public class GuiAESU extends GuiBase {
TileAdjustableSU tile;
@ -61,12 +61,14 @@ public class GuiAESU extends GuiBase {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
final Layer layer = Layer.FOREGROUND;
GlStateManager.pushMatrix();
GlStateManager.scale(0.6, 0.6, 1);
this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.tile.getEnergy()) + "/"
if(!GuiBase.showSlotConfig){
GlStateManager.pushMatrix();
GlStateManager.scale(0.6, 0.6, 1);
this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.tile.getEnergy()) + "/"
+ PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.tile.getMaxPower()) + " "
+ PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
GlStateManager.popMatrix();
GlStateManager.popMatrix();
}
this.builder.drawMultiEnergyBar(this, 81, 28, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);

View file

@ -51,10 +51,13 @@ public class GuiBase extends GuiContainer {
public BuiltContainer container;
public static boolean showSlotConfig = false;
private boolean upgrades;
public GuiBase(EntityPlayer player, TileEntity tile, BuiltContainer container) {
super(container);
this.tile = tile;
this.container = container;
showSlotConfig = false;
}
protected void drawSlot(int x, int y, Layer layer) {
@ -125,9 +128,10 @@ public class GuiBase extends GuiContainer {
IUpgradeable upgradeable = (IUpgradeable) tile;
if (upgradeable.canBeUpgraded()) {
builder.drawUpgrades(this, upgradeable, guiLeft, guiTop);
upgrades = true;
}
}
builder.drawSlotTab(this, guiLeft, guiTop, mouseX, mouseY);
builder.drawSlotTab(this, guiLeft, guiTop, mouseX, mouseY, upgrades);
}
@ -210,7 +214,11 @@ public class GuiBase extends GuiContainer {
@Override
protected void mouseReleased(int mouseX, int mouseY, int state) {
if(isPointInRegion(-26, 84, 30, 30, mouseX, mouseY)){
int offset = 0;
if(!upgrades){
offset = 80;
}
if(isPointInRegion(-26, 84 - offset, 30, 30, mouseX, mouseY)){
showSlotConfig = !showSlotConfig;
if(!showSlotConfig){
GuiSlotConfiguration.reset();

View file

@ -52,10 +52,12 @@ public class GuiBatbox extends GuiBase {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
final Layer layer = Layer.FOREGROUND;
GlStateManager.pushMatrix();
GlStateManager.scale(0.6, 0.6, 5);
this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.tile.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.tile.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
GlStateManager.popMatrix();
if(!GuiBase.showSlotConfig){
GlStateManager.pushMatrix();
GlStateManager.scale(0.6, 0.6, 5);
this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.tile.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.tile.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
GlStateManager.popMatrix();
}
this.builder.drawMultiEnergyBar(this, 81, 28, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
}

View file

@ -53,10 +53,12 @@ public class GuiMFE extends GuiBase {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
final Layer layer = Layer.FOREGROUND;
GlStateManager.pushMatrix();
GlStateManager.scale(0.6, 0.6, 1);
this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.mfe.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.mfe.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
GlStateManager.popMatrix();
if(!GuiBase.showSlotConfig){
GlStateManager.pushMatrix();
GlStateManager.scale(0.6, 0.6, 1);
this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.mfe.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.mfe.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
GlStateManager.popMatrix();
}
this.builder.drawMultiEnergyBar(this, 81, 28, (int) this.mfe.getEnergy(), (int) this.mfe.getMaxPower(), mouseX, mouseY, 0, layer);
}

View file

@ -62,6 +62,9 @@ public class TRBuilder extends GuiBuilder {
}
public void drawMultiEnergyBar(GuiBase gui, int x, int y, int energyStored, int maxEnergyStored, int mouseX, int mouseY, int buttonID, GuiBase.Layer layer) {
if(GuiBase.showSlotConfig){
return;
}
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
@ -243,6 +246,9 @@ public class TRBuilder extends GuiBuilder {
}
public void drawUpDownButtons(GuiBase gui, int x, int y, GuiBase.Layer layer){
if(GuiBase.showSlotConfig){
return;
}
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
@ -255,6 +261,9 @@ public class TRBuilder extends GuiBuilder {
}
public void drawEnergyOutput(GuiBase gui, int right, int top, int maxOutput, GuiBase.Layer layer){
if(GuiBase.showSlotConfig){
return;
}
String text = PowerSystem.getLocaliszedPowerFormattedNoSuffix(maxOutput) + " "
+ PowerSystem.getDisplayPower().abbreviation + "/t";
int width = gui.mc.fontRenderer.getStringWidth(text);
@ -269,6 +278,9 @@ public class TRBuilder extends GuiBuilder {
}
public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix, GuiBase.Layer layer) {
if(GuiBase.showSlotConfig){
return;
}
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
@ -301,6 +313,9 @@ public class TRBuilder extends GuiBuilder {
}
public void drawBigHeatBar(GuiBase gui, int x, int y, int value, int max, GuiBase.Layer layer) {
if(GuiBase.showSlotConfig){
return;
}
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
@ -386,11 +401,15 @@ public class TRBuilder extends GuiBuilder {
gui.drawTexturedModalRect(posX - 27, posY + 4, 126, 151, 30, 87);
}
public void drawSlotTab(GuiScreen gui, int posX, int posY, int mouseX, int mouseY){
public void drawSlotTab(GuiScreen gui, int posX, int posY, int mouseX, int mouseY, boolean upgrades){
int offset = 0;
if(!upgrades){
offset = 80;
}
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
gui.drawTexturedModalRect(posX - 26, posY + 84, 157, 148, 30, 30);
renderItemStack(new ItemStack(ModItems.WRENCH), posX - 19, posY + 92);
if (isInRect(posX - 19, posY + 92, 12, 12, mouseX, mouseY)) {
gui.drawTexturedModalRect(posX - 26, posY + 84 - offset, 157, 148, 30, 30);
renderItemStack(new ItemStack(ModItems.WRENCH), posX - 19, posY + 92 - offset);
if (isInRect(posX - 19, posY + 92 - offset, 12, 12, mouseX, mouseY)) {
List<String> list = new ArrayList<>();
list.add("Configure slots");
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRenderer);

View file

@ -5,14 +5,12 @@ import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.client.FMLClientHandler;
import reborncore.RebornCore;
import reborncore.client.gui.GuiUtil;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.network.NetworkManager;
import reborncore.common.network.packet.PacketIOSave;
import reborncore.common.network.packet.PacketSlotSave;
@ -44,9 +42,9 @@ public class SlotConfigPopupElement extends ElementBase {
IBlockAccess blockAccess = machine.getWorld();
BlockPos pos = machine.getPos();
IBlockState state = blockAccess.getBlockState(pos);
IBlockState actualState = Blocks.DIRT.getDefaultState().getActualState(blockAccess, pos);
IBlockState actualState = state.getBlock().getDefaultState().getActualState(blockAccess, pos);
BlockRendererDispatcher dispatcher = FMLClientHandler.instance().getClient().getBlockRendererDispatcher();
IBakedModel model = dispatcher.getBlockModelShapes().getModelForState(state.withProperty(BlockMachineBase.FACING, EnumFacing.NORTH));
IBakedModel model = dispatcher.getBlockModelShapes().getModelForState(state.getBlock().getDefaultState());
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 4, 23); //left
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, -12, -90F, 1F, 0F, 0F); //top