コード例 #1
0
        /// <summary>
        /// Loads all the Texture Data
        /// </summary>
        public void LoadAllTextures()
        {
            string _BaseTexturePath = GameData.TextureDirectory;

            var _AllDirectories = System.IO.Directory.GetDirectories(_BaseTexturePath);

            foreach (string directory in _AllDirectories)
            {
                string _InfoPath = directory.EnsureDirectoryFormat() + "info.xml";

                if (System.IO.File.Exists(_InfoPath))
                {
                    // Texture Exists Load The XML File
                    try
                    {
                        var _LoadedTextureFile = LoadTextureFile(_InfoPath);
                        // Load All The Actual Images;
                        foreach (var t in _LoadedTextureFile.Textures.Textures)
                        {
                            string _FullFilePath = directory.EnsureDirectoryFormat() + t.FileName.GetFileNameFromFullPath(true);
                            var    _ImageID      = GameData.ImageManager.AddImage(_LoadedTextureFile.Name, t.FileName, _FullFilePath, false);
                            t.ImageID = _ImageID;
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrorLogable.LogError(ex, "Error Loading XML Texture File: " + _InfoPath, ACT.Core.Enums.ErrorLevel.Severe);
                    }
                }
            }
        }
コード例 #2
0
        public ActorManager(string BaseDirectory)
        //: base(XnaGame)
        {
            // Search Folders


            string[] _SubDirectories = Directory.GetDirectories(BaseDirectory.FormatDirectory() + "Actors");

            foreach (string _SubDirectory in _SubDirectories)
            {
                if (File.Exists(_SubDirectory.FormatDirectory() + "data.xml"))
                {
                    if (_Actors.ContainsKey(_SubDirectory.GetDirectoryName()))
                    {
                        _Actors.Remove(_SubDirectory.GetDirectoryName());
                    }

                    _Actors.Add(_SubDirectory.GetDirectoryName(), File.ReadAllText(_SubDirectory.FormatDirectory() + "data.xml"));
                }
                else
                {
                    ErrorLogable.LogError(new FileNotFoundException("data.xml was not found in : " + _SubDirectory), "Could not load data file for: " + _SubDirectory);
                }
            }

            // Search Zip
        }
コード例 #3
0
        public void LoadTexture(string Name, Stream InputStream)
        {
            if (_Textures.ContainsKey(Name))
            {
                ErrorLogable.LogError(null, "Duplicate Load Texture: " + Name); return;
            }

            _Textures.Add(Name, Texture2D.FromStream(this.Game.GraphicsDevice, InputStream));
        }
コード例 #4
0
 /// <summary>
 /// Add A Layer To The Editor Screen.
 /// </summary>
 /// <param name="Name"></param>
 /// <returns></returns>
 public bool AddLayer(string Name)
 {
     Name = Name.ToLower();
     if (_ScreenImages.ContainsKey(Name) == true)
     {
         ErrorLogable.LogError(null, "Editor Screen Already Contains This Layer: " + Name); return(false);
     }
     _ScreenImages.Add(Name, new Graphics.CompressibleImage((Image) new Bitmap(800, 600), System.Drawing.Imaging.ImageFormat.Png));
     return(true);
 }
コード例 #5
0
        /// <summary>
        /// Adds A Layer To The World.  Note: All Layers Are Added To The End Call Reorder Layer Method To Change Layer Order.
        /// </summary>
        /// <param name="Name">Layer Name</param>
        /// <param name="Visible">If It Is Visible</param>
        /// <returns></returns>
        public bool AddLayer(LayerInfo NewLayer)
        {
            if (_Layers.ContainsKey(NewLayer.Name.ToLower()) == true)
            {
                ErrorLogable.LogError(null, "Duplicate Layer Found"); return(false);
            }

            _Layers.Add(NewLayer.Name.ToLower(), NewLayer);

            return(true);
        }
コード例 #6
0
 /// <summary>
 /// Updates the Screens Layer Image
 /// </summary>
 /// <param name="LayerName">Name Of The Layer To Update</param>
 /// <param name="NewLayerImage">New Image</param>
 public void UpdateLayerImage(string LayerName, Image NewLayerImage)
 {
     if (_ScreenImages.ContainsKey(LayerName.ToLower()))
     {
         _ScreenImages[LayerName.ToLower()] = new CompressibleImage(NewLayerImage, System.Drawing.Imaging.ImageFormat.Png);
     }
     else
     {
         ErrorLogable.LogError(null, "Layer Image Not Found: " + LayerName, ACT.Core.Enums.ErrorLevel.Severe);
         throw new Exception("Error Saving Image To Layer: Layer Not Found: " + LayerName);
     }
 }
コード例 #7
0
 /// <summary>
 /// Get The CompressedImage
 /// </summary>
 /// <param name="LayerName"></param>
 /// <returns></returns>
 public Graphics.CompressibleImage GetLayerCompressedImage(string LayerName)
 {
     if (_ScreenImages.ContainsKey(LayerName.ToLower()))
     {
         return(_ScreenImages[LayerName.ToLower()]);
     }
     else
     {
         ErrorLogable.LogError(null, "Layer Image Not Found: " + LayerName, ACT.Core.Enums.ErrorLevel.Severe);
         return(null);
     }
 }
コード例 #8
0
 public Texture2D GetTexture(string Name)
 {
     if (_Textures.ContainsKey(Name))
     {
         return(_Textures[Name]);
     }
     else
     {
         ErrorLogable.LogError(null, "Texture Not Found: " + Name);
         throw new Exception("Texture Not Found");
     }
 }
コード例 #9
0
        public void UpdateWorkingLayer(int X, int Y)
        {
            string _Key = GetKey(X, Y, Enumerations.RelativePosition.Main);

            if (!Screens.ContainsKey(_Key))
            {
                ErrorLogable.LogError(null, "The Screen was Not Found: " + _Key, ACT.Core.Enums.ErrorLevel.Critical);
                throw new Exception("The Specified Screen Was Not Found");
            }

            Screens[_Key].UpdateLayerImage(_CurrentLayer, _WorkingLayerImage);
        }
コード例 #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="BaseDirectory"></param>
        /// <returns></returns>
        public static LoadResults LoadSystemTextures(string BaseDirectory)
        {
            string[]    _TextureDirectories = System.IO.Directory.GetDirectories(BaseDirectory);
            LoadResults _TmpReturn          = new LoadResults();

            for (int x = 0; x < _TextureDirectories.Count(); x++)
            {
                if (!System.IO.File.Exists(_TextureDirectories[x].EnsureDirectoryFormat() + "info.txt"))
                {
                    continue;
                }

                dynamic TextureInfo = ACT.Core.Dynamic.Encoder.LoadFromFile(_TextureDirectories[x].EnsureDirectoryFormat() + "info.txt");

                var _MemberNames = TextureInfo.backgrounds.GetMemberNames;

                for (int xx = 0; xx < _MemberNames.Count; xx++)
                {
                    if (_MemberNames[xx] == "name")
                    {
                        continue;
                    }
                    TextureInfo _TmpNewTexture = new Assets.TextureInfo();
                    _TmpNewTexture.FileName = TextureInfo.backgrounds.GetObject(_MemberNames[xx]).GetObject("filename");

                    if (!System.IO.File.Exists(_TextureDirectories[x].EnsureDirectoryFormat() + _TmpNewTexture.FileName))
                    {
                        _TmpReturn.TotalImagesFailed++;
                        ErrorLogable.LogError(null, "Image File Not Found: " + _TmpNewTexture.FileName, ACT.Core.Enums.ErrorLevel.Critical);
                        continue;
                    }
                    _TmpReturn.TotalImagesLoaded++;

                    _TmpNewTexture.PackageName = _TextureDirectories[x].GetDirectoryName();
                    _TmpNewTexture.Description = TextureInfo.backgrounds.GetObject(_MemberNames[xx]).GetObject("description");
                    _TmpNewTexture.DisplayName = TextureInfo.backgrounds.GetObject(_MemberNames[xx]).GetObject("displayname");
                    _TmpNewTexture.FileName    = TextureInfo.backgrounds.GetObject(_MemberNames[xx]).GetObject("filename");
                    _TmpNewTexture.ID          = TextureInfo.backgrounds.GetObject(_MemberNames[xx]).GetObject("id");
                    _TmpNewTexture.Name        = TextureInfo.backgrounds.GetObject(_MemberNames[xx]).GetObject("name");
                    _TmpNewTexture.Image       = new CompressibleImage(new Bitmap(_TextureDirectories[x].EnsureDirectoryFormat() + _TmpNewTexture.FileName), System.Drawing.Imaging.ImageFormat.Png);
                    _SystemTextureCache.Add(_TmpNewTexture.Name, _TmpNewTexture);
                }
            }

            return(_TmpReturn);
        }
コード例 #11
0
        public void LoadTexture(string Name, string Location)
        {
            // Return Out (Log Duplicate Effort)
            if (_Textures.ContainsKey(Name))
            {
                ErrorLogable.LogError(null, "Duplicate Load Texture: " + Name); return;
            }

            if (System.IO.File.Exists(Location + Name + ".png"))
            {
                // System.IO.FileStream _tmp = new FileStream("asdasd",  FileMode.Open);

                _Textures.Add(Name, Texture2D.FromStream(this.Game.GraphicsDevice, System.IO.File.Open(Location + Name + ".png", FileMode.Open)));
            }
            else if (System.IO.File.Exists(Location))
            {
                _Textures.Add(Name, Texture2D.FromStream(this.Game.GraphicsDevice, System.IO.File.Open(Location, FileMode.Open)));
            }
            //_Textures.Add(Name, this.Game.Content.Load<Texture2D>(Name));
        }
コード例 #12
0
        /// <summary>
        /// Loads All The System Resources Found In The Directory Specified
        /// </summary>
        /// <param name="BaseDirectory"></param>
        /// <returns></returns>
        public static LoadResults LoadSystemImages(string BaseDirectory)
        {
            LoadResults _TmpReturn = new LoadResults();

            if (Directory.Exists(BaseDirectory))
            {
                _SystemImageCache.Clear();
                // Load All Objects Found
                foreach (string _ObjFile in Directory.GetFiles(BaseDirectory))
                {
                    if (_ObjFile.EndsWith(".png") == false)
                    {
                        continue;
                    }

                    System.IO.FileInfo _TmpFileInfo = new FileInfo(_ObjFile);
                    _TmpReturn.TotalBytesLoaded += _TmpFileInfo.Length;
                    _TmpFileInfo = null;

                    try
                    {
                        CompressibleImage _TmpImage = new CompressibleImage(Image.FromFile(_ObjFile), System.Drawing.Imaging.ImageFormat.Png);
                        _SystemImageCache.Add(_ObjFile.GetFileName(false), _TmpImage);
                        _TmpReturn.TotalImagesLoaded++;
                    }
                    catch (Exception ex)
                    {
                        ErrorLogable.LogError(ex, "Error Loading Resource: " + BaseDirectory + _ObjFile, ACT.Core.Enums.ErrorLevel.Critical);
                        _TmpReturn.TotalImagesFailed++;
                    }
                }
            }
            else
            {
                _TmpReturn.TotalImagesLoaded = -1; ErrorLogable.LogError(null, "Error Loading Resources From Directory: " + BaseDirectory, ACT.Core.Enums.ErrorLevel.Critical);
            }

            return(_TmpReturn);
        }
コード例 #13
0
        public EditorWorld(string FileName, int EditorWidth, int EditorHeight, Point FocusPoint)
        {
            if (System.IO.File.Exists(FileName) == false)
            {
                throw new Exception("World File Not Found");
            }

            _ApplicationDirectory = AppDomain.CurrentDomain.BaseDirectory.EnsureDirectoryFormat();
            _BaseDirectory        = FileName.Substring(0, FileName.LastIndexOf("\\") + 1).EnsureDirectoryFormat();
            _LayersDirectory      = _BaseDirectory + "layers\\";
            _ObjectDirectory      = _BaseDirectory + "objects\\";

            // LOAD FILE NEW FORMAT
            dynamic Settings = ACT.Core.Dynamic.Encoder.LoadFromFile(FileName);

            NonPassableColor = System.Drawing.ColorTranslator.FromHtml(Settings.nonpassablecolor);

            #region Load The Layers
            foreach (string name in Settings.layers.GetMemberNames)
            {
                if (name == "name")
                {
                    continue;
                }
                dynamic   _TmpLayerData = Settings.layers.GetObject(name);
                LayerInfo _NewLayer     = new LayerInfo();
                _NewLayer.Name      = _TmpLayerData.Name;
                _NewLayer.Visible   = Convert.ToBoolean(_TmpLayerData.visible);
                _NewLayer.LayerType = Enum.Parse(typeof(Enumerations.LayerType), _TmpLayerData.type);
                _Layers.Add(_NewLayer.Name, _NewLayer);
            }
            #endregion

            #region Load The Screens
            foreach (string name in Settings.screens.GetMemberNames)
            {
                if (name == "name")
                {
                    continue;
                }
                dynamic _TmpScreenData = Settings.screens.GetObject(name);

                string[] PositionData = name.SplitString("-", StringSplitOptions.RemoveEmptyEntries);
                if (PositionData.Length != 2)
                {
                    ErrorLogable.LogError(null, "Invalid PositionData-Name", ACT.Core.Enums.ErrorLevel.Severe);
                    continue;
                }
                EditorScreen _NewScreen = new EditorScreen(Convert.ToInt32(PositionData[0]), Convert.ToInt32(PositionData[1]), this);

                #region Load the Objects
                foreach (string objname in _TmpScreenData.objects.GetMemberNames)
                {
                    if (objname == "name")
                    {
                        continue;
                    }
                    dynamic MapObjectInfo = _TmpScreenData.objects.GetObject(objname);
                    try
                    {
                        MapObject _NewMapObject = new MapObject();
                        _NewMapObject.ID = new Guid(objname.Trim());
                        string _MapImageLocation = _ObjectDirectory + _NewMapObject.ID + ".png";

                        if (!System.IO.File.Exists(_MapImageLocation))
                        {
                            ErrorLogable.LogError(null, "Error Locating Object: " + _NewMapObject.ID.ToString(), ACT.Core.Enums.ErrorLevel.Critical);
                            continue;
                        }

                        string _Location = MapObjectInfo.location;
                        string _Size     = MapObjectInfo.size;

                        string[] _Points = _Location.SplitString(",", StringSplitOptions.RemoveEmptyEntries);
                        string[] _Sizes  = _Location.SplitString(",", StringSplitOptions.RemoveEmptyEntries);

                        _NewMapObject.DrawLocation = new Point(Convert.ToInt32(_Points[0]), Convert.ToInt32(_Points[1]));
                        _NewMapObject.ImageSize    = new Size(Convert.ToInt32(_Sizes[0]), Convert.ToInt32(_Sizes[1]));
                        _NewMapObject.Position     = Enum.Parse(typeof(NebulaGames.RPGWorld.Enumerations.RelativePosition), MapObjectInfo.relativeposition);
                        _NewMapObject.ResourceName = "";
                        _NewMapObject.Screen       = _NewScreen;
                        _NewScreen.MapObjects.Add(_NewMapObject);

                        Graphics.CompressibleImage _TmpMapObject = new CompressibleImage(Image.FromFile(_MapImageLocation), System.Drawing.Imaging.ImageFormat.Png);

                        ResourceManager.AddObject(_NewMapObject.ID.ToString(), _TmpMapObject);
                    }
                    catch (Exception ex)
                    {
                        ErrorLogable.LogError(ex, "Error Loading Object: " + name, ACT.Core.Enums.ErrorLevel.Critical);
                    }
                }
                #endregion

                #region Load the Layer Images
                foreach (string TmpLayerName in _Layers.Keys)
                {
                    if (System.IO.File.Exists(_LayersDirectory + TmpLayerName + "\\" + name + ".png"))
                    {
                        _NewScreen.AddUpdateLayerImage(TmpLayerName.ToLower(), Image.FromFile(_LayersDirectory + TmpLayerName + "\\" + name + ".png"));
                    }
                }
                #endregion

                Screens.Add(name, _NewScreen);
            }
            #endregion

            EditorScreenWidth  = EditorWidth;
            EditorScreenHeight = EditorHeight;

            OffsetX = (EditorScreenWidth - 800) / 2;
            OffsetY = (EditorScreenHeight - 600) / 2;

            _BackBufferImage = new Bitmap(EditorScreenWidth, EditorScreenHeight);
            _G = System.Drawing.Graphics.FromImage(_BackBufferImage);
            _MiniMapBufferGraphics      = System.Drawing.Graphics.FromImage(_MiniMapBufferImage);
            _SingleScreenGraphicsObject = System.Drawing.Graphics.FromImage(_SingleScreenImage);
        }
コード例 #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="SourceCode"></param>
        /// <param name="assemblies"></param>
        /// <returns></returns>
        public static object CompileInMemory(string Name, string SourceCode, params string[] assemblies)
        {
            try
            {
                // Add Method Code Here
                Dictionary <string, string> provOptions = new Dictionary <string, string>();

                // provOptions.Add("CompilerVersion", "v4");
                provOptions.Add("CompilerDirectoryPath", @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\");
                using (CodeDomProvider cc = CodeDomProvider.CreateProvider("cs", provOptions))
                {
                    CompilerParameters Parameters = new CompilerParameters();

                    // *** Start by adding any referenced assemblies
                    Parameters.ReferencedAssemblies.Add("System.dll");
                    Parameters.ReferencedAssemblies.Add("System.Data.Linq.dll");
                    Parameters.ReferencedAssemblies.Add("System.Data.dll");
                    Parameters.ReferencedAssemblies.Add("System.Core.dll");
                    Parameters.ReferencedAssemblies.Add("System.Xml.dll");
                    Parameters.ReferencedAssemblies.Add(Environment.GetEnvironmentVariable("XNAGSv4") + @"References\Windows\x86\Microsoft.Xna.Framework.dll");
                    Parameters.ReferencedAssemblies.Add(Environment.GetEnvironmentVariable("XNAGSv4") + @"References\Windows\x86\Microsoft.Xna.Framework.Game.dll");
                    Parameters.ReferencedAssemblies.Add(Environment.GetEnvironmentVariable("XNAGSv4") + @"References\Windows\x86\Microsoft.Xna.Framework.Graphics.dll");
                    Parameters.ReferencedAssemblies.Add("mscorlib.dll");
                    Parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");
                    Parameters.ReferencedAssemblies.Add("GG2DLib.dll");
                    Parameters.ReferencedAssemblies.Add("ICSharpCode.SharpZipLib.dll");



                    if (assemblies != null)
                    {
                        foreach (string assembly in assemblies)
                        {
                            if (!Parameters.ReferencedAssemblies.Contains(assembly))
                            {
                                Parameters.ReferencedAssemblies.Add(assembly);
                            }
                        }
                    }
                    // *** Load the resulting assembly into memory
                    Parameters.GenerateInMemory = true;

                    // *** Now compile the whole thing
                    CompilerResults loCompiled = cc.CompileAssemblyFromSource(Parameters, SourceCode);

                    if (loCompiled.Errors.HasErrors)
                    {
                        string lcErrorMsg = "";

                        // *** Create Error String
                        lcErrorMsg = loCompiled.Errors.Count.ToString() + " Errors:";
                        for (int x = 0; x < loCompiled.Errors.Count; x++)
                        {
                            lcErrorMsg = lcErrorMsg + "\r\nLine: " + loCompiled.Errors[x].Line.ToString() + " - " +
                                         loCompiled.Errors[x].ErrorText;
                        }

                        return(string.Format("Compiler Error: {0}\r\n\r\n{1}", lcErrorMsg, SourceCode));
                    }

                    Assembly loAssembly = loCompiled.CompiledAssembly;

                    _Compiled.Add(Name, loAssembly);

                    return(loAssembly);
                }
            }
            catch (Exception ex)
            {
                System.Collections.Generic.Dictionary <string, object> methodParams = new System.Collections.Generic.Dictionary <string, object>();
                methodParams.Add("SourceCode", SourceCode);
                methodParams.Add("assemblies", assemblies);

                ErrorLogable.LogError(ex, "Error Compiling: " + Name);
                throw ex;
            }
        }