/// Descend into the path specified by \p arr, and add a new child there. /// Should be used only by Fl_Tree's internals. /// Adds the item based on the value of prefs.sortorder(). /// Fl_Tree_Item *Fl_Tree_Item::add(const Fl_Tree_Prefs &prefs, char **arr) { int t = find_child(*arr); Fl_Tree_Item *item; if ( t == -1 ) { item = (Fl_Tree_Item*)add(prefs, *arr); } else { item = (Fl_Tree_Item*)child(t); } if ( *(arr+1) ) { // descend? return(item->add(prefs, arr+1)); } else { return(item); // end? done } }
void init_appendai_list() { std::shared_ptr<AppendAIPatch> aip = std::dynamic_pointer_cast<AppendAIPatch>(mods->get("aip")); Fl_Tree* tree = new Fl_Tree(5, 70+40, 254, 70, "Hybrid Enemies Mod"); if(!aip->valid()) { tree->deactivate(); return; } Fl_Tree_Item* first = tree->first(); first->label("Enemy AI"); AppendAIPatch::entity_storage appended_ais = aip->appended_ai(); int idx = 0; for(unsigned ai : appended_ais) { first->add(Fl_Tree_Prefs(), AppendAIPatch::FriendlyName(ai).c_str())->user_data(new int(idx)); idx++; } new AddAIButton(150, 145+40, 35, 20, "Add"); new RemoveAIButton(190, 145+40, 70, 20, "Remove"); appended_ai_tree = tree; }