From 2a089e63501294fd6579540e1bc6c03aee3acacb Mon Sep 17 00:00:00 2001
From: NiziulLuizin <74280280+NiziulLuizin@users.noreply.github.com>
Date: Thu, 30 Mar 2023 14:19:26 -0700
Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Adding=20the=20codes=20from=20ve?=
=?UTF-8?q?rsion=20[0.1.3.1]=20(#6)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Alternative-throttle-control.csproj | 3 +-
Alternative-throttle-control/Main.cs | 31 +++--
.../Properties/AssemblyInfo.cs | 4 +-
.../AlternativeThrottleControl.cs | 127 ++++++++----------
Alternative-throttle-control/tools/Timer.cs | 40 ------
.../user-interfaces/UserInterfaces.cs | 22 ++-
README.md | 2 +-
7 files changed, 88 insertions(+), 141 deletions(-)
rename Alternative-throttle-control/{alternative-throttle-control => script}/AlternativeThrottleControl.cs (59%)
delete mode 100644 Alternative-throttle-control/tools/Timer.cs
diff --git a/Alternative-throttle-control/Alternative-throttle-control.csproj b/Alternative-throttle-control/Alternative-throttle-control.csproj
index c6c8e8e..fd0299c 100644
--- a/Alternative-throttle-control/Alternative-throttle-control.csproj
+++ b/Alternative-throttle-control/Alternative-throttle-control.csproj
@@ -42,11 +42,10 @@
-
+
-
diff --git a/Alternative-throttle-control/Main.cs b/Alternative-throttle-control/Main.cs
index 8393708..80116a9 100644
--- a/Alternative-throttle-control/Main.cs
+++ b/Alternative-throttle-control/Main.cs
@@ -1,6 +1,7 @@
-using Alternative_throttle_control.alternative_throttle_control;
+using Alternative_throttle_control.script;
using Alternative_throttle_control.user_interfaces;
using GTA;
+using GTA.UI;
namespace Alternative_throttle_control
{
@@ -23,9 +24,9 @@ public Main()
{
case true:
{
- if (_alternativeThrottleControl == null
+ if (_alternativeThrottleControl is null
||
- _userInterfaces == null)
+ _userInterfaces is null)
{
_alternativeThrottleControl
= InstantiateScript();
@@ -54,23 +55,25 @@ public Main()
return;
case false:
{
- if (_alternativeThrottleControl == null
+ if (_alternativeThrottleControl is null
||
- _userInterfaces == null)
+ _userInterfaces is null)
{
return;
}
- if (!_alternativeThrottleControl.IsPaused
+ if (_alternativeThrottleControl.IsPaused
||
- !_userInterfaces.IsPaused)
+ _userInterfaces.IsPaused)
{
- _alternativeThrottleControl
- .Pause();
-
- _userInterfaces
- .Pause();
+ return;
}
+
+ _alternativeThrottleControl
+ .Pause();
+
+ _userInterfaces
+ .Pause();
}
return;
}
@@ -80,9 +83,9 @@ public Main()
Aborted += (o, e) =>
{
- if (_alternativeThrottleControl == null
+ if (_alternativeThrottleControl is null
||
- _userInterfaces == null)
+ _userInterfaces is null)
{
return;
}
diff --git a/Alternative-throttle-control/Properties/AssemblyInfo.cs b/Alternative-throttle-control/Properties/AssemblyInfo.cs
index 910fcd7..b655bfa 100644
--- a/Alternative-throttle-control/Properties/AssemblyInfo.cs
+++ b/Alternative-throttle-control/Properties/AssemblyInfo.cs
@@ -33,6 +33,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.1.3.0")]
-[assembly: AssemblyFileVersion("0.1.3.0")]
+[assembly: AssemblyVersion("0.1.3.1")]
+[assembly: AssemblyFileVersion("0.1.3.1")]
[assembly: NeutralResourcesLanguage("en")]
diff --git a/Alternative-throttle-control/alternative-throttle-control/AlternativeThrottleControl.cs b/Alternative-throttle-control/script/AlternativeThrottleControl.cs
similarity index 59%
rename from Alternative-throttle-control/alternative-throttle-control/AlternativeThrottleControl.cs
rename to Alternative-throttle-control/script/AlternativeThrottleControl.cs
index 0cc9d4e..3d9e707 100644
--- a/Alternative-throttle-control/alternative-throttle-control/AlternativeThrottleControl.cs
+++ b/Alternative-throttle-control/script/AlternativeThrottleControl.cs
@@ -1,13 +1,11 @@
using Alternative_throttle_control.settings;
using GTA;
using System.Windows.Forms;
-using CTimer
- = Alternative_throttle_control.tools.Timer;
using GTAControl
= GTA.Control;
-namespace Alternative_throttle_control.alternative_throttle_control
+namespace Alternative_throttle_control.script
{
[ScriptAttributes(NoDefaultInstance = true)]
internal sealed class AlternativeThrottleControl : Script
@@ -17,9 +15,6 @@ public AlternativeThrottleControl()
var keyThatDeterminesTheIncreaseOrDecreaseOfTheValues
= Keys.NumPad3;
- var timer
- = new CTimer();
-
var settingsManager
= new SettingsManager();
@@ -41,42 +36,36 @@ var throttleUpValue
var throttleDownValue
= 0.25f;
- Tick += (o, e) =>
+ Tick += (o, e) =>
{
- switch (Game.Player.Character.IsInFlyingVehicle)
+ if (Game
+ .IsControlJustPressed(GTAControl
+ .VehicleExit))
+ {
+ IdleThrottle();
+ }
+
+ Game
+ .SetControlValueNormalized(GTAControl
+ .VehicleFlyThrottleUp, throttleUpValue);
+ Game
+ .SetControlValueNormalized(GTAControl
+ .VehicleFlyThrottleDown, throttleDownValue);
+
+ if (Game
+ .IsKeyPressed(keyForTheThrottleUp))
{
- case false:
- {
- IdleThrottle();
- }
- return;
- case true:
- {
- Game
- .SetControlValueNormalized(GTAControl
- .VehicleFlyThrottleUp, throttleUpValue);
- Game
- .SetControlValueNormalized(GTAControl
- .VehicleFlyThrottleDown, throttleDownValue);
-
-
- if (Game
- .IsKeyPressed(keyForTheThrottleUp))
- {
- IncreaseThrottle();
-
- return;
- }
-
- if (Game
- .IsKeyPressed(keyForTheThrottleDown))
- {
- DecreaseThrottle();
-
- return;
- }
- }
- return;
+ IncreaseThrottle();
+
+ return;
+ }
+
+ if (Game
+ .IsKeyPressed(keyForTheThrottleDown))
+ {
+ DecreaseThrottle();
+
+ return;
}
};
@@ -106,79 +95,79 @@ void IncreaseThrottle()
{
if (keyThatDeterminesTheIncreaseOrDecreaseOfTheValues == keyForTheThrottleUp)
{
- ThrottleUp();
+ IncreaseThrottleUp();
}
if (keyThatDeterminesTheIncreaseOrDecreaseOfTheValues == keyForTheThrottleDown)
{
- ThrottleDown();
+ DecreaseThrottleUp();
}
return;
- void ThrottleUp()
+ void IncreaseThrottleUp()
{
if (throttleUpValue > 1f)
throttleUpValue = 1f;
if (throttleUpValue < 1f)
- throttleUpValue += throttleSensitivity;
+ throttleUpValue += throttleSensitivity + (Game.LastFrameTime / 5f);
}
- void ThrottleDown()
+ void DecreaseThrottleUp()
{
if (throttleDownValue < 0.25f)
throttleDownValue = 0.25f;
- if (timer
- .ReturnsTrueForEach(1))
+ if (throttleDownValue == 0.25f)
{
- if (throttleDownValue == 0.25f)
- keyThatDeterminesTheIncreaseOrDecreaseOfTheValues = Keys.NumPad3;
+ Yield();
+
+ keyThatDeterminesTheIncreaseOrDecreaseOfTheValues = Keys.NumPad3;
}
if (throttleDownValue > 0.25f)
- throttleDownValue -= throttleSensitivity;
+ throttleDownValue -= throttleSensitivity + (Game.LastFrameTime / 5f);
}
}
void DecreaseThrottle()
{
- if (keyThatDeterminesTheIncreaseOrDecreaseOfTheValues == keyForTheThrottleUp)
+ if (keyThatDeterminesTheIncreaseOrDecreaseOfTheValues == keyForTheThrottleDown)
{
- ThrottleDown();
+ IncreaseThrottleDown();
}
- if (keyThatDeterminesTheIncreaseOrDecreaseOfTheValues == keyForTheThrottleDown)
+ if (keyThatDeterminesTheIncreaseOrDecreaseOfTheValues == keyForTheThrottleUp)
{
- ThrottleUp();
+ DecreaseThrottleDown();
}
return;
- void ThrottleDown()
+ void IncreaseThrottleDown()
+ {
+ if (throttleDownValue > 1f)
+ throttleDownValue = 1f;
+
+ if (throttleDownValue < 1f)
+ throttleDownValue += throttleSensitivity + (Game.LastFrameTime / 5f);
+ }
+
+ void DecreaseThrottleDown()
{
if (throttleUpValue < 0.25f)
throttleUpValue = 0.25f;
- if (timer
- .ReturnsTrueForEach(1))
+ if (throttleUpValue == 0.25f)
{
- if (throttleUpValue == 0.25f)
- keyThatDeterminesTheIncreaseOrDecreaseOfTheValues = Keys.NumPad3;
+ Yield();
+
+ keyThatDeterminesTheIncreaseOrDecreaseOfTheValues = Keys.NumPad3;
}
if (throttleUpValue > 0.25f)
- throttleUpValue -= throttleSensitivity;
- }
-
- void ThrottleUp()
- {
- if (throttleDownValue > 1f)
- throttleDownValue = 1f;
-
- if (throttleDownValue < 1f)
- throttleDownValue += throttleSensitivity;
+ throttleUpValue -= throttleSensitivity + (Game.LastFrameTime / 5f);
}
}
}
diff --git a/Alternative-throttle-control/tools/Timer.cs b/Alternative-throttle-control/tools/Timer.cs
deleted file mode 100644
index f8ad609..0000000
--- a/Alternative-throttle-control/tools/Timer.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using GTA;
-
-namespace Alternative_throttle_control.tools
-{
- internal sealed class Timer
- {
- private float _currentGameTime;
-
- private float _oldGameTime;
-
- public Timer()
- {
- _currentGameTime
- = Game
- .GameTime;
-
- _oldGameTime
- = Game
- .GameTime;
- }
-
- internal bool ReturnsTrueForEach(int milliseconds)
- {
- _currentGameTime
- = Game
- .GameTime;
-
- if (!(_currentGameTime > _oldGameTime + milliseconds))
- {
- return false;
- }
- {
- _oldGameTime
- = _currentGameTime;
-
- return true;
- }
- }
- }
-}
diff --git a/Alternative-throttle-control/user-interfaces/UserInterfaces.cs b/Alternative-throttle-control/user-interfaces/UserInterfaces.cs
index 64e9dd0..47c7b09 100644
--- a/Alternative-throttle-control/user-interfaces/UserInterfaces.cs
+++ b/Alternative-throttle-control/user-interfaces/UserInterfaces.cs
@@ -1,10 +1,5 @@
-using Alternative_throttle_control.settings;
-using Alternative_throttle_control.user_interfaces.creators.resources.structs;
-using Alternative_throttle_control.user_interfaces.interfaces;
-using Alternative_throttle_control.user_interfaces.managers;
+using Alternative_throttle_control.user_interfaces.interfaces;
using GTA;
-using GTA.UI;
-using System.Drawing;
namespace Alternative_throttle_control.user_interfaces
{
@@ -18,19 +13,20 @@ var throttleInterface
Tick += (o, e) =>
{
- if (Game.Player.Character.IsInFlyingVehicle)
+ if (Game
+ .IsControlJustPressed(Control
+ .VehicleExit))
{
- throttleInterface
- .BuildTheInterface();
-
- throttleInterface
- .ShowTheInterface();
+ Wait(5000);
return;
}
throttleInterface
- .RemoveTheInterface();
+ .BuildTheInterface();
+
+ throttleInterface
+ .ShowTheInterface();
};
Aborted += (o, e) =>
diff --git a/README.md b/README.md
index 9cb0db0..7dd127c 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-
+
About the mod