Пример #1
0
        static void LoadParamUI(ShaderParam param, string label = "", bool drag = false)
        {
            switch (param.Type)
            {
            case ShaderParamType.Bool:
            {
                ImGuiHelper.InputFromBoolean(label, param, "DataValue");
            }
            break;

            case ShaderParamType.Int:
            {
                ImGuiHelper.InputFromInt(label, param, "DataValue", 1, drag);
            }
            break;

            case ShaderParamType.UInt:
            {
                ImGuiHelper.InputFromUint(label, param, "DataValue", 1, drag);
            }
            break;

            case ShaderParamType.Float:
            {
                ImGuiHelper.InputFromFloat(label, param, "DataValue", drag);
            }
            break;

            case ShaderParamType.Float2:
            {
                ImGuiHelper.InputFloatsFromVector2(label, param, "DataValue", drag);
            }
            break;

            case ShaderParamType.Float3:
            {
                if (param.Name.Contains("color") || param.Name.Contains("Color"))
                {
                    ImGuiHelper.InputFloatsFromColor3(label, param, "DataValue");
                }
                else
                {
                    ImGuiHelper.InputFloatsFromVector3(label, param, "DataValue", drag);
                }
            }
            break;

            case ShaderParamType.Float4:
            {
                if (param.Name.Contains("color") || param.Name.Contains("Color"))
                {
                    ImGuiHelper.InputFloatsFromColor4(label, param, "DataValue", ImGuiColorEditFlags.AlphaBar | ImGuiColorEditFlags.AlphaPreviewHalf);
                }
                else
                {
                    ImGuiHelper.InputFloatsFromVector4(label, param, "DataValue", drag);
                }
            }
            break;

            case ShaderParamType.Srt2D:
            {
                Srt2D value = (Srt2D)param.DataValue;
                var   pos   = new Vector2(value.Translation.X, value.Translation.Y);
                var   scale = new Vector2(value.Scaling.X, value.Scaling.Y);
                var   rot   = value.Rotation;

                bool edited0 = ImGui.DragFloat2("Scale", ref scale);
                bool edited1 = ImGui.DragFloat("Rotate", ref rot, 0.1f);
                bool edited2 = ImGui.DragFloat2("Translate", ref pos);
                if (edited0 || edited1 || edited2)
                {
                    param.DataValue = new Srt2D()
                    {
                        Scaling     = new Syroot.Maths.Vector2F(scale.X, scale.Y),
                        Translation = new Syroot.Maths.Vector2F(pos.X, pos.Y),
                        Rotation    = rot,
                    };
                }
            }
            break;

            case ShaderParamType.TexSrt:
            case ShaderParamType.TexSrtEx:
            {
                TexSrt value   = (TexSrt)param.DataValue;
                bool   edited3 = ImGuiHelper.ComboFromEnum <TexSrtMode>("Mode", value, "Mode");
                var    pos     = new Vector2(value.Translation.X, value.Translation.Y);
                var    scale   = new Vector2(value.Scaling.X, value.Scaling.Y);
                var    rot     = value.Rotation;

                bool edited0 = ImGui.DragFloat2("Scale", ref scale);
                bool edited1 = ImGui.DragFloat("Rotate", ref rot, 0.1f);
                bool edited2 = ImGui.DragFloat2("Translate", ref pos);
                if (edited0 || edited1 || edited2 || edited3)
                {
                    param.DataValue = new TexSrt()
                    {
                        Mode        = value.Mode,
                        Scaling     = new Syroot.Maths.Vector2F(scale.X, scale.Y),
                        Translation = new Syroot.Maths.Vector2F(pos.X, pos.Y),
                        Rotation    = rot,
                    };
                }
            }
            break;
            }
        }