Search in sources :

Example 1 with GuiSlider

use of net.geforcemods.securitycraft.gui.components.GuiSlider in project SecurityCraft by Geforce132.

the class GuiCustomizeBlock method initGui.

@Override
public void initGui() {
    super.initGui();
    for (int i = 0; i < tileEntity.getNumberOfCustomizableOptions(); i++) {
        descriptionButtons[i] = new GuiItemButton(i, guiLeft + 130, (guiTop + 10) + (i * 25), 20, 20, "", itemRender, new ItemStack(tileEntity.acceptedModules()[i].getItem()));
        buttonList.add(descriptionButtons[i]);
        hoverCheckers[i] = new HoverChecker(descriptionButtons[i], 20);
    }
    if (tileEntity.customOptions() != null)
        for (int i = 0; i < tileEntity.customOptions().length; i++) {
            Option option = tileEntity.customOptions()[i];
            if (option instanceof OptionDouble && ((OptionDouble) option).isSlider()) {
                optionButtons[i] = new GuiSlider((StatCollector.translateToLocal("option." + blockName + "." + option.getName()) + " ").replace("#", option.toString()), blockName, i, guiLeft + 178, (guiTop + 10) + (i * 25), 120, 20, "", "", (Double) option.getMin(), (Double) option.getMax(), (Double) option.getValue(), true, true, (OptionDouble) option);
                optionButtons[i].packedFGColour = 14737632;
            } else {
                optionButtons[i] = new GuiButton(i, guiLeft + 178, (guiTop + 10) + (i * 25), 120, 20, getOptionButtonTitle(option));
                optionButtons[i].packedFGColour = option.toString().matches(option.getDefaultValue().toString()) ? 16777120 : 14737632;
            }
            buttonList.add(optionButtons[i]);
            hoverCheckers[i + tileEntity.getNumberOfCustomizableOptions()] = new HoverChecker(optionButtons[i], 20);
        }
}
Also used : OptionDouble(net.geforcemods.securitycraft.api.Option.OptionDouble) GuiButton(net.minecraft.client.gui.GuiButton) Option(net.geforcemods.securitycraft.api.Option) PacketSToggleOption(net.geforcemods.securitycraft.network.packets.PacketSToggleOption) GuiSlider(net.geforcemods.securitycraft.gui.components.GuiSlider) ItemStack(net.minecraft.item.ItemStack) GuiItemButton(net.geforcemods.securitycraft.gui.components.GuiItemButton) HoverChecker(net.minecraftforge.fml.client.config.HoverChecker)

Aggregations

Option (net.geforcemods.securitycraft.api.Option)1 OptionDouble (net.geforcemods.securitycraft.api.Option.OptionDouble)1 GuiItemButton (net.geforcemods.securitycraft.gui.components.GuiItemButton)1 GuiSlider (net.geforcemods.securitycraft.gui.components.GuiSlider)1 PacketSToggleOption (net.geforcemods.securitycraft.network.packets.PacketSToggleOption)1 GuiButton (net.minecraft.client.gui.GuiButton)1 ItemStack (net.minecraft.item.ItemStack)1 HoverChecker (net.minecraftforge.fml.client.config.HoverChecker)1