Installing Addons from a button...

Discussion and development of skins for XBMC4XBOX
User avatar
byron
Posts: 582
Joined: Wed Jul 04, 2012 9:26 pm
Location: Illinois
Has thanked: 27 times
Been thanked: 96 times

Installing Addons from a button...

Post by byron »

I'm currently in the middle of revamping the OSD icons and OSD windows for a skin, and found that I'm able to install XBMC Subtitles from a button by first going into a4x installer, navigating to the addon, saving the url to my favourites (specifically just as a reference for coding purposes) and then using that link as an <onclick> function for the subtitles button. What I want to do is have two buttons --- one for when the addon is installed (to run it), and one for when it isn't (to install it) --- hidden respectively.

For instance, mainline would be easy via:

Code: Select all

<visible>System.HasAddon(script.xbmc.subtitles)</visible>
and then the two buttons (each with different functions) could toggle visibility based on whether or not the addon is installed. Basically just trying to make it automatic for someone who wants to use subs...so can any of you brilliant thinkers out there figure out a way to prove that the system has said addon installed (or not installed) that's able to be used via conditional visibility?
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Installing Addons from a button...

Post by Dan Dar3 »

Or, maybe we could try to add System.HasAddon() to XBMC4Xbox code - had a quick look and although the internal code might not be the same (mainline seem to have an AddonDatabase), maybe we could hack something together to do what you need now and later on can be taken further by Buzz to the full addon system. I'll try some code changes locally and then submit them with a ticket to Buzz for review. Will let you know when I have a build for some intermediary testing if you are willing.
User avatar
byron
Posts: 582
Joined: Wed Jul 04, 2012 9:26 pm
Location: Illinois
Has thanked: 27 times
Been thanked: 96 times

Re: Installing Addons from a button...

Post by byron »

Nice...more than willing to try it out when it's built. Thanks buddy, much appreciated :)
User avatar
Dom DXecutioner
Posts: 585
Joined: Thu Jul 05, 2012 11:59 pm
Location: California
Has thanked: 249 times
Been thanked: 219 times
Contact:

Re: Installing Addons from a button...

Post by Dom DXecutioner »

@Dan,

Sounds like it's a matter of:

- adding System.HasAddon(foo) to the built-in functions
- check (recursively) the plugins and scripts folders for the addon.xml
- open the addon.xml and check the id tag for the supplied title
- if found, return true, otherwise false

or something like that... tho i don't think that install option should be call from this function, but you know best; if anyone can do it, you can :D
Image
User avatar
byron
Posts: 582
Joined: Wed Jul 04, 2012 9:26 pm
Location: Illinois
Has thanked: 27 times
Been thanked: 96 times

Re: Installing Addons from a button...

Post by byron »

@ dom...it shouldn't be a function, it should be a visible condition (at least for what I'm suggesting). If said add-on is installed, the button for running it would be visible, and if said add-on isn't installed then the other button for installing it is (based on the conditional visibility of System.HasAddon (foo)).
User avatar
Dom DXecutioner
Posts: 585
Joined: Thu Jul 05, 2012 11:59 pm
Location: California
Has thanked: 249 times
Been thanked: 219 times
Contact:

Re: Installing Addons from a button...

Post by Dom DXecutioner »

Agreed!
Image
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Installing Addons from a button...

Post by Dan Dar3 »

Sorry, I thought I would be finishing it today, but something else got in the way - will report back in a couple of days.

For scripts, I'll need to look into how the installer plugin deploys it, but if say using a "script.xbmc.subtitles" addon id for now it will look for Q:\scripts\XBMC Subtitles or whatever folder it gets deploys it to; similar for plugins. Later on when XBMC4Xbox gets full support for addons it will get its internals rewritten to look into its internal database and all that.
User avatar
byron
Posts: 582
Joined: Wed Jul 04, 2012 9:26 pm
Location: Illinois
Has thanked: 27 times
Been thanked: 96 times

Re: Installing Addons from a button...

Post by byron »

No need for apologies friend...you're doing the project a service in your free time. I can't speak for everyone obviously, but I for one sure appreciate what your doing so just take your time. I've figured out ways that this feature can get rid of a decent amount of code in my rapier mod, and also will make custom home menu items possible such as a YouTube menu item that is only visible when the add-on gets installed etc...looking forward to playing around with it :)
User avatar
byron
Posts: 582
Joined: Wed Jul 04, 2012 9:26 pm
Location: Illinois
Has thanked: 27 times
Been thanked: 96 times

Re: Installing Addons from a button...

Post by byron »

Dan Dar3 wrote:For scripts, I'll need to look into how the installer plugin deploys it, but if say using a "script.xbmc.subtitles" addon id for now it will look for Q:\scripts\XBMC Subtitles or whatever folder it gets deploys it to; similar for plugins.
So just out of curiosity - since you're already toying with things - how difficult would it be to implement the function

Code: Select all

Skin.SetAddon(string,type)
Would it be just a matter of pointing xbmc to the plugin folder in the same manner to set the string? I can look into this once you finish up with what you're doing so I can see what you've done and have something to start with...my xml skills with the program are good, but my cpp abilities are terrible.
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Installing Addons from a button...

Post by Dan Dar3 »

One step at a time :-) it's baby steps for me too, although I might look brave here :-)
User avatar
byron
Posts: 582
Joined: Wed Jul 04, 2012 9:26 pm
Location: Illinois
Has thanked: 27 times
Been thanked: 96 times

Re: Installing Addons from a button...

Post by byron »

Untitled.png
Untitled.png (168.09 KiB) Viewed 5482 times
User avatar
Dom DXecutioner
Posts: 585
Joined: Thu Jul 05, 2012 11:59 pm
Location: California
Has thanked: 249 times
Been thanked: 219 times
Contact:

Re: Installing Addons from a button...

Post by Dom DXecutioner »

As an alternative, to set shortcuts, you can use the script at the following link: http://www.xbmc4xbox.org.uk/forum/viewt ... 525#p20274
Image
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Installing Addons from a button...

Post by Dan Dar3 »

Just to say I'm back and working on this next.
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Installing Addons from a button...

Post by Dan Dar3 »

I had no idea what was I getting myself into, should see the bumps on my head :-)

I think I got something working though, I've created a new ticket and PMed you with a test build.
http://redmine.exotica.org.uk/issues/312

See the ticket and the script attached to it to get an idea how to use it - it's limited only to scripts really, but other things like "special://xbmc/plugins/programs/Addons4Xbox Installer" might just works as well. It doesn't fully support addon ids really, Dom you are right, it should go through the addon.xml files recursively and parse them but I thought that would be too expensive, depending on how many addons you would have in each category, especially if used with a skin.

Let me know how it goes or wait for Buzz to approve it.
User avatar
byron
Posts: 582
Joined: Wed Jul 04, 2012 9:26 pm
Location: Illinois
Has thanked: 27 times
Been thanked: 96 times

Re: Installing Addons from a button...

Post by byron »

Hey man...sorry for the delay in responding
I had no idea what was I getting myself into, should see the bumps on my head :-)
At least you got it to compile...and also to work btw ;) Here's a debug (first with the "missing script button" and then the "installed script button" with above conditions) of your work in action. Worked without a hitch - well almost - 64mb ram made it a bit choppy but I'll see if I can't sort that out with some skinning trickery.

http://xbmclogs.com/show.php?id=257446

I've been on vacation, so that's the reason for the delay...didn't want you thinking I had blown this off. It was nice of you to take your free time and turn it into something for all of us. I know when I work on something and don't get a response after a "release" I start to get anxious and wonder why nobody says anything. Thanks again, and I'll do some more testing on other things besides this script (XBMC subtitles) to see what I can get away with.

Also - I'm not sure what the script you included is even for as I just took the default.xbe and replaced the old one in different build and all worked without the script (?).
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Installing Addons from a button...

Post by Dan Dar3 »

Thanks Byron, I appreciate it - I did imagine though that people are in usually in holidays about now (in fact going myself in about two weeks), and I had something else to work on.

The script was meant for a quick test, it was useful for me during development and should be useful for testing things like these - the boolean conditions logic is shared between skins and scripts, so obviously it was easier for me to run that script instead of navigating though a skin to validate the logic. You can simply copy into Q:\scripts and then run it from Programs > Scripts, and you get the output into Q:\xbmc.log. Try it, might help you get an idea how you can test back end logic before you try to use it in your skins.
User avatar
byron
Posts: 582
Joined: Wed Jul 04, 2012 9:26 pm
Location: Illinois
Has thanked: 27 times
Been thanked: 96 times

Re: Installing Addons from a button...

Post by byron »

This just got committed in the latest nightly...much thanks bro. :D
User avatar
byron
Posts: 582
Joined: Wed Jul 04, 2012 9:26 pm
Location: Illinois
Has thanked: 27 times
Been thanked: 96 times

Re: Installing Addons from a button...

Post by byron »

Well Dan, perhaps you can help...I tried doing the same thing the lyrics button on MusicOSD and have encountered something that maybe you might be able to guide me through since you ported the code. CU Lyrics is deprecated, CU LRC Lyrics is now the go to addon for lyrics atm. So, the problem is CU Lyrics WILL install and WILL open the script from this button:

CU Lyrics OSD button (DEBUG LOG):

Code: Select all

<control type="button" id="399"> <!--Lyrics-->
	<description>LYRICS BUTTON</description>
	<width>70</width>
	<height>70</height>
	<label>31926</label>
	<focusedcolor>red</focusedcolor>
	<font></font>
	<texturefocus>osd-subtitles-focus.png</texturefocus>
	<texturenofocus>osd-subtitles-nofocus.png</texturenofocus>
	<onclick condition="System.HasAddon(script.cu.lyrics)">RunScript(special://home/scripts/CU Lyrics/default.py)</onclick>
	<onclick condition="!System.HasAddon(script.cu.lyrics)">RunPlugin(plugin://programs/Addons4Xbox Installer/?installfromrepo=true&addonname=CU+Lyrics&url=http%3A%2F%2Fmirrors.xbmc.org%2Faddons%2Ffrodo%2Fscript.cu.lyrics%2Fscript.cu.lyrics-3.0.1.zip&datadir=http%3A%2F%2Fmirrors.xbmc.org%2Faddons%2Ffrodo&addonid=script.cu.lyrics&type=zip&repoid=repository.xbmc.org)</onclick>
	<animation effect="zoom" end="120" center="auto" time="100">focus</animation>
	<animation effect="zoom" start="120" center="auto" time="100">unfocus</animation>
</control>
First click does this (!System.HasAddon(script.cu.lyrics)):
musicOSD_lyrics_install.jpg
Second click runs it after it's installed (System.HasAddon(script.cu.lyrics)):
musicOSD_lyrics_running.jpg

CU LRC Lyrics OSD button (DEBUG LOG):

Code: Select all

<control type="button" id="399"> <!--Lyrics-->
	<description>LYRICS BUTTON</description>
	<width>70</width>
	<height>70</height>
	<label>31926</label>
	<focusedcolor>red</focusedcolor>
	<font></font>
	<texturefocus>osd-subtitles-focus.png</texturefocus>
	<texturenofocus>osd-subtitles-nofocus.png</texturenofocus>
	<onclick condition="System.HasAddon(script.cu.lrclyrics)">RunScript(special://home/scripts/CU LRC Lyrics/default.py)</onclick>
	<onclick condition="!System.HasAddon(script.cu.lrclyrics)">RunPlugin(plugin://programs/Addons4Xbox Installer/?installfromrepo=true&addonname=CU+LRC+Lyrics&url=http%3A%2F%2Fmirrors.xbmc.org%2Faddons%2Ffrodo%2Fscript.cu.lrclyrics%2Fscript.cu.lrclyrics-1.0.7.zip&datadir=http%3A%2F%2Fmirrors.xbmc.org%2Faddons%2Ffrodo&addonid=script.cu.lrclyrics&type=zip&repoid=repository.xbmc.org)</onclick>
	<animation effect="zoom" end="120" center="auto" time="100">focus</animation>
	<animation effect="zoom" start="120" center="auto" time="100">unfocus</animation>
</control>
First Click installs the script, every other time you click it...keeps trying to install. I checked the addon id and it's correct, tried everything I could think of but couldn't figure out why System.HasAddon(script.cu.lrclyrics) wont run the script, but System.HasAddon(script.cu.lyrics) will run that addon. Tried to illustrate the best that I could...Any thoughts?
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Installing Addons from a button...

Post by Dan Dar3 »

If I get this right, might not be a problem with System.HasAddon() condition, but with double "onclick" property? appears only the second one is considered...
If that if the case, is it possible to add two button that overlap, each controlled by the condition (one poitive one negative) so that only one is visibile at a time? This way each will have their own click that would run correctly.
User avatar
Dan Dar3
Posts: 1176
Joined: Sun Jul 08, 2012 4:09 pm
Has thanked: 273 times
Been thanked: 257 times
Contact:

Re: Installing Addons from a button...

Post by Dan Dar3 »

OR, on second thought, I could write you a small script that you can deploy maybe as part of the skin, so that the button always stays visible and calls this script - the script internally will use the condition and call either the Lyrics script if it exists, or calls the installer to install it first and then to run it. Basically we move the decision and action logic inside this additional script.

I'm currently away in holidays, but I will be back this weekend, so I'll come back soon.
Post Reply