Soundboard: play modes, optional mic, live volume, dark-friendly icon
- Mode, saved: one sound at a time, each sound once (a click restarts it) or mayhem (every click layers another copy). A tile click plays by the mode; Stop is in the context menu. - "Mix in microphone": when off, a playing sound replaces the open mic rather than mixing with it. - Volume, local volume, master volume and per-sound volume now reach sounds already playing; a sound turned down to nothing no longer keys the microphone. - Toolbar and menu use the pack's SOUNDPACK icon, readable on dark themes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -139,7 +139,7 @@ final class MainMenuBar extends JMenuBar {
|
||||
deleteAvatarItem.addActionListener(e -> commands.deleteAvatar());
|
||||
JMenuItem giantPtt = new JMenuItem("Giant PTT", Icons.of("CAPTURE"));
|
||||
giantPtt.addActionListener(e -> commands.showGiantPtt());
|
||||
JMenuItem soundboard = new JMenuItem("Soundboard", Icons.of("MUSIC"));
|
||||
JMenuItem soundboard = new JMenuItem("Soundboard", Icons.ofAny("SOUNDPACK", "MUSIC"));
|
||||
soundboard.addActionListener(e -> commands.showSoundboard());
|
||||
self.add(awayMenu);
|
||||
self.add(activateItem);
|
||||
|
||||
@@ -111,7 +111,7 @@ final class ToolbarActions {
|
||||
add("deleteAvatar", Category.SELF, "Delete Avatar", commands::deleteAvatar, "DELETE_AVATAR")
|
||||
.enabledWhen(() -> is(ServerSession::hasAvatar));
|
||||
add("giantPtt", Category.SELF, "Giant PTT", commands::showGiantPtt, "CAPTURE");
|
||||
add("soundboard", Category.SELF, "Soundboard", commands::showSoundboard, "MUSIC");
|
||||
add("soundboard", Category.SELF, "Soundboard", commands::showSoundboard, "SOUNDPACK", "MUSIC");
|
||||
}
|
||||
|
||||
private void addDialogs() {
|
||||
|
||||
+50
-11
@@ -17,7 +17,10 @@ import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
@@ -56,8 +59,9 @@ import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* The soundboard: a grid of sounds, each played onto the air with a click and stopped with
|
||||
* another. Files dropped on it are added; the context menu edits, reorders and removes.
|
||||
* The soundboard: a grid of sounds, each played onto the air with a click, as the chosen
|
||||
* {@link Settings.SoundboardMode} has it. Files dropped on it are added; the context menu
|
||||
* stops, edits, reorders and removes.
|
||||
*/
|
||||
final class SoundboardWindow extends JDialog {
|
||||
|
||||
@@ -106,7 +110,7 @@ final class SoundboardWindow extends JDialog {
|
||||
if (e.isPopupTrigger()) {
|
||||
tileMenu(model.get(index)).show(grid, e.getX(), e.getY());
|
||||
} else if (SwingUtilities.isLeftMouseButton(e)) {
|
||||
toggle(model.get(index));
|
||||
play.accept(model.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +122,7 @@ final class SoundboardWindow extends JDialog {
|
||||
else emptyMenu().show(grid, e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
bindKey("ENTER", "play", () -> selected(this::toggle));
|
||||
bindKey("ENTER", "play", () -> selected(play));
|
||||
bindKey("DELETE", "remove", () -> selected(this::remove));
|
||||
bindKey("F2", "edit", () -> selected(this::edit));
|
||||
|
||||
@@ -138,12 +142,41 @@ final class SoundboardWindow extends JDialog {
|
||||
buttons.add(new JLabel("Local"));
|
||||
buttons.add(volumeSlider(settings.soundboardLocalVolume, 100));
|
||||
|
||||
JComboBox<Settings.SoundboardMode> mode = new JComboBox<>(Settings.SoundboardMode.values());
|
||||
mode.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
||||
boolean selected, boolean focused) {
|
||||
return super.getListCellRendererComponent(list, label((Settings.SoundboardMode) value),
|
||||
index, selected, focused);
|
||||
}
|
||||
});
|
||||
mode.setSelectedItem(settings.soundboardMode.get());
|
||||
mode.addActionListener(e -> {
|
||||
settings.soundboardMode.set((Settings.SoundboardMode) mode.getSelectedItem());
|
||||
settings.save();
|
||||
});
|
||||
JCheckBox withMic = new JCheckBox("Mix in microphone", settings.soundboardWithMic.get());
|
||||
withMic.addActionListener(e -> {
|
||||
settings.soundboardWithMic.set(withMic.isSelected());
|
||||
settings.save();
|
||||
});
|
||||
|
||||
JPanel options = new JPanel(new FlowLayout(FlowLayout.LEFT, UIScale.scale(6), 0));
|
||||
options.add(new JLabel("Mode"));
|
||||
options.add(mode);
|
||||
options.add(Box.createHorizontalStrut(UIScale.scale(12)));
|
||||
options.add(withMic);
|
||||
|
||||
status.setForeground(Theme.blocked());
|
||||
JPanel south = new JPanel();
|
||||
south.setLayout(new BoxLayout(south, BoxLayout.Y_AXIS));
|
||||
buttons.setAlignmentX(LEFT_ALIGNMENT);
|
||||
options.setAlignmentX(LEFT_ALIGNMENT);
|
||||
status.setAlignmentX(LEFT_ALIGNMENT);
|
||||
south.add(buttons);
|
||||
south.add(Box.createVerticalStrut(UIScale.scale(6)));
|
||||
south.add(options);
|
||||
south.add(Box.createVerticalStrut(UIScale.scale(4)));
|
||||
south.add(status);
|
||||
|
||||
@@ -173,11 +206,6 @@ final class SoundboardWindow extends JDialog {
|
||||
|
||||
// ---- playing ----
|
||||
|
||||
private void toggle(SoundboardSound sound) {
|
||||
if (soundboard.isPlaying(sound)) soundboard.stop(sound);
|
||||
else play.accept(sound);
|
||||
}
|
||||
|
||||
private void playingChanged() {
|
||||
stopAll.setEnabled(soundboard.isPlaying());
|
||||
grid.repaint();
|
||||
@@ -215,6 +243,7 @@ final class SoundboardWindow extends JDialog {
|
||||
|
||||
private void edit(SoundboardSound sound) {
|
||||
if (!SoundEditDialog.edit(this, sound)) return;
|
||||
soundboard.updateVolume(sound);
|
||||
sounds.save();
|
||||
grid.repaint();
|
||||
}
|
||||
@@ -240,8 +269,10 @@ final class SoundboardWindow extends JDialog {
|
||||
|
||||
private JPopupMenu tileMenu(SoundboardSound sound) {
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
boolean playing = soundboard.isPlaying(sound);
|
||||
menu.add(item(playing ? "Stop" : "Play", () -> toggle(sound)));
|
||||
menu.add(item("Play", () -> play.accept(sound)));
|
||||
JMenuItem stop = item("Stop", () -> soundboard.stop(sound));
|
||||
stop.setEnabled(soundboard.isPlaying(sound));
|
||||
menu.add(stop);
|
||||
menu.addSeparator();
|
||||
menu.add(item("Edit…", () -> edit(sound)));
|
||||
JMenuItem left = item("Move left", () -> move(sound, -1));
|
||||
@@ -283,6 +314,14 @@ final class SoundboardWindow extends JDialog {
|
||||
});
|
||||
}
|
||||
|
||||
private static String label(Settings.SoundboardMode mode) {
|
||||
return switch (mode) {
|
||||
case SINGLE -> "One at a time";
|
||||
case ONCE_EACH -> "Each once";
|
||||
case MAYHEM -> "Mayhem";
|
||||
};
|
||||
}
|
||||
|
||||
private static JMenuItem item(String label, Runnable action) {
|
||||
JMenuItem item = new JMenuItem(label);
|
||||
item.addActionListener(e -> action.run());
|
||||
|
||||
Reference in New Issue
Block a user