示例#1
0
        private void InitializeLoginPage()
        {
            var curve = GameApp.Service<ResourceManager>().Acquire<Curve>("Curves/CardMove");
            var candFmtOptions = new Graphics.TextRenderer.FormatOptions(new Graphics.TextRenderer.FontDescriptor("Microsoft YaHei", 11));

            m_txtUserName = new UI.TextBox(100, 30, m_textFormatOptions, candFmtOptions)
            {
                ForeColor = Color.Red,
                SelectionBackColor = new Color(255, 0, 0, 0.75f),
                SlidingCurve = curve,
                Transform = MatrixHelper.Translate(462, 200),
                Dispatcher = Root
            };

            m_txtPassword = new UI.TextBox(100, 30, m_textFormatOptions, candFmtOptions)
            {
                ForeColor = Color.Red,
                SelectionBackColor = new Color(255, 0, 0, 0.75f),
                PasswordChar = '*',
                SlidingCurve = curve,
                Transform = MatrixHelper.Translate(462, 250),
                Dispatcher = Root,
            };

            TextRenderer.IFormattedText textUserName = GameApp.Service<TextRenderer>().FormatText("用户名: ", m_textFormatOptions);
            var lblUserName = new UI.Label()
            {
                TextColor = Color.Red,
                Dispatcher = Root,
                FormattedText = textUserName,
                Transform = MatrixHelper.Translate(350, 200)
            };
            TextRenderer.IFormattedText textPassword = GameApp.Service<TextRenderer>().FormatText("密码: ", m_textFormatOptions);
            var lblPassword = new UI.Label()
            {
                TextColor = Color.Red,
                Dispatcher = Root,
                FormattedText = textPassword,
                Transform = MatrixHelper.Translate(350, 250)
            };
            TextRenderer.IFormattedText textMessage = GameApp.Service<TextRenderer>().FormatText(string.Empty, m_textFormatOptions);
            m_lblMessage = new UI.Label()
            {
                TextColor = Color.Red,
                Dispatcher = Root,
                FormattedText = textMessage,
                Transform = MatrixHelper.Translate(350, 300)
            };

            var resourceMgr = GameApp.Service<ResourceManager>();
            var buttonTexture = resourceMgr.Acquire<Graphics.VirtualTexture>("atlas:Textures/UI/InGame/Atlas0$Button");
            Graphics.TexturedQuad m_buttonFace = new Graphics.TexturedQuad(buttonTexture);

            TextRenderer.IFormattedText textLoginButton = GameApp.Service<TextRenderer>().FormatText("登录", m_textFormatOptions);
            var btnLogin = new UI.Button()
            {
                Dispatcher = Root,
                ButtonText = textLoginButton,
                TextColor = Color.White,
                Transform = MatrixHelper.Translate(300, 350),
                NormalFace = m_buttonFace
            };
            btnLogin.MouseButton1Down += new EventHandler<UI.MouseEventArgs>(btnLogin_MouseButton1Down);

            TextRenderer.IFormattedText textReturnButton = GameApp.Service<TextRenderer>().FormatText("返回", m_textFormatOptions);
            var btnReturn = new UI.Button()
            {
                Dispatcher = Root,
                ButtonText = textReturnButton,
                TextColor = Color.White,
                Transform = MatrixHelper.Translate(450, 350),
                NormalFace = m_buttonFace
            };
            btnReturn.MouseButton1Down += delegate(object sender, UI.MouseEventArgs e)
            {
                Root.Dispatcher = null;
                GameApp.Service<MenuUI>().Startup();
            };

            TextRenderer.IFormattedText textRegister = GameApp.Service<TextRenderer>().FormatText("注册", m_textFormatOptions);
            var btnRegister = new UI.Button()
            {
                Dispatcher = Root,
                ButtonText = textRegister,
                TextColor = Color.White,
                Transform = MatrixHelper.Translate(600, 350),
                NormalFace = m_buttonFace
            };
            btnRegister.MouseButton1Down += delegate(object sender, UI.MouseEventArgs e)
            {
                System.Diagnostics.Process.Start("http://touhouspring.com");
            };
        }
示例#2
0
        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)
            //};
        }