mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 17:58:01 +00:00
-Add menu item "Play sound" in Game menu.
Now sounds playing if menu item "Play sound" is selected and file is exist.
This commit is contained in:
@@ -167,8 +167,8 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon
|
||||
private void addMenu() {
|
||||
Object[] obj = {
|
||||
HUMAN_GRAVEYARD_ACTION, HUMAN_REMOVED_ACTION, HUMAN_FLASHBACK_ACTION, COMPUTER_GRAVEYARD_ACTION,
|
||||
COMPUTER_REMOVED_ACTION, GuiDisplay3.eotCheckboxForMenu, new JSeparator(),
|
||||
ErrorViewer.ALL_THREADS_ACTION, new JSeparator(), CONCEDE_ACTION};
|
||||
COMPUTER_REMOVED_ACTION, new JSeparator(), GuiDisplay3.eotCheckboxForMenu, GuiDisplay3.playsoundCheckboxForMenu, new JSeparator(),
|
||||
ErrorViewer.ALL_THREADS_ACTION, CONCEDE_ACTION};
|
||||
|
||||
JMenu gameMenu = new JMenu(ForgeProps.getLocalized(MENU_BAR.MENU.TITLE));
|
||||
for(Object o:obj) {
|
||||
@@ -1148,9 +1148,10 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon
|
||||
|
||||
public boolean stopEOT() {
|
||||
return eotCheckboxForMenu.isSelected();
|
||||
}
|
||||
}
|
||||
|
||||
public static JCheckBoxMenuItem eotCheckboxForMenu = new JCheckBoxMenuItem("Stop at End of Turn", false);
|
||||
public static JCheckBoxMenuItem playsoundCheckboxForMenu = new JCheckBoxMenuItem("Play Sound", true);
|
||||
|
||||
MultiSplitPane pane = new MultiSplitPane();
|
||||
JButton cancelButton = new JButton();
|
||||
|
||||
@@ -16,20 +16,24 @@ public class MP3Player implements NewConstants{
|
||||
|
||||
private Player player;
|
||||
private InputStream is;
|
||||
private File file;
|
||||
|
||||
/** Creates a new instance of MP3Player */
|
||||
public MP3Player(String filename) {
|
||||
File base = ForgeProps.getFile(SOUND_BASE);
|
||||
file = new File(base, filename);
|
||||
if(GuiDisplay3.playsoundCheckboxForMenu.isSelected()&&file.exists()){
|
||||
try {
|
||||
// Create an InputStream to the file
|
||||
File base = ForgeProps.getFile(SOUND_BASE);
|
||||
File file = new File(base, filename);
|
||||
// Create an InputStream to the file
|
||||
is = new FileInputStream(file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void play() {
|
||||
if(GuiDisplay3.playsoundCheckboxForMenu.isSelected()&&file.exists()){
|
||||
try {
|
||||
player = new Player(is);
|
||||
PlayerThread pt = new PlayerThread();
|
||||
@@ -37,6 +41,7 @@ public class MP3Player implements NewConstants{
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PlayerThread extends Thread {
|
||||
|
||||
Reference in New Issue
Block a user