Explanation of some code please.

Everything regarding the Power-Grid SDK can be asked and discussed here.

Explanation of some code please.

Postby Vora » 12. May 2015, 21:32

I've been rooting through some different plugins and the SDK again and I was wondering if someone could give me a steer on what some of the code commands actually do.

1) SkinIdx:0,

I noticed this in the Grids.JSON files. My question is what does this set?

I haven't noticed any need for it so I removed it from my plugin and it works fine.

2) In the SDK I noticed a few TODO points. This one is in the advanced plugin folder plugin.json. In the Layouts section is mentions skin nesting.

I don't suppose this is anything like layers in photoshop is it?

I could be way off as this is still new to me and I'm still learning. I am trying to see if there is a way to stack up pngs and use one as a background and one as the button. Therefore I could change the background using another command while keeping the button Gfx the same.

Thanks.
Vora
 
Posts: 12
Joined: 9. May 2015, 18:46

Re: Explanation of some code please.

Postby Addihash » 13. May 2015, 09:23

1) SkinIdx is just an index for the skin, if you dont use it anywhere else you don't need it.
2) It is exatly that! maybe take a look at the S.K.I.L.L. plugin, I think there we do something like that.
Addihash
Administrator
 
Posts: 232
Joined: 2. Feb 2015, 14:35

Re: Explanation of some code please.

Postby Vora » 13. May 2015, 09:53

Addihash wrote:1) SkinIdx is just an index for the skin, if you dont use it anywhere else you don't need it.
2) It is exatly that! maybe take a look at the S.K.I.L.L. plugin, I think there we do something like that.


Thx for the info, I'll dig into the S.K.I.L.L. plugin after work today.
Vora
 
Posts: 12
Joined: 9. May 2015, 18:46

Re: Explanation of some code please.

Postby Addihash » 13. May 2015, 09:55

Also the lever in the toggle plugin uses nesting layouts in one skin. This should be similar to nestim skins.
Addihash
Administrator
 
Posts: 232
Joined: 2. Feb 2015, 14:35

Re: Explanation of some code please.

Postby Vora » 13. May 2015, 17:58

I've just looked through the S.K.I.L.L. plugin and just to check that I'm interpreting it right.

The first top Skin (Layer) in the Layout [] (Name:"SkillSkin",) is the first one to be loaded and all the other skin entries that follow within the same Layout [] are placed on top based on there position dictated by the Left: "" and Right: "" entries.

Is that correct?
Vora
 
Posts: 12
Joined: 9. May 2015, 18:46

Re: Explanation of some code please.

Postby Addihash » 15. May 2015, 10:15

The Top Skin "SkillSkin" is the only skin used by the control (see at the bottom of the plugin.json under controls).
A Skin consists of one or more layouts, these are defined in Layouts[].
A Layout can have different types such as Gfx (like "BG") and even be a Skin itself(like all the other layouts in the "SkillSkin" skin)!
These other skins are defined below and also conist of different layouts (fortunately none of the type skin ;) )

In the "SkillSkin" skin the layouts are loaded from top to bottom. So the first layout to be loaded is "BG" the next one is "Header" and the last one is "BtnMicMute".
The Left: and Top: entries are defining how much pixels from the left/top of this skin that layout should be moved ((0|0) is the top left corner).
Addihash
Administrator
 
Posts: 232
Joined: 2. Feb 2015, 14:35

Re: Explanation of some code please.

Postby Vora » 15. May 2015, 11:12

Addihash,

Thanks for the update on how this code works. I have been playing with it to "layer" Gfx and it works nicely.

My next task was make a button to change them to suit the situation.

I'm using my Star Citizen as the test and I have inadvertently broken my toggle buttons, now they don't work. :oops:

I think I'll dial it back to the working plugin and make it simplier.

Thanks again.
Vora
 
Posts: 12
Joined: 9. May 2015, 18:46

Re: Explanation of some code please.

Postby Vora » 16. May 2015, 15:37

Next question!

How does the .setVisible command work?

I'm positive I made it work before but now nothing happens.

I have a Gfx in a skin within the plugin.json

In my .qs file I have a function the simply toggles a flag and depending on that flag status set a Gfx visibility to true or false, but it does not work.

The function works because with no other code in it except the flag toggle it affects the other parts of the grid that I want it to (deactivates buttons). Therefore I now the function is valid and declared correctly in the plugin.json.


The code in the function looks like this:

Code: Select all
function GVis(pxSkin)         
{
   if(flag_Vis < 0)
   {
      this.FindLayout("<Layout_Name>").setVisible(false);
   }
   if(flag_Vis > 0)
   {
      this.FindLayout("<Layout_Name>").setVisible(true);
      
   }
   
   flag_Vis = flag_Vis*(-1);


flag_Vis is declared globally and set to -1 on startup.

I have even used the code from the S.K.I.L.L. Plugin where a local var is used to store the layout and then set the visibility to true or false and that did work either.

I assume it is to do with the skin set up in the plugin.json. I have tried to changed visibility on a simple skin (one layout, one Gfx), nested skins (Multiple Layouts, One Gfx in each).

Thank you.
Vora
 
Posts: 12
Joined: 9. May 2015, 18:46

Re: Explanation of some code please.

Postby Addihash » 18. May 2015, 13:30

Is that function called from a skin containing the Layout you want to set visible? If not this can not find the Layout. If you would post the .qs and the plugin.json I could take a closer look.
Addihash
Administrator
 
Posts: 232
Joined: 2. Feb 2015, 14:35

Re: Explanation of some code please.

Postby Vora » 19. May 2015, 00:21

Addihash wrote:Is that function called from a skin containing the Layout you want to set visible? If not this can not find the Layout. If you would post the .qs and the plugin.json I could take a closer look.


Thanks Addihash, its fine now and I figured it out. In fact the grid in question is in with you guys under review for the store.
Vora
 
Posts: 12
Joined: 9. May 2015, 18:46

Next

Return to Power-Grid SDK

Who is online

Users browsing this forum: No registered users and 1 guest