Skip to content

Commit 9358732

Browse files
In case a locomotive has a front and a rear cab the rectangles of the two cabs overlap.
1 parent b90e3b9 commit 9358732

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Source/RunActivity/Viewer3D/Popups/ControlRectangle.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
1717

18-
using System;
18+
using System.Linq;
1919
using Microsoft.Xna.Framework;
2020
using Microsoft.Xna.Framework.Graphics;
21+
using Orts.Simulation.RollingStocks;
2122
using Orts.Viewer3D.RollingStock;
2223

2324
namespace Orts.Viewer3D.Popups
@@ -41,7 +42,13 @@ public override void Draw(SpriteBatch spriteBatch)
4142
if (Viewer.Camera is CabCamera && (Viewer.PlayerLocomotiveViewer as MSTSLocomotiveViewer)._hasCabRenderer)
4243
{
4344
var cabRenderer = (Viewer.PlayerLocomotiveViewer as MSTSLocomotiveViewer)._CabRenderer;
44-
foreach (var controlRenderer in cabRenderer.ControlMap.Values)
45+
46+
var loco = Viewer.PlayerLocomotive as MSTSLocomotive;
47+
var cabViewFrontRear = loco.UsingRearCab ? 1 : 0;
48+
var itemsFrontCount = loco.CabViewList[(int)CabViewType.Front].CVFFile.CabViewControls.Count() - 1;
49+
var itemsRearCount = loco.CabViewList.Count > 1 ? loco.CabViewList[(int)CabViewType.Rear].CVFFile.CabViewControls.Count() - 1 : 0;
50+
51+
foreach (var controlRenderer in cabRenderer.ControlMap.Values.Skip(cabViewFrontRear == 0 ? 0 : itemsFrontCount).Take(cabViewFrontRear == 0 ? itemsFrontCount : itemsRearCount))
4552
{
4653
if ((Viewer.Camera as CabCamera).SideLocation == controlRenderer.Control.CabViewpoint && controlRenderer is ICabViewMouseControlRenderer mouseRenderer)
4754
{

0 commit comments

Comments
 (0)