Help - Search - Members - Calendar
Full Version: Random Backgrounds
Scenyx Entertainment Community > Xbox1 Forums > Dashboard Forums > Official Team UIX Forums > User.Interface.X (UIX) Code
frostyfire03530
I've tried to duplicate and piece together a code to get random backgrounds displayed. I can get them to display when the xbx files are located within the skin folder but i was wondering if i could change the location that the xbx's are searched for...
CODE
DEF theBackground Group
{
   children
   [
       DEF background0 Background
       {
           skyColor 0 0 0 backdrop ImageTexture { url "skins/backgrounds/background0.xbx" }
       }
       DEF background1 Background
       {
           skyColor 0 0 0 backdrop ImageTexture { url "skins/backgrounds/background1.xbx" }
       }
       DEF background2 Background
       {
           skyColor 0 0 0 backdrop ImageTexture { url "skins/backgrounds/background2.xbx" }
       }
       DEF background3 Background
       {
           skyColor 0 0 0 backdrop ImageTexture { url "skins/backgrounds/background3.xbx" }
       }
       DEF background4 Background
       {
           skyColor 0 0 0 backdrop ImageTexture { url "skins/backgrounds/background4.xbx" }
       }
   ]
}

I've tried to change the url command like the audio ones located elsewhere in the default.xip but to no success... I've tried using the device//partition format but that doesn't work either tried to use the whole path for the uix test build i'm doing on my f partion but it just resets the dash when you try to load a bg so... any help would be appreciated... that is if UIX isn't dead from all the crap that has been going on lately
t1x2irc2
i'm pretty sure this will work
CODE

skyColor 0 0 0 backdrop ImageTexture { url "A:/skins/backgrounds/background0.xbx" }


or
CODE

url "A:\\skin\\backgrounds\\background0.xbx";


A: = UIX DIR
frostyfire03530
[CODE]
DEF theBackground Group
{
children
[
DEF background0 Background
{
skyColor 0 0 0 //backdrop ImageTexture { url "A:\\skins\\backgrounds\\background.xbx" }
}
DEF background1 Background
{
skyColor 0 0 0 backdrop ImageTexture { url "A:\\skins\\backgrounds\\background0.xbx" }
}
DEF background2 Background
{
skyColor 0 0 0 backdrop ImageTexture { url "A:\\skins\\backgrounds\\background1.xbx" }
}
DEF background3 Background
{
skyColor 0 0 0 backdrop ImageTexture { url "A:\\skins\\backgrounds\\background2.xbx" }
}
]
}

function RandomBackgroundSettings()
{
LoadBackground();
UpdateMainMenu();
}

function LoadBackground()
{
var IniFile = new Settings;
IniFile.SetIniSection( "BackgroundSettings" );
var a = IniFile.GetIniValue( "random" );
var NoB = IniFile.GetIniValue( "NumberofBackgrounds" );
IniFile.CloseIniFile();
var n = Math.round(Math.random() * (theBackground.children.length() + 1));
if( a == "true" ) { theBackground.children[n].isBound = true; }
else if( a == "false" ) { theBackground.children[0].isBound = true; }
}
==========================================
ok this is the whole code that i am using to get this to work... i tried your naming method t1 but it still just resets te dash... so it got me thinking that maybe all the times that it has been resetting it not that it can't find the file but maybe i'm just having it launch like out of sequence or something.... like i said though that would be strange because when it is linked to the skins default url location it load the code fine... meh idk... any one else....
frostyfire03530
CODE

function LoadBackground()
{
   var IniFile = new Settings;
   IniFile.SetIniSection( "BackgroundSettings" );
   var a = IniFile.GetIniValue( "random" );
   IniFile.CloseIniFile();
   var n = Math.round(Math.random() * (theBackground.children.length() - 1));
   if( a == "true" ) { theBackground.children[n].isBound = true; }
   else if( a == "false" ) { theBackground.children[0].isBound = true; }
   UpdateMainMenu();
}

also if anyone can help me with the math... I'm trying to make it so that if random backgrounds are selected then you will always have a ImageTexture loaded and when random is not selected you will just have the blank cellwall displayed. From what I have it works except for the math to exclude the first child for the Background group [ie: the blank cell wall]
I tried to do this
CODE

   var n = Math.round(Math.random() * (theBackground.children.length() - 1));
   if( n = 0 )
           {n = 1;}
       else
           {n = n;}

but all i get is the blank cell wall being displayed any suggestions on this too would be great
Odb718
frostyfire03530, I dont think you need the IniFile.CloseIniFile(); but it's been ages since I've worked with 01.03.05 (aka v0.0)
If you want I'll release my "tabbed background" code. Pretty sweet stuff.
Im pretty sure you'd be able to tack on a random bg image with ease.
But I'll release the code with a skin, and I'm not sure if I want to release any skins any more. I'll see how I feel about it later this weekend. :/
Odb718
oh, frostyfire03530, if you need help with the random math you should steal the code for the random bg music. Just copy everything but change it from music to bg images...
you should copy it, but see if you couldn't get it to display the bg image in the skin for every possibility... this way you'd know it works, you'd just have to figure out the code to get the random bg images out of the seperate folder.
Heck what you should do is make it so it displays either background.xbx, xboxlogo.xbx or xboxlogow.xbx at first. This way you know the randomness works. You'd just have to figure out the code to get it to display out of the background folder.

Hopefully I've given you some ideas.
frostyfire03530
well the math odb that i have is fine for being random... the problem is that the functionality i want with the dash is to have the option to turn random on and off (ie: when the random is off no background image is displayed.. just the cellwall) i would want to keep the randomness that i have already yet tell the math to exclude the first child of the background group which is a blank BG def.
I have allready scipted the option to turn it on and off... i can turn the randomness on and then have no random at all... but can't get it to exclude first child, that was the math i was looking was available.... then i don't know about the url crap.... i wanted this to be a dynamic thing because i give this dash out to my brother and a firend of mine and the tweaks i do to mine they like and want.. I can just include the xbx's in with the compilation of the default.xip but like i said i wanted this to be upgradeable to add more BG with ease and to change them with ease like from ftp or installing them from a burned disk...
Odb718
blink.gif
QUOTE
i would want to keep the randomness that i have already yet tell the math to exclude the first child of the background group which is a blank BG def.
So just delete the first bit of code... why have a blank bg in the random???
edit it so it is a viable background image.

also, your line of code...
CODE
  else if( a == "false" ) { theBackground.children[0].isBound = true; }
.isBound = should be false, not true. Not sure how you were getting it to disappear the way it is now....

I think thats what your whole problem has boiled down to. You were thinking you had to have a bg image be blank in order for it to be able to not display. When all you needed to do was set theBackground.children[0].isBound = to false for it to not display the bg images. huh.gif
gasclown
not sure if im understanding this conversation correctly but just in case there is no need need to have a transparent xbx and in fact the dash/xbox cannot handle it.

backdrop ImageTexture { url "" }} is yr best bet.
frostyfire03530
Odb718: I think i get what you mean... if that's what the changing the isbound =false will do then that is what i wanted... what was making the bg image blank before was in the bg list was a commented out imagetexture link... but i will try your suggestion out right now
gasclown: no, i'm not trying to make it trans. but thanks for the input i'm glad you guys are still out to help, so thanks anyway i think odb718 proposed a solution to my prob... biggrin.gif
frostyfire03530
ok too late to edit...
ALRIGHTY!!! Got the fuctions to work how i wanted them. See at the begining I had taken out the entire theBackground Background def. and replaced it with the group def... after sticking it back in and telling the fuction to load isbound=false when random =false it loaded the fuction fine... all i had to do then to make it load a random background on startup was to add the LoadBackground fcn. in the main menu intialize section... the only thing to make this great though would be if i could make the url's fuction right (ie: launch the xbx's from a separate global folder) i'm going to try this again but i think the dash will just reset like it has when i tried it before so if anyone could tell me the proper input for the url format in UIX it would be appreciated, thanks to all who have helped me out so far
Odb718
Well you should thank JbOnE because he helped me figure out most of my bg image code. (basically told me flat out)
When you're done with the code please post it as a finished tutorial on how to do it.
and if ya need more help you know where to find us.
beerchug.gif
frostyfire03530
i tried get the a global bg folder to work but still to no success the dash still resets... the only reason i wanted this global folder was so that you could switch to a different skin and still be able to have the random bg enabled in say the "blue cellwal" skin but... meh there are still ways to do it so i'll whip up the tut.
but yeah thanks again to t1x2irc2 for the input and JbOnE, Odb718, gasclown for help with the code... JbOnE, can't wait for v2.0!!!
frostyfire03530
ok guys just one kink left to work out...
change this...
CODE

function LoadBackground()
{
   var IniFile = new Settings;
   IniFile.SetIniSection( "BackgroundSettings" );
   var a = IniFile.GetIniValue( "random" );
   IniFile.CloseIniFile();
   var n = Math.round(Math.random() * (theBackground.children.length() - 1));

   if( a == "true" ) { theBackground.children[n].isBound = true; }
   else if( a == "single" ) { theBackground.children[0].isBound = true; }
   else if( a == "false" ) { theBackground.children[n].isBound = false; }
}

to more of something like this...
CODE

function LoadBackground()
{
   var IniFile = new Settings;
   IniFile.SetIniSection( "BackgroundSettings" );
   var a = IniFile.GetIniValue( "random" );
   var b = IniFile.GetIniValue( "NUMBER" );
   IniFile.CloseIniFile();
   var n = Math.round(Math.random() * (b - 1));

   if( a == "true" ) { theBackground.children[n].isBound = true; }
   else if( a == "single" ) { theBackground.children[0].isBound = true; }
   else if( a == "false" ) { theBackground.children[n].isBound = false; }
}

that way there can be more bg defined in default.xap without having to change the file everytime you want to add more bg's, all they would have to do is select the numbe of backgrounds they have from the dash settings...
my problem is i don't know the config language to write the code in the math... so if you guys could help thanks... got to go to work though will be on later...
frostyfire03530
crap DP gomen...
frostyfire03530
ok this is the code that i have to load a user set amount of backgrouds...
CODE

function LoadBackground()
{
   var IniFile = new Settings;
   IniFile.SetIniSection( "BackgroundSettings" );
   var a = IniFile.GetIniValue( "random" );
   b = IniFile.GetIniValue( "number" );
   IniFile.CloseIniFile();
   var n = Math.round(Math.random() * (b - 1));
   if( a == "true" ) { theBackground.children[n].isBound = true; }
   else if( a == "single" ) { theBackground.children[0].isBound = true; }
   else if( a == "false" ) { theBackground.children[n].isBound = false; }
}

my only problem now exists with that the background will now no longer refresh when the mainmenu loads... I used to just have the LoadBackground(); command after EnableAudio(); command in the DEF theMainMenu Level i'm stumped as to why now it won't load on startup... i can still click the right thumb to activate it but it needs to activate on startup too...
Odb718
usually if something like that happens it's because you're missing a ; or something along those lines.
frostyfire03530
well i talked to JbOnE and he said he doesn't know what is going on, to him the code looks right and he doesn't see a problem... meh.. IDK I'll play with the code for about one more day then post the tut. as is.. thanks all...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.