コード例 #1
0
    public void Start()
    {
        bool isLocalServerRunning = AsyncRPGServer.GetInstance().IsServerActive();

        Screen.showCursor = true;

        // Create the root widget group
        m_rootWidgetGroup = new WidgetGroup(null, Screen.width, Screen.height, 0.0f, 0.0f);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        m_widgetEventDispatcher = new WidgetEventDispatcher();
        m_widgetEventDispatcher.Start(m_rootWidgetGroup);

        // Create the widget group to hold the login panel
        m_loginPanelWidgetGroup =
            new WidgetGroup(
                m_rootWidgetGroup,
                loginPanelStyle.gamePanelStyle.Width, loginPanelStyle.gamePanelStyle.Height,
                Screen.width / 2 - loginPanelStyle.gamePanelStyle.Width / 2,
                Screen.height / 2 - loginPanelStyle.gamePanelStyle.Height / 2);

        // Background for the game info
        new ImageWidget(
            m_loginPanelWidgetGroup,
            loginPanelStyle.gamePanelStyle.Width,
            loginPanelStyle.gamePanelStyle.Height,
            loginPanelStyle.gamePanelStyle.Background,
            0.0f, 0.0f);

        // Username and Password - Left Aligned
        {
            WidgetLayoutCursor cursor = new WidgetLayoutCursor(
                loginPanelStyle.gamePanelStyle.BorderWidth
                + loginPanelStyle.gamePanelStyle.WidgetSpacing,
                loginPanelStyle.gamePanelStyle.BorderWidth
                + loginPanelStyle.gamePanelStyle.WidgetSpacing);
            cursor.Kerning = loginPanelStyle.gamePanelStyle.WidgetSpacing;
            cursor.Leading = loginPanelStyle.gamePanelStyle.WidgetSpacing;

            // Server
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Server:"));
            m_serverText =
                cursor.Advance(
                    new TextEntryWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.textEntryStyle,
                        cursor.X, cursor.Y,
                        "localhost"));
            m_serverText.Visible = !isLocalServerRunning;
            m_localHostLabel     =
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    m_serverText.Width, m_serverText.Height,
                    m_serverText.LocalX, m_serverText.LocalY,
                    "localhost");
            m_localHostLabel.Visible = isLocalServerRunning;
            cursor.NewLine();

            // Local hosted check box
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Host Server:"));
            m_localHostCheckBox =
                cursor.Advance(
                    new CheckBoxWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.checkBoxStyle,
                        cursor.X, cursor.Y));
            m_localHostCheckBox.Enabled = isLocalServerRunning;
            cursor.NewLine();

            // Username
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Username:"******"test" : ""));
            cursor.NewLine();

            // Password
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Password:"******"password" : ""));
            m_passwordText.IsPassword = true;
            cursor.NewLine();
        }

        // Buttons - Centered along the bottom
        {
            WidgetLayoutCursor cursor = new WidgetLayoutCursor(
                loginPanelStyle.gamePanelStyle.Width / 2
                - loginPanelStyle.gamePanelStyle.WidgetSpacing / 2
                - loginPanelStyle.buttonStyle.Width,
                loginPanelStyle.gamePanelStyle.Height
                - loginPanelStyle.buttonStyle.Height
                - loginPanelStyle.labelStyle.Height
                - loginPanelStyle.gamePanelStyle.BorderWidth
                - loginPanelStyle.gamePanelStyle.WidgetSpacing);

            m_createAccountButton =
                cursor.Advance(
                    new ButtonWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.buttonStyle,
                        cursor.X, cursor.Y,
                        "New Account"));
            m_createAccountButton.Visible = false;

            m_loginButton =
                cursor.Advance(
                    new ButtonWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.buttonStyle,
                        cursor.X, cursor.Y,
                        "Login"));
            m_loginButton.Visible = true;

            cursor.NewLine();

            m_loginStatusLabel =
                cursor.Advance(
                    new LabelWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.gamePanelStyle.Width
                        - 2.0f * loginPanelStyle.gamePanelStyle.BorderWidth,
                        loginPanelStyle.labelStyle.Height,
                        cursor.X, cursor.Y,
                        ""));
        }

        // Server Status Panel
        m_serverPanelWidgetGroup =
            new WidgetGroup(
                m_rootWidgetGroup,
                loginPanelStyle.gamePanelStyle.Width, loginPanelStyle.gamePanelStyle.Height,
                Screen.width / 2 - loginPanelStyle.gamePanelStyle.Width / 2,
                Screen.height / 2 - loginPanelStyle.gamePanelStyle.Height / 2);
        m_serverPanelWidgetGroup.Visible = false;

        // Background for the game info
        new ImageWidget(
            m_serverPanelWidgetGroup,
            loginPanelStyle.gamePanelStyle.Width,
            loginPanelStyle.gamePanelStyle.Height,
            loginPanelStyle.gamePanelStyle.Background,
            0.0f, 0.0f);

        {
            float contentCenter       = loginPanelStyle.gamePanelStyle.Width / 2.0f;
            WidgetLayoutCursor cursor = new WidgetLayoutCursor(
                0.0f,
                loginPanelStyle.gamePanelStyle.BorderWidth
                + loginPanelStyle.gamePanelStyle.WidgetSpacing);
            cursor.Kerning = loginPanelStyle.gamePanelStyle.WidgetSpacing;
            cursor.Leading = loginPanelStyle.gamePanelStyle.WidgetSpacing;

            LabelWidget topLabel =
                cursor.Advance(
                    new LabelWidget(
                        m_serverPanelWidgetGroup,
                        loginPanelStyle.labelStyle,
                        contentCenter - loginPanelStyle.labelStyle.Width / 2.0f, cursor.Y,
                        "[Server]"));
            topLabel.Alignment = TextAnchor.UpperCenter;
            cursor.NewLine();

            m_serverStatusText =
                cursor.Advance(
                    new ScrollTextWidget(
                        m_serverPanelWidgetGroup,
                        loginPanelStyle.scrollTextStyle,
                        contentCenter - loginPanelStyle.scrollTextStyle.Width / 2.0f, cursor.Y,
                        ""));
            cursor.NewLine();

            m_serverOkButton =
                cursor.Advance(
                    new ButtonWidget(
                        m_serverPanelWidgetGroup,
                        loginPanelStyle.buttonStyle,
                        contentCenter - loginPanelStyle.buttonStyle.Width / 2.0f, cursor.Y,
                        "Ok"));
            m_serverOkButton.Visible = false;
        }
    }
コード例 #2
0
ファイル: LoginView.cs プロジェクト: ltloibrights/AsyncRPG
    public void Start()
    {
        bool isLocalServerRunning= AsyncRPGServer.GetInstance().IsServerActive();
        Screen.showCursor = true;

        // Create the root widget group
        m_rootWidgetGroup = new WidgetGroup(null, Screen.width, Screen.height, 0.0f, 0.0f);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        m_widgetEventDispatcher = new WidgetEventDispatcher();
        m_widgetEventDispatcher.Start(m_rootWidgetGroup);

        // Create the widget group to hold the login panel
        m_loginPanelWidgetGroup =
            new WidgetGroup(
                m_rootWidgetGroup,
                loginPanelStyle.gamePanelStyle.Width, loginPanelStyle.gamePanelStyle.Height,
                Screen.width / 2 - loginPanelStyle.gamePanelStyle.Width / 2,
                Screen.height / 2 - loginPanelStyle.gamePanelStyle.Height / 2);

        // Background for the game info
        new ImageWidget(
            m_loginPanelWidgetGroup,
            loginPanelStyle.gamePanelStyle.Width,
            loginPanelStyle.gamePanelStyle.Height,
            loginPanelStyle.gamePanelStyle.Background,
            0.0f, 0.0f);

        // Username and Password - Left Aligned
        {
            WidgetLayoutCursor cursor = new WidgetLayoutCursor(
                loginPanelStyle.gamePanelStyle.BorderWidth
                + loginPanelStyle.gamePanelStyle.WidgetSpacing,
                loginPanelStyle.gamePanelStyle.BorderWidth
                + loginPanelStyle.gamePanelStyle.WidgetSpacing);
            cursor.Kerning= loginPanelStyle.gamePanelStyle.WidgetSpacing;
            cursor.Leading= loginPanelStyle.gamePanelStyle.WidgetSpacing;

            // Server
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Server:"));
            m_serverText =
                cursor.Advance(
                    new TextEntryWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.textEntryStyle,
                        cursor.X, cursor.Y,
                        "localhost"));
            m_serverText.Visible= !isLocalServerRunning;
            m_localHostLabel=
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    m_serverText.Width, m_serverText.Height,
                    m_serverText.LocalX, m_serverText.LocalY,
                    "localhost");
            m_localHostLabel.Visible= isLocalServerRunning;
            cursor.NewLine();

            // Local hosted check box
            cursor.Advance(
                new LabelWidget(
                m_loginPanelWidgetGroup,
                loginPanelStyle.labelStyle,
                cursor.X, cursor.Y,
                "Host Server:"));
            m_localHostCheckBox=
                cursor.Advance(
                    new CheckBoxWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.checkBoxStyle,
                        cursor.X, cursor.Y));
            m_localHostCheckBox.Enabled = isLocalServerRunning;
            cursor.NewLine();

            // Username
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Username:"******"test" : ""));
            cursor.NewLine();

            // Password
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Password:"******"password" : ""));
            m_passwordText.IsPassword= true;
            cursor.NewLine();
        }

        // Buttons - Centered along the bottom
        {
            WidgetLayoutCursor cursor = new WidgetLayoutCursor(
                loginPanelStyle.gamePanelStyle.Width/2
                - loginPanelStyle.gamePanelStyle.WidgetSpacing/2
                - loginPanelStyle.buttonStyle.Width,
                loginPanelStyle.gamePanelStyle.Height
                - loginPanelStyle.buttonStyle.Height
                - loginPanelStyle.labelStyle.Height
                - loginPanelStyle.gamePanelStyle.BorderWidth
                - loginPanelStyle.gamePanelStyle.WidgetSpacing);

            m_createAccountButton =
                cursor.Advance(
                    new ButtonWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.buttonStyle,
                        cursor.X, cursor.Y,
                        "New Account"));
            m_createAccountButton.Visible= false;

            m_loginButton =
                cursor.Advance(
                    new ButtonWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.buttonStyle,
                        cursor.X, cursor.Y,
                        "Login"));
            m_loginButton.Visible= true;

            cursor.NewLine();

            m_loginStatusLabel=
                cursor.Advance(
                    new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.gamePanelStyle.Width
                    - 2.0f*loginPanelStyle.gamePanelStyle.BorderWidth,
                    loginPanelStyle.labelStyle.Height,
                    cursor.X, cursor.Y,
                    ""));
        }

        // Server Status Panel
        m_serverPanelWidgetGroup =
            new WidgetGroup(
                m_rootWidgetGroup,
                loginPanelStyle.gamePanelStyle.Width, loginPanelStyle.gamePanelStyle.Height,
                Screen.width / 2 - loginPanelStyle.gamePanelStyle.Width / 2,
                Screen.height / 2 - loginPanelStyle.gamePanelStyle.Height / 2);
        m_serverPanelWidgetGroup.Visible= false;

        // Background for the game info
        new ImageWidget(
            m_serverPanelWidgetGroup,
            loginPanelStyle.gamePanelStyle.Width,
            loginPanelStyle.gamePanelStyle.Height,
            loginPanelStyle.gamePanelStyle.Background,
            0.0f, 0.0f);

        {
            float contentCenter= loginPanelStyle.gamePanelStyle.Width / 2.0f;
            WidgetLayoutCursor cursor = new WidgetLayoutCursor(
                0.0f,
                loginPanelStyle.gamePanelStyle.BorderWidth
                + loginPanelStyle.gamePanelStyle.WidgetSpacing);
            cursor.Kerning= loginPanelStyle.gamePanelStyle.WidgetSpacing;
            cursor.Leading= loginPanelStyle.gamePanelStyle.WidgetSpacing;

            LabelWidget topLabel=
                cursor.Advance(
                    new LabelWidget(
                        m_serverPanelWidgetGroup,
                        loginPanelStyle.labelStyle,
                        contentCenter - loginPanelStyle.labelStyle.Width / 2.0f, cursor.Y,
                        "[Server]"));
            topLabel.Alignment= TextAnchor.UpperCenter;
            cursor.NewLine();

            m_serverStatusText=
                cursor.Advance(
                    new ScrollTextWidget(
                    m_serverPanelWidgetGroup,
                    loginPanelStyle.scrollTextStyle,
                    contentCenter - loginPanelStyle.scrollTextStyle.Width / 2.0f, cursor.Y,
                    ""));
            cursor.NewLine();

            m_serverOkButton=
                cursor.Advance(
                    new ButtonWidget(
                    m_serverPanelWidgetGroup,
                    loginPanelStyle.buttonStyle,
                    contentCenter - loginPanelStyle.buttonStyle.Width / 2.0f, cursor.Y,
                    "Ok"));
            m_serverOkButton.Visible= false;
        }
    }