xboxscene.org forums

Author Topic: Code Help  (Read 985 times)

wyrp

  • Archived User
  • Newbie
  • *
  • Posts: 7
Code Help
« on: November 22, 2004, 12:16:00 AM »

I'm trying to combine code from the game.lua / apps.lua with code from the mainmenu.lua in order to retain the appearance of the main menu in the other menus while retaining the ability for the dash to automatically find and list the contents. So far I've been able to get the appearance to carry over, but despite my efforts I've been unable to meld the auto listing with the mainmenu tabs.

Anybody know which lines would need to be used to pull this off?
Logged

bucko

  • Recovered User
  • Hero Member
  • *
  • Posts: 4255
Code Help
« Reply #1 on: November 23, 2004, 07:11:00 AM »

I can't help you there :( but come on our chan in IRC someone may be able to help you if anyone is up.

http://www.xboxopensource.com/pjirc/HeavyApplet.html

This post has been edited by bucko: Nov 23 2004, 03:12 PM
Logged

wyrp

  • Archived User
  • Newbie
  • *
  • Posts: 7
Code Help
« Reply #2 on: November 24, 2004, 12:23:00 PM »

So far this is what I've got for my apps.lua. When implemented, the applications menu has the xlogo and rotating crosshair, it is possible to scroll through the possible apps to launch, it is even possible to launch apps, however the container and title of each application does not appear. I think the problem is in my rendering function, but I'm having trouble locating where.

Any help?

[Code Removed]

code revised @ 4:26am Eastern 11-25-04.
One selection box shows, still no text, cannot get rest of boxes.

This post has been edited by wyrp: Nov 27 2004, 11:47 PM
Logged

wyrp

  • Archived User
  • Newbie
  • *
  • Posts: 7
Code Help
« Reply #3 on: November 27, 2004, 02:00:00 AM »

Here is an update. I've got it so that the application titles show now, however the non-selected target items below the target continue to wrap in a circular fashion, and non-selected items above target do not show yet, but menu is functional.

I am not finished with this project yet, but here is where I am at in-case anyone would like to review, comment, or test my progress.  It should also be noted that I take no liability in case of damage resulting in the use of this code, not that it should cause any problems, and that when I find the solution to the remaining problems I will post another update.

I really could use some help on this, if anyone knows lua.

[CODE REMOVED]

You'll notice that there are only minor differences between the game.lua and the app.lua, but since modifying for use as the game.lua the bugs become more evident.

This post has been edited by wyrp: Nov 27 2004, 11:48 PM
Logged

wyrp

  • Archived User
  • Newbie
  • *
  • Posts: 7
Code Help
« Reply #4 on: November 27, 2004, 03:44:00 PM »

I've got it working!
Both the Games and Apps menus will look like the main menu.

Apps Menu Code
QUOTE

--apps menu

findfiles(0)
Rotation = 0
MenuTop = 0
mRot = 0
TargetRotation = 0
BackRotation = 0
TargetItem = 0

menuitems=getmenu(0)


loadmesh("xsphere", "SKINS:\\xdash\\mainmenu\\xsphere.xbg")
loadmesh("outersphere", "SKINS:\\xdash\\outersphere.xbg")
loadmesh("crosshair", "SKINS:\\xdash\\mainmenu\\crosshair.xbg")
loadmesh("menuitem", "SKINS:\\xdash\\mainmenu\\menuitem.xbg")
loadmesh("selectedmenuitem", "SKINS:\\xdash\\mainmenu\\selectedmenuitem.xbg")


loadtexture("XRayMap", "SKINS:\\xdash\\xray.bmp")


framecnt=10
function framemove ()
   framecnt=framecnt-1
   if TargetRotation<Rotation then
   Rotation=Rotation-2.5
   elseif TargetRotation>Rotation then
   Rotation=Rotation+2.5
   elseif framecnt<5 then
   if (contAy>0.5 or contApushup>0) and TargetItem>0 then
   TargetItem=TargetItem-1
   TargetRotation=25*TargetItem
   PlaySound("menuup")
   framecnt=20
  elseif (contAy<-0.5 or contApushdown>0) and TargetItem<menuitems-1 then
   TargetItem=TargetItem+1
   TargetRotation=25*TargetItem
   PlaySound("menudown")
   framecnt=20
  end
  if contApusha>0.75 then
   launchxbe(getitemfilename(0, TargetItem))
   framecnt=10
  end
 
  if contApushy>0.5 then
   newscene("SKINS:\\xdash\\apps.lua")
   framecnt=30
  end
 
  if contApushb>0.5 then
   newscene("SKINS:\\xdash\\mainmenu.lua")
   framecnt=10
  end
   end
   
end

function render ()
   BackRotation=BackRotation-0.0003

   setfont("mainfont")

   setrenderstate(102, 0)
   setrenderstate(92, 0)
   setrenderstate(59, 0)
   setrenderstate(147, 0)
   renderobject("outersphere", 3, 0, 0, 31, PI/2, BackRotation, 0, 1.3, 1.3, 1.3)


   setrenderstateargb(75, 0, 0, 0, 0)
   
   setupxray(1, 255, 0, 93, 199)   
   settexture("XRayMap", 0)
   renderobject("crosshair", 0, -16, 0.95, 3, 0, 0, rad(Rotation), 0.5, 0.5, 0.5)
   setupxray(0, 175, 0, 93, 199)
   
   setrenderstate(102, 0)
   setrenderstate(59, 0)
   renderobject("xsphere", 1, -15, 0.95, 3, 0, -PI/18, 0, 0.5, 0.5, 0.5)


   for i=0, menuitems-1 do
  mRot=Rotation-(25*i)
  alpha=255-abs(mRot)*4
  --if i>=TargetItem then
  if alpha>0 then
   itemx=(cos(mRot)*20)-16
   itemy=(sin(mRot)*20)+0.95
   setrenderstate(59, 1)
   setrenderstate(62, 32771)
   setrenderstate(63, 774)
   setrenderstateargb(75, alpha, 0, 0, 0)
   renderobject("storageitem", 1, itemx, itemy, 3, 0, 0, 0, 0.25, 0.25, 0.25)
   if abs(mRot)<=32 then
    setrenderstateargb(75, alpha*alpha/256, 0, 0, 0)
    renderobject("selectedmenuitem", 1, itemx, itemy, 3, 0, 0, 0, 0.25, 0.25, 0.25)
   end
   settextargb(alpha,255,255,255)
   textx=(cos(mRot)*147)+255
   texty=237-(sin(mRot)*147)
   rendertext(getitemstring(0,i), textx, texty)
  
  end
 
   end
   
end


Game Menu Code
QUOTE

--games menu

findfiles(1)
Rotation = 0
MenuTop = 0
mRot = 0
TargetRotation = 0
BackRotation = 0
TargetItem = 0

menuitems=getmenu(2)


loadmesh("xsphere", "SKINS:\\xdash\\mainmenu\\xsphere.xbg")
loadmesh("outersphere", "SKINS:\\xdash\\outersphere.xbg")
loadmesh("crosshair", "SKINS:\\xdash\\mainmenu\\crosshair.xbg")
loadmesh("menuitem", "SKINS:\\xdash\\mainmenu\\menuitem.xbg")
loadmesh("selectedmenuitem", "SKINS:\\xdash\\mainmenu\\selectedmenuitem.xbg")


loadtexture("XRayMap", "SKINS:\\xdash\\xray.bmp")


framecnt=15
function framemove ()
   framecnt=framecnt-1
   if TargetRotation<Rotation then
   Rotation=Rotation-2.5
   elseif TargetRotation>Rotation then
   Rotation=Rotation+2.5
   elseif framecnt<5 then
   if (contAy>0.5 or contApushup>0) and TargetItem>0 then
   TargetItem=TargetItem-1
   TargetRotation=25*TargetItem
   PlaySound("menuup")
   framecnt=10
  elseif (contAy<-0.5 or contApushdown>0) and TargetItem<menuitems-1 then
   TargetItem=TargetItem+1
   TargetRotation=25*TargetItem
   PlaySound("menudown")
   framecnt=10
  end
  if contApusha>0.5 then
   launchxbe(getitemfilename(2, TargetItem))
   framecnt=10
  end
 
  if contApushy>0.5 then
   newscene("SKINS:\\xdash\\games.lua")
   framecnt=30
  end
 
  if contApushb>0.5 then
   newscene("SKINS:\\xdash\\mainmenu.lua")
   framecnt=10
  end
   end
   
end

function render ()

   BackRotation=BackRotation-0.0003

   setfont("mainfont")

   setrenderstate(102, 0)
   setrenderstate(92, 0)
   setrenderstate(59, 0)
   setrenderstate(147, 0)
   renderobject("outersphere", 3, 0, 0, 31, PI/2, BackRotation, 0, 1.3, 1.3, 1.3)


   setrenderstateargb(75, 0, 0, 0, 0)
   
   setupxray(1, 255, 0, 93, 199)   
   settexture("XRayMap", 0)
   renderobject("crosshair", 0, -16, 0.95, 3, 0, 0, rad(Rotation), 0.5, 0.5, 0.5)
   setupxray(0, 175, 0, 93, 199)
   
   setrenderstate(102, 0)
   setrenderstate(59, 0)
   renderobject("xsphere", 1, -15, 0.95, 3, 0, -PI/18, 0, 0.5, 0.5, 0.5)

   
   for i=0, menuitems-1 do
  mRot=Rotation-(25*i)
  alpha=255-abs(mRot)*4
  --if i>=TargetItem then
  if alpha>0 then
   itemx=(cos(mRot)*20)-16
   itemy=(sin(mRot)*20)+0.95
   setrenderstate(59, 1)
   setrenderstate(62, 32771)
   setrenderstate(63, 774)
   setrenderstateargb(75, alpha, 0, 0, 0)
   renderobject("storageitem", 1, itemx, itemy, 3, 0, 0, 0, 0.25, 0.25, 0.25)
   if abs(mRot)<=32 then
    setrenderstateargb(75, alpha*alpha/256, 0, 0, 0)
    renderobject("selectedmenuitem", 1, itemx, itemy, 3, 0, 0, 0, 0.25, 0.25, 0.25)
   end
   settextargb(alpha,255,255,255)
   textx=(cos(mRot)*147)+255
   texty=237-(sin(mRot)*147)
   rendertext(getitemstring(2,i), textx, texty)
  
  end
 
   end
   
end


This post has been edited by wyrp: Nov 27 2004, 11:45 PM
Logged

HoRnEyDvL

  • Administrator
  • Sr. Member
  • *****
  • Posts: 462
Code Help
« Reply #5 on: November 27, 2004, 07:17:00 PM »

Nice Work WYRP :) Wanna post some screens or something :)
Logged

wyrp

  • Archived User
  • Newbie
  • *
  • Posts: 7
Code Help
« Reply #6 on: November 27, 2004, 09:31:00 PM »

I can't really take the credit for code, all I did was review and combine code from the main and apps/games lua's.
Logged