//Script by Evil Pumpkin for "BOH" (unreleased)
// modded by me.... "Evil Pumpkin 0wnz joo!!"
// 
// 

#include "../../../lib/std.mi"

Global Int voling,seeking,now;
Global String Hitten;
Global slider hidseek,hidvol;

Global layer Vol,volfull,seek1,seekfull;
Global map volmap,seekmap;
Global region volregion,seekregion;
Global Layout plnormal;

Function volumeinit();

System.onscriptloaded(){
 Group plgroup = getContainer("Pledit").getLayout("plnormal").getObject("Pl.component.group");
 hidseek = plgroup.getObject("hidseek");
 hidvol = plgroup.getObject("hidvol");

 vol = plgroup.getObject("vol");
 volfull = plgroup.getObject("volfull");
 volregion = New Region;
 volregion.loadfrombitmap("volumeregion");
 vol.setregion(volregion);
 volmap = New Map;
 volmap.loadmap("volumemap");

 seek1 = plgroup.getObject("seek1");
 seekfull = plgroup.getObject("seekfull");
 seekregion = New Region;
 seekregion.loadfrombitmap("seekregion");
 seek1.setregion(seekregion);
 seekmap = New Map;
 seekmap.loadmap("seekmap");

 volumeinit();
 seekfull.hide();
}

vol.onleftbuttondown(int x, int y){
 voling=1;
 x = x-vol.getleft();
 y = y-vol.gettop();
 if (volmap.inregion(x,y)){
  int c = volmap.getvalue(x,y);
  volfull.setregionfrommap(volmap,c,1);
  setvolume(c);
 } 
}
vol.onleftbuttonup(int x, int y){voling=0;}
vol.onmousemove(int x, int y){
 if (voling){
  x = x-vol.getleft();
  y = y-vol.gettop();
  if (volmap.inregion(x,y)){
   int c = volmap.getvalue(x,y);
   volfull.setregionfrommap(volmap,c,1);
   setvolume(c);
  } 
 }
}

hidvol.onpostedposition(int p){
 volfull.setregionfrommap(volmap,p,1); 
}

seek1.onleftbuttondown(int x, int y){
 seeking = 1;
 x= x-seek1.getleft();
 y= y-seek1.gettop();
 if (seekmap.inregion(x,y)){
  now= seekmap.getvalue(x,y);
  seekfull.setregionfrommap(seekmap,now,1);
 }
}

seek1.onmousemove(int x, int y){
 if (seeking){
  x= x-seek1.getleft();
  y= y-seek1.gettop();
  if (seekmap.inregion(x,y)){
   now= seekmap.getvalue(x,y);
   seekfull.setregionfrommap(seekmap,now,1);
  }
 }
}

seek1.onleftbuttonup(int x, int y){
 now = now/255*system.getplayitemlength();
 seekto(now);
 seeking=0;
}

hidseek.onpostedposition(int p){
 if (!seeking){seekfull.show();seekfull.setregionfrommap(seekmap,p,1);} 
}

System.onstop(){
 seekfull.hide();
}

volumeinit(){
 int c = getvolume();
 volfull.setregionfrommap(volmap,c,1);
}
