Search in sources :

Example 1 with Functions

use of mcjty.rftoolscontrol.logic.registry.Functions in project RFToolsControl by McJty.

the class AbstractParameterEditor method createEditorPanel.

void createEditorPanel(Minecraft mc, Gui gui, Panel panel, ParameterEditorCallback callback, Panel constantPanel, ParameterType type) {
    Panel variablePanel = new Panel(mc, gui).setLayout(new HorizontalLayout()).setDesiredHeight(18);
    variableIndex = new TextField(mc, gui).setDesiredHeight(14).setTooltips("Index (in the processor)", "of the variable", "(first variable has index 0)").addTextEvent((parent, newText) -> callback.valueChanged(readValue()));
    variablePanel.addChild(new Label(mc, gui).setText("Index:")).setTooltips("Index (in the processor)", "of the variable", "(first variable has index 0)").setDesiredHeight(14).addChild(variableIndex);
    Panel functionPanel = new Panel(mc, gui).setLayout(new HorizontalLayout());
    functionLabel = new ChoiceLabel(mc, gui).setDesiredWidth(120);
    List<Function> functions = Functions.getFunctionsByType(type);
    for (Function function : functions) {
        functionLabel.addChoices(function.getId());
        functionLabel.setChoiceTooltip(function.getId(), function.getDescription().toArray(new String[function.getDescription().size()]));
    }
    functionPanel.addChild(functionLabel);
    functionLabel.addChoiceEvent(((parent, newChoice) -> callback.valueChanged(readValue())));
    tabbedPanel = new TabbedPanel(mc, gui).addPage(PAGE_CONSTANT, constantPanel).addPage(PAGE_VARIABLE, variablePanel).addPage(PAGE_FUNCTION, functionPanel);
    tabbedPanel.setLayoutHint(new PositionalLayout.PositionalHint(5, 5 + 18, 190 - 10, 60 + getHeight() - 5 - 18 - 40));
    buttonPanel = new Panel(mc, gui).setLayout(new HorizontalLayout()).setLayoutHint(new PositionalLayout.PositionalHint(5, 5, 190 - 10, 18));
    ToggleButton constantButton = new ToggleButton(mc, gui).setText(PAGE_CONSTANT).addButtonEvent(w -> switchPage(PAGE_CONSTANT, callback));
    variableButton = new ToggleButton(mc, gui).setText(PAGE_VARIABLE).addButtonEvent(w -> switchPage(PAGE_VARIABLE, callback));
    functionButton = new ToggleButton(mc, gui).setText(PAGE_FUNCTION).addButtonEvent(w -> switchPage(PAGE_FUNCTION, callback));
    buttonPanel.addChild(constantButton).addChild(variableButton).addChild(functionButton);
    panel.addChild(buttonPanel).addChild(tabbedPanel);
}
Also used : Window(mcjty.lib.gui.Window) ParameterType(mcjty.rftoolscontrol.api.parameters.ParameterType) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Gui(net.minecraft.client.gui.Gui) List(java.util.List) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) ParameterValue(mcjty.rftoolscontrol.api.parameters.ParameterValue) Minecraft(net.minecraft.client.Minecraft) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) Function(mcjty.rftoolscontrol.api.code.Function) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Functions(mcjty.rftoolscontrol.logic.registry.Functions) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Function(mcjty.rftoolscontrol.api.code.Function)

Aggregations

List (java.util.List)1 Window (mcjty.lib.gui.Window)1 HorizontalAlignment (mcjty.lib.gui.layout.HorizontalAlignment)1 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)1 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)1 mcjty.lib.gui.widgets (mcjty.lib.gui.widgets)1 Function (mcjty.rftoolscontrol.api.code.Function)1 ParameterType (mcjty.rftoolscontrol.api.parameters.ParameterType)1 ParameterValue (mcjty.rftoolscontrol.api.parameters.ParameterValue)1 Functions (mcjty.rftoolscontrol.logic.registry.Functions)1 Minecraft (net.minecraft.client.Minecraft)1 Gui (net.minecraft.client.gui.Gui)1