<commit_before>﻿using UnityEngine;
using System.Collections.Generic;

namespace KspCraftOrganizer {
	
	public class OrganizerWindowTagsManagementBar {
		
		private static readonly string GUI_ID_ADD_NEW_TAG_TEXT = "GUI_ID_ADD_NEW_TAG_TEXT";

		private readonly OrganizerWindow parent;

		private Vector2 assingTagsScrollPosition;
		private string newTagText = "";
		private bool newTagWasJustAdded;
		private bool needsToUpdateSelectionInNewTag;
		private bool showDefaultTagsToAdd;

		public OrganizerWindowTagsManagementBar(OrganizerWindow parent) {
			this.parent = parent;
		}

		private OrganizerController model { get { return parent.model; } }

		public void drawManageTagsColumn() {
			using (new GUILayout.VerticalScope(GUILayout.Width(OrganizerWindow.MANAGE_TAGS_TOOLBAR_WIDTH))) {
				using (new GUILayout.HorizontalScope(GUILayout.ExpandWidth(false))) {
					if (model.selectedCraftsCount == 0) {
						GUILayout.Label("No craft selected, cannot assign tags", parent.warningLabelStyle);
					} else if (model.selectedCraftsCount == 1) {
						GUILayout.Label("Assign tags to selected craft. The changes will be applied immediately:");
					} else {
						GUILayout.Label("Assign tags to " + model.selectedCraftsCount + " selected crafts. The changes will be applied immediately:");
					}
					GUILayout.Space(20);
				}
				assingTagsScrollPosition = GUILayout.BeginScrollView(assingTagsScrollPosition);
				if (model.availableTags.Count > 0) {

					foreach (ManagementTagGroup tagGroup in model.managementTagsGroups.groups) {
						bool collapsed = tagGroup.collapsedInManagementView;
						if (collapsed) {
							if (GUILayout.Button("+ " + tagGroup.displayName, parent.skin.label)) {
								tagGroup.collapsedInManagementView = !collapsed;
							}
						} else {
							if (GUILayout.Button("- " + tagGroup.displayName + ":", parent.skin.label)) {
								tagGroup.collapsedInManagementView = !collapsed;
							}
							foreach (TagInGroup<OrganizerTagEntity> tag in tagGroup.tags) {
								drawSingleTag(tag.originalTag);

								GUILayout.Space(5);
							}
						}
					}

					if (model.managementTagsGroups.groups.Count > 0) {
						if (model.restTagsInManagementCollapsed) {
							if (GUILayout.Button("+ Rest tags", parent.skin.label)) {
								model.restTagsInManagementCollapsed = !model.restTagsInManagementCollapsed;
							}
						} else {
							if (GUILayout.Button("- Rest tags:", parent.skin.label)) {
								model.restTagsInManagementCollapsed = !model.restTagsInManagementCollapsed;
							}
						}
					} else {
						model.restTagsInManagementCollapsed = false;
					}
					if (!model.restTagsInManagementCollapsed) {
						foreach (OrganizerTagEntity tag in model.managementTagsGroups.restTags) {
							drawSingleTag(tag);

							GUILayout.Space(5);
						}
					}
				} else {
					GUILayout.Label("<No tags exist yet>");
				}
				GUILayout.Label("Add new tag:");

				using (new GUILayout.HorizontalScope(GUILayout.ExpandWidth(false))) {

					GUI.SetNextControlName(GUI_ID_ADD_NEW_TAG_TEXT);
					newTagText = GUILayout.TextField(newTagText, GUILayout.Width(150));

					focusNewTagTextFieldIfNeeded();

					bool addButtonClicked = GUILayout.Button("Add", GUILayout.ExpandWidth(false));
					string nameOfFocusedControl = GUI.GetNameOfFocusedControl();
					Event currentEven = Event.current;
					bool enterPressedOnInput =
						nameOfFocusedControl == GUI_ID_ADD_NEW_TAG_TEXT
						&& currentEven.type == EventType.KeyUp
						&& currentEven.keyCode == KeyCode.Return;
					if ((addButtonClicked || enterPressedOnInput) && newTagText.Trim() != "") {
						model.addAvailableTag(newTagText.Trim());
						newTagWasJustAdded = true;
					}
				}
				if (!model.thisIsPrimarySave) {
					GUILayout.Label("The tag will be added only to the currently selected save game", parent.warningLabelStyle);
				}
				GUILayout.Space(10);

				if (GUILayout.Button("Default tags " + (showDefaultTagsToAdd ? "<<" : ">>"))) {
					showDefaultTagsToAdd = !showDefaultTagsToAdd;<commit_msg>corrected problem with horizontal scrollbar unnecesarly showing up in tags management bar<commit_after>﻿using UnityEngine;
using System.Collections.Generic;

namespace KspCraftOrganizer {
	
	public class OrganizerWindowTagsManagementBar {
		
		private static readonly string GUI_ID_ADD_NEW_TAG_TEXT = "GUI_ID_ADD_NEW_TAG_TEXT";

		private readonly OrganizerWindow parent;

		private Vector2 assingTagsScrollPosition;
		private string newTagText = "";
		private bool newTagWasJustAdded;
		private bool needsToUpdateSelectionInNewTag;
		private bool showDefaultTagsToAdd;

		public OrganizerWindowTagsManagementBar(OrganizerWindow parent) {
			this.parent = parent;
		}

		private OrganizerController model { get { return parent.model; } }

		public void drawManageTagsColumn() {
			using (new GUILayout.VerticalScope(GUILayout.Width(OrganizerWindow.MANAGE_TAGS_TOOLBAR_WIDTH))) {
				using (new GUILayout.HorizontalScope(GUILayout.ExpandWidth(false))) {
					if (model.selectedCraftsCount == 0) {
						GUILayout.Label("No craft selected, cannot assign tags", parent.warningLabelStyle);
					} else if (model.selectedCraftsCount == 1) {
						GUILayout.Label("Assign tags to selected craft. The changes will be applied immediately:");
					} else {
						GUILayout.Label("Assign tags to " + model.selectedCraftsCount + " selected crafts. The changes will be applied immediately:");
					}
					GUILayout.Space(20);
				}
				assingTagsScrollPosition = GUILayout.BeginScrollView(assingTagsScrollPosition);
				if (model.availableTags.Count > 0) {

					foreach (ManagementTagGroup tagGroup in model.managementTagsGroups.groups) {
						bool collapsed = tagGroup.collapsedInManagementView;
						if (collapsed) {
							if (GUILayout.Button("+ " + tagGroup.displayName, parent.skin.label)) {
								tagGroup.collapsedInManagementView = !collapsed;
							}
						} else {
							if (GUILayout.Button("- " + tagGroup.displayName + ":", parent.skin.label)) {
								tagGroup.collapsedInManagementView = !collapsed;
							}
							foreach (TagInGroup<OrganizerTagEntity> tag in tagGroup.tags) {
								drawSingleTag(tag.originalTag);

								GUILayout.Space(5);
							}
						}
					}

					if (model.managementTagsGroups.groups.Count > 0) {
						if (model.restTagsInManagementCollapsed) {
							if (GUILayout.Button("+ Rest tags", parent.skin.label)) {
								model.restTagsInManagementCollapsed = !model.restTagsInManagementCollapsed;
							}
						} else {
							if (GUILayout.Button("- Rest tags:", parent.skin.label)) {
								model.restTagsInManagementCollapsed = !model.restTagsInManagementCollapsed;
							}
						}
					} else {
						model.restTagsInManagementCollapsed = false;
					}
					if (!model.restTagsInManagementCollapsed) {
						foreach (OrganizerTagEntity tag in model.managementTagsGroups.restTags) {
							drawSingleTag(tag);

							GUILayout.Space(5);
						}
					}
				} else {
					GUILayout.Label("<No tags exist yet>");
				}
				GUILayout.Label("Add new tag:");

				using (new GUILayout.HorizontalScope(GUILayout.ExpandWidth(false))) {

					GUI.SetNextControlName(GUI_ID_ADD_NEW_TAG_TEXT);
					newTagText = GUILayout.TextField(newTagText, GUILayout.Width(145));

					focusNewTagTextFieldIfNeeded();

					bool addButtonClicked = GUILayout.Button("Add", GUILayout.ExpandWidth(false));
					string nameOfFocusedControl = GUI.GetNameOfFocusedControl();
					Event currentEven = Event.current;
					bool enterPressedOnInput =
						nameOfFocusedControl == GUI_ID_ADD_NEW_TAG_TEXT
						&& currentEven.type == EventType.KeyUp
						&& currentEven.keyCode == KeyCode.Return;
					if ((addButtonClicked || enterPressedOnInput) && newTagText.Trim() != "") {
						model.addAvailableTag(newTagText.Trim());
						newTagWasJustAdded = true;
					}
				}
				if (!model.thisIsPrimarySave) {
					GUILayout.Label("The tag will be added only to the currently selected save game", parent.warningLabelStyle);
				}
				GUILayout.Space(10);

				if (GUILayout.Button("Default tags " + (showDefaultTagsToAdd ? "<<" : ">>"), GUILayout.Width(OrganizerWindow.MANAGE_TAGS_TOOLBAR_WIDTH - (parent.isKspSkin() ? 20 : 10) - 20))) {
					showDefaultTagsToAdd = !showDefaultTagsToAdd;
{'fraction_non_alphanumeric': 0.10252672497570457, 'fraction_numerical': 0.00413022351797862, 'mean_word_length': 3.667233560090703, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 15, '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': '7391101', 'n_tokens_mistral': 3214, 'n_tokens_neox': 2410, 'n_words': 463}