Exemplo n.º 1
0
        public void LoadWorlds(IContentProvider content)
        {
            CSettingsFile file = new CSettingsFile(content.ReadAllText("lvls/worlds.cfg"));

            for (int i = 0; i < file.SectionCount; i++)
            {
                string w = file.getSection(i);
                CWorld world;

                world = new CWorld();

                world.name       = file.ReadString(w + ".name", w);
                world.background = file.ReadString(w + ".background", "bg1.png");

                string light = file.ReadString(w + ".ambient", "ffffff");
                world.light = ColorX.FromArgb(light);

                string[] values = file.ReadStringArray(w + ".levels");

                world.lvls.AddRange(values);

                if (world.lvls.Count > 0)
                {
                    worlds.Add(world);
                }
            }
        }
Exemplo n.º 2
0
        void IXleSerializable.ReadData(XleSerializationInfo info)
        {
            X     = info.ReadInt32("X");
            Y     = info.ReadInt32("Y");
            Color = ColorX.FromArgb(info.ReadInt32("Color").ToString("X8"));

            HP      = info.ReadInt32("HP");
            Attack  = info.ReadInt32("Attack");
            Defense = info.ReadInt32("Defense");
        }
Exemplo n.º 3
0
        void IXleSerializable.ReadData(XleSerializationInfo info)
        {
            mGuards        = info.ReadList <Guard>("Guards");
            DefaultAttack  = info.ReadInt32("GuardDefaultAttack");
            DefaultColor   = ColorX.FromArgb(info.ReadInt32("GuardDefaultColor").ToString("X8"));
            DefaultDefense = info.ReadInt32("GuardDefaultDefense");
            DefaultHP      = info.ReadInt32("GuardDefaultHP");

            InitializeGuardData();
        }
Exemplo n.º 4
0
        private static Color AttributeToColor(XElement node, string name)
        {
            var attrib = GetAttribute(node, name);

            try
            {
                Color result = ColorX.FromArgb(attrib.Value);

                return(result);
            }
            catch (Exception e)
            {
                throw new InvalidOperationException("Attribute " + name + " does not contain a properly formatted color.", e);
            }
        }
Exemplo n.º 5
0
        public void FromArgbString()
        {
            Action badParse = () => ColorX.FromArgb("lkdsjflkdsj");

            badParse.Should().Throw <ArgumentException>();

            var clr = ColorX.FromArgb("0xaabbcc");

            clr.A.Should().Be(0xff);
            clr.R.Should().Be(0xaa);
            clr.G.Should().Be(0xbb);
            clr.B.Should().Be(0xcc);

            var clr1 = ColorX.FromArgb("0x99aabbcc");

            clr1.A.Should().Be(0x99);
            clr1.R.Should().Be(0xaa);
            clr1.G.Should().Be(0xbb);
            clr1.B.Should().Be(0xcc);
        }
Exemplo n.º 6
0
        public object ReadYaml(IParser parser, Type type)
        {
            var scalar = (YamlDotNet.Core.Events.Scalar)parser.Current;
            var value  = scalar.Value;

            if (string.IsNullOrWhiteSpace(value) && type == typeof(Color?))
            {
                parser.MoveNext();
                return(null);
            }

            Color result;

            if (!ColorX.TryParseNamedColor(value, out result))
            {
                result = ColorX.FromArgb(value);
            }

            parser.MoveNext();
            return(result);
        }
Exemplo n.º 7
0
        public override IRenderable Render()
        {
            var labelStyle = new InlineElementStyle
            {
                Background = new BackgroundStyle {
                    Color = ColorX.FromArgb("e34234")
                },
                Padding = LayoutBox.SameAllAround(8)
            };

            return(new App(new AppProps
            {
                Children =
                {
                    new Window(new WindowProps
                    {
                        Children =
                        {
                            new Label(new LabelProps                     {
                                Text = "Justify Content Value"
                            }),
                            new RadioMenu(new RadioMenuProps
                            {
                                Buttons =
                                {
                                    new RadioButton(new RadioButtonProps {
                                        Text = "Start", OnAccept = e => Set(JustifyContent.Start), Checked = true,
                                    }),
                                    new RadioButton(new RadioButtonProps {
                                        Text = "End", OnAccept = e => Set(JustifyContent.End)
                                    }),
                                    new RadioButton(new RadioButtonProps {
                                        Text = "Center", OnAccept = e => Set(JustifyContent.Center)
                                    }),
                                    new RadioButton(new RadioButtonProps {
                                        Text = "Space Between", OnAccept = e => Set(JustifyContent.SpaceBetween)
                                    }),
                                    new RadioButton(new RadioButtonProps {
                                        Text = "Space Around", OnAccept = e => Set(JustifyContent.SpaceAround)
                                    }),
                                    new RadioButton(new RadioButtonProps {
                                        Text = "Space Evenly", OnAccept = e => Set(JustifyContent.SpaceEvenly)
                                    }),
                                },
                                OnCancel = Props.OnCancel,
                            })
                        }
                    }),

                    new Window(new WindowProps
                    {
                        Style = new InlineElementStyle
                        {
                            Padding = LayoutBox.SameAllAround(12),
                        },
                        Children =
                        {
                            new Label(new LabelProps                     {
                                Text = "Really long text to setup some horizontal space."
                            }),
                            new Window(new WindowProps
                            {
                                Name = "magic-window",
                                Style = new InlineElementStyle
                                {
                                    Flex = new FlexStyle
                                    {
                                        Direction = FlexDirection.Row,
                                        JustifyContent = State.JustifyContent,
                                    },
                                    Background = new BackgroundStyle     {
                                        Color = Color.DimGray
                                    }
                                },
                                Children =
                                {
                                    new Label(new LabelProps             {
                                        Style = labelStyle, Text = "This",
                                    }),
                                    new Label(new LabelProps             {
                                        Style = labelStyle, Text = "is"
                                    }),
                                    new Label(new LabelProps             {
                                        Style = labelStyle, Text = "an"
                                    }),
                                    new Label(new LabelProps             {
                                        Style = labelStyle, Text = "example"
                                    }),
                                }
                            }),
                        }
                    })
                }
            }));
        }