示例#1
0
        public override bool HandleKeyPress(KeyInput e)
        {
            if (e.Event == KeyInputEvent.Down)
            {
                var hk = Hotkey.FromKeyInput(e);

                if (hk == Game.Settings.Keys.DevReloadChromeKey)
                {
                    ChromeProvider.Initialize(Game.ModData.Manifest.Chrome);
                    return(true);
                }

                if (hk == Game.Settings.Keys.HideUserInterfaceKey)
                {
                    foreach (var child in this.Children)
                    {
                        child.Visible ^= true;
                    }

                    return(true);
                }

                if (hk == Game.Settings.Keys.TakeScreenshotKey)
                {
                    if (e.Event == KeyInputEvent.Down)
                    {
                        Game.TakeScreenshot = true;
                    }

                    return(true);
                }
            }

            return(base.HandleKeyPress(e));
        }
示例#2
0
        /// <summary>Possibly handle keyboard input (if this widget has keyboard focus)</summary>
        /// <returns><c>true</c>, if keyboard input was handled, <c>false</c> if the input should bubble to the parent widget</returns>
        /// <param name="e">Key input data</param>
        public static bool HandleKeyPress(KeyInput e)
        {
            if (e.Event == KeyInputEvent.Down)
            {
                var hk = Hotkey.FromKeyInput(e);

                if (hk == Game.Settings.Keys.DevReloadChromeKey)
                {
                    ChromeProvider.Initialize(Game.ModData);
                    return(true);
                }

                if (hk == Game.Settings.Keys.HideUserInterfaceKey)
                {
                    Root.Visible ^= true;
                    return(true);
                }

                if (hk == Game.Settings.Keys.TakeScreenshotKey)
                {
                    Game.TakeScreenshot = true;
                    return(true);
                }
            }

            if (KeyboardFocusWidget != null)
            {
                return(KeyboardFocusWidget.HandleKeyPressOuter(e));
            }

            return(Root.HandleKeyPressOuter(e));
        }
示例#3
0
        void IUtilityCommand.Run(Utility utility, string[] args)
        {
            // HACK: The engine code assumes that Game.modData is set.
            var modData = Game.ModData = utility.ModData;

            ChromeProvider.Initialize(modData);

            var image = args[1];
            var zoom  = args[2];

            var regions = new List <string>();

            foreach (var c in ChromeProvider.Collections)
            {
                if (c.Value.Image != image)
                {
                    continue;
                }

                var pr = c.Value.PanelRegion;
                if (pr != null && pr.Length == 8)
                {
                    var sides = new[]
                    {
                        Pair.New(PanelSides.Top | PanelSides.Left, new Rectangle(pr[0], pr[1], pr[2], pr[3])),
                        Pair.New(PanelSides.Top, new Rectangle(pr[0] + pr[2], pr[1], pr[4], pr[3])),
                        Pair.New(PanelSides.Top | PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1], pr[6], pr[3])),
                        Pair.New(PanelSides.Left, new Rectangle(pr[0], pr[1] + pr[3], pr[2], pr[5])),
                        Pair.New(PanelSides.Center, new Rectangle(pr[0] + pr[2], pr[1] + pr[3], pr[4], pr[5])),
                        Pair.New(PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1] + pr[3], pr[6], pr[5])),
                        Pair.New(PanelSides.Bottom | PanelSides.Left, new Rectangle(pr[0], pr[1] + pr[3] + pr[5], pr[2], pr[7])),
                        Pair.New(PanelSides.Bottom, new Rectangle(pr[0] + pr[2], pr[1] + pr[3] + pr[5], pr[4], pr[7])),
                        Pair.New(PanelSides.Bottom | PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1] + pr[3] + pr[5], pr[6], pr[7]))
                    };

                    foreach (var s in sides)
                    {
                        var r = s.Second;
                        if (c.Value.PanelSides.HasSide(s.First))
                        {
                            regions.Add("[\"{0}.<{1}>\",{2},{3},{4},{5}]".F(c.Key, s.First, r.X, r.Y, r.Width, r.Height));
                        }
                    }
                }

                foreach (var kv in c.Value.Regions)
                {
                    var r = kv.Value;
                    regions.Add("[\"{0}\",{1},{2},{3},{4}]".F(c.Key + "." + kv.Key, r.X, r.Y, r.Width, r.Height));
                }
            }

            var output     = HtmlTemplate.JoinWith("\n").F(zoom, Convert.ToBase64String(modData.ModFiles.Open(image).ReadAllBytes()), "[" + regions.JoinWith(",") + "]");
            var outputPath = Path.ChangeExtension(image, ".html");

            File.WriteAllLines(outputPath, new[] { output });
            Console.WriteLine("Saved {0}", outputPath);
        }
示例#4
0
        public void InitializeLoaders()
        {
            // all this manipulation of static crap here is nasty and breaks
            // horribly when you use ModData in unexpected ways.
            ChromeMetrics.Initialize(Manifest.ChromeMetrics);
            ChromeProvider.Initialize(Manifest.Chrome);
            VoxelLoader = new VoxelLoader();

            CursorProvider = new CursorProvider(this);
        }
示例#5
0
        public void InitializeLoaders(IReadOnlyFileSystem fileSystem)
        {
            // all this manipulation of static crap here is nasty and breaks
            // horribly when you use ModData in unexpected ways.
            ChromeMetrics.Initialize(this);
            ChromeProvider.Initialize(this);

            Game.Sound.Initialize(SoundLoaders, fileSystem);

            CursorProvider = new CursorProvider(this);
        }
示例#6
0
 public void InitializeLoaders()
 {
     // all this manipulation of static crap here is nasty and breaks
     // horribly when you use ModData in unexpected ways.
     ChromeMetrics.Initialize(Manifest.ChromeMetrics);
     ChromeProvider.Initialize(Manifest.Chrome);
     SheetBuilder = new SheetBuilder(SheetType.Indexed);
     SpriteLoader = new SpriteLoader(new string[] { ".shp" }, SheetBuilder);
     VoxelLoader  = new VoxelLoader();
     CursorProvider.Initialize(Manifest.Cursors);
 }
示例#7
0
        public override bool HandleKeyPress(KeyInput e)
        {
            if (e.Event == KeyInputEvent.Down)
            {
                var hk = Hotkey.FromKeyInput(e);

                if (hk == Game.Settings.Keys.DevReloadChromeKey)
                {
                    ChromeProvider.Initialize(Game.ModData.Manifest.Chrome);
                    return(true);
                }
            }

            return(base.HandleKeyPress(e));
        }
示例#8
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[] { });
        }
示例#9
0
        void IUtilityCommand.Run(Utility utility, string[] args)
        {
            // HACK: The engine code assumes that Game.modData is set.
            var modData = Game.ModData = utility.ModData;

            ChromeProvider.Initialize(modData);

            var image = args[1];
            var zoom  = args[2];

            var regions = new List <string>();

            foreach (var c in ChromeProvider.Collections)
            {
                if (c.Value.Image != image)
                {
                    continue;
                }

                var pr = c.Value.PanelRegion;
                if (pr != null && pr.Length == 8)
                {
                    var sides = new (PanelSides PanelSides, Rectangle Bounds)[]
示例#10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fileSystem"></param>
 public void InitializeLoaders(IReadOnlyFileSystem fileSystem)
 {
     ChromeMetrics.Initialize(this);
     ChromeProvider.Initialize(this);
     WarGame.Sound.Initialize(SoundLoaders, fileSystem);
 }