Ejemplo n.º 1
0
        private void SetupSoundSystemWithSoundtrack()
        {
            var registrationEmail = ProjectSettings.TryGet("Tooll.Sound.BassNetLicense.Email", "");
            var registrationKey   = ProjectSettings.TryGet("Tooll.Sound.BassNetLicense.Key", "");

            if (!String.IsNullOrEmpty(registrationEmail) && !String.IsNullOrEmpty(registrationKey))
            {
                BassNet.Registration(registrationEmail, registrationKey);
            }

            Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_LATENCY, IntPtr.Zero);

            while (!ProjectSettings.Contains("Soundtrack.Path") ||
                   !File.Exists((string)ProjectSettings["Soundtrack.Path"]))
            {
                ProjectSettings["Soundtrack.Path"] = UIHelper.PickFileWithDialog(".", ProjectSettings.TryGet("Soundtrack.Path", "."), "Select Soundtrack");
            }

            if (!ProjectSettings.Contains("Soundtrack.ImagePath"))
            {
                ProjectSettings["Soundtrack.ImagePath"] = UIHelper.PickFileWithDialog(".", ProjectSettings.TryGet("Soundtrack.Path", "."), "Select optional frequency image for soundtrack");
            }

            var soundFilePath = (string)ProjectSettings["Soundtrack.Path"];

            SetProjectSoundFile(soundFilePath);
        }
Ejemplo n.º 2
0
        private void SetupOperatorGitRepository()
        {
            const string NewtonSoftDllFilename = "Newtonsoft.Json.dll";

            if (File.Exists(NewtonSoftDllFilename))
            {
                throw new ShutDownException("Please remove " + NewtonSoftDllFilename + " from Tooll's directory because it will break compilation of Operators.",
                                            "Incorrect Settings");
            }

            var          operatorRepository       = new OperatorGitRepository(MetaManager.OPERATOR_PATH);
            const string operatorRepositoryUrl    = "Git.OperatorRepositoryURL";
            const string operatorRepositoryBranch = "Git.OperatorRepositoryBranch";

            if (ProjectSettings.Contains(operatorRepositoryUrl))
            {
                if (!ProjectSettings.Contains("Git.OperatorRepositoryBranch"))
                {
                    // https://streber.framefield.com/1636#5__operatorrepositoryremoteurl_definiert_aber_gitbranch_undefiniert_oder_fehlerhaft
                    throw new ShutDownException("Your project settings misses a definition for GitBranch.\n\nPlease fix this before restarting Tooll.",
                                                "Incorrect Settings");
                }

                var repositoryUrl = ProjectSettings[operatorRepositoryUrl] as string;
                var branchToUse   = ProjectSettings[operatorRepositoryBranch] as string;
                OperatorRepository            = operatorRepository;
                OperatorRepository.RemotePath = repositoryUrl;
                if (!Directory.Exists(MetaManager.OPERATOR_PATH))
                {
                    ShutdownMode = ShutdownMode.OnExplicitShutdown;

                    // https://streber.framefield.com/1636#1__operatorrepositoryremoteurl_definiert_aber_operators_fehlt
                    // fetch operators from url
                    var progressDialog = new CloneRepositoryProgressDialog(OperatorRepository)
                    {
                        LocalPath  = OperatorRepository.LocalPath,
                        RemotePath = OperatorRepository.RemotePath
                    };
                    progressDialog.ShowDialog();

                    ShutdownMode = ShutdownMode.OnMainWindowClose;
                }
                else if (!operatorRepository.IsValid)
                {
                    // https://streber.framefield.com/1636#2__operatorrepositoryremoteurl_definiert_aber_operators__git_fehlt
                    throw new ShutDownException(String.Format("git-repository is set to '{0}' in project settings, but 'Operators/.git' is missing or broken.\n\nPlease fix this or remove the Operators directory. Tooll will then fetch the Operators from the server.", repositoryUrl),
                                                "Missing Operator");
                }

                if (operatorRepository.LocalRepo.GetBranch() != branchToUse)
                {
                    // https://streber.framefield.com/1636#4__operatorrepositoryremoteurl_existiert_aber_operators__git__gt_branch____projectsettings_gitbranch
                    throw new ShutDownException(String.Format("Error: Your 'Operators/.git' branch '{0}' doesn't match the project settings '{1}'.\n\nPlease fix this before restarting Tooll.", operatorRepository.LocalRepo.GetBranch(), branchToUse),
                                                "Incorrect Settings");
                }

                var developerGit = new NGit.Api.Git(new FileRepository("./.git"));
                if (developerGit.GetRepository().GetAllRefs().Any())
                {
                    // valid developer git repository available, so check if branch of developer git repos matches operators repos branch
                    var developerGitBranch = developerGit.GetRepository().GetBranch();
                    if (developerGitBranch != branchToUse)
                    {
                        throw new ShutDownException(String.Format("Error: You starting Tooll as developer but your 'Operators/.git' branch '{0}' doesn't match the Tooll/.git branch '{1}'.\n\nPlease fix this before restarting Tooll.", branchToUse, developerGitBranch),
                                                    "Incorrect Settings");
                    }
                }

                OperatorRepository.Branch = branchToUse;
            }
            else
            {
                if (!Directory.Exists(MetaManager.OPERATOR_PATH) || !Directory.GetFiles(MetaManager.OPERATOR_PATH, "*.mop").Any())
                {
                    // https://streber.framefield.com/1636#6__operatorsrepositoryremoteurl_nicht_definiert_aber_operators__existiert_nicht
                    throw new ShutDownException("Your Operator directory is missing or empty.\n\nYou can define Git.OperatorsRepositoryURL and Git.OperatorRepositoryBranch in your projects settings to fetch a fresh copy.",
                                                "Incorrect Settings");
                }

                if (operatorRepository.IsValid)
                {
                    // https://streber.framefield.com/1636#3__operatorrepositoryremoteurl_nicht_definiert_aber_operators__git_existiert
                    throw new ShutDownException("Although you didn't specify a git repository in your project settings, the directory 'Operators/.git' exists.\n\nPlease fix this.",
                                                "Incorrect Settings");
                }
            }
        }