internal CommandConsole(LuaEnvironment lua, DrawingSizeF screenSize, GameApplication.OutputStreams streams, int maxLines = 500)
 {
     Debug.Assert(lua != null, "Lua environment can not be null");
     Debug.Assert(streams != null, "Streams can not be null");
     _streams = streams;
     _lua = lua;
     _outputView = ToDispose<OutputView>(new OutputView(screenSize));
     _inputView = ToDispose<InputView>(new InputView(_outputView));
 }
Exemple #2
0
        public static void RegisterModule(LuaEnvironment env)
        {
            System.Diagnostics.Debug.Assert(env != null);

            var types = from ass in AppDomain.CurrentDomain.GetAssemblies()
                        from type in ass.GetTypes()
                        where !type.IsAbstract && type.IsPublic
                        where !type.GetCustomAttributes(true).OfType<LuaExcludeAttribute>().Any()
                        where typeof(IControl).IsAssignableFrom(type)
                        select type;

            LuaTable moduleTable = LuaEnvironment.ValueConverter.CreateModuleFromTypes(types, ModuleName);
            moduleTable.SetNameValue("_G", env.Environment);
            moduleTable.SetNameValue("__index", moduleTable);
            env.SetNameValue(ModuleName, moduleTable);
        }
 internal LuaValueConverter(LuaEnvironment env)
 {
     _environment = env;
 }
        public GameApplication(string configPath = "config/config.cfg", string formTitle = "Default Form Title")
            : base()
        {
            if(_singleton != null)
                _singleton.Exit();
            _singleton = this;
            _mainThreadId = Thread.CurrentThread.ManagedThreadId;

            _streams = ToDispose<OutputStreams>(new OutputStreams());

            _formTitle = formTitle;
            _appConfiguration = configPath == null ? new ApplicationConfig() : new ApplicationConfig(configPath);
            _initializeForm();
            _initializeGraphics();
            Lua = new LuaEnvironment();
            _commandConsole = ToDispose<CommandConsole>(new CommandConsole(Lua, new DrawingSizeF(Viewport.Width, Viewport.Height), _streams));
            RegisterEngineComponent(_commandConsole);
            _controlManager = ToDispose<ControlManager>(new ControlManager());
            RegisterEngineComponent(_controlManager);
            OnUpdate += Update;
            OnRender += Render;
            OnLoadContent += LoadContent;
            OnUnloadContent += UnloadContent;
        }
 internal LuaEnvironment()
 {
     _singleton = this;
     ResetEnvironment();
 }