private void btnBlendDst_Click(object sender, EventArgs e)
        {
            EBlendFactor      eBlendFactor = (EBlendFactor)Enum.Parse(typeof(EBlendFactor), btnBlendDst.Text);
            GLBlendFactorForm form         = new GLBlendFactorForm();

            form.setGlBendFactor(eBlendFactor);
            form.ShowDialog();
            if (form.DialogResult == DialogResult.OK)
            {
                btnBlendDst.Text = form.getGlBendFactor().ToString();
                if (btnBlendSrc.Text == Enum.GetName(typeof(EBlendFactor), EBlendFactor.GL_SRC_ALPHA) &&
                    btnBlendDst.Text == Enum.GetName(typeof(EBlendFactor), EBlendFactor.GL_ONE_MINUS_SRC_ALPHA))
                {
                    btnBlendNormal.Font = new Font(btnBlendNormal.Font, FontStyle.Bold);
                    btnBlendToAdd.Font  = new Font(btnBlendToAdd.Font, FontStyle.Regular);
                }
                else if (btnBlendSrc.Text == Enum.GetName(typeof(EBlendFactor), EBlendFactor.GL_SRC_ALPHA) &&
                         btnBlendDst.Text == Enum.GetName(typeof(EBlendFactor), EBlendFactor.GL_ONE))
                {
                    btnBlendToAdd.Font  = new Font(btnBlendToAdd.Font, FontStyle.Bold);
                    btnBlendNormal.Font = new Font(btnBlendNormal.Font, FontStyle.Regular);
                }
                else
                {
                    btnBlendToAdd.Font  = new Font(btnBlendToAdd.Font, FontStyle.Regular);
                    btnBlendNormal.Font = new Font(btnBlendNormal.Font, FontStyle.Regular);
                }
                updateTitle(true);
            }
        }
        private String toXml()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
            sb.Append("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n");
            sb.Append("<plist version=\"1.0\">\n");
            sb.Append("<dict>\n");
            // angle
            AppendKV(sb, 1, "angle", emitAngle.getValue().ToString(), "real");
            // angleVariance
            AppendKV(sb, 1, "angleVariance", emitAngleVar.getValue().ToString(), "real");
            // ??? blendFuncDestination
            AppendKV(sb, 1, "blendFuncDestination", GLBlendFactorForm.transGlBlendFactor((EBlendFactor)Enum.Parse(typeof(EBlendFactor), btnBlendDst.Text)).ToString(), "integer");
            // ??? blendFuncSource
            AppendKV(sb, 1, "blendFuncSource", GLBlendFactorForm.transGlBlendFactor((EBlendFactor)Enum.Parse(typeof(EBlendFactor), btnBlendSrc.Text)).ToString(), "integer");
            // duration
            AppendKV(sb, 1, "duration", emDuration.getValue().ToString(), "real");
            // ??? emitterType TODO confirm 1.0 and 0.0
            AppendKV(sb, 1, "emitterType", (radioEmitterGravity.Checked ? 0.0f : 1.0f).ToString(), "real");
            // finishColorAlpha
            AppendKV(sb, 1, "finishColorAlpha", ((float)(endColor.getA() / 255.0f)).ToString(), "real");
            // finishColorBlue
            AppendKV(sb, 1, "finishColorBlue", ((float)(endColor.getB() / 255.0f)).ToString(), "real");
            // finishColorGreen
            AppendKV(sb, 1, "finishColorGreen", ((float)(endColor.getG() / 255.0f)).ToString(), "real");
            // finishColorRed
            AppendKV(sb, 1, "finishColorRed", ((float)(endColor.getR() / 255.0f)).ToString(), "real");
            // finishColorVarianceAlpha
            AppendKV(sb, 1, "finishColorVarianceAlpha", ((float)(endColorVar.getA() / 255.0f)).ToString(), "real");
            // finishColorVarianceBlue
            AppendKV(sb, 1, "finishColorVarianceBlue", ((float)(endColorVar.getB() / 255.0f)).ToString(), "real");
            // finishColorVarianceGreen
            AppendKV(sb, 1, "finishColorVarianceGreen", ((float)(endColorVar.getG() / 255.0f)).ToString(), "real");
            // finishColorVarianceRed
            AppendKV(sb, 1, "finishColorVarianceRed", ((float)(endColorVar.getR() / 255.0f)).ToString(), "real");
            // finishParticleSize
            AppendKV(sb, 1, "finishParticleSize", finishSize.getValue().ToString(), "real");
            // finishParticleSizeVariance
            AppendKV(sb, 1, "finishParticleSizeVariance", finishSizeVar.getValue().ToString(), "real");
            // gravityx
            AppendKV(sb, 1, "gravityx", emGravityX.getValue().ToString(), "real");
            // gravityy
            AppendKV(sb, 1, "gravityy", emGravityY.getValue().ToString(), "real");
            // maxParticles
            AppendKV(sb, 1, "maxParticles", maxParticles.getValue().ToString(), "real");
            // maxRadius
            AppendKV(sb, 1, "maxRadius", emRadialMaxRadius.getValue().ToString(), "real");
            // maxRadiusVariance
            AppendKV(sb, 1, "maxRadiusVariance", emRadialMaxRadiusVar.getValue().ToString(), "real");
            // minRadius
            AppendKV(sb, 1, "minRadius", emRadialMinRadius.getValue().ToString(), "real");
            // particleLifespan
            AppendKV(sb, 1, "particleLifespan", lifeSpan.getValue().ToString(), "real");
            // particleLifespanVariance
            AppendKV(sb, 1, "particleLifespanVariance", lifeSpanVar.getValue().ToString(), "real");
            // radialAccelVariance
            AppendKV(sb, 1, "radialAccelVariance", emGravityRadialAccelVar.getValue().ToString(), "real");
            // radialAcceleration
            AppendKV(sb, 1, "radialAcceleration", emGravityRadialAccel.getValue().ToString(), "real");
            // rotatePerSecond
            AppendKV(sb, 1, "rotatePerSecond", emRadialDegPerSecond.getValue().ToString(), "real");
            // rotatePerSecondVariance
            AppendKV(sb, 1, "rotatePerSecondVariance", emRadialDegPerSecondVar.getValue().ToString(), "real");
            // rotationEnd
            AppendKV(sb, 1, "rotationEnd", rotationEnd.getValue().ToString(), "real");
            // rotationEndVariance
            AppendKV(sb, 1, "rotationEndVariance", rotationEndVar.getValue().ToString(), "real");
            // rotationStart
            AppendKV(sb, 1, "rotationStart", rotationStart.getValue().ToString(), "real");
            // rotationStartVariance
            AppendKV(sb, 1, "rotationStartVariance", rotationStartVar.getValue().ToString(), "real");
            // sourcePositionVariancex
            AppendKV(sb, 1, "sourcePositionVariancex", emPosXVar.getValue().ToString(), "real");
            // sourcePositionVariancey
            AppendKV(sb, 1, "sourcePositionVariancey", emPosYVar.getValue().ToString(), "real");
            // sourcePositionx
            AppendKV(sb, 1, "sourcePositionx", emPosX.getValue().ToString(), "real");
            // sourcePositiony
            AppendKV(sb, 1, "sourcePositiony", emPosY.getValue().ToString(), "real");
            // speed
            AppendKV(sb, 1, "speed", emGravitySpeed.getValue().ToString(), "real");
            // speedVariance
            AppendKV(sb, 1, "speedVariance", emGravitySpeedVar.getValue().ToString(), "real");
            // startColorAlpha
            AppendKV(sb, 1, "startColorAlpha", ((float)(startColor.getA() / 255.0f)).ToString(), "real");
            // startColorBlue
            AppendKV(sb, 1, "startColorBlue", ((float)(startColor.getB() / 255.0f)).ToString(), "real");
            // startColorGreen
            AppendKV(sb, 1, "startColorGreen", ((float)(startColor.getG() / 255.0f)).ToString(), "real");
            // startColorRed
            AppendKV(sb, 1, "startColorRed", ((float)(startColor.getR() / 255.0f)).ToString(), "real");
            // startColorVarianceAlpha
            AppendKV(sb, 1, "startColorVarianceAlpha", ((float)(startColorVar.getA() / 255.0f)).ToString(), "real");
            // startColorVarianceBlue
            AppendKV(sb, 1, "startColorVarianceBlue", ((float)(startColorVar.getB() / 255.0f)).ToString(), "real");
            // startColorVarianceGreen
            AppendKV(sb, 1, "startColorVarianceGreen", ((float)(startColorVar.getG() / 255.0f)).ToString(), "real");
            // startColorVarianceRed
            AppendKV(sb, 1, "startColorVarianceRed", ((float)(startColorVar.getR() / 255.0f)).ToString(), "real");
            // startParticleSize
            AppendKV(sb, 1, "startParticleSize", startSize.getValue().ToString(), "real");
            // startParticleSizeVariance
            AppendKV(sb, 1, "startParticleSizeVariance", startSizeVar.getValue().ToString(), "real");
            // tangentialAccelVariance
            AppendKV(sb, 1, "tangentialAccelVariance", emGravityTangentAccelVar.getValue().ToString(), "real");
            // tangentialAcceleration
            AppendKV(sb, 1, "tangentialAcceleration", emGravityTangentAccel.getValue().ToString(), "real");
            // textureFileName
            AppendKV(sb, 1, "textureFileName", textureFileName, "string");

            sb.Append("</dict>\n");
            sb.Append("</plist>\n");

            return(sb.ToString());
        }
        private void readFromXml(XmlDocument doc)
        {
            XmlElement        eDict   = ((XmlElement)doc.SelectNodes("plist")[0].SelectNodes("dict")[0]);
            List <XmlElement> eChilds = new List <XmlElement>();

            for (XmlNode node = eDict.FirstChild; node != null; node = node.NextSibling)
            {
                if (!(node is XmlElement))
                {
                    continue;
                }

                eChilds.Add((XmlElement)node);
            }

            for (int i = 0; i < eChilds.Count; ++i)
            {
                XmlElement e = eChilds[i];
                if (e.ChildNodes[0].Value == "angle")
                {
                    emitAngle.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "angleVariance")
                {
                    emitAngleVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "blendFuncDestination")
                {
                    btnBlendDst.Text = Enum.GetName(typeof(EBlendFactor), GLBlendFactorForm.transGlBlendFactor(int.Parse(eChilds[++i].ChildNodes[0].Value)));
                }
                else if (e.ChildNodes[0].Value == "blendFuncSource")
                {
                    btnBlendSrc.Text = Enum.GetName(typeof(EBlendFactor), GLBlendFactorForm.transGlBlendFactor(int.Parse(eChilds[++i].ChildNodes[0].Value)));
                }
                else if (e.ChildNodes[0].Value == "duration")
                {
                    emDuration.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "emitterType")
                {
                    // ??? emitterType TODO confirm 1.0 and 0.0
                    if (float.Parse(eChilds[++i].ChildNodes[0].Value) == 0)
                    {
                        radioEmitterGravity.Checked = true;
                    }
                    else
                    {
                        radioEmitterRadial.Checked = true;
                    }
                }
                else if (e.ChildNodes[0].Value == "finishColorAlpha")
                {
                    endColor.setA((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorBlue")
                {
                    endColor.setB((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorGreen")
                {
                    endColor.setG((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorRed")
                {
                    endColor.setR((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorVarianceAlpha")
                {
                    endColorVar.setA((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorVarianceBlue")
                {
                    endColorVar.setB((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorVarianceGreen")
                {
                    endColorVar.setG((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishColorVarianceRed")
                {
                    endColorVar.setR((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "finishParticleSize")
                {
                    finishSize.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "finishParticleSizeVariance")
                {
                    finishSizeVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "gravityx")
                {
                    emGravityX.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "gravityy")
                {
                    emGravityY.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "maxParticles")
                {
                    maxParticles.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "maxRadius")
                {
                    emRadialMaxRadius.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "maxRadiusVariance")
                {
                    emRadialMaxRadiusVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "minRadius")
                {
                    emRadialMinRadius.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "particleLifespan")
                {
                    lifeSpan.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "particleLifespanVariance")
                {
                    lifeSpanVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "radialAccelVariance")
                {
                    emGravityRadialAccelVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "radialAcceleration")
                {
                    emGravityRadialAccel.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "rotatePerSecond")
                {
                    emRadialDegPerSecond.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "rotatePerSecondVariance")
                {
                    emRadialDegPerSecondVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "rotationEnd")
                {
                    rotationEnd.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "rotationEndVariance")
                {
                    rotationEndVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "rotationStart")
                {
                    rotationStart.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "rotationStartVariance")
                {
                    rotationStartVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "sourcePositionVariancex")
                {
                    emPosXVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "sourcePositionVariancey")
                {
                    emPosYVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "sourcePositionx")
                {
                    emPosX.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "sourcePositiony")
                {
                    emPosY.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "speed")
                {
                    emGravitySpeed.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "speedVariance")
                {
                    emGravitySpeedVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "startColorAlpha")
                {
                    startColor.setA((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorBlue")
                {
                    startColor.setB((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorGreen")
                {
                    startColor.setG((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorRed")
                {
                    startColor.setR((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorVarianceAlpha")
                {
                    startColorVar.setA((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorVarianceBlue")
                {
                    startColorVar.setB((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorVarianceGreen")
                {
                    startColorVar.setG((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startColorVarianceRed")
                {
                    startColorVar.setR((byte)Math.Round((float.Parse(eChilds[++i].ChildNodes[0].Value) * 255)));
                }
                else if (e.ChildNodes[0].Value == "startParticleSize")
                {
                    startSize.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "startParticleSizeVariance")
                {
                    startSizeVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "tangentialAccelVariance")
                {
                    emGravityTangentAccelVar.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "tangentialAcceleration")
                {
                    emGravityTangentAccel.setValue(float.Parse(eChilds[++i].ChildNodes[0].Value));
                }
                else if (e.ChildNodes[0].Value == "textureFileName")
                {
                    setTextureFileName(eChilds[++i].ChildNodes[0].Value);
                }
            }
        }
Exemple #4
0
        public void onBtnSet_Click(object sender, EventArgs e)
        {
            if (ePropType == EPropType.ePropType_GL_BlendFactor)
            {
                GLBlendFactorForm form = new GLBlendFactorForm();
                form.setGlBendFactor((EBlendFactor)Enum.Parse(typeof(EBlendFactor), tb.Text));
                form.ShowDialog();
                this.tb.Text = Enum.GetName(typeof(EBlendFactor), form.getGlBendFactor());
            }
            else if (ePropType == EPropType.ePropType_GL_SysParticle)
            {
                ParticleTypeForm form = new ParticleTypeForm();
                form.setType((ESysParticleType)Enum.Parse(typeof(ESysParticleType), tb.Text));
                form.ShowDialog();
                this.tb.Text = Enum.GetName(typeof(ESysParticleType), form.getType());
            }
            else if (ePropType == EPropType.ePropType_Condition)
            {
                CondTypeForm form = new CondTypeForm();
                form.setType((ECondType)Enum.Parse(typeof(ECondType), tb.Text));
                form.ShowDialog();
                this.tb.Text = Enum.GetName(typeof(ECondType), form.getType());
            }
            else if (ePropType == EPropType.ePropType_OffsetType)
            {
                OffsetTypeForm form = new OffsetTypeForm();
                form.setType((EOffsetType)Enum.Parse(typeof(EOffsetType), tb.Text));
                form.ShowDialog();
                this.tb.Text = Enum.GetName(typeof(EOffsetType), form.getType());
            }
            else if (ePropType == EPropType.ePropType_ShaderType)
            {
                __curContextMenuValue = "";
                ContextMenu contextMenu = new ContextMenu();
                contextMenu.MenuItems.Add("默认 - ShaderPositionTextureColor");
                contextMenu.MenuItems.Add("模糊 - ShaderBlur");
                contextMenu.MenuItems.Add("灰度图 - ShaderGrey");
                contextMenu.MenuItems.Add("马赛克 - ShaderMosaic");
                contextMenu.MenuItems.Add("调色(亮度,对比度,饱和度) - ShaderCompose");
                contextMenu.MenuItems.Add("Bloom - ShaderBloom");
                contextMenu.Show(this.tb, new Point(0, 0));
                for (int i = 0; i < contextMenu.MenuItems.Count; i++)
                {
                    contextMenu.MenuItems[i].Click += onContextMenuClick;
                }
            }
            else if (ePropType == EPropType.ePropType_ShaderParamType)
            {
                String shaderName = "";
                foreach (Prop prop in propForm.props)
                {
                    if (prop.ePropType == EPropType.ePropType_ShaderType)
                    {
                        shaderName = prop.tb.Text;
                        break;
                    }
                }

                if (shaderName == "")
                {
                    return;
                }

                ContextMenu contextMenu = new ContextMenu();
                contextMenu.MenuItems.Add("(空)");
                switch (shaderName)
                {
                case "ShaderBlur":
                    contextMenu.MenuItems.Add("模糊程度 - ShaderParam_Blur");
                    break;

                case "ShaderGrey":      // 目前没有参数
                    contextMenu.MenuItems.Add("灰度程度 - ShaderParam_Grey");
                    break;

                case "ShaderMosaic":      // 目前没有参数
                    contextMenu.MenuItems.Add("马赛克程度 - ShaderParam_Mosaic");
                    break;

                case "ShaderCompose":      // 目前没有参数
                    contextMenu.MenuItems.Add("调色(亮度)  - ShaderParam_Compose_brightness");
                    contextMenu.MenuItems.Add("调色(对比度) - ShaderParam_Compose_contrast");
                    contextMenu.MenuItems.Add("调色(饱和度) - ShaderParam_Compose_saturation");
                    break;

                case "ShaderBloom":
                    contextMenu.MenuItems.Add("bloom(offset)  - ShaderParam_Bloom_offset");
                    contextMenu.MenuItems.Add("bloom(scale)  - ShaderParam_Bloom_scale");
                    break;
                }

                contextMenu.Show(this.tb, new Point(0, 0));
                for (int i = 0; i < contextMenu.MenuItems.Count; i++)
                {
                    contextMenu.MenuItems[i].Click += onContextMenuClick;
                }
            }
        }