public static void SetConfig(IModConfig config) { OverrideRefreshRate = config.GetSettingsValue <int>("refreshRateOverride"); VibrationStrength = config.GetSettingsValue <float>("vibrationIntensity"); ShowHelmet = config.GetSettingsValue <bool>("helmetVisibility"); ControllerOrientedMovement = config.GetSettingsValue <bool>("movementControllerOriented"); EnableGesturePrompts = config.GetSettingsValue <bool>("showGesturePrompts"); PreventCursorLock = config.GetSettingsValue <bool>("disableCursorLock"); DebugMode = config.GetSettingsValue <bool>("debug"); AutoHideToolbelt = config.GetSettingsValue <bool>("autoHideToolbelt"); HudScale = config.GetSettingsValue <float>("hudScale"); BypassFatalErrors = config.GetSettingsValue <bool>("bypassFatalErrors"); // OWML doesn't support negative slider values so I subtract it here. ToolbeltHeight = config.GetSettingsValue <float>("toolbeltHeight") - 1f; if (PreventCursorLock) { NomaiVRPatch.Empty <CursorManager>("Update"); Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } OnConfigChange?.Invoke(); }
/// <summary> /// Does the on configuration change. /// </summary> static internal void DoOnConfigChange() { try { OnConfigChange?.Invoke(); } catch (Exception ex) { RIExceptionManager.Publish(ex, "Failed during: RIEventManager.DoOnConfigChange()"); } }
protected override void OnMessage(MessageEventArgs e) { if (!e.IsText) { return; } var msg = e.Data; logger.Debug(new LogReceivedMessage { Message = msg, Session = ID }.ToJson()); string msgType = null; try { msgType = JObject.Parse(msg)["type"]?.ToObject <string>(); switch (msgType) { case "Authorization": OnAuthorization?.Invoke(this, Authorization.FromJson(msg)); return; case "Client.Initialized": OnClientInitialized?.Invoke(this, ClientInitialized.FromJson(msg)); return; case "Client.Register": OnClientRegister?.Invoke(this, ClientRegister.FromJson(msg)); return; case "Config.Change": if (Configurer) { OnConfigChange?.Invoke(this, ConfigChange.FromJson(msg)); } return; case "Config.Register": Configurer = true; Subscriber = true; OnConfigRegister?.Invoke(this); return; case "Config.Start": if (Configurer) { OnConfigStart?.Invoke(this); } return; case "Config.Stop": if (Configurer) { OnConfigStop?.Invoke(this); } return; case "Execution.StartRequest": OnExecutionRequest?.Invoke(this, ExecutionStartRequest.FromJson(msg)); return; case "Execution.Started": OnExecutionStarted?.Invoke(this, ExecutionStarted.FromJson(msg)); return; case "Execution.Stopped": OnExecutionStopped?.Invoke(this, ExecutionStopped.FromJson(msg)); return; case "Info.Message": OnInfo?.Invoke(this, InfoMessage.FromJson(msg)); return; case "Info.Subscribe": if (!Subscriber) { Subscriber = true; OnSubscribe?.Invoke(this); } return; case "Info.Unsubscribe": Subscriber = false; return; default: logger.Info(new LogReceivedUnknownMessageType { MessageType = msgType, Session = ID }.ToJson()); return; } } catch (Exception ex) { //logger.Error() logger.Error(new LogMessageHandlingError { Exception = ex, MessageType = msgType, Session = ID }.ToJson()); } }
public void ConfigEntryChanged(object sender, ConfigPropertyChangedEventArgs e) { if (sender is Lighting) { var lighting = (Lighting)sender; var discreteConfigObject = (from x in Config.Devices.Lightings where x.Description.Equals(lighting.Description) select x).FirstOrDefault(); if (discreteConfigObject != null) { switch (e.ConfigPropertyName) { case "Disabled": discreteConfigObject.Disabled = lighting.Disabled; break; case "TimerEnabled": discreteConfigObject.TimerEnabled = lighting.TimerEnabled; break; case "OffTime": discreteConfigObject.OffTime = lighting.OffTime; break; case "OnTime": discreteConfigObject.OnTime = lighting.OnTime; break; case "DeviceStatus": discreteConfigObject.DeviceStatus = lighting.DeviceStatus; break; } } else { Logger.Fatal($"Configobject for {lighting.Description} not found!"); } } else if (sender is Shutter) { var shutter = (Shutter)sender; var discreteConfigObject = (from x in Config.Devices.Shutters where x.Description.Equals(shutter.Description) select x).FirstOrDefault(); if (discreteConfigObject != null) { switch (e.ConfigPropertyName) { case "Disabled": discreteConfigObject.Disabled = shutter.Disabled; break; case "TimerEnabled": discreteConfigObject.TimerEnabled = shutter.TimerEnabled; break; case "OffTime": discreteConfigObject.CloseTime = shutter.OffTime; break; case "OnTime": discreteConfigObject.OpenTime = shutter.OnTime; break; case "DeviceStatus": discreteConfigObject.DeviceStatus = shutter.DeviceStatus; break; } } else { Logger.Fatal($"Configobject for {shutter.Description} not found!"); } } else if (sender is WindMonitor) { var windMonitor = (WindMonitor)sender; var discreteConfigObject = (from x in Config.Devices.WindMonitors where x.Description.Equals(windMonitor.Description) select x).FirstOrDefault(); if (discreteConfigObject != null) { switch (e.ConfigPropertyName) { case "Disabled": discreteConfigObject.Disabled = windMonitor.Disabled; break; } } Logger.Fatal($"Configobject for {windMonitor.Description} not found!"); } else { return; } SaveConfigFile(); OnConfigChange?.Invoke(this, EventArgs.Empty); }