Beispiel #1
0
 public ModData( params string[] mods )
 {
     Manifest = new Manifest( mods );
     ObjectCreator = new ObjectCreator( Manifest );
     LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen.Value);
     LoadScreen.Init(Manifest.LoadScreen.NodesDict.ToDictionary(x => x.Key, x => x.Value.Value));
     LoadScreen.Display();
     WidgetLoader = new WidgetLoader( this );
 }
Beispiel #2
0
 public ModData( params string[] mods )
 {
     Manifest = new Manifest( mods );
     ObjectCreator = new ObjectCreator( Manifest );
     LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen);
     LoadScreen.Init();
     LoadScreen.Display();
     WidgetLoader = new WidgetLoader( this );
 }
Beispiel #3
0
        public ModData(string mod, bool useLoadScreen = false)
        {
            Languages = new string[0];
            Manifest = new Manifest(mod);
            ObjectCreator = new ObjectCreator(Manifest);
            Manifest.LoadCustomData(ObjectCreator);

            if (useLoadScreen)
            {
                LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen.Value);
                LoadScreen.Init(Manifest, Manifest.LoadScreen.ToDictionary(my => my.Value));
                LoadScreen.Display();
            }

            WidgetLoader = new WidgetLoader(this);
            RulesetCache = new RulesetCache(this);
            RulesetCache.LoadingProgress += HandleLoadingProgress;
            MapCache = new MapCache(this);

            var spriteLoaders = new List<ISpriteLoader>();
            foreach (var format in Manifest.SpriteFormats)
            {
                var loader = ObjectCreator.FindType(format + "Loader");
                if (loader == null || !loader.GetInterfaces().Contains(typeof(ISpriteLoader)))
                    throw new InvalidOperationException("Unable to find a sprite loader for type '{0}'.".F(format));

                spriteLoaders.Add((ISpriteLoader)ObjectCreator.CreateBasic(loader));
            }

            SpriteLoaders = spriteLoaders.ToArray();

            var sequenceFormat = Manifest.Get<SpriteSequenceFormat>();
            var sequenceLoader = ObjectCreator.FindType(sequenceFormat.Type + "Loader");
            var ctor = sequenceLoader != null ? sequenceLoader.GetConstructor(new[] { typeof(ModData) }) : null;
            if (sequenceLoader == null || !sequenceLoader.GetInterfaces().Contains(typeof(ISpriteSequenceLoader)) || ctor == null)
                throw new InvalidOperationException("Unable to find a sequence loader for type '{0}'.".F(sequenceFormat.Type));

            SpriteSequenceLoader = (ISpriteSequenceLoader)ctor.Invoke(new[] { this });
            SpriteSequenceLoader.OnMissingSpriteError = s => Log.Write("debug", s);

            // HACK: Mount only local folders so we have a half-working environment for the asset installer
            GlobalFileSystem.UnmountAll();
            foreach (var dir in Manifest.Folders)
                GlobalFileSystem.Mount(dir);

            defaultRules = Exts.Lazy(() => RulesetCache.Load());

            initialThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
        }
Beispiel #4
0
        public ModData( params string[] mods )
        {
            Manifest = new Manifest( mods );
            ObjectCreator = new ObjectCreator( Manifest );
            LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen);
            LoadScreen.Init();
            LoadScreen.Display();

            FileSystem.LoadFromManifest( Manifest );
            ChromeProvider.Initialize( Manifest.Chrome );
            SheetBuilder = new SheetBuilder( TextureChannel.Red );
            CursorSheetBuilder = new CursorSheetBuilder( this );
            AvailableMaps = FindMaps( mods );
            WidgetLoader = new WidgetLoader( this );
        }
Beispiel #5
0
        public ModData(string mod)
        {
            Languages = new string[0];
            Manifest = new Manifest(mod);
            ObjectCreator = new ObjectCreator(Manifest);
            LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen.Value);
            LoadScreen.Init(Manifest, Manifest.LoadScreen.NodesDict.ToDictionary(x => x.Key, x => x.Value.Value));
            LoadScreen.Display();
            WidgetLoader = new WidgetLoader(this);

            // HACK: Mount only local folders so we have a half-working environment for the asset installer
            FileSystem.UnmountAll();
            foreach (var dir in Manifest.Folders)
                FileSystem.Mount(dir);
        }
Beispiel #6
0
        public ModData( params string[] mods )
        {
            Manifest = new Manifest( mods );
            ObjectCreator = new ObjectCreator( Manifest );
            LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen);
            LoadScreen.Init();
            LoadScreen.Display();

            // all this manipulation of static crap here is nasty and breaks
            // horribly when you use ModData in unexpected ways.

            FileSystem.LoadFromManifest( Manifest );
            ChromeProvider.Initialize( Manifest.Chrome );
            SheetBuilder = new SheetBuilder( TextureChannel.Red );
            CursorSheetBuilder = new CursorSheetBuilder( this );
            AvailableMaps = FindMaps( mods );
            WidgetLoader = new WidgetLoader( this );
        }
Beispiel #7
0
        public ModData(string mod)
        {
            Languages = new string[0];
            Manifest = new Manifest(mod);
            ObjectCreator = new ObjectCreator(Manifest);
            LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen.Value);
            LoadScreen.Init(Manifest, Manifest.LoadScreen.NodesDict.ToDictionary(x => x.Key, x => x.Value.Value));
            LoadScreen.Display();
            WidgetLoader = new WidgetLoader(this);
            RulesetCache = new RulesetCache(this);
            RulesetCache.LoadingProgress += HandleLoadingProgress;
            MapCache = new MapCache(this);

            // HACK: Mount only local folders so we have a half-working environment for the asset installer
            GlobalFileSystem.UnmountAll();
            foreach (var dir in Manifest.Folders)
                GlobalFileSystem.Mount(dir);

            defaultRules = Exts.Lazy(() => RulesetCache.LoadDefaultRules());

            initialThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
        }
Beispiel #8
0
        public ModData(Manifest mod, InstalledMods mods, bool useLoadScreen = false)
        {
            Languages = new string[0];

            // Take a local copy of the manifest
            Manifest       = new Manifest(mod.Id, mod.Package);
            ObjectCreator  = new ObjectCreator(Manifest, mods);
            PackageLoaders = ObjectCreator.GetLoaders <IPackageLoader>(Manifest.PackageFormats, "package");

            ModFiles = new FS(mods, PackageLoaders);
            ModFiles.LoadFromManifest(Manifest);
            Manifest.LoadCustomData(ObjectCreator);

            if (useLoadScreen)
            {
                LoadScreen = ObjectCreator.CreateObject <ILoadScreen>(Manifest.LoadScreen.Value);
                LoadScreen.Init(this, Manifest.LoadScreen.ToDictionary(my => my.Value));
                LoadScreen.Display();
            }

            WidgetLoader = new WidgetLoader(this);
            MapCache     = new MapCache(this);

            SoundLoaders  = ObjectCreator.GetLoaders <ISoundLoader>(Manifest.SoundFormats, "sound");
            SpriteLoaders = ObjectCreator.GetLoaders <ISpriteLoader>(Manifest.SpriteFormats, "sprite");

            var sequenceFormat = Manifest.Get <SpriteSequenceFormat>();
            var sequenceLoader = ObjectCreator.FindType(sequenceFormat.Type + "Loader");
            var sequenceCtor   = sequenceLoader != null?sequenceLoader.GetConstructor(new[] { typeof(ModData) }) : null;

            if (sequenceLoader == null || !sequenceLoader.GetInterfaces().Contains(typeof(ISpriteSequenceLoader)) || sequenceCtor == null)
            {
                throw new InvalidOperationException("Unable to find a sequence loader for type '{0}'.".F(sequenceFormat.Type));
            }

            SpriteSequenceLoader = (ISpriteSequenceLoader)sequenceCtor.Invoke(new[] { this });
            SpriteSequenceLoader.OnMissingSpriteError = s => Log.Write("debug", s);

            var modelFormat = Manifest.Get <ModelSequenceFormat>();
            var modelLoader = ObjectCreator.FindType(modelFormat.Type + "Loader");
            var modelCtor   = modelLoader != null?modelLoader.GetConstructor(new[] { typeof(ModData) }) : null;

            if (modelLoader == null || !modelLoader.GetInterfaces().Contains(typeof(IModelSequenceLoader)) || modelCtor == null)
            {
                throw new InvalidOperationException("Unable to find a model loader for type '{0}'.".F(modelFormat.Type));
            }

            ModelSequenceLoader = (IModelSequenceLoader)modelCtor.Invoke(new[] { this });
            ModelSequenceLoader.OnMissingModelError = s => Log.Write("debug", s);

            Hotkeys = new HotkeyManager(ModFiles, Game.Settings.Keys, Manifest);

            defaultRules    = Exts.Lazy(() => Ruleset.LoadDefaults(this));
            defaultTileSets = Exts.Lazy(() =>
            {
                var items = new Dictionary <string, TileSet>();

                foreach (var file in Manifest.TileSets)
                {
                    var t = new TileSet(DefaultFileSystem, file);
                    items.Add(t.Id, t);
                }

                return((IReadOnlyDictionary <string, TileSet>)(new ReadOnlyDictionary <string, TileSet>(items)));
            });

            defaultSequences = Exts.Lazy(() =>
            {
                var items = DefaultTileSets.ToDictionary(t => t.Key, t => new SequenceProvider(DefaultFileSystem, this, t.Value, null));
                return((IReadOnlyDictionary <string, SequenceProvider>)(new ReadOnlyDictionary <string, SequenceProvider>(items)));
            });

            initialThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
        }