[Plug-in] Plug-in Central: Common access to plug-in user interface (proposal and implementation)

    • [Plug-in] Plug-in Central: Common access to plug-in user interface (proposal and implementation)

      A plug-in which displays a menu of installed (and conforming!) plug-ins to access their GUI in a simple and constant way.

      No need to remember the command(s) of each plug-in! Just the command to call the Central up.

      Version 0.2.0:

      - New to 0.2.0:

      *) Adapted to the latest updates to RWGui.

      -Features:

      *) GUI-only: everything is done via a GUI (of course!).

      *) There is only one chat command (default /pc, but it can be configured in the plug-in settings.properties) which displays, in alphabetical order, a list of all installed plug-ins which conform to a simple API:


      *) The plug-in looked for can be selected with a mouse click and its GUI will be displayed.
      ____________________

      Important - Important - Important - Important:

      In order to work, the plug-in requires the RWGui back-end plug-in ver. 0.5.0 available in this thread.
      ____________________

      - Commands

      There is only one command: /pc (configurable in the plug-in settings.properties) which shows the above main menu.

      Installation

      *) Extract the files in the ZIP placing the whole plugincentral folder into the plugins folder of RW (if the plugins folder does not exist, just create one). The resulting hierarchy shall be:

      Quellcode

      1. ── RisingWorld
      2. ├── plugins
      3. │ ├── plugincentral
      4. │ │ ├── locale
      5. │ │ ├── plugincentral.jar
      6. │ │ └── settings. properties

      *) If it is not already installed, the GUI plug-in available in this thread shall also be installed.

      Making my plug-in to appear in Plug-in Central list

      Only two rather simple methods have to be added to a plug-in to make it compatible the Plug-in Central:

      public String getPublicName() which returns a (constant) string with a human readable name for your plug-in.

      public void mainGui(Player player) which displays the main entry point for your plug-in to player (in practice, this method does what your plug-in already does in response to some specific player command).

      Sample code to add to a plug-in to conform to the proposal:

      Java-Quellcode

      1. // names and signatures of these two methods are important;
      2. // what they actually do, is largely left to the individual plug-in
      3. public String getPublicName()
      4. {
      5. return "My Plug-in Name";
      6. }
      7. public void mainGui(Player player)
      8. {
      9. // create and display the GUI here as needed
      10. // according to whatever the plug-in already does:
      11. GuiPanel myPanel = new GuiPanel(...);
      12. ...
      13. player.addGuiElement(myPanel);
      14. // or any other way to tell something to the player
      15. player.sendTextMessage("Help Summary for My Plug-in");
      16. ...
      17. }
      Alles anzeigen

      The existing chat command to access the plug-in can remain and use the same code:

      Quellcode

      1. @EventMethod
      2. public void onPlayerCommand(PlayerCommandEvent event)
      3. {
      4. String[] cmd = event.getCommand().split(" ");
      5. if (cmd[0].equals("/myPluginCommand") )
      6. mainGui(event.getPlayer());
      7. }

      Notes:
      *) The code does not require any additional logic to be implemented in the plug-in (it should already have code to display some kind of user interface to the player)

      *) It is not necessary to remove anything from existing plug-ins: all existing features can remain and work as previously.

      *) It is not necessarily limited to GUI-based plug-ins; also chat-based plug-ins can benefit from it: there is no limitation on what the main user interface method can do, each plug-in decides: it might be a super-dooper completely GUI panel, it might be just a summary of chat commands in the chat itself or anything in between.

      If anybody has ideas for improvement, please post them here!

      Open points and known issues

      *) None at the moment, but bugs may well exist! I did my best but foreseeing all the possible use cases and contexts is hard. Post here bug reports, with specific steps to replicate the issues and I'll try to correct them.

      I really need steps or instructions to replicate the problem on my PC or I cannot fix it!
      Dateien
      __________
      My plug-ins: Planks 'n Beams, GPS, UPS, Weather control, Plugin Central, RWGui (GUI back-end), Bank (Money back end)

      Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von Miwarre ()

    • Benutzer online 1

      1 Besucher