2022-05-23 11:10:11 +08:00
using System.Drawing ;
using System ;
using System.Windows.Forms ;
using GTA ;
2022-04-06 02:18:24 +02:00
using LemonUI.Menus ;
2021-08-06 12:31:25 +02:00
2022-05-22 15:55:26 +08:00
namespace RageCoop.Client.Menus.Sub
2021-08-06 12:31:25 +02:00
{
2021-12-03 20:30:00 +01:00
/// <summary>
/// Don't use it!
/// </summary>
2022-05-23 11:10:11 +08:00
public class SettingsMenu
2021-08-06 12:31:25 +02:00
{
2022-05-22 15:55:26 +08:00
public NativeMenu MainMenu = new NativeMenu ( "RAGECOOP" , "Settings" , "Go to the settings" )
2021-08-06 12:31:25 +02:00
{
UseMouse = false ,
2022-05-22 15:55:26 +08:00
Alignment = Main . Settings . FlipMenu ? GTA . UI . Alignment . Right : GTA . UI . Alignment . Left
2021-08-06 12:31:25 +02:00
} ;
2021-08-18 11:47:59 +02:00
2022-05-25 10:09:59 +08:00
private readonly NativeCheckboxItem _disableTrafficItem = new NativeCheckboxItem ( "Disable Traffic (NPCs/Vehicles)" , "Local traffic only" , Main . Settings . DisableTraffic ) ;
2022-05-22 15:55:26 +08:00
private readonly NativeCheckboxItem _flipMenuItem = new NativeCheckboxItem ( "Flip menu" , Main . Settings . FlipMenu ) ;
2022-05-25 11:32:34 +08:00
private readonly NativeCheckboxItem _disablePauseAlt = new NativeCheckboxItem ( "Disable Alternate Pause" , "Don't freeze game time when Esc pressed" , Main . Settings . DisableTraffic ) ;
2022-05-23 16:59:49 +08:00
private readonly NativeCheckboxItem _showNetworkInfoItem = new NativeCheckboxItem ( "Show Network Info" , Networking . ShowNetworkInfo ) ;
2022-05-25 11:32:34 +08:00
2022-05-23 11:10:11 +08:00
private static NativeItem _menuKey = new NativeItem ( "Menu Key" , "The key to open menu" , Main . Settings . MenuKey . ToString ( ) ) ;
private static NativeItem _passengerKey = new NativeItem ( "Passenger Key" , "The key to enter a vehicle as passenger" , Main . Settings . PassengerKey . ToString ( ) ) ;
2021-08-06 12:31:25 +02:00
2021-12-03 20:30:00 +01:00
/// <summary>
/// Don't use it!
/// </summary>
2022-05-23 11:10:11 +08:00
public SettingsMenu ( )
2021-08-06 12:31:25 +02:00
{
2022-04-06 02:18:24 +02:00
MainMenu . Banner . Color = Color . FromArgb ( 225 , 0 , 0 , 0 ) ;
MainMenu . Title . Color = Color . FromArgb ( 255 , 165 , 0 ) ;
2022-04-10 14:34:55 +02:00
_disableTrafficItem . CheckboxChanged + = DisableTrafficCheckboxChanged ;
2022-05-25 11:32:34 +08:00
_disablePauseAlt . CheckboxChanged + = _disablePauseAlt_CheckboxChanged ;
2022-04-10 14:34:55 +02:00
_flipMenuItem . CheckboxChanged + = FlipMenuCheckboxChanged ;
_showNetworkInfoItem . CheckboxChanged + = ShowNetworkInfoCheckboxChanged ;
2022-05-23 11:10:11 +08:00
_menuKey . Activated + = ChaneMenuKey ;
_passengerKey . Activated + = ChangePassengerKey ;
2021-08-06 12:31:25 +02:00
2022-04-10 14:34:55 +02:00
MainMenu . Add ( _disableTrafficItem ) ;
2022-05-25 11:32:34 +08:00
MainMenu . Add ( _disablePauseAlt ) ;
2022-04-10 14:34:55 +02:00
MainMenu . Add ( _flipMenuItem ) ;
MainMenu . Add ( _showNetworkInfoItem ) ;
2022-05-23 11:10:11 +08:00
MainMenu . Add ( _menuKey ) ;
MainMenu . Add ( _passengerKey ) ;
}
2022-05-25 11:32:34 +08:00
private void _disablePauseAlt_CheckboxChanged ( object sender , EventArgs e )
{
Main . Settings . DisableAlternatePause = _disablePauseAlt . Checked ;
Util . SaveSettings ( ) ;
}
2022-05-23 11:10:11 +08:00
private void ChaneMenuKey ( object sender , EventArgs e )
{
try
{
Main . Settings . MenuKey = ( Keys ) Enum . Parse (
typeof ( Keys ) ,
Game . GetUserInput ( WindowTitle . EnterMessage20 ,
Main . Settings . MenuKey . ToString ( ) , 20 ) ) ;
_menuKey . AltTitle = Main . Settings . MenuKey . ToString ( ) ;
2022-05-23 15:01:55 +08:00
Util . SaveSettings ( ) ;
2022-05-23 11:10:11 +08:00
}
catch { }
}
private void ChangePassengerKey ( object sender , EventArgs e )
{
try
{
Main . Settings . PassengerKey = ( Keys ) Enum . Parse (
typeof ( Keys ) ,
Game . GetUserInput ( WindowTitle . EnterMessage20 ,
Main . Settings . PassengerKey . ToString ( ) , 20 ) ) ;
_passengerKey . AltTitle = Main . Settings . PassengerKey . ToString ( ) ;
2022-05-23 15:01:55 +08:00
Util . SaveSettings ( ) ;
2022-05-23 11:10:11 +08:00
}
catch { }
2021-08-06 12:31:25 +02:00
}
2022-05-22 15:55:26 +08:00
public void DisableTrafficCheckboxChanged ( object a , System . EventArgs b )
2021-08-22 13:59:15 +02:00
{
2022-05-25 10:09:59 +08:00
Main . Settings . DisableTraffic = _disableTrafficItem . Checked ;
2022-05-25 11:32:34 +08:00
Util . SaveSettings ( ) ;
2021-08-22 13:59:15 +02:00
}
2022-05-22 15:55:26 +08:00
public void FlipMenuCheckboxChanged ( object a , System . EventArgs b )
2021-08-06 12:31:25 +02:00
{
2022-04-10 14:34:55 +02:00
Main . MainMenu . MainMenu . Alignment = _flipMenuItem . Checked ? GTA . UI . Alignment . Right : GTA . UI . Alignment . Left ;
2022-05-23 11:10:11 +08:00
2022-04-10 14:34:55 +02:00
MainMenu . Alignment = _flipMenuItem . Checked ? GTA . UI . Alignment . Right : GTA . UI . Alignment . Left ;
2022-05-22 15:55:26 +08:00
Main . Settings . FlipMenu = _flipMenuItem . Checked ;
2021-08-06 12:31:25 +02:00
Util . SaveSettings ( ) ;
}
2022-05-22 15:55:26 +08:00
public void ShowNetworkInfoCheckboxChanged ( object a , System . EventArgs b )
2021-08-18 11:47:59 +02:00
{
2022-05-23 16:59:49 +08:00
Networking . ShowNetworkInfo = _showNetworkInfoItem . Checked ;
2021-08-18 11:47:59 +02:00
2022-05-23 16:59:49 +08:00
if ( ! Networking . ShowNetworkInfo )
2021-08-18 11:47:59 +02:00
{
2022-05-23 16:59:49 +08:00
Networking . BytesReceived = 0 ;
Networking . BytesSend = 0 ;
2021-08-18 11:47:59 +02:00
}
}
2021-08-06 12:31:25 +02:00
}
}