mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-15 17:44:46 +00:00
Merge pull request #56 from asdflj/levelmaintainer
update level maintainer
This commit is contained in:
18 files changed
+480
-97
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
||||
public class FCGuiLineField extends FCGuiTextField {
|
||||
private final int _xPos;
|
||||
private final int _yPos;
|
||||
private final int _width;
|
||||
private final FontRenderer _fontRender;
|
||||
|
||||
public FCGuiLineField(FontRenderer fontRenderer, int xPos, int yPos, int width) {
|
||||
this(fontRenderer, xPos, yPos, width, 5);
|
||||
}
|
||||
|
||||
public FCGuiLineField(FontRenderer fontRenderer, int xPos, int yPos, int width, int height) {
|
||||
super(fontRenderer, xPos, yPos, width, height);
|
||||
this._xPos = xPos;
|
||||
this._yPos = yPos;
|
||||
this._width = width;
|
||||
this._fontRender = fontRenderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextBox() {
|
||||
if (this.getVisible()) {
|
||||
drawRect(this._xPos, this._yPos, this.xPosition + this.width, this.yPosition + this.height, getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,11 +46,11 @@ public class FCGuiTextField extends GuiTextField {
|
||||
public void drawTextBox() {
|
||||
super.drawTextBox();
|
||||
if (this.getBorder() > 0 && this.getVisible()) {
|
||||
GuiTextField.drawRect(
|
||||
this._xPos - this.getBorder(),
|
||||
this._yPos - this.getBorder(),
|
||||
this._width - 2 * PADDING - this._fontRender.getCharWidth('_') + this.getBorder(),
|
||||
this._height - 2 * PADDING + this.getBorder(),
|
||||
drawRect(
|
||||
this._xPos - getBorder(),
|
||||
this._yPos - getBorder(),
|
||||
this.xPosition + this.width + getBorder(),
|
||||
this.yPosition + this.height + getBorder(),
|
||||
this.getColor());
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,10 @@ public class FCGuiTextField extends GuiTextField {
|
||||
tooltip = t;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
public class TooltipProvider implements ITooltip {
|
||||
@Override
|
||||
public String getMessage() {
|
||||
|
||||
@@ -20,11 +20,16 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
|
||||
private boolean halfSize = false;
|
||||
private String fillVar;
|
||||
private String currentValue;
|
||||
private final boolean background;
|
||||
private static final String prefix = NameConst.TT_KEY;
|
||||
|
||||
public GuiFCImgButton(final int x, final int y, final String idx, final String val) {
|
||||
super(0, 0, 16, "");
|
||||
this(x, y, idx, val, true);
|
||||
}
|
||||
|
||||
public GuiFCImgButton(final int x, final int y, final String idx, final String val, boolean background) {
|
||||
super(0, 0, 16, "");
|
||||
this.background = background;
|
||||
this.buttonSetting = idx;
|
||||
this.currentValue = val;
|
||||
this.xPosition = x;
|
||||
@@ -198,14 +203,15 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
|
||||
|
||||
final int uv_y = (int) Math.floor(iconIndex / 3.0);
|
||||
final int uv_x = iconIndex - uv_y * 3;
|
||||
|
||||
this.drawTexturedModalRect(
|
||||
0,
|
||||
0,
|
||||
Math.round(32F * 16F / 3F),
|
||||
Math.round(32F * 16F / 3F),
|
||||
Math.round(16F * 16F / 3F),
|
||||
Math.round(16F * 16F / 3F));
|
||||
if (this.background) {
|
||||
this.drawTexturedModalRect(
|
||||
0,
|
||||
0,
|
||||
Math.round(32F * 16F / 3F),
|
||||
Math.round(32F * 16F / 3F),
|
||||
Math.round(16F * 16F / 3F),
|
||||
Math.round(16F * 16F / 3F));
|
||||
}
|
||||
this.drawTexturedModalRect(
|
||||
0,
|
||||
0,
|
||||
@@ -234,14 +240,15 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
|
||||
|
||||
final int uv_y = (int) Math.floor(iconIndex / 3.0);
|
||||
final int uv_x = iconIndex - uv_y * 3;
|
||||
|
||||
this.drawTexturedModalRect(
|
||||
0,
|
||||
0,
|
||||
Math.round(32F * 16F / 3F),
|
||||
Math.round(32F * 16F / 3F),
|
||||
Math.round(16F * 16F / 3F),
|
||||
Math.round(16F * 16F / 3F));
|
||||
if (this.background) {
|
||||
this.drawTexturedModalRect(
|
||||
0,
|
||||
0,
|
||||
Math.round(32F * 16F / 3F),
|
||||
Math.round(32F * 16F / 3F),
|
||||
Math.round(16F * 16F / 3F),
|
||||
Math.round(16F * 16F / 3F));
|
||||
}
|
||||
this.drawTexturedModalRect(
|
||||
0,
|
||||
0,
|
||||
|
||||
@@ -9,6 +9,7 @@ import appeng.core.sync.packets.PacketNEIDragClick;
|
||||
import codechicken.nei.VisiblityData;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
import cofh.core.render.CoFHFontRenderer;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer;
|
||||
@@ -16,18 +17,19 @@ import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.slot.SlotSingleItem;
|
||||
import com.glodblock.github.network.CPacketLevelMaintainer;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import java.awt.*;
|
||||
import java.util.Collections;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@@ -41,6 +43,9 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
private TileLevelMaintainer tile;
|
||||
private FCGuiTextField input;
|
||||
private int lastWorkingTick;
|
||||
private final int interval = 20;
|
||||
private final CoFHFontRenderer render;
|
||||
|
||||
public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
|
||||
super(new ContainerLevelMaintainer(ipl, tile));
|
||||
@@ -48,56 +53,74 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
this.xSize = 195;
|
||||
this.ySize = 214;
|
||||
this.tile = tile;
|
||||
this.render = new CoFHFontRenderer(
|
||||
Minecraft.getMinecraft().gameSettings,
|
||||
TEX_BG,
|
||||
Minecraft.getMinecraft().getTextureManager(),
|
||||
true);
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list) {
|
||||
for (Slot slot : this.cont.getRequestSlots()) {
|
||||
if (!slot.getHasStack()) {
|
||||
component[slot.getSlotIndex()].setState(TileLevelMaintainer.State.Nothing);
|
||||
}
|
||||
}
|
||||
for (IAEItemStack is : list) {
|
||||
long size = is.getItemStack().getTagCompound().getLong("Batch");
|
||||
int i = is.getItemStack().getTagCompound().getInteger("Index");
|
||||
boolean isEnable = is.getItemStack().getTagCompound().getBoolean("Enable");
|
||||
NBTTagCompound data = is.getItemStack().getTagCompound();
|
||||
long size = data.getLong("Batch");
|
||||
int i = data.getInteger("Index");
|
||||
boolean isEnable = data.getBoolean("Enable");
|
||||
TileLevelMaintainer.State state = TileLevelMaintainer.State.values()[data.getInteger("State")];
|
||||
component[i].getQty().textField.setText(String.valueOf(is.getStackSize()));
|
||||
component[i].getBatch().textField.setText(String.valueOf(size));
|
||||
component[i].setEnable(isEnable);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
super.drawScreen(mouseX, mouseY, btn);
|
||||
if (ModAndClassUtil.isSearchBar) {
|
||||
for (Component com : this.component) {
|
||||
handleTooltip(mouseX, mouseY, com.getQty().textField.new TooltipProvider());
|
||||
handleTooltip(mouseX, mouseY, com.getBatch().textField.new TooltipProvider());
|
||||
}
|
||||
component[i].setState(state);
|
||||
}
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
|
||||
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
|
||||
component[i] = new Component(
|
||||
new Widget(
|
||||
new FCGuiTextField(this.fontRendererObj, guiLeft + 37, guiTop + 21 + 20 * i, 52, 16),
|
||||
new GuiFCImgButton(guiLeft + 37 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"),
|
||||
I18n.format(NameConst.TT_REQUEST_SIZE),
|
||||
new FCGuiTextField(this.fontRendererObj, guiLeft + 46, guiTop + 19 + 19 * i, 52, 14),
|
||||
NameConst.TT_LEVEL_MAINTAINER_REQUEST_SIZE,
|
||||
i,
|
||||
"TileLevelMaintainer.Quantity"),
|
||||
new Widget(
|
||||
new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 21 + 20 * i, 52, 16),
|
||||
new GuiFCImgButton(guiLeft + 100 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"),
|
||||
I18n.format(NameConst.TT_BATCH_SIZE),
|
||||
new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 19 + 19 * i, 52, 14),
|
||||
NameConst.TT_LEVEL_MAINTAINER_BATCH_SIZE,
|
||||
i,
|
||||
"TileLevelMaintainer.Batch"),
|
||||
new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "ENABLE", "ENABLE"),
|
||||
new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "DISABLE", "DISABLE"),
|
||||
new GuiFCImgButton(guiLeft + 105 + 47, guiTop + 17 + 19 * i, "SUBMIT", "SUBMIT", false),
|
||||
new GuiFCImgButton(guiLeft + 9, guiTop + 20 + 19 * i, "ENABLE", "ENABLE", false),
|
||||
new GuiFCImgButton(guiLeft + 9, guiTop + 20 + 19 * i, "DISABLE", "DISABLE", false),
|
||||
new FCGuiLineField(fontRendererObj, guiLeft + 47, guiTop + 33 + 19 * i, 125),
|
||||
this.buttonList);
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
|
||||
}
|
||||
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
super.drawScreen(mouseX, mouseY, btn);
|
||||
for (Component com : this.component) {
|
||||
handleTooltip(mouseX, mouseY, com.getQty().textField.new TooltipProvider());
|
||||
handleTooltip(mouseX, mouseY, com.getBatch().textField.new TooltipProvider());
|
||||
handleTooltip(mouseX, mouseY, com.getLine().new TooltipProvider());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
mc.getTextureManager().bindTexture(TEX_BG);
|
||||
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
|
||||
int tick = MinecraftServer.getServer().getTickCounter();
|
||||
if (tick > lastWorkingTick + interval && this.input == null) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
|
||||
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
|
||||
}
|
||||
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
|
||||
this.component[i].draw();
|
||||
}
|
||||
@@ -105,7 +128,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_LEVEL_MAINTAINER)), 8, 6, 0x404040);
|
||||
fontRendererObj.drawString(getGuiDisplayName(NameConst.i18n(NameConst.GUI_LEVEL_MAINTAINER)), 8, 6, 0x404040);
|
||||
mouseRegions.render(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@@ -253,25 +276,30 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
private class Component {
|
||||
public boolean isEnable = true;
|
||||
private Widget qty;
|
||||
private Widget batch;
|
||||
private GuiFCImgButton disable;
|
||||
private GuiFCImgButton enable;
|
||||
private final Widget qty;
|
||||
private final Widget batch;
|
||||
private final GuiFCImgButton disable;
|
||||
private final GuiFCImgButton enable;
|
||||
private final GuiFCImgButton submit;
|
||||
private final FCGuiLineField line;
|
||||
private TileLevelMaintainer.State state;
|
||||
|
||||
public Component(
|
||||
Widget qtyInput,
|
||||
Widget batchInput,
|
||||
GuiFCImgButton submitBtn,
|
||||
GuiFCImgButton enableBtn,
|
||||
GuiFCImgButton disableBtn,
|
||||
FCGuiLineField line,
|
||||
List buttonList) {
|
||||
this.qty = qtyInput;
|
||||
this.batch = batchInput;
|
||||
this.enable = enableBtn;
|
||||
this.disable = disableBtn;
|
||||
this.enable.setHalfSize(true);
|
||||
this.disable.setHalfSize(true);
|
||||
buttonList.add(this.qty.button);
|
||||
buttonList.add(this.batch.button);
|
||||
this.submit = submitBtn;
|
||||
this.line = line;
|
||||
this.state = TileLevelMaintainer.State.Nothing;
|
||||
buttonList.add(this.submit);
|
||||
buttonList.add(this.enable);
|
||||
buttonList.add(this.disable);
|
||||
}
|
||||
@@ -303,20 +331,20 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
}
|
||||
|
||||
protected boolean sendToServer(GuiButton btn) {
|
||||
if (this.getQty().button == btn) {
|
||||
return this.send(this.getQty());
|
||||
}
|
||||
if (this.getBatch().button == btn) {
|
||||
return this.send(this.getBatch());
|
||||
}
|
||||
if (this.enable == btn) {
|
||||
boolean didSomething = false;
|
||||
if (this.submit == btn) {
|
||||
if (this.send(this.getQty())) this.send(this.getBatch());
|
||||
didSomething = true;
|
||||
} else if (this.enable == btn) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketLevelMaintainer("TileLevelMaintainer.Enable", this.getIndex()));
|
||||
didSomething = true;
|
||||
} else if (this.disable == btn) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketLevelMaintainer("TileLevelMaintainer.Disable", this.getIndex()));
|
||||
didSomething = true;
|
||||
}
|
||||
return false;
|
||||
return didSomething;
|
||||
}
|
||||
|
||||
public FCGuiTextField isMouseIn(final int xCoord, final int yCoord) {
|
||||
@@ -333,9 +361,50 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
return this.batch;
|
||||
}
|
||||
|
||||
public FCGuiLineField getLine() {
|
||||
return this.line;
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
this.getQty().draw();
|
||||
this.getBatch().draw();
|
||||
ArrayList<String> message = new ArrayList<String>();
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_TITLE) + "\n");
|
||||
switch (this.state) {
|
||||
case Idling:
|
||||
this.line.setColor(0xFF55FF55);
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
|
||||
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE));
|
||||
break;
|
||||
case Crafting:
|
||||
this.line.setColor(0xFFFFFF55);
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
|
||||
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
|
||||
break;
|
||||
case Exporting:
|
||||
this.line.setColor(0xFFAA00AA);
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
|
||||
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
|
||||
break;
|
||||
default:
|
||||
this.line.setColor(0);
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
|
||||
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NONE));
|
||||
}
|
||||
message.add("");
|
||||
if (isShiftKeyDown()) {
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE));
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE_DESC) + "\n");
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK_DESC) + "\n");
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT_DESC) + "\n");
|
||||
} else {
|
||||
message.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
|
||||
}
|
||||
this.line.setMessage(
|
||||
render.wrapFormattedStringToWidth(String.join("\n", message), (int) Math.floor(xSize * 0.8)));
|
||||
this.line.drawTextBox();
|
||||
if (this.isEnable) {
|
||||
this.enable.visible = true;
|
||||
this.disable.visible = false;
|
||||
@@ -344,33 +413,39 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
this.disable.visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setState(TileLevelMaintainer.State state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
||||
private class Widget {
|
||||
public final int idx;
|
||||
public final String action;
|
||||
private FCGuiTextField textField;
|
||||
private GuiFCImgButton button;
|
||||
private final FCGuiTextField textField;
|
||||
private final String tooltip;
|
||||
|
||||
public Widget(FCGuiTextField textField, GuiFCImgButton button, String tooltip, int idx, String action) {
|
||||
public Widget(FCGuiTextField textField, String tooltip, int idx, String action) {
|
||||
this.textField = textField;
|
||||
this.textField.setMessage(tooltip);
|
||||
this.textField.setEnableBackgroundDrawing(false);
|
||||
this.textField.setText("0");
|
||||
this.textField.setMaxStringLength(10); // it's enough to useful
|
||||
this.button = button;
|
||||
this.idx = idx;
|
||||
this.action = action;
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
if (isShiftKeyDown()) {
|
||||
this.setTooltip(render.wrapFormattedStringToWidth(NameConst.i18n(this.tooltip), xSize / 2));
|
||||
} else {
|
||||
this.setTooltip(render.wrapFormattedStringToWidth(
|
||||
NameConst.i18n(this.tooltip, "\n", false) + "\n" + NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE),
|
||||
(int) Math.floor(xSize * 0.8)));
|
||||
}
|
||||
this.textField.drawTextBox();
|
||||
}
|
||||
|
||||
public GuiFCImgButton btn() {
|
||||
return this.button;
|
||||
}
|
||||
|
||||
public void setTooltip(String message) {
|
||||
this.textField.setMessage(message);
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,11 +18,11 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
|
||||
this.tile = tile;
|
||||
AeItemStackHandler request = new AeItemStackHandler(tile.getRequestSlots());
|
||||
for (int y = 0; y < TileLevelMaintainer.REQ_COUNT; y++) {
|
||||
FakeSlot slot = new FakeSlot(request, y, 17, 19 + y * 20);
|
||||
FakeSlot slot = new FakeSlot(request, y, 27, 20 + y * 19);
|
||||
addSlotToContainer(slot);
|
||||
requestSlots[y] = slot;
|
||||
}
|
||||
bindPlayerInventory(ipl, 0, 132);
|
||||
bindPlayerInventory(ipl, 0, 130);
|
||||
}
|
||||
|
||||
public TileLevelMaintainer getTile() {
|
||||
|
||||
Reference in new issue
Block a user