forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Changing skins

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
2Xtremes2004



Joined: 31 Aug 2005
Posts: 53

PostPosted: Sat Oct 22, 2005 12:38 pm    Post subject: Changing skins Reply with quote

Ok, I set up a menu in my app so that I could change the background. My menu is set up pretty close to the menu in Shine's Snake game. My question is, is there a way to make it change all the graphics in the app, and not just the background, without having to make a option for each seperate object? Also, I remember seeing something about the reason mp3 were not going to be supported was because of having to buy the rights or something. If thats the case how do other homebrew makers get away with it, for example, I have XBMC on my xbox and it supports mp3.
_________________
I want my money back!?
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Sat Oct 22, 2005 6:03 pm    Post subject: Reply with quote

put all images into arrays
make a skin an entry
skin1 = array[1]
skin2 = array[2]
skin3 = array[3]
...
should work

greets
lumo
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
MikeHaggar



Joined: 18 Jul 2005
Posts: 116

PostPosted: Sat Oct 22, 2005 11:54 pm    Post subject: Re: Changing skins Reply with quote

Using XBMC as an example for guys who cares about rights, isn't exactly good ;)

And .ogg is probably a better format to use anyway...
Back to top
View user's profile Send private message
2Xtremes2004



Joined: 31 Aug 2005
Posts: 53

PostPosted: Sun Oct 23, 2005 12:59 am    Post subject: Reply with quote

I was not applying that they care about rights, I don't know if they do or not, either way I was just using them as an example. Anyways.. I have never heared of .ogg, is there any kind of .mp3 to .ogg converter. Will Lua support .ogg in the future?
_________________
I want my money back!?


Last edited by 2Xtremes2004 on Sun Oct 23, 2005 2:36 am; edited 1 time in total
Back to top
View user's profile Send private message
2Xtremes2004



Joined: 31 Aug 2005
Posts: 53

PostPosted: Sun Oct 23, 2005 2:15 am    Post subject: Reply with quote

I have never used an array, so I am a bit clueless about them. Could you point me towards an example please. Maybe, it is something like this:

Code:

-- Default options
options = { theme = "Skin#1", music = "Song#1" }

-- Possible options for system config menu
possibleOptions = {
   theme = {
      displayName = "Themes",
      values = {"Skin#1, Skin#2"} },
   music = {
      displayName = "Background Music",
      values = {"Song#1", "Song#2", "Song#3"} }

-- Skin Arrays
Skin#1 = {
background = Image.load("Skins/Background.png"),
hold = Image.load("Data/Hold.png"),
battl = Image.load("Data/Battery Low.png"),
batth = Image.load("Data/Battery Half.png"),
battf = Image.load("Data/Battery Full.png"),
usba = Image.load("Data/USBON.png"),
baudio = Image.load("Data/Audio.png"),
bimage = Image.load("Data/Image.png"),
pointer = Image.load("Data/Pointer.png"),
lshoulder = Image.load("Data/LON.png"),
rshoulder = Image.load("Data/RON.png")
}

_________________
I want my money back!?
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Sun Oct 23, 2005 4:04 am    Post subject: Reply with quote

array = table in lua
Code:

-- Skin Arrays
Skins# = {
{
background = Image.load("Skins/Background.png"),
hold = Image.load("Data/Hold.png"),
battl = Image.load("Data/Battery Low.png"),
batth = Image.load("Data/Battery Half.png"),
battf = Image.load("Data/Battery Full.png"),
usba = Image.load("Data/USBON.png"),
baudio = Image.load("Data/Audio.png"),
bimage = Image.load("Data/Image.png"),
pointer = Image.load("Data/Pointer.png"),
lshoulder = Image.load("Data/LON.png"),
rshoulder = Image.load("Data/RON.png")
}
{
background = Image.load("Skins/Background2.png"),
hold = Image.load("Data/Hold2.png"),
battl = Image.load("Data/Battery Low2.png"),
batth = Image.load("Data/Battery Half2.png"),
battf = Image.load("Data/Battery Full2.png"),
usba = Image.load("Data/USBON2.png"),
baudio = Image.load("Data/Audio2.png"),
bimage = Image.load("Data/Image2.png"),
pointer = Image.load("Data/Pointer2.png"),
lshoulder = Image.load("Data/LON2.png"),
rshoulder = Image.load("Data/RON2.png")
}
}

this codeholds 2skins

_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
2Xtremes2004



Joined: 31 Aug 2005
Posts: 53

PostPosted: Sun Oct 23, 2005 4:24 am    Post subject: Reply with quote

Ok, I got it put into my script, but it shows an error every time its suppose to blit an image. Do I need to go back through and edit my script to load from the array?

This is how it was set up:
Code:
screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false)


Do I change it to something like this?
Code:
screen:blit(0, 0, Skin{background}, 0, 0, Skin{background}:width(), Skin{background}:height(), false)


...or something else. Sorry for being such a noob, but I'm slowly learning :-P Thx for all the help so far.
_________________
I want my money back!?
Back to top
View user's profile Send private message
haust



Joined: 01 Oct 2005
Posts: 25
Location: France

PostPosted: Sun Oct 23, 2005 9:13 am    Post subject: Reply with quote

Sorry but why the # symbol in Skins# ?? For fun or for some lua feature ??
Back to top
View user's profile Send private message
flattspott



Joined: 22 Aug 2005
Posts: 22

PostPosted: Sun Oct 23, 2005 11:35 am    Post subject: Reply with quote

I think you need a variable to track which skin is active

Since tables start with an index of 1, one is the starting point of the variable.

activeSkin = 1
to change the skin just increase the activeSkin variable




screen:blit(0, 0, Skin[activeSkin].background, 0, 0, Skin[activeSkin].background:width(), Skin[activeSkin].background:height(), false)
Back to top
View user's profile Send private message
2Xtremes2004



Joined: 31 Aug 2005
Posts: 53

PostPosted: Sun Oct 23, 2005 3:54 pm    Post subject: Reply with quote

When I tried it like this:
Code:

Skin = {
{
background = Image.load("Skins/Background.png"),
hold = Image.load("Data/Hold.png"),
battl = Image.load("Data/Battery Low.png"),
batth = Image.load("Data/Battery Half.png"),
battf = Image.load("Data/Battery Full.png"),
usba = Image.load("Data/USBON.png"),
baudio = Image.load("Data/Audio.png"),
bimage = Image.load("Data/Image.png"),
pointer = Image.load("Data/Pointer.png"),
lshoulder = Image.load("Data/LON.png"),
rshoulder = Image.load("Data/RON.png")
}
{
background = Image.load("Skins/Background2.png"),
hold = Image.load("Data/Hold2.png"),
battl = Image.load("Data/Battery Low2.png"),
batth = Image.load("Data/Battery Half2.png"),
battf = Image.load("Data/Battery Full2.png"),
usba = Image.load("Data/USBON2.png"),
baudio = Image.load("Data/Audio2.png"),
bimage = Image.load("Data/Image2.png"),
pointer = Image.load("Data/Pointer2.png"),
lshoulder = Image.load("Data/LON2.png"),
rshoulder = Image.load("Data/RON2.png")
}
}


It gives me the following error:
Code:

error: System/SYSTEM.LUA:70 '}' expected (to close '{' at line51)
near '{'
Error: No script file found.
Press start to restart


Any ideas, anyone?
_________________
I want my money back!?
Back to top
View user's profile Send private message
ShUr1k3n



Joined: 16 Oct 2005
Posts: 42

PostPosted: Sun Oct 23, 2005 6:58 pm    Post subject: Reply with quote

U must put a "," between "options" like this:

Code:
Skin = {
{
background = Image.load("Skins/Background.png"),
hold = Image.load("Data/Hold.png"),
battl = Image.load("Data/Battery Low.png"),
batth = Image.load("Data/Battery Half.png"),
battf = Image.load("Data/Battery Full.png"),
usba = Image.load("Data/USBON.png"),
baudio = Image.load("Data/Audio.png"),
bimage = Image.load("Data/Image.png"),
pointer = Image.load("Data/Pointer.png"),
lshoulder = Image.load("Data/LON.png"),
rshoulder = Image.load("Data/RON.png")
},  < --------- HERE........
{
background = Image.load("Skins/Background2.png"),
hold = Image.load("Data/Hold2.png"),
battl = Image.load("Data/Battery Low2.png"),
batth = Image.load("Data/Battery Half2.png"),
battf = Image.load("Data/Battery Full2.png"),
usba = Image.load("Data/USBON2.png"),
baudio = Image.load("Data/Audio2.png"),
bimage = Image.load("Data/Image2.png"),
pointer = Image.load("Data/Pointer2.png"),
lshoulder = Image.load("Data/LON2.png"),
rshoulder = Image.load("Data/RON2.png")
}
}


Regards,

ShUr1k3n
Back to top
View user's profile Send private message Send e-mail
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Sun Oct 23, 2005 7:17 pm    Post subject: Reply with quote

oops forgot that little puppy ','
greets
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
2Xtremes2004



Joined: 31 Aug 2005
Posts: 53

PostPosted: Wed Oct 26, 2005 5:27 am    Post subject: Reply with quote

So, this should work right?

Code:
-- Default options
options = { theme = "Skin1", music = "Song#1" }
activeSkin = 1

-- Possible options for system config menu
possibleOptions = {
   theme = {
      displayName = "Themes",
      values = {"Skin1, Skin2"} },
   music = {
      displayName = "Background Music",
      values = {"Song#1", "Song#2", "Song#3"} }

Skin1 = Skin[1]
Skin2 = Skin[2]

Skin = {
{
background = Image.load("Skins/Background.png"),
hold = Image.load("Data/Hold.png"),
battl = Image.load("Data/Battery Low.png"),
batth = Image.load("Data/Battery Half.png"),
battf = Image.load("Data/Battery Full.png"),
usba = Image.load("Data/USBON.png"),
baudio = Image.load("Data/Audio.png"),
bimage = Image.load("Data/Image.png"),
pointer = Image.load("Data/Pointer.png"),
lshoulder = Image.load("Data/LON.png"),
rshoulder = Image.load("Data/RON.png")
},
{
background = Image.load("Skins/Background2.png"),
hold = Image.load("Data/Hold2.png"),
battl = Image.load("Data/Battery Low2.png"),
batth = Image.load("Data/Battery Half2.png"),
battf = Image.load("Data/Battery Full2.png"),
usba = Image.load("Data/USBON2.png"),
baudio = Image.load("Data/Audio2.png"),
bimage = Image.load("Data/Image2.png"),
pointer = Image.load("Data/Pointer2.png"),
lshoulder = Image.load("Data/LON2.png"),
rshoulder = Image.load("Data/RON2.png")
}
}

screen:blit(0, 0, Skin[activeSkin].background, 0, 0, Skin[activeSkin].background:width(), Skin[activeSkin].background:height(), false)


Ok, I updated my script with the above code and now it gives me this error:
Code:

error: System/SYSTEM.LUA:48: attempt to index global 'Skin' (a nil value)
Error: No script file found.
Press start to restart

_________________
I want my money back!?


Last edited by 2Xtremes2004 on Wed Oct 26, 2005 5:43 am; edited 1 time in total
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Wed Oct 26, 2005 5:42 am    Post subject: Reply with quote

you can remove the following lines:
Code:
Skin1 = Skin[1]
Skin2 = Skin[2]


greets
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
2Xtremes2004



Joined: 31 Aug 2005
Posts: 53

PostPosted: Wed Oct 26, 2005 5:47 am    Post subject: Reply with quote

Ok, I removed the two lines like you suggested and it will load the first skin fine, but it will not load Skin2.
_________________
I want my money back!?
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Wed Oct 26, 2005 5:52 am    Post subject: Reply with quote

could you upload the bunch of files in a zip?
then i have a look on it...
maybe you come to our irc room?

greets
lumo
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
2Xtremes2004



Joined: 31 Aug 2005
Posts: 53

PostPosted: Thu Oct 27, 2005 4:38 pm    Post subject: Reply with quote

I Finaly got it!!!! ;-P Turns out, all I needed was this:

Code:

   selectedLevel = (options["level"])
   if skinSelected ~= selectedLevel then
      if selectedLevel == "Skin#1" then
         activeSkin = 1
         skinSelected = "Skin#1"
      elseif selectedLevel == "Skin#2" then
         activeSkin = 2
         skinSelected = "Skin#2"
      end
   end


Thx for the help LuMo, ShUr1k3n, and flattspott!
_________________
I want my money back!?
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Thu Oct 27, 2005 6:38 pm    Post subject: Reply with quote

hehe thought that was straigt forward (that you have to change the value somehow ;) )
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group