Skip to content

Commit

Permalink
📝 Adding the codes from version [0.1.3.1] (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
niziul authored Mar 30, 2023
1 parent d515ff4 commit 2a089e6
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="alternative-throttle-control\AlternativeThrottleControl.cs" />
<Compile Include="script\AlternativeThrottleControl.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="settings\SettingsManager.cs" />
<Compile Include="tools\Timer.cs" />
<Compile Include="user-interfaces\creators\ContainerElementCreator.cs" />
<Compile Include="user-interfaces\creators\CustomSpriteCreator.cs" />
<Compile Include="user-interfaces\creators\resources\interfaces\IConfiguration.cs" />
Expand Down
31 changes: 17 additions & 14 deletions Alternative-throttle-control/Main.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -23,9 +24,9 @@ public Main()
{
case true:
{
if (_alternativeThrottleControl == null
if (_alternativeThrottleControl is null
||
_userInterfaces == null)
_userInterfaces is null)
{
_alternativeThrottleControl
= InstantiateScript<AlternativeThrottleControl>();
Expand Down Expand Up @@ -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;
}
Expand All @@ -80,9 +83,9 @@ public Main()

Aborted += (o, e) =>
{
if (_alternativeThrottleControl == null
if (_alternativeThrottleControl is null
||
_userInterfaces == null)
_userInterfaces is null)
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Alternative-throttle-control/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,9 +15,6 @@ public AlternativeThrottleControl()
var keyThatDeterminesTheIncreaseOrDecreaseOfTheValues
= Keys.NumPad3;

var timer
= new CTimer();

var settingsManager
= new SettingsManager();

Expand All @@ -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;
}
};

Expand Down Expand Up @@ -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);
}
}
}
Expand Down
40 changes: 0 additions & 40 deletions Alternative-throttle-control/tools/Timer.cs

This file was deleted.

22 changes: 9 additions & 13 deletions Alternative-throttle-control/user-interfaces/UserInterfaces.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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) =>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p><a href="https://www.gta5-mods.com/scripts/accurate-throttle-for-aircraft-keyboards#description_tab" target="_blank"><img alt="Alternative Yaw Control - Keyboards" src="/Repository-assets/Alternative-throttle-control/Cover.png" /></a></p>
<p><a href="https://www.gta5-mods.com/scripts/accurate-throttle-for-aircraft-keyboards#description_tab" target="_blank"><img alt="Alternative Yaw Control - Keyboards" src="https://img.gta5-mods.com/q95/images/accurate-throttle-for-aircraft-keyboards/a08472-alternative-throttle-input-control.png" /></a></p>

<p><strong>About the mod</strong></p>

Expand Down

0 comments on commit 2a089e6

Please sign in to comment.