use of com.glitchcog.fontificator.gui.controls.panel.model.DropdownFont in project ChatGameFontificator by GlitchCog.
the class ControlPanelFont method fillInputFromConfig.
@Override
protected void fillInputFromConfig() {
borderFilenameInput.setText(config.getBorderFilename());
fontFilenameInput.setText(config.getFontFilename());
gridWidthInput.setText(Integer.toString(config.getGridWidth()));
gridHeightInput.setText(Integer.toString(config.getGridHeight()));
fontScaleSlider.setScaledValue(config.getFontScale());
borderScaleSlider.setScaledValue(config.getBorderScale());
borderInsetXSlider.setValue(config.getBorderInsetX());
borderInsetYSlider.setValue(config.getBorderInsetY());
characterKeyInput.setText(config.getCharacterKey());
extendedCharBox.setSelected(config.isExtendedCharEnabled());
charPicker.setSelectedChar(config.getUnknownChar());
spaceWidthSlider.setValue(config.getSpaceWidth());
baselineOffsetSlider.setValue(config.getBaselineOffset());
lineSpacingSlider.setValue(config.getLineSpacing());
charSpacingSlider.setValue(config.getCharSpacing());
fontTypeCheckbox.setSelected(FontType.VARIABLE_WIDTH.equals(config.getFontType()));
spaceWidthSlider.setEnabled(fontTypeCheckbox.isSelected());
final boolean ecbSelected = extendedCharBox.isSelected();
unknownCharPopupButton.setEnabled(!ecbSelected);
unknownCharLabel.setEnabled(!ecbSelected);
boolean found;
found = false;
for (Map.Entry<DropdownLabel, DropdownFont> entry : PRESET_FONT_FILE_MAP.entrySet()) {
if (entry.getValue() != null && config.getFontFilename().equals(entry.getValue().getFontFilename())) {
found = true;
fontPresetDropdown.setSelectedText(entry.getKey().getLabel());
}
}
if (!found) {
String filename = new File(fontFilenameInput.getText()).getName();
fontPresetDropdown.setSelectedText(filename);
}
found = false;
for (Map.Entry<DropdownLabel, DropdownBorder> entry : PRESET_BORDER_FILE_MAP.entrySet()) {
if (entry.getValue() != null && config.getBorderFilename().equals(entry.getValue().getBorderFilename())) {
found = true;
borderPresetDropdown.setSelectedText(entry.getKey().getLabel());
}
}
if (!found) {
String filename = new File(borderFilenameInput.getText()).getName();
borderPresetDropdown.setSelectedText(filename);
}
// Although the font was already updated from the listener attached the the fontTypeDropdown, it should be done
// here to make it official. If the font and border aren't updated, they could be out of sync with the input
// filled from config on preset loads, and it shouldn't be the responsibility of actionlisteners attached to UI
// components to update the display
updateFontOrBorder(true);
// Also, the border must be updated here too.
updateFontOrBorder(false);
}
Aggregations