fix #2640, #2641, #2642; improve Zone Planner UI

This commit is contained in:
asiekierka 2015-04-18 22:37:32 +02:00
parent 84f923eff5
commit 8c77c24363
4 changed files with 61 additions and 39 deletions

View file

@ -420,6 +420,7 @@ tip.shift.PipeItemsObsidian=Power with an engine\nMore power - greater distance
tip.shift.PipePowerIron=Change the limit with a wrench or gates
tip.tool.add=Add
tip.tool.fullscreen=Fullscreen
tip.tool.remove=Remove
achievement.woodenGearAchievement=A bit rough around the edges

View file

@ -181,6 +181,8 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
return;
}
createUtilsIfNeeded();
if (stage == Stage.BUILDING) {
if (builder != null && !builder.isDone(this)) {
builder.buildNextSlot(worldObj, this, xCoord, yCoord, zCoord);
@ -191,6 +193,10 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
dig();
} else if (stage == Stage.IDLE) {
idling();
// We are sending a network packet update ONLY below.
// In this case, since idling() does it anyway, we should return.
return;
} else if (stage == Stage.MOVING) {
int energyUsed = this.getBattery().useEnergy(20, (int) Math.ceil(20 + getBattery().getEnergyStored() / 10), false);
@ -200,9 +206,9 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
// If it's raining or snowing above the head, slow down.
if (worldObj.isRaining()) {
int headBPX = (int) Math.floor(headPosX);
int headBPY = (int) Math.floor(headPosY);
int headBPZ = (int) Math.floor(headPosZ);
int headBPX = (int) headPosX;
int headBPY = (int) headPosY;
int headBPZ = (int) headPosZ;
if (worldObj.getHeightValue(headBPX, headBPZ) < headBPY) {
speed *= 0.7;
}
@ -212,8 +218,6 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
}
}
createUtilsIfNeeded();
if (updateTracker.markTimeIfDelay(worldObj)) {
sendNetworkUpdate();
}
@ -333,7 +337,7 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
Integer[][] columnHeights = new Integer[builder.blueprint.sizeX - 2][builder.blueprint.sizeZ - 2];
boolean[][] blockedColumns = new boolean[builder.blueprint.sizeX - 2][builder.blueprint.sizeZ - 2];
for (int searchY = yCoord + 3; searchY >= yCoord; --searchY) {
for (int searchY = yCoord + 3; searchY >= 1; --searchY) {
int startX, endX, incX;
if (searchY % 2 == 0) {

View file

@ -142,7 +142,7 @@ public class TileZonePlan extends TileBuildCraft implements IInventory {
}
private void importMap(ItemStack stack) {
if (stack.getItem() instanceof IMapLocation) {
if (stack != null && stack.getItem() instanceof IMapLocation) {
final IZone zone = ((IMapLocation) stack.getItem()).getZone(stack);
if (zone != null && zone instanceof ZonePlan) {
selectedAreas[currentSelectedArea] = (ZonePlan) zone;

View file

@ -66,7 +66,7 @@ public class GuiZonePlan extends GuiAdvancedInterface {
private float alpha = 0.8F;
private GuiBetterButton tool;
private GuiBetterButton tool, fsButton;
private List inventorySlots;
private List savedButtonList;
@ -139,6 +139,9 @@ public class GuiZonePlan extends GuiAdvancedInterface {
tool = new GuiBetterButton(0, guiLeft + 27, guiTop + 111, 15, StandardButtonTextureSets.SMALL_BUTTON, "+");
tool.setToolTip(new ToolTip(new ToolTipLine(StringUtils.localize("tip.tool.add"))));
buttonList.add(tool);
fsButton = new GuiBetterButton(1, guiLeft + 44, guiTop + 111, 20, StandardButtonTextureSets.SMALL_BUTTON, "FS");
fsButton.setToolTip(new ToolTip(new ToolTipLine(StringUtils.localize("tip.tool.fullscreen"))));
buttonList.add(fsButton);
savedButtonList = buttonList;
@ -160,6 +163,10 @@ public class GuiZonePlan extends GuiAdvancedInterface {
}));
}
private boolean isFullscreen() {
return getContainer().mapTexture.height > 100;
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
super.drawGuiContainerBackgroundLayer(f, x, y);
@ -202,7 +209,7 @@ public class GuiZonePlan extends GuiAdvancedInterface {
GL11.glDisable(GL11.GL_BLEND);
}
if (getContainer().mapTexture.height <= 100) {
if (!isFullscreen()) {
drawBackgroundSlots();
bindTexture(texture);
@ -217,7 +224,9 @@ public class GuiZonePlan extends GuiAdvancedInterface {
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
textField.drawTextBox();
if (!isFullscreen()) {
textField.drawTextBox();
}
}
@Override
@ -307,11 +316,37 @@ public class GuiZonePlan extends GuiAdvancedInterface {
}
}
private void toFullscreen() {
mapWidth = this.mc.displayWidth;
mapHeight = this.mc.displayHeight;
getContainer().mapTexture = new DynamicTextureBC(mapWidth, mapHeight);
currentSelection = new DynamicTextureBC(mapWidth, mapHeight);
uploadMap();
refreshSelectedArea();
container.inventorySlots = new LinkedList();
buttonList = new LinkedList();
}
private void toWindowed() {
mapWidth = 213;
mapHeight = 100;
getContainer().mapTexture = new DynamicTextureBC(mapWidth, mapHeight);
currentSelection = new DynamicTextureBC(mapWidth, mapHeight);
uploadMap();
refreshSelectedArea();
container.inventorySlots = inventorySlots;
buttonList = savedButtonList;
}
@Override
protected void keyTyped(char carac, int val) {
super.keyTyped(carac, val);
if (textField.isFocused()) {
if (!isFullscreen() && textField.isFocused()) {
if (carac == 13 || carac == 27) {
textField.setFocused(false);
} else {
@ -324,9 +359,7 @@ public class GuiZonePlan extends GuiAdvancedInterface {
}));
}
return;
}
if (val == Keyboard.KEY_F5) {
} else if (val == Keyboard.KEY_F5) {
uploadMap();
refreshSelectedArea();
} else if (carac == '+' && zoomLevel > 1) {
@ -337,30 +370,12 @@ public class GuiZonePlan extends GuiAdvancedInterface {
zoomLevel++;
uploadMap();
refreshSelectedArea();
} else if (carac == 'm') {
mapWidth = 213;
mapHeight = 100;
getContainer().mapTexture = new DynamicTextureBC(mapWidth, mapHeight);
currentSelection = new DynamicTextureBC(mapWidth, mapHeight);
uploadMap();
refreshSelectedArea();
container.inventorySlots = inventorySlots;
buttonList = savedButtonList;
} else if (carac == 'm' || (carac == 27 && isFullscreen())) {
toWindowed();
} else if (carac == 'M') {
mapWidth = this.mc.displayWidth;
mapHeight = this.mc.displayHeight;
getContainer().mapTexture = new DynamicTextureBC(mapWidth, mapHeight);
currentSelection = new DynamicTextureBC(mapWidth, mapHeight);
uploadMap();
refreshSelectedArea();
container.inventorySlots = new LinkedList();
buttonList = new LinkedList();
toFullscreen();
} else {
super.keyTyped(carac, val);
}
}
@ -423,6 +438,8 @@ public class GuiZonePlan extends GuiAdvancedInterface {
tool.getToolTip().remove(0);
tool.getToolTip().add(new ToolTipLine(StringUtils.localize("tip.tool.add")));
}
} else if (button == fsButton) {
toFullscreen();
}
}