Ejemplo n.º 1
0
 //============================================================
 // <T>加载全部处理。</T>
 //============================================================
 public virtual void LoadAll()
 {
     // 清空集合
     if (_folders != null)
     {
         _folders.Clear();
     }
     if (_objects != null)
     {
         _objects.Clear();
     }
     // 加载所有子目录
     foreach (string path in RDirectory.ListDirectories(_directory))
     {
         // 跳过SVN目录
         if (path.IndexOf(".svn") != -1)
         {
             continue;
         }
         // 加载子目录
         OnLoadFolder(path);
     }
     if (_folders != null)
     {
         _folders.Sort();
     }
     // 加载配置
     if (RFile.Exists(ConfigFileName))
     {
         FXmlDocument xdoc = new FXmlDocument();
         xdoc.LoadFile(ConfigFileName);
         LoadConfig(xdoc.Root);
     }
 }
Ejemplo n.º 2
0
        //============================================================
        // <T>加载窗体信息。<T>
        //============================================================
        public void LoadConfig()
        {
            string       applicationConfig = RMoCommon.GetEnvironment("application.root") + "\\Configuration\\excel.export.xml";
            FXmlDocument xmldoc            = new FXmlDocument();

            xmldoc.LoadFile(applicationConfig);
            foreach (FXmlNode node in xmldoc.Root.Nodes)
            {
                if ("ExcelExportList" == node.Name)
                {
                    _templateSource = node.Get("source_path");
                    _templateTarget = node.Get("target_path");
                    LoadTemplate(node);
                }
                if ("ConverterExportList" == node.Name)
                {
                    _mergerTarget = node.Get("target_path");
                    LoadMerger(node);
                }
                if ("CommandList" == node.Name)
                {
                    LoadCopy(node);
                }
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
 //============================================================
 // <T>加载所有目录。</T>
 //============================================================
 public virtual void LoadFolderAll()
 {
     // 加载所有子目录
     foreach (string path in RDirectory.ListDirectories(_directory))
     {
         // 跳过SVN目录
         if (path.IndexOf(".svn") != -1)
         {
             continue;
         }
         // 加载子目录
         OnLoadFolder(path);
     }
     if (_folders != null)
     {
         _folders.Sort();
     }
     // 加载配置
     if (RFile.Exists(ConfigFileName))
     {
         FXmlDocument xdoc = new FXmlDocument();
         try {
             xdoc.LoadFile(ConfigFileName);
         } catch (Exception e) {
             throw new FFatalException(e, "Open config file error. (file_name={0})", ConfigFileName);
         }
         LoadConfig(xdoc.Root);
     }
 }
Ejemplo n.º 5
0
        public void LoadFile(string filename)
        {
            Clear();
            FXmlDocument xdoc = new FXmlDocument(filename);

            xdoc.LoadFile(filename);
            LoadConfig(xdoc.Root);
        }
Ejemplo n.º 6
0
        //============================================================
        // <T>加载路径。</T>
        //
        // @param directory 路径
        //============================================================
        public static void LoadDirectory(string directory)
        {
            _directory = directory;
            // 加载应用信息
            string appFile = _directory + @"\Tools\Configuration\application.xml";

            if (RFile.Exists(appFile))
            {
                FXmlDocument xdoc = new FXmlDocument();
                // 加载文件
                xdoc.LoadFile(appFile);
                LoadConfig(xdoc.Root);
            }
        }
Ejemplo n.º 7
0
        //============================================================
        // <T>执行复制命令。<T>
        //============================================================
        public void SaveCopy()
        {
            int count = lvwCopy.CheckedItems.Count;

            if (0 != count)
            {
                FXmlDocument xmldoc = new FXmlDocument();
                for (int i = 0; i < count; i++)
                {
                    ListViewItem listViewItem = lvwCopy.Items[i];
                    FXmlNode     node         = listViewItem.Tag as FXmlNode;
                    string       from         = node.Get("from");
                    string       target       = node.Get("target");
                    xmldoc.LoadFile(from);
                    xmldoc.SaveFile(target);
                }
            }
        }
Ejemplo n.º 8
0
        //============================================================
        // <T>加载模型配置文件。</T>
        //
        // @param fileName 文件名称
        //============================================================
        public void LoadModelConfigFile(string fileName)
        {
            FXmlDocument document = new FXmlDocument();

            document.LoadFile(fileName);
            foreach (FXmlNode node in document.Root.Nodes)
            {
                switch (node.Name)
                {
                case "Struct":
                    break;

                case "Scene":
                    LoadModelSceneConfig(node);
                    break;
                }
            }
        }
Ejemplo n.º 9
0
        //============================================================
        // <T>加载配置文件。</T>
        //============================================================
        public static void LoadDirectory(string directory)
        {
            _configFileName = directory + @"\Configuration\configuration.xml";
            // 记载配置文件
            FXmlDocument xdoc = new FXmlDocument();

            xdoc.LoadFile(_configFileName);
            FXmlNode xconfig = xdoc.Root;

            // 加载核心配置
            RMoCore.LoadConfig(xconfig);
            RMoCore.Setup();
            // 加载资源管理
            RMobileManager.Directory = directory;
            RMobileManager.LoadConfig(xconfig);

            RContent2dManager.LoadConfig(xconfig);
            RContent2dManager.Setup();
        }
Ejemplo n.º 10
0
        protected void LoadConfig(string name)
        {
            Assembly  assembly = Assembly.GetEntryAssembly();
            FFileInfo info     = new FFileInfo(assembly.Location);

            _path = info.DirectoryName;
            // Make file name
            string file = null;

            if (name != null && name.IndexOf(':') != -1)
            {
                file = name;
            }
            else
            {
                AssemblyName aname = assembly.GetName();
                if (name == null)
                {
                    file = RFile.MakeFileName(_path, aname.Name);
                }
                else
                {
                    file = RFile.MakeFileName(_path, name);
                }
                if (!file.EndsWith(TYPE_XML))
                {
                    file += TYPE_XML;
                }
            }
            // Load config
            FXmlDocument xdoc = new FXmlDocument();

            //xdoc.Formater.Formater = this;
            _exists = File.Exists(file);
            if (_exists)
            {
                _exists = true;
                xdoc.LoadFile(file);
            }
            // Set config
            _config = xdoc.Root;
            BuildConfigMap(_config);
        }
Ejemplo n.º 11
0
        //============================================================
        // <T>加载配置文件,取得地址。</T>
        //
        // @param directory 文件路径。
        //============================================================
        public void LoadTemplateConfig(string directory)
        {
            FXmlDocument xmldoc = new FXmlDocument();

            xmldoc.LoadFile(directory + "\\enemy.xml");
            foreach (FXmlNode node in xmldoc.Root.Nodes)
            {
                FMbTplEnemy enemy = new FMbTplEnemy();
                enemy.Id           = node.GetInteger("tid");
                enemy.Label        = node.Get("label");
                enemy.HealthPoint  = node.GetInteger("health_point");
                enemy.MagicPoint   = node.GetInteger("magic_point");
                enemy.AttackPower  = node.GetInteger("attack_power");
                enemy.DefensePower = node.GetInteger("defense_power");
                enemy.MoveSpeed    = node.GetInteger("move_speed");
                enemy.IconRid      = node.GetInteger("icon_rid");
                enemy.ResourceRid  = node.GetInteger("resource_rid");
                _enemys.Push(enemy);
            }
        }
Ejemplo n.º 12
0
        //============================================================
        public void XmlToExcel(string fileName, string excelName, string saveName)
        {
            FXmlDocument xml = new FXmlDocument();

            xml.LoadFile(fileName);
            FXmlNode root = xml.Root;

            Excel.Application app      = new Excel.Application();
            Excel.Workbook    workbook = app.Workbooks.Open(excelName,
                                                            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                            Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            Excel.Worksheet columnsWorksheet = workbook.Worksheets["定义"];
            Excel.Worksheet rowsWorksheet    = workbook.Worksheets["数据"];
            LoadFileColumns(columnsWorksheet);
            int rowCount = 3;

            foreach (FXmlNode node in root.Nodes)
            {
                // 找到列下标
                foreach (FXlsColumn column in _columns.Values)
                {
                    string name        = column.Name;
                    int    columnIndex = -1;
                    for (int n = 1; n <= _columns.Count; n++)
                    {
                        string excColumn = rowsWorksheet.Cells[2, n].Text;
                        if (name.Equals(excColumn))
                        {
                            columnIndex = n;
                            break;
                        }
                    }
                    // 将XML中的值附到相应的单元格上
                    string value = null;
                    if ("type_cd" == name)
                    {
                        value = node.Get("type");
                        if (columnIndex > 0)
                        {
                            rowsWorksheet.Cells[rowCount, columnIndex] = value;
                        }
                    }
                    //else if ("name" == name) {
                    //   value = node.Get("label");
                    //   if (columnIndex > 0) {
                    //      rowsWorksheet.Cells[rowCount, columnIndex] = value;
                    //   }
                    //}
                    else
                    {
                        if (node.Contains(name))
                        {
                            value = node.Get(name);
                            if (columnIndex > 0)
                            {
                                rowsWorksheet.Cells[rowCount, columnIndex] = value;
                            }
                        }
                    }
                }
                rowCount++;
            }
            app.DisplayAlerts = false;
            rowsWorksheet.SaveAs(saveName,
                                 Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                 Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            app.Quit();
            System.GC.Collect();
        }
Ejemplo n.º 13
0
        //============================================================
        public void Process(string filename)
        {
            FXmlDocument xdoc           = new FXmlDocument();
            FXmlNode     nodeExportList = null;

            xdoc.LoadFile(filename);
            foreach (FXmlNode node in xdoc.Root.Nodes)
            {
                if ("ExcelExportList" == node.Name)
                {
                    nodeExportList = node;
                    string saveSource = node.Nvl("source_path");
                    string saveTarget = node.Nvl("target_path");
                    // 处理所有Excel文档
                    using (FXlsDocument xlsDox = new FXlsDocument()) {
                        foreach (FXmlNode enode in node.Nodes)
                        {
                            bool valid = enode.GetBoolean("valid");
                            if (valid)
                            {
                                // 读取设置
                                string source = enode.Nvl("source");
                                string tag    = enode.Nvl("tag");
                                string target = enode.Nvl("target");
                                string name   = enode.Nvl("name");
                                // 转换文件
                                xlsDox.LoadFile(saveSource + source);
                                xlsDox.SaveXmlPath((saveTarget + target), tag);
                                foreach (FXmlNode cnode in enode.Nodes)
                                {
                                    string copy = cnode.Text;
                                    if (null != copy)
                                    {
                                        xlsDox.SaveXmlPath(copy, tag);
                                    }
                                }
                            }
                        }
                    }
                }
                else if ("ConverterExportList" == node.Name)
                {
                    foreach (FXmlNode cnode in node.Nodes)
                    {
                        bool valid = cnode.GetBoolean("valid");
                        if (valid)
                        {
                            // 读取设置
                            string type = cnode.Nvl("type");
                            // 接口实现相应xml文件合并
                            ITplConverter ftpl = CreatConverter(type);
                            if (null != ftpl)
                            {
                                ftpl.LoadExportListConfig(nodeExportList);
                                ftpl.LoadConfig(cnode);
                                ftpl.Process();
                            }
                        }
                    }
                }
            }
        }