Jump to content


Photo

Random Backgrounds


  • Please log in to reply
17 replies to this topic

#1 frostyfire03530

frostyfire03530

    X-S Member

  • Members
  • Pip
  • 80 posts
  • Xbox Version:v1.4

Posted 30 September 2005 - 07:18 AM

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

Edited by frostyfire03530, 30 September 2005 - 07:19 AM.


#2 t1x2irc2

t1x2irc2

    X-S Member

  • Members
  • Pip
  • 68 posts

Posted 30 September 2005 - 03:47 PM

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

#3 frostyfire03530

frostyfire03530

    X-S Member

  • Members
  • Pip
  • 80 posts
  • Xbox Version:v1.4

Posted 30 September 2005 - 04:35 PM

[code=auto:0]
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....

#4 frostyfire03530

frostyfire03530

    X-S Member

  • Members
  • Pip
  • 80 posts
  • Xbox Version:v1.4

Posted 30 September 2005 - 06:45 PM

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

#5 Odb718

Odb718

    X-S Freak

  • Last Chance
  • PipPipPipPipPip
  • 1,589 posts
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 01 October 2005 - 02:18 AM

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. :/

#6 Odb718

Odb718

    X-S Freak

  • Last Chance
  • PipPipPipPipPip
  • 1,589 posts
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 01 October 2005 - 04:11 AM

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.

#7 frostyfire03530

frostyfire03530

    X-S Member

  • Members
  • Pip
  • 80 posts
  • Xbox Version:v1.4

Posted 01 October 2005 - 04:35 AM

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...

#8 Odb718

Odb718

    X-S Freak

  • Last Chance
  • PipPipPipPipPip
  • 1,589 posts
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 01 October 2005 - 12:00 PM

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

#9 gasclown

gasclown

    X-S Freak

  • Members
  • PipPipPipPipPip
  • 1,128 posts
  • Location:Brisvegas
  • Xbox Version:v1.4
  • 360 version:unknown

Posted 02 October 2005 - 11:31 PM

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.

#10 frostyfire03530

frostyfire03530

    X-S Member

  • Members
  • Pip
  • 80 posts
  • Xbox Version:v1.4

Posted 03 October 2005 - 05:26 AM

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

#11 frostyfire03530

frostyfire03530

    X-S Member

  • Members
  • Pip
  • 80 posts
  • Xbox Version:v1.4

Posted 03 October 2005 - 06:16 AM

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

#12 Odb718

Odb718

    X-S Freak

  • Last Chance
  • PipPipPipPipPip
  • 1,589 posts
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 03 October 2005 - 10:39 AM

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

#13 frostyfire03530

frostyfire03530

    X-S Member

  • Members
  • Pip
  • 80 posts
  • Xbox Version:v1.4

Posted 03 October 2005 - 04:22 PM

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!!!

#14 frostyfire03530

frostyfire03530

    X-S Member

  • Members
  • Pip
  • 80 posts
  • Xbox Version:v1.4

Posted 03 October 2005 - 11:13 PM

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...

#15 frostyfire03530

frostyfire03530

    X-S Member

  • Members
  • Pip
  • 80 posts
  • Xbox Version:v1.4

Posted 03 October 2005 - 11:13 PM

crap DP gomen...

Edited by frostyfire03530, 03 October 2005 - 11:14 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users