Beispiel #1
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;
    }
Beispiel #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;
    }
Beispiel #3
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);
    }
Beispiel #4
0
 /*
 ============================================================================
 ORK GUI functions
 ============================================================================
 */
 // only for no autocollapse and no scrollable
 public void ReShow(string text)
 {
     text = MultiLabel.ReplaceSpecials(text);
     this.content = new MultiContent(text, dp);
     this.contentTexture = TextureDrawer.SetPixelColors(this.contentTexture, new Rect(dp.contentP2Offset.x,
             dp.contentP2Offset.y, dp.contentBounds.width, dp.contentBounds.height), Color.clear);
     this.contentTexture = this.content.GetTexture(this.contentTexture, dp);
     this.contentTexture.Apply();
 }
Beispiel #5
0
 private Vector2 CalcSize(MultiContent mc, Texture img)
 {
     Vector2 size = Vector2.zero;
     if(mc != null)
     {
         float currentY = 0;
         float currentWidth = 0;
         float currentHeight = 0;
         for(int i=0; i<mc.label.Length; i++)
         {
             if(mc.label[i].bounds.y == currentY)
             {
                 currentWidth = mc.label[i].bounds.x+mc.label[i].bounds.width;
                 if(mc.label[i].bounds.height > currentHeight)
                     currentHeight = mc.label[i].bounds.height;
             }
             else
             {
                 currentY = mc.label[i].bounds.y;
                 size.y += currentHeight;
                 if(currentWidth > size.x)
                     size.x = currentWidth;
                 currentWidth = mc.label[i].bounds.x+mc.label[i].bounds.width;
             }
         }
         if(currentWidth > size.x) size.x = currentWidth;
         size.y = currentY+currentHeight;
     }
     if(img != null)
     {
         size.x += img.width;
         if(img.height > size.y) size.y = img.height;
         size.x += mc.font.GetTextSize(" ").x;
     }
     return size;
 }
Beispiel #6
0
 private Vector2 CalcSize(MultiContent mc, Texture img, GUIStyle textStyle)
 {
     Vector2 size = Vector2.zero;
     if(mc != null)
     {
         float currentY = 0;
         float currentWidth = 0;
         float currentHeight = 0;
         for(int i=0; i<mc.label.Length; i++)
         {
             if(mc.label[i].bounds.y == currentY)
             {
                 currentWidth = mc.label[i].bounds.x+mc.label[i].bounds.width;
                 if(mc.label[i].bounds.height > currentHeight)
                     currentHeight = mc.label[i].bounds.height;
             }
             else
             {
                 currentY = mc.label[i].bounds.y;
                 size.y += currentHeight;
                 if(currentWidth > size.x)
                     size.x = currentWidth;
                 currentWidth = mc.label[i].bounds.x+mc.label[i].bounds.width;
             }
         }
         if(currentWidth > size.x) size.x = currentWidth;
         size.y = currentY+currentHeight;
     }
     if(img != null)
     {
         Vector2 v = textStyle.CalcSize(new GUIContent(img));
         size.x += v.x;
         if(v.y > size.y) size.y = v.y;
         size.x += textStyle.CalcSize(new GUIContent(".")).x;
     }
     return size;
 }
Beispiel #7
0
 /*
 ============================================================================
 ORK GUI system functions
 ============================================================================
 */
 public void InitContent(DialoguePosition dp)
 {
     this.selectFirst = dp.selectFirst;
     if(this.title != null && "" != this.title.text)
     {
         this.titleLabel = new MultiContent(this.title.text, dp);
         this.titleSize = this.CalcSize(this.titleLabel, this.title.image);
     }
     if(this.content != null && "" != this.content.text)
     {
         this.leftLabel = new MultiContent(this.content.text, dp);
         this.leftSize = this.CalcSize(this.leftLabel, this.content.image);
     }
     else
     {
         this.leftLabel = new MultiContent(" ", dp);
         this.leftSize = this.CalcSize(this.leftLabel, this.content.image);
     }
     if("" != this.info)
     {
         this.rightLabel = new MultiContent(this.info, dp);
         this.rightSize = this.CalcSize(this.rightLabel, null);
         this.alignRightSide = this.info.IndexOf("#px", 0) != -1;
     }
 }
Beispiel #8
0
 /*
 ============================================================================
 Unity GUI functions
 ============================================================================
 */
 public void InitContent(GUIStyle textStyle, GUIStyle shadowStyle, TextPosition textPosition, bool scrollable, bool sf)
 {
     this.selectFirst = sf;
     if(this.title != null && "" != this.title.text)
     {
         this.titleLabel = new MultiContent(this.title.text, textStyle, shadowStyle, textPosition, scrollable);
         this.titleSize = this.CalcSize(this.titleLabel, this.title.image, textStyle);
     }
     if(this.content != null && "" != this.content.text)
     {
         this.leftLabel = new MultiContent(this.content.text, textStyle, shadowStyle, textPosition, scrollable);
         this.leftSize = this.CalcSize(this.leftLabel, this.content.image, textStyle);
     }
     else
     {
         this.leftLabel = new MultiContent(" ", textStyle, shadowStyle, textPosition, scrollable);
         this.leftSize = this.CalcSize(this.leftLabel, this.content.image, textStyle);
     }
     if("" != this.info)
     {
         this.rightLabel = new MultiContent(this.info, textStyle, shadowStyle, textPosition, scrollable);
         this.rightSize = this.CalcSize(this.rightLabel, null, textStyle);
         this.alignRightSide = this.info.IndexOf("#px", 0) != -1;
     }
 }