public override void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { base.ApplyOverlayUpdate(OSU); string arbString = OSU.WidgetAppData?.TryGetPropertyPath <string>(PropertyPath); if (!string.IsNullOrEmpty(arbString)) { try { switch (TargetedObject) { case ObjectToTarget.Image: m_image.material.color = YUR_Formatter.ConvertToColor(arbString); break; case ObjectToTarget.Text: m_text.fontMaterial.color = YUR_Formatter.ConvertToColor(arbString); break; case ObjectToTarget.Renderer: m_rend.material.SetColor("_Color", YUR_Formatter.ConvertToColor(arbString)); break; default: break; } } catch (Exception e) { YUR_Manager.Instance.Log($"Could not get update because {e.Message}"); YUR_Manager.Instance.OnYURUpdate.RemoveListener(ApplyOverlayUpdate); } } }
public override void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { base.ApplyOverlayUpdate(OSU); int?arbInt = OSU.WidgetAppData?.TryGetPropertyPath <int>(PropertyPath); if (arbInt != null) { try { switch (TargetedObject) { case ObjectToTarget.Image: m_image.material.renderQueue = (int)arbInt; break; case ObjectToTarget.Text: m_text.fontMaterial.renderQueue = (int)arbInt; break; case ObjectToTarget.Renderer: m_rend.material.renderQueue = (int)arbInt; break; default: break; } } catch (Exception e) { YUR_Manager.Instance.Log($"Could not get update because {e.Message}"); YUR_Manager.Instance.OnYURUpdate.RemoveListener(ApplyOverlayUpdate); } } }
public override void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { base.ApplyOverlayUpdate(OSU); bool?arbBool = OSU.WidgetAppData?.TryGetPropertyPath <bool>(PropertyPath); if (arbBool != null) { try { switch (TargetedObject) { case ObjectToTarget.Image: m_image.enabled = (bool)arbBool; break; case ObjectToTarget.Text: m_text.enabled = (bool)arbBool; break; case ObjectToTarget.Renderer: m_rend.enabled = (bool)arbBool; break; default: break; } } catch (Exception e) { YUR_Manager.Instance.Log($"Could not get update because {e.Message}"); YUR_Manager.Instance.OnYURUpdate.RemoveListener(ApplyOverlayUpdate); } } }
private void OnOverlayStatusUpdate(OverlayStatusUpdate osu) { try { if (osu.HeartRate == null) { var calMetric = typeof(OverlayStatusUpdate).GetProperty("CalculationMetrics")?.GetValue(osu); var hr = calMetric?.GetType().GetProperty("EstHeartRate")?.GetValue(calMetric); if (hr != null) { OnHearRateDataReceived(Convert.ToInt32(hr)); } } else { OnHearRateDataReceived(Convert.ToInt32(osu.HeartRate.Value)); } } catch (Exception e) { // we don't want ANY uncaught exception, // YUR invokes the action on the freaking MAIN THREAD!!! logger.Critical($"Exception occured while handling YUR Mod Status Update: {e.Message}"); logger.Critical(e); } }
// This is used to update objects that use the YUR workout metrics private void OnStatusUpdate(OverlayStatusUpdate obj) { try { if (LatestOSU == null) { // Fires on the first instance of getting an OverlayStatusUpdate object Instance.Log("Starting YUR Service..."); OnYURStartup.Invoke(); LatestOSU = obj; } } catch (UnityException e) { Instance.Log("Could not fire startup event. Here's why: " + e.Message); } try { Instance.Log ( "Latest Status Update: " + "\n" + "Game Name: " + LatestOSU.GameName + "\n" + "Today Squat Count: " + LatestOSU.TodaySquatCount + "\n" + "User Rank: " + LatestOSU.Rank + "\n" + "Today's Calories: " + LatestOSU.TodayCalories + "\n" + "Time in Workout: " + LatestOSU.SecondsInWorkout ); OnYURUpdate.Invoke(obj); } catch (UnityException e) { Instance.Log("Couldn't fire update event. Here's why: " + e.Message); } }
public void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { m_object = gameObject; try { switch (ToggleObject) { case ObjectToToggle.GameObject: gameObject.SetActive(GetElementVisibilityFromTag(OSU, Tag, ValueToCheck, turnOnIfFalse)); break; case ObjectToToggle.Image: m_image.enabled = GetElementVisibilityFromTag(OSU, Tag, ValueToCheck, turnOnIfFalse); break; case ObjectToToggle.Text: m_text.enabled = GetElementVisibilityFromTag(OSU, Tag, ValueToCheck, turnOnIfFalse); break; default: break; } } catch (Exception e) { YUR_Manager.Instance.Log($"Could not update object because {e.Message}"); YUR_Manager.Instance.OnYURUpdate.RemoveListener(ApplyOverlayUpdate); } }
public override void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { base.ApplyOverlayUpdate(OSU); if (SFC == null) { SFC = transform.parent.transform.parent.GetChild(0).gameObject.GetComponent <SetFillColor>(); } if (SFC != null && SFC.enabled) { SFC.enabled = false; } if (m_rend == null) { m_rend = transform.parent.transform.parent.GetChild(0).gameObject.GetComponent <Renderer>(); } string arbText = OSU.WidgetAppData?.TryGetPropertyPath <string>(m_arbDataPath); try { if (!string.IsNullOrEmpty(arbText)) { m_rend.material.color = YUR_Formatter.ConvertToColor(arbText); } } catch (Exception e) { YUR_Manager.Instance.Log($"Could not get update because {e.Message}"); YUR_Manager.Instance.OnYURUpdate.RemoveListener(ApplyOverlayUpdate); } }
public void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { float val = GetDataTagValue(OSU, DataValue, out m_overrideFloor, out m_overrideCeiling); Floor = m_overrideFloor == null ? Floor : (float)m_overrideFloor; Ceiling = m_overrideCeiling == null ? Ceiling : (float)m_overrideCeiling; m_image.fillAmount = GetPercentage(val, Floor, Ceiling); }
public void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { string header = OSU.CurrentNotification.HeaderText; string body = OSU.CurrentNotification.Body; if (!string.IsNullOrEmpty(header) && !string.IsNullOrEmpty(body)) { YUR_Manager.Instance.Log($"Notification Found! Here's the header: {header}"); YUR_Manager.Instance.Log($"Notification Found! Here's the body: {body}"); OnNotificationHeader.Invoke(header); OnNotificationBody.Invoke(body); OnNotification.Invoke(); } }
public override void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { base.ApplyOverlayUpdate(OSU); float[] arbArray = OSU.WidgetAppData?.TryGetPropertyPath <float[]>(PropertyPath); try { m_transform.localPosition = YUR_Formatter.ConvertAs(arbArray, YurFormat.Vector3); } catch (Exception e) { YUR_Manager.Instance.Log($"Could not get update because {e.Message}"); YUR_Manager.Instance.OnYURUpdate.RemoveListener(ApplyOverlayUpdate); } }
public void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { try { if (m_text.enabled) { m_text.SetText(GetTextTagValue(OSU, TextValue)); } } catch (Exception e) { if (m_text == null) { m_text = GetComponent <TMP_Text>(); } YUR_Manager.Instance.Log($"Could not get update because {e.Message}"); } }
public override void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { base.ApplyOverlayUpdate(OSU); int?arbInt = OSU.WidgetAppData?.TryGetPropertyPath <int>(PropertyPath); if (arbInt != null) { try { m_text.fontSize = (int)arbInt; } catch (Exception e) { YUR_Manager.Instance.Log($"Could not get update because {e.Message}"); YUR_Manager.Instance.OnYURUpdate.RemoveListener(ApplyOverlayUpdate); } } }
public override void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { base.ApplyOverlayUpdate(OSU); float?arbFloat = OSU.WidgetAppData?.TryGetPropertyPath <float>(PropertyPath); if (arbFloat != null) { Color col = Color.white; try { switch (TargetedObject) { case ObjectToTarget.Image: col = m_image.color; col.a = (float)arbFloat; m_image.color = col; break; case ObjectToTarget.Text: col = m_text.fontMaterial.color; col.a = (float)arbFloat; m_text.fontMaterial.color = col; break; case ObjectToTarget.Renderer: col = m_rend.material.color; col.a = (float)arbFloat; m_rend.material.SetColor("_Color", col); break; default: break; } } catch (Exception e) { YUR_Manager.Instance.Log($"Could not get update because {e.Message}"); YUR_Manager.Instance.OnYURUpdate.RemoveListener(ApplyOverlayUpdate); } } }
public void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { switch (ObjectToTarget) { case ObjectToChangeColorOn.Renderer: m_rend.material.color = GetFillColorTagValue(OSU, FillColor); break; case ObjectToChangeColorOn.Image: m_image.color = GetFillColorTagValue(OSU, FillColor); break; case ObjectToChangeColorOn.Text: m_text.color = GetFillColorTagValue(OSU, FillColor); break; default: break; } }
public override void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { base.ApplyOverlayUpdate(OSU); object appObj = OSU.WidgetAppData?.TryGetPropertyPath <object>(PropertyPath); NewtonsoftSerializer s = new NewtonsoftSerializer(); print(s.SerializeObject(OSU.WidgetAppData)); print(appObj.GetType()); if (appObj != null) { print(appObj.GetType()); string formatted = ""; if (appObj != null) { if (appObj.GetType() == typeof(string)) { m_text.SetText((string)appObj); } else { float convertedFloat = (float)Convert.ChangeType(appObj, typeof(float)); try { m_text.SetText(YUR_Formatter.ConvertAs(convertedFloat, format)); } catch { formatted = ""; } } } } }
protected override string DefaultDataTag => "emission"; //lol, emission public override void ApplyOverlayUpdate(OverlayStatusUpdate OSU) { base.ApplyOverlayUpdate(OSU); string[] arbArray = OSU.WidgetAppData?.TryGetPropertyPath <string[]>(PropertyPath); if (arbArray != null) { string[] arr = arbArray.ToArray(); try { m_rend.material.SetColor("_EmissionColor", YUR_Formatter.ConvertToColor(arr[0])); m_rend.material.SetFloat("_Emission", float.Parse(arr[1])); } catch (Exception e) { YUR_Manager.Instance.Log($"Could not get update because {e.Message}"); YUR_Manager.Instance.OnYURUpdate.RemoveListener(ApplyOverlayUpdate); } } }
public static string GetTextTagValue(OverlayStatusUpdate info, YurDataValues tag) { string value = null; switch (tag) { case YurDataValues.TodaySquatCount: value = YUR_Formatter.ConvertAs(info.TodaySquatCount, YurFormat.NoSigValues); break; case YurDataValues.SquatCount: value = YUR_Formatter.ConvertAs(info.SquatCount, YurFormat.NoSigValues); break; case YurDataValues.EstOrHeartRate: value = YUR_Formatter.ConvertAs((info.HeartRate ?? 0) > 0? info.HeartRate.Value : info.CalculationMetrics.EstHeartRate, YurFormat.NoSigValues); break; case YurDataValues.HeartRate: value = YUR_Formatter.ConvertAs((info.HeartRate ?? 0), YurFormat.NoSigValues); break; case YurDataValues.TotalXP: value = YUR_Formatter.ConvertAs(info.TotalXP, YurFormat.NoSigValues); break; case YurDataValues.NextLevelXP: value = YUR_Formatter.ConvertAs((info.RankNextRequiredXP <= info.RankCurrentRequiredXP)? info.RankCurrentRequiredXP : info.RankNextRequiredXP, YurFormat.ShortK); break; case YurDataValues.CurrentLevelXP: value = YUR_Formatter.ConvertAs(info.RankCurrentRequiredXP, YurFormat.ShortK); break; case YurDataValues.EstRate: value = YUR_Formatter.ConvertAs(info.CalculationMetrics.EstHeartRate, YurFormat.NoSigValues); break; case YurDataValues.BurnRate: value = YUR_Formatter.ConvertAs(info.CalculationMetrics.BurnRate, YurFormat.OneSigValue); break; case YurDataValues.TodayCalories: value = YUR_Formatter.ConvertAs(info.TodayCalories, YurFormat.NoSigValues); break; case YurDataValues.TodayTime: value = YUR_Formatter.ConvertAs(info.SecondsToday, YurFormat.Time); break; case YurDataValues.TodayTimeNoSeconds: value = YUR_Formatter.ConvertAs(info.SecondsToday, YurFormat.TimeNoSeconds); break; case YurDataValues.WorkoutTime: value = YUR_Formatter.ConvertAs(info.SecondsInWorkout, YurFormat.Time); break; case YurDataValues.WorkoutTimeNoSeconds: value = YUR_Formatter.ConvertAs(info.SecondsInWorkout, YurFormat.TimeNoSeconds); break; case YurDataValues.WorkoutCalories: value = YUR_Formatter.ConvertAs(info.CurrentCalories, YurFormat.NoSigValues); break; case YurDataValues.UserRank: value = YUR_Formatter.ConvertAs(info.Rank, YurFormat.NoSigValues); break; case YurDataValues.ClockTime: value = YUR_Formatter.ConvertAs(DateTime.Now.ToString(), YurFormat.FormattedTime); break; case YurDataValues.ClockTimeSuffix: value = YUR_Formatter.ConvertAs(DateTime.Now.ToString(), YurFormat.TimeOfDaySignifier); break; case YurDataValues.XPCompletionPercentage: float nrankDiff = info.RankNextRequiredXP - info.RankCurrentRequiredXP; float caltonrank = info.RankNextRequiredXP - info.TotalXP; value = YUR_Formatter.ConvertAs((1 - (caltonrank / nrankDiff)), YurFormat.TwoSigValues); break; default: //unknown value = null; break; } return(value); }
public static Color GetFillColorTagValue(OverlayStatusUpdate info, YurFillColors tag) { Color value = Color.gray; switch (tag) { case YurFillColors.Default: value = ColorFunctions.GetDefaultColor(); break; case YurFillColors.SquatCountLevel: value = ColorFunctions.GetSquatColor(info.SquatCount); break; case YurFillColors.TodaySquatCountLevel: value = ColorFunctions.GetSquatColor(info.TodaySquatCount); break; case YurFillColors.EstOrHeartRateLevel: value = ColorFunctions.GetDayLevelColor((int)info.CalculationMetrics.ActivityLevel); break; case YurFillColors.WorkoutTimeLevel: value = ColorFunctions.GetWorkoutTimeColor(info.SecondsInWorkout); break; case YurFillColors.TodayTimeLevel: value = ColorFunctions.GetTodayTimeColor(info.SecondsToday); break; case YurFillColors.BurnRateLevel: value = ColorFunctions.GetDayLevelColor((int)info.CalculationMetrics.ActivityLevel); break; case YurFillColors.TodayCaloriesLevel: value = ColorFunctions.GetTodayCalsColor(info.TodayCalories); break; case YurFillColors.UserRank: Color colorToReturn; if (ColorUtility.TryParseHtmlString(info.RankCurrentColor, out colorToReturn)) { value = colorToReturn; } else { value = ColorFunctions.GetDefaultColor(); } break; case YurFillColors.UserRankContrast: value = ColorFunctions.GetReadableForeColor(info.RankCurrentColor); break; case YurFillColors.WorkoutCaloriesLevel: //TODO: what should this be? value = ColorFunctions.GetTodayCalsColor(info.CurrentCalories); break; default: //unknown value = ColorFunctions.GetDefaultColor(); break; } return(value); }
public static bool GetElementVisibilityFromTag(OverlayStatusUpdate info, YurVisibilityValues tag, int equalsVal, bool reverseResult) { bool?value; switch (tag) { case YurVisibilityValues.DayLevel: if (equalsVal <= 0) { value = false; } else { var calLvl = Mathf.Max(Mathf.Min((int)info.TodayCalories / 250, 4), 0); value = calLvl == equalsVal; } break; case YurVisibilityValues.HeartRateAvailable: value = ((info.HeartRate ?? 0) >= 10); break; case YurVisibilityValues.WorkoutInProgress: value = info.IsWorkoutInProgress; break; case YurVisibilityValues.BioDataValid: value = info.IsBioValid; break; case YurVisibilityValues.LoggedIn: value = info.IsLoggedIn; break; case YurVisibilityValues.Online: value = info.IsOnline; break; case YurVisibilityValues.NotificationActive: value = info.CurrentNotification != null; break; case YurVisibilityValues.NotificationHeaderActive: value = ((info.CurrentNotification?.Type ?? 0) & NotificationType.Header) != 0; break; case YurVisibilityValues.NotificationBodyActive: value = ((info.CurrentNotification?.Type ?? 0) & NotificationType.Body) != 0; break; case YurVisibilityValues.NotificationFooterActive: value = ((info.CurrentNotification?.Type ?? 0) & NotificationType.Footer) != 0; break; case YurVisibilityValues.TwentyFourHourTime: value = CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains("H"); break; case YurVisibilityValues.IsFace: value = string.Equals(m_object.transform.parent.transform.parent.name, "Face"); break; default: value = false; break; } if (!value.HasValue) { //hmm... default to visible? Gir's response: Nahhhhh value = false; } if (reverseResult) { value = !value.Value; } return(value.Value); }
public static float GetDataTagValue(OverlayStatusUpdate info, YurDataValues tag, out float?floorValue, out float?ceilingValue) { float value = 0.0f; floorValue = null; ceilingValue = null; switch (tag) { case YurDataValues.TodaySquatCount: value = info.TodaySquatCount; break; case YurDataValues.SquatCount: value = info.SquatCount; break; case YurDataValues.EstOrHeartRate: value = ((info.HeartRate ?? 0) > 0 ? info.HeartRate.Value : info.CalculationMetrics.EstHeartRate); break; case YurDataValues.HeartRate: value = (info.HeartRate ?? 0); break; case YurDataValues.TotalXP: value = info.TotalXP; break; case YurDataValues.XPCompletionPercentage: float nrankDiff = info.RankNextRequiredXP - info.RankCurrentRequiredXP; float caltonrank = info.RankNextRequiredXP - info.TotalXP; value = 1 - (caltonrank / nrankDiff); break; case YurDataValues.NextLevelXP: value = (info.RankNextRequiredXP <= info.RankCurrentRequiredXP) ? info.RankCurrentRequiredXP : info.RankNextRequiredXP; break; case YurDataValues.CurrentLevelXP: value = info.RankCurrentRequiredXP; break; case YurDataValues.EstRate: value = info.CalculationMetrics.EstHeartRate; break; case YurDataValues.BurnRate: value = info.CalculationMetrics.BurnRate; break; case YurDataValues.TodayCalories: value = info.TodayCalories; break; case YurDataValues.TodayTime: value = info.SecondsToday; break; case YurDataValues.TodayTimeNoSeconds: value = info.SecondsToday; break; case YurDataValues.WorkoutTime: value = info.SecondsInWorkout; break; case YurDataValues.WorkoutTimeNoSeconds: value = info.SecondsInWorkout; break; case YurDataValues.WorkoutCalories: value = info.CurrentCalories; break; case YurDataValues.UserRank: value = info.Rank; break; case YurDataValues.NotificationHeader: value = 0.0f; break; case YurDataValues.NotificationBody: value = 0.0f; break; case YurDataValues.NotificationFooter: value = 0.0f; break; case YurDataValues.ClockTime: value = 0.0f; break; case YurDataValues.ClockTimeSuffix: value = 0.0f; break; default: //unknown value = 0.0f; break; } return(value); }