Пример #1
0
        private void mbQuestScript_Click(object sender, EventArgs e)
        {
            LuaEditor lua = NewLuaEditor();

            lua.scintilla1.Text = Scripts.GetQuestScript();
            lua.SetSaved();
        }
Пример #2
0
        public void OpenFile(string path)
        {
            if (!path.Contains(".lua"))
            {
                return;
            }

            // Check to see if the file is already opened and if so bring that tab to the front
            foreach (LuaEditor opened in dockPanel.Documents)
            {
                if (opened.Name == path)
                {
                    opened.Activate();
                    return;
                }
            }

            // Open the file
            LuaEditor doc = NewLuaEditor();

            doc.Name = path;
            doc.Text = path.Substring(path.LastIndexOf("\\") + 1);

            StreamReader reader = new StreamReader(path);

            doc.scintilla1.Text = reader.ReadToEnd();
            reader.Close();
            doc.scintilla1.UndoRedo.EmptyUndoBuffer();
            doc.SetSaved();
            doc.Show(dockPanel);
        }
Пример #3
0
        private LuaEditor NewLuaEditor()
        {
            LuaEditor newLua = new LuaEditor();

            // Set the closing even
            newLua.FormClosing        += LuaEditor_FormClosing;
            newLua.scintilla1.KeyDown += LuaEditor_KeyDown;
            newLua.Name = null;
            newLua.Text = "Untitled Lua Script";
            int count = 0;

            foreach (LuaEditor lua in dockPanel.Documents)
            {
                if (lua.Text.Contains(newLua.Text))
                {
                    count++;
                }
            }

            if (count > 0)
            {
                count++;
                newLua.Text += " " + count.ToString();
            }

            if (!m_settings.ShowLineNumbers)
            {
                newLua.scintilla1.Margins.Margin0.Width = 0;
            }

            newLua.Show(dockPanel);

            return(newLua);
        }
Пример #4
0
 private void LuaEditor_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (sender is LuaEditor)
     {
         LuaEditor lua = sender as LuaEditor;
         if (lua.SaveNeeded)
         {
             DialogResult result = MessageBox.Show("Do you want to save changes to " + lua.Text + "?", "Save Changes?", MessageBoxButtons.YesNoCancel);
             if (result == DialogResult.Yes)
             {
                 Save(lua.Name, lua.scintilla1.Text);
             }
             if (result == DialogResult.Cancel)
             {
                 e.Cancel = true;
             }
         }
     }
 }
Пример #5
0
        private void tsbNew_Click(object sender, EventArgs e)
        {
            LuaEditor lua = NewLuaEditor();

            lua.SetSaved();
        }