use of com.glitchcog.fontificator.gui.component.LabeledSlider in project ChatGameFontificator by GlitchCog.
the class MessageCensorPanel method build.
@Override
protected void build() {
setBorder(new TitledBorder(ControlPanelBase.getBaseBorder(), "Message Censorship Configuration", TitledBorder.CENTER, TitledBorder.TOP));
setLayout(new GridBagLayout());
GridBagConstraints gbc = ControlPanelBase.getGbc();
enableCensorshipBox = new JCheckBox("Enable message censoring");
purgeOnTwitchBanBox = new JCheckBox("Purge messages on Twitch ban/timeout");
censorAllUrlsBox = new JCheckBox("Censor all messages containing URLs");
censorFirstPostUrlsBox = new JCheckBox("Censor messages containing URLs in a user's initial post");
censorUnknownCharsBox = new JCheckBox("Censor messages containing a specified percentage of extended characters:");
final String minLabel = "> 0";
// @formatter:off
unknownCharSlider = new LabeledSlider("", "%", ConfigCensor.MIN_UNKNOWN_CHAR_PCT, ConfigCensor.MAX_UNKNOWN_CHAR_PCT, Math.max(Math.max(Integer.toString(ConfigCensor.MIN_UNKNOWN_CHAR_PCT).length(), Integer.toString(ConfigCensor.MAX_UNKNOWN_CHAR_PCT).length()), minLabel.length())) {
// @formatter:on
private static final long serialVersionUID = 1L;
@Override
public String getValueString() {
if (getValue() == slider.getMinimum()) {
return minLabel;
} else {
return super.getValueString();
}
}
};
userWhitelist = new ListInput("User Whitelist", "Exempt from all censorship", this);
userBlacklist = new ListInput("User Blacklist", "Every message censored", this);
bannedWordList = new ListInput("Banned Words", "Containing censors message", this);
ActionListener bl = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateConfig();
chat.repaint();
chat.initMessageRollout();
}
};
enableCensorshipBox.addActionListener(bl);
purgeOnTwitchBanBox.addActionListener(bl);
censorAllUrlsBox.addActionListener(bl);
censorFirstPostUrlsBox.addActionListener(bl);
censorUnknownCharsBox.addActionListener(bl);
unknownCharSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
config.setUnknownCharPercentage(unknownCharSlider.getValue());
}
});
messageList = new MessageCheckList(chat, this);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.gridwidth = 3;
add(new JLabel("Censorship rules affect the visualization only; they don't influence the visibility of IRC posts."), gbc);
gbc.gridy++;
add(enableCensorshipBox, gbc);
gbc.gridy++;
add(purgeOnTwitchBanBox, gbc);
gbc.gridy++;
add(censorAllUrlsBox, gbc);
gbc.gridy++;
add(censorFirstPostUrlsBox, gbc);
gbc.gridy++;
JPanel unknownPanel = new JPanel(new GridBagLayout());
GridBagConstraints uGbc = getGbc();
uGbc.anchor = GridBagConstraints.WEST;
uGbc.weightx = 1.0;
uGbc.fill = GridBagConstraints.NONE;
unknownPanel.add(censorUnknownCharsBox, uGbc);
uGbc.gridy++;
uGbc.anchor = GridBagConstraints.EAST;
uGbc.weightx = 1.0;
uGbc.weighty = 1.0;
uGbc.fill = GridBagConstraints.BOTH;
unknownPanel.add(unknownCharSlider, uGbc);
add(unknownPanel, gbc);
gbc.gridy++;
gbc.weightx = 0.33;
gbc.gridwidth = 1;
add(userWhitelist, gbc);
gbc.gridx++;
add(userBlacklist, gbc);
gbc.gridx++;
add(bannedWordList, gbc);
gbc.gridx++;
gbc.gridy++;
gbc.gridx = 0;
gbc.gridwidth = 3;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
add(messageList, gbc);
gbc.gridy++;
}
use of com.glitchcog.fontificator.gui.component.LabeledSlider in project ChatGameFontificator by GlitchCog.
the class ControlPanelChat method build.
@Override
protected void build() {
resizableBox = new JCheckBox("Resize Chat by Dragging");
scrollableBox = new JCheckBox("Mouse Wheel Scrolls Chat");
reverseScrollBox = new JCheckBox("Reverse Chat Order");
chatFromBottomBox = new JCheckBox("Chat Starts from Bottom");
widthInput = new LabeledInput("Width", 3);
heightInput = new LabeledInput("Height", 3);
DocumentListener chatSizeDocListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
somethingChanged(e);
}
@Override
public void removeUpdate(DocumentEvent e) {
somethingChanged(e);
}
@Override
public void changedUpdate(DocumentEvent e) {
somethingChanged(e);
}
/**
* Something changed, so try to get the new width and height and set the updateSizeButton to enabled or
* disabled accordingly
*
* @param e
*/
private void somethingChanged(DocumentEvent e) {
try {
int w = Integer.parseInt(widthInput.getText());
int h = Integer.parseInt(heightInput.getText());
updateSizeButton.setEnabled(w != config.getWidth() || h != config.getHeight());
} catch (Exception ex) {
updateSizeButton.setEnabled(false);
}
}
};
DocumentListener chromaDocListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
toggleChromaButtonEnabled();
}
@Override
public void removeUpdate(DocumentEvent e) {
toggleChromaButtonEnabled();
}
@Override
public void changedUpdate(DocumentEvent e) {
toggleChromaButtonEnabled();
}
};
widthInput.addDocumentListener(chatSizeDocListener);
heightInput.addDocumentListener(chatSizeDocListener);
updateSizeButton = new JButton("Update Chat Size");
chromaEnabledBox = new JCheckBox("Enable Chroma Key Border");
chromaInvertBox = new JCheckBox("Invert Chroma Key Border");
chromaCornerSlider = new LabeledSlider("Corner Radius", "pixels", ConfigChat.MIN_CHROMA_CORNER_RADIUS, ConfigChat.MAX_CHROMA_CORNER_RADIUS);
final String[] chromaLabels = new String[] { "Left", "Top", "Right", "Bottom" };
chromaBorderInput = new LabeledInput[chromaLabels.length];
for (int i = 0; i < chromaBorderInput.length; i++) {
chromaBorderInput[i] = new LabeledInput(chromaLabels[i], 4);
chromaBorderInput[i].addDocumentListener(chromaDocListener);
}
updateChromaSizeButton = new JButton("Update Chroma Border");
ActionListener boxListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JCheckBox source = (JCheckBox) e.getSource();
if (resizableBox.equals(source)) {
chatWindow.setResizable(resizableBox.isSelected());
config.setResizable(resizableBox.isSelected());
} else if (scrollableBox.equals(source)) {
config.setScrollable(scrollableBox.isSelected());
if (!scrollableBox.isSelected()) {
// No scrolling, so reset any existing scroll offset
chat.resetScrollOffset();
}
} else if (reverseScrollBox.equals(source)) {
config.setReverseScrolling(reverseScrollBox.isSelected());
} else if (chatFromBottomBox.equals(source)) {
// Reset scrolling to avoid having to translate it between chat-start top/bottom styles
chat.resetScrollOffset();
config.setChatFromBottom(chatFromBottomBox.isSelected());
} else if (chromaEnabledBox.equals(source)) {
config.setChromaEnabled(chromaEnabledBox.isSelected());
toggleChromaInputFields();
} else if (chromaInvertBox.equals(source)) {
config.setChromaInvert(chromaInvertBox.isSelected());
}
chat.repaint();
}
};
resizableBox.addActionListener(boxListener);
scrollableBox.addActionListener(boxListener);
reverseScrollBox.addActionListener(boxListener);
chatFromBottomBox.addActionListener(boxListener);
chromaEnabledBox.addActionListener(boxListener);
chromaInvertBox.addActionListener(boxListener);
ActionListener dimListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
LoadConfigReport report = new LoadConfigReport();
config.validateDimStrings(report, widthInput.getText(), heightInput.getText());
if (report.isErrorFree()) {
final int width = Integer.parseInt(widthInput.getText());
final int height = Integer.parseInt(heightInput.getText());
config.setWidth(width);
config.setHeight(height);
chatWindow.setSize(config.getWidth(), config.getHeight());
} else {
ChatWindow.popup.handleProblem(report);
}
} catch (Exception ex) {
ChatWindow.popup.handleProblem("Chat Width and Chat Height values could not be parsed", ex);
}
}
};
updateSizeButton.addActionListener(dimListener);
ActionListener chromaDimListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
LoadConfigReport report = new LoadConfigReport();
config.validateChromaDimStrings(report, chromaBorderInput[0].getText(), chromaBorderInput[1].getText(), chromaBorderInput[2].getText(), chromaBorderInput[3].getText());
if (report.isErrorFree()) {
inputToConfigChromaBorders();
chat.repaint();
} else {
ChatWindow.popup.handleProblem(report);
}
} catch (Exception ex) {
ChatWindow.popup.handleProblem("Chat Chroma border values could not be parsed", ex);
}
}
};
updateChromaSizeButton.addActionListener(chromaDimListener);
chromaCornerSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
config.setChromaCornerRadius(chromaCornerSlider.getValue());
chat.repaint();
}
});
JPanel chatDimPanel = new JPanel(new GridBagLayout());
JPanel chatOptionsPanel = new JPanel(new GridBagLayout());
JPanel chromaDimPanel = new JPanel(new GridBagLayout());
chatDimPanel.setBorder(new TitledBorder(baseBorder, "Chat Window Size", TitledBorder.CENTER, TitledBorder.TOP));
chatOptionsPanel.setBorder(new TitledBorder(baseBorder, "Chat Window Options", TitledBorder.CENTER, TitledBorder.TOP));
chromaDimPanel.setBorder(baseBorder);
GridBagConstraints dGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, DEFAULT_INSETS, 0, 0);
dGbc.gridx = 0;
dGbc.gridy = 0;
dGbc.gridwidth = 1;
chatDimPanel.add(widthInput, dGbc);
dGbc.gridx++;
chatDimPanel.add(heightInput, dGbc);
dGbc.gridx = 0;
dGbc.gridy++;
dGbc.gridwidth = 2;
chatDimPanel.add(updateSizeButton, dGbc);
dGbc.gridy++;
chatDimPanel.add(resizableBox, dGbc);
dGbc.gridy++;
GridBagConstraints coGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, DEFAULT_INSETS, 0, 0);
coGbc.anchor = GridBagConstraints.WEST;
chatOptionsPanel.add(scrollableBox, coGbc);
coGbc.gridy++;
chatOptionsPanel.add(reverseScrollBox, coGbc);
coGbc.gridy++;
chatOptionsPanel.add(chatFromBottomBox, coGbc);
coGbc.gridy++;
GridBagConstraints chromaGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, NO_INSETS, 0, 0);
chromaGbc.gridwidth = 3;
chromaDimPanel.add(chromaEnabledBox, chromaGbc);
chromaGbc.gridy++;
chromaDimPanel.add(chromaBorderInput[1], chromaGbc);
chromaGbc.gridy++;
chromaGbc.gridwidth = 1;
chromaGbc.anchor = GridBagConstraints.EAST;
chromaDimPanel.add(chromaBorderInput[0], chromaGbc);
chromaGbc.gridx++;
chromaGbc.anchor = GridBagConstraints.CENTER;
chromaDimPanel.add(updateChromaSizeButton, chromaGbc);
chromaGbc.gridx++;
chromaGbc.anchor = GridBagConstraints.WEST;
chromaDimPanel.add(chromaBorderInput[2], chromaGbc);
chromaGbc.gridx = 0;
chromaGbc.anchor = GridBagConstraints.CENTER;
chromaGbc.gridy++;
chromaGbc.gridwidth = 3;
chromaDimPanel.add(chromaBorderInput[3], chromaGbc);
chromaGbc.gridy++;
chromaDimPanel.add(chromaInvertBox, chromaGbc);
chromaGbc.gridy++;
chromaDimPanel.add(chromaCornerSlider, chromaGbc);
JPanel everything = new JPanel(new GridBagLayout());
GridBagConstraints eGbc = new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, NO_INSETS, 0, 0);
eGbc.weighty = 0.5;
eGbc.weightx = 0.5;
eGbc.fill = GridBagConstraints.HORIZONTAL;
eGbc.insets = new Insets(0, 3, 0, 3);
everything.add(chatDimPanel, eGbc);
eGbc.weightx = 0.5;
eGbc.gridx++;
everything.add(chatOptionsPanel, eGbc);
eGbc.weightx = 1.0;
eGbc.weighty = 0.0;
eGbc.gridx = 0;
eGbc.gridy++;
eGbc.gridwidth = 2;
eGbc.fill = GridBagConstraints.BOTH;
eGbc.anchor = GridBagConstraints.CENTER;
everything.add(chromaDimPanel, eGbc);
eGbc.gridy++;
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
add(everything, gbc);
}
use of com.glitchcog.fontificator.gui.component.LabeledSlider in project ChatGameFontificator by GlitchCog.
the class ControlPanelFont method build.
@Override
protected void build() {
sliderListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider) e.getSource();
if (fontScaleSlider.getSlider().equals(source)) {
config.setFontScale(fontScaleSlider.getScaledValue());
fontScaleSlider.setValueTextColor(((int) config.getFontScale() == config.getFontScale()) ? SCALE_EVEN : SCALE_UNEVEN);
} else if (borderScaleSlider.getSlider().equals(source)) {
config.setBorderScale(borderScaleSlider.getScaledValue());
borderScaleSlider.setValueTextColor(((int) config.getBorderScale() == config.getBorderScale()) ? SCALE_EVEN : SCALE_UNEVEN);
} else if (borderInsetXSlider.getSlider().equals(source)) {
config.setBorderInsetX(borderInsetXSlider.getValue());
} else if (borderInsetYSlider.getSlider().equals(source)) {
config.setBorderInsetY(borderInsetYSlider.getValue());
} else if (spaceWidthSlider.getSlider().equals(source)) {
config.setSpaceWidth(spaceWidthSlider.getValue());
} else if (baselineOffsetSlider.getSlider().equals(source)) {
config.setBaselineOffset(baselineOffsetSlider.getValue());
} else if (lineSpacingSlider.getSlider().equals(source)) {
config.setLineSpacing(lineSpacingSlider.getValue());
} else if (charSpacingSlider.getSlider().equals(source)) {
config.setCharSpacing(charSpacingSlider.getValue());
}
chat.repaint();
}
};
ActionListener fontAl = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JMenuItem source = (JMenuItem) e.getSource();
DropdownLabel key = new DropdownLabel(source.getText());
if (CUSTOM_KEY.equals(key)) {
int selectionResult = fontPngPicker.showDialog(ControlWindow.me, "Select Font PNG");
if (selectionResult == JFileChooser.APPROVE_OPTION) {
fontFilenameInput.setText(fontPngPicker.getSelectedFile().getAbsolutePath());
fontPresetDropdown.setSelectedText(fontPngPicker.getSelectedFile().getName());
}
} else {
fontFilenameInput.setText(PRESET_FONT_FILE_MAP.get(key).getFontFilename());
fontTypeCheckbox.setSelected(FontType.VARIABLE_WIDTH.equals(PRESET_FONT_FILE_MAP.get(key).getDefaultType()));
spaceWidthSlider.setEnabled(fontTypeCheckbox.isSelected());
}
updateFontOrBorder(true);
}
};
ActionListener borderAl = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JMenuItem source = (JMenuItem) e.getSource();
DropdownLabel key = new DropdownLabel(source.getText());
if (CUSTOM_KEY.equals(key)) {
int selectionResult = borderPngPicker.showDialog(ControlWindow.me, "Select Border PNG");
if (selectionResult == JFileChooser.APPROVE_OPTION) {
borderFilenameInput.setText(borderPngPicker.getSelectedFile().getAbsolutePath());
borderPresetDropdown.setSelectedText(borderPngPicker.getSelectedFile().getName());
}
} else {
DropdownBorder border = PRESET_BORDER_FILE_MAP.get(key);
borderFilenameInput.setText(border.getBorderFilename());
colorPanel.setBorderColor(border.getDefaultTint());
}
updateFontOrBorder(false);
}
};
fontTypeListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
config.setFontType(fontTypeCheckbox.isSelected() ? FontType.VARIABLE_WIDTH : FontType.FIXED_WIDTH);
spaceWidthSlider.setEnabled(fontTypeCheckbox.isSelected());
updateFontOrBorder(true);
}
};
extendedCharBox = new JCheckBox("Display Extended Characters");
extendedCharBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final boolean ecbSelected = extendedCharBox.isSelected();
config.setExtendedCharEnabled(ecbSelected);
unknownCharPopupButton.setEnabled(!ecbSelected);
unknownCharLabel.setEnabled(!ecbSelected);
chat.repaint();
}
});
unknownCharLabel = new JLabel("");
charPicker = new CharacterPicker(ControlWindow.me, fProps.getFontConfig(), unknownCharLabel, chat);
Map<String, List<String>> fontMenuMap = getMenuMapFromPresets(PRESET_FONT_FILE_MAP.keySet());
fontMenuMap.put(CUSTOM_KEY.getLabel(), null);
Map<String, List<String>> borderMenuMap = getMenuMapFromPresets(PRESET_BORDER_FILE_MAP.keySet());
borderMenuMap.put(CUSTOM_KEY.getLabel(), null);
fontTypeCheckbox = new JCheckBox("Variable Width Characters");
fontFilenameInput = new LabeledInput("Font Filename", 32);
fontPresetDropdown = new ComboMenuBar(fontMenuMap, fontAl);
borderFilenameInput = new LabeledInput("Border Filename", 32);
borderPresetDropdown = new ComboMenuBar(borderMenuMap, borderAl);
gridWidthInput = new LabeledInput("Grid Width", 4);
gridHeightInput = new LabeledInput("Grid Height", 4);
fontScaleSlider = new LabeledSlider("Font Scale", "x", ConfigFont.MIN_FONT_SCALE, ConfigFont.MAX_FONT_SCALE, ConfigFont.FONT_BORDER_SCALE_GRANULARITY);
borderScaleSlider = new LabeledSlider("Border Scale", "x", ConfigFont.MIN_BORDER_SCALE, ConfigFont.MAX_BORDER_SCALE, ConfigFont.FONT_BORDER_SCALE_GRANULARITY);
borderInsetXSlider = new LabeledSlider("X", "pixels", ConfigFont.MIN_BORDER_INSET, ConfigFont.MAX_BORDER_INSET);
borderInsetYSlider = new LabeledSlider("Y", "pixels", ConfigFont.MIN_BORDER_INSET, ConfigFont.MAX_BORDER_INSET);
characterKeyInput = new LabeledInput("Character Key", 32);
spaceWidthSlider = new LabeledSlider("Space Width", "%", ConfigFont.MIN_SPACE_WIDTH, ConfigFont.MAX_SPACE_WIDTH);
baselineOffsetSlider = new LabeledSlider("Baseline Height Offset", "pixels", ConfigFont.MIN_BASELINE_OFFSET, ConfigFont.MAX_BASELINE_OFFSET);
lineSpacingSlider = new LabeledSlider("Line Spacing", "pixels", ConfigFont.MIN_LINE_SPACING, ConfigFont.MAX_LINE_SPACING);
charSpacingSlider = new LabeledSlider("Char Spacing", "pixels", ConfigFont.MIN_CHAR_SPACING, ConfigFont.MAX_LINE_SPACING);
unknownCharPopupButton = new JButton("Select Missing Character");
unknownCharPopupButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
charPicker.setVisible(true);
}
});
fontFilenameInput.setEnabled(false);
borderFilenameInput.setEnabled(false);
fontScaleSlider.addChangeListener(sliderListener);
borderScaleSlider.addChangeListener(sliderListener);
borderInsetXSlider.addChangeListener(sliderListener);
borderInsetYSlider.addChangeListener(sliderListener);
spaceWidthSlider.addChangeListener(sliderListener);
baselineOffsetSlider.addChangeListener(sliderListener);
lineSpacingSlider.addChangeListener(sliderListener);
charSpacingSlider.addChangeListener(sliderListener);
JPanel fontPanel = new JPanel(new GridBagLayout());
JPanel borderPanel = new JPanel(new GridBagLayout());
JPanel unknownPanel = new JPanel(new GridBagLayout());
fontPanel.setBorder(new TitledBorder(baseBorder, "Font"));
borderPanel.setBorder(new TitledBorder(baseBorder, "Border"));
unknownPanel.setBorder(new TitledBorder(baseBorder, "Extended and Unicode Characters"));
GridBagConstraints fontGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 0, 0);
GridBagConstraints borderGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 0, 0);
GridBagConstraints unknownGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 0, 0);
// Fields are still used and stored in properties files when saved, but the values are either fixed or meant to
// be filled by other components
// add(fontFilenameInput);
// add(borderFilenameInput);
// add(gridWidthInput);
// add(gridHeightInput);
// add(characterKeyInput);
fontPanel.add(fontPresetDropdown, fontGbc);
fontGbc.gridx++;
// This slider being on the same row as the preset dropdown keeps the combo menu bar from collapsing to no
// height in the layout
fontPanel.add(fontScaleSlider, fontGbc);
fontGbc.gridwidth = 2;
fontGbc.gridx = 0;
fontGbc.gridy++;
fontPanel.add(lineSpacingSlider, fontGbc);
fontGbc.gridy++;
fontPanel.add(charSpacingSlider, fontGbc);
fontGbc.gridy++;
JPanel variableWidthPanel = new JPanel(new GridBagLayout());
GridBagConstraints vwpGbc = getGbc();
vwpGbc.anchor = GridBagConstraints.EAST;
vwpGbc.weightx = 0.0;
vwpGbc.fill = GridBagConstraints.NONE;
variableWidthPanel.add(fontTypeCheckbox, vwpGbc);
vwpGbc.anchor = GridBagConstraints.WEST;
vwpGbc.weightx = 1.0;
vwpGbc.fill = GridBagConstraints.HORIZONTAL;
vwpGbc.gridx++;
variableWidthPanel.add(spaceWidthSlider, vwpGbc);
fontPanel.add(variableWidthPanel, fontGbc);
fontGbc.gridy++;
fontPanel.add(baselineOffsetSlider, fontGbc);
fontGbc.gridy++;
borderPanel.add(borderPresetDropdown, borderGbc);
borderGbc.gridx++;
// This slider being on the same row as the preset dropdown keeps the combo menu bar from collapsing to no
// height in the layout
borderPanel.add(borderScaleSlider, borderGbc);
borderGbc.gridwidth = 2;
borderGbc.gridx = 0;
borderGbc.gridy++;
borderGbc.anchor = GridBagConstraints.CENTER;
borderPanel.add(new JLabel("Font Insets Off Border"), borderGbc);
borderGbc.gridy++;
borderPanel.add(borderInsetXSlider, borderGbc);
borderGbc.gridy++;
borderPanel.add(borderInsetYSlider, borderGbc);
borderGbc.gridy++;
unknownPanel.add(extendedCharBox, unknownGbc);
unknownGbc.gridx++;
unknownPanel.add(unknownCharPopupButton, unknownGbc);
unknownGbc.gridx++;
unknownPanel.add(unknownCharLabel, unknownGbc);
unknownGbc.gridx++;
JPanel everything = new JPanel(new GridBagLayout());
GridBagConstraints eGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 10, 10);
everything.add(fontPanel, eGbc);
eGbc.gridy++;
everything.add(borderPanel, eGbc);
eGbc.gridy++;
everything.add(unknownPanel, eGbc);
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.CENTER;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
add(everything, gbc);
// Filler panel
gbc.gridy++;
gbc.weighty = 1.0;
gbc.anchor = GridBagConstraints.SOUTH;
add(new JPanel(), gbc);
}
use of com.glitchcog.fontificator.gui.component.LabeledSlider in project ChatGameFontificator by GlitchCog.
the class ControlPanelDebug method build.
@Override
protected void build() {
postTestMessage = new JButton("Post Debug Message");
postTestMessage.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ctrlWindow.addManualMessage("Test", SpriteFont.NORMAL_ASCII_KEY);
}
});
postMessagesButton = new JToggleButton("Post Messages");
postRateSlider = new LabeledSlider("Post Rate ", " / min", 1, 120, 15, 3);
postClock = new Timer(60000 / postRateSlider.getValue(), new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
postRandomMessage();
}
});
postRateSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (!((JSlider) e.getSource()).getValueIsAdjusting()) {
postClock.setDelay(60000 / postRateSlider.getValue());
if (postClock.isRunning()) {
postRandomMessage();
postClock.restart();
}
}
}
});
postMessagesButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
postRandomMessage();
if (postMessagesButton.isSelected()) {
postClock.start();
} else {
postClock.stop();
}
}
});
drawTextGridBox = new JCheckBox("Draw Text Grid");
textGridColorButton = new ColorButton("Text Grid Color", new Color(0x99FF88), "Color of the border grid", this);
drawBorderGridBox = new JCheckBox("Draw Border Grid");
borderGridColorButton = new ColorButton("Border Grid Color", new Color(0x9988FF), "Color of the border grid", this);
ActionListener refreshListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (chat != null) {
chat.repaint();
}
}
};
drawTextGridBox.addActionListener(refreshListener);
drawBorderGridBox.addActionListener(refreshListener);
JPanel topPanel = new JPanel(new GridBagLayout());
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0.0;
gbc.weighty = 0.0;
gbc.fill = GridBagConstraints.NONE;
topPanel.add(postTestMessage, gbc);
gbc.gridx++;
topPanel.add(postMessagesButton, gbc);
gbc.gridx++;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
topPanel.add(postRateSlider, gbc);
gbc.gridwidth = 4;
gbc.gridx = 0;
gbc.gridy = 0;
add(topPanel, gbc);
gbc.gridy++;
gbc.gridwidth = 1;
gbc.weightx = 0.5;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(drawTextGridBox, gbc);
gbc.gridx++;
add(textGridColorButton, gbc);
gbc.gridx++;
add(drawBorderGridBox, gbc);
gbc.gridx++;
add(borderGridColorButton, gbc);
gbc.gridy++;
gbc.gridx = 0;
gbc.gridwidth = 4;
gbc.weighty = 0.1;
CollagePanel collagePanel = new CollagePanel(chat);
add(collagePanel, gbc);
gbc.gridy++;
gbc.weightx = 1.0;
gbc.weighty = 0.9;
gbc.anchor = GridBagConstraints.SOUTH;
gbc.fill = GridBagConstraints.BOTH;
gbc.gridwidth = 4;
add(logBox, gbc);
}
use of com.glitchcog.fontificator.gui.component.LabeledSlider in project ChatGameFontificator by GlitchCog.
the class ControlPanelEmoji method build.
@Override
protected void build() {
enableAll = new JCheckBox("Enable Emoji");
enableAnimation = new JCheckBox("Enable Animation");
enableTwitchBadges = new JCheckBox("Enable Twitch Badges");
enableFfzBadges = new JCheckBox("Enable FrankerFaceZ Badges");
progressPanel = new EmojiLoadProgressPanel(chat, this);
emojiScaleToLineHeight = new JCheckBox("Relative to Line Height");
emojiScale = new LabeledSlider("Emoji Scale", "%", ConfigEmoji.MIN_SCALE, ConfigEmoji.MAX_SCALE, 100, 3);
badgeScaleToLineHeight = new JCheckBox("Relative to Line Height");
badgeScale = new LabeledSlider("Badge Scale", "%", ConfigEmoji.MIN_SCALE, ConfigEmoji.MAX_SCALE, 100, 3);
badgeHeightOffset = new LabeledSlider("Badge Height Offset", "pixels", ConfigEmoji.MIN_BADGE_OFFSET, ConfigEmoji.MAX_BADGE_OFFSET, 0, 3);
emojiLoadingDisplayStratLabel = new JLabel("Emoji Loading Display Strategy:");
emojiLoadingDisplayStrat = new JComboBox<EmojiLoadingDisplayStragegy>(EmojiLoadingDisplayStragegy.values());
enableTwitch = new JCheckBox("Enable Twitch Emotes");
cacheTwitch = new JCheckBox("Cache Global Twitch Emotes");
enableFrankerFaceZ = new JCheckBox("Enable FrankerFaceZ Emotes");
cacheFrankerFaceZ = new JCheckBox("Cache FrankerFaceZ Emotes");
enableBetterTtv = new JCheckBox("Enable BetterTTV Emotes");
cacheBetterTtv = new JCheckBox("Cache BetterTTV Emotes");
emojiScale.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
config.setEmojiScale(emojiScale.getValue());
chat.repaint();
}
});
badgeScale.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
config.setBadgeScale(badgeScale.getValue());
chat.repaint();
}
});
badgeHeightOffset.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
config.setBadgeHeightOffset(badgeHeightOffset.getValue());
chat.repaint();
}
});
emojiLoadingDisplayStrat.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
config.setDisplayStrategy((EmojiLoadingDisplayStragegy) emojiLoadingDisplayStrat.getSelectedItem());
chat.repaint();
}
});
// This action listener is for loading emotes and badges whenever a checkbox is checked while connected
ActionListener cbal = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JCheckBox source = (JCheckBox) e.getSource();
if (bot.isConnected()) {
Set<EmojiJob> jobsToRun = new HashSet<EmojiJob>();
Set<EmojiJob> jobsToCancel = new HashSet<EmojiJob>();
final boolean clickAll = enableAll.equals(source);
final boolean clickFfzLoad = clickAll || enableFrankerFaceZ.equals(source);
final boolean clickFfzCache = clickAll || cacheFrankerFaceZ.equals(source);
final boolean clickBttvLoad = clickAll || enableBetterTtv.equals(source);
final boolean clickBttvCache = clickAll || cacheBetterTtv.equals(source);
// Badges is independent of enableAll
final boolean clickTwitchBadges = !config.isTwitchBadgesLoaded(getConnectChannel()) && enableTwitchBadges.equals(source);
final boolean clickFfzBadges = !config.isFfzBadgesLoaded(getConnectChannel()) && enableFfzBadges.equals(source);
final String oauth = fProps.getProperty(FontificatorProperties.KEY_IRC_AUTH);
if (clickFfzLoad && !config.isFfzLoaded(getConnectChannel())) {
EmojiJob jobA = new EmojiJob(oauth, EmojiType.FRANKERFACEZ_CHANNEL, EmojiOperation.LOAD, getConnectChannel());
EmojiJob jobB = new EmojiJob(oauth, EmojiType.FRANKERFACEZ_GLOBAL, EmojiOperation.LOAD);
if (enableAll.isSelected() && enableFrankerFaceZ.isSelected()) {
jobsToRun.add(jobA);
jobsToRun.add(jobB);
} else {
jobsToCancel.add(jobA);
jobsToCancel.add(jobB);
}
}
if (clickBttvLoad && !config.isBttvLoaded(getConnectChannel())) {
EmojiJob jobA = new EmojiJob(oauth, EmojiType.BETTER_TTV_CHANNEL, EmojiOperation.LOAD, getConnectChannel());
EmojiJob jobB = new EmojiJob(oauth, EmojiType.BETTER_TTV_GLOBAL, EmojiOperation.LOAD);
if (enableAll.isSelected() && enableBetterTtv.isSelected()) {
jobsToRun.add(jobA);
jobsToRun.add(jobB);
} else {
jobsToCancel.add(jobA);
jobsToCancel.add(jobB);
}
}
if (clickFfzCache && !config.isFfzCached()) {
EmojiJob jobA = new EmojiJob(oauth, EmojiType.FRANKERFACEZ_CHANNEL, EmojiOperation.CACHE);
EmojiJob jobB = new EmojiJob(oauth, EmojiType.FRANKERFACEZ_GLOBAL, EmojiOperation.CACHE);
if (enableAll.isSelected() && cacheFrankerFaceZ.isSelected()) {
jobsToRun.add(jobA);
jobsToRun.add(jobB);
} else {
jobsToCancel.add(jobA);
jobsToCancel.add(jobB);
}
}
if (clickBttvCache && !config.isBttvCached()) {
EmojiJob jobA = new EmojiJob(oauth, EmojiType.BETTER_TTV_CHANNEL, EmojiOperation.CACHE);
EmojiJob jobB = new EmojiJob(oauth, EmojiType.BETTER_TTV_GLOBAL, EmojiOperation.CACHE);
if (enableAll.isSelected() && cacheBetterTtv.isSelected()) {
jobsToRun.add(jobA);
jobsToRun.add(jobB);
} else {
jobsToCancel.add(jobA);
jobsToCancel.add(jobB);
}
}
if (clickTwitchBadges && !config.isTwitchBadgesLoaded(getConnectChannel())) {
EmojiJob job = new EmojiJob(oauth, EmojiType.TWITCH_BADGE, EmojiOperation.LOAD, getConnectChannel());
// No check for enable all here, because badges are independent of the emoji enableAll toggle
if (enableTwitchBadges.isSelected()) {
jobsToRun.add(job);
} else {
jobsToCancel.add(job);
}
}
if (clickFfzBadges && !config.isFfzBadgesLoaded(getConnectChannel())) {
EmojiJob job = new EmojiJob(oauth, EmojiType.FRANKERFACEZ_BADGE, EmojiOperation.LOAD, getConnectChannel());
// No check for enable all here, because badges are independent of the emoji enableAll toggle
if (enableFfzBadges.isSelected()) {
jobsToRun.add(job);
} else {
jobsToCancel.add(job);
}
}
loadEmojiWork(jobsToRun);
cancelEmojiWork(jobsToCancel);
if (!jobsToRun.isEmpty() && !progressPanel.isCurrentlyRunning()) {
runEmojiWork();
}
}
// These are only the checkboxes handled in fillConfigFromInput()
config.setEmojiEnabled(enableAll.isSelected());
config.setAnimationEnabled(enableAnimation.isSelected());
config.setTwitchBadgesEnabled(enableTwitchBadges.isSelected());
config.setFfzBadgesEnabled(enableFfzBadges.isSelected());
config.setTwitchEnabled(enableTwitch.isSelected());
config.setTwitchCacheEnabled(cacheTwitch.isSelected());
config.setFfzEnabled(enableFrankerFaceZ.isSelected());
config.setFfzCacheEnabled(cacheFrankerFaceZ.isSelected());
config.setBttvEnabled(enableBetterTtv.isSelected());
config.setBttvCacheEnabled(cacheBetterTtv.isSelected());
config.setEmojiScaleToLine(emojiScaleToLineHeight.isSelected());
config.setBadgeScaleToLine(badgeScaleToLineHeight.isSelected());
resolveEnables();
chat.repaint();
}
};
enableAll.addActionListener(cbal);
enableAnimation.addActionListener(cbal);
enableTwitchBadges.addActionListener(cbal);
enableFfzBadges.addActionListener(cbal);
emojiScaleToLineHeight.addActionListener(cbal);
badgeScaleToLineHeight.addActionListener(cbal);
enableTwitch.addActionListener(cbal);
cacheTwitch.addActionListener(cbal);
enableFrankerFaceZ.addActionListener(cbal);
cacheFrankerFaceZ.addActionListener(cbal);
enableBetterTtv.addActionListener(cbal);
cacheBetterTtv.addActionListener(cbal);
// Top row containing emoji toggle, animation, and badge toggles
JPanel allEnabledPanel = new JPanel(new GridBagLayout());
GridBagConstraints allGbc = getGbc();
allGbc.weighty = 1.0;
allGbc.fill = GridBagConstraints.NONE;
allGbc.anchor = GridBagConstraints.WEST;
allGbc.weightx = 0.25;
allEnabledPanel.add(enableAll, allGbc);
allGbc.gridx++;
allEnabledPanel.add(enableAnimation, allGbc);
allGbc.gridx++;
allGbc.anchor = GridBagConstraints.EAST;
allEnabledPanel.add(enableTwitchBadges, allGbc);
allGbc.gridx++;
allEnabledPanel.add(enableFfzBadges, allGbc);
allGbc.gridx++;
scaleAndDisplayPanel = new JPanel(new GridBagLayout());
scaleAndDisplayPanel.setBorder(baseBorder);
GridBagConstraints scaleAndDisplayGbc = getGbc();
// Emoji scaling
scaleAndDisplayGbc.anchor = GridBagConstraints.CENTER;
scaleAndDisplayGbc.fill = GridBagConstraints.HORIZONTAL;
scaleAndDisplayGbc.weightx = 1.0;
scaleAndDisplayPanel.add(emojiScale, scaleAndDisplayGbc);
scaleAndDisplayGbc.gridx++;
scaleAndDisplayGbc.fill = GridBagConstraints.NONE;
scaleAndDisplayGbc.weightx = 0.0;
scaleAndDisplayPanel.add(emojiScaleToLineHeight, scaleAndDisplayGbc);
scaleAndDisplayGbc.gridx = 0;
scaleAndDisplayGbc.gridy++;
// Badge scaling
scaleAndDisplayGbc.anchor = GridBagConstraints.CENTER;
scaleAndDisplayGbc.fill = GridBagConstraints.HORIZONTAL;
scaleAndDisplayGbc.weightx = 1.0;
scaleAndDisplayPanel.add(badgeScale, scaleAndDisplayGbc);
scaleAndDisplayGbc.gridx++;
scaleAndDisplayGbc.fill = GridBagConstraints.NONE;
scaleAndDisplayGbc.weightx = 0.0;
scaleAndDisplayPanel.add(badgeScaleToLineHeight, scaleAndDisplayGbc);
scaleAndDisplayGbc.gridx = 0;
scaleAndDisplayGbc.gridy++;
scaleAndDisplayGbc.fill = GridBagConstraints.HORIZONTAL;
scaleAndDisplayGbc.gridwidth = 2;
scaleAndDisplayPanel.add(badgeHeightOffset, scaleAndDisplayGbc);
scaleAndDisplayGbc.gridy++;
scaleAndDisplayGbc.gridwidth = 2;
scaleAndDisplayGbc.weightx = 1.0;
scaleAndDisplayGbc.fill = GridBagConstraints.HORIZONTAL;
scaleAndDisplayPanel.add(new JSeparator(SwingConstants.HORIZONTAL), scaleAndDisplayGbc);
scaleAndDisplayGbc.gridy++;
JPanel bottomOfScaleDisplayPanel = new JPanel();
bottomOfScaleDisplayPanel.add(emojiLoadingDisplayStratLabel);
bottomOfScaleDisplayPanel.add(emojiLoadingDisplayStrat);
scaleAndDisplayPanel.add(bottomOfScaleDisplayPanel, scaleAndDisplayGbc);
twitchPanel = new JPanel(new GridBagLayout());
twitchPanel.setBorder(BorderFactory.createTitledBorder(baseBorder, "Twitch Emotes"));
GridBagConstraints twitchGbc = getGbc();
twitchPanel.add(enableTwitch, twitchGbc);
twitchGbc.gridy++;
twitchPanel.add(cacheTwitch, twitchGbc);
twitchGbc.gridy++;
frankerPanel = new JPanel(new GridBagLayout());
frankerPanel.setBorder(BorderFactory.createTitledBorder(baseBorder, "FrankerFaceZ Emotes"));
GridBagConstraints frankerGbc = getGbc();
frankerPanel.add(enableFrankerFaceZ, frankerGbc);
frankerGbc.gridy++;
frankerPanel.add(cacheFrankerFaceZ, frankerGbc);
frankerGbc.gridy++;
betterPanel = new JPanel(new GridBagLayout());
betterPanel.setBorder(BorderFactory.createTitledBorder(baseBorder, "BetterTTV Emotes"));
GridBagConstraints betterGbc = getGbc();
betterPanel.add(enableBetterTtv, betterGbc);
betterGbc.gridy++;
betterPanel.add(cacheBetterTtv, betterGbc);
betterGbc.gridy++;
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.gridwidth = 3;
add(allEnabledPanel, gbc);
gbc.gridy++;
gbc.gridwidth = 1;
add(twitchPanel, gbc);
gbc.gridx++;
add(frankerPanel, gbc);
gbc.gridx++;
add(betterPanel, gbc);
gbc.gridx++;
gbc.gridx = 0;
gbc.gridy++;
gbc.gridwidth = 3;
add(scaleAndDisplayPanel, gbc);
gbc.gridy++;
gbc.gridy++;
gbc.anchor = GridBagConstraints.SOUTH;
gbc.weighty = 1.0;
gbc.weightx = 1.0;
gbc.gridwidth = 3;
gbc.fill = GridBagConstraints.BOTH;
add(progressPanel, gbc);
gbc.gridy++;
}
Aggregations