Esempio n. 1
0
        private static void SetupDependencies()
        {
            _typeRegistry = new UnityRegistry("EOLib.IO");

            _pubProvider     = _typeRegistry.Resolve <IPubFileProvider>();
            _mapFileProvider = _typeRegistry.Resolve <IMapFileProvider>();
        }
Esempio n. 2
0
 private static MetaType ToMetaType(ITypeRegistry registry, MemberType type)
 {
     return(new MetaType
     {
         SystemType = type?.SystemType,
         Type = registry.Resolve(type?.ReferenceType?.Element)
     });
 }
Esempio n. 3
0
        private void GenerateAssociationProperties(T type, Element element, ITypeRegistry registry)
        {
            if (element.OwnedElements != null && element.OwnedElements.Any())
            {
                foreach (var association in element.OwnedElements.Where(e => e.Type == ElementType.UMLAssociation && e.AssociationEndFrom.Reference.Element == element))
                {
                    var resolved = registry.Resolve(association.AssociationEndTo.Reference.Element);

                    if (ShouldGenerateProperty(resolved, association.Stereotype))
                    {
                        type.Properties.Add(new Property
                        {
                            IsCollection = association.AssociationEndTo.Multiplicity?.Contains("*") ?? false,
                            Name         = association.AssociationEndTo.Name ?? resolved.Name,
                            Description  = association.Documentation,
                            Type         = new MetaType
                            {
                                Type = resolved
                            }
                        });
                    }
                }
            }
        }
Esempio n. 4
0
        private static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Usage: BatchMap.exe <srcmap|srcdir> <dstmap|dstdir> <pubdir>");
                return;
            }

            var srcFilePath       = args[0];
            var dstFilePath       = args[1];
            var pubFilePath       = args[2];
            var singleFileProcess = false;

            if (srcFilePath.ToLower().EndsWith(".emf") && !dstFilePath.ToLower().EndsWith(".emf"))
            {
                Console.WriteLine("Invalid: single map cannot be processed into output directory. Specify destination emf file.");
                return;
            }

            if (dstFilePath.ToLower().EndsWith(".emf") && !srcFilePath.ToLower().EndsWith(".emf"))
            {
                Console.WriteLine("Invalid: map directory cannot be processed into single output map. Specify destination output directory.");
                return;
            }

            if (srcFilePath.ToLower().EndsWith(".emf") && dstFilePath.ToLower().EndsWith(".emf"))
            {
                singleFileProcess = true;
                if (!File.Exists(srcFilePath))
                {
                    Console.WriteLine("Invalid input: input file does not exist!");
                    return;
                }

                if (File.Exists(dstFilePath))
                {
                    char inp;
                    do
                    {
                        Console.Write("Destination file exists. Overwrite? [y/n] ");
                        string input = Console.ReadLine() ?? "";
                        inp = input.Length > 0 ? input[0] : ' ';
                    } while (inp != 'y' && inp != 'n' && inp != 'Y' && inp != 'N');

                    if (inp == 'n' || inp == 'N')
                    {
                        Console.WriteLine("Will not overwrite existing file. Exiting.");
                        return;
                    }
                }
            }
            else
            {
                if (!Directory.Exists(srcFilePath) || Directory.GetFiles(srcFilePath, "*.emf").Length == 0)
                {
                    Console.WriteLine("Invalid input: source directory does not exist or is missing maps!");
                    return;
                }

                if (Directory.Exists(dstFilePath) && Directory.GetFiles(dstFilePath, "*.emf").Length > 0)
                {
                    char inp;
                    do
                    {
                        Console.WriteLine("Destination directory contains emf files. Overwrite? [y/n] ");
                        string input = Console.ReadLine() ?? "";
                        inp = input.Length > 0 ? input[0] : ' ';
                    } while (inp != 'y' && inp != 'n' && inp != 'Y' && inp != 'N');

                    if (inp == 'n' || inp == 'N')
                    {
                        Console.WriteLine("Will not overwrite existing files. Exiting.");
                        return;
                    }
                }
                else if (!Directory.Exists(dstFilePath))
                {
                    Directory.CreateDirectory(dstFilePath);
                }
            }

            SetupDependencies();

            try
            {
                var actions = _typeRegistry.Resolve <IPubFileLoadActions>();

                actions.LoadItemFileByName(Path.Combine(pubFilePath, "dat001.eif"));
                actions.LoadNPCFileByName(Path.Combine(pubFilePath, "dtn001.enf"));
            }
            catch
            {
                Console.WriteLine("Error loading pub files!");
                _typeRegistry.Dispose();
                return;
            }

            try
            {
                ProcessFiles(srcFilePath, dstFilePath, singleFileProcess);
            }
            catch (Exception ex)
            {
                Console.WriteLine();

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Exception was thrown: ");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine(ex.Message);

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("\nCall stack: \n");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine(ex.StackTrace);
            }

            _typeRegistry.Dispose();
        }
Esempio n. 5
0
        public virtual void RunGame()
        {
            var game = _registry.Resolve <IEndlessGame>();

            game.Run();
        }