Example #1
0
 void SetPie(MapFile map)
 {
     _pie = new Piechart(map.Name);
     foreach (ObjectFile obj in map.Values)
         _pie.Add(obj.Name, obj.TotalSize);
     panel1.Invalidate();
 }
Example #2
0
 public void SetMapFile(string path)
 {
     MapGrinder g = new MapGrinder();
     this.TopLevelControl.Text = path;
     _map = g.Grind(path);
     SetPie(_map);
 }
Example #3
0
 void SetPie(MapFile map, string name)
 {
     _pie = new Piechart(name);
     ObjectFile obj = map[name];
     foreach (Blob blob in obj)
         _pie.Add(blob.Name, blob.Size);
     panel1.Invalidate();
 }
        /// <summary>
        /// Save the given map file.
        /// </summary>
        /// <param name="mapFile">The map file to be saved</param>
        public void SaveMapFile(MapFile mapFile)
        {
            Debug.Assert(mapFile != null, "mapFile is null!");

            SaveExternalFiles(mapFile);

            using (var mapFileWriter = GetMapFileWriter())
            {
                GetMapFileSerializer().Serialize(mapFileWriter, Unwrap(mapFile));
            }
        }
        static MapObject ReadObject(MapFile map, BinaryReader br)
        {
            string type = br.ReadCString();

            switch (type)
            {
            case "CMapWorld":
                return(ReadRoot(map, br));

            case "CMapGroup":
                return(ReadGroup(map, br));

            case "CMapSolid":
                return(ReadSolid(map, br));

            case "CMapEntity":
                return(ReadEntity(map, br));

            default:
                throw new ArgumentOutOfRangeException("Unknown RMF map object: " + type);
            }
        }
        static void ReadMapBase(MapFile map, MapObject obj, BinaryReader br)
        {
            int visgroupId = br.ReadInt32();

            if (visgroupId > 0)
            {
                obj.Visgroups.Add(visgroupId);
            }

            obj.Color = br.ReadRGBColour();

            int numChildren = br.ReadInt32();

            for (int i = 0; i < numChildren; i++)
            {
                MapObject child = ReadObject(map, br);
                if (child != null)
                {
                    obj.Children.Add(child);
                }
            }
        }
Example #7
0
        public void MappingEvent()
        {
            var provider = new MappingEventProvider();

            provider.Initialize(_config,
                                null,
                                MapFile.Read("FOXA", Market.USA),
                                new DateTime(2006, 1, 1));

            Assert.AreEqual("NWSA", _config.MappedSymbol);

            var symbolEvent = (SymbolChangedEvent)provider
                              .GetEvents(new NewTradableDateEventArgs(
                                             new DateTime(2013, 6, 29),
                                             null,
                                             _config.Symbol,
                                             null)).Single();

            Assert.AreEqual("FOXA", symbolEvent.NewSymbol);
            Assert.AreEqual("NWSA", symbolEvent.OldSymbol);
            Assert.AreEqual("FOXA", _config.MappedSymbol);
        }
Example #8
0
                protected virtual IndexEntry SelectEntry(MapFile map, IndexEntry entry)
                {
                    //Prepare
                    IndexEntry result = entry;

                    //Create Dialog
                    using (TagBrowserDialog tagDlg = new TagBrowserDialog(map.IndexEntries, map.Name))
                    {
                        //Setup
                        tagDlg.AllowNull  = false;
                        tagDlg.SelectedID = entry.Id;

                        //Show
                        if (tagDlg.ShowDialog() == DialogResult.OK)
                        {
                            result = map.IndexEntries[tagDlg.SelectedID];
                        }
                    }

                    //Return
                    return(entry);
                }
Example #9
0
            public static void SaveGlobalConfig(List <ServiceNftable> newParameters)
            {
                var shares = MapFile.Get().Share;
                var data   = new List <LineModel>()
                {
                };

                foreach (var parameter in newParameters)
                {
                    data.Add(ConvertData(parameter));
                }
                var nftable = new NftableModel()
                {
                    _Id       = serviceGuid,
                    Guid      = serviceGuid,
                    Timestamp = Timestamp.Now,
                    Share     = shares,
                    Data      = data
                };

                DeNSo.Session.New.Set(nftable);
            }
Example #10
0
        /// <summary>
        /// Create and set a breakpoint at the given location.
        /// An exception is thrown if the location cannot be found.
        /// </summary>
        public DalvikLocationBreakpoint SetAtLocation(string document, int startLine, int startCol, int endLine, int endCol, object data)
        {
            // Search matching document
            var doc = MapFile.FindDocument(document);

            if (doc == null)
            {
                throw new ArgumentException("Unknown document " + document);
            }

            // Search best position
            var pos = doc.Find(startLine, startCol, endLine, endCol);

            if (pos == null)
            {
                throw new ArgumentException(string.Format("No code found at position {0},{1}-{2},{3}", startLine, startCol, endLine, endCol));
            }

            // Lookup class & method
            var type = MapFile.GetTypeById(pos.Position.TypeId);

            if (type == null)
            {
                throw new ArgumentException(string.Format("Inconsistent map file, missing type {0}", pos.Position.TypeId));
            }
            var method = type.GetMethodById(pos.Position.MethodId);

            if (method == null)
            {
                throw new ArgumentException(string.Format("Inconsistent map file, missing method {0}", pos.Position.MethodId));
            }

            // Now create the breakpoint
            var bp = CreateLocationBreakpoint(pos, type, method, data);

            SetBreakpoint(bp);

            return(bp);
        }
Example #11
0
        private static bool CheckTile(MapFile EMF, int x, int y)
        {
            if (EMF.WarpLookup[y, x] != null)
            {
                return(false);
            }

            if (EMF.TileLookup[y, x] != null)
            {
                switch (EMF.TileLookup[y, x].spec)
                {
                case TileSpec.Wall:
                case TileSpec.ChairDown:
                case TileSpec.ChairLeft:
                case TileSpec.ChairRight:
                case TileSpec.ChairUp:
                case TileSpec.ChairDownRight:
                case TileSpec.ChairUpLeft:
                case TileSpec.ChairAll:
                case TileSpec.Chest:
                case TileSpec.BankVault:
                case TileSpec.NPCBoundary:
                case TileSpec.MapEdge:
                case TileSpec.Board1:
                case TileSpec.Board2:
                case TileSpec.Board3:
                case TileSpec.Board4:
                case TileSpec.Board5:
                case TileSpec.Board6:
                case TileSpec.Board7:
                case TileSpec.Board8:
                case TileSpec.Jukebox:
                    return(false);
                }
            }

            return(true);
        }
Example #12
0
        public Editor()
        {
            // default graph properties
            GraphGridColor   = Color.DarkOliveGreen;
            GraphGridOpacity = 0.5f;                    // default 10% visible

            graphOffset = new PointF(0.0f, 0.0f);       // panning offset
            graphZoom   = 1.2f;
            tileOffset  = new PointF(0.0f, 0.0f);
            tileZoom    = 1.2f;
            GridSize    = 16;

            CurrentTool = tools_t.TOOL_NONE;
            selection   = new Selection(1, 0);
            // initialize private stuff
            mapfile       = new MapFile();
            SelectedLayer = 0;
            ShowGrid      = true;
            TileMode      = false;
            TileDrawing   = true;
            LayersAbove   = true;

            // designer auto-generated initialization procedure
            InitializeComponent();

            // add mousewheel function to event trigger list
            SizeChanged += Editor_SizeChanged;
            Paint       += Editor_Paint;

            MouseWheel += Editor_MouseWheel;
            MouseDown  += Editor_MouseDown;
            MouseMove  += Editor_MouseMove;
            MouseUp    += Editor_MouseUp;

            // make sure only we can paint, and double-buffered
            this.SetStyle(ControlStyles.AllPaintingInWmPaint
                          | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
        }
Example #13
0
    public static void Save(Map map, string path)
    {
        if (map.transform.childCount <= 0)
        {
            return;
        }

        var mapObjects = new List <MapObject>();

        foreach (var child in map.transform)
        {
            Transform transform = child as Transform;
            Prefab    prefab    = child as Prefab;
            mapObjects.Add(new MapObject(prefab.id, transform.position));
        }

        var mapFile = new MapFile(map.name, mapObjects.ToArray());

        XmlSerializer serializer = new XmlSerializer(typeof(MapFile));

        using (FileStream stream = new FileStream(path, FileMode.Create))
            serializer.Serialize(stream, mapFile);
    }
Example #14
0
        private void mapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Check
            if (sender is ToolStripItem mapItem)
            {
                //Open
                m_MapFile = new MapFile();
                m_MapFile.Load(mapItem.Name);

                //Load
                listBox1.Items.Clear();
                foreach (IndexEntry entry in m_MapFile.IndexEntries)
                {
                    listBox1.Items.Add($"{entry.Id} {entry.Filename}.{entry.Root}");
                }

                //Set
                tagCountToolStripTextBox.Text = $"{m_MapFile.IndexEntries.Count} tags";

                //Dispose
                m_MapFile.Dispose();
            }
        }
Example #15
0
        /// <summary>
        /// Record the mapping from .NET to Dex
        /// </summary>
        public void RecordMapping(MapFile mapFile)
        {
            // Create mapping
            var dexName   = (classDef != null) ? classDef.Fullname : null;
            var mapFileId = (classDef != null) ? classDef.MapFileId : 0;
            var entry     = new TypeEntry(typeDef.FullName, typeDef.Scope.Name, dexName, mapFileId);

            if (fieldBuilders != null)
            {
                fieldBuilders.ForEach(x => x.RecordMapping(entry));
            }
            if (methodBuilders != null)
            {
                methodBuilders.ForEach(x => x.RecordMapping(entry));
            }
            mapFile.Add(entry);

            // Create mapping of nested classes
            if (nestedBuilders != null)
            {
                nestedBuilders.ForEach(x => x.RecordMapping(mapFile));
            }
        }
Example #16
0
        /// <summary>
        /// Loads the specified map and returns it as a template. Templates are cached, so maps that are requested multiple times only need to be loaded once.
        /// </summary>
        private MapTemplate GetMapTemplate(string path, IDictionary <string, object> globals)
        {
            path = Path.GetFullPath(path);
            if (!_mapTemplateCache.TryGetValue(path, out var template))
            {
                Logger.Info($"Loading map template '{path}' from file.");

                // NOTE: Entity rewrite directives are applied after entity path expansion, so rewriting will also affect these entities.
                //       Rewriting happens before template detection, so rewriting something to a macro_template entity will work as expected:
                var map = MapFile.Load(path);
                map.ExpandPaths();
                ApplyRewriteDirectives(map, _rewriteDirectives);

                template = MapTemplate.FromMap(map, path, globals, Logger);

                _mapTemplateCache[path] = template;
            }
            else
            {
                Logger.Verbose($"Loading map template '{path}' from cache.");
            }
            return(template);
        }
Example #17
0
        /// <summary>
        /// Connect to the VM in the given process id on the given device.
        /// </summary>
        public void Connect(IDevice device, int pid, MapFile mapFile)
        {
            // Disconnect any pending connections
            Disconnect();

            // Cleanup
            process      = null;
            this.mapFile = mapFile;
            this.pid     = pid;

            // Setup forward
            var port = GetFreePort();
            var adb  = new Adb();

            adb.ForwardJdwp(device, port, pid);

            // Establish connection
            connection             = new JdwpConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), port), ChunkHandler, pid, PacketHandler);
            connection.Disconnect += OnConnectionDisconnect;

            // Notify
            ConnectedChanged.Fire(this);
        }
Example #18
0
            public static void AddParameterToGlobal(string key, string value)
            {
                var type         = Helper.ServiceData.SupposeDataType(value);
                var booleanVerbs = Helper.ServiceData.SupposeBooleanVerbs(value);
                var line         = new LineModel {
                    FilePath     = $"{MntDir}/{MainFile}",
                    Key          = key,
                    Value        = value,
                    Type         = type,
                    BooleanVerbs = booleanVerbs
                };
                var data = MapFile.Get().Data;

                data.Add(line);
                var ssh = new SshModel {
                    _Id       = ServiceGuid,
                    Guid      = ServiceGuid,
                    Timestamp = Timestamp.Now,
                    Data      = data
                };

                DeNSo.Session.New.Set(ssh);
            }
Example #19
0
        /// <summary>
        /// Initializes this instance
        /// </summary>
        /// <param name="config">The <see cref="SubscriptionDataConfig"/></param>
        /// <param name="factorFile">The factor file to use</param>
        /// <param name="mapFile">The <see cref="MapFile"/> to use</param>
        public void Initialize(
            SubscriptionDataConfig config,
            FactorFile factorFile,
            MapFile mapFile)
        {
            _config = config;
            // Estimate delisting date.
            switch (config.Symbol.ID.SecurityType)
            {
            case SecurityType.Future:
                _delistingDate = config.Symbol.ID.Date;
                break;

            case SecurityType.Option:
                _delistingDate = OptionSymbol.GetLastDayOfTrading(
                    config.Symbol);
                break;

            default:
                _delistingDate = mapFile.DelistingDate;
                break;
            }
        }
Example #20
0
        public void CanRoundtripMaps()
        {
            InstalledFilesTestData.ReadFiles(".map", _output, entry =>
            {
                // These maps have false positive differences, so ignore differences.
                bool skipRoundtripEqualityTest = false;
                switch (entry.FilePath)
                {
                // Differences in passability data, because the original files have unusual
                // values for partial passability bytes beyond the map width.
                case @"Maps\USA07-TaskForces\USA07-TaskForces.map":
                case @"maps\map evil shelobslair\map evil shelobslair.map":                                 // BFME
                case @"maps\map good shelobslair\map good shelobslair.map":                                 // BFME
                case @"data\maps\official\map_sp_aliens_1_1_london\map_sp_aliens_1_1_london.map":           // CNC3
                case @"data\maps\official\map_sp_gdi_2_4_nuke_facility\map_sp_gdi_2_4_nuke_facility.map":   // CNC3
                case @"data\maps\official\map_sp_gdi_4_4_berne\map_sp_gdi_4_4_berne.map":                   // CNC3
                case @"data\maps\official\map_sp_nod_2_3_coastal_brazil\map_sp_nod_2_3_coastal_brazil.map": // CNC3
                case @"data\maps\official\map_sp_nod_5_5_the_tower\map_sp_nod_5_5_the_tower.map":           // CNC3
                case @"data\maps\official\map_mp_4_black1\map_mp_4_black1.map":                             // CNC3
                case @"data\maps\official\metagameworld\metagameworld.map":                                 // CNC3
                case @"data\maps\official\metagameworldact1\metagameworldact1.map":                         // CNC3
                case @"data\maps\official\metagameworldact2\metagameworldact2.map":                         // CNC3
                case @"data\maps\official\metagameworldact3\metagameworldact3.map":                         // CNC3
                    skipRoundtripEqualityTest = true;
                    break;
                }

                using (var entryStream = entry.Open())
                {
                    TestUtility.DoRoundtripTest(
                        () => MapFile.Decompress(entryStream),
                        stream => MapFile.FromStream(stream),
                        (mapFile, stream) => mapFile.WriteTo(stream),
                        skipRoundtripEqualityTest);
                }
            });
        }
Example #21
0
        public StringTableGen2(EndianReader reader, MapFile baseMapFile) : base()
        {
            //
            // Read offsets
            //

            reader.SeekTo(baseMapFile.Header.StringIDsIndicesOffset);

            int[] stringOffset = new int[baseMapFile.Header.StringIDsCount];
            for (var i = 0; i < baseMapFile.Header.StringIDsCount; i++)
            {
                stringOffset[i] = reader.ReadInt32();
                Add("");
            }

            reader.SeekTo(baseMapFile.Header.StringIDsBufferOffset);

            EndianReader newReader = new EndianReader(new MemoryStream(reader.ReadBytes(baseMapFile.Header.StringIDsBufferSize)), reader.Format);

            //
            // Read strings
            //

            for (var i = 0; i < stringOffset.Length; i++)
            {
                if (stringOffset[i] == -1)
                {
                    this[i] = "<null>";
                    continue;
                }

                newReader.SeekTo(stringOffset[i]);
                this[i] = newReader.ReadNullTerminatedString();
            }
            newReader.Close();
            newReader.Dispose();
        }
Example #22
0
        public virtual void TestFix()
        {
            string IndexLessMapFile = "testFix.mapfile";
            int    PairSize         = 20;

            MapFile.Writer writer = null;
            try
            {
                FileSystem fs  = FileSystem.GetLocal(conf);
                Path       dir = new Path(TestDir, IndexLessMapFile);
                writer = CreateWriter(IndexLessMapFile, typeof(IntWritable), typeof(Text));
                for (int i = 0; i < PairSize; i++)
                {
                    writer.Append(new IntWritable(0), new Text("value"));
                }
                writer.Close();
                FilePath indexFile = new FilePath(".", "." + IndexLessMapFile + "/index");
                bool     isDeleted = false;
                if (indexFile.Exists())
                {
                    isDeleted = indexFile.Delete();
                }
                if (isDeleted)
                {
                    Assert.True("testFix error !!!", MapFile.Fix(fs, dir, typeof(IntWritable
                                                                                 ), typeof(Text), true, conf) == PairSize);
                }
            }
            catch (Exception)
            {
                NUnit.Framework.Assert.Fail("testFix error !!!");
            }
            finally
            {
                IOUtils.Cleanup(null, writer);
            }
        }
Example #23
0
    // Use this for initialization
    void Start()
    {
        mapfile         = new MapFile();
        resourceManager = new ResourceManager();
        worldstart      = calculateTransformPosition(Worldx, Worldy);
        worldend        = new Vector3(MapRows * characterWidth, -MapCols * characterHeight, 0) + calculateTransformPosition(Worldx, Worldy);
        if (prefabParent == null)
        {
            prefabParent = GameObject.Find("AsciiMapCharacters");
        }

        if (prefabMapBlockView == null)
        {
            prefabMapBlockView = (GameObject)Resources.Load("Main/MapBlockView", typeof(GameObject));
        }

        for (int x = 0; x < DisplayBlocksXSize; x++)
        {
            int worldxx = Worldx - ((DisplayBlocksXSize - 1) / 2) + x;
            for (int y = 0; y < DisplayBlocksYSize; y++)
            {
                int worldyy = Worldy - ((DisplayBlocksYSize - 1) / 2) + y;
                LoadMap(worldxx, worldyy, x, y, YieldDirection.NoYield);
            }
        }

        player = GameObject.Find("Player");
        if (player == null)
        {
            throw new MissingReferenceException("Player gameobject is missing");
        }

        // throw the player in the center of the map.
        Vector3 playerPosition = new Vector3(10 * characterWidth, -10 * characterHeight, 0) + calculateTransformPosition(Worldx, Worldy);

        player.transform.position = playerPosition;
    }
Example #24
0
            public static void SaveShareConfig(string fileName, string name, string queryName, List <ServiceSamba> newParameters)
            {
                var data     = MapFile.Get().Data;
                var shares   = MapFile.Get().Share;
                var oldShare = shares.FirstOrDefault(o => o.Name == queryName);

                shares.Remove(oldShare);
                var shareData = newParameters.Select(ConvertData).ToList();
                var newShare  = new ShareModel {
                    FilePath = fileName,
                    Name     = name,
                    Data     = shareData
                };

                shares.Add(newShare);
                var samba = new SambaModel {
                    _Id       = ServiceGuid,
                    Guid      = ServiceGuid,
                    Timestamp = Timestamp.Now,
                    Share     = shares,
                    Data      = data
                };
                //DeNSo.Session.New.Set(samba);
            }
Example #25
0
        private static DeviceBuffer CreateCliffDetails(
            GraphicsDevice graphicsDevice,
            MapFile mapFile)
        {
            var cliffDetails = new CliffInfo[mapFile.BlendTileData.CliffTextureMappings.Length];

            const int cliffScalingFactor = 64;

            for (var i = 0; i < cliffDetails.Length; i++)
            {
                var cliffMapping = mapFile.BlendTileData.CliffTextureMappings[i];
                cliffDetails[i] = new CliffInfo
                {
                    BottomLeftUV  = cliffMapping.BottomLeftCoords * cliffScalingFactor,
                    BottomRightUV = cliffMapping.BottomRightCoords * cliffScalingFactor,
                    TopLeftUV     = cliffMapping.TopLeftCoords * cliffScalingFactor,
                    TopRightUV    = cliffMapping.TopRightCoords * cliffScalingFactor
                };
            }

            return(cliffDetails.Length > 0
                ? graphicsDevice.CreateStaticStructuredBuffer(cliffDetails)
                : null);
        }
        /// <summary>
        /// Creates a new instance
        /// </summary>
        /// <param name="config">The <see cref="SubscriptionDataConfig"/></param>
        /// <param name="factorFile">The factor file to use</param>
        /// <param name="mapFile">The <see cref="MapFile"/> to use</param>
        /// <param name="tradableDateEventProviders">The tradable dates event providers</param>
        /// <param name="tradableDayNotifier">Tradable dates provider</param>
        /// <param name="includeAuxiliaryData">True to emit auxiliary data</param>
        public AuxiliaryDataEnumerator(
            SubscriptionDataConfig config,
            FactorFile factorFile,
            MapFile mapFile,
            ITradableDateEventProvider [] tradableDateEventProviders,
            ITradableDatesNotifier tradableDayNotifier,
            bool includeAuxiliaryData)
        {
            _auxiliaryData = new Queue <BaseData>();

            foreach (var tradableDateEventProvider in tradableDateEventProviders)
            {
                tradableDateEventProvider.Initialize(
                    config,
                    factorFile,
                    mapFile);
            }

            tradableDayNotifier.NewTradableDate += (sender, eventArgs) =>
            {
                foreach (var tradableDateEventProvider in tradableDateEventProviders)
                {
                    // Call implementation
                    // and materialize list since we need symbol changes applied to the config
                    // regardless of the includeAuxiliaryData argument
                    var newEvents = tradableDateEventProvider.GetEvents(eventArgs).ToList();
                    if (includeAuxiliaryData)
                    {
                        foreach (var newEvent in newEvents)
                        {
                            _auxiliaryData.Enqueue(newEvent);
                        }
                    }
                }
            };
        }
Example #27
0
        public virtual void WithDataTest()
        {
            MapFile mapFile = new MapFile(EmbeddedResourceLoader.Load("Resources.WithData.output.map", this.GetType()));

            MapFileInfo mapFileInfo = mapFile.MapFileInfo;

            Assert.True(mapFileInfo.DebugFile);

            for (sbyte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel)
            {
                Point poi = new Point(0.04, 0.04);

                int tileX = MercatorProjection.LongitudeToTileX(0.04, zoomLevel);
                int tileY = MercatorProjection.LatitudeToTileY(0.04, zoomLevel);

                Tile tile = new Tile(tileX, tileY, zoomLevel);

                double lonMin = MercatorProjection.TileXToLongitude(tileX, zoomLevel);
                double lonMax = MercatorProjection.TileXToLongitude(tileX + 1, zoomLevel);
                double latMin = MercatorProjection.TileYToLatitude(tileY + 1, zoomLevel);
                double latMax = MercatorProjection.TileYToLatitude(tileY, zoomLevel);

                //tile.Index = new TileIndex(tileX, tileY, zoomLevel.ToString());
                //tile.Extent = new Extent(lonMin, latMin, lonMax, latMax);

                MapReadResult mapReadResult = mapFile.ReadMapData(tile);

                Assert.AreEqual(1, mapReadResult.PointOfInterests.Count);
                Assert.AreEqual(1, mapReadResult.Ways.Count);

                CheckPointOfInterest(mapReadResult.PointOfInterests[0]);
                CheckWay(mapReadResult.Ways[0]);
            }

            mapFile.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (openAMMFileDialog.ShowDialog() == DialogResult.OK)
            {
                currentAMMFile.Text = openAMMFileDialog.FileName;

                // TODO: load async. It is fast enough for now.
                currentMap = new MapFileLoader(openAMMFileDialog.FileName).Read(currentDataFile);

                listBox1.DataSource    = currentMap.GetGenericFields();
                listBox1.DisplayMember = "DisplayFieldName";
                listBox1.ValueMember   = "FieldID";

                List <IGenericFieldBlock> fields = currentMap.GetGenericFields();
                dataBytes = new List <byte>();
                fields.ForEach(x =>
                {
                    dataBytes.AddRange(x.ToBytes());
                });

                rawBinaryOutput.Lines = new string[] { "Select a block to preview contents" };
                button2.Enabled       = true;
            }
        }
        /// <summary>
        /// Checks if there is fundamental data for
        /// </summary>
        /// <param name="ticker">The ticker.</param>
        /// <param name="date">The date.</param>
        /// <param name="mapFile">The map file.</param>
        /// <param name="fineAvailableDates"></param>
        /// <param name="fineFundamentalFolder">The fine fundamental folder.</param>
        /// <returns></returns>
        private static bool CheckFundamentalData(DateTime date, MapFile mapFile, IEnumerable <DateTime> fineAvailableDates, DirectoryInfo fineFundamentalFolder)
        {
            // Check if security has fine file within a trailing month for a date-ticker set.
            // There are tricky cases where a folder named by a ticker can have data for multiple securities.
            // e.g  GOOG -> GOOGL (GOOG T1AZ164W5VTX) / GOOCV -> GOOG (GOOCV VP83T1ZUHROL) case.
            // The fine data in the 'fundamental/fine/goog' folder will be for 'GOOG T1AZ164W5VTX' up to the 2014-04-02 and for 'GOOCV VP83T1ZUHROL' afterward.
            // Therefore, date before checking if the security has fundamental data for a date, we need to filter the fine files the map's first date.
            var firstDate = mapFile?.FirstDate ?? DateTime.MinValue;
            var hasFundamentalDataForDate = fineAvailableDates.Where(d => d >= firstDate).Any(d => date.AddMonths(-1) <= d && d <= date);

            // The following section handles mergers and acquisitions cases.
            // e.g. YHOO -> AABA (YHOO R735QTJ8XC9X)
            // The dates right after the acquisition, valid fine fundamental data for AABA are still under the former ticker folder.
            // Therefore if no fine fundamental data is found in the 'fundamental/fine/aaba' folder, it searches into the 'yhoo' folder.
            if (mapFile != null && mapFile.Count() > 2 && !hasFundamentalDataForDate)
            {
                var previousTicker = mapFile.LastOrDefault(m => m.Date < date)?.MappedSymbol;
                if (previousTicker != null)
                {
                    var previousTickerFineFundamentalFolder = Path.Combine(fineFundamentalFolder.FullName, previousTicker);
                    if (Directory.Exists(previousTickerFineFundamentalFolder))
                    {
                        var previousTickerFineAvailableDates = Directory.GetFiles(previousTickerFineFundamentalFolder, "*.zip")
                                                               .Select(f => DateTime.ParseExact(Path.GetFileNameWithoutExtension(f), DateFormat.EightCharacter, CultureInfo.InvariantCulture))
                                                               .ToList();
                        hasFundamentalDataForDate = previousTickerFineAvailableDates.Where(d => d >= firstDate).Any(d => date.AddMonths(-1) <= d && d <= date);
                    }
                    else
                    {
                        Log.Debug($"CoarseUniverseGeneratorProgram.CheckFundamentalData(): fine folder was not found at '{previousTickerFineFundamentalFolder}'");
                    }
                }
            }

            return(hasFundamentalDataForDate);
        }
Example #30
0
        private void SaveCameras(MapFile map, List <SerialisedObject> list)
        {
            var cams = map.Cameras;

            var so = new SerialisedObject("cameras");

            so.Set("activecamera", -1);

            for (var i = 0; i < cams.Count; i++)
            {
                var camera = cams[i];
                if (camera.IsActive)
                {
                    so.Set("activecamera", i);
                }

                var vgo = new SerialisedObject("camera");
                vgo.Set("position", $"[{FormatVector3(camera.EyePosition)}]");
                vgo.Set("look", $"[{FormatVector3(camera.LookPosition)}]");
                so.Children.Add(vgo);
            }

            list.Add(so);
        }
Example #31
0
        public virtual void TestMainMethodMapFile()
        {
            string inFile = "mainMethodMapFile.mapfile";
            string path   = new Path(TestDir, inFile).ToString();

            string[]       args   = new string[] { path, path };
            MapFile.Writer writer = null;
            try
            {
                writer = CreateWriter(inFile, typeof(IntWritable), typeof(Text));
                writer.Append(new IntWritable(1), new Text("test_text1"));
                writer.Append(new IntWritable(2), new Text("test_text2"));
                writer.Close();
                MapFile.Main(args);
            }
            catch (Exception)
            {
                NUnit.Framework.Assert.Fail("testMainMethodMapFile error !!!");
            }
            finally
            {
                IOUtils.Cleanup(null, writer);
            }
        }
Example #32
0
            public SharedTagResources()
            {
                //Prepare
                MapFile   resourceMap = null;
                ITagGroup tagGroup    = null;

                //Gather ui resources
                using (resourceMap = new MapFile())
                {
                    //Load
                    resourceMap.Load(RegistrySettings.MainmenuFileName);

                    //Get tags
                    m_UiSharedResources.AddRange(resourceMap.IndexEntries.Select(e => { tagGroup = TagLookup.CreateTagGroup(e.Root); return($"{e.Filename}.{tagGroup.GroupName}"); }));
                }

                //Gather multiplayer shared resources
                using (resourceMap = new MapFile())
                {
                    //Load
                    resourceMap.Load(RegistrySettings.SharedFileName);

                    //Get tags
                    m_MultiplayerSharedResources.AddRange(resourceMap.IndexEntries.Select(e => { tagGroup = TagLookup.CreateTagGroup(e.Root); return($"{e.Filename}.{tagGroup.GroupName}"); }));
                }

                //Gather singleplayer shared resources
                using (resourceMap = new MapFile())
                {
                    //Load
                    resourceMap.Load(RegistrySettings.SharedFileName);

                    //Get tags
                    m_SingleplayerSharedResources.AddRange(resourceMap.IndexEntries.Select(e => { tagGroup = TagLookup.CreateTagGroup(e.Root); return($"{e.Filename}.{tagGroup.GroupName}"); }));
                }
            }
Example #33
0
        public virtual void TestRename()
        {
            string NewFileName = "test-new.mapfile";
            string OldFileName = "test-old.mapfile";

            MapFile.Writer writer = null;
            try
            {
                FileSystem fs = FileSystem.GetLocal(conf);
                writer = CreateWriter(OldFileName, typeof(IntWritable), typeof(IntWritable));
                writer.Close();
                MapFile.Rename(fs, new Path(TestDir, OldFileName).ToString(), new Path(TestDir, NewFileName
                                                                                       ).ToString());
                MapFile.Delete(fs, new Path(TestDir, NewFileName).ToString());
            }
            catch (IOException ex)
            {
                NUnit.Framework.Assert.Fail("testRename error " + ex);
            }
            finally
            {
                IOUtils.Cleanup(null, writer);
            }
        }
        private void SaveExternalFiles(MapFile mapFile)
        {
            // KEEP the order! The name of metadata files could be adjusted when we save them.

            foreach (MetadataFile metadataFile in mapFile.MetadataList)
            {
                if (metadataFile.ErrorInLoading == null)
                {
                    WriteMetadataFile(metadataFile);
                }
            }

            foreach (ExtensionFile extensionFile in mapFile.Extensions)
            {
                if (extensionFile.ErrorInLoading == null)
                {
                    WriteExtensionFile(extensionFile);
                }
            }
        }
Example #35
0
 // TODO : ? move to loader
 protected void ReadAvailableFiles()
 {
     FileInfo[] files = (new DirectoryInfo(mapDir).GetFiles("*." + extension));
     availableMaps = new MapFile[files.Length];
     for (int i = 0; i < files.Length; i++)
     {
         availableMaps[i] = new MapFile();
         availableMaps[i].Name = FilenameToName(files[i].Name.Split('.')[0]).ToUpper();
         availableMaps[i].FilePath = files[i].Name;
         Console.WriteLine(files[i].ToString());
     }
 }
Example #36
0
		public void SetActiveMap(MapFile newActiveMap)
		{
			m_drawingEvent.Wait();
			m_drawingEvent.Reset();

			if(MapRef != null && MapRef.AmbientNoise != 0)
				EOGame.Instance.SoundManager.StopLoopingSoundEffect(MapRef.AmbientNoise);
			
			MapRef = newActiveMap;

			if (m_miniMapRenderer == null)
				m_miniMapRenderer = new MiniMapRenderer(this);
			else
				m_miniMapRenderer.Map = MapRef;

			MapItems.Clear();
			lock (_rendererListLock)
			{
				otherRenderers.ForEach(_rend => _rend.Dispose());
				otherRenderers.Clear();
			}

			lock (_npcListLock)
			{
				npcList.ForEach(_npc => _npc.Dispose());
				npcList.Clear();
			}
			lock (_spikeTrapsLock)
				_visibleSpikeTraps.Clear();

			//need to reset door-related members when changing maps.
			if (_door != null)
			{
				_door.doorOpened = false;
				_door.backOff = false;
				_door = null;
				_doorY = 0;
				_doorTimer.Change(Timeout.Infinite, Timeout.Infinite);
			}

			m_mapLoadTime = DateTime.Now;
			m_transitionMetric = 1;
			if (!MapRef.MapAvailable)
				m_miniMapRenderer.Visible = false;

			if (MapRef.Name.Length > 0)
			{
				if (EOGame.Instance.Hud != null)
					EOGame.Instance.Hud.AddChat(ChatTabs.System, "", World.GetString(DATCONST2.STATUS_LABEL_YOU_ENTERED) + " " + MapRef.Name, ChatType.NoteLeftArrow);
				else
					m_needDispMapName = true;
			}

			PlayOrStopBackgroundMusic();
			PlayOrStopAmbientNoise();

			m_drawingEvent.Set();
		}
Example #37
0
 public MapSymbolProvider(String symbolFilename) {
     mf = new MapFile(symbolFilename);
 }
Example #38
0
 /// <summary>
 /// Reads a *.map file and returns an image based on its contents.
 /// </summary>
 /// <param name="mapFile">A MapFile object.</param>
 /// <returns></returns>
 public Image GetImage(MapFile mapFile)
 {
     return this.GetImage(new List<MapFile>() { mapFile });
 }
 /// <summary>
 /// Unwrap the map file.
 /// </summary>
 protected abstract object Unwrap(MapFile mapFile);
 protected override object Unwrap(MapFile mapFile)
 {
     return mapFile is DataSvcMapFile ? ((DataSvcMapFile)mapFile).Impl : null;
 }
		private static bool _isMapValid()
		{
			try
			{
				// ReSharper disable once UnusedVariable
				var map = new MapFile(string.Format(Constants.MapFileFormatString, World.Instance.NeedMap));
			}
			catch { return false; }

			return true;
		}
 private void SetMapFileLoadErrors(MapFile mapFile, IEnumerable<ProxyGenerationError> proxyGenerationErrors)
 {
     mapFile.LoadErrors = proxyGenerationErrors;
 }
Example #43
0
		/*** Functions for loading/checking the different pub/map files ***/

		//tries to load the map that MainPlayer.ActiveCharacter is hanging out on
		private bool _tryLoadMap(int mapID, bool forceReload)
		{
			try
			{
				if (mapID < 0)
					mapID = MainPlayer.ActiveCharacter.CurrentMap;

				string mapFile = Path.Combine("maps", string.Format("{0,5:D5}.emf", mapID));

				if(!MapCache.ContainsKey(mapID))
					MapCache.Add(mapID, new MapFile(mapFile));
				else if(forceReload)
					MapCache[mapID] = new MapFile(mapFile);

				//map renderer construction moved to be more closely coupled to loading of the map
				if (m_mapRender == null)
					m_mapRender = new MapRenderer(EOGame.Instance, m_api);
			}
			catch
			{
				return false;
			}

			return true;
		}
        private void LoadExternalFiles(MapFile mapFile)
        {
            // Do basic check for metadata files and extension files.
            ValidateMapFile(mapFile);

            foreach (MetadataFile metadataFile in mapFile.MetadataList)
            {
                metadataFile.IsExistingFile = true;
                LoadMetadataFile(metadataFile);
            }

            foreach (ExtensionFile extensionFile in mapFile.Extensions)
            {
                extensionFile.IsExistingFile = true;
                LoadExtensionFile(extensionFile);
            }
        }
        /// <summary>
        /// Subscription data reader takes a subscription request, loads the type, accepts the data source and enumerate on the results.
        /// </summary>
        /// <param name="config">Subscription configuration object</param>
        /// <param name="periodStart">Start date for the data request/backtest</param>
        /// <param name="periodFinish">Finish date for the data request/backtest</param>
        /// <param name="resultHandler">Result handler used to push error messages and perform sampling on skipped days</param>
        /// <param name="mapFileResolver">Used for resolving the correct map files</param>
        /// <param name="factorFileProvider">Used for getting factor files</param>
        /// <param name="tradeableDates">Defines the dates for which we'll request data, in order, in the security's exchange time zone</param>
        /// <param name="isLiveMode">True if we're in live mode, false otherwise</param>
        /// <param name="includeAuxilliaryData">True if we want to emit aux data, false to only emit price data</param>
        public SubscriptionDataReader(SubscriptionDataConfig config,
                                      DateTime periodStart,
                                      DateTime periodFinish,
                                      IResultHandler resultHandler,
                                      MapFileResolver mapFileResolver,
                                      IFactorFileProvider factorFileProvider,
                                      IEnumerable <DateTime> tradeableDates,
                                      bool isLiveMode,
                                      bool includeAuxilliaryData = true)
        {
            //Save configuration of data-subscription:
            _config = config;

            _auxiliaryData = new Queue <BaseData>();

            //Save Start and End Dates:
            _periodStart  = periodStart;
            _periodFinish = periodFinish;

            //Save access to securities
            _isLiveMode            = isLiveMode;
            _includeAuxilliaryData = includeAuxilliaryData;

            //Save the type of data we'll be getting from the source.

            //Create the dynamic type-activators:
            var objectActivator = ObjectActivator.GetActivator(config.Type);

            _resultHandler  = resultHandler;
            _tradeableDates = tradeableDates.GetEnumerator();
            if (objectActivator == null)
            {
                _resultHandler.ErrorMessage("Custom data type '" + config.Type.Name + "' missing parameterless constructor E.g. public " + config.Type.Name + "() { }");
                _endOfStream = true;
                return;
            }

            //Create an instance of the "Type":
            var userObj = objectActivator.Invoke(new object[] {});

            _dataFactory = userObj as BaseData;

            //If its quandl set the access token in data factory:
            var quandl = _dataFactory as Quandl;

            if (quandl != null)
            {
                if (!Quandl.IsAuthCodeSet)
                {
                    Quandl.SetAuthCode(Config.Get("quandl-auth-token"));
                }
            }

            _factorFile = new FactorFile(config.Symbol.Value, new List <FactorFileRow>());
            _mapFile    = new MapFile(config.Symbol.Value, new List <MapFileRow>());

            // load up the map and factor files for equities
            if (!config.IsCustomData && config.SecurityType == SecurityType.Equity)
            {
                try
                {
                    var mapFile = mapFileResolver.ResolveMapFile(config.Symbol.ID.Symbol, config.Symbol.ID.Date);

                    // only take the resolved map file if it has data, otherwise we'll use the empty one we defined above
                    if (mapFile.Any())
                    {
                        _mapFile = mapFile;
                    }

                    var factorFile = factorFileProvider.Get(_config.Symbol);
                    _hasScaleFactors = factorFile != null;
                    if (_hasScaleFactors)
                    {
                        _factorFile = factorFile;
                    }
                }
                catch (Exception err)
                {
                    Log.Error(err, "Fetching Price/Map Factors: " + config.Symbol.ID + ": ");
                }
            }

            _subscriptionFactoryEnumerator = ResolveDataEnumerator(true);
        }
        private void ValidateMapFile(MapFile mapFile)
        {
            var metadataFileNames = mapFile.MetadataList.Select(p => p.FileName).Where(p => !string.IsNullOrEmpty(p));
            var extensionFileNames = mapFile.Extensions.Select(p => p.FileName).Where(p => !string.IsNullOrEmpty(p));

            var fileNameSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
            foreach (string fileName in metadataFileNames.Concat(extensionFileNames))
            {
                if (!fileNameSet.Contains(fileName))
                {
                    fileNameSet.Add(fileName);
                }
                else
                {
                    throw new FormatException(String.Format(CultureInfo.CurrentCulture,
                                                            WCFModelStrings.ReferenceGroup_TwoExternalFilesWithSameName,
                                                            fileName));
                }
            }
        }