Пример #1
0
        public void setNodeNameAndPath(SceneGraph scene, string obj_path)
        {
            string result      = "";
            int    strlenobjec = "object_library".Length;

            if (obj_path.StartsWith("object_library", StringComparison.OrdinalIgnoreCase))
            {
                obj_path = obj_path.Remove(0, strlenobjec + 1);
            }
            if (Tools.groupInLibSub(obj_path))
            {
                result = "object_library/";
            }

            result += obj_path;
            int    last_separator = result.LastIndexOf('/');
            string key            = result.Substring(last_separator + 1);
            string lowkey         = key.ToLower();

            if (!scene.name_to_node.ContainsKey(lowkey))
            {
                scene.name_to_node[lowkey] = this;
            }

            m_name = key;
            m_dir  = "";

            if (last_separator != -1)
            {
                m_dir = result.Substring(0, last_separator);
            }
        }
Пример #2
0
        public string groupRename(string oldname, bool is_def)
        {
            string str = oldname.Contains('/') ? String.Copy(oldname) : m_renamer.basename + '/' + oldname;

            if (Tools.groupInLibSub(str))
            {
                return(str);
            }
            if (!is_def && !str.ToLower().Contains("/grp") && !str.ToLower().Contains("/map"))
            {
                return(str);
            }

            string querystring = str.ToLower();
            string res         = null;

            if (m_renamer.new_names.TryGetValue(querystring, out res))
            {
                return(res);
            }

            string prefix = str;
            int    gidx   = prefix.IndexOf("/grp", 0, StringComparison.OrdinalIgnoreCase);

            if (gidx != -1)
            {
                prefix = prefix.Substring(gidx + 4); // skip /grp
                var m      = Regex.Match(prefix, "[^A-Za-z]");
                int finidx = prefix.Length;
                if (m.Success)
                {
                    finidx = m.Index;
                }
                prefix = prefix.Substring(0, finidx); // collect chars to first non-letter
            }
            else
            {
                if (prefix.ToLower().Contains("/map"))
                {
                    prefix = "maps/grp";
                }
                else
                {
                    Debug.Log("bad def name:" + prefix);
                    prefix = "baddef";
                }
            }

            string tgt = groupMakeName(prefix);

            m_renamer.new_names[querystring] = tgt;
            return(tgt);
        }