Exemple #1
0
        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            Destroy();

            //NeoAxis shutdown
            WinFormsAppWorld.Shutdown();
        }
Exemple #2
0
 private void buttonDestroy_Click(object sender, EventArgs e)
 {
     WinFormsAppWorld.WorldDestroy();
     if (ExampleEngineApp.Instance != null)
     {
         ExampleEngineApp.Instance.Client_DisconnectFromServer();
     }
 }
        protected override void OnDestroy()
        {
            WinFormsAppWorld.WorldDestroy();
            Client_DisconnectFromServer();

            base.OnDestroy();
            instance = null;
        }
Exemple #4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //NeoAxis initialization
            if (!WinFormsAppWorld.Init(new ExampleEngineApp(EngineApp.ApplicationTypes.Simulation), this,
                                       "user:Logs/WinFormsAppExample.log", true, null, null, null, null))
            {
                Close();
                return;
            }

            UpdateVolume();

            renderTargetUserControl1.AutomaticUpdateFPS = 60;
            renderTargetUserControl1.KeyDown           += renderTargetUserControl1_KeyDown;
            renderTargetUserControl1.KeyUp     += renderTargetUserControl1_KeyUp;
            renderTargetUserControl1.MouseDown += renderTargetUserControl1_MouseDown;
            renderTargetUserControl1.MouseUp   += renderTargetUserControl1_MouseUp;
            renderTargetUserControl1.MouseMove += renderTargetUserControl1_MouseMove;
            renderTargetUserControl1.Tick      += renderTargetUserControl1_Tick;
            renderTargetUserControl1.Render    += renderTargetUserControl1_Render;
            renderTargetUserControl1.RenderUI  += renderTargetUserControl1_RenderUI;

            const string startMapName = "Maps\\MainMenu\\Map.map";

            //generate map list
            {
                string[] mapList = VirtualDirectory.GetFiles("", "*.map", SearchOption.AllDirectories);
                foreach (string mapName in mapList)
                {
                    comboBoxMaps.Items.Add(mapName);
                    if (mapName == startMapName)
                    {
                        comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1;
                    }
                }
            }

            //load map
            WinFormsAppWorld.MapLoad(startMapName, true);

            //set camera position
            if (Map.Instance != null)
            {
                MapCamera mapCamera = FindFirstMapCamera();
                if (mapCamera != null)
                {
                    freeCameraPosition  = mapCamera.Position;
                    freeCameraDirection = SphereDir.FromVector(mapCamera.Rotation.GetForward());
                }
                else
                {
                    freeCameraPosition  = Map.Instance.EditorCameraPosition;
                    freeCameraDirection = Map.Instance.EditorCameraDirection;
                }
            }
        }
Exemple #5
0
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            WinFormsAppWorld.WorldDestroy();
            if (ExampleEngineApp.Instance != null)
            {
                ExampleEngineApp.Instance.Client_DisconnectFromServer();
            }

            string host     = textBoxServerAddress.Text;
            int    port     = 56565;
            string userName = textBoxUserName.Text;
            string password = "";

            ExampleEngineApp.Instance.TryConnectToServer(host, port, userName, password);
        }
Exemple #6
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (!WinFormsAppWorld.Create(this))
            {
                forceCloseForm = true;
                Close();
                return;
            }

            LoadDockingConfig();

            UpdateWorkAreaMenuItems();
            statusBarToolStripMenuItem.Checked = showStatusBar;
            menuStrip.Visible        = true;
            toolStripGeneral.Visible = true;
            if (!showStatusBar)
            {
                statusStrip1.Visible = false;
            }
            dockPanel.Visible = true;

            //create work area views
            InitWorkAreaControl();

            //configure sound
            UpdateEngineSoundVolume();

            //update dock forms
            if (entityTypesForm != null)
            {
                entityTypesForm.UpdateTree();
            }

            //show text in Output window
            Log.Info("Powered by the NeoAxis 3D Engine.");
            Log.Info("-------------------------------------------------------------");

            timer1.Start();

            //load map
            MapLoad("Maps\\Demos\\Village Demo\\Map\\Map.map");

            if (SplashForm.Instance != null)
            {
                SplashForm.Instance.AllowClose = true;
            }
        }
Exemple #7
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //NeoAxis initialization
            if (!WinFormsAppWorld.Init(this, "user:Logs/WinFormsAppExample.log"))
            {
                Close();
                return;
            }

            UpdateVolume();

            //load map
            WinFormsAppWorld.MapLoad("Maps\\WindowsAppExample\\Map.map", true);

            renderTargetUserControl1.AutomaticUpdateFPS = 60;
            renderTargetUserControl1.Render            += renderTargetUserControl1_Render;
            renderTargetUserControl1.RenderUI          += renderTargetUserControl1_RenderUI;
        }
Exemple #8
0
        private void buttonLoadMap_Click(object sender, EventArgs e)
        {
            if (comboBoxMaps.SelectedIndex == -1)
            {
                return;
            }

            string mapName = (string)comboBoxMaps.SelectedItem;

            if (GameNetworkClient.Instance != null)
            {
                //network mode.
                //send request message "Example_MapLoad" to the server.
                GameNetworkClient.Instance.CustomMessagesService.SendToServer("Example_MapLoad", mapName);
            }
            else
            {
                //load map in single mode.

                WinFormsAppWorld.MapLoad(mapName, true);

                //set camera position
                if (Map.Instance != null)
                {
                    MapCamera mapCamera = FindFirstMapCamera();
                    if (mapCamera != null)
                    {
                        freeCameraPosition  = mapCamera.Position;
                        freeCameraDirection = SphereDir.FromVector(mapCamera.Rotation.GetForward());
                    }
                    else
                    {
                        freeCameraPosition  = Map.Instance.EditorCameraPosition;
                        freeCameraDirection = Map.Instance.EditorCameraDirection;
                    }
                }
            }
        }
        void Client_ConnectionStatusChanged(NetworkClient sender, NetworkConnectionStatuses status)
        {
            switch (status)
            {
            case NetworkConnectionStatuses.Disconnected:
            {
                //string text = "Unable to connect";
                //if( sender.DisconnectionReason != "" )
                //   text += ". " + sender.DisconnectionReason;
                //Log.Error( text );

                WinFormsAppWorld.WorldDestroy();
                Client_DisconnectFromServer();
            }
            break;

            case NetworkConnectionStatuses.Connecting:
                break;

            case NetworkConnectionStatuses.Connected:
                break;
            }
        }
Exemple #10
0
        bool MapLoad(string virtualFileName)
        {
            if (!WinFormsAppWorld.MapLoad(virtualFileName, true))
            {
                return(false);
            }

            //set camera position
            MapCamera mapCamera = FindFirstMapCamera();

            if (mapCamera != null)
            {
                freeCameraPosition  = mapCamera.Position;
                freeCameraDirection = SphereDir.FromVector(mapCamera.Rotation.GetForward());
            }
            else
            {
                freeCameraPosition  = Map.Instance.EditorCameraPosition;
                freeCameraDirection = Map.Instance.EditorCameraDirection;
            }

            return(true);
        }
 void Client_EntitySystemService_WorldDestroy(EntitySystemClientNetworkService sender,
                                              bool newMapWillBeLoaded)
 {
     WinFormsAppWorld.WorldDestroy();
 }
Exemple #12
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //NeoAxis initialization
            EngineApp.ConfigName = "user:Configs/DedicatedServer.config";
            EngineApp.ReplaceRenderingSystemComponentName = "RenderingSystem_NULL";
            EngineApp.ReplaceSoundSystemComponentName     = "SoundSystem_NULL";
            if (!WinFormsAppWorld.Init(new WinFormsAppEngineApp(EngineApp.ApplicationTypes.Simulation), this,
                                       "user:Logs/DedicatedServer.log", true, null, null, null, null))
            {
                Close();
                return;
            }
            WinFormsAppEngineApp.Instance.AutomaticTicks = false;

            Engine.Log.Handlers.InfoHandler += delegate(string text, ref bool dumpToLogFile)
            {
                Log("Log: " + text);
            };

            Engine.Log.Handlers.ErrorHandler += delegate(string text, ref bool handled, ref bool dumpToLogFile)
            {
                handled = true;
                timer1.Stop();
                MessageBox.Show(text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                timer1.Start();
            };

            Engine.Log.Handlers.FatalHandler += delegate(string text, string createdLogFilePath,
                                                         ref bool handled)
            {
                handled = true;
                timer1.Stop();
                MessageBox.Show(text, "Fatal", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            };

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

            //generate map list
            {
                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;
                    }

                    comboBoxMaps.Items.Add(mapName);
                    if (mapName == lastMapName)
                    {
                        comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1;
                    }
                }

                comboBoxMaps.SelectedIndexChanged += comboBoxMaps_SelectedIndexChanged;
            }

            checkBoxLoadMapAtStartup.Checked          = loadMapAtStartup;
            checkBoxAllowCustomClientCommands.Checked = allowCustomClientCommands;

            //load map at startup
            if (loadMapAtStartup && comboBoxMaps.SelectedItem != null)
            {
                Create();
                string mapName = comboBoxMaps.SelectedItem as string;
                if (!MapLoad(mapName))
                {
                    return;
                }
            }
        }
Exemple #13
0
        public MainForm()
        {
            instance = this;

            //NeoAxis initialization
            EngineApp.ConfigName = "user:Configs/WinFormsMultiViewAppExample.config";
            if (!WinFormsAppWorld.InitWithoutCreation(
                    new MultiViewAppEngineApp(EngineApp.ApplicationTypes.Simulation),
                    "user:Logs/WinFormsMultiViewAppExample.log", true, null, null, null, null))
            {
                Close();
                return;
            }

            EngineApp.Instance.Config.RegisterClassParameters(typeof(MainForm));

            //print information logs to the Output panel.
            Log.Handlers.InfoHandler += delegate(string text, ref bool dumpToLogFile)
            {
                if (outputForm != null)
                {
                    outputForm.Print(text);
                }
            };

            //show splash screen
            if (showSplashScreenAtStartup && !Debugger.IsAttached)
            {
                Image      image      = WinFormsMultiViewAppExample.Properties.Resources.ApplicationSplash;
                SplashForm splashForm = new SplashForm(image);
                splashForm.Show();
            }

            InitializeComponent();

            //restore window state
            if (showMaximized)
            {
                Screen screen = Screen.FromControl(this);
                if (screen.Primary)
                {
                    WindowState = FormWindowState.Maximized;
                }
            }
            else
            {
                Size = new Size(startWindowSize.X, startWindowSize.Y);
            }

            SuspendLayout();

            dockPanel         = new DockPanel();
            dockPanel.Visible = false;
            dockPanel.Parent  = this;
            dockPanel.Dock    = DockStyle.Fill;
            dockPanel.Name    = "dockPanel";
            dockPanel.BringToFront();

            //create dock forms
            entityTypesForm = new EntityTypesForm();
            dockForms.Add(entityTypesForm);
            propertiesForm = new PropertiesForm();
            dockForms.Add(propertiesForm);
            outputForm = new OutputForm();
            dockForms.Add(outputForm);
            example3DViewForm = new Example3DViewForm();
            dockForms.Add(example3DViewForm);

            menuStrip.Visible        = false;
            toolStripGeneral.Visible = false;

            ResumeLayout();
        }
Exemple #14
0
 private void closeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     WinFormsAppWorld.WorldDestroy();
 }