public CharacterUIEntry(ModifiedMenuPool pool, UIMenu mainMenu, string firstName, string lastName, string dateOfBirth, int gender) { var genderstring = "Male"; if (gender == 1) { genderstring = "Female"; } Menu = pool.AddSubMenuOffset(mainMenu, firstName + " " + lastName, firstName + "\n" + lastName + "\n" + dateOfBirth + "\n" + genderstring, new PointF(Screen.Width / 2, Screen.Height / 2)); SelectButton = new UIMenuItem("~b~Play This Character!"); YesButton = new UIMenuItem("~r~Delete!", "Permantly delete this character!"); NoButton = new UIMenuItem("~g~No!", "Dont permantly delete this character!"); DeleteMenu = pool.AddSubMenuOffset(Menu, "~r~Delete Character", new PointF(Screen.Width / 2, Screen.Height / 2)); DeleteMenu.AddItem(YesButton); DeleteMenu.AddItem(NoButton); Menu.AddItem(SelectButton); Menu.OnItemSelect += (sender, item, index) => { if (item == SelectButton) { Login.Instance.SelectCharacterRequest(firstName, lastName); } }; DeleteMenu.OnItemSelect += (sender, item, index) => { if (item == YesButton) { Login.Instance.DeleteCharacterRequest(firstName, lastName); } else if (item == NoButton) { DeleteMenu.Visible = false; Menu.Visible = true; } }; }
public Login() { Instance = this; EventHandlers["playerSpawned"] += new Action <ExpandoObject>(onSpawn); EventHandlers["refreshCharacters"] += new Action <dynamic, dynamic, dynamic, dynamic>(RefreshCharacters); EventHandlers["RequestReset"] += new Action(RequestReset); EventHandlers["characterSelected"] += new Action <dynamic, dynamic, dynamic, dynamic>(SelectCharacter); //UI CODE _loginMenuPool = new ModifiedMenuPool(); LoginUI(); _loginMenuPool.RefreshIndex(); _loginMenu.Visible = true; #pragma warning disable CS1998 // This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. Tick += new Func <Task>(async delegate #pragma warning restore CS1998 // This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. { if (API.UpdateOnscreenKeyboard() == 1 && _isKeyboardUp) { _creationMenu.MenuItems[_creationMenu.CurrentSelection].Text = new string(API.GetOnscreenKeyboardResult().Where(c => char.IsLetterOrDigit(c) || char.IsWhiteSpace(c) || c == '-' || c == '_').ToArray()); API.EnableAllControlActions(0); _isKeyboardUp = false; _creationMenu.Visible = true; } else if (API.UpdateOnscreenKeyboard() == 2 && _isKeyboardUp) { _isKeyboardUp = false; API.EnableAllControlActions(0); _creationMenu.Visible = true; } if (_loginMenuPool.IsAnyMenuOpen() == false && _hasChosenCharacter == false) { _loginMenu.Visible = true; } _loginMenuPool.ProcessMenus(); }); }