From 01baf9a7cba134957211556567abd5c21581ff8a Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Thu, 21 Sep 2023 16:52:48 +0100 Subject: [PATCH 01/16] Improve null object error hiding --- source/ObjectViewer/Hosts.cs | 15 ++---- source/OpenBVE/System/Host.cs | 14 ++---- source/OpenBveApi/System/Hosts.cs | 81 +++++++++++++++++++++---------- source/RouteViewer/System/Host.cs | 14 ++---- 4 files changed, 65 insertions(+), 59 deletions(-) diff --git a/source/ObjectViewer/Hosts.cs b/source/ObjectViewer/Hosts.cs index cbe0e6186..5cb58dda7 100644 --- a/source/ObjectViewer/Hosts.cs +++ b/source/ObjectViewer/Hosts.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Drawing; using System.IO; +using System.Linq; using OpenBveApi; using OpenBveApi.Hosts; using OpenBveApi.Interface; @@ -290,19 +291,9 @@ public override bool LoadObject(string path, System.Text.Encoding Encoding, out } } } - - string fn = Path.GetFileNameWithoutExtension(path).ToLowerInvariant(); - switch (fn) + if (!NullFiles.Contains(Path.GetFileNameWithoutExtension(path).ToLowerInvariant())) { - case "empty": - case "null": - case "nullrail": - case "null_rail": - // Don't add an error for some common null objects - break; - default: - Interface.AddMessage(MessageType.Error, false, "No plugin found that is capable of loading object " + path); - break; + Interface.AddMessage(MessageType.Error, false, "No plugin found that is capable of loading object " + path); } } else { ReportProblem(ProblemType.PathNotFound, path); diff --git a/source/OpenBVE/System/Host.cs b/source/OpenBVE/System/Host.cs index ccebc5eea..56ad9a60a 100644 --- a/source/OpenBVE/System/Host.cs +++ b/source/OpenBVE/System/Host.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Drawing; using System.IO; +using System.Linq; using LibRender2.Screens; using OpenBveApi; using OpenBveApi.Colors; @@ -374,18 +375,9 @@ public override bool LoadObject(string path, System.Text.Encoding Encoding, out } } } - string fn = Path.GetFileNameWithoutExtension(path).ToLowerInvariant(); - switch (fn) + if (!NullFiles.Contains(Path.GetFileNameWithoutExtension(path).ToLowerInvariant())) { - case "empty": - case "null": - case "nullrail": - case "null_rail": - // Don't add an error for some common null objects - break; - default: - Interface.AddMessage(MessageType.Error, false, "No plugin found that is capable of loading object " + path); - break; + Interface.AddMessage(MessageType.Error, false, "No plugin found that is capable of loading object " + path); } } else { ReportProblem(ProblemType.PathNotFound, path); diff --git a/source/OpenBveApi/System/Hosts.cs b/source/OpenBveApi/System/Hosts.cs index 52a4da7c0..a9d61d8a0 100644 --- a/source/OpenBveApi/System/Hosts.cs +++ b/source/OpenBveApi/System/Hosts.cs @@ -67,9 +67,10 @@ public enum HostPlatform WINE = 4 } - + /// Represents the host application and functionality it exposes. - public abstract partial class HostInterface { + public abstract partial class HostInterface + { /// Returns whether the current host application is running under Mono public bool MonoRuntime => Type.GetType("Mono.Runtime") != null; @@ -81,10 +82,11 @@ public HostPlatform Platform { get { - if((int)cachedPlatform != 99) + if ((int)cachedPlatform != 99) { return cachedPlatform; } + if (Environment.OSVersion.Platform == PlatformID.Win32S | Environment.OSVersion.Platform == PlatformID.Win32Windows | Environment.OSVersion.Platform == PlatformID.Win32NT) { try @@ -98,15 +100,18 @@ public HostPlatform Platform { //ignored } + cachedPlatform = HostPlatform.MicrosoftWindows; return cachedPlatform; } + if (System.IO.File.Exists(@"/System/Library/CoreServices/SystemVersion.plist")) { //Mono's platform detection doesn't reliably differentiate between OS-X and Unix cachedPlatform = HostPlatform.AppleOSX; return cachedPlatform; } + string kernelName = DetectUnixKernel(); switch (kernelName) @@ -161,8 +166,8 @@ private static string DetectUnixKernel() [DllImport("libc")] private static extern void uname(out UName uname_struct); - [DllImport("ntdll.dll", EntryPoint="wine_get_version", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] - private static extern string GetWineVersion (); + [DllImport("ntdll.dll", EntryPoint = "wine_get_version", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] + private static extern string GetWineVersion(); /// The base host interface constructor protected HostInterface(HostApplication host) @@ -179,28 +184,32 @@ protected HostInterface(HostApplication host) /// Reports a problem to the host application. /// The type of problem that is reported. /// The textual message that describes the problem. - public virtual void ReportProblem(ProblemType type, string text) { } + public virtual void ReportProblem(ProblemType type, string text) + { + } /// Contains a list of missing files encountered public readonly List MissingFiles; - + /// Queries the dimensions of a texture. /// The path to the file or folder that contains the texture. /// Receives the width of the texture. /// Receives the height of the texture. /// Whether querying the dimensions was successful. - public virtual bool QueryTextureDimensions(string path, out int width, out int height) { + public virtual bool QueryTextureDimensions(string path, out int width, out int height) + { width = 0; height = 0; return false; } - + /// Loads a texture and returns the texture data. /// The path to the file or folder that contains the texture. /// The parameters that specify how to process the texture. /// Receives the texture. /// Whether loading the texture was successful. - public virtual bool LoadTexture(string path, TextureParameters parameters, out Texture texture) { + public virtual bool LoadTexture(string path, TextureParameters parameters, out Texture texture) + { texture = null; return false; } @@ -209,7 +218,8 @@ public virtual bool LoadTexture(string path, TextureParameters parameters, out T /// Receives the texture. /// The openGL wrap mode /// Whether loading the texture was successful. - public virtual bool LoadTexture(ref Texture texture, OpenGlTextureWrapMode wrapMode) { + public virtual bool LoadTexture(ref Texture texture, OpenGlTextureWrapMode wrapMode) + { return false; } @@ -219,17 +229,19 @@ public virtual bool LoadTexture(ref Texture texture, OpenGlTextureWrapMode wrapM /// Receives the handle to the texture. /// Whether the texture should also be pre-loaded /// Whether loading the texture was successful. - public virtual bool RegisterTexture(string path, TextureParameters parameters, out Texture handle, bool loadTexture = false) { + public virtual bool RegisterTexture(string path, TextureParameters parameters, out Texture handle, bool loadTexture = false) + { handle = null; return false; } - + /// Registers a texture and returns a handle to the texture. /// The texture data. /// The parameters that specify how to process the texture. /// Receives the handle to the texture. /// Whether loading the texture was successful. - public virtual bool RegisterTexture(Texture texture, TextureParameters parameters, out Texture handle) { + public virtual bool RegisterTexture(Texture texture, TextureParameters parameters, out Texture handle) + { handle = null; return false; } @@ -239,7 +251,8 @@ public virtual bool RegisterTexture(Texture texture, TextureParameters parameter /// The parameters that specify how to process the texture. /// Receives the handle to the texture. /// Whether loading the texture was successful. - public virtual bool RegisterTexture(Bitmap texture, TextureParameters parameters, out Texture handle) { + public virtual bool RegisterTexture(Bitmap texture, TextureParameters parameters, out Texture handle) + { handle = null; return false; } @@ -248,16 +261,18 @@ public virtual bool RegisterTexture(Bitmap texture, TextureParameters parameters /// The path to the file or folder that contains the sound. /// Receives the sound. /// Whether loading the sound was successful. - public virtual bool LoadSound(string path, out Sounds.Sound sound) { + public virtual bool LoadSound(string path, out Sounds.Sound sound) + { sound = null; return false; } - + /// Registers a sound and returns a handle to the sound. /// The path to the file or folder that contains the sound. /// Receives a handle to the sound. /// Whether loading the sound was successful. - public virtual bool RegisterSound(string path, out SoundHandle handle) { + public virtual bool RegisterSound(string path, out SoundHandle handle) + { handle = null; return false; } @@ -272,12 +287,13 @@ public virtual bool RegisterSound(string path, double radius, out SoundHandle ha handle = null; return false; } - + /// Registers a sound and returns a handle to the sound. /// The sound data. /// Receives a handle to the sound. /// Whether loading the sound was successful. - public virtual bool RegisterSound(Sounds.Sound sound, out SoundHandle handle) { + public virtual bool RegisterSound(Sounds.Sound sound, out SoundHandle handle) + { handle = null; return false; } @@ -386,7 +402,7 @@ public virtual bool LoadStaticObject(string Path, System.Text.Encoding Encoding, Object = null; return false; } - + /// Executes a function script in the host application /// The function script to execute /// The train or a null reference @@ -397,7 +413,9 @@ public virtual bool LoadStaticObject(string Path, System.Text.Encoding Encoding, /// Whether this is part of a train /// The frame time elapsed /// The current state of the attached object - public virtual void ExecuteFunctionScript(FunctionScripting.FunctionScript functionScript, AbstractTrain train, int CarIndex, Vector3 Position, double TrackPosition, int SectionIndex, bool IsPartOfTrain, double TimeElapsed, int CurrentState) { } + public virtual void ExecuteFunctionScript(FunctionScripting.FunctionScript functionScript, AbstractTrain train, int CarIndex, Vector3 Position, double TrackPosition, int SectionIndex, bool IsPartOfTrain, double TimeElapsed, int CurrentState) + { + } /// Creates a static object within the world of the host application, and returns the ObjectManager ID /// The prototype (un-transformed) static object @@ -440,7 +458,7 @@ public virtual int CreateStaticObject(StaticObject Prototype, Vector3 Position, /// The index of the dynamic object public virtual void CreateDynamicObject(ref ObjectState internalObject) { - + } /// Adds an object with a custom timetable texture @@ -468,8 +486,10 @@ public virtual void HideObject(ObjectState objectToHide) /// The type of message to be reported. /// Whether this message relates to a file not found /// The textual message. - public virtual void AddMessage(MessageType type, bool FileNotFound, string text) { } - + public virtual void AddMessage(MessageType type, bool FileNotFound, string text) + { + } + /// Adds a fully constructed message to the in-game display /// The message to add public virtual void AddMessage(object AbstractMessage) @@ -714,5 +734,16 @@ public virtual void AddTrain(AbstractTrain ReferenceTrain, AbstractTrain NewTrai /// Complete address of the named pipe endpoint. public static Uri Win32PluginHostEndpointAddress => new Uri(pipeBaseAddress + '/' + pipeName); + + /// Contains the list of commonly used 'empty' files + /// These generally aren't a valid object, and should be ignored for errors + public static string[] NullFiles = + { + "empty", + "null", + "nothing", + "nullrail", + "null_rail" + }; } } diff --git a/source/RouteViewer/System/Host.cs b/source/RouteViewer/System/Host.cs index 71773cfa9..6e4442121 100644 --- a/source/RouteViewer/System/Host.cs +++ b/source/RouteViewer/System/Host.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Drawing; using System.IO; +using System.Linq; using OpenBveApi; using OpenBveApi.Hosts; using OpenBveApi.Interface; @@ -390,18 +391,9 @@ public override bool LoadObject(string path, System.Text.Encoding Encoding, out } } } - string fn = Path.GetFileNameWithoutExtension(path).ToLowerInvariant(); - switch (fn) + if (!NullFiles.Contains(Path.GetFileNameWithoutExtension(path).ToLowerInvariant())) { - case "empty": - case "null": - case "nullrail": - case "null_rail": - // Don't add an error for some common null objects - break; - default: - Interface.AddMessage(MessageType.Error, false, "No plugin found that is capable of loading object " + path); - break; + Interface.AddMessage(MessageType.Error, false, "No plugin found that is capable of loading object " + path); } } else { ReportProblem(ProblemType.PathNotFound, path); From 377be7409c604ec129404662224b74e25cb89e23 Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Thu, 21 Sep 2023 17:36:37 +0100 Subject: [PATCH 02/16] Add explanatory comment for structure.roof 0 --- .../Plugins/Route.CsvRw/Namespaces/NonTrack/Structure.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Structure.cs b/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Structure.cs index a0be52a01..4062a6924 100644 --- a/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Structure.cs +++ b/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Structure.cs @@ -499,6 +499,14 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } } break; + /* + * NOTE: + * ----- + * Mackoy's documentation states the following: + * RoofIdxStType: Roof structure index (0: None) + * + * Unfortunately inconsistant with null objects for rails + */ case StructureCommand.RoofL: { if (!PreviewOnly) From d76b2769e741b7281fe8a6b809642f40802a93c9 Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Thu, 21 Sep 2023 18:26:39 +0100 Subject: [PATCH 03/16] Update Tinsford patch --- assets/Compatibility/RoutePatches/UnitedKingdom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/Compatibility/RoutePatches/UnitedKingdom.xml b/assets/Compatibility/RoutePatches/UnitedKingdom.xml index 733409c18..c184bba4e 100644 --- a/assets/Compatibility/RoutePatches/UnitedKingdom.xml +++ b/assets/Compatibility/RoutePatches/UnitedKingdom.xml @@ -285,6 +285,8 @@ Tinsford.csv BritishRail.xml true + + .Wall 6;1;1 From 4f4103ee58cf249c2a2b91f054527fd8fc5cc591 Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Thu, 21 Sep 2023 18:35:43 +0100 Subject: [PATCH 04/16] Fix: Correctly terminate the Route Preview thread without exception Harmless, but this is clean / correct --- source/OpenBVE/UserInterface/formMain.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/source/OpenBVE/UserInterface/formMain.cs b/source/OpenBVE/UserInterface/formMain.cs index 33e0af6a6..bc51b34e6 100644 --- a/source/OpenBVE/UserInterface/formMain.cs +++ b/source/OpenBVE/UserInterface/formMain.cs @@ -1590,6 +1590,7 @@ private void linkHomepage_LinkClicked(object sender, LinkLabelLinkClickedEventAr private void buttonClose_Click(object sender, EventArgs e) { currentlyClosing = true; + previewRouteResultQueue.CompleteAdding(); if (sender != null) { //Don't cause an infinite loop From 084eacd4048f57bd7ad481819ce420b1700399c0 Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Mon, 25 Sep 2023 19:32:18 +0100 Subject: [PATCH 05/16] New: Add Slovak language (DuckyProgamator) https://github.com/leezer3/OpenBVE/issues/948 --- assets/Flags/SK.png | Bin 0 -> 2648 bytes assets/Languages/sk-SK.xlf | 2 ++ 2 files changed, 2 insertions(+) create mode 100644 assets/Flags/SK.png create mode 100644 assets/Languages/sk-SK.xlf diff --git a/assets/Flags/SK.png b/assets/Flags/SK.png new file mode 100644 index 0000000000000000000000000000000000000000..a8642b78dbebd38855e13b3ea1b4a60c964275ad GIT binary patch literal 2648 zcmc&#O=uHQ5dPl&kt|(^$%3Z#FEO!#(u(zm3eq-2Y!1dE9y};|>Qyg_XYIjwQ>X_K z(ITEC7H{IkfCt6g{Aq1b{Hd3wwW(?BMw4CNizJZjs*Rhn1GDpHc;C#tnK%0qBk@Cu z+$sZ5V#Cp+RCZBTT@w8+Tpc(9$epq1(6M2KsB$Jxt1%VLaWPAvQ;b;M1 zS%I}A)vU^KR`p*UOCa0PUFE{WJuL6qU)5KRpR$7emrY1M{b&M4mcD^if$!`9T|n&L zi^2^VWUCjYw=*zuIXp^#L0&7Gu#FmolUGtE%m@E>)*Fa}2O#wC1KHq#``lUR^BJsO zx(q|paN$-OGjq!(Y@-Gi$3%jmmu*H#$B+Ay;I;%&c<>OM&kLfeK(Pps=U|03Is1o! z-T{_DEff5n3_jRJg9kv|F7UwsILbs4X&H7sM9$sF{_U5g!>u z;pT0&EEB({5A#`#T@Tx2*@BdB8+J<`yl81J2RNUY#%Svh`c~$k7W0sUy~xaJO=$s< z58pAJBd|$9uLqc%&VkJ-yAe#XjoUZ6;P<-mcxs7i_K8gFh?^2%ZbLl*jQJx-&1S1n zLVg9~;w!v=lCIk9F34hA*fIg;n1sW)J8%NmKT8;C=W*s`64LW$c4OAy$=AOmP}#}v z>_O@E8{nt?A5X<+MUutMp+8ojvS~e~ +English (United States)SlovenčinaUS.pngSK.pngUnknown2016-02-212023-09-24openBVEopenBVEStart new gameSpustiť novú hruReview last gameHodnotenie jazdyGet Add-onsZískať Add-onyCustomize controlsNastavenie ovládaniaOptionsVoľbyVisit official homepageNavštíviť oficiálnu stránkuCheck for updatesZkontrolovať aktualizácieA connection to the server could be established. Unfortunately, the version information could not be retrieved.Spojenie so serverom nadviazané, ale informácie o verzii sa nedá získať.You already have the latest version.Máte najaktuálnejšiu verziu.The new version [version] ([date]) is available for download on the Official Homepage.Nová verzia [version] ([date]) sa dá stiahnuť na oficiálnej domovskej stránke.CloseZatvoriťPackage ManagementPackage ManagementReport ProblemNahlásiť ProblémAboutO hreArcadeZačiatočníkNormalPokročilýExpertProfesionálUnknownNeznámýA critical error occured whilst parsing the [file] fileVyskytla sa závažná chyba pri parsovaní súboru [file]The file system configuration could not be accessed or is invalid due to the following reason:Nastavenie systému nemohlo byť načítané z nasledujúceho dôvodu:Warning:Varovanie:No control configuration files found.Ovládacie prvky neboli nájdené.An older key-configuration file was found.Bolo nájdené staré nastavenie ovládacích prvkov.The current key-configuration has been reset to defaults.Nastavenie ovládacích prvkov bolo resetované.The default key assingment file is an older version or corrupt.Nalezená verzia východzieho nastavenia ovládacích prvkov je staršia verzia alebo je poškodená.The default key assignment file does not exist.Predvolené nastavenie ovládacích prvkov nebolo nájdené.You are currently running on the [platform] backend. Please use the in-game menu to configure any joystick based controls.You are currently running on the [platform] backend. Please use the in-game menu to configure any joystick based controls.OpenAL 1.1 is required. You seem to have version 1.0.Pre chod hry je potrebný OpemA“1.1. Vypadá to tak že máte verziu 1.0.The OpenAL context could not be created.OpenAL kontext nemohol byť vytvorený.The OpenAL sound device could not be opened.Zvukové zariadenie OpenAL nemohlo byť otvorené.An error occured whilst attempting to switch to fullscreen mode.Vyskytla sa chyba pri skúšaní prejsť do režimu plnej obrazovky.Please check your fullscreen resolution settings.Prosím skontrolujte rozlíšenie plnej obrazovky v nastaveniach.The selected route is corrupt: \r\n WithTrack section missing.The selected route is corrupt: \r\n WithTrack section missing.The selected route is corrupt: \r\n No stations defined.The selected route is corrupt: \r\n No stations defined.The selected route is corrupt: \r\n No objects defined.The selected route is corrupt: \r\n No objects defined.The selected route is corrupt: \r\n Unable to locate all defined objects.The train plugin [plugin] failed to load.The train plugin [plugin] failed to load.The built-in ATS/ ATC systems will be used instead, which may cause issues.The built-in ATS/ ATC systems will be used instead, which may cause issues.Attempted to create a package with an empty filename.Attempted to create a package with an empty filename.The directory in which you attempted to save the package file does not exist: \r \nThe directory in which you attempted to save the package file does not exist: \r \nNo write access available in the directory in which you attempted to save the package file: \r \nNo write access available in the directory in which you attempted to save the package file: \r \nFailed to create the following file: \r \nFailed to create the following file: \r \nPlease check that this path is accessible.Please check that this path is accessible.If you are attempting to install addons in the Program Files or ProgramData folders, this may require administrator permission. \r\n\r\n This is not recommended for security reasons.If you are attempting to install addons in the Program Files or ProgramData folders, this may require administrator permission. \r\n\r\n This is not recommended for security reasons.The package database version appears to be a newer version than supported by this copy of OpenBVE.The package database XML was invalid, and has been re-created.Start new gameSpustiť novú hruRouteTraťSelectionVýberAdd-onsAdd-onyBrowse manuallyPrehliadaťRecently usedNaposledy spustenéDetailsDetailyDescriptionPopisMapMapaGradient profileVýškový profilSettingsNastaveniaEncoding:Kódovanie:Preview:Náhľad:Processing route, please wait.....Processing route, please wait.....TrainVlakSelectionVýberAdd-onsAdd-onyBrowse manuallyPrehliadaťRecently usedNaposledy použitéRoute defaultVýchodzieUse the train suggested by the routePoužiť pridružený vlak k tratiDetailsDetailyDescriptionPopisSettingsNastaveniaEncoding:Kódování:Reverse Consist:Preview:Náhľad:The default train could not be found:\n\nVlak pridružený k trati nenájdený.--- This train uses a safety system plugin which cannot be used on your operating system. The built-in safety systems ATS/ATC will be used instead, which might cause operational problems. ------ Tento vlak používa zásuvný modul zabezpečovacieho systému, ktorý nemôže byť použitý na vašom systému. Vstavané systémy ATS/ATC budú použité namiesto nich, čo môže spôsobiť problémy pri riadení. ---StartSpusiťMode of driving:Obtiažnosť riadenia:StartSpustiťReview last gameHodnotenie poslednej jazdyConditionsZákladné údajeRouteTraťRoute file:Súbor trate:TrainVlakTrain folder:Zložka vlaku:Date and timeČasové údajeDate:Dátum:Time:Čas:ScoreSkóreRatingHodnotenieMode:Obtiažnosť:Achieved:Dosiahnuté:Maximum:Maximum:Ratio:Úspešnosť:LogZáznamTimeČasPosition (m)Poloha (m)ValueHodnotenieCumulativeCelkomReasonPríčinaShow penalties onlyZobraziť iba trestné bodyExport...Export...Black boxČierna skrinkaFormat:Formát:Comma-separated valueHodnoty oddelené čiarkou (*.csv)Formatted textFormátovaný textExport...Export...Package ManagementPackage ManagementProceed...Proceed...Proceed AnywayProceed AnywayProcessing, please wait...Spracovanie, prosím čakajte...Unknown File...Unknown File...These are shown in the list below:These are shown in the list below:No package selected.No package selected.No website provided.No website provided.Installed PackagesInstalled PackagesSelect the type of packages you wish to view:Select the type of packages you wish to view:NameNameVersionVersionMinimum VersionMinimum VersionMaximum VersionMaximum VersionAuthorAutorWebsiteStránkaTypeTypInstallInštalovaťInstall PackageInštalovať BalíkInstall a PackageInštalovať BalíkThis file does not appear to be a valid openBVE package.This file does not appear to be a valid openBVE package.Package Version ErrorPackage Version ErrorThe selected package is already installed, and is a newer version.The selected package is already installed, and is a newer version.The selected package is already installed, and is an older version.The selected package is already installed, and is an older version.The selected package is already installed, and is an identical version.The selected package is already installed, and is an identical version.Package installation was successful.Package installation was successful.Installation SuccessfulInstallation SuccessfulA list of files installed is shown below:A list of files installed is shown below:Unfortunately, package installation failed.Unfortunately, package installation failed.Package Installation FailedInštalovanie Balíka zlyhaloSelect Package......Vybrať Balík......The current package has unmet dependancies.The current package has unmet dependancies.Dependancy ErrorDependancy ErrorThe following dependancies may be broken by this action:The following dependancies may be broken by this action:The following packages are recommended, but not installed:The following packages are recommended, but not installed:Recommended PackagesRecommended PackagesPackage Name:Package Name:Package Author:Autor Balíka:Package Version:Package Version:Package Website:Stránka Balíka:Package Description:Popis Balíka:Create PackageVytvoriť BalíkCreate a PackageVytvoriť BalíkSave As...Uložit ako...Save package as:Uložiť balík ako:Select DependanciesSelect DependanciesAdd DependancyAdd DependancyRemoveRemovePackage details and dependancies may be assigned in the following steps.Package details and dependancies may be assigned in the following steps.Add RecommendationAdd RecommendationClear SelectionClear SelectionAdd Item(s)Add Item(s)The following files and folders will be packaged:The following files and folders will be packaged:The new package has been assigned the following GUID:The new package has been assigned the following GUID:Enter Package DetailsCreate a PackagePlease enter a package name.Please enter a package name.Please enter a package author.Please enter a package author.Please enter a package description.Please enter a package description.Please enter a valid package version number in the following format: \r\n 1.0.0Please enter a valid package version number in the following format: \r\n 1.0.0You have entered an invalid version number. \r\n Please try again.You have entered an invalid version number. \r\n Please try again.Package creation was successful.Package creation was successful.Package Creation SuccessfulPackage Creation SuccessfulThe following files were added to your package:The following files were added to your package:Unfortunately, creation of your package failed.Unfortunately, creation of your package failed.Package Creation FailedPackage Creation FailedThe following error was encountered:The following error was encountered:Proceed......Pokračovať......No files were selected to package- Please retry.No files were selected to package- Please retry.The selected filename is invalid- Please retry.The selected filename is invalid- Please retry.The new package has been assigned the following GUID:The new package has been assigned the following GUID:Replacing the package with the following GUID:Replacing the package with the following GUID:Save PackageUložiť BalíkIs this to replace an existing package?Is this to replace an existing package?YesÁnoNoNieReplace this PackageNahradiť tento BalíkPlease select the package you wish to replace:Prosím vyberte Balík ktorý si prajete nahradiť:No packages are currently installed.Žiadne balíky nie sú inštalované.RouteTraťTrainVlakOtherInéPlease select the package type:Prosím vyberte typ balíka:Unfortunately, uninstallation of this package failed.Odinštalovanie balíka zlyhalo.Uninstallation FailedOdinštalovanie ZlyhaloUninstallation of this package was successful.Odinštalovanie balíka bolo úspešné.Uninstallation SuccessfulOdinštaovanie ÚspešnéA log is shown below:A log is shown below:Uninstall PackageOdinštalovať BalíkSome existing packages may be broken by this action.Some existing packages may be broken by this action.Unable to uninstall the selected package. \r\n XML file list missing.Unable to uninstall the selected package. \r\n XML file list missing.Do you wish to remove this package from the database?Do you wish to remove this package from the database?An error occured whilst saving the package database. \r\n Please check for write permissions.An error occured whilst saving the package database. \r\n Please check for write permissions.New version:Nová verzia:Current version:Súčasná verzia:Finished!Dokončené!Selected PackagesVybrané BalíkyDependancyDependancyRecommendationRecommendationPlease select the action you wish to take:Please select the action you wish to take:OverwritePrepísaťReplaceNahradiťNext >Next >< Back< BackCancelZrušiťOKOKInstallInštalovaťCreateVytvoriťIgnoreIgnorovaťAbortPrerušiťAttempted to create a package with an empty filename.Attempted to create a package with an empty filename.The directory in which you attempted to save the package file does not exist: \r \nThe directory in which you attempted to save the package file does not exist: \r \nNo write access available in the directory in which you attempted to save the package file: \r \nNo write access available in the directory in which you attempted to save the package file: \r \nFailed to create the following file: \r \nFailed to create the following file: \r \nCustomize controlsNastavenie ovládacích prvkovCommandPríkazTypeTypDigitalDigitalAnalog (half axis)Analog (pol osy)Analog (full axis)Analog (celá osa)DescriptionPopisAssignmentPriradenieCommand OptionCommand OptionAdd controlPridať prvokRemove controlOdobrať prvokImport...Importovať...Export...Exportovať...Reset to defaultsObnoviť na východzieMove upPosun horeMove downPosun doleCurrently selected commandAktuálne vybraný príkazCommand:Príkaz:Command Option:Command Option:Keyboard:Klávesnica:Click here to enable keyboard grab to automatically select the desired key.Click here to enable keyboard grab to automatically select the desired key.Please press any key...Please press any key...Key:Tlačidlo:Modifiers:Modifikátor:ShiftShiftCtrlCtrlAltAltJoystick:Joystick:Assignment:Priadenie:Click here to enable joystick grab to automatically select the desired axis, button or hat.Kliknutím sem aktivujete nastavene joysticku.\r\n\r\nPredtým však vráťte páku do východzej polohy a uvolnite všetky tlačídlá.Press a button or move an axis or hat into the desired direction...Stlačte tlačidlo podľa vašej voľby alebo pohnite pákou v požadovanom smere...Move an axis into the direction of "increase" or "power"...Pohněte pákou v požadovanom smeru pre sníženie aleboo zvýšenie výkonu...Attached joysticksJoystick pripojenýKeyboardKlávesnicaShift +\x20Shift +\x20Ctrl +\x20Ctrl +\x20Alt +\x20Alt +\x20Joystick [index]Joystick [index]axis [index]osa [index]negative directionzáporný směrpositive directionkladný smerinvalid directionchybný smerbutton [index]tlačidlo [index]hat [index]postavenie [index]leftvľavoup-lefthore-vľavouphoreup-righthore-vpravorightvpravodown-rightdole-vpravodowndoledown-leftdole-vľavoinvalidchybneNot assignedNepriradené,\x20,\x20LED Display speed unitsLED Display speed unitsMiles per Hour (MPH)Míle za Hodinu (MPH)Kilometre za Hodinu (KPH)Kilometers per Hour (KPH)Set Calibration:Set Calibration:LaunchLaunchNo RailDriver conrollers detected.No RailDriver conrollers detected.Error loading RailDriver calibration file.Error loading RailDriver calibration file.Please press 'Next' to start calibration.Please press 'Next' to start calibration.Move the reverser lever to the full reverse position and press 'Next'.Move the reverser lever to the full reverse position and press 'Next'.Move the reverser lever to the full forward position and press 'Next'.Move the reverser lever to the full forward position and press 'Next'.Move the combined brake / throttle lever to the full power position and press 'Next'.Move the combined brake / throttle lever to the full power position and press 'Next'.Move the combined brake / throttle lever to the full brake position and press 'Next'.Move the combined brake / throttle lever to the full brake position and press 'Next'.Move the dynamic brake lever to the release position and press 'Next'.Move the dynamic brake lever to the release position and press 'Next'.Move the dynamic brake lever to the emergency position and press 'Next'.Move the dynamic brake lever to the emergency position and press 'Next'.Move the independant brake lever to the release position and press 'Next'.Move the independant brake lever to the release position and press 'Next'.Move the independant brake lever to the full position and press 'Next'.Move the independant brake lever to the full position and press 'Next'.Move the bail-off lever to the release position and press 'Next'.Move the bail-off lever to the release position and press 'Next'.Move and hold the bail-off lever into the full position and press 'Next'.Move and hold the bail-off lever into the full position and press 'Next'.Move the wiper switch to OFF and press 'Next'.Move the wiper switch to OFF and press 'Next'.Move the wiper switch to FULL and press 'Next'.Move the wiper switch to FULL and press 'Next'.Move the lights switch to OFF and press 'Next'.Move the lights switch to OFF and press 'Next'.Move the lights switch to FULL and press 'Next'.Move the lights switch to FULL and press 'Next'.Calibration complete.Calibration complete.OptionsVoľbyLanguageJazykDisplaySpôsob zobrazeniaDisplay modeZobrazeniaWindow modeOknoFullscreen modeCelá obrazovkaVertical synchronization:Vertikálna synchronizácia:DisabledVYPEnabledZAPWindow modeOknoWidth:Šírka:Height:Výška:FullscreenCelá obrazovkaWidth:Šírka:Height:Výška:Bits per pixel:Farebná hĺbka:QualityKvalita zobrazeniaInterpolationInterpoláciaMode:Metóda:Nearest neighborNajbližší susedBilinearBilineárnaNearest neighbor (mipmapping)Njbližší sused (mipmapping)Bilinear (mipmapping)Bilineárna (mipmapping)Trilinear (mipmapping)Trilineárna (mipmapping)Anisotropic filteringAnisotropné filtrovanieLevel of anisotropic filtering:Úroveň anisotropného filtrovania:Level of anti-aliasing:Úroveň anti-aliasingu:Transparency:Transparentnosť:SharpOstréSmoothHladkéDistance effectsViditeľnosťViewing distance:Viditeľnosť na vzdialenosť:mmMotion blur:Rozmazanie:DisabledVypnutéLowNízkeMediumStrednéHighVysokéMiscellaneousOstatnéDetail of simulationDetail simulácieTopplingPrevrátenieCollisionsKolízieDerailmentsVykoľajenieEnable black boxČierna skrinkaEnable loading swayEnable loading swayControlsOvládacie prvkyJoysticks enabledJoystickJoystick threshold:Citlivosť:Allow EB on brake axisPovolit EB na brzdovej osiSoundZvukEffective range:Vzdialenostný dosah:LowKrátkyMediumStrednýHighVysokýNumber of allowed sounds:Počet povolených zvukov:VerbosityPre vývojarovShow warning messagesUkázať výstražné správyShow error messagesUkázat chybové zprávyAdvanced OptionsPokročilé nastaveniaLoad in advanceNačítať predomEnable the new rendererDisable OpenGL display listsZakázať OpenGL display listyAccelerated Time FactorZrýchlenie časuUnload unused texturesUvolniť nepoužité textúryOtherOtherTimetable mode:Timetable modeNoneNoneDefaultDefaultAuto-generated timetableAuto-generated timetablePrefer custom timetablePrefer custom timetableChoose...Choose...Route installation directory:Route installation directory:Train installation directory:Train installation directory:Other items installation directory:Other items installation directory:Package compression format:Package compression format:Previous Page...Predchádzajúca Strana...Next Page...Ďalšia Strana...Kiosk ModeKiosk ModeEnable Kiosk ModeEnable Kiosk ModeControl Timeout (s)Control Timeout (s)HUD SizeHUD SizeSmallSmallNormalNormalLargeLargeAttempt to fix transparency issues in older content.Attempt to fix transparency issues in older content.Enable hacks for buggy older content.Enable hacks for buggy older content.Input Device PluginInput Device PluginWARNING: If you enable Input Device Plugin(s), these may conflict with one or more controls.WARNING: If you enable Input Device Plugin(s), these may conflict with one or more controls.NameNameStatusStatusFailureFailureDisableDisableEnableEnableVersionVersionProviderProviderFile NameFile NameEnable this Input Device PluginEnable this Input Device PluginConfigConfigEnable Panel2 Extended ModeX Object ParserOBJ Object ParserDefault Signals:CSV filesCSV súboryText filesTextové súboryControlsOvládacie prvkyAll filesVšetky súboryTimeČasPosition (m)Poloha (m)ValueHodnotenieCumulativeCelkomReasonPríčinaSpeed (m/s)Rýchlosť (m/s)Acceleration (m/s²)Zrýchlenie (m/s²)ReverserReverserPowerVýkonBrakeBrzdaEventUdalosťRoute:Trať:Train:Vlak:Date:Dátum:Mode:Obtiažnosť:Score:Skóre:Rating:Hodnotenie:LoadingNačítanieLoading route...Načítanie trate...Loading train...Načítanie vlaku...Almost ready to startPripraveno k spusteniuFiles not found:Súbory nenájdené:Some issues were encountered while loading the route and train.\r\n\r\nAs some files could not be found, the route or train might not appear as intended. Try to redownload the route and train packages in order to ensure that you have a complete distribution.\r\n\r\nThe following list of issues might give additional information. You can still start the route by selecting "Ignore" from below.Pri načítání trate a vlaku bolo nájdených niekoľko chýb.\r\n\r\nNiektoré súbory obsiahnuté v trati a vlaku neboli nájdené, preto se ujistite, či máte stiahnuté všetky súčasti simulácie.\r\n\r\nNásledujúcí zoznam chýb vám môže poskytnúť viac informácií. Kliknutím na tlačidlo "Ignorovať" môžete pokračovat v spustení simulácie.Some issues were encountered while loading the route and train. If you are the route or train developer, it might be worth taking a look at the following list of issues.\r\n\r\nAs a regular user, you can select "Ignore" at this point to start the game.Pri načítaní trate a vlaku bolo nájdených niekoľko chýb. Ak ste vývojárom tratí a vlakov, môže vám nasledujúci zoznam chýb poskytnúť viac informácií. Ako bežný užívateľ môžete kliknutím na tlačidlo "Ignorovať" pokračovať v spustení simulácie.Show issuesPodrobnostiProblemsChybyTypeTypDescriptionPopisSave report...Uložiť správu...IgnoreIgnorovaťCancelZrušiťMax.\r\nspd.Max.\r\nrych.Drv.\r\ntimeDoba\r\njazdyStation nameStanicaArrivalPríjazdDepartureOdjazd\x20\x20You may proceed at [speed] [unit] with extreme caution.S mimoriadnou opatrnosťoi môžete pokračovat rýchlosťou [speed] [unit].You have passed a stop signal. Please apply the emergency brakes immediately and come to a complete hold.Prešli ste návesť zakazujúcu jazdu. Bezodkladne použite rýchlobrzdu a vráťte sa späť.The signal indicates a speed limit of [limit] [unit]. You are currently traveling at [speed] [unit]. Please slow down.Rýchlosť návestená návestidlom je [limit] [unit]. Vaša skutočná rýchlosť je [speed] [unit]. Prosím spomaľte.The speed post indicates a speed limit of [limit] [unit]. You are currently traveling at [speed] [unit]. Please slow down.Rýchlosť návestená návesťou je [limit] [unit]. Vaša skutočná rýchlosť je [speed] [unit]. Prosím spomaľte.You have arrived at [name].Prišli ste do stanice [name].You have arrived at [name] and are [time] late.Prišli ste do stanice [name] s meškaním [time].You have arrived at [name] and are [time] early.Prišli ste do stanice [name] o [time] skôr.Overrun: [difference] m.Presnosť zastavenia: +[difference] m.Underrun: [difference] m.Presnosť zastavenia: -[difference] m.This is the terminal station.Táto stanica je konečná.Departure is expected in [time].Do odjazdu zostáva [time].Please activate [system].Aktivujte [system].Please correct your stop position.Opravte svoju pozíciu zastavenia.Boarding complete. You may close the doors now.Máte súhlas k odjazdu. Môžete zavrieť dvere a odísť.Boarding complete.Máte súhlas k odjazdu.You have passed [name] where you should have stopped.Zabudli ste zastaviť v stanici [name].You have passed [name] while still boarding. Please come to a complete hold immediately.Odišli ste zo stanice [name], práve keď nastupovali cestujúci. Vráťte sa späť, vyčkajte nástupu a potom zatvorte dvere.Loading. Please wait...Načítavanie. Prosím čakajte...Interior cameraPohľad z kabínyInterior camera (look ahead)Pohľad z kabíny (pohľad vpred)Exterior cameraVonkajší pohľadTrack cameraPohľad na traťFly-by camera (normal)Kamera sledujúca prejazd vlaku (normál)Fly-by camera (zooming)Kamera sledujúca prejazd vlaku (zoom)CPU: normalCPU zaťaženie: normálneCPU: lowCPU zaťaženie: nízkeBackface culling: onZobrazenie zadnej strany objektov: VYPBackface culling: offZobrazenie zadnej strany objektov:: ZAPThis feature is not available in Expert mode.Táto funkcia nie je v obtiažnosti "profesionál" k dispozícii.The AI might be unable to fully operate this train.Majte napamäti, že automatický rušňovodič nie je schopný plne ovládať tento vlak.Camera restriction: onZamknutie pohľadu zo stanovišťa: ZAPCamera restriction: offZamknutie pohľadu zo stanovišťa: VYPMouse grab: onOvládanie pomocou myši: ZAPMouse grab: offOvládanie pomocou myši: VYPOverspeedPrekročená rýchlosťPassed red signalPrejdenie návesti STOJTopplingPrevrátenieDerailedVykoľajeniePassenger discomfortNepohodlie cestujícichDoors openedOtvorené dvereArrived at stationPríjazd do stanicePerfect time bonusBonus za včasný príjazdLateMeškaniePerfect stop bonusBonus za správne zastavenieStopPresnosť zastaveniaPremature departurePredčasný odjazdTotalCelkomYour rating:Vaše hodnotenie:AbysmalKatastrofálneTerriblePríšenéBadZléPoorŠpatnéFairSlabéMediocrePriemernéGoodDobréGreatSkveléSuperbVýbornéExcellentPrvotriedneUnknownNeznámeResume simulationPokračovať SimuláciuJump to stationSkok do staniceExit to main menuOdísť do hlavného menuDo you really want to exit to the main menu?Ukončiť simuláciu a vrátiť sa do hlavného menu?NoNieYesÁnoQuitUkončiťDo you really want to quit?Ukončiť openBVE?NoNieYesÁno← Back← SpäťCustomise controlsPrispôsobiť ovládacie prvkyPlease press any key or move a joystick axis to set this control...Stlačte kláves alebo pohnite pákou joystickom pre nastavenie tohto prvku...KeyboardKlávesnicaJoystickJoystickN/AN/APositivePositiveNegativeNegativeCurrent assignment:Current assignment:ATSATSATS RUNATS ZÁSAHP POWERP SIGNÁLPTN APPROACHPRIBLÍŽENIEBRAKE RELEASEODBRZDENIEÍBRAKE APPLYBRZDAATS-PATS-PFAILUREPORUCHAATCATCATC POWERATC SIGNÁLATC SRVATC BRZDAATC EMGATC RYCH.BRZDAEBBDELOSŤCONST SPEEDUDRŽUJ RYCH.FPNNBZPPNNBBLLNNRELODLAPLAPSRVSRVEMGRBHLDDBLLRPScore:\x20Score:\x20Increases power by one notch for trains with two handlesZvýšenie výkonu o jeden stupeň pri vlaku s oddelenými kontrolérmiDecreases power by one notch for trains with two handlesZníženie výkonu o jeden stupeň pri vlaku s oddelenými kontrolérmiControls power for trains with two handles on half of a joystick axisOvládacie prvky výkonu pri vlaku s oddeleným ovládaním kontroléra a brzdy (joystick-polovica osí)Controls power for trains with two handles on a full joystick axisOvládacie prvky výkonu pri vlaku s oddeleným ovládaním kontroléra a brzdy (joystick-všetky osi)Decreases brake by one notch for trains with two handlesZníženie brzdného účinku o jeden stupeň pri vlaku s oddelenými kontrolérmiIncreases brake by one notch for trains with two handlesZvýšenie brzdného účinku o jeden stupeň pri vlaku s oddelenými kontrolérmiN/AN/AN/AN/AControls brake for trains with two handles on half of a joystick axisOvládacie prvky brzdy pri vlaku s oddeleným ovládaním kontroléra a brzdy (joystick-polovica osy)Controls brake for trains with two handles on a full joystick axisOvládacie prvky brzdy pri vlaku s oddeleným ovládaním kontroléra a brzdy (joystick-všetky osy)Activates emergency brakes for trains with two handlesAktivácia rýchlobrzdy pri vlaku s oddeleným ovládaním kontroléra a brzdyMoves handle toward power by one notch for trains with one handleZvýšenie výkonu a zníženie brzdného účinku o jeden stupeň pri vlaku s jedným kontroléromMoves handle toward neutral by one notch for trains with one handleDá páku pri neutrál pri vlaku s jedným kontroléromMoves handle toward brake by one notch for trains with one handleZvýšenie brzdného účinku a zníženie výkonu o jeden stupeň pri vlaku s jedným kontroléromActivates emergency brake for trains with one handleAktivácia rýchlobrzdy pri vlaku s jedným kontroléromControls power and brake for trains with one handle on a full joystick axisOvládacie prvky výkonu a brzdy pri vlaku s s jedným kontrolérom (joystick-všetky osi)Adjusts the power notch directly from a command option value.Adjusts the power notch directly from a command option value.Adjusts the brake notch directly from a command option value.Adjusts the brake notch directly from a command option value.Adjusts the reverser directly from a command option value.Adjusts the reverser directly from a command option value.Hold BrakeHold BrakeMoves reverser forward by one notchPrestavenie reverzeru vpredMoves reverser backward by one notchPrestavenie reverzeru vzadControls reverser on a full joystick axisOvládanie reverzeru (joystick-všetky osi)Opens or closes the left doorsOtvorenie/zatvorenie ľavých dveríOpens or closes the right doorsOtvorenie/zatvorenie pravých dveríPlays the primary hornKlaxon 1Plays the secondary hornKlaxon 2Plays or stops the music hornKlaxon 3 (zvuková slučka)Activates or deactivates the constant speed deviceActivácia/deaktivácia udržiavania rýchlostiActivates or deactivates the security system on some trainsActivácia/deaktivácia zabezpečovacieho systému u niektorých vlakovThe S function of the security systemS funkcia zabezpečovacieho systémuThe A1 function of the security systemA1 funkcia zabezpečovacieho systémuThe A2 function of the security systemA2 funkcia zabezpečovacieho systémuThe B1 function of the security systemB1 funkcia zabezpečovacieho systémuThe B2 function of the security systemB2 funkcia zabezpečovacieho systémuThe C1 function of the security systemC1 funkcia zabezpečovacieho systémuThe C2 function of the security systemC2 funkcia zabezpečovacieho systémuThe D function of the security systemD funkcia zabezpečovacieho systémuThe E function of the security systemE funkcia zabezpečovacieho systémuThe F function of the security systemF funkcia zabezpečovacieho systémuThe G function of the security systemG funkcia zabezpečovacieho systémuThe H function of the security systemH funkcia zabezpečovacieho systémuThe I function of the security systemI funkcia zabezpečovacieho systémuThe J function of the security systemJ funkcia zabezpečovacieho systémuThe K function of the security systemK funkcia zabezpečovacieho systémuThe L function of the security systemfunkcia zabezpečovacieho systémuN/AN/AN/AN/AN/AN/AN/AN/ASwitches to the train's interior viewPohľad z kabínySwitches to the train's interior view. However, the panel is not displayed.Switches to the train's exterior viewPohľad z vonku, nasleduje vlakSwitches to the track viewPohľad na trať, zostáva na miesteSwitches between different fly-by viewsPrepínanie kamier sledujúcich prejazd vlakuMoves the camera forwardPosun kamery vpredMoves the camera backwardPosun kamery vzadMoves the camera leftPosun kamery vľavoMoves the camera rightPosun kamery vpravoMoves the camera upPosun kamery horeMoves the camera downPosun kamery doleRotates the camera leftRotácia kamery vľavo (osa Y)Rotates the camera rightRotácia kamery vpravo (osa Y)Rotates the camera upRotácia kamery hore (osa X)Rotates the camera downRotácia kamery dole (osa X)Rotates the camera counter-clockwiseRotácia kamery proti smeru hodinových ručičiek (osa Z)Rotates the camera clockwiseRotácia kamery v smere hodinových ručičiek (osa Z)Zooms the camera inPřiblíženie pohľaduZooms the camera outOddialenie pohľaduJumps to the previous point of interest in the route.Skok na predchádzajúce preddefinované miesto v trati.Jumps to the next point of interest in the route.Skok na nasledujúce preddefinované miesto v trati.Resets the camera view to default valuesPredvolené zobrazenie kameryActivates or deactivates interior view camera restrictionZAP/VYP obmedzenie pohľadu kamery v interiériToggles through different timetable modesZobrazenie cestovného poriadku bve4/openBVE/VYP (bve4 pokiaľ je obsiahnutý)Scrolls the timetable upPosun cestovného poriadku horeScrolls the timetable downPosun cestovného poriadku doleDisplays the in-game menuZobrazenie menuMoves the cursor up within the in-game menuPohyb v menu horeMoves the cursor down within the in-game menuPohyb v menu dolePerforms the selected command within the in-game menuVýber položky v menuGoes back within the in-game menuSpäť v menuShows or hides the clockZobrazenie/skrytie časuToggles through different speed display modesPrepínanie medzi rôznymi režimami zobrazovania rýchlostiToggles through different gradient display modesToggles through different gradient display modesToggles through different next station remain distance display modesToggles through different next station remain distance display modesToggles through different time acceleration factorsZrýchlenie času ZAP/VYPShows or hides the frame rate displayZobrazenie/skrytie počtu snímok (FPS)Activates or deactivates the virtual driver (AI)Ovládanie vlaku autopilotomPauses or resumes the simulationPozastavenie/spustenie simulácieToggles to or from fullscreen modePrepínanie zobrazenia okno/celá obrazovkaMutes sound or resumes playing soundsZvuk ZAP/VYPQuits the simulationUkončenie simulácieToggles through different interface modesZmena zobrazenia informáciíActivates or deactivates backface cullingAktívca a deaktivácia zobrazenia zadnej strany objektovSwitches to or from reduced CPU modeZmena zaťaženia CPUActivates or deactivates wireframe modeActivácia/deaktivácia zobrazenia sieťového modeluShows or hides vertex normalsZobraziť/skryť normálové vektoryShows or hides brake system debug outputZobrazit/skrýt stav brzdShows or hides plugin debug outputShows or hides plugin debug outputShows or hides the touch rangeShows or hides the route information windowZobrazit/skrýt okno informací o tratiShows or hides event markers (For developers)Shows or hides event markers (For developers)Increases the speed of the windscreen wipersIncreases the speed of the windscreen wipersDecreases the speed of the windscreen wipersDecreases the speed of the windscreen wipersFills fuelFills fuelToggles the train headlightsToggles the train headlightsActivates or deactivates the live steam injectorActivates or deactivates the live steam injectorActivates or deactivates the exhaust steam injectorActivates or deactivates the exhaust steam injectorIncreases the cutoffIncreases the cutoffDecreases the cutoffDecreases the cutoffActivates or deactivates the blowersActivates or deactivates the blowersStarts the engineStarts the engineStops the engineStops the engineShifts up a gear in a train fitted with a gearboxShifts up a gear in a train fitted with a gearboxShifts down a gear in a train fitted with a gearboxShifts down a gear in a train fitted with a gearboxRaises the pantographRaises the pantographLowers the pantographLowers the pantographToggles the main breakerToggles the main breaker00112233445566778899Ampersand&Asterisk*At@BackquoteBackquoteBackslashZpětné lomítkoBackspaceBackspaceBreakBreakCapslockCapslockCaretStříškaClearClearColonDvojtečkaCommaČárkaDeleteDeleteDollarDollarDownŠipka doluEndEndEnterEnterEqualsEqualsEscapeEscEuroEuroExclamationVykřičníkF1F1F2F2F3F3F4F4F5F5F6F6F7F7F8F8F9F9F10F10F11F11F12F12F13F13F14F14F15F15GreaterVäčšíHash#HelpHelpHomeHomeInsertInsertKeypad 0NUM [0]Keypad 1NUM [1]Keypad 2NUM [2]Keypad 3NUM [3]Keypad 4NUM [4]Keypad 5NUM [5]Keypad 6NUM [6]Keypad 7NUM [7]Keypad 8NUM [8]Keypad 9NUM [9]Keypad DivideNUM [/]Keypad EnterNUM [Enter]Keypad Equals=Keypad MinusNUM [-]Keypad MultiplyNUM [*]Keypad PeriodNUM [.]Keypad PlusNUM [+]Left AltĽavý AltLeft CtrlĽavý CtrlLeftŠípka vľavoLeft bracketĽavá hranatá zátvorkaLeft parenthesisĽavé zátvorkyLessLessLeft MetaLeft MetaLeft ShiftĽavý ShiftLeft ApplicationLeft ApplicationMenuMenuMinusMínusAlt GrAlt GrNumlockNumlockPage downPage downPage upPage upPausePausePeriodBodkaPlusPlusPowerPowerPrintPrintQuestionOtáznikQuoteJednoduché úvodzovkyQuote doubleDvojité úvodzovkyRight AltPravý AltRight CtrlPravý CtrlReturnReturnRightŠípka vpravoRight bracketPravá hranatá zátvorkaRight parenthesisPravé zátvorkyRight MetaRight MetaRight ShiftPravý ShiftRight ApplicationRight ApplicationScrolllockScrolllockSemicolonBodkočiarkaSlashLomkaSpaceMedzerníkSysRqSysRqTabTabUnderscoreSpodná čiarkaUpŠípka horeAABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZNewNovýOpen...Otvoriť...SaveUložiťSave as...Uložiť ako...CloseZatvoriťDo you want to save data before creating a new train?Chcete uložiť údaje pred vytvorením nového vlaku?Do you want to save data before opening another train?Chcete uložiť údaje pred otvorením ďalšieho vlaku?Do you want to save data before closing?Chcete pred zatvorením uložiť údaje?Properties (1)Properties (1)Properties (2)Properties (2)PerformancePerformanceDeceleration:Deceleration:CoefficientOfStaticFriction:CoefficientOfStaticFriction:CoefficientOfRollingResistance:CoefficientOfRollingResistance:AerodynamicDragCoefficient:AerodynamicDragCoefficient:DelayDelayDelayPowerUpDelayPowerUpDelayPowerDownDelayPowerDownDelayBrakeUpDelayBrakeUpDelayBrakeDownDelayBrakeDownSetSetNotchNotchSaveSaveCancelCancelMoveMoveJerkPowerUp:JerkPowerUp:JerkPowerDown:JerkPowerDown:JerkBrakeUp:JerkBrakeUp:JerkBrakeDown:JerkBrakeDown:BrakeCylinderUp:BrakeCylinderUp:BrakeCylinderDown:BrakeCylinderDown:BrakeBrakeBrakeType:BrakeType:BrakeControlSystem:BrakeControlSystem:BrakeControlSpeed:BrakeControlSpeed:Electromagnetic straight air brakeElectromagnetic straight air brakeElectro-pneumatic air brake without brake pipeElectro-pneumatic air brake without brake pipeAir brake with partial release featureAir brake with partial release featureNoneNoneClosing electromagnetic valveClosing electromagnetic valveDelay-including controlDelay-including controlPressurePressureBrakeCylinderServiceMaximumPressure:BrakeCylinderServiceMaximumPressure:BrakeCylinderEmergencyMaximumPressure:BrakeCylinderEmergencyMaximumPressure:MainReservoirMinimumPressure:MainReservoirMinimumPressure:MainReservoirMaximumPressure:MainReservoirMaximumPressure:BrakePipeNormalPressure:BrakePipeNormalPressure:HandleHandleHandleType:HandleType:PowerNotches:PowerNotches:BrakeNotches:BrakeNotches:DriverPowerNotches:DriverPowerNotches:DriverBrakeNotches:DriverBrakeNotches:PowerNotchReduceSteps:PowerNotchReduceSteps:SeparatedSeparatedCombinedCombinedBrakeNotches must be at least 1 if HoldBrake is set.BrakeNotches must be at least 1 if HoldBrake is set.DriverPowerNotches must be less than or equal to PowerNotches.DriverPowerNotches must be less than or equal to PowerNotches.DriverBrakeNotches must be less than or equal to BrakeNotches.DriverBrakeNotches must be less than or equal to BrakeNotches.CabCabDriverCar:DriverCar:DriverCar must be less than NumberOfMotorCars + NumberOfTrailerCars.DriverCar must be less than NumberOfMotorCars + NumberOfTrailerCars.CarCarMotorCarMass:MotorCarMass:NumberOfMotorCars:NumberOfMotorCars:TrailerCarMass:TrailerCarMass:NumberOfTrailerCars:NumberOfTrailerCars:LengthOfACar:LengthOfACar:FrontCarIsMotorCar:FrontCarIsMotorCar:WidthOfACar:WidthOfACar:HeightOfACar:HeightOfACar:CenterOfGravityHeight:CenterOfGravityHeight:ExposedFrontalArea:ExposedFrontalArea:UnexposedFrontalArea:UnexposedFrontalArea:NumberOfTrailerCars must be at least 1 if FrontCarIsAMotorCar is not set.NumberOfTrailerCars must be at least 1 if FrontCarIsAMotorCar is not set.DeviceDeviceConstSpeed:ConstSpeed:HoldBrake:HoldBrake:ReAdhesionDevice:ReAdhesionDevice:PassAlarm:PassAlarm:DoorOpenMode:DoorOpenMode:DoorCloseMode:DoorCloseMode:DoorWidth:DoorWidth:DoorMaxTolerance:DoorMaxTolerance:NoneNoneManual switchingManual switchingAutomatic switchingAutomatic switchingType A (instant)Type A (instant)Type B (slow)Type B (slow)Type C (medium)Type C (medium)Type D (fast)Type D (fast)SingleSingleLoopingLoopingSemi-automaticSemi-automaticAutomaticAutomaticManualManualAccelerationAccelerationNotch:Notch:DataDataPreviewPreviewSubtract deceleration due to air and rolling resistanceSubtract deceleration due to air and rolling resistanceXmax:Xmax:Ymax:Ymax:Motor SoundMotor SoundEdit modeEdit modeSoundIndex:SoundIndex:PitchPitchVolumeVolumeNoneNonePreviewPreviewYpitchYpitchYvolumeYvolumeXmin:Xmin:Xmax:Xmax:LeftLeftRightRightInInOutOutYmaxPitch:YmaxPitch:YmaxVolume:YmaxVolume:Extended FeaturesExtended FeaturesPlease note: Features found on this page may require the following minimum version of openBVE:Please note: Features found on this page may require the following minimum version of openBVE:Locomotive BrakeLocomotive BrakeBrakeType:BrakeType:Notches:Notches:DelayUp:DelayUp:DelayDown:DelayDown:Type:Type:SetSetNot fittedNot fittedNotched air brakeNotched air brakeAir brake with partial releaseAir brake with partial releaseCombinedCombinedIndependentIndependentBlockingBlockingDelayLocoBrakeUpDelayLocoBrakeUpDelayLocoBrakeDownDelayLocoBrakeDownMiscellaneous FeaturesMiscellaneous FeaturesHandle behaviour on EB:Handle behaviour on EB:No ActionNo ActionReturn Power to neutralReturn Power to neutralReturn Reverser to neutralReturn Reverser to neutralReturn Power and Reverser to neutralReturn Power and Reverser to neutralLanguageLanguageFileNewOpen...SaveSave as...Import...Export...ExitYou have attempted to open a train. \n\n These cannot be opened directly- \n\n Please use the import function to import this train into TrainEditor2.LanguageDo you want to save the current file before creating a new one?Do you want to save the current file before opening another file?Do you want to save the current file before closing?UpDownAddRemoveCopySet...Open...TrainGeneralCarsCouplersGeneral settingsHandleHandleTypeSeparatedCombinedPowerNotchesBrakeNotchesPowerNotchReduceStepsDriverPowerNotchesDriverBrakeNotchesEbHandleBehaviourNo actionReturn power to neutralReturn reverser to neutralReturn power and reverser to neutralLocoBrakeHandleTypeCombinedIndependentBlockingLocoBrakeNotchesCabXYZDriverCarDeviceAtsNoneATS-SNATS-SN / ATS-PAtcNoneManual switchingAutomatic switchingEbConstSpeedHoldBrakeReAdhesionDeviceNoneType A (instant)Type B (slow)Type C (medium)Type D (fast)PassAlarmNoneSingleLoopingDoorOpenModeDoorCloseModeSemi-automaticAutomaticManualDoorWidthDoorMaxToleranceCar settingsGeneralIsMotorCarMassLengthWidthHeightCenterOfGravityHeightExposedFrontalAreaUnexposedFrontalAreaDefinedAxlesAxlesFrontAxleRearAxleFrontBogieRearBogieLoadingSwayReversedObjectPerformanceDecelerationCoefficientOfStaticFrictionCoefficientOfRollingResistanceAerodynamicDragCoefficientMoveJerkPowerUpJerkPowerDownJerkBrakeUpJerkBrakeDownBrakeCylinderUpBrakeCylinderDownBrakeBrakeTypeElectromagnetic straight air brakeElectro-pneumatic air brake without brake pipeAir brake with partial release featureLocoBrakeTypeNot fittedNotched air brakeAir brake with partial releaseBrakeControlSystemNoneClosing electromagnetic valveDelay-including controlBrakeControlSpeedPressureBrakeCylinderServiceMaximumPressureBrakeCylinderEmergencyMaximumPressureMainReservoirMinimumPressureMainReservoirMaximumPressureBrakePipeNormalPressureDelayPowerBrakeLocoBrakeNotchValueAcceleration settingsNotchParametera0a1v1v2e (2.0)PreviewSubtract deceleration due to air and rolling resistanceXYx-minx-maxy-miny-maxZoom InZoom OutResetMotor sound settingsEditUndoRedoCutCopyPasteCleanupDeleteViewPowerBrakeTrackInputPitchVolumeSound source indexNoneToolSelectMoveDotLineView settingx-min(Velocity)x-max(Velocity)y-min(Pitch)y-max(Pitch)y-min(Volume)y-max(Volume)Zoom InZoom OutResetDirect inputx coordinatey coordinateDotMovePlayback settingSound source settingRunning soundTrackArea settingLoop playbackConstant speedAcceleration:SwapPlaybackPauseStopVertex informationVelocityPitchVolumeSound source indexTypePowerBrakeTrackModePitchVolumeSound source indexToolSelectMoveDotLineVelocityPitchVolumeA point already exists at the same x coordinate, do you want to overwrite it?Coupler settingsGeneralMinMaxPanel settingsThisResolutionLeftRightTopBottomDaytimeImageNighttimeImageTransparentColorCenterXYOriginXYScreenNumberLayerPilotLampSubjectLocationXYDaytimeImageNighttimeImageTransparentColorLayerNeedleSubjectLocationXYDefinedRadiusRadiusDaytimeImageNighttimeImageColorTransparentColorDefinedOriginOriginXYInitialAngleLastAngleMinimumMaximumDefinedNaturalFreqNaturalFreqDefiedDampingRatioDampingRatioBackstopsmoothedLayerDigitalNumberSubjectLocationXYDaytimeImageNighttimeImageTransparentColorLayerIntervalDigitalGaugeSubjectLocationXYRadiusColorInitialAngleLastAngleMinimumMaximumStepLayerLinearGaugeSubjectLocationXYDaytimeImageNighttimeImageTransparentColorMinimumMaximumDirectionXYWidthLayerTimetableLocationXYHeightWidthTransparentColorLayerTouchLocationXYSizeXYJumpScreenSoundIndexCommandCommandOptionSound settingsKeyFilenamePositionRadiusEdit entrySection selectKey type selectInput valueFilenameRadiusPosition settingPositionx coordinatey coordinatez coordinateFile name has not been entered.The specified key is already set.StatusErrorWarningInformationClearLevelDescriptionErrorWarningInformationpositivenon-negativenon-zeroThis value must be a {0}floating-point number.invalid_color \ No newline at end of file From 20105ccfda0c81ee48d50cf6c1c8c8aac0b55567 Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Wed, 27 Sep 2023 10:11:06 +0100 Subject: [PATCH 06/16] Change: Minor improvement to UK* plugin AI Driver has partially completed the startup sequence --- source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKDt.cs | 2 +- source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKMUt.cs | 2 +- source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKSpt.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKDt.cs b/source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKDt.cs index 6e39e395c..0f4a2d099 100644 --- a/source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKDt.cs +++ b/source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKDt.cs @@ -69,7 +69,7 @@ internal override void Perform(AIData data) currentStep++; return; case 2: - if (Plugin.Sound[2] == 0) + if (Plugin.Sound[2] == 0 || Plugin.Sound[2] == -1000) { data.Response = AIResponse.Medium; currentStep++; diff --git a/source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKMUt.cs b/source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKMUt.cs index 4358c049c..9f977da0c 100644 --- a/source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKMUt.cs +++ b/source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKMUt.cs @@ -67,7 +67,7 @@ internal override void Perform(AIData data) currentStep++; return; case 2: - if (Plugin.Sound[2] == 0) + if (Plugin.Sound[2] == 0 || Plugin.Sound[2] == -1000) { data.Response = AIResponse.Medium; currentStep++; diff --git a/source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKSpt.cs b/source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKSpt.cs index 14beaa228..31d69e83b 100644 --- a/source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKSpt.cs +++ b/source/TrainManager/SafetySystems/Plugin/AI/PluginAI.UKSpt.cs @@ -67,7 +67,7 @@ internal override void Perform(AIData data) currentStep++; return; case 2: - if (Plugin.Sound[2] == 0) + if (Plugin.Sound[2] == 0 || Plugin.Sound[2] == -1000) { data.Response = AIResponse.Medium; currentStep++; From 3a1f4366a77a392d726ba00829b678f3d6166b1e Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Wed, 27 Sep 2023 17:04:08 +0100 Subject: [PATCH 07/16] Change: Cache object optimization state --- .../OpenBveApi/Objects/ObjectTypes/StaticObject.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/OpenBveApi/Objects/ObjectTypes/StaticObject.cs b/source/OpenBveApi/Objects/ObjectTypes/StaticObject.cs index c128ec12e..4c82df6e9 100644 --- a/source/OpenBveApi/Objects/ObjectTypes/StaticObject.cs +++ b/source/OpenBveApi/Objects/ObjectTypes/StaticObject.cs @@ -10,6 +10,8 @@ namespace OpenBveApi.Objects /// public class StaticObject : UnifiedObject { + /// Whether the object is optimized + private bool IsOptimized; /// The mesh of the object public Mesh Mesh; /// The starting track position, for static objects only. @@ -43,7 +45,8 @@ public StaticObject(HostInterface Host) StartingTrackDistance = StartingTrackDistance, EndingTrackDistance = EndingTrackDistance, Dynamic = Dynamic, - Mesh = {Vertices = new VertexTemplate[Mesh.Vertices.Length]} + Mesh = {Vertices = new VertexTemplate[Mesh.Vertices.Length]}, + IsOptimized = IsOptimized }; // vertices for (int j = 0; j < Mesh.Vertices.Length; j++) @@ -91,7 +94,8 @@ public override UnifiedObject Clone() StartingTrackDistance = StartingTrackDistance, EndingTrackDistance = EndingTrackDistance, Dynamic = Dynamic, - Mesh = {Vertices = new VertexTemplate[Mesh.Vertices.Length]} + Mesh = {Vertices = new VertexTemplate[Mesh.Vertices.Length]}, + IsOptimized = IsOptimized }; // vertices for (int j = 0; j < Mesh.Vertices.Length; j++) @@ -149,6 +153,7 @@ public override UnifiedObject Mirror() } Result.Mesh.Faces[i].Flip(); } + Result.IsOptimized = IsOptimized; return Result; } @@ -474,6 +479,11 @@ public override void CreateObject(Vector3 Position, Transformation WorldTransfor /// public override void OptimizeObject(bool PreserveVerticies, int Threshold, bool VertexCulling) { + if (IsOptimized) + { + return; + } + IsOptimized = true; int v = Mesh.Vertices.Length; int m = Mesh.Materials.Length; int f = Mesh.Faces.Length; From 884bfff8fafa7d223a69ca472d3f91728551ce73 Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Wed, 27 Sep 2023 17:07:16 +0100 Subject: [PATCH 08/16] Fix: Issue with some interlaced PNGs --- source/Plugins/Texture.BmpGifJpegPngTiff/PNG/PngDecoder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Plugins/Texture.BmpGifJpegPngTiff/PNG/PngDecoder.cs b/source/Plugins/Texture.BmpGifJpegPngTiff/PNG/PngDecoder.cs index bdd335667..077e31e72 100644 --- a/source/Plugins/Texture.BmpGifJpegPngTiff/PNG/PngDecoder.cs +++ b/source/Plugins/Texture.BmpGifJpegPngTiff/PNG/PngDecoder.cs @@ -408,7 +408,7 @@ internal bool Read(string fileName) break; case ScanlineFilterAlgorithm.Average: leftByte = relativeRowByte >= BytesPerPixel ? data[rowStartByte + relativeRowByte - BytesPerPixel] : (byte)0; - upByte = data[previousRowStartByte + relativeRowByte]; + upByte = currentScanline == 0 ? (byte)0 : data[previousRowStartByte + relativeRowByte]; data[rowStartByte + relativeRowByte] = (byte)((data[rowStartByte + relativeRowByte] + ((leftByte + upByte) >> 1)) % 256); break; case ScanlineFilterAlgorithm.Paeth: From 1273f5fa9d8db833a1057db39ed62511311b4cb6 Mon Sep 17 00:00:00 2001 From: LX862 Date: Sun, 1 Oct 2023 17:31:53 +0800 Subject: [PATCH 09/16] Remove memory debug message --- source/OpenBVE/System/GameWindow.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/source/OpenBVE/System/GameWindow.cs b/source/OpenBVE/System/GameWindow.cs index 22ffe8af2..71564f062 100644 --- a/source/OpenBVE/System/GameWindow.cs +++ b/source/OpenBVE/System/GameWindow.cs @@ -1054,7 +1054,6 @@ private void SetupSimulation() using (Process proc = Process.GetCurrentProcess()) { long memoryUsed = proc.PrivateMemorySize64; - MessageBox.Show(memoryUsed.ToString()); if ((memoryUsed > 900000000 && !Interface.CurrentOptions.LoadInAdvance) || memoryUsed > 1600000000) { // Either using ~900mb at the first station or 1.5gb + with all textures loaded is likely to cause critical OOM errors with the 32-bit process memory limit From 56e3792dcdea0d157508050cdd3c3954cb47cf3b Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Thu, 5 Oct 2023 17:12:02 +0100 Subject: [PATCH 10/16] Change: Inline a bunch of variables --- source/OpenBVE/Audio/Sounds.Update.cs | 3 +- source/OpenBVE/Game/Menu/Menu.SingleMenu.cs | 3 +- .../Script/TrackFollowingObjectParser.cs | 4 +- source/OpenBVE/System/GameWindow.cs | 4 +- source/OpenBVE/System/Host.cs | 3 +- source/OpenBVE/System/Input/Controls.cs | 67 +++++---------- source/OpenBVE/System/Interface.cs | 11 ++- source/OpenBVE/System/Options.cs | 81 +++++++------------ source/OpenBVE/System/Program.cs | 12 +-- .../OpenBVE/UserInterface/formMain.Options.cs | 3 +- .../UserInterface/formMain.Packages.cs | 6 +- .../OpenBVE/UserInterface/formMain.Start.cs | 3 +- source/OpenBVE/UserInterface/formMain.cs | 7 +- 13 files changed, 69 insertions(+), 138 deletions(-) diff --git a/source/OpenBVE/Audio/Sounds.Update.cs b/source/OpenBVE/Audio/Sounds.Update.cs index 667d7089a..a0c0c5860 100644 --- a/source/OpenBVE/Audio/Sounds.Update.cs +++ b/source/OpenBVE/Audio/Sounds.Update.cs @@ -104,8 +104,7 @@ protected override void UpdateInverseModel(double timeElapsed) * The sound is to be played or is already playing. * */ if (Sources[i].State == SoundSourceState.Playing) { - int state; - AL.GetSource(Sources[i].OpenAlSourceName, ALGetSourcei.SourceState, out state); + AL.GetSource(Sources[i].OpenAlSourceName, ALGetSourcei.SourceState, out int state); if (state != (int)ALSourceState.Initial & state != (int)ALSourceState.Playing) { /* * The sound is not playing any longer. diff --git a/source/OpenBVE/Game/Menu/Menu.SingleMenu.cs b/source/OpenBVE/Game/Menu/Menu.SingleMenu.cs index 7c7cd7774..e219206c5 100644 --- a/source/OpenBVE/Game/Menu/Menu.SingleMenu.cs +++ b/source/OpenBVE/Game/Menu/Menu.SingleMenu.cs @@ -220,8 +220,7 @@ public SingleMenu(MenuType menuType, int data = 0, double MaxWidth = 0) Icon icon = Icon.ExtractAssociatedIcon(potentialFiles[j]); if (icon != null) { - Texture t; - Program.CurrentHost.RegisterTexture(icon.ToBitmap(), new TextureParameters(null, null), out t); + Program.CurrentHost.RegisterTexture(icon.ToBitmap(), new TextureParameters(null, null), out Texture t); iconCache.Add(ext, t); Items[totalEntries].Icon = t; } diff --git a/source/OpenBVE/Parsers/Script/TrackFollowingObjectParser.cs b/source/OpenBVE/Parsers/Script/TrackFollowingObjectParser.cs index 4f185cca1..ed011a971 100644 --- a/source/OpenBVE/Parsers/Script/TrackFollowingObjectParser.cs +++ b/source/OpenBVE/Parsers/Script/TrackFollowingObjectParser.cs @@ -257,9 +257,7 @@ private static void ParseTrainNode(string ObjectPath, string FileName, XElement break; default: { - int n; - - if (!NumberFormats.TryParseIntVb6(Value, out n)) + if (!NumberFormats.TryParseIntVb6(Value, out int n)) { Interface.AddMessage(MessageType.Error, false, $"Value is invalid in {Key} in {Section} at line {LineNumber.ToString(culture)} in {FileName}"); } diff --git a/source/OpenBVE/System/GameWindow.cs b/source/OpenBVE/System/GameWindow.cs index 71564f062..ac6f28d4b 100644 --- a/source/OpenBVE/System/GameWindow.cs +++ b/source/OpenBVE/System/GameWindow.cs @@ -508,9 +508,7 @@ protected override void OnMouseMove(MouseMoveEventArgs e) if (Program.Renderer.CurrentInterface == InterfaceType.Normal) { - MouseCursor.Status Status; - MouseCursor newCursor; - if (Program.Renderer.Touch.MoveCheck(new Vector2(e.X, e.Y), out Status, out newCursor)) + if (Program.Renderer.Touch.MoveCheck(new Vector2(e.X, e.Y), out MouseCursor.Status Status, out MouseCursor newCursor)) { if (newCursor != null) { diff --git a/source/OpenBVE/System/Host.cs b/source/OpenBVE/System/Host.cs index 56ad9a60a..d65f2c2b3 100644 --- a/source/OpenBVE/System/Host.cs +++ b/source/OpenBVE/System/Host.cs @@ -343,8 +343,7 @@ public override bool LoadObject(string path, System.Text.Encoding Encoding, out if (Program.CurrentHost.Plugins[i].Object.CanLoadObject(path)) { try { - UnifiedObject obj; - if (Program.CurrentHost.Plugins[i].Object.LoadObject(path, Encoding, out obj)) { + if (Program.CurrentHost.Plugins[i].Object.LoadObject(path, Encoding, out UnifiedObject obj)) { if (obj == null) { continue; diff --git a/source/OpenBVE/System/Input/Controls.cs b/source/OpenBVE/System/Input/Controls.cs index 5afb50824..cfdf96ea1 100644 --- a/source/OpenBVE/System/Input/Controls.cs +++ b/source/OpenBVE/System/Input/Controls.cs @@ -140,15 +140,11 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) { Controls[Length].Command = Translations.CommandInfos[j].Command; Controls[Length].InheritedType = Translations.CommandInfos[j].Type; - ControlMethod Method; - Enum.TryParse(Terms[1], true, out Method); + Enum.TryParse(Terms[1], true, out ControlMethod Method); bool Valid = false; if (Method == ControlMethod.Keyboard & Terms.Length >= 4) { - Key CurrentKey; - // ReSharper disable once NotAccessedVariable - int SDLTest; - if (int.TryParse(Terms[2], out SDLTest)) + if (int.TryParse(Terms[2], out _)) { //We've discovered a SDL keybinding is present, so reset the loading process with the default keyconfig & show an appropriate error message if (ControlsReset == false) @@ -185,10 +181,9 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) return; } - if (Enum.TryParse(Terms[2], true, out CurrentKey)) + if (Enum.TryParse(Terms[2], true, out Key CurrentKey)) { - int Modifiers; - if (int.TryParse(Terms[3], NumberStyles.Integer, Culture, out Modifiers)) + if (int.TryParse(Terms[3], NumberStyles.Integer, Culture, out int Modifiers)) { Controls[Length].Method = Method; Controls[Length].Device = Guid.Empty; @@ -196,8 +191,7 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) Controls[Length].Key = (OpenBveApi.Input.Key)CurrentKey; Controls[Length].Direction = 0; Controls[Length].Modifier = (KeyboardModifier) Modifiers; - int Option; - if (Terms.Length >= 5 && int.TryParse(Terms[4], NumberStyles.Integer, Culture, out Option)) + if (Terms.Length >= 5 && int.TryParse(Terms[4], NumberStyles.Integer, Culture, out int Option)) { Controls[Length].Option = Option; } @@ -208,26 +202,22 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) } else if (Method == ControlMethod.Joystick & Terms.Length >= 4) { - int oldDevice; Guid Device = Guid.Empty; - if (int.TryParse(Terms[2], NumberStyles.Integer, Culture, out oldDevice)) + if (int.TryParse(Terms[2], NumberStyles.Integer, Culture, out int oldDevice)) { Device = Joystick.GetGuid(oldDevice); } - JoystickComponent Component; - Enum.TryParse(Terms[3], true, out Component); + Enum.TryParse(Terms[3], true, out JoystickComponent Component); if (Device != Guid.Empty || Guid.TryParse(Terms[2], out Device)) { if (Component == JoystickComponent.Axis & Terms.Length >= 6) { - int CurrentAxis; - if (int.TryParse(Terms[4], out CurrentAxis)) + if (int.TryParse(Terms[4], out int CurrentAxis)) { - int Direction; - if (int.TryParse(Terms[5], NumberStyles.Integer, Culture, out Direction)) + if (int.TryParse(Terms[5], NumberStyles.Integer, Culture, out int Direction)) { Controls[Length].Method = Method; @@ -236,8 +226,7 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) Controls[Length].Element = CurrentAxis; Controls[Length].Direction = Direction; Controls[Length].Modifier = KeyboardModifier.None; - int Option; - if (Terms.Length >= 7 && int.TryParse(Terms[6], NumberStyles.Integer, Culture, out Option)) + if (Terms.Length >= 7 && int.TryParse(Terms[6], NumberStyles.Integer, Culture, out int Option)) { Controls[Length].Option = Option; } @@ -248,11 +237,9 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) } else if (Component == JoystickComponent.Hat & Terms.Length >= 6) { - int CurrentHat; - if (int.TryParse(Terms[4], out CurrentHat)) + if (int.TryParse(Terms[4], out int CurrentHat)) { - int HatDirection; - if (int.TryParse(Terms[5], out HatDirection)) + if (int.TryParse(Terms[5], out int HatDirection)) { Controls[Length].Method = Method; Controls[Length].Device = Device; @@ -260,8 +247,7 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) Controls[Length].Element = CurrentHat; Controls[Length].Direction = HatDirection; Controls[Length].Modifier = KeyboardModifier.None; - int Option; - if (Terms.Length >= 7 && int.TryParse(Terms[6], NumberStyles.Integer, Culture, out Option)) + if (Terms.Length >= 7 && int.TryParse(Terms[6], NumberStyles.Integer, Culture, out int Option)) { Controls[Length].Option = Option; } @@ -273,8 +259,7 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) } else if (Component == JoystickComponent.Button & Terms.Length >= 5) { - int CurrentButton; - if (int.TryParse(Terms[4], out CurrentButton)) + if (int.TryParse(Terms[4], out int CurrentButton)) { Controls[Length].Method = Method; Controls[Length].Device = Device; @@ -282,8 +267,7 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) Controls[Length].Element = CurrentButton; Controls[Length].Direction = 0; Controls[Length].Modifier = KeyboardModifier.None; - int Option; - if (Terms.Length >= 6 && int.TryParse(Terms[5], NumberStyles.Integer, Culture, out Option)) + if (Terms.Length >= 6 && int.TryParse(Terms[5], NumberStyles.Integer, Culture, out int Option)) { Controls[Length].Option = Option; } @@ -296,24 +280,20 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) } else if (Method == ControlMethod.RailDriver & Terms.Length >= 4) { - int oldDevice; Guid Device = Guid.Empty; - if (int.TryParse(Terms[2], NumberStyles.Integer, Culture, out oldDevice)) + if (int.TryParse(Terms[2], NumberStyles.Integer, Culture, out int oldDevice)) { Device = Joystick.GetGuid(oldDevice); } if (Device != Guid.Empty || Guid.TryParse(Terms[2], out Device)) { - JoystickComponent Component; - Enum.TryParse(Terms[3], true, out Component); + Enum.TryParse(Terms[3], true, out JoystickComponent Component); if (Component == JoystickComponent.Axis & Terms.Length >= 6) { - int CurrentAxis; - if (int.TryParse(Terms[4], out CurrentAxis)) + if (int.TryParse(Terms[4], out int CurrentAxis)) { - int Direction; - if (int.TryParse(Terms[5], NumberStyles.Integer, Culture, out Direction)) + if (int.TryParse(Terms[5], NumberStyles.Integer, Culture, out int Direction)) { Controls[Length].Method = Method; @@ -322,8 +302,7 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) Controls[Length].Element = CurrentAxis; Controls[Length].Direction = Direction; Controls[Length].Modifier = KeyboardModifier.None; - int Option; - if (Terms.Length >= 7 && int.TryParse(Terms[6], NumberStyles.Integer, Culture, out Option)) + if (Terms.Length >= 7 && int.TryParse(Terms[6], NumberStyles.Integer, Culture, out int Option)) { Controls[Length].Option = Option; } @@ -334,8 +313,7 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) } else if (Component == JoystickComponent.Button & Terms.Length >= 5) { - int CurrentButton; - if (int.TryParse(Terms[4], out CurrentButton)) + if (int.TryParse(Terms[4], out int CurrentButton)) { Controls[Length].Method = ControlMethod.RailDriver; Controls[Length].Device = Device; @@ -343,8 +321,7 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls) Controls[Length].Element = CurrentButton; Controls[Length].Direction = 0; Controls[Length].Modifier = KeyboardModifier.None; - int Option; - if (Terms.Length >= 6 && int.TryParse(Terms[5], NumberStyles.Integer, Culture, out Option)) + if (Terms.Length >= 6 && int.TryParse(Terms[5], NumberStyles.Integer, Culture, out int Option)) { Controls[Length].Option = Option; } diff --git a/source/OpenBVE/System/Interface.cs b/source/OpenBVE/System/Interface.cs index ec506d55b..17fabec7e 100644 --- a/source/OpenBVE/System/Interface.cs +++ b/source/OpenBVE/System/Interface.cs @@ -29,10 +29,10 @@ internal static bool TryParseTime(string Expression, out double Value) i = Expression.IndexOf(':'); } if (i >= 1) { - int h; if (int.TryParse(Expression.Substring(0, i), NumberStyles.Integer, Culture, out h)) { + if (int.TryParse(Expression.Substring(0, i), NumberStyles.Integer, Culture, out int h)) { int n = Expression.Length - i - 1; if (n == 1 | n == 2) { - uint m; if (uint.TryParse(Expression.Substring(i + 1, n), NumberStyles.None, Culture, out m)) { + if (uint.TryParse(Expression.Substring(i + 1, n), NumberStyles.None, Culture, out uint m)) { Value = 3600.0 * h + 60.0 * m; return true; } @@ -42,8 +42,7 @@ internal static bool TryParseTime(string Expression, out double Value) Program.CurrentHost.AddMessage(MessageType.Warning, false, "A maximum of 4 digits of precision are supported in TIME values"); n = 4; } - uint m; if (uint.TryParse(Expression.Substring(i + 1, 2), NumberStyles.None, Culture, out m)) { - uint s; + if (uint.TryParse(Expression.Substring(i + 1, 2), NumberStyles.None, Culture, out uint m)) { string ss = Expression.Substring(i + 3, n - 2); if (Interface.CurrentOptions.EnableBveTsHacks) { @@ -56,7 +55,7 @@ internal static bool TryParseTime(string Expression, out double Value) ss = ss.Substring(1, ss.Length - 1); } } - if (uint.TryParse(ss, NumberStyles.None, Culture, out s)) { + if (uint.TryParse(ss, NumberStyles.None, Culture, out uint s)) { Value = 3600.0 * h + 60.0 * m + s; return true; } @@ -64,7 +63,7 @@ internal static bool TryParseTime(string Expression, out double Value) } } } else if (i == -1) { - int h; if (int.TryParse(Expression, NumberStyles.Integer, Culture, out h)) { + if (int.TryParse(Expression, NumberStyles.Integer, Culture, out int h)) { Value = 3600.0 * h; return true; } diff --git a/source/OpenBVE/System/Options.cs b/source/OpenBVE/System/Options.cs index 46fb3675f..e49a0ae99 100644 --- a/source/OpenBVE/System/Options.cs +++ b/source/OpenBVE/System/Options.cs @@ -387,8 +387,7 @@ internal static void LoadOptions() break; case "windowwidth": { - int a; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out a)) + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int a)) { a = 960; } @@ -396,8 +395,7 @@ internal static void LoadOptions() } break; case "windowheight": { - int a; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out a)) + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int a)) { a = 600; } @@ -405,8 +403,7 @@ internal static void LoadOptions() } break; case "fullscreenwidth": { - int a; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out a)) + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int a)) { a = 1024; } @@ -414,8 +411,7 @@ internal static void LoadOptions() } break; case "fullscreenheight": { - int a; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out a)) + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int a)) { a = 768; } @@ -423,8 +419,7 @@ internal static void LoadOptions() } break; case "fullscreenbits": { - int a; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out a)) + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int a)) { a = 32; } @@ -432,14 +427,12 @@ internal static void LoadOptions() } break; case "mainmenuwidth": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.MainMenuWidth = a; } break; case "mainmenuheight": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.MainMenuHeight = a; } break; case "loadinadvance": @@ -471,20 +464,17 @@ internal static void LoadOptions() } break; case "anisotropicfilteringlevel": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.AnisotropicFilteringLevel = a; } break; case "anisotropicfilteringmaximum": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.AnisotropicFilteringMaximum = a; } break; case "antialiasinglevel": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.AntiAliasingLevel = a; } break; case "transparencymode": @@ -494,8 +484,7 @@ internal static void LoadOptions() case "smooth": Interface.CurrentOptions.TransparencyMode = TransparencyMode.Quality; break; default: { - int a; - if (int.TryParse(Value, NumberStyles.Integer, Culture, out a)) + if (int.TryParse(Value, NumberStyles.Integer, Culture, out int a)) { Interface.CurrentOptions.TransparencyMode = (TransparencyMode)a; } @@ -511,8 +500,7 @@ internal static void LoadOptions() break; case "viewingdistance": { - int a; - if (int.TryParse(Value, NumberStyles.Integer, Culture, out a)) + if (int.TryParse(Value, NumberStyles.Integer, Culture, out int a)) { if (a >= 100 && a <= 10000) { @@ -522,8 +510,7 @@ internal static void LoadOptions() } break; case "quadleafsize": { - int a; - if (int.TryParse(Value, NumberStyles.Integer, Culture, out a)) + if (int.TryParse(Value, NumberStyles.Integer, Culture, out int a)) { if (a >= 50 && a <= 500) { @@ -540,8 +527,7 @@ internal static void LoadOptions() default: Interface.CurrentOptions.MotionBlur = MotionBlurMode.None; break; } break; case "fpslimit": - int limit; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out limit) || limit < 0) + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int limit) || limit < 0) { limit = 0; } @@ -553,14 +539,12 @@ internal static void LoadOptions() { case "basicthreshold": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.ObjectOptimizationBasicThreshold = a; } break; case "fullthreshold": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.ObjectOptimizationFullThreshold = a; } break; case "vertexCulling": @@ -595,8 +579,7 @@ internal static void LoadOptions() default: Interface.CurrentOptions.GameMode = GameMode.Normal; break; } break; case "acceleratedtimefactor": - int tf; - int.TryParse(Value, NumberStyles.Integer, Culture, out tf); + int.TryParse(Value, NumberStyles.Integer, Culture, out int tf); if (tf <= 0) { tf = 5; @@ -619,21 +602,18 @@ internal static void LoadOptions() break; case "joystickaxisthreshold": { - double a; - double.TryParse(Value, NumberStyles.Float, Culture, out a); + double.TryParse(Value, NumberStyles.Float, Culture, out double a); Interface.CurrentOptions.JoystickAxisThreshold = a; } break; case "keyrepeatdelay": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); if (a <= 0) a = 500; Interface.CurrentOptions.KeyRepeatDelay = 0.001 * a; } break; case "keyrepeatinterval": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); if (a <= 0) a = 100; Interface.CurrentOptions.KeyRepeatInterval = 0.001 * a; } break; @@ -642,8 +622,7 @@ internal static void LoadOptions() break; case "cursorhidedelay": { - double a; - double.TryParse(Value, NumberStyles.Float, Culture, out a); + double.TryParse(Value, NumberStyles.Float, Culture, out double a); Interface.CurrentOptions.CursorHideDelay = a; } break; @@ -669,8 +648,7 @@ internal static void LoadOptions() break; case "number": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.SoundNumber = a < 16 ? 16 : a; } break; } break; @@ -742,8 +720,7 @@ internal static void LoadOptions() } break; case "routeencodings": { - int a; - if (!int.TryParse(Key, NumberStyles.Integer, Culture, out a)) + if (!int.TryParse(Key, NumberStyles.Integer, Culture, out int a)) { a = Encoding.UTF8.CodePage; } @@ -766,8 +743,7 @@ internal static void LoadOptions() } break; case "trainencodings": { - int a; - if (!int.TryParse(Key, NumberStyles.Integer, Culture, out a)) + if (!int.TryParse(Key, NumberStyles.Integer, Culture, out int a)) { a = Encoding.UTF8.CodePage; } @@ -799,8 +775,7 @@ internal static void LoadOptions() { case "xobject": { - int p; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out p) || p < 0 || p > 3) + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int p) || p < 0 || p > 3) { Interface.CurrentOptions.CurrentXParser = XParsers.Original; } @@ -812,8 +787,7 @@ internal static void LoadOptions() } case "objobject": { - int p; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out p) || p < 0 || p > 2) + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int p) || p < 0 || p > 2) { Interface.CurrentOptions.CurrentObjParser = ObjParsers.Original; } @@ -839,8 +813,7 @@ internal static void LoadOptions() break; case "panel2extendedminsize": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.Panel2ExtendedMinSize = a; } break; } diff --git a/source/OpenBVE/System/Program.cs b/source/OpenBVE/System/Program.cs index 57716066b..fd2e6aed0 100644 --- a/source/OpenBVE/System/Program.cs +++ b/source/OpenBVE/System/Program.cs @@ -101,8 +101,7 @@ private static void Main(string[] args) { //Determine the current CPU architecture- //ARM will generally only support OpenGL-ES - PortableExecutableKinds peKind; - typeof(object).Module.GetPEKind(out peKind, out CurrentCPUArchitecture); + typeof(object).Module.GetPEKind(out PortableExecutableKinds peKind, out CurrentCPUArchitecture); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); @@ -158,8 +157,7 @@ private static void Main(string[] args) { Interface.LoadControls(null, out Interface.CurrentControls); folder = Program.FileSystem.GetDataFolder("Controls"); string file = Path.CombineFile(folder, "Default keyboard assignment.controls"); - Control[] controls; - Interface.LoadControls(file, out controls); + Interface.LoadControls(file, out Control[] controls); Interface.AddControls(ref Interface.CurrentControls, controls); InputDevicePlugin.LoadPlugins(Program.FileSystem); @@ -181,8 +179,7 @@ private static void Main(string[] args) { // --- if a route was provided but no train, try to use the route default --- if (result.RouteFile != null & result.TrainFolder == null) { - string error; - if (!CurrentHost.LoadPlugins(FileSystem, Interface.CurrentOptions, out error, TrainManager, Renderer)) + if (!CurrentHost.LoadPlugins(FileSystem, Interface.CurrentOptions, out string error, TrainManager, Renderer)) { MessageBox.Show(error, Translations.GetInterfaceString("program_title"), MessageBoxButtons.OK, MessageBoxIcon.Error); throw new Exception("Unable to load the required plugins- Please reinstall OpenBVE"); @@ -362,8 +359,7 @@ private static void Main(string[] args) { /// Whether the initialization was successful. private static bool Initialize() { - string error; - if (!CurrentHost.LoadPlugins(FileSystem, Interface.CurrentOptions, out error, TrainManager, Renderer)) { + if (!CurrentHost.LoadPlugins(FileSystem, Interface.CurrentOptions, out string error, TrainManager, Renderer)) { MessageBox.Show(error, @"OpenBVE", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } diff --git a/source/OpenBVE/UserInterface/formMain.Options.cs b/source/OpenBVE/UserInterface/formMain.Options.cs index 384b20b2f..f67e49f1f 100644 --- a/source/OpenBVE/UserInterface/formMain.Options.cs +++ b/source/OpenBVE/UserInterface/formMain.Options.cs @@ -16,8 +16,7 @@ internal partial class formMain { private void comboboxLanguages_SelectedIndexChanged(object sender, EventArgs e) { if (this.Tag != null) return; string Folder = Program.FileSystem.GetDataFolder("Flags"); - string newImage; - if (Translations.SelectedLanguage(Folder, ref Interface.CurrentOptions.LanguageCode, comboboxLanguages, out newImage)) + if (Translations.SelectedLanguage(Folder, ref Interface.CurrentOptions.LanguageCode, comboboxLanguages, out string newImage)) { pictureboxLanguage.Image = ImageExtensions.FromFile(newImage); ApplyLanguage(); diff --git a/source/OpenBVE/UserInterface/formMain.Packages.cs b/source/OpenBVE/UserInterface/formMain.Packages.cs index 025618eb4..59c7675bb 100644 --- a/source/OpenBVE/UserInterface/formMain.Packages.cs +++ b/source/OpenBVE/UserInterface/formMain.Packages.cs @@ -40,8 +40,7 @@ private void RefreshPackages() MessageBox.Show(Translations.GetInterfaceString("packages_database_save_error")); } - string errorMessage; - if (Database.LoadDatabase(Program.FileSystem.PackageDatabaseFolder, currentDatabaseFile, out errorMessage)) + if (Database.LoadDatabase(Program.FileSystem.PackageDatabaseFolder, currentDatabaseFile, out string errorMessage)) { PopulatePackageList(Database.currentDatabase.InstalledRoutes, dataGridViewPackages, true, false, false); comboBoxPackageType.SelectedIndex = 0; @@ -1246,8 +1245,7 @@ private void linkLabelPackageWebsite_Click(object sender, EventArgs e) launchLink += "http://"; } launchLink += currentPackage.Website; - Uri URL; - bool result = Uri.TryCreate(launchLink, UriKind.Absolute, out URL) && (URL.Scheme == Uri.UriSchemeHttp || URL.Scheme == Uri.UriSchemeHttps); + bool result = Uri.TryCreate(launchLink, UriKind.Absolute, out Uri URL) && (URL.Scheme == Uri.UriSchemeHttp || URL.Scheme == Uri.UriSchemeHttps); if (result) { Process.Start(launchLink); diff --git a/source/OpenBVE/UserInterface/formMain.Start.cs b/source/OpenBVE/UserInterface/formMain.Start.cs index ae614f396..62e0d6f45 100644 --- a/source/OpenBVE/UserInterface/formMain.Start.cs +++ b/source/OpenBVE/UserInterface/formMain.Start.cs @@ -1149,8 +1149,7 @@ private void PreviewRoute(CancellationToken cancelToken) // Gets the last item put into the queue at this time. { - LaunchParameters tmp; - while (previewRouteResultQueue.TryTake(out tmp)) + while (previewRouteResultQueue.TryTake(out LaunchParameters tmp)) { result = tmp; } diff --git a/source/OpenBVE/UserInterface/formMain.cs b/source/OpenBVE/UserInterface/formMain.cs index bc51b34e6..ed01761b3 100644 --- a/source/OpenBVE/UserInterface/formMain.cs +++ b/source/OpenBVE/UserInterface/formMain.cs @@ -1278,9 +1278,7 @@ private void formMain_FormClosing() Program.Sounds.DeInitialize(); DisposePreviewRouteThread(); { - // ReSharper disable once NotAccessedVariable - string error; - Program.CurrentHost.UnloadPlugins(out error); + Program.CurrentHost.UnloadPlugins(out _); } if (Program.CurrentHost.Platform != HostPlatform.AppleOSX && Program.CurrentHost.Platform != HostPlatform.FreeBSD) { @@ -1522,8 +1520,7 @@ private void radioButtonPackages_CheckedChanged(object sender, EventArgs e) if (radioButtonPackages.Checked) { ResetInstallerPanels(); - string errorMessage; - if (Database.LoadDatabase(Program.FileSystem.PackageDatabaseFolder, currentDatabaseFile, out errorMessage)) + if (Database.LoadDatabase(Program.FileSystem.PackageDatabaseFolder, currentDatabaseFile, out string errorMessage)) { PopulatePackageList(Database.currentDatabase.InstalledRoutes, dataGridViewPackages, true, false, false); } From 867a650cd76332149a07e2baaa7b29ea0deb2f78 Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Thu, 5 Oct 2023 17:38:18 +0100 Subject: [PATCH 11/16] Change: Add patches for some Polish routes Minor glitches with some disappearing stock --- assets/Compatibility/RoutePatches/Poland.xml | 31 +++++++++++++++++++ .../Compatibility/RoutePatches/database.xml | 1 + 2 files changed, 32 insertions(+) create mode 100644 assets/Compatibility/RoutePatches/Poland.xml diff --git a/assets/Compatibility/RoutePatches/Poland.xml b/assets/Compatibility/RoutePatches/Poland.xml new file mode 100644 index 000000000..2cd3714de --- /dev/null +++ b/assets/Compatibility/RoutePatches/Poland.xml @@ -0,0 +1,31 @@ + + + + + 7802444DAA75DD1B109FE04032FC52FE069F0B25CD54B24CFB2F6651A481F8E3 + VIRTUAL2.rw + true + true + + + + A706EB6A6C7E4394FFD876666FE48365E36AC7156C24F883BF51E4457F1296D0 + POC_os.rw + true + true + + + ED3AADB683C0FE44CBC7AFD46F20F057909E2E73FF4C10E68D2ECA7B354AAC7C + POC_osp.rw + true + true + + + + 1C600BA5074BF9C8B3E1BD045E544C123C919EAA82E676E04EBFBDAE971B0A03 + Leszno-Krotoszyn.csv + true + true + + + \ No newline at end of file diff --git a/assets/Compatibility/RoutePatches/database.xml b/assets/Compatibility/RoutePatches/database.xml index 23a4a0867..f24c0f7e4 100644 --- a/assets/Compatibility/RoutePatches/database.xml +++ b/assets/Compatibility/RoutePatches/database.xml @@ -8,6 +8,7 @@ Holland.xml HongKong.xml Hungary.xml + Poland.xml Italy.xml Japan.xml Misc.xml From 6bdd0f632e3da0153989f9fce15d7389a82e857f Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Thu, 5 Oct 2023 21:33:15 +0100 Subject: [PATCH 12/16] Change: Inline more variables, minor tweaks --- .../FunctionScript.Notation.cs | 90 ++++++------------- .../FunctionScripts/FunctionScript.cs | 5 +- source/OpenBveApi/Graphics/Colors.cs | 8 +- source/OpenBveApi/Interface/Input/Commands.cs | 3 +- source/OpenBveApi/Interface/Time.cs | 11 ++- source/OpenBveApi/Math/Math.cs | 15 ++-- source/OpenBveApi/Math/Matrix4.cs | 16 ++-- source/OpenBveApi/Math/Vectors/Vector3.cs | 3 +- source/OpenBveApi/Math/Vectors/Vector4.cs | 3 +- source/OpenBveApi/Objects/Glow.cs | 3 +- .../OpenBveApi/Objects/Helpers/MeshBuilder.cs | 3 +- source/OpenBveApi/Objects/MeshFace.cs | 1 - .../OpenBveApi/Packages/Packages.Loksim3D.cs | 3 +- source/OpenBveApi/System/Hosts.cs | 3 +- .../Plugins/Object.Animated/Plugin.Parser.cs | 9 +- source/Plugins/Object.CsvB3d/Plugin.Parser.cs | 10 +-- 16 files changed, 62 insertions(+), 124 deletions(-) diff --git a/source/OpenBveApi/FunctionScripts/FunctionScript.Notation.cs b/source/OpenBveApi/FunctionScripts/FunctionScript.Notation.cs index d04677e42..e29c78097 100644 --- a/source/OpenBveApi/FunctionScripts/FunctionScript.Notation.cs +++ b/source/OpenBveApi/FunctionScripts/FunctionScript.Notation.cs @@ -17,12 +17,10 @@ public static string GetPostfixNotationFromFunctionNotation(string Expression) { if (Expression.EndsWith("]", StringComparison.InvariantCultureIgnoreCase)) { throw new System.IO.InvalidDataException("Unexpected closing bracket encountered in " + Expression); } - // ReSharper disable once NotAccessedVariable /* * If this is a simple number, we can short-circuit the rest of this function */ - double value; - if (double.TryParse(Expression, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out value)) { + if (double.TryParse(Expression, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out _)) { return Expression; } for (int j = 0; j < Expression.Length; j++) { @@ -342,12 +340,8 @@ internal static string GetOptimizedPostfixNotation(string Expression) { StackLength--; q = false; } else if (StackLength >= 2) { - // ReSharper disable once NotAccessedVariable - double b; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out b)) { - // ReSharper disable once NotAccessedVariable - double a; - if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out _)) { + if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out _)) { // a b <> // b a (Stack[StackLength - 1], Stack[StackLength - 2]) = (Stack[StackLength - 2], Stack[StackLength - 1]); @@ -364,10 +358,8 @@ internal static string GetOptimizedPostfixNotation(string Expression) { { bool q = true; if (StackLength >= 2) { - double b; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out b)) { - double a; - if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double b)) { + if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out double a)) { // x y + // (x y +) Stack[StackLength - 2] = (a + b).ToString(Culture); @@ -416,10 +408,8 @@ internal static string GetOptimizedPostfixNotation(string Expression) { { bool q = true; if (StackLength >= 2) { - double b; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out b)) { - double a; - if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double b)) { + if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out double a)) { // x y - // (x y -) Stack[StackLength - 2] = (a - b).ToString(Culture); @@ -475,8 +465,7 @@ internal static string GetOptimizedPostfixNotation(string Expression) { StackLength--; q = false; } else { - double a; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double a)) { // x minus // (x minus) Stack[StackLength - 1] = (-a).ToString(Culture); @@ -493,10 +482,8 @@ internal static string GetOptimizedPostfixNotation(string Expression) { { bool q = true; if (StackLength >= 2) { - double b; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out b)) { - double a; - if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double b)) { + if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out double a)) { // x y * // (x y *) Stack[StackLength - 2] = (a * b).ToString(Culture); @@ -530,8 +517,7 @@ internal static string GetOptimizedPostfixNotation(string Expression) { } } else if (StackLength >= 4 && Stack[StackLength - 2] == "fma") { if (double.TryParse(Stack[StackLength - 3], System.Globalization.NumberStyles.Float, Culture, out a)) { - double c; - if (double.TryParse(Stack[StackLength - 4], System.Globalization.NumberStyles.Float, Culture, out c)) { + if (double.TryParse(Stack[StackLength - 4], System.Globalization.NumberStyles.Float, Culture, out double c)) { // A x y fma z * // A (x z *) (y z *) fma Stack[StackLength - 4] = (c * b).ToString(Culture); @@ -567,8 +553,7 @@ internal static string GetOptimizedPostfixNotation(string Expression) { StackLength--; q = false; } else { - double a; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double a)) { // x reciprocal // (x reciprocal) a = a == 0.0 ? 0.0 : 1.0 / a; @@ -586,11 +571,9 @@ internal static string GetOptimizedPostfixNotation(string Expression) { { bool q = true; if (StackLength >= 2) { - double b; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out b)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double b)) { if (b != 0.0) { - double a; - if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out double a)) { // x y / // (x y /) Stack[StackLength - 2] = (a / b).ToString(Culture); @@ -617,8 +600,7 @@ internal static string GetOptimizedPostfixNotation(string Expression) { { bool q = true; if (StackLength >= 1) { - double a; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double a)) { // x ++ // (x ++) Stack[StackLength - 1] = (a + 1).ToString(Culture); @@ -634,8 +616,7 @@ internal static string GetOptimizedPostfixNotation(string Expression) { { bool q = true; if (StackLength >= 1) { - double a; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double a)) { // x -- // (x --) Stack[StackLength - 1] = (a - 1).ToString(Culture); @@ -673,8 +654,7 @@ internal static string GetOptimizedPostfixNotation(string Expression) { Stack[StackLength - 1] = "<"; q = false; } else { - double a; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double a)) { Stack[StackLength - 1] = a == 0.0 ? "1" : "0"; q = false; } @@ -689,10 +669,8 @@ internal static string GetOptimizedPostfixNotation(string Expression) { { bool q = true; if (StackLength >= 2) { - double b; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out b)) { - double a; - if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double b)) { + if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out double a)) { Stack[StackLength - 2] = a == b ? "1" : "0"; StackLength--; q = false; @@ -708,10 +686,8 @@ internal static string GetOptimizedPostfixNotation(string Expression) { { bool q = true; if (StackLength >= 2) { - double b; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out b)) { - double a; - if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double b)) { + if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out double a)) { Stack[StackLength - 2] = a != b ? "1" : "0"; StackLength--; q = false; @@ -727,10 +703,8 @@ internal static string GetOptimizedPostfixNotation(string Expression) { { bool q = true; if (StackLength >= 2) { - double b; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out b)) { - double a; - if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double b)) { + if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out double a)) { Stack[StackLength - 2] = a < b ? "1" : "0"; StackLength--; q = false; @@ -746,10 +720,8 @@ internal static string GetOptimizedPostfixNotation(string Expression) { { bool q = true; if (StackLength >= 2) { - double b; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out b)) { - double a; - if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double b)) { + if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out double a)) { Stack[StackLength - 2] = a > b ? "1" : "0"; StackLength--; q = false; @@ -765,10 +737,8 @@ internal static string GetOptimizedPostfixNotation(string Expression) { { bool q = true; if (StackLength >= 2) { - double b; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out b)) { - double a; - if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double b)) { + if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out double a)) { Stack[StackLength - 2] = a <= b ? "1" : "0"; StackLength--; q = false; @@ -784,10 +754,8 @@ internal static string GetOptimizedPostfixNotation(string Expression) { { bool q = true; if (StackLength >= 2) { - double b; - if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out b)) { - double a; - if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out a)) { + if (double.TryParse(Stack[StackLength - 1], System.Globalization.NumberStyles.Float, Culture, out double b)) { + if (double.TryParse(Stack[StackLength - 2], System.Globalization.NumberStyles.Float, Culture, out double a)) { Stack[StackLength - 2] = a >= b ? "1" : "0"; StackLength--; q = false; diff --git a/source/OpenBveApi/FunctionScripts/FunctionScript.cs b/source/OpenBveApi/FunctionScripts/FunctionScript.cs index c976442ab..3d1fa584c 100644 --- a/source/OpenBveApi/FunctionScripts/FunctionScript.cs +++ b/source/OpenBveApi/FunctionScripts/FunctionScript.cs @@ -106,7 +106,7 @@ public FunctionScript(HostInterface Host, string Expression, bool Infix) Stack = new double[16]; int m = 0, s = 0; Constants = new double[16]; int c = 0; for (int i = 0; i < Arguments.Length; i++) { - double d; if (double.TryParse(Arguments[i], System.Globalization.NumberStyles.Float, Culture, out d)) { + if (double.TryParse(Arguments[i], System.Globalization.NumberStyles.Float, Culture, out double d)) { if (n >= InstructionSet.Length) Array.Resize(ref InstructionSet, InstructionSet.Length << 1); InstructionSet[n] = Instructions.SystemConstant; if (c >= Constants.Length) Array.Resize(ref Constants, Constants.Length << 1); @@ -309,8 +309,7 @@ public FunctionScript(HostInterface Host, string Expression, bool Infix) if (s < 2) throw new InvalidOperationException(Arguments[i] + " requires at least 2 arguments on the stack in function script " + Expression); if (Arguments[i - 2].ToLowerInvariant() == "cars") { - int nCars; - NumberFormats.TryParseIntVb6(Arguments[i - 1], out nCars); + NumberFormats.TryParseIntVb6(Arguments[i - 1], out int nCars); if (System.Math.Abs(nCars) != nCars) { //It makes absolutely no sense to test whether there are less than 0 cars in a train, so let's at least throw a broken script error diff --git a/source/OpenBveApi/Graphics/Colors.cs b/source/OpenBveApi/Graphics/Colors.cs index ff12eb06a..ba35759ff 100644 --- a/source/OpenBveApi/Graphics/Colors.cs +++ b/source/OpenBveApi/Graphics/Colors.cs @@ -124,7 +124,7 @@ public static bool TryParseHexColor(string Expression, out Color24 Color) if (Expression.StartsWith("#", StringComparison.InvariantCultureIgnoreCase)) { string a = Expression.Substring(1).TrimStart(); - int x; if (int.TryParse(a, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out x)) + if (int.TryParse(a, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int x)) { int r = (x >> 16) & 0xFF; int g = (x >> 8) & 0xFF; @@ -145,9 +145,7 @@ public static bool TryParseHexColor(string Expression, out Color24 Color) /// The new Color24 public static Color24 ParseHexColor(string Expression) { - Color24 color; - - if (!TryParseHexColor(Expression, out color)) + if (!TryParseHexColor(Expression, out Color24 color)) { throw new FormatException(); } @@ -338,7 +336,7 @@ public static bool TryParseHexColor(string Expression, out Color32 Color) if (Expression.StartsWith("#", StringComparison.InvariantCultureIgnoreCase)) { string a = Expression.Substring(1).TrimStart(); - int x; if (int.TryParse(a, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out x)) + if (int.TryParse(a, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int x)) { int r = (x >> 16) & 0xFF; int g = (x >> 8) & 0xFF; diff --git a/source/OpenBveApi/Interface/Input/Commands.cs b/source/OpenBveApi/Interface/Input/Commands.cs index 43180e230..dd3e5f84d 100644 --- a/source/OpenBveApi/Interface/Input/Commands.cs +++ b/source/OpenBveApi/Interface/Input/Commands.cs @@ -336,8 +336,7 @@ public static VirtualKeys SecurityToVirtualKey(Command cmd) if (cmdname == null) throw new ArgumentNullException("cmd"); if (cmdname.StartsWith("Security", StringComparison.Ordinal)) cmdname = cmdname.Substring(8).ToUpperInvariant(); - VirtualKeys key; - if (!Enum.TryParse(cmdname, out key)) + if (!Enum.TryParse(cmdname, out VirtualKeys key)) throw new ArgumentException(@"VirtualKeys does not contain the following key: " + cmdname, "cmd"); return key; diff --git a/source/OpenBveApi/Interface/Time.cs b/source/OpenBveApi/Interface/Time.cs index 8ec4269a2..385e77afe 100644 --- a/source/OpenBveApi/Interface/Time.cs +++ b/source/OpenBveApi/Interface/Time.cs @@ -20,10 +20,10 @@ public static bool TryParseTime(string Expression, out double Value) i = Expression.IndexOf(':'); } if (i >= 1) { - int h; if (int.TryParse(Expression.Substring(0, i), NumberStyles.Integer, Culture, out h)) { + if (int.TryParse(Expression.Substring(0, i), NumberStyles.Integer, Culture, out int h)) { int n = Expression.Length - i - 1; if (n == 1 | n == 2) { - uint m; if (uint.TryParse(Expression.Substring(i + 1, n), NumberStyles.None, Culture, out m)) { + if (uint.TryParse(Expression.Substring(i + 1, n), NumberStyles.None, Culture, out uint m)) { Value = 3600.0 * h + 60.0 * m; return true; } @@ -32,10 +32,9 @@ public static bool TryParseTime(string Expression, out double Value) { n = 4; } - uint m; if (uint.TryParse(Expression.Substring(i + 1, 2), NumberStyles.None, Culture, out m)) { - uint s; + if (uint.TryParse(Expression.Substring(i + 1, 2), NumberStyles.None, Culture, out uint m)) { string ss = Expression.Substring(i + 3, n - 2); - if (uint.TryParse(ss, NumberStyles.None, Culture, out s)) { + if (uint.TryParse(ss, NumberStyles.None, Culture, out uint s)) { Value = 3600.0 * h + 60.0 * m + s; return true; } @@ -43,7 +42,7 @@ public static bool TryParseTime(string Expression, out double Value) } } } else if (i == -1) { - int h; if (int.TryParse(Expression, NumberStyles.Integer, Culture, out h)) { + if (int.TryParse(Expression, NumberStyles.Integer, Culture, out int h)) { Value = 3600.0 * h; return true; } diff --git a/source/OpenBveApi/Math/Math.cs b/source/OpenBveApi/Math/Math.cs index a2ce40245..f81ae0cee 100644 --- a/source/OpenBveApi/Math/Math.cs +++ b/source/OpenBveApi/Math/Math.cs @@ -31,8 +31,7 @@ public static bool TryParseDoubleVb6(string Expression, out double Value) CultureInfo Culture = CultureInfo.InvariantCulture; for (int n = Expression.Length; n > 0; n--) { - double a; - if (double.TryParse(Expression.Substring(0, n), NumberStyles.Float, Culture, out a)) + if (double.TryParse(Expression.Substring(0, n), NumberStyles.Float, Culture, out double a)) { Value = a; return true; @@ -52,8 +51,7 @@ public static bool TryParseFloatVb6(string Expression, out float Value) CultureInfo Culture = CultureInfo.InvariantCulture; for (int n = Expression.Length; n > 0; n--) { - float a; - if (float.TryParse(Expression.Substring(0, n), NumberStyles.Float, Culture, out a)) + if (float.TryParse(Expression.Substring(0, n), NumberStyles.Float, Culture, out float a)) { Value = a; return true; @@ -73,8 +71,7 @@ public static bool TryParseIntVb6(string Expression, out int Value) CultureInfo Culture = CultureInfo.InvariantCulture; for (int n = Expression.Length; n > 0; n--) { - double a; - if (double.TryParse(Expression.Substring(0, n), NumberStyles.Float, Culture, out a)) + if (double.TryParse(Expression.Substring(0, n), NumberStyles.Float, Culture, out double a)) { if (a >= -2147483648.0 & a <= 2147483647.0) { @@ -104,8 +101,7 @@ public static bool IsValidDouble(string Expression, double[] UnitFactors) /// True if parsing succeds, false otherwise public static bool TryParseDouble(string Expression, double[] UnitFactors, out double Value) { - double a; - if (double.TryParse(Expression, NumberStyles.Number, CultureInfo.InvariantCulture, out a)) + if (double.TryParse(Expression, NumberStyles.Number, CultureInfo.InvariantCulture, out double a)) { Value = a * UnitFactors[UnitFactors.Length - 1]; return true; @@ -145,8 +141,7 @@ public static bool TryParseDouble(string Expression, double[] UnitFactors, out d /// True if parsing succeds, false otherwise public static bool TryParseDoubleVb6(string Expression, double[] UnitFactors, out double Value) { - double a; - if (double.TryParse(Expression, NumberStyles.Number, CultureInfo.InvariantCulture, out a)) + if (double.TryParse(Expression, NumberStyles.Number, CultureInfo.InvariantCulture, out double a)) { Value = a * UnitFactors[UnitFactors.Length - 1]; return true; diff --git a/source/OpenBveApi/Math/Matrix4.cs b/source/OpenBveApi/Math/Matrix4.cs index 70fa6f2fa..b71372385 100644 --- a/source/OpenBveApi/Math/Matrix4.cs +++ b/source/OpenBveApi/Math/Matrix4.cs @@ -423,8 +423,7 @@ public static void CreateTranslation(ref Vector3 vector, out Matrix4D result) /// The resulting Matrix4. public static Matrix4D CreateTranslation(double x, double y, double z) { - Matrix4D result; - CreateTranslation(x, y, z, out result); + CreateTranslation(x, y, z, out Matrix4D result); return result; } @@ -433,8 +432,7 @@ public static Matrix4D CreateTranslation(double x, double y, double z) /// The resulting Matrix4. public static Matrix4D CreateTranslation(Vector3 vector) { - Matrix4D result; - CreateTranslation(vector.X, vector.Y, vector.Z, out result); + CreateTranslation(vector.X, vector.Y, vector.Z, out Matrix4D result); return result; } @@ -487,8 +485,7 @@ public static void CreateFromAxisAngle(Vector3 axis, double angle, out Matrix4D /// A matrix instance. public static Matrix4D CreateFromAxisAngle(Vector3 axis, double angle) { - Matrix4D result; - CreateFromAxisAngle(axis, angle, out result); + CreateFromAxisAngle(axis, angle, out Matrix4D result); return result; } @@ -499,9 +496,7 @@ public static Matrix4D CreateFromAxisAngle(Vector3 axis, double angle) /// Matrix result. public static void CreateFromQuaternion(ref Quaternion q, out Matrix4D result) { - Vector3 axis; - double angle; - q.ToAxisAngle(out axis, out angle); + q.ToAxisAngle(out Vector3 axis, out double angle); CreateFromAxisAngle(axis, angle, out result); } @@ -512,8 +507,7 @@ public static void CreateFromQuaternion(ref Quaternion q, out Matrix4D result) /// A matrix instance. public static Matrix4D CreateFromQuaternion(Quaternion q) { - Matrix4D result; - CreateFromQuaternion(ref q, out result); + CreateFromQuaternion(ref q, out Matrix4D result); return result; } diff --git a/source/OpenBveApi/Math/Vectors/Vector3.cs b/source/OpenBveApi/Math/Vectors/Vector3.cs index 8babf6f6e..af2bae607 100644 --- a/source/OpenBveApi/Math/Vectors/Vector3.cs +++ b/source/OpenBveApi/Math/Vectors/Vector3.cs @@ -701,8 +701,7 @@ public void Transform(Matrix4D transformMatrix, bool ignoreW = true) /// The result of the operation. public static Vector3 Transform(Vector3 vec, Quaternion quat) { - Vector3 result; - Transform(ref vec, ref quat, out result); + Transform(ref vec, ref quat, out Vector3 result); return result; } diff --git a/source/OpenBveApi/Math/Vectors/Vector4.cs b/source/OpenBveApi/Math/Vectors/Vector4.cs index acf726188..e2a4f75a7 100644 --- a/source/OpenBveApi/Math/Vectors/Vector4.cs +++ b/source/OpenBveApi/Math/Vectors/Vector4.cs @@ -314,8 +314,7 @@ public bool Equals(Vector4 b) /// The transformed vector public static Vector4 Transform(Vector4 vec, Matrix4D mat) { - Vector4 result; - Transform(ref vec, ref mat, out result); + Transform(ref vec, ref mat, out Vector4 result); return result; } diff --git a/source/OpenBveApi/Objects/Glow.cs b/source/OpenBveApi/Objects/Glow.cs index 513942556..f6baad9e7 100644 --- a/source/OpenBveApi/Objects/Glow.cs +++ b/source/OpenBveApi/Objects/Glow.cs @@ -53,8 +53,7 @@ public static double GetDistanceFactor(Matrix4D ModelMatrix, VertexTemplate[] Ve return 1.0; } - double halfdistance; - SplitAttenuationData(GlowAttenuationData, out mode, out halfdistance); + SplitAttenuationData(GlowAttenuationData, out mode, out double halfdistance); int i = Face.Vertices[0].Index; Vector3 d = new Vector3(Vertices[i].Coordinates.X, Vertices[i].Coordinates.Y, -Vertices[i].Coordinates.Z); d.Transform(ModelMatrix, false); diff --git a/source/OpenBveApi/Objects/Helpers/MeshBuilder.cs b/source/OpenBveApi/Objects/Helpers/MeshBuilder.cs index 083b43e41..66957bd96 100644 --- a/source/OpenBveApi/Objects/Helpers/MeshBuilder.cs +++ b/source/OpenBveApi/Objects/Helpers/MeshBuilder.cs @@ -145,8 +145,7 @@ public void Apply(ref StaticObject Object, bool EnableHacks = false, bool Ignore if (Materials[i].LightMap != null) { - Texture lightMap; - currentHost.RegisterTexture(Materials[i].LightMap, new TextureParameters(null, Color24.White), out lightMap); + currentHost.RegisterTexture(Materials[i].LightMap, new TextureParameters(null, Color24.White), out Texture lightMap); Object.Mesh.Materials[mm + i].LightMapTexture = lightMap; } diff --git a/source/OpenBveApi/Objects/MeshFace.cs b/source/OpenBveApi/Objects/MeshFace.cs index 594c9c530..bc57c9f44 100644 --- a/source/OpenBveApi/Objects/MeshFace.cs +++ b/source/OpenBveApi/Objects/MeshFace.cs @@ -63,7 +63,6 @@ public MeshFace(MeshFaceVertex[] verticies, ushort material) } /// Creates a new MeshFace containing N vertices - /// The number of vertices in the face public MeshFace(int numVertices) { Vertices = new MeshFaceVertex[numVertices]; diff --git a/source/OpenBveApi/Packages/Packages.Loksim3D.cs b/source/OpenBveApi/Packages/Packages.Loksim3D.cs index d3d50cc9c..2d3f4a48e 100644 --- a/source/OpenBveApi/Packages/Packages.Loksim3D.cs +++ b/source/OpenBveApi/Packages/Packages.Loksim3D.cs @@ -58,8 +58,7 @@ internal static Package Parse(XmlDocument currentXML, string fileName, ref strin case "VersionInfo": try { - int v; - int.TryParse(node.Attributes["Code"].Value, out v); + int.TryParse(node.Attributes["Code"].Value, out int v); currentPackage.PackageVersion = new Version(0,0,v); } catch diff --git a/source/OpenBveApi/System/Hosts.cs b/source/OpenBveApi/System/Hosts.cs index a9d61d8a0..ff8116705 100644 --- a/source/OpenBveApi/System/Hosts.cs +++ b/source/OpenBveApi/System/Hosts.cs @@ -158,8 +158,7 @@ private struct UName private static string DetectUnixKernel() { Debug.Flush(); - UName uts; - uname(out uts); + uname(out UName uts); return uts.sysname; } diff --git a/source/Plugins/Object.Animated/Plugin.Parser.cs b/source/Plugins/Object.Animated/Plugin.Parser.cs index c46a2353c..77e3573df 100644 --- a/source/Plugins/Object.Animated/Plugin.Parser.cs +++ b/source/Plugins/Object.Animated/Plugin.Parser.cs @@ -46,8 +46,7 @@ private static AnimatedObjectCollection ReadObject(string FileName, System.Text. if (Lines[i].Length != 0) { string sct = Lines[i].Trim().Trim('[', ']'); - AnimatedSection Section; - Enum.TryParse(sct, true, out Section); + Enum.TryParse(sct, true, out AnimatedSection Section); switch (Section) { case AnimatedSection.Include: @@ -65,8 +64,7 @@ private static AnimatedObjectCollection ReadObject(string FileName, System.Text. { string a = Lines[i].Substring(0, j).TrimEnd(); string b = Lines[i].Substring(j + 1).TrimStart(); - AnimatedKey key; - if (!Enum.TryParse(a, true, out key)) + if (!Enum.TryParse(a, true, out AnimatedKey key)) { continue; } @@ -228,8 +226,7 @@ private static AnimatedObjectCollection ReadObject(string FileName, System.Text. { string a = Lines[i].Substring(0, j).TrimEnd(); string b = Lines[i].Substring(j + 1).TrimStart(); - AnimatedKey key; - if(!Enum.TryParse(a, true, out key)) + if(!Enum.TryParse(a, true, out AnimatedKey key)) { currentHost.AddMessage(MessageType.Error, false, "Unknown key " + a + " encountered at line " + (i + 1).ToString(Culture) + " in the Section " + Section + " in file " + FileName); i++; diff --git a/source/Plugins/Object.CsvB3d/Plugin.Parser.cs b/source/Plugins/Object.CsvB3d/Plugin.Parser.cs index d5f53b494..4a3bbd4ba 100644 --- a/source/Plugins/Object.CsvB3d/Plugin.Parser.cs +++ b/source/Plugins/Object.CsvB3d/Plugin.Parser.cs @@ -17,8 +17,7 @@ public partial class Plugin { private static bool IsCommand(string Text, bool IsB3d) { - B3DCsvCommands command; - if (!Enum.TryParse(Text, true, out command)) + if (!Enum.TryParse(Text, true, out B3DCsvCommands command)) { // not a valid command return false; @@ -275,9 +274,7 @@ private static StaticObject ReadObject(string FileName, Encoding Encoding) { // parse terms if (Command != null) { - //string cmd = Command.ToLowerInvariant(); - B3DCsvCommands cmd; - Enum.TryParse(Command.TrimStart('[').TrimEnd(']'), true, out cmd); + Enum.TryParse(Command.TrimStart('[').TrimEnd(']'), true, out B3DCsvCommands cmd); switch(cmd) { case B3DCsvCommands.CreateMeshBuilder: case B3DCsvCommands.MeshBuilder: @@ -1364,8 +1361,7 @@ private static StaticObject ReadObject(string FileName, Encoding Encoding) { "TextPadding is not a supported command - did you mean SetTextPadding? - at line " + (i + 1).ToString(Culture) + " in file " + FileName); } - Vector2 Padding; - if(!Vector2.TryParse(Arguments, out Padding)) + if(!Vector2.TryParse(Arguments, out Vector2 Padding)) { currentHost.AddMessage(MessageType.Warning, false, "Invalid TextPadding at line " + (i + 1).ToString(Culture) + " in file " + FileName); } From fa8bb34b122a7f549c33a15568e956ca5e4962fb Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Sat, 7 Oct 2023 19:02:33 +0100 Subject: [PATCH 13/16] Change: Create OpenGL button class, abstract GLControl https://github.com/leezer3/OpenBVE/pull/329 --- source/LibRender2/LibRender2.csproj | 2 ++ source/LibRender2/Primitives/Button.cs | 26 +++++++++++++++++++ source/LibRender2/Primitives/GLControl.cs | 28 +++++++++++++++++++++ source/LibRender2/Primitives/Picturebox.cs | 23 ++++++----------- source/LibRender2/Primitives/Textbox.cs | 29 +++++++--------------- 5 files changed, 72 insertions(+), 36 deletions(-) create mode 100644 source/LibRender2/Primitives/Button.cs create mode 100644 source/LibRender2/Primitives/GLControl.cs diff --git a/source/LibRender2/LibRender2.csproj b/source/LibRender2/LibRender2.csproj index 240c95c13..2241e1b29 100644 --- a/source/LibRender2/LibRender2.csproj +++ b/source/LibRender2/LibRender2.csproj @@ -72,7 +72,9 @@ + + diff --git a/source/LibRender2/Primitives/Button.cs b/source/LibRender2/Primitives/Button.cs new file mode 100644 index 000000000..683b6cb36 --- /dev/null +++ b/source/LibRender2/Primitives/Button.cs @@ -0,0 +1,26 @@ +using LibRender2.Text; +using OpenBveApi.Colors; +using OpenBveApi.Graphics; + +namespace LibRender2.Primitives +{ + public class Button : GLControl + { + /// The text displayed on the button + public string Text; + /// The color of the text on the button + public Color128 TextColor; + /// The font for the button + public OpenGlFont Font; + + public Button(BaseRenderer renderer) : base(renderer) + { + } + + public override void Draw() + { + Renderer.Rectangle.Draw(Texture, Location, Size, BackgroundColor); + Renderer.OpenGlString.Draw(Font, Text, Location, TextAlignment.CenterLeft, TextColor); + } + } +} diff --git a/source/LibRender2/Primitives/GLControl.cs b/source/LibRender2/Primitives/GLControl.cs new file mode 100644 index 000000000..098d6c94b --- /dev/null +++ b/source/LibRender2/Primitives/GLControl.cs @@ -0,0 +1,28 @@ +using OpenBveApi.Colors; +using OpenBveApi.Math; +using OpenBveApi.Textures; + +namespace LibRender2.Primitives +{ + /// An abstract OpenGL based control + public abstract class GLControl + { + /// Holds a reference to the base renderer + internal readonly BaseRenderer Renderer; + /// The background color for the control + public Color128 BackgroundColor; + /// The texture for the picturebox + public Texture Texture; + /// The stored location for the control + public Vector2 Location; + /// The stored size for the control + public Vector2 Size; + + protected GLControl(BaseRenderer renderer) + { + Renderer = renderer; + } + + public abstract void Draw(); + } +} diff --git a/source/LibRender2/Primitives/Picturebox.cs b/source/LibRender2/Primitives/Picturebox.cs index b62441b34..ebadb6c86 100644 --- a/source/LibRender2/Primitives/Picturebox.cs +++ b/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 { - /// Holds a reference to the base renderer - private readonly BaseRenderer Renderer; - /// The texture for the picturebox - public Texture Texture; - /// The background color for the picturebox - public Color128 BackgroundColor; /// The image sizing mode public ImageSizeMode SizeMode; - /// The stored location for the textbox - public Vector2 Location; - /// The stored size for the textbox - 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)) { diff --git a/source/LibRender2/Primitives/Textbox.cs b/source/LibRender2/Primitives/Textbox.cs index 4d3515fce..ac32ac5d7 100644 --- a/source/LibRender2/Primitives/Textbox.cs +++ b/source/LibRender2/Primitives/Textbox.cs @@ -8,10 +8,8 @@ namespace LibRender2.Primitives { - public class Textbox + public class Textbox : GLControl { - /// Holds a reference to the base renderer - private readonly BaseRenderer renderer; /// The font the items in this textbox are to be drawn with private readonly OpenGlFont myFont; /// The font color @@ -32,10 +30,6 @@ public string Text topLine = 0; } } - /// The background texture - public Texture BackgroundTexture; - /// The background color - public Color128 BackgroundColor; /// Backing property for the textbox text private string myText; @@ -43,10 +37,6 @@ public string Text public readonly int Border; /// The top line to be renderered private int topLine; - /// The stored location for the textbox - public Vector2 Location; - /// The stored size for the textbox - public Vector2 Size; /// Whether the textbox is currently selected by the mouse public bool CurrentlySelected; /// Whether the textbox can scroll @@ -105,14 +95,13 @@ private List WrappedLines(int width) return wrappedLines; } - public Textbox(BaseRenderer Renderer, OpenGlFont Font, Color128 FontColor, Color128 backgroundColor) + public Textbox(BaseRenderer Renderer, OpenGlFont Font, Color128 FontColor, Color128 backgroundColor) : base(Renderer) { - renderer = Renderer; myFont = Font; myFontColor = FontColor; Border = 5; topLine = 0; - BackgroundTexture = null; + Texture = null; BackgroundColor = backgroundColor; myScrollbarColor = Color128.Orange; } @@ -126,9 +115,9 @@ public void VerticalScroll(int numberOfLines) } } - public void Draw() + public override void Draw() { - renderer.Rectangle.Draw(BackgroundTexture, Location, Size, BackgroundColor); //Draw the backing rectangle first + Renderer.Rectangle.Draw(Texture, Location, Size, BackgroundColor); //Draw the backing rectangle first if (string.IsNullOrEmpty(Text)) { return; @@ -138,7 +127,7 @@ public void Draw() if (splitString.Count == 1) { //DRAW SINGLE LINE - renderer.OpenGlString.Draw(myFont, Text, new Vector2(Location.X + Border, Location.Y + Border), TextAlignment.TopLeft, myFontColor); + Renderer.OpenGlString.Draw(myFont, Text, new Vector2(Location.X + Border, Location.Y + Border), TextAlignment.TopLeft, myFontColor); CanScroll = false; } else @@ -151,14 +140,14 @@ public void Draw() CanScroll = maxFittingLines < splitString.Count; if (CanScroll) { - renderer.Rectangle.Draw(null, new Vector2(Location.X + Size.X - 12, Location.Y + 2), new Vector2(8, Size.Y - 4), Color128.Grey); //Backing rectangle + Renderer.Rectangle.Draw(null, new Vector2(Location.X + Size.X - 12, Location.Y + 2), new Vector2(8, Size.Y - 4), Color128.Grey); //Backing rectangle } //DRAW SPLIT LINES int currentLine = topLine; int bottomLine = Math.Min(maxFittingLines, splitString.Count); for (int i = 0; i < bottomLine; i++) { - renderer.OpenGlString.Draw(myFont, splitString[currentLine], new Vector2(Location.X + Border, Location.Y + Border + myFont.FontSize * i), TextAlignment.TopLeft, myFontColor); + Renderer.OpenGlString.Draw(myFont, splitString[currentLine], new Vector2(Location.X + Border, Location.Y + Border + myFont.FontSize * i), TextAlignment.TopLeft, myFontColor); currentLine++; } @@ -166,7 +155,7 @@ public void Draw() { double scrollBarHeight = (Size.Y - 4) * maxFittingLines / splitString.Count; double percentageScroll = topLine / (double)(splitString.Count - maxFittingLines); - renderer.Rectangle.Draw(null, new Vector2(Location.X + Size.X - 13, Location.Y + (Size.Y - scrollBarHeight) * percentageScroll), new Vector2(10, scrollBarHeight), myScrollbarColor); + Renderer.Rectangle.Draw(null, new Vector2(Location.X + Size.X - 13, Location.Y + (Size.Y - scrollBarHeight) * percentageScroll), new Vector2(10, scrollBarHeight), myScrollbarColor); } } From e90be0feec51d825d9f1370e8c40e9ef9ae1778c Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Sat, 7 Oct 2023 22:20:09 +0100 Subject: [PATCH 14/16] Change: Inline more variables, minor tweaks --- source/CarXMLConvertor/TabbedList.cs | 8 ++- source/LibRender2/Camera/Camera.cs | 18 ++--- source/LibRender2/Overlays/RailPath.cs | 3 +- source/LibRender2/Shaders/Shader.cs | 3 +- source/LibRender2/Text/OpenGlFont.cs | 5 +- source/LibRender2/Text/OpenGlString.cs | 14 ++-- source/ObjectViewer/Hosts.cs | 6 +- source/ObjectViewer/Options.cs | 18 ++--- source/ObjectViewer/ProgramS.cs | 3 +- .../Interface/Input/Commands.CommandInfo.cs | 3 +- .../Interface/Translations/LanguageFile.cs | 6 +- source/OpenBveApi/Math/Quaternion.cs | 8 +-- .../Routes/QuadTree/QuadNode.Leaf.cs | 4 +- source/Plugins/Object.LokSim/GroupParser.cs | 6 +- source/Plugins/Object.LokSim/ObjectParser.cs | 10 +-- source/Plugins/Object.Msts/ShapeParser.cs | 3 +- .../CsvRwRouteParser.PreprocessOptions.cs | 14 ++-- .../Plugins/Route.CsvRw/CsvRwRouteParser.cs | 12 ++-- .../Namespaces/NonTrack/Options.cs | 18 ++--- .../Route.CsvRw/Namespaces/NonTrack/Route.cs | 24 +++---- .../Route.CsvRw/Namespaces/NonTrack/Signal.cs | 3 +- .../Namespaces/NonTrack/Structure.cs | 70 ++++++------------- source/RouteViewer/Audio/Sounds.Update.cs | 3 +- source/RouteViewer/NewRendererR.cs | 4 +- source/RouteViewer/Options.cs | 21 ++---- source/RouteViewer/ProgramR.cs | 6 +- source/RouteViewer/System/Host.cs | 9 +-- source/TrainEditor2/Audio/SoundApi.Update.cs | 3 +- 28 files changed, 102 insertions(+), 203 deletions(-) diff --git a/source/CarXMLConvertor/TabbedList.cs b/source/CarXMLConvertor/TabbedList.cs index d64bf5b80..bc0754926 100644 --- a/source/CarXMLConvertor/TabbedList.cs +++ b/source/CarXMLConvertor/TabbedList.cs @@ -6,9 +6,11 @@ internal class TabbedList { internal TabbedList() { - this.Lines = new List(); - this.Lines.Add(""); - this.Lines.Add(""); + this.Lines = new List + { + "", + "" + }; this.Tabs = 0; } diff --git a/source/LibRender2/Camera/Camera.cs b/source/LibRender2/Camera/Camera.cs index f315b29f5..150b949c8 100644 --- a/source/LibRender2/Camera/Camera.cs +++ b/source/LibRender2/Camera/Camera.cs @@ -34,10 +34,7 @@ public class CameraProperties /// The absolute in-world camera position public Vector3 AbsolutePosition { - get - { - return absolutePosition; - } + get => absolutePosition; set { if (value == absolutePosition) @@ -60,10 +57,7 @@ public Vector3 AbsolutePosition /// The current relative camera Direction public CameraAlignment AlignmentDirection { - get - { - return alignmentDirection; - } + get => alignmentDirection; set { Renderer.UpdateVisibility(true); @@ -88,10 +82,7 @@ public CameraAlignment AlignmentDirection /// The current camera mode public CameraViewMode CurrentMode { - get - { - return currentMode; - } + get => currentMode; set { if (currentMode == value) @@ -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. diff --git a/source/LibRender2/Overlays/RailPath.cs b/source/LibRender2/Overlays/RailPath.cs index c0a0ccd42..c70214f28 100644 --- a/source/LibRender2/Overlays/RailPath.cs +++ b/source/LibRender2/Overlays/RailPath.cs @@ -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; } diff --git a/source/LibRender2/Shaders/Shader.cs b/source/LibRender2/Shaders/Shader.cs index 6d4024a03..ac4ca79ac 100644 --- a/source/LibRender2/Shaders/Shader.cs +++ b/source/LibRender2/Shaders/Shader.cs @@ -39,7 +39,6 @@ public class Shader : IDisposable public Shader(BaseRenderer Renderer, string VertexShaderName, string FragmentShaderName, bool IsFromStream = false) { renderer = Renderer; - int status; handle = GL.CreateProgram(); if (IsFromStream) @@ -79,7 +78,7 @@ public Shader(BaseRenderer Renderer, string VertexShaderName, string FragmentSha GL.DeleteShader(fragmentShader); GL.BindFragDataLocation(handle, 0, "fragColor"); GL.LinkProgram(handle); - GL.GetProgram(handle, GetProgramParameterName.LinkStatus, out status); + GL.GetProgram(handle, GetProgramParameterName.LinkStatus, out int status); if (status == 0) { diff --git a/source/LibRender2/Text/OpenGlFont.cs b/source/LibRender2/Text/OpenGlFont.cs index fb0111d0d..150654433 100644 --- a/source/LibRender2/Text/OpenGlFont.cs +++ b/source/LibRender2/Text/OpenGlFont.cs @@ -67,10 +67,7 @@ public Vector2 MeasureString(string text) { for (int i = 0; i < text.Length; i++) { - // ReSharper disable once NotAccessedVariable - Texture texture; - OpenGlFontChar data; - i += GetCharacterData(text, i, out texture, out data) - 1; + i += GetCharacterData(text, i, out Texture _, out OpenGlFontChar data) - 1; width += data.TypographicSize.X; if (data.TypographicSize.Y > height) diff --git a/source/LibRender2/Text/OpenGlString.cs b/source/LibRender2/Text/OpenGlString.cs index b851b26a9..f0cd05691 100644 --- a/source/LibRender2/Text/OpenGlString.cs +++ b/source/LibRender2/Text/OpenGlString.cs @@ -53,8 +53,7 @@ public void Draw(OpenGlFont font, string text, Vector2 location, TextAlignment a for (int i = 0; i < text.Length; i++) { - OpenGlFontChar data; - i += font.GetCharacterData(text, i, out _, out data) - 1; + i += font.GetCharacterData(text, i, out _, out OpenGlFontChar data) - 1; width += data.TypographicSize.X; } @@ -80,8 +79,7 @@ public void Draw(OpenGlFont font, string text, Vector2 location, TextAlignment a for (int i = 0; i < text.Length; i++) { - OpenGlFontChar data; - i += font.GetCharacterData(text, i, out _, out data) - 1; + i += font.GetCharacterData(text, i, out _, out OpenGlFontChar data) - 1; if (data.TypographicSize.Y > height) { @@ -140,9 +138,7 @@ private void DrawImmediate(string text, OpenGlFont font, double left, double top for (int i = 0; i < text.Length; i++) { - Texture texture; - OpenGlFontChar data; - i += font.GetCharacterData(text, i, out texture, out data) - 1; + i += font.GetCharacterData(text, i, out Texture texture, out OpenGlFontChar data) - 1; if (renderer.currentHost.LoadTexture(ref texture, OpenGlTextureWrapMode.ClampClamp)) { @@ -205,9 +201,7 @@ private void DrawWithShader(string text, OpenGlFont font, double left, double to for (int i = 0; i < text.Length; i++) { - Texture texture; - OpenGlFontChar data; - i += font.GetCharacterData(text, i, out texture, out data) - 1; + i += font.GetCharacterData(text, i, out Texture texture, out OpenGlFontChar data) - 1; if (renderer.currentHost.LoadTexture(ref texture, OpenGlTextureWrapMode.ClampClamp)) { GL.BindTexture(TextureTarget.Texture2D, texture.OpenGlTextures[(int)OpenGlTextureWrapMode.ClampClamp].Name); diff --git a/source/ObjectViewer/Hosts.cs b/source/ObjectViewer/Hosts.cs index 5cb58dda7..a21f01a44 100644 --- a/source/ObjectViewer/Hosts.cs +++ b/source/ObjectViewer/Hosts.cs @@ -148,8 +148,7 @@ public override bool LoadTexture(ref Texture Texture, OpenGlTextureWrapMode wrap public override bool RegisterTexture(string path, TextureParameters parameters, out Texture handle, bool loadTexture = false) { if (File.Exists(path) || Directory.Exists(path)) { - Texture data; - if (Program.Renderer.TextureManager.RegisterTexture(path, parameters, out data)) { + if (Program.Renderer.TextureManager.RegisterTexture(path, parameters, out Texture data)) { handle = data; if (loadTexture) { @@ -257,8 +256,7 @@ public override bool LoadObject(string path, System.Text.Encoding Encoding, out if (Program.CurrentHost.Plugins[i].Object.CanLoadObject(path)) { try { - UnifiedObject obj; - if (Program.CurrentHost.Plugins[i].Object.LoadObject(path, Encoding, out obj)) { + if (Program.CurrentHost.Plugins[i].Object.LoadObject(path, Encoding, out UnifiedObject obj)) { if (obj == null) { continue; diff --git a/source/ObjectViewer/Options.cs b/source/ObjectViewer/Options.cs index 7814ab692..690e58a74 100644 --- a/source/ObjectViewer/Options.cs +++ b/source/ObjectViewer/Options.cs @@ -74,8 +74,7 @@ internal static void LoadOptions() { case "windowwidth": { - int a; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out a) || a < 300) + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int a) || a < 300) { a = 960; } @@ -83,8 +82,7 @@ internal static void LoadOptions() } break; case "windowheight": { - int a; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out a) || a < 300) + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int a) || a < 300) { a = 600; } @@ -111,14 +109,12 @@ internal static void LoadOptions() } break; case "anisotropicfilteringlevel": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.AnisotropicFilteringLevel = a; } break; case "antialiasinglevel": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.AntiAliasingLevel = a; } break; case "transparencymode": @@ -128,8 +124,7 @@ internal static void LoadOptions() case "smooth": Interface.CurrentOptions.TransparencyMode = TransparencyMode.Quality; break; default: { - int a; - if (int.TryParse(Value, NumberStyles.Integer, Culture, out a)) + if (int.TryParse(Value, NumberStyles.Integer, Culture, out int a)) { Interface.CurrentOptions.TransparencyMode = (TransparencyMode)a; } @@ -169,8 +164,7 @@ internal static void LoadOptions() { case "mode": { - ObjectOptimizationMode mode; - if (Enum.TryParse(Value, out mode)) + if (Enum.TryParse(Value, out ObjectOptimizationMode mode)) { Interface.CurrentOptions.ObjectOptimizationMode = mode; } diff --git a/source/ObjectViewer/ProgramS.cs b/source/ObjectViewer/ProgramS.cs index 1a9a674c2..a103b96f4 100644 --- a/source/ObjectViewer/ProgramS.cs +++ b/source/ObjectViewer/ProgramS.cs @@ -83,8 +83,7 @@ internal static void Main(string[] args) Renderer.Screen.Width = 960; Renderer.Screen.Height = 600; } - string error; - if (!CurrentHost.LoadPlugins(FileSystem, Interface.CurrentOptions, out error, TrainManager, Renderer)) + if (!CurrentHost.LoadPlugins(FileSystem, Interface.CurrentOptions, out string error, TrainManager, Renderer)) { MessageBox.Show(error, @"OpenBVE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; diff --git a/source/OpenBveApi/Interface/Input/Commands.CommandInfo.cs b/source/OpenBveApi/Interface/Input/Commands.CommandInfo.cs index 33c5b00b4..5897e2722 100644 --- a/source/OpenBveApi/Interface/Input/Commands.CommandInfo.cs +++ b/source/OpenBveApi/Interface/Input/Commands.CommandInfo.cs @@ -77,9 +77,8 @@ internal CommandInfo(Command Command, CommandType Type, string Name, bool Enable /// This ignores the translated command description public override bool Equals(object obj) { - if (obj is CommandInfo) + if (obj is CommandInfo newCommandInfo) { - CommandInfo newCommandInfo = (CommandInfo) obj; return newCommandInfo.Equals(this); } return false; diff --git a/source/OpenBveApi/Interface/Translations/LanguageFile.cs b/source/OpenBveApi/Interface/Translations/LanguageFile.cs index d04377366..54ff602b1 100644 --- a/source/OpenBveApi/Interface/Translations/LanguageFile.cs +++ b/source/OpenBveApi/Interface/Translations/LanguageFile.cs @@ -87,8 +87,7 @@ public static bool SelectedLanguage(string FlagFolder, ref string CurrentLanguag int i = comboboxLanguages.SelectedIndex; if (i != -1) { - Language l = comboboxLanguages.Items[i] as Language; - if (l == null) + if (!(comboboxLanguages.Items[i] is Language l)) { return false; } @@ -118,8 +117,7 @@ public static bool SelectedLanguage(ref string CurrentLanguageCodeArgument, Comb int i = comboboxLanguages.SelectedIndex; if (i != -1) { - Language l = comboboxLanguages.Items[i] as Language; - if (l == null) + if (!(comboboxLanguages.Items[i] is Language l)) { return false; } diff --git a/source/OpenBveApi/Math/Quaternion.cs b/source/OpenBveApi/Math/Quaternion.cs index d8cf38501..69d72d3ad 100644 --- a/source/OpenBveApi/Math/Quaternion.cs +++ b/source/OpenBveApi/Math/Quaternion.cs @@ -268,10 +268,10 @@ public static void Multiply(ref Quaternion left, ref Quaternion right, out Quate /// The scalar public void Multiply(double scalar) { - W = W * scalar; - X = X * scalar; - Y = Y * scalar; - Z = Z * scalar; + W *= scalar; + X *= scalar; + Y *= scalar; + Z *= scalar; } /// diff --git a/source/OpenBveApi/Routes/QuadTree/QuadNode.Leaf.cs b/source/OpenBveApi/Routes/QuadTree/QuadNode.Leaf.cs index 92f226dba..3a46adaee 100644 --- a/source/OpenBveApi/Routes/QuadTree/QuadNode.Leaf.cs +++ b/source/OpenBveApi/Routes/QuadTree/QuadNode.Leaf.cs @@ -145,9 +145,9 @@ private void CreateVisibilityList(QuadNode node, List CreateVisibilityList(intern.Children[i], nodes, viewingDistance); } } - else if (node is QuadTreePopulatedLeafNode) + else if (node is QuadTreePopulatedLeafNode leafNode) { - nodes.Add((QuadTreePopulatedLeafNode)node); + nodes.Add(leafNode); } } } diff --git a/source/Plugins/Object.LokSim/GroupParser.cs b/source/Plugins/Object.LokSim/GroupParser.cs index a5565ce42..f693bdb37 100644 --- a/source/Plugins/Object.LokSim/GroupParser.cs +++ b/source/Plugins/Object.LokSim/GroupParser.cs @@ -192,8 +192,7 @@ internal static AnimatedObjectCollection ReadObject(string FileName, System.Text //Defines when the object should be shown try { - string func; - if (GetAnimatedFunction(attribute.Value, false, out func)) + if (GetAnimatedFunction(attribute.Value, false, out string func)) { Object.FunctionScript = FunctionScriptNotation.GetPostfixNotationFromInfixNotation(func); } @@ -209,8 +208,7 @@ internal static AnimatedObjectCollection ReadObject(string FileName, System.Text //Defines when the object should be hidden try { - string func; - if (GetAnimatedFunction(attribute.Value, false, out func)) + if (GetAnimatedFunction(attribute.Value, false, out string func)) { Object.FunctionScript = FunctionScriptNotation.GetPostfixNotationFromInfixNotation(func); } diff --git a/source/Plugins/Object.LokSim/ObjectParser.cs b/source/Plugins/Object.LokSim/ObjectParser.cs index 9ffcb4495..5c8941388 100644 --- a/source/Plugins/Object.LokSim/ObjectParser.cs +++ b/source/Plugins/Object.LokSim/ObjectParser.cs @@ -33,7 +33,6 @@ using OpenBveApi.Colors; using OpenBveApi.Math; using System.Linq; -using System.Text; using OpenBveApi.Interface; using OpenBveApi.Objects; @@ -296,8 +295,7 @@ internal static StaticObject ReadObject(string FileName, Vector3 Rotation) for (int j = 0; j < Verticies.Length; j++) { //This is the position of the vertex in the temp array - int currentVertex; - if (!int.TryParse(Verticies[j], out currentVertex)) + if (!int.TryParse(Verticies[j], out int currentVertex)) { Plugin.currentHost.AddMessage(MessageType.Error, false, Verticies[j] + " does not parse to a valid Vertex in " + node.Name + " in Loksim3D object file " + FileName); continue; @@ -315,15 +313,13 @@ internal static StaticObject ReadObject(string FileName, Vector3 Rotation) { string[] TextureCoords = childNode.Attributes["Texture"].Value.Split(';'); Vector2 currentCoords; - float OpenBVEWidth; - float OpenBVEHeight; string[] splitCoords = TextureCoords[j].Split(','); - if (!float.TryParse(splitCoords[0], out OpenBVEWidth)) + if (!float.TryParse(splitCoords[0], out float OpenBVEWidth)) { Plugin.currentHost.AddMessage(MessageType.Error, false, "Invalid texture width specified in " + node.Name + " in Loksim3D object file " + FileName); continue; } - if (!float.TryParse(splitCoords[1], out OpenBVEHeight)) + if (!float.TryParse(splitCoords[1], out float OpenBVEHeight)) { Plugin.currentHost.AddMessage(MessageType.Error, false, "Invalid texture height specified in " + node.Name + " in Loksim3D object file " + FileName); continue; diff --git a/source/Plugins/Object.Msts/ShapeParser.cs b/source/Plugins/Object.Msts/ShapeParser.cs index 0f4bdc2cc..d2de2c960 100644 --- a/source/Plugins/Object.Msts/ShapeParser.cs +++ b/source/Plugins/Object.Msts/ShapeParser.cs @@ -289,8 +289,7 @@ internal void Apply(out StaticObject Object) Object.Mesh.Materials[mm + i].BlendMode = MeshMaterialBlendMode.Normal; if (materials[i].DaytimeTexture != null) { - OpenBveApi.Textures.Texture tday; - Plugin.currentHost.RegisterTexture(materials[i].DaytimeTexture, new TextureParameters(null, null), out tday); + Plugin.currentHost.RegisterTexture(materials[i].DaytimeTexture, new TextureParameters(null, null), out OpenBveApi.Textures.Texture tday); Object.Mesh.Materials[mm + i].DaytimeTexture = tday; } else diff --git a/source/Plugins/Route.CsvRw/CsvRwRouteParser.PreprocessOptions.cs b/source/Plugins/Route.CsvRw/CsvRwRouteParser.PreprocessOptions.cs index 1ce626376..7c9110bb0 100644 --- a/source/Plugins/Route.CsvRw/CsvRwRouteParser.PreprocessOptions.cs +++ b/source/Plugins/Route.CsvRw/CsvRwRouteParser.PreprocessOptions.cs @@ -38,12 +38,10 @@ private void PreprocessOptions(Expression[] Expressions, ref RouteData Data, ref { Expressions[j].ConvertRwToCsv(Section, SectionAlwaysPrefix); // separate command and arguments - string Command, ArgumentSequence; - Expressions[j].SeparateCommandsAndArguments(out Command, out ArgumentSequence, Culture, true, IsRW, Section); + Expressions[j].SeparateCommandsAndArguments(out string Command, out string ArgumentSequence, Culture, true, IsRW, Section); // process command - double Number; bool NumberCheck = !IsRW || string.Compare(Section, "track", StringComparison.OrdinalIgnoreCase) == 0; - if (!NumberCheck || !NumberFormats.TryParseDoubleVb6(Command, UnitOfLength, out Number)) + if (!NumberCheck || !NumberFormats.TryParseDoubleVb6(Command, UnitOfLength, out _)) { // split arguments string[] Arguments; @@ -119,24 +117,22 @@ private void PreprocessOptions(Expression[] Expressions, ref RouteData Data, ref string Indices = Command.Substring(k + 1, Command.Length - k - 2).TrimStart(); Command = Command.Substring(0, k).TrimEnd(); int h = Indices.IndexOf(";", StringComparison.Ordinal); - int CommandIndex1; if (h >= 0) { string a = Indices.Substring(0, h).TrimEnd(); string b = Indices.Substring(h + 1).TrimStart(); - if (a.Length > 0 && !NumberFormats.TryParseIntVb6(a, out CommandIndex1)) + if (a.Length > 0 && !NumberFormats.TryParseIntVb6(a, out _)) { Command = null; break; } - int CommandIndex2; - if (b.Length > 0 && !NumberFormats.TryParseIntVb6(b, out CommandIndex2)) + if (b.Length > 0 && !NumberFormats.TryParseIntVb6(b, out _)) { Command = null; } } else { - if (Indices.Length > 0 && !NumberFormats.TryParseIntVb6(Indices, out CommandIndex1)) + if (Indices.Length > 0 && !NumberFormats.TryParseIntVb6(Indices, out _)) { Command = null; } diff --git a/source/Plugins/Route.CsvRw/CsvRwRouteParser.cs b/source/Plugins/Route.CsvRw/CsvRwRouteParser.cs index e4039aebe..7f1671b1e 100644 --- a/source/Plugins/Route.CsvRw/CsvRwRouteParser.cs +++ b/source/Plugins/Route.CsvRw/CsvRwRouteParser.cs @@ -157,8 +157,7 @@ internal void ParseRoute(string FileName, bool isRW, System.Text.Encoding Encodi private void ParseRouteForData(string FileName, System.Text.Encoding Encoding, ref RouteData Data, bool PreviewOnly) { //Read the entire routefile into memory List Lines = System.IO.File.ReadAllLines(FileName, Encoding).ToList(); - Expression[] Expressions; - PreprocessSplitIntoExpressions(FileName, Lines, out Expressions, true); + PreprocessSplitIntoExpressions(FileName, Lines, out Expression[] Expressions, true); PreprocessChrRndSub(FileName, Encoding, ref Expressions); double[] UnitOfLength = new double[] { 1.0 }; //Set units of speed initially to km/h @@ -233,8 +232,7 @@ private void ParseRouteForData(string FileName, System.Text.Encoding Encoding, E } // separate command and arguments - string Command, ArgumentSequence; - Expressions[j].SeparateCommandsAndArguments(out Command, out ArgumentSequence, Culture, false, IsRW, Section); + Expressions[j].SeparateCommandsAndArguments(out string Command, out string ArgumentSequence, Culture, false, IsRW, Section); // process command bool NumberCheck = !IsRW || string.Compare(Section, "track", StringComparison.OrdinalIgnoreCase) == 0; if (NumberCheck && NumberFormats.IsValidDouble(Command, UnitOfLength)) { @@ -436,12 +434,10 @@ private void ParseRouteForData(string FileName, System.Text.Encoding Encoding, E Expressions[j].ConvertRwToCsv(Section, SectionAlwaysPrefix); } // separate command and arguments - string Command, ArgumentSequence; - Expressions[j].SeparateCommandsAndArguments(out Command, out ArgumentSequence, Culture, false, IsRW, Section); + Expressions[j].SeparateCommandsAndArguments(out string Command, out string ArgumentSequence, Culture, false, IsRW, Section); // process command - double currentTrackPosition; bool NumberCheck = !IsRW || string.Compare(Section, "track", StringComparison.OrdinalIgnoreCase) == 0; - if (NumberCheck && NumberFormats.TryParseDouble(Command, UnitOfLength, out currentTrackPosition)) { + if (NumberCheck && NumberFormats.TryParseDouble(Command, UnitOfLength, out double currentTrackPosition)) { // track position if (ArgumentSequence.Length != 0) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "A track position must not contain any arguments at line " + Expressions[j].Line.ToString(Culture) + ", column " + Expressions[j].Column.ToString(Culture) + " in file " + Expressions[j].File); diff --git a/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Options.cs b/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Options.cs index 703fc81a4..0e30b1e8d 100644 --- a/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Options.cs +++ b/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Options.cs @@ -76,8 +76,7 @@ private void ParseOptionCommand(OptionsCommand Command, string[] Arguments, doub } else { - int a; - if (!NumberFormats.TryParseIntVb6(Arguments[0], out a)) + if (!NumberFormats.TryParseIntVb6(Arguments[0], out int a)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Mode is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -103,8 +102,7 @@ private void ParseOptionCommand(OptionsCommand Command, string[] Arguments, doub } else { - int a; - if (!NumberFormats.TryParseIntVb6(Arguments[0], out a)) + if (!NumberFormats.TryParseIntVb6(Arguments[0], out int a)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Mode is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -126,8 +124,7 @@ private void ParseOptionCommand(OptionsCommand Command, string[] Arguments, doub } else { - int a; - if (!NumberFormats.TryParseIntVb6(Arguments[0], out a)) + if (!NumberFormats.TryParseIntVb6(Arguments[0], out int a)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Mode is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -149,8 +146,7 @@ private void ParseOptionCommand(OptionsCommand Command, string[] Arguments, doub } else { - int a; - if (!NumberFormats.TryParseIntVb6(Arguments[0], out a)) + if (!NumberFormats.TryParseIntVb6(Arguments[0], out int a)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Mode is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -171,8 +167,7 @@ private void ParseOptionCommand(OptionsCommand Command, string[] Arguments, doub } else { - int a; - if (!NumberFormats.TryParseIntVb6(Arguments[0], out a)) + if (!NumberFormats.TryParseIntVb6(Arguments[0], out int a)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Mode is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -193,8 +188,7 @@ private void ParseOptionCommand(OptionsCommand Command, string[] Arguments, doub } else { - int a; - if (!NumberFormats.TryParseIntVb6(Arguments[0], out a)) + if (!NumberFormats.TryParseIntVb6(Arguments[0], out int a)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Mode is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } diff --git a/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Route.cs b/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Route.cs index b0b71b853..b8a7a69a3 100644 --- a/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Route.cs +++ b/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Route.cs @@ -89,8 +89,7 @@ private void ParseRouteCommand(RouteCommand Command, string[] Arguments, int Ind } else { - double a; - if (!NumberFormats.TryParseDoubleVb6(Arguments[0], out a)) + if (!NumberFormats.TryParseDoubleVb6(Arguments[0], out double a)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "ValueInMillimeters is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -117,8 +116,7 @@ private void ParseRouteCommand(RouteCommand Command, string[] Arguments, int Ind } else { - double a; - if (!NumberFormats.TryParseDoubleVb6(Arguments[0], out a)) + if (!NumberFormats.TryParseDoubleVb6(Arguments[0], out double a)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Speed is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -157,8 +155,7 @@ private void ParseRouteCommand(RouteCommand Command, string[] Arguments, int Ind } else { - double a; - if (!NumberFormats.TryParseDoubleVb6(Arguments[0], out a)) + if (!NumberFormats.TryParseDoubleVb6(Arguments[0], out double a)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Value is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -179,8 +176,7 @@ private void ParseRouteCommand(RouteCommand Command, string[] Arguments, int Ind } else { - double t; - if (!TryParseTime(Arguments[0], out t)) + if (!TryParseTime(Arguments[0], out double t)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, Arguments[0] + " does not parse to a valid time in command " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -270,8 +266,7 @@ private void ParseRouteCommand(RouteCommand Command, string[] Arguments, int Ind } else { - double a; - if (!NumberFormats.TryParseDoubleVb6(Arguments[0], UnitOfLength, out a)) + if (!NumberFormats.TryParseDoubleVb6(Arguments[0], UnitOfLength, out double a)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Height is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -288,8 +283,7 @@ private void ParseRouteCommand(RouteCommand Command, string[] Arguments, int Ind } else { - double a; - if (!NumberFormats.TryParseDoubleVb6(Arguments[0], out a)) + if (!NumberFormats.TryParseDoubleVb6(Arguments[0], out double a)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "ValueInCelsius is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -314,8 +308,7 @@ private void ParseRouteCommand(RouteCommand Command, string[] Arguments, int Ind } else { - double a; - if (!NumberFormats.TryParseDoubleVb6(Arguments[0], out a)) + if (!NumberFormats.TryParseDoubleVb6(Arguments[0], out double a)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "ValueInKPa is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -475,8 +468,7 @@ private void ParseRouteCommand(RouteCommand Command, string[] Arguments, int Ind } else { - int cv; - if (!NumberFormats.TryParseIntVb6(Arguments[0], out cv)) + if (!NumberFormats.TryParseIntVb6(Arguments[0], out int cv)) { switch (Arguments[0].ToLowerInvariant()) { diff --git a/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Signal.cs b/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Signal.cs index f4f305f1b..b1ff51126 100644 --- a/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Signal.cs +++ b/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Signal.cs @@ -43,8 +43,7 @@ private void ParseSignalCommand(string Command, string[] Arguments, int Index, E } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj is AnimatedObjectCollection) { AnimatedObjectSignalData Signal = new AnimatedObjectSignalData(obj); diff --git a/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Structure.cs b/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Structure.cs index 4062a6924..b3746be01 100644 --- a/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Structure.cs +++ b/source/Plugins/Route.CsvRw/Namespaces/NonTrack/Structure.cs @@ -18,7 +18,6 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, { case StructureCommand.Rail: { - if (commandIndices[0] < 0) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "RailStructureIndex is expected to be non-negative in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); @@ -45,8 +44,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, { if (!PreviewOnly) { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.RailObjects.Add(commandIndices[0], obj, "RailStructure"); @@ -89,8 +87,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.Beacon.Add(commandIndices[0], obj, "BeaconStructure"); @@ -138,8 +135,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); bool overwriteDefault = commandIndices[1] >= 0 && commandIndices[1] >= 3; Data.Structure.Poles[commandIndices[0]].Add(commandIndices[1], obj, overwriteDefault); } @@ -175,8 +171,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.Ground.Add(commandIndices[0], obj, "GroundStructure"); @@ -214,8 +209,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.WallL.Add(commandIndices[0], obj, "Left WallStructure"); @@ -253,8 +247,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.WallR.Add(commandIndices[0], obj, "Right WallStructure"); @@ -292,8 +285,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.DikeL.Add(commandIndices[0], obj, "Left DikeStructure"); @@ -331,8 +323,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.DikeR.Add(commandIndices[0], obj, "Right DikeStructure"); @@ -370,8 +361,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.FormL.Add(commandIndices[0], obj, "Left FormStructure"); @@ -409,8 +399,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.FormR.Add(commandIndices[0], obj, "Right FormStructure"); @@ -448,8 +437,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - StaticObject obj; - Plugin.CurrentHost.LoadStaticObject(f, Encoding, false, out obj); + Plugin.CurrentHost.LoadStaticObject(f, Encoding, false, out StaticObject obj); if (obj != null) { Data.Structure.FormCL.Add(commandIndices[0], obj, "Left FormCStructure"); @@ -487,8 +475,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - StaticObject obj; - Plugin.CurrentHost.LoadStaticObject(f, Encoding, false, out obj); + Plugin.CurrentHost.LoadStaticObject(f, Encoding, false, out StaticObject obj); if (obj != null) { Data.Structure.FormCR.Add(commandIndices[0], obj, "Right FormCStructure"); @@ -550,8 +537,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.RoofL.Add(commandIndices[0], obj, "Left RoofStructure"); @@ -606,8 +592,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.RoofR.Add(commandIndices[0], obj, "Right RoofStructure"); @@ -662,8 +647,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - StaticObject obj; - Plugin.CurrentHost.LoadStaticObject(f, Encoding, false, out obj); + Plugin.CurrentHost.LoadStaticObject(f, Encoding, false, out StaticObject obj); if (obj != null) { Data.Structure.RoofCL.Add(commandIndices[0], obj, "Left RoofCStructure"); @@ -718,8 +702,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - StaticObject obj; - Plugin.CurrentHost.LoadStaticObject(f, Encoding, false, out obj); + Plugin.CurrentHost.LoadStaticObject(f, Encoding, false, out StaticObject obj); if (obj != null) { Data.Structure.RoofCR.Add(commandIndices[0], obj, "Right RoofCStructure"); @@ -758,8 +741,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - StaticObject obj; - Plugin.CurrentHost.LoadStaticObject(f, Encoding, true, out obj); + Plugin.CurrentHost.LoadStaticObject(f, Encoding, true, out StaticObject obj); if (obj != null) { Data.Structure.CrackL.Add(commandIndices[0], obj, "Left CrackStructure"); @@ -797,8 +779,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - StaticObject obj; - Plugin.CurrentHost.LoadStaticObject(f, Encoding, true, out obj); + Plugin.CurrentHost.LoadStaticObject(f, Encoding, true, out StaticObject obj); if (obj != null) { Data.Structure.CrackR.Add(commandIndices[0], obj, "Right CrackStructure"); @@ -843,8 +824,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, { if (!PreviewOnly) { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.FreeObjects.Add(commandIndices[0], obj, "FreeObject"); @@ -957,8 +937,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, Data.Backgrounds.Add(commandIndices[0], new StaticBackground(null, 6, false, Plugin.CurrentOptions.ViewingDistance)); } - int x; - if (!NumberFormats.TryParseIntVb6(Arguments[0], out x)) + if (!NumberFormats.TryParseIntVb6(Arguments[0], out int x)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "BackgroundTextureIndex " + Arguments[0] + " is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -997,8 +976,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, Data.Backgrounds.Add(commandIndices[0], new StaticBackground(null, 6, false, Plugin.CurrentOptions.ViewingDistance)); } - int aspect; - if (!NumberFormats.TryParseIntVb6(Arguments[0], out aspect)) + if (!NumberFormats.TryParseIntVb6(Arguments[0], out int aspect)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "BackgroundTextureIndex " + Arguments[0] + " is invalid in " + Command + " at line " + Expression.Line.ToString(Culture) + ", column " + Expression.Column.ToString(Culture) + " in file " + Expression.File); } @@ -1045,8 +1023,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } else { - UnifiedObject obj; - Plugin.CurrentHost.LoadObject(f, Encoding, out obj); + Plugin.CurrentHost.LoadObject(f, Encoding, out UnifiedObject obj); if (obj != null) { Data.Structure.WeatherObjects.Add(commandIndices[0], obj, "RainStructure"); @@ -1076,8 +1053,7 @@ private void ParseStructureCommand(StructureCommand Command, string[] Arguments, } if (File.Exists(path)) { - LightDefinition[] newLightDefinition; - if (DynamicLightParser.ReadLightingXML(path, out newLightDefinition)) + if (DynamicLightParser.ReadLightingXML(path, out LightDefinition[] newLightDefinition)) { if (Data.Structure.LightDefinitions.ContainsKey(commandIndices[0])) { diff --git a/source/RouteViewer/Audio/Sounds.Update.cs b/source/RouteViewer/Audio/Sounds.Update.cs index 4ebadfdf4..aec301193 100644 --- a/source/RouteViewer/Audio/Sounds.Update.cs +++ b/source/RouteViewer/Audio/Sounds.Update.cs @@ -104,8 +104,7 @@ protected override void UpdateInverseModel(double timeElapsed) * The sound is to be played or is already playing. * */ if (Sources[i].State == SoundSourceState.Playing) { - int state; - AL.GetSource(Sources[i].OpenAlSourceName, ALGetSourcei.SourceState, out state); + AL.GetSource(Sources[i].OpenAlSourceName, ALGetSourcei.SourceState, out int state); if (state != (int)ALSourceState.Initial & state != (int)ALSourceState.Playing) { /* * The sound is not playing any longer. diff --git a/source/RouteViewer/NewRendererR.cs b/source/RouteViewer/NewRendererR.cs index e2b25134e..e4bf4015b 100644 --- a/source/RouteViewer/NewRendererR.cs +++ b/source/RouteViewer/NewRendererR.cs @@ -610,9 +610,7 @@ private void RenderOverlays() { OpenGlString.Draw(Fonts.SmallFont, "Jump to track position:", new Vector2(4, 80), TextAlignment.TopLeft, Color128.White, true); - double distance; - - if (double.TryParse(Program.JumpToPositionValue, out distance)) + if (double.TryParse(Program.JumpToPositionValue, out double distance)) { if (distance < Program.MinimumJumpToPositionValue - 100) { diff --git a/source/RouteViewer/Options.cs b/source/RouteViewer/Options.cs index 26c3eec02..76bd9cdfb 100644 --- a/source/RouteViewer/Options.cs +++ b/source/RouteViewer/Options.cs @@ -71,16 +71,14 @@ internal static void LoadOptions() break; case "windowwidth": { - int a; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out a) || a < 300) { + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int a) || a < 300) { a = 960; } Interface.CurrentOptions.WindowWidth = a; } break; case "windowheight": { - int a; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out a) || a < 300) { + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int a) || a < 300) { a = 600; } Interface.CurrentOptions.WindowHeight = a; @@ -90,16 +88,14 @@ internal static void LoadOptions() break; case "viewingdistance": { - int a; - if (!int.TryParse(Value, NumberStyles.Integer, Culture, out a) || a < 300) { + if (!int.TryParse(Value, NumberStyles.Integer, Culture, out int a) || a < 300) { a = 600; } Interface.CurrentOptions.ViewingDistance = a; } break; case "quadleafsize": { - int a; - if (int.TryParse(Value, NumberStyles.Integer, Culture, out a)) + if (int.TryParse(Value, NumberStyles.Integer, Culture, out int a)) { if (a >= 50 && a <= 500) { @@ -123,14 +119,12 @@ internal static void LoadOptions() } break; case "anisotropicfilteringlevel": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.AnisotropicFilteringLevel = a; } break; case "antialiasinglevel": { - int a; - int.TryParse(Value, NumberStyles.Integer, Culture, out a); + int.TryParse(Value, NumberStyles.Integer, Culture, out int a); Interface.CurrentOptions.AntiAliasingLevel = a; } break; case "transparencymode": @@ -138,8 +132,7 @@ internal static void LoadOptions() case "sharp": Interface.CurrentOptions.TransparencyMode = TransparencyMode.Performance; break; case "smooth": Interface.CurrentOptions.TransparencyMode = TransparencyMode.Quality; break; default: { - int a; - if (int.TryParse(Value, NumberStyles.Integer, Culture, out a)) { + if (int.TryParse(Value, NumberStyles.Integer, Culture, out int a)) { Interface.CurrentOptions.TransparencyMode = (TransparencyMode)a; } else { Interface.CurrentOptions.TransparencyMode = TransparencyMode.Quality; diff --git a/source/RouteViewer/ProgramR.cs b/source/RouteViewer/ProgramR.cs index 79afda424..342fe9bbf 100644 --- a/source/RouteViewer/ProgramR.cs +++ b/source/RouteViewer/ProgramR.cs @@ -79,8 +79,7 @@ internal static void Main(string[] args) Renderer = new NewRenderer(CurrentHost, Interface.CurrentOptions, FileSystem); CurrentRoute = new CurrentRoute(CurrentHost, Renderer); TrainManager = new TrainManager(CurrentHost, Renderer, Interface.CurrentOptions, FileSystem); - string error; - if (!CurrentHost.LoadPlugins(FileSystem, Interface.CurrentOptions, out error, TrainManager, Renderer)) + if (!CurrentHost.LoadPlugins(FileSystem, Interface.CurrentOptions, out string error, TrainManager, Renderer)) { MessageBox.Show(error, @"OpenBVE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -679,8 +678,7 @@ internal static void keyDownEvent(object sender, KeyboardKeyEventArgs e) { direction = 0; } - double value; - if (double.TryParse(JumpToPositionValue, NumberStyles.Float, CultureInfo.InvariantCulture,out value)) + if (double.TryParse(JumpToPositionValue, NumberStyles.Float, CultureInfo.InvariantCulture, out double value)) { if (value < CurrentRoute.Tracks[0].Elements[CurrentRoute.Tracks[0].Elements.Length - 1].StartingTrackPosition + 100 && value > MinimumJumpToPositionValue - 100) { diff --git a/source/RouteViewer/System/Host.cs b/source/RouteViewer/System/Host.cs index 6e4442121..bd9358988 100644 --- a/source/RouteViewer/System/Host.cs +++ b/source/RouteViewer/System/Host.cs @@ -179,8 +179,7 @@ public override bool LoadTexture(ref Texture Texture, OpenGlTextureWrapMode wrap public override bool RegisterTexture(string path, TextureParameters parameters, out Texture handle, bool loadTexture = false) { if (File.Exists(path) || Directory.Exists(path)) { - Texture data; - if (Program.Renderer.TextureManager.RegisterTexture(path, parameters, out data)) { + if (Program.Renderer.TextureManager.RegisterTexture(path, parameters, out Texture data)) { handle = data; if (loadTexture) { @@ -314,8 +313,7 @@ public override bool LoadStaticObject(string path, System.Text.Encoding Encoding try { if (Program.CurrentHost.Plugins[i].Object.CanLoadObject(path)) { try { - UnifiedObject unifiedObject; - if (Program.CurrentHost.Plugins[i].Object.LoadObject(path, Encoding, out unifiedObject)) { + if (Program.CurrentHost.Plugins[i].Object.LoadObject(path, Encoding, out UnifiedObject unifiedObject)) { if (unifiedObject is StaticObject staticObject) { staticObject.OptimizeObject(PreserveVertices, Interface.CurrentOptions.ObjectOptimizationBasicThreshold, true); @@ -359,8 +357,7 @@ public override bool LoadObject(string path, System.Text.Encoding Encoding, out if (Program.CurrentHost.Plugins[i].Object.CanLoadObject(path)) { try { - UnifiedObject obj; - if (Program.CurrentHost.Plugins[i].Object.LoadObject(path, Encoding, out obj)) { + if (Program.CurrentHost.Plugins[i].Object.LoadObject(path, Encoding, out UnifiedObject obj)) { if (obj == null) { continue; diff --git a/source/TrainEditor2/Audio/SoundApi.Update.cs b/source/TrainEditor2/Audio/SoundApi.Update.cs index c93e7ac55..31ee6d26b 100644 --- a/source/TrainEditor2/Audio/SoundApi.Update.cs +++ b/source/TrainEditor2/Audio/SoundApi.Update.cs @@ -85,8 +85,7 @@ protected override void UpdateInverseModel(double timeElapsed) * */ if (Sources[i].State == SoundSourceState.Playing) { - int state; - AL.GetSource(Sources[i].OpenAlSourceName, ALGetSourcei.SourceState, out state); + AL.GetSource(Sources[i].OpenAlSourceName, ALGetSourcei.SourceState, out int state); if (state != (int)ALSourceState.Initial & state != (int)ALSourceState.Playing) { /* From 79d370de02eb459bb877a27726826f72523bf40c Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Sun, 8 Oct 2023 10:41:59 +0100 Subject: [PATCH 15/16] Change: Move cursor support slightly to allow LibRender2 to set --- source/LibRender2/BaseRenderer.cs | 7 ++ source/LibRender2/Cursors/Cursor.cs | 79 ++++++++++++++++-- source/LibRender2/Primitives/GLControl.cs | 11 ++- source/LibRender2/Primitives/Textbox.cs | 28 ++++--- .../LibRender2/Trains/Panel/TouchElement.cs | 3 +- source/OpenBVE/Game/Menu/Menu.cs | 13 +-- source/OpenBVE/Graphics/NewRenderer.cs | 5 ++ source/OpenBVE/Graphics/Renderers/Touch.cs | 1 - source/OpenBVE/System/Cursor.cs | 81 ++----------------- source/OpenBVE/System/GameWindow.cs | 20 ++--- source/OpenBVE/System/Options.cs | 2 - source/OpenBVE/System/Program.cs | 2 +- source/OpenBveApi/System/BaseOptions.cs | 2 + .../Panel/PanelAnimatedXmlParser.cs | 2 +- .../Train.OpenBve/Panel/PanelXmlParser.cs | 2 +- 15 files changed, 136 insertions(+), 122 deletions(-) diff --git a/source/LibRender2/BaseRenderer.cs b/source/LibRender2/BaseRenderer.cs index c6db00fd1..069ea26a5 100644 --- a/source/LibRender2/BaseRenderer.cs +++ b/source/LibRender2/BaseRenderer.cs @@ -1663,5 +1663,12 @@ public void RenderFaceImmediateMode(ObjectState State, MeshFace Face, Matrix4D m GL.MatrixMode(MatrixMode.Projection); GL.PopMatrix(); } + + /// Sets the current MouseCursor + /// The new cursor + public virtual void SetCursor(OpenTK.MouseCursor newCursor) + { + + } } } diff --git a/source/LibRender2/Cursors/Cursor.cs b/source/LibRender2/Cursors/Cursor.cs index a58766865..84fb4e6ae 100644 --- a/source/LibRender2/Cursors/Cursor.cs +++ b/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 { @@ -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); @@ -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); @@ -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); @@ -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); @@ -89,4 +93,67 @@ public override string ToString() return FileName; } } + + public static class AvailableCursors + { + public static readonly List CursorList = new List(); + 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"; + } + } } diff --git a/source/LibRender2/Primitives/GLControl.cs b/source/LibRender2/Primitives/GLControl.cs index 098d6c94b..282e17eac 100644 --- a/source/LibRender2/Primitives/GLControl.cs +++ b/source/LibRender2/Primitives/GLControl.cs @@ -11,7 +11,7 @@ public abstract class GLControl internal readonly BaseRenderer Renderer; /// The background color for the control public Color128 BackgroundColor; - /// The texture for the picturebox + /// The texture for the control public Texture Texture; /// The stored location for the control public Vector2 Location; @@ -23,6 +23,15 @@ protected GLControl(BaseRenderer renderer) Renderer = renderer; } + /// Draws the control public abstract void Draw(); + + /// Passes a mouse move event to the control + /// The absolute screen X co-ordinate + /// The absolute screen Y co-ordinate + public virtual void MouseMove(int x, int y) + { + + } } } diff --git a/source/LibRender2/Primitives/Textbox.cs b/source/LibRender2/Primitives/Textbox.cs index ac32ac5d7..8ad056d19 100644 --- a/source/LibRender2/Primitives/Textbox.cs +++ b/source/LibRender2/Primitives/Textbox.cs @@ -4,7 +4,6 @@ using OpenBveApi.Colors; using OpenBveApi.Graphics; using OpenBveApi.Math; -using OpenBveApi.Textures; namespace LibRender2.Primitives { @@ -19,10 +18,7 @@ public class Textbox : GLControl /// The string contents of the textbox public string Text { - get - { - return myText; - } + get => myText; set { myText = value; @@ -42,13 +38,7 @@ public string Text /// Whether the textbox can scroll public bool CanScroll; /// Used for internal size calculations - private Vector2 internalSize - { - get - { - return CanScroll ? new Vector2(Size.X, Size.Y - 12) : Size; - } - } + private Vector2 internalSize => CanScroll ? new Vector2(Size.X, Size.Y - 12) : Size; private List WrappedLines(int width) { @@ -161,6 +151,18 @@ public override void Draw() } } - + 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; + Renderer.SetCursor(CanScroll ? AvailableCursors.ScrollCursor : OpenTK.MouseCursor.Default); + } + else + { + Renderer.SetCursor(OpenTK.MouseCursor.Default); + CurrentlySelected = false; + } + } } } diff --git a/source/LibRender2/Trains/Panel/TouchElement.cs b/source/LibRender2/Trains/Panel/TouchElement.cs index 8fbc12141..6db236f50 100644 --- a/source/LibRender2/Trains/Panel/TouchElement.cs +++ b/source/LibRender2/Trains/Panel/TouchElement.cs @@ -1,5 +1,4 @@ -using LibRender2.Cursors; -using OpenBveApi.Objects; +using OpenBveApi.Objects; namespace LibRender2.Trains { diff --git a/source/OpenBVE/Game/Menu/Menu.cs b/source/OpenBVE/Game/Menu/Menu.cs index cd8a3342b..b891e9333 100644 --- a/source/OpenBVE/Game/Menu/Menu.cs +++ b/source/OpenBVE/Game/Menu/Menu.cs @@ -181,7 +181,7 @@ public void PushMenu(MenuType type, int data = 0, bool replace = false) if (Program.Renderer.CurrentInterface < InterfaceType.Menu) { // Deliberately set to the standard cursor, as touch controls may have set to something else - Program.currentGameWindow.Cursor = MouseCursor.Default; + Program.Renderer.SetCursor(MouseCursor.Default); } if (!isInitialized) Init(); @@ -353,16 +353,7 @@ internal bool ProcessMouseMove(int x, int y) } if (menu.Type == MenuType.RouteList || menu.Type == MenuType.TrainList || menu.Type == MenuType.PackageInstall || menu.Type == MenuType.Packages || (int)menu.Type >= 107) { - if (x > routeDescriptionBox.Location.X && x < routeDescriptionBox.Location.X + routeDescriptionBox.Size.X && y > routeDescriptionBox.Location.Y && y < routeDescriptionBox.Location.Y + routeDescriptionBox.Size.Y) - { - routeDescriptionBox.CurrentlySelected = true; - Program.currentGameWindow.Cursor = routeDescriptionBox.CanScroll ? Cursors.ScrollCursor : MouseCursor.Default; - } - else - { - routeDescriptionBox.CurrentlySelected = false; - Program.currentGameWindow.Cursor = MouseCursor.Default; - } + routeDescriptionBox.MouseMove(x, y); //HACK: Use this to trigger our menu start button! if (x > Program.Renderer.Screen.Width - 200 && x < Program.Renderer.Screen.Width - 10 && y > Program.Renderer.Screen.Height - 40 && y < Program.Renderer.Screen.Height - 10) { diff --git a/source/OpenBVE/Graphics/NewRenderer.cs b/source/OpenBVE/Graphics/NewRenderer.cs index f6d53c706..f08a2c7ae 100644 --- a/source/OpenBVE/Graphics/NewRenderer.cs +++ b/source/OpenBVE/Graphics/NewRenderer.cs @@ -480,6 +480,11 @@ internal void RenderScene(double TimeElapsed, double RealTimeElapsed) OptionLighting = true; } + public override void SetCursor(OpenTK.MouseCursor newCursor) + { + Program.currentGameWindow.Cursor = newCursor; + } + public NewRenderer(HostInterface CurrentHost, BaseOptions CurrentOptions, FileSystem FileSystem) : base(CurrentHost, CurrentOptions, FileSystem) { } diff --git a/source/OpenBVE/Graphics/Renderers/Touch.cs b/source/OpenBVE/Graphics/Renderers/Touch.cs index b164a5756..83e3df07f 100644 --- a/source/OpenBVE/Graphics/Renderers/Touch.cs +++ b/source/OpenBVE/Graphics/Renderers/Touch.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using LibRender2; -using LibRender2.Cursors; using LibRender2.Trains; using OpenBveApi.Interface; using OpenBveApi.Math; diff --git a/source/OpenBVE/System/Cursor.cs b/source/OpenBVE/System/Cursor.cs index 21979bdef..b5e8d87ec 100644 --- a/source/OpenBVE/System/Cursor.cs +++ b/source/OpenBVE/System/Cursor.cs @@ -1,85 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Reflection; using System.Windows.Forms; -using OpenBveApi.Interface; -using OpenTK; +using LibRender2; namespace OpenBve { internal static class Cursors { - internal static readonly List CursorList = new List(); - internal static MouseCursor CurrentCursor; - internal static MouseCursor CurrentCursorPlus; - internal static MouseCursor CurrentCursorMinus; - internal static MouseCursor ScrollCursor; - - internal static void LoadCursorImages(string CursorFolder) - { - if (!Directory.Exists(CursorFolder)) - { - MessageBox.Show(@"The default cursor images have been moved or deleted.", Translations.GetInterfaceString("program_title"), MessageBoxButtons.OK, MessageBoxIcon.Warning); - 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); - LibRender2.Cursors.MouseCursor c = new LibRender2.Cursors.MouseCursor(Program.Renderer, Path.GetFileName(File), Image); - ScrollCursor = c.MyCursor; - } - else - { - Bitmap Image = new Bitmap(Fs); - CursorList.Add(new LibRender2.Cursors.MouseCursor(Program.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 LibRender2.Cursors.MouseCursor(Program.Renderer, "nk.png", Image)); - } - } - Interface.CurrentOptions.CursorFileName = "nk.png"; - } - internal static void ListCursors(ComboBox comboBoxCursor) { comboBoxCursor.Items.Clear(); //Load all available cursors int idx = -1; - for (int i = 0; i < CursorList.Count; i++) + for (int i = 0; i < LibRender2.AvailableCursors.CursorList.Count; i++) { - comboBoxCursor.Items.Add(CursorList[i]); - if (CursorList[i].FileName == Interface.CurrentOptions.CursorFileName) + comboBoxCursor.Items.Add(LibRender2.AvailableCursors.CursorList[i]); + if (LibRender2.AvailableCursors.CursorList[i].FileName == Interface.CurrentOptions.CursorFileName) { idx = i; } @@ -98,15 +33,15 @@ internal static void SelectedCursor(ComboBox comboboxCursor, PictureBox pictureb { return; } - LibRender2.Cursors.MouseCursor c = comboboxCursor.Items[i] as LibRender2.Cursors.MouseCursor; + MouseCursor c = comboboxCursor.Items[i] as MouseCursor; if (c == null) { return; } Interface.CurrentOptions.CursorFileName = c.FileName; - CurrentCursor = c.MyCursor; - CurrentCursorPlus = c.MyCursorPlus; - CurrentCursorMinus = c.MyCursorMinus; + LibRender2.AvailableCursors.CurrentCursor = c.MyCursor; + LibRender2.AvailableCursors.CurrentCursorPlus = c.MyCursorPlus; + LibRender2.AvailableCursors.CurrentCursorMinus = c.MyCursorMinus; pictureboxCursor.Image = c.Image; } } diff --git a/source/OpenBVE/System/GameWindow.cs b/source/OpenBVE/System/GameWindow.cs index ac6f28d4b..542cf1fb9 100644 --- a/source/OpenBVE/System/GameWindow.cs +++ b/source/OpenBVE/System/GameWindow.cs @@ -34,7 +34,7 @@ using Path = System.IO.Path; using Vector2 = OpenTK.Vector2; using Control = OpenBveApi.Interface.Control; -using MouseCursor = LibRender2.Cursors.MouseCursor; +using MouseCursor = LibRender2.MouseCursor; namespace OpenBve { @@ -514,36 +514,36 @@ protected override void OnMouseMove(MouseMoveEventArgs e) { switch (Status) { - case MouseCursor.Status.Default: - Cursor = newCursor.MyCursor; + case MouseCursor.Status.Default: + Program.Renderer.SetCursor(newCursor.MyCursor); break; case MouseCursor.Status.Plus: - Cursor = newCursor.MyCursorPlus; + Program.Renderer.SetCursor(newCursor.MyCursorPlus); break; case MouseCursor.Status.Minus: - Cursor = newCursor.MyCursorMinus; + Program.Renderer.SetCursor(newCursor.MyCursorMinus); break; } } - else if (Cursors.CurrentCursor != null) + else if (LibRender2.AvailableCursors.CurrentCursor != null) { switch (Status) { case MouseCursor.Status.Default: - Cursor = Cursors.CurrentCursor; + Program.Renderer.SetCursor(AvailableCursors.CurrentCursor); break; case MouseCursor.Status.Plus: - Cursor = Cursors.CurrentCursorPlus; + Program.Renderer.SetCursor(AvailableCursors.CurrentCursorPlus); break; case MouseCursor.Status.Minus: - Cursor = Cursors.CurrentCursorMinus; + Program.Renderer.SetCursor(AvailableCursors.CurrentCursorMinus); break; } } } else { - Cursor = OpenTK.MouseCursor.Default; + Program.Renderer.SetCursor(OpenTK.MouseCursor.Default); } } } diff --git a/source/OpenBVE/System/Options.cs b/source/OpenBVE/System/Options.cs index e49a0ae99..bc70573a7 100644 --- a/source/OpenBVE/System/Options.cs +++ b/source/OpenBVE/System/Options.cs @@ -81,8 +81,6 @@ internal class Options : BaseOptions /// The time in seconds after which the mouse cursor is hidden /// Set to zero to never hide the cursor internal double CursorHideDelay; - internal string CursorFileName; - /// Whether a screen reader is available /// Not saved, detected on game init internal bool ScreenReaderAvailable; diff --git a/source/OpenBVE/System/Program.cs b/source/OpenBVE/System/Program.cs index fd2e6aed0..219dbc8c6 100644 --- a/source/OpenBVE/System/Program.cs +++ b/source/OpenBVE/System/Program.cs @@ -152,7 +152,7 @@ private static void Main(string[] args) { Translations.LoadLanguageFiles(folder); folder = Program.FileSystem.GetDataFolder("Cursors"); - Cursors.LoadCursorImages(folder); + LibRender2.AvailableCursors.LoadCursorImages(Program.Renderer, folder); Interface.LoadControls(null, out Interface.CurrentControls); folder = Program.FileSystem.GetDataFolder("Controls"); diff --git a/source/OpenBveApi/System/BaseOptions.cs b/source/OpenBveApi/System/BaseOptions.cs index 2165848e6..32c2011df 100644 --- a/source/OpenBveApi/System/BaseOptions.cs +++ b/source/OpenBveApi/System/BaseOptions.cs @@ -99,5 +99,7 @@ public abstract class BaseOptions public ObjectDisposalMode ObjectDisposalMode; /// Uses the native Windows GDI+ decoders for PNG / JPG public bool UseGDIDecoders; + /// The filename of the current cursor + public string CursorFileName; } } diff --git a/source/Plugins/Train.OpenBve/Panel/PanelAnimatedXmlParser.cs b/source/Plugins/Train.OpenBve/Panel/PanelAnimatedXmlParser.cs index 19915cee4..850edd475 100644 --- a/source/Plugins/Train.OpenBve/Panel/PanelAnimatedXmlParser.cs +++ b/source/Plugins/Train.OpenBve/Panel/PanelAnimatedXmlParser.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Xml; using System.Xml.Linq; -using LibRender2.Cursors; +using LibRender2; using LibRender2.Trains; using OpenBveApi; using OpenBveApi.Colors; diff --git a/source/Plugins/Train.OpenBve/Panel/PanelXmlParser.cs b/source/Plugins/Train.OpenBve/Panel/PanelXmlParser.cs index 3f3580301..5e966fb0c 100644 --- a/source/Plugins/Train.OpenBve/Panel/PanelXmlParser.cs +++ b/source/Plugins/Train.OpenBve/Panel/PanelXmlParser.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Xml; using System.Xml.Linq; -using LibRender2.Cursors; +using LibRender2; using LibRender2.Trains; using OpenBveApi.Colors; using OpenBveApi.FunctionScripting; From 16350573f855f28cea63c759a41bc5ce915d144d Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Sun, 8 Oct 2023 10:51:27 +0100 Subject: [PATCH 16/16] Add highlighting to button on mouseover --- source/LibRender2/Primitives/Button.cs | 14 ++++++++++++++ source/LibRender2/Primitives/GLControl.cs | 2 ++ source/LibRender2/Primitives/Textbox.cs | 2 -- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/source/LibRender2/Primitives/Button.cs b/source/LibRender2/Primitives/Button.cs index 683b6cb36..3a9381fe9 100644 --- a/source/LibRender2/Primitives/Button.cs +++ b/source/LibRender2/Primitives/Button.cs @@ -8,6 +8,8 @@ public class Button : GLControl { /// The text displayed on the button public string Text; + /// The highlight color of the button + public Color128 HighlightColor; /// The color of the text on the button public Color128 TextColor; /// The font for the button @@ -20,7 +22,19 @@ 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; + } + } } } diff --git a/source/LibRender2/Primitives/GLControl.cs b/source/LibRender2/Primitives/GLControl.cs index 282e17eac..6fc1a900a 100644 --- a/source/LibRender2/Primitives/GLControl.cs +++ b/source/LibRender2/Primitives/GLControl.cs @@ -17,6 +17,8 @@ public abstract class GLControl public Vector2 Location; /// The stored size for the control public Vector2 Size; + /// Whether the control is currently selected by the mouse + public bool CurrentlySelected; protected GLControl(BaseRenderer renderer) { diff --git a/source/LibRender2/Primitives/Textbox.cs b/source/LibRender2/Primitives/Textbox.cs index 8ad056d19..1acf26b09 100644 --- a/source/LibRender2/Primitives/Textbox.cs +++ b/source/LibRender2/Primitives/Textbox.cs @@ -33,8 +33,6 @@ public string Text public readonly int Border; /// The top line to be renderered private int topLine; - /// Whether the textbox is currently selected by the mouse - public bool CurrentlySelected; /// Whether the textbox can scroll public bool CanScroll; /// Used for internal size calculations