@@ -1522,6 +1522,7 @@ public class CabViewGaugeRenderer : CabViewControlRenderer
15221522 Rectangle DestinationRectangle = new Rectangle ( ) ;
15231523 // bool LoadMeterPositive = true;
15241524 Color DrawColor ;
1525+ float DrawRotation ;
15251526 Double Num ;
15261527 bool IsFire ;
15271528
@@ -1605,30 +1606,38 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
16051606 {
16061607 if ( Gauge . Orientation == 0 )
16071608 {
1608- destX = ( int ) ( xratio * ( Control . PositionX + ( zeropos < xpos ? zeropos : xpos ) ) ) ;
1609- destY = ( int ) ( yratio * Control . PositionY ) ;
1610- destW = ( int ) ( xratio * ( xpos > zeropos ? xpos - zeropos : zeropos - xpos ) ) ;
1609+ destX = ( int ) ( xratio * ( Control . PositionX ) ) + ( int ) ( xratio * ( zeropos < xpos ? zeropos : xpos ) ) ;
1610+ // destY = (int)(yratio * Control.PositionY);
1611+ destY = ( int ) ( yratio * ( Control . PositionY ) - ( int ) ( yratio * ( Gauge . Direction == 0 && zeropos > xpos ? ( zeropos - xpos ) * Math . Sin ( DrawRotation ) : 0 ) ) ) ;
1612+ destW = ( ( int ) ( xratio * xpos ) - ( int ) ( xratio * zeropos ) ) * ( xpos >= zeropos ? 1 : - 1 ) ;
16111613 destH = ( int ) ( yratio * ypos ) ;
16121614 }
16131615 else
16141616 {
1615- destX = ( int ) ( xratio * Control . PositionX ) ;
1617+ destX = ( int ) ( xratio * Control . PositionX ) + ( int ) ( xratio * ( Gauge . Direction == 0 && ypos > zeropos ? ( ypos - zeropos ) * Math . Sin ( DrawRotation ) : 0 ) ) ;
16161618 if ( Gauge . Direction != 1 && ! IsFire )
1617- destY = ( int ) ( yratio * ( Control . PositionY + ( zeropos > ypos ? zeropos : 2 * zeropos - ypos ) ) ) ;
1619+ destY = ( int ) ( yratio * ( Control . PositionY + zeropos ) ) + ( ypos > zeropos ? ( int ) ( yratio * ( zeropos - ypos ) ) : 0 ) ;
16181620 else
16191621 destY = ( int ) ( yratio * ( Control . PositionY + ( zeropos < ypos ? zeropos : ypos ) ) ) ;
16201622 destW = ( int ) ( xratio * xpos ) ;
1621- destH = ( int ) ( yratio * ( ypos > zeropos ? ypos - zeropos : zeropos - ypos ) ) ;
1623+ destH = ( ( int ) ( yratio * ( ypos - zeropos ) ) ) * ( ypos > zeropos ? 1 : - 1 ) ;
16221624 }
16231625 }
16241626 else
16251627 {
16261628 var topY = Control . PositionY ; // top of visible column. +ve Y is downwards
16271629 if ( Gauge . Direction != 0 ) // column grows from bottom or from right
16281630 {
1629- destX = ( int ) ( xratio * ( Control . PositionX + Gauge . Width - xpos ) ) ;
16301631 if ( Gauge . Orientation != 0 )
1632+ {
16311633 topY += Gauge . Height * ( 1 - percent ) ;
1634+ destX = ( int ) ( xratio * ( Control . PositionX + Gauge . Width - xpos + ypos * Math . Sin ( DrawRotation ) ) ) ;
1635+ }
1636+ else
1637+ {
1638+ topY -= xpos * Math . Sin ( DrawRotation ) ;
1639+ destX = ( int ) ( xratio * ( Control . PositionX + Gauge . Width - xpos ) ) ;
1640+ }
16321641 }
16331642 else
16341643 {
@@ -1641,20 +1650,33 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
16411650 }
16421651 else // pointer gauge using texture
16431652 {
1653+ // even if there is a rotation, we leave the X position unaltered (for small angles Cos(alpha) = 1)
16441654 var topY = Control . PositionY ; // top of visible column. +ve Y is downwards
16451655 if ( Gauge . Orientation == 0 ) // gauge horizontal
16461656 {
1657+
16471658 if ( Gauge . Direction != 0 ) // column grows from right
1659+ {
16481660 destX = ( int ) ( xratio * ( Control . PositionX + Gauge . Width - 0.5 * Gauge . Area . Width - xpos ) ) ;
1661+ topY -= xpos * Math . Sin ( DrawRotation ) ;
1662+ }
16491663 else
1664+ {
16501665 destX = ( int ) ( xratio * ( Control . PositionX - 0.5 * Gauge . Area . Width + xpos ) ) ;
1666+ topY += xpos * Math . Sin ( DrawRotation ) ;
1667+ }
16511668 }
16521669 else // gauge vertical
16531670 {
1671+ // even if there is a rotation, we leave the Y position unaltered (for small angles Cos(alpha) = 1)
16541672 topY += ypos - 0.5 * Gauge . Area . Height ;
1655- destX = ( int ) ( xratio * Control . PositionX ) ;
1656- if ( Gauge . Direction != 0 ) // column grows from bottom
1657- topY += Gauge . Height - 2 * ypos ;
1673+ if ( Gauge . Direction == 0 )
1674+ destX = ( int ) ( xratio * ( Control . PositionX - ypos * Math . Sin ( DrawRotation ) ) ) ;
1675+ else // column grows from bottom
1676+ {
1677+ topY += Gauge . Height - 2.0f * ypos ;
1678+ destX = ( int ) ( xratio * ( Control . PositionX + ypos * Math . Sin ( DrawRotation ) ) ) ;
1679+ }
16581680 }
16591681 destY = ( int ) ( yratio * topY ) ;
16601682 destW = ( int ) ( xratio * Gauge . Area . Width ) ;
@@ -1693,6 +1715,7 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
16931715 DestinationRectangle . Y = destY ;
16941716 DestinationRectangle . Width = destW ;
16951717 DestinationRectangle . Height = destH ;
1718+ DrawRotation = Gauge . Rotation ;
16961719 }
16971720
16981721 public override void Draw ( GraphicsDevice graphicsDevice )
@@ -1701,7 +1724,7 @@ public override void Draw(GraphicsDevice graphicsDevice)
17011724 {
17021725 Shader . SetTextureData ( DestinationRectangle . Left , DestinationRectangle . Top , DestinationRectangle . Width , DestinationRectangle . Height ) ;
17031726 }
1704- ControlView . SpriteBatch . Draw ( Texture , DestinationRectangle , SourceRectangle , DrawColor ) ;
1727+ ControlView . SpriteBatch . Draw ( Texture , DestinationRectangle , SourceRectangle , DrawColor , DrawRotation , origin : Vector2 . Zero , SpriteEffects . None , layerDepth : 0 ) ;
17051728 }
17061729 }
17071730
0 commit comments