Esempio n. 1
0
        protected virtual void buildSaveData(IkadnWriter writer)
        {
            var baseSettings = new IkonComposite(BaseSettingsTag);

            baseSettings.Add(LanguageKey, new IkonText(this.LanguageId));
            baseSettings.Add(LastGameKey, this.LastGame.BuildSaveData());
            baseSettings.Compose(writer);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Usage: TextureAtlas <folder> [options]");
                return;
            }
            else
            {
                ReadParameters(args);
            }

            var builder = new AtlasBuilder(
                items.Select(x => new KeyValuePair <string, Size>(x.Key, x.Value.Size)).ToArray(),
                margin, new Size(width, heigth)
                );

            var atlasIkon  = new IkonComposite(compositeTag);
            var atlasImage = new Bitmap(width, heigth);

            using (Graphics g = Graphics.FromImage(atlasImage))
                foreach (var x in builder.Build())
                {
                    Console.WriteLine(x.Key + " " + x.Value);
                    string[] nameParams = x.Key.Split('-');

                    var bounds = x.Value;
                    foreach (var param in nameParams)
                    {
                        if (param.StartsWith("hStretch"))
                        {
                            int amount;
                            if (!int.TryParse(param.Substring("hStretch".Length), out amount))
                            {
                                amount = 1;
                            }
                            bounds.Inflate(-amount, 0);
                        }
                    }

                    var textureCoords = new IkonArray();
                    textureCoords.Add(serializeRectangle(bounds.Left, bounds.Top));
                    textureCoords.Add(serializeRectangle(bounds.Right, bounds.Top));
                    textureCoords.Add(serializeRectangle(bounds.Right, bounds.Bottom));
                    textureCoords.Add(serializeRectangle(bounds.Left, bounds.Bottom));

                    atlasIkon.Add(nameParams[0], textureCoords);
                    var destRect = new Rectangle(x.Value.Location, x.Value.Size);
                    g.DrawImage(items[x.Key], destRect);
                }

            using (var outStream = new StreamWriter(outputIkonPath)) {
                var writer = new IkadnWriter(outStream);
                atlasIkon.Compose(writer);
            }

            atlasImage.Save(outputImagePath, ImageFormat.Png);
        }
Esempio n. 3
0
        private void save(FileInfo saveFile, string title)
        {
            using (var output = new StreamWriter(saveFile.Create())) {
                var gameData = gameController.GameInstance.Save();
                gameData.Add(SaveGameTitleKey, new IkonText(title));

                var writer = new IkadnWriter(output);
                gameData.Compose(writer);
            }
        }
        public void Save()
        {
            var saveFile = new FileInfo(SettingsFilePath);

            saveFile.Directory.Create();

            using (var output = new StreamWriter(SettingsFilePath))
            {
                var writer = new IkadnWriter(output);
                buildSaveData(writer);
            }
        }
        protected override void buildSaveData(IkadnWriter writer)
        {
            base.buildSaveData(writer);

            var settings = new IkonComposite(WinformsSettingsTag);

            settings.Add(GuiScaleKey, new IkonFloat(this.GuiScale));

            settings.Add(FpsBusyWaitKey, new IkonInteger((int)this.FramerateBusySpinUsage));
            settings.Add(FpsKey, new IkonInteger(this.Framerate));
            settings.Add(FpsUnlimitedKey, new IkonInteger(this.UnlimitedFramerate ? 1 : -1));
            settings.Add(VSyncKey, new IkonInteger(this.VSync ? 1 : -1));

            settings.Add(ReportTechnologyKey, new IkonInteger(this.ReportTechnology ? 1 : -1));
            settings.Compose(writer);
        }
Esempio n. 6
0
        private void save(FileInfo saveFile, string title, IkonBaseObject previewData)
        {
            using (var output = new StreamWriter(saveFile.Create()))
            {
                var version     = System.Reflection.Assembly.GetEntryAssembly().GetName().Version;
                var versionData = new IkonArray();
                versionData.Add(new IkonInteger(version.Major));
                versionData.Add(new IkonInteger(version.Minor));
                versionData.Add(new IkonInteger(version.Revision));
                versionData.Add(new IkonInteger(version.Build));

                var writer = new IkadnWriter(output);
                versionData.Compose(writer);
                new IkonText(title).Compose(writer);
                previewData.Compose(writer);
                gameController.Save().Compose(writer);
            }
        }
Esempio n. 7
0
        protected override void buildSaveData(IkadnWriter writer)
        {
            base.buildSaveData(writer);

            var settings = new IkonComposite(WinformsSettingsTag)
            {
                { GuiScaleKey, new IkonFloat(this.GuiScale) },

                { FpsBusyWaitKey, new IkonInteger((int)this.FramerateBusySpinUsage) },
                { FpsKey, new IkonInteger(this.Framerate) },
                { FpsUnlimitedKey, new IkonInteger(this.UnlimitedFramerate ? 1 : -1) },
                { VSyncKey, new IkonInteger(this.VSync ? 1 : -1) },

                { ReportContactKey, new IkonInteger(this.ReportContact ? 1 : -1) },
                { ReportTechnologyKey, new IkonInteger(this.ReportTechnology ? 1 : -1) },
                { ShowScanRangeKey, new IkonInteger(this.ShowScanRange ? 1 : -1) }
            };

            settings.Compose(writer);
        }
Esempio n. 8
0
 protected override void DoCompose(IkadnWriter writer)
 {
     throw new InvalidOperationException(this.Tag + " is not meant to be serialized.");
 }
Esempio n. 9
0
 protected override void DoCompose(IkadnWriter writer)
 {
     throw new InvalidOperationException("Localization context is not meant to be serialized.");
 }
Esempio n. 10
0
        protected override void DoCompose(IkadnWriter writer)
        {
#pragma warning disable CA1303 // Do not pass literals as localized parameters
            throw new InvalidOperationException("Localization context is not meant to be serialized.");
#pragma warning restore CA1303 // Do not pass literals as localized parameters
        }