Possible to conditionally load a different skin file if an addon is enabled?
#1
I am wondering it it is possible, either via skin code or via addon code, to conditionally load a particular skin file, is a particular (weather) addon is in use.  Basically I want to intercept the weather window if the addon is enabled, and load different stuff into it.

I.e. when weather is opened:

if System.AddonIsEnabled(blah.blah) -> load CustomWeather.xml
else -> load MyWeather.xml

The best solution I have found is to replace MyWeather.xml with something like this:

Code:

<?xml version="1.0" encoding="UTF-8"?>
<window>
  <include condition="String.IsEqual(Weather.Plugin(),weather.ozweather)" file="OzWeatherMyWeather.xml">ozweather</include>
  <include condition="!String.IsEqual(Weather.Plugin(),weather.ozweather)" file="MyWeather_ConfluenceStandard.xml">normal_weather</include>
</window>

...but ideally I'd like an unmolested MyWeather.xml to be present, or at most say a line in that that basically expresses 'if addon -> do this, otherwise carry on with the default you find here'

I'm open to both skin code solutions and addon solutions, if anybody has any ideas as to how this might work!
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#2
Only just seen this. If you're still looking for an answer then I would think onload would work for this in MyWeather.xml, for an Estuary example see https://github.com/xbmc/xbmc/blob/c52e76...ion.xml#L5

Then make sure OzWeatherMyWeather.xml is a custom window with a window id number, so if addon is enabled you can used ActivateWindow e.g. ActivateWindow(1120) where 1120 is window id for OzWeatherMyWeather.xml
Reply
#3
@jjd-uk Interesting - thanks! 

I have given this a try, and found that I actually think it's better this way:
Code:
<onload condition="String.IsEqual(Weather.Plugin(),weather.ozweather)">ReplaceWindow(1190)</onload>

...as this seems to keep the history intact (i.e. otherwise I can't seem to exit from my custom weather window, if I use ActivateWindow it just effectively reload when it goes back to the standard weather and hits the onload again...).

However, there's one distinctly noticeable disadvantage (vs. the way I had it, above) - one sees a flash of the standard weather screen first, which is rather unsightly.  Not sure if that can be solved, and not sure I can comfortably live with that.

But the custom window approach got me thinking, and I guess I can just modify the Home.xml, such that it skips the standard window entirely.

Code:

<onclick condition="!String.IsEmpty(Weather.Plugin) + !String.IsEqual(Weather.Plugin(),weather.ozweather)">ActivateWindow(Weather)</onclick>
<onclick condition="!String.IsEmpty(Weather.Plugin) + String.IsEqual(Weather.Plugin(),weather.ozweather)">ActivateWindow(1190)</onclick>
<onclick condition="String.IsEmpty(Weather.Plugin)">ActivateWindow(servicesettings,weather)</onclick>

Or alternatively just find and replace all ActivateWindow(Weather) and replace with ActivateWindow(1190) I guess.  That lets me leave the MyWeather.xml as it is, and is probably the smallest change I can make to use the custom weather screen.

Many thanks for the help!
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#4
You're right, modifying the onclick actions to contain the conditionals is the more elegant way leaving MyWeather.xml completely unchanged. I was so fixated on doing a minimal MyWeather.xml change I hadn't considered that.
Reply
#5
Yep that is the same for me...my mind gets stuck in a particular groove and can't see the wood for the trees.  Thanks again!
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#6
Unfortunately I hit a big stumbling block here - using a custom window, I can't get my buttons to work for: Weather Refresh, Weather Next Location, Weather Previous Location.  They call the appropriate builtins but nothing happens as I think Kodi only sends messages to the weather window.  I can't work out another way of triggering the functionality I want (well, without a bunch of extra Python anyway - and maintaining that will be worse than dealing with a more modified MyWeather.xml in the end.

Frustrating, but unfortunately this seems to be one of those instances where the GUI is pretty tied to the specific implementation...
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#7
I think the only way you're going to achieve this is by using the include option.

eg

xml:
<?xml version="1.0" encoding="UTF-8"?>
<window>
<include condition="String.IsEqual(Weather.Plugin(),weather.ozweather)">Include_ozweather</include>
<include condition="!String.IsEqual(Weather.Plugin(),weather.ozweather)">Include_normal_weather</include>
</window>

Then make an include (eg Include_Weather_Layout) with the 2 includes for each layout.
Reply
#8
Yep that's exactly what I have done, indeed...Well, I keep the two includes in separate files but basically the same.

A shame as the custom window approach was cleaner but not that big a deal really.
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply

Logout Mark Read Team Forum Stats Members Help
Possible to conditionally load a different skin file if an addon is enabled?0