<commit_before>﻿using KerbalImprovedSaveSystem.Extensions;
using KSP.IO;
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;

namespace KerbalImprovedSaveSystem
{
	/// <summary>
	/// Used to execute file operations depending of dialog result (yes/no).
	/// </summary>
	/// <param name="filename">The name of the file to be modified.</param>
	internal delegate void FileOpCallback(string filename);

	/// <summary>
	/// Start Kerbal Improved Save System when in a flight scene.
	/// </summary>
	[KSPAddon(KSPAddon.Startup.FlightAndKSC, true)]
	public class KerbalImprovedSaveSystem : MonoBehaviour
	{
		// used to identify log entries of this plugin
		public const string modLogTag = "[KISS]: ";

		// stuff to configure the GUI
		private Rect windowPosSize;
		private bool isVisible;
		private KISSDialog _kissDialog;
		private string kissTooltip;
		private GUIStyle _windowStyle, _labelStyle, _whiteLblStyle, _buttonStyle, _altBtnStyle, _delBtnStyle, _listBtnStyle,
			_listSelectionStyle, _txtFieldStyle, _listStyle, _toggleStyle, _selectionGridSytle, _tooltipWindowStyle, _tooltipLblStyle;
		private Texture2D _settingsTexture;

		// scroll position in the list of existing savegames
		private Vector2 scrollPos;
		private bool showSettings;

		// stuff to detect double clicks
		private bool dblClicked;
		private DateTime lastClickTime;
		private TimeSpan catchTime = TimeSpan.FromMilliseconds(250);

		// savegame directory of the current came
		private string saveGameDir;
		// currently selected filename for savegame
		private string selectedFileName;
		// list of existing savegames
		private List<string> existingSaveGames;

		// reference to the plugin configuration
		private PluginConfiguration config;

		// stuff for controlling the suggested name for the savegame when opening KISS
		private string[] dfltSaveNames;
		private int selectedDfltSaveName;
		private GUIContent[] slctnGridContent;

		// flags  and variables to configure behaviour

		// enable/disable overwrite confirmations
		private bool confirmOverwrite = false;
		// enable/disable delete confirmations
		private bool confirmDelete = false;
		// timestamps in game time instead of system time
		private bool useGameTime = false;
		// reverse sorting of savegames (newest first of only using saves with timestamps)
		private bool reverseOrder = false;
		// enable/disable quicksave mode (quicksave without showing gui)
		private bool quickSaveMode = false;
		// enable/disable detection of pressed key for changing keybinding for KISS
		private bool detectingNewKey = false;
		// holds the currently used keybinding for KISS
		private KeyCode kissKeyCode;
		private String kissKeyCaption;

		/// <summary>
		/// Handles initialization of the plugin
		/// </summary><commit_msg>Replaced a String with a string<commit_after>﻿using KerbalImprovedSaveSystem.Extensions;
using KSP.IO;
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;

namespace KerbalImprovedSaveSystem
{
	/// <summary>
	/// Used to execute file operations depending of dialog result (yes/no).
	/// </summary>
	/// <param name="filename">The name of the file to be modified.</param>
	internal delegate void FileOpCallback(string filename);

	/// <summary>
	/// Start Kerbal Improved Save System when in a flight scene.
	/// </summary>
	[KSPAddon(KSPAddon.Startup.FlightAndKSC, true)]
	public class KerbalImprovedSaveSystem : MonoBehaviour
	{
		// used to identify log entries of this plugin
		public const string modLogTag = "[KISS]: ";

		// stuff to configure the GUI
		private Rect windowPosSize;
		private bool isVisible;
		private KISSDialog _kissDialog;
		private string kissTooltip;
		private GUIStyle _windowStyle, _labelStyle, _whiteLblStyle, _buttonStyle, _altBtnStyle, _delBtnStyle, _listBtnStyle,
			_listSelectionStyle, _txtFieldStyle, _listStyle, _toggleStyle, _selectionGridSytle, _tooltipWindowStyle, _tooltipLblStyle;
		private Texture2D _settingsTexture;

		// scroll position in the list of existing savegames
		private Vector2 scrollPos;
		private bool showSettings;

		// stuff to detect double clicks
		private bool dblClicked;
		private DateTime lastClickTime;
		private TimeSpan catchTime = TimeSpan.FromMilliseconds(250);

		// savegame directory of the current came
		private string saveGameDir;
		// currently selected filename for savegame
		private string selectedFileName;
		// list of existing savegames
		private List<string> existingSaveGames;

		// reference to the plugin configuration
		private PluginConfiguration config;

		// stuff for controlling the suggested name for the savegame when opening KISS
		private string[] dfltSaveNames;
		private int selectedDfltSaveName;
		private GUIContent[] slctnGridContent;

		// flags  and variables to configure behaviour

		// enable/disable overwrite confirmations
		private bool confirmOverwrite = false;
		// enable/disable delete confirmations
		private bool confirmDelete = false;
		// timestamps in game time instead of system time
		private bool useGameTime = false;
		// reverse sorting of savegames (newest first of only using saves with timestamps)
		private bool reverseOrder = false;
		// enable/disable quicksave mode (quicksave without showing gui)
		private bool quickSaveMode = false;
		// enable/disable detection of pressed key for changing keybinding for KISS
		private bool detectingNewKey = false;
		// holds the currently used keybinding for KISS
		private KeyCode kissKeyCode;
		private string kissKeyCaption;

		/// <summary>
		/// Handles initialization of the plugin
		/// </summary>
{'fraction_non_alphanumeric': 0.06818993216708319, 'fraction_numerical': 0.001785076758300607, 'mean_word_length': 4.315939278937382, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '488130', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1493, 'n_words': 568}