Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: $pvar() Questions: Need Some Help With My Code (Read 1444 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

$pvar() Questions: Need Some Help With My Code

I have (for about 4-5 hours now) been TRYING my hardest to figure out why my code doesn't function correctly. For the life of me, I just can't seem to wrap my head around this pvar stuff.
What I am trying to do:
I am trying to make a panel that switches between 3 (and eventually more) pages of images that I can use as my background. I have the visuals working very nicely, but I can't seem to get the arrows to scroll between the 'pages'.

Here is my code for the background panel:

Code: [Select]
//==========
// Global
//==========
$puts(bg-dir,'C:\Program Files\foobar2000\FoOrby\bgs')
$puts(bgX,220)
$puts(bgY,170)
$puts(bgW,%_width%)

//==========
// PerTrack
//==========
$button2(5,$eval({%_height%/2}-15),0,0,35,30,'$font(Wingdings,24,,255-255-255)ç','$font(Wingdings,24,,255-255-255)ç',PVAR:SET:bgpageRW:$ifequal($getpvar(bgpageRW),1,2,3),TOOLTIP:"Previous Backgrounds")
$button2($eval(%_width%-40),$eval({%_height%/2}-15),0,0,35,30,'$font(Wingdings,24,,255-255-255)è','$font(Wingdings,24,,255-255-255)è',PVAR:SET:bgpageFW:$ifequal($getpvar(bgpageFW),3,2,1),TOOLTIP:"Next Backgrounds")

$setpvar(bg-value,PVAR:SET:bg-value:1)
//====|PAGE ONE|====
$puts(page1,
//-----BG IMAGE 1
$imageabs2($get(bgX),$get(bgY),-55,-20,$get(bgW),%_height%,0,0,$get(bg-dir)\img$eval($getpvar(bg-value)+1).*,NOKEEPASPECT)
$button(55,20,0,0,220,170,$get(bg-dir)\overlay2.png,$get(bg-dir)\overlay.png,$setpvar(buttoncmd,img1),TOOLTIP:"")
//-----BG IMAGE 2
$imageabs2($get(bgX),$get(bgY),-295,-20,$get(bgW),%_height%,0,0,$get(bg-dir)\img$eval($getpvar(bg-value)+2).*,NOKEEPASPECT)
$button(295,20,0,0,220,170,$get(bg-dir)\overlay2.png,$get(bg-dir)\overlay.png,$setpvar(buttoncmd,img2),TOOLTIP:"")
//-----BG IMAGE 3
$imageabs2($get(bgX),$get(bgY),-535,-20,$get(bgW),%_height%,0,0,$get(bg-dir)\img$eval($getpvar(bg-value)+3).*,NOKEEPASPECT)
$button(535,20,0,0,220,170,$get(bg-dir)\overlay2.png,$get(bg-dir)\overlay.png,$setpvar(buttoncmd,img3),TOOLTIP:"")
)

//====|PAGE TWO|====
$puts(page2,
//-----BG IMAGE 4
$imageabs2($get(bgX),$get(bgY),-55,-20,$get(bgW),%_height%,0,0,$get(bg-dir)\img$eval($getpvar(bg-value)+4).*,NOKEEPASPECT)
$button(55,20,0,0,220,170,$get(bg-dir)\overlay2.png,$get(bg-dir)\overlay.png,$setpvar(buttoncmd,img4),TOOLTIP:"")
//-----BG IMAGE 5
$imageabs2($get(bgX),$get(bgY),-295,-20,$get(bgW),%_height%,0,0,$get(bg-dir)\img$eval($getpvar(bg-value)+5).*,NOKEEPASPECT)
$button(295,20,0,0,220,170,$get(bg-dir)\overlay2.png,$get(bg-dir)\overlay.png,$setpvar(buttoncmd,img5),TOOLTIP:"")
//-----BG IMAGE 6
$imageabs2($get(bgX),$get(bgY),-535,-20,$get(bgW),%_height%,0,0,$get(bg-dir)\img$eval($getpvar(bg-value)+6).*,NOKEEPASPECT)
$button(535,20,0,0,220,170,$get(bg-dir)\overlay2.png,$get(bg-dir)\overlay.png,$setpvar(buttoncmd,img6),TOOLTIP:"")
)

//====|PAGE TWO|====
$puts(page3,
//-----BG IMAGE 7
$imageabs2($get(bgX),$get(bgY),-55,-20,$get(bgW),%_height%,0,0,$get(bg-dir)\img$eval($getpvar(bg-value)+7).*,NOKEEPASPECT)
$button(55,20,0,0,220,170,$get(bg-dir)\overlay2.png,$get(bg-dir)\overlay.png,$setpvar(buttoncmd,img7),TOOLTIP:"")
//-----BG IMAGE 8
$imageabs2($get(bgX),$get(bgY),-295,-20,$get(bgW),%_height%,0,0,$get(bg-dir)\img$eval($getpvar(bg-value)+8).*,NOKEEPASPECT)
$button(295,20,0,0,220,170,$get(bg-dir)\overlay2.png,$get(bg-dir)\overlay.png,$setpvar(buttoncmd,img8),TOOLTIP:"")
//-----BG IMAGE 9
$imageabs2($get(bgX),$get(bgY),-535,-20,$get(bgW),%_height%,0,0,$get(bg-dir)\img$eval($getpvar(bg-value)+9).*,NOKEEPASPECT)
$button(535,20,0,0,220,170,$get(bg-dir)\overlay2.png,$get(bg-dir)\overlay.png,$setpvar(buttoncmd,img9),TOOLTIP:"")
)

//-------------------------------------------------------------------------------------------------
//====|PAGE CODE|====
$select($getpvar(bgpageFW),
$ifequal($getpvar(bgpageFW),1,$get(page1),),
$ifequal($getpvar(bgpageFW),2,$get(page2),),
$ifequal($getpvar(bgpageFW),3,$get(page3),)
)

$select($getpvar(bgpageRW),
$ifequal($getpvar(bgpageRW),1,$get(page1),),
$ifequal($getpvar(bgpageRW),2,$get(page2),),
$ifequal($getpvar(bgpageRW),3,$get(page3),)
)


Then in my MAIN layout code page, I have this section that is meant to control the background image:

Code: [Select]
//==========
// Globals
//==========
$puts(background,'C:\Program Files\foobar2000\FoOrby\bgs')

//==========
// Background
//==========
$windowstyle(showtitlebar)
//----------------------------------TOP BARS----------------------------------
$imageabs2(%_width%,%_height%,0,0,1600,1200,0,0,$get(background)\$getpvar(buttoncmd).*,NOKEEPASPECT)

I can't figure out how to make the background panel scroll through the 9 images (back and forward) while making it so that clicking the image sets that image as my background. If having my config would make things any easier, I am willing to do that.

Any help would be really great. Thanks .
Song List: keikoniumboards.ke.funpic.org/files/songlist.html

$pvar() Questions: Need Some Help With My Code

Reply #1
what about using somehting like that:

$button(.......,PVAR:SET:imagechange:1,)

$select($getpvar(imagechange),
image1
,
image2
,
image3
,
image4
)

if you set pvar to 1 image1 will be selected and so on...
ofcourse you need to change the buttoncode to achieve the behaviour. this is just the principle. i think this should work.

edit: and maybe for the button (scrolling forward) something like that (i didn't test it though):


Code: [Select]
$button(.....,
$ifgreater($get(imagechange)
   ,
   3
   ,
   set:pvar:imagechance:1
   ,
   $ifequal($get(imagechange)
      ,
      1
      ,
      set:pvar:imagechance:2
      ,
      )
      $ifequal($get(imagechange)
      ,
      2
      ,
      set:pvar:imagechance:3
      ,
      set:pvar:imagechance:1
      )
   )
,)

 
SimplePortal 1.0.0 RC1 © 2008-2021