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();
}
}
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);
}
}
}
}
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);
}
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();
}
}
}
}
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();
}
Aggregations