示例#1
0
        public CursorProvider(ModData modData)
        {
            var sequenceFiles = modData.Manifest.Cursors;

            cursors = new Dictionary<string, CursorSequence>();
            palettes = new Cache<string, PaletteReference>(CreatePaletteReference);
            var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
            var shadowIndex = new int[] { };

            if (sequences.NodesDict.ContainsKey("ShadowIndex"))
            {
                Array.Resize(ref shadowIndex, shadowIndex.Length + 1);
                Exts.TryParseIntegerInvariant(sequences.NodesDict["ShadowIndex"].Value,
                    out shadowIndex[shadowIndex.Length - 1]);
            }

            palette = new HardwarePalette();
            foreach (var p in sequences.NodesDict["Palettes"].Nodes)
                palette.AddPalette(p.Key, new Palette(GlobalFileSystem.Open(p.Value.Value), shadowIndex), false);

            var spriteLoader = new SpriteLoader(new string[0], new SheetBuilder(SheetType.Indexed));
            foreach (var s in sequences.NodesDict["Cursors"].Nodes)
                LoadSequencesForCursor(spriteLoader, s.Key, s.Value);

            palette.Initialize();
        }
示例#2
0
        public CursorProvider(ModData modData)
        {
            var sequenceFiles = modData.Manifest.Cursors;

            cursors  = new Dictionary <string, CursorSequence>();
            palettes = new Cache <string, PaletteReference>(CreatePaletteReference);
            var sequences   = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
            var shadowIndex = new int[] { };

            var nodesDict = sequences.ToDictionary();

            if (nodesDict.ContainsKey("ShadowIndex"))
            {
                Array.Resize(ref shadowIndex, shadowIndex.Length + 1);
                Exts.TryParseIntegerInvariant(nodesDict["ShadowIndex"].Value,
                                              out shadowIndex[shadowIndex.Length - 1]);
            }

            palette = new HardwarePalette();
            foreach (var p in nodesDict["Palettes"].Nodes)
            {
                palette.AddPalette(p.Key, new ImmutablePalette(GlobalFileSystem.Open(p.Value.Value), shadowIndex), false);
            }

            var spriteLoader = new SpriteLoader(new string[0], new SheetBuilder(SheetType.Indexed));

            foreach (var s in nodesDict["Cursors"].Nodes)
            {
                LoadSequencesForCursor(spriteLoader, s.Key, s.Value);
            }
            spriteLoader.SheetBuilder.Current.ReleaseBuffer();

            palette.Initialize();
        }
示例#3
0
        public static void Initialize(string[] sequenceFiles)
        {
            cursors = new Dictionary <string, CursorSequence>();
            var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));

            int[] ShadowIndex = { };

            if (sequences.NodesDict.ContainsKey("ShadowIndex"))
            {
                Array.Resize(ref ShadowIndex, ShadowIndex.Length + 1);
                int.TryParse(sequences.NodesDict["ShadowIndex"].Value, out ShadowIndex[ShadowIndex.Length - 1]);
            }

            Palette = new HardwarePalette();
            foreach (var p in sequences.NodesDict["Palettes"].Nodes)
            {
                Palette.AddPalette(p.Key, new Palette(FileSystem.Open(p.Value.Value), ShadowIndex), false);
            }

            foreach (var s in sequences.NodesDict["Cursors"].Nodes)
            {
                LoadSequencesForCursor(s.Key, s.Value);
            }

            Palette.Initialize();
        }
示例#4
0
 public PaletteReference(string name, int index, IPalette palette, HardwarePalette hardwarePalette)
 {
     Name                 = name;
     Palette              = palette;
     this.index           = index;
     this.hardwarePalette = hardwarePalette;
 }
示例#5
0
		public PaletteReference(string name, int index, IPalette palette, HardwarePalette hardwarePalette)
		{
			Name = name;
			Palette = palette;
			this.index = index;
			this.hardwarePalette = hardwarePalette;
		}
示例#6
0
        internal WorldRenderer(World world)
        {
            this.world   = world;
            this.palette = Game.modData.Palette;
            foreach (var pal in world.traitDict.ActorsWithTraitMultiple <IPalette>(world))
            {
                pal.Trait.InitPalette(this);
            }

            terrainRenderer = new TerrainRenderer(world, this);
            shroudRenderer  = new ShroudRenderer(world);
        }
示例#7
0
        public void SetPalette(HardwarePalette palette)
        {
            if (palette.Texture == currentPaletteTexture)
            {
                return;
            }

            Flush();
            currentPaletteTexture = palette.Texture;

            RgbaSpriteRenderer.SetPalette(currentPaletteTexture);
            SpriteRenderer.SetPalette(currentPaletteTexture);
            WorldSpriteRenderer.SetPalette(currentPaletteTexture);
        }
示例#8
0
        internal WorldRenderer(World world)
        {
            this.world = world;
            palette    = new HardwarePalette();

            palettes = new Cache <string, PaletteReference>(CreatePaletteReference);
            foreach (var pal in world.traitDict.ActorsWithTraitMultiple <IPalette>(world))
            {
                pal.Trait.InitPalette(this);
            }

            palette.Initialize();

            terrainRenderer = new TerrainRenderer(world, this);
            shroudRenderer  = new ShroudRenderer(world);
        }
示例#9
0
		internal WorldRenderer(World world)
		{
			this.world = world;
			Viewport = new Viewport(this, world.Map);
			palette = new HardwarePalette();

			palettes = new Dictionary<string, PaletteReference>();
			foreach (var pal in world.traitDict.ActorsWithTrait<ILoadsPalettes>())
				pal.Trait.LoadPalettes(this);

			palette.Initialize();

			Theater = new Theater(world.TileSet);
			terrainRenderer = new TerrainRenderer(world, this);

			devTrait = Exts.Lazy(() => world.LocalPlayer != null ? world.LocalPlayer.PlayerActor.Trait<DeveloperMode>() : null);
		}
示例#10
0
        internal WorldRenderer(World world)
        {
            this.world = world;
            Viewport = new Viewport(this, world.Map);
            palette = new HardwarePalette();

            palettes = new Cache<string, PaletteReference>(CreatePaletteReference);
            foreach (var pal in world.traitDict.ActorsWithTraitMultiple<IPalette>(world))
                pal.Trait.InitPalette(this);

            palette.Initialize();

            Theater = new Theater(world.TileSet);
            terrainRenderer = new TerrainRenderer(world, this);

            devTrait = Lazy.New(() => world.LocalPlayer != null ? world.LocalPlayer.PlayerActor.Trait<DeveloperMode>() : null);
        }
示例#11
0
        internal WorldRenderer(World world)
        {
            this.world = world;
            Viewport   = new Viewport(this, world.Map);
            palette    = new HardwarePalette();

            palettes = new Dictionary <string, PaletteReference>();
            foreach (var pal in world.traitDict.ActorsWithTrait <ILoadsPalettes>())
            {
                pal.Trait.LoadPalettes(this);
            }

            palette.Initialize();

            Theater         = new Theater(world.TileSet);
            terrainRenderer = new TerrainRenderer(world, this);

            devTrait = Exts.Lazy(() => world.LocalPlayer != null ? world.LocalPlayer.PlayerActor.Trait <DeveloperMode>() : null);
        }
示例#12
0
        internal WorldRenderer(World world)
        {
            this.world = world;
            Viewport   = new Viewport(this, world.Map);
            palette    = new HardwarePalette();

            palettes = new Cache <string, PaletteReference>(CreatePaletteReference);
            foreach (var pal in world.traitDict.ActorsWithTraitMultiple <IPalette>(world))
            {
                pal.Trait.InitPalette(this);
            }

            palette.Initialize();

            Theater         = new Theater(world.TileSet);
            terrainRenderer = new TerrainRenderer(world, this);

            devTrait = Lazy.New(() => world.LocalPlayer != null ? world.LocalPlayer.PlayerActor.Trait <DeveloperMode>() : null);
        }
示例#13
0
        public static void Initialize(string[] sequenceFiles)
        {
            cursors = new Dictionary<string, CursorSequence>();
            var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
            int[] ShadowIndex = { };

            if (sequences.NodesDict.ContainsKey("ShadowIndex"))
            {
                Array.Resize(ref ShadowIndex, ShadowIndex.Length + 1);
                int.TryParse(sequences.NodesDict["ShadowIndex"].Value, out ShadowIndex[ShadowIndex.Length - 1]);
            }

            Palette = new HardwarePalette();
            foreach (var p in sequences.NodesDict["Palettes"].Nodes)
                Palette.AddPalette(p.Key, new Palette(FileSystem.Open(p.Value.Value), ShadowIndex), false);

            foreach (var s in sequences.NodesDict["Cursors"].Nodes)
                LoadSequencesForCursor(s.Key, s.Value);

            Palette.Initialize();
        }
示例#14
0
        public void LoadInitialAssets()
        {
            // all this manipulation of static crap here is nasty and breaks
            // horribly when you use ModData in unexpected ways.

            FileSystem.UnmountAll();
            foreach (var dir in Manifest.Folders)
                FileSystem.Mount(dir);

            AvailableMaps = FindMaps(Manifest.Mods);

            Palette = new HardwarePalette();
            ChromeMetrics.Initialize(Manifest.ChromeMetrics);
            ChromeProvider.Initialize(Manifest.Chrome);
            SheetBuilder = new SheetBuilder(TextureChannel.Red);
            SpriteLoader = new SpriteLoader(new string[] { ".shp" }, SheetBuilder);
            CursorProvider.Initialize(Manifest.Cursors);
            Palette.Update(new IPaletteModifier[] { });
        }
示例#15
0
        public override void Init(ModData modData, Dictionary<string, string> info)
        {
            // Avoid standard loading mechanisms so we
            // can display the loadscreen as early as possible
            r = Game.Renderer;
            if (r == null)
                return;

            if (info.ContainsKey("Text"))
                messages = info["Text"].Split(',');

            if (info.ContainsKey("Palette"))
            {
                using (var stream = modData.DefaultFileSystem.Open(info["Palette"]))
                {
                    palette = new ImmutablePalette(stream, new int[] { });
                }

                hardwarePalette = new HardwarePalette();
                hardwarePalette.AddPalette("loadscreen", palette, false);
                hardwarePalette.Initialize();
                r.SetPalette(hardwarePalette);
            }

            if (info.ContainsKey("Image"))
            {
                using (var stream = modData.DefaultFileSystem.Open(info["Image"]))
                {
                    CpsD2Loader loader = new CpsD2Loader();
                    if (!loader.TryParseSprite(stream, out frames))
                        return;
                }

                if (frames.Length == 0)
                    return;

                sheetBuilder = new SheetBuilder(SheetType.Indexed, 512);
                logo = sheetBuilder.Add(frames[0]);

                logoPos = new float2((r.Resolution.Width - logo.Size.X) / 2, (r.Resolution.Height - logo.Size.Y) / 2);
            }
        }