use of me.desht.pneumaticcraft.common.progwidgets.IProgWidget in project pnc-repressurized by TeamPneumatic.
the class GuiUnitProgrammer method render.
public void render(int x, int y, boolean showFlow, boolean showInfo, boolean translate) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int origX = x;
int origY = y;
x -= translatedX;
y -= translatedY;
float scale = getScale();
x = (int) (x / scale);
y = (int) (y / scale);
if (scaleScroll.getState() != lastZoom) {
float shift = SCALE_PER_STEP * (scaleScroll.getState() - lastZoom);
if (new Rectangle(guiLeft + startX, guiTop + startY, areaWidth, areaHeight).contains(origX, origY) && !scaleScroll.isDragging()) {
translatedX += shift * x;
translatedY += shift * y;
} else {
translatedX += areaWidth / 2 * shift;
translatedY += areaHeight / 2 * shift;
}
}
lastZoom = scaleScroll.getState();
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
GL11.glScissor((guiLeft + startX) * sr.getScaleFactor(), (sr.getScaledHeight() - areaHeight - (guiTop + startY)) * sr.getScaleFactor(), areaWidth * sr.getScaleFactor(), areaHeight * sr.getScaleFactor());
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glPushMatrix();
GL11.glTranslated(translatedX, translatedY, 0);
GL11.glScaled(scale, scale, 1);
if (showFlow)
showFlow();
GL11.glEnable(GL11.GL_TEXTURE_2D);
for (IProgWidget widget : progWidgets) {
GL11.glPushMatrix();
GL11.glTranslated(widget.getX() + guiLeft, widget.getY() + guiTop, 0);
GL11.glScaled(0.5, 0.5, 1);
widget.render();
GL11.glPopMatrix();
}
for (IProgWidget widget : progWidgets) {
List<String> errors = new ArrayList<String>();
widget.addErrors(errors, progWidgets);
if (errors.size() > 0) {
drawBorder(widget, 0xFFFF0000);
} else {
List<String> warnings = new ArrayList<String>();
widget.addWarnings(warnings, progWidgets);
if (warnings.size() > 0) {
drawBorder(widget, 0xFFFFFF00);
}
}
}
renderAdditionally();
GL11.glColor4d(1, 1, 1, 1);
if (showInfo) {
for (IProgWidget widget : progWidgets) {
GL11.glPushMatrix();
GL11.glTranslated(widget.getX() + guiLeft, widget.getY() + guiTop, 0);
GL11.glScaled(0.5, 0.5, 1);
widget.renderExtraInfo();
GL11.glPopMatrix();
}
}
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_SCISSOR_TEST);
boolean isLeftClicking = Mouse.isButtonDown(0);
if (translate && isLeftClicking && wasClicking && !scaleScroll.isDragging() && new Rectangle(guiLeft + startX, guiTop + startY, areaWidth, areaHeight).contains(origX, origY)) {
translatedX += origX - lastMouseX;
translatedY += origY - lastMouseY;
}
wasClicking = isLeftClicking;
lastMouseX = origX;
lastMouseY = origY;
}
use of me.desht.pneumaticcraft.common.progwidgets.IProgWidget in project pnc-repressurized by TeamPneumatic.
the class GuiUnitProgrammer method renderForeground.
public void renderForeground(int x, int y, IProgWidget tooltipExcludingWidget) {
IProgWidget widget = getHoveredWidget(x, y);
if (widget != null && widget != tooltipExcludingWidget) {
List<String> tooltip = new ArrayList<>();
widget.getTooltip(tooltip);
List<String> errors = new ArrayList<>();
widget.addErrors(errors, progWidgets);
if (errors.size() > 0) {
tooltip.add(TextFormatting.RED + I18n.format("gui.programmer.errors"));
for (String s : errors) {
String msg = I18n.hasKey(s) ? I18n.format(s) : s;
String[] lines = WordUtils.wrap("- " + msg, 30).split(System.getProperty("line.separator"));
for (String line : lines) {
tooltip.add(TextFormatting.RED + " " + line);
}
}
}
List<String> warnings = new ArrayList<String>();
widget.addWarnings(warnings, progWidgets);
if (warnings.size() > 0) {
tooltip.add(TextFormatting.YELLOW + I18n.format("gui.programmer.warnings"));
for (String s : warnings) {
String msg = I18n.hasKey(s) ? I18n.format(s) : s;
String[] lines = WordUtils.wrap("- " + msg, 30).split(System.getProperty("line.separator"));
for (String line : lines) {
tooltip.add(TextFormatting.YELLOW + " " + line);
}
}
}
addAdditionalInfoToTooltip(widget, tooltip);
if (tooltip.size() > 0)
drawHoveringText(tooltip, x - guiLeft, y - guiTop, fontRenderer);
}
}
use of me.desht.pneumaticcraft.common.progwidgets.IProgWidget in project pnc-repressurized by TeamPneumatic.
the class GuiDroneDebuggerOptions method drawScreen.
@Override
public void drawScreen(int x, int y, float partialTicks) {
if (selectedDrone != null) {
Minecraft.getMinecraft().fontRenderer.drawString("Drone name: " + selectedDrone.getName(), 20, screenHeight - 15, 0xFFFFFFFF, true);
Minecraft.getMinecraft().fontRenderer.drawString("Routine: " + selectedDrone.getLabel(), screenWidth / 2, screenHeight - 15, 0xFFFFFFFF, true);
}
programmerUnit.render(x, y, true, true, true);
programmerUnit.renderForeground(x, y, null);
if (selectedDrone == null) {
drawCenteredString(Minecraft.getMinecraft().fontRenderer, "Press '" + Keyboard.getKeyName(KeyHandler.getInstance().keybindDebuggingDrone.getKeyCode()) + "' on a Drone when tracked by an Entity Tracker to debug the Drone.", screenWidth / 2, screenHeight / 2, 0xFFFF0000);
}
IProgWidget widget = programmerUnit.getHoveredWidget(x, y);
if (widget == null)
widget = areaShowingWidget;
upgradeHandler.getShowingPositions().clear();
if (widget != null) {
int widgetId = selectedDrone.getProgWidgets().indexOf(widget);
for (DebugEntry entry : selectedDrone.getDebugEntries()) {
if (entry.getProgWidgetId() == widgetId && !entry.getPos().equals(new BlockPos(0, 0, 0))) {
upgradeHandler.getShowingPositions().add(entry.getPos());
}
}
}
}
use of me.desht.pneumaticcraft.common.progwidgets.IProgWidget in project pnc-repressurized by TeamPneumatic.
the class GuiDroneDebuggerOptions method initGui.
@Override
public void initGui(IGuiScreen gui) {
GuiScreen guiScreen = (GuiScreen) gui;
screenWidth = guiScreen.width;
screenHeight = guiScreen.height;
if (PneumaticCraftRepressurized.proxy.getPlayer() != null) {
ItemStack helmet = PneumaticCraftRepressurized.proxy.getPlayer().getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (helmet != null) {
int entityId = NBTUtil.getInteger(helmet, NBTKeys.PNEUMATIC_HELMET_DEBUGGING_DRONE);
Entity entity = PneumaticCraftRepressurized.proxy.getClientWorld().getEntityByID(entityId);
if (entity instanceof EntityDrone) {
selectedDrone = (EntityDrone) entity;
}
}
}
int spacing = 20;
programmingStartX = spacing;
programmingWidth = guiScreen.width - spacing * 2;
programmingHeight = guiScreen.height - spacing - PROGRAMMING_START_Y;
programmerUnit = new DebugInfoProgrammerUnit(selectedDrone != null ? selectedDrone.getProgWidgets() : new ArrayList<IProgWidget>(), gui.getFontRenderer(), 0, 0, guiScreen.width, guiScreen.height, 100, programmingStartX, PROGRAMMING_START_Y, programmingWidth, programmingHeight, 0, 0, 0);
if (selectedDrone != null) {
for (IProgWidget widget : selectedDrone.getProgWidgets()) {
if (widget instanceof ProgWidgetStart) {
programmerUnit.gotoPiece(widget);
break;
}
}
}
}
use of me.desht.pneumaticcraft.common.progwidgets.IProgWidget in project pnc-repressurized by TeamPneumatic.
the class TileEntityProgrammer method getWidgetsFromNBT.
private static void getWidgetsFromNBT(NBTTagCompound tag, List<IProgWidget> progWidgets) {
NBTTagList widgetTags = tag.getTagList("widgets", 10);
for (int i = 0; i < widgetTags.tagCount(); i++) {
NBTTagCompound widgetTag = widgetTags.getCompoundTagAt(i);
String widgetName = widgetTag.getString("name");
for (IProgWidget widget : WidgetRegistrator.registeredWidgets) {
if (widgetName.equals(widget.getWidgetString())) {
// create the right progWidget for the given id tag.
IProgWidget addedWidget = widget.copy();
addedWidget.readFromNBT(widgetTag);
progWidgets.add(addedWidget);
break;
}
}
}
updatePuzzleConnections(progWidgets);
}
Aggregations