// Start is called before the first frame update protected virtual void Start() { actionButton = GetComponent <Button>(); if (actionButton == null) { Debug.LogError("reose"); return; } actionButton.onClick.AddListener(() => PerformAction()); // turn off button gameObj actionButton.gameObject.SetActive(true); CheckState(); // Find & operate on our tooltip obj toolTip = GetComponentInChildren <ToolTip>(); if (toolTip == null) { Debug.LogError("Tooltip was not found in the children of " + gameObject.name); return; } LayoutGroup grGroup = GetComponentInParent <LayoutGroup>(); grGroup.enabled = false; RectTransform ttRectTransform = toolTip.GetComponent <RectTransform>(); //ttRectTransform.anchorMin = new Vector2(0.5f, 1f); //ttRectTransform.anchorMax = new Vector2(0.5f, 1.0f); ttRectTransform.SetParent(transform.parent, true); ttRectTransform.SetAsLastSibling(); toolTip.gameObject.SetActive(false); grGroup.enabled = true; }
protected virtual void OnSceneGUI() { if (DrawAttachPoints) { Handles.color = Color.Lerp(Color.clear, Color.red, 0.5f); float scale = toolTip.ContentScale * 0.01f; ToolTipUtility.GetAttachPointPositions(ref localAttachPointPositions, toolTip.LocalContentSize); foreach (Vector3 attachPoint in localAttachPointPositions) { Handles.SphereHandleCap(0, toolTip.ContentParentTransform.TransformPoint(attachPoint), Quaternion.identity, scale, EventType.Repaint); } } if (DrawHandles) { ToolTip toolTip = (ToolTip)target; float handleSize = 0; float arrowSize = 0; BaseMixedRealityLineDataProvider line = toolTip.GetComponent <BaseMixedRealityLineDataProvider>(); if (line == null) { Handles.color = Color.white; Handles.DrawDottedLine(toolTip.AnchorPosition, toolTip.AttachPointPosition, 5f); } EditorGUI.BeginChangeCheck(); Handles.color = Color.cyan; handleSize = HandleUtility.GetHandleSize(toolTip.PivotPosition) * handleSizeMultiplier; arrowSize = handleSize * 2; Vector3 newPivotPosition = Handles.FreeMoveHandle(toolTip.PivotPosition, Quaternion.identity, handleSize, Vector3.zero, Handles.SphereHandleCap); Handles.ArrowHandleCap(0, newPivotPosition, Quaternion.LookRotation(Vector3.up), arrowSize, EventType.Repaint); Handles.ArrowHandleCap(0, newPivotPosition, Quaternion.LookRotation(Vector3.forward), arrowSize, EventType.Repaint); Handles.ArrowHandleCap(0, newPivotPosition, Quaternion.LookRotation(Vector3.right), arrowSize, EventType.Repaint); Handles.color = Color.white; Handles.Label(newPivotPosition + (Vector3.up * arrowSize), "Pivot", EditorStyles.whiteLabel); Handles.color = Color.cyan; handleSize = HandleUtility.GetHandleSize(toolTip.AnchorPosition) * handleSizeMultiplier; arrowSize = handleSize * 2; Vector3 newAnchorPosition = Handles.FreeMoveHandle(toolTip.AnchorPosition, Quaternion.identity, HandleUtility.GetHandleSize(toolTip.AnchorPosition) * handleSizeMultiplier, Vector3.zero, Handles.SphereHandleCap); Handles.ArrowHandleCap(0, newAnchorPosition, Quaternion.LookRotation(Vector3.up), arrowSize, EventType.Repaint); Handles.ArrowHandleCap(0, newAnchorPosition, Quaternion.LookRotation(Vector3.forward), arrowSize, EventType.Repaint); Handles.ArrowHandleCap(0, newAnchorPosition, Quaternion.LookRotation(Vector3.right), arrowSize, EventType.Repaint); Handles.color = Color.white; Handles.Label(newAnchorPosition + (Vector3.up * arrowSize), "Anchor", EditorStyles.whiteLabel); if (EditorGUI.EndChangeCheck()) { if (newAnchorPosition != toolTip.AnchorPosition) { Undo.RegisterCompleteObjectUndo(toolTip.Anchor.transform, "Moved Anchor"); toolTip.Anchor.transform.position = newAnchorPosition; } if (newPivotPosition != toolTip.PivotPosition) { Undo.RegisterCompleteObjectUndo(toolTip.Pivot.transform, "Moved Pivot"); toolTip.Pivot.transform.position = newPivotPosition; } } if (EditAttachPoint) { EditorGUI.BeginChangeCheck(); Handles.color = Color.cyan; handleSize = HandleUtility.GetHandleSize(toolTip.AttachPointPosition) * handleSizeMultiplier; arrowSize = handleSize * 2; Vector3 newAttachPointPosition = Handles.FreeMoveHandle(toolTip.AttachPointPosition, Quaternion.identity, HandleUtility.GetHandleSize(toolTip.AttachPointPosition) * handleSizeMultiplier, Vector3.zero, Handles.SphereHandleCap); Handles.ArrowHandleCap(0, newAttachPointPosition, Quaternion.LookRotation(Vector3.up), arrowSize, EventType.Repaint); Handles.ArrowHandleCap(0, newAttachPointPosition, Quaternion.LookRotation(Vector3.forward), arrowSize, EventType.Repaint); Handles.ArrowHandleCap(0, newAttachPointPosition, Quaternion.LookRotation(Vector3.right), arrowSize, EventType.Repaint); Handles.color = Color.white; Handles.Label(newAttachPointPosition + (Vector3.up * arrowSize), "Attach Point", EditorStyles.whiteLabel); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(toolTip, "Moved Attach Point"); Undo.RegisterCompleteObjectUndo(toolTip.Anchor.transform, "Moved Attach Point"); toolTip.AttachPointPosition = newAttachPointPosition; } } } }
private void ConfigureTooltip() { if ((Object)tooltipSetting == (Object)null) { prevTooltip = null; } if ((Object)tooltipSetting != (Object)null && (Object)dirtyHoverTooltip != (Object)null && (Object)tooltipSetting == (Object)dirtyHoverTooltip) { ClearToolTip(dirtyHoverTooltip); } if ((Object)tooltipSetting != (Object)null) { tooltipSetting.RebuildDynamicTooltip(); if (tooltipSetting.multiStringCount == 0) { clearMultiStringTooltip(); } else if ((Object)prevTooltip != (Object)tooltipSetting || !multiTooltipContainer.activeInHierarchy) { prepareMultiStringTooltip(tooltipSetting); prevTooltip = tooltipSetting; } bool flag = multiTooltipContainer.transform.childCount != 0; toolTipWidget.SetActive(flag); if (flag) { RectTransform rectTransform = (!((Object)tooltipSetting.overrideParentObject == (Object)null)) ? tooltipSetting.overrideParentObject : tooltipSetting.GetComponent <RectTransform>(); RectTransform component = toolTipWidget.GetComponent <RectTransform>(); component.transform.SetParent(anchorRoot.transform); if (!tooltipSetting.worldSpace) { anchorRoot.anchoredPosition = rectTransform.transform.GetPosition(); } else { anchorRoot.anchoredPosition = WorldToScreen(rectTransform.transform.GetPosition()) + new Vector3((float)(Screen.width / 2), (float)(Screen.height / 2), 0f); } RectTransform rectTransform2 = anchorRoot; Vector2 anchoredPosition = rectTransform2.anchoredPosition; Vector2 up = Vector2.up; Vector2 pivot = rectTransform.rectTransform().pivot; float y = pivot.y; Vector2 sizeDelta = rectTransform.rectTransform().sizeDelta; rectTransform2.anchoredPosition = anchoredPosition - up * (y * sizeDelta.y); RectTransform rectTransform3 = anchorRoot; Vector2 anchoredPosition2 = rectTransform3.anchoredPosition; Vector2 right = Vector2.right; Vector2 pivot2 = rectTransform.rectTransform().pivot; float x = pivot2.x; Vector2 sizeDelta2 = rectTransform.rectTransform().sizeDelta; rectTransform3.anchoredPosition = anchoredPosition2 - right * (x * sizeDelta2.x); RectTransform rectTransform4 = anchorRoot; Vector2 anchoredPosition3 = rectTransform4.anchoredPosition; Vector2 right2 = Vector2.right; Vector2 sizeDelta3 = rectTransform.sizeDelta; rectTransform4.anchoredPosition = anchoredPosition3 + right2 * (sizeDelta3.x * tooltipSetting.parentPositionAnchor.x); RectTransform rectTransform5 = anchorRoot; Vector2 anchoredPosition4 = rectTransform5.anchoredPosition; Vector2 up2 = Vector2.up; Vector2 sizeDelta4 = rectTransform.sizeDelta; rectTransform5.anchoredPosition = anchoredPosition4 + up2 * (sizeDelta4.y * tooltipSetting.parentPositionAnchor.y); float num = 1f; CanvasScaler component2 = base.transform.parent.GetComponent <CanvasScaler>(); if ((Object)component2 == (Object)null) { component2 = base.transform.parent.parent.GetComponent <CanvasScaler>(); } if ((Object)component2 != (Object)null) { num = component2.scaleFactor; } RectTransform rectTransform6 = anchorRoot; Vector2 anchoredPosition5 = anchorRoot.anchoredPosition; float x2 = anchoredPosition5.x / num; Vector2 anchoredPosition6 = anchorRoot.anchoredPosition; rectTransform6.anchoredPosition = new Vector2(x2, anchoredPosition6.y / num); component.pivot = tooltipSetting.tooltipPivot; Vector2 vector3 = component.anchorMin = (component.anchorMax = new Vector2(0f, 0f)); component.anchoredPosition = tooltipSetting.tooltipPositionOffset * num; if (!tooltipSetting.worldSpace) { Rect rect = ((RectTransform)base.transform).rect; Vector3 position = base.transform.GetPosition(); float x3 = position.x; Vector3 position2 = base.transform.GetPosition(); Vector2 vector4 = new Vector2(x3, position2.y) + ScreenEdgePadding; Vector3 position3 = base.transform.GetPosition(); float x4 = position3.x; Vector3 position4 = base.transform.GetPosition(); Vector2 vector5 = new Vector2(x4, position4.y) + rect.width * Vector2.right + rect.height * Vector2.up - ScreenEdgePadding * Mathf.Max(1f, num); vector5.x *= num; vector5.y *= num; Vector3 position5 = component.GetPosition(); float x5 = position5.x; vector3 = component.pivot; float x6 = vector3.x; Vector2 sizeDelta5 = component.sizeDelta; Vector2 vector6 = default(Vector2); vector6.x = x5 - x6 * (sizeDelta5.x * num); Vector3 position6 = component.GetPosition(); float y2 = position6.y; Vector2 pivot3 = component.pivot; float y3 = pivot3.y; Vector2 sizeDelta6 = component.sizeDelta; vector6.y = y2 - y3 * (sizeDelta6.y * num); Vector3 position7 = component.GetPosition(); float x7 = position7.x; Vector2 pivot4 = component.pivot; float num2 = 1f - pivot4.x; Vector2 sizeDelta7 = component.sizeDelta; Vector2 vector7 = default(Vector2); vector7.x = x7 + num2 * (sizeDelta7.x * num); Vector3 position8 = component.GetPosition(); float y4 = position8.y; Vector2 pivot5 = component.pivot; float num3 = 1f - pivot5.y; Vector2 sizeDelta8 = component.sizeDelta; vector7.y = y4 + num3 * (sizeDelta8.y * num); Vector2 vector8 = Vector2.zero; if (vector6.x < vector4.x) { vector8.x = vector4.x - vector6.x; } if (vector7.x > vector5.x) { vector8.x = vector5.x - vector7.x; } if (vector6.y < vector4.y) { vector8.y = vector4.y - vector6.y; } if (vector7.y > vector5.y) { vector8.y = vector5.y - vector7.y; } vector8 /= num; component.anchoredPosition += vector8; } } } if (((RectTransform)base.transform).GetSiblingIndex() != base.transform.parent.childCount - 1) { ((RectTransform)base.transform).SetAsLastSibling(); } }
private void RefreshProgressBars() { if (currentlySelectedMinion != null && !currentlySelectedMinion.IsNull()) { MinionIdentity minionIdentity = currentlySelectedMinion as MinionIdentity; HierarchyReferences component = expectationsTooltip.GetComponent <HierarchyReferences>(); component.GetReference("Labels").gameObject.SetActive((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null); component.GetReference("MoraleBar").gameObject.SetActive((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null); component.GetReference("ExpectationBar").gameObject.SetActive((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null); component.GetReference("StoredMinion").gameObject.SetActive((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null); experienceProgressFill.gameObject.SetActive((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null); if ((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null) { expectationsTooltip.SetSimpleTooltip(string.Format(UI.TABLESCREENS.INFORMATION_NOT_AVAILABLE_TOOLTIP, (currentlySelectedMinion as StoredMinionIdentity).GetStorageReason(), currentlySelectedMinion.GetProperName())); experienceBarTooltip.SetSimpleTooltip(string.Format(UI.TABLESCREENS.INFORMATION_NOT_AVAILABLE_TOOLTIP, (currentlySelectedMinion as StoredMinionIdentity).GetStorageReason(), currentlySelectedMinion.GetProperName())); EXPCount.text = string.Empty; duplicantLevelIndicator.text = UI.TABLESCREENS.NA; } else { MinionResume component2 = minionIdentity.GetComponent <MinionResume>(); float num = MinionResume.CalculatePreviousExperienceBar(component2.TotalSkillPointsGained); float num2 = MinionResume.CalculateNextExperienceBar(component2.TotalSkillPointsGained); float fillAmount = (component2.TotalExperienceGained - num) / (num2 - num); EXPCount.text = Mathf.RoundToInt(component2.TotalExperienceGained - num) + " / " + Mathf.RoundToInt(num2 - num); duplicantLevelIndicator.text = component2.AvailableSkillpoints.ToString(); experienceProgressFill.fillAmount = fillAmount; experienceBarTooltip.SetSimpleTooltip(string.Format(UI.SKILLS_SCREEN.EXPERIENCE_TOOLTIP, Mathf.RoundToInt(num2 - num) - Mathf.RoundToInt(component2.TotalExperienceGained - num))); AttributeInstance attributeInstance = Db.Get().Attributes.QualityOfLife.Lookup(component2); AttributeInstance attributeInstance2 = Db.Get().Attributes.QualityOfLifeExpectation.Lookup(component2); float num3 = 0f; float num4 = 0f; if (!string.IsNullOrEmpty(hoveredSkillID) && !component2.HasMasteredSkill(hoveredSkillID)) { List <string> list = new List <string>(); List <string> list2 = new List <string>(); list.Add(hoveredSkillID); while (list.Count > 0) { for (int num5 = list.Count - 1; num5 >= 0; num5--) { if (!component2.HasMasteredSkill(list[num5])) { num3 += (float)(Db.Get().Skills.Get(list[num5]).tier + 1); if (component2.AptitudeBySkillGroup.ContainsKey(Db.Get().Skills.Get(list[num5]).skillGroup) && component2.AptitudeBySkillGroup[Db.Get().Skills.Get(list[num5]).skillGroup] > 0f) { num4 += 1f; } foreach (string priorSkill in Db.Get().Skills.Get(list[num5]).priorSkills) { list2.Add(priorSkill); } } } list.Clear(); list.AddRange(list2); list2.Clear(); } } float num6 = attributeInstance.GetTotalValue() + num4 / (attributeInstance2.GetTotalValue() + num3); float f = Mathf.Max(attributeInstance.GetTotalValue() + num4, attributeInstance2.GetTotalValue() + num3); while (moraleNotches.Count < Mathf.RoundToInt(f)) { GameObject gameObject = UnityEngine.Object.Instantiate(moraleNotch, moraleNotch.transform.parent); gameObject.SetActive(true); moraleNotches.Add(gameObject); } while (moraleNotches.Count > Mathf.RoundToInt(f)) { GameObject gameObject2 = moraleNotches[moraleNotches.Count - 1]; moraleNotches.Remove(gameObject2); UnityEngine.Object.Destroy(gameObject2); } for (int i = 0; i < moraleNotches.Count; i++) { if ((float)i < attributeInstance.GetTotalValue() + num4) { moraleNotches[i].GetComponentsInChildren <Image>()[1].color = moraleNotchColor; } else { moraleNotches[i].GetComponentsInChildren <Image>()[1].color = Color.clear; } } moraleProgressLabel.text = UI.SKILLS_SCREEN.MORALE + ": " + attributeInstance.GetTotalValue().ToString(); if (num4 > 0f) { LocText locText = moraleProgressLabel; locText.text = locText.text + " + " + GameUtil.ApplyBoldString(GameUtil.ColourizeString(moraleNotchColor, num4.ToString())); } while (expectationNotches.Count < Mathf.RoundToInt(f)) { GameObject gameObject3 = UnityEngine.Object.Instantiate(expectationNotch, expectationNotch.transform.parent); gameObject3.SetActive(true); expectationNotches.Add(gameObject3); } while (expectationNotches.Count > Mathf.RoundToInt(f)) { GameObject gameObject4 = expectationNotches[expectationNotches.Count - 1]; expectationNotches.Remove(gameObject4); UnityEngine.Object.Destroy(gameObject4); } for (int j = 0; j < expectationNotches.Count; j++) { if ((float)j < attributeInstance2.GetTotalValue() + num3) { if ((float)j < attributeInstance2.GetTotalValue()) { expectationNotches[j].GetComponentsInChildren <Image>()[1].color = expectationNotchColor; } else { expectationNotches[j].GetComponentsInChildren <Image>()[1].color = expectationNotchProspectColor; } } else { expectationNotches[j].GetComponentsInChildren <Image>()[1].color = Color.clear; } } expectationsProgressLabel.text = UI.SKILLS_SCREEN.MORALE_EXPECTATION + ": " + attributeInstance2.GetTotalValue().ToString(); if (num3 > 0f) { LocText locText2 = expectationsProgressLabel; locText2.text = locText2.text + " + " + GameUtil.ApplyBoldString(GameUtil.ColourizeString(expectationNotchColor, num3.ToString())); } if (num6 < 1f) { expectationWarning.SetActive(true); moraleWarning.SetActive(false); } else { expectationWarning.SetActive(false); moraleWarning.SetActive(true); } string empty = string.Empty; Dictionary <string, float> dictionary = new Dictionary <string, float>(); string text = empty; empty = text + GameUtil.ApplyBoldString(UI.SKILLS_SCREEN.MORALE) + ": " + attributeInstance.GetTotalValue() + "\n"; for (int k = 0; k < attributeInstance.Modifiers.Count; k++) { dictionary.Add(attributeInstance.Modifiers[k].GetDescription(), attributeInstance.Modifiers[k].Value); } List <KeyValuePair <string, float> > list3 = dictionary.ToList(); list3.Sort((KeyValuePair <string, float> pair1, KeyValuePair <string, float> pair2) => pair2.Value.CompareTo(pair1.Value)); foreach (KeyValuePair <string, float> item in list3) { text = empty; empty = text + " • " + item.Key + ": " + ((!(item.Value > 0f)) ? UIConstants.ColorPrefixRed : UIConstants.ColorPrefixGreen) + item.Value.ToString() + UIConstants.ColorSuffix + "\n"; } empty += "\n"; text = empty; empty = text + GameUtil.ApplyBoldString(UI.SKILLS_SCREEN.MORALE_EXPECTATION) + ": " + attributeInstance2.GetTotalValue() + "\n"; for (int l = 0; l < attributeInstance2.Modifiers.Count; l++) { text = empty; empty = text + " • " + attributeInstance2.Modifiers[l].GetDescription() + ": " + ((!(attributeInstance2.Modifiers[l].Value > 0f)) ? UIConstants.ColorPrefixGreen : UIConstants.ColorPrefixRed) + attributeInstance2.Modifiers[l].GetFormattedString(component2.gameObject) + UIConstants.ColorSuffix + "\n"; } expectationsTooltip.SetSimpleTooltip(empty); } } }