Esempio n. 1
0
    void ChoiceWindow(int windowID)
    {
        if(windowID >= 0 && GameHandler.WindowHandler().GetFocusID() == windowID)
        {
            GUI.BringWindowToFront(windowID);
        }

        TextPosition textPosition = new TextPosition(dp.boxBounds, dp.boxPadding, dp.lineSpacing);
        textPosition.bounds.x = 0;
        textPosition.bounds.y = 0;
        if(dp.autoCollapse && this.newHeight > 0) textPosition.bounds.height = this.newHeight;

        if(dp.isDragWindow) GUI.DragWindow(dp.dragBounds);
        GUI.BeginGroup(textPosition.bounds);

        if(windowID >= 0 && Event.current.type == EventType.MouseUp && dp.focusable &&
            !GameHandler.WindowHandler().IsFocusBlocked())
        {
            GameHandler.WindowHandler().SetFocusID(windowID);
            GUI.BringWindowToFront(windowID);
        }

        if(speakerPortrait != null && speakerPortrait.inBox)
        {
            speakerPortrait.ShowPortrait();
        }

        Vector2 v = Vector2.zero;
        textPosition.bounds.x += dp.boxPadding.x;
        textPosition.bounds.y += dp.boxPadding.y;
        textPosition.bounds.width -= (dp.boxPadding.x + dp.boxPadding.z);
        textPosition.bounds.height -= (dp.boxPadding.y + dp.boxPadding.w);

        this.viewHeight = textPosition.bounds.height;

        GUIStyle shadowStyle = new GUIStyle(GUI.skin.label);
        shadowStyle.normal.textColor = DataHolder.Color(1);

        GUIStyle textStyle = new GUIStyle(GUI.skin.label);
        textStyle.wordWrap = false;

        if(dp.scrollable)
        {
            Rect scrollRect = new Rect(textPosition.bounds.x, textPosition.bounds.y, textPosition.bounds.width-dp.boxPadding.z, this.scrollSize);
            if(this.scrollSize > textPosition.bounds.height) scrollRect.width -= GUI.skin.verticalScrollbar.fixedWidth+1;
            this.scroll = GUI.BeginScrollView(textPosition.bounds, this.scroll, scrollRect);
            GUI.BeginGroup(scrollRect);
            textPosition.bounds.width = scrollRect.width;
        }
        else
        {
            GUI.BeginGroup(textPosition.bounds);
        }

        for(int i=0; i<this.content.label.Length; i++)
        {
            if(dp.showShadow)
            {
                shadowStyle.normal.textColor = this.content.label[i].shadowColor;
                GUI.Label(
                    new Rect(this.content.label[i].bounds.x + dp.shadowOffset.x, this.content.label[i].bounds.y + dp.shadowOffset.y,
                    this.content.label[i].bounds.width, this.content.label[i].bounds.height),
                    this.content.label[i].content, shadowStyle);
            }

            textStyle.normal.textColor = this.content.label[i].textColor;
            GUI.Label(this.content.label[i].bounds, this.content.label[i].content, textStyle);
        }

        float xPos = this.content.xPos;
        float yPos = this.content.yPos;
        if("" != text) v = textStyle.CalcSize(this.content.label[this.content.label.Length-1].content);
        else v = Vector2.zero;

        // get title text length
        float choiceStartX = 0;
        float maxRightWidth = 0;
        for(int i=0; i<choice.Length; i++)
        {
            if(choice[i].title != null)
            {
                v = choice[i].titleSize;
                if(v.x > choiceStartX) choiceStartX = v.x;
            }
            if(choice[i].rightLabel != null && choice[i].alignRightSide)
            {
                if(choice[i].rightSize.x > maxRightWidth) maxRightWidth = choice[i].rightSize.x;
            }
        }
        if(choiceStartX > 0) choiceStartX += dp.columnSpacing;

        // choices
        xPos = choiceStartX;
        if("" == text) yPos -= textPosition.lineSpacing;
        this.selectionOffset = v.y + dp.columnSpacing;
        LevelHandler lh = GameHandler.GetLevelHandler();
        textStyle.alignment = TextAnchor.UpperLeft;
        shadowStyle.alignment = TextAnchor.UpperLeft;

        colFill = dp.columnFill;
        if(ColumnFill.VERTICAL.Equals(colFill))
        {
            maxCol = (int)Mathf.Ceil(((float)choice.Length) / ((float)dp.choiceColumns));
            colCount = dp.choiceColumns;
        }
        else
        {
            maxCol = dp.choiceColumns;
            colCount = (int)Mathf.Ceil(((float)choice.Length) / ((float)dp.choiceColumns));
        }

        int counter = 0;
        float storedYPos = yPos;
        int columnCount = dp.choiceColumns;
        if(this.choice.Length == 1) columnCount = 1;
        float colWidth = (textPosition.bounds.width / columnCount) - (dp.columnSpacing * (columnCount - 1)) - choiceStartX;
        float maxYPos = yPos;
        float cOffsetX = 0;

        int lastSelection = this.selection;
        for(int i=0; i<choice.Length; i++)
        {
            cOffsetX = dp.choiceOffsetX*i;
            if(counter >= maxCol)
            {
                counter = 0;
                if(ColumnFill.VERTICAL.Equals(colFill))
                {
                    yPos = storedYPos;
                    xPos += colWidth + dp.columnSpacing + choiceStartX;
                }
                else
                {
                    xPos = choiceStartX;
                    yPos += v.y + dp.columnSpacing;
                }
            }
            else if(i > 0)
            {
                if(ColumnFill.VERTICAL.Equals(colFill))
                {
                    yPos +=  dp.columnSpacing;
                }
                else
                {
                    xPos += colWidth + dp.columnSpacing + choiceStartX;
                }
            }

            float imageWidth = 0;
            float textAdd = 0;
            Rect cbounds;
            Color c;

            // title
            if(choiceStartX > 0 && choice[i].title != null && "" != choice[i].title.text)
            {
                v = choice[i].titleSize;
                cbounds = new Rect(xPos, yPos, v.x, v.y);
                if(dp.choiceDefineWidth) cbounds.x = cOffsetX;
                if(choice[i].title.image)
                {
                    textStyle.alignment = TextAnchor.MiddleLeft;
                    GUI.Label(new Rect(cbounds.x+dp.choicePadding.x-choiceStartX, cbounds.y, v.x, v.y),
                            new GUIContent(choice[i].title.image), textStyle);
                    imageWidth = choice[i].title.image.width;
                    textAdd = textStyle.CalcSize(new GUIContent(".")).x;
                    textStyle.alignment = TextAnchor.UpperLeft;
                }
                for(int j=0; j<choice[i].titleLabel.label.Length; j++)
                {
                    Rect b = new Rect(cbounds.x+choice[i].titleLabel.label[j].bounds.x + imageWidth+dp.choicePadding.x-choiceStartX+textAdd,
                                        cbounds.y+choice[i].titleLabel.label[j].bounds.y,
                                        cbounds.width,
                                        cbounds.height);
                    if(dp.showShadow)
                    {
                        shadowStyle.normal.textColor = choice[i].titleLabel.label[j].shadowColor;
                        GUI.Label(
                            new Rect(b.x + dp.shadowOffset.x,
                                        b.y + dp.shadowOffset.y,
                                        b.width,
                                        b.height),
                                choice[i].titleLabel.label[j].content, shadowStyle);
                    }
                    textStyle.normal.textColor = choice[i].titleLabel.label[j].textColor;
                    GUI.Label(b, choice[i].titleLabel.label[j].content, textStyle);
                }
            }

            c = GUI.backgroundColor;
            if(choice[i].active || dp.alpha < dp.choiceInactiveAlpha) c.a = dp.alpha;
            else c.a = dp.choiceInactiveAlpha;
            GUI.backgroundColor = c;
            c = GUI.color;
            if(choice[i].active || dp.alpha < dp.choiceInactiveAlpha) c.a = dp.alpha;
            else c.a = dp.choiceInactiveAlpha;
            GUI.color = c;

            if(this.selection == i && dp.selectSkin &&
                    DataHolder.GameSettings().IsKeyboardAllowed() && choice[i].isButton)
            {
                GUI.skin = dp.selectSkin;
            }
            v = choice[i].leftSize;
            float cHeight = choice[i].rightSize.y;
            if(cHeight > v.y) v.y = cHeight;
            cbounds = new Rect(xPos, yPos, colWidth, v.y);
            if(dp.choiceDefineWidth)
            {
                cbounds.x = cOffsetX;
                cbounds.width = dp.choiceWidth;
            }
            this.choicePositions[i].x = cbounds.x+this.windowRect.x+textPosition.bounds.x;
            this.choicePositions[i].y = cbounds.y+this.windowRect.y+textPosition.bounds.y;
            if(v.x > colWidth) v.x = colWidth-(2*dp.choicePadding.x);
            this.choiceSizes[i].x = cbounds.width;
            this.choiceSizes[i].y = cbounds.height;

            if(choice[i].isButton)
            {
                if(GUI.Button(cbounds, ""))
                {
                    this.selection = i;
                    if(!choice[i].doubleClick &&
                        (!choice[i].selectFirst || lastSelection == this.selection))
                    {
                        lh.PressOk();
                        this.windowPress = true;
                    }
                    else if(choice[i].selectFirst)
                    {
                        GameHandler.ChangeHappened(0, 0, 0);
                    }
                }
            }

            if(this.bar != null)
            {
                for(int j=0; j<this.bar.Length; j++)
                {
                    this.bar[j].ShowBar(i, new Vector2(cbounds.x, cbounds.y));
                }
            }

            // left
            imageWidth = 0;
            textAdd = 0;
            if(choice[i].content.image)
            {
                textStyle.alignment = TextAnchor.MiddleLeft;
                GUI.Label(new Rect(cbounds.x+dp.choicePadding.x, cbounds.y, v.x, v.y),
                        new GUIContent(choice[i].content.image), textStyle);
                imageWidth = choice[i].content.image.width;
                textAdd = textStyle.CalcSize(new GUIContent(".")).x;
                textStyle.alignment = TextAnchor.UpperLeft;
            }

            if(choice[i].leftLabel != null)
            {
                for(int j=0; j<choice[i].leftLabel.label.Length; j++)
                {
                    Rect b = new Rect(cbounds.x+choice[i].leftLabel.label[j].bounds.x + imageWidth+dp.choicePadding.x+textAdd,
                                        cbounds.y+choice[i].leftLabel.label[j].bounds.y,
                                        cbounds.width,
                                        cbounds.height);
                    if(dp.showShadow)
                    {
                        shadowStyle.normal.textColor = choice[i].leftLabel.label[j].shadowColor;
                        GUI.Label(
                            new Rect(b.x + dp.shadowOffset.x,
                                        b.y + dp.shadowOffset.y,
                                        b.width,
                                        b.height),
                                choice[i].leftLabel.label[j].content, shadowStyle);
                    }
                    textStyle.normal.textColor = choice[i].leftLabel.label[j].textColor;
                    GUI.Label(b, choice[i].leftLabel.label[j].content, textStyle);
                }
            }

            // right
            if(choice[i].rightLabel != null)
            {
                float xAdd = 0;
                if(choice[i].alignRightSide) xAdd = cbounds.x+cbounds.width-maxRightWidth-dp.choicePadding.x;
                else xAdd = cbounds.x+cbounds.width-choice[i].rightSize.x-dp.choicePadding.x;

                for(int j=0; j<choice[i].rightLabel.label.Length; j++)
                {
                    Rect b = new Rect(xAdd+choice[i].rightLabel.label[j].bounds.x,
                                        cbounds.y+choice[i].rightLabel.label[j].bounds.y,
                                        choice[i].rightLabel.label[j].bounds.width,
                                        choice[i].rightLabel.label[j].bounds.height);
                    if(dp.showShadow)
                    {
                        shadowStyle.normal.textColor = choice[i].rightLabel.label[j].shadowColor;
                        GUI.Label(
                            new Rect(b.x + dp.shadowOffset.x,
                                        b.y + dp.shadowOffset.y,
                                        b.width,
                                        b.height),
                                choice[i].rightLabel.label[j].content, shadowStyle);
                    }
                    textStyle.normal.textColor = choice[i].rightLabel.label[j].textColor;
                    GUI.Label(b, choice[i].rightLabel.label[j].content, textStyle);
                }
            }

            if(this.selection == i && dp.skin)
            {
                GUI.skin = dp.skin;
            }
            if(ColumnFill.VERTICAL.Equals(colFill) || i == choice.Length-1) yPos += v.y;
            if(yPos > maxYPos) maxYPos = yPos;
            counter++;

            c = GUI.backgroundColor;
            c.a = 1;
            GUI.backgroundColor = c;
            c = GUI.color;
            c.a = 1;
            GUI.color = c;
        }
        yPos = maxYPos;

        this.selectionHeight = v.y + dp.columnSpacing;
        if(dp.autoCollapse)
        {
            this.newHeight = yPos + dp.boxPadding.y + dp.boxPadding.w;
            if(this.newHeight > 0) dp.boxBounds.height = this.newHeight;
        }
        GUI.EndGroup();
        if(dp.scrollable)
        {
            GUI.EndScrollView();
            this.scrollSize = yPos;
        }
        GUI.EndGroup();
    }
Esempio n. 2
0
    public void CreateContent(DialoguePosition dp, string name, string text, ChoiceContent[] choices, SpeakerPortrait speakerPortrait, StatusBar[] bar)
    {
        this.dp = dp;
        // if same content > exit, nothing to do
        if(this.EqualContent(text, choices))
        {
            bool change = false;
            for(int i=0; i<this.choice.Length; i++)
            {
                if(this.choice[i].ActiveChange(dp, choices[i].active))
                {
                    change = true;
                    this.contentTexture = this.choice[i].SetTexture(this.contentTexture, dp, i==this.selection);
                }
            }
            if(change) this.contentTexture.Apply();
            return;
        }

        this.text = text;
        this.speakerPortrait = speakerPortrait;
        this.bar = bar;
        TextPosition textPosition = new TextPosition(dp.boxBounds, dp.boxPadding, dp.lineSpacing);
        textPosition.bounds.width -= (dp.boxPadding.x + dp.boxPadding.z);
        textPosition.bounds.height -= (dp.boxPadding.y + dp.boxPadding.w);

        text = MultiLabel.ReplaceSpecials(text);
        this.content = new MultiContent(text, dp);
        if(choices != null)
        {
            this.choice = choices;
            this.choicePositions = new Vector2[choices.Length];
            this.choiceSizes = new Vector2[choices.Length];
            this.maxSelection = choices.Length;
            for(int i=0; i<this.choice.Length; i++)
            {
                this.choice[i].InitContent(dp);
            }
        }
        else
        {
            this.choice = null;
            this.maxSelection = 0;
        }

        float contentHeightAdd = 0;
        if(this.choice != null)
        {
            colFill = dp.columnFill;
            if(ColumnFill.VERTICAL.Equals(colFill))
            {
                maxCol = (int)Mathf.Ceil(((float)choice.Length) / ((float)dp.choiceColumns));
                colCount = dp.choiceColumns;
            }
            else
            {
                maxCol = dp.choiceColumns;
                colCount = (int)Mathf.Ceil(((float)choice.Length) / ((float)dp.choiceColumns));
            }

            float addHlp = 0;
            if(dp.choiceColumns > 1)
            {
                for(int i=0; i<this.choice.Length; i++)
                {
                    if(addHlp < this.choice[i].leftSize.y) addHlp = this.choice[i].leftSize.y;
                    if(addHlp < this.choice[i].rightSize.y) addHlp = this.choice[i].rightSize.y;
                    if(addHlp < this.choice[i].titleSize.y) addHlp = this.choice[i].titleSize.y;
                }
                if(ColumnFill.VERTICAL.Equals(colFill))
                {
                    contentHeightAdd = addHlp*maxCol+dp.columnSpacing*(maxCol-1);
                }
                else
                {
                    contentHeightAdd = addHlp*colCount+dp.columnSpacing*(colCount-1);
                }
            }
            else
            {
                for(int i=0; i<this.choice.Length; i++)
                {
                    addHlp = this.choice[i].leftSize.y;
                    if(addHlp < this.choice[i].rightSize.y) addHlp = this.choice[i].rightSize.y;
                    if(addHlp < this.choice[i].titleSize.y) addHlp = this.choice[i].titleSize.y;
                    contentHeightAdd += addHlp;
                    if(i < this.choice.Length-1) contentHeightAdd += dp.columnSpacing;
                }
            }
        }

        if(dp.autoCollapse && !DataHolder.GameSettings().noAutoCollapse)
        {
            dp.boxBounds.height = this.content.yPos + dp.boxPadding.y + dp.boxPadding.w + contentHeightAdd;
            textPosition.bounds.height = this.content.yPos + contentHeightAdd;
        }
        this.addScroll = false;
        if(dp.scrollable && (this.content.yPos + contentHeightAdd) > textPosition.bounds.height)
        {
            textPosition.bounds.height = this.content.yPos + contentHeightAdd;
            textPosition.bounds.width -= dp.skin.verticalScrollbarThumb.fixedWidth;
            this.addScroll = true;
        }

        Rect b = this.AddBox(textPosition);
        float p2OffsetY = this.AddContent(textPosition);
        this.AddScroll(b, p2OffsetY, textPosition);
        this.AddName(name);
        this.AddOk();
        this.newTextures = true;
    }
Esempio n. 3
0
    public Vector3 CreateTextures(DialoguePosition dp, int i, int maxCol, ColumnFill colFill, float storedYPos, 
			Vector3 pos, float colWidth, float choiceStartX, float maxRightWidth, bool last, bool center, StatusBar[] bar)
    {
        this.selectFirst = dp.selectFirst;
        float cOffsetX = 0;
        if(dp.choiceDefineWidth)
        {
            cOffsetX = dp.choiceOffsetX*i;
            colWidth = dp.choiceWidth;
        }

        float tHeight = this.titleSize.y;
        if(this.leftSize.y > tHeight) tHeight = this.leftSize.y;
        if(this.rightSize.y > tHeight) tHeight = this.rightSize.y;
        Texture2D tex = TextureDrawer.GetCleanTexture((int)(cOffsetX+colWidth+choiceStartX), (int)tHeight);
        Texture2D texSel = null;

        if(dp.selectSkin && this.isButton)
        {
            texSel = TextureDrawer.GetCleanTexture(tex.width, tex.height);
        }

        this.buttonBounds = new Rect(choiceStartX+cOffsetX, 0, tex.width-choiceStartX-cOffsetX, tex.height);
        if(this.isButton)
        {
            tex = TextureDrawer.SetImageTexture(tex, this.buttonBounds,
                    GameHandler.GetSkin(dp.skin).button);
            if(texSel != null) texSel = TextureDrawer.SetImageTexture(texSel, this.buttonBounds,
                        GameHandler.GetSkin(dp.selectSkin).button);
        }

        if(pos.z >= maxCol)
        {
            pos.z = 0;
            if(ColumnFill.VERTICAL.Equals(colFill))
            {
                pos.y = storedYPos;
                pos.x += colWidth + dp.columnSpacing + choiceStartX;
            }
            else
            {
                pos.x = choiceStartX;
                pos.y += dp.columnSpacing;
            }
        }
        else if(i > 0)
        {
            if(ColumnFill.VERTICAL.Equals(colFill))
            {
                pos.y +=  dp.columnSpacing;
            }
            else
            {
                pos.x += colWidth + dp.columnSpacing + choiceStartX;
            }
        }
        this.textureBounds = new Rect(pos.x-choiceStartX, pos.y, tex.width, tex.height);

        float imageWidth = 0;
        float textAdd = 0;
        GUIFont font = DataHolder.Fonts().GetFont(dp.skin.font);
        GUIFont fontSel = null;
        if(texSel != null && dp.selectSkin.font != null) fontSel = DataHolder.Fonts().GetFont(dp.selectSkin.font);

        // title
        if(choiceStartX > 0 && this.title != null && "" != this.title.text)
        {
            if(this.title.image)
            {
                Texture2D tex2 = this.title.image as Texture2D;
                Rect b = new Rect(cOffsetX+dp.choicePadding.x, (tex.height-tex2.height)/2, tex2.width, tex2.height);
                b.y = tex.height-b.y-b.height;
                tex = TextureDrawer.AddTexture(tex, b, tex2.GetPixels());
                if(texSel != null) texSel = TextureDrawer.AddTexture(texSel, b, tex2.GetPixels());

                imageWidth = this.title.image.width+dp.choicePadding.x;
                textAdd = font.GetTextSize(" ").x;
            }
            for(int j=0; j<this.titleLabel.label.Length; j++)
            {
                this.titleLabel.label[j].bounds.x += cOffsetX+imageWidth+textAdd;
                tex = this.titleLabel.label[j].AddTextureNoOffset(font, tex, dp);
                if(texSel != null) texSel = this.titleLabel.label[j].AddTextureNoOffset(fontSel, texSel, dp);
            }
        }

        if(bar != null)
        {
            for(int j=0; j<bar.Length; j++)
            {
                tex = bar[j].AddBar(tex, i, new Vector2(this.buttonBounds.x, this.buttonBounds.y));
                if(texSel != null) texSel = bar[j].AddBar(texSel, i, new Vector2(this.buttonBounds.x, this.buttonBounds.y));
            }
        }

        // left
        float centerOffset = 0;
        if(center)
        {
            centerOffset = ((this.buttonBounds.width-this.leftSize.x)/2)-dp.choicePadding.x;
        }
        imageWidth = 0;
        textAdd = 0;
        if(this.content.image)
        {
            Texture2D tex2 = this.content.image as Texture2D;
            Rect b = new Rect(this.buttonBounds.x+dp.choicePadding.x+centerOffset,
                    (tex.height-tex2.height)/2, tex2.width, tex2.height);
            b.y = tex.height-b.y-b.height;
            tex = TextureDrawer.AddTexture(tex, b, tex2.GetPixels());
            if(texSel != null) texSel = TextureDrawer.AddTexture(texSel, b, tex2.GetPixels());

            imageWidth = this.content.image.width+dp.choicePadding.x;
            textAdd = font.GetTextSize(" ").x;
        }

        if(this.leftLabel != null)
        {
            for(int j=0; j<this.leftLabel.label.Length; j++)
            {
                this.leftLabel.label[j].bounds.x += this.buttonBounds.x+imageWidth+textAdd+dp.choicePadding.x+centerOffset;
                tex = this.leftLabel.label[j].AddTextureNoOffset(font, tex, dp);
                if(texSel != null) texSel = this.leftLabel.label[j].AddTextureNoOffset(fontSel, texSel, dp);
            }
        }

        // right
        if(this.rightLabel != null)
        {
            float xAdd = 0;
            if(this.alignRightSide) xAdd = this.buttonBounds.x+this.buttonBounds.width-maxRightWidth-dp.choicePadding.x;
            else xAdd = this.buttonBounds.x+this.buttonBounds.width-this.rightSize.x-dp.choicePadding.x;

            for(int j=0; j<this.rightLabel.label.Length; j++)
            {
                this.rightLabel.label[j].bounds.x += xAdd;
                tex = this.rightLabel.label[j].AddTextureNoOffset(font, tex, dp);
                if(texSel != null) texSel = this.rightLabel.label[j].AddTextureNoOffset(fontSel, texSel, dp);
            }
        }

        if(ColumnFill.VERTICAL.Equals(colFill) || last) pos.y += tHeight;
        pos.z += 1;

        this.normalTexture = tex.GetPixels();
        if(texSel != null) this.selectTexture = texSel.GetPixels();

        if(this.dragable || this.doubleClick)
        {
            float w = this.leftSize.x+this.rightSize.x+dp.choicePadding.x*2+font.GetTextSize("   ").x;
            if(w > this.buttonBounds.width)
            {
                this.dragTexture = TextureDrawer.GetCleanTexture(
                        TextureDrawer.GetNextPowerOfTwo(this.buttonBounds.width),
                        TextureDrawer.GetNextPowerOfTwo(this.buttonBounds.height));

                this.dragTexture = TextureDrawer.SetPixels(this.dragTexture,
                        tex.GetPixels((int)this.buttonBounds.x, (int)this.buttonBounds.y,
                            (int)this.buttonBounds.width, (int)this.buttonBounds.height),
                        (int)((this.dragTexture.width-this.buttonBounds.width)/2),
                        (int)((this.dragTexture.height-this.buttonBounds.height)/2), (int)this.buttonBounds.width,
                        (int)this.buttonBounds.height);

                this.halfDrag = new Vector2(this.buttonBounds.width/2, this.buttonBounds.height/2);
            }
            else
            {
                this.dragTexture = TextureDrawer.GetCleanTexture(
                        TextureDrawer.GetNextPowerOfTwo(w),
                        TextureDrawer.GetNextPowerOfTwo(this.buttonBounds.height));

                Vector2 offset = new Vector2((this.dragTexture.width-w)/2,
                        (this.dragTexture.height-this.buttonBounds.height)/2);
                float rw = this.rightSize.x+dp.choicePadding.x;
                float lw = w-rw;

                this.dragTexture = TextureDrawer.SetPixels(this.dragTexture,
                        (int)offset.x, (int)offset.y, tex, (int)this.buttonBounds.x,
                        (int)this.buttonBounds.y, (int)lw, (int)this.buttonBounds.height);

                this.dragTexture = TextureDrawer.SetPixels(this.dragTexture,
                        (int)(offset.x+lw-1), (int)offset.y, tex,
                        (int)(this.buttonBounds.x+this.buttonBounds.width-rw+1),
                        (int)this.buttonBounds.y, (int)rw, (int)this.buttonBounds.height);

                this.halfDrag = new Vector2(w/2, this.buttonBounds.height/2);
            }
            this.dragTexture.Apply();
        }

        if(!this.active)
        {
            this.normalTexture = TextureDrawer.MultiplyAlpha(this.normalTexture, dp.choiceInactiveAlpha);
            if(texSel != null) this.selectTexture = TextureDrawer.MultiplyAlpha(this.selectTexture, dp.choiceInactiveAlpha);
        }
        return new Vector3(pos.x, pos.y, pos.z);
    }