public override void Startup() { var font = new Graphics.TextRenderer.FontDescriptor("Constantia", 20, System.Drawing.FontStyle.Bold); FormatOptions = new Graphics.TextRenderer.FormatOptions(font) { Alignment = Graphics.TextRenderer.Alignment.CenterMiddle }; var drawOptions = Graphics.TextRenderer.DrawOptions.Default; drawOptions.ColorScaling = Vector4.One; DrawOptions = drawOptions; MoveCurve = GameApp.Service<Services.ResourceManager>().Acquire<Curve>("Curves/DamageIndicatorFloat"); FadeCurve = GameApp.Service<Services.ResourceManager>().Acquire<Curve>("Curves/DamageIndicatorFade"); }
private void InitializeContextButton() { var device = GameApp.Instance.GraphicsDevice; var content = GameApp.Instance.Content; var resourceMgr = GameApp.Service<ResourceManager>(); var buttonTexture = resourceMgr.Acquire<Graphics.VirtualTexture>("atlas:Textures/UI/InGame/Atlas0$Button"); m_buttonFace = new Graphics.TexturedQuad(buttonTexture); var font = new Graphics.TextRenderer.FontDescriptor("DFKai-SB", 16); m_buttonTextFormatOptions = new Graphics.TextRenderer.FormatOptions(font); }
public SpellButtons(CardControl control) : base(control) { // TODO: spell button shall be stylized from cardcontrol's style const int IntervalV = 10; m_buttonFaceTexture = GameApp.Service<Services.ResourceManager>().Acquire<Graphics.VirtualTexture>("atlas:Textures/UI/InGame/Atlas0$Button"); var buttonFace = new Graphics.TexturedQuad(m_buttonFaceTexture); var font = new Graphics.TextRenderer.FontDescriptor("Segoe UI", 16); int y = 0; foreach (var spell in Card.Spells) { y -= m_buttonFaceTexture.Height + IntervalV; var btn = new Button { NormalFace = buttonFace, ButtonText = GameApp.Service<Graphics.TextRenderer>().FormatText(spell.Model.Name, new Graphics.TextRenderer.FormatOptions(font)) }; btn.Transform = MatrixHelper.Translate(-m_buttonFaceTexture.Width / 2, y); btn.MouseButton1Up += new EventHandler<MouseEventArgs>(SpellButton_MouseButton1Up); btn.Dispatcher = m_spellButtonContainer; m_spellButtons.Add(btn); } m_fadeInOutTrack.Elapsed += w => { foreach (var button in Buttons) { var clr = new Color(1.0f, 1.0f, 1.0f, w); button.NormalFace.ColorToModulate = clr; button.TextColor = clr; } if (w == 0.0f) { m_spellButtonContainer.Dispatcher = null; } }; }
void TextProperty.IHost.SetText(string text, Font font, Font ansiFont, Color textColor, Color textOutlineColor) { SystemFontStyle fontStyle; switch (font.Style) { default: case FontStyle.Regular: fontStyle = SystemFontStyle.Regular; break; case FontStyle.Bold: fontStyle = SystemFontStyle.Bold; break; case FontStyle.Italic: fontStyle = SystemFontStyle.Italic; break; } SystemFontStyle ansiFontStyle; switch (ansiFont.Style) { default: case FontStyle.Regular: ansiFontStyle = SystemFontStyle.Regular; break; case FontStyle.Bold: ansiFontStyle = SystemFontStyle.Bold; break; case FontStyle.Italic: ansiFontStyle = SystemFontStyle.Italic; break; } if (TypedTarget.FormattedText == null || TypedTarget.FormattedText.Text != text || TypedTarget.FormattedText.FormatOptions.Font.FamilyName != font.Family || TypedTarget.FormattedText.FormatOptions.Font.Size != font.Size || TypedTarget.FormattedText.FormatOptions.Font.Style != fontStyle || TypedTarget.FormattedText.FormatOptions.Font.OutlineThickness != font.OutlineThickness || TypedTarget.FormattedText.FormatOptions.AnsiFont.FamilyName != ansiFont.Family || TypedTarget.FormattedText.FormatOptions.AnsiFont.Size != ansiFont.Size || TypedTarget.FormattedText.FormatOptions.AnsiFont.Style != ansiFontStyle || TypedTarget.FormattedText.FormatOptions.AnsiFont.OutlineThickness != ansiFont.OutlineThickness) { var fd = new Graphics.TextRenderer.FontDescriptor(font.Family, font.Size.Value, fontStyle, font.OutlineThickness.Value); var ansiFd = new Graphics.TextRenderer.FontDescriptor(ansiFont.Family, ansiFont.Size.Value, ansiFontStyle, ansiFont.OutlineThickness.Value); TypedTarget.FormattedText = GameApp.Service<Graphics.TextRenderer>().FormatText(text, new Graphics.TextRenderer.FormatOptions(fd, ansiFd)); } TypedTarget.TextColor = new XnaColor(textColor.Red, textColor.Green, textColor.Blue, textColor.Alpha); TypedTarget.TextOutlineColor = new XnaColor(textOutlineColor.Red, textOutlineColor.Green, textOutlineColor.Blue, textOutlineColor.Alpha); }
public override void Startup() { #region Initialize Page Matrix toScreenSpace = Matrix.Identity; toScreenSpace.M11 = 2 / 1024.0f; toScreenSpace.M22 = 2 / 768.0f; toScreenSpace.M41 = -1; toScreenSpace.M42 = -1; var cam = new Camera { PostWorldMatrix = toScreenSpace, Position = Vector3.UnitZ, IsPerspective = false, ViewportWidth = 2, ViewportHeight = -2 }; cam.Dirty(); Root = new UI.TransformNode { Transform = cam.WorldToProjectionMatrix, Dispatcher = GameApp.Service<UIManager>().Root }; LoadPage("MainMenu"); LoadPage("FreeMode"); LoadPage("Network"); LoadPage("Quit"); #endregion if (m_isFirstLoaded) { #region Main Menu m_pages["MainMenu"].MenuClicked += (id, item) => { if (id == "freemode") { CurrentPage = m_pages["FreeMode"]; } //else if (id == "storymode") //{ // //Test Conversation UI // CurrentPage = null; // Root.Dispatcher = null; // GameApp.Service<GameManager>().EnterConversation(); //} else if (id == "makedeck") { CurrentPage = null; Root.Dispatcher = null; GameApp.Service<GameManager>().EnterDeckUI(); } else if (id == "quit") { CurrentPage = m_pages["Quit"]; } }; #endregion #region FreeMode Menu PrepareGameStartupParam(); m_pages["FreeMode"].MenuClicked += (id, item) => { if (id == "vsai" || id == "hotseat") { CurrentPage = null; // detach menu ui Root.Dispatcher = null; Agents.BaseAgent agent0; Agents.BaseAgent agent1; switch (id) { case "vsai": if (GameApp.Instance.GetCommandLineArgValue("playback") != null) { var pbAgent = new Agents.PlaybackAgent(0); param.Seed = pbAgent.RandomSeed; agent0 = pbAgent; } else if (GameApp.Instance.GetCommandLineArgValue("record") != null) { agent0 = new Agents.LocalPlayerAgent(0, param.Seed); } else { agent0 = new Agents.LocalPlayerAgent(0); } agent1 = new Agents.AIAgent(1); break; case "hotseat": agent0 = new Agents.LocalPlayerAgent(0); agent1 = new Agents.LocalPlayerAgent(1); break; default: throw new InvalidOperationException("Invalid menu item"); } GameApp.Service<GameManager>().StartGame(param, new Agents.BaseAgent[] { agent0, agent1 }); } else if (id == "vsnetwork") { //CurrentPage = m_pages["Network"]; CurrentPage = null; Root.Dispatcher = null; GameApp.Service<GameManager>().EnterNetworkUI(); } else if (id == "back") { CurrentPage = m_pages["MainMenu"]; } }; #endregion #region Network Menu m_pages["Network"].MenuClicked += (id, item) => { if (id == "backtofreemode") { //CurrentPage = m_pages["FreeMode"]; } }; #endregion #region Quit Menu m_pages["Quit"].MenuClicked += (id, item) => { if (id == "quit") { GameApp.Instance.Exit(); } else if (id == "back") { CurrentPage = m_pages["MainMenu"]; } }; #endregion //m_isFirstLoaded = false; } CurrentPage = m_pages["MainMenu"]; var curve = GameApp.Service<ResourceManager>().Acquire<Curve>("Curves/CardMove"); var font = new Graphics.TextRenderer.FontDescriptor("Microsoft YaHei", 16); var fmtOptions = new Graphics.TextRenderer.FormatOptions(font); var candFmtOptions = new Graphics.TextRenderer.FormatOptions(new Graphics.TextRenderer.FontDescriptor("Microsoft YaHei", 11)); var txtBox = new UI.TextBox(250, 30, fmtOptions, candFmtOptions) { ForeColor = Color.Black, SelectionBackColor = new Color(0, 0, 0, 0.75f), SlidingCurve = curve, Transform = MatrixHelper.Translate(50, 200), Dispatcher = Root }; txtBox = new UI.TextBox(250, 30, fmtOptions, candFmtOptions) { ForeColor = Color.Black, SelectionBackColor = new Color(0, 0, 0, 0.75f), SlidingCurve = curve, Transform = MatrixHelper.Translate(50, 250), Dispatcher = Root }; //m_testAnimation = new Graphics.SwfInstance("germs") //{ // IsPlaying = true, // TimeFactor = 2.0f, // Transform = MatrixHelper.RotateZ(MathHelper.Pi / 4) * MatrixHelper.Translate(256f, 256f) //}; //m_testAnimation2 = new Graphics.SwfInstance("28835") //{ // IsPlaying = true, // Transform = MatrixHelper.Translate(768f, 0f) //}; }