static DisplayPart[] CreateDisplayParts(string debuggerDisplayString) { var list = ListCache <DisplayPart> .AllocList(); var sb = ObjectCache.AllocStringBuilder(); int pos = 0; for (;;) { sb.Clear(); var text = ReadText(debuggerDisplayString, ref pos, sb); if (text.Length != 0) { list.Add(DisplayPart.CreateText(text)); } sb.Clear(); var evalInfo = ReadEvalText(debuggerDisplayString, ref pos, sb); if (evalInfo.expression.Length != 0) { list.Add(DisplayPart.CreateEvaluate(evalInfo.expression, evalInfo.formatSpecifiers)); } if (pos >= debuggerDisplayString.Length) { break; } } ObjectCache.Free(ref sb); return(ListCache <DisplayPart> .FreeAndToArray(ref list)); }
public virtual void Close() { var opts = DisplayPart.GetOptions() as MessageOptions; if (opts != null && opts.CloseClickAction != null) { opts.CloseClickAction(this); } _closeAction?.Invoke(this); }
private void UpdateStatus(string status, DisplayPart part) { if (InvokeRequired) { Invoke(new Action <string, DisplayPart>(UpdateStatus), status, part); } else { if (part == DisplayPart.Status) { lblStatus.Text = status; } else { txtStats.Text = status; } } }
static DisplayPart[] CreateDisplayParts(string?debuggerDisplayString) { if (debuggerDisplayString is null) { return(Array.Empty <DisplayPart>()); } if (debuggerDisplayString.Length == 0) { return new[] { DisplayPart.CreateText(string.Empty) } } ; var list = ListCache <DisplayPart> .AllocList(); var sb = ObjectCache.AllocStringBuilder(); int pos = 0; for (;;) { sb.Clear(); var text = ReadText(debuggerDisplayString, ref pos, sb); if (text.Length != 0) { list.Add(DisplayPart.CreateText(text)); } sb.Clear(); var expression = ReadEvalText(debuggerDisplayString, ref pos, sb); if (expression.Length != 0) { list.Add(DisplayPart.CreateEvaluate(expression)); } if (pos >= debuggerDisplayString.Length) { break; } } ObjectCache.Free(ref sb); return(ListCache <DisplayPart> .FreeAndToArray(ref list)); }
/// <inheritdoc /> public string GetMessage() { return(DisplayPart.GetMessage()); }
public virtual void AssignDisplay(EntityBlueprint blueprint, DroneSpawnData data, int faction = 0) { this.faction = faction; ClearDisplay(); shell.sprite = ResourceManager.GetAsset <Sprite>(blueprint.coreShellSpriteID); if (shell.sprite) { shell.enabled = true; shell.rectTransform.sizeDelta = shell.sprite.bounds.size * 100; shell.color = FactionManager.GetFactionColor(faction); shell.type = Image.Type.Sliced; shell.rectTransform.pivot = new Vector2(shell.sprite.pivot.x / (shell.sprite.bounds.size.x * 100), shell.sprite.pivot.y / (shell.sprite.bounds.size.y * 100)); } else { shell.enabled = false; } core.sprite = ResourceManager.GetAsset <Sprite>(blueprint.coreSpriteID); if (core.sprite) { core.enabled = true; core.rectTransform.sizeDelta = core.sprite.bounds.size * 100; core.type = Image.Type.Sliced; core.material = ResourceManager.GetAsset <Material>("material_color_swap"); core.color = FactionManager.GetFactionColor(faction); // orient core image so relative center stays the same regardless of shell tier } else { core.enabled = false; } if (data != null && data.type == DroneType.Mini) { miniDroneShooter.enabled = true; miniDroneShooter.sprite = ResourceManager.GetAsset <Sprite>(AbilityUtilities.GetShooterByID(6)); miniDroneShooter.color = FactionManager.GetFactionColor(faction); miniDroneShooter.rectTransform.sizeDelta = miniDroneShooter.sprite.bounds.size * 100; miniDroneShooter.type = Image.Type.Sliced; } else if (blueprint.intendedType == EntityBlueprint.IntendedType.Turret || blueprint.intendedType == EntityBlueprint.IntendedType.Tank || blueprint.intendedType == EntityBlueprint.IntendedType.WeaponStation) { miniDroneShooter.enabled = true; miniDroneShooter.sprite = ResourceManager.GetAsset <Sprite>(AbilityUtilities.GetShooterByID(blueprint.parts[0].abilityID, blueprint.parts[0].secondaryData)); miniDroneShooter.color = FactionManager.GetFactionColor(faction); miniDroneShooter.rectTransform.sizeDelta = miniDroneShooter.sprite.bounds.size * 100; miniDroneShooter.type = Image.Type.Sliced; } else { miniDroneShooter.enabled = false; } if (blueprint.intendedType != EntityBlueprint.IntendedType.Turret && blueprint.intendedType != EntityBlueprint.IntendedType.Tank) { foreach (EntityBlueprint.PartInfo part in blueprint.parts) { DisplayPart basePart = Instantiate(partPrefab, transform, false).GetComponent <DisplayPart>(); basePart.UpdateFaction(faction); parts.Add(basePart); basePart.info = part; } } }