2021-08-06 12:31:25 +02:00
|
|
|
|
using GTA;
|
2022-09-06 21:46:35 +08:00
|
|
|
|
using GTA.Native;
|
2021-08-06 12:31:25 +02:00
|
|
|
|
using LemonUI;
|
|
|
|
|
using LemonUI.Menus;
|
2022-06-19 15:04:38 +08:00
|
|
|
|
using LemonUI.Scaleform;
|
2022-07-20 17:50:01 +08:00
|
|
|
|
using System.Drawing;
|
2021-08-06 12:31:25 +02:00
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
namespace RageCoop.Client.Menus
|
2021-08-06 12:31:25 +02:00
|
|
|
|
{
|
2021-12-03 20:30:00 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Don't use it!
|
|
|
|
|
/// </summary>
|
2022-05-31 09:14:30 +08:00
|
|
|
|
internal static class CoopMenu
|
2021-08-06 12:31:25 +02:00
|
|
|
|
{
|
2022-05-31 09:14:30 +08:00
|
|
|
|
public static ObjectPool MenuPool = new ObjectPool();
|
|
|
|
|
public static NativeMenu Menu = new NativeMenu("RAGECOOP", "MAIN")
|
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
|
|
|
|
};
|
2022-07-20 17:50:01 +08:00
|
|
|
|
public static PopUp PopUp = new PopUp()
|
2022-06-19 15:04:38 +08:00
|
|
|
|
{
|
2022-09-06 21:46:35 +08:00
|
|
|
|
Title = "",
|
|
|
|
|
Prompt = "",
|
2022-06-19 15:04:38 +08:00
|
|
|
|
Subtitle = "",
|
2022-09-06 21:46:35 +08:00
|
|
|
|
Error = "",
|
2022-06-19 15:04:38 +08:00
|
|
|
|
ShowBackground = true,
|
2022-09-06 21:46:35 +08:00
|
|
|
|
Visible = false,
|
2022-06-19 15:04:38 +08:00
|
|
|
|
};
|
2022-05-31 09:14:30 +08:00
|
|
|
|
public static NativeMenu LastMenu { get; set; } = Menu;
|
2021-09-27 20:28:27 +02:00
|
|
|
|
#region ITEMS
|
2022-05-31 09:14:30 +08:00
|
|
|
|
private static readonly NativeItem _usernameItem = new NativeItem("Username") { AltTitle = Main.Settings.Username };
|
2022-07-20 17:50:01 +08:00
|
|
|
|
private static readonly NativeItem _passwordItem = new NativeItem("Password") { AltTitle = new string('*', Main.Settings.Password.Length) };
|
2022-06-24 16:49:59 +08:00
|
|
|
|
|
2022-05-31 09:14:30 +08:00
|
|
|
|
public static readonly NativeItem ServerIpItem = new NativeItem("Server IP") { AltTitle = Main.Settings.LastServerAddress };
|
2022-07-11 11:06:31 +08:00
|
|
|
|
internal static readonly NativeItem _serverConnectItem = new NativeItem("Connect");
|
2022-05-31 09:14:30 +08:00
|
|
|
|
private static readonly NativeItem _aboutItem = new NativeItem("About", "~y~SOURCE~s~~n~" +
|
2022-04-06 02:18:24 +02:00
|
|
|
|
"https://github.com/RAGECOOP~n~" +
|
2021-09-27 20:28:27 +02:00
|
|
|
|
"~y~VERSION~s~~n~" +
|
2022-08-16 23:17:04 +08:00
|
|
|
|
Main.Version)
|
2022-07-20 17:50:01 +08:00
|
|
|
|
{ LeftBadge = new LemonUI.Elements.ScaledTexture("commonmenu", "shop_new_star") };
|
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
2021-09-27 20:28:27 +02:00
|
|
|
|
#endregion
|
2021-08-06 12:31:25 +02:00
|
|
|
|
|
2021-12-03 20:30:00 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Don't use it!
|
|
|
|
|
/// </summary>
|
2022-05-31 09:14:30 +08:00
|
|
|
|
static CoopMenu()
|
2021-08-06 12:31:25 +02:00
|
|
|
|
{
|
2022-06-19 15:04:38 +08:00
|
|
|
|
|
2022-05-31 09:14:30 +08:00
|
|
|
|
Menu.Banner.Color = Color.FromArgb(225, 0, 0, 0);
|
2023-10-18 16:57:19 -03:00
|
|
|
|
Menu.BannerText.Color = Color.FromArgb(255, 165, 0);
|
2022-04-06 02:18:24 +02:00
|
|
|
|
|
2022-04-10 14:34:55 +02:00
|
|
|
|
_usernameItem.Activated += UsernameActivated;
|
2022-09-06 21:46:35 +08:00
|
|
|
|
_passwordItem.Activated += _passwordActivated;
|
2021-08-06 12:31:25 +02:00
|
|
|
|
ServerIpItem.Activated += ServerIpActivated;
|
2022-05-31 23:12:32 -08:00
|
|
|
|
_serverConnectItem.Activated += (sender, item) => { Networking.ToggleConnection(Main.Settings.LastServerAddress); };
|
2021-08-06 12:31:25 +02:00
|
|
|
|
|
2021-12-04 21:34:43 +01:00
|
|
|
|
|
2022-05-31 23:12:32 -08:00
|
|
|
|
Menu.AddSubMenu(ServersMenu.Menu);
|
|
|
|
|
|
2022-05-31 09:14:30 +08:00
|
|
|
|
Menu.Add(_usernameItem);
|
2022-06-24 16:49:59 +08:00
|
|
|
|
Menu.Add(_passwordItem);
|
2022-05-31 09:14:30 +08:00
|
|
|
|
Menu.Add(ServerIpItem);
|
|
|
|
|
Menu.Add(_serverConnectItem);
|
2021-08-06 12:31:25 +02:00
|
|
|
|
|
2022-05-31 09:14:30 +08:00
|
|
|
|
Menu.AddSubMenu(SettingsMenu.Menu);
|
|
|
|
|
Menu.AddSubMenu(DevToolMenu.Menu);
|
2023-07-24 10:40:33 -03:00
|
|
|
|
#if DEBUG
|
2022-05-31 09:14:30 +08:00
|
|
|
|
Menu.AddSubMenu(DebugMenu.Menu);
|
2023-07-24 10:40:33 -03:00
|
|
|
|
#endif
|
2022-05-27 14:33:33 +08:00
|
|
|
|
|
2022-05-31 09:14:30 +08:00
|
|
|
|
MenuPool.Add(Menu);
|
|
|
|
|
MenuPool.Add(SettingsMenu.Menu);
|
2022-05-27 14:33:33 +08:00
|
|
|
|
MenuPool.Add(DevToolMenu.Menu);
|
2023-07-24 10:40:33 -03:00
|
|
|
|
#if DEBUG
|
2022-05-27 14:33:33 +08:00
|
|
|
|
MenuPool.Add(DebugMenu.Menu);
|
2022-05-23 11:10:11 +08:00
|
|
|
|
MenuPool.Add(DebugMenu.DiagnosticMenu);
|
2023-07-24 10:40:33 -03:00
|
|
|
|
#endif
|
2022-05-31 23:12:32 -08:00
|
|
|
|
MenuPool.Add(ServersMenu.Menu);
|
2022-06-19 15:04:38 +08:00
|
|
|
|
MenuPool.Add(PopUp);
|
2022-05-30 14:32:38 +08:00
|
|
|
|
|
2022-05-31 09:14:30 +08:00
|
|
|
|
Menu.Add(_aboutItem);
|
2021-08-06 12:31:25 +02:00
|
|
|
|
}
|
2022-06-24 16:49:59 +08:00
|
|
|
|
|
|
|
|
|
|
2022-07-20 17:50:01 +08:00
|
|
|
|
public static bool ShowPopUp(string prompt, string title, string subtitle, string error, bool showbackground)
|
2022-06-19 15:04:38 +08:00
|
|
|
|
{
|
2022-09-06 21:46:35 +08:00
|
|
|
|
PopUp.Prompt = prompt;
|
|
|
|
|
PopUp.Title = title;
|
|
|
|
|
PopUp.Subtitle = subtitle;
|
|
|
|
|
PopUp.Error = error;
|
|
|
|
|
PopUp.ShowBackground = showbackground;
|
|
|
|
|
PopUp.Visible = true;
|
2022-08-18 17:45:08 +08:00
|
|
|
|
Script.Yield();
|
2022-06-19 15:04:38 +08:00
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
Game.DisableAllControlsThisFrame();
|
|
|
|
|
MenuPool.Process();
|
2022-08-25 00:58:21 +08:00
|
|
|
|
|
|
|
|
|
var scaleform = new Scaleform("instructional_buttons");
|
|
|
|
|
scaleform.CallFunction("CLEAR_ALL");
|
|
|
|
|
scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
|
|
|
|
|
scaleform.CallFunction("CREATE_CONTAINER");
|
|
|
|
|
|
|
|
|
|
scaleform.CallFunction("SET_DATA_SLOT", 0, Function.Call<string>((Hash)0x0499D7B09FC9B407, 2, (int)Control.FrontendAccept, 0), "Continue");
|
|
|
|
|
scaleform.CallFunction("SET_DATA_SLOT", 1, Function.Call<string>((Hash)0x0499D7B09FC9B407, 2, (int)Control.FrontendCancel, 0), "Cancel");
|
|
|
|
|
scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
|
|
|
|
|
scaleform.Render2D();
|
2022-06-19 15:04:38 +08:00
|
|
|
|
if (Game.IsControlJustPressed(Control.FrontendAccept))
|
|
|
|
|
{
|
2022-09-06 21:46:35 +08:00
|
|
|
|
PopUp.Visible = false;
|
2022-06-19 15:04:38 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (Game.IsControlJustPressed(Control.FrontendCancel))
|
|
|
|
|
{
|
|
|
|
|
PopUp.Visible = false;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-09-06 21:46:35 +08:00
|
|
|
|
Script.Yield();
|
2022-08-24 19:26:40 +08:00
|
|
|
|
Game.DisableAllControlsThisFrame();
|
|
|
|
|
|
2022-06-19 15:04:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-31 09:14:30 +08:00
|
|
|
|
public static void UsernameActivated(object a, System.EventArgs b)
|
2021-08-06 12:31:25 +02:00
|
|
|
|
{
|
2022-04-10 14:34:55 +02:00
|
|
|
|
string newUsername = Game.GetUserInput(WindowTitle.EnterMessage20, _usernameItem.AltTitle, 20);
|
2021-08-06 12:31:25 +02:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(newUsername))
|
|
|
|
|
{
|
2022-05-22 15:55:26 +08:00
|
|
|
|
Main.Settings.Username = newUsername;
|
2021-08-06 12:31:25 +02:00
|
|
|
|
Util.SaveSettings();
|
|
|
|
|
|
2022-04-10 14:34:55 +02:00
|
|
|
|
_usernameItem.AltTitle = newUsername;
|
2021-08-06 12:31:25 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-24 16:49:59 +08:00
|
|
|
|
private static void _passwordActivated(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string newPass = Game.GetUserInput(WindowTitle.EnterMessage20, "", 20);
|
2022-08-18 17:45:08 +08:00
|
|
|
|
Main.Settings.Password = newPass;
|
|
|
|
|
Util.SaveSettings();
|
|
|
|
|
_passwordItem.AltTitle = new string('*', newPass.Length);
|
2022-06-24 16:49:59 +08:00
|
|
|
|
}
|
2022-05-31 09:14:30 +08:00
|
|
|
|
public static void ServerIpActivated(object a, System.EventArgs b)
|
2021-08-06 12:31:25 +02:00
|
|
|
|
{
|
|
|
|
|
string newServerIp = Game.GetUserInput(WindowTitle.EnterMessage60, ServerIpItem.AltTitle, 60);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(newServerIp) && newServerIp.Contains(":"))
|
|
|
|
|
{
|
2022-05-22 15:55:26 +08:00
|
|
|
|
Main.Settings.LastServerAddress = newServerIp;
|
2021-08-06 12:31:25 +02:00
|
|
|
|
Util.SaveSettings();
|
|
|
|
|
|
|
|
|
|
ServerIpItem.AltTitle = newServerIp;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-26 20:52:23 -06:00
|
|
|
|
|
2022-05-31 09:14:30 +08:00
|
|
|
|
public static void InitiateConnectionMenuSetting()
|
2021-09-26 20:52:23 -06:00
|
|
|
|
{
|
2022-05-30 14:32:38 +08:00
|
|
|
|
_usernameItem.Enabled = false;
|
|
|
|
|
ServerIpItem.Enabled = false;
|
|
|
|
|
_serverConnectItem.Enabled = false;
|
2021-09-26 20:52:23 -06:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-31 09:14:30 +08:00
|
|
|
|
public static void ConnectedMenuSetting()
|
2021-09-26 20:52:23 -06:00
|
|
|
|
{
|
2022-05-30 14:32:38 +08:00
|
|
|
|
_serverConnectItem.Enabled = true;
|
|
|
|
|
_serverConnectItem.Title = "Disconnect";
|
2022-05-31 09:14:30 +08:00
|
|
|
|
Menu.Visible = false;
|
2021-09-26 20:52:23 -06:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-31 09:14:30 +08:00
|
|
|
|
public static void DisconnectedMenuSetting()
|
2021-09-26 20:52:23 -06:00
|
|
|
|
{
|
2022-05-30 14:32:38 +08:00
|
|
|
|
_usernameItem.Enabled = true;
|
|
|
|
|
ServerIpItem.Enabled = true;
|
|
|
|
|
_serverConnectItem.Enabled = true;
|
|
|
|
|
_serverConnectItem.Title = "Connect";
|
2021-09-26 20:52:23 -06:00
|
|
|
|
}
|
2021-08-06 12:31:25 +02:00
|
|
|
|
}
|
|
|
|
|
}
|