Add an indicator that shows the number of active crafting jobs.
This commit is contained in:
@@ -51,6 +51,7 @@ import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.client.gui.widgets.TabButton;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.client.render.StackSizeRenderer;
|
||||
import appeng.container.implementations.CraftingStatusContainer;
|
||||
import appeng.container.implementations.MEMonitorableContainer;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
@@ -295,6 +296,16 @@ public class MEMonitorableScreen<T extends MEMonitorableContainer> extends AEBas
|
||||
|
||||
this.currentMouseX = mouseX;
|
||||
this.currentMouseY = mouseY;
|
||||
|
||||
// Show the number of active crafting jobs
|
||||
if (this.craftingStatusBtn != null && container.activeCraftingJobs != -1) {
|
||||
// The stack size renderer expects a 16x16 slot, while the button is normally
|
||||
// bigger
|
||||
int x = this.craftingStatusBtn.x + (this.craftingStatusBtn.getWidth() - 16) / 2;
|
||||
int y = this.craftingStatusBtn.y + (this.craftingStatusBtn.getWidth_CLASH() - 16) / 2;
|
||||
StackSizeRenderer.renderSizeLabel(font, x - this.guiLeft, y - this.guiTop,
|
||||
String.valueOf(container.activeCraftingJobs));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -359,6 +370,7 @@ public class MEMonitorableScreen<T extends MEMonitorableContainer> extends AEBas
|
||||
if (this.searchField != null) {
|
||||
this.searchField.render(matrixStack, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
|
||||
@@ -46,6 +46,8 @@ import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
@@ -101,6 +103,13 @@ public class MEMonitorableContainer extends AEBaseContainer
|
||||
public boolean canAccessViewCells = false;
|
||||
@GuiSync(98)
|
||||
public boolean hasPower = false;
|
||||
/**
|
||||
* The number of active crafting jobs in the network. -1 means unknown and will
|
||||
* hide the label on the screen.
|
||||
*/
|
||||
@GuiSync(100)
|
||||
public int activeCraftingJobs = -1;
|
||||
|
||||
private IConfigManagerHost gui;
|
||||
private IConfigManager serverCM;
|
||||
private IGridNode networkNode;
|
||||
@@ -189,6 +198,8 @@ public class MEMonitorableContainer extends AEBaseContainer
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
|
||||
this.updateActiveCraftingJobs();
|
||||
|
||||
for (final Settings set : this.serverCM.getSettings()) {
|
||||
final Enum<?> sideLocal = this.serverCM.getSetting(set);
|
||||
final Enum<?> sideRemote = this.clientCM.getSetting(set);
|
||||
@@ -286,6 +297,36 @@ public class MEMonitorableContainer extends AEBaseContainer
|
||||
this.queueInventory(c);
|
||||
}
|
||||
|
||||
private void updateActiveCraftingJobs() {
|
||||
IGridNode hostNode = networkNode;
|
||||
if (hostNode == null) {
|
||||
// Wireless terminals do not directly expose the target grid (even though they
|
||||
// have one)
|
||||
if (host instanceof IActionHost) {
|
||||
hostNode = ((IActionHost) host).getActionableNode();
|
||||
}
|
||||
}
|
||||
IGrid grid = null;
|
||||
if (hostNode != null) {
|
||||
grid = hostNode.getGrid();
|
||||
}
|
||||
|
||||
if (grid == null) {
|
||||
// No grid to query crafting jobs from
|
||||
this.activeCraftingJobs = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
int activeJobs = 0;
|
||||
ICraftingGrid craftingGrid = grid.getCache(ICraftingGrid.class);
|
||||
for (ICraftingCPU cpus : craftingGrid.getCpus()) {
|
||||
if (cpus.isBusy()) {
|
||||
activeJobs++;
|
||||
}
|
||||
}
|
||||
this.activeCraftingJobs = activeJobs;
|
||||
}
|
||||
|
||||
private void queueInventory(final IContainerListener c) {
|
||||
if (Platform.isServer() && c instanceof PlayerEntity && this.monitor != null) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user