Search in sources :

Example 1 with GuiResponder

use of net.minecraft.client.gui.GuiPageButtonList.GuiResponder in project watson by totemo.

the class WatsonGuiScreen method initGui.

// --------------------------------------------------------------------------
/**
   * @see GuiScreen#initGui()
   */
@SuppressWarnings("unchecked")
@Override
public void initGui() {
    Minecraft mc = Minecraft.getMinecraft();
    FontRenderer fr = mc.fontRendererObj;
    _rowHeight = (int) (fr.FONT_HEIGHT * 2.75);
    int startY = height / 2 - 4 * _rowHeight;
    int currentRow = 0;
    buttonList.clear();
    buttonList.add(new GuiButton(ID_SHOW_WATSON, width / 2 - 175, startY + currentRow * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_WATSON)));
    buttonList.add(new GuiButton(ID_CLEAR_EDITS, width / 2 + 25, startY + currentRow++ * _rowHeight, 150, 20, getButtonLabel(ID_CLEAR_EDITS)));
    buttonList.add(new GuiButton(ID_SHOW_VECTORS, width / 2 - 175, startY + currentRow * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_VECTORS)));
    GuiResponder sliderResponder = new GuiPageButtonList.GuiResponder() {

        @Override
        public void onTick(int id, float value) {
            // Update the display when the slider slides. Save the new length in
            // the configuration when the GUI closes.
            DisplaySettings ds = Controller.instance.getDisplaySettings();
            ds.setMinVectorLength((int) value, false);
        }

        @Override
        public void func_175321_a(int id, boolean value) {
        }

        @Override
        public void func_175319_a(int id, String value) {
        }
    };
    Configuration config = Configuration.instance;
    GuiSlider slider = new GuiSlider(sliderResponder, ID_MIN_VECTOR_LENGTH, width / 2 + 25, startY + currentRow++ * _rowHeight, "Min Vector Length", 0, 20, config.getVectorLength(), new GuiSlider.FormatHelper() {

        @Override
        public String getText(int id, String name, float value) {
            return "Min Vector Length: " + Integer.toString((int) value);
        }
    });
    buttonList.add(slider);
    buttonList.add(new GuiButton(ID_SHOW_LABELS, width / 2 - 175, startY + currentRow * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_LABELS)));
    buttonList.add(new GuiButton(ID_LABEL_ORDER, width / 2 + 25, startY + currentRow++ * _rowHeight, 150, 20, getButtonLabel(ID_LABEL_ORDER)));
    buttonList.add(new GuiButton(ID_SHOW_ANNOTATIONS, width / 2 - 175, startY + currentRow * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_ANNOTATIONS)));
    buttonList.add(new GuiButton(ID_SHOW_SELECTION, width / 2 + 25, startY + currentRow++ * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_SELECTION)));
    buttonList.add(new GuiOptionButton(ID_DONE, width / 2 - 40, startY + (currentRow + 2) * _rowHeight, 80, 20, I18n.format("gui.done", new Object[0])));
    enableButtons();
}
Also used : GuiResponder(net.minecraft.client.gui.GuiPageButtonList.GuiResponder) Configuration(watson.Configuration) GuiOptionButton(net.minecraft.client.gui.GuiOptionButton) GuiSlider(net.minecraft.client.gui.GuiSlider) Minecraft(net.minecraft.client.Minecraft) GuiButton(net.minecraft.client.gui.GuiButton) FontRenderer(net.minecraft.client.gui.FontRenderer) DisplaySettings(watson.DisplaySettings)

Aggregations

Minecraft (net.minecraft.client.Minecraft)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 GuiButton (net.minecraft.client.gui.GuiButton)1 GuiOptionButton (net.minecraft.client.gui.GuiOptionButton)1 GuiResponder (net.minecraft.client.gui.GuiPageButtonList.GuiResponder)1 GuiSlider (net.minecraft.client.gui.GuiSlider)1 Configuration (watson.Configuration)1 DisplaySettings (watson.DisplaySettings)1