<commit_before>﻿// Original Work Copyright (c) <NAME> 2014-2016
// This file is subject to the GPL v2 License
// For additional details, see the LICENSE file

using System;
using System.Linq;
using EndlessClient.Controllers;
using EndlessClient.GameExecution;
using EndlessClient.Input;
using EndlessClient.UIControls;
using EOLib;
using EOLib.Data.Account;
using EOLib.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using XNAControls;

namespace EndlessClient.ControlSets
{
	public class CreateAccountControlSet : BaseControlSet
	{
		private readonly KeyboardDispatcher _dispatcher;
		private readonly IMainButtonController _mainButtonController;
		private readonly ICreateAccountController _createAccountController;
		private readonly Texture2D[] _personSet2;
		private readonly Random _randomGen;

		private Texture2D _backButtonTexture;

		private XNATextBox _tbAccountName,
						   _tbPassword,
						   _tbConfirm,
						   _tbRealName,
						   _tbLocation,
						   _tbEmail;
		private XNAButton _btnCreate,
						  _btnCancel,
						  _backButton;
		private PictureBox _person2Picture;

		private TextBoxClickEventHandler _clickHandler;
		private TextBoxTabEventHandler _tabHandler;

		public override GameStates GameState { get { return GameStates.CreateAccount; } }

		public CreateAccountControlSet(KeyboardDispatcher dispatcher,
									   IMainButtonController mainButtonController,
									   ICreateAccountController createAccountController)
		{
			_dispatcher = dispatcher;
			_mainButtonController = mainButtonController;
			_createAccountController = createAccountController;
			_personSet2 = new Texture2D[8];
			_randomGen = new Random();
		}

		public override void InitializeResources(INativeGraphicsManager gfxManager, ContentManager xnaContentManager)
		{
			base.InitializeResources(gfxManager, xnaContentManager);

			for (int i = 0; i < _personSet2.Length; ++i)
				_personSet2[i] = gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 61 + i, true);

			_backButtonTexture = gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 24, true);
		}

		protected override void InitializeControlsHelper(IControlSet currentControlSet)
		{
			_tbAccountName = GetControl(currentControlSet, GameControlIdentifier.CreateAccountName, GetCreateAccountNameTextBox);
			_tbPassword = GetControl(currentControlSet, GameControlIdentifier.CreateAccountPassword, GetCreateAccountPasswordTextBox);
			_tbConfirm = GetControl(currentControlSet, GameControlIdentifier.CreateAccountPasswordConfirm, GetCreateAccountConfirmTextBox);
			_tbRealName = GetControl(currentControlSet, GameControlIdentifier.CreateAccountRealName, GetCreateAccountRealNameTextBox);
			_tbLocation = GetControl(currentControlSet, GameControlIdentifier.CreateAccountLocation, GetCreateAccountLocationTextBox);
			_tbEmail = GetControl(currentControlSet, GameControlIdentifier.CreateAccountEmail, GetCreateAccountEmailTextBox);
			_btnCreate = GetControl(currentControlSet, GameControlIdentifier.CreateAccountButton, () => GetCreateButton(false));
			_btnCancel = GetControl(currentControlSet, GameControlIdentifier.CreateAccountCancelButton, GetCreateAccountCancelButton);
			_backButton = GetControl(currentControlSet, GameControlIdentifier.BackButton, GetBackButton);
			_person2Picture = GetControl(currentControlSet, GameControlIdentifier.PersonDisplay2, GetPerson2Picture);

			_allComponents.Add(_tbAccountName);
			_allComponents.Add(_tbPassword);
			_allComponents.Add(_tbConfirm);
			_allComponents.Add(_tbRealName);
			_allComponents.Add(_tbLocation);
			_allComponents.Add(_tbEmail);
			_allComponents.Add(_btnCreate);
			_allComponents.Add(_btnCancel);
			_allComponents.Add(_person2Picture);

			var textBoxes = _allComponents.OfType<XNATextBox>().ToArray();
			_clickHandler = new TextBoxClickEventHandler(_dispatcher, textBoxes);
			_tabHandler = new TextBoxTabEventHandler(_dispatcher, textBoxes);

			if (_dispatcher.Subscriber != null)
				_dispatcher.Subscriber.Selected = false;
			_dispatcher.Subscriber = _tbAccountName;
			_dispatcher.Subscriber.Selected = true;
		}

		public override IGameComponent FindComponentByControlIdentifier(GameControlIdentifier control)
		{<commit_msg>Fix bug where back button didn't disappear<commit_after>﻿// Original Work Copyright (c) <NAME> 2014-2016
// This file is subject to the GPL v2 License
// For additional details, see the LICENSE file

using System;
using System.Linq;
using EndlessClient.Controllers;
using EndlessClient.GameExecution;
using EndlessClient.Input;
using EndlessClient.UIControls;
using EOLib;
using EOLib.Data.Account;
using EOLib.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using XNAControls;

namespace EndlessClient.ControlSets
{
	public class CreateAccountControlSet : BaseControlSet
	{
		private readonly KeyboardDispatcher _dispatcher;
		private readonly IMainButtonController _mainButtonController;
		private readonly ICreateAccountController _createAccountController;
		private readonly Texture2D[] _personSet2;
		private readonly Random _randomGen;

		private Texture2D _backButtonTexture;

		private XNATextBox _tbAccountName,
						   _tbPassword,
						   _tbConfirm,
						   _tbRealName,
						   _tbLocation,
						   _tbEmail;
		private XNAButton _btnCreate,
						  _btnCancel,
						  _backButton;
		private PictureBox _person2Picture;

		private TextBoxClickEventHandler _clickHandler;
		private TextBoxTabEventHandler _tabHandler;

		public override GameStates GameState { get { return GameStates.CreateAccount; } }

		public CreateAccountControlSet(KeyboardDispatcher dispatcher,
									   IMainButtonController mainButtonController,
									   ICreateAccountController createAccountController)
		{
			_dispatcher = dispatcher;
			_mainButtonController = mainButtonController;
			_createAccountController = createAccountController;
			_personSet2 = new Texture2D[8];
			_randomGen = new Random();
		}

		public override void InitializeResources(INativeGraphicsManager gfxManager, ContentManager xnaContentManager)
		{
			base.InitializeResources(gfxManager, xnaContentManager);

			for (int i = 0; i < _personSet2.Length; ++i)
				_personSet2[i] = gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 61 + i, true);

			_backButtonTexture = gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 24, true);
		}

		protected override void InitializeControlsHelper(IControlSet currentControlSet)
		{
			_tbAccountName = GetControl(currentControlSet, GameControlIdentifier.CreateAccountName, GetCreateAccountNameTextBox);
			_tbPassword = GetControl(currentControlSet, GameControlIdentifier.CreateAccountPassword, GetCreateAccountPasswordTextBox);
			_tbConfirm = GetControl(currentControlSet, GameControlIdentifier.CreateAccountPasswordConfirm, GetCreateAccountConfirmTextBox);
			_tbRealName = GetControl(currentControlSet, GameControlIdentifier.CreateAccountRealName, GetCreateAccountRealNameTextBox);
			_tbLocation = GetControl(currentControlSet, GameControlIdentifier.CreateAccountLocation, GetCreateAccountLocationTextBox);
			_tbEmail = GetControl(currentControlSet, GameControlIdentifier.CreateAccountEmail, GetCreateAccountEmailTextBox);
			_btnCreate = GetControl(currentControlSet, GameControlIdentifier.CreateAccountButton, () => GetCreateButton(false));
			_btnCancel = GetControl(currentControlSet, GameControlIdentifier.CreateAccountCancelButton, GetCreateAccountCancelButton);
			_backButton = GetControl(currentControlSet, GameControlIdentifier.BackButton, GetBackButton);
			_person2Picture = GetControl(currentControlSet, GameControlIdentifier.PersonDisplay2, GetPerson2Picture);

			_allComponents.Add(_tbAccountName);
			_allComponents.Add(_tbPassword);
			_allComponents.Add(_tbConfirm);
			_allComponents.Add(_tbRealName);
			_allComponents.Add(_tbLocation);
			_allComponents.Add(_tbEmail);
			_allComponents.Add(_btnCreate);
			_allComponents.Add(_btnCancel);
			_allComponents.Add(_backButton);
			_allComponents.Add(_person2Picture);

			var textBoxes = _allComponents.OfType<XNATextBox>().ToArray();
			_clickHandler = new TextBoxClickEventHandler(_dispatcher, textBoxes);
			_tabHandler = new TextBoxTabEventHandler(_dispatcher, textBoxes);

			if (_dispatcher.Subscriber != null)
				_dispatcher.Subscriber.Selected = false;
			_dispatcher.Subscriber = _tbAccountName;
			_dispatcher.Subscriber.Selected = true;
		}

		public override IGameComponent FindComponentByControlIdentifier(GameControlIdentifier control)
		{
{'fraction_non_alphanumeric': 0.0677393027865221, 'fraction_numerical': 0.0062959076600209865, 'mean_word_length': 6.232715008431703, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1557682', 'n_tokens_mistral': 2636, 'n_tokens_neox': 2272, 'n_words': 467}