View Single Post
Old 9th January 2019, 12:46   #9
ariszlo
Senior Member
 
Join Date: Jun 2015
Location: Hungary
Posts: 490
Getting there. Below is how I edited electricity.m. Now, if I toggle boost on then volume goes up to 100% as expected. If I toggle it off then it returns to the original level. So far so good. If I switch skins or quit Winamp while boost is off then volume is preserved fine. However, if I switch skins or quit Winamp while boost is on then the boost level (= 100%) is saved, not the original level.

What do I need to add to the script to toggle boost of before switching skins or quitting Winamp?

PHP Code:
#include "../../../lib/std.mi"

Global ToggleButton mytoggleboost;
Global 
AnimatedLayer animlayer;
Global 
Boolean elecstatusbooststatus;
Global 
Group stdgrp;
Global 
Int oldvol// added
Global Int olpreamp// added

System.onScriptLoaded()
{
    
stdgrp=getScriptGroup();

    
oldvol system.getVolume(); // added
    
olpreamp system.getEqPreamp(); // added

    
mytoggle=stdgrp.findObject("mytoggle");
    
boost=stdgrp.findObject("boost");
    
animlayer=stdgrp.findObject("animatedlayer");

    
booststatus getPrivateInt("Venom","toggle_boost",0);
    
boost.setActivated(booststatus);
    
boost.onToggle(booststatus);

    
elecstatus getPrivateInt("Venom","toggle_electricity",0);
    
mytoggle.setActivated(elecstatus);
    
mytoggle.onToggle(elecstatus);
}

mytoggle.onToggle(Boolean t)
{
    
setPrivateInt("Venom","toggle_electricity",t);

    if(
t){
        
animlayer.play();
    }else{
        
animlayer.stop();
        
animlayer.gotoFrame(0);
    }
}

boost.onToggle(Boolean t)
{
    
setPrivateInt("Venom","toggle_boost",t);

    if(
t){
        
//setPrivateInt("Venom","old_volume",getVolume());
        //setPrivateInt("Venom","old_preamp",getEqPreamp());
        
setVolume(255);
        
setEqPreamp(127);
        
animlayer.play();
    }else{
        if(!
mytoggle.getActivated()){
            
animlayer.stop();
            
animlayer.gotoFrame(0);
        }
        
//setVolume(getPrivateInt("Venom","old_volume",50));
        //setEqPreamp(getPrivateInt("Venom","old_preamp",0));        
        
system.setVolume(oldvol);
        
system.setEqPreamp(olpreamp);
    }

ariszlo is offline   Reply With Quote