Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic merge of T1.5.1-870-ge0bf062eb and 17 pull requests
- Pull request #570 at 3539862: Experimental glTF 2.0 support with PBR lighting - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #882 at 9c456aa: Blueprint/train car operations UI window - Pull request #885 at 8f94333: feat: Add notifications to Menu - Pull request #886 at 6c0785b: Scene viewer extension to TrackViewer - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #896 at 5866028: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains - Pull request #897 at 42f1dd9: feat: Improved system information collection - Pull request #903 at 9bead33: Downloading route content (Github, zip) - Pull request #907 at 9b0b04f: Bug fix for https://bugs.launchpad.net/or/+bug/2047300 Dynamic tracks disappear after long tunnel - Pull request #911 at 6834af0: docs: Add refactoring as a special type of PR - Pull request #912 at d595703: New Triple Valve Features Vol. 2 - Pull request #914 at 2ffadd6: Adjustments to Duplex steam - Pull request #915 at 6d911d7: Correct calculation error with curve friction - Pull request #917 at 3bbf66e: Lighting Configuration Enhancements - Pull request #919 at a3c907f: Added mouse wheel support for controls which can be moved by pressing t…
- Loading branch information
Showing
6 changed files
with
179 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// COPYRIGHT 2024 by the Open Rails project. | ||
// | ||
// This file is part of Open Rails. | ||
// | ||
// Open Rails is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Open Rails is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Open Rails. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
using System; | ||
using Microsoft.Xna.Framework; | ||
using Microsoft.Xna.Framework.Graphics; | ||
using Orts.Viewer3D.RollingStock; | ||
|
||
namespace Orts.Viewer3D.Popups | ||
{ | ||
public class ControlRectangle : Window | ||
{ | ||
private readonly Texture2D Line; | ||
private readonly int Thickness = 3; | ||
private readonly Color Color = Color.Yellow; | ||
private readonly Viewer Viewer; | ||
|
||
public ControlRectangle(WindowManager owner, Viewer viewer) : base(owner) | ||
{ | ||
Line = new Texture2D(Owner.Viewer.GraphicsDevice, 1, 1, false, SurfaceFormat.Color); | ||
Line.SetData(new[] { Color }); | ||
Viewer = viewer; | ||
} | ||
|
||
public override void Draw(SpriteBatch spriteBatch) | ||
{ | ||
if (Viewer.Camera is CabCamera && (Viewer.PlayerLocomotiveViewer as MSTSLocomotiveViewer)._hasCabRenderer) | ||
{ | ||
var cabRenderer = (Viewer.PlayerLocomotiveViewer as MSTSLocomotiveViewer)._CabRenderer; | ||
foreach (var controlRenderer in cabRenderer.ControlMap.Values) | ||
{ | ||
if ((Viewer.Camera as CabCamera).SideLocation == controlRenderer.Control.CabViewpoint && controlRenderer is ICabViewMouseControlRenderer mouseRenderer) | ||
{ | ||
if (mouseRenderer.isMouseControl()) | ||
{ | ||
Rectangle rectangle = mouseRenderer.DestinationRectangleGet(); | ||
|
||
int width = rectangle.Width; | ||
int height = rectangle.Height; | ||
|
||
if (width > 0) | ||
{ | ||
// do not know why rectangles with width and height = 0 are there | ||
|
||
// top line | ||
DrawLine(spriteBatch, rectangle.X, rectangle.Y, width, Thickness, 0); | ||
|
||
// bottom line | ||
DrawLine(spriteBatch, rectangle.X, rectangle.Y + height - Thickness, width, Thickness, 0); | ||
|
||
// left line | ||
DrawLine(spriteBatch, rectangle.X + Thickness, rectangle.Y, height, Thickness, 90); | ||
|
||
// right line | ||
DrawLine(spriteBatch, rectangle.X + width, rectangle.Y, height, Thickness, 90); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void DrawLine(SpriteBatch spriteBatch, int X, int Y, int width, int height, int degrees) | ||
{ | ||
spriteBatch.Draw( | ||
Line, | ||
new Rectangle(X, Y, width, height), | ||
null, | ||
Color, | ||
ConvertToRadiansFromDegrees(degrees), | ||
new Vector2(0, 0), | ||
SpriteEffects.None, 0); | ||
} | ||
|
||
private float ConvertToRadiansFromDegrees(int angle) | ||
{ | ||
return (float)((System.Math.PI / 180) * angle); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters