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: titleformat - directly calling common functions on params (Read 1369 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

titleformat - directly calling common functions on params

Is there any way to do something like this?

Code: [Select]
bool titleformat_hook_impl_multiformat::process_function(titleformat_text_out * p_out, const char * p_name, t_size p_name_length, titleformat_hook_function_params * p_params, bool & p_found_flag)
{
    if (0 == pfc::strcmp_ex(p_name, p_name_length, "do_left", pfc::infinite_size)) {
        static_api_ptr_t<titleformat_common_methods> default_api;
        default_api->process_function(m_file_info, m_location, p_out, "left", 4, p_params, p_found_flag);
        return true;
    }
    p_found_flag = false;
    return false;
}


Basically, I'm trying to invoke built-in titleformat functions on my own titleformat_hook_function_params object. But the above code doesn't seem to work (always returns false / not found). This is the only thing I came up with after scouring titleformat.h. Maybe it's not possible....

titleformat - directly calling common functions on params

Reply #1
The titleformat_common_methods service only provides fields and functions to access track metadata. The built-in functions like $left are not accessible this way. You would have to create and execute a script using the desired function and parameters. You could either provide the parameters as constants. Then you would have to escape special characters inside them. You could also provide them via a hook and use something like %1%, %2% (or $arg(1), $arg(2)) in the generated script.

titleformat - directly calling common functions on params

Reply #2
Thanks foosion!

That would be quite a lot of overhead. I guess re-implementing the built-in functions myself is the simplest solution.

titleformat - directly calling common functions on params

Reply #3
Note that you would need to use different names for your re-implemented functions. As far as I remember a hook cannot override any of the built-in functions.

titleformat - directly calling common functions on params

Reply #4
That is correct. :-)