Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
leezer3 committed May 20, 2023
2 parents 8d52411 + d218387 commit f73cda6
Show file tree
Hide file tree
Showing 153 changed files with 2,541 additions and 1,885 deletions.
4 changes: 2 additions & 2 deletions assets/In-game/Default/interface.cfg
Expand Up @@ -280,7 +280,7 @@ textshadow = 1
transition = 2

[element]
subject = dist_next_station2
subject = distnextstation2
position = 8, -116
alignment = -1, 1
textcolor = 255, 255, 255, 255
Expand All @@ -289,7 +289,7 @@ textshadow = 1
transition = 2

[element]
subject = dist_next_station
subject = distnextstation
position = 8, -132
alignment = -1, 1
textcolor = 255, 255, 255, 255
Expand Down
27 changes: 25 additions & 2 deletions source/DevTools/LBAHeader/Program.cs
@@ -1,4 +1,28 @@
using System;
//Simplified BSD License (BSD-2-Clause)
//
//Copyright (c) 2020, Christopher Lees, The OpenBVE Project
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions are met:
//
//1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
//DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
//ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
//ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
//(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

using System;
using System.IO;
using Mono.Cecil;

Expand Down Expand Up @@ -69,7 +93,6 @@ public static void Add32BitFlag(string fileToProcess)
string configFile = fileToProcess + ".config";
string finalFileName = fileToProcess.Replace(".exe", "-32.exe");
Console.WriteLine("Creating 32-bit preferred copy of executable " + fileToProcess);
var output = Console.Out;
try
{
ModuleDefinition modDef = ModuleDefinition.ReadModule(fileToProcess);
Expand Down
24 changes: 24 additions & 0 deletions source/InputDevicePlugins/DefaultDisplayPlugin/Config.cs
@@ -1,3 +1,27 @@
//Simplified BSD License (BSD-2-Clause)
//
//Copyright (c) 2020, S520, The OpenBVE Project
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions are met:
//
//1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
//DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
//ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
//ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
//(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

using System;
using System.Windows.Forms;

Expand Down
@@ -1,8 +1,31 @@
//Simplified BSD License (BSD-2-Clause)
//
//Copyright (c) 2020, S520, The OpenBVE Project
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions are met:
//
//1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
//DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
//ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
//ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
//(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

using System;
using System.Globalization;
using System.Windows.Forms;
using OpenBveApi.FileSystem;
using OpenBveApi.Hosts;
using OpenBveApi.Interface;
using OpenBveApi.Runtime;

Expand Down
52 changes: 20 additions & 32 deletions source/LibRender2/Backgrounds/Background.cs
Expand Up @@ -21,23 +21,17 @@ internal Background(BaseRenderer Renderer)
/// <param name="Scale">The scale</param>
public void Render(BackgroundHandle Data, float Scale)
{
DynamicBackground dynamicBackground = Data as DynamicBackground;
StaticBackground staticBackground = Data as StaticBackground;
BackgroundObject backgroundObject = Data as BackgroundObject;

if (dynamicBackground != null)
{
RenderDynamicBackground(dynamicBackground, Scale);
}

if (staticBackground != null)
{
RenderStaticBackground(staticBackground, Scale);
}

if (backgroundObject != null)
switch (Data)
{
RenderBackgroundObject(backgroundObject);
case DynamicBackground dynamicBackground:
RenderDynamicBackground(dynamicBackground, Scale);
break;
case StaticBackground staticBackground:
RenderStaticBackground(staticBackground, Scale);
break;
case BackgroundObject backgroundObject:
RenderBackgroundObject(backgroundObject);
break;
}
}

Expand All @@ -47,23 +41,17 @@ public void Render(BackgroundHandle Data, float Scale)
/// <param name="Scale">The scale</param>
public void Render(BackgroundHandle Data, float Alpha, float Scale)
{
DynamicBackground dynamicBackground = Data as DynamicBackground;
StaticBackground staticBackground = Data as StaticBackground;
BackgroundObject backgroundObject = Data as BackgroundObject;

if (dynamicBackground != null)
{
RenderDynamicBackground(dynamicBackground, Alpha, Scale);
}

if (staticBackground != null)
{
RenderStaticBackground(staticBackground, Alpha, Scale);
}

if (backgroundObject != null)
switch (Data)
{
RenderBackgroundObject(backgroundObject);
case DynamicBackground dynamicBackground:
RenderDynamicBackground(dynamicBackground, Alpha, Scale);
break;
case StaticBackground staticBackground:
RenderStaticBackground(staticBackground, Alpha, Scale);
break;
case BackgroundObject backgroundObject:
RenderBackgroundObject(backgroundObject);
break;
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/LibRender2/Camera/Camera.cs
Expand Up @@ -334,9 +334,9 @@ public void Reset(Vector3 Position)
}

/// <summary>Unconditionally resets the camera</summary>
public void Reset()
public void Reset(bool ReverseDirection)
{
Alignment.Yaw = 0.0;
Alignment.Yaw = ReverseDirection ? 180 / 57.2957795130824 : 0;
Alignment.Pitch = 0.0;
Alignment.Roll = 0.0;
Alignment.Position = new Vector3(0.0, 2.5, 0.0);
Expand Down
7 changes: 7 additions & 0 deletions source/LibRender2/Camera/CameraRestriction.cs
Expand Up @@ -12,5 +12,12 @@ public struct CameraRestriction
public Vector3 BottomLeft;
/// <summary>The relative top right vector</summary>
public Vector3 TopRight;

/// <summary>Reverses the camera restriction</summary>
public void Reverse()
{
AbsoluteBottomLeft.Rotate(Vector3.Forward, 3.14159);
AbsoluteTopRight.Rotate(Vector3.Forward, 3.14159);
}
}
}
92 changes: 92 additions & 0 deletions source/LibRender2/Cursors/Cursor.cs
@@ -0,0 +1,92 @@
using System.Drawing;
using System.Reflection;

namespace LibRender2.Cursors
{
public class MouseCursor
{
internal readonly BaseRenderer Renderer;
public readonly string FileName;
public readonly OpenTK.MouseCursor MyCursor;
public readonly OpenTK.MouseCursor MyCursorPlus;
public readonly OpenTK.MouseCursor MyCursorMinus;
public readonly Image Image;

public MouseCursor(BaseRenderer renderer, string fileName, Bitmap image)
{
Renderer = renderer;
FileName = fileName;
Image = image;

var thisAssembly = Assembly.GetExecutingAssembly();
using (var stream = thisAssembly.GetManifestResourceStream("OpenBve.plus.png"))
{
if (stream != null)
{
Bitmap Plus = new Bitmap(stream);
using (var g = System.Drawing.Graphics.FromImage(Plus))
{
g.DrawImage(image, 0.0f, 0.0f, image.Width, image.Height);
var data = Plus.LockBits(new Rectangle(0, 0, Plus.Width, Plus.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
MyCursorPlus = new OpenTK.MouseCursor(5, 0, data.Width, data.Height, data.Scan0);
Plus.UnlockBits(data);
}
}
else
{
Bitmap Plus = new Bitmap(OpenBveApi.Path.CombineFile(Renderer.fileSystem.GetDataFolder(), "Cursors\\Symbols\\plus.png"));
using (var g = System.Drawing.Graphics.FromImage(Plus))
{
g.DrawImage(image, 0.0f, 0.0f, image.Width, image.Height);
var data = Plus.LockBits(new Rectangle(0, 0, Plus.Width, Plus.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
MyCursorPlus = new OpenTK.MouseCursor(5, 0, data.Width, data.Height, data.Scan0);
Plus.UnlockBits(data);
}
}
}
using (var stream = thisAssembly.GetManifestResourceStream("OpenBve.minus.png"))
{
if (stream != null)
{
Bitmap Minus = new Bitmap(stream);
using (var g = System.Drawing.Graphics.FromImage(Minus))
{
g.DrawImage(image, 0.0f, 0.0f, image.Width, image.Height);
var data = Minus.LockBits(new Rectangle(0, 0, Minus.Width, Minus.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
MyCursorMinus = new OpenTK.MouseCursor(5, 0, data.Width, data.Height, data.Scan0);
Minus.UnlockBits(data);
}
}
else
{
Bitmap Minus = new Bitmap(OpenBveApi.Path.CombineFile(Renderer.fileSystem.GetDataFolder(), "Cursors\\Symbols\\minus.png"));
using (var g = System.Drawing.Graphics.FromImage(Minus))
{
g.DrawImage(image, 0.0f, 0.0f, image.Width, image.Height);
var data = Minus.LockBits(new Rectangle(0, 0, Minus.Width, Minus.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
MyCursorMinus = new OpenTK.MouseCursor(5, 0, data.Width, data.Height, data.Scan0);
Minus.UnlockBits(data);
}
}
}

{
var data = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
MyCursor = new OpenTK.MouseCursor(5, 0, data.Width, data.Height, data.Scan0);
image.UnlockBits(data);
}
}

public enum Status
{
Default,
Plus,
Minus
}

public override string ToString()
{
return FileName;
}
}
}
5 changes: 3 additions & 2 deletions source/LibRender2/LibRender2.csproj
Expand Up @@ -21,7 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
<LangVersion>7</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
Expand All @@ -32,7 +32,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
<LangVersion>7</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
Expand All @@ -53,6 +53,7 @@
<Compile Include="Camera\Camera.cs" />
<Compile Include="Camera\CameraAlignment.cs" />
<Compile Include="Camera\CameraRestriction.cs" />
<Compile Include="Cursors\Cursor.cs" />
<Compile Include="Fog\Fog.cs" />
<Compile Include="Lighting\Lighting.cs" />
<Compile Include="Loading\Loading.cs" />
Expand Down
22 changes: 12 additions & 10 deletions source/LibRender2/Objects/ObjectLibrary.cs
Expand Up @@ -104,20 +104,22 @@ public void ShowObject(ObjectState State, ObjectType Type)
{
if (State.Prototype.Mesh.Materials[face.Material].WrapMode == null)
{
// If the object does not have a stored wrapping mode, determine it now
foreach (VertexTemplate vertex in State.Prototype.Mesh.Vertices)
if (State.Prototype.Mesh.Vertices.Length < 5000)
{
if (vertex.TextureCoordinates.X < 0.0f || vertex.TextureCoordinates.X > 1.0f)
// If the object does not have a stored wrapping mode and has a sensible number of verticies to check, determine it now
foreach (VertexTemplate vertex in State.Prototype.Mesh.Vertices)
{
wrap |= OpenGlTextureWrapMode.RepeatClamp;
}
if (vertex.TextureCoordinates.X < 0.0f || vertex.TextureCoordinates.X > 1.0f)
{
wrap |= OpenGlTextureWrapMode.RepeatClamp;
}

if (vertex.TextureCoordinates.Y < 0.0f || vertex.TextureCoordinates.Y > 1.0f)
{
wrap |= OpenGlTextureWrapMode.ClampRepeat;
if (vertex.TextureCoordinates.Y < 0.0f || vertex.TextureCoordinates.Y > 1.0f)
{
wrap |= OpenGlTextureWrapMode.ClampRepeat;
}
}
}

State.Prototype.Mesh.Materials[face.Material].WrapMode = wrap;
}
}
Expand Down Expand Up @@ -194,7 +196,7 @@ public void ShowObject(ObjectState State, ObjectType Type)
}
}
}

List<FaceState> list;

switch (Type)
Expand Down
16 changes: 2 additions & 14 deletions source/LibRender2/Overlays/RailPath.cs
Expand Up @@ -29,27 +29,15 @@ public class RailPath
/// <summary>Whether the path is visible at the current camera location</summary>
public bool CurrentlyVisible()
{
if (Display)
{
int temp;
return Visible(Renderer.CameraTrackFollower.TrackPosition, out temp);
}

return false;
return Display && Visible(Renderer.CameraTrackFollower.TrackPosition, out _);
}

/// <summary>Whether the path is visible at the specified location</summary>
/// <param name="trackPosition">The track position to check</param>
/// <returns></returns>
public bool Visible(double trackPosition)
{
if (Display)
{
int temp;
return Visible(trackPosition, out temp);
}

return false;
return Display && Visible(trackPosition, out _);
}

/// <summary>Whether this path is visible at the specified location</summary>
Expand Down

0 comments on commit f73cda6

Please sign in to comment.