2021-08-06 12:31:25 +02:00
|
|
|
|
using GTA;
|
|
|
|
|
|
|
|
|
|
using LemonUI;
|
|
|
|
|
using LemonUI.Menus;
|
|
|
|
|
|
|
|
|
|
namespace CoopClient.Menus
|
|
|
|
|
{
|
2021-11-28 23:35:37 +01:00
|
|
|
|
internal class MenusMain
|
2021-08-06 12:31:25 +02:00
|
|
|
|
{
|
|
|
|
|
public ObjectPool MenuPool = new ObjectPool();
|
|
|
|
|
|
2021-09-27 20:28:27 +02:00
|
|
|
|
public NativeMenu MainMenu = new NativeMenu("GTACOOP:R", "MAIN")
|
2021-08-06 12:31:25 +02:00
|
|
|
|
{
|
|
|
|
|
UseMouse = false,
|
|
|
|
|
Alignment = Main.MainSettings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
|
|
|
|
|
};
|
2021-09-27 20:28:27 +02:00
|
|
|
|
#region SUB
|
2021-08-06 12:31:25 +02:00
|
|
|
|
public Sub.Settings SubSettings = new Sub.Settings();
|
|
|
|
|
#endregion
|
|
|
|
|
|
2021-09-27 20:28:27 +02:00
|
|
|
|
#region ITEMS
|
2021-08-06 12:31:25 +02:00
|
|
|
|
private readonly NativeItem UsernameItem = new NativeItem("Username") { AltTitle = Main.MainSettings.Username };
|
|
|
|
|
private readonly NativeItem ServerIpItem = new NativeItem("Server IP") { AltTitle = Main.MainSettings.LastServerAddress };
|
|
|
|
|
private readonly NativeItem ServerConnectItem = new NativeItem("Connect");
|
2021-09-27 20:28:27 +02:00
|
|
|
|
private readonly NativeItem AboutItem = new NativeItem("About", "~y~SOURCE~s~~n~" +
|
|
|
|
|
"https://github.com/GTACOOP-R~n~" +
|
|
|
|
|
"~y~VERSION~s~~n~" +
|
2021-09-28 16:51:16 +02:00
|
|
|
|
Main.CurrentVersion.Replace("_", ".")) { LeftBadge = new LemonUI.Elements.ScaledTexture("commonmenu", "shop_new_star") };
|
2021-09-27 20:28:27 +02:00
|
|
|
|
#endregion
|
2021-08-06 12:31:25 +02:00
|
|
|
|
|
|
|
|
|
public MenusMain()
|
|
|
|
|
{
|
|
|
|
|
UsernameItem.Activated += UsernameActivated;
|
|
|
|
|
ServerIpItem.Activated += ServerIpActivated;
|
|
|
|
|
ServerConnectItem.Activated += (sender, item) => { Main.MainNetworking.DisConnectFromServer(Main.MainSettings.LastServerAddress); };
|
|
|
|
|
|
|
|
|
|
MainMenu.Add(UsernameItem);
|
|
|
|
|
MainMenu.Add(ServerIpItem);
|
|
|
|
|
MainMenu.Add(ServerConnectItem);
|
|
|
|
|
|
|
|
|
|
MainMenu.AddSubMenu(SubSettings.MainMenu);
|
|
|
|
|
|
|
|
|
|
MainMenu.Add(AboutItem);
|
|
|
|
|
|
|
|
|
|
MenuPool.Add(MainMenu);
|
|
|
|
|
MenuPool.Add(SubSettings.MainMenu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UsernameActivated(object a, System.EventArgs b)
|
|
|
|
|
{
|
|
|
|
|
string newUsername = Game.GetUserInput(WindowTitle.EnterMessage20, UsernameItem.AltTitle, 20);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(newUsername))
|
|
|
|
|
{
|
|
|
|
|
Main.MainSettings.Username = newUsername;
|
|
|
|
|
Util.SaveSettings();
|
|
|
|
|
|
|
|
|
|
UsernameItem.AltTitle = newUsername;
|
|
|
|
|
MenuPool.RefreshAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ServerIpActivated(object a, System.EventArgs b)
|
|
|
|
|
{
|
|
|
|
|
string newServerIp = Game.GetUserInput(WindowTitle.EnterMessage60, ServerIpItem.AltTitle, 60);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(newServerIp) && newServerIp.Contains(":"))
|
|
|
|
|
{
|
|
|
|
|
Main.MainSettings.LastServerAddress = newServerIp;
|
|
|
|
|
Util.SaveSettings();
|
|
|
|
|
|
|
|
|
|
ServerIpItem.AltTitle = newServerIp;
|
|
|
|
|
MenuPool.RefreshAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-26 20:52:23 -06:00
|
|
|
|
|
|
|
|
|
public void InitiateConnectionMenuSetting()
|
|
|
|
|
{
|
|
|
|
|
MainMenu.Items[0].Enabled = false;
|
|
|
|
|
MainMenu.Items[1].Enabled = false;
|
|
|
|
|
MainMenu.Items[2].Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ConnectedMenuSetting()
|
|
|
|
|
{
|
|
|
|
|
MainMenu.Items[2].Enabled = true;
|
|
|
|
|
MainMenu.Items[2].Title = "Disconnect";
|
|
|
|
|
SubSettings.MainMenu.Items[1].Enabled = !Main.DisableTraffic && Main.NpcsAllowed;
|
|
|
|
|
|
|
|
|
|
MainMenu.Visible = false;
|
|
|
|
|
MenuPool.RefreshAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DisconnectedMenuSetting()
|
|
|
|
|
{
|
|
|
|
|
MainMenu.Items[0].Enabled = true;
|
|
|
|
|
MainMenu.Items[1].Enabled = true;
|
|
|
|
|
MainMenu.Items[2].Enabled = true;
|
|
|
|
|
MainMenu.Items[2].Title = "Connect";
|
|
|
|
|
SubSettings.MainMenu.Items[1].Enabled = false;
|
|
|
|
|
|
|
|
|
|
MenuPool.RefreshAll();
|
|
|
|
|
}
|
2021-08-06 12:31:25 +02:00
|
|
|
|
}
|
|
|
|
|
}
|