/// <summary> /// Renders the GUISpinButton. /// </summary> public override void Render(float timePassed) { // Do not render if not visible. if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } // The GUISpinButton has the focus if (Focus) { //render the focused image _imageFocused.Render(timePassed); } else { //render the non-focused image _imageNonFocused.Render(timePassed); } // Compute with of label so that the text does not overlap the spin controls. int labelWidth = _width - (2 * _textOffsetX) - (2 * _spinWidth) - _textOffsetX; if (labelWidth <= 0) { base.Render(timePassed); return; } _labelControl.Width = labelWidth; // render the text on the button if (_labelControl is GUILabelControl) { ((GUILabelControl)_labelControl).TextAlignment = _textAlignment; ((GUILabelControl)_labelControl).TextVAlignment = _textVAlignment; ((GUILabelControl)_labelControl).Label = _label; ((GUILabelControl)_labelControl).TextColor = Disabled ? _disabledColor : Focus?_textColor : _textColorNoFocus; } else { ((GUIFadeLabel)_labelControl).TextAlignment = _textAlignment; ((GUIFadeLabel)_labelControl).TextVAlignment = _textVAlignment; ((GUIFadeLabel)_labelControl).Label = _label; ((GUIFadeLabel)_labelControl).TextColor = Disabled ? _disabledColor : Focus?_textColor : _textColorNoFocus; } int x = 0; int y = 0; switch (_textAlignment) { case Alignment.ALIGN_LEFT: x = _textOffsetX + _positionX; break; case Alignment.ALIGN_RIGHT: x = _positionX + _width - _textOffsetX; break; case Alignment.ALIGN_CENTER: x = _positionX + ((_width / 2) - (labelWidth / 2)); break; } switch (_textVAlignment) { case VAlignment.ALIGN_TOP: y = _textOffsetY + _positionY; break; case VAlignment.ALIGN_BOTTOM: y = _positionY + _height - _textOffsetY; break; case VAlignment.ALIGN_MIDDLE: y = _positionY + ((_height / 2) - (_labelControl.Height / 2)); break; } _labelControl.SetPosition(x, y); _labelControl.Render(timePassed); x = 0; y = 0; switch (_spinAlignment) { case Alignment.ALIGN_LEFT: x = _spinOffsetX + _positionX; break; case Alignment.ALIGN_RIGHT: x = _positionX + _width - _spinOffsetX - _spinControl.Width; break; case Alignment.ALIGN_CENTER: x = _positionX + ((_width / 2) - (_spinControl.Width / 2)); break; } switch (_spinVAlignment) { case VAlignment.ALIGN_TOP: y = _spinOffsetY + _positionY; break; case VAlignment.ALIGN_BOTTOM: y = _positionY + _height - _spinOffsetY - _spinControl.Height; break; case VAlignment.ALIGN_MIDDLE: y = _positionY + ((_height / 2) - (_spinControl.Height / 2)); break; } _spinControl.SetPosition(x, y); _spinControl.Render(timePassed); base.Render(timePassed); }
/// <summary> /// Renders the GUIButtonControl. /// </summary> public override void Render(float timePassed) { // Do not render if not visible. if (GUIGraphicsContext.EditMode == false) { if (!IsVisible) { base.Render(timePassed); return; } } base.Render(timePassed); // The GUIButtonControl has the focus if (Focus) { //render the focused image _imageFocused.Render(timePassed); GUIPropertyManager.SetProperty("#highlightedbutton", Label); } else { //render the non-focused image _imageNonFocused.Render(timePassed); } // render the text on the button if (Disabled) { if (_labelControl is GUILabelControl) { ((GUILabelControl)_labelControl).Label = _label; ((GUILabelControl)_labelControl).TextColor = _disabledColor; } else { ((GUIFadeLabel)_labelControl).Label = _label; ((GUIFadeLabel)_labelControl).TextColor = _disabledColor; } _labelControl.SetPosition(_textOffsetX + _positionX, _textOffsetY + _positionY); _labelControl.Render(timePassed); } else { if (_labelControl is GUILabelControl) { ((GUILabelControl)_labelControl).Label = _label; ((GUILabelControl)_labelControl).TextColor = _disabledColor; } else { ((GUIFadeLabel)_labelControl).Label = _label; ((GUIFadeLabel)_labelControl).TextColor = _textColor; } _labelControl.SetPosition(_textOffsetX + _positionX, _textOffsetY + _positionY); _labelControl.Render(timePassed); } base.Render(timePassed); if (_spinControl != null) { int off = 5; GUIGraphicsContext.ScaleHorizontal(ref off); _spinControl.SetPosition(_imageNonFocused.XPosition + _imageNonFocused.Width - off - 2 * _spinControlWidth, _imageNonFocused.YPosition + (_imageNonFocused.Height - _spinControlHeight) / 2); _spinControl.Render(timePassed); } //base.Render(timePassed); }