public DPSprite AddDPSprite(DialoguePosition dp) { GameObject tmp = GameObject.CreatePrimitive(PrimitiveType.Plane); tmp.name = "_DPSprite"; DPSprite sprite = (DPSprite)tmp.AddComponent("DPSprite"); sprite.dialoguePosition = dp; return (DPSprite)this.AddSprite(sprite); }
public DialoguePosition GetCopy(int index) { if(index < 0 || index >= position.Length) index = 0; DialoguePosition p = new DialoguePosition(); p.realID = index; p.boxBounds = new Rect(position[index].boxBounds.x, position[index].boxBounds.y, position[index].boxBounds.width, position[index].boxBounds.height); p.boxPadding = new Vector4(position[index].boxPadding.x, position[index].boxPadding.y, position[index].boxPadding.z, position[index].boxPadding.w); p.lineSpacing = position[index].lineSpacing; p.showBox = position[index].showBox; p.nameBounds = new Rect(position[index].nameBounds.x, position[index].nameBounds.y, position[index].nameBounds.width, position[index].nameBounds.height); p.namePadding = new Vector4(position[index].namePadding.x, position[index].namePadding.y, position[index].namePadding.z, position[index].namePadding.w); p.showNameBox = position[index].showNameBox; p.showShadow = position[index].showShadow; p.shadowOffset = new Vector2(position[index].shadowOffset.x, position[index].shadowOffset.y); p.scrollable = position[index].scrollable; p.autoCollapse = position[index].autoCollapse; p.oneline = position[index].oneline; p.alignCenter = position[index].alignCenter; p.hideButton = position[index].hideButton; p.fadeIn = position[index].fadeIn; p.fadeInTime = position[index].fadeInTime; p.fadeInInterpolation = position[index].fadeInInterpolation; p.fadeOut = position[index].fadeOut; p.fadeOutTime = position[index].fadeOutTime; p.fadeOutInterpolation = position[index].fadeOutInterpolation; p.choicePadding = new Vector2(position[index].choicePadding.x, position[index].choicePadding.y); p.moveIn = position[index].moveIn; p.moveInTime = position[index].moveInTime; p.moveInInterpolation = position[index].moveInInterpolation; p.moveInStart = new Vector2(position[index].moveInStart.x, position[index].moveInStart.y); p.moveOut = position[index].moveOut; p.moveOutTime = position[index].moveOutTime; p.moveOutInterpolation = position[index].moveOutInterpolation; p.moveOutStart = new Vector2(position[index].moveOutStart.x, position[index].moveOutStart.y); p.choiceInactiveAlpha = position[index].choiceInactiveAlpha; p.choiceDefineWidth = position[index].choiceDefineWidth; p.choiceWidth = position[index].choiceWidth; p.choiceOffsetX = position[index].choiceOffsetX; p.skinName = position[index].skinName; p.selectSkinName = position[index].selectSkinName; p.okSkinName = position[index].okSkinName; p.nameSkinName = position[index].nameSkinName; p.choiceColumns = position[index].choiceColumns; p.columnSpacing = position[index].columnSpacing; p.columnFill = position[index].columnFill; p.isDragWindow = position[index].isDragWindow; p.selectFirst = position[index].selectFirst; p.dragBounds = new Rect(position[index].dragBounds.x, position[index].dragBounds.y, position[index].dragBounds.width, position[index].dragBounds.height); return p; }
// Start is called before the first frame update void Awake() { if (!inst) { inst = this; } dialoguePosition = GetComponent <DialoguePosition>(); dialogueText = GetComponent <DialogueText>(); dialogueArt = GetComponent <DialogueArt>(); dialogueSound = GetComponent <DialogueSound>(); audioSource = GetComponent <AudioSource>(); }
public Texture2D AddTextureNoOffset(GUIFont font, Texture2D texture, DialoguePosition dp) { if(this.content.image != null) { Texture2D tex = this.content.image as Texture2D; Rect b = new Rect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height); b.x += dp.boxPadding.x; b.y = texture.height-b.y-b.height; texture = TextureDrawer.AddTexture(texture, b, tex.GetPixels()); } else texture = font.AddTextTexture(texture, this, 0, Vector2.zero, dp.showShadow, dp.shadowOffset); return texture; }
/* ============================================================================ ORK GUI functions ============================================================================ */ public void StoreMenu(DialoguePosition dp) { if(BattleMenuMode.BASE.Equals(this.mode)) this.baseDP = dp; else if(BattleMenuMode.SKILL.Equals(this.mode)) this.skillDP = dp; else if(BattleMenuMode.ITEM.Equals(this.mode)) DataHolder.BattleMenu().itemDP = dp; else if(BattleMenuMode.TARGET.Equals(this.mode)) DataHolder.BattleMenu().targetDP = dp; }
public void RemovePosition(DialoguePosition dp) { this.shown = ArrayHelper.Remove(dp, this.shown); }
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; }
public string ShowText(DialoguePosition dp, string text, string name) { return this.ShowText(dp, text, name, null); }
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); }
public static DialoguePosition[] Remove(DialoguePosition c, DialoguePosition[] list) { ArrayList tmp = new ArrayList(); foreach(DialoguePosition str in list) tmp.Add(str); tmp.Remove(c); return tmp.ToArray(typeof(DialoguePosition)) as DialoguePosition[]; }
public Texture2D GetTexture(Texture2D texture, DialoguePosition dp, float offsetX, float offsetY) { for(int i=0; i<this.label.Length; i++) { this.label[i].bounds.x += offsetX; this.label[i].bounds.y += offsetY; texture = this.AddLabel(texture, dp, i); this.label[i].bounds.x -= offsetX; this.label[i].bounds.y -= offsetY; this.addNext = i+1; } return texture; }
public Texture2D GetTexture(Texture2D texture, DialoguePosition dp) { float y = -1; float offsetX = 0; for(int i=0; i<this.label.Length; i++) { if(dp.oneline && dp.alignCenter && (i == 0 || this.label[i].bounds.y != y)) { y = this.label[i].bounds.y; offsetX = 0; for(int j=i; j<this.label.Length; j++) { if(y == this.label[i].bounds.y) offsetX += this.label[i].bounds.width; else break; } offsetX = (dp.contentBounds.width-offsetX)/2; } else if(!dp.oneline && this.label[i].bounds.y > dp.contentBounds.height) { break; } this.label[i].bounds.x += offsetX; texture = this.AddLabel(texture, dp, i); this.addNext = i+1; } return texture; }
public Texture2D AddNextLabel(Texture2D texture, DialoguePosition dp) { return this.AddLabel(texture, dp, this.addNext++); }
public Texture2D AddLabel(Texture2D texture, DialoguePosition dp, int i) { return this.label[i].AddTexture(this.font, texture, dp); }
/* ============================================================================ 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; } }
public string ShowOneLine(DialoguePosition dp, string text, int c1, int c2) { 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; TextPosition textPosition = new TextPosition(dp.boxBounds, dp.boxPadding, dp.lineSpacing); textPosition.bounds.x = dp.currentPos.x; textPosition.bounds.y = dp.currentPos.y; if(dp.autoCollapse && this.newHeight > 0) textPosition.bounds.height = this.newHeight; if(dp.showBox) GUI.Box(textPosition.bounds, ""); 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); GUIStyle shadowStyle = new GUIStyle(GUI.skin.label); shadowStyle.normal.textColor = DataHolder.Color(c2); GUIStyle textStyle = new GUIStyle(GUI.skin.label); textStyle.wordWrap = false; textStyle.normal.textColor = DataHolder.Color(c1); float xPos = 0; float yPos = 0; GUI.BeginGroup(textPosition.bounds); GUIContent part = new GUIContent(text); Vector2 v = textStyle.CalcSize(part); if(dp.alignCenter) { xPos = textPosition.bounds.width / 2; xPos -= v.x / 2; } if(dp.showShadow) { GUI.Label( new Rect(xPos + dp.shadowOffset.x, yPos + dp.shadowOffset.y, v.x, v.y), part, shadowStyle); } GUI.Label(new Rect(xPos, yPos, v.x, v.y), part, textStyle); yPos += v.y; GUI.EndGroup(); // show ok button on mouse control if(DataHolder.GameSettings().IsMouseAllowed() && !dp.hideButton) { Vector2 vec2 = DataHolder.GameSettings().dialogueOkSize[GameHandler.GetLanguage()]; Rect okBounds = new Rect(dp.boxBounds.x, dp.boxBounds.y, vec2.x, vec2.y); ButtonPosition buttonPos = DataHolder.GameSettings().dialogueOkPosition; if(ButtonPosition.TOP_CENTER.Equals(buttonPos) || ButtonPosition.BOTTOM_CENTER.Equals(buttonPos)) { okBounds.x += (dp.boxBounds.width - okBounds.width) / 2; } else if(ButtonPosition.TOP_RIGHT.Equals(buttonPos) || ButtonPosition.BOTTOM_RIGHT.Equals(buttonPos)) { okBounds.x += (dp.boxBounds.width - okBounds.width); } if(ButtonPosition.BOTTOM_LEFT.Equals(buttonPos) || ButtonPosition.BOTTOM_CENTER.Equals(buttonPos) || ButtonPosition.BOTTOM_RIGHT.Equals(buttonPos)) { if(dp.autoCollapse && this.newHeight > 0) okBounds.y += (this.newHeight - okBounds.height); else okBounds.y += (dp.boxBounds.height - okBounds.height); } vec2 = DataHolder.GameSettings().dialogueOkOffset[GameHandler.GetLanguage()]; okBounds.x += vec2.x; okBounds.y += vec2.y; part = new GUIContent(DataHolder.GameSettings().dialogueOkText[GameHandler.GetLanguage()]); v = textStyle.CalcSize(part); if(GUI.Button(okBounds, part)) { GameHandler.GetLevelHandler().PressOk(); } } if(dp.autoCollapse) this.newHeight = yPos + dp.boxPadding.y + dp.boxPadding.w; c = GUI.backgroundColor; c.a = 1; GUI.backgroundColor = c; c = GUI.color; c.a = 1; GUI.color = c; return ""; }
public Texture2D SetTexture(Texture2D texture, DialoguePosition dp, bool selected) { return this.SetTexture(texture, dp, dp.boxPadding, dp.contentP2Offset, selected); }
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); }
public Texture2D SetTexture(Texture2D texture, DialoguePosition dp, Vector4 padding, Vector2 p2Offset, bool selected) { if(selected && this.selectTexture != null) { texture = TextureDrawer.SetPixels(texture, this.selectTexture, (int)(p2Offset.x+padding.x+this.textureBounds.x), (int)(texture.height-this.textureBounds.y-this.textureBounds.height-p2Offset.y), (int)this.textureBounds.width, (int)this.textureBounds.height); } else { texture = TextureDrawer.SetPixels(texture, this.normalTexture, (int)(p2Offset.x+padding.x+this.textureBounds.x), (int)(texture.height-this.textureBounds.y-this.textureBounds.height-p2Offset.y), (int)this.textureBounds.width, (int)this.textureBounds.height); } return texture; }
public void Preload() { this.dp = DataHolder.DialoguePositions().GetCopy(DataHolder.GameSettings().areaNamePosition); this.dp.Preload("", DataHolder.AreaName(this.areaName), null, null, null); }
/* ============================================================================ Texture functions ============================================================================ */ public bool ActiveChange(DialoguePosition dp, bool newActive) { bool change = false; if(this.active != newActive) { this.active = newActive; if(this.active) { this.normalTexture = TextureDrawer.DivideAlpha(this.normalTexture, dp.choiceInactiveAlpha); if(this.selectTexture != null && this.selectTexture.Length > 0) { this.selectTexture = TextureDrawer.DivideAlpha(this.selectTexture, dp.choiceInactiveAlpha); } } else { this.normalTexture = TextureDrawer.MultiplyAlpha(this.normalTexture, dp.choiceInactiveAlpha); if(this.selectTexture != null && this.selectTexture.Length > 0) { this.selectTexture = TextureDrawer.MultiplyAlpha(this.selectTexture, dp.choiceInactiveAlpha); } } change = true; } return change; }
public static void SetAreaName(int id, DialoguePosition dp) { int tmp = GameHandler.Instance().areaName; GameHandler.Instance().areaName = id; if(id != tmp) { GameSettingsData gs = DataHolder.GameSettings(); if(gs.showAreaNames) { GameHandler.GetLevelHandler().ShowInfo(dp, gs.areaNameVisibleTime); } } }
public bool ShowChoice(DialoguePosition dp, string text, string name, GUIContent[] choices, SpeakerPortrait speakerPortrait) { ChoiceContent[] ch = new ChoiceContent[choices.Length]; for(int i=0; i<ch.Length; i++) { ch[i] = new ChoiceContent(choices[i]); } return this.ShowChoice(dp, text, name, ch, speakerPortrait, null); }
public Texture2D AddTextTexture(Texture2D texture, LabelContent label, DialoguePosition dp, Vector2 p2Offset) { return this.AddTextTexture(texture, label, dp.boxPadding.x, p2Offset, dp.showShadow, dp.shadowOffset); }
public bool ShowChoice(DialoguePosition dp, string text, string name, ChoiceContent[] choices) { return this.ShowChoice(dp, text, name, choices, null, null); }
/* ============================================================================ GUI click functions ============================================================================ */ public void AddPosition(DialoguePosition dp) { this.shown = ArrayHelper.Add(dp, this.shown); }
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; }
public void LoadData() { ArrayList data = XMLHandler.LoadXML(dir+filename); if(data.Count > 0) { foreach(Hashtable entry in data) { if(entry[XMLHandler.NODE_NAME] as string == DialoguePositionData.DIALOGUEPOSITIONS) { if(entry.ContainsKey(XMLHandler.NODES)) { ArrayList subs = entry[XMLHandler.NODES] as ArrayList; name = new string[subs.Count]; position = new DialoguePosition[subs.Count]; foreach(Hashtable val in subs) { if(val[XMLHandler.NODE_NAME] as string == DialoguePositionData.DIALOGUEPOSITION) { int i = int.Parse((string)val["id"]); position[i] = new DialoguePosition(); position[i].lineSpacing = int.Parse((string)val["linespacing"]); position[i].showBox = bool.Parse((string)val["showbox"]); position[i].showNameBox = bool.Parse((string)val["shownamebox"]); position[i].showShadow = bool.Parse((string)val["showshadow"]); position[i].scrollable = bool.Parse((string)val["scrollable"]); if(val.ContainsKey("autocollapse")) position[i].autoCollapse = bool.Parse((string)val["autocollapse"]); if(val.ContainsKey("oneline")) position[i].oneline = bool.Parse((string)val["oneline"]); if(val.ContainsKey("aligncenter")) position[i].alignCenter = bool.Parse((string)val["aligncenter"]); if(val.ContainsKey("hidebutton")) position[i].hideButton = bool.Parse((string)val["hidebutton"]); if(val.ContainsKey("choiceinactivealpha")) position[i].choiceInactiveAlpha = float.Parse((string)val["choiceinactivealpha"]); if(val.ContainsKey("choicecolumns")) position[i].choiceColumns = int.Parse((string)val["choicecolumns"]); if(val.ContainsKey("columnspacing")) position[i].columnSpacing = int.Parse((string)val["columnspacing"]); if(val.ContainsKey("columnfill")) position[i].columnFill = (ColumnFill)System.Enum.Parse(typeof(ColumnFill), (string)val["columnfill"]); if(val.ContainsKey("selectfirst")) position[i].selectFirst = true; if(val.ContainsKey("choicewidth")) { position[i].choiceDefineWidth = true; position[i].choiceWidth = float.Parse((string)val["choicewidth"]); position[i].choiceOffsetX = float.Parse((string)val["choiceox"]); } // fading if(val.ContainsKey("fadeintime")) { position[i].fadeIn = true; position[i].fadeInTime = float.Parse((string)val["fadeintime"]); position[i].fadeInInterpolation = (EaseType)System.Enum.Parse(typeof(EaseType), (string)val["fadeininterpolation"]); } if(val.ContainsKey("fadeouttime")) { position[i].fadeOut = true; position[i].fadeOutTime = float.Parse((string)val["fadeouttime"]); position[i].fadeOutInterpolation = (EaseType)System.Enum.Parse(typeof(EaseType), (string)val["fadeoutinterpolation"]); } // moving if(val.ContainsKey("moveintime")) { position[i].moveIn = true; position[i].moveInStart.x = float.Parse((string)val["mix"]); position[i].moveInStart.y = float.Parse((string)val["miy"]); position[i].moveInTime = float.Parse((string)val["moveintime"]); position[i].moveInInterpolation = (EaseType)System.Enum.Parse(typeof(EaseType), (string)val["moveininterpolation"]); } if(val.ContainsKey("moveouttime")) { position[i].moveOut = true; position[i].moveOutStart.x = float.Parse((string)val["mox"]); position[i].moveOutStart.y = float.Parse((string)val["moy"]); position[i].moveOutTime = float.Parse((string)val["moveouttime"]); position[i].moveOutInterpolation = (EaseType)System.Enum.Parse(typeof(EaseType), (string)val["moveoutinterpolation"]); } ArrayList s = val[XMLHandler.NODES] as ArrayList; foreach(Hashtable ht in s) { if(ht[XMLHandler.NODE_NAME] as string == DialoguePositionData.NAME) { name[i] = ht[XMLHandler.CONTENT] as string; } else if(ht[XMLHandler.NODE_NAME] as string == DialoguePositionData.SKIN) { position[i].skinName = ht[XMLHandler.CONTENT] as string; } else if(ht[XMLHandler.NODE_NAME] as string == DialoguePositionData.SELECTSKIN) { position[i].selectSkinName = ht[XMLHandler.CONTENT] as string; } else if(ht[XMLHandler.NODE_NAME] as string == DialoguePositionData.OKSKIN) { position[i].okSkinName = ht[XMLHandler.CONTENT] as string; } else if(ht[XMLHandler.NODE_NAME] as string == DialoguePositionData.NAMESKIN) { position[i].nameSkinName = ht[XMLHandler.CONTENT] as string; } else if(ht[XMLHandler.NODE_NAME] as string == DialoguePositionData.BOXBOUNDS) { position[i].boxBounds.x = float.Parse((string)ht["x"]); position[i].boxBounds.y = float.Parse((string)ht["y"]); position[i].boxBounds.width = float.Parse((string)ht["w"]); position[i].boxBounds.height = float.Parse((string)ht["h"]); } else if(ht[XMLHandler.NODE_NAME] as string == DialoguePositionData.NAMEBOXBOUNDS) { position[i].nameBounds.x = float.Parse((string)ht["x"]); position[i].nameBounds.y = float.Parse((string)ht["y"]); position[i].nameBounds.width = float.Parse((string)ht["w"]); position[i].nameBounds.height = float.Parse((string)ht["h"]); } else if(ht[XMLHandler.NODE_NAME] as string == DialoguePositionData.BOXPADDING) { position[i].boxPadding.x = float.Parse((string)ht["x"]); position[i].boxPadding.y = float.Parse((string)ht["y"]); position[i].boxPadding.z = float.Parse((string)ht["z"]); position[i].boxPadding.w = float.Parse((string)ht["w"]); } else if(ht[XMLHandler.NODE_NAME] as string == DialoguePositionData.NAMEBOXPADDING) { position[i].namePadding.x = float.Parse((string)ht["x"]); position[i].namePadding.y = float.Parse((string)ht["y"]); position[i].namePadding.z = float.Parse((string)ht["z"]); position[i].namePadding.w = float.Parse((string)ht["w"]); } else if(ht[XMLHandler.NODE_NAME] as string == DialoguePositionData.SHADOWOFFSET) { position[i].shadowOffset.x = float.Parse((string)ht["x"]); position[i].shadowOffset.y = float.Parse((string)ht["y"]); } else if(ht[XMLHandler.NODE_NAME] as string == DialoguePositionData.CHOICEPADDING) { position[i].choicePadding.x = float.Parse((string)ht["x"]); position[i].choicePadding.y = float.Parse((string)ht["y"]); } else if(ht[XMLHandler.NODE_NAME] as string == DialoguePositionData.DRAGBOUNDS) { position[i].isDragWindow = true; position[i].dragBounds.x = float.Parse((string)ht["x"]); position[i].dragBounds.y = float.Parse((string)ht["y"]); position[i].dragBounds.width = float.Parse((string)ht["w"]); position[i].dragBounds.height = float.Parse((string)ht["h"]); } } } } } } } } }
// one line public string ShowOneLine(DialoguePosition dp, string text) { return this.ShowOneLine(dp, text, 0, 1); }
internal virtual Vector3 GetPosition(DialoguePosition dialoguePos) { switch (dialoguePos) { case DialoguePosition.Top : return topPos; case DialoguePosition.Left: return leftPos; case DialoguePosition.Right: return rightPos; case DialoguePosition.Bottom: return bottomPos; default : return initialPos; } }
public MultiContent(string text, DialoguePosition dp) { this.font = DataHolder.Fonts().GetFont(dp.skin.font); GUIStyle shadowStyle = new GUIStyle(dp.skin.label); shadowStyle.normal.textColor = DataHolder.Color(1); GUIStyle textStyle = new GUIStyle(dp.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); this.originalText = text; this.label = new LabelContent[0]; this.currentColor = 0; this.shadowColor = -1; int oldColor = 0; int oldShadowColor = -1; this.textPos = 0; int i = 0; int nl = 0; int fs = 0; int skip = 0; bool lineBreak = false; this.xPos = 0; this.yPos = 0; bool setNextX = false; bool setNextY = false; float nextX = 0; float nextY = 0; string addstring = ""; bool addSpace = false; bool finished = false; Vector2 v = Vector2.zero; Color tCol; Color sCol; Texture2D icon = null; GUIContent part = null; LabelContent nextLabel; while(!finished) { skip = 0; lineBreak = false; oldColor = this.currentColor; oldShadowColor = this.shadowColor; icon = null; part = null; tCol = DataHolder.Color(this.currentColor); if(this.shadowColor == -1 || this.shadowColor >= DataHolder.Colors().GetDataCount()) { sCol = DataHolder.Color(1); } else { sCol = DataHolder.Color(this.shadowColor); } fs = text.IndexOf("#", this.textPos); nl = text.IndexOf("\n", this.textPos); if(fs != -1 && (nl == -1 || fs < nl)) { i = fs; } else { i = nl; } if(i == -1) { i = text.Length - 1; finished = true; } if(setNextX) { this.xPos = nextX; setNextX = false; } if(setNextY) { this.yPos = nextY; setNextY = false; } if(!finished) { if (text[i].ToString() == "#") { if((text.Length - i) >= 1) { string nextChar = text[i+1].ToString(); if(nextChar == "c" || nextChar == "s") { // set text color for the next part int nS = text.IndexOf("#", i+1); if(nS != -1) { string sub = text.Substring(i, nS-i+1); skip = sub.Length+1; try { if(nextChar == "c") { this.currentColor = int.Parse(sub.Substring(2, sub.Length-3)); } else if(nextChar == "s") { this.shadowColor = int.Parse(sub.Substring(2, sub.Length-3)); } } catch(System.Exception e) { Debug.Log(e.Message); if(nextChar == "c") { this.currentColor = 0; } else if(nextChar == "s") { this.shadowColor = -1; } } } } else if(nextChar == "!") { this.currentColor = 0; this.shadowColor = -1; skip = 3; if((text.Length - (i+skip-1)) >= 1 && (text.Substring(i+skip-1, 1) == "\n" || text.Substring(i+skip-1, 1) == "\r")) { lineBreak = true; skip += 1; } } else if(nextChar == "#") { i++; skip = 2; } else if(nextChar == "p") { nextChar = text[i+2].ToString(); // set x or y position for the next text part int nS = text.IndexOf("#", i+2); if(nS != -1) { string sub = text.Substring(i, nS-i+1); skip = sub.Length+1; try { if(nextChar == "x") { nextX = float.Parse(sub.Substring(3, sub.Length-4)); setNextX = true; } else if(nextChar == "y") { nextY = float.Parse(sub.Substring(3, sub.Length-4)); setNextY = true; } } catch(System.Exception e) { Debug.Log(e.Message); } } } else if(nextChar == "i" && text[i+2].ToString() == "q") // icons { int nS = text.IndexOf("#", i+4); if(nS != -1) { string sub = text.Substring(i, nS-i+1); skip = sub.Length+1; sub = text.Substring(i+5, nS-(i+5)); int index = int.Parse(sub); sub = text.Substring(i+3, 2); if(sub == "sv") icon = DataHolder.StatusValues().GetIcon(index); else if(sub == "se") icon = DataHolder.Effects().GetIcon(index); else if(sub == "el") icon = DataHolder.Elements().GetIcon(index); else if(sub == "st") icon = DataHolder.SkillTypes().GetIcon(index); else if(sub == "sk") icon = DataHolder.Skills().GetIcon(index); else if(sub == "it") icon = DataHolder.ItemTypes().GetIcon(index); else if(sub == "im") icon = DataHolder.Items().GetIcon(index); else if(sub == "ir") icon = DataHolder.ItemRecipes().GetIcon(index); else if(sub == "ep") icon = DataHolder.EquipmentParts().GetIcon(index); else if(sub == "wp") icon = DataHolder.Weapons().GetIcon(index); else if(sub == "am") icon = DataHolder.Armors().GetIcon(index); else if(sub == "cl") icon = DataHolder.Classes().GetIcon(index); else if(sub == "ch") icon = DataHolder.Characters().GetIcon(index); else if(sub == "en") icon = DataHolder.Enemies().GetIcon(index); else icon = null; } } else { skip = 2; } } else { skip = 1; } } else if((text.Length - i) >= 1 && (text.Substring(i, 1) == "\n" || text.Substring(i, 1) == "\r")) { lineBreak = true; skip = 2; } i--; } if((i-this.textPos+1) > 0) { if(addSpace) addstring = " "; else addstring = ""; part = new GUIContent(addstring + text.Substring(this.textPos, i - this.textPos + 1)); nextLabel = new LabelContent(part, this.xPos, this.yPos, tCol, sCol, font); v = new Vector2(nextLabel.bounds.width, nextLabel.bounds.height); if ((this.xPos+v.x) > textPosition.bounds.width) { i = this.textPos+font.GetFittingTextLength(part.text, textPosition.bounds.width-this.xPos); lineBreak = true; icon = null; skip = 0; int tmp = i; part = new GUIContent(addstring + text.Substring(this.textPos, i - this.textPos + 1)); v = font.GetTextSize(part.text); while (this.xPos+v.x > textPosition.bounds.width) { i--; if((i-this.textPos+1) > 0) { part = new GUIContent(addstring + text.Substring(this.textPos, i - this.textPos + 1)); } else { part = new GUIContent(""); } v = font.GetTextSize(part.text); tmp = i+1; } while(" " != text[i].ToString() && i>(this.textPos+1)) { i--; } if((i-this.textPos+1) > 0 && " " == text[i].ToString()) { part = new GUIContent(addstring + text.Substring(this.textPos, i - this.textPos + 1)); } else { i = tmp; } nextLabel = new LabelContent(part, this.xPos, this.yPos, tCol, sCol, font); v = new Vector2(nextLabel.bounds.width, nextLabel.bounds.height); this.currentColor = oldColor; this.shadowColor = oldShadowColor; finished = false; } this.label = ArrayHelper.Add(nextLabel, this.label); this.xPos += v.x; if(!lineBreak) { addSpace = part.text[part.text.Length-1].ToString() == " "; } } if(icon != null) { part = new GUIContent(icon); nextLabel = new LabelContent(part, this.xPos, this.yPos, tCol, sCol, font); v = new Vector2(nextLabel.bounds.width, nextLabel.bounds.height); //this.xPos += font.GetTextSize(".").x; if(this.xPos+v.x <= textPosition.bounds.width) { this.label = ArrayHelper.Add(nextLabel, this.label); this.xPos += v.x; addSpace = true; icon = null; } else { lineBreak = true; } } if(lineBreak) { this.xPos = 0; this.yPos += v.y + textPosition.lineSpacing; addSpace = false; if(i+skip < text.Length && " " == text[i+skip].ToString()) { i++; } if((this.yPos+v.y) > (textPosition.bounds.height) && !dp.scrollable) { finished = true; } else if(icon != null) { part = new GUIContent(icon); nextLabel = new LabelContent(part, this.xPos, this.yPos, tCol, sCol, font); v = new Vector2(nextLabel.bounds.width, nextLabel.bounds.height); //this.xPos += font.GetTextSize(".").x; this.label = ArrayHelper.Add(nextLabel, this.label); this.xPos += v.x; addSpace = true; icon = null; } } else if(finished) { this.xPos = 0; this.yPos += v.y + textPosition.lineSpacing; } this.textPos = i + skip; } }