Feature/level maintainer terminal (#166)

* Fix `zIndexes` for compatability with `DuraDisplay`

* Update AE2 and fix compatability

---------

Co-authored-by: Andrei Laiff <[email protected]>
This commit is contained in:
Martin RobertzandAndrei Laiff authored and GitHub committed 2023-10-22 22:15:39 +02:00
1 parent 6d646f8c4a
commit bad5622723
8 files changed
+272 -149

No files matched your search

+38 -3
View File
@@ -1,8 +1,41 @@
// Add your dependencies here
/*
* Add your dependencies here. Supported configurations:
* - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod
* Available at runtime and compiletime for mods depending on this mod
* - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API
* Available at runtime but not compiletime for mods depending on this mod
* - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods
* Not available at all for mods depending on this mod, only visible at compiletime for this mod
* - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod
* Available at compiletime but not runtime for mods depending on this mod
* - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency
* Not available at all for mods depending on this mod, only visible at runtime for this mod
* - devOnlyNonPublishable("g:n:v:c"): a combination of runtimeOnlyNonPublishable and compileOnly for dependencies present at both compiletime and runtime,
* but not published as Maven dependencies - useful for RFG-deobfuscated dependencies or local testing
* - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime
* Available at runtime for mods depending on this mod
* - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry
* - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main
*
* - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name
* Requires you to enable usesShadowedDependencies in gradle.properties
*
* - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient)
*
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed,
* but use this sparingly as it can break using your mod as another mod's dependency if you're not careful.
*
* To depend on obfuscated jars you can use `devOnlyNonPublishable(rfg.deobf("dep:spec:1.2.3"))` to fetch an obfuscated jar from maven,
* or `devOnlyNonPublishable(rfg.deobf(project.files("libs/my-mod-jar.jar")))` to use a file.
*
* Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not.
* The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published.
*
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.4.5-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-268-GTNH-pre:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-271-GTNH-pre:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.6.2:dev')
api("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.1:dev")
@@ -23,4 +56,6 @@ dependencies {
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.4.13-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:GTplusplus:1.10.21:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.3.18:dev") { transitive = false }
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.1.7:dev")
}
@@ -58,7 +58,7 @@ import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketIfaceTermUpdate;
import appeng.core.sync.packets.PacketInterfaceTerminalUpdate;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.helpers.InventoryAction;
import appeng.helpers.PatternHelper;
@@ -80,7 +80,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
AppEng.MOD_ID,
"textures/guis/newinterfaceterminal.png");
private final IfaceList masterList = new IfaceList();
private final InterfaceWirelessList masterList = new InterfaceWirelessList();
private final MEGuiTextField searchFieldOutputs;
private final MEGuiTextField searchFieldInputs;
private final MEGuiTextField searchFieldNames;
@@ -100,11 +100,13 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
* Z-level Map (FLOATS) 0.0 - BACKGROUND 1.0 - ItemStacks 2.0 - Slot color overlays 20.0 - ItemStack overlays 21.0 -
* Slot mouse hover overlay 200.0 - Tooltips
*/
private static final float ITEMSTACK_Z = 1.0f;
private static final float ITEM_STACK_Z = 100.0f;
private static final float SLOT_Z = 0.5f;
private static final float ITEMSTACK_OVERLAY_Z = 20.0f;
private static final float SLOT_HOVER_Z = 31.0f;
private static final float TOOLTIP_Z = 200.0f;
private static final float ITEM_STACK_OVERLAY_Z = 200.0f;
private static final float SLOT_HOVER_Z = 310.0f;
private static final float TOOLTIP_Z = 210.0f;
private static final float STEP_Z = 10.0f;
private static final float MAGIC_RENDER_ITEM_Z = 50.0f;
protected int offsetY;
@@ -327,7 +329,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
offsetY + HEADER_HEIGHT + viewHeight + 1,
0.0f,
0.0f,
(HEADER_HEIGHT + IfaceSection.TITLE_HEIGHT + 1.0f) / 256.0f,
(HEADER_HEIGHT + InterfaceWirelessSection.TITLE_HEIGHT + 1.0f) / 256.0f,
this.xSize / 256.0f,
(HEADER_HEIGHT + 106.0f) / 256.0f);
Tessellator.instance.draw();
@@ -359,7 +361,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
final int scroll = this.getScrollBar().getCurrentScroll();
int viewY = -scroll; // current y in viewport coordinates
int entryIdx = 0;
List<IfaceSection> visibleSections = this.masterList.getVisibleSections();
List<InterfaceWirelessSection> visibleSections = this.masterList.getVisibleSections();
final float guiScaleX = (float) mc.displayWidth / width;
final float guiScaleY = (float) mc.displayHeight / height;
@@ -374,7 +376,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
* Render each section
*/
while (viewY < this.viewHeight && entryIdx < visibleSections.size()) {
IfaceSection section = visibleSections.get(entryIdx);
InterfaceWirelessSection section = visibleSections.get(entryIdx);
int sectionHeight = section.getHeight();
/* Is it viewable/in the viewport at all? */
@@ -401,7 +403,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
* @param relMouseY transformed mouse coords relative to viewport
* @return the height of the section rendered in viewport coordinates, max of viewHeight.
*/
private int drawSection(IfaceSection section, int viewY, int relMouseX, int relMouseY) {
private int drawSection(InterfaceWirelessSection section, int viewY, int relMouseX, int relMouseY) {
int title;
int renderY = 0;
final int sectionBottom = viewY + section.getHeight() - 1;
@@ -409,49 +411,70 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
/*
* Render title
*/
GL11.glTranslatef(0.0f, 0.0f, 50f);
bindTexture(BACKGROUND);
if (sectionBottom > 0 && sectionBottom < IfaceSection.TITLE_HEIGHT) {
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z);
if (sectionBottom > 0 && sectionBottom < InterfaceWirelessSection.TITLE_HEIGHT) {
/* Transition draw */
title = sectionBottom;
} else if (viewY < 0) {
/* Hidden title draw */
title = 0;
} else {
/* Normal title draw */
title = 0;
}
GL11.glTranslatef(0.0f, 0.0f, -(ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z));
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
Iterator<InerfaceWirelessEntry> visible = section.getVisible();
while (visible.hasNext()) {
if (viewY < viewHeight) {
renderY += drawEntry(
visible.next(),
viewY + InterfaceWirelessSection.TITLE_HEIGHT + renderY,
title,
relMouseX,
relMouseY);
} else {
InerfaceWirelessEntry entry = visible.next();
entry.dispY = -9999;
entry.optionsButton.yPosition = -1;
}
}
bindTexture(BACKGROUND);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z);
if (sectionBottom > 0 && sectionBottom < InterfaceWirelessSection.TITLE_HEIGHT) {
/* Transition draw */
drawTexturedModalRect(
0,
0,
VIEW_LEFT,
HEADER_HEIGHT + IfaceSection.TITLE_HEIGHT - sectionBottom,
HEADER_HEIGHT + InterfaceWirelessSection.TITLE_HEIGHT - sectionBottom,
VIEW_WIDTH,
sectionBottom);
fontRendererObj.drawString(section.name, 2, sectionBottom - IfaceSection.TITLE_HEIGHT + 2, fontColor);
title = sectionBottom;
fontRendererObj
.drawString(section.name, 2, sectionBottom - InterfaceWirelessSection.TITLE_HEIGHT + 2, fontColor);
} else if (viewY < 0) {
/* Hidden title draw */
drawTexturedModalRect(0, 0, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, IfaceSection.TITLE_HEIGHT);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glTranslatef(0.0f, 0.0f, 100f);
drawTexturedModalRect(0, 0, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, InterfaceWirelessSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, 2, fontColor);
title = 0;
GL11.glEnable(GL11.GL_DEPTH_TEST);
} else {
/* Normal title draw */
drawTexturedModalRect(0, viewY, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, IfaceSection.TITLE_HEIGHT);
drawTexturedModalRect(
0,
viewY,
VIEW_LEFT,
HEADER_HEIGHT,
VIEW_WIDTH,
InterfaceWirelessSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, viewY + 2, fontColor);
title = 0;
}
GL11.glTranslatef(0.0f, 0.0f, -50f);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glTranslatef(0.0f, 0.0f, -(ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z));
Iterator<IfaceEntry> visible = section.getVisible();
while (visible.hasNext()) {
if (viewY < viewHeight) {
renderY += drawEntry(
visible.next(),
viewY + IfaceSection.TITLE_HEIGHT + renderY,
title,
relMouseX,
relMouseY);
} else {
IfaceEntry entry = visible.next();
entry.dispY = -9999;
entry.optionsButton.yPosition = -1;
}
}
return IfaceSection.TITLE_HEIGHT + renderY;
return InterfaceWirelessSection.TITLE_HEIGHT + renderY;
}
/**
@@ -459,7 +482,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
*
* @param viewY the gui coordinate z
*/
private int drawEntry(IfaceEntry entry, int viewY, int titleBottom, int relMouseX, int relMouseY) {
private int drawEntry(InerfaceWirelessEntry entry, int viewY, int titleBottom, int relMouseX, int relMouseY) {
bindTexture(BACKGROUND);
Tessellator.instance.startDrawingQuads();
int relY = 0;
@@ -502,7 +525,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
}
toRender.drawButton(mc, relMouseX, relMouseY);
if (toRender.getMouseIn()
&& relMouseY >= Math.max(IfaceSection.TITLE_HEIGHT, entry.optionsButton.yPosition)) {
&& relMouseY >= Math.max(InterfaceWirelessSection.TITLE_HEIGHT, entry.optionsButton.yPosition)) {
// draw a tooltip
GL11.glTranslatef(0f, 0f, TOOLTIP_Z);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
@@ -531,30 +554,30 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
ItemStack stack = inv.getStackInSlot(slotIdx);
boolean tooltip = relMouseX > colLeft - 1 && relMouseX < colRight - 1
&& relMouseY >= Math.max(viewY + rowYTop, IfaceSection.TITLE_HEIGHT)
&& relMouseY >= Math.max(viewY + rowYTop, InterfaceWirelessSection.TITLE_HEIGHT)
&& relMouseY < Math.min(viewY + rowYBot, viewHeight);
if (stack != null) {
final ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
final ItemStack toRender = iep.getOutput(stack);
GL11.glPushMatrix();
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEMSTACK_Z);
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_Z);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
translatedRenderItem.zLevel = 3.0f - 50.0f;
translatedRenderItem.zLevel = ITEM_STACK_Z - MAGIC_RENDER_ITEM_Z;
translatedRenderItem
.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), toRender, 0, 0);
GL11.glTranslatef(0.0f, 0.0f, ITEMSTACK_OVERLAY_Z - ITEMSTACK_Z);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
aeRenderItem.setAeStack(AEItemStack.create(toRender));
aeRenderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), toRender, 0, 0);
aeRenderItem.zLevel = 0.0f;
RenderHelper.disableStandardItemLighting();
if (!tooltip) {
if (entry.brokenRecipes[slotIdx]) {
GL11.glTranslatef(0.0f, 0.0f, SLOT_Z - ITEMSTACK_OVERLAY_Z);
GL11.glTranslatef(0.0f, 0.0f, SLOT_Z - ITEM_STACK_OVERLAY_Z);
drawRect(0, 0, 16, 16, GuiColors.ItemSlotOverlayInvalid.getColor());
} else if (entry.filteredRecipes[slotIdx]) {
GL11.glTranslatef(0.0f, 0.0f, ITEMSTACK_OVERLAY_Z);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z);
drawRect(0, 0, 16, 16, GuiColors.ItemSlotOverlayUnpowered.getColor());
}
} else {
@@ -563,7 +586,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
GL11.glPopMatrix();
} else if (entry.filteredRecipes[slotIdx]) {
GL11.glPushMatrix();
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEMSTACK_OVERLAY_Z);
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_OVERLAY_Z);
drawRect(0, 0, 16, 16, GuiColors.ItemSlotOverlayUnpowered.getColor());
GL11.glPopMatrix();
}
@@ -757,32 +780,38 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
return false;
}
public void postUpdate(List<PacketIfaceTermUpdate.PacketEntry> updates, int statusFlags) {
if ((statusFlags & PacketIfaceTermUpdate.CLEAR_ALL_BIT) == PacketIfaceTermUpdate.CLEAR_ALL_BIT) {
public void postUpdate(List<PacketInterfaceTerminalUpdate.PacketEntry> updates, int statusFlags) {
if ((statusFlags & PacketInterfaceTerminalUpdate.CLEAR_ALL_BIT)
== PacketInterfaceTerminalUpdate.CLEAR_ALL_BIT) {
/* Should clear all client entries. */
this.masterList.list.clear();
}
/* Should indicate disconnected, so the terminal turns dark. */
this.online = (statusFlags & PacketIfaceTermUpdate.DISCONNECT_BIT) != PacketIfaceTermUpdate.DISCONNECT_BIT;
this.online = (statusFlags & PacketInterfaceTerminalUpdate.DISCONNECT_BIT)
!= PacketInterfaceTerminalUpdate.DISCONNECT_BIT;
for (PacketIfaceTermUpdate.PacketEntry cmd : updates) {
for (PacketInterfaceTerminalUpdate.PacketEntry cmd : updates) {
parsePacketCmd(cmd);
}
this.masterList.markDirty();
}
private void parsePacketCmd(PacketIfaceTermUpdate.PacketEntry cmd) {
private void parsePacketCmd(PacketInterfaceTerminalUpdate.PacketEntry cmd) {
long id = cmd.entryId;
if (cmd instanceof PacketIfaceTermUpdate.PacketAdd addCmd) {
IfaceEntry entry = new IfaceEntry(id, addCmd.name, addCmd.rows, addCmd.rowSize, addCmd.online)
.setLocation(addCmd.x, addCmd.y, addCmd.z, addCmd.dim, addCmd.side)
.setIcons(addCmd.selfRep, addCmd.dispRep).setItems(addCmd.items);
if (cmd instanceof PacketInterfaceTerminalUpdate.PacketAdd addCmd) {
InerfaceWirelessEntry entry = new InerfaceWirelessEntry(
id,
addCmd.name,
addCmd.rows,
addCmd.rowSize,
addCmd.online).setLocation(addCmd.x, addCmd.y, addCmd.z, addCmd.dim, addCmd.side)
.setIcons(addCmd.selfRep, addCmd.dispRep).setItems(addCmd.items);
masterList.addEntry(entry);
} else if (cmd instanceof PacketIfaceTermUpdate.PacketRemove) {
} else if (cmd instanceof PacketInterfaceTerminalUpdate.PacketRemove) {
masterList.removeEntry(id);
} else if (cmd instanceof PacketIfaceTermUpdate.PacketOverwrite owCmd) {
IfaceEntry entry = masterList.list.get(id);
} else if (cmd instanceof PacketInterfaceTerminalUpdate.PacketOverwrite owCmd) {
InerfaceWirelessEntry entry = masterList.list.get(id);
if (entry == null) {
return;
@@ -800,8 +829,8 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
}
}
masterList.isDirty = true;
} else if (cmd instanceof PacketIfaceTermUpdate.PacketRename renameCmd) {
IfaceEntry entry = masterList.list.get(id);
} else if (cmd instanceof PacketInterfaceTerminalUpdate.PacketRename renameCmd) {
InerfaceWirelessEntry entry = masterList.list.get(id);
if (entry != null) {
if (StatCollector.canTranslate(renameCmd.newName)) {
@@ -894,16 +923,16 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
/**
* Tracks the list of entries.
*/
private class IfaceList {
private class InterfaceWirelessList {
private final Map<Long, IfaceEntry> list = new HashMap<>();
private final Map<String, IfaceSection> sections = new TreeMap<>();
private final List<IfaceSection> visibleSections = new ArrayList<>();
private final Map<Long, InerfaceWirelessEntry> list = new HashMap<>();
private final Map<String, InterfaceWirelessSection> sections = new TreeMap<>();
private final List<InterfaceWirelessSection> visibleSections = new ArrayList<>();
private boolean isDirty;
private int height;
private IfaceEntry hoveredEntry;
private InerfaceWirelessEntry hoveredEntry;
IfaceList() {
InterfaceWirelessList() {
this.isDirty = true;
}
@@ -914,7 +943,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
height = 0;
visibleSections.clear();
for (IfaceSection section : sections.values()) {
for (InterfaceWirelessSection section : sections.values()) {
String query = GuiInterfaceWireless.this.searchFieldNames.getText();
if (!query.isEmpty() && !section.name.toLowerCase().contains(query.toLowerCase())) {
continue;
@@ -966,7 +995,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
} else {
int y = 0;
for (IfaceSection section : sections) {
for (InterfaceWirelessSection section : sections) {
if (y > viewY) {
result = true;
scrollbar.setCurrentScroll(y);
@@ -978,11 +1007,11 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
return result;
}
public void addEntry(IfaceEntry entry) {
IfaceSection section = sections.get(entry.dispName);
public void addEntry(InerfaceWirelessEntry entry) {
InterfaceWirelessSection section = sections.get(entry.dispName);
if (section == null) {
section = new IfaceSection(entry.dispName);
section = new InterfaceWirelessSection(entry.dispName);
sections.put(entry.dispName, section);
}
section.addEntry(entry);
@@ -991,14 +1020,14 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
}
public void removeEntry(long id) {
IfaceEntry entry = list.remove(id);
InerfaceWirelessEntry entry = list.remove(id);
if (entry != null) {
entry.section.removeEntry(entry);
}
}
public List<IfaceSection> getVisibleSections() {
public List<InterfaceWirelessSection> getVisibleSections() {
if (isDirty) {
update();
}
@@ -1016,7 +1045,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
if (relMouseX < 0 || relMouseX >= VIEW_WIDTH || relMouseY < 0 || relMouseY >= viewHeight) {
return false;
}
for (IfaceSection section : getVisibleSections()) {
for (InterfaceWirelessSection section : getVisibleSections()) {
if (section.mouseClicked(relMouseX, relMouseY, btn)) {
return true;
}
@@ -1028,13 +1057,13 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
/**
* A section holds all the interface entries with the same name.
*/
private class IfaceSection {
private class InterfaceWirelessSection {
public static final int TITLE_HEIGHT = 12;
String name;
List<IfaceEntry> entries = new ArrayList<>();
Set<IfaceEntry> visibleEntries = new TreeSet<>(Comparator.comparing(e -> {
List<InerfaceWirelessEntry> entries = new ArrayList<>();
Set<InerfaceWirelessEntry> visibleEntries = new TreeSet<>(Comparator.comparing(e -> {
if (e.dispRep != null) {
return e.dispRep.getDisplayName() + e.id;
} else {
@@ -1045,7 +1074,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
private boolean isDirty = true;
boolean visible = false;
IfaceSection(String name) {
InterfaceWirelessSection(String name) {
this.name = name;
}
@@ -1065,7 +1094,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
height = 0;
} else {
height = TITLE_HEIGHT;
for (IfaceEntry entry : visibleEntries) {
for (InerfaceWirelessEntry entry : visibleEntries) {
height += entry.guiHeight;
}
}
@@ -1077,7 +1106,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
String input = GuiInterfaceWireless.this.searchFieldInputs.getText().toLowerCase();
String output = GuiInterfaceWireless.this.searchFieldOutputs.getText().toLowerCase();
for (IfaceEntry entry : entries) {
for (InerfaceWirelessEntry entry : entries) {
var moleAss = AEApi.instance().definitions().blocks().molecularAssembler().maybeStack(1);
entry.dispY = -9999;
if (onlyMolecularAssemblers
@@ -1116,19 +1145,19 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
}
}
public void addEntry(IfaceEntry entry) {
public void addEntry(InerfaceWirelessEntry entry) {
this.entries.add(entry);
entry.section = this;
this.isDirty = true;
}
public void removeEntry(IfaceEntry entry) {
public void removeEntry(InerfaceWirelessEntry entry) {
this.entries.remove(entry);
entry.section = null;
this.isDirty = true;
}
public Iterator<IfaceEntry> getVisible() {
public Iterator<InerfaceWirelessEntry> getVisible() {
if (isDirty) {
update();
}
@@ -1136,7 +1165,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
}
public boolean mouseClicked(int relMouseX, int relMouseY, int btn) {
Iterator<IfaceEntry> it = getVisible();
Iterator<InerfaceWirelessEntry> it = getVisible();
boolean ret = false;
while (it.hasNext() && !ret) {
@@ -1150,7 +1179,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
/**
* This class keeps track of an entry and its widgets.
*/
private class IfaceEntry {
private class InerfaceWirelessEntry {
String dispName;
AppEngInternalInventory inv;
@@ -1161,7 +1190,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
ItemStack selfRep;
/** Nullable - icon that represents the interface's "target" */
ItemStack dispRep;
IfaceSection section;
InterfaceWirelessSection section;
long id;
int x, y, z, dim, side;
int rows, rowSize;
@@ -1175,7 +1204,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
boolean[] filteredRecipes;
private int hoveredSlotIdx = -1;
IfaceEntry(long id, String name, int rows, int rowSize, boolean online) {
InerfaceWirelessEntry(long id, String name, int rows, int rowSize, boolean online) {
this.id = id;
if (StatCollector.canTranslate(name)) {
this.dispName = StatCollector.translateToLocal(name);
@@ -1200,7 +1229,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
this.filteredRecipes = new boolean[rows * rowSize];
}
IfaceEntry setLocation(int x, int y, int z, int dim, int side) {
InerfaceWirelessEntry setLocation(int x, int y, int z, int dim, int side) {
this.x = x;
this.y = y;
this.z = z;
@@ -1210,7 +1239,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
return this;
}
IfaceEntry setIcons(ItemStack selfRep, ItemStack dispRep) {
InerfaceWirelessEntry setIcons(ItemStack selfRep, ItemStack dispRep) {
// Kotlin would make this pretty easy :(
this.selfRep = selfRep;
this.dispRep = dispRep;
@@ -1230,7 +1259,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
this.guiHeight = 18 * rows + 4;
}
IfaceEntry setItems(NBTTagList items) {
InerfaceWirelessEntry setItems(NBTTagList items) {
assert items.tagCount() == inv.getSizeInventory();
for (int i = 0; i < items.tagCount(); ++i) {
@@ -1270,7 +1299,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
return false;
}
if (mouseX >= optionsButton.xPosition && mouseX < 2 + optionsButton.width
&& mouseY > Math.max(optionsButton.yPosition, IfaceSection.TITLE_HEIGHT)
&& mouseY > Math.max(optionsButton.yPosition, InterfaceWirelessSection.TITLE_HEIGHT)
&& mouseY <= Math.min(optionsButton.yPosition + optionsButton.height, viewHeight)) {
optionsButton.func_146113_a(mc.getSoundHandler());
DimensionalCoord blockPos = new DimensionalCoord(x, y, z, dim);
@@ -1311,7 +1340,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
int offsetY = mouseY - dispY;
int offsetX = mouseX - (VIEW_WIDTH - rowSize * 18) - 1;
if (offsetX >= 0 && offsetX < (rowSize * 18)
&& mouseY > Math.max(dispY, IfaceSection.TITLE_HEIGHT)
&& mouseY > Math.max(dispY, InterfaceWirelessSection.TITLE_HEIGHT)
&& offsetY < Math.min(viewHeight - dispY, guiHeight)) {
final int col = offsetX / 18;
final int row = offsetY / 18;
@@ -263,19 +263,6 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
}
}
this.input = null;
for (int i = 0; i < this.cont.getRequestSlots().length; i++) {
SlotFluidConvertingFake slot = this.cont.getRequestSlots()[i];
ItemStack currentStack = this.cont.getPlayerInv().getItemStack();
if (getSlotArea(slot).contains(xCoord, yCoord) && currentStack != null) {
ItemStack itemStack = createLevelValues(currentStack.copy());
itemStack.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putStack(itemStack);
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(itemStack, slot.getSlotIndex()));
this.updateAmount(slot.getSlotIndex(), itemStack.stackSize);
return;
}
}
}
super.mouseClicked(xCoord, yCoord, btn);
}
@@ -370,6 +357,17 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
if (draggedStack != null) {
draggedStack.stackSize = 0;
}
for (int i = 0; i < this.cont.getRequestSlots().length; i++) {
SlotFluidConvertingFake slot = this.cont.getRequestSlots()[i];
if (getSlotArea(slot).contains(mouseX, mouseY) && draggedStack != null) {
ItemStack itemStack = createLevelValues(draggedStack.copy());
itemStack.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putStack(itemStack);
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(itemStack, slot.getSlotIndex()));
this.updateAmount(slot.getSlotIndex(), itemStack.stackSize);
return true;
}
}
return false;
}
@@ -81,6 +81,7 @@ import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import appeng.util.item.AEItemStack;
import cpw.mods.fml.common.Loader;
@@ -114,11 +115,13 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
// private GuiFCImgButton modeSwitchEdit;
private final LevelTerminalList masterList = new LevelTerminalList();
private final List<String> extraOptionsText = new ArrayList<>(2);
private static final float ITEM_STACK_Z = 1.0f;
private static final float ITEM_STACK_Z = 100.0f;
private static final float SLOT_Z = 0.5f;
private static final float ITEM_STACK_OVERLAY_Z = 20.0f;
private static final float SLOT_HOVER_Z = 31.0f;
private static final float TOOLTIP_Z = 200.0f;
private static final float ITEM_STACK_OVERLAY_Z = 200.0f;
private static final float SLOT_HOVER_Z = 310.0f;
private static final float TOOLTIP_Z = 210.0f;
private static final float STEP_Z = 10.0f;
private static final float MAGIC_RENDER_ITEM_Z = 50.0f;
public GuiLevelTerminal(InventoryPlayer inventoryPlayer, Container container) {
super(inventoryPlayer, container);
@@ -440,32 +443,14 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
/*
* Render title
*/
GL11.glTranslatef(0.0f, 0.0f, 50f);
mc.getTextureManager().bindTexture(TEX_BG);
if (sectionBottom > 0 && sectionBottom < LevelTerminalSection.TITLE_HEIGHT) {
/* Transition draw */
drawTexturedModalRect(
0,
0,
VIEW_LEFT,
HEADER_HEIGHT + LevelTerminalSection.TITLE_HEIGHT - sectionBottom,
VIEW_WIDTH,
sectionBottom);
fontRendererObj
.drawString(section.name, 2, sectionBottom - LevelTerminalSection.TITLE_HEIGHT + 2, fontColor);
title = sectionBottom;
} else if (viewY < 0) {
/* Hidden title draw */
drawTexturedModalRect(0, 0, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, LevelTerminalSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, 2, fontColor);
title = 0;
} else {
/* Normal title draw */
drawTexturedModalRect(0, viewY, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, LevelTerminalSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, viewY + 2, fontColor);
title = 0;
}
GL11.glTranslatef(0.0f, 0.0f, -50f);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
Iterator<LevelTerminalEntry> visible = section.getVisible();
@@ -485,6 +470,36 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
entry.configButton.yPosition = -1;
}
}
/*
* Render title
*/
mc.getTextureManager().bindTexture(TEX_BG);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z);
if (sectionBottom > 0 && sectionBottom < LevelTerminalSection.TITLE_HEIGHT) {
/* Transition draw */
drawTexturedModalRect(
0,
0,
VIEW_LEFT,
HEADER_HEIGHT + LevelTerminalSection.TITLE_HEIGHT - sectionBottom,
VIEW_WIDTH,
sectionBottom);
fontRendererObj
.drawString(section.name, 2, sectionBottom - LevelTerminalSection.TITLE_HEIGHT + 2, fontColor);
} else if (viewY < 0) {
/* Hidden title draw */
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glTranslatef(0.0f, 0.0f, 100f);
drawTexturedModalRect(0, 0, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, LevelTerminalSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, 2, fontColor);
GL11.glEnable(GL11.GL_DEPTH_TEST);
} else {
/* Normal title draw */
drawTexturedModalRect(0, viewY, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, LevelTerminalSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, viewY + 2, fontColor);
}
GL11.glTranslatef(0.0f, 0.0f, -(ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z));
return LevelTerminalSection.TITLE_HEIGHT + renderY;
}
@@ -583,21 +598,13 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_Z);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
aeItemStack.setStackSize(1);
aeRenderItem.setAeStack(aeItemStack);
aeRenderItem.zLevel = 3.0f - 50.0f;
aeRenderItem.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
aeRenderItem.zLevel = 0.0f;
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
itemStack.stackSize = 1;
aeItemStack.setStackSize(quantity);
aeRenderItem.setAeStack(aeItemStack);
aeRenderItem.zLevel = ITEM_STACK_Z - MAGIC_RENDER_ITEM_Z;
aeRenderItem.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
aeRenderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
if (batch > 0) {
aeItemStack.setStackSize(batch);
aeRenderItem.setAeStack(aeItemStack);
aeRenderItem
.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, -11);
}
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
int color = switch (state) {
case Idle -> FCGuiColors.StateIdle.getColor();
case Craft -> FCGuiColors.StateCraft.getColor();
@@ -608,6 +615,11 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
int offset = 0;
int size = 4;
drawRect(offset, offset, offset + size, offset + size, color);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
this.drawReadableAmount(fontRendererObj, quantity, 16.0f, 12f, 16777215);
if (batch > 0) {
this.drawReadableAmount(fontRendererObj, batch, 16.0f, 1f, 16777215);
}
RenderHelper.disableStandardItemLighting();
/*
@@ -645,6 +657,45 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
return relY + 1;
}
public void drawReadableAmount(final FontRenderer fontRenderer, long amount, float x, float y, int color) {
final float scaleFactor = AEConfig.instance.useTerminalUseLargeFont() ? 0.85f : 0.5f;
final float inverseScaleFactor = 1.0f / scaleFactor;
final int offset = AEConfig.instance.useTerminalUseLargeFont() ? 0 : -1;
final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
final String stackSize = this.getToBeRenderedStackSize(amount);
fontRenderer.setUnicodeFlag(false);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPushMatrix();
GL11.glScaled(scaleFactor, scaleFactor, scaleFactor);
final int X = (int) (((float) x + offset - fontRenderer.getStringWidth(stackSize) * scaleFactor)
* inverseScaleFactor);
final int Y = (int) (((float) y + offset * scaleFactor) * inverseScaleFactor);
fontRenderer.drawString(stackSize, X + 1, Y, 0);
fontRenderer.drawString(stackSize, X - 1, Y, 0);
fontRenderer.drawString(stackSize, X, Y + 1, 0);
fontRenderer.drawString(stackSize, X, Y - 1, 0);
fontRenderer.drawString(stackSize, X, Y, color);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
fontRenderer.setUnicodeFlag(unicodeFlag);
}
private String getToBeRenderedStackSize(final long originalSize) {
if (AEConfig.instance.useTerminalUseLargeFont()) {
return ReadableNumberConverter.INSTANCE.toSlimReadableForm(originalSize);
} else {
return ReadableNumberConverter.INSTANCE.toWideReadableForm(originalSize);
}
}
@SuppressWarnings("unchecked")
@Override
public void drawHoveringText(List textLines, int x, int y, FontRenderer font) {
@@ -135,10 +135,10 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
data.setTag(TLMTags.Stack.tagName, itemStackTag);
}
if (!data.hasKey(TLMTags.Quantity.tagName)) {
data.setLong(TLMTags.Quantity.tagName, itemStack.stackSize);
data.setLong(TLMTags.Quantity.tagName, itemStack.stackSize > 0 ? itemStack.stackSize : 1);
}
if (!data.hasKey(TLMTags.Batch.tagName)) {
data.setLong(TLMTags.Batch.tagName, 0);
data.setLong(TLMTags.Batch.tagName, 1);
}
if (!data.hasKey(TLMTags.Enable.tagName)) {
data.setBoolean(TLMTags.Enable.tagName, false);
@@ -1,13 +1,15 @@
package com.glodblock.github.nei;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.client.gui.GuiFluidMonitor;
import com.glodblock.github.client.gui.GuiItemMonitor;
import com.glodblock.github.client.gui.GuiLevelMaintainer;
import codechicken.nei.api.INEIGuiAdapter;
public class NEIGuiHandler extends INEIGuiAdapter {
public class AE2FC_NEIGuiHandler extends INEIGuiAdapter {
@Override
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
@@ -18,4 +20,12 @@ public class NEIGuiHandler extends INEIGuiAdapter {
}
return false;
}
@Override
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
if (gui instanceof GuiLevelMaintainer guiLevelMaintainer) {
return guiLevelMaintainer.handleDragNDrop(gui, mouseX, mouseY, draggedStack, button);
}
return super.handleDragNDrop(gui, mouseX, mouseY, draggedStack, button);
}
}
@@ -17,7 +17,7 @@ public class NEI_FC_Config implements IConfigureNEI {
@Override
public void loadConfig() {
API.registerNEIGuiHandler(new NEIGuiHandler());
API.registerNEIGuiHandler(new AE2FC_NEIGuiHandler());
API.addSearchProvider(new NEIItemFilter());
API.registerStackStringifyHandler(new FCStackStringifyHandler());
@@ -65,9 +65,9 @@ public class CommonProxy {
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1);
}
AEApi.instance().registries().externalStorage().addExternalStorageInterface(new AEFluidInterfaceHandler());
AEApi.instance().registries().ifaceTerm().register(PartFluidP2PInterface.class);
AEApi.instance().registries().ifaceTerm().register(PartFluidInterface.class);
AEApi.instance().registries().ifaceTerm().register(TileFluidInterface.class);
AEApi.instance().registries().interfaceTerminal().register(PartFluidP2PInterface.class);
AEApi.instance().registries().interfaceTerminal().register(PartFluidInterface.class);
AEApi.instance().registries().interfaceTerminal().register(TileFluidInterface.class);
}
public void registerRenderers() {}