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

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