Exemple #1
0
        public bool CheckFiles(Form form)
        {
            IniHelper helper = new IniHelper(Program.INT_FILE);
            string    SEP    = "" + Path.PathSeparator;
            string    name   = null;
            bool      CN     = false;
            string    dir    = "";

            if (!File.Exists(textFile))
            {
                CN = SelectGameVer(out name);
                if (string.IsNullOrEmpty(name))
                {
                    return(false);
                }
                form.Info("请选择游戏目录");
                dir = SelectGamePath(CN);
                if (dir == null)
                {
                    return(false);
                }
                //查找本地已经存在的
                string deftext = PathHelper.Combine(dir, "resource", "localized_text", (CN?"chinese":"taiwan"), (CN?DEF_TEXT:DEF_TW));
                if (File.Exists(deftext))
                {
                    form.Info("找到翻译文件\n" + deftext);
                    helper.WriteValue("data", "text", deftext);
                    this.textFile = deftext;
                }
                else
                {
                    //解压
                    if (VZip.ExtractAllHfsFindFile(PathHelper.Combine(dir, "hfs"), name, Application.StartupPath))
                    {
                        form.Info("找到翻译文件\n" + name);
                        helper.WriteValue("data", "text", name);
                        this.textFile = PathHelper.Combine(Application.StartupPath, name);
                    }
                    else
                    {
                        form.Info("没找到翻译文件\n" + name);
                        return(false);
                    }
                }
            }
            if (!File.Exists(dbFile))
            {
                if (string.IsNullOrEmpty(name))
                {
                    CN = SelectGameVer(out name);
                    if (string.IsNullOrEmpty(name))
                    {
                        return(false);
                    }
                    form.Info("请选择游戏目录");
                    dir = SelectGamePath(CN);
                    if (dir == null)
                    {
                        return(false);
                    }
                }
                string defdb = PathHelper.Combine(dir, "sql", DEF_DB);
                if (File.Exists(defdb))
                {
                    form.Info("找到数据库\n" + defdb);
                    helper.WriteValue("data", "heroes", defdb);
                    this.dbFile = defdb;
                }
                else
                {
                    //解压
                    if (VZip.ExtractAllHfsFindFile(PathHelper.Combine(dir, "hfs"), DEF_DB, Application.StartupPath))
                    {
                        form.Info("找到数据库\n" + DEF_DB);
                        helper.WriteValue("data", "heroes", DEF_DB);
                        this.dbFile = DEF_DB;
                    }
                    else
                    {
                        form.Error("没找到数据库\n" + DEF_DB);
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemple #2
0
        public void TW2CN(string path)
        {
            //font
            Console.WriteLine("复制字体");
            string fontpath = PathHelper.Combine(path, "scaleform", "font");

            if (!Directory.Exists(fontpath))
            {
                Directory.CreateDirectory(fontpath);
            }
            string curfont = PathHelper.Combine(Application.StartupPath, "fonts_ch.swf");
            string cnfont  = PathHelper.Combine(fontpath, "fonts_ch.swf");

            if (!File.Exists(cnfont))
            {
                if (File.Exists(curfont))
                {
                    File.Copy(curfont, cnfont);
                }
                else
                {
                    if (!VZip.ExtractAllHfsFindFile(PathHelper.Combine(path, "hfs"),
                                                    "fonts_ch.swf",
                                                    fontpath))
                    {
                        if (VZip.ExtractAllHfsFindFile(PathHelper.Combine(path, "hfs"),
                                                       "fonts_tw.swf",
                                                       fontpath))
                        {
                            string text = PathHelper.Combine(fontpath, "fonts_tw.swf");
                            File.Move(text, cnfont);
                        }
                    }
                }
            }
            //db
            string textpath = PathHelper.Combine(path, "resource", "localized_text", "chinese");
            string cntext   = PathHelper.Combine(textpath, "heroes_text_chinese.txt");

            if (!File.Exists(cntext))
            {
                if (VZip.ExtractAllHfsFindFile(PathHelper.Combine(path, "hfs"),
                                               "heroes_text_taiwan.txt",
                                               textpath))
                {
                    string text = PathHelper.Combine(textpath, "heroes_text_taiwan.txt");

                    File.Delete(cntext);
                    File.Move(text, cntext);
                    TextTW2CN(cntext);
                }
            }
            Console.WriteLine("处理数据库");
            string dbpath = PathHelper.Combine(path, "sql");
            string cndb   = PathHelper.Combine(dbpath, "heroes.db3");

            if (!File.Exists(cndb))
            {
                if (!VZip.ExtractAllHfsFindFile(PathHelper.Combine(path, "hfs"),
                                                "heroes.db3", dbpath))
                {
                    return;
                }
            }
            if (File.Exists(cndb))
            {
                DbTW2CN(cndb);
            }
        }