Skip to content

Commit

Permalink
📝 Adding the codes from version [0.1.0.2] (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
niziul authored Mar 31, 2023
1 parent 9ef7d9a commit b0fb410
Show file tree
Hide file tree
Showing 20 changed files with 352 additions and 239 deletions.
9 changes: 6 additions & 3 deletions Alternative-yaw-control/Alternative-yaw-control.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="ScriptHookVDotNet3">
<HintPath>..\..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto V\ScriptHookVDotNet3.dll</HintPath>
<Reference Include="ScriptHookVDotNet3, Version=3.6.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\ScriptHookVDotNet3.3.6.0\lib\net48\ScriptHookVDotNet3.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -44,8 +44,8 @@
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="script\AlternativeYawControl.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 All @@ -59,6 +59,9 @@
<Compile Include="user-interfaces\UserInterfaces.cs" />
<Compile Include="user-interfaces\interfaces\YawInterface.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy "$(ProjectDir)\bin\Debug\Alternative-yaw-control.dll" /y "C:\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto V\scripts"</PostBuildEvent>
Expand Down
192 changes: 71 additions & 121 deletions Alternative-yaw-control/Main.cs
Original file line number Diff line number Diff line change
@@ -1,156 +1,106 @@
using GTA;
using GTAControl
= GTA.Control;

using System.Windows.Forms;

using CTimer
= Alternative_yaw_control.tools.Timer;

using Alternative_throttle_control.settings;
using Alternative_yaw_control.script;
using Alternative_yaw_control.user_interfaces;
using GTA;

namespace Alternative_yaw_control
{
internal class Main : Script
internal sealed class Main : Script
{
private readonly Keys _keyForTheYawRigth;

private readonly Keys _keyForTheYawLeft;

private float _yawSensitivity;
private AlternativeYawControl _alternativeYawControl;

private float _yawRigthValue;

private float _yawLeftValue;
private UserInterfaces _userInterfaces;

public Main()
{
var keyThatDeterminesTheIncreaseOrDecreaseOfTheValues
= Keys.NumPad2;

var timer
= new CTimer();

var settingsManager
= new SettingsManager();
Tick += (o, e) =>
{
if (Game.IsLoading)
{
return;
}
_keyForTheYawRigth
= settingsManager
.ReturnTheKeyForTheYawRight();
switch (Game.Player.Character.IsInFlyingVehicle)
{
case true:
{
if (_alternativeYawControl is null
||
_userInterfaces is null)
{
_alternativeYawControl
= InstantiateScript<AlternativeYawControl>();
_keyForTheYawLeft
= settingsManager
.ReturnTheKeyForTheYawLeft();
_userInterfaces
= InstantiateScript<UserInterfaces>();
_yawSensitivity
= settingsManager
.ReturnTheYawSensitivity();
_alternativeYawControl
.Resume();
_yawRigthValue
= 0.25f;
_yawLeftValue
= 0.25f;
_userInterfaces
.Resume();
}
Tick += (o, e) =>
{
switch (Game.Player.Character.IsInFlyingVehicle)
{
case false:
{
if (_yawRigthValue != 0.25f)
_yawRigthValue = 0.25f;
if (_alternativeYawControl.IsPaused
||
_userInterfaces.IsPaused)
{
_alternativeYawControl
.Resume();
if (_yawLeftValue != 0.25f)
_yawLeftValue = 0.25f;
_userInterfaces
.Resume();
}
}
return;
case true:
case false:
{
Game
.SetControlValueNormalized(GTAControl
.VehicleFlyYawRight, _yawRigthValue);
Game
.SetControlValueNormalized(GTAControl
.VehicleFlyYawLeft, _yawLeftValue);
if (Game
.IsKeyPressed(_keyForTheYawRigth))
if (_alternativeYawControl is null
||
_userInterfaces is null)
{
if (keyThatDeterminesTheIncreaseOrDecreaseOfTheValues == _keyForTheYawRigth)
{
if (_yawRigthValue > 1f)
_yawRigthValue = 1f;
if (_yawRigthValue < 1f)
_yawRigthValue += _yawSensitivity;
}
if (keyThatDeterminesTheIncreaseOrDecreaseOfTheValues == _keyForTheYawLeft)
{
if (_yawLeftValue < 0.25f)
_yawLeftValue = 0.25f;
if (timer
.ReturnsTrueForEach(1))
{
if (_yawLeftValue == 0.25f)
keyThatDeterminesTheIncreaseOrDecreaseOfTheValues = Keys.NumPad2;
}
if (_yawLeftValue > 0.25f)
_yawLeftValue -= _yawSensitivity;
}
return;
}
if (Game
.IsKeyPressed(_keyForTheYawLeft))
if (_alternativeYawControl.IsPaused
||
_userInterfaces.IsPaused)
{
if (keyThatDeterminesTheIncreaseOrDecreaseOfTheValues == _keyForTheYawRigth)
{
if (_yawRigthValue < 0.25f)
_yawRigthValue = 0.25f;
if (timer
.ReturnsTrueForEach(1))
{
if (_yawRigthValue == 0.25f)
keyThatDeterminesTheIncreaseOrDecreaseOfTheValues = Keys.NumPad2;
}
if (_yawRigthValue > 0.25f)
_yawRigthValue -= _yawSensitivity;
}
if (keyThatDeterminesTheIncreaseOrDecreaseOfTheValues == _keyForTheYawLeft)
{
if (_yawLeftValue > 1f)
_yawLeftValue = 1f;
if (_yawLeftValue < 1f)
_yawLeftValue += _yawSensitivity;
}
return;
}
_alternativeYawControl
.Pause();
_userInterfaces
.Pause();
}
return;
}
}
Interval = 2000;
};

KeyDown += (o, e) =>
Aborted += (o, e) =>
{
if (e.KeyCode == _keyForTheYawRigth
if (_alternativeYawControl is null
||
e.KeyCode == _keyForTheYawLeft)
_userInterfaces is null)
{
if (keyThatDeterminesTheIncreaseOrDecreaseOfTheValues == Keys.NumPad2)
{
keyThatDeterminesTheIncreaseOrDecreaseOfTheValues = e.KeyCode;
}
return;
}
_alternativeYawControl
.Abort();
_userInterfaces
.Abort();
_alternativeYawControl
= null;
_userInterfaces
= null;
};
}
}
}
}
38 changes: 38 additions & 0 deletions Alternative-yaw-control/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Alternative-yaw-control")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Alternative-yaw-control")]
[assembly: AssemblyCopyright("Copyright © 2022 - 2023 niziulluizin")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("61654175-D64A-4B55-8544-5C2290D06A0B")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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.0.2")]
[assembly: AssemblyFileVersion("0.1.0.2")]
[assembly: NeutralResourcesLanguage("en")]
4 changes: 4 additions & 0 deletions Alternative-yaw-control/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ScriptHookVDotNet3" version="3.6.0" targetFramework="net48" />
</packages>
Loading

0 comments on commit b0fb410

Please sign in to comment.