Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/SDK/mainmenu.cpp @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #include "foobar2000-sdk-pch.h" | |
| 2 #include "menu_helpers.h" | |
| 3 | |
| 4 bool mainmenu_commands::g_execute_dynamic(const GUID & p_guid, const GUID & p_subGuid,service_ptr_t<service_base> p_callback) { | |
| 5 mainmenu_commands::ptr ptr; t_uint32 index; | |
| 6 if (!menu_item_resolver::g_resolve_main_command(p_guid, ptr, index)) return false; | |
| 7 mainmenu_commands_v2::ptr v2; | |
| 8 if (!ptr->service_query_t(v2)) return false; | |
| 9 if (!v2->is_command_dynamic(index)) return false; | |
| 10 bool rv = false; | |
| 11 fb2k::crashOnException([&] { | |
| 12 rv = v2->dynamic_execute(index, p_subGuid, p_callback);; | |
| 13 }, "mainmenu_commands::dynamic_execute"); | |
| 14 return rv; | |
| 15 } | |
| 16 bool mainmenu_commands::g_execute(const GUID & p_guid,service_ptr_t<service_base> p_callback) { | |
| 17 mainmenu_commands::ptr ptr; t_uint32 index; | |
| 18 if (!menu_item_resolver::g_resolve_main_command(p_guid, ptr, index)) return false; | |
| 19 fb2k::crashOnException( [&] { | |
| 20 ptr->execute(index, p_callback); | |
| 21 }, "mainmenu_commands::execute"); | |
| 22 return true; | |
| 23 } | |
| 24 | |
| 25 bool mainmenu_commands::g_find_by_name(const char * p_name,GUID & p_guid) { | |
| 26 pfc::string8_fastalloc temp; | |
| 27 for( auto ptr : enumerate() ) { | |
| 28 const t_uint32 count = ptr->get_command_count(); | |
| 29 for(t_uint32 n=0;n<count;n++) { | |
| 30 ptr->get_name(n,temp); | |
| 31 if (stricmp_utf8(temp,p_name) == 0) { | |
| 32 p_guid = ptr->get_command(n); | |
| 33 return true; | |
| 34 } | |
| 35 } | |
| 36 } | |
| 37 return false; | |
| 38 | |
| 39 } | |
| 40 | |
| 41 | |
| 42 static bool dynamic_execute_recur(mainmenu_node::ptr node, const GUID & subID, service_ptr_t<service_base> callback) { | |
| 43 switch(node->get_type()) { | |
| 44 case mainmenu_node::type_command: | |
| 45 if (subID == node->get_guid()) { | |
| 46 node->execute(callback); return true; | |
| 47 } | |
| 48 break; | |
| 49 case mainmenu_node::type_group: | |
| 50 { | |
| 51 const t_size total = node->get_children_count(); | |
| 52 for(t_size walk = 0; walk < total; ++walk) { | |
| 53 if (dynamic_execute_recur(node->get_child(walk), subID, callback)) return true; | |
| 54 } | |
| 55 } | |
| 56 break; | |
| 57 } | |
| 58 return false; | |
| 59 } | |
| 60 | |
| 61 bool mainmenu_commands_v2::is_command_dynamic(t_uint32 index) { | |
| 62 (void)index; return false; | |
| 63 } | |
| 64 mainmenu_node::ptr mainmenu_commands_v2::dynamic_instantiate(t_uint32 index) { | |
| 65 (void)index; uBugCheck(); | |
| 66 } | |
| 67 | |
| 68 bool mainmenu_commands_v2::dynamic_execute(t_uint32 index, const GUID & subID, service_ptr_t<service_base> callback) { | |
| 69 return dynamic_execute_recur(dynamic_instantiate(index), subID, callback); | |
| 70 } |
