protected virtual void update_ticks() { if (TicksAreVisible == false) { foreach (var tick in ticks) { tick.go.SetVisible(false); } return; } TickMaterial.color = tickColor; Vector2f tickSize = TickDimensions; AxisAlignedBox2f localBounds = BoxModel.LocalBounds(this); // create extra ticks if we need them if (tick_count > tick_count_cache) { while (ticks.Count < tick_count) { TickGO tick = new TickGO(); tick.go = create_tick_go(tickSize, TickMaterial); AppendNewGO(tick.go, rootGO, false); BoxModel.Translate(tick.go, Vector2f.Zero, localBounds.CenterLeft, -Height * 0.01f); ticks.Add(tick); } tick_count_cache = tick_count; } // align and show/hide ticks for (int i = 0; i < ticks.Count; ++i) { fGameObject go = ticks[i].go; if (i < tick_count) { float t = (float)i / (float)(tick_count - 1); update_tick_go(i, go, tickSize, t); BoxModel.MoveTo(go, localBounds.CenterLeft, -Height * 0.01f); BoxModel.Translate(go, new Vector2f(t * Width, 0)); go.SetVisible(true); } else { ticks[i].go.SetVisible(false); } } }
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); } }
public override void PreRender() { if (IsEditing) { // cursor blinks every 0.5s float dt = FPlatform.RealTime() - start_active_time; cursor.SetVisible((int)(2 * dt) % 2 == 0); // DO NOT DO THIS EVERY FRAME!!! BoxModel.MoveTo(cursor, this.Bounds2D.CenterLeft, -Height * 0.1f); Vector2f cursorPos = textMesh.TextObject.GetCursorPosition(cursor_position); BoxModel.Translate(cursor, cursorPos); } else { cursor.SetVisible(false); } }