Beispiel #1
0
        void Execute()
        {
            CTag tag = CTag.Find(name);

            if (tag == null)
            {
                tag = new CTag(name); // the tag would be registered
            }

            tag.Enabled   = enabled;
            tag.Color     = CColorUtils.FromRGBA((uint)color);
            tag.BackColor = CColorUtils.FromRGBA((uint)color);
        }
Beispiel #2
0
        public void TestCvarColor()
        {
            Color  color        = CColorUtils.FromRGBA(0x12345678);
            string colorDefault = string.Format("{0} {1} {2} {3}", color.r, color.g, color.b, color.a);

            CVar cvar = new CVar("var", color);

            Assert.IsTrue(cvar.IsColor);
            Assert.IsTrue(cvar.IsDefault);
            Assert.AreEqual(colorDefault, cvar.DefaultValue);

            Assert.AreEqual(color, cvar.ColorValue);
            Assert.AreEqual(0x12345678, cvar.IntValue);
            Assert.AreEqual(colorDefault, cvar.Value);

            Color otherColor      = new Color(0.1f, 0.2f, 0.3f, 0.4f);
            uint  otherColorValue = CColorUtils.ToRGBA(ref otherColor);

            Execute("var 0.1 0.2 0.3 0.4");
            Assert.IsFalse(cvar.IsDefault);
            Assert.AreEqual(otherColor, cvar.ColorValue);
            Assert.AreEqual(otherColorValue, (uint)cvar.IntValue);
            Assert.AreEqual("0.1 0.2 0.3 0.4", cvar.Value);

            otherColorValue = 0x87654321;
            otherColor      = CColorUtils.FromRGBA(0x87654321);
            Execute("var 0x{0}", otherColorValue.ToString("X"));
            Assert.IsFalse(cvar.IsDefault);
            Assert.AreEqual(otherColor, cvar.ColorValue);
            Assert.AreEqual(otherColorValue, (uint)cvar.IntValue);
            Assert.AreEqual("0.5294118 0.3960785 0.2627451 0.1294118", cvar.Value);

            Execute("reset var");
            Assert.IsTrue(cvar.IsDefault);
            Assert.AreEqual(colorDefault, cvar.Value);
            Assert.AreEqual(color, cvar.ColorValue);
            Assert.AreEqual(0x12345678, cvar.IntValue);
        }