void Defaults_Click(EButton sender)
        {
            foreach (EControl control in window.Controls)
            {
                ECheckBox checkBox = control as ECheckBox;
                if (checkBox == null)
                {
                    continue;
                }

                PropertyInfo property = checkBox.UserData as PropertyInfo;
                if (property == null)
                {
                    continue;
                }

                DefaultValueAttribute[] attributes = (DefaultValueAttribute[])property.
                                                     GetCustomAttributes(typeof(DefaultValueAttribute), true);

                if (attributes.Length == 0)
                {
                    continue;
                }

                checkBox.Checked = (bool)attributes[0].Value;
            }
        }
        void Connect_Click(EButton sender)
        {
            if (string.IsNullOrEmpty(userName))
            {
                SetInfo("Invalid user name.", true);
                return;
            }

            SetInfo("Connecting to the server...", false);

            GameNetworkClient client = new GameNetworkClient(true);

            client.ConnectionStatusChanged += Client_ConnectionStatusChanged;

            int    port     = 56565;
            string password = "";

            string error;

            if (!client.BeginConnect(connectToAddress, port, EngineVersionInformation.Version,
                                     userName, password, out error))
            {
                Log.Error(error);
                DisposeClient();
                return;
            }

            editBoxUserName.Enable    = false;
            editBoxConnectTo.Enable   = false;
            buttonCreateServer.Enable = false;
            buttonConnect.Enable      = false;
        }
        public MessageWindow(string Text, string Title, EButton button)
            : this(Text, Title)
        {
            int width = (int)lblText.CreateGraphics().MeasureString(lblText.Text, lblText.Font).Width;

            switch (button)
            {
            case EButton.OK:
                btnCancel.Visible = false;
                btnOk.Visible     = true;
                btnOk.Left        = width / 2 + lblText.Left - btnOk.Width / 2;
                btnOk.Text        = "确定[&O]";
                break;

            case EButton.YesNo:
                btnCancel.Visible = true;
                btnOk.Visible     = true;
                btnOk.Left        = (width - btnOk.Width * 2) / 3 + lblText.Left;
                btnCancel.Left    = (width - btnOk.Width * 2) / 3 + btnOk.Left + btnOk.Width;
                btnOk.Text        = "是[&Y]";
                btnCancel.Text    = "否[&N]";
                break;

            case EButton.OKCancel:
                btnCancel.Visible = true;
                btnOk.Visible     = true;
                btnOk.Left        = (width - btnOk.Width * 2) / 3 + lblText.Left;
                btnCancel.Left    = (width - btnOk.Width * 2) / 3 + btnOk.Left + btnOk.Width;
                btnOk.Text        = "确定[&O]";
                btnCancel.Text    = "取消[&C]";
                break;
            }
        }
Beispiel #4
0
 public static DialogResult Show(string text, string title, EButton button)
 {
     using (MessageWindow mw = new MessageWindow(text, title, button))
     {
         return(mw.ShowDialog());
     }
 }
Beispiel #5
0
        /// <summary>
        ///   Constructor
        /// </summary>
        /// <param name="type">Button type</param>
        /// <param name="text">Button text</param>
        /// <param name="onclick">Javascript onclick event of the button</param>
        /// <param name="isNavigation">Whether the onclick specified is url navigation</param>
        /// <param name="htmlAttributes">[Optional] Extra HTML attributes</param>
        public Button(EButton type, string text, string onclick, bool isNavigation, object htmlAttributes = null)
            : base(EHtmlTag.Button, htmlAttributes)
        {
            InnerHtml          = text;
            Attributes["type"] = type.GetStringValue();

            if (type == EButton.Cancel || type == EButton.Back)
            {
                OnClick = "javascript:window.history.back()";
                return;
            }

            if (string.IsNullOrWhiteSpace(onclick))
            {
                return;
            }

            if (isNavigation)
            {
                OnClick = "window.location='" + onclick + "'";
            }
            else
            {
                OnClick = "javascript:" + onclick;
            }
        }
 public static DialogResult Show(string Text, string Title, EButton button)
 {
     using (MessageWindow MW = new MessageWindow(Text, Title, button))
     {
         return(MW.ShowDialog());
     }
 }
Beispiel #7
0
        void OKButton_Click( EButton sender )
        {
            if( clickHandler != null )
                clickHandler( sender );

            SetShouldDetach();
        }
Beispiel #8
0
        void checkBoxEnabled_Click(ECheckBox sender)
        {
            EButton itemButton = listBox.ItemButtons[listBox.SelectedIndex];

            ((ECheckBox)itemButton.Controls["CheckBox"]).Checked = sender.Checked;

            UpdateCurrentPostEffect();
        }
Beispiel #9
0
 /// <summary>
 /// Create a HTML button
 /// </summary>
 /// <param name="html">Current HTML helper object</param>
 /// <param name="type">Button type</param>
 /// <param name="text">Button text</param>
 /// <param name="htmlAttributes">[Optional] Extra HTML attributes</param>
 /// <returns>A HTML Button</returns>
 public static Button Button(
     this HtmlHelper html,
     EButton type,
     string text,
     object htmlAttributes = null)
 {
     return(new Button(type, text, string.Empty, htmlAttributes));
 }
Beispiel #10
0
 public void OnRightPage(EButton button)
 {
     if (_current_page >= _max_page)
     {
         return;
     }
     _current_page++;
     _change_page_lab();
 }
Beispiel #11
0
        void OKButton_Click(EButton sender)
        {
            if (clickHandler != null)
            {
                clickHandler(sender);
            }

            SetShouldDetach();
        }
Beispiel #12
0
 public void OnLeftPage(EButton button)
 {
     if (_current_page <= 1)
     {
         return;
     }
     _current_page--;
     _change_page_lab();
 }
Beispiel #13
0
 /// <summary>
 /// Create a HTML button
 /// </summary>
 /// <param name="html">Current HTML helper object</param>
 /// <param name="type">Button type</param>
 /// <param name="text">Button text</param>
 /// <param name="onclick">Button javascript onclick event</param>
 /// <param name="isNavigation">Whether the onclick specified is url navigation</param>
 /// <param name="htmlAttributes">[Optional] Extra HTML attributes</param>
 /// <returns>A HTML Button</returns>
 public static Button Button(
     this HtmlHelper html,
     EButton type,
     string text,
     string onclick,
     bool isNavigation,
     object htmlAttributes = null)
 {
     return(new Button(type, text, onclick, isNavigation, htmlAttributes));
 }
Beispiel #14
0
    public void IUIObject_HasButton_OnClickButton(EButton eButtonName)
    {
        foreach (var pButton in _mapButton.Values)
        {
            DisableButton(pButton);
        }
        CurrentActivateButton(eButtonName);

        p_Event_OnClickButton.DoNotify(eButtonName);
    }
Beispiel #15
0
        public MessageWindow(string text, string title, EButton button, EIcon icon)
        {
            InitializeComponent();
            lblText.Text = text;
            this.Text    = title;
            this.Width   = lblText.Left + 10 + (int)lblText.CreateGraphics().MeasureString(lblText.Text, lblText.Font).Width;
            this.Top     = Screen.PrimaryScreen.Bounds.Height / 2 - this.Height / 2;
            this.Left    = Screen.PrimaryScreen.Bounds.Width / 2 - this.Width / 2; switch (icon)
            {
            case EIcon.Information:
                pictureBox1.Image = All.Properties.Resources.Infomation;
                break;

            case EIcon.Alert:
                pictureBox1.Image = All.Properties.Resources.Alter;
                break;

            case EIcon.Error:
                pictureBox1.Image = All.Properties.Resources.Error;
                break;

            case EIcon.Question:
                pictureBox1.Image = All.Properties.Resources.Question;
                break;
            }
            switch (button)
            {
            case EButton.OK:
                btnCancel.Visible = false;
                btnOk.Visible     = true;
                btnOk.Left        = this.Width / 2 - btnOk.Width / 2;
                btnOk.Text        = "确定";
                break;

            case EButton.OKCancel:
                btnCancel.Visible = true;
                btnOk.Visible     = true;
                btnOk.Left        = this.Width / 2 - btnOk.Width - 10;
                btnCancel.Left    = this.Width / 2 + 10;
                btnOk.Text        = "确定";
                btnCancel.Text    = "取消";
                break;

            case EButton.YesNo:
                btnCancel.Visible = true;
                btnOk.Visible     = true;
                btnOk.Left        = this.Width / 2 - btnOk.Width - 10;
                btnCancel.Left    = this.Width / 2 + 10;
                btnOk.Text        = "是";
                btnCancel.Text    = "否";
                break;
            }
            lblText.Text = text;
            this.Text    = title;
        }
Beispiel #16
0
        void Exit_Click(EButton sender)
        {
            GameEngineApp.Instance.Server_DestroyServer("The server has been destroyed");
            GameEngineApp.Instance.Client_DisconnectFromServer();

            //close all windows
            foreach (EControl control in GameEngineApp.Instance.ControlManager.Controls)
            {
                control.SetShouldDetach();
            }
            //create main menu
            GameEngineApp.Instance.ControlManager.Controls.Add(new MainMenuWindow());
        }
Beispiel #17
0
    /* protected & private - Field declaration         */


    // ========================================================================== //

    /* public - [Do] Function
     * 외부 객체가 호출(For External class call)*/

    public void IUIObject_HasButton_OnClickButton(EButton eButtonName)
    {
        switch (eButtonName)
        {
        case EButton.Button_Exit:

            break;

        case EButton.Button_Restart:

            break;
        }
        p_Event_OnClickButton.DoNotify(eButtonName);
    }
Beispiel #18
0
        /// <summary>
        ///   Creates a button
        /// </summary>
        /// <param name="html">Current HTML helpers</param>
        /// <param name="type">Button type</param>
        /// <param name="text">Button text</param>
        /// <param name="htmlAttributes">[Optional] Any extra html attributes</param>
        /// <returns>A HTML button element</returns>
        public static IExtendedHtmlString Button(this HtmlHelpers html, EButton type, string text, object htmlAttributes = null)
        {
            HtmlComponent component = new HtmlComponent(EHtmlTag.Button, htmlAttributes);

            component.Attributes["type"] = type.GetStringValue();
            component.InnerHtml          = text;

            if (type == EButton.Cancel)
            {
                component.Attributes["onclick"] = "javascript:window.history.back()";
            }

            return(new ExtendedHtmlString(component));
        }
Beispiel #19
0
    void ButtonPushed(EButton.ColorType color)
    {
        if (clickCount >= 3)
            return;

        clickCount++;

        if (phase == Phase.FIRST)
        {
            Piston piston = firstPistons[clickCount - 1];
            if (piston)
            {
                piston.color = color;
            }

            if (firstCombination[clickCount - 1] != color)
            {
                first_failed = true;
            }

            if (clickCount >= 3)
            {
                resetDelay.Start();
                if(!first_failed)
                    OnFirstPhase.Invoke();
            }
        }
        else if (phase == Phase.SECOND)
        {
            Piston piston = secondPistons[clickCount - 1];
            if (piston)
            {
                piston.color = color;
            }

            if (secondCombination[clickCount - 1] != color)
            {
                second_failed = true;
            }

            if (clickCount >= 3)
            {
                resetDelay.Start();
                if (!second_failed)
                    OnSecondPhase.Invoke();
            }
        }
    }
Beispiel #20
0
        public EventContentLine(int index, EventEditor parent)
        {
            this.index  = index;
            this.parent = parent;
            indexText   = new EText().Content(index.ToString()).RelativeSize(false).Width(20);
            nameField   = new ETextInputField().RelativeSize(true).OnInputUpdate((ETextInputField f, string val) => { parent.cfg.events[this.index] = val; nameText.Content(val); });
            nameText    = new EText().Content(parent.cfg.events[index]).RelativeSize(true);

            editButton       = new EButton().RelativeSize(false).Width(80).OnClicked((EButton b) => { parent.BeginEdit(index); }) + new EText().Content("edit");
            editFinishButton = new EButton().RelativeSize(false).Width(50).OnClicked((EButton b) => { parent.FinishEdit(); }) + new EText().Content("finish");
            deleteButton     = new EButton().RelativeSize(false).Width(30).OnClicked((EButton b) => { parent.RemoveEvent(index); }) + new EText().Content("x");

            children.Add(new EHorizontalLayout() + indexText + nameText + editButton);
            children.Add(new EHorizontalLayout() + indexText + nameField + editFinishButton + deleteButton);
            children.Add(new EHorizontalLayout() + indexText + nameText);
            this.OnConstruct(parent);
        }
Beispiel #21
0
 public PageListPanel(ComponentEditorWindow window)
 {
     EnableScroll(true);
     RelativeSize(true);
     addPageButton = new EButton().OnClicked((EButton b) => AddNewPage()).Width(70) + new EText("New page");
     dbPageList    = new EVerticalLayout().EnableScroll(true).RelativeSize(true);
     this.window   = window;
     this.children.Add(
         (new EHorizontalLayout().Height(16)
          + addPageButton
         )
         );
     this.children.Add(
         new ESpacer().Height(8)
         );
     this.children.Add(dbPageList);
 }
Beispiel #22
0
        void listBoxCheckBox_Click(ECheckBox sender)
        {
            //set listBox current item
            for (int n = 0; n < listBox.Items.Count; n++)
            {
                EButton itemButton = listBox.ItemButtons[n];
                if (itemButton.Controls["CheckBox"] == sender)
                {
                    listBox.SelectedIndex = n;
                }
            }

            checkBoxEnabled.Checked = sender.Checked;
            checkBoxEnabled.Enable  = (sender.Parent.Text != "HDR");

            UpdateCurrentPostEffect();
        }
        ///////////////////////////////////////////

        protected override void OnAttach()
        {
            base.OnAttach();

            //disable check for disconnection
            GameEngineApp.Instance.Client_AllowCheckForDisconnection = false;

            //register config fields
            EngineApp.Instance.Config.RegisterClassParameters(GetType());

            //create window
            window = ControlDeclarationManager.Instance.CreateControl(
                "Gui\\MultiplayerLoginWindow.gui");
            Controls.Add(window);

            MouseCover = true;
            BackColor  = new ColorValue(0, 0, 0, .5f);

            //initialize controls

            buttonCreateServer        = (EButton)window.Controls["CreateServer"];
            buttonCreateServer.Click += CreateServer_Click;

            buttonConnect        = (EButton)window.Controls["Connect"];
            buttonConnect.Click += Connect_Click;

            ((EButton)window.Controls["Exit"]).Click += Exit_Click;

            //generate user name
            if (string.IsNullOrEmpty(userName))
            {
                EngineRandom random = new EngineRandom();
                userName = "******" + random.Next(1000).ToString("D03");
            }

            editBoxUserName             = (EEditBox)window.Controls["UserName"];
            editBoxUserName.Text        = userName;
            editBoxUserName.TextChange += editBoxUserName_TextChange;

            editBoxConnectTo             = (EEditBox)window.Controls["ConnectTo"];
            editBoxConnectTo.Text        = connectToAddress;
            editBoxConnectTo.TextChange += editBoxConnectTo_TextChange;

            SetInfo("", false);
        }
        ///////////////////////////////////////////
        protected override void OnAttach()
        {
            base.OnAttach();

            //disable check for disconnection
            GameEngineApp.Instance.Client_AllowCheckForDisconnection = false;

            //register config fields
            EngineApp.Instance.Config.RegisterClassParameters( GetType() );

            //create window
            window = ControlDeclarationManager.Instance.CreateControl(
                "Gui\\MultiplayerLoginWindow.gui" );
            Controls.Add( window );

            MouseCover = true;
            BackColor = new ColorValue( 0, 0, 0, .5f );

            //initialize controls

            buttonCreateServer = (EButton)window.Controls[ "CreateServer" ];
            buttonCreateServer.Click += CreateServer_Click;

            buttonConnect = (EButton)window.Controls[ "Connect" ];
            buttonConnect.Click += Connect_Click;

            ( (EButton)window.Controls[ "Exit" ] ).Click += Exit_Click;

            //generate user name
            if( string.IsNullOrEmpty( userName ) )
            {
                EngineRandom random = new EngineRandom();
                userName = "******" + random.Next( 1000 ).ToString( "D03" );
            }

            editBoxUserName = (EEditBox)window.Controls[ "UserName" ];
            editBoxUserName.Text = userName;
            editBoxUserName.TextChange += editBoxUserName_TextChange;

            editBoxConnectTo = (EEditBox)window.Controls[ "ConnectTo" ];
            editBoxConnectTo.Text = connectToAddress;
            editBoxConnectTo.TextChange += editBoxConnectTo_TextChange;

            SetInfo( "", false );
        }
Beispiel #25
0
    public bool IsScreenPressed(EButton button, out RaycastHit raycast)
    {
        raycast = new RaycastHit();

        if (Input.GetMouseButtonDown((int)button))
        {
            RaycastHit hit;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100))
            {
                raycast = hit;

                return(true);
            }
        }

        return(false);
    }
Beispiel #26
0
            public PageContentPanel(ComponentEditorWindow window)
            {
                RelativeSize(true);
                UCellRelativeSize(false);
                UCellWidth(200);
                HandleSize(4);
                this.window    = window;
                delPageButton  = new EButton().Width(100).OnClicked((EButton b) => DelPage()) + new EText().Content("Del");
                editPageButton = new EButton().Width(100).OnClicked((EButton b) => EditPage()) + new EText().Content("Rename");

                namingBar = (new ESwitchTab().Height(16)
                             + (new EHorizontalLayout().Height(16)
                                + new EText().BindContent(() =>
                {
                    return(this.window.selectedPage == -1 ? "" : window.database.pages[this.window.selectedPage].pageName);
                })
                                .RelativeSize(true)
                                + editPageButton
                                + delPageButton
                                )
                             + (new EHorizontalLayout().Height(16)
                                + new ETextInputField().RelativeSize(true)
                                + editPageButton
                                + delPageButton
                                )
                             );

                compList = new EVerticalLayout().RelativeSize(true).EnableScroll(true);
                uchild   = (new EVerticalLayout().RelativeSize(true)
                            + namingBar
                            + (new EButton().Height(20) + new EText("Flags"))
                            + (new EVerticalLayout().RelativeSize(true).EnableScroll(true)
                               + new EBox().Content(new GUIContent("Placeholder")).Height(50)
                               + new EBox().Content(new GUIContent("Placeholder")).Height(50)
                               + new EBox().Content(new GUIContent("Placeholder")).Height(50)
                               )
                            );
                //page contents
                lchild = (
                    new EVerticalLayout().RelativeSize(true)
                    + (new EButton().OnClicked((EButton b) => window.OpenCompCreateTab()) + new EText("New component"))
                    + compList
                    );
            }
        public MessageWindow(string Text, string Title, EButton button, EIcon icon)
            : this(Text, Title, button)
        {
            switch (icon)
            {
            case EIcon.Information:
            case EIcon.Alert:
                pictureBox1.Image = All.Properties.Resources.information;
                break;

            case EIcon.Error:
                pictureBox1.Image = All.Properties.Resources.error1;
                break;

            case EIcon.Question:
                pictureBox1.Image = All.Properties.Resources.question2;
                break;
            }
        }
Beispiel #28
0
        void Start_Click(EButton sender)
        {
            if (string.IsNullOrEmpty(SelectedMapName))
            {
                return;
            }

            GameNetworkServer server = GameNetworkServer.Instance;

            //AllowToConnectDuringGame
            server.AllowToConnectNewClients = checkBoxAllowToConnectDuringGame.Checked;

            if (SelectedMapName == dynamicMapExampleText)
            {
                GameEngineApp.Instance.SetNeedMapCreateForDynamicMapExample();
            }
            else
            {
                GameEngineApp.Instance.SetNeedMapLoad(SelectedMapName);
            }
        }
        void Defaults_Click( EButton sender )
        {
            foreach( EControl control in window.Controls )
            {
                ECheckBox checkBox = control as ECheckBox;
                if( checkBox == null )
                    continue;

                PropertyInfo property = checkBox.UserData as PropertyInfo;
                if( property == null )
                    continue;

                DefaultValueAttribute[] attributes = (DefaultValueAttribute[])property.
                    GetCustomAttributes( typeof( DefaultValueAttribute ), true );

                if( attributes.Length == 0 )
                    continue;

                checkBox.Checked = (bool)attributes[ 0 ].Value;
            }
        }
Beispiel #30
0
    /* protected & private - Field declaration         */



    // ========================================================================== //

    /* public - [Do] Function
     * 외부 객체가 호출(For External class call)*/

    public void IUIObject_HasButton_OnClickButton(EButton eButtonName)
    {
        switch (eButtonName)
        {
        case EButton.Button_Exit:

            break;

        case EButton.Button_Restart:

            break;


        case EButton.Button_Resume:
            HomeKeeperGameManager.instance.DoGame_Resume();
            break;
        }



        p_Event_OnClickButton.DoNotify(eButtonName);
    }
        void CreateServer_Click(EButton sender)
        {
            if (string.IsNullOrEmpty(userName))
            {
                SetInfo("Invalid user name.", true);
                return;
            }

            SetInfo("Creating server...", false);

            GameNetworkServer server = new GameNetworkServer("NeoAxis Server",
                                                             EngineVersionInformation.Version, 128, true);

            int port = 56565;

            string error;

            if (!server.BeginListen(port, out error))
            {
                SetInfo("Error: " + error, true);
                server.Dispose("");
                return;
            }

            //create user for server
            server.UserManagementService.CreateServerUser(userName);

            //close all windows
            foreach (EControl control in GameEngineApp.Instance.ControlManager.Controls)
            {
                control.SetShouldDetach();
            }
            //create lobby window
            MultiplayerLobbyWindow lobbyWindow = new MultiplayerLobbyWindow();

            GameEngineApp.Instance.ControlManager.Controls.Add(lobbyWindow);

            GameEngineApp.Instance.Server_OnCreateServer();
        }
        void Defaults_Click( EButton sender )
        {
            foreach( EControl control in window.Controls )
            {
                ECheckBox checkBox = control as ECheckBox;
                if( checkBox == null )
                    continue;

                FieldInfo field = checkBox.UserData as FieldInfo;
                if( field == null )
                    continue;

                ConfigAttribute[] attributes = (ConfigAttribute[])field.GetCustomAttributes(
                    typeof( ConfigAttribute ), true );

                if( attributes.Length == 0 )
                    continue;

                Config.Parameter parameter = EngineApp.Instance.Config.GetParameter(
                    attributes[ 0 ].GroupPath, attributes[ 0 ].Name );

                checkBox.Checked = bool.Parse( parameter.DefaultValue );
            }
        }
Beispiel #33
0
        internal static void Click(EButton button, EEventType type)
        {
            //Call the imported function with the cursor's current position
            var  x         = (uint)Cursor.Position.X;
            var  y         = (uint)Cursor.Position.Y;
            uint eventType = 0;

            switch (button)
            {
            case EButton.Left:
                eventType = type == EEventType.Down ? MouseEventLeftDown : MouseEventLeftUp;
                break;

            case EButton.Right:
                eventType = type == EEventType.Down ? MouseEventRightDown : MouseEventRightUp;
                break;

            case EButton.Middle:
                eventType = type == EEventType.Down ? MouseEventMiddleDown : MouseEventMiddleUp;
                break;
            }

            mouse_event(eventType, x, y, 0, 0);
        }
Beispiel #34
0
 //
 public MessageBoxWindow( string messageText, string caption, EButton.ClickDelegate clickHandler )
 {
     this.messageText = messageText;
     this.caption = caption;
     this.clickHandler = clickHandler;
 }
Beispiel #35
0
        protected override void OnAttach()
        {
            base.OnAttach();

            window = ControlDeclarationManager.Instance.CreateControl( "Gui\\WorldLoadSaveWindow.gui" );
            Controls.Add( window );

            //worlds listBox
            {
                listBox = (EListBox)window.Controls[ "List" ];

                for( int slotIndex = 1; slotIndex <= slotCount; slotIndex++ )
                {
                    string fileName = GetWorldFileName( slotIndex );

                    string item;
                    if( VirtualFile.Exists( fileName ) )
                        item = fileName;
                    else
                        item = emptySlotText;

                    listBox.Items.Add( item );
                }

                listBox.SelectedIndexChange += listBox_SelectedIndexChanged;
                if( listBox.Items.Count != 0 && listBox.SelectedIndex == -1 )
                    listBox.SelectedIndex = 0;
                if( listBox.Items.Count != 0 )
                    listBox_SelectedIndexChanged( null );
            }

            //Load button event handler
            loadButton = (EButton)window.Controls[ "Load" ];
            loadButton.Click += delegate( EButton sender )
            {
                string item = (string)listBox.SelectedItem;
                if( item != null && item != emptySlotText )
                    Load( item );
            };

            //Save button event handler
            saveButton = (EButton)window.Controls[ "Save" ];
            saveButton.Click += delegate( EButton sender )
            {
                string item = (string)listBox.SelectedItem;
                if( item != null )
                {
                    if( item == emptySlotText )
                        item = GetWorldFileName( listBox.SelectedIndex + 1 );
                    Save( item );
                }
            };

            //Close button event handler
            ( (EButton)window.Controls[ "Close" ] ).Click += delegate( EButton sender )
            {
                SetShouldDetach();
            };

            UpdateButtonsEnabledFlag();
        }
 void CloseButton_Click( EButton sender )
 {
     SetShouldDetach();
 }
Beispiel #37
0
 void CloseButton_Click(EButton sender)
 {
     SetShouldDetach();
 }
        void CreateServer_Click( EButton sender )
        {
            if( string.IsNullOrEmpty( userName ) )
            {
                SetInfo( "Invalid user name.", true );
                return;
            }

            SetInfo( "Creating server...", false );

            GameNetworkServer server = new GameNetworkServer( "NeoAxis Server",
                EngineVersionInformation.Version, 128, true );

            int port = 56565;

            string error;
            if( !server.BeginListen( port, out error ) )
            {
                SetInfo( "Error: " + error, true );
                server.Dispose( "" );
                return;
            }

            //create user for server
            server.UserManagementService.CreateServerUser( userName );

            //close all windows
            foreach( EControl control in GameEngineApp.Instance.ControlManager.Controls )
                control.SetShouldDetach();
            //create lobby window
            MultiplayerLobbyWindow lobbyWindow = new MultiplayerLobbyWindow();
            GameEngineApp.Instance.ControlManager.Controls.Add( lobbyWindow );

            GameEngineApp.Instance.Server_OnCreateServer();
        }
        void Multiplayer_Click( EButton sender )
        {
            if( EngineApp.Instance.WebPlayerMode )
            {
                Log.Warning( "Networking is not supported for web player at this time." );
                return;
            }

            Controls.Add( new MultiplayerLoginWindow() );
        }
Beispiel #40
0
 public bool Check(EButton b)
 {
     return check;
 }
 public bool Check(EButton b)
 {
     return true;
 }
 //void Run_Click( EButton sender )
 //{
 //    GameEngineApp.Instance.SetNeedMapLoad("Maps\\SmallAntMap\\Map.map");
 //}
 void ToggleFaction_Click(EButton sender)
 {
     Faction = !Faction;
     Transit = true;
     window.Controls["SelectFaction"].Enable = false;
     window.Controls["ToggleFaction"].Enable = false;
     window.Controls["Run"].Enable = false;
 }
        void Faction_Click( EButton sender )
        {
            //GameEntities.RTS_Specific.GenericAntCharacter.
            //GameEntities.RTSUnit.Equals["Warrior_1"];
            MapSelect = true;
            Transition = true;
            window.Controls["SelectFaction"].Enable = false;
            foreach (Entity entity in Map.Instance.Children)
            {
                GameEntities.RTS_Specific.GenericAntCharacter warrioir = entity as GameEntities.RTS_Specific.GenericAntCharacter;
                if (warrioir != null)
                {
                    warrioir.fighting = true;

                }
            }
            //UpdateBaseAnimation("Attack", true, true, 1);
        }
 void Back_Click(EButton sender)
 {
     MapSelect = false;
     Transition = true;
     window.Controls["Back"].Enable = false;
 }
 void Exit_Click( EButton sender )
 {
     SetShouldDetach();
 }
        ///////////////////////////////////////////
        protected override void OnAttach()
        {
            base.OnAttach();

            //register config fields
            EngineApp.Instance.Config.RegisterClassParameters( GetType() );

            //create window
            window = ControlDeclarationManager.Instance.CreateControl(
                "Gui\\MultiplayerLobbyWindow.gui" );
            Controls.Add( window );

            ( (EButton)window.Controls[ "Exit" ] ).Click += Exit_Click;

            buttonStart = (EButton)window.Controls[ "Start" ];
            if( GameNetworkServer.Instance != null )
                buttonStart.Click += Start_Click;
            if( GameNetworkClient.Instance != null )
                buttonStart.Enable = false;

            listBoxUsers = (EListBox)window.Controls[ "Users" ];

            editBoxChatMessage = (EEditBox)window.Controls[ "ChatMessage" ];
            editBoxChatMessage.PreKeyDown += editBoxChatMessage_PreKeyDown;

            //comboBoxMaps
            {
                comboBoxMaps = (EComboBox)window.Controls[ "Maps" ];

                if( GameNetworkServer.Instance != null )
                {
                    //dynamic map example
                    comboBoxMaps.Items.Add( new MapItem( dynamicMapExampleText, false ) );
                    if( lastMapName == dynamicMapExampleText )
                        comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1;

                    string[] mapList = VirtualDirectory.GetFiles( "", "*.map",
                        SearchOption.AllDirectories );

                    foreach( string mapName in mapList )
                    {
                        //check for network support
                        if( VirtualFile.Exists( string.Format( "{0}\\NoNetworkSupport.txt",
                            Path.GetDirectoryName( mapName ) ) ) )
                        {
                            continue;
                        }

                        bool recommended =
                            mapName.Contains( "JigsawPuzzleGame" ) ||
                            mapName.Contains( "TankDemo" ) ||
                            mapName.Contains( "DeathmatchDemo" );

                        comboBoxMaps.Items.Add( new MapItem( mapName, recommended ) );
                        if( mapName == lastMapName )
                            comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1;
                    }

                    comboBoxMaps.SelectedIndexChange += comboBoxMaps_SelectedIndexChange;

                    if( comboBoxMaps.Items.Count != 0 && comboBoxMaps.SelectedIndex == -1 )
                        comboBoxMaps.SelectedIndex = 0;
                }
                else
                {
                    comboBoxMaps.Enable = false;
                }
            }

            //checkBoxAllowToConnectDuringGame
            {
                checkBoxAllowToConnectDuringGame = (ECheckBox)window.Controls[
                    "AllowToConnectDuringGame" ];

                if( GameNetworkServer.Instance != null )
                {
                    checkBoxAllowToConnectDuringGame.CheckedChange +=
                        checkBoxAllowToConnectDuringGame_CheckedChange;
                }
                else
                {
                    checkBoxAllowToConnectDuringGame.Enable = false;
                }
            }

            //server specific
            GameNetworkServer server = GameNetworkServer.Instance;
            if( server != null )
            {
                //for receive map name
                server.UserManagementService.AddUserEvent += Server_UserManagementService_AddUserEvent;

                //for chat support
                server.ChatService.ReceiveText += Server_ChatService_ReceiveText;
            }

            //client specific
            GameNetworkClient client = GameNetworkClient.Instance;
            if( client != null )
            {
                //for receive map name
                client.CustomMessagesService.ReceiveMessage +=
                    Client_CustomMessagesService_ReceiveMessage;

                //for chat support
                client.ChatService.ReceiveText += Client_ChatService_ReceiveText;

                AddMessage( string.Format( "Connected to server: \"{0}\"", client.RemoteServerName ) );
                foreach( string serviceName in client.ServerConnectedNode.RemoteServices )
                    AddMessage( string.Format( "Server service: \"{0}\"", serviceName ) );
            }

            UpdateControls();
        }
Beispiel #47
0
        /// <summary>
        /// This method handle the click event on inventory items
        /// </summary>
        /// <param name="sender">The button in the inventory box</param>
        public void InventoryItem_Click(EButton sender)
        {
            Unit playerUnit = GetPlayerUnit();

            //If there is an item is hole try to swap or change item position
            if (playerUnit.Inventory.CurrentHoldItem != string.Empty)
            {

                if (playerUnit.Inventory.CurrentHoldItem.StartsWith("A") && !sender.Name.ToString().StartsWith("A"))
                    (playerUnit as PlayerCharacter).RemoveAllWeapon();

                Item item = playerUnit.Inventory.SwapItem(playerUnit.Inventory.CurrentHoldItem, sender.Name);

                if (!playerUnit.Inventory.CurrentHoldItem.StartsWith("A") && sender.Name.ToString().StartsWith("A"))
                    try
                    {
                        (item as WeaponItem).OnSelect(playerUnit);
                    }
                    catch
                    {
                    }

            }
            else
            {
                //Try to select item
                playerUnit.Inventory.holdItem(sender.Name);
            }
        }
Beispiel #48
0
        protected override void OnAttach()
        {
            base.OnAttach();

            window = ControlDeclarationManager.Instance.CreateControl("Gui\\WorldLoadSaveWindow.gui");
            Controls.Add(window);

            //worlds listBox
            {
                listBox = (EListBox)window.Controls["List"];

                for (int slotIndex = 1; slotIndex <= slotCount; slotIndex++)
                {
                    string fileName = GetWorldFileName(slotIndex);

                    string item;
                    if (VirtualFile.Exists(fileName))
                    {
                        item = fileName;
                    }
                    else
                    {
                        item = emptySlotText;
                    }

                    listBox.Items.Add(item);
                }

                listBox.SelectedIndexChange += listBox_SelectedIndexChanged;
                if (listBox.Items.Count != 0 && listBox.SelectedIndex == -1)
                {
                    listBox.SelectedIndex = 0;
                }
                if (listBox.Items.Count != 0)
                {
                    listBox_SelectedIndexChanged(null);
                }
            }

            //Load button event handler
            loadButton        = (EButton)window.Controls["Load"];
            loadButton.Click += delegate(EButton sender)
            {
                string item = (string)listBox.SelectedItem;
                if (item != null && item != emptySlotText)
                {
                    Load(item);
                }
            };

            //Save button event handler
            saveButton        = (EButton)window.Controls["Save"];
            saveButton.Click += delegate(EButton sender)
            {
                string item = (string)listBox.SelectedItem;
                if (item != null)
                {
                    if (item == emptySlotText)
                    {
                        item = GetWorldFileName(listBox.SelectedIndex + 1);
                    }
                    Save(item);
                }
            };

            //Close button event handler
            ((EButton)window.Controls["Close"]).Click += delegate(EButton sender)
            {
                SetShouldDetach();
            };

            UpdateButtonsEnabledFlag();
        }
        void Exit_Click( EButton sender )
        {
            GameEngineApp.Instance.Server_DestroyServer( "The server has been destroyed" );
            GameEngineApp.Instance.Client_DisconnectFromServer();

            //close all windows
            foreach( EControl control in GameEngineApp.Instance.ControlManager.Controls )
                control.SetShouldDetach();
            //create main menu
            GameEngineApp.Instance.ControlManager.Controls.Add( new MainMenuWindow() );
        }
Beispiel #50
0
        void ControlPanelButton_Click( EButton sender )
        {
            int index = int.Parse( sender.Name.Substring( "ControlPanelButton".Length ) );

            TaskTargetChooseIndex = -1;

            List<RTSUnitAI.UserControlPanelTask> tasks = GetControlTasks();

            if( tasks == null || index >= tasks.Count )
                return;
            if( !tasks[ index ].Enable )
                return;

            RTSUnitAI.Task.Types taskType = tasks[ index ].Task.Type;

            switch( taskType )
            {
            //Stop, SelfDestroy
            case RTSUnitAI.Task.Types.Stop:
            case RTSUnitAI.Task.Types.SelfDestroy:
                foreach( Unit unit in selectedUnits )
                {
                    RTSUnitAI intellect = unit.Intellect as RTSUnitAI;
                    if( intellect == null )
                        continue;

                    if( IsEnableTaskTypeInTasks( intellect.GetControlPanelTasks(), taskType ) )
                        intellect.DoTask( new RTSUnitAI.Task( taskType ), false );
                }
                break;

            //ProductUnit
            case RTSUnitAI.Task.Types.ProductUnit:
                foreach( Unit unit in selectedUnits )
                {
                    RTSBuildingAI intellect = unit.Intellect as RTSBuildingAI;
                    if( intellect == null )
                        continue;

                    if( IsEnableTaskTypeInTasks( intellect.GetControlPanelTasks(), taskType ) )
                        intellect.DoTask( new RTSUnitAI.Task( taskType, tasks[ index ].Task.EntityType ), false );
                }
                break;

            //Move, Attack, Repair
            case RTSUnitAI.Task.Types.Move:
            case RTSUnitAI.Task.Types.Attack:
            case RTSUnitAI.Task.Types.Repair:
                //do taskTargetChoose
                TaskTargetChooseIndex = index;
                break;

            //BuildBuilding
            case RTSUnitAI.Task.Types.BuildBuilding:
                if( selectedUnits.Count == 1 )
                {
                    Unit unit = selectedUnits[ 0 ];
                    RTSUnitAI intellect = unit.Intellect as RTSUnitAI;
                    if( intellect != null )
                    {
                        //do taskTargetChoose
                        TaskTargetChooseIndex = index;

                        taskTargetBuildingType = (RTSBuildingType)tasks[ index ].Task.EntityType;

                        string meshName = null;
                        {
                            foreach( MapObjectTypeAttachedObject typeAttachedObject in
                                taskTargetBuildingType.AttachedObjects )
                            {
                                MapObjectTypeAttachedMesh typeMeshAttachedObject = typeAttachedObject as
                                    MapObjectTypeAttachedMesh;
                                if( typeMeshAttachedObject != null )
                                {
                                    meshName = typeMeshAttachedObject.MeshName;
                                    break;
                                }
                            }
                        }

                        taskTargetBuildMeshObject = SceneManager.Instance.CreateMeshObject( meshName );
                        taskTargetBuildSceneNode = new SceneNode();
                        taskTargetBuildSceneNode.Attach( taskTargetBuildMeshObject );
                        taskTargetBuildSceneNode.Visible = false;
                    }
                }
                break;

            }
        }
        void Start_Click( EButton sender )
        {
            if( string.IsNullOrEmpty( SelectedMapName ) )
                return;

            GameNetworkServer server = GameNetworkServer.Instance;

            //AllowToConnectDuringGame
            server.AllowToConnectNewClients = checkBoxAllowToConnectDuringGame.Checked;

            if( SelectedMapName == dynamicMapExampleText )
                GameEngineApp.Instance.SetNeedMapCreateForDynamicMapExample();
            else
                GameEngineApp.Instance.SetNeedMapLoad( SelectedMapName );
        }
 void Run_Click( EButton sender )
 {
     GameEngineApp.Instance.SetNeedMapLoad( "Maps\\MainDemo\\Map.map" );
 }
        void Connect_Click( EButton sender )
        {
            if( string.IsNullOrEmpty( userName ) )
            {
                SetInfo( "Invalid user name.", true );
                return;
            }

            SetInfo( "Connecting to the server...", false );

            GameNetworkClient client = new GameNetworkClient( true );
            client.ConnectionStatusChanged += Client_ConnectionStatusChanged;

            int port = 56565;
            string password = "";

            string error;
            if( !client.BeginConnect( connectToAddress, port, EngineVersionInformation.Version,
                userName, password, out error ) )
            {
                Log.Error( error );
                DisposeClient();
                return;
            }

            editBoxUserName.Enable = false;
            editBoxConnectTo.Enable = false;
            buttonCreateServer.Enable = false;
            buttonConnect.Enable = false;
        }