예제 #1
0
void dsp_preset_switcher::findDspNames( pfc::list_t<pfc::string8> &out ) const
{
	// storing menu handles may not be a good idea, since the user can change DSP preset settings without notify this component

	out.remove_all();

	// enumerate mainmenu items
	service_enum_t<mainmenu_commands> e;
	service_ptr_t<mainmenu_commands_v2> ptr;
	while( e.next( ptr ) )
	{
		for( t_uint32 i = 0 , imax = ptr->get_command_count(); i < imax; ++i )
		{
			// lock-on on DSP settings
			pfc::string8 group_name;
			ptr->get_name( i , group_name );
			const char *DSP_PARENT_STR = "DSP";  // partial match, hope to work with non-English locale
			if( strstr( group_name.toString() , DSP_PARENT_STR ) == nullptr )
				continue;

			// should be a dynamic item
			if( !ptr->is_command_dynamic( i ) )
			{
				console::printf( CONSOLE_HEADER "%s(): item is NOT dynamic!!" , __FUNCTION__ );
				continue;
			}
			const mainmenu_node::ptr dsp_group_node = ptr->dynamic_instantiate( i );

			// should be a group node
			if( dsp_group_node->get_type() != mainmenu_node::type_group )
			{
				console::printf( CONSOLE_HEADER "%s(): node is NOT type_group!!" , __FUNCTION__ );
				continue;
			}

			// enumerate dsp names
			for( t_size j = 0 , jmax = dsp_group_node->get_children_count(); ( j < jmax ) && ( jmax > 1 ) ; ++j )  // jmax == 1 when there only exist "Preferences" items
			{
				const mainmenu_node::ptr dsp_item_node = dsp_group_node->get_child( j );
				if( dsp_item_node->get_type() == mainmenu_node::type_command )
				{
					pfc::string8 n;
					t_uint32 d;
					dsp_item_node->get_display( n , d );
					out.add_item( n );
					//console::printf( CONSOLE_HEADER "%s" , n.toString() );
				}
				else if( dsp_item_node->get_type() == mainmenu_node::type_separator )
				{
					// stop when encountered type_separator
					break;
				}
			}
			return;
		}
	}

	return;
}
예제 #2
0
bool dsp_preset_switcher::selDspName( const int idx , const char *name ) const
{
	// notify first
	syncSelection( idx );

	// find menu item
	service_enum_t<mainmenu_commands> e;
	service_ptr_t<mainmenu_commands_v2> ptr;
	while( e.next( ptr ) )
	{
		for( t_uint32 i = 0 , imax = ptr->get_command_count(); i < imax; ++i )
		{
			// lock-on on DSP settings
			pfc::string8 group_name;
			ptr->get_name( i , group_name );
			const char *DSP_PARENT_STR = "DSP";  // partial match, hope to work with non-English locale
			if( strstr( group_name.toString() , DSP_PARENT_STR ) == nullptr )
				continue;

			// should be a dynamic item
			if( !ptr->is_command_dynamic( i ) )
			{
				console::printf( CONSOLE_HEADER "%s(): item is NOT dynamic!!" , __FUNCTION__ );
				continue;
			}
			const mainmenu_node::ptr dsp_group_node = ptr->dynamic_instantiate( i );

			// should be a group node
			if( dsp_group_node->get_type() != mainmenu_node::type_group )
			{
				console::printf( CONSOLE_HEADER "%s(): node is NOT type_group!!" , __FUNCTION__ );
				continue;
			}

			// enumerate dsp names
			for( t_size j = 0 , jmax = dsp_group_node->get_children_count(); ( j < jmax ) && ( jmax > 1 ) ; ++j )  // jmax == 1 when there only exist "Preferences" items
			{
				const mainmenu_node::ptr dsp_item_node = dsp_group_node->get_child( j );
				if( dsp_item_node->get_type() == mainmenu_node::type_command )
				{
					pfc::string8 n;
					t_uint32 d;
					dsp_item_node->get_display( n , d );
					if( strncmp( name , n.get_ptr() , strlen( name ) ) == 0 )
					{
						// change core settings
						dsp_item_node->execute( nullptr );
						return true;
					}
				}
			}
			return false;
		}
	}

	return false;
}
예제 #3
0
	bool mainmenunode_subguid_to_path(const mainmenu_node::ptr & ptr_node, const GUID & p_subguid, pfc::string8 & p_out, bool b_is_root)
	{
		if (ptr_node.is_valid())
		{
			switch (ptr_node->get_type())
			{
			case mainmenu_node::type_command:
			{
				if (p_subguid == ptr_node->get_guid())
				{
					t_uint32 flags;
					ptr_node->get_display(p_out, flags);
					return true;
				}
			}
			return false;
			case mainmenu_node::type_group:
			{
				mainmenu_node::ptr ptr_child;
				for (t_size i = 0, count = ptr_node->get_children_count(); i<count; i++)
				{
					ptr_child = ptr_node->get_child(i);
					pfc::string8 name;
					if (mainmenunode_subguid_to_path(ptr_child, p_subguid, name))
					{
						if (b_is_root)
							p_out = name;
						else
						{
							t_uint32 flags;
							ptr_node->get_display(p_out, flags);
							p_out << "/" << name;
						}
						return true;
					}
				}
			}
			return false;
			default:
				return false;
			};
		}
		return false;
	}