private void Text(string text, Color color) { if (FloatyTextManager.Template == null) { Debug.Log("Floaty text tempalte null"); return; } if (Contains(text)) { return; } float timeToReach = Time.fixedTime + animationTime; GameObject go = Instantiate(FloatyTextManager.Template, this.transform); go.SetActive(true); GameObject childText = go.transform.Find("Text").gameObject; Text t = childText.GetComponent <Text>(); t.color = color; t.text = text; SmartUI sui = go.GetComponent <SmartUI>(); childText.GetComponent <SmartUI>().addAnimation(new fadeOut(animationTime), null); sui.addAnimation(new slideY(-100 + sui.position.height, -100 - (sui.position.height * ((travelDistanceP / 100f)) + 1), animationTime * 0.8f, SmartUI.TweenTypes.easeBoth), null);//80% of the anim time is spent floating up currentlyDisplayed.Add(go, timeToReach); }
// Use this for initialization void Awake() { if (barToChange != null) { barToChangeSUI = barToChange.GetComponent <SmartUI>(); } else { Debug.LogError("SmartUIProgress bar : " + this + " reference GameObject barToChange missing"); } if (barTotalSpace != null) { barTotalSpaceSUI = barTotalSpace.GetComponent <SmartUI>(); } else { Debug.LogError("SmartUIProgress bar : " + this + " reference GameObject barToChange missing"); } if (displayText != null) { displayTextText = displayText.GetComponent <Text>(); } }
/** * Draws this item's representation */ public override void Draw() { Engine.PerformanceStatsInProgress.GuiUpdates++; if (ItemInstance != null) { var item = ItemInstance.Item; Sprite icon = CoM.Instance.ItemIconSprites[item.IconID]; DrawParameters dp = DrawParameters.Default; int offsetX = (int)((Width) - icon.rect.width) / 2; int offsetY = (int)((Height) - icon.rect.height) / 2; SmartUI.Color = Color; dp.Transform = ColorTransform; if (BeingDragged || !Enabled) { SmartUI.Color = Color.gray; dp = DrawParameters.BlackAndWhite; } SmartUI.Draw(X + offsetX, Y + offsetY, icon, dp); SmartUI.Color = Color.white; if (ItemInstance.Item.Usable) { GUIStyle myStyle = CoM.SubtextStyle; myStyle.alignment = TextAnchor.LowerLeft; SmartUI.TextWithShadow(new Rect(X + offsetX + 2, Y + offsetY, 40, 35), ItemInstance.RemainingCharges.ToString(), myStyle, 1); } } }
private void rebuildContent() { float finalHeight = 0; foreach (Transform child in ViewportContent.transform) { if (!child.gameObject.activeSelf) { continue; } SmartUI sui = child.GetComponent <SmartUI>(); Vector2 sizePixels = sui.getSize(); sui.position.y = sui.convertHeightPixelToPercent(finalHeight); sui.setElementToRect(); finalHeight += (sizePixels.y + itemSpacing * Screen.height); /*if (direction == BuildDirection.Up) * { * sui.VAlign = SmartUI.VAligns.bottom; * }*/ } float heightPercent = ViewSUI.convertHeightPixelToPercent(finalHeight); if (direction == BuildDirection.Up) { ViewSUI.VAlign = SmartUI.VAligns.bottom; } ViewSUI.position.height = heightPercent; ViewSUI.setElementToRect(); }
public Vector2 getParentSize() { SmartUI sui = transform.parent.GetComponent <SmartUI>(); if (sui != null) { return(sui.getSize()); } else { if (transform.parent.GetComponent <SmartLayoutGroup>() != null) // If a layout group, check it's parent instead { sui = transform.parent.parent.GetComponent <SmartUI>(); if (sui != null) { return(sui.getSize()); } else { return(transform.parent.parent.GetComponent <RectTransform>().rect.size); } } return(transform.parent.GetComponent <RectTransform>().rect.size); } }
public void setPos(float currentOffest) { if (currentOffest == 0) { return; } //Error starting from same position every stroke float cumulativeHeight = scrollPos + currentOffest * scrollSpeed; cumulativeHeight = cumulativeHeight > 0 ? 0 : cumulativeHeight; var rect = GetComponent <SmartUI>().getPhysicalRect(); cumulativeHeight = (cumulativeHeight + totalHeight) < (rect.y + rect.height * 1.5) ? scrollPos : cumulativeHeight; scrollPos = cumulativeHeight; foreach (Transform child in transform) { SmartUI item = child.GetComponent <SmartUI>(); if (item != null) { item.position.y = sui.convertHeightPixelToPercent(cumulativeHeight); item.setElementToRect(); cumulativeHeight += item.getPhysicalRect().height + spacing; } } }
protected virtual void drawOverlay() { if (OverlaySprite != null) { SmartUI.Draw(X, Y, OverlaySprite); } }
// ------------------------------------------------------------------ // Public // ------------------------------------------------------------------ public override void DrawContents() { Sprite icon = Action == null ? null : Action.Icon; if (icon != null) { var drawParameters = DrawParameters.Default; if (!Enabled) { drawParameters.Transform = ColorTransform.BlackAndWhite; drawParameters.Transform.ColorOffset = new Color(0.2f, 0.2f, 0.2f, 0f); } drawParameters.Scale = new Vector2(SIZE / icon.rect.width, SIZE / icon.rect.height); SmartUI.Draw(0, 0, icon, drawParameters); } if (Action != null) { if (Action.Type == ActionType.Spell) { var style = CoM.SubtextStyle; style.alignment = TextAnchor.LowerCenter; string costString = Action.Spell.CostFor(CoM.Party.Selected).ToString(); Rect rect = ContentsFrame; rect.height -= 4; SmartUI.TextWithShadow(rect, costString, style, 1); } } }
/** * Draw label with potential dropshadow */ public override void Draw() { SmartUI.Color = Color; if (EnableBackground) { SmartUI.Draw(Bounds, Style); } SmartUI.Color = Color.white; if (FauxEdge) { // SmartUI has quite slow shadowing as it has to go in an modify all the color codes. So I use my own cached one here. SmartUI.Text(ContentsBounds.Translated(new Vector2(ShadowDistance, ShadowDistance)), shadowCaption, Style); SmartUI.Text(ContentsBounds.Translated(new Vector2(-ShadowDistance, ShadowDistance)), shadowCaption, Style); SmartUI.Text(ContentsBounds.Translated(new Vector2(-ShadowDistance, -ShadowDistance)), shadowCaption, Style); SmartUI.Text(ContentsBounds.Translated(new Vector2(ShadowDistance, -ShadowDistance)), shadowCaption, Style); SmartUI.Text(ContentsBounds, colorisedCaption, Style); } else if (DropShadow) { // SmartUI has quite slow shadowing as it has to go in an modify all the color codes. So I use my own cached one here. SmartUI.Text(ContentsBounds.Translated(new Vector2(ShadowDistance, ShadowDistance)), shadowCaption, Style); SmartUI.Text(ContentsBounds, colorisedCaption, Style); } else { SmartUI.Text(ContentsBounds, colorisedCaption, Style); } SmartUI.Color = Color.white; }
public override void Draw() { Trace.Log("Draw"); if (Spell != null) { SmartUI.Draw(Bounds, Spell.Icon); } }
/** Draw the selected image */ public override void DrawContents() { if (Pictures != null) { SmartUI.Draw((this.ContentsBounds.width - Pictures[SelectedIndex].Sprite.rect.width) / 2, 0, Pictures[SelectedIndex].Sprite); } base.DrawContents(); }
public override void DrawContents() { SmartUI.DrawLegacySlow( delegate { Value = GUI.HorizontalSlider(Frame, Value, Min, Max); } ); }
/** Draws the slot. */ protected virtual void drawSlot() { var sprite = IsEmpty ? EmptySlotSprite : (FullSlotSprite ?? EmptySlotSprite); if (sprite != null) { SmartUI.Draw(X, Y, sprite); } }
public override void DrawContents() { if (blackOutLevel > 0) { SmartUI.DrawFillRect(Frame, Color.black.Faded(blackOutLevel)); } base.DrawContents(); }
public override void Draw() { base.Draw(); var overlaySprite = isCurrent ? OVERLAY_SELECTED : OVERLAY_STANDARD; if (overlaySprite != null) { SmartUI.Draw(X - 2, Y - 2, overlaySprite); } }
/** Draws the indicator under the object */ protected virtual void drawIndicator() { if (IndicatorColor != Color.clear) { var backgroundSprite = ResourceManager.GetSprite("Icons/SlotInlay"); SmartUI.PushAndSetColor(IndicatorColor); SmartUI.Draw(X, Y, backgroundSprite); SmartUI.PopColor(); } }
/** Draws hilight ring over slot. */ protected virtual void drawRing() { if (RingColor != Color.clear && RingSprite != null) { Color oldColor = SmartUI.Color; SmartUI.Color = RingColor; SmartUI.DrawSliced(new Rect(X, Y, Width, Height), RingSprite, new RectOffset(4, 4, 4, 4)); SmartUI.Color = oldColor; } }
/** If there is a party then draws the party icon at the correct orientation */ private void DrawParty() { if (Party == null) { return; } Vector2 location = TileToScreen(Party.LocationX, Party.LocationY); Sprite partyIcon = MapIcons[PARTY_DIRECTION_ICON + Party.Facing.Sector]; SmartUI.Draw(location.x, location.y, partyIcon); }
// Update is called once per frame void Update() { if (!dragging) { float pixelToTrackTo = pixelFromPercent(percentToTrackTo); float lerped = (transform.transform.position.x * lerpMultiplier + pixelToTrackTo) / (lerpMultiplier + 1); SmartUI sui = GetComponent <SmartUI>(); sui.position.x = lerped; sui.setElementToRect(); } }
private void rebuildContent() { if (direction == BuildDirection.Down || direction == BuildDirection.Up) { float finalHeight = 0; foreach (Transform child in ViewportContent.transform) { if (!child.gameObject.activeSelf) { continue; } SmartUI sui = child.GetComponent <SmartUI>(); Vector2 sizePixels = sui.getSize(); sui.position.y = sui.convertHeightPixelToPercent(finalHeight); sui.setElementToRect(); finalHeight += (sizePixels.y + itemSpacing * Screen.height); } float heightPercent = ViewSUI.convertHeightPixelToPercent(finalHeight); if (direction == BuildDirection.Up) { ViewSUI.VAlign = SmartUI.VAligns.bottom; } ViewSUI.position.height = heightPercent; ViewSUI.setElementToRect(); } else if (direction == BuildDirection.Right || direction == BuildDirection.Left) { float finalWidth = itemSpacing * Screen.width; foreach (Transform child in ViewportContent.transform) { if (!child.gameObject.activeSelf) { continue; } SmartUI sui = child.GetComponent <SmartUI>(); Vector2 sizePixels = sui.getSize(); sui.position.x = sui.convertWidthPixelToPercent(finalWidth); sui.setElementToRect(); finalWidth += (sizePixels.x + itemSpacing * Screen.width); } float widthPercent = ViewSUI.convertWidthPixelToPercent(finalWidth); if (direction == BuildDirection.Right) { ViewSUI.HAlign = SmartUI.HAligns.left; } if (direction == BuildDirection.Left) { ViewSUI.HAlign = SmartUI.HAligns.right; } ViewSUI.position.width = widthPercent; ViewSUI.setElementToRect(); } }
public override void DrawContents() { SmartUI.Color = Enabled ? Color : Color.gray; SmartUI.Enabled = this.Enabled; string newText = SmartUI.TextField(Frame, String.IsNullOrEmpty(Value) ? "" : Value, FontSize); SmartUI.Enabled = true; if (Editable && Enabled) { Value = newText; } SmartUI.Color = Color.white; }
// Use this for initialization void Start() { ViewportContent = transform.Find("Viewport").Find("Content").gameObject; ViewSUI = ViewportContent.GetComponent <SmartUI>(); if (direction == BuildDirection.Up || direction == BuildDirection.Down) { GetComponent <ScrollRect>().onValueChanged.AddListener(onScrollVertical); } else if (direction == BuildDirection.Left || direction == BuildDirection.Right) { GetComponent <ScrollRect>().onValueChanged.AddListener(onScrollHorizontal); } }
/** Draw the items list */ public override void DrawContents() { base.DrawContents(); const int xPos = 0; int yPos = 0; int index = 0; foreach (T item in ItemList) { SmartUI.SolidText(new Rect(xPos, yPos, Width, ITEM_HEIGHT), DoConvertItemToString(item), (index == _selectedIndex) ? SelectedItemStyle : ItemStyle); yPos += ITEM_HEIGHT; index++; } }
public override void DrawContents() { base.DrawContents(); Image.Width = (int)ContentsBounds.width; Image.Height = (int)ContentsBounds.height; Image.Update(); Image.Draw(); RectOffset border = new RectOffset(2, 2, 2, 2); if (!Enabled) { SmartUI.DrawFillRect(border.Remove(Frame), new Color(0.4f, 0.4f, 0.4f, 0.66f)); } }
/** Draws the controls contents */ public override void Draw() { if (EnableBackground) { SmartUI.Color = Color; DrawBackground(); SmartUI.Color = Color.white; } GUIStyle vsb = (ScrollMode == ScrollMode.HorizonalOnly || ScrollMode == ScrollMode.None) ? GUIStyle.none : GUI.skin.verticalScrollbar; GUIStyle hsb = (ScrollMode == ScrollMode.VerticalOnly || ScrollMode == ScrollMode.None) ? GUIStyle.none : GUI.skin.horizontalScrollbar; ScrollLocation = SmartUI.BeginScrollView(Bounds, ScrollLocation, ContentsScrollRect, hsb, vsb, false); DrawContents(); SmartUI.EndScrollView(); }
/** Draw the map */ public override void DrawContents() { if (Map == null) { return; } if (Dirty) { RenderMap(); } // calculate our offset if (TrackParty && (Party != null)) { MapDisplayOffset.x = MAP_FRAME + (int)((Party.LocationX) * TILE_SIZE - Width / 2); MapDisplayOffset.y = MAP_FRAME + (int)((30 - Party.LocationY + 1.5f) * TILE_SIZE - Height / 2); } else { MapDisplayOffset.Set(0.0f, 0.0f); } if (Background != null) { if (Mode == MapMode.Small) { Background.X = (-Party.LocationX + 5 - BACKGROUND_BORDER) * TILE_SIZE; Background.Y = (Party.LocationY - 32 + 6 - BACKGROUND_BORDER) * TILE_SIZE; } else { Background.X = 0; Background.Y = 0; } Background.Draw(); } Rect textureRect = new Rect(MapDisplayOffset.x, (MapCanvas.height - Height - MapDisplayOffset.y), Width, Height); SmartUI.Color = new Color(0.8f, 0.8f, 0.8f); SmartUI.Draw(new Rect(0, 0, Width, Height), MapCanvas, textureRect, DrawParameters.Default); DrawParty(); }
public float getOpacity() { if (!inheritOpacity) { return(opacity); } SmartUI sui = transform.parent.GetComponent <SmartUI>(); if (sui != null) { return(sui.getOpacity() * opacity); } else { //Debug.Log(transform.parent.name + " " + transform.parent.GetComponent<RectTransform>().rect.size); return(1); } }
public void rebuildAll() { SmartUI sui = GetComponent <SmartUI>(); float cumulativeHeight = 0; foreach (Transform child in transform) { SmartUI item = child.GetComponent <SmartUI>(); if (item != null) { item.position.y = sui.convertHeightPixelToPercent(Mathf.FloorToInt(cumulativeHeight)); item.setElementToRect(); cumulativeHeight += item.getPhysicalRect().height + spacing; item.setElementToRect(); } } totalHeight = cumulativeHeight; }
/** Draws the sprite */ public override void DrawContents() { if (Sprite != null) { DrawParameters dp = GetDrawParameters; dp.AlphaBlend = AlphaBlend; dp.Scale = new Vector2(ContentsFrame.width / Sprite.rect.width, ContentsFrame.height / Sprite.rect.height); dp.Rotation = Rotation; if (!ImageColorTransform.IsIdentity) { dp.Transform = dp.Transform + ImageColorTransform; } SmartUI.Color = Color * ImageColor; SmartUI.Draw(0, 0, Sprite, dp); SmartUI.Color = Color.white; } }
// ---------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------- /** Draw an item type indicator on slots that are restricted by type */ public override void DrawContents() { // Sometimes the contents is changed but no update was called inbetween so we make sure the changes // are in sync now. if (_dirty) { Apply(); } if (DataLink != null) { if ((ItemRestriction != ItemLocation.Any) && DataLink.IsEmpty) { int iconID = MDRItem.GetSpriteForItemLocation(ItemRestriction); Sprite icon = (iconID >= 0) ? CoM.Instance.ItemIconSprites[iconID] : null; if (icon) { var dp = DrawParameters.BlackAndWhite; SmartUI.Color = new Color(0.35f, 0.35f, 0.35f, 0.75f); SmartUI.Draw(6, 6, icon, dp); SmartUI.Color = Color.white; } } // draw paired item if required. if (DataLink.PairedSlot != null) { if ((!DataLink.PairedSlot.IsEmpty) && (DataLink.PairedSlot.ItemInstance.Item.Hands == 2)) { var dp = DrawParameters.BlackAndWhite; SmartUI.DrawFillRect(new Rect(3, 3, Width - 6, Height - 6), new Color(0.1f, 0.1f, 0.1f, 0.9f)); SmartUI.Color = new Color(0.35f, 0.35f, 0.35f, 0.75f); SmartUI.Draw(6, 6, DataLink.PairedSlot.ItemInstance.Item.Icon, dp); SmartUI.Color = Color.white; } } } base.DrawContents(); }