mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +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() {
|
private void addMenu() {
|
||||||
Object[] obj = {
|
Object[] obj = {
|
||||||
HUMAN_GRAVEYARD_ACTION, HUMAN_REMOVED_ACTION, HUMAN_FLASHBACK_ACTION, COMPUTER_GRAVEYARD_ACTION,
|
HUMAN_GRAVEYARD_ACTION, HUMAN_REMOVED_ACTION, HUMAN_FLASHBACK_ACTION, COMPUTER_GRAVEYARD_ACTION,
|
||||||
COMPUTER_REMOVED_ACTION, GuiDisplay3.eotCheckboxForMenu, new JSeparator(),
|
COMPUTER_REMOVED_ACTION, new JSeparator(), GuiDisplay3.eotCheckboxForMenu, GuiDisplay3.playsoundCheckboxForMenu, new JSeparator(),
|
||||||
ErrorViewer.ALL_THREADS_ACTION, new JSeparator(), CONCEDE_ACTION};
|
ErrorViewer.ALL_THREADS_ACTION, CONCEDE_ACTION};
|
||||||
|
|
||||||
JMenu gameMenu = new JMenu(ForgeProps.getLocalized(MENU_BAR.MENU.TITLE));
|
JMenu gameMenu = new JMenu(ForgeProps.getLocalized(MENU_BAR.MENU.TITLE));
|
||||||
for(Object o:obj) {
|
for(Object o:obj) {
|
||||||
@@ -1151,6 +1151,7 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static JCheckBoxMenuItem eotCheckboxForMenu = new JCheckBoxMenuItem("Stop at End of Turn", false);
|
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();
|
MultiSplitPane pane = new MultiSplitPane();
|
||||||
JButton cancelButton = new JButton();
|
JButton cancelButton = new JButton();
|
||||||
|
|||||||
@@ -16,20 +16,24 @@ public class MP3Player implements NewConstants{
|
|||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private InputStream is;
|
private InputStream is;
|
||||||
|
private File file;
|
||||||
|
|
||||||
/** Creates a new instance of MP3Player */
|
/** Creates a new instance of MP3Player */
|
||||||
public MP3Player(String filename) {
|
public MP3Player(String filename) {
|
||||||
|
File base = ForgeProps.getFile(SOUND_BASE);
|
||||||
|
file = new File(base, filename);
|
||||||
|
if(GuiDisplay3.playsoundCheckboxForMenu.isSelected()&&file.exists()){
|
||||||
try {
|
try {
|
||||||
// Create an InputStream to the file
|
// Create an InputStream to the file
|
||||||
File base = ForgeProps.getFile(SOUND_BASE);
|
|
||||||
File file = new File(base, filename);
|
|
||||||
is = new FileInputStream(file);
|
is = new FileInputStream(file);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void play() {
|
public void play() {
|
||||||
|
if(GuiDisplay3.playsoundCheckboxForMenu.isSelected()&&file.exists()){
|
||||||
try {
|
try {
|
||||||
player = new Player(is);
|
player = new Player(is);
|
||||||
PlayerThread pt = new PlayerThread();
|
PlayerThread pt = new PlayerThread();
|
||||||
@@ -38,6 +42,7 @@ public class MP3Player implements NewConstants{
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class PlayerThread extends Thread {
|
class PlayerThread extends Thread {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|||||||
Reference in New Issue
Block a user