static public GameObject SpawnBlackButton(GameObject parent, Vector2 givenSize, string givenLabel, List <TMPro.TextMeshProUGUI> texts, bool isFallback = false) { ColorBlock colourBlockA = new ColorBlock(); colourBlockA.disabledColor = new Color(1, 1, 1, 1); colourBlockA.highlightedColor = new Color(1, 1, 1, 1); colourBlockA.normalColor = new Color(1, 1, 1, 1); colourBlockA.pressedColor = new Color(1, 1, 1, 1); colourBlockA.colorMultiplier = 1; ColorBlock colourBlockB = new ColorBlock(); colourBlockB.disabledColor = new Color(0.094f, 0.094f, 0.094f, 0.286f); colourBlockB.highlightedColor = new Color(0.300f, 0.300f, 0.300f, 1.00f); colourBlockB.normalColor = new Color(0.300f, 0.300f, 0.300f, 1.00f); colourBlockB.pressedColor = new Color(0.500f, 0.500f, 0.500f, 1.000f); colourBlockB.colorMultiplier = 1; GameObject buttonA = ElementCreator.SpawnButtonSize(parent, Resources.panelTextures[4], colourBlockA, new Vector2(0, 1), givenSize); GameObject buttonB = ElementCreator.SpawnButtonOffset(buttonA, Resources.panelTextures[3], colourBlockB, isFallback); buttonA.GetComponent <RoR2.UI.HGButton>().interactable = false; Image highlightImageA = ElementCreator.SpawnImageOffset(new List <Image>(), buttonA, Resources.panelTextures[2], new Color(1, 1, 1, 1), new Vector2(0.5f, 0.5f), new Vector2(-4, -12), new Vector2(12, 4)); buttonA.GetComponent <RoR2.UI.HGButton>().imageOnHover = buttonB.GetComponent <Image>(); buttonB.GetComponent <RoR2.UI.HGButton>().imageOnHover = highlightImageA; ElementCreator.SpawnTextOffset(texts, buttonA, new Color(1, 1, 1, 1), 24, 0, new Vector2(12, 4), new Vector2(-12, -4)); texts[0].text = givenLabel; return(buttonB); }
static public GameObject SpawnBlueButton(GameObject parent, Vector2 givenPivot, Vector2 givenSize, string givenLabel, TMPro.TextAlignmentOptions alignment, List <Image> images, bool isFallback = false) { ColorBlock colourBlock = new ColorBlock(); colourBlock.disabledColor = new Color(0.255f, 0.201f, 0.201f, 0.714f); colourBlock.highlightedColor = new Color(0.988f, 1.000f, 0.693f, 0.733f); colourBlock.normalColor = new Color(0.327f, 0.403f, 0.472f, 1.000f); colourBlock.pressedColor = new Color(0.740f, 0.755f, 0.445f, 0.984f); colourBlock.colorMultiplier = 1; GameObject button = ElementCreator.SpawnButtonSize(parent, Resources.panelTextures[0], colourBlock, givenPivot, givenSize, isFallback); ElementCreator.SpawnImageOffset(images, button, Resources.panelTextures[7], new Color(1, 1, 1, 1), new Vector2(0.5f, 0.5f), new Vector2(-6, -6), new Vector2(6, 6)); images[images.Count - 1].gameObject.SetActive(false); ElementCreator.SpawnImageOffset(new List <Image>(), button, Resources.panelTextures[1], new Color(1, 1, 1, 0.286f), new Vector2(0.5f, 0.5f), new Vector2(0, 0), new Vector2(0, 0)); Image highlightImage = ElementCreator.SpawnImageOffset(new List <Image>(), button, Resources.panelTextures[2], new Color(1, 1, 1, 1), new Vector2(0.5f, 0.5f), new Vector2(-4, -12), new Vector2(12, 4)); button.GetComponent <RoR2.UI.HGButton>().imageOnHover = highlightImage; List <TMPro.TextMeshProUGUI> buttonText = new List <TMPro.TextMeshProUGUI>(); ElementCreator.SpawnTextOffset(buttonText, button, new Color(1, 1, 1, 1), 24, 0, new Vector2(12, 4), new Vector2(-12, -4)); buttonText[0].alignment = alignment; buttonText[0].text = givenLabel; buttonText[0].lineSpacing = -25; return(button); }
static void DrawInstructions() { List <TMPro.TextMeshProUGUI> instructionsText = new List <TMPro.TextMeshProUGUI>(); Vector3 position = new Vector3(); position.x = rootTransform.rect.width / 2f; position.y = -UIConfig.offsetVertical - UIConfig.blueButtonCount[Data.mode] * (UIConfig.blueButtonHeight + UIConfig.spacingVertical) - storeHeight - UIConfig.spacingVertical; ElementCreator.SpawnTextSize(instructionsText, rootTransform.gameObject, new Color(1, 1, 1, 1), 24, 0, new Vector2(0.5f, 1), new Vector2(500, UIConfig.blackButtonHeight), position); if (UIConfig.GetMode() == 0) { instructionsText[0].text = instructionTexts[0]; } else if (UIConfig.GetMode() == 1) { instructionsText[0].text = instructionTexts[1]; } else if (UIConfig.GetMode() == 2) { if (!DataShop.canDisablePurchasedBlueprints) { instructionsText[0].text = instructionTexts[2]; } else { instructionsText[0].text = instructionTexts[0]; } } shopInterfaces.Add(instructionsText[0].gameObject); }
internal SwTempPrimitive(IMathUtility mathUtils, IModeler modeler, SwTempBody[] bodies, bool isCreated) { m_MathUtils = mathUtils; m_Modeler = modeler; m_Creator = new ElementCreator <ISwTempBody[]>(CreateBodies, bodies, isCreated); }
public void As_RecursiveDescentAppliedToPropertyToArrayIndex_ReturnsNull() { JsonPathElement element = new JsonPathRecursiveDescentElement(ElementCreator.CreateAny(JsonPathElementType.Property)); var actual = element.As <JsonPathArrayIndexElement>(); actual.Should().BeNull(); }
public void As_PropertyToArrayIndex_ReturnsNull() { var element = ElementCreator.CreateAny(JsonPathElementType.Property); var actual = element.As <JsonPathArrayIndexElement>(); actual.Should().BeNull(); }
public void As_PropertyToProperty_Casts() { var element = ElementCreator.CreateAny(JsonPathElementType.Property); var actual = element.As <JsonPathPropertyElement>(); actual.Should().Be(element); }
public void CastTo_RecursiveDescentAppliedToPropertyToArrayIndex_Throws() { JsonPathElement element = new JsonPathRecursiveDescentElement(ElementCreator.CreateAny(JsonPathElementType.Property)); Action action = () => element.CastTo <JsonPathArrayIndexElement>(); action.Should().Throw <InvalidCastException>(); }
public void CastTo_PropertyToArrayIndex_Throws() { var element = ElementCreator.CreateAny(JsonPathElementType.Property); Action action = () => element.CastTo <JsonPathArrayIndexElement>(); action.Should().Throw <InvalidCastException>(); }
static public GameObject CreatePanel(Transform givenParent) { Image outline = ElementCreator.SpawnImageOffset(new List <Image>(), givenParent.gameObject, Resources.panelTextures[7], new Color(0.357f, 0.373f, 0.471f, 1), new Vector2(0, 1), new Vector2(0, 0), new Vector2(0, 0)); Image background = ElementCreator.SpawnImageOffset(new List <Image>(), outline.gameObject, null, new Color(0, 0, 0, 0.8f), new Vector2(0, 1), new Vector2(UIConfig.panelPadding, UIConfig.panelPadding), new Vector2(-UIConfig.panelPadding, -UIConfig.panelPadding)); background.gameObject.AddComponent <RectMask2D>(); return(outline.gameObject); }
public void GetUnderlyingElement_Property_ReturnsProperty() { var element = ElementCreator.CreateAny(JsonPathElementType.Property); var actual = element.GetUnderlyingElement(); actual.Should().Be(element); }
public void GetUnderlyingElement_RecursiveDescentAppliedToProperty_ReturnsProperty() { var property = ElementCreator.CreateAny(JsonPathElementType.Property); JsonPathElement element = new JsonPathRecursiveDescentElement(property); var actual = element.GetUnderlyingElement(); actual.Should().Be(property); }
internal SwConfiguration(SwDocument3D doc, IConfiguration conf, bool created) : base(conf) { m_Doc = doc; m_Creator = new ElementCreator <IConfiguration>(Create, conf, created); m_PropertiesLazy = new Lazy <ISwCustomPropertiesCollection>( () => new SwConfigurationCustomPropertiesCollection(m_Doc, Name)); }
internal SwConfiguration(IConfiguration conf, SwDocument3D doc, ISwApplication app, bool created) : base(conf, doc, app) { m_Doc = doc; m_Creator = new ElementCreator <IConfiguration>(Create, conf, created); m_PropertiesLazy = new Lazy <ISwCustomPropertiesCollection>( () => new SwConfigurationCustomPropertiesCollection(Name, m_Doc, OwnerApplication)); }
public void Matches(JsonPathElementType type, bool?expected) { var element = new JsonPathAnyPropertyElement(); var other = ElementCreator.CreateAny(type); bool?actual = element.Matches(other); actual.Should().Be(expected); }
public void Matches_Any_ReturnsFalse(JsonPathElementType type) { var element = new JsonPathArrayIndexElement(7); var other = ElementCreator.CreateAny(type); bool?actual = element.Matches(other); actual.Should().BeFalse(); }
public void Matches_Any(JsonPathElementType type, bool?expected) { var element = new JsonPathFilterExpressionElement("@.name"); var other = ElementCreator.CreateAny(type); bool?actual = element.Matches(other); actual.Should().Be(expected); }
public void Matches_Any(JsonPathElementType type, bool?expected) { var element = new JsonPathArraySliceElement(null, null); var other = ElementCreator.CreateAny(type); bool?actual = element.Matches(other); actual.Should().Be(expected); }
internal SwTempPrimitive(SwTempBody[] bodies, ISwApplication app, bool isCreated) { m_App = app; m_MathUtils = m_App.Sw.IGetMathUtility(); m_Modeler = m_App.Sw.IGetModeler(); m_Creator = new ElementCreator <ISwTempBody[]>(CreateBodies, bodies, isCreated); }
public void Matches_Any_ReturnsFalse(JsonPathElementType type) { var element = new JsonPathPropertyListElement(new[] { "name0", "name1" }); var other = ElementCreator.CreateAny(type); bool?actual = element.Matches(other); actual.Should().BeFalse(); }
public void Matches_Any(JsonPathElementType type, bool?expected) { var element = new JsonPathRecursiveDescentElement(new JsonPathArrayIndexElement(0)); var other = ElementCreator.CreateAny(type); bool?actual = element.Matches(other); actual.Should().Be(expected); }
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- static void DrawShading() { float shadingHeight = 270; Image shadingA = ElementCreator.SpawnImageOffset(new List <Image>(), rootTransform.gameObject, Resources.panelTextures[8], new Color(0, 0, 0, 1), new Vector2(0, 1), new Vector2(0, 0), new Vector2(0, -(rootTransform.rect.height - shadingHeight))); Image shadingB = ElementCreator.SpawnImageOffset(new List <Image>(), rootTransform.gameObject, Resources.panelTextures[9], new Color(0, 0, 0, 1), new Vector2(0, 1), new Vector2(0, rootTransform.rect.height - shadingHeight), new Vector2(0, 0)); shopInterfaces.Add(shadingA.gameObject); shopInterfaces.Add(shadingB.gameObject); }
public void As_RecursiveDescentAppliedToPropertyToProperty_Casts() { var property = ElementCreator.CreateAny(JsonPathElementType.Property); JsonPathElement element = new JsonPathRecursiveDescentElement(property); var actual = element.As <JsonPathPropertyElement>(); actual.Should().Be(property); }
static public void CreateCanvas() { if (rootTransform != null) { DestroyImmediate(rootTransform.transform.parent.gameObject); } GameObject root = new GameObject(); root.name = "Canvas"; Canvas canvas = root.AddComponent <Canvas>(); canvas.renderMode = RenderMode.ScreenSpaceOverlay; canvas.sortingOrder = -1; CanvasScaler canvasScaler = root.AddComponent <CanvasScaler>(); canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; canvasScaler.matchWidthOrHeight = 1; canvasScaler.referenceResolution = new Vector2(1920, 1080); CanvasGroup canvasGroup = root.AddComponent <CanvasGroup>(); canvasGroup.blocksRaycasts = false; root.AddComponent <GraphicRaycaster>(); root.AddComponent <RoR2.UI.MPEventSystemProvider>(); Image background = ElementCreator.SpawnImageOffset(new List <Image>(), root, null, new Color(0, 0, 0, 0), new Vector2(0, 1), new Vector2(0, 0), new Vector2(0, 0)); background.raycastTarget = true; GameObject rootTransformObject = new GameObject("Base"); rootTransformObject.transform.parent = root.transform; rootTransform = rootTransformObject.AddComponent <RectTransform>(); rootTransform.pivot = new Vector2(0, 0); rootTransform.anchorMin = Vector2.zero; rootTransform.anchorMax = Vector2.one; rootTransform.offsetMin = Vector2.zero; rootTransform.offsetMax = Vector2.zero; rootTransform.localScale = Vector3.one; CanvasGroup canvasGroupChild = rootTransformObject.AddComponent <CanvasGroup>(); canvasGroupChild.blocksRaycasts = true; itemDropListMenu = rootTransform.gameObject.AddComponent <RoR2.UI.MainMenu.BaseMainMenuScreen>(); itemDropListMenu.desiredCameraTransform = new GameObject().transform; itemDropListMenu.desiredCameraTransform.position = new Vector3(20, 40, 0); itemDropListMenu.desiredCameraTransform.eulerAngles = new Vector3(90, 20, 0); //itemDropListMenu.desiredCameraTransform.position = new Vector3(60, 10, 35); //itemDropListMenu.desiredCameraTransform.eulerAngles = new Vector3(40, 165, 0); itemDropListMenu.desiredCameraTransform.localScale = new Vector3(1, 1, 1); itemDropListMenu.onEnter = new UnityEngine.Events.UnityEvent(); itemDropListMenu.onEnter.AddListener(OpenStartingItems); itemDropListMenu.onExit = new UnityEngine.Events.UnityEvent(); itemDropListMenu.onExit.AddListener(CloseStartingItems); }
public void IsOfType_MultipleTypes(bool expected, JsonPathElementType elementType, bool isRecursiveDescent, params JsonPathElementType[] typeArgs) { var element = isRecursiveDescent ? new JsonPathRecursiveDescentElement(ElementCreator.CreateAny(elementType)) : ElementCreator.CreateAny(elementType); bool actual = element.IsOfType(typeArgs); actual.Should().Be(expected); }
protected SwSketchSegment(ISwDocument doc, ISketchSegment seg, bool created) : base(doc, seg) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } m_SketchMgr = doc.Model.SketchManager; m_Creator = new ElementCreator <ISketchSegment>(CreateEntity, seg, created); }
public void IsOfTypeInRange(bool expected, JsonPathElementType elementType, bool isRecursiveDescent, JsonPathElementType firstType, JsonPathElementType lastType) { var element = isRecursiveDescent ? new JsonPathRecursiveDescentElement(ElementCreator.CreateAny(elementType)) : ElementCreator.CreateAny(elementType); bool actual = element.IsOfTypeInRange(firstType, lastType); actual.Should().Be(expected); }
public void IsOfType_SingleType(JsonPathElementType elementType, bool isRecursiveDescent, JsonPathElementType typeArg, bool expected) { var element = isRecursiveDescent ? new JsonPathRecursiveDescentElement(ElementCreator.CreateAny(elementType)) : ElementCreator.CreateAny(elementType); bool actual = element.IsOfType(typeArg); actual.Should().Be(expected); }
internal SwBoundingBox(ISwDocument doc, ISwApplication app) { m_Doc = doc; m_MathUtils = app.Sw.IGetMathUtility(); m_Creator = new ElementCreator <EditableBox3D>(CreateBox, null, false); UserUnits = false; }
internal SwFeature(ISwDocument doc, IFeature feat, bool created) : base(feat, doc) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } Dimensions = new SwFeatureDimensionsCollection(m_Doc, this); m_Creator = new ElementCreator <IFeature>(CreateFeature, feat, created); }