Exemplo n.º 1
0
    public override bool AddDockableAttachment(BaseAttachment attach)
    {
        SliderAttachment slider = attach as SliderAttachment;

        slider.SetCloneable(false);
        slider.SetIsDraggable(true);
        slider.SetToolmodeResponse(new BaseTool.ToolMode[] { BaseTool.ToolMode.GRABBING });
        slider.DockInto(m_paramscroller);

        //iTween.MoveTo(slider.gameObject, iTween.Hash("position", transform.position, "time", 0.5f, "islocal", true));
        //iTween.RotateTo(slider.gameObject, iTween.Hash("rotation", transform.rotation, "time", 0.5f));

        return(true);
    }
    /*
     * Controls
     */


    public void InitInstrumentControls()
    {
        if (musicRef != null)
        {
            m_rotator = new GameObject("rotator");
            m_rotator.transform.parent        = transform;
            m_rotator.transform.localPosition = Vector3.zero;

            //Create clipbuttons
            ScrollerAttachment clipScroller = UIFactory.CreateParamScroller();
            clipScroller.SetItemSpacing(m_clipCubeSpacing);
            clipScroller.AddAcceptedDocktype(typeof(ClipCubeAttachment));
            clipScroller.transform.parent = m_rotator.transform;
            clipScroller.SetOffset(new Vector3(-m_controlsMirrorOffset, m_controlsYOffset + 0.02f, 0.0f));
            //clipScroller.transform.localPosition = new Vector3(-m_controlsMirrorOffset, m_controlsYOffset + 0.02f, 0.0f);
            clipScroller.SetItemScale(UIFactory.sliderScale.x);

            foreach (InstrumentClip clip in musicRef.clipList)
            {
                ClipCubeAttachment cube = UIFactory.CreateClipCube(clip, true);
                cube.SetCloneable(true);
                cube.SetColour(musicRef.color);
                cube.DockInto(clipScroller);
            }

            //Create param sliders
            ScrollerAttachment paramScroller = UIFactory.CreateParamScroller();
            paramScroller.transform.parent = m_rotator.transform;
            paramScroller.SetOffset(new Vector3(m_controlsMirrorOffset, m_controlsYOffset, 0.0f));
            //paramScroller.transform.localPosition = new Vector3(m_controlsMirrorOffset, m_controlsYOffset, 0.0f);
            paramScroller.SetItemScale(UIFactory.sliderScale.x);

            foreach (BaseInstrumentParam param in musicRef.paramList)
            {
                SliderAttachment slider = UIFactory.CreateSlider(param, UIFrame.AnchorLocation.BOTTOM_LEFT);
                slider.SetCloneable(true);
                slider.DockInto(paramScroller);
            }

            if (musicRef.clipList.Count < clipScroller.numDisplayedAttachments)
            {
                clipScroller.SetNumDisplayedAttachments(musicRef.clipList.Count);
            }

            if (musicRef.paramList.Count < paramScroller.numDisplayedAttachments)
            {
                paramScroller.SetNumDisplayedAttachments(musicRef.paramList.Count);
            }

            m_parameterScroller = paramScroller.gameObject;
            m_clipScroller      = clipScroller.gameObject;

            //Central divider
            float largestHeight = (clipScroller.upperVisibleBounds > paramScroller.upperVisibleBounds) ? clipScroller.upperVisibleBounds : paramScroller.upperVisibleBounds;
            m_dividingQuad = UIFactory.CreateGuiQuad();
            m_dividingQuad.transform.localScale    = new Vector3(m_dividerWidth, largestHeight, 1.0f);
            m_dividingQuad.transform.parent        = m_rotator.transform;
            m_dividingQuad.transform.localPosition = new Vector3(0.0f, m_controlsYOffset, 0.0f);

            DisableControls();
        }
    }