// creates a button in the desired geometry shape public void Create() { entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDLabel")); bgMesh = new fGameObject(AppendMeshGO("background", make_background_mesh(), MaterialUtil.CreateFlatMaterialF(BackgroundColor), entry)); bgMesh.RotateD(Vector3f.AxisX, -90.0f); BoxPosition horzAlign = BoxPosition.CenterLeft; if (AlignmentHorz == HorizontalAlignment.Center) { horzAlign = BoxPosition.Center; } else if (AlignmentHorz == HorizontalAlignment.Right) { horzAlign = BoxPosition.CenterRight; } textMesh = GameObjectFactory.CreateTextMeshGO( "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset); Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign); BoxModel.Translate(textMesh, Vector2f.Zero, toPos); AppendNewGO(textMesh, entry, false); }
public override void Setup() { measureGO = GameObjectFactory.CreateParentGO("dimension"); measureGO.SetLayer(FPlatform.WidgetOverlayLayer); textGO = GameObjectFactory.CreateTextMeshGO("text", "1.0", Colorf.Black, TextHeight.SceneValuef); UnityUtil.AddChild(measureGO, textGO, false); textGO.SetLayer(FPlatform.WidgetOverlayLayer); }
// actually create GO elements, etc public void Create() { entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDPopupMessage")); bgMesh = AppendMeshGO("background", make_background_mesh(), MaterialUtil.CreateFlatMaterialF(BackgroundColor), entry); bgMesh.RotateD(Vector3f.AxisX, -90.0f); IBoxModelElement contentArea = BoxModel.PaddedBounds(this, Padding); BoxPosition titleBoxPos = BoxModel.ToPosition(TitleAlignment, VerticalAlignment.Top); titleTextMesh = (titleText == "") ? null : GameObjectFactory.CreateTextMeshGO( "title", TitleText, TextColor, TitleTextHeight, titleBoxPos, SceneGraphConfig.TextLabelZOffset); float fTitleHeight = 0; if (titleTextMesh != null) { Vector2f titleToPos = BoxModel.GetBoxPosition(contentArea, titleBoxPos); BoxModel.Translate(titleTextMesh, Vector2f.Zero, titleToPos); AppendNewGO(titleTextMesh, entry, false); fTitleHeight = TitleTextHeight; } IBoxModelElement messageArea = BoxModel.PaddedBounds(contentArea, 0, 0, 0, Padding + fTitleHeight); Vector2f textDims = messageArea.Size2D; BoxPosition textBoxPos = BoxModel.ToPosition(Alignment, VerticalAlignment.Top); textMesh = GameObjectFactory.CreateTextAreaGO( "message", Text, TextColor, TextHeight, textDims, Alignment, textBoxPos, SceneGraphConfig.TextLabelZOffset); Vector2f textToPos = BoxModel.GetBoxPosition(messageArea, textBoxPos); BoxModel.Translate(textMesh, Vector2f.Zero, textToPos); AppendNewGO(textMesh, entry, false); if (EnableClickToDismiss) { footerTextMesh = GameObjectFactory.CreateTextMeshGO( "footer", DismissText, DismissTextColor, TextHeight * 0.5f, BoxPosition.CenterBottom, SceneGraphConfig.TextLabelZOffset); BoxModel.Translate(footerTextMesh, Vector2f.Zero, BoxModel.GetBoxPosition(contentArea, BoxPosition.CenterBottom)); AppendNewGO(footerTextMesh, entry, false); } }
// creates a button in the desired geometry shape public void Create() { entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDLabel")); bgMesh = AppendMeshGO("background", HUDUtil.MakeBackgroundMesh(Shape), MaterialUtil.CreateFlatMaterialF(BackgroundColor), entry); bgMesh.RotateD(Vector3f.AxisX, -90.0f); if (EnableBorder) { HUDShape borderShape = Shape; borderShape.Radius += BorderWidth; borderShape.Height += 2 * BorderWidth; borderShape.Width += 2 * BorderWidth; border = AppendMeshGO("border", HUDUtil.MakeBackgroundMesh(borderShape), MaterialUtil.CreateFlatMaterialF(BorderColor), entry); border.RotateD(Vector3f.AxisX, -90.0f); border.Translate(-0.001f * Vector3f.AxisY, true); } BoxPosition horzAlign = BoxPosition.CenterLeft; if (AlignmentHorz == HorizontalAlignment.Center) { horzAlign = BoxPosition.Center; } else if (AlignmentHorz == HorizontalAlignment.Right) { horzAlign = BoxPosition.CenterRight; } textMesh = GameObjectFactory.CreateTextMeshGO( "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset); textMesh.TextObject.SetFixedWidth(Shape.Width); textMesh.TextObject.SetOverflowMode(TextOverflowMode.Ellipses); Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign); BoxModel.Translate(textMesh, Vector2f.Zero, toPos); AppendNewGO(textMesh, entry, false); MaterialUtil.DisableShadows(RootGameObject); }
protected void update_labels() { AxisAlignedBox2f localBounds = BoxModel.LocalBounds(this); foreach (var pair in Labels) { float t = (float)(pair.Key); PositionLabel labelinfo = pair.Value; if (labelinfo.go == null) { BoxPosition boxPos = BoxPosition.CenterTop; if (labelinfo.position == LabelPositionType.CenteredAbove) { boxPos = BoxPosition.CenterBottom; } else if (labelinfo.position == LabelPositionType.BelowLeftAligned) { boxPos = BoxPosition.TopLeft; } else if (labelinfo.position == LabelPositionType.BelowRightAligned) { boxPos = BoxPosition.TopRight; } labelinfo.go = GameObjectFactory.CreateTextMeshGO("sliderlabel_" + labelinfo.text, labelinfo.text, labelinfo.color, LabelTextHeight, boxPos); AppendNewGO(labelinfo.go, rootGO, false); } if (labelinfo.position == LabelPositionType.CenteredBelow || labelinfo.position == LabelPositionType.BelowLeftAligned || labelinfo.position == LabelPositionType.BelowRightAligned) { BoxModel.MoveTo(labelinfo.go, localBounds.BottomLeft, -Height * 0.01f); } else if (labelinfo.position == LabelPositionType.CenteredAbove) { BoxModel.MoveTo(labelinfo.go, localBounds.TopLeft, -Height * 0.01f); } else { throw new NotSupportedException("HUDSliderBase.update_labels : unhandled LabelPositionType"); } BoxModel.Translate(labelinfo.go, new Vector2f(t * Width, 0) + labelinfo.offset); } }
void UpdateText() { if (button == null) { return; } if (labelMesh == null && text.Length > 0) { labelMesh = GameObjectFactory.CreateTextMeshGO( "label", Text, TextColor, TextHeight, BoxPosition.Center, SceneGraphConfig.TextLabelZOffset); BoxModel.Translate(labelMesh, Vector2f.Zero, this.Bounds2D.Center); AppendNewGO(labelMesh, button, false); } if (labelMesh != null) { labelMesh.SetColor(TextColor); labelMesh.SetText(Text); } }
// creates a button in the desired geometry shape public void Create() { entry = new GameObject(UniqueNames.GetNext("HUDTextEntry")); Mesh mesh = MeshGenerators.CreateTrivialRect(Width, Height, MeshGenerators.UVRegionType.FullUVSquare); backgroundMaterial = MaterialUtil.CreateFlatMaterialF(BackgroundColor); activeBackgroundMaterial = MaterialUtil.CreateFlatMaterialF(ActiveBackgroundColor); bgMesh = AppendMeshGO("background", mesh, backgroundMaterial, entry); bgMesh.transform.Rotate(Vector3.right, -90.0f); // ?? BoxPosition horzAlign = BoxPosition.CenterLeft; if (AlignmentHorz == HorizontalAlignment.Center) { horzAlign = BoxPosition.Center; } else if (AlignmentHorz == HorizontalAlignment.Right) { horzAlign = BoxPosition.CenterRight; } textMesh = GameObjectFactory.CreateTextMeshGO( "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset); Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign); BoxModel.Translate(textMesh, Vector2f.Zero, toPos); AppendNewGO(textMesh, entry, false); cursor = GameObjectFactory.CreateRectangleGO("cursor", Height * 0.1f, Height * 0.8f, Colorf.VideoBlack, false); BoxModel.Translate(cursor, Vector2f.Zero, this.Bounds2D.CenterLeft, -Height * 0.1f); cursor.RotateD(Vector3f.AxisX, -90.0f); AppendNewGO(cursor, entry, false); cursor.SetVisible(false); }