コード例 #1
0
 //////////////////////////////////////////////////////////////////////////
 public bool LoadFromFile(string fileName)
 {
     DefFile = new DefinitionFile();
     if (!DefFile.ParseFile(fileName))
     {
         DefFile = null;
         return false;
     }
     else
     {
         FileName = fileName;
         return true;
     }
 }
コード例 #2
0
 //////////////////////////////////////////////////////////////////////////
 private void ScanDefinition(string DefFilename)
 {
     DefinitionFile DefFile = new DefinitionFile();
     if(!DefFile.ParseFile(DefFilename))
     {
         AddLog(LogSeverity.Error, "Error parsing file '" + DefFilename + "'");
         return;
     }
     ScanDefinition(DefFilename, DefFile);
 }
コード例 #3
0
        //////////////////////////////////////////////////////////////////////////
        public DocumentOpenResult OpenDocument(WmeCanvas Canvas, string FileName)
        {
            if (FileName == null)
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "Windows and definition files (*.window; *.def)|*.window;*.def|Windows (*.window)|*.window|Defintion files (*.def)|*.def|All files (*.*)|*.*";
                dlg.RestoreDirectory = true;
                dlg.CheckFileExists = true;

                if (dlg.ShowDialog() != DialogResult.OK) return DocumentOpenResult.Cancel;
                else FileName = dlg.FileName;
            }

            DefinitionFile DefFile = new DefinitionFile();
            string FileType = "";

            if(DefFile.ParseFile(FileName) && DefFile.Children.Count > 0)
                FileType = DefFile.Children[0].Name.ToUpper();

            if(FileType != "WINDOW" && FileType != "INVENTORY_BOX" && FileType != "RESPONSE_BOX")
            {
                MessageBox.Show("Unsupported file type.", Form.ActiveForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return DocumentOpenResult.Cancel;
            }

            bool Ret = false;

            if (InitEngine(FileName, Canvas))
            {
                Game.AbsolutePathWarning = false;
                switch(FileType)
                {
                    case "WINDOW":
                        Window = new WUIWindow(Game);
                        Ret = Window.LoadFromFile(FileName);
                        if(Ret)
                        {
                            Game.Windows.Add(Window);
                            Game.FocusedWindow = Window;
                        }
                        break;

                    case "INVENTORY_BOX":
                        InvBox = new WAdInventoryBox(Game);
                        Ret = InvBox.LoadFromFile(FileName);
                        if(Ret && InvBox.Window != null)
                        {
                            Game.Windows.Add(InvBox.Window);
                            Game.FocusedWindow = InvBox.Window;
                        }
                        break;

                    case "RESPONSE_BOX":
                        RespBox = new WAdResponseBox(Game);
                        Ret = RespBox.LoadFromFile(FileName);
                        if (Ret && RespBox.Window != null)
                        {
                            Game.Windows.Add(RespBox.Window);
                            Game.FocusedWindow = RespBox.Window;
                        }
                        break;

                }
                Game.AbsolutePathWarning = true;
                UpdateScrollSize();

                this.FileName = FileName;
            }
            else Ret = false;

            if (!Ret) DisposeNatives();

            if (Ret) return DocumentOpenResult.Ok;
            else return DocumentOpenResult.Error;
        }