Search in sources :

Example 91 with GuiTextField

use of net.minecraft.client.gui.GuiTextField in project Cavern2 by kegare.

the class GuiMiningPointsEditor method updateScreen.

@Override
public void updateScreen() {
    if (editMode) {
        for (GuiTextField textField : editFieldList) {
            if (textField.getVisible()) {
                textField.updateCursorCounter();
            }
        }
    } else {
        editButton.enabled = !pointList.selected.isEmpty();
        removeButton.enabled = editButton.enabled;
        filterTextField.updateCursorCounter();
    }
}
Also used : GuiTextField(net.minecraft.client.gui.GuiTextField)

Example 92 with GuiTextField

use of net.minecraft.client.gui.GuiTextField in project Cavern2 by kegare.

the class GuiMiningPointsEditor method keyTyped.

@Override
protected void keyTyped(char c, int code) throws IOException {
    if (editMode) {
        for (GuiTextField textField : editFieldList) {
            if (code == Keyboard.KEY_ESCAPE) {
                textField.setFocused(false);
            } else if (textField.getVisible() && textField.isFocused()) {
                if (!CharUtils.isAsciiControl(c) && !CharUtils.isAsciiNumeric(c)) {
                    continue;
                }
                textField.textboxKeyTyped(c, code);
            }
        }
    } else {
        if (filterTextField.isFocused()) {
            if (code == Keyboard.KEY_ESCAPE) {
                filterTextField.setFocused(false);
            }
            String prev = filterTextField.getText();
            filterTextField.textboxKeyTyped(c, code);
            String text = filterTextField.getText();
            boolean changed = text != prev;
            if (Strings.isNullOrEmpty(text) && changed) {
                pointList.setFilter(null);
            } else if (instantFilter.isChecked() && changed || code == Keyboard.KEY_RETURN) {
                pointList.setFilter(text);
            }
        } else {
            if (code == Keyboard.KEY_ESCAPE) {
                actionPerformed(doneButton);
            } else if (code == Keyboard.KEY_BACK) {
                pointList.selected.clear();
            } else if (code == Keyboard.KEY_TAB) {
                if (++pointList.nameType > 2) {
                    pointList.nameType = 0;
                }
            } else if (code == Keyboard.KEY_HOME) {
                pointList.scrollToTop();
            } else if (code == Keyboard.KEY_END) {
                pointList.scrollToEnd();
            } else if (code == Keyboard.KEY_SPACE) {
                pointList.scrollToSelected();
            } else if (code == Keyboard.KEY_PRIOR) {
                pointList.scrollToPrev();
            } else if (code == Keyboard.KEY_NEXT) {
                pointList.scrollToNext();
            } else if (code == Keyboard.KEY_F || code == mc.gameSettings.keyBindChat.getKeyCode()) {
                filterTextField.setFocused(true);
            } else if (isCtrlKeyDown() && code == Keyboard.KEY_A) {
                pointList.contents.forEach(entry -> pointList.selected.add(entry));
            } else if (code == Keyboard.KEY_DELETE && !pointList.selected.isEmpty()) {
                actionPerformed(removeButton);
            }
        }
    }
}
Also used : CaveFilters(cavern.util.CaveFilters) GuiButtonExt(net.minecraftforge.fml.client.config.GuiButtonExt) Keyboard(org.lwjgl.input.Keyboard) StringUtils(org.apache.commons.lang3.StringUtils) CharUtils(org.apache.commons.lang3.CharUtils) Config(cavern.config.Config) I18n(net.minecraft.client.resources.I18n) Strings(com.google.common.base.Strings) ItemStack(net.minecraft.item.ItemStack) ArrayEntry(net.minecraftforge.fml.client.config.GuiConfigEntries.ArrayEntry) Lists(com.google.common.collect.Lists) Block(net.minecraft.block.Block) Side(net.minecraftforge.fml.relauncher.Side) OreDictionary(net.minecraftforge.oredict.OreDictionary) Map(java.util.Map) CaveConfigGui(cavern.client.config.CaveConfigGui) Objects(com.google.common.base.Objects) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) OreDictEntry(cavern.client.gui.GuiSelectOreDict.OreDictEntry) GuiTextField(net.minecraft.client.gui.GuiTextField) GuiCheckBox(net.minecraftforge.fml.client.config.GuiCheckBox) GuiButton(net.minecraft.client.gui.GuiButton) Items(net.minecraft.init.Items) TextFormatting(net.minecraft.util.text.TextFormatting) Set(java.util.Set) IOException(java.io.IOException) Mouse(org.lwjgl.input.Mouse) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) BlockMeta(cavern.util.BlockMeta) List(java.util.List) CaveRenderingRegistry(cavern.client.CaveRenderingRegistry) GuiScreen(net.minecraft.client.gui.GuiScreen) CaveUtils(cavern.util.CaveUtils) HoverChecker(net.minecraftforge.fml.client.config.HoverChecker) NumberUtils(org.apache.commons.lang3.math.NumberUtils) ArrayListExtended(cavern.util.ArrayListExtended) ItemBlock(net.minecraft.item.ItemBlock) Comparator(java.util.Comparator) GuiTextField(net.minecraft.client.gui.GuiTextField)

Example 93 with GuiTextField

use of net.minecraft.client.gui.GuiTextField in project Cavern2 by kegare.

the class GuiSelectItem method initGui.

@Override
public void initGui() {
    if (itemList == null) {
        itemList = new ItemList();
    }
    itemList.setDimensions(width, height, 32, height - 28);
    if (doneButton == null) {
        doneButton = new GuiButtonExt(0, 0, 0, 145, 20, I18n.format("gui.done"));
    }
    doneButton.x = width / 2 + 10;
    doneButton.y = height - doneButton.height - 4;
    if (detailInfo == null) {
        detailInfo = new GuiCheckBox(1, 0, 5, I18n.format(Config.LANG_KEY + "detail"), true);
    }
    detailInfo.setIsChecked(CaveConfigGui.detailInfo);
    detailInfo.x = width / 2 + 95;
    if (instantFilter == null) {
        instantFilter = new GuiCheckBox(2, 0, detailInfo.y + detailInfo.height + 2, I18n.format(Config.LANG_KEY + "instant"), true);
    }
    instantFilter.setIsChecked(CaveConfigGui.instantFilter);
    instantFilter.x = detailInfo.x;
    buttonList.clear();
    buttonList.add(doneButton);
    buttonList.add(detailInfo);
    buttonList.add(instantFilter);
    if (filterTextField == null) {
        filterTextField = new GuiTextField(0, fontRenderer, 0, 0, 150, 16);
        filterTextField.setMaxStringLength(100);
    }
    filterTextField.x = width / 2 - filterTextField.width - 5;
    filterTextField.y = height - filterTextField.height - 6;
    selectedHoverChecker = new HoverChecker(0, 20, 0, 100, 800);
    detailHoverChecker = new HoverChecker(detailInfo, 800);
    instantHoverChecker = new HoverChecker(instantFilter, 800);
}
Also used : GuiButtonExt(net.minecraftforge.fml.client.config.GuiButtonExt) GuiCheckBox(net.minecraftforge.fml.client.config.GuiCheckBox) GuiTextField(net.minecraft.client.gui.GuiTextField) HoverChecker(net.minecraftforge.fml.client.config.HoverChecker)

Example 94 with GuiTextField

use of net.minecraft.client.gui.GuiTextField in project Cavern2 by kegare.

the class GuiVeinsEditor method keyTyped.

@Override
protected void keyTyped(char c, int code) throws IOException {
    if (editMode) {
        for (GuiTextField textField : editFieldList) {
            if (code == Keyboard.KEY_ESCAPE) {
                textField.setFocused(false);
            } else if (textField.isFocused()) {
                if (textField != blockField && textField != blockMetaField && textField != targetField && textField != targetMetaField && textField != biomesField) {
                    if (!CharUtils.isAsciiControl(c) && !CharUtils.isAsciiNumeric(c)) {
                        continue;
                    }
                }
                textField.textboxKeyTyped(c, code);
            }
        }
    } else {
        if (filterTextField.isFocused()) {
            if (code == Keyboard.KEY_ESCAPE) {
                filterTextField.setFocused(false);
            }
            String prev = filterTextField.getText();
            filterTextField.textboxKeyTyped(c, code);
            String text = filterTextField.getText();
            boolean changed = text != prev;
            if (Strings.isNullOrEmpty(text) && changed) {
                veinList.setFilter(null);
            } else if (instantFilter.isChecked() && changed || code == Keyboard.KEY_RETURN) {
                veinList.setFilter(text);
            }
        } else {
            if (code == Keyboard.KEY_ESCAPE) {
                actionPerformed(doneButton);
            } else if (code == Keyboard.KEY_BACK) {
                veinList.selected.clear();
            } else if (code == Keyboard.KEY_TAB) {
                if (++veinList.nameType > 2) {
                    veinList.nameType = 0;
                }
            } else if (code == Keyboard.KEY_UP) {
                if (isCtrlKeyDown()) {
                    Collections.sort(veinList.selected, veinList);
                    for (CaveVein vein : veinList.selected) {
                        veinList.contents.swapTo(veinList.contents.indexOf(vein), -1);
                        veinList.veins.swapTo(veinList.veins.indexOf(vein), -1);
                    }
                    veinList.scrollToTop();
                    veinList.scrollToSelected();
                } else {
                    veinList.scrollUp();
                }
            } else if (code == Keyboard.KEY_DOWN) {
                if (isCtrlKeyDown()) {
                    Collections.sort(veinList.selected, veinList);
                    Collections.reverse(veinList.selected);
                    for (CaveVein vein : veinList.selected) {
                        veinList.contents.swapTo(veinList.contents.indexOf(vein), 1);
                        veinList.veins.swapTo(veinList.veins.indexOf(vein), 1);
                    }
                    veinList.scrollToTop();
                    veinList.scrollToSelected();
                } else {
                    veinList.scrollDown();
                }
            } else if (code == Keyboard.KEY_HOME) {
                veinList.scrollToTop();
            } else if (code == Keyboard.KEY_END) {
                veinList.scrollToEnd();
            } else if (code == Keyboard.KEY_SPACE) {
                veinList.scrollToSelected();
            } else if (code == Keyboard.KEY_PRIOR) {
                veinList.scrollToPrev();
            } else if (code == Keyboard.KEY_NEXT) {
                veinList.scrollToNext();
            } else if (code == Keyboard.KEY_F || code == mc.gameSettings.keyBindChat.getKeyCode()) {
                filterTextField.setFocused(true);
            } else if (isCtrlKeyDown() && code == Keyboard.KEY_A) {
                veinList.contents.forEach(entry -> veinList.selected.add(entry));
            } else if (code == Keyboard.KEY_DELETE && !veinList.selected.isEmpty()) {
                actionPerformed(removeButton);
            } else if (code == Keyboard.KEY_C && isCtrlKeyDown()) {
                Collections.sort(veinList.selected, veinList);
                veinList.copied.clear();
                for (CaveVein entry : veinList.selected) {
                    veinList.copied.add(new CaveVein(entry));
                }
            } else if (code == Keyboard.KEY_X && isCtrlKeyDown()) {
                keyTyped(Character.MIN_VALUE, Keyboard.KEY_C);
                actionPerformed(removeButton);
            } else if (code == Keyboard.KEY_V && isCtrlKeyDown() && !veinList.copied.isEmpty()) {
                int index1 = -1;
                int index2 = -1;
                int i = 0;
                for (CaveVein vein : veinList.copied) {
                    CaveVein entry = new CaveVein(vein);
                    if (veinList.veins.add(entry) && veinList.contents.add(entry) && !veinList.selected.isEmpty()) {
                        if (index1 < 0) {
                            index1 = veinList.contents.indexOf(veinList.selected.get(veinList.selected.size() - 1)) + 1;
                        }
                        Collections.swap(veinList.contents, index1 + i, veinList.contents.indexOf(entry));
                        if (index2 < 0) {
                            index2 = veinList.veins.indexOf(veinList.selected.get(veinList.selected.size() - 1)) + 1;
                        }
                        Collections.swap(veinList.veins, index2 + i, veinList.veins.indexOf(entry));
                        ++i;
                    }
                }
                veinList.scrollToTop();
                veinList.scrollToSelected();
            }
        }
    }
}
Also used : Blocks(net.minecraft.init.Blocks) CaveVein(cavern.config.manager.CaveVein) CaveFilters(cavern.util.CaveFilters) GuiButtonExt(net.minecraftforge.fml.client.config.GuiButtonExt) CavernConfig(cavern.config.CavernConfig) CaveVeinManager(cavern.config.manager.CaveVeinManager) Keyboard(org.lwjgl.input.Keyboard) CharUtils(org.apache.commons.lang3.CharUtils) Config(cavern.config.Config) I18n(net.minecraft.client.resources.I18n) Strings(com.google.common.base.Strings) ItemStack(net.minecraft.item.ItemStack) Lists(com.google.common.collect.Lists) Block(net.minecraft.block.Block) Side(net.minecraftforge.fml.relauncher.Side) Map(java.util.Map) CaveConfigGui(cavern.client.config.CaveConfigGui) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Splitter(com.google.common.base.Splitter) GuiTextField(net.minecraft.client.gui.GuiTextField) GuiCheckBox(net.minecraftforge.fml.client.config.GuiCheckBox) GuiButton(net.minecraft.client.gui.GuiButton) Items(net.minecraft.init.Items) Collection(java.util.Collection) TextFormatting(net.minecraft.util.text.TextFormatting) Set(java.util.Set) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Mouse(org.lwjgl.input.Mouse) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) File(java.io.File) Sets(com.google.common.collect.Sets) BlockMeta(cavern.util.BlockMeta) List(java.util.List) GuiScreen(net.minecraft.client.gui.GuiScreen) CaveUtils(cavern.util.CaveUtils) HoverChecker(net.minecraftforge.fml.client.config.HoverChecker) NumberUtils(org.apache.commons.lang3.math.NumberUtils) ArrayListExtended(cavern.util.ArrayListExtended) Comparator(java.util.Comparator) Collections(java.util.Collections) Biome(net.minecraft.world.biome.Biome) Joiner(com.google.common.base.Joiner) GuiTextField(net.minecraft.client.gui.GuiTextField) CaveVein(cavern.config.manager.CaveVein)

Example 95 with GuiTextField

use of net.minecraft.client.gui.GuiTextField in project DynamicSurroundings by OreCruncher.

the class PresetInfoModifyGui method initGui.

@Override
public void initGui() {
    this.labelList.clear();
    this.buttonList.clear();
    this.anchorX = (this.width - REGION_WIDTH) / 2;
    this.anchorY = (this.height - REGION_HEIGHT) / 2;
    final String theTitle = this.editMode ? EDIT_TITLE : CREATE_TITLE;
    final int titleWidth = this.fontRenderer.getStringWidth(theTitle);
    int X = this.anchorX + (REGION_WIDTH - titleWidth) / 2;
    int Y = this.anchorY + MARGIN;
    GuiLabel label = new GuiLabel(this.fontRenderer, ID_TITLE, X, Y, REGION_WIDTH, BUTTON_HEIGHT, Color.MC_GOLD.rgb());
    label.addLine(theTitle);
    this.labelList.add(label);
    X = this.anchorX + MARGIN;
    Y += BUTTON_HEIGHT;
    final int entryWidth = REGION_WIDTH - MARGIN * 2;
    final int labelColor = Color.WHITE.rgb();
    final int requiredWidth = this.fontRenderer.getStringWidth(REQUIRED_TEXT);
    label = new GuiLabel(this.fontRenderer, ID_PRESET_FILENAME, X, Y, LABEL_WIDTH, BUTTON_HEIGHT, labelColor);
    label.addLine(FILENAME_LABEL);
    this.labelList.add(label);
    this.fileNameRequired = new GuiLabel(this.fontRenderer, ID_FILENAME_REQUIRED, X + entryWidth - requiredWidth, Y, LABEL_WIDTH, BUTTON_HEIGHT, Color.RED.rgb());
    this.fileNameRequired.addLine(REQUIRED_TEXT);
    this.fileNameRequired.visible = false;
    this.labelList.add(this.fileNameRequired);
    Y += BUTTON_HEIGHT;
    this.fileName = new GuiTextField(ID_PRESET_FILENAME_TEXT, this.fontRenderer, X, Y, entryWidth, BUTTON_HEIGHT);
    this.fileName.setMaxStringLength(32);
    this.fileName.setText(this.info.getFilename());
    this.fileName.setValidator(input -> !input.matches(FILENAME_VALIDATION_REGEX));
    Y += BUTTON_HEIGHT + INSET;
    label = new GuiLabel(this.fontRenderer, ID_PRESET_FILENAME, X, Y, LABEL_WIDTH, BUTTON_HEIGHT, labelColor);
    label.addLine(PRESET_TITLE_LABEL);
    this.labelList.add(label);
    this.presetTitleRequired = new GuiLabel(this.fontRenderer, ID_TITLE_REQUIRED, X + entryWidth - requiredWidth, Y, LABEL_WIDTH, BUTTON_HEIGHT, Color.RED.rgb());
    this.presetTitleRequired.addLine(REQUIRED_TEXT);
    this.presetTitleRequired.visible = false;
    this.labelList.add(this.presetTitleRequired);
    Y += BUTTON_HEIGHT;
    this.presetTitle = new GuiTextField(ID_PRESET_TITLE_TEXT, this.fontRenderer, X, Y, entryWidth, BUTTON_HEIGHT);
    this.presetTitle.setMaxStringLength(48);
    this.presetTitle.setText(this.info.getTitle());
    Y += BUTTON_HEIGHT + INSET;
    label = new GuiLabel(this.fontRenderer, ID_PRESET_FILENAME, X, Y, LABEL_WIDTH, BUTTON_HEIGHT, labelColor);
    label.addLine(PRESET_DESCRIPTION_LABEL);
    this.labelList.add(label);
    Y += BUTTON_HEIGHT;
    this.presetDescription = new GuiTextField(ID_PRESET_DESCRIPTION_TEXT, this.fontRenderer, X, Y, entryWidth, BUTTON_HEIGHT);
    this.presetDescription.setMaxStringLength(255);
    this.presetDescription.setText(this.info.getDescription());
    Y += BUTTON_HEIGHT * 2 + INSET * 2 + MARGIN;
    // Set the final size of the background panel;
    this.regionWidth = REGION_WIDTH;
    this.regionHeight = Y - this.anchorY;
    this.backgroundPanel.setWidth(this.regionWidth);
    this.backgroundPanel.setHeight(this.regionHeight);
    // Done button
    int doneX = this.anchorX + (this.regionWidth - BUTTON_WIDTH * 3) / 2;
    final int doneY = this.anchorY + this.regionHeight - (int) (BUTTON_HEIGHT * 1.5F);
    this.doneButton = new GuiButtonExt(ID_DONE, doneX, doneY, BUTTON_WIDTH, BUTTON_HEIGHT, DONE_BUTTON_LABEL);
    this.buttonList.add(this.doneButton);
    // Cancel button
    doneX += BUTTON_WIDTH * 2;
    final GuiButtonExt button = new GuiButtonExt(ID_CANCEL, doneX, doneY, BUTTON_WIDTH, BUTTON_HEIGHT, CANCEL_BUTTON_LABEL);
    this.buttonList.add(button);
    // Filename field has first focus
    this.fileName.setFocused(true);
    doneEnableCheck();
}
Also used : GuiButtonExt(net.minecraftforge.fml.client.config.GuiButtonExt) GuiLabel(net.minecraft.client.gui.GuiLabel) GuiTextField(net.minecraft.client.gui.GuiTextField)

Aggregations

GuiTextField (net.minecraft.client.gui.GuiTextField)130 GuiButton (net.minecraft.client.gui.GuiButton)49 GuiButtonExt (net.minecraftforge.fml.client.config.GuiButtonExt)12 GuiCheckBox (net.minecraftforge.fml.client.config.GuiCheckBox)12 HoverChecker (net.minecraftforge.fml.client.config.HoverChecker)11 ItemStack (net.minecraft.item.ItemStack)9 List (java.util.List)8 GuiButtonThemed (betterquesting.api.client.gui.controls.GuiButtonThemed)5 Collectors (java.util.stream.Collectors)4 CaveConfigGui (cavern.client.config.CaveConfigGui)3 Config (cavern.config.Config)3 ArrayListExtended (cavern.util.ArrayListExtended)3 BlockMeta (cavern.util.BlockMeta)3 CaveFilters (cavern.util.CaveFilters)3 GuiButtonExt (cpw.mods.fml.client.config.GuiButtonExt)3 Map (java.util.Map)3 GuiDropDownList (riskyken.armourersWorkshop.client.gui.controls.GuiDropDownList)3 GuiButtonVariableDims (am2.guis.controls.GuiButtonVariableDims)2 GuiBigTextField (betterquesting.api.client.gui.controls.GuiBigTextField)2 CaveBiome (cavern.config.manager.CaveBiome)2