SettingDialog :

- Image url does not need an additionnal "/" at the start of the path (still work with it though). It to be consistent with the paths used for the asset manager.
- If the image is not found an AssetNotFound exception is thrown.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7517 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent f1361cc9e6
commit 620e339b7c
  1. 72
      engine/src/desktop/com/jme3/system/JmeSystem.java

@ -29,22 +29,19 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jme3.system;
import com.jme3.app.SettingsDialog;
import com.jme3.app.SettingsDialog.SelectionListener;
import com.jme3.asset.AssetManager;
import com.jme3.asset.AssetNotFoundException;
import com.jme3.asset.DesktopAssetManager;
import com.jme3.audio.AudioRenderer;
import com.jme3.util.JmeFormatter;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
@ -57,46 +54,36 @@ public class JmeSystem {
* Microsoft Windows 32 bit
*/
Windows32,
/**
* Microsoft Windows 64 bit
*/
Windows64,
/**
* Linux 32 bit
*/
Linux32,
/**
* Linux 64 bit
*/
Linux64,
/**
* Apple Mac OS X 32 bit
*/
MacOSX32,
/**
* Apple Mac OS X 64 bit
*/
MacOSX64,
/**
* Apple Mac OS X 32 bit PowerPC
*/
MacOSX_PPC32,
/**
* Apple Mac OS X 64 bit PowerPC
*/
MacOSX_PPC64,
}
private static final Logger logger = Logger.getLogger(JmeSystem.class.getName());
private static boolean initialized = false;
private static boolean lowPermissions = false;
@ -121,19 +108,25 @@ public class JmeSystem {
}
public static boolean showSettingsDialog(AppSettings sourceSettings, final boolean loadFromRegistry) {
if (SwingUtilities.isEventDispatchThread())
if (SwingUtilities.isEventDispatchThread()) {
throw new IllegalStateException("Cannot run from EDT");
}
final AppSettings settings = new AppSettings(false);
settings.copyFrom(sourceSettings);
final URL iconUrl = JmeSystem.class.getResource(sourceSettings.getSettingsDialogImage());
String iconPath = sourceSettings.getSettingsDialogImage();
final URL iconUrl = JmeSystem.class.getResource(iconPath.startsWith("/") ? iconPath : "/" + iconPath);
if (iconUrl == null) {
throw new AssetNotFoundException(sourceSettings.getSettingsDialogImage());
}
final AtomicBoolean done = new AtomicBoolean();
final AtomicInteger result = new AtomicInteger();
final Object lock = new Object();
final SelectionListener selectionListener = new SelectionListener() {
public void onSelection(int selection) {
synchronized (lock) {
done.set(true);
@ -143,6 +136,7 @@ public class JmeSystem {
}
};
SwingUtilities.invokeLater(new Runnable() {
public void run() {
synchronized (lock) {
SettingsDialog dialog = new SettingsDialog(settings, iconUrl, loadFromRegistry);
@ -153,12 +147,13 @@ public class JmeSystem {
});
synchronized (lock) {
while (!done.get())
while (!done.get()) {
try {
lock.wait();
} catch (InterruptedException ex) {
}
}
}
sourceSettings.copyFrom(settings);
@ -166,23 +161,24 @@ public class JmeSystem {
}
private static boolean is64Bit(String arch) {
if (arch.equals("x86"))
if (arch.equals("x86")) {
return false;
else if (arch.equals("amd64"))
} else if (arch.equals("amd64")) {
return true;
else if (arch.equals("x86_64"))
} else if (arch.equals("x86_64")) {
return true;
else if (arch.equals("ppc") || arch.equals("PowerPC"))
} else if (arch.equals("ppc") || arch.equals("PowerPC")) {
return false;
else if (arch.equals("ppc64"))
} else if (arch.equals("ppc64")) {
return true;
else if (arch.equals("i386") || arch.equals("i686"))
} else if (arch.equals("i386") || arch.equals("i686")) {
return false;
else if (arch.equals("universal"))
} else if (arch.equals("universal")) {
return false;
else
} else {
throw new UnsupportedOperationException("Unsupported architecture: " + arch);
}
}
public static Platform getPlatform() {
String os = System.getProperty("os.name").toLowerCase();
@ -226,8 +222,8 @@ public class JmeSystem {
} catch (IllegalAccessException ex) {
logger.log(Level.SEVERE, "Failed to create context", ex);
} catch (ClassNotFoundException ex) {
logger.log(Level.SEVERE, "CRITICAL ERROR: Context class is missing!\n" +
"Make sure jme3_lwjgl-ogl is on the classpath.", ex);
logger.log(Level.SEVERE, "CRITICAL ERROR: Context class is missing!\n"
+ "Make sure jme3_lwjgl-ogl is on the classpath.", ex);
}
return null;
@ -253,8 +249,8 @@ public class JmeSystem {
} catch (IllegalAccessException ex) {
logger.log(Level.SEVERE, "Failed to create context", ex);
} catch (ClassNotFoundException ex) {
logger.log(Level.SEVERE, "CRITICAL ERROR: Context class is missing!\n" +
"Make sure jme3_jogl is on the classpath.", ex);
logger.log(Level.SEVERE, "CRITICAL ERROR: Context class is missing!\n"
+ "Make sure jme3_jogl is on the classpath.", ex);
}
return null;
@ -297,8 +293,8 @@ public class JmeSystem {
ctx.setSettings(settings);
} else {
throw new UnsupportedOperationException(
"Unrecognizable renderer specified: "+
settings.getRenderer());
"Unrecognizable renderer specified: "
+ settings.getRenderer());
}
return ctx;
}
@ -313,8 +309,8 @@ public class JmeSystem {
clazz = (Class<? extends AudioRenderer>) Class.forName("com.jme3.audio.joal.JoalAudioRenderer");
} else {
throw new UnsupportedOperationException(
"Unrecognizable audio renderer specified: "+
settings.getAudioRenderer());
"Unrecognizable audio renderer specified: "
+ settings.getAudioRenderer());
}
AudioRenderer ar = clazz.newInstance();
@ -324,30 +320,28 @@ public class JmeSystem {
} catch (IllegalAccessException ex) {
logger.log(Level.SEVERE, "Failed to create context", ex);
} catch (ClassNotFoundException ex) {
logger.log(Level.SEVERE, "CRITICAL ERROR: Audio implementation class is missing!\n" +
"Make sure jme3_lwjgl-oal or jm3_joal is on the classpath.", ex);
logger.log(Level.SEVERE, "CRITICAL ERROR: Audio implementation class is missing!\n"
+ "Make sure jme3_lwjgl-oal or jm3_joal is on the classpath.", ex);
}
return null;
}
public static void initialize(AppSettings settings) {
if (initialized)
if (initialized) {
return;
}
initialized = true;
try {
if (!lowPermissions) {
// can only modify logging settings
// if permissions are available
// JmeFormatter formatter = new JmeFormatter();
// Handler fileHandler = new FileHandler("jme.log");
// fileHandler.setFormatter(formatter);
// Logger.getLogger("").addHandler(fileHandler);
// Handler consoleHandler = new ConsoleHandler();
// consoleHandler.setFormatter(formatter);
// Logger.getLogger("").removeHandler(Logger.getLogger("").getHandlers()[0]);
// Logger.getLogger("").addHandler(consoleHandler);
}

Loading…
Cancel
Save