For Applets, the named properties are the applet parameters. */ public static String getAppProperty(String name) { return getThisAppContext().getAppProperty(name); } /** Gets a named TalkBack field. */ public static String getTalkBackField(String name) { return getThisAppContext().getTalkBackField(name); } /** Sets a new TalkBack field. If the named field already exists, it is replaced. */ public static void setTalkBackField(String name, String value) { getThisAppContext().setTalkBackField(name, value); } public static void setTalkBackField(String name, Throwable t) { getThisAppContext().setTalkBackField(name, t); } public static void clearTalkBackFields() { getThisAppContext().clearTalkBackFields(); } /** Uploads talkback data to an external URL using the POST (multipart form) method.
The upload starts immediately. Use {@link Upload#isCompleted()} to check if the upload is finished. @param talkbackPath the path on the applet's server. @return null if talkbackPath is an invalid URL. */ public static Upload uploadTalkBackFields(String talkbackPath) { return getThisAppContext().uploadTalkBackFields(talkbackPath); } /** Determines if this app is running from one of the specified hosts. */ public static boolean isValidHost(String[] validHosts) { return getThisAppContext().isValidHost(validHosts); } public static void setConsoleOutputEnabled(boolean consoleOut) { getThisAppContext().setConsoleOutputEnabled(consoleOut); } public static boolean isConsoleOutputEnabled() { return getThisAppContext().isConsoleOutputEnabled(); } public static String getLogText() { return getThisAppContext().getLogText(); } public static void clearLog() { getThisAppContext().clearLog(); } /** Prints a the string representation of an object to the log. */ public static void print(Object object) { if (object == null) { print("null"); } else { print(object.toString()); } } /** Prints the string representation of a boolean to the log. */ public static void print(boolean b) { print(Boolean.toString(b)); } /** Prints the string representation of an integer to the log. */ public static void print(int n) { print(Integer.toString(n)); } /** Prints the string representation of a float to the log. */ public static void print(float n) { print(Float.toString(n)); } /** Prints the string representation of a double to the log. */ public static void print(double n) { print(Double.toString(n)); } /** Prints a line of text to the log. */ public static void print(String statement) { AppContext context = getThisAppContext(); if (context != null) { context.print(statement); } else if (Build.DEBUG) { System.out.println(statement); } } /** Prints a line of text and a Throwable's stack trace to the log. */ public static void print(String statement, Throwable t) { AppContext context = getThisAppContext(); if (context != null) { context.print(statement, t); } else if (Build.DEBUG) { System.out.println(statement); t.printStackTrace(); } } /** Prints the amount of current memory usage and the change in memory usage since the last call to this method. System.gc() is called before querying the amount of free memory. */ public static void printMemory(String statement) { AppContext context = getThisAppContext(); if (context != null) { context.printMemory(statement); } else if (Build.DEBUG) { System.out.println(statement); } } /** Attempts to store persistant user data to the local machine.
For applets, each key is stored in a Base64-encoded cookie. The user's web browser must have LiveConnect, JavaScript, and cookies enabled. Web browsers may have the following limitations for cookies (according to RFC 2109 section 6.3):
Cookies may "expire" (become unaccessable) after an amount of time or may be deleted at any time by the browser.
Base64 encoding increases the data size by 33%. In summary, for Applets, try to use as few keys as possible, and keep the data length to a minimum.
Example: CoreSystem.putUserData("MyGame", data); @see #getUserData(String) @see #removeUserData(String) */ public static void putUserData(String key, byte[] data) { getThisAppContext().putUserData(key, data); } /** Attempts to get persistant user data from the local machine. @see #putUserData(String, byte[]) @see #removeUserData(String) */ public static byte[] getUserData(String key) { return getThisAppContext().getUserData(key); } /** Attempts to remove persistant user data from the local machine. @see #putUserData(String, byte[]) @see #getUserData(String) */ public static void removeUserData(String key) { getThisAppContext().removeUserData(key); } public static URL getBaseURL() { return getThisAppContext().getBaseURL(); } public static String getLocaleLanguage() { return getThisAppContext().getLocaleLanguage(); } public static String getLocaleCountry() { return getThisAppContext().getLocaleCountry(); } public static void showDocument(String url) { showDocument(url, "_top"); } public static void showDocument(String url, String target) { getThisAppContext().showDocument(url, target); } // // Shorcut methods to Platform // /** Returns the current value of the system timer in milliseconds. */ public static long getTimeMillis() { return platform.getTimeMillis(); } /** Returns the current value of the system timer in microseconds. */ public static long getTimeMicros() { return platform.getTimeMicros(); } /** Checks if the platform has access to the native operating system clipboard. If not, an internal clipboard is used. */ public static boolean isNativeClipboard() { return platform.isNativeClipboard(); } /** Returns the text currently in the clipboard. Returns an empty string if there is no text in the clipboard. If the native clipboard is not accessible (typical in Applet environments), an application clipboard is used. */ public static String getClipboardText() { return platform.getClipboardText(); } /** Sets the text in the clipboard. If the native clipboard is not accessible (typical in Applet environments), an application clipboard is used. */ public static void setClipboardText(String text) { platform.setClipboardText(text); } /** Returns true if this platform is hosted in a browser (Applets). */ public static boolean isBrowserHosted() { return platform.isBrowserHosted(); } /** Returns the name of the web browser, or null if the browser name could not be determined. */ public static String getBrowserName() { return platform.getBrowserName(); } /** Returns the version of the web browser, or null if the browser version could not be determined. */ public static String getBrowserVersion() { return platform.getBrowserVersion(); } // // Sound methods // /** Gets the audio mute setting for this application. @return true if the application is muted (silent), false otherwise */ public static boolean isMute() { return getThisAppContext().isMute(); } /** Sets the audio mute setting for this application. This setting takes effect immediately for all calls to {@link pulpcore.sound.Sound#play()}.
Due to buffering, if any sounds are playing when this setting is changed, there may be a slight delay before the new setting takes affect on those playing sounds. @param mute true to mute the application, false otherwise */ public static void setMute(boolean mute) { getThisAppContext().setMute(mute); } /** Gets the master sound volume mute setting for this application. @return the master sound volume, from 0 (silent) to 1 (full). */ public static double getSoundVolume() { return getThisAppContext().getSoundVolume(); } /** Sets the master sound volume mute setting for this application. This setting takes effect immediately for all calls to {@link pulpcore.sound.Sound#play()}.
Due to buffering, if any sounds are playing when this setting is changed, there may be a slight delay before the new setting takes affect on those playing sounds. @param volume the master sound volume, from 0 (silent) to 1 (full). */ public static void setSoundVolume(double volume) { getThisAppContext().setSoundVolume(volume); } /** Returns true if the user's system can play sound.
As of PulpCore 0.11.4, the sound engine is loaded asynchronously. While the engine is loading, this method returns true, but may later return false if the initialization fails. */ public static boolean isSoundEngineAvailable() { SoundEngine soundEngine = getPlatform().getSoundEngine(); int state = SoundEngine.STATE_FAILURE; if (soundEngine != null) { state = soundEngine.getState(); } return (state == SoundEngine.STATE_INIT || state == SoundEngine.STATE_READY); } /** Gets the number of sounds currently playing in the sound engine. */ public static int getNumSoundsPlaying() { // Don't create the sound engine if it's not already created if (!getPlatform().isSoundEngineCreated()) { return 0; } SoundEngine soundEngine = getPlatform().getSoundEngine(); if (soundEngine == null) { return 0; } else { return soundEngine.getNumSoundsPlaying(); } } /** Gets the maximum number of sounds that can be played simultaneously. */ public static int getMaxSimultaneousSounds() { SoundEngine soundEngine = getPlatform().getSoundEngine(); if (soundEngine == null) { return 0; } else { return soundEngine.getMaxSimultaneousSounds(); } } }