Esempio n. 1
0
        public TileData(Engine engine)
        {
            _instance = this;

            IConfigurationService configurationService = engine.Kernel.Get<IConfigurationService>();
            string ultimaOnlineDirectory = configurationService.GetValue<string>(ConfigSections.UltimaOnline, ConfigKeys.UltimaOnlineDirectory);

            string filePath = Path.Combine(ultimaOnlineDirectory, "tiledata.mul");

            if (filePath != null)
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader bin = new BinaryReader(fs);

                    m_LandData = new LandData[0x4000];

                    for (int i = 0; i < 0x4000; ++i)
                    {
                        if ((i & 0x1F) == 0)
                        {
                            bin.ReadInt32(); // header
                        }

                        TileFlag flags = (TileFlag)bin.ReadInt32();
                        bin.ReadInt16(); // skip 2 bytes -- textureID

                        m_LandData[i] = new LandData(ReadNameString(bin), flags);
                    }

                    m_ItemData = new ItemData[0x4000];
                    m_HeightTable = new int[0x4000];

                    for (int i = 0; i < 0x4000; ++i)
                    {
                        if ((i & 0x1F) == 0)
                            bin.ReadInt32(); // header

                        TileFlag flags = (TileFlag)bin.ReadInt32();
                        int weight = bin.ReadByte();
                        int quality = bin.ReadByte();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int quantity = bin.ReadByte();
                        int anim = bin.ReadInt16();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int value = bin.ReadByte();
                        int height = bin.ReadByte();

                        m_ItemData[i] = new ItemData(ReadNameString(bin), flags, weight, quality, quantity, value, height, anim);
                        m_HeightTable[i] = height;
                    }
                }
            }
            else
            {
                throw new FileNotFoundException();
            }
        }
Esempio n. 2
0
 public Maps(Engine engine)
 {
     Felucca = new Map(engine, 0, 0, 6144, 4096);
     Trammel = new Map(engine, 0, 1, 6144, 4096);
     Ilshenar = new Map(engine, 2, 2, 2304, 1600);
     Malas = new Map(engine, 3, 3, 2560, 2048);
     Tokuno = new Map(engine, 4, 4, 1448, 1448);
 }
Esempio n. 3
0
 internal Map(Engine engine, int fileIndex, int mapID, int width, int height)
 {
     _engine = engine;
     _fileIndex = fileIndex;
     _mapID = mapID;
     _width = width;
     _height = height;
 }
Esempio n. 4
0
 public TextureFactory(Engine engine)
 {
     _engine = engine;
     _gumpCache = new Cache<int, Texture>(TimeSpan.FromMinutes(5), 0x1000);
     _landCache = new Cache<int, Texture>(TimeSpan.FromMinutes(5), 0x1000);
     _staticCache = new Cache<int, Texture>(TimeSpan.FromMinutes(5), 0x1000);
     _lastCacheClean = DateTime.MinValue;
     _textures = new Textures(engine);
     _hues = new Hues(engine);
     _gumps = new Gumps(engine);
     _art = new Art(engine);
     _unicodeFonts = new UnicodeFonts(engine);
 }
Esempio n. 5
0
        public Camera2D(Engine engine)
        {
            _projectionDirty = true;
            _transformDirty = true;
            _boundingFrustumDirty = true;

            _engine = engine;
            _engine.RenderForm.Resize += OnRenderFormResize;

            _width = _engine.RenderForm.ClientSize.Width;
            _height = engine.RenderForm.ClientSize.Height;
            _halfVector = new Vector2(1f / _width, 1f / _height);
        }
Esempio n. 6
0
        public Hues(Engine engine)
        {
            IConfigurationService configurationService = engine.Kernel.Get<IConfigurationService>();

            string ultimaOnlineDirectory = configurationService.GetValue<string>(ConfigSections.UltimaOnline, ConfigKeys.UltimaOnlineDirectory);

            if (!Directory.Exists(ultimaOnlineDirectory))
            {
                _filesExist = false;
                return;
            }

            string path = Path.Combine(ultimaOnlineDirectory, "hues.mul");

            using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryReader bin = new BinaryReader(fs);

                int blockCount = (int)fs.Length / 708;

                if (blockCount > 375)
                    blockCount = 375;

                _hues = new Texture[blockCount];

                for (int i = 0; i < blockCount; ++i)
                {
                    bin.ReadInt32();

                    Texture texture = new Texture(engine.Device, 34, 1, 0, Usage.None, Format.A1R5G5B5, Pool.Managed); ;
                    IntPtr dataPtr = texture.LockRectangle(0, LockFlags.None).DataPointer;

                    unsafe
                    {
                        ushort* line = (ushort*)dataPtr;

                        for (int j = 0; j < 34; j++)
                            (*line++) = (ushort)(bin.ReadUInt16() | 0x8000);

                        texture.UnlockRectangle(0);
                        bin.ReadBytes(20); //Don't need to know the names

                        _hues[i] = texture;
                    }
                }
            }
        }
Esempio n. 7
0
 public Gumps(Engine engine)
 {
     _device = engine.Device;
     _fileIndex = new FileIndex(engine, "Gumpidx.mul", "Gumpart.mul", 0x10000, 12);
 }
Esempio n. 8
0
 public Textures(Engine engine)
 {
     _device = engine.Device;
     _fileIndex = new FileIndex(engine, "texidx.mul", "texmaps.mul", 0x4000, 10);
 }
Esempio n. 9
0
        public UnicodeFonts(Engine engine)
        {
            IConfigurationService configurationService = engine.Kernel.Get<IConfigurationService>();
            IDeviceProvider provider = engine.Kernel.Get<IDeviceProvider>();

            _device = provider.Device;

            string ultimaOnlineDirectory = configurationService.GetValue<string>(ConfigSections.UltimaOnline, ConfigKeys.UltimaOnlineDirectory);

            if (!Directory.Exists(ultimaOnlineDirectory))
            {
                Tracer.Warn("UnicodeFonts: Ultima Online directory not found!");
                return;
            }

            for (int i = 0; i < _files.Length; i++)
            {
                string filePath = Path.Combine(ultimaOnlineDirectory, _files[i]);

                if (!File.Exists(filePath))
                {
                    Tracer.Warn("UnicodeFonts: Unable to find file {0}", filePath);
                    continue;
                }

                _fonts[i] = new UnicodeFont();

                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    int length = (int)fs.Length;
                    byte[] buffer = new byte[length];

                    int read = fs.Read(buffer, 0, buffer.Length);

                    using (MemoryStream stream = new MemoryStream(buffer))
                    {
                        using (BinaryReader bin = new BinaryReader(stream))
                        {
                            for (int c = 0; c < 0x10000; ++c)
                            {
                                _fonts[i].Chars[c] = new UnicodeChar();
                                stream.Seek((long)((c) * 4), SeekOrigin.Begin);

                                int index = bin.ReadInt32();

                                if ((index >= fs.Length) || (index <= 0))
                                    continue;

                                stream.Seek((long)index, SeekOrigin.Begin);

                                sbyte xOffset = bin.ReadSByte();
                                sbyte yOffset = bin.ReadSByte();

                                int Width = bin.ReadByte();
                                int Height = bin.ReadByte();

                                _fonts[i].Chars[c].XOffset = xOffset;
                                _fonts[i].Chars[c].YOffset = yOffset;
                                _fonts[i].Chars[c].Width = Width;
                                _fonts[i].Chars[c].Height = Height;

                                if (!((Width == 0) || (Height == 0)))
                                    _fonts[i].Chars[c].Bytes = bin.ReadBytes(Height * (((Width - 1) / 8) + 1));
                            }
                        }
                    }
                }
            }
        }
Esempio n. 10
0
File: Art.cs Progetto: nydehi/openuo
 public Art(Engine engine)
 {
     _device = engine.Device;
     _fileIndex = new FileIndex(engine, "artidx.mul", "art.mul", 0x10000, 4);
 }