From 31dad59c9f0994cb353d06b0f94989e7e74da7c8 Mon Sep 17 00:00:00 2001 From: kappa1 Date: Sun, 6 Mar 2011 01:34:06 +0000 Subject: [PATCH] AppletLoader: "al_logo" and "al_progress" are now optional parameters, they default to "appletlogo.gif" and "appletprogress.gif". Credit to arielsan for patch. --- applet/advance/appletloader.html | 12 +++--- applet/basic/basicapplet.html | 12 +++--- .../org/lwjgl/util/applet/AppletLoader.java | 37 +++++++++++++------ 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/applet/advance/appletloader.html b/applet/advance/appletloader.html index ce0c405d..52abbcf8 100644 --- a/applet/advance/appletloader.html +++ b/applet/advance/appletloader.html @@ -15,12 +15,6 @@ - - - - - - @@ -50,6 +44,12 @@ + + + + + + diff --git a/applet/basic/basicapplet.html b/applet/basic/basicapplet.html index 08e5c506..ced5ee6a 100644 --- a/applet/basic/basicapplet.html +++ b/applet/basic/basicapplet.html @@ -15,12 +15,6 @@ - - - - - - @@ -50,6 +44,12 @@ + + + + + + diff --git a/src/java/org/lwjgl/util/applet/AppletLoader.java b/src/java/org/lwjgl/util/applet/AppletLoader.java index f5307f73..388ad1d4 100644 --- a/src/java/org/lwjgl/util/applet/AppletLoader.java +++ b/src/java/org/lwjgl/util/applet/AppletLoader.java @@ -99,9 +99,6 @@ import sun.security.util.SecurityConstants; *
  • al_main - [String] Full package and class the applet to instantiate and display when loaded.
  • *
  • al_jars - [String] Comma seperated list of jars to download.
  • *

    - *

  • al_logo - [String Path of of the logo resource to paint while loading.
  • - *
  • al_progressbar - [String] Path of the progressbar resource to paint on top of the logo, width clipped by percentage.
  • - *

    *

  • al_windows - [String] Jar containing native files for windows.
  • *
  • al_linux - [String] Jar containing native files for linux.
  • *
  • al_mac - [String] Jar containing native files for mac.
  • @@ -126,6 +123,9 @@ import sun.security.util.SecurityConstants; *
  • boxbgcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as background. Default: #ffffff.
  • *
  • boxfgcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as foreground. Default: #000000.
  • *

    + *

  • al_logo - [String Path of of the logo resource to paint while loading.Default: "appletlogo.gif".
  • + *
  • al_progressbar - [String] Path of the progressbar resource to paint on top of the logo, width clipped by percentage.Default: "appletprogress.gif".
  • + *

    *

  • lwjgl_arguments -
  • [String] used to pass the hidden LWJGL parameters to LWJGL e.g. ("-Dorg.lwjgl.input.Mouse.allowNegativeMouseCoords=true -Dorg.lwjgl.util.Debug=true"). * *

    @@ -270,7 +270,7 @@ public class AppletLoader extends Applet implements Runnable, AppletStub { setState(STATE_INIT); // sanity check - String[] requiredArgs = {"al_main", "al_logo", "al_progressbar", "al_jars"}; + String[] requiredArgs = {"al_main", "al_jars"}; for ( String requiredArg : requiredArgs ) { if ( getParameter(requiredArg) == null ) { fatalErrorOccured("missing required applet parameter: " + requiredArg, null); @@ -292,13 +292,9 @@ public class AppletLoader extends Applet implements Runnable, AppletStub { setBackground(bgColor); fgColor = getColor("boxfgcolor", Color.black); - // load logos, if value is "" then skip - if (getParameter("al_logo").length() > 0) { - logo = getImage(getParameter("al_logo")); - } - if (getParameter("al_progressbar").length() > 0) { - progressbar = getImage(getParameter("al_progressbar")); - } + // load logos, if value is "" then an image is not loaded + logo = getImage(getStringParameter("al_logo", "appletlogo.gif")); + progressbar = getImage(getStringParameter("al_progressbar", "appletprogress.gif")); // check for lzma support try { @@ -1563,6 +1559,9 @@ public class AppletLoader extends Applet implements Runnable, AppletStub { */ protected Image getImage(String s) { + // if s is "" then don't load an image + if (s.length() == 0) return null; + Image image = null; try { @@ -1688,9 +1687,23 @@ public class AppletLoader extends Applet implements Runnable, AppletStub { return defaultColor; } } + + /** + * Retrieves the String value for the parameter + * @param name Name of parameter + * @param defaultValue default value to return if no such parameter + * @return value of parameter or defaultValue + */ + protected String getStringParameter(String name, String defaultValue) { + String parameter = getParameter(name); + if (parameter != null) { + return parameter; + } + return defaultValue; + } /** - * Retrieves the boolean value for the applet + * Retrieves the boolean value for the parameter * @param name Name of parameter * @param defaultValue default value to return if no such parameter * @return value of parameter or defaultValue