示例#1
0
        //============================================================
        // <T>扫描资源控制台。</T>
        //
        // @author TYFNG 20120409
        //============================================================
        public void Scan()
        {
            // 检查文件存在性
            if (!RDirectory.Exists(_directory))
            {
                return;
            }
            // 扫描文件
            FStrings fileNames = RDirectory.ListFiles(_directory);

            foreach (string fileName in fileNames)
            {
                // 检查后缀
                if (!fileName.EndsWith(".xml"))
                {
                    continue;
                }
                // 解析资源
                string     name    = fileName.Substring(fileName.LastIndexOf("\\") + 1);
                string     code    = name.Substring(0, name.Length - 4);
                FRsDataset dataset = new FRsDataset();
                dataset.Code     = code;
                dataset.FileName = fileName;
                _datasets.Set(code, dataset);
            }
        }
示例#2
0
        //============================================================
        // <T>扫描工作路径,获得对象列表。</T>
        //============================================================
        public override void Scan()
        {
            base.Scan();
            // 设置目录
            _exportFileName = _directoryExprot + "\\tx_" + Code + ".swf";
            // 查询图片
            string resourceDirectory = RContent3dManager.TextureConsole.ResourceDirectory;

            foreach (string filename in RDirectory.ListFiles(_directory))
            {
                if (filename.EndsWith(".jpg"))
                {
                    FFileInfo        info   = new FFileInfo(filename);
                    FDrTextureBitmap bitmap = new FDrTextureBitmap();
                    bitmap.TypeCd   = EDrTexture.Diffuse;
                    bitmap.Source   = info.FullName.Substring(resourceDirectory.Length);
                    bitmap.FileName = info.FullName;
                    bitmap.Length   = info.Info.Length;
                    _bitmaps.Push(bitmap);
                }
            }
            // 加载设置文件
            if (RFile.Exists(_configFileName))
            {
                LoadConfigFile(_configFileName);
            }
        }
示例#3
0
        static void FilterProject(string projectName, string path)
        {
            // 获得项目文件集合
            FDictionary <SFileInfo> infos = new FDictionary <SFileInfo>();

            foreach (string fileName in RDirectory.ListFiles(path))
            {
                if (fileName.EndsWith(".h") || fileName.EndsWith(".cpp"))
                {
                    string    formatName = fileName.Replace('\\', '/');
                    string    name       = RString.Right(formatName, "/");
                    SFileInfo info       = new SFileInfo();
                    info.fileName = formatName;
                    info.include  = false;
                    infos.Set(name, info);
                }
            }
            // 查找使用中的文件集合
            string       configFileName = path + "/vcproject/" + projectName + ".vcxproj";
            FXmlDocument document       = new FXmlDocument(configFileName);

            foreach (FXmlNode xnode in document.Root.Nodes)
            {
                if (xnode.IsName("ItemGroup"))
                {
                    foreach (FXmlNode xfile in xnode.Nodes)
                    {
                        if (xfile.IsName("ClInclude") || xfile.IsName("ClCompile"))
                        {
                            string    include = xfile.Get("Include");
                            string    name    = RString.Right(include, "\\");
                            SFileInfo info    = infos.Find(name);
                            if (info != null)
                            {
                                info.include = true;
                            }
                        }
                    }
                }
            }
            // 查找删除集合
            foreach (SFileInfo info in infos.Values)
            {
                if (!info.include)
                {
                    RLogger.Find(typeof(SFileInfo)).Debug(null, "FilterProject", info.fileName);
                    File.Delete(info.fileName);
                }
            }
            // 查找没用目录
            RDirectory.Delete(path + "/build");
            RDirectory.Delete(path + "/dist");
            RDirectory.Delete(path + "/nbproject/private");
            RDirectory.Delete(path + "/maproject/libs");
            RDirectory.Delete(path + "/maproject/obj");
            RDirectory.Delete(path + "/vcproject/Debug");
            RDirectory.Delete(path + "/vcproject/Release");
            RDirectory.Delete(path + "/vcproject/x64");
            File.Delete(path + "/vcproject/" + projectName + ".vcxproj.user");
        }
示例#4
0
        //============================================================
        // <T>扫描资源。</T>
        //============================================================
        public override void Scan()
        {
            base.Scan();
            // 扫描所有文件
            _optionValid = true;
            FStrings fileNames = RDirectory.ListFiles(_directory);

            fileNames.Sort();
            foreach (string fileName in fileNames)
            {
                // 文件是否图片
                string name = fileName.Substring(fileName.LastIndexOf("\\") + 1);
                if (name.EndsWith(".png"))
                {
                    name = name.Substring(0, name.Length - 4);
                    // 是否符合命名标准
                    if (5 == name.Length)
                    {
                        int direction  = RInt.Parse(name.Substring(0, 1));
                        int frameIndex = RInt.Parse(name.Substring(1)) - 1;
                        // 同步剪辑
                        FRsResourceClip  clip  = SyncClip(direction);
                        FRsResourceFrame frame = new FRsResourceFrame();
                        frame.FileName = fileName;
                        clip.PushFrame(frame);
                        // 设置有效
                        _optionValid = true;
                    }
                    else
                    {
                        RMoCore.TrackConsole.Write(this, "Scan", "Invalid picture define. (file_name={0})", fileName);
                    }
                }
            }
            // 检查剪辑帧数相等
            FRsResourceClip firstClip = FristClip;

            if (null != firstClip)
            {
                foreach (FRsResourceClip clip in _clips)
                {
                    if (clip != null)
                    {
                        if (firstClip.FrameCount != clip.FrameCount)
                        {
                            RMoCore.TrackConsole.Write(this, "Scan", "Animation clip frame is differenty. (first_frames={0}, clip_frames={1})",
                                                       firstClip.FrameCount, clip.FrameCount);
                        }
                    }
                }
            }
            string _configName = _directory + "\\config.xml";

            if (RFile.Exists(_configName))
            {
                FXmlDocument xdoc = new FXmlDocument();
                xdoc.LoadFile(_configName);
                LoadConfig(xdoc.Root);
            }
        }
示例#5
0
 //============================================================
 // <T>打开处理。</T>
 //============================================================
 public void Open()
 {
     if (!RDirectory.Exists(_configDirectory))
     {
         return;
     }
     if (_opened)
     {
         return;
     }
     // 打开文件
     foreach (string fileName in RDirectory.ListFiles(_configDirectory))
     {
         // 检查类型
         if (!fileName.EndsWith(".xml"))
         {
             continue;
         }
         // 创建主题
         FTplTheme theme = new FTplTheme();
         theme.FileName = fileName;
         using (FXmlDocument xdocument = new FXmlDocument(fileName)) {
             theme.LoadConfig(xdocument.Root);
         }
         _themes.Set(theme.Name, theme);
         // 设置默认主题
         if (_activeTheme == null)
         {
             _activeTheme = theme;
         }
     }
     _opened = true;
 }
示例#6
0
        //============================================================
        // <T>扫描工作路径,获得对象列表。</T>
        //============================================================
        public override void Scan()
        {
            base.Scan();
            // 检查文件集合
            FStrings fileNames = RDirectory.ListFiles(_directory);

            foreach (string fileName in fileNames)
            {
                if (fileName.EndsWith(".xml"))
                {
                    string name = RFile.GetFileName(fileName);
                    name = name.Substring(0, name.Length - 4);
                    if (name.StartsWith("import.") || name.StartsWith("temp."))
                    {
                        continue;
                    }
                    FDrScene scene = new FDrScene();
                    scene.Name            = _name;
                    scene.Label           = _label;
                    scene.TechniqueName   = name;
                    scene.Directory       = _directory;
                    scene.DirectoryExprot = _directoryExprot;
                    scene.Scan();
                    _scenes.Push(scene);
                }
            }
            // 设置目录
            _exportFileName = _directoryExprot + "\\sc_" + Code + ".swf";
            // 加载设置文件
            if (RFile.Exists(_configFileName))
            {
                //LoadConfig(new FXmlDocument(_directory + "\\config.xml").Root);
            }
        }
示例#7
0
        //============================================================
        // <T>加载按钮事件。</T>
        //
        // @param sender 事件产生者
        // @param e      数据对象
        //============================================================
        private void tsbReload_Click(object sender, EventArgs e)
        {
            FStrings directorys = RDirectory.ListFiles(_resource.Directory);

            foreach (string fileName in directorys)
            {
                bool haveIt = false;
                if (fileName.EndsWith(".png"))
                {
                    //foreach (FDsResourceClip clip in _resourceAnimation.Clips) {
                    //   if (haveIt) {
                    //      break;
                    //   }
                    //   if (null != clip) {
                    //      foreach (FDsResourceFrame frame in clip.Frames) {
                    //         if (fileName.EndsWith(frame.FileName)) {
                    //            haveIt = true;
                    //            break;
                    //         }
                    //      }
                    //   }
                    //}
                    if (!haveIt)
                    {
                        MessageBox.Show(fileName);
                    }
                }
            }
        }
示例#8
0
        //============================================================
        // <T>加载文件夹信息,取得地址。</T>
        // <P>加载文件下文件信息,取得文件地址。</P>
        //
        // @param directory 文件路径。
        //============================================================
        public void LoadDirectory(string directory)
        {
            // 加载给定路径下面的文件夹.
            FStrings paths = RDirectory.ListDirectories(directory);
            int      count = paths.Count;

            for (int n = 0; n < count; n++)
            {
                // 检查文件夹
                string path = paths[n];
                if (path.Contains(".svn"))
                {
                    continue;
                }
                // 取得文件夹类型名称。
                string fullName = path.Substring(path.LastIndexOf("\\") + 1);
                string id       = fullName.Substring(0, fullName.IndexOf('-'));
                string label    = fullName.Substring(fullName.IndexOf('-') + 1).Trim();
                // 文件夹的全路径地址。
                FDsMapTileCatalog mapTileCatalog = new FDsMapTileCatalog();
                mapTileCatalog.Resource.Id       = RInt.Parse(id);
                mapTileCatalog.Resource.FullName = fullName;
                mapTileCatalog.Resource.Lable    = label;
                _mapTileCatalogs.Push(mapTileCatalog.Resource);
                //加载瓦片图片集合
                FStrings files     = RDirectory.ListFiles(path);
                int      fileCount = files.Count;
                for (int i = 0; i < fileCount; i++)
                {
                    string file = files[i];
                    if (!file.Contains(".png"))
                    {
                        continue;
                    }
                    // 取得文件名称。
                    string tileId   = file.Substring(file.LastIndexOf("\\") + 1, 4);
                    Bitmap resource = new Bitmap(file);
                    // 文件的全路径地址
                    FDsMapTile mapTile = new FDsMapTile();
                    mapTile.Resource.Id       = RInt.Parse(id + "" + tileId);
                    mapTile.Resource.Resource = resource;
                    mapTileCatalog.Resource.MapTiles.Push(mapTile.Resource);
                }
            }
        }
示例#9
0
        //============================================================
        // <T>扫描文件夹。</T>
        //============================================================
        public void Scan()
        {
            // 处理所有子文件
            FStrings fileNames = RDirectory.ListFiles(_directory);

            foreach (string fileName in fileNames)
            {
                if (-1 != fileName.IndexOf(".svn"))
                {
                    continue;
                }
                // 解析资源
                string shortName = fileName.Substring(fileName.LastIndexOf("\\") + 1);
                string name      = shortName.Substring(3);
                // 解析图片资源
                if (shortName.StartsWith("RP-"))
                {
                    string fullName   = name;
                    string label      = name;
                    int    codeIndex  = name.IndexOf("-");
                    int    labelIndex = name.IndexOf(".png");
                    if (-1 != codeIndex)
                    {
                        label    = name.Substring(0, labelIndex);
                        fullName = name.Substring(codeIndex + 1, labelIndex - codeIndex);
                        name     = name.Substring(0, codeIndex);
                    }
                    if (11 == name.Length)
                    {
                        name = name.Replace(".", "");
                        // 创建图片资源
                        int code = RInt.Parse(name);
                        FRsResourcePicture picture = RContent2dManager.ResourceConsole.CreateResource(ERsResource.Picture, code) as FRsResourcePicture;
                        picture.Folder    = this;
                        picture.Code      = code;
                        picture.Name      = name;
                        picture.Label     = label;
                        picture.FullLabel = FullLabel + "\\" + label;
                        picture.Keyword   = label.Replace(".", "");
                        picture.FileName  = fileName;
                        picture.Directory = _directory;
                        picture.Scan();
                        _resources.Push(picture);
                    }
                }
                // 解析音乐资源
                if (shortName.StartsWith("RM-"))
                {
                    string fullName   = name;
                    string label      = name;
                    int    codeIndex  = name.IndexOf("-");
                    int    labelIndex = name.IndexOf(".mp3");
                    if (-1 != codeIndex)
                    {
                        label    = name.Substring(0, labelIndex);
                        fullName = name.Substring(codeIndex + 1, labelIndex - codeIndex);
                        name     = name.Substring(0, codeIndex);
                    }
                    if (11 == name.Length)
                    {
                        name = name.Replace(".", "");
                        // 创建音乐资源
                        int code = RInt.Parse(name);
                        FRsResourceMusic music = RContent2dManager.ResourceConsole.CreateResource(ERsResource.Music, code) as FRsResourceMusic;
                        music.Folder    = this;
                        music.Code      = code;
                        music.Name      = name;
                        music.Label     = label;
                        music.FullLabel = FullLabel + "\\" + label;
                        music.Keyword   = label.Replace(".", "");
                        music.FileName  = fileName;
                        music.Directory = _directory;
                        music.Scan();
                        _resources.Push(music);
                    }
                }
                // 解析声音资源
                if (shortName.StartsWith("RS-"))
                {
                    string fullName   = name;
                    string label      = name;
                    int    codeIndex  = name.IndexOf("-");
                    int    labelIndex = name.IndexOf(".mp3");
                    if (-1 != codeIndex)
                    {
                        label    = name.Substring(0, labelIndex);
                        fullName = name.Substring(codeIndex + 1, labelIndex - codeIndex);
                        name     = name.Substring(0, codeIndex);
                    }
                    if (11 == name.Length)
                    {
                        name = name.Replace(".", "");
                        // 创建声音资源
                        int code = RInt.Parse(name);
                        FRsResourceSound sound = RContent2dManager.ResourceConsole.CreateResource(ERsResource.Sound, code) as FRsResourceSound;
                        sound.Folder    = this;
                        sound.Code      = code;
                        sound.Name      = name;
                        sound.Label     = label;
                        sound.FullLabel = FullLabel + "\\" + label;
                        sound.Keyword   = label.Replace(".", "");
                        sound.FileName  = fileName;
                        sound.Directory = _directory;
                        sound.Scan();
                        _resources.Push(sound);
                    }
                }
            }
            // 加载设置信息
            //_configName = _directory + "\\config.xml";
            //if (RFile.Exists(_configName)) {
            //   FXmlDocument xdoc = new FXmlDocument();
            //   xdoc.LoadFile(_configName);
            //   foreach (FXmlNode xnode in xdoc.Root.Nodes) {
            //      if (xnode.IsName("Object")) {
            //         string code = null;
            //         if (xnode.Contains("code")) {
            //            code = xnode.Get("code");
            //         } else {
            //            code = xnode.Get("id", String.Empty);
            //         }
            //         if ("" == code) {
            //         }
            //         //FDsResource resource = FindResourceById(code);
            //         //if(null != resource) {
            //         //   resource.LoadConfig(xnode);
            //         //}
            //      }
            //   }
            //}
        }
示例#10
0
        //============================================================
        // <T>扫描工作路径,获得对象列表。</T>
        //============================================================
        public override void Scan()
        {
            base.Scan();
            // 设置目录
            _exportFileName = _directoryExprot + "\\tx_" + Code + ".swf";
            // 查询图片
            string resourceDirectory = RContent3dManager.TextureConsole.ResourceDirectory;

            foreach (string filename in RDirectory.ListFiles(_directory))
            {
                if (filename.EndsWith("layer.merge.jpg"))
                {
                    // 加入和冰层
                    FFileInfo        info   = new FFileInfo(filename);
                    FDrTextureBitmap bitmap = new FDrTextureBitmap();
                    bitmap.TypeCd   = EDrTexture.LayerMerge;
                    bitmap.Source   = info.FullName.Substring(resourceDirectory.Length);
                    bitmap.FileName = info.FullName;
                    bitmap.Length   = info.Info.Length;
                    _bitmaps.Push(bitmap);
                }
            }
            foreach (string filename in RDirectory.ListFiles(_directory))
            {
                if (filename.EndsWith("layer.merge.jpg"))
                {
                    continue;
                }
                else if (filename.EndsWith(".jpg") && !filename.EndsWith(".m.jpg"))
                {
                    // 加入纹理层
                    FFileInfo        info   = new FFileInfo(filename);
                    FDrTextureBitmap bitmap = new FDrTextureBitmap();
                    if (filename.EndsWith("layer.1.jpg"))
                    {
                        bitmap.TypeCd = EDrTexture.Layer1;
                    }
                    else if (filename.EndsWith("layer.2.jpg"))
                    {
                        bitmap.TypeCd = EDrTexture.Layer2;
                    }
                    else if (filename.EndsWith("layer.3.jpg"))
                    {
                        bitmap.TypeCd = EDrTexture.Layer3;
                    }
                    else if (filename.EndsWith("layer.4.jpg"))
                    {
                        bitmap.TypeCd = EDrTexture.Layer4;
                    }
                    bitmap.Source   = info.FullName.Substring(resourceDirectory.Length);
                    bitmap.FileName = info.FullName;
                    bitmap.Length   = info.Info.Length;
                    _bitmaps.Push(bitmap);
                }
            }
            // 加载设置文件
            if (RFile.Exists(_configFileName))
            {
                LoadConfigFile(_configFileName);
            }
        }