コード例 #1
0
ファイル: DialogEditor.cs プロジェクト: CisBetter/ags
        public DialogEditor(Dialog dialogToEdit, AGSEditor agsEditor)
        {
            _dialog = dialogToEdit;
            _agsEditor = agsEditor;

            Init();
        }
コード例 #2
0
        public void ConvertDialogScriptToRealScript(Dialog dialog, Game game, CompileMessages errors)
        {
            string thisLine;
            _currentlyInsideCodeArea = false;
            _hadFirstEntryPoint = false;
            _game = game;
            _currentDialog = dialog;
            _existingEntryPoints.Clear();
            _currentLineNumber = 0;

            StringReader sr = new StringReader(dialog.Script);
            StringWriter sw = new StringWriter();
            sw.Write(string.Format("function _run_dialog{0}(int entryPoint) {1} ", dialog.ID, "{"));
            while ((thisLine = sr.ReadLine()) != null)
            {
                _currentLineNumber++;
                try
                {
                    ConvertDialogScriptLine(thisLine, sw, errors);
                }
                catch (CompileMessage ex)
                {
                    errors.Add(ex);
                }
            }
            if (_currentlyInsideCodeArea)
            {
                sw.WriteLine("}");
            }
            sw.WriteLine("return RUN_DIALOG_RETURN; }"); // end the function
            dialog.CachedConvertedScript = sw.ToString();
            sw.Close();
            sr.Close();
        }
コード例 #3
0
ファイル: DialogEditor.cs プロジェクト: StormyDay/ags
        public DialogEditor(Dialog dialogToEdit, AGSEditor agsEditor)
        {
            InitializeComponent();
            _dialog = dialogToEdit;
            _agsEditor = agsEditor;

            _extraMenu.Commands.Add(new MenuCommand(FIND_COMMAND, "Find...", System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F, "FindMenuIcon"));
            _extraMenu.Commands.Add(new MenuCommand(FIND_NEXT_COMMAND, "Find next", System.Windows.Forms.Keys.F3, "FindNextMenuIcon"));
            _extraMenu.Commands.Add(new MenuCommand(REPLACE_COMMAND, "Replace...", System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E));
            _extraMenu.Commands.Add(MenuCommand.Separator);
            _extraMenu.Commands.Add(new MenuCommand(FIND_ALL_COMMAND, "Find All...", System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift | System.Windows.Forms.Keys.F, "FindMenuIcon"));
            _extraMenu.Commands.Add(new MenuCommand(REPLACE_ALL_COMMAND, "Replace All...", System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift | System.Windows.Forms.Keys.E));
            _extraMenu.Commands.Add(new MenuCommand(GOTO_LINE_COMMAND, "Go To Line...", System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G));

            scintillaEditor.SetAsDialog();
            scintillaEditor.AutoCompleteEnabled = true;
            scintillaEditor.IgnoreLinesWithoutIndent = true;
            scintillaEditor.AutoSpaceAfterComma = false;
            scintillaEditor.CallTipsEnabled = true;
            scintillaEditor.FixedTypeForThisKeyword = "Dialog";
            scintillaEditor.SetFillupKeys(Constants.AUTOCOMPLETE_ACCEPT_KEYS);
            //scintillaEditor.SetKeyWords(dialogKeyWords);
            scintillaEditor.SetKeyWords(Constants.SCRIPT_KEY_WORDS);
            scintillaEditor.SetClassNamesList(BuildCharacterKeywords());
            scintillaEditor.SetAutoCompleteKeyWords(Constants.SCRIPT_KEY_WORDS);
            scintillaEditor.SetAutoCompleteSource(_dialog);
            scintillaEditor.SetText(dialogToEdit.Script);

            flowLayoutPanel1.Controls.Remove(btnNewOption);
            foreach (DialogOption option in dialogToEdit.Options)
            {
                DialogOptionEditor optionEditor = new DialogOptionEditor(option);
                _optionPanes.Add(optionEditor);
                flowLayoutPanel1.Controls.Add(optionEditor);
            }
            flowLayoutPanel1.Controls.Add(btnNewOption);
            flowLayoutPanel1.Controls.Add(btnDeleteOption);

            if (_dialog.Options.Count >= Dialog.MAX_OPTIONS_PER_DIALOG)
            {
                btnNewOption.Visible = false;
            }
            if (_dialog.Options.Count < 1)
            {
                btnDeleteOption.Visible = false;
            }
        }
コード例 #4
0
ファイル: DialogsComponent.cs プロジェクト: smarinel/ags-web
 public override void CommandClick(string controlID)
 {
     if (controlID == COMMAND_NEW_ITEM)
     {
         IList<Dialog> items = _agsEditor.CurrentGame.Dialogs;
         Dialog newItem = new Dialog();
         newItem.ID = items.Count;
         newItem.Name = _agsEditor.GetFirstAvailableScriptName("dDialog");
         items.Add(newItem);
         _guiController.ProjectTree.StartFromNode(this, TOP_LEVEL_COMMAND_ID);
         _guiController.ProjectTree.AddTreeLeaf(this, "Dlg" + newItem.ID, newItem.ID.ToString() + ": " + newItem.Name, "DialogIcon");
         _guiController.ProjectTree.SelectNode(this, "Dlg" + newItem.ID);
         ShowPaneForDialog(newItem);
     }
     else if (controlID == COMMAND_DELETE_ITEM)
     {
         if (MessageBox.Show("Are you sure you want to delete this dialog? Doing so will break any scripts that refer to dialogs by their number.", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             int removingID = _itemRightClicked.ID;
             foreach (Dialog item in _agsEditor.CurrentGame.Dialogs)
             {
                 if (item.ID > removingID)
                 {
                     item.ID--;
                 }
                 // Force a refresh since ID's have changed
                 item.CachedConvertedScript = null;
             }
             if (_documents.ContainsKey(_itemRightClicked))
             {
                 _guiController.RemovePaneIfExists(_documents[_itemRightClicked]);
                 _documents.Remove(_itemRightClicked);
             }
             _agsEditor.CurrentGame.Dialogs.Remove(_itemRightClicked);
             RePopulateTreeView();
         }
     }
     else if (controlID != TOP_LEVEL_COMMAND_ID)
     {
         ShowPaneForDialog(Convert.ToInt32(controlID.Substring(3)));
     }
 }
コード例 #5
0
ファイル: DialogsComponent.cs プロジェクト: smarinel/ags-web
        private DialogEditor ShowPaneForDialog(Dialog chosenItem)
        {
            AddDocumentIfNeeded(true, chosenItem);
            _guiController.ShowCuppit("The Dialog Editor is where you set up conversations that the player can have with other characters. The possible options for this dialog topic are on the left, and the script that will run when the player chooses one is on the right.", "Dialog introduction");

            return (DialogEditor)_documents[chosenItem].Control;
        }
コード例 #6
0
ファイル: DialogsComponent.cs プロジェクト: smarinel/ags-web
 private Dictionary<string, object> ConstructPropertyObjectList(Dialog item)
 {
     Dictionary<string, object> list = new Dictionary<string, object>();
     list.Add(item.Name + " (Dialog " + item.ID + ")", item);
     return list;
 }
コード例 #7
0
ファイル: DialogsComponent.cs プロジェクト: smarinel/ags-web
 private void AddDocumentIfNeeded(bool showEditor, Dialog chosenItem)
 {
     if (!_documents.ContainsKey(chosenItem))
     {
         DialogEditor dialogEditor = new DialogEditor(chosenItem, _agsEditor);
         _documents.Add(chosenItem, new ContentDocument(dialogEditor, chosenItem.WindowTitle, this, ConstructPropertyObjectList(chosenItem)));
         _documents[chosenItem].SelectedPropertyGridObject = chosenItem;
         _documents[chosenItem].MainMenu = dialogEditor.ExtraMenu;
     }
     if (showEditor)
     {
         _guiController.AddOrShowPane(_documents[chosenItem]);
     }
 }
コード例 #8
0
ファイル: DialogsComponent.cs プロジェクト: smarinel/ags-web
 public override IList<MenuCommand> GetContextMenu(string controlID)
 {
     IList<MenuCommand> menu = new List<MenuCommand>();
     if (controlID == TOP_LEVEL_COMMAND_ID)
     {
         menu.Add(new MenuCommand(COMMAND_NEW_ITEM, "New Dialog", null));
     }
     else
     {
         int charID = Convert.ToInt32(controlID.Substring(3));
         _itemRightClicked = _agsEditor.CurrentGame.Dialogs[charID];
         menu.Add(new MenuCommand(COMMAND_DELETE_ITEM, "Delete this dialog", null));
     }
     return menu;
 }