Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 18-Sep-2019 20:55:54

ARappy
Member
Registered: 15-Aug-2019
Posts: 12

How to customize a plugit to your needs easily

Here is an example with "dialoglist" plugit:

In my project i'm often using the plugit "dialoglist" in "Interface" folder. So to simplify the use of this plugit, I choose to create only one instance of it, and manage it dynamically by just changing the items list it contains at runtime, using its Action "Add element to list".

After adding some items to the dialog by calling its Action "Add element to list" and the user answered to this dialog, you can remove those items by calling the reverse Action "Remove element from list", if you want to use it again with different items, instead of creating a new one (when using it dynamically).

But this is not very convenient because you need to delete all items one by one, and suppose you saved their names in some var.

So i decided to modify this plugit to do it more simply.

By chance (and especially OS3D developpers great skills), OS3D plugit code is in plain text and its structure is very well designed, so it is easily understandable and customizable.

In this case, you can simply add a new action i called "Reset" to this plugit, to empty the item's list completely in one call. This is done simply by adding a few lines in the plugit code:

dialoglist.xml:

   <ACTION name="Reset"/>


cdialoglist.pkg:

    PluginRegisterAction inst "Reset" mkfun6 @cbReset obstr; 
    
    fun cbReset(inst, from, action, param, reply, obstr)=
        set obstr.PDLGL_lList = nil;
    0;;

This take effect after closing dialog and reopen it again, when need to interract again with user.


Of course, this can be a problem to customized the original plugit for just one specific need in a particular project, and although the need to keep compatibility with OS3D next release.

But there is a very simple way to do a copy of the orginal plugit and make a customized one, that will then be completely independant from the original one.


Here is one Method to do it, if it can help some new OS3D users:

For this you just have to change one line in the xml definition file of the plugit called "plugit_name.xml" (for dialoglist it is dialoglist.xml).


1) In windows explorer, make a copy of the plugit folder in a new folder category (in my case i call this type folder "user"). This will create a new category in the plugit list where you can keep all your customized plugit, without interfering with the original ones.


2) Inside this new folder open the file "plugit_name.xml". In this example, it is "dialoglist.xml":

   Then Search the string:

    <PLUGIN name="Dialog List" version="1.0" type="interface">

This line indicate to OS3D the name of the plugit and the type of plugit folder in which it should go (here "Interface")


3) Then You just have to change only this two parameters:

   1) The name of the plugit, because OS3D can't have two plugit with the same name.
 
   2) The type of the plugit.

      In this example:
   
        <PLUGIN name="Dialog List" version="1.0" type="interface">

          becomes:
   
        <PLUGIN name="Dialog Liste" version="1.0" type="user">
       
        (i choose the new name "Dialog Liste" because i'm french, but you can choose anything else)
       
   There is nothing else to change in the code, just this line.
   
    If OS3D is already running, just press F5 on the scene to reload all plugits and see your customized plugit appears in the new category folder "user" you have created (the original one will still be in "Interface"). Here's an example with some others plugit i have already customized:

user
   
When this is done, you can now add in the code of your customized plugit any action or event you need (if they were not present in the original one) without breaking anything to the original plugits.

Last edited by ARappy (18-Sep-2019 21:10:52)

Offline

#2 19-Sep-2019 08:37:51

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,081
Website

Re: How to customize a plugit to your needs easily

Thanks for sharing smile
It will definitely help users to start plugit clones!

Offline

Board footer

Powered by FluxBB