//Update public void Update() { if (mEventDialogWindow.IsHidden) { Interface.InputBlockingElements.Remove(this); } else { if (!Interface.InputBlockingElements.Contains(this)) { Interface.InputBlockingElements.Add(this); } } if (Globals.EventDialogs.Count > 0) { if (mEventDialogWindow.IsHidden) { base.Show(); mEventDialogWindow.Show(); mEventDialogWindow.MakeModal(); mEventDialogArea.ScrollToTop(); mEventDialogWindow.BringToFront(); var faceTex = Globals.ContentManager.GetTexture( GameContentManager.TextureType.Face, Globals.EventDialogs[0].Face ); var responseCount = 0; var maxResponse = 1; if (Globals.EventDialogs[0].Opt1.Length > 0) { responseCount++; } if (Globals.EventDialogs[0].Opt2.Length > 0) { responseCount++; maxResponse = 2; } if (Globals.EventDialogs[0].Opt3.Length > 0) { responseCount++; maxResponse = 3; } if (Globals.EventDialogs[0].Opt4.Length > 0) { responseCount++; maxResponse = 4; } mEventResponse1.Name = ""; mEventResponse2.Name = ""; mEventResponse3.Name = ""; mEventResponse4.Name = ""; switch (maxResponse) { case 1: mEventDialogWindow.Name = "EventDialogWindow_1Response"; mEventResponse1.Name = "Response1Button"; break; case 2: mEventDialogWindow.Name = "EventDialogWindow_2Responses"; mEventResponse1.Name = "Response1Button"; mEventResponse2.Name = "Response2Button"; break; case 3: mEventDialogWindow.Name = "EventDialogWindow_3Responses"; mEventResponse1.Name = "Response1Button"; mEventResponse2.Name = "Response2Button"; mEventResponse3.Name = "Response3Button"; break; case 4: mEventDialogWindow.Name = "EventDialogWindow_4Responses"; mEventResponse1.Name = "Response1Button"; mEventResponse2.Name = "Response2Button"; mEventResponse3.Name = "Response3Button"; mEventResponse4.Name = "Response4Button"; break; } mEventDialogWindow.LoadJsonUi( GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString() ); if (faceTex != null) { mEventFace.Show(); mEventFace.Texture = faceTex; mEventDialogArea.Show(); mEventDialogAreaNoFace.Hide(); } else { mEventFace.Hide(); mEventDialogArea.Hide(); mEventDialogAreaNoFace.Show(); } if (responseCount == 0) { mEventResponse1.Show(); mEventResponse1.SetText(Strings.EventWindow.Continue); mEventResponse2.Hide(); mEventResponse3.Hide(); mEventResponse4.Hide(); } else { if (Globals.EventDialogs[0].Opt1 != "") { mEventResponse1.Show(); mEventResponse1.SetText(Globals.EventDialogs[0].Opt1); } else { mEventResponse1.Hide(); } if (Globals.EventDialogs[0].Opt2 != "") { mEventResponse2.Show(); mEventResponse2.SetText(Globals.EventDialogs[0].Opt2); } else { mEventResponse2.Hide(); } if (Globals.EventDialogs[0].Opt3 != "") { mEventResponse3.Show(); mEventResponse3.SetText(Globals.EventDialogs[0].Opt3); } else { mEventResponse3.Hide(); } if (Globals.EventDialogs[0].Opt4 != "") { mEventResponse4.Show(); mEventResponse4.SetText(Globals.EventDialogs[0].Opt4); } else { mEventResponse4.Hide(); } } mEventDialogWindow.SetSize( mEventDialogWindow.Texture.GetWidth(), mEventDialogWindow.Texture.GetHeight() ); if (faceTex != null) { mEventDialogLabel.ClearText(); mEventDialogLabel.Width = mEventDialogArea.Width - mEventDialogArea.GetVerticalScrollBar().Width; mEventDialogLabel.AddText( Globals.EventDialogs[0].Prompt, mEventDialogLabelTemplate.TextColor, mEventDialogLabelTemplate.CurAlignments.Count > 0 ? mEventDialogLabelTemplate.CurAlignments[0] : Alignments.Left, mEventDialogLabelTemplate.Font ); mEventDialogLabel.SizeToChildren(false, true); mEventDialogArea.ScrollToTop(); } else { mEventDialogLabelNoFace.ClearText(); mEventDialogLabelNoFace.Width = mEventDialogAreaNoFace.Width - mEventDialogAreaNoFace.GetVerticalScrollBar().Width; mEventDialogLabelNoFace.AddText( Globals.EventDialogs[0].Prompt, mEventDialogLabelNoFaceTemplate.TextColor, mEventDialogLabelNoFaceTemplate.CurAlignments.Count > 0 ? mEventDialogLabelNoFaceTemplate.CurAlignments[0] : Alignments.Left, mEventDialogLabelNoFaceTemplate.Font ); mEventDialogLabelNoFace.SizeToChildren(false, true); mEventDialogAreaNoFace.ScrollToTop(); } } } }
public void Setup(string picture, int size, bool clickable) { Picture = picture; Size = size; Clickable = clickable; mPicture.Texture = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Image, picture); if (mPicture.Texture != null) { mPicture.SetSize(mPicture.Texture.GetWidth(), mPicture.Texture.GetHeight()); Align.Center(mPicture); if (size != (int)PictureSize.Original) // Don't scale if you want to keep the original size. { if (size == (int)PictureSize.StretchToFit) { mPicture.SetSize(mGameCanvas.Width, mGameCanvas.Height); Align.Center(mPicture); } else { var n = 1; //If you want half fullscreen size set n to 2. if (size == (int)PictureSize.HalfScreen) { n = 2; } var ar = (float)mPicture.Width / (float)mPicture.Height; var heightLimit = true; if (mGameCanvas.Width < mGameCanvas.Height * ar) { heightLimit = false; } if (heightLimit) { var height = mGameCanvas.Height; var width = mGameCanvas.Height * ar; mPicture.SetSize((int)(width / n), (int)(height / n)); Align.Center(mPicture); } else { var width = mGameCanvas.Width; var height = width / ar; mPicture.SetSize((int)(width / n), (int)(height / n)); Align.Center(mPicture); } } } mPicture.BringToFront(); mPicture.Show(); } else { Close(); } }