Skip to content

Commit 8117250

Browse files
committed
1 parent 4dced6b commit 8117250

File tree

14 files changed

+184
-12
lines changed

14 files changed

+184
-12
lines changed

Source/Documentation/Manual/cabs.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,36 @@ and the mirrors.
480480
The control blocks are like the one shown for the cab light. The Type strings
481481
are ORTS_LEFTDOOR, ORTS_RIGHTDOOR and ORTS_MIRRORS.
482482

483+
.. _cabs-generic-items:
484+
485+
Cab controls for generic items
486+
------------------------------
487+
488+
OR supports the cabview controls for two generic two-state items.
489+
The cabview controls aree called ``<ORTS_GENERIC_ITEM_1>`` and
490+
``<ORTS_GENERIC_ITEM_2>``. Their state can be toggled also by respectively
491+
clicking keys ``<Shift+.>`` and ``<Shift+,>``.
492+
493+
Sound events are associated, that is::
494+
495+
240: GenericItem1On
496+
241: GenericItem1Off
497+
242: GenericItem2On
498+
243: GenericItem2Off
499+
500+
Animations within the .s file of the locomotive, either stopped/moving or
501+
two-state can be associated to the item state. Linked stopped/moving (wiper type)
502+
animations are named ``<ORTSITEM1CONTONUOUS>`` and ``<ORTSITEM2CONTINUOUS>``.
503+
Linked two-state animations (doors type) are named ``<ORTSITEM1TWOSTATE>`` and
504+
``<ORTSITEM2TWOSTATE>``.
505+
The default animation speed for stopped/moving type animations is 8 FPS.
506+
It may be modified with following parameter in the .sd file::
507+
508+
ESD_CustomAnimationSpeed ( 8 )
509+
510+
Examples of use are fan control, open/close of aerodynamic coverages of couplers
511+
in high speed trains, menu pages switching.
512+
483513

484514
High-resolution Cab Backgrounds and Controls
485515
--------------------------------------------

Source/Documentation/Manual/sound.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,18 @@ Trigger Function
391391
235 AirConditioningOff
392392
========= =====================================
393393

394+
Triggers from 240 to 243 associated to the two generic items
395+
(see :ref:`here <cabs-generic-items>`) :
396+
397+
========= =====================================
398+
Trigger Function
399+
========= =====================================
400+
240 GenericItem1On
401+
241 GenericItem1Off
402+
242 GenericItem2On
403+
243 GenericItem2Off
404+
========= =====================================
405+
394406
Variable Triggers
395407
-----------------
396408

Source/ORTS.Common/Input/UserCommand.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,10 @@ public enum UserCommand
205205
[GetString("Control ImmediateRefill")] ControlImmediateRefill,
206206
[GetString("Control Turntable Clockwise")] ControlTurntableClockwise,
207207
[GetString("Control Turntable Counterclockwise")] ControlTurntableCounterclockwise,
208-
[GetString("Control Generic 1")] ControlGeneric1,
209-
[GetString("Control Generic 2")] ControlGeneric2,
208+
[GetString("Control Generic Item 1")] ControlGenericItem1,
209+
[GetString("Control Generic Item 2")] ControlGenericItem2,
210+
[GetString("Control TCS Generic 1")] ControlTCSGeneric1,
211+
[GetString("Control TCS Generic 2")] ControlTCSGeneric2,
210212
[GetString("Control Cab Radio")] ControlCabRadio,
211213
[GetString("Control AI Fire On")] ControlAIFireOn,
212214
[GetString("Control AI Fire Off")] ControlAIFireOff,

Source/ORTS.Settings/InputSettings.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,10 @@ static void InitializeCommands(UserCommandInput[] Commands)
388388
Commands[(int)UserCommand.ControlForwards] = new UserCommandKeyInput(0x11);
389389
Commands[(int)UserCommand.ControlGearDown] = new UserCommandKeyInput(0x12, KeyModifiers.Shift);
390390
Commands[(int)UserCommand.ControlGearUp] = new UserCommandKeyInput(0x12);
391-
Commands[(int)UserCommand.ControlGeneric1] = new UserCommandKeyInput(0x33, KeyModifiers.Control);
392-
Commands[(int)UserCommand.ControlGeneric2] = new UserCommandKeyInput(0x34, KeyModifiers.Control);
391+
Commands[(int)UserCommand.ControlGenericItem1] = new UserCommandKeyInput(0x33, KeyModifiers.Shift);
392+
Commands[(int)UserCommand.ControlGenericItem2] = new UserCommandKeyInput(0x34, KeyModifiers.Shift);
393+
Commands[(int)UserCommand.ControlTCSGeneric1] = new UserCommandKeyInput(0x33, KeyModifiers.Control);
394+
Commands[(int)UserCommand.ControlTCSGeneric2] = new UserCommandKeyInput(0x34, KeyModifiers.Control);
393395
Commands[(int)UserCommand.ControlHandbrakeFull] = new UserCommandKeyInput(0x28, KeyModifiers.Shift);
394396
Commands[(int)UserCommand.ControlHandbrakeNone] = new UserCommandKeyInput(0x27, KeyModifiers.Shift);
395397
Commands[(int)UserCommand.ControlHeadlightDecrease] = new UserCommandKeyInput(0x23, KeyModifiers.Shift);

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ public enum CABViewControlTypes
202202
ORTS_ELECTRIC_TRAIN_SUPPLY_COMMAND_SWITCH,
203203
ORTS_ELECTRIC_TRAIN_SUPPLY_ON,
204204
ORTS_2DEXTERNALWIPERS,
205+
ORTS_GENERIC_ITEM1,
206+
ORTS_GENERIC_ITEM2,
205207

206208
// TCS Controls
207209
ORTS_TCS1,

Source/Orts.Formats.Msts/ShapeDescriptorFile.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public SDShape(STFReader stf)
6464
ESD_Bounding_Box = null;
6565
}),
6666
new STFReader.TokenProcessor("esd_ortssoundfilename", ()=>{ ESD_SoundFileName = stf.ReadStringBlock(null); }),
67-
new STFReader.TokenProcessor("esd_ortsbellanimationfps", ()=>{ ESD_BellAnimationFPS = stf.ReadFloatBlock(STFReader.UNITS.Frequency, null); }),
67+
new STFReader.TokenProcessor("esd_ortsbellanimationfps", ()=>{ ESD_CustomAnimationFPS = stf.ReadFloatBlock(STFReader.UNITS.Frequency, null); }),
68+
new STFReader.TokenProcessor("esd_ortscustomanimationfps", ()=>{ ESD_CustomAnimationFPS = stf.ReadFloatBlock(STFReader.UNITS.Frequency, null); }),
6869
});
6970
// TODO - some objects have no bounding box - ie JP2BillboardTree1.sd
7071
//if (ESD_Bounding_Box == null) throw new STFException(stf, "Missing ESD_Bound_Box statement");
@@ -76,7 +77,7 @@ public SDShape(STFReader stf)
7677
public bool ESD_Snapable;
7778
public bool ESD_SubObj;
7879
public string ESD_SoundFileName = "";
79-
public float ESD_BellAnimationFPS = 8;
80+
public float ESD_CustomAnimationFPS = 8;
8081
}
8182

8283
public class ESD_Bounding_Box

Source/Orts.Simulation/Common/Commands.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,4 +1999,47 @@ public override string ToString()
19991999
}
20002000
}
20012001

2002+
[Serializable()]
2003+
public sealed class ToggleGenericItem1Command : Command
2004+
{
2005+
public static MSTSLocomotive Receiver { get; set; }
2006+
2007+
public ToggleGenericItem1Command(CommandLog log)
2008+
: base(log)
2009+
{
2010+
Redo();
2011+
}
2012+
2013+
public override void Redo()
2014+
{
2015+
Receiver.GenericItem1Toggle();
2016+
}
2017+
2018+
public override string ToString()
2019+
{
2020+
return base.ToString();
2021+
}
2022+
}
2023+
2024+
[Serializable()]
2025+
public sealed class ToggleGenericItem2Command : Command
2026+
{
2027+
public static MSTSLocomotive Receiver { get; set; }
2028+
2029+
public ToggleGenericItem2Command(CommandLog log)
2030+
: base(log)
2031+
{
2032+
Redo();
2033+
}
2034+
2035+
public override void Redo()
2036+
{
2037+
Receiver.GenericItem2Toggle();
2038+
}
2039+
2040+
public override string ToString()
2041+
{
2042+
return base.ToString();
2043+
}
2044+
}
20022045
}

Source/Orts.Simulation/Common/Events.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ public enum Event
9292
GenericEvent6,
9393
GenericEvent7,
9494
GenericEvent8,
95+
GenericItem1On,
96+
GenericItem1Off,
97+
GenericItem2On,
98+
GenericItem2Off,
9599
HornOff,
96100
HornOn,
97101
LightSwitchToggle,
@@ -500,6 +504,11 @@ public static Event From(bool mstsBinEnabled, Source source, int eventID)
500504
case 234: return Event.AirConditioningOn;
501505
case 235: return Event.AirConditioningOff;
502506

507+
case 240: return Event.GenericItem1On;
508+
case 241: return Event.GenericItem1Off;
509+
case 242: return Event.GenericItem2On;
510+
case 243: return Event.GenericItem2Off;
511+
503512
case 250: return Event.OverchargeBrakingOn;
504513
case 251: return Event.OverchargeBrakingOff;
505514

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,8 @@ public override void Save(BinaryWriter outf)
12181218
outf.Write(IsWaterScoopDown);
12191219
outf.Write(CurrentTrackSandBoxCapacityM3);
12201220
outf.Write(SaveAdhesionFilter);
1221+
outf.Write(GenericItem1);
1222+
outf.Write(GenericItem2);
12211223
outf.Write(RemoteControlGroup);
12221224
outf.Write(DPUnitID);
12231225

@@ -1268,6 +1270,9 @@ public override void Restore(BinaryReader inf)
12681270
SaveAdhesionFilter = inf.ReadSingle();
12691271

12701272
AdhesionFilter.Reset(SaveAdhesionFilter);
1273+
1274+
GenericItem1 = inf.ReadBoolean();
1275+
GenericItem2 = inf.ReadBoolean();
12711276
RemoteControlGroup = inf.ReadInt32();
12721277
DPUnitID = inf.ReadInt32();
12731278

@@ -4236,6 +4241,18 @@ public void OdometerToggleDirection()
42364241
Simulator.Confirmer.Confirm(CabControl.Odometer, OdometerCountingUp ? CabSetting.Increase : CabSetting.Decrease);
42374242
}
42384243

4244+
public void GenericItem1Toggle()
4245+
{
4246+
GenericItem1 = !GenericItem1;
4247+
SignalEvent(GenericItem1? Event.GenericItem1On : Event.GenericItem1Off); // hook for sound trigger
4248+
}
4249+
4250+
public void GenericItem2Toggle()
4251+
{
4252+
GenericItem2 = !GenericItem2;
4253+
SignalEvent(GenericItem2 ? Event.GenericItem2On : Event.GenericItem2Off); // hook for sound trigger
4254+
}
4255+
42394256
public override bool GetCabFlipped()
42404257
{
42414258
return UsingRearCab;
@@ -5119,6 +5136,16 @@ public virtual float GetDataOf(CabViewControl cvc)
51195136
seconds += 60;
51205137
data = seconds;
51215138
break;
5139+
case CABViewControlTypes.ORTS_GENERIC_ITEM1:
5140+
{
5141+
data = GenericItem1 ? 1 : 0;
5142+
break;
5143+
}
5144+
case CABViewControlTypes.ORTS_GENERIC_ITEM2:
5145+
{
5146+
data = GenericItem2 ? 1 : 0;
5147+
break;
5148+
}
51225149

51235150
// Train Control System controls
51245151
case CABViewControlTypes.ORTS_TCS1:

Source/Orts.Simulation/Simulation/RollingStocks/MSTSWagon.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public class MSTSWagon : TrainCar
8181
public bool IsDavisFriction = true; // Default to new Davis type friction
8282
public bool IsBelowMergeSpeed = true; // set indicator for low speed operation as per given speed
8383

84+
85+
public bool GenericItem1;
86+
public bool GenericItem2;
87+
8488
Interpolator BrakeShoeFrictionFactor; // Factor of friction for wagon brake shoes
8589
const float WaterLBpUKG = 10.0f; // lbs of water in 1 gal (uk)
8690
float TempMassDiffRatio;

0 commit comments

Comments
 (0)