Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ create_resource_tmp = $(eval $(call resource_rule_impl, $(firstword $(subst ^, ,
# OpenBve #
###########

OPEN_BVE_FOLDERS := . Audio Game Graphics Graphics/Renderer Interface OldCode OldCode/NewCode Parsers Properties OldParsers OldParsers/BveRouteParser Simulation/TrainManager Simulation/TrainManager/Train Simulation/World System System/Functions System/Input System/Logging System/Program System/Translations UserInterface
OPEN_BVE_FOLDERS := . Audio Game Graphics Graphics/Renderer Interface OldCode OldCode/NewCode Parsers Properties OldParsers OldParsers/BveRouteParser Simulation/TrainManager Simulation/TrainManager/Train Simulation/TrainPlugins Simulation/World System System/Functions System/Input System/Logging System/Program System/Translations UserInterface
OPEN_BVE_FOLDERS := $(addprefix $(OPEN_BVE_ROOT)/, $(OPEN_BVE_FOLDERS))
OPEN_BVE_SRC := $(filter-out "$(OPEN_BVE_ROOT)/Properties/AssemblyInfo.cs",$(patsubst %, "%", $(foreach sdir, $(OPEN_BVE_FOLDERS), $(wildcard $(sdir)/*.cs))))
OPEN_BVE_DOC := $(addprefix /doc:, $(foreach sdir, $(OPEN_BVE_FOLDERS), $(wildcard $(sdir)/*.xml)))
Expand Down
22 changes: 22 additions & 0 deletions source/OpenBVE/Game/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ internal struct Message
internal Vector2 RendererPosition;
/// <summary>The level of alpha used by the renderer whilst fading out the message</summary>
internal double RendererAlpha;

internal Message(string Text, MessageDependency Depencency, MessageColor Color, double Timeout)
{
this.InternalText = Text;
this.Depencency = Depencency;
this.Color = Color;
this.Timeout = Timeout;
DisplayText = "";
RendererPosition = new Vector2(0.0, 0.0);
RendererAlpha = 0.0;
}
}

/// <summary>The current in-game messages</summary>
Expand Down Expand Up @@ -71,11 +82,22 @@ internal static void AddMessage(string Text, MessageDependency Depencency, Inter
Messages[n].RendererAlpha = 0.0;
}
}

internal static void AddMessage(Message Message)
{
int n = Messages.Length;
Array.Resize<Message>(ref Messages, n + 1);
Messages[n] = Message;
Messages[n].Timeout += Game.SecondsSinceMidnight;
}

internal static void AddDebugMessage(string text, double duration)
{
Game.AddMessage(text, Game.MessageDependency.None, Interface.GameMode.Expert, MessageColor.Magenta, Game.SecondsSinceMidnight + duration);
}



/// <summary>The number 1km/h must be multiplied by to produce your desired speed units, or 0.0 to disable this</summary>
internal static double SpeedConversionFactor = 0.0;
/// <summary>The unit of speed displayed in in-game messages</summary>
Expand Down
8 changes: 6 additions & 2 deletions source/OpenBVE/OldCode/Loading.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using OpenBveApi.Colors;
using OpenBveApi.Math;

namespace OpenBve {
Expand Down Expand Up @@ -29,8 +31,10 @@ internal static class Loading {
private static Encoding CurrentTrainEncoding;
internal static double TrainProgressCurrentSum;
internal static double TrainProgressCurrentWeight;
/// <summary>Stores the plugin error message string, or a null reference if no error encountered</summary>
internal static string PluginError;
/// <summary>The queue of messages to be displayed once the game has loaded</summary>
internal static List<Game.Message> MessageQueue = new List<Game.Message>();
/// <summary>The color to be used for the plugin message</summary>
internal static MessageColor PluginMessageColor = MessageColor.Red;

// load
/// <summary>Initializes loading the route and train asynchronously. Set the Loading.Cancel member to cancel loading. Check the Loading.Complete member to see when loading has finished.</summary>
Expand Down
9 changes: 6 additions & 3 deletions source/OpenBVE/OldCode/NewCode/GameWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection;
using System.Threading;
using System.Windows.Forms;
using OpenBveApi.Colors;
using OpenTK;
using OpenTK.Graphics;
using GL = OpenTK.Graphics.OpenGL.GL;
Expand Down Expand Up @@ -665,10 +666,12 @@ private void SetupSimulation()
Game.RouteInformation.ErrorsAndWarnings = Messages;
//Print the plugin error encountered (If any) for 10s
//This must be done after the simulation has init, as otherwise the timeout doesn't work
if (Loading.PluginError != null)
if (Loading.MessageQueue.Count > 0)
{
Game.AddMessage(Loading.PluginError, Game.MessageDependency.None, Interface.GameMode.Expert, OpenBveApi.Colors.MessageColor.Red, Game.SecondsSinceMidnight + 5.0);
Game.AddMessage(Interface.GetInterfaceString("errors_plugin_failure2"), Game.MessageDependency.None, Interface.GameMode.Expert, OpenBveApi.Colors.MessageColor.Red, Game.SecondsSinceMidnight + 5.0);
foreach (var message in Loading.MessageQueue)
{
Game.AddMessage(message);
}
}
}
loadComplete = true;
Expand Down
Loading