public override void Resize(Rect rect) { base.Resize(rect); float panelPadding = 12; float fieldPadding = 4; float fieldHeight = 28; Vector2 SizeRandomize = new Vector2(22, 22); Vector2 SizeInfo = new Vector2(24, 24); RectRandomize = new Rect(PanelRect.width - panelPadding - SizeRandomize.y, PanelRect.HalfHeight() - SizeRandomize.y * 0.5f, SizeRandomize.x, SizeRandomize.y); RectInfo = new Rect(panelPadding, PanelRect.HalfHeight() - SizeInfo.HalfY(), SizeInfo.x, SizeInfo.y); float availableSpace = PanelRect.width - (panelPadding * 2) - RectInfo.width - RectRandomize.width - fieldPadding; float firstMinWidth = 80; float nickMinWidth = 90; float lastMinWidth = 90; float fieldsMinWidth = firstMinWidth + nickMinWidth + lastMinWidth + (fieldPadding * 2); float extraSpace = availableSpace - fieldsMinWidth; float extraForField = Mathf.Floor(extraSpace / 3); float top = PanelRect.HalfHeight() - fieldHeight * 0.5f; RectFirstName = new Rect(RectInfo.xMax, top, firstMinWidth + extraForField, fieldHeight); RectNickName = new Rect(RectFirstName.xMax + fieldPadding, top, nickMinWidth + extraForField, fieldHeight); RectLastName = new Rect(RectNickName.xMax + fieldPadding, top, lastMinWidth + extraForField, fieldHeight); // Shift the info button to the left a bit to making the spacing look better. RectInfo.x -= 6; }
public override void Resize(Rect rect) { base.Resize(rect); Vector2 available = PanelRect.size - Style.SizePanelPadding; float arrowPadding = 1; float arrowWidth = Textures.TextureButtonNext.width; float bioWidth = 32; float chronoWidth = 48; float extendedArrowSize = arrowPadding + arrowWidth; float extendedFieldSize = extendedArrowSize * 2; float usedSpace = (extendedFieldSize * 2) + bioWidth + chronoWidth; float availableSpace = PanelRect.width - usedSpace; float spacing = availableSpace / 3; float idealSpace = 15; float extraFieldWidth = 0; if (spacing > idealSpace) { float extra = (spacing - idealSpace) * 3; extraFieldWidth += Mathf.Floor(extra / 2); spacing = idealSpace; } else { spacing = Mathf.Floor(spacing); } float fieldHeight = 28; GameFont saveFont = Text.Font; Text.Font = GameFont.Tiny; Vector2 bioLabelSize = Text.CalcSize("EdB.PC.Panel.Age.Biological".Translate()); Vector2 chronoLabelSize = Text.CalcSize("EdB.PC.Panel.Age.Chronological".Translate()); Text.Font = saveFont; float labelHeight = Mathf.Max(bioLabelSize.y, chronoLabelSize.y); float contentHeight = labelHeight + fieldHeight; float top = PanelRect.HalfHeight() - (contentHeight * 0.5f); float fieldTop = top + labelHeight; RectBiologicalAgeField = new Rect(spacing + extendedArrowSize, fieldTop, bioWidth + extraFieldWidth, fieldHeight); RectChronologicalAgeField = new Rect(RectBiologicalAgeField.xMax + extendedArrowSize + spacing + extendedArrowSize, fieldTop, chronoWidth + extraFieldWidth, fieldHeight); RectBiologicalAgeLabel = new Rect(RectBiologicalAgeField.MiddleX() - bioLabelSize.x / 2, RectBiologicalAgeField.y - bioLabelSize.y, bioLabelSize.x, bioLabelSize.y); RectChronologicalAgeLabel = new Rect(RectChronologicalAgeField.MiddleX() - chronoLabelSize.x / 2, RectChronologicalAgeField.y - chronoLabelSize.y, chronoLabelSize.x, chronoLabelSize.y); }
protected void DrawLoadingProgress() { Rect progressBarRect = new Rect(PanelRect.HalfWidth() - ProgressBarSize.x * 0.5f, PanelRect.HalfHeight() - ProgressBarSize.y * 0.5f, ProgressBarSize.x, ProgressBarSize.y); var progress = providerEquipment.LoadingProgress; GUI.color = Color.gray; Widgets.DrawBox(progressBarRect); if (progress.defCount > 0) { int totalCount = progress.defCount * 2; int processed = progress.stuffProcessed + progress.thingsProcessed; float percent = (float)processed / (float)totalCount; float barWidth = progressBarRect.width * percent; Widgets.DrawRectFast(new Rect(progressBarRect.x, progressBarRect.y, barWidth, progressBarRect.height), Color.green); } GUI.color = Style.ColorText; Text.Font = GameFont.Tiny; string label = "EdB.PC.Equipment.LoadingProgress.Initializing".Translate(); if (progress.phase == EquipmentDatabase.LoadingPhase.ProcessingStuff) { label = "EdB.PC.Equipment.LoadingProgress.StuffDefs".Translate(); } else if (progress.phase == EquipmentDatabase.LoadingPhase.ProcessingThings) { label = "EdB.PC.Equipment.LoadingProgress.ThingDefs".Translate(); } else if (progress.phase == EquipmentDatabase.LoadingPhase.Loaded) { label = "EdB.PC.Equipment.LoadingProgress.Finished".Translate(); } Widgets.Label(new Rect(progressBarRect.x, progressBarRect.yMax + 2, progressBarRect.width, 20), label); Text.Font = GameFont.Small; GUI.color = Color.white; }