Пример #1
0
		public LuaConsole()
		{
			_sortReverse = false;
			_lastColumnSorted = string.Empty;
			_luaList = new LuaFileList
			{
				ChangedCallback = SessionChangedCallback,
				LoadCallback = ClearOutputWindow
			};

			InitializeComponent();
			LuaImp = new EmuLuaLibrary(this);
			Closing += (o, e) =>
			{
				if (AskSave())
				{
					SaveConfigSettings();
				}
				else
				{
					e.Cancel = true;
				}
			};

			LuaListView.QueryItemText += LuaListView_QueryItemText;
			LuaListView.QueryItemBkColor += LuaListView_QueryItemBkColor;
			LuaListView.VirtualMode = true;

			TopMost = Global.Config.LuaSettings.TopMost;
		}
Пример #2
0
        public LuaConsole()
        {
            _sortReverse      = false;
            _lastColumnSorted = string.Empty;
            _luaList          = new LuaFileList
            {
                ChangedCallback = SessionChangedCallback,
                LoadCallback    = ClearOutputWindow
            };

            InitializeComponent();
            LuaImp   = new EmuLuaLibrary(this);
            Closing += (o, e) =>
            {
                if (AskSave())
                {
                    SaveConfigSettings();
                }
                else
                {
                    e.Cancel = true;
                }
            };

            LuaListView.QueryItemText    += LuaListView_QueryItemText;
            LuaListView.QueryItemBkColor += LuaListView_QueryItemBkColor;
            LuaListView.VirtualMode       = true;

            TopMost = Global.Config.LuaSettings.TopMost;
        }
Пример #3
0
        public void Restart()
        {
            // Even if the lua console is self-rebooting from client.reboot_core() we still want to re-inject dependencies
            if (IsRebootingCore)
            {
                LuaImp.Restart(Emulator.ServiceProvider);
                return;
            }

            if (LuaImp?.GuiLibrary != null && LuaImp.GuiLibrary.HasLuaSurface)
            {
                LuaImp.GuiLibrary.DrawFinish();
            }

            var runningScripts = _luaList.Where(f => f.Enabled).ToList();

            foreach (var file in runningScripts)
            {
                LuaImp.CallExitEvent(file.Thread);

                var functions = LuaImp.RegisteredFunctions.Where(lf => lf.Lua == file.Thread).ToList();

                foreach (var function in functions)
                {
                    LuaImp.RegisteredFunctions.Remove(function);
                }

                UpdateRegisteredFunctionsDialog();

                file.Stop();
            }

            LuaImp = new EmuLuaLibrary(Emulator.ServiceProvider);
            InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => a.Library + "." + a.Name).ToArray());

            foreach (var file in runningScripts)
            {
                string pathToLoad = ProcessPath(file.Path);

                try
                {
                    LuaSandbox.Sandbox(file.Thread, () =>
                    {
                        file.Thread = LuaImp.SpawnCoroutine(pathToLoad);
                        LuaSandbox.CreateSandbox(file.Thread, Path.GetDirectoryName(pathToLoad));
                        file.State = LuaFile.RunState.Running;
                    }, () =>
                    {
                        file.State = LuaFile.RunState.Disabled;
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            UpdateDialog();
        }
Пример #4
0
        public void Restart()
        {
            if (LuaImp != null && LuaImp.GuiLibrary != null && LuaImp.GuiLibrary.HasLuaSurface)
            {
                LuaImp.GuiLibrary.DrawFinish();
            }

            var runningScripts = _luaList.Where(f => f.Enabled).ToList();

            foreach (var file in runningScripts)
            {
                LuaImp.CallExitEvent(file.Thread);

                var functions = LuaImp.RegisteredFunctions.Where(x => x.Lua == file.Thread).ToList();

                foreach (var function in functions)
                {
                    LuaImp.RegisteredFunctions.Remove(function);
                }

                UpdateRegisteredFunctionsDialog();

                file.Stop();
            }

            LuaImp = new EmuLuaLibrary(this);
            InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => a.Library + "." + a.Name).ToArray());

            foreach (var file in runningScripts)
            {
                string pathToLoad = Path.IsPathRooted(file.Path) ? file.Path : PathManager.MakeProgramRelativePath(file.Path);                 //JUNIPIER SQUATCHBOX COMPLEX
                try
                {
                    LuaSandbox.Sandbox(file.Thread, () =>
                    {
                        file.Thread = LuaImp.SpawnCoroutine(pathToLoad);
                        LuaSandbox.CreateSandbox(file.Thread, Path.GetDirectoryName(pathToLoad));
                        file.State = LuaFile.RunState.Running;
                    }, () =>
                    {
                        file.State = LuaFile.RunState.Disabled;
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            UpdateDialog();
        }
Пример #5
0
        public void Restart()
        {
            if (LuaImp != null && LuaImp.GuiLibrary != null && LuaImp.GuiLibrary.HasLuaSurface)
            {
                LuaImp.GuiLibrary.DrawFinish();
            }

            var runningScripts = _luaList.Where(f => f.Enabled).ToList();

            foreach (var file in runningScripts)
            {
                LuaImp.CallExitEvent(file.Thread);

                var functions = LuaImp.RegisteredFunctions.Where(x => x.Lua == file.Thread).ToList();

                foreach (var function in functions)
                {
                    LuaImp.RegisteredFunctions.Remove(function);
                }

                UpdateRegisteredFunctionsDialog();

                file.Stop();
            }

            LuaImp = new EmuLuaLibrary(this);
            InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => a.Library + "." + a.Name).ToArray());

            foreach (var file in runningScripts)
            {
                try
                {
                    file.Thread  = LuaImp.SpawnCoroutine(file.Path);
                    file.Enabled = true;
                }
                catch (Exception ex)
                {
                    if (ex is LuaScriptException)
                    {
                        file.Enabled = false;
                        ConsoleLog(ex.Message);
                    }
                    else
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }

            UpdateDialog();
        }
Пример #6
0
		public void Restart()
		{
			if (LuaImp != null && LuaImp.GuiLibrary != null && LuaImp.GuiLibrary.HasLuaSurface)
			{
				LuaImp.GuiLibrary.DrawFinish();
			}

			var runningScripts = _luaList.Where(f => f.Enabled).ToList();

			foreach (var file in runningScripts)
			{
				LuaImp.CallExitEvent(file.Thread);

				var functions = LuaImp.RegisteredFunctions.Where(x => x.Lua == file.Thread).ToList();

				foreach (var function in functions)
					LuaImp.RegisteredFunctions.Remove(function);

				UpdateRegisteredFunctionsDialog();

				file.Stop();
			}

			LuaImp = new EmuLuaLibrary(this);
			InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => a.Library + "." + a.Name).ToArray());

			foreach (var file in runningScripts)
			{
				try
				{
					LuaSandbox.Sandbox(() =>
					{
						file.Thread = LuaImp.SpawnCoroutine(file.Path);
						file.State = LuaFile.RunState.Running;
					}, () =>
					{
						file.State = LuaFile.RunState.Disabled;
					});
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.ToString());
				}
			}

			UpdateDialog();
		}
Пример #7
0
		public void Restart()
		{
			if (LuaImp != null && LuaImp.GuiLibrary != null && LuaImp.GuiLibrary.HasLuaSurface)
			{
				LuaImp.GuiLibrary.DrawFinish();
			}

			var runningScripts = _luaList.Where(f => f.Enabled).ToList();

			foreach (var file in runningScripts)
			{
				LuaImp.CallExitEvent(file.Thread);

				var functions = LuaImp.RegisteredFunctions.Where(x => x.Lua == file.Thread).ToList();

				foreach (var function in functions)
					LuaImp.RegisteredFunctions.Remove(function);

				UpdateRegisteredFunctionsDialog();

				file.Stop();
			}

			LuaImp = new EmuLuaLibrary(this);
			InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => a.Library + "." + a.Name).ToArray());

			foreach (var file in runningScripts)
			{
				string pathToLoad = Path.IsPathRooted(file.Path) ? file.Path : PathManager.MakeProgramRelativePath(file.Path); //JUNIPIER SQUATCHBOX COMPLEX
				try
				{
					LuaSandbox.Sandbox(file.Thread, () =>
					{
						file.Thread = LuaImp.SpawnCoroutine(pathToLoad);
						LuaSandbox.CreateSandbox(file.Thread, Path.GetDirectoryName(pathToLoad));
						file.State = LuaFile.RunState.Running;
					}, () =>
					{
						file.State = LuaFile.RunState.Disabled;
					});
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.ToString());
				}
			}

			UpdateDialog();
		}