Ejemplo n.º 1
0
        public void PrepareForWriting(XElement xDialog, DialogObject dlg)
        {
            _xDialog = xDialog;

            var xCharProps = _xDialog.Element("characterProperties");
            if(xCharProps==null)
            {
                xCharProps = new XElement("characterProperties");
                _xDialog.Add(xCharProps);
            }
            else
                xCharProps.RemoveAll();

            var map = dlg.Dialog.AttributeCollection.WriteXml(xCharProps);

            var xChars = _xDialog.AddOrClearChild("characters");

            foreach(var ch in dlg.Dialog.DialogCharacters)
            {
                var xCh = new XElement("character");
                xCh.Add(new XAttribute("name", ch.Name));
                ch.WriteProperties(xCh, propName => map[propName]);
                xChars.Add(xCh);
            }

            Debug.Assert(_dialog != null && _dialog.Dialog != null);
        }
Ejemplo n.º 2
0
        public FormDialogProperties(DialogObjectManager manager, DialogObject dialog)
        {
            InitializeComponent();

            _dialogObject = dialog;
            _dialog = _dialogObject.Dialog;
            _manager = manager;

            _comboCharacters.Items.AddRange(_dialog.Dialogs.Characters.Keys.ToArray());

            foreach(var character in _dialog.DialogCharacters)
            {
                var item = _listCharacters.Items.Add(new ListViewItem(character.Name));
                item.Tag = new DialogCharacter(_dialog) {IsPlayer = character.IsPlayer, Name = character.Name};
                item.Checked = character.IsPlayer;
            }

            string name = _dialogObject.GetName();

            _textDialogName.Text = name;

            string scriptFileName;
            try
            {
                if(_dialog.ScriptFile!=null)
                    scriptFileName = _dialog.ScriptFile;
                else
                {
                    var filePath = Path.Combine(manager.RootDirectory, _dialogObject.RelativePath + ".lua");
                    if (File.Exists(filePath))
                        scriptFileName = name + ".lua";
                    else
                        scriptFileName = string.Empty;
                }
            }
            catch
            {
                scriptFileName = string.Empty;
            }

            _textScriptFile.Text = scriptFileName;
        }
Ejemplo n.º 3
0
 public UserPreferences(DialogObject dialogInfo)
 {
     _dialog = dialogInfo;
 }
Ejemplo n.º 4
0
        public DialogObject GetOrCreateDialogObject(string relativePath)
        {
            string relPath = relativePath.ToLower();

            DialogObject result;
            if(_directoryDialogMapping.TryGetValue(relPath,out result))
                return result;

            result=new DialogObject();
            string fPath = null;
            if (RootDirectory != null)
                fPath = Path.Combine(RootDirectory, relPath + ".dlg");

            var changed = _dialogs.HasChanges;

            var dlgInfo = new DialogInfo(_dialogs);
            result.Dialog = dlgInfo;
            if (File.Exists(fPath))
            {
                var pref = new UserPreferences(result);
                var xDialog = GetDialogNode(relativePath);
                pref.PrepareForReading(xDialog ?? new XElement("dialog", new XAttribute("path", relativePath)));
                dlgInfo.LoadFromFile(fPath, pref);
            }
            result.RelativePath = relativePath;
            result.HasChanges = false;
            _dialogs.Add(dlgInfo);

            if(!changed)
                _dialogs.HasChanges = false;

            _directoryDialogMapping.Add(relPath, result);
            return result;
        }