Skip to content

Commit 7a7e96d

Browse files
committed
Automatic merge of T1.5.1-344-ga8a891064 and 8 pull requests
- Pull request #722 at fb9079e: Fix Windows Forms deprecations in ActivityEditor - Pull request #732 at 1edb2e5: Improvements for air brakes - Pull request #751 at 00981a2: Web interface to control cab controls with external hardware - Pull request #767 at 4cb5c77: Refine sunrise and sunset - Pull request #803 at 7157e08: Various adjustments to steam adhesion - Pull request #807 at 791c0a3: fix: Stop z-fighting by pushing world/view/projection multiplications onto the GPU - Pull request #809 at f67822a: Some on-screen messages not suppressed, Bug #2008012 - Pull request #812 at d07f812: Bug fix for https://bugs.launchpad.net/or/+bug/2009955 Missing code to rotate DMU display in 2D cabs
10 parents 48479b4 + a8a8910 + fb9079e + 1edb2e5 + 00981a2 + 4cb5c77 + 7157e08 + 791c0a3 + f67822a + d07f812 commit 7a7e96d

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,9 @@ protected int ParseNumStyle(STFReader stf)
14521452
public class CVCScreen : CabViewControl
14531453
{
14541454
public readonly Dictionary<string, string> CustomParameters = new Dictionary<string, string>();
1455+
1456+
public float Rotation { get; set; }
1457+
14551458
public CVCScreen()
14561459
{
14571460
}
@@ -1465,6 +1468,7 @@ public CVCScreen(STFReader stf, string basepath)
14651468
new STFReader.TokenProcessor("graphic", ()=>{ ParseGraphic(stf, basepath); }),
14661469
new STFReader.TokenProcessor("units", ()=>{ ParseUnits(stf); }),
14671470
new STFReader.TokenProcessor("parameters", ()=>{ ParseCustomParameters(stf); }),
1471+
new STFReader.TokenProcessor("ortsangle", () =>{ Rotation = ParseRotation(stf); }),
14681472
new STFReader.TokenProcessor("disablediflowvoltagepowersupplyoff", ()=>{ ParseDisabledIfLowVoltagePowerSupplyOff(stf); }),
14691473
new STFReader.TokenProcessor("disabledifcabpowersupplyoff", ()=>{ ParseDisabledIfCabPowerSupplyOff(stf); }),
14701474
new STFReader.TokenProcessor("hideifdisabled", ()=>{ ParseHideIfDisabled(stf); }),

Source/RunActivity/Viewer3D/Popups/WindowText.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,9 @@ public void Draw(SpriteBatch spriteBatch, Rectangle position, Point offset, stri
229229
}
230230

231231
[CallOnThread("Render")]
232-
void Draw(SpriteBatch spriteBatch, Point position, float rotation, int width, string text, LabelAlignment align, Color color, Color outline)
232+
public void Draw(SpriteBatch spriteBatch, Point position, float rotation, int width, string text, LabelAlignment align, Color color, Color outline)
233233
{
234+
if (text == null) return;
234235
EnsureCharacterData(text);
235236
var characters = Characters;
236237

Source/RunActivity/Viewer3D/RollingStock/SubSystems/DistributedPowerInterface.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class DistributedPowerInterface
8282
/// </summary>
8383
public bool IsSoftLayout;
8484
public DPIWindow ActiveWindow;
85-
public DistributedPowerInterface(float height, float width, MSTSLocomotive locomotive, Viewer viewer, CabViewControl control)
85+
public DistributedPowerInterface(float height, float width, MSTSLocomotive locomotive, Viewer viewer, CVCScreen control)
8686
{
8787
Viewer = viewer;
8888
Locomotive = locomotive;
@@ -172,7 +172,7 @@ public DPDefaultWindow(DistributedPowerInterface dpi, CabViewControl control) :
172172
sUnits = sUnits.Replace('/', '_');
173173
CABViewControlUnits.TryParse(sUnits, out LoadUnits);
174174
}
175-
DPITable = new DPITable(FullTable, LoadUnits, fullScreen:true, dpi:dpi);
175+
DPITable = new DPITable(FullTable, LoadUnits, fullScreen:true, dpi:dpi, (control as CVCScreen).Rotation);
176176
AddToLayout(DPITable, new Point(0, 0));
177177
}
178178
}
@@ -199,18 +199,21 @@ public class TextPrimitive
199199
public Color Color;
200200
public WindowTextFont Font;
201201
public string Text;
202+
public float DrawRotation;
202203

203-
public TextPrimitive(Point position, Color color, string text, WindowTextFont font)
204+
public TextPrimitive(Point position, Color color, string text, WindowTextFont font, float drawRotation = 0)
204205
{
205206
Position = position;
206207
Color = color;
207208
Text = text;
208209
Font = font;
210+
DrawRotation = drawRotation;
209211
}
210212

211213
public void Draw(SpriteBatch spriteBatch, Point position)
212214
{
213-
Font.Draw(spriteBatch, position, Text, Color);
215+
Font.Draw(spriteBatch, position, DrawRotation, 0, Text, LabelAlignment.Left, Color, Color.Black);
216+
// Font.Draw(spriteBatch, position, Text, Color);
214217
}
215218
}
216219
public struct TexturePrimitive
@@ -372,6 +375,7 @@ public class DPITable : DPIWindow
372375
readonly int ColLength = 88;
373376
public bool FullTable = true;
374377
public CABViewControlUnits LoadUnits;
378+
private float DrawRotation = 0;
375379

376380
// Change text color
377381
readonly Dictionary<string, Color> ColorCodeCtrl = new Dictionary<string, Color>
@@ -390,22 +394,24 @@ public class DPITable : DPIWindow
390394

391395
public readonly string[] FirstColumn = { "ID", "Throttle", "Load", "BP", "Flow", "Remote", "ER", "BC", "MR" };
392396

393-
public DPITable(bool fullTable, CABViewControlUnits loadUnits, bool fullScreen, DistributedPowerInterface dpi) : base(dpi, 640, fullTable? 230 : 162)
397+
public DPITable(bool fullTable, CABViewControlUnits loadUnits, bool fullScreen, DistributedPowerInterface dpi, float drawRotation) : base(dpi, 640, fullTable? 230 : 162)
394398
{
395399
DPI = dpi;
396400
FullScreen = fullScreen;
397401
FullTable = fullTable;
398402
LoadUnits = loadUnits;
403+
DrawRotation = drawRotation;
399404
BackgroundColor = DPI.BlackWhiteTheme ? Color.Black : ColorBackground;
400405
SetFont();
401406
string text = "";
402407
for (int iRow = 0; iRow < (fullTable ? NumberOfRowsFull : NumberOfRowsPartial); iRow++)
403408
{
404409
for (int iCol = 0; iCol < NumberOfColumns; iCol++)
405410
{
406-
// text = iCol.ToString() + "--" + iRow.ToString();
407-
TableText[iRow, iCol] = new TextPrimitive(new Point(20 + ColLength * iCol, (iRow) * (FontHeightTableText + 8)), Color.White, text, TableTextFont);
408-
TableSymbol[iRow, iCol] = new TextPrimitive(new Point(10 + ColLength * iCol, (iRow) * (FontHeightTableText + 8)), Color.Green, text, TableSymbolFont);
411+
TableText[iRow, iCol] = new TextPrimitive(new Point(20 + ColLength * iCol - (int)(iRow * (FontHeightTableText - 8) * DrawRotation / 2), (iRow) * (FontHeightTableText + 8) + (int)(ColLength * iCol * DrawRotation)),
412+
Color.White, text, TableTextFont, DrawRotation);
413+
TableSymbol[iRow, iCol] = new TextPrimitive(new Point(10 + ColLength * iCol - (int)(iRow * (FontHeightTableText - 8) * DrawRotation / 2), (iRow) * (FontHeightTableText + 8) + (int)(ColLength * iCol * DrawRotation)),
414+
Color.Green, text, TableSymbolFont, DrawRotation);
409415
}
410416
}
411417
}

0 commit comments

Comments
 (0)