Esempio n. 1
0
        void Init()
        {
            //文件路径
            this.conflang = MyConfig.GetLanguageFile(this.datapath);
            //游戏数据,MSE数据
            this.datacfg = new DataConfig(MyConfig.GetCardInfoFile(this.datapath));
            //初始化YGOUtil的数据
            YGOUtil.SetConfig(this.datacfg);

            //代码提示
            string funtxt     = MyPath.Combine(this.datapath, MyConfig.FILE_FUNCTION);
            string conlua     = MyPath.Combine(this.datapath, MyConfig.FILE_CONSTANT);
            string confstring = MyPath.Combine(this.datapath, MyConfig.FILE_STRINGS);

            this.codecfg = new CodeConfig();
            //添加函数
            this.codecfg.AddFunction(funtxt);
            //添加指示物
            this.codecfg.AddStrings(confstring);
            //添加常量
            this.codecfg.AddConstant(conlua);
            this.codecfg.SetNames(this.datacfg.dicSetnames);
            //生成菜单
            this.codecfg.InitAutoMenus();
            this.history = new History(this);
            //读取历史记录
            this.history.ReadHistory(MyPath.Combine(this.datapath, MyConfig.FILE_HISTORY));
            //加载多语言
            LanguageHelper.LoadFormLabels(this.conflang);
        }
Esempio n. 2
0
        //打开文件
        public void Open(string file)
        {
            if (string.IsNullOrEmpty(file) || !File.Exists(file))
            {
                return;
            }
            //添加历史
            this.history.AddHistory(file);
            //检查是否已经打开
            if (this.FindEditForm(file, true))
            {
                return;
            }
            //检查可用的
            if (this.FindEditForm(file, false))
            {
                return;
            }

            if (YGOUtil.IsScript(file))
            {
                this.OpenScript(file);
            }
            else if (YGOUtil.IsDataBase(file))
            {
                this.OpenDataBase(file);
            }
        }
Esempio n. 3
0
        //添加历史记录
        void AddHistorys(string[] lines)
        {
            luahistory.Clear();
            cdbhistory.Clear();
            foreach (string line in lines)
            {
                if (string.IsNullOrEmpty(line) || line.StartsWith("#"))
                {
                    continue;
                }

                if (File.Exists(line))
                {
                    if (YGOUtil.IsScript(line))
                    {
                        if (luahistory.Count < DEXConfig.MAX_HISTORY &&
                            luahistory.IndexOf(line) < 0)
                        {
                            luahistory.Add(line);
                        }
                    }
                    else
                    {
                        if (cdbhistory.Count < DEXConfig.MAX_HISTORY &&
                            cdbhistory.IndexOf(line) < 0)
                        {
                            cdbhistory.Add(line);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        void Init()
        {
            //文件路径
            conflang = DEXConfig.GetLanguageFile(datapath);
            //游戏数据,MSE数据
            olddatacfg = datacfg = new DataConfig(DEXConfig.GetCardInfoFile(datapath));
            string confstring = MyPath.Combine(datapath, DEXConfig.FILE_STRINGS);

            if (File.Exists(confstring))
            {
                Dictionary <long, string> d = datacfg.dicSetnames;
                if (!d.ContainsKey(0))
                {
                    d.Add(0L, "Archetype");
                }
                foreach (string l in File.ReadAllLines(confstring))
                {
                    if (l.StartsWith("!setname"))
                    {
                        string[] sn = l.Split(new char[] { ' ' }, 3);
                        _ = long.TryParse(sn[1], System.Globalization.NumberStyles.HexNumber, null,
                                          out long sc);
                        if (!d.ContainsKey(sc))
                        {
                            d.Add(sc, sn[2]);
                        }
                    }
                }
            }
            //初始化YGOUtil的数据
            YGOUtil.SetConfig(datacfg);

            //代码提示
            string funtxt = MyPath.Combine(datapath, DEXConfig.FILE_FUNCTION);
            string conlua = MyPath.Combine(datapath, DEXConfig.FILE_CONSTANT);

            codecfg = new CodeConfig();
            //添加函数
            codecfg.AddFunction(funtxt);
            //添加指示物
            codecfg.AddStrings(confstring);
            //添加常量
            codecfg.AddConstant(conlua);
            codecfg.SetNames(datacfg.dicSetnames);
            //生成菜单
            codecfg.InitAutoMenus();
            history = new History(this);
            //读取历史记录
            history.ReadHistory(MyPath.Combine(datapath, DEXConfig.FILE_HISTORY));
            //加载多语言
            LanguageHelper.LoadFormLabels(conflang);
        }
Esempio n. 5
0
        //新建文件
        void Menuitem_newClick(object sender, EventArgs e)
        {
            using SaveFileDialog dlg = new();
            dlg.Title = LanguageHelper.GetMsg(LMSG.NewFile);
            if (GetActive() != null)//判断当前窗口是不是DataEditor
            {
                try
                {
                    dlg.Filter = LanguageHelper.GetMsg(LMSG.CdbType);
                }
                catch { }
            }
            else
            {
                try
                {
                    dlg.Filter = LanguageHelper.GetMsg(LMSG.ScriptFilter);
                }
                catch { }
            }

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string file = dlg.FileName;
                if (File.Exists(file))
                {
                    File.Delete(file);
                }
                //是否是数据库
                if (YGOUtil.IsDataBase(file))
                {
                    if (DataBase.Create(file))                   //是否创建成功
                    {
                        if (MyMsg.Question(LMSG.IfOpenDataBase)) //是否打开新建的数据库
                        {
                            Open(file);
                        }
                    }
                }
                else
                {
                    try
                    {
                        File.Create(file).Dispose();
                    }
                    catch { }
                    Open(file);
                }
            }
        }
Esempio n. 6
0
 public bool CanOpen(string file)
 {
     return(YGOUtil.isScript(file));
 }