public static String getFontChar(TextFormatting color) { if (color == null) { return ""; } return color + color.getFriendlyName().substring(0, 1); }
@Override public String getLabel(final int index) { if (index >= 0 && index < textColors.size()) { return textColors.get(index).getFriendlyName(); } return ""; } });
private static void updateModNameFormat(LocalizedConfiguration config) { EnumSet<TextFormatting> validFormatting = EnumSet.allOf(TextFormatting.class); validFormatting.remove(TextFormatting.RESET); String[] validValues = new String[validFormatting.size()]; int i = 0; for (TextFormatting formatting : validFormatting) { validValues[i] = formatting.getFriendlyName().toLowerCase(Locale.ENGLISH); i++; } Property property = config.getString("modNameFormat", CATEGORY_ADVANCED, defaultModNameFormatFriendly, validValues); boolean showInGui = !isModNameFormatOverrideActive(); property.setShowInGui(showInGui); String modNameFormatFriendly = property.getString(); values.modNameFormat = parseFriendlyModNameFormat(modNameFormatFriendly); }
private void addButtonRowForTextbox(int signRowNum, int height, int leftMost) { Map<TextFormatting, GuiButtonTooltip> rowButtons = buttonMaps.get(signRowNum); int buttonID = signRowNum * 100; int w, h, x = leftMost, y = height;//leftMost was 104 w = h = 14; for (TextFormatting color : TextFormatting.values()) { if (color.isColor()) { GuiButtonTooltip btn = new GuiButtonTooltip(buttonID++, x + 40, y, w, h, getColorChar(color)); btn.allowPressedIfDisabled().setTooltip(color + color.getFriendlyName()); btn.packedFGColour = toHex(color); this.addButton(btn); x += w - 1; rowButtons.put(color, btn); } } x += w * 3 + 2; y = height; for (TextFormatting color : TextFormatting.values()) { if (!color.isColor() && color != TextFormatting.RESET) { GuiButtonTooltip btn = new GuiButtonTooltip(buttonID++, x, y, w, h, getFontChar(color)); btn.allowPressedIfDisabled().setTooltip(color + color.getFriendlyName()); this.addButton(btn); x += w; rowButtons.put(color, btn); } } }
for(int i = 0; i < tfValues.length; i++) cvFormatList.addPanel(new PanelButtonStorage<>(new GuiRectangle(0, i * 16, 100, 16), 1, tfValues[i].getFriendlyName(), tfValues[i].toString()));