Commit 28956620 authored by JP Dinger's avatar JP Dinger

Skins2: Cosmetics. Add a REGISTER_CMD1 for commands with one argument.

parent 0fb4941e
...@@ -49,6 +49,8 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf ) ...@@ -49,6 +49,8 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf )
/// Create the generic commands /// Create the generic commands
#define REGISTER_CMD( name, cmd ) \ #define REGISTER_CMD( name, cmd ) \
m_commandMap[name] = CmdGenericPtr( new cmd( getIntf() ) ); m_commandMap[name] = CmdGenericPtr( new cmd( getIntf() ) );
#define REGISTER_CMD1( name, cmd, a1 ) \
m_commandMap[name] = CmdGenericPtr( new cmd( getIntf(), a1 ) );
REGISTER_CMD( "none", CmdDummy ) REGISTER_CMD( "none", CmdDummy )
REGISTER_CMD( "dialogs.changeSkin()", CmdDlgChangeSkin ) REGISTER_CMD( "dialogs.changeSkin()", CmdDlgChangeSkin )
...@@ -78,23 +80,15 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf ) ...@@ -78,23 +80,15 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf )
REGISTER_CMD( "playlist.add()", CmdDlgAdd ) REGISTER_CMD( "playlist.add()", CmdDlgAdd )
REGISTER_CMD( "playlist.next()", CmdPlaylistNext ) REGISTER_CMD( "playlist.next()", CmdPlaylistNext )
REGISTER_CMD( "playlist.previous()", CmdPlaylistPrevious ) REGISTER_CMD( "playlist.previous()", CmdPlaylistPrevious )
m_commandMap["playlist.setRandom(true)"] = REGISTER_CMD1( "playlist.setRandom(true)", CmdPlaylistRandom, true )
CmdGenericPtr( new CmdPlaylistRandom( getIntf(), true ) ); REGISTER_CMD1( "playlist.setRandom(false)", CmdPlaylistRandom, false )
m_commandMap["playlist.setRandom(false)"] = REGISTER_CMD1( "playlist.setLoop(true)", CmdPlaylistLoop, true )
CmdGenericPtr( new CmdPlaylistRandom( getIntf(), false ) ); REGISTER_CMD1( "playlist.setLoop(false)", CmdPlaylistLoop, false )
m_commandMap["playlist.setLoop(true)"] = REGISTER_CMD1( "playlist.setRepeat(true)", CmdPlaylistRepeat, true )
CmdGenericPtr( new CmdPlaylistLoop( getIntf(), true ) ); REGISTER_CMD1( "playlist.setRepeat(false)", CmdPlaylistRepeat, false )
m_commandMap["playlist.setLoop(false)"] =
CmdGenericPtr( new CmdPlaylistLoop( getIntf(), false ) );
m_commandMap["playlist.setRepeat(true)"] =
CmdGenericPtr( new CmdPlaylistRepeat( getIntf(), true ) );
m_commandMap["playlist.setRepeat(false)"] =
CmdGenericPtr( new CmdPlaylistRepeat( getIntf(), false ) );
VarTree &rVarTree = VlcProc::instance( getIntf() )->getPlaytreeVar(); VarTree &rVarTree = VlcProc::instance( getIntf() )->getPlaytreeVar();
m_commandMap["playlist.del()"] = REGISTER_CMD1( "playlist.del()", CmdPlaytreeDel, rVarTree )
CmdGenericPtr( new CmdPlaytreeDel( getIntf(), rVarTree ) ); REGISTER_CMD1( "playtree.del()", CmdPlaytreeDel, rVarTree )
m_commandMap["playtree.del()"] =
CmdGenericPtr( new CmdPlaytreeDel( getIntf(), rVarTree ) );
REGISTER_CMD( "playlist.sort()", CmdPlaytreeSort ) REGISTER_CMD( "playlist.sort()", CmdPlaytreeSort )
REGISTER_CMD( "playtree.sort()", CmdPlaytreeSort ) REGISTER_CMD( "playtree.sort()", CmdPlaytreeSort )
REGISTER_CMD( "vlc.fullscreen()", CmdFullscreen ) REGISTER_CMD( "vlc.fullscreen()", CmdFullscreen )
...@@ -112,10 +106,8 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf ) ...@@ -112,10 +106,8 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf )
REGISTER_CMD( "vlc.toggleRecord()", CmdToggleRecord ) REGISTER_CMD( "vlc.toggleRecord()", CmdToggleRecord )
REGISTER_CMD( "vlc.nextFrame()", CmdNextFrame ) REGISTER_CMD( "vlc.nextFrame()", CmdNextFrame )
REGISTER_CMD( "vlc.quit()", CmdQuit ) REGISTER_CMD( "vlc.quit()", CmdQuit )
m_commandMap["equalizer.enable()"] = REGISTER_CMD1( "equalizer.enable()", CmdSetEqualizer, true )
CmdGenericPtr( new CmdSetEqualizer( getIntf(), true ) ); REGISTER_CMD1( "equalizer.disable()", CmdSetEqualizer, false )
m_commandMap["equalizer.disable()"] =
CmdGenericPtr( new CmdSetEqualizer( getIntf(), false ) );
// Register the constant bool variables in the var manager // Register the constant bool variables in the var manager
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
...@@ -123,6 +115,9 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf ) ...@@ -123,6 +115,9 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf )
pVarManager->registerVar( VariablePtr( pVarTrue ), "true" ); pVarManager->registerVar( VariablePtr( pVarTrue ), "true" );
VarBool *pVarFalse = new VarBoolFalse( getIntf() ); VarBool *pVarFalse = new VarBoolFalse( getIntf() );
pVarManager->registerVar( VariablePtr( pVarFalse ), "false" ); pVarManager->registerVar( VariablePtr( pVarFalse ), "false" );
#undef REGISTER_CMD
#undef REGISTER_CMD1
} }
...@@ -130,12 +125,9 @@ Interpreter *Interpreter::instance( intf_thread_t *pIntf ) ...@@ -130,12 +125,9 @@ Interpreter *Interpreter::instance( intf_thread_t *pIntf )
{ {
if( ! pIntf->p_sys->p_interpreter ) if( ! pIntf->p_sys->p_interpreter )
{ {
Interpreter *pInterpreter; Interpreter *pInterpreter = new (std::nothrow) Interpreter( pIntf );
pInterpreter = new Interpreter( pIntf );
if( pInterpreter ) if( pInterpreter )
{
pIntf->p_sys->p_interpreter = pInterpreter; pIntf->p_sys->p_interpreter = pInterpreter;
}
} }
return pIntf->p_sys->p_interpreter; return pIntf->p_sys->p_interpreter;
} }
...@@ -515,40 +507,29 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme ) ...@@ -515,40 +507,29 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
VarPercent *Interpreter::getVarPercent( const string &rName, Theme *pTheme ) VarPercent *Interpreter::getVarPercent( const string &rName, Theme *pTheme )
{ {
// Try to get the variable from the variable manager
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
VarPercent *pVar = (VarPercent*)pVarManager->getVar( rName, "percent" ); return static_cast<VarPercent*>(pVarManager->getVar( rName, "percent" ));
return pVar;
} }
VarList *Interpreter::getVarList( const string &rName, Theme *pTheme ) VarList *Interpreter::getVarList( const string &rName, Theme *pTheme )
{ {
// Try to get the variable from the variable manager
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
VarList *pVar = (VarList*)pVarManager->getVar( rName, "list" ); return static_cast<VarList*>(pVarManager->getVar( rName, "list" ));
return pVar;
} }
VarTree *Interpreter::getVarTree( const string &rName, Theme *pTheme ) VarTree *Interpreter::getVarTree( const string &rName, Theme *pTheme )
{ {
// Try to get the variable from the variable manager
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
VarTree *pVar = (VarTree*)pVarManager->getVar( rName, "tree" ); return static_cast<VarTree*>(pVarManager->getVar( rName, "tree" ));
return pVar;
} }
string Interpreter::getConstant( const string &rValue ) string Interpreter::getConstant( const string &rValue )
{ {
// Check if the value is a registered constant // Check if the value is a registered constant; if not, keep as is.
string val = VarManager::instance( getIntf() )->getConst( rValue ); string val = VarManager::instance( getIntf() )->getConst( rValue );
if( val.empty() ) return val.empty() ? rValue : val;
{
// if not, keep the value as is
val = rValue;
}
return val;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment