Sort tasks within task categories
This commit is contained in:
parent
2ffcbf0565
commit
04cb2b1560
|
@ -83,6 +83,10 @@ void LimboTaskDB::scan_user_tasks() {
|
||||||
String dir1 = GLOBAL_GET("limbo_ai/behavior_tree/user_task_dir_" + itos(i));
|
String dir1 = GLOBAL_GET("limbo_ai/behavior_tree/user_task_dir_" + itos(i));
|
||||||
_populate_from_user_dir(dir1, &tasks_cache);
|
_populate_from_user_dir(dir1, &tasks_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (KeyValue<String, List<String>> &E : tasks_cache) {
|
||||||
|
E.value.sort_custom<ComparatorByTaskName>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> LimboTaskDB::get_categories() {
|
List<String> LimboTaskDB::get_categories() {
|
||||||
|
|
|
@ -21,6 +21,12 @@ private:
|
||||||
static HashMap<String, List<String>> core_tasks;
|
static HashMap<String, List<String>> core_tasks;
|
||||||
static HashMap<String, List<String>> tasks_cache;
|
static HashMap<String, List<String>> tasks_cache;
|
||||||
|
|
||||||
|
struct ComparatorByTaskName {
|
||||||
|
bool operator()(const String &p_left, const String &p_right) const {
|
||||||
|
return get_task_name(p_left) < get_task_name(p_right);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <class T>
|
template <class T>
|
||||||
static void register_task() {
|
static void register_task() {
|
||||||
|
@ -39,6 +45,13 @@ public:
|
||||||
static _FORCE_INLINE_ String get_misc_category() { return "Misc"; }
|
static _FORCE_INLINE_ String get_misc_category() { return "Misc"; }
|
||||||
static List<String> get_categories();
|
static List<String> get_categories();
|
||||||
static List<String> get_tasks_in_category(const String &p_category);
|
static List<String> get_tasks_in_category(const String &p_category);
|
||||||
|
static _FORCE_INLINE_ String get_task_name(String p_class_or_script_path) {
|
||||||
|
if (p_class_or_script_path.begins_with("res:")) {
|
||||||
|
return p_class_or_script_path.get_file().get_basename().trim_prefix("BT").to_pascal_case();
|
||||||
|
} else {
|
||||||
|
return p_class_or_script_path.trim_prefix("BT");
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LIMBO_REGISTER_TASK(m_class) \
|
#define LIMBO_REGISTER_TASK(m_class) \
|
||||||
|
|
Loading…
Reference in New Issue