Exemplo n.º 1
0
 private void m_propertyGrid_ValidatePropertyValue(object sender, ValidatePropertyValueEventArgs e)
 {
     if (e.PropertyName == "Name")
     {
         if (e.NewValue == null || NodeNameUtil.HasNameCollisionWithSiblings(m_propertyGrid.SelectedObject as Node, e.NewValue.ToString()))
         {
             // 未通过验证就撤销更改
             e.Cancel  = true;
             e.Message = "该命名与当前父节点下的其他节点有冲突,请重新命名。";
         }
     }
 }
Exemplo n.º 2
0
        public bool Init(BootParams bp)
        {
            // 请理性工作
            if (Scene.Instance != null)
            {
                Scene.Instance.Dispose();
            }
            if (ResourceManager.Instance != null)
            {
                ResourceManager.Instance.Clear();
            }

            ArchiveUtil.ClearCreators();
            NodeNameUtil.ResetIDAllocLut();

            // 初始化工厂
            ArchiveUtil.RegisterCreator(ArchiveType.Json, typeof(Archive_Json));

            // 初始化资源系统
            if (!ResourceManager.Instance.LoadDefault(Path.Combine(bp.ReourcePath, bp.DefaultReourceImage)))
            {
                Logging.Instance.Log("加载默认资源 ('{0}') 失败.", bp.DefaultReourceImage);
                return(false);
            }
            if (bp.ReourceImages != null)
            {
                foreach (string resFile in bp.ReourceImages)
                {
                    string resCombined = Path.Combine(bp.ReourcePath, resFile);
                    if (!ResourceManager.Instance.LoadFile(resCombined))
                    {
                        Logging.Instance.Log("加载资源 ('{0}') 失败.", resCombined);
                        return(false);
                    }
                }
            }

            // 用户 atlas 加载
            if (bp.ScenePath.Length > 0)
            {
                string userAtlasName = Path.GetFileNameWithoutExtension(bp.ScenePath);
                string userAtlasPath = Path.Combine(Path.GetDirectoryName(bp.ScenePath), userAtlasName);
                if (!ResourceManager.Instance.LoadFile(userAtlasPath, userAtlasName))
                {
                    Logging.Instance.Log("加载用户资源 ('{0}') 失败.", userAtlasPath);
                }
                else
                {
                    Logging.Instance.Log("加载用户资源 ('{0}') 成功.", userAtlasPath);
                }
            }

            // 初始化场景
            Scene.Instance = new Scene();
            if (!Scene.Instance.Init(bp.DesignTimeResolution))
            {
                return(false);
            }
            if (bp.ScenePath.Length != 0 && !Scene.Instance.Load(bp.ScenePath))
            {
                return(false);
            }
            Logging.Instance.Log("场景初始化成功.");

            return(true);
        }