Example #1
0
		public EmuLuaLibrary(LuaConsole passed)
			: this()
		{
			LuaWait = new AutoResetEvent(false);
			Docs.Clear();
			_caller = passed.Get();

			// Register lua libraries
			var libs = Assembly
				.Load("BizHawk.Client.Common")
				.GetTypes()
				.Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
				.Where(t => t.IsSealed)
				.ToList();

			libs.AddRange(
				Assembly
				.GetAssembly(typeof(EmuLuaLibrary))
				.GetTypes()
				.Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
				.Where(t => t.IsSealed)
			);

			foreach (var lib in libs)
			{
				var instance = (LuaLibraryBase)Activator.CreateInstance(lib, _lua);
				instance.LuaRegister(lib, Docs);
				Libraries.Add(lib, instance);
			}

			_lua.RegisterFunction("print", this, GetType().GetMethod("Print"));

			EmulatorLuaLibrary.FrameAdvanceCallback = Frameadvance;
			EmulatorLuaLibrary.YieldCallback = EmuYield;
		}
Example #2
0
        public EmuLuaLibrary(LuaConsole passed)
            : this()
        {
            LuaWait = new AutoResetEvent(false);
            Docs.Clear();
            _caller = passed.Get();

            // Register lua libraries
            var libs = Assembly
                       .Load("BizHawk.Client.Common")
                       .GetTypes()
                       .Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
                       .Where(t => t.IsSealed)
                       .ToList();

            libs.AddRange(
                Assembly
                .GetAssembly(typeof(EmuLuaLibrary))
                .GetTypes()
                .Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
                .Where(t => t.IsSealed)
                );

            foreach (var lib in libs)
            {
                var instance = (LuaLibraryBase)Activator.CreateInstance(lib, _lua);
                instance.LuaRegister(lib, Docs);
                Libraries.Add(lib, instance);
            }

            _lua.RegisterFunction("print", this, GetType().GetMethod("Print"));

            EmulatorLuaLibrary.FrameAdvanceCallback = Frameadvance;
            EmulatorLuaLibrary.YieldCallback        = EmuYield;
        }
Example #3
0
        public EmuLuaLibrary(LuaConsole passed)
            : this()
        {
            LuaWait = new AutoResetEvent(false);
            Docs.Clear();
            _caller = passed.Get();

            // Register lua libraries
            var libs = Assembly
                .Load("BizHawk.Client.Common")
                .GetTypes()
                .Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
                .Where(t => t.IsSealed)
                .Where(t => ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, t))
                .ToList();

            libs.AddRange(
                Assembly
                .GetAssembly(typeof(EmuLuaLibrary))
                .GetTypes()
                .Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
                .Where(t => t.IsSealed)
                .Where(t => ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, t))
            );

            foreach (var lib in libs)
            {
                bool addLibrary = true;
                var attributes = lib.GetCustomAttributes(typeof(LuaLibraryAttributes), false);
                if (attributes.Any())
                {
                    addLibrary = VersionInfo.DeveloperBuild || (attributes.First() as LuaLibraryAttributes).Released;
                }

                if (addLibrary)
                {
                    var instance = (LuaLibraryBase)Activator.CreateInstance(lib, _lua);
                    instance.LuaRegister(lib, Docs);
                    instance.LogOutputCallback = ConsoleLuaLibrary.LogOutput;
                    ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, instance);
                    Libraries.Add(lib, instance);
                }
            }

            _lua.RegisterFunction("print", this, GetType().GetMethod("Print"));

            EmulatorLuaLibrary.FrameAdvanceCallback = Frameadvance;
            EmulatorLuaLibrary.YieldCallback = EmuYield;
        }
Example #4
0
        public EmuLuaLibrary(LuaConsole passed, IEmulatorServiceProvider serviceProvider)
            : this()
        {
            LuaWait = new AutoResetEvent(false);
            Docs.Clear();
            _caller = passed.Get();

            // Register lua libraries
            var libs = Assembly
                       .Load("BizHawk.Client.Common")
                       .GetTypes()
                       .Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
                       .Where(t => t.IsSealed)
                       .Where(t => ServiceInjector.IsAvailable(serviceProvider, t))
                       .ToList();

            libs.AddRange(
                Assembly
                .GetAssembly(typeof(EmuLuaLibrary))
                .GetTypes()
                .Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
                .Where(t => t.IsSealed)
                .Where(t => ServiceInjector.IsAvailable(serviceProvider, t))
                );

            foreach (var lib in libs)
            {
                bool addLibrary = true;
                var  attributes = lib.GetCustomAttributes(typeof(LuaLibraryAttributes), false);
                if (attributes.Any())
                {
                    addLibrary = VersionInfo.DeveloperBuild || (attributes.First() as LuaLibraryAttributes).Released;
                }

                if (addLibrary)
                {
                    var instance = (LuaLibraryBase)Activator.CreateInstance(lib, _lua);
                    instance.LuaRegister(lib, Docs);
                    instance.LogOutputCallback = ConsoleLuaLibrary.LogOutput;
                    ServiceInjector.UpdateServices(serviceProvider, instance);
                    Libraries.Add(lib, instance);
                }
            }

            _lua.RegisterFunction("print", this, GetType().GetMethod("Print"));

            EmulatorLuaLibrary.FrameAdvanceCallback = Frameadvance;
            EmulatorLuaLibrary.YieldCallback        = EmuYield;
        }