ShowPortrait() public method

public ShowPortrait ( ) : void
return void
Esempio n. 1
0
    public string ShowText(DialoguePosition dp, string text, string name, SpeakerPortrait speakerPortrait)
    {
        if(dp.skin) GUI.skin = dp.skin;

        Color c = GUI.backgroundColor;
        c.a = dp.alpha;
        GUI.backgroundColor = c;
        c = GUI.color;
        c.a = dp.alpha;
        GUI.color = c;

        if(this.newContent || this.content == null)
        {
            GUIStyle shadowStyle = new GUIStyle(GUI.skin.label);
            shadowStyle.normal.textColor = DataHolder.Color(1);
            GUIStyle textStyle = new GUIStyle(GUI.skin.label);
            textStyle.wordWrap = false;
            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, textStyle, shadowStyle, textPosition, dp.scrollable);
            this.newContent = false;
        }

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

        this.windowRect.x = dp.currentPos.x;
        this.windowRect.y = dp.currentPos.y;
        this.windowRect.width = dp.boxBounds.width;
        this.windowRect.height = dp.boxBounds.height;

        int windowID = dp.GetWindowID();

        this.dp = dp;
        this.text = text;
        this.speakerPortrait = speakerPortrait;

        if(dp.isDragWindow)
        {
            this.windowRect = GUI.Window(windowID, this.windowRect, TextWindow, name);
            if(dp.currentPos.x != this.windowRect.x || dp.currentPos.y != this.windowRect.y)
            {
                if(dp.focusable) GameHandler.WindowHandler().SetFocusID(windowID);

                if(DataHolder.GameSettings().saveWindowDrag)
                {
                    if(this.windowRect.x < 0) this.windowRect.x = 0;
                    else if((this.windowRect.x+this.windowRect.width) > DataHolder.GameSettings().defaultScreen.x)
                    {
                        this.windowRect.x = DataHolder.GameSettings().defaultScreen.x-this.windowRect.width;
                    }
                    if(this.windowRect.y < 0) this.windowRect.y = 0;
                    else if((this.windowRect.y+this.windowRect.height) > DataHolder.GameSettings().defaultScreen.y)
                    {
                        this.windowRect.y = DataHolder.GameSettings().defaultScreen.y-this.windowRect.height;
                    }
                }
                dp.currentPos.x = this.windowRect.x;
                dp.currentPos.y = this.windowRect.y;
                dp.SetBasePosition(this.windowRect.x, this.windowRect.y);
            }
        }
        else
        {
            if(name != "")
            {
                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.nameSkin) GUI.skin = dp.nameSkin;
                Vector2 v = textStyle.CalcSize(new GUIContent(name));
                TextPosition namePosition = new TextPosition(dp.nameBounds, dp.namePadding, 0);
                namePosition.bounds.x = dp.currentPos.x+dp.nameOffset.x;
                namePosition.bounds.y = dp.currentPos.y+dp.nameOffset.y;
                namePosition.bounds.width = v.x + dp.namePadding.x + dp.namePadding.z;
                if(dp.showNameBox) GUI.Box(namePosition.bounds, "");
                namePosition.bounds.x += dp.namePadding.x;
                namePosition.bounds.y += dp.namePadding.y;
                namePosition.bounds.width -= (dp.namePadding.x + dp.namePadding.z);
                namePosition.bounds.height -= (dp.namePadding.y + dp.namePadding.w);
                if(dp.showShadow)
                {
                    GUI.Label(
                        new Rect(namePosition.bounds.x + dp.shadowOffset.x, namePosition.bounds.y + dp.shadowOffset.y,
                                namePosition.bounds.width, namePosition.bounds.height),
                        name, shadowStyle);
                }

                GUI.Label(new Rect(namePosition.bounds.x, namePosition.bounds.y, namePosition.bounds.width, namePosition.bounds.height),
                        name, textStyle);
                if(dp.skin) GUI.skin = dp.skin;
            }

            if(dp.showBox)
            {
                this.windowRect = GUI.Window(windowID, this.windowRect, TextWindow, "", "box");
            }
            else
            {
                GUI.BeginGroup(this.windowRect);
                this.TextWindow(-1);
                GUI.EndGroup();
            }
        }

        c = GUI.backgroundColor;
        c.a = 1;
        GUI.backgroundColor = c;
        c = GUI.color;
        c.a = 1;
        GUI.color = c;

        if(this.content.textPos >= this.content.originalText.Length-1)
            return "";
        else
            return this.GetColorString(this.content.currentColor)+this.GetShadowColorString(this.content.shadowColor)+
                this.content.originalText.Substring(this.content.textPos, this.content.originalText.Length-this.content.textPos);
    }
Esempio n. 2
0
    public bool ShowChoice(DialoguePosition dp, string text, string name, ChoiceContent[] choices, SpeakerPortrait speakerPortrait, StatusBar[] bar)
    {
        bool press = false;
        if(dp.skin) GUI.skin = dp.skin;

        this.maxSelection = choices.Length;

        Color c = GUI.backgroundColor;
        c.a = dp.alpha;
        GUI.backgroundColor = c;
        c = GUI.color;
        c.a = dp.alpha;
        GUI.color = c;

        if(this.newContent || this.content == null)
        {
            GUIStyle shadowStyle = new GUIStyle(GUI.skin.label);
            shadowStyle.normal.textColor = DataHolder.Color(1);
            GUIStyle textStyle = new GUIStyle(GUI.skin.label);
            textStyle.wordWrap = false;
            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, textStyle, shadowStyle, textPosition, dp.scrollable);
            this.choice = choices;
            this.choicePositions = new Vector2[choices.Length];
            this.choiceSizes = new Vector2[choices.Length];
            for(int i=0; i<choice.Length; i++)
            {
                choice[i].InitContent(textStyle, shadowStyle, textPosition, dp.scrollable, dp.selectFirst);
                if(dp.showShadow) choice[i].SetDragGUI(dp.skin, textStyle, shadowStyle, dp.choicePadding.x, dp.shadowOffset);
                else choice[i].SetDragGUI(dp.skin, textStyle, null, dp.choicePadding.x, dp.shadowOffset);
                this.choicePositions[i] = new Vector2(0, 0);
                this.choiceSizes[i] = new Vector2(0, 0);
            }
            this.newContent = false;
        }

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

        this.windowRect.x = dp.currentPos.x;
        this.windowRect.y = dp.currentPos.y;
        this.windowRect.width = dp.boxBounds.width;
        this.windowRect.height = dp.boxBounds.height;

        int windowID = dp.GetWindowID();

        this.dp = dp;
        this.text = text;
        this.speakerPortrait = speakerPortrait;
        this.bar = bar;

        if(dp.isDragWindow)
        {
            this.windowRect = GUI.Window(windowID, this.windowRect, ChoiceWindow, name);
            if(dp.currentPos.x != this.windowRect.x || dp.currentPos.y != this.windowRect.y)
            {
                if(dp.focusable) GameHandler.WindowHandler().SetFocusID(windowID);

                if(DataHolder.GameSettings().saveWindowDrag)
                {
                    if(this.windowRect.x < 0) this.windowRect.x = 0;
                    else if((this.windowRect.x+this.windowRect.width) > DataHolder.GameSettings().defaultScreen.x)
                    {
                        this.windowRect.x = DataHolder.GameSettings().defaultScreen.x-this.windowRect.width;
                    }
                    if(this.windowRect.y < 0) this.windowRect.y = 0;
                    else if((this.windowRect.y+this.windowRect.height) > DataHolder.GameSettings().defaultScreen.y)
                    {
                        this.windowRect.y = DataHolder.GameSettings().defaultScreen.y-this.windowRect.height;
                    }
                }
                dp.currentPos.x = this.windowRect.x;
                dp.currentPos.y = this.windowRect.y;
                dp.SetBasePosition(this.windowRect.x, this.windowRect.y);
            }
        }
        else
        {
            if(name != "")
            {
                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.nameSkin) GUI.skin = dp.nameSkin;
                Vector2 v = textStyle.CalcSize(new GUIContent(name));
                TextPosition namePosition = new TextPosition(dp.nameBounds, dp.namePadding, 0);
                namePosition.bounds.x = dp.currentPos.x+dp.nameOffset.x;
                namePosition.bounds.y = dp.currentPos.y+dp.nameOffset.y;
                namePosition.bounds.width = v.x + dp.namePadding.x + dp.namePadding.z;
                if(dp.showNameBox) GUI.Box(namePosition.bounds, "");
                namePosition.bounds.x += dp.namePadding.x;
                namePosition.bounds.y += dp.namePadding.y;
                namePosition.bounds.width -= (dp.namePadding.x + dp.namePadding.z);
                namePosition.bounds.height -= (dp.namePadding.y + dp.namePadding.w);
                if(dp.showShadow)
                {
                    GUI.Label(
                        new Rect(namePosition.bounds.x + dp.shadowOffset.x, namePosition.bounds.y + dp.shadowOffset.y,
                                namePosition.bounds.width, namePosition.bounds.height),
                        name, shadowStyle);
                }

                GUI.Label(new Rect(namePosition.bounds.x, namePosition.bounds.y, namePosition.bounds.width, namePosition.bounds.height),
                        name, textStyle);
                if(dp.skin) GUI.skin = dp.skin;
            }

            if(dp.showBox)
            {
                this.windowRect = GUI.Window(windowID, this.windowRect, ChoiceWindow, "", "box");
            }
            else
            {
                GUI.BeginGroup(this.windowRect);
                this.ChoiceWindow(-1);
                GUI.EndGroup();
            }
        }

        if(this.windowPress)
        {
            press = true;
            this.windowPress = false;
        }

        c = GUI.backgroundColor;
        c.a = 1;
        GUI.backgroundColor = c;
        c = GUI.color;
        c.a = 1;
        GUI.color = c;

        return press;
    }