public static void RemoveNewNodeName(cGUID id) { ShortGUIDDescriptor desc = customNodeNames.FirstOrDefault(o => o.ID == id); if (desc == null) { return; } customNodeNames.Remove(desc); }
public static string GetEntityName(cGUID id) { string id_string = id.ToString(); ShortGUIDDescriptor desc = customNodeNames.FirstOrDefault(o => o.ID_cachedstring == id_string); if (desc == null) { return(NodeDB.GetEditorName(id)); } return(desc.Description); }
//Get parameter/entity name //We fall through to NodeDB here which means we can replace all NodeDB calls to Cathode/Editor name in the GUI app public static string GetParameterName(cGUID id) { string id_string = id.ToString(); ShortGUIDDescriptor desc = customParamNames.FirstOrDefault(o => o.ID_cachedstring == id_string); if (desc == null) { return(NodeDB.GetCathodeName(id, CurrentInstance.commandsPAK)); } return(desc.Description); }
//To be called directly after loading the pak using CathodeLib public static void LoadNames() { customParamNames = new List <ShortGUIDDescriptor>(); customNodeNames = new List <ShortGUIDDescriptor>(); BinaryReader reader = new BinaryReader(File.OpenRead(CurrentInstance.commandsPAK.Filepath)); reader.BaseStream.Position = 20; int end_of_pak = reader.ReadInt32() * 4; end_of_pak += reader.ReadInt32() * 4; reader.BaseStream.Position = end_of_pak; int content_after_pak = (int)reader.BaseStream.Length - end_of_pak; if (content_after_pak == 0) { return; } int number_of_custom_param_names = reader.ReadInt32(); for (int i = 0; i < number_of_custom_param_names; i++) { ShortGUIDDescriptor thisDesc = new ShortGUIDDescriptor(); thisDesc.ID = Utilities.Consume <cGUID>(reader); thisDesc.Description = reader.ReadString(); customParamNames.Add(thisDesc); } for (int i = 0; i < customParamNames.Count; i++) { customParamNames[i].ID_cachedstring = customParamNames[i].ID.ToString(); } int number_of_custom_node_names = reader.ReadInt32(); for (int i = 0; i < number_of_custom_node_names; i++) { ShortGUIDDescriptor thisDesc = new ShortGUIDDescriptor(); thisDesc.ID = Utilities.Consume <cGUID>(reader); thisDesc.Description = reader.ReadString(); customNodeNames.Add(thisDesc); } for (int i = 0; i < customNodeNames.Count; i++) { customNodeNames[i].ID_cachedstring = customNodeNames[i].ID.ToString(); } reader.Close(); }
//Add new param/node names public static void AddNewParameterName(cGUID id, string name) { ShortGUIDDescriptor desc = customParamNames.FirstOrDefault(o => o.ID == id); if (desc != null) { desc.Description = name; } else { customParamNames.Add(new ShortGUIDDescriptor { ID = id, ID_cachedstring = id.ToString(), Description = name }); } }
//-- public static void AddNewNodeName(cGUID id, string name) { ShortGUIDDescriptor desc = customNodeNames.FirstOrDefault(o => o.ID == id); if (desc != null) { desc.Description = name; } else { customNodeNames.Add(new ShortGUIDDescriptor { ID = id, ID_cachedstring = id.ToString(), Description = name }); } EditorUtils.PurgeEntityNameFromCache(id); }