예제 #1
0
        public void ApplyParameters()
        {
            CryEngineParameters = new CryEngineParameters(Project);

            var engineDirectory = GetEngineDirectoryName(CryEngineParameters);

            if (engineDirectory == null)
            {
                LoggingService.LogError("Unable to set the correct mono-runtime! Make sure the launcher path is set in the project's settings.");
                return;
            }

            var engineRoot = (FilePath)engineDirectory;
            var monoRoot   = engineRoot.Combine("bin", "common", "Mono").FullPath;

            if (!Directory.Exists(monoRoot))
            {
                LoggingService.LogError("Unable to locate the mono-runtime at {0}! Make sure the launcher path is set to the correct launcher in the project's settings.", monoRoot);
                return;
            }

            var currentRuntime = Runtime.SystemAssemblyService.CurrentRuntime as MonoTargetRuntime;

            if (currentRuntime != null && ((FilePath)currentRuntime.Prefix).CanonicalPath.CompareTo(monoRoot.CanonicalPath) == 0)
            {
                // The right runtime is already set, so our job is done here.
                return;
            }

            // Apply proper mono runtime for CryEngine
            foreach (TargetRuntime runtime in Runtime.SystemAssemblyService.GetTargetRuntimes())
            {
                var monoRuntime = runtime as MonoTargetRuntime;
                if (monoRuntime == null)
                {
                    continue;
                }

                var monoRuntimePath = (FilePath)monoRuntime.Prefix;
                if (monoRuntimePath.CanonicalPath.CompareTo(monoRoot.CanonicalPath) == 0)
                {
                    CryEngineRuntime = monoRuntime;
                }
            }

            if (CryEngineRuntime == null)
            {
                var mri = new MonoRuntimeInfo(monoRoot.FullPath);
                CryEngineRuntime = MonoTargetRuntime.RegisterRuntime(mri);
            }

            Runtime.SystemAssemblyService.DefaultRuntime = CryEngineRuntime;

            Project.NotifyModified("RunTime");
        }
        private int Launch(CryEngineSoftDebuggerStartInfo startInfo)
        {
            if (_ceProcess != null)
            {
                throw new InvalidOperationException("CryEngine already running");
            }

            CryEngineParameters engineParameters = startInfo.ExecuteCommand.CryEngineParameters;
            var ceTarget = startInfo.ExecuteCommand.Target as CryEngineExecutionTarget;

            var launcherPath     = ceTarget != null ? ceTarget.LauncherPath : engineParameters.LauncherPath;
            var workingDirectory = Path.GetDirectoryName(launcherPath);

            var arguments = $"-project {engineParameters.ProjectPath}";

            if (engineParameters.CommandArguments != null)
            {
                arguments += " " + engineParameters.CommandArguments;
            }

            if (ceTarget != null && ceTarget.CommandArguments != null)
            {
                arguments += " " + ceTarget.CommandArguments;
            }

            var psi = new ProcessStartInfo(launcherPath)
            {
                Arguments        = startInfo.Arguments,
                UseShellExecute  = false,
                WorkingDirectory = workingDirectory
            };

            // NOTE: Temporarily C# will only work with the project-based approach (rather than the monolithic in-engine-project approach
            psi.Arguments += arguments;

            var instancePort = GetFirstAvailableRandomPort(17615, 18000);

            psi.Arguments += string.Format(" -monoDebuggerEnable -monoDebuggerPort {0}", instancePort);

            _ceProcess = Process.Start(psi);

            _ceProcess.EnableRaisingEvents = true;
            _ceProcess.Exited += (s, e) => EndSession();

            while (string.IsNullOrEmpty(_ceProcess.MainWindowTitle))
            {
                Thread.Sleep(20);
                _ceProcess.Refresh();
            }

            return(instancePort);
        }
예제 #3
0
        protected override void OnInitializeFromTemplate(ProjectCreateInformation projectCreateInfo, System.Xml.XmlElement template)
        {
            base.OnInitializeFromTemplate(projectCreateInfo, template);

            var engineParameters = new CryEngineParameters(Project);

            engineParameters.LauncherPath = projectCreateInfo.Parameters["BuildLocation"];
            engineParameters.ProjectPath  = projectCreateInfo.Parameters["ProjectLocation"];

            engineParameters.Save(Project);

            ApplyParameters();
        }
        public CryEngineOptionsPanelWidget(CryEngineGameProjectExtension projectExtension)
        {
            if (projectExtension == null)
            {
                throw new ArgumentNullException(nameof(projectExtension));
            }

            var engineParameters = new CryEngineParameters(projectExtension.Project);

            _launcherPath.Path     = engineParameters.LauncherPath;
            _projectPath.Path      = engineParameters.ProjectPath;
            _commandArguments.Text = engineParameters.CommandArguments;

            Build();
        }
예제 #5
0
        private string GetEngineDirectoryName(CryEngineParameters projectParameters)
        {
            if (projectParameters == null || string.IsNullOrWhiteSpace(projectParameters.LauncherPath))
            {
                return(null);
            }

            var binDirectory = Directory.GetParent(projectParameters.LauncherPath);

            if (binDirectory == null || binDirectory.Parent == null || binDirectory.Parent.Parent == null)
            {
                return(null);
            }

            var engineDirectory = binDirectory.Parent.Parent;

            return(engineDirectory.FullName);
        }
        public void Store(CryEngineGameProjectExtension projectExtension)
        {
            if (projectExtension == null)
            {
                return;
            }

            var engineParameters = new CryEngineParameters(projectExtension.Project)
            {
                LauncherPath     = _launcherPath.Path,
                ProjectPath      = _projectPath.Path,
                CommandArguments = _commandArguments.Text
            };

            engineParameters.Save(projectExtension.Project);

            projectExtension.ApplyParameters();
        }