package net.minecraft.client.gui.components;

import net.minecraft.client.gui.components.events.GuiEventListener;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.Options;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.client.Option;
import net.minecraft.client.Minecraft;

public class OptionsList extends ContainerObjectSelectionList<Entry> {
    public OptionsList(final Minecraft dbn, final int integer2, final int integer3, final int integer4, final int integer5, final int integer6) {
        super(dbn, integer2, integer3, integer4, integer5, integer6);
        this.centerListVertically = false;
    }
    
    public int addBig(final Option dbq) {
        return this.addEntry(Entry.big(this.minecraft.options, this.width, dbq));
    }
    
    public void addSmall(final Option dbq1, @Nullable final Option dbq2) {
        this.addEntry(Entry.small(this.minecraft.options, this.width, dbq1, dbq2));
    }
    
    public void addSmall(final Option[] arr) {
        for (int integer3 = 0; integer3 < arr.length; integer3 += 2) {
            this.addSmall(arr[integer3], (integer3 < arr.length - 1) ? arr[integer3 + 1] : null);
        }
    }
    
    @Override
    public int getRowWidth() {
        return 400;
    }
    
    @Override
    protected int getScrollbarPosition() {
        return super.getScrollbarPosition() + 32;
    }
    
    public static class Entry extends ContainerObjectSelectionList.Entry<Entry> {
        private final List<AbstractWidget> children;
        
        private Entry(final List<AbstractWidget> list) {
            this.children = list;
        }
        
        public static Entry big(final Options dbr, final int integer, final Option dbq) {
            return new Entry(ImmutableList.<AbstractWidget>of(dbq.createButton(dbr, integer / 2 - 155, 0, 310)));
        }
        
        public static Entry small(final Options dbr, final int integer, final Option dbq3, @Nullable final Option dbq4) {
            final AbstractWidget dct5 = dbq3.createButton(dbr, integer / 2 - 155, 0, 150);
            if (dbq4 == null) {
                return new Entry(ImmutableList.<AbstractWidget>of(dct5));
            }
            return new Entry(ImmutableList.<AbstractWidget>of(dct5, dbq4.createButton(dbr, integer / 2 - 155 + 160, 0, 150)));
        }
        
        @Override
        public void render(final int integer1, final int integer2, final int integer3, final int integer4, final int integer5, final int integer6, final int integer7, final boolean boolean8, final float float9) {
            this.children.forEach(dct -> {
                dct.y = integer2;
                dct.render(integer6, integer7, float9);
            });
        }
        
        @Override
        public List<? extends GuiEventListener> children() {
            return this.children;
        }
    }
}
