public void Preload(string name, string text, ChoiceContent[] choices, SpeakerPortrait speakerPortrait, StatusBar[] bar) { if(this.skin == null) this.LoadSkins(); if(this.fadeIn && !this.inDone) this.alpha = 0; this.multiLabel.CreateContent(this, name, text, choices, speakerPortrait, bar); this.preloaded = true; this.destroyTextures = false; }
/* ============================================================================ Init functions ============================================================================ */ public void Show(string name, string text, ChoiceContent[] choices, SpeakerPortrait speakerPortrait, StatusBar[] bar, bool dt) { this.destroyTextures = dt; if(this.skin == null) this.LoadSkins(); if(this.fadeIn && !this.inDone) this.alpha = 0; if(this.sprite == null) { this.multiLabel.CreateContent(this, name, text, choices, speakerPortrait, bar); this.sprite = GameHandler.GUIHandler().AddDPSprite(this); } else { this.multiLabel.CreateContent(this, name, text, choices, speakerPortrait, bar); } }
public override void Execute(GameEvent gameEvent) { int[] ids = DataHolder.Teleports().GetTeleportIDs(this.show7); if(ids.Length == 0) { gameEvent.StepFinished(this.nextFail); } else { string[] ch = DataHolder.Teleports().GetNamesForIDs(ids); int lang = GameHandler.GetLanguage(); if(this.show6) { ids = ArrayHelper.Add(this.choiceNext[0], ids); if(lang < ((string[])this.choice[0]).Length) { ch = ArrayHelper.Add(((string[])this.choice[0])[lang], ch); } else { ch = ArrayHelper.Add(((string[])this.choice[0])[0], ch); } } gameEvent.SetTeleportIDs(ids, this.show6); string nm = ""; SpeakerPortrait sp = null; if(this.show3) { nm = gameEvent.GetActorName(this.actorID); } else { nm = ""; } string msg = ""; if(lang < this.message.Length) { msg = this.message[lang]; } else { msg = this.message[0]; } if(this.show4) { sp = new SpeakerPortrait(this.scene, this.v2, this.show5); } this.dummyNext = new int[ids.Length]; for(int i=0; i<this.dummyNext.Length; i++) this.dummyNext[i] = i; GameHandler.GetLevelHandler().ShowChoice(nm, msg, ch, this.number, gameEvent, sp); } }
public override void Execute(GameEvent gameEvent) { string nm = ""; SpeakerPortrait sp = null; if(this.show3) { nm = gameEvent.GetActorName(this.actorID); } else { nm = ""; } int lang = GameHandler.GetLanguage(); string msg = ""; if(lang < this.message.Length) { msg = this.message[lang]; } else { msg = this.message[0]; } string[] ch = new string[0]; this.dummyNext = new int[0]; for(int i=0; i<this.choice.Count; i++) { if(!this.addVariableCondition[i] || this.variableCondition[i].CheckVariables()) { ch = ArrayHelper.Add(this.GetChoiceText(i, lang), ch); this.dummyNext = ArrayHelper.Add(this.choiceNext[i], this.dummyNext); } } if(this.show4) { sp = new SpeakerPortrait(this.scene, this.v2, this.show5); } GameHandler.GetLevelHandler().ShowChoice(nm, msg, ch, this.number, gameEvent, sp); }
public override void Execute(GameEvent gameEvent) { string nm = ""; SpeakerPortrait sp = null; if(this.show3) { nm = gameEvent.GetActorName(this.actorID); } else { nm = ""; } string msg = ""; if(GameHandler.GetLanguage() < this.message.Length) { msg = this.message[GameHandler.GetLanguage()]; } else { msg = this.message[0]; } if(this.show4) { sp = new SpeakerPortrait(this.scene, this.v2, this.show5); } GameHandler.GetLevelHandler().ShowDialogue(nm, msg, this.number, gameEvent, this.next, this.show, this.time, this.show2, sp); }
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, 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 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 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); }