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 Oct 11, 2023
2 parents ae23564 + 1635057 commit 0e9ff90
Show file tree
Hide file tree
Showing 82 changed files with 582 additions and 690 deletions.
31 changes: 31 additions & 0 deletions assets/Compatibility/RoutePatches/Poland.xml
@@ -0,0 +1,31 @@
<openBVE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<RoutePatches>
<!-- Jasło - Mierzwice route -->
<Patch>
<Hash>7802444DAA75DD1B109FE04032FC52FE069F0B25CD54B24CFB2F6651A481F8E3</Hash>
<FileName>VIRTUAL2.rw</FileName>
<AccurateObjectDisposal>true</AccurateObjectDisposal>
<ReducedColorTransparency>true</ReducedColorTransparency>
</Patch>
<!-- Koduchy - Mumole route -->
<Patch>
<Hash>A706EB6A6C7E4394FFD876666FE48365E36AC7156C24F883BF51E4457F1296D0</Hash>
<FileName>POC_os.rw</FileName>
<AccurateObjectDisposal>true</AccurateObjectDisposal>
<ReducedColorTransparency>true</ReducedColorTransparency>
</Patch>
<Patch>
<Hash>ED3AADB683C0FE44CBC7AFD46F20F057909E2E73FF4C10E68D2ECA7B354AAC7C</Hash>
<FileName>POC_osp.rw</FileName>
<AccurateObjectDisposal>true</AccurateObjectDisposal>
<ReducedColorTransparency>true</ReducedColorTransparency>
</Patch>
<!-- Leszno-Krotoszyn -->
<Patch>
<Hash>1C600BA5074BF9C8B3E1BD045E544C123C919EAA82E676E04EBFBDAE971B0A03</Hash>
<FileName>Leszno-Krotoszyn.csv</FileName>
<AccurateObjectDisposal>true</AccurateObjectDisposal>
<ReducedColorTransparency>true</ReducedColorTransparency>
</Patch>
</RoutePatches>
</openBVE>
2 changes: 2 additions & 0 deletions assets/Compatibility/RoutePatches/UnitedKingdom.xml
Expand Up @@ -285,6 +285,8 @@
<FileName>Tinsford.csv</FileName>
<SignalSet>BritishRail.xml</SignalSet>
<AccurateObjectDisposal>true</AccurateObjectDisposal>
<!-- Invalid dike direction accepted by BVE -->
<Expression Number="372">.Wall 6;1;1</Expression>
</Patch>
<!-- Milngavie - Springburn -->
<Patch>
Expand Down
1 change: 1 addition & 0 deletions assets/Compatibility/RoutePatches/database.xml
Expand Up @@ -8,6 +8,7 @@
<PatchList>Holland.xml</PatchList>
<PatchList>HongKong.xml</PatchList>
<PatchList>Hungary.xml</PatchList>
<PatchList>Poland.xml</PatchList>
<PatchList>Italy.xml</PatchList>
<PatchList>Japan.xml</PatchList>
<PatchList>Misc.xml</PatchList>
Expand Down
Binary file added assets/Flags/SK.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions assets/Languages/sk-SK.xlf

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions source/CarXMLConvertor/TabbedList.cs
Expand Up @@ -6,9 +6,11 @@ internal class TabbedList
{
internal TabbedList()
{
this.Lines = new List<string>();
this.Lines.Add("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
this.Lines.Add("<openBVE xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
this.Lines = new List<string>
{
"<?xml version=\"1.0\" encoding=\"utf-8\"?>",
"<openBVE xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"
};
this.Tabs = 0;
}

Expand Down
7 changes: 7 additions & 0 deletions source/LibRender2/BaseRenderer.cs
Expand Up @@ -1663,5 +1663,12 @@ public void RenderFaceImmediateMode(ObjectState State, MeshFace Face, Matrix4D m
GL.MatrixMode(MatrixMode.Projection);
GL.PopMatrix();
}

/// <summary>Sets the current MouseCursor</summary>
/// <param name="newCursor">The new cursor</param>
public virtual void SetCursor(OpenTK.MouseCursor newCursor)
{

}
}
}
18 changes: 4 additions & 14 deletions source/LibRender2/Camera/Camera.cs
Expand Up @@ -34,10 +34,7 @@ public class CameraProperties
/// <summary>The absolute in-world camera position</summary>
public Vector3 AbsolutePosition
{
get
{
return absolutePosition;
}
get => absolutePosition;
set
{
if (value == absolutePosition)
Expand All @@ -60,10 +57,7 @@ public Vector3 AbsolutePosition
/// <summary>The current relative camera Direction</summary>
public CameraAlignment AlignmentDirection
{
get
{
return alignmentDirection;
}
get => alignmentDirection;
set
{
Renderer.UpdateVisibility(true);
Expand All @@ -88,10 +82,7 @@ public CameraAlignment AlignmentDirection
/// <summary>The current camera mode</summary>
public CameraViewMode CurrentMode
{
get
{
return currentMode;
}
get => currentMode;
set
{
if (currentMode == value)
Expand Down Expand Up @@ -351,8 +342,7 @@ public void UpdateQuadTreeLeaf()
/*
* Find the leaf node the camera is currently in.
* */
QuadTreeLeafNode currentLeaf;
Renderer.VisibleObjects.quadTree.GetLeafNode(AbsolutePosition, out currentLeaf);
Renderer.VisibleObjects.quadTree.GetLeafNode(AbsolutePosition, out QuadTreeLeafNode currentLeaf);

/*
* Check if the leaf node the camera is in has changed.
Expand Down
79 changes: 73 additions & 6 deletions source/LibRender2/Cursors/Cursor.cs
@@ -1,7 +1,11 @@
using System.Drawing;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Reflection;
using OpenBveApi.Interface;

namespace LibRender2.Cursors
namespace LibRender2
{
public class MouseCursor
{
Expand All @@ -24,7 +28,7 @@ public MouseCursor(BaseRenderer renderer, string fileName, Bitmap image)
if (stream != null)
{
Bitmap Plus = new Bitmap(stream);
using (var g = System.Drawing.Graphics.FromImage(Plus))
using (var g = 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);
Expand All @@ -35,7 +39,7 @@ public MouseCursor(BaseRenderer renderer, string fileName, Bitmap image)
else
{
Bitmap Plus = new Bitmap(OpenBveApi.Path.CombineFile(Renderer.fileSystem.GetDataFolder(), "Cursors\\Symbols\\plus.png"));
using (var g = System.Drawing.Graphics.FromImage(Plus))
using (var g = 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);
Expand All @@ -49,7 +53,7 @@ public MouseCursor(BaseRenderer renderer, string fileName, Bitmap image)
if (stream != null)
{
Bitmap Minus = new Bitmap(stream);
using (var g = System.Drawing.Graphics.FromImage(Minus))
using (var g = 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);
Expand All @@ -60,7 +64,7 @@ public MouseCursor(BaseRenderer renderer, string fileName, Bitmap image)
else
{
Bitmap Minus = new Bitmap(OpenBveApi.Path.CombineFile(Renderer.fileSystem.GetDataFolder(), "Cursors\\Symbols\\minus.png"));
using (var g = System.Drawing.Graphics.FromImage(Minus))
using (var g = 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);
Expand Down Expand Up @@ -89,4 +93,67 @@ public override string ToString()
return FileName;
}
}

public static class AvailableCursors
{
public static readonly List<MouseCursor> CursorList = new List<MouseCursor>();
public static OpenTK.MouseCursor CurrentCursor;
public static OpenTK.MouseCursor CurrentCursorPlus;
public static OpenTK.MouseCursor CurrentCursorMinus;
public static OpenTK.MouseCursor ScrollCursor;
internal static BaseRenderer Renderer;
public static void LoadCursorImages(BaseRenderer renderer, string CursorFolder)
{
Renderer = renderer;
if (!Directory.Exists(CursorFolder))
{
Renderer.currentHost.AddMessage(MessageType.Error, true, "Failed to load the default cursor images- Falling back to embedded.");
LoadEmbeddedCursorImages();
return;
}

string[] CursorImageFiles = Directory.GetFiles(CursorFolder);

foreach (var File in CursorImageFiles)
{
try
{
using (var Fs= new FileStream(File, FileMode.Open, FileAccess.Read))
{
if (File.EndsWith("scroll.png", StringComparison.InvariantCultureIgnoreCase))
{
Bitmap Image = new Bitmap(Fs);
MouseCursor c = new MouseCursor(Renderer, Path.GetFileName(File), Image);
ScrollCursor = c.MyCursor;
}
else
{
Bitmap Image = new Bitmap(Fs);
CursorList.Add(new MouseCursor(Renderer, Path.GetFileName(File), Image));
}


}
}
catch
{
// ignored
}
}
}

private static void LoadEmbeddedCursorImages()
{
var thisAssembly = Assembly.GetExecutingAssembly();
using (var stream = thisAssembly.GetManifestResourceStream("OpenBve.nk.png"))
{
if (stream != null)
{
Bitmap Image = new Bitmap(stream);
CursorList.Add(new MouseCursor(Renderer, "nk.png", Image));
}
}
Renderer.currentOptions.CursorFileName = "nk.png";
}
}
}
2 changes: 2 additions & 0 deletions source/LibRender2/LibRender2.csproj
Expand Up @@ -72,7 +72,9 @@
<Compile Include="Overlays\Marker.cs" />
<Compile Include="Overlays\RailPath.cs" />
<Compile Include="Overlays\TimeTableMode.cs" />
<Compile Include="Primitives\Button.cs" />
<Compile Include="Primitives\Cube.cs" />
<Compile Include="Primitives\GLControl.cs" />
<Compile Include="Primitives\Picturebox.cs" />
<Compile Include="Primitives\Rectangle.cs" />
<Compile Include="openGL\Vertex.cs" />
Expand Down
3 changes: 1 addition & 2 deletions source/LibRender2/Overlays/RailPath.cs
Expand Up @@ -65,8 +65,7 @@ public void Render()
{
double halfDistance = (Math.Max(Renderer.currentOptions.ViewingDistance, 1000) / 2.0) * 1.1;
int numElements = (int)(halfDistance / BlockLength);
int startElement;
if (!Display || !Visible(Renderer.CameraTrackFollower.TrackPosition, out startElement))
if (!Display || !Visible(Renderer.CameraTrackFollower.TrackPosition, out int startElement))
{
return;
}
Expand Down
40 changes: 40 additions & 0 deletions source/LibRender2/Primitives/Button.cs
@@ -0,0 +1,40 @@
using LibRender2.Text;
using OpenBveApi.Colors;
using OpenBveApi.Graphics;

namespace LibRender2.Primitives
{
public class Button : GLControl
{
/// <summary>The text displayed on the button</summary>
public string Text;
/// <summary>The highlight color of the button</summary>
public Color128 HighlightColor;
/// <summary>The color of the text on the button</summary>
public Color128 TextColor;
/// <summary>The font for the button</summary>
public OpenGlFont Font;

public Button(BaseRenderer renderer) : base(renderer)
{
}

public override void Draw()
{
Renderer.Rectangle.Draw(Texture, Location, Size, BackgroundColor);
if (CurrentlySelected)
{
Renderer.Rectangle.Draw(Texture, Location + 4, Size - 2, HighlightColor);
}
Renderer.OpenGlString.Draw(Font, Text, Location, TextAlignment.CenterLeft, TextColor);
}

public override void MouseMove(int x, int y)
{
if (x > Location.X && x < Location.X + Size.X && y > Location.Y && y < Location.Y + Size.Y)
{
CurrentlySelected = true;
}
}
}
}
39 changes: 39 additions & 0 deletions source/LibRender2/Primitives/GLControl.cs
@@ -0,0 +1,39 @@
using OpenBveApi.Colors;
using OpenBveApi.Math;
using OpenBveApi.Textures;

namespace LibRender2.Primitives
{
/// <summary>An abstract OpenGL based control</summary>
public abstract class GLControl
{
/// <summary>Holds a reference to the base renderer</summary>
internal readonly BaseRenderer Renderer;
/// <summary>The background color for the control</summary>
public Color128 BackgroundColor;
/// <summary>The texture for the control</summary>
public Texture Texture;
/// <summary>The stored location for the control</summary>
public Vector2 Location;
/// <summary>The stored size for the control</summary>
public Vector2 Size;
/// <summary>Whether the control is currently selected by the mouse</summary>
public bool CurrentlySelected;

protected GLControl(BaseRenderer renderer)
{
Renderer = renderer;
}

/// <summary>Draws the control</summary>
public abstract void Draw();

/// <summary>Passes a mouse move event to the control</summary>
/// <param name="x">The absolute screen X co-ordinate</param>
/// <param name="y">The absolute screen Y co-ordinate</param>
public virtual void MouseMove(int x, int y)
{

}
}
}
23 changes: 7 additions & 16 deletions source/LibRender2/Primitives/Picturebox.cs
@@ -1,33 +1,24 @@
using OpenBveApi.Colors;
using OpenBveApi.Colors;
using OpenBveApi.Math;
using OpenBveApi.Textures;
using OpenTK.Graphics.OpenGL;

namespace LibRender2.Primitives
{
public class Picturebox
public class Picturebox : GLControl
{
/// <summary>Holds a reference to the base renderer</summary>
private readonly BaseRenderer Renderer;
/// <summary>The texture for the picturebox</summary>
public Texture Texture;
/// <summary>The background color for the picturebox</summary>
public Color128 BackgroundColor;
/// <summary>The image sizing mode</summary>
public ImageSizeMode SizeMode;
/// <summary>The stored location for the textbox</summary>
public Vector2 Location;
/// <summary>The stored size for the textbox</summary>
public Vector2 Size;

private bool flipX;
private bool flipY;


public Picturebox(BaseRenderer renderer)
public Picturebox(BaseRenderer renderer) : base(renderer)
{
Renderer = renderer;
SizeMode = ImageSizeMode.Zoom;
}

public void Draw()
public override void Draw()
{
if (!Renderer.currentHost.LoadTexture(ref Texture, OpenGlTextureWrapMode.ClampClamp))
{
Expand Down

0 comments on commit 0e9ff90

Please sign in to comment.