示例#1
0
 public XNIProcessor()
     : base()
 {
     _metaData      = new Dictionary <string, ControlMetadata>();
     attribImporter = new Importers();
     LoadAllControlMetadata();
 }
示例#2
0
        static void LoadGameDll(string BasePath)
        {
            BasePath = Path.Combine(BasePath, "Game.dll");

            Assembly GameAssembly = Reflect.LoadAssembly(BasePath);

            Type[] GameImplementations = Reflect.GetAllImplementationsOf(GameAssembly, typeof(LibTechGame)).ToArray();

            if (GameImplementations.Length == 0)
            {
                GConsole.WriteLine("No game implementations found in " + BasePath);
                Environment.Exit(0);
            }
            else if (GameImplementations.Length > 1)
            {
                GConsole.WriteLine("Too many game implementations in " + BasePath);
                Environment.Exit(0);
            }

            AppDomain.CurrentDomain.AssemblyResolve += (S, E) => TryLoadAssembly(E.Name, BasePath);
            Importers.RegisterAll(GameAssembly);

            Game = (LibTechGame)Activator.CreateInstance(GameImplementations[0]);
            Game.Load();
        }
示例#3
0
 public virtual void Register(IImporter importer)
 {
     if (importer == null)
         throw new ArgumentNullException("importer");
     
     Importers.Put(importer);
 }
示例#4
0
        void Load(string DefFile)
        {
            string[] Lines = File.ReadAllLines(DefFile);
            RelativeSpawns = new List <Vector3>();

            foreach (var L in Lines)
            {
                string[] Args = L.Trim().Split(' ');

                switch (Args[0].ToLower())
                {
                case "model":
                    WorldModel = Importers.Load <Model>(Args[1]);
                    break;

                case "spawn":
                    RelativeSpawns.Add(new Vector3(Args[1].ParseToFloat(), Args[2].ParseToFloat(), Args[3].ParseToFloat()));
                    break;

                default:
                    GConsole.WriteLine("Invalid world argument: {0}", L);
                    break;
                }
            }

            if (WorldModel == null)
            {
                throw new Exception("World model was not loaded");
            }
        }
示例#5
0
 public List <string> GetTopicImportUids()
 {
     lock (Importers)
     {
         return(Importers.Select(i => i.Key).ToList());
     }
 }
示例#6
0
        public string StartTopicImport(string uid, MqttImportTopicParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            if (string.IsNullOrEmpty(uid))
            {
                uid = Guid.NewGuid().ToString("D");
            }

            var importer = new MqttTopicImporter(parameters, this, _logger);

            importer.Start();

            lock (Importers)
            {
                if (Importers.TryGetValue(uid, out var existingImporter))
                {
                    existingImporter.Stop();
                }

                Importers[uid] = importer;
            }

            _logger.Log(LogLevel.Information, "Started importer '{0}' for topic '{1}' from server '{2}'.", uid, parameters.Topic, parameters.Server);
            return(uid);
        }
示例#7
0
        private static List <FavoriteConfigurationElement> ImportItemsFromFile(IPersistence persistence, string path,
                                                                               string fileName = DUPLICIT_ITEMS_FILE)
        {
            string fullFileName = Path.Combine(path, fileName);
            var    importers    = new Importers(persistence);

            return(importers.ImportFavorites(fullFileName));
        }
 public void RegisterImporter <T, U>() where U : ContentImporter <T>
 {
     if (Importers.ContainsKey(typeof(U)))
     {
         return; // TODO: Throw/log something in future?
     }
     Importers.Add(typeof(T), Activator.CreateInstance <U>());
 }
示例#9
0
        public virtual void Register(IImporter importer)
        {
            if (importer == null)
            {
                throw new ArgumentNullException(nameof(importer));
            }

            Importers.Put(importer);
        }
示例#10
0
        internal OrganizeFavoritesForm(IPersistence persistence, ConnectionManager connectionManager, FavoriteIcons favoriteIcons)
        {
            InitializeComponent();

            this.persistence       = persistence;
            this.connectionManager = connectionManager;
            this.favoriteIcons     = favoriteIcons;
            InitializeDataGrid();
            this.importers = new Importers(this.persistence);
            ImportOpenFileDialog.Filter = this.importers.GetProvidersDialogFilter();
            UpdateCountLabels();
        }
示例#11
0
        static void RunGame()
        {
            InitConsole();

            FileWatcher.Init("content");
            Importers.RegisterAll(Reflect.GetExeAssembly());

            Engine.GUI = new libGUI();

            Engine.Window              = new RenderWindow(Engine.WindowWidth, Engine.WindowHeight, "libTech", Engine.WindowResizable);
            Engine.Window.OnMouseMove += Engine.GUI.OnMouseMove;
            Engine.Window.OnKey       += OnKey;
            Engine.Window.OnChar      += Engine.GUI.OnChar;

            Engine.GUI.Init(Engine.Window, new ShaderProgram(new ShaderStage(ShaderType.VertexShader, "content/shaders/gui.vert"), new ShaderStage(ShaderType.FragmentShader, "content/shaders/gui.frag")));

            GConsole.Init();
            GConsole.WriteLine("Running {0}", RenderAPI.Renderer, RenderAPI.Version);

            GConsole.Color = FishGfx.Color.Orange;
            foreach (var DllName in FailedToLoadDLLs)
            {
                GConsole.WriteLine("Failed to load '{0}'", DllName);
            }
            GConsole.Color = FishGfx.Color.White;

            // Graphics init
            Gfx.ShadersDirectory = "content/shaders";
            //Gfx.Line3D = DefaultShaders.Line3D;
            //Gfx.Point3D = DefaultShaders.Point3D;
            //Gfx.Default3D = DefaultShaders.DefaultColor3D;

            // Camera init
            Engine.Camera2D = new Camera();
            Engine.Camera2D.SetOrthogonal(0, 0, Engine.Window.WindowWidth, Engine.Window.WindowHeight);

            Engine.Camera3D = new Camera();
            Engine.Camera3D.SetPerspective(Engine.Window.WindowWidth, Engine.Window.WindowHeight);

            LoadGameDll(Engine.GamePath);

            float Dt = 0;

            while (!Engine.Window.ShouldClose)
            {
                Update(Dt);
                Draw(Dt);
                Thread.Sleep(0);
            }
        }
示例#12
0
        private void DropFiles(Form parentForm)
        {
            var files = this.data.GetData(DataFormats.FileDrop) as String[];

            if (files == null)
            {
                return;
            }

            var importers = new Importers(this.persistence);
            var toImport  = importers.ImportFavorites(files);

            this.ApplyTargetGroup(toImport);
            var managedImport = new ImportWithDialogs(parentForm, this.persistence, this.connectinManager);

            managedImport.Import(toImport);
        }
        /// <summary>
        /// Fills the document whith the result of the import
        /// </summary>
        /// <param name="importResult"></param>
        public void CreateDocument(Importers.RtfDeltaImporter.Document importResult)
        {
            AddParagraph("This document lists the changes that have been applied during the imporation of a new release of the specification");

            AddSubParagraph("Modified paragraphs");
            AddParagraph("This section lists the paragraphs that have been modified during the importation");
            foreach (Importers.RtfDeltaImporter.Paragraph paragraph in importResult.ChangedParagraphs)
            {
                AddSubParagraph(paragraph.Id);
                AddSubParagraph("Original contents");
                AddParagraph(ValidText(paragraph.OriginalText));
                CloseSubParagraph();
                AddSubParagraph("New contents");
                AddParagraph(ValidText(paragraph.Text));
                CloseSubParagraph();
                CloseSubParagraph();
            }
            CloseSubParagraph();

            AddSubParagraph("New paragraphs");
            AddParagraph("This section lists the paragraphs that have been added during the importation");
            AddTable(new string[] { "Paragraph", "Contents" }, new int[] { 40, 100 });
            foreach (Importers.RtfDeltaImporter.Paragraph paragraph in importResult.NewParagraphs)
            {
                AddRow(paragraph.Id, paragraph.Text);
            }
            CloseSubParagraph();
            AddSubParagraph("Removed paragraphs");
            AddParagraph("This section lists the paragraphs that have been removed during the importation");
            AddTable(new string[] { "Paragraph", "Contents" }, new int[] { 40, 100 });
            foreach (Importers.RtfDeltaImporter.Paragraph paragraph in importResult.RemovedParagraphs)
            {
                AddRow(paragraph.Id, paragraph.Text);
            }
            CloseSubParagraph();

            AddSubParagraph("Errors during importation");
            AddParagraph("This section lists the errors encountered during importation");
            AddTable(new string[] { "Paragraph", "Error" }, new int[] { 40, 100 });
            foreach (Importers.RtfDeltaImporter.ImportationError error in importResult.Errors)
            {
                AddRow(error.Paragraph.Id, error.Message);
            }
            CloseSubParagraph();
        }
示例#14
0
        public void StopTopicImport(string uid)
        {
            if (uid == null)
            {
                throw new ArgumentNullException(nameof(uid));
            }

            lock (Importers)
            {
                if (Importers.TryGetValue(uid, out var importer))
                {
                    importer.Stop();
                    _logger.Log(LogLevel.Information, "Stopped importer '{0}'.");
                }

                Importers.Remove(uid);
            }
        }
        public T Load <T>(string relativePath) where T : class
        {
            var completePath = Path.Combine(ContentRoot, relativePath);

            if (!File.Exists(completePath))
            {
                throw new ContentPathException(completePath, "Could not find a file at the provided path.");
            }

            var type = typeof(T);

            if (!Importers.ContainsKey(type))
            {
                throw new ContentUnsupportedException(type, "The requested type has no importers registered.");
            }

            return(Importers[type].ImportObject(completePath) as T);
        }
示例#16
0
文件: Game.cs 项目: masums/libTech
        public override void Load()
        {
            FontTest     = new MSDFFont("content/fonts/Hack.ttf");
            CrosshairTex = Importers.Load <Texture>("content/textures/crosshair_default.png");

            /*MSDF = new ShaderProgram(new ShaderStage(ShaderType.VertexShader, "content/shaders/default.vert"),
             * new ShaderStage(ShaderType.FragmentShader, "content/shaders/msdf.frag"));*/

            Ply = new Player();
            Engine.SpawnEntity(Ply);

            GameWorld    = new World("content/maps/sandbox.txt");
            Ply.Position = GameWorld.RelativeSpawns.FirstOrDefault();
            Engine.SpawnEntity(GameWorld);

            GConsole.RegisterCommand("getcam", () => {
                GConsole.WriteLine("Pos: " + Ply.Position.ToString());
            });
        }
示例#17
0
        private void TraceExtensions()
        {
            Trace.TraceInformation("Factories {0}:", Factories.Count);
            Factories.ForEach(x => Trace.TraceInformation(x.ToString()));

            Trace.TraceInformation("Importers {0}:", Importers.Count);
            Importers.ForEach(x => Trace.TraceInformation(x.ToString()));

            Trace.TraceInformation("Exporters: {0}", Exporters.Count);
            Exporters.ForEach(x => Trace.TraceInformation(x.ToString()));

            Trace.TraceInformation("Visualizers: {0}", Visualizers.Count);
            Visualizers.ForEach(x => Trace.TraceInformation(x.ToString()));

            Trace.TraceInformation("Settings: {0}", Settings.Count);
            Settings.ForEach(x => Trace.TraceInformation(x.ToString()));

            Trace.TraceInformation("AttributeProviders: {0}", AttributeProviders.Count);
            AttributeProviders.ForEach(x => Trace.TraceInformation(x.ToString()));
        }
示例#18
0
        static void LoadGameDll(string BasePath)
        {
            string   GameDllPath   = Path.Combine(BasePath, "Game.dll");
            Assembly GameAssembly  = Assembly.GetExecutingAssembly();
            bool     LoadImporters = false;

            if (File.Exists(GameDllPath))
            {
                GameAssembly  = Reflect.LoadAssembly(GameDllPath);
                LoadImporters = true;
            }

            Type[] GameImplementations = Reflect.GetAllImplementationsOf(GameAssembly, typeof(LibTechGame)).ToArray();

            if (GameImplementations.Length == 0)
            {
                GConsole.WriteLine("No game implementations found in " + GameDllPath);
                Environment.Exit(0);
            }
            else if (GameImplementations.Length > 1)
            {
                GConsole.WriteLine("Too many game implementations in " + GameDllPath);
                Environment.Exit(0);
            }

            AppDomain.CurrentDomain.AssemblyResolve += (S, E) => TryLoadAssembly(E.Name, GameDllPath);

            if (LoadImporters)
            {
                Importers.RegisterAll(GameAssembly);
            }

            Entity.LoadAllTypes();

            Engine.Game = (LibTechGame)Activator.CreateInstance(GameImplementations[0]);
            Engine.Game.Load();
        }
示例#19
0
        internal void Load(Editor editor, string path)
        {
            Verify.DirectoryExists(path, "path");

            Trace.TraceInformation("Loading default editor extensions at folder {0}", Path.GetFullPath(path));

            var extensions = Directory.GetFiles(path, "*.DLL").Concat(Directory.GetFiles(path, "*.EXE"))
                             .SelectMany(file => LoadExportedTypes(file))
                             .Select(type => new { Export = type.GetCustomAttributes(typeof(ExportAttribute), false).SingleOrDefault(), Type = type })
                             .Where(pair => pair.Export != null)
                             .ToLookup(pair => ((ExportAttribute)pair.Export).ContractType, pair => pair.Type);

            AttributeProviders.AddRange(from type in extensions[typeof(IAttributeProvider)] where !AttributeProviders.Any(x => x.GetType() == type) select(IAttributeProvider) Activator.CreateInstance(type));
            Factories.AddRange(from type in extensions[typeof(IFactory)] where !Factories.Any(x => x.Value.GetType() == type) select new Extension <IFactory>(editor, (IFactory)Activator.CreateInstance(type)));
            Visualizers.AddRange(from type in extensions[typeof(IVisualizer)] where !Visualizers.Any(x => x.Value.GetType() == type) select new Extension <IVisualizer>(editor, (IVisualizer)Activator.CreateInstance(type)));
            Tools.AddRange(from type in extensions[typeof(ITool)] where !Tools.Any(x => x.Value.GetType() == type) select new Extension <ITool>(editor, (ITool)Activator.CreateInstance(type)));
            Importers.AddRange(from type in extensions[typeof(IImporter)] where !Importers.Any(x => x.Value.GetType() == type) select new Extension <IImporter>(editor, (IImporter)Activator.CreateInstance(type)));
            Exporters.AddRange(from type in extensions[typeof(IExporter)] where !Exporters.Any(x => x.Value.GetType() == type) select new Extension <IExporter>(editor, (IExporter)Activator.CreateInstance(type)));
            Settings.AddRange(from type in extensions[typeof(ISettings)] where !Settings.Any(x => x.Value.GetType() == type) select new Extension <ISettings>(editor, (ISettings)Activator.CreateInstance(type)));

            TraceExtensions();

            Trace.TraceInformation("Extensions Loaded.");
        }
 public VersionSpecificImporter_6_6_5_15100(Importers.IImporter importer)
     : base(importer)
 {
 }
示例#21
0
 public static T Load <T>(string Pth)
 {
     return(Importers.Get <T>(Pth).Load(Pth));
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="aDictionary"></param>
 /// <param name="importResult"></param>
 public DeltaImportReportHandler(DataDictionary.Dictionary aDictionary, Importers.RtfDeltaImporter.Document importResult, string baseFileName)
     : base(aDictionary)
 {
     createFileName(baseFileName);
     ImportResult = importResult;
 }
示例#23
0
 private BankStatementImporterRepository CreateSubject()
 {
     return(new BankStatementImporterRepository(Importers.Select(i => i.Object)));
 }
 protected VersionSpecificImporter(Importers.IImporter importer)
 {
     Importer = importer;
 }
        /// <summary>
        ///     Fills the document whith the result of the import
        /// </summary>
        /// <param name="importResult"></param>
        public void CreateDocument(Importers.RtfDeltaImporter.Document importResult)
        {
            AddParagraph(
                "This document lists the changes that have been applied during the imporation of a new release of the specification");

            AddSubParagraph("Summary");
            AddParagraph("This section presents the summary of the document importation");
            AddTable(new string[] {"Item", "Count", "Comment"}, new int[] {40, 40, 60});
            AddRow("Paragraph count", importResult.Paragraphs.Count.ToString(),
                "This is the number of paragraphs processed during the importation of the document");
            AddRow("Modified paragraphs", importResult.ChangedParagraphs.Count.ToString(),
                "This is the number of paragraphs that have been changed between the two revisions");
            AddRow("New paragraphs", importResult.NewParagraphs.Count.ToString(),
                "The is the number of new paragraphs in this new revision");
            AddRow("Moved paragraphs", importResult.MovedParagraphs.Count.ToString(),
                "The is the number of paragraphs that have been moved around in this new revision");
            AddRow("Deleted paragraphs", importResult.RemovedParagraphs.Count.ToString(),
                "This is the number of paragraphs that have been deleted in this new revision");
            CloseSubParagraph();

            AddSubParagraph("Modified paragraphs");
            AddParagraph("This section lists the paragraphs that have been modified during the importation");
            foreach (Paragraph paragraph in importResult.ChangedParagraphs)
            {
                AddSubParagraph(paragraph.Id);
                AddSubParagraph("Original contents");
                AddParagraph(ValidText(paragraph.OriginalText));
                CloseSubParagraph();
                AddSubParagraph("New contents");
                AddParagraph(ValidText(paragraph.Text));
                CloseSubParagraph();
                CloseSubParagraph();
            }
            CloseSubParagraph();

            AddSubParagraph("New paragraphs");
            AddParagraph("This section lists the paragraphs that have been added during the importation");
            AddTable(new string[] {"Paragraph", "Contents"}, new int[] {40, 100});
            foreach (Paragraph paragraph in importResult.NewParagraphs)
            {
                AddRow(paragraph.Id, paragraph.Text);
            }
            CloseSubParagraph();
            AddSubParagraph("Removed paragraphs");
            AddParagraph("This section lists the paragraphs that have been removed during the importation");
            AddTable(new string[] {"Paragraph", "Contents"}, new int[] {40, 100});
            foreach (Paragraph paragraph in importResult.RemovedParagraphs)
            {
                AddRow(paragraph.Id, paragraph.Text);
            }
            CloseSubParagraph();

            AddSubParagraph("Moved paragraphs");
            AddParagraph(
                "This section lists the paragraphs that have been moved during the importation. No change has been performed in the model. Review should be performed manually.");
            AddTable(new string[] {"Paragraph", "Contents", "Initial position"}, new int[] {40, 100, 40});
            foreach (Paragraph paragraph in importResult.MovedParagraphs)
            {
                AddRow(paragraph.Id, paragraph.Text, paragraph.OriginalText);
            }
            CloseSubParagraph();

            AddSubParagraph("Errors during importation");
            AddParagraph(
                "This section lists the errors encountered during importation. No change has been performed in the model. Review should be performed manually.");
            AddTable(new string[] {"Paragraph", "Text", "Error"}, new int[] {30, 80, 80});
            foreach (ImportationError error in importResult.Errors)
            {
                AddRow(error.Paragraph.Id, error.Paragraph.Text, error.Message);
            }
            CloseSubParagraph();

            AddSubParagraph("List of paragraphs");
            AddParagraph("This section lists the paragraphs that have been processed during the importation");
            AddTable(new string[] {"Paragraph", "", "", "", ""}, new int[] {30, 30, 30, 30, 30});
            int i = 0;
            string[] data = new string[5] {"", "", "", "", ""};
            foreach (Paragraph paragraph in importResult.Paragraphs.Values)
            {
                data[i] = paragraph.Id;
                i += 1;

                if (i == data.Length)
                {
                    AddRow(data);
                    i = 0;
                    data = new string[5] {"", "", "", "", ""};
                }
            }

            if (i > 0)
            {
                AddRow(data);
            }
            CloseSubParagraph();
        }
示例#26
0
 internal Extension <IImporter> FindImporter(Type type)
 {
     return(Importers.SingleOrDefault(e => e.IsDefault && e.Value.TargetType == type)
            ?? Importers.FirstOrDefault(e => e.Value.TargetType == type));
 }
示例#27
0
        static void Main(string[] args)
        {
            CVar.InitMode = true;
            CVar.Register("game", "basegame", CVarType.Replicated | CVarType.Init, (This, Old, New) => This.Value = Path.GetFullPath((string)New));

            CVar.Register("width", 1366, CVarType.Archive);
            CVar.Register("height", 768, CVarType.Archive);
            CVar.Register("borderless", false, CVarType.Archive);
            CVar.Register("resizable", false, CVarType.Archive);
            CVar.Register("gl_doublebuffer", true, CVarType.Archive);
            CVar.Register("gl_samples", 8, CVarType.Archive);

            CVar.Register("gl_forwardcompat", true, CVarType.Archive | CVarType.Init | CVarType.Unsafe);
            CVar.Register("gl_major", 4, CVarType.Archive | CVarType.Init | CVarType.Unsafe);
            CVar.Register("gl_minor", 5, CVarType.Archive | CVarType.Init | CVarType.Unsafe);

            // Parse all arguments and set CVars
            foreach (var Arg in ArgumentParser.All)
            {
                switch (Arg.Key)
                {
                case "console":
                    GConsole.Open = true;
                    break;

                default: {
                    CVar CVar = CVar.Find(Arg.Key);

                    if (CVar != null)
                    {
                        CVar.Value = Arg.Value.LastOrDefault();
                    }
                    else
                    {
                        CVar.Register(Arg.Key, Arg.Value.LastOrDefault());
                    }

                    break;
                }
                }
            }

            CVar.InitMode = false;
            foreach (var CVar in CVar.GetAll())
            {
                GConsole.WriteLine(CVar);
            }

            FileWatcher.Init("content");
            Importers.RegisterAll(Reflect.GetExeAssembly());

            CreateContext();
            InitPhysics();

            LoadContent();

            Stopwatch SWatch = Stopwatch.StartNew();
            float     Target = 1.0f / 120;
            float     Dt     = Target;

            TextureTarget Tgt = TextureTarget.Texture2dMultisample;

            if (CVar.GetInt("gl_samples") == 0)
            {
                Tgt = TextureTarget.Texture2d;
            }

            Texture ColorTex = new Texture(Width, Height, Tgt, 1, InternalFormat.Rgb16f);
            Texture DepthTex = new Texture(Width, Height, Tgt, 1, InternalFormat.Depth24Stencil8);

            Framebuffer FB = new Framebuffer();

            FB.AttachColorTexture(ColorTex);
            FB.AttachDepthTexture(DepthTex);

            Texture SkyboxCubeMap = new Texture(1024, 1024, TextureTarget.TextureCubeMap, 1, InternalFormat.Srgb8Alpha8);

            SkyboxCubeMap.SetFilter(Gl.LINEAR, Gl.LINEAR);
            SkyboxCubeMap.SubImage3D(Image.FromFile("content/textures/skybox/interstellar/front.png"), Z: Texture.FRONT);
            SkyboxCubeMap.SubImage3D(Image.FromFile("content/textures/skybox/interstellar/back.png"), Z: Texture.BACK);
            SkyboxCubeMap.SubImage3D(Image.FromFile("content/textures/skybox/interstellar/left.png"), Z: Texture.LEFT);
            SkyboxCubeMap.SubImage3D(Image.FromFile("content/textures/skybox/interstellar/right.png"), Z: Texture.RIGHT);
            SkyboxCubeMap.SubImage3D(Image.FromFile("content/textures/skybox/interstellar/top.png"), Z: Texture.TOP);
            SkyboxCubeMap.SubImage3D(Image.FromFile("content/textures/skybox/interstellar/bottom.png"), Z: Texture.BOTTOM);

            //FB.Clear(new Vector4(1, 0, 0, 1));

            Model SkyboxCube = Importers.Load <Model>("content/models/cube.obj");

            SkyboxCube.Scale = new Vector3(2);
            SkyboxCube.Meshes[0].Material.Shader  = ShaderProgram.Skybox;
            SkyboxCube.Meshes[0].Material.Diffuse = SkyboxCubeMap;

            //bool DoDebug = true;

            while (!Glfw.WindowShouldClose(Window))
            {
                /*if (Khronos.KhronosApi.LogEnabled) {
                 *      Khronos.KhronosApi.LogCommand("END FRAME", null, null);
                 *      Khronos.KhronosApi.LogEnabled = false;
                 * }
                 *
                 * if (DoDebug) {
                 *      DoDebug = false;
                 *      Khronos.KhronosApi.LogEnabled = true;
                 *      Khronos.KhronosApi.LogCommand("BEGIN FRAME", null, null);
                 * }*/

                Update(Dt);
                Gl.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit | ClearBufferMask.StencilBufferBit);

                FB.Bind();
                {
                    Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
                    SetupState();

                    Gl.Disable(EnableCap.CullFace);
                    Gl.DepthMask(false);
                    SkyboxCube.Position = Camera.ActiveCamera?.Position ?? Vector3.Zero;
                    SkyboxCube.Draw();
                    Gl.DepthMask(true);

                    DrawScene(Dt);
                }
                FB.Unbind();

                // Swap to GUI camera
                Gl.Disable(EnableCap.DepthTest);
                Gl.Disable(EnableCap.CullFace);
                Camera.ActiveCamera = Camera.GUICamera;

                Immediate.UseShaders(() => {
                    if (ColorTex.Multisampled)
                    {
                        Immediate.TriangleShader = ShaderProgram.PostMultisample;
                        Immediate.TriangleShader.Uniform2f("TexSize", new Vector2(ColorTex.Width, ColorTex.Height));
                    }
                    else
                    {
                        Immediate.TriangleShader = ShaderProgram.Post;
                    }

                    Immediate.TriangleShader.Uniform1f("Exposure", 1.0f);

                    Gl.Enable(EnableCap.FramebufferSrgb);
                    Immediate.Texture2D(Vector2.Zero, ColorTex, UVInvertY: true);
                    Gl.Disable(EnableCap.FramebufferSrgb);
                });

                DrawGUI(Dt);
                Glfw.SwapBuffers(Window);

                // Cap at Target framerate
                while ((float)SWatch.ElapsedMilliseconds / 1000 < Target)
                {
                    ;
                }

                Dt  = (float)SWatch.ElapsedMilliseconds / 1000;
                FPS = (int)(1.0f / Dt);
                SWatch.Restart();
            }

            Environment.Exit(0);
        }
示例#28
0
 public static Dictionary <string, string> AvailableImporters()
 {
     return(Importers
            .OrderBy(i => i.Value.Emulator)
            .ToDictionary(tkey => tkey.Value.Emulator, tvalue => tvalue.Value.Extension));
 }
示例#29
0
 /// <summary>
 /// Given a file, read its headers, and find a suitable importer for it
 /// </summary>
 public static Importer ImporterFor(CsvParser csv)
 {
     return(Importers.FirstOrDefault(i => i.Matches(csv)));
 }
示例#30
0
        static void LoadContent()
        {
            string GameDllPath = Path.Combine(CVar.GetString("game"), "Game.dll");

            if (!File.Exists(GameDllPath))
            {
                FatalError("File not found: {0}", GameDllPath);
            }

            Assembly GameAssembly = Reflect.LoadAssembly(GameDllPath);

            Importers.RegisterAll(GameAssembly);

            Type[] GameImplementations = Reflect.GetAllImplementationsOf(GameAssembly, typeof(LibTechGame)).ToArray();

            if (GameImplementations.Length == 0)
            {
                FatalError("Could not find game implementation in {0}", GameDllPath);
            }
            if (GameImplementations.Length > 1)
            {
                FatalError("Found too many game implementations in {0}", GameDllPath);
            }

            Game = (LibTechGame)Activator.CreateInstance(GameImplementations[0]);
            Game.Load();

            RenderDevice = new RenderDevice(ShaderProgram.GUI, Width, Height);
            NuklearAPI.Init(RenderDevice);
            NuklearAPI.SetClipboardCallback((Txt) => {
                if (string.IsNullOrEmpty(Txt))
                {
                    return;
                }

                Glfw.SetClipboardString(Window, Txt);
            }, () => {
                string Str = Glfw.GetClipboardString(Window);
                if (Str == null)
                {
                    Str = "";
                }

                return(Str);
            });

            Glfw.SetCursorPosCallback(Window, (Wnd, X, Y) => {
                RenderDevice.OnMouseMove((int)X, (int)Y);
            });

            Glfw.SetMouseButtonCallback(Window, (Wnd, Button, State, Mods) => {
                NuklearEvent.MouseButton NkButton;
                bool IsDown = State == Glfw.InputState.Press ? true : false;

                if (!(State == Glfw.InputState.Press || State == Glfw.InputState.Release))
                {
                    return;
                }

                if (Button == Glfw.MouseButton.ButtonLeft)
                {
                    NkButton = NuklearEvent.MouseButton.Left;
                }
                else if (Button == Glfw.MouseButton.ButtonMiddle)
                {
                    NkButton = NuklearEvent.MouseButton.Middle;
                }
                else if (Button == Glfw.MouseButton.ButtonRight)
                {
                    NkButton = NuklearEvent.MouseButton.Right;
                }
                else
                {
                    return;
                }

                RenderDevice.OnMouseButton(NkButton, (int)MousePos.X, (int)MousePos.Y, IsDown);
            });

            Glfw.SetScrollCallback(Window, (Wnd, X, Y) => {
                RenderDevice.OnScroll((float)X, (float)Y);
            });

            Glfw.SetCharCallback(Window, (Wnd, Chr) => {
                RenderDevice.OnText(((char)Chr).ToString());
            });

            Glfw.SetKeyCallback(Window, (Wnd, KCode, SCode, State, Mods) => {
                if (KCode == Glfw.KeyCode.F1 && State == Glfw.InputState.Press)
                {
                    GConsole.Open = true;
                }

                NkKeys K = ConvertToNkKey(KCode, Mods);

                if (K != NkKeys.None)
                {
                    RenderDevice.OnKey(K, State == Glfw.InputState.Press);
                    if (State == Glfw.InputState.Repeat)
                    {
                        RenderDevice.OnKey(K, true);
                    }
                }
            });

            Glfw.SetDropCallback(Window, (Wnd, Cnt, Paths) => {
                DragDropPaths = Paths;
            });
        }
示例#31
0
 /// <summary>
 /// Returns a value indicating whether or not there is an importer for the given extension
 /// </summary>
 public static bool IsValidMovieExtension(string extension)
 {
     return(Importers
            .Select(i => i.Value)
            .Any(e => string.Equals(extension, e.Extension, StringComparison.OrdinalIgnoreCase)));
 }
示例#32
0
        static void RunGame()
        {
            TimeStopwatch = Stopwatch.StartNew();
            InitConsole();

            Engine.VFS = new VirtualFileSystem(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
            Engine.VFS.Mount("/content/", "./content");
            Engine.VFS.Mount("/materials/", "C:/Program Files (x86)/Steam/steamapps/common/GarrysMod/garrysmod/addons/quake_3_gmod_160207505/materials");

            string[] SourceGameDirs = Engine.SourceGameDirs.Value.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries).Where(Pth => Directory.Exists(Pth)).ToArray();

            if (SourceGameDirs.Length > 0)
            {
                foreach (var GameDir in SourceGameDirs)
                {
                    Engine.VFS.GetSourceProvider().AddRoot(GameDir);
                }
            }

            if (Directory.Exists(Path.Combine(Engine.GamePath, "content")))
            {
                Engine.VFS.Mount("/content/", Path.Combine(Engine.GamePath, "content"));
            }

            List <string> ZipResources = new List <string>();

            ZipResources.AddRange(Engine.VFS.GetFiles("/content/").Where(P => Path.GetExtension(P) == ".pk3" || Path.GetExtension(P) == ".zip"));

            foreach (var ZipResource in ZipResources)
            {
                Engine.VFS.MountArchive("/content/", ZipResource);
            }

            FileWatcher.Init("content");
            Importers.RegisterAll(Reflect.GetExeAssembly());

            Engine.GUI = new NuklearGUI();

            Engine.Window              = new RenderWindow(Engine.WindowWidth, Engine.WindowHeight, "libTech", Engine.WindowResizable);
            Engine.Window.OnMouseMove += Engine.GUI.OnMouseMove;
            Engine.Window.OnKey       += OnKey;
            Engine.Window.OnChar      += Engine.GUI.OnChar;

            RenderDoc.Init();

            GConsole.Init();
            GConsole.WriteLine("Running {0}", RenderAPI.Renderer, RenderAPI.Version);

            string ExtensionsFile = "extensions.txt";

            if (File.Exists(ExtensionsFile))
            {
                File.Delete(ExtensionsFile);
            }

            File.WriteAllLines(ExtensionsFile, RenderAPI.Extensions);
            EngineRenderer.Init();

            Engine.GUI.Init(Engine.Window, new ShaderProgram(new ShaderStage(ShaderType.VertexShader, "content/shaders/gui.vert"), new ShaderStage(ShaderType.FragmentShader, "content/shaders/gui.frag")));
            Engine.UI = new libGUI(Engine.Window);

            DbgDraw.Init();
            Lua.Init();

            GConsole.Color = Color.Orange;
            foreach (var DllName in FailedToLoadDLLs)
            {
                GConsole.WriteLine("Failed to load '{0}'", DllName);
            }
            GConsole.Color = Color.White;

            // Graphics init
            Gfx.ShadersDirectory = "content/shaders";
            //Gfx.Line3D = DefaultShaders.Line3D;
            //Gfx.Point3D = DefaultShaders.Point3D;
            //Gfx.Default3D = DefaultShaders.DefaultColor3D;

            // Camera init
            Engine.Camera2D = new Camera();
            Engine.Camera2D.SetOrthogonal(0, 0, Engine.Window.WindowWidth, Engine.Window.WindowHeight);

            Engine.Camera3D = new Camera();
            Engine.Camera3D.SetPerspective(Engine.Window.WindowWidth, Engine.Window.WindowHeight, FarPlane: 16000);

            LoadGameDll(Engine.GamePath);

            Stopwatch SWatch = Stopwatch.StartNew();

            int MaxFPS = Engine.MaxFPS;

            if (MaxFPS <= 0)
            {
                MaxFPS = 900;
            }

            float FrameCap = 1.0f / MaxFPS;
            float Dt       = 1.0f / 60.0f;

            while (!Engine.Window.ShouldClose)
            {
                Engine.FrameTime.Push(Dt);

                Update(Dt);
                EngineRenderer.Draw(Dt);

                // TODO: Move frame cap somewhere else
                while ((SWatch.ElapsedMilliseconds / 1000.0f) < FrameCap)
                {
                    Thread.Sleep(0);
                }

                Dt = SWatch.ElapsedMilliseconds / 1000.0f;
                SWatch.Restart();
            }
        }
示例#33
0
 private static Type ImporterForExtension(string ext)
 {
     return(Importers.FirstOrDefault(i => string.Equals(i.Value.Extension, ext, StringComparison.OrdinalIgnoreCase)).Key);
 }
示例#34
0
        public TLCGenPluginManager(string pluginpath)
        {
            try
            {
                if (Directory.Exists(pluginpath))
                {
                    // Find all Generator DLL's
                    foreach (String file in Directory.GetFiles(pluginpath))
                    {
                        if (Path.GetExtension(file).ToLower() == ".dll")
                        {
                            // Find and loop all types from the assembly
                            var assemblyInstance = Assembly.LoadFrom(file);
                            var types            = assemblyInstance.GetTypes();
                            var bFound           = false;
                            foreach (Type t in types)
                            {
                                // Find TLCGenPluginAttribute attribute, and if found, continue
                                var attr = (TLCGenPluginAttribute)Attribute.GetCustomAttribute(t, typeof(TLCGenPluginAttribute));
                                if (attr != null)
                                {
                                    var plugin = Activator.CreateInstance(t);

                                    if ((attr.PluginElements & TLCGenPluginElems.Generator) == TLCGenPluginElems.Generator)
                                    {
                                        Generators.Add(plugin as ITLCGenGenerator);
                                    }

                                    if ((attr.PluginElements & TLCGenPluginElems.Importer) == TLCGenPluginElems.Importer)
                                    {
                                        Importers.Add(plugin as ITLCGenImporter);
                                    }

                                    if ((attr.PluginElements & TLCGenPluginElems.MenuControl) == TLCGenPluginElems.MenuControl)
                                    {
                                        MenuItems.Add(plugin as ITLCGenMenuItem);
                                    }

                                    if ((attr.PluginElements & TLCGenPluginElems.TabControl) == TLCGenPluginElems.TabControl)
                                    {
                                        TabItems.Add(plugin as ITLCGenTabItem);
                                    }

                                    if ((attr.PluginElements & TLCGenPluginElems.ToolBarControl) == TLCGenPluginElems.ToolBarControl)
                                    {
                                        TabItems.Add(plugin as ITLCGenTabItem);
                                    }

                                    bFound = true;
                                }
                            }
                            if (!bFound)
                            {
                                //#if !DEBUG
                                System.Windows.MessageBox.Show($"Library {file} wordt niet herkend als TLCGen addin.");

                                //#endif
                            }
                        }
                    }
                }
                else
                {
                }
            }
            catch
            {
                throw new NotImplementedException();
            }
        }