Exemplo n.º 1
0
        public ProjectProtocolHandler(Lifetime lifetime, IProtocol protocol, ILogger logger)
        {
            logger.Log(LoggingLevel.INFO, $"{protocol.Name} is protocol");
            BsmtRiderModel = new BSMT_RiderModel(lifetime, protocol);
            BSMT_RiderModel.RegisterDeclaredTypesSerializers(protocol.Serializers);

            BsmtRiderModel.FoundBeatSaberLocations
            .Set((t, _) => RdTask <string[]> .Successful(BeatSaberPathUtils.GetInstallDir().ToArray()));
        }
Exemplo n.º 2
0
        public override RdProjectTemplateContent CreateContent(DotNetProjectTemplateExpander expander,
                                                               IDotNetTemplateContentFactory factory,
                                                               int index, IDictionary <string, string> context)
        {
            var content   = factory.CreateNextParameters(new[] { expander }, index + 1, context);
            var parameter = expander.TemplateInfo.GetParameter(Name);

            if (parameter == null)
            {
                return(content);
            }


            var possiblePaths = BeatSaberPathUtils.GetInstallDir(); // Shell.Instance.GetComponent<ProjectProtocolHandler>().BsmtRiderModel.GetUserSettings.Sync(null).ConfiguredBeatSaberLocations;
            var options       = new List <RdProjectTemplateGroupOption>();

            foreach (var path in possiblePaths)
            {
                var optionContext = new Dictionary <string, string>(context)
                {
                    { Name, path }
                };
                var content1 = factory.CreateNextParameters(new[] { expander }, index + 1, optionContext);
                options.Add(new RdProjectTemplateGroupOption(path, path, null, content1));
            }

            var customPathBox = new RdProjectTemplateTextParameter(Name, "Custom path", null, Tooltip,
                                                                   RdTextParameterStyle.FileChooser,
                                                                   content);

            options.Add(new RdProjectTemplateGroupOption(
                            "Custom",
                            !possiblePaths.IsNullOrEmpty() ? "Custom" : "Custom (Beat Saber installation was not found)",
                            null,
                            customPathBox));

            return(new RdProjectTemplateGroupParameter(Name, "BeatSaberPath",
                                                       possiblePaths.Any() ? possiblePaths.Last() : string.Empty, null, options));
        }