Interface PluginContext


  • public interface PluginContext
    A plug-in context is passed to a plug-in when it is initialized, shown, or hidden. It provides information about the context in which the plug-in code is being executed.

    To ease plug-in development, when a script is run directly from a code editor window the script will be provided with a dummy context instance. A dummy context is mostly compatible with a true context, but its getPlugin() and getInstalledPlugin() methods will both return null. Also, all dummy contexts share a single setting namespace, so any plug-in settings that you create may vary depending on whether the script is running from an installed plug-in or is being tested by running it from a script editor.

    Note: The scope and purpose of the plug-in context has changed significantly in Strange Eons 3. Most things that a plug-in context was used for in previous releases, such as looking up the game locale, can now be accessed directly by the plug-in itself. The interface definition has changed accordingly, meaning that older compiled plug-ins will need to be updated. Scripts, however, will be given a context that provides backwards-compatible implementations of most of the 2.x methods if the application is running in compatibility mode.

    Since:
    3.0
    Author:
    Chris Jennings
    See Also:
    Plugin, PluginContextFactory
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALT
      A modifier constant indicating that an Alt key was held down.
      static int COMMAND
      A modifier constant indicating that the Command key (on Apple computers) was held down.
      static int CONTROL
      A modifier constant indicating that a Control or Ctrl key was held down.
      static int CTRL
      A modifier constant indicating that a Control or Ctrl key was held down.
      static int MENU
      A modifier constant indicating that the key used as a menu accelerator key on this platform was held down.
      static int META
      A modifier constant indicating that a Meta key was held down.
      static int SHIFT
      A modifier constant indicating that a Shift key was held down.
    • Field Detail

      • SHIFT

        static final int SHIFT
        A modifier constant indicating that a Shift key was held down.
        See Also:
        Constant Field Values
      • ALT

        static final int ALT
        A modifier constant indicating that an Alt key was held down.
        See Also:
        Constant Field Values
      • CONTROL

        static final int CONTROL
        A modifier constant indicating that a Control or Ctrl key was held down.
        See Also:
        Constant Field Values
      • CTRL

        static final int CTRL
        A modifier constant indicating that a Control or Ctrl key was held down.
        See Also:
        Constant Field Values
      • META

        static final int META
        A modifier constant indicating that a Meta key was held down.
        See Also:
        Constant Field Values
      • COMMAND

        static final int COMMAND
        A modifier constant indicating that the Command key (on Apple computers) was held down.
        See Also:
        Constant Field Values
      • MENU

        static final int MENU
        A modifier constant indicating that the key used as a menu accelerator key on this platform was held down. (For example, it maps to Ctrl on Windows and Command on Mac.)
    • Method Detail

      • getPlugin

        Plugin getPlugin()
        Returns the plug-in instance that this context was created for. Returns null if this is a script running with a dummy context.
        Returns:
        the plug-in instance that this context was passed to
      • isInformationProbe

        boolean isInformationProbe()
        Provides a hint about whether the plug-in should perform optional initialization steps. If this method returns true, then the plug-in is only being initialized to determine its name, version, description, and/or type. The plug-in may use this as a hint that it need only perform enough initialization to provide these services. This instance of the plug-in will never be shown.
        Returns:
        true if the plug-in will only be queried for information
      • getSettings

        Settings getSettings()
        Returns a Settings instance that can be used to read and write user settings using this plug-in's namespace. Any settings that you create through this settings instance will exist in user settings (and hence be saved between application runs), but have its keys transparently decorated with a unique prefix so that this plug-in's settings cannot clash with the main application settings or the settings of other plug-ins.
        Returns:
        a Settings instance that uses this plug-in's namespace
      • getModifiers

        int getModifiers()
        Returns a bit mask representing the modifier keys that were held down when the plug-in was activated. This method is only useful for ACTIVATED plug-ins, and only for the context passed in when the plug-in's Plugin.showPlugin(ca.cgjennings.apps.arkham.plugins.PluginContext, boolean) method is called. In all other cases, it will return 0.

        To use the result of this method, combine the modifiers that you wish to test for using binary or (|) to create a mask value. Then check that the bitwise and (&) of the return value and your mask are equal to your mask:

         // check if both Shift and Ctrl and held down
         mask = PluginContext.SHIFT | PluginContext.CONTROL;
         if( (context.getModifiers() & mask) == mask ) {
             // both keys are down
         }
         

        Obtaining the modifiers held when a plug-in was activated can be used to provide alternate modes of operation for a plug-in. Be aware, however, that the user may assign a keyboard accelerator to the plug-in that conflicts with your interpretation of the modifier values.

        Returns:
        a bit mask of modifier constants
      • getUILocale

        @Deprecated
        default java.util.Locale getUILocale()
        Deprecated.
      • getGameLocale

        @Deprecated
        default java.util.Locale getGameLocale()
        Deprecated.
      • addUIText

        @Deprecated
        default void addUIText​(java.util.Locale locale,
                               java.lang.String resource)
        Deprecated.
      • addGameText

        @Deprecated
        default void addGameText​(java.util.Locale locale,
                                 java.lang.String resource)
        Deprecated.