Check if skin is loaded? (1 Viewer)

GetWell

Portal Pro
October 4, 2006
205
32
Home Country
Denmark Denmark
Hi,

Is there a way for checking if a skin is loaded?

The scenario are: a users changes skin from a supported skin to a unsupported, and then my plugin will fail because the controls isn't there anymore.
I will then disable my plugin instead of crash.

My plugin is an overlay
 

DieBagger

Retired Team Member
  • Premium Supporter
  • September 11, 2007
    2,516
    1,276
    40
    Austria
    Home Country
    Austria Austria
    Hi,

    Is there a way for checking if a skin is loaded?

    The scenario are: a users changes skin from a supported skin to a unsupported, and then my plugin will fail because the controls isn't there anymore.
    I will then disable my plugin instead of crash.

    My plugin is an overlay

    You can just check the control for null (after Init).

    Code:
    [SkinControlAttribute(1)]
    protected GUIButtonControl btnMyButton = null;
    
    private bool CheckIfLoaded()
    {
       return btnMyButton != null;
    }
     

    GetWell

    Portal Pro
    October 4, 2006
    205
    32
    Home Country
    Denmark Denmark
    will btnMyButton be set back to null when shifting from supported skin back to unsupported skin?
     

    GetWell

    Portal Pro
    October 4, 2006
    205
    32
    Home Country
    Denmark Denmark
    hmm I am seeing two different behaviors:

    1. Starting with a unsupported skin, the plugin don't work at all, and is not coming up after changing to a supported skin
    2. Starting with a supported skin, the plugin starts well. Shifting to unsupported, where I get an error

    that tells me that Init() only gets called once, which makes sense.. but which method gets called every time the skin is changed?
     

    DieBagger

    Retired Team Member
  • Premium Supporter
  • September 11, 2007
    2,516
    1,276
    40
    Austria
    Home Country
    Austria Austria
    hmm I am seeing two different behaviors:

    1. Starting with a unsupported skin, the plugin don't work at all, and is not coming up after changing to a supported skin
    2. Starting with a supported skin, the plugin starts well. Shifting to unsupported, where I get an error

    that tells me that Init() only gets called once, which makes sense.. but which method gets called every time the skin is changed?

    I talked with a few guys and it seems that even the big plugins (mp-tvseries, mopi) don't specially handle this type of situation. I also looked at the sourcecode and there is no event thrown after a skin is changed. You can check

    Code:
    GUIGraphicsContext.Skin

    to see if the skin has changed.
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,755
    7,200
    Sydney
    Home Country
    Australia Australia
    You can listen to Skin Changes and then Re-Init.

    e.g. In TVSeries we re-load skin settings based on new skin that gets loaded. Basically you store the current skin, and if user exits settings window you can check if currentskin == previousskin. I think there is also some ACTIONS you can listen to as well.
     

    Users who are viewing this thread

    Top Bottom