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-237-g5c9f646ff and 11 pull requests
- Pull request #719 at 0f4d975: Upgraded to MonoGame 3.8.0 (+ small update for other libraries) - Pull request #722 at fb9079e: Fix Windows Forms deprecations in ActivityEditor - Pull request #732 at 83002d7: Improvements for air brakes - Pull request #735 at b9a0ea3: Added new parameter for battery switch - Pull request #751 at f947f29: Web interface to control cab controls with external hardware - Pull request #753 at ab8fe32: Extends CabControls for user input - Pull request #760 at 113dd63: Updated EditorConfig with .NET and StyleCop analyzer configuration - Pull request #764 at 5f9a01b: fix: Improve sky dome distortion causing bug #1471416 - Pull request #766 at c9657de: Control Car additional functionality - Pull request #767 at 9317f8c: Refine sunrise and sunset - Pull request #768 at bc8aea4: OpenRailway Map enhancements
- Loading branch information
Showing
9 changed files
with
302 additions
and
147 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
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,109 @@ | ||
// COPYRIGHT 2022 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 System.Collections.Generic; | ||
using Orts.Formats.Msts; | ||
using Orts.Simulation.RollingStocks; | ||
using ORTS.Common; | ||
using ORTS.Common.Input; | ||
|
||
namespace Orts.Viewer3D | ||
{ | ||
/// <summary> | ||
/// Processed external device data sent to UserInput class | ||
/// </summary> | ||
public class ExternalDeviceState | ||
{ | ||
public Dictionary<(CabViewControlType,int), ExternalDeviceCabControl> CabControls; | ||
public Dictionary<UserCommand, ExternalDeviceButton> Commands; | ||
public ExternalDeviceState() | ||
{ | ||
Commands = new Dictionary<UserCommand, ExternalDeviceButton>(); | ||
CabControls = new Dictionary<(CabViewControlType,int), ExternalDeviceCabControl>(); | ||
} | ||
|
||
public virtual void Handled() | ||
{ | ||
foreach (var button in Commands.Values) | ||
{ | ||
button.Changed = false; | ||
} | ||
foreach (var control in CabControls.Values) | ||
{ | ||
control.Changed = false; | ||
} | ||
} | ||
|
||
public bool IsPressed(UserCommand command) | ||
{ | ||
return Commands.TryGetValue(command, out var button) && button.IsPressed; | ||
} | ||
|
||
public bool IsReleased(UserCommand command) | ||
{ | ||
return Commands.TryGetValue(command, out var button) && button.IsReleased; | ||
} | ||
|
||
public bool IsDown(UserCommand command) | ||
{ | ||
return Commands.TryGetValue(command, out var button) && button.IsDown; | ||
} | ||
} | ||
public class ExternalDeviceButton | ||
{ | ||
bool isDown; | ||
public bool IsDown | ||
{ | ||
get | ||
{ | ||
return isDown; | ||
} | ||
set | ||
{ | ||
if (isDown != value) | ||
{ | ||
isDown = value; | ||
Changed = true; | ||
} | ||
} | ||
} | ||
public bool IsPressed { get { return IsDown && Changed; } } | ||
public bool IsReleased { get { return !IsDown && Changed; } } | ||
public bool Changed; | ||
} | ||
public class ExternalDeviceCabControl | ||
{ | ||
float value; | ||
public bool Changed; | ||
public float Value | ||
{ | ||
get | ||
{ | ||
return value; | ||
} | ||
set | ||
{ | ||
if (this.value != value) | ||
{ | ||
this.value = value; | ||
Changed = true; | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.