private static void HandleEditorConfigFiles( ILogger logger, DirectoryInfo projectPath, OptionsFile options) { logger.LogInformation($"{AppEmojisConstants.AreaEditorConfig} Working on EditorConfig files"); var rawCodingRulesDistributionProjectTargetBaseUrl = $"{RawCodingRulesDistributionBaseUrl}/{options.ProjectTarget.ToStringLowerCase()}"; EditorConfigHelper.HandleFile(logger, "root", rawCodingRulesDistributionProjectTargetBaseUrl, projectPath, string.Empty); foreach (var item in options.Mappings.Sample.Paths) { var path = new DirectoryInfo(item); EditorConfigHelper.HandleFile(logger, "sample", rawCodingRulesDistributionProjectTargetBaseUrl, path, "sample"); } foreach (var item in options.Mappings.Src.Paths) { var path = new DirectoryInfo(item); EditorConfigHelper.HandleFile(logger, "src", rawCodingRulesDistributionProjectTargetBaseUrl, path, "src"); } foreach (var item in options.Mappings.Test.Paths) { var path = new DirectoryInfo(item); EditorConfigHelper.HandleFile(logger, "test", rawCodingRulesDistributionProjectTargetBaseUrl, path, "test"); } }
public Config(string file) { if (!File.Exists(file)) { logger.Warning($"twitch config file \"{file}\" not found"); } else { // If the file does exist, read its content optionsFile = new OptionsFile(file); optionsFile.ReadFile(); OverlayServerPort = optionsFile.ReadValueInt(KEY_OVERLAY_SERVER_PORT, -1); if (OverlayServerPort == -1) { OverlayServerPort = null; } RetainInitalVotes = optionsFile.ReadValueBool(KEY_TWITCH_RETAIN_INITIAL_VOTES, false); TwitchChannelName = optionsFile.ReadValue(KEY_TWITCH_CHANNEL_NAME); TwitchOAuth = optionsFile.ReadValue(KEY_TWITCH_CHANNEL_OAUTH); TwitchUserName = optionsFile.ReadValue(KEY_TWITCH_CHANNEL_USER_NAME); VotingMode = optionsFile.ReadValueInt(KEY_TWITCH_VOTING_CHANCE_SYSTEM, 0) == 0 ? EVotingMode.MAJORITY : EVotingMode.PERCENTAGE; OverlayMode = (EOverlayMode)optionsFile.ReadValueInt(KEY_TWITCH_OVERLAY_MODE, 0); } }
private static void HandleDirectoryBuildPropsFiles( ILogger logger, DirectoryInfo projectPath, OptionsFile options) { logger.LogInformation($"{AppEmojisConstants.AreaDirectoryBuildProps} Working on Directory.Build.props files"); var rawCodingRulesDistributionProjectTargetBaseUrl = $"{RawCodingRulesDistributionBaseUrl}/{options.ProjectTarget.ToStringLowerCase()}"; DirectoryBuildPropsHelper.HandleFile(logger, "root", rawCodingRulesDistributionProjectTargetBaseUrl, options.UseLatestMinorNugetVersion, projectPath, string.Empty); foreach (var item in options.Mappings.Sample.Paths) { var path = new DirectoryInfo(item); DirectoryBuildPropsHelper.HandleFile(logger, "sample", rawCodingRulesDistributionProjectTargetBaseUrl, options.UseLatestMinorNugetVersion, path, "sample"); } foreach (var item in options.Mappings.Src.Paths) { var path = new DirectoryInfo(item); DirectoryBuildPropsHelper.HandleFile(logger, "src", rawCodingRulesDistributionProjectTargetBaseUrl, options.UseLatestMinorNugetVersion, path, "src"); } foreach (var item in options.Mappings.Test.Paths) { var path = new DirectoryInfo(item); DirectoryBuildPropsHelper.HandleFile(logger, "test", rawCodingRulesDistributionProjectTargetBaseUrl, options.UseLatestMinorNugetVersion, path, "test"); } }
public PersistableOption(string name, string category, object defaultValue, OptionsFile file, bool encrypted) { Name = name; Category = category; DefaultValue = defaultValue; file = File; Encrypted = encrypted; }
public void SaveOptions() { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/options3.opts"; FileStream stream = new FileStream(path, FileMode.Create); OptionsFile opts = new OptionsFile(masterSlider.value, sxSlider.value, muSlider.value, voSlider.value, atSlider.value, resolutionDropdown.value, fullscreenToggle.isOn, mouseLookX.sensitivityX, mouseLookY.sensitivityY); formatter.Serialize(stream, opts); stream.Close(); }
public static Task SanityCheckFiles( ILogger logger, DirectoryInfo projectPath, OptionsFile options) { ArgumentNullException.ThrowIfNull(projectPath); ArgumentNullException.ThrowIfNull(options); ProjectSanityCheckHelper.CheckFiles( throwIf: false, logger, projectPath, options.ProjectTarget); return(Task.Delay(1)); }
public static async Task HandleFiles( ILogger logger, DirectoryInfo projectPath, OptionsFile options) { ArgumentNullException.ThrowIfNull(projectPath); ArgumentNullException.ThrowIfNull(options); ProjectSanityCheckHelper.CheckFiles( throwIf: true, logger, projectPath, options.ProjectTarget); HandleEditorConfigFiles(logger, projectPath, options); if (options.ProjectTarget is SupportedProjectTargetType.DotNetCore or SupportedProjectTargetType.DotNet5 or SupportedProjectTargetType.DotNet6) { HandleDirectoryBuildPropsFiles(logger, projectPath, options); if (options.UseTemporarySuppressions) { DirectoryInfo?temporarySuppressionsPath = null; if (!string.IsNullOrEmpty(options.TemporarySuppressionsPath)) { temporarySuppressionsPath = new DirectoryInfo(options.TemporarySuppressionsPath); } FileInfo?buildFile = null; if (!string.IsNullOrEmpty(options.BuildFile)) { buildFile = new FileInfo(options.BuildFile); } await HandleTemporarySuppressions( logger, projectPath, buildFile, temporarySuppressionsPath, options.TemporarySuppressionAsExcel); } } }
private string applyOptions(string commandLine) { if (OptionsFile.IsEmpty()) { return(commandLine); } #if NET451 var path = AppDomain.CurrentDomain.BaseDirectory.AppendPath(OptionsFile); #else var path = AppContext.BaseDirectory.AppendPath(OptionsFile); #endif if (File.Exists(path)) { return($"{OptionReader.Read(path)} {commandLine}"); } return(commandLine); }
public Config(string file) { if (!File.Exists(file)) { logger.Warning($"twitch config file \"{file}\" not found"); } else { // If the file does exist, read its content optionsFile = new OptionsFile(file); optionsFile.ReadFile(); OverlayServerPort = optionsFile.ReadValueInt(KEY_OVERLAY_SERVER_PORT, -1); if (OverlayServerPort == -1) { OverlayServerPort = null; } RetainInitalVotes = optionsFile.ReadValueBool(KEY_TWITCH_RETAIN_INITIAL_VOTES, false); TwitchChannelName = optionsFile.ReadValue(KEY_TWITCH_CHANNEL_NAME); TwitchOAuth = optionsFile.ReadValue(KEY_TWITCH_CHANNEL_OAUTH); TwitchUserName = optionsFile.ReadValue(KEY_TWITCH_CHANNEL_USER_NAME); VotingMode = optionsFile.ReadValueInt(KEY_TWITCH_VOTING_CHANCE_SYSTEM, 0) == 0 ? EVotingMode.MAJORITY : EVotingMode.PERCENTAGE; OverlayMode = (EOverlayMode)optionsFile.ReadValueInt(KEY_TWITCH_OVERLAY_MODE, 0); string tmpPermittedUsernames = optionsFile.ReadValue(KEY_TWITCH_PERMITTED_USERNAMES, "").Trim().ToLower(); // lower case the username to allow case-insensitive comparisons if (tmpPermittedUsernames.Length > 0) { PermittedTwitchUsernames = tmpPermittedUsernames.Split(','); for (var i = 0; i < PermittedTwitchUsernames.Length; i++) { // remove any potential whitespaces around the usernames PermittedTwitchUsernames[i] = PermittedTwitchUsernames[i].Trim(); } } else { PermittedTwitchUsernames = new string[0]; } } }
public void UpdatePrefs() { // skip saving changes if we're still setting up the form if (!m_Ready) { return; } AudioHelper.PlayOneshot2D(SoundTweak); // some settings are computer-specific so we store those in PlayerPrefs PlayerPrefs.SetInt(OptionsFile.SAVEKEY_CONFIG_RES_W, m_SupportedRez[DropResolution.value].width); PlayerPrefs.SetInt(OptionsFile.SAVEKEY_CONFIG_RES_H, m_SupportedRez[DropResolution.value].height); PlayerPrefs.SetInt(OptionsFile.SAVEKEY_CONFIG_GFX_QUALITY, DropQuality.value); // the rest goes into the cloud-stored options file OptionsFile.SetInt(OptionsFile.SAVEKEY_CONFIG_VOL_SOUND, (int)SliderSound.value); OptionsFile.SetInt(OptionsFile.SAVEKEY_CONFIG_VOL_MUSIC, (int)SliderMusic.value); OptionsFile.SetInt(OptionsFile.SAVEKEY_CONFIG_SCREENSHAKE, ToggleScreenShake.isOn ? 1 : 0); OptionsFile.SetInt(OptionsFile.SAVEKEY_CONFIG_VSYNC, ToggleVsync.isOn ? 1 : 0); }
private IEnumerable <string> readOptions() { if (OptionsFile.IsEmpty()) { return(new string[0]); } #if NET451 var path = AppDomain.CurrentDomain.BaseDirectory.AppendPath(OptionsFile); #else var path = AppContext.BaseDirectory.AppendPath(OptionsFile); #endif if (File.Exists(path)) { var options = OptionReader.Read(path); return(StringTokenizer.Tokenize(options)); } return(new string[0]); }
private static OptionsFile CreateDefaultOptions( DirectoryInfo projectPath) { var options = new OptionsFile(); var directories = projectPath.GetDirectories(); var sampleName = directories.FirstOrDefault(x => x.Name.Equals("sample", StringComparison.OrdinalIgnoreCase))?.Name; if (sampleName is not null) { options.Mappings.Sample.Paths.Add(sampleName); } var srcName = directories.FirstOrDefault(x => x.Name.Equals("src", StringComparison.OrdinalIgnoreCase))?.Name ?? "src"; options.Mappings.Src.Paths.Add(srcName); var testName = directories.FirstOrDefault(x => x.Name.Equals("test", StringComparison.OrdinalIgnoreCase))?.Name ?? "test"; options.Mappings.Test.Paths.Add(testName); return(options); }
/// <summary> /// parse command line arguments and open forms</summary> public Main() { // inicialize program options = new ProgramOptions(); optionsFile = new OptionsFile(options); // create local server for comunication between local instances server = new Server(this); Program.log.write("Program: Main"); #if DEBUG Program.log.write("program: debug mode"); #else Program.log.write("program: release mode"); #endif // TODO: Load global options file and save it when application is closed // load options // options.loadOptions(); // get command line arguments this.args = Environment.GetCommandLineArgs(); #if DEBUG // custom debug arguments if (this.args.Length == 1 && Os.FileExists("test.diagram")) // if not argument is added from system ad some testing arguments { // comand line arguments testing this.args = new string[] { System.Reflection.Assembly.GetExecutingAssembly().Location ,"test.diagram" }; } #endif // process comand line arguments this.ParseCommandLineArguments(this.args); #if !MONO SystemEvents.PowerModeChanged += OnPowerChange; #endif // check if this program instance created server if (server.mainProcess) { this.mainform = new MainForm(this); } }
public void ApplyGraphics() { OptionsFile.ApplyGraphics(); }
public void Save() { PlayerPrefs.Save(); OptionsFile.Save(); }
public void LoadOptions() { resolutions = Screen.resolutions; List <string> resolutionList = new List <string>(); int currentResolutionIndex = 0; foreach (Resolution r in resolutions) { resolutionList.Add(r.width + " x " + r.height); if (r.width == Screen.currentResolution.width && r.height == Screen.currentResolution.height) { currentResolutionIndex = resolutionList.Count - 1; } } string path = Application.persistentDataPath + "/options3.opts"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); OptionsFile opts = formatter.Deserialize(stream) as OptionsFile; stream.Close(); resolutionDropdown.ClearOptions(); fullscreenToggle.isOn = opts.fullscreen; Screen.fullScreen = opts.fullscreen; currentResolutionIndex = opts.resoDropdownIndex; masterSlider.value = opts.masterValue; sxSlider.value = opts.sxValue; muSlider.value = opts.muValue; voSlider.value = opts.voValue; atSlider.value = opts.atValue; mouseLookX.sensitivityX = opts.xSensitivity; mouseLookY.sensitivityY = opts.ySensitivity; xSlider.value = opts.xSensitivity; ySlider.value = opts.ySensitivity; if (vcaController != null) { vcaController.SetMainVolume(opts.masterValue); vcaController.SetSxVolume(opts.sxValue); vcaController.SetMuVolume(opts.muValue); vcaController.SetVoVolume(opts.voValue); vcaController.SetAtVolume(opts.atValue); } } else { Debug.LogError("Options file not found"); } resolutionDropdown.AddOptions(resolutionList); resolutionDropdown.value = currentResolutionIndex; resolutionDropdown.RefreshShownValue(); ChangeResolution(); }
public PersistableOption(string name, string category, object defaultValue, OptionsFile file) : this(name, category, defaultValue, file, false) { ; }
private static async Task <bool> TwitchLogin() { string twitchUsername = null; string twitchOAuth = null; string twitchPollPass = null; m_twitchPollMode = File.Exists("chaosmod/.twitchpoll"); OptionsFile twitchFile = new OptionsFile("chaosmod/twitch.ini"); twitchFile.ReadFile(); m_twitchChannelName = twitchFile.ReadValue("TwitchUserName"); twitchUsername = twitchFile.ReadValue("TwitchChannelName"); twitchOAuth = twitchFile.ReadValue("TwitchChannelOAuth"); twitchPollPass = twitchFile.ReadValue("TwitchVotingPollPass"); m_disableNoVoteMsg = twitchFile.ReadValueBool("TwitchVotingDisableNoVoteRoundMsg", false); m_enableTwitchChanceSystem = twitchFile.ReadValueBool("TwitchVotingChanceSystem", false); m_enableTwitchChanceSystemRetainChance = twitchFile.ReadValueBool("TwitchVotingChanceSystemRetainChance", true); if (m_twitchPollMode) { OptionsFile configFile = new OptionsFile("chaosmod/config.ini"); configFile.ReadFile(); m_twitchPollDur = twitchFile.ReadValueInt("NewEffectSpawnTime", 30); if (m_twitchPollDur < 15 || m_twitchPollDur > 180) { SendToPipe("invalid_poll_dur"); return(false); } } if (m_twitchPollMode) { m_twitchPollClients = new List <IWebSocketConnection>(); m_twitchSocketServer = new WebSocketServer("ws://0.0.0.0:31337"); m_twitchSocketServer.RestartAfterListenError = true; m_twitchSocketServer.Start(socket => { socket.OnOpen += () => { Console.WriteLine($"New client! ({socket.ConnectionInfo.ClientIpAddress}:{socket.ConnectionInfo.ClientPort})"); socket.Send($"{{\"type\":\"auth\",\"data\":\"{twitchPollPass}\"}}"); m_twitchPollClients.Add(socket); }; socket.OnMessage += (msg) => { Console.WriteLine(msg); dynamic json = DeserializeJson(msg); if (json == null) { return; } string type = json.type; if (type == "created") { m_twitchPollUUID = json.id; } else if (type == "update") { dynamic choices = json.poll.choices; m_votes[0] = (int)choices[0].votes; m_votes[1] = (int)choices[1].votes; m_votes[2] = (int)choices[2].votes; m_twitchPollUUID = null; } }; socket.OnClose += () => { Console.WriteLine($"Connection to client {socket.ConnectionInfo.ClientIpAddress}:{socket.ConnectionInfo.ClientPort} closed."); m_twitchPollClients.Remove(socket); }; }); return(true); } if (string.IsNullOrWhiteSpace(m_twitchChannelName) || string.IsNullOrWhiteSpace(twitchUsername) || string.IsNullOrWhiteSpace(twitchOAuth)) { SendToPipe("invalid_login"); return(false); } ConnectionCredentials credentials = new ConnectionCredentials(twitchUsername, twitchOAuth); WebSocketClient webSocketClient = new WebSocketClient(); m_twitchClient = new TwitchClient(webSocketClient); m_twitchClient.Initialize(credentials, m_twitchChannelName); m_twitchClient.OnMessageReceived += OnMessageRecieved; bool failed = false; bool done = false; m_twitchClient.OnConnectionError += (object sender, OnConnectionErrorArgs e) => { failed = true; done = true; }; m_twitchClient.OnConnected += (object sender, OnConnectedArgs e) => { done = true; }; m_twitchClient.Connect(); int lastTick = Environment.TickCount; while (!done) { await Task.Delay(100); if (lastTick < Environment.TickCount - 3000) { failed = true; done = true; break; } } if (failed) { SendToPipe("invalid_login"); return(false); } Console.WriteLine("Logged into Twitch Account!"); done = false; m_twitchClient.OnJoinedChannel += (object sender, OnJoinedChannelArgs e) => { if (e.Channel.ToLower() == m_twitchChannelName.ToLower()) { done = true; } }; lastTick = Environment.TickCount; while (!done) { await Task.Delay(100); if (lastTick < Environment.TickCount - 1500) { failed = true; done = true; } } if (failed) { SendToPipe("invalid_channel"); return(false); } Console.WriteLine("Connected to Twitch Channel!"); return(true); }