diff --git a/Accurate-throttle-for-aircraft/Main.cs b/Accurate-throttle-for-aircraft/Main.cs deleted file mode 100644 index 3b314c4..0000000 --- a/Accurate-throttle-for-aircraft/Main.cs +++ /dev/null @@ -1,46 +0,0 @@ -using GTA; - -namespace Accurate_throttle_for_aircraft -{ - internal sealed class Main : Script - { - public Main() - { - var throttle - = 0.25f; - - Tick += (o, e) => - { - if (Game.Player.Character.IsInFlyingVehicle) - { - Game - .SetControlValueNormalized(Control - .VehicleFlyThrottleUp, throttle); - - if (Game.IsKeyPressed(System.Windows.Forms.Keys.Oemplus)) - { - if (throttle > 1f) - throttle = 1f; - - if (throttle < 1f) - throttle += 0.0065f; - } - - if (Game.IsKeyPressed(System.Windows.Forms.Keys.OemMinus)) - { - if (throttle < 0.25f) - throttle = 0.25f; - - if (throttle > 0.25f) - throttle -= 0.0065f; - } - - return; - } - - if (throttle != 0.25f) - throttle = 0.25f; - }; - } - } -} diff --git a/Accurate-throttle-for-aircraft/settings/SettingsManager.cs b/Accurate-throttle-for-aircraft/settings/SettingsManager.cs deleted file mode 100644 index 42504be..0000000 --- a/Accurate-throttle-for-aircraft/settings/SettingsManager.cs +++ /dev/null @@ -1,255 +0,0 @@ -using GTA; -using GTA.UI; - -using System; -using System.IO; -using System.Drawing; - - -namespace Accurate_throttle_for_aircraft.settings -{ - internal sealed class SettingsManager - { - internal string PathToTheAccurateThrottleForAircraft - { - get - { - return _ - = Directory - .GetCurrentDirectory() - + - @"\scripts\AccurateThrottleForAircraft"; - } - } - internal string PathToTheInterfaceResources - { - get - { - return _ - = PathToTheAccurateThrottleForAircraft - + - @"\UserInterfaceResources\CustomSprite"; - } - } - internal string PathToTheDefaultLayoutImage - { - get - { - return _ - = PathToTheAccurateThrottleForAircraft - + - @"\UserInterfaceResources\CustomSprite\DefaultLayout.png"; - } - } - internal string PathToDisplayCompatibilityFile - { - get - { - return _ - = PathToTheAccurateThrottleForAircraft - + - @"\UserInterfaceResources\DisplayCompatibility.ini"; - } - } - internal string PathToBehaviorOfUserInterfaceElementsFile - { - get - { - return _ - = PathToTheAccurateThrottleForAircraft - + - @"\BehaviorOfUserInterfaceElements.ini"; - } - } - - internal bool ReturnTheInterfaceVisibility() - { - var behaviorOfUserInterfaceElementsFile - = ScriptSettings - .Load(PathToBehaviorOfUserInterfaceElementsFile); - - var interfaceVisibility - = false; - - var section - = "Interface Visibility"; - - var key - = "_"; - - var value - = behaviorOfUserInterfaceElementsFile - .GetAllValues(section, - key)[0]; - - if (value != null - && - value == "On") - { - interfaceVisibility - = true; - } - - return interfaceVisibility; - } - - internal bool ReturnTheInterfaceDisplayBehavior() - { - var behaviorOfUserInterfaceElementsFile - = ScriptSettings - .Load(PathToBehaviorOfUserInterfaceElementsFile); - - var interfaceDiplayBehavior - = false; - - var section - = "Display Only In Autorotation"; - - var key - = "_"; - - var value - = behaviorOfUserInterfaceElementsFile - .GetAllValues(section, - key)[0]; - - if (value != null - && - value == "On") - { - interfaceDiplayBehavior - = true; - } - - return interfaceDiplayBehavior; - } - - internal PointF ReturnTheInterfaceOffsetPosition() - { - var interfaceOffsetPosition - = ScriptSettings - .Load(PathToBehaviorOfUserInterfaceElementsFile); - - var offsetPositionX - = interfaceOffsetPosition - .GetAllValues(section: "Interface Offset Position", - name : "X")[0]; - - var offsetPositionY - = interfaceOffsetPosition - .GetAllValues(section: "Interface Offset Position", - name : "Y")[0]; - - return _ - = new PointF(x: float - .Parse(offsetPositionX), - y: float - .Parse(offsetPositionY)); - } - - internal PointF ReturnThePositionOfCenterOfScreen() - { - var displayCompatibility - = ScriptSettings - .Load(PathToDisplayCompatibilityFile); - - var aspectRatio - = Screen - .AspectRatio; - - var screenCompatibility - = displayCompatibility - .GetAllValues(section: "Compatibility", - name : $"{aspectRatio}")[0]; - - var screenCenterPosition - = displayCompatibility - .GetAllValues(section: screenCompatibility, - name : "Screen Center Position")[0]; - - return _ - = new PointF(x: float - .Parse(screenCenterPosition), - y: 0f); - } - internal PointF ReturnTheCustomPositionOfCenterOfScreen() - { - var positionOfCenterOfScreen - = ReturnThePositionOfCenterOfScreen(); - - return _ - = new PointF(x: positionOfCenterOfScreen - .X * 1.8f, - y: 680f); - } - - internal SizeF ReturnTheSizeOfThis(string imagePath) - { - var sizeOfImage - = new SizeF(); - - using (var image = Image.FromFile(imagePath)) - { - sizeOfImage - = image - .Size; - } - - - return sizeOfImage; - } - internal SizeF ReturnTheCustomSizeOfThis(string imageFile) - { - var sizeOfThisImageFile - = ReturnTheSizeOfThis(imageFile); - - return _ - = new SizeF(width: sizeOfThisImageFile - .Width / 2f, - height: sizeOfThisImageFile - .Height / 2f); - } - - internal Color ReturnTheColorOfThis(string section) - { - var behaviorOfUserInterfaceElementsFile - = ScriptSettings - .Load(PathToBehaviorOfUserInterfaceElementsFile); - - var keys - = new[] - { - "Color - A", - "Color - R", - "Color - G", - "Color - B" - }; - - var unconvertedColor - = new string[4]; - - var convertedColor - = new byte[4]; - - for (var i = (byte)0; i < keys - .Length; i++) - { - unconvertedColor - [i] = behaviorOfUserInterfaceElementsFile - .GetAllValues(section, - keys[i])[0]; - - convertedColor - [i] = byte - .Parse(unconvertedColor[i]); - } - - return _ - = Color - .FromArgb(alpha: convertedColor[0], - red : convertedColor[1], - green: convertedColor[2], - blue : convertedColor[3]); - } - } -} \ No newline at end of file diff --git a/Accurate-throttle-for-aircraft/user-interfaces/Elements.cs b/Accurate-throttle-for-aircraft/user-interfaces/Elements.cs deleted file mode 100644 index 2c30da6..0000000 --- a/Accurate-throttle-for-aircraft/user-interfaces/Elements.cs +++ /dev/null @@ -1,28 +0,0 @@ -using GTA.UI; - -using System.Collections.Generic; - - -namespace Accurate_throttle_for_aircraft.user_interfaces -{ - internal sealed class Elements - { - private readonly IEnumerable _elements; - - - public Elements(IEnumerable elements) - { - _elements - = elements; - } - - internal void ScaledDraw() - { - foreach (var element in _elements) - { - element - .ScaledDraw(); - } - } - } -} \ No newline at end of file diff --git a/Accurate-throttle-for-aircraft/user-interfaces/UserInterfaces.cs b/Accurate-throttle-for-aircraft/user-interfaces/UserInterfaces.cs deleted file mode 100644 index 4081945..0000000 --- a/Accurate-throttle-for-aircraft/user-interfaces/UserInterfaces.cs +++ /dev/null @@ -1,252 +0,0 @@ -using GTA; -using GTA.UI; - -using System.Drawing; - -using Accurate_throttle_for_aircraft.settings; -using Accurate_throttle_for_aircraft.user_interfaces.managers; -using Accurate_throttle_for_aircraft.user_interfaces.creators.resources.structs; - -namespace Accurate_throttle_for_aircraft.user_interfaces -{ - internal sealed class UserInterfaces : Script - { - public UserInterfaces() - { - var settingsManager - = new SettingsManager(); - - var interfaceVisibility - = settingsManager - .ReturnTheInterfaceVisibility(); - - if (!interfaceVisibility) - Pause(); - - var throttleInterface - = new ThrottleInterface(); - - Tick += (o, e) => - { - if (Game.Player.Character.IsInFlyingVehicle) - { - throttleInterface - .BuildTheInterface(); - - throttleInterface - .ShowTheInterface(); - - return; - } - - throttleInterface - .RemoveTheInterface(); - }; - - Aborted += (o, e) => - { - throttleInterface - .RemoveTheInterface(); - }; - } - } - - internal sealed class ThrottleInterface - { - private CustomSprite[] _imagensForTheInterface; - - private Elements _elementsForTheThrottleInterface; - - private PointF _lineImagePosition; - - public ThrottleInterface() - { - _elementsForTheThrottleInterface - = new Elements(_imagensForTheInterface); - } - - private CustomSprite[] ReturnTheImagensForTheInterface() - { - var customSpriteManager - = new CustomSpriteManager(); - - return _ - = - new[] - { - customSpriteManager - .ReturnAnCustomSpriteWithThis(ReturnStCustomSpriteConfigurationOfThis("DefaultLayout")), - customSpriteManager - .ReturnAnCustomSpriteWithThis(ReturnStCustomSpriteConfigurationOfThis("Line")) - }; - } - - private CustomSprite[] ReturnTheImagesOrganizedAndReadyForTheInterface() - { - var settingsManager - = new SettingsManager(); - - var interfaceOffsetPosition - = settingsManager - .ReturnTheInterfaceOffsetPosition(); - - var imagensForTheInterface - = ReturnTheImagensForTheInterface(); - - var defaultLayoutImage - = imagensForTheInterface[0]; - - var lineImage - = imagensForTheInterface[1]; - - defaultLayoutImage - .Centered = true; - - lineImage - .Centered = false; - - var defaultLayoutImagePosition - = defaultLayoutImage - .Position; - - var lineImagePosition - = lineImage - .Position; - - var defaultLayoutImageOffsetPosition - = new PointF(defaultLayoutImagePosition.X + interfaceOffsetPosition.X, - defaultLayoutImagePosition.Y + interfaceOffsetPosition.Y); - - var lineImageOffsetPosition - = new PointF(lineImagePosition.X + interfaceOffsetPosition.X - 120f, - lineImagePosition.Y + interfaceOffsetPosition.Y - 14f ); - - defaultLayoutImage - .Position = defaultLayoutImageOffsetPosition; - - lineImage - .Position = lineImageOffsetPosition; - - return _ - = - new[] - { - defaultLayoutImage, - lineImage - }; - } - - private StCustomSpriteConfiguration ReturnStCustomSpriteConfigurationOfThis(string imageName) - { - var settingsManager - = new SettingsManager(); - - var pathToTheInterfaceResources - = settingsManager - .PathToTheInterfaceResources; - - var pathToTheImagesThatMakeUpTheInterface - = pathToTheInterfaceResources + $@"\{imageName}.png"; - - var customPositionOfCenterOfScreen - = settingsManager - .ReturnTheCustomPositionOfCenterOfScreen(); - - var customColorOfCustomSprite - = settingsManager - .ReturnTheColorOfThis(imageName); - - var customSizeOfCustomSprite - = settingsManager - .ReturnTheCustomSizeOfThis(pathToTheImagesThatMakeUpTheInterface); - - return _ - = - new StCustomSpriteConfiguration() - { - Filename - = pathToTheImagesThatMakeUpTheInterface, - - Position - = customPositionOfCenterOfScreen, - - Color - = customColorOfCustomSprite, - - Size - = customSizeOfCustomSprite, - }; - } - - private void PutTheImageOfTheLineAtTheBeginningOfTheSlideBar() - { - var lineImage - = _imagensForTheInterface[1]; - - var lineImagePosition - = lineImage - .Position; - - var beginningOfTheSlideBar - = new PointF(x: 159.5f, - y: 0f); - - var beginningPositionOfTheSlideBar - = new PointF(x: lineImagePosition.X + beginningOfTheSlideBar.X, - y: lineImagePosition.Y + beginningOfTheSlideBar.Y); - - lineImage - .Position = beginningPositionOfTheSlideBar; - } - - internal void BuildTheInterface() - { - for (var i = 0; i < 2; i++) - { - if (_imagensForTheInterface == null) - { - _imagensForTheInterface - = ReturnTheImagensForTheInterface(); - - _imagensForTheInterface - = ReturnTheImagesOrganizedAndReadyForTheInterface(); - - PutTheImageOfTheLineAtTheBeginningOfTheSlideBar(); - - _lineImagePosition - = _imagensForTheInterface[1].Position; - - _elementsForTheThrottleInterface - = new Elements(_imagensForTheInterface); - } - } - } - - internal void RemoveTheInterface() - { - for (var i = 0; i < 2; i++) - { - if (_imagensForTheInterface != null) - { - _imagensForTheInterface = null; - } - } - } - - internal void ShowTheInterface() - { - var lineImage - = _imagensForTheInterface[1]; - - var updatePosition - = new PointF(_lineImagePosition.X - (Game.GetControlValueNormalized(Control.VehicleFlyThrottleUp) * 159.9f), - _lineImagePosition.Y); - - lineImage - .Position = updatePosition; - - _elementsForTheThrottleInterface - .ScaledDraw(); - } - } -} \ No newline at end of file diff --git a/Accurate-throttle-for-aircraft.sln b/Alternative-throttle-control.sln similarity index 83% rename from Accurate-throttle-for-aircraft.sln rename to Alternative-throttle-control.sln index 54dcf39..0015d39 100644 --- a/Accurate-throttle-for-aircraft.sln +++ b/Alternative-throttle-control.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.1.32414.318 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Accurate-throttle-for-aircraft", "Smooth-throttle-for-aircraft\Accurate-throttle-for-aircraft.csproj", "{26D0FDDA-415D-4951-B5A1-95CFDDDE6F32}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Alternative-throttle-control", "Alternative-throttle-control\Alternative-throttle-control.csproj", "{26D0FDDA-415D-4951-B5A1-95CFDDDE6F32}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Accurate-throttle-for-aircraft/Accurate-throttle-for-aircraft.csproj b/Alternative-throttle-control/Alternative-throttle-control.csproj similarity index 86% rename from Accurate-throttle-for-aircraft/Accurate-throttle-for-aircraft.csproj rename to Alternative-throttle-control/Alternative-throttle-control.csproj index d248c2b..646e5b2 100644 --- a/Accurate-throttle-for-aircraft/Accurate-throttle-for-aircraft.csproj +++ b/Alternative-throttle-control/Alternative-throttle-control.csproj @@ -7,8 +7,8 @@ {26D0FDDA-415D-4951-B5A1-95CFDDDE6F32} Library Properties - Accurate_throttle_for_aircraft - Accurate-throttle-for-aircraft + Alternative_throttle_control + Alternative-throttle-control v4.8 512 true @@ -22,6 +22,7 @@ prompt 4 x64 + false pdbonly @@ -32,6 +33,7 @@ 4 + ..\..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto V\ScriptHookVDotNet3.dll @@ -50,7 +52,7 @@ - + @@ -58,6 +60,6 @@ - xcopy "$(ProjectDir)\bin\Debug\Accurate-throttle-for-aircraft.dll" /y "C:\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto V\scripts" + xcopy "$(ProjectDir)\bin\Debug\Alternative-throttle-control.dll" /y "C:\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto V\scripts" \ No newline at end of file diff --git a/Alternative-throttle-control/Main.cs b/Alternative-throttle-control/Main.cs new file mode 100644 index 0000000..4c7962e --- /dev/null +++ b/Alternative-throttle-control/Main.cs @@ -0,0 +1,103 @@ +using GTA; + +using GTAControl + = GTA.Control; + +using System.Windows.Forms; + +using Alternative_throttle_control.settings; + +namespace Alternative_throttle_control +{ + internal sealed class Main : Script + { + private readonly Keys _keyForThrottleIncrease; + + private readonly Keys _keyForThrottleDecrease; + + private float _throttleSensitivity; + + private float _throttleValue; + + public Main() + { + var settingsManager + = new SettingsManager(); + + _keyForThrottleIncrease + = settingsManager + .ReturnTheKeyForTheThrottleIncrease(); + + _keyForThrottleDecrease + = settingsManager + .ReturnTheKeyForTheThrottleDecrease(); + + _throttleSensitivity + = settingsManager + .ReturnTheThrottleSensitivity(); + + _throttleValue + = 0.25f; + + Tick += (o, e) => + { + if (Game.IsLoading) + { + return; + } + + switch (Game.Player.Character.IsInFlyingVehicle) + { + case true: + { + Game + .SetControlValueNormalized(GTAControl + .VehicleFlyThrottleUp, _throttleValue); + + if (Game + .IsKeyPressed(_keyForThrottleIncrease)) + { + IncreaseThrottle(); + } + + if (Game + .IsKeyPressed(_keyForThrottleDecrease)) + { + DecreaseThrottle(); + } + } + return; + case false: + { + IdleThrottle(); + } + return; + } + }; + } + + private void IncreaseThrottle() + { + if (_throttleValue > 1f) + _throttleValue = 1f; + + if (_throttleValue < 1f) + _throttleValue += _throttleSensitivity; + } + + private void DecreaseThrottle() + { + if (_throttleValue < 0.25f) + _throttleValue = 0.25f; + + if (_throttleValue > 0.25f) + _throttleValue -= _throttleSensitivity; + } + + private void IdleThrottle() + { + if (_throttleValue != 0.25f) + _throttleValue = 0.25f; + } + } +} \ No newline at end of file diff --git a/Alternative-throttle-control/settings/SettingsManager.cs b/Alternative-throttle-control/settings/SettingsManager.cs new file mode 100644 index 0000000..6f88d80 --- /dev/null +++ b/Alternative-throttle-control/settings/SettingsManager.cs @@ -0,0 +1,426 @@ +using GTA; + +using GTAScreen + = GTA.UI.Screen; + +using System.IO; + +using System.Drawing; + +using System.Windows.Forms; + +using System.Collections.Generic; + +using Alternative_throttle_control.user_interfaces.creators.resources.structs; + +namespace Alternative_throttle_control.settings +{ + internal sealed class SettingsManager + { + internal string PathToTheAlternativeThrottleControlFolder + { + get + { + return _ + = Directory + .GetCurrentDirectory() + + + @"\scripts\AlternativeThrottleControl"; + } + } + internal string PathToTheUserInterfaceResourcesFolder + { + get + { + return _ + = PathToTheAlternativeThrottleControlFolder + + + @"\UserInterfaceResources"; + } + } + internal string PathToTheThrottleInterfaceFolder + { + get + { + return _ + = PathToTheUserInterfaceResourcesFolder + + + @"\ThrottleInterface"; + } + } + internal string PathToTheCustomSpriteFolder + { + get + { + return _ + = PathToTheThrottleInterfaceFolder + + + @"\CustomSprite"; + } + } + + internal string PathToTheInterfaceSetupFile + { + get + { + return _ + = PathToTheThrottleInterfaceFolder + + + @"\InterfaceSetup.ini"; + } + } + internal string PathToDisplayCompatibilityFile + { + get + { + return _ + = PathToTheUserInterfaceResourcesFolder + + + @"\DisplayCompatibility.ini"; + } + } + internal string PathToBehaviorOfUserInterfaceElementsFile + { + get + { + return _ + = PathToTheAlternativeThrottleControlFolder + + + @"\BehaviorOfUserInterfaceElements.ini"; + } + } + internal string PathToScriptBehaviorFile + { + get + { + return _ + = PathToTheAlternativeThrottleControlFolder + + + @"\ScriptBehavior.ini"; + } + } + + internal float ReturnTheThrottleSensitivity() + { + var throttleConfigurationFile + = ScriptSettings + .Load(PathToScriptBehaviorFile); + + var throttleSensitivity + = throttleConfigurationFile + .GetAllValues("ThrottleConfiguration", "ThrottleSensitivity")[0]; + + return throttleSensitivity; + } + + internal bool ReturnTheInterfaceVisibility() + { + var behaviorOfUserInterfaceElementsFile + = ScriptSettings + .Load(PathToBehaviorOfUserInterfaceElementsFile); + + var interfaceVisibility + = false; + + var section + = "InterfaceVisibility"; + + var key + = "_"; + + var value + = behaviorOfUserInterfaceElementsFile + .GetAllValues(section, + key)[0]; + + if (value != null + && + value == "On") + { + interfaceVisibility + = true; + } + + return interfaceVisibility; + } + + internal Keys ReturnTheKeyForTheThrottleIncrease() + { + var keyConfigurationFile + = ScriptSettings + .Load(PathToScriptBehaviorFile); + + var keyForThrottleIncrease + = keyConfigurationFile + .GetAllValues("KeyConfiguration", "KeyForTheThrottleIncrease")[0]; + + return keyForThrottleIncrease; + } + internal Keys ReturnTheKeyForTheThrottleDecrease() + { + var keyConfigurationFile + = ScriptSettings + .Load(PathToScriptBehaviorFile); + + var keyForThrottleDecrease + = keyConfigurationFile + .GetAllValues("KeyConfiguration", "KeyForTheThrottleDecrease")[0]; + + return keyForThrottleDecrease; + } + + internal PointF ReturnTheInterfaceOffsetPosition() + { + var interfaceOffsetPosition + = ScriptSettings + .Load(PathToBehaviorOfUserInterfaceElementsFile); + + var offsetPositionX + = interfaceOffsetPosition + .GetAllValues(section: "InterfaceOffsetPosition", + name : "X")[0]; + + var offsetPositionY + = interfaceOffsetPosition + .GetAllValues(section: "InterfaceOffsetPosition", + name : "Y")[0]; + + return _ + = new PointF(x: float + .Parse(offsetPositionX), + y: float + .Parse(offsetPositionY)); + } + + internal string ReturnTheMeasurementSystemOfSpeedometer() + { + var behaviorOfUserInterfaceElementsFile + = ScriptSettings + .Load(PathToBehaviorOfUserInterfaceElementsFile); + + var measurementSystem + = behaviorOfUserInterfaceElementsFile + .GetAllValues(section: "MeasurementSystemOfSpeedometer", + name : "_")[0]; + + return measurementSystem; + } + + internal PointF ReturnThePositionOfCenterOfScreen() + { + var displayCompatibility + = ScriptSettings + .Load(PathToDisplayCompatibilityFile); + + var aspectRatio + = GTAScreen + .AspectRatio; + + var screenCompatibility + = displayCompatibility + .GetAllValues(section: "Compatibility", + name : $"{aspectRatio}")[0]; + + var screenCenterPosition + = displayCompatibility + .GetAllValues(section: screenCompatibility, + name : "ScreenCenterPosition")[0]; + + return _ + = new PointF(x: float + .Parse(screenCenterPosition), + y: 0f); + } + internal PointF ReturnTheCustomPositionOfCenterOfScreen() + { + var positionOfCenterOfScreen + = ReturnThePositionOfCenterOfScreen(); + + return _ + = new PointF(x: positionOfCenterOfScreen + .X * 1.8f, + y: 680f); + } + + internal SizeF ReturnTheSizeOfThis(string imagePath) + { + var sizeOfImage + = new SizeF(); + + using (var image = Image.FromFile(imagePath)) + { + sizeOfImage + = image + .Size; + } + + + return sizeOfImage; + } + internal SizeF ReturnTheCustomSizeOfThis(string imageFile) + { + var sizeOfThisImageFile + = ReturnTheSizeOfThis(imageFile); + + return _ + = new SizeF(width: sizeOfThisImageFile + .Width / 2f, + height: sizeOfThisImageFile + .Height / 2f); + } + + internal Color ReturnTheColorOfThis(string section) + { + var interfaceSetupFile + = ScriptSettings + .Load(PathToTheInterfaceSetupFile); + + var unconvertedColor + = interfaceSetupFile + .GetAllValues(section, "Color")[0].Replace("A", "") + .Replace("R", "") + .Replace("G", "") + .Replace("B", "") + .Replace(":", "") + .Split(' '); + + var convertedColor + = new[] + { + byte + .Parse(unconvertedColor[0]), + byte + .Parse(unconvertedColor[1]), + byte + .Parse(unconvertedColor[2]), + byte + .Parse(unconvertedColor[3]) + }; + + return _ + = Color + .FromArgb(alpha: convertedColor[0], + red: convertedColor[1], + green: convertedColor[2], + blue: convertedColor[3]); + } + + internal IList ReturnOneListOfInterfaceComponentsName() + { + var allComponentsName + = new List(); + + var allComponentsInformation + = ReturnOneListOfInterfaceComponentsInformation(); + + foreach (var componentInformation in allComponentsInformation) + { + allComponentsName + .Add(componentInformation.Replace("NAME", "") + .Replace("TYPE", "") + .Replace(":", "") + .Split(' ')[0]); + } + + return _ + = allComponentsName; + } + internal IList ReturnOneListOfInterfaceComponentsInformation() + { + var componentsInformation + = new List(); + + var interfaceSetupFile + = ScriptSettings + .Load(PathToTheInterfaceSetupFile); + + var allComponentsInformation + = interfaceSetupFile + .GetAllValues("ComponentsInformation", "Component"); + + foreach (var ComponentInformation in allComponentsInformation) + { + componentsInformation + .Add(ComponentInformation); + } + + return _ + = componentsInformation; + } + + internal StCustomSpriteConfiguration ReturnStCustomSpriteConfigurationOfThis(string filename) + { + var pathToTheImagesThatMakeUpTheInterface + = PathToTheCustomSpriteFolder + $@"\{filename}.png"; + + var customPositionOfCenterOfScreen + = ReturnTheCustomPositionOfCenterOfScreen(); + + var offsetPosition + = ReturnTheInterfaceOffsetPosition(); + + var customPositionWithInterfaceOffset + = new PointF(customPositionOfCenterOfScreen.X + offsetPosition.X, + customPositionOfCenterOfScreen.Y + offsetPosition.Y); + + var customColorOfCustomSprite + = ReturnTheColorOfThis(filename); + + var customSizeOfCustomSprite + = ReturnTheCustomSizeOfThis(pathToTheImagesThatMakeUpTheInterface); + + return _ + = + new StCustomSpriteConfiguration() + { + Filename + = pathToTheImagesThatMakeUpTheInterface, + + Position + = customPositionWithInterfaceOffset, + + Color + = customColorOfCustomSprite, + + Size + = customSizeOfCustomSprite, + }; + } + + internal StTextElementConfiguration ReturnStTextElementConfigurationOfThis(string caption) + { + var customPositionOfCenterOfScreen + = ReturnTheCustomPositionOfCenterOfScreen(); + + var offsetPosition + = ReturnTheInterfaceOffsetPosition(); + + var customPositionWithInterfaceOffset + = new PointF(customPositionOfCenterOfScreen.X + offsetPosition.X, + customPositionOfCenterOfScreen.Y + offsetPosition.Y); + + var customColorOfThisTextElement + = ReturnTheColorOfThis(caption); + + var customScaleOfThisTextElement + = 0.35f; + + return _ + = + new StTextElementConfiguration() + { + Caption + = caption, + + Position + = customPositionWithInterfaceOffset, + + Color + = customColorOfThisTextElement, + + Scale + = customScaleOfThisTextElement, + }; + } + } +} \ No newline at end of file diff --git a/Alternative-throttle-control/user-interfaces/UserInterfaces.cs b/Alternative-throttle-control/user-interfaces/UserInterfaces.cs new file mode 100644 index 0000000..67bd8b5 --- /dev/null +++ b/Alternative-throttle-control/user-interfaces/UserInterfaces.cs @@ -0,0 +1,44 @@ +using GTA; +using GTA.UI; + +using System.Drawing; + +using Alternative_throttle_control.settings; +using Alternative_throttle_control.user_interfaces.managers; +using Alternative_throttle_control.user_interfaces.creators.resources.structs; +using Alternative_throttle_control.user_interfaces.interfaces; + +namespace Alternative_throttle_control.user_interfaces +{ + internal sealed class UserInterfaces : Script + { + public UserInterfaces() + { + var throttleInterface + = new ThrottleInterface(); + + Tick += (o, e) => + { + if (Game.Player.Character.IsInFlyingVehicle) + { + throttleInterface + .BuildTheInterface(); + + throttleInterface + .ShowTheInterface(); + + return; + } + + throttleInterface + .RemoveTheInterface(); + }; + + Aborted += (o, e) => + { + throttleInterface + .RemoveTheInterface(); + }; + } + } +} \ No newline at end of file diff --git a/Accurate-throttle-for-aircraft/user-interfaces/creators/ContainerElementCreator.cs b/Alternative-throttle-control/user-interfaces/creators/ContainerElementCreator.cs similarity index 82% rename from Accurate-throttle-for-aircraft/user-interfaces/creators/ContainerElementCreator.cs rename to Alternative-throttle-control/user-interfaces/creators/ContainerElementCreator.cs index 0f2c590..a46f401 100644 --- a/Accurate-throttle-for-aircraft/user-interfaces/creators/ContainerElementCreator.cs +++ b/Alternative-throttle-control/user-interfaces/creators/ContainerElementCreator.cs @@ -1,8 +1,8 @@ using GTA.UI; -using Accurate_throttle_for_aircraft.user_interfaces.creators.resources.structs; +using Alternative_throttle_control.user_interfaces.creators.resources.structs; -namespace Accurate_throttle_for_aircraft.user_interfaces.creators +namespace Alternative_throttle_control.user_interfaces.creators { internal abstract class ContainerElementCreator { diff --git a/Accurate-throttle-for-aircraft/user-interfaces/creators/CustomSpriteCreator.cs b/Alternative-throttle-control/user-interfaces/creators/CustomSpriteCreator.cs similarity index 84% rename from Accurate-throttle-for-aircraft/user-interfaces/creators/CustomSpriteCreator.cs rename to Alternative-throttle-control/user-interfaces/creators/CustomSpriteCreator.cs index 1d1eeac..c6ec3ba 100644 --- a/Accurate-throttle-for-aircraft/user-interfaces/creators/CustomSpriteCreator.cs +++ b/Alternative-throttle-control/user-interfaces/creators/CustomSpriteCreator.cs @@ -1,9 +1,9 @@ using GTA.UI; -using Accurate_throttle_for_aircraft.user_interfaces.creators.resources.structs; +using Alternative_throttle_control.user_interfaces.creators.resources.structs; -namespace Accurate_throttle_for_aircraft.user_interfaces.creators +namespace Alternative_throttle_control.user_interfaces.creators { internal abstract class CustomSpriteCreator { diff --git a/Accurate-throttle-for-aircraft/user-interfaces/creators/TextElementCreator.cs b/Alternative-throttle-control/user-interfaces/creators/TextElementCreator.cs similarity index 83% rename from Accurate-throttle-for-aircraft/user-interfaces/creators/TextElementCreator.cs rename to Alternative-throttle-control/user-interfaces/creators/TextElementCreator.cs index bbd72af..a65f9a5 100644 --- a/Accurate-throttle-for-aircraft/user-interfaces/creators/TextElementCreator.cs +++ b/Alternative-throttle-control/user-interfaces/creators/TextElementCreator.cs @@ -1,9 +1,9 @@ using GTA.UI; -using Accurate_throttle_for_aircraft.user_interfaces.creators.resources.structs; +using Alternative_throttle_control.user_interfaces.creators.resources.structs; -namespace Accurate_throttle_for_aircraft.user_interfaces.creators +namespace Alternative_throttle_control.user_interfaces.creators { internal abstract class TextElementCreator { diff --git a/Accurate-throttle-for-aircraft/user-interfaces/creators/resources/interfaces/IConfiguration.cs b/Alternative-throttle-control/user-interfaces/creators/resources/interfaces/IConfiguration.cs similarity index 65% rename from Accurate-throttle-for-aircraft/user-interfaces/creators/resources/interfaces/IConfiguration.cs rename to Alternative-throttle-control/user-interfaces/creators/resources/interfaces/IConfiguration.cs index 08b78fb..81b03d7 100644 --- a/Accurate-throttle-for-aircraft/user-interfaces/creators/resources/interfaces/IConfiguration.cs +++ b/Alternative-throttle-control/user-interfaces/creators/resources/interfaces/IConfiguration.cs @@ -1,6 +1,6 @@ using System.Drawing; -namespace Accurate_throttle_for_aircraft.user_interfaces.creators.resources.interfaces +namespace Alternative_throttle_control.user_interfaces.creators.resources.interfaces { internal interface IConfiguration { diff --git a/Accurate-throttle-for-aircraft/user-interfaces/creators/resources/structs/StContainerElementConfiguration.cs b/Alternative-throttle-control/user-interfaces/creators/resources/structs/StContainerElementConfiguration.cs similarity index 61% rename from Accurate-throttle-for-aircraft/user-interfaces/creators/resources/structs/StContainerElementConfiguration.cs rename to Alternative-throttle-control/user-interfaces/creators/resources/structs/StContainerElementConfiguration.cs index 314b047..f1a24ac 100644 --- a/Accurate-throttle-for-aircraft/user-interfaces/creators/resources/structs/StContainerElementConfiguration.cs +++ b/Alternative-throttle-control/user-interfaces/creators/resources/structs/StContainerElementConfiguration.cs @@ -1,9 +1,9 @@ using System.Drawing; -using Accurate_throttle_for_aircraft.user_interfaces.creators.resources.interfaces; +using Alternative_throttle_control.user_interfaces.creators.resources.interfaces; -namespace Accurate_throttle_for_aircraft.user_interfaces.creators.resources.structs +namespace Alternative_throttle_control.user_interfaces.creators.resources.structs { internal struct StContainerElementConfiguration : IConfiguration { diff --git a/Accurate-throttle-for-aircraft/user-interfaces/creators/resources/structs/StCustomSpriteConfiguration.cs b/Alternative-throttle-control/user-interfaces/creators/resources/structs/StCustomSpriteConfiguration.cs similarity index 65% rename from Accurate-throttle-for-aircraft/user-interfaces/creators/resources/structs/StCustomSpriteConfiguration.cs rename to Alternative-throttle-control/user-interfaces/creators/resources/structs/StCustomSpriteConfiguration.cs index 0913753..752e944 100644 --- a/Accurate-throttle-for-aircraft/user-interfaces/creators/resources/structs/StCustomSpriteConfiguration.cs +++ b/Alternative-throttle-control/user-interfaces/creators/resources/structs/StCustomSpriteConfiguration.cs @@ -1,9 +1,9 @@ using System.Drawing; -using Accurate_throttle_for_aircraft.user_interfaces.creators.resources.interfaces; +using Alternative_throttle_control.user_interfaces.creators.resources.interfaces; -namespace Accurate_throttle_for_aircraft.user_interfaces.creators.resources.structs +namespace Alternative_throttle_control.user_interfaces.creators.resources.structs { internal struct StCustomSpriteConfiguration : IConfiguration { diff --git a/Accurate-throttle-for-aircraft/user-interfaces/creators/resources/structs/StTextElementConfiguration.cs b/Alternative-throttle-control/user-interfaces/creators/resources/structs/StTextElementConfiguration.cs similarity index 65% rename from Accurate-throttle-for-aircraft/user-interfaces/creators/resources/structs/StTextElementConfiguration.cs rename to Alternative-throttle-control/user-interfaces/creators/resources/structs/StTextElementConfiguration.cs index be46882..4e83f14 100644 --- a/Accurate-throttle-for-aircraft/user-interfaces/creators/resources/structs/StTextElementConfiguration.cs +++ b/Alternative-throttle-control/user-interfaces/creators/resources/structs/StTextElementConfiguration.cs @@ -1,9 +1,9 @@ using System.Drawing; -using Accurate_throttle_for_aircraft.user_interfaces.creators.resources.interfaces; +using Alternative_throttle_control.user_interfaces.creators.resources.interfaces; -namespace Accurate_throttle_for_aircraft.user_interfaces.creators.resources.structs +namespace Alternative_throttle_control.user_interfaces.creators.resources.structs { internal struct StTextElementConfiguration : IConfiguration { diff --git a/Alternative-throttle-control/user-interfaces/interfaces/ThrottleInterface.cs b/Alternative-throttle-control/user-interfaces/interfaces/ThrottleInterface.cs new file mode 100644 index 0000000..b783147 --- /dev/null +++ b/Alternative-throttle-control/user-interfaces/interfaces/ThrottleInterface.cs @@ -0,0 +1,306 @@ +using GTA; +using GTA.UI; +using GTAFont + = GTA.UI.Font; + +using System.Drawing; + +using Alternative_throttle_control.settings; + +using Alternative_throttle_control.user_interfaces.managers; + + +namespace Alternative_throttle_control.user_interfaces.interfaces +{ + internal class ThrottleInterface + { + private ContainerElement _containerElement; + + private SettingsManager _settingsManager; + + private CustomSprite[] _customSprites; + + private TextElement[] _textElements; + + private PointF _sliderInitialPosition; + + private string _measurementSystem; + + public ThrottleInterface() + { + _settingsManager + = new SettingsManager(); + + _measurementSystem + = _settingsManager + .ReturnTheMeasurementSystemOfSpeedometer(); + } + + internal void BuildTheInterface() + { + if (_containerElement != null) + { + return; + } + + _containerElement + = ReturnContainerElementForTheYawInterface(); + + _customSprites + = new[] + { + ReturnCustomSpriteDefaultLayout(), + ReturnCustomSpriteLine() + }; + + _containerElement + .Items.Add(_customSprites[0]); + + _containerElement + .Items.Add(_customSprites[1]); + + if (_textElements != null) + { + return; + } + + _textElements + = new[] + { + ReturnTextElementMeasurementSystem(), + ReturnTextElementSpeedometer() + }; + + _containerElement + .Items.Add(_textElements[0]); + + _containerElement + .Items.Add(_textElements[1]); + } + + internal void ShowTheInterface() + { + UpdateTheSpeedometer(); + + UpdateTheThrotlleLine(); + + _containerElement + .ScaledDraw(); + } + + private void UpdateTheThrotlleLine() + { + if (Game.GetControlValueNormalized(Control.VehicleFlyThrottleUp) != 0f) + { + var throttleValue + = Game.GetControlValueNormalized(Control.VehicleFlyThrottleUp); + + _customSprites[1] + .Position = new PointF(_sliderInitialPosition.X - (throttleValue * 160.5f), + _sliderInitialPosition.Y); + + return; + } + + _sliderInitialPosition + = new PointF(41f, 4f); + } + + private void UpdateTheSpeedometer() + { + var vehicleSpeed + = 0f; + + var vehicleSpeedInMetrePerSecond + = Game.Player.Character.CurrentVehicle.Speed; + + switch (_measurementSystem) + { + case "Knot": + { + vehicleSpeed + = vehicleSpeedInMetrePerSecond * 1.943f; + } + break; + case "Kmh": + { + vehicleSpeed + = vehicleSpeedInMetrePerSecond * 3.590f; + } + break; + case "Mph": + { + vehicleSpeed + = vehicleSpeedInMetrePerSecond * 2.236f; + } + break; + default: + { + vehicleSpeed + = vehicleSpeedInMetrePerSecond; + } + break; + } + + _textElements[1] + .Caption = $"{vehicleSpeed:0}"; + } + + internal void RemoveTheInterface() + { + if (_containerElement == null) + { + return; + } + + _customSprites + = null; + + _textElements + = null; + + _containerElement + .Items.Clear(); + + _containerElement + = null; + } + + private ContainerElement ReturnContainerElementForTheYawInterface() + { + var containerElement + = new ContainerElement(); + + var customSpriteDefaultLayout + = ReturnTheCustomSpritesOfThis("DefaultLayout"); + + containerElement + .Position = customSpriteDefaultLayout + .Position; + + containerElement + .Size = customSpriteDefaultLayout + .Size; + + containerElement + .Centered = false; + + return _ + = containerElement; + } + + private CustomSprite ReturnCustomSpriteDefaultLayout() + { + var customSpriteDefaultLayout + = ReturnTheCustomSpritesOfThis(filename: "DefaultLayout"); + + customSpriteDefaultLayout + .Centered = true; + + customSpriteDefaultLayout + .Position = PointF.Empty; + + return _ + = customSpriteDefaultLayout; + } + private CustomSprite ReturnCustomSpriteLine() + { + var customSpriteLine + = ReturnTheCustomSpritesOfThis(filename: "Line"); + + customSpriteLine + .Centered = false; + + customSpriteLine + .Position = new PointF(40f, 3.5f); + + return _ + = customSpriteLine; + } + private CustomSprite ReturnTheCustomSpritesOfThis(string filename) + { + var customSpriteManager + = new CustomSpriteManager(); + + var customSprite + = customSpriteManager + .ReturnAnCustomSpriteWithThis(_settingsManager + .ReturnStCustomSpriteConfigurationOfThis(filename)); + + return _ + = customSprite; + } + + private TextElement ReturnTextElementMeasurementSystem() + { + var textElementFlyYawRight + = ReturnTheTextElementOfThis("MeasurementSystem"); + + textElementFlyYawRight + .Caption = _measurementSystem; + + textElementFlyYawRight + .Scale = 0.60f; + + textElementFlyYawRight + .Outline = false; + + textElementFlyYawRight + .Shadow = false; + + textElementFlyYawRight + .Font = GTAFont.Pricedown; + + textElementFlyYawRight + .Alignment = Alignment.Center; + + textElementFlyYawRight + .Position = new PointF(81f, -32f); + + return _ + = textElementFlyYawRight; + } + private TextElement ReturnTextElementSpeedometer() + { + var textElementFlyYawLeft + = ReturnTheTextElementOfThis("Speedometer"); + + textElementFlyYawLeft + .Caption = "0"; + + textElementFlyYawLeft + .Scale = 0.55f; + + textElementFlyYawLeft + .Outline = false; + + textElementFlyYawLeft + .Shadow = false; + + textElementFlyYawLeft + .Font = GTAFont.Pricedown; + + textElementFlyYawLeft + .Alignment = Alignment.Center; + + textElementFlyYawLeft + .Position = new PointF(81f, -8f); + + return _ + = textElementFlyYawLeft; + } + private TextElement ReturnTheTextElementOfThis(string caption) + { + var textElementManager + = new TextElementManager(); + + var textElement + = textElementManager + .ReturnAnTextElementWithThis(_settingsManager + .ReturnStTextElementConfigurationOfThis(caption)); + + return _ + = textElement; + } + } +} \ No newline at end of file diff --git a/Accurate-throttle-for-aircraft/user-interfaces/managers/ContainerElementManager.cs b/Alternative-throttle-control/user-interfaces/managers/ContainerElementManager.cs similarity index 62% rename from Accurate-throttle-for-aircraft/user-interfaces/managers/ContainerElementManager.cs rename to Alternative-throttle-control/user-interfaces/managers/ContainerElementManager.cs index 62f4715..a6fcd1c 100644 --- a/Accurate-throttle-for-aircraft/user-interfaces/managers/ContainerElementManager.cs +++ b/Alternative-throttle-control/user-interfaces/managers/ContainerElementManager.cs @@ -1,11 +1,11 @@ using GTA.UI; -using Accurate_throttle_for_aircraft.user_interfaces.creators; +using Alternative_throttle_control.user_interfaces.creators; -using Accurate_throttle_for_aircraft.user_interfaces.creators.resources.structs; +using Alternative_throttle_control.user_interfaces.creators.resources.structs; -namespace Accurate_throttle_for_aircraft.user_interfaces.managers +namespace Alternative_throttle_control.user_interfaces.managers { internal sealed class ContainerElementManager : ContainerElementCreator { diff --git a/Accurate-throttle-for-aircraft/user-interfaces/managers/CustomSpriteManager.cs b/Alternative-throttle-control/user-interfaces/managers/CustomSpriteManager.cs similarity index 62% rename from Accurate-throttle-for-aircraft/user-interfaces/managers/CustomSpriteManager.cs rename to Alternative-throttle-control/user-interfaces/managers/CustomSpriteManager.cs index 13f1082..d3b9d38 100644 --- a/Accurate-throttle-for-aircraft/user-interfaces/managers/CustomSpriteManager.cs +++ b/Alternative-throttle-control/user-interfaces/managers/CustomSpriteManager.cs @@ -1,11 +1,11 @@ using GTA.UI; -using Accurate_throttle_for_aircraft.user_interfaces.creators; +using Alternative_throttle_control.user_interfaces.creators; -using Accurate_throttle_for_aircraft.user_interfaces.creators.resources.structs; +using Alternative_throttle_control.user_interfaces.creators.resources.structs; -namespace Accurate_throttle_for_aircraft.user_interfaces.managers +namespace Alternative_throttle_control.user_interfaces.managers { internal sealed class CustomSpriteManager : CustomSpriteCreator { diff --git a/Accurate-throttle-for-aircraft/user-interfaces/managers/TextElementManager.cs b/Alternative-throttle-control/user-interfaces/managers/TextElementManager.cs similarity index 61% rename from Accurate-throttle-for-aircraft/user-interfaces/managers/TextElementManager.cs rename to Alternative-throttle-control/user-interfaces/managers/TextElementManager.cs index eec6eeb..86446ba 100644 --- a/Accurate-throttle-for-aircraft/user-interfaces/managers/TextElementManager.cs +++ b/Alternative-throttle-control/user-interfaces/managers/TextElementManager.cs @@ -1,11 +1,11 @@ using GTA.UI; -using Accurate_throttle_for_aircraft.user_interfaces.creators; +using Alternative_throttle_control.user_interfaces.creators; -using Accurate_throttle_for_aircraft.user_interfaces.creators.resources.structs; +using Alternative_throttle_control.user_interfaces.creators.resources.structs; -namespace Accurate_throttle_for_aircraft.user_interfaces.managers +namespace Alternative_throttle_control.user_interfaces.managers { internal sealed class TextElementManager : TextElementCreator { diff --git a/README.md b/README.md index a387a39..42a4174 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,52 @@ -![](https://img.gta5-mods.com/q95/images/accurate-throttle-for-aircraft-keyboards/659906-accurate-throttle-for-aircraft.png) +

+ Alternative Yaw Control - Keyboards +

-About the mod +

About the mod

-Accurate throttle for Aircraft is a mod where we add the possibility to conduct the gradual and smooth increase of throttle of an aircraft using the keyboard. - -By default, throttle by keyboard is somewhat binary, it's either 100%, or 0% there is no smooth as is found in throttle using joystick. +

Alternative Throttle Control is a mod where we add the possibility to conduct the gradual and smooth increase of throttle of an aircraft using the keyboard. By default, throttle by keyboard is somewhat binary, it's either 100%, or 0% there is no smooth as is found in throttle using joystick. Currently you can increase the acceleration using Add and decrease it with None.

-Currently you can increase the acceleration using Oemplus and decrease it with OemMinus. In the future I plan to add the possibility to choose the key by changing the startup file. +

Requisites

-Requisites - - -Featured +

Featured

-- More assertive aircraft throttle control -- A beautiful and minimalist interface where you can see how much power is being put into the throttle :) +
    +
  • More assertive aircraft throttle control
  • +
  • A beautiful and minimalist interface where you can see how much power is being put into the throttle :)
  • +
-Installation +

Installation

-Extract from the .rar file the Accurate-throttle-for-aircraft.dll file and the folder named AccurateThrottleForAircraft in the script folder. +
    +
  1. Access the mod page to download the necessary files by clicking on the image that is at the top of the file.;
  2. +
  3. Extract from the .rar file the Alternative-throttle-control.dll file and the folder named AlternativeThrottleControl;
  4. +
  5. Place the extracted files in your script folder
  6. +
-Download +

Changelog

-accessing the mod page on the gta5-mods website. +
    +
  • [v0.1.1.0] +
      +
    • this version of the script comes with some of the additions requested by the community, they are:  +
        +
      • addition of speedometer with km/h, mph and knot support.
      • +
      • addition of the "ScriptBehivior.ini" file with the key settings and the possibility to adjust the throttle sensitivity.
      • +
      +
    • +
    +
  • +
  • [v0.1.0.0] +
      +
    • initial release
    • +
    +
  • +
-Changelog +

 

-- v0.1.0.0: - initial release.