Class OperatorLPElementRenderPattern

All Implemented Interfaces:
ISubGui, ISubGuiBox, IRenderPatternValueTypeTooltip

Render pattern for operator elements, which edits the expression of the element in the slots and in the expression panel. The parts of the panel are in ExpressionParameterChips, ExpressionTextController, ExpressionBreadcrumb and ExpressionValueEditor.
  • Constructor Details

  • Method Details

    • init

      public void init(int guiLeft, int guiTop)
      Specified by:
      init in interface ISubGui
      Overrides:
      init in class RenderPattern<OperatorLPElement, ContainerScreenLogicProgrammerBase, ContainerLogicProgrammerBase>
    • updateButtons

      protected void updateButtons()
      Show the buttons that apply to the current state, before they are rendered or clicked.
    • addParameter

      protected void addParameter()
      Add a parameter, to the typed text while it is not applied yet, as applying it would undo the parameter otherwise.
    • getRenderSymbol

      protected String getRenderSymbol()
      Overrides:
      getRenderSymbol in class RenderPattern<OperatorLPElement, ContainerScreenLogicProgrammerBase, ContainerLogicProgrammerBase>
      Returns:
      The symbol to render in the pattern.
    • getEditor

      @Nullable protected ExpressionEditor getEditor()
    • sendAction

      protected void sendAction(net.minecraft.nbt.CompoundTag action)
    • getTextField

      protected ExpressionTextField getTextField()
    • selectSlot

      protected void selectSlot(int slot)
    • armParameter

      protected void armParameter(int index)
    • updateEditor

      protected void updateEditor()
    • cancelSelection

      public boolean cancelSelection()
      Stop typing, or cancel the selected slot or parameter.
      Returns:
      If something was stopped or cancelled.
    • onOperatorPicked

      public boolean onOperatorPicked(IOperator operator)
      Called by the gui when an operator was picked from the list while a slot is selected.
      Parameters:
      operator - The operator.
      Returns:
      If the operator was nested.
    • tickText

      public void tickText()
      Apply typed text once typing pauses. Called each tick, outside of rendering.
    • applyPendingText

      public void applyPendingText()
      Apply typed text that is not applied yet, such as when the gui closes.
    • getDraftError

      @Nullable public ExpressionParseException getDraftError()
      Returns:
      Why typed text can not be applied, which keeps the card from being written, or null if there is none.
    • getTokenPathAt

      @Nullable protected static int[] getTokenPathAt(List<ExpressionPrinter.Token> tokens, int index)
    • isInTextBox

      protected boolean isInTextBox(double mouseX, double mouseY)
    • getSlotAt

      protected int getSlotAt(double mouseX, double mouseY)
    • mouseClicked

      public boolean mouseClicked(net.minecraft.client.input.MouseButtonEvent evt, boolean isDoubleClick)
      Specified by:
      mouseClicked in interface ISubGui
      Overrides:
      mouseClicked in class SubGuiBox
    • onSlotClicked

      protected void onSlotClicked(ExpressionEditor editor, int slot)
      Put the selected parameter in the slot, or open the nested operator in it when it is clicked twice, or select it.
    • mouseDragged

      public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY)
    • mouseReleased

      public boolean mouseReleased(double mouseX, double mouseY, int button)
      Drop a dragged parameter into the slot under the mouse, or cancel when it is not over a slot.
    • mouseScrolled

      public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY)
    • charTyped

      public boolean charTyped(net.minecraft.client.input.CharacterEvent evt)
      Description copied from interface: ISubGui
      Char type event
      Specified by:
      charTyped in interface ISubGui
      Overrides:
      charTyped in class SubGuiBox
      Parameters:
      evt - The character event
      Returns:
      True if all next actions should be skipped
    • keyPressed

      public boolean keyPressed(net.minecraft.client.input.KeyEvent evt)
      Description copied from interface: ISubGui
      Key press event
      Specified by:
      keyPressed in interface ISubGui
      Overrides:
      keyPressed in class SubGuiBox
      Parameters:
      evt - The key event
      Returns:
      True if all next actions should be skipped
    • renderBg

      public void renderBg(net.minecraft.client.gui.GuiGraphicsExtractor guiGraphics, int guiLeft, int guiTop, net.minecraft.client.renderer.texture.TextureManager textureManager, net.minecraft.client.gui.Font fontRenderer, float partialTicks, int mouseX, int mouseY)
      Specified by:
      renderBg in interface ISubGui
      Overrides:
      renderBg in class RenderPattern<OperatorLPElement, ContainerScreenLogicProgrammerBase, ContainerLogicProgrammerBase>
    • renderSlots

      protected void renderSlots(net.minecraft.client.gui.GuiGraphicsExtractor guiGraphics, int guiLeft, int guiTop, net.minecraft.client.gui.Font font, ExpressionEditor editor, ExpressionTypeChecker.Result result, int mouseX, int mouseY)
      Draw the contents of the slots that are not items: nested operators, values, and parameters.
    • startsWith

      protected static boolean startsWith(int[] path, int[] prefix)
    • renderTextField

      protected void renderTextField(net.minecraft.client.gui.GuiGraphicsExtractor guiGraphics, int guiLeft, int guiTop, ExpressionEditor editor, ExpressionTypeChecker.Result result, @Nullable int[] hoveredPath, int mouseX, int mouseY)
      Draw the text of the expression, which can be edited in place. It is colored like the slots: the edited operator, errors, empty slots, and the part of a hovered slot.
    • drawGuiContainerForegroundLayer

      public void drawGuiContainerForegroundLayer(net.minecraft.client.gui.GuiGraphicsExtractor guiGraphics, int guiLeft, int guiTop, net.minecraft.client.renderer.texture.TextureManager textureManager, net.minecraft.client.gui.Font fontRenderer, int mouseX, int mouseY)
      Specified by:
      drawGuiContainerForegroundLayer in interface ISubGui
      Overrides:
      drawGuiContainerForegroundLayer in class SubGuiBox
    • isRenderTooltip

      public boolean isRenderTooltip()
      Specified by:
      isRenderTooltip in interface IRenderPatternValueTypeTooltip
    • setRenderTooltip

      public void setRenderTooltip(boolean renderTooltip)
      Specified by:
      setRenderTooltip in interface IRenderPatternValueTypeTooltip