Decompiled source of Arab Viking v2.2.2

plugins/ArabViking.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ArabViking")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.2.2.0")]
[assembly: AssemblyInformationalVersion("2.2.2+5139e2d2ca4ee659a9566e7735848d51d96a31ed")]
[assembly: AssemblyProduct("ArabViking")]
[assembly: AssemblyTitle("ArabViking")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal enum IsolatedArabicLetters
{
	Hamza = 65152,
	Alef = 65165,
	AlefHamza = 65155,
	WawHamza = 65157,
	AlefMaksoor = 65159,
	AlefMaksora = 64508,
	HamzaNabera = 65161,
	Ba = 65167,
	Ta = 65173,
	Tha2 = 65177,
	Jeem = 65181,
	H7aa = 65185,
	Khaa2 = 65189,
	Dal = 65193,
	Thal = 65195,
	Ra2 = 65197,
	Zeen = 65199,
	Seen = 65201,
	Sheen = 65205,
	S9a = 65209,
	Dha = 65213,
	T6a = 65217,
	T6ha = 65221,
	Ain = 65225,
	Gain = 65229,
	Fa = 65233,
	Gaf = 65237,
	Kaf = 65241,
	Lam = 65245,
	Meem = 65249,
	Noon = 65253,
	Ha = 65257,
	Waw = 65261,
	Ya = 65265,
	AlefMad = 65153,
	TaMarboota = 65171,
	PersianPe = 64342,
	PersianChe = 64378,
	PersianZe = 64394,
	PersianGaf = 64402,
	PersianGaf2 = 64398,
	PersianYeh = 64508
}
internal enum GeneralArabicLetters
{
	Hamza = 1569,
	Alef = 1575,
	AlefHamza = 1571,
	WawHamza = 1572,
	AlefMaksoor = 1573,
	AlefMagsora = 1609,
	HamzaNabera = 1574,
	Ba = 1576,
	Ta = 1578,
	Tha2 = 1579,
	Jeem = 1580,
	H7aa = 1581,
	Khaa2 = 1582,
	Dal = 1583,
	Thal = 1584,
	Ra2 = 1585,
	Zeen = 1586,
	Seen = 1587,
	Sheen = 1588,
	S9a = 1589,
	Dha = 1590,
	T6a = 1591,
	T6ha = 1592,
	Ain = 1593,
	Gain = 1594,
	Fa = 1601,
	Gaf = 1602,
	Kaf = 1603,
	Lam = 1604,
	Meem = 1605,
	Noon = 1606,
	Ha = 1607,
	Waw = 1608,
	Ya = 1610,
	AlefMad = 1570,
	TaMarboota = 1577,
	PersianPe = 1662,
	PersianChe = 1670,
	PersianZe = 1688,
	PersianGaf = 1711,
	PersianGaf2 = 1705,
	PersianYeh = 1740
}
internal struct ArabicMapping
{
	public int from;

	public int to;

	public ArabicMapping(int from, int to)
	{
		this.from = from;
		this.to = to;
	}
}
internal class ArabicTable
{
	private static ArabicMapping[] mapList;

	private static ArabicTable arabicMapper;

	internal static ArabicTable ArabicMapper
	{
		get
		{
			if (arabicMapper == null)
			{
				arabicMapper = new ArabicTable();
			}
			return arabicMapper;
		}
	}

	private ArabicTable()
	{
		mapList = new ArabicMapping[42]
		{
			new ArabicMapping(1569, 65152),
			new ArabicMapping(1575, 65165),
			new ArabicMapping(1571, 65155),
			new ArabicMapping(1572, 65157),
			new ArabicMapping(1573, 65159),
			new ArabicMapping(1609, 64508),
			new ArabicMapping(1574, 65161),
			new ArabicMapping(1576, 65167),
			new ArabicMapping(1578, 65173),
			new ArabicMapping(1579, 65177),
			new ArabicMapping(1580, 65181),
			new ArabicMapping(1581, 65185),
			new ArabicMapping(1582, 65189),
			new ArabicMapping(1583, 65193),
			new ArabicMapping(1584, 65195),
			new ArabicMapping(1585, 65197),
			new ArabicMapping(1586, 65199),
			new ArabicMapping(1587, 65201),
			new ArabicMapping(1588, 65205),
			new ArabicMapping(1589, 65209),
			new ArabicMapping(1590, 65213),
			new ArabicMapping(1591, 65217),
			new ArabicMapping(1592, 65221),
			new ArabicMapping(1593, 65225),
			new ArabicMapping(1594, 65229),
			new ArabicMapping(1601, 65233),
			new ArabicMapping(1602, 65237),
			new ArabicMapping(1603, 65241),
			new ArabicMapping(1604, 65245),
			new ArabicMapping(1605, 65249),
			new ArabicMapping(1606, 65253),
			new ArabicMapping(1607, 65257),
			new ArabicMapping(1608, 65261),
			new ArabicMapping(1610, 65265),
			new ArabicMapping(1570, 65153),
			new ArabicMapping(1577, 65171),
			new ArabicMapping(1662, 64342),
			new ArabicMapping(1670, 64378),
			new ArabicMapping(1688, 64394),
			new ArabicMapping(1711, 64402),
			new ArabicMapping(1705, 64398),
			new ArabicMapping(1740, 64508)
		};
	}

	internal int Convert(int toBeConverted)
	{
		for (int i = 0; i < mapList.Length; i++)
		{
			ArabicMapping arabicMapping = mapList[i];
			if (arabicMapping.from == toBeConverted)
			{
				return arabicMapping.to;
			}
		}
		return toBeConverted;
	}
}
internal class TashkeelLocation
{
	public char tashkeel;

	public int position;

	public TashkeelLocation(char tashkeel, int position)
	{
		this.tashkeel = tashkeel;
		this.position = position;
	}
}
internal class ArabicFixerTool
{
	internal static bool showTashkeel = true;

	internal static bool combineTashkeel = true;

	internal static bool useHinduNumbers = false;

	internal static StringBuilder internalStringBuilder = new StringBuilder();

	internal static void RemoveTashkeel(ref string str, out List<TashkeelLocation> tashkeelLocation)
	{
		tashkeelLocation = new List<TashkeelLocation>();
		int lastSplitIndex = 0;
		internalStringBuilder.Clear();
		internalStringBuilder.EnsureCapacity(str.Length);
		int num = 0;
		for (int j = 0; j < str.Length; j++)
		{
			if (str[j] == '\u064b')
			{
				tashkeelLocation.Add(new TashkeelLocation('\u064b', j));
				num++;
				IncrementSB(ref str, j);
			}
			else if (str[j] == '\u064c')
			{
				tashkeelLocation.Add(new TashkeelLocation('\u064c', j));
				num++;
				IncrementSB(ref str, j);
			}
			else if (str[j] == '\u064d')
			{
				tashkeelLocation.Add(new TashkeelLocation('\u064d', j));
				num++;
				IncrementSB(ref str, j);
			}
			else if (str[j] == '\u064e')
			{
				if (num > 0 && combineTashkeel && tashkeelLocation[num - 1].tashkeel == '\u0651')
				{
					tashkeelLocation[num - 1].tashkeel = 'ﱠ';
					IncrementSB(ref str, j);
				}
				else
				{
					tashkeelLocation.Add(new TashkeelLocation('\u064e', j));
					num++;
					IncrementSB(ref str, j);
				}
			}
			else if (str[j] == '\u064f')
			{
				if (num > 0 && combineTashkeel && tashkeelLocation[num - 1].tashkeel == '\u0651')
				{
					tashkeelLocation[num - 1].tashkeel = 'ﱡ';
					IncrementSB(ref str, j);
				}
				else
				{
					tashkeelLocation.Add(new TashkeelLocation('\u064f', j));
					num++;
					IncrementSB(ref str, j);
				}
			}
			else if (str[j] == '\u0650')
			{
				if (num > 0 && combineTashkeel && tashkeelLocation[num - 1].tashkeel == '\u0651')
				{
					tashkeelLocation[num - 1].tashkeel = 'ﱢ';
					IncrementSB(ref str, j);
				}
				else
				{
					tashkeelLocation.Add(new TashkeelLocation('\u0650', j));
					num++;
					IncrementSB(ref str, j);
				}
			}
			else if (str[j] == '\u0651')
			{
				if (num > 0 && combineTashkeel)
				{
					if (tashkeelLocation[num - 1].tashkeel == '\u064e')
					{
						tashkeelLocation[num - 1].tashkeel = 'ﱠ';
						IncrementSB(ref str, j);
						continue;
					}
					if (tashkeelLocation[num - 1].tashkeel == '\u064f')
					{
						tashkeelLocation[num - 1].tashkeel = 'ﱡ';
						IncrementSB(ref str, j);
						continue;
					}
					if (tashkeelLocation[num - 1].tashkeel == '\u0650')
					{
						tashkeelLocation[num - 1].tashkeel = 'ﱢ';
						IncrementSB(ref str, j);
						continue;
					}
				}
				tashkeelLocation.Add(new TashkeelLocation('\u0651', j));
				num++;
				IncrementSB(ref str, j);
			}
			else if (str[j] == '\u0652')
			{
				tashkeelLocation.Add(new TashkeelLocation('\u0652', j));
				num++;
				IncrementSB(ref str, j);
			}
			else if (str[j] == '\u0653')
			{
				tashkeelLocation.Add(new TashkeelLocation('\u0653', j));
				num++;
				IncrementSB(ref str, j);
			}
			else if (str[j] == 'ﱠ')
			{
				IncrementSB(ref str, j);
			}
			else if (str[j] == 'ﱡ')
			{
				IncrementSB(ref str, j);
			}
			else if (str[j] == 'ﱢ')
			{
				IncrementSB(ref str, j);
			}
		}
		if (lastSplitIndex != 0)
		{
			IncrementSB(ref str, str.Length);
			str = internalStringBuilder.ToString();
		}
		void IncrementSB(ref string str, int i)
		{
			if (i - lastSplitIndex > 0)
			{
				internalStringBuilder.Append(str, lastSplitIndex, i - lastSplitIndex);
			}
			lastSplitIndex = i + 1;
		}
	}

	internal static void ReturnTashkeel(ref char[] letters, List<TashkeelLocation> tashkeelLocation)
	{
		Array.Resize(ref letters, letters.Length + tashkeelLocation.Count);
		for (int i = 0; i < tashkeelLocation.Count; i++)
		{
			TashkeelLocation tashkeelLocation2 = tashkeelLocation[i];
			for (int num = letters.Length - 1; num > tashkeelLocation2.position; num--)
			{
				letters[num] = letters[num - 1];
			}
			letters[tashkeelLocation2.position] = tashkeelLocation2.tashkeel;
		}
	}

	internal static string FixLine(string str)
	{
		RemoveTashkeel(ref str, out var tashkeelLocation);
		char[] array = new char[str.Length];
		char[] letters = str.ToCharArray();
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = (char)ArabicTable.ArabicMapper.Convert(str[i]);
		}
		for (int j = 0; j < array.Length; j++)
		{
			bool flag = false;
			if (array[j] == 'ﻝ' && j < array.Length - 1)
			{
				if (array[j + 1] == 'ﺇ')
				{
					array[j] = 'ﻷ';
					letters[j + 1] = '\uffff';
					flag = true;
				}
				else if (array[j + 1] == 'ﺍ')
				{
					array[j] = 'ﻹ';
					letters[j + 1] = '\uffff';
					flag = true;
				}
				else if (array[j + 1] == 'ﺃ')
				{
					array[j] = 'ﻵ';
					letters[j + 1] = '\uffff';
					flag = true;
				}
				else if (array[j + 1] == 'ﺁ')
				{
					array[j] = 'ﻳ';
					letters[j + 1] = '\uffff';
					flag = true;
				}
			}
			if (!IsIgnoredCharacter(array[j]))
			{
				if (IsMiddleLetter(array, j))
				{
					letters[j] = (char)(array[j] + 3);
				}
				else if (IsFinishingLetter(array, j))
				{
					letters[j] = (char)(array[j] + 1);
				}
				else if (IsLeadingLetter(array, j))
				{
					letters[j] = (char)(array[j] + 2);
				}
			}
			if (flag)
			{
				j++;
			}
			if (useHinduNumbers)
			{
				letters[j] = (char)HandleInduNumber(array[j], letters[j]);
			}
		}
		if (showTashkeel && tashkeelLocation.Count > 0)
		{
			ReturnTashkeel(ref letters, tashkeelLocation);
		}
		internalStringBuilder.Clear();
		internalStringBuilder.EnsureCapacity(letters.Length);
		List<char> numberList = null;
		for (int num = letters.Length - 1; num >= 0; num--)
		{
			if (char.IsPunctuation(letters[num]) && num > 0 && num < letters.Length - 1 && (char.IsPunctuation(letters[num - 1]) || char.IsPunctuation(letters[num + 1])))
			{
				if (letters[num] == '(')
				{
					internalStringBuilder.Append(')');
				}
				else if (letters[num] == ')')
				{
					internalStringBuilder.Append('(');
				}
				else if (letters[num] == '<')
				{
					internalStringBuilder.Append('>');
				}
				else if (letters[num] == '>')
				{
					internalStringBuilder.Append('<');
				}
				else if (letters[num] == '[')
				{
					internalStringBuilder.Append(']');
				}
				else if (letters[num] == ']')
				{
					internalStringBuilder.Append('[');
				}
				else if (letters[num] != '\uffff')
				{
					internalStringBuilder.Append(letters[num]);
				}
			}
			else if (letters[num] == ' ' && num > 0 && num < letters.Length - 1 && (char.IsLower(letters[num - 1]) || char.IsUpper(letters[num - 1]) || char.IsNumber(letters[num - 1])) && (char.IsLower(letters[num + 1]) || char.IsUpper(letters[num + 1]) || char.IsNumber(letters[num + 1])))
			{
				AddNumber(letters[num]);
			}
			else if (char.IsNumber(letters[num]) || char.IsLower(letters[num]) || char.IsUpper(letters[num]) || char.IsSymbol(letters[num]) || char.IsPunctuation(letters[num]))
			{
				if (letters[num] == '(')
				{
					AddNumber(')');
				}
				else if (letters[num] == ')')
				{
					AddNumber('(');
				}
				else if (letters[num] == '<')
				{
					AddNumber('>');
				}
				else if (letters[num] == '>')
				{
					AddNumber('<');
				}
				else if (letters[num] == '[')
				{
					internalStringBuilder.Append(']');
				}
				else if (letters[num] == ']')
				{
					internalStringBuilder.Append('[');
				}
				else
				{
					AddNumber(letters[num]);
				}
			}
			else if ((letters[num] >= '\ud800' && letters[num] <= '\udbff') || (letters[num] >= '\udc00' && letters[num] <= '\udfff'))
			{
				AddNumber(letters[num]);
			}
			else
			{
				AppendNumbers();
				if (letters[num] != '\uffff')
				{
					internalStringBuilder.Append(letters[num]);
				}
			}
		}
		AppendNumbers();
		return internalStringBuilder.ToString();
		void AddNumber(char value)
		{
			if (numberList == null)
			{
				numberList = new List<char>();
			}
			numberList.Add(value);
		}
		void AppendNumbers()
		{
			if (numberList != null && numberList.Count > 0)
			{
				for (int k = 0; k < numberList.Count; k++)
				{
					internalStringBuilder.Append(numberList[numberList.Count - 1 - k]);
				}
				numberList.Clear();
			}
		}
	}

	internal static ushort HandleInduNumber(ushort letterOrigin, ushort letterFinal)
	{
		return letterOrigin switch
		{
			48 => 1632, 
			49 => 1633, 
			50 => 1634, 
			51 => 1635, 
			52 => 1636, 
			53 => 1637, 
			54 => 1638, 
			55 => 1639, 
			56 => 1640, 
			57 => 1641, 
			_ => letterFinal, 
		};
	}

	internal static bool IsIgnoredCharacter(char ch)
	{
		bool num = char.IsPunctuation(ch);
		bool flag = char.IsNumber(ch);
		bool flag2 = char.IsLower(ch);
		bool flag3 = char.IsUpper(ch);
		bool flag4 = char.IsSymbol(ch);
		bool flag5 = ch == 'ﭖ' || ch == 'ﭺ' || ch == 'ﮊ' || ch == 'ﮒ' || ch == 'ﮎ';
		bool flag6 = (ch <= '\ufeff' && ch >= 'ﹰ') || flag5 || ch == 'ﯼ';
		if (!(num || flag || flag2 || flag3 || flag4) && flag6 && ch != 'a' && ch != '>' && ch != '<')
		{
			return ch == '؛';
		}
		return true;
	}

	internal static bool IsLeadingLetter(char[] letters, int index)
	{
		bool num = index == 0 || letters[index - 1] == ' ' || letters[index - 1] == '*' || letters[index - 1] == 'A' || char.IsPunctuation(letters[index - 1]) || letters[index - 1] == '>' || letters[index - 1] == '<' || letters[index - 1] == 'ﺍ' || letters[index - 1] == 'ﺩ' || letters[index - 1] == 'ﺫ' || letters[index - 1] == 'ﺭ' || letters[index - 1] == 'ﺯ' || letters[index - 1] == 'ﮊ' || letters[index - 1] == 'ﻭ' || letters[index - 1] == 'ﺁ' || letters[index - 1] == 'ﺃ' || letters[index - 1] == 'ﺀ' || letters[index - 1] == 'ﺇ' || letters[index - 1] == 'ﺅ';
		bool flag = letters[index] != ' ' && letters[index] != 'ﺩ' && letters[index] != 'ﺫ' && letters[index] != 'ﺭ' && letters[index] != 'ﺯ' && letters[index] != 'ﮊ' && letters[index] != 'ﺍ' && letters[index] != 'ﺃ' && letters[index] != 'ﺇ' && letters[index] != 'ﺁ' && letters[index] != 'ﺅ' && letters[index] != 'ﻭ' && letters[index] != 'ﺀ';
		bool flag2 = index < letters.Length - 1 && letters[index + 1] != ' ' && letters[index + 1] != '\n' && letters[index + 1] != '\r' && !char.IsPunctuation(letters[index + 1]) && !char.IsNumber(letters[index + 1]) && !char.IsSymbol(letters[index + 1]) && !char.IsLower(letters[index + 1]) && !char.IsUpper(letters[index + 1]) && letters[index + 1] != 'ﺀ';
		return num && flag && flag2;
	}

	internal static bool IsFinishingLetter(char[] letters, int index)
	{
		bool num = index != 0 && letters[index - 1] != ' ' && letters[index - 1] != 'ﺩ' && letters[index - 1] != 'ﺫ' && letters[index - 1] != 'ﺭ' && letters[index - 1] != 'ﺯ' && letters[index - 1] != 'ﮊ' && letters[index - 1] != 'ﻭ' && letters[index - 1] != 'ﺍ' && letters[index - 1] != 'ﺁ' && letters[index - 1] != 'ﺃ' && letters[index - 1] != 'ﺇ' && letters[index - 1] != 'ﺅ' && letters[index - 1] != 'ﺀ' && !char.IsPunctuation(letters[index - 1]) && !char.IsSymbol(letters[index - 1]) && letters[index - 1] != '>' && letters[index - 1] != '<';
		bool flag = letters[index] != ' ' && letters[index] != 'ﺀ';
		return num && flag;
	}

	internal static bool IsMiddleLetter(char[] letters, int index)
	{
		bool flag = index != 0 && letters[index] != 'ﺍ' && letters[index] != 'ﺩ' && letters[index] != 'ﺫ' && letters[index] != 'ﺭ' && letters[index] != 'ﺯ' && letters[index] != 'ﮊ' && letters[index] != 'ﻭ' && letters[index] != 'ﺁ' && letters[index] != 'ﺃ' && letters[index] != 'ﺇ' && letters[index] != 'ﺅ' && letters[index] != 'ﺀ';
		bool flag2 = index != 0 && letters[index - 1] != 'ﺍ' && letters[index - 1] != 'ﺩ' && letters[index - 1] != 'ﺫ' && letters[index - 1] != 'ﺭ' && letters[index - 1] != 'ﺯ' && letters[index - 1] != 'ﮊ' && letters[index - 1] != 'ﻭ' && letters[index - 1] != 'ﺁ' && letters[index - 1] != 'ﺃ' && letters[index - 1] != 'ﺇ' && letters[index - 1] != 'ﺅ' && letters[index - 1] != 'ﺀ' && !char.IsPunctuation(letters[index - 1]) && letters[index - 1] != '>' && letters[index - 1] != '<' && letters[index - 1] != ' ' && letters[index - 1] != '*';
		if (index < letters.Length - 1 && letters[index + 1] != ' ' && letters[index + 1] != '\r' && letters[index + 1] != 'ﺀ' && !char.IsNumber(letters[index + 1]) && !char.IsSymbol(letters[index + 1]) && !char.IsPunctuation(letters[index + 1]) && flag2 && flag)
		{
			return !char.IsPunctuation(letters[index + 1]);
		}
		return false;
	}
}
public static class AllLanguagesDumper
{
	public static void DumpAllLanguages(string outputDir)
	{
		Localization instance = Localization.instance;
		if (instance == null)
		{
			Debug.LogError((object)"[LangDump] Localization.instance is null.");
			return;
		}
		List<string> languages = instance.GetLanguages();
		if (languages == null || languages.Count == 0)
		{
			Debug.LogError((object)"[LangDump] No available languages found.");
			return;
		}
		if (!Directory.Exists(outputDir))
		{
			Directory.CreateDirectory(outputDir);
		}
		string selectedLanguage = instance.GetSelectedLanguage();
		foreach (string item in languages)
		{
			instance.SetupLanguage(item);
			Dictionary<string, string> translations = instance.m_translations;
			string text = Path.Combine(outputDir, item + ".json");
			using StreamWriter streamWriter = new StreamWriter(text, append: false, Encoding.UTF8);
			streamWriter.WriteLine("{");
			int num = 0;
			foreach (KeyValuePair<string, string> item2 in translations)
			{
				string text2 = Sanitize(item2.Key);
				string text3 = Sanitize(item2.Value);
				streamWriter.Write("  \"" + text2 + "\": \"" + text3 + "\"");
				num++;
				if (num < translations.Count)
				{
					streamWriter.WriteLine(",");
				}
				else
				{
					streamWriter.WriteLine();
				}
			}
			streamWriter.WriteLine("}");
			Debug.Log((object)$"[LangDump] Dumped {num} entries for {item} to {text}");
		}
		instance.SetupLanguage(selectedLanguage);
	}

	private static string Sanitize(string text)
	{
		if (string.IsNullOrEmpty(text))
		{
			return "";
		}
		return text.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("\r", "\\r")
			.Replace("\n", "\\n")
			.Replace("\t", "\\t");
	}
}
namespace ArabViking
{
	[BepInPlugin("ArabViking_ArabViking", "ArabViking", "2.2.2")]
	public class Main : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(FejdStartup), "SetupGui")]
		public static class MainMenuPatch
		{
			public static void Postfix()
			{
				if (!hideTextureButtons.Value)
				{
					return;
				}
				try
				{
					Transform obj = ((Component)FejdStartup.instance).transform.Find("Menu/TopRight/StartGui_MerchButton");
					if (obj != null)
					{
						GameObject gameObject = ((Component)obj).gameObject;
						if (gameObject != null)
						{
							gameObject.SetActive(false);
						}
					}
					Transform obj2 = ((Component)FejdStartup.instance).transform.Find("Menu/TopRight/StartGui_BoardgameButton");
					if (obj2 != null)
					{
						GameObject gameObject2 = ((Component)obj2).gameObject;
						if (gameObject2 != null)
						{
							gameObject2.SetActive(false);
						}
					}
					Transform obj3 = ((Component)FejdStartup.instance).transform.Find("Menu/Canvas Changelog/ChangeLog");
					if (obj3 != null)
					{
						GameObject gameObject3 = ((Component)obj3).gameObject;
						if (gameObject3 != null)
						{
							gameObject3.SetActive(false);
						}
					}
				}
				catch (Exception ex)
				{
					log.LogError((object)ex);
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "UpdateBuild")]
		public static class BuildHudPatch
		{
			public static void Postfix(Player player, bool forceUpdateAllBuildStatuses)
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					Hud instance = Hud.instance;
					if (!((Character)player).InPlaceMode())
					{
						return;
					}
					Piece val = default(Piece);
					Vector2Int val2 = default(Vector2Int);
					int num = default(int);
					PieceCategory val3 = default(PieceCategory);
					PieceTable val4 = default(PieceTable);
					player.GetBuildSelection(ref val, ref val2, ref num, ref val3, ref val4);
					if (!instance.m_pieceSelectionWindow.activeSelf)
					{
						return;
					}
					instance.UpdatePieceList(player, val2, val3, forceUpdateAllBuildStatuses);
					instance.m_pieceCategoryRoot.SetActive(val4.m_categories.Count > 0);
					if (val4.m_categories.Count > 0)
					{
						for (int i = 0; i < instance.m_pieceCategoryTabs.Length; i++)
						{
							GameObject val5 = instance.m_pieceCategoryTabs[i];
							Transform val6 = val5.transform.Find("Selected");
							bool flag = i < val4.m_categories.Count;
							val5.SetActive(flag);
							if (flag)
							{
								_ = $"{val4.m_categoryLabels[i]} [<color=yellow>{player.GetAvailableBuildPiecesInCategory(val4.m_categories[i])}</color>]";
								if (val4.m_categories[i] == val3)
								{
									((Component)val6).gameObject.SetActive(true);
									((TMP_Text)((Component)val6).GetComponentInChildren<TextMeshProUGUI>()).overflowMode = (TextOverflowModes)0;
								}
								else
								{
									((Component)val6).gameObject.SetActive(false);
									((TMP_Text)val5.GetComponentInChildren<TextMeshProUGUI>()).overflowMode = (TextOverflowModes)0;
								}
							}
						}
					}
					Localization.instance.Localize(instance.m_buildHud.transform);
				}
				catch (Exception ex)
				{
					log.LogError((object)ex);
				}
			}
		}

		public const string MODNAME = "ArabViking";

		public const string AUTHOR = "ArabViking";

		public const string GUID = "ArabViking_ArabViking";

		public const string VERSION = "2.2.2";

		internal static ManualLogSource log;

		internal static Harmony harmony;

		internal static Assembly assembly;

		internal static ConfigEntry<bool> hideTextureButtons;

		internal static ConfigEntry<bool> dumpLanguageFiles;

		public void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			harmony = new Harmony("ArabViking_ArabViking");
			assembly = Assembly.GetExecutingAssembly();
			log = ((BaseUnityPlugin)this).Logger;
		}

		public void Start()
		{
			harmony.PatchAll(assembly);
			log.LogInfo((object)" بيرعتلا ةادأ ليمحت مت ");
			log.LogInfo((object)" رادصإ : 2.2.2");
			hideTextureButtons = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Hide Texture Buttons", true, "Toggle whether to use custom huds or not.");
			dumpLanguageFiles = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Dump Language Files", false, "Toggle whether to create dumps of all languages.");
			if (dumpLanguageFiles.Value)
			{
				AllLanguagesDumper.DumpAllLanguages("./DUMPS/");
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ArabViking";

		public const string PLUGIN_NAME = "ArabViking";

		public const string PLUGIN_VERSION = "2.2.2";
	}
}
namespace ArabicSupport
{
	public class ArabicFixer
	{
		public static string Fix(string str)
		{
			return Fix(str, showTashkeel: false, useHinduNumbers: true);
		}

		public static string Fix(string str, bool rtl)
		{
			if (rtl)
			{
				return Fix(str);
			}
			string[] array = str.Split(' ');
			string text = "";
			string text2 = "";
			string[] array2 = array;
			foreach (string text3 in array2)
			{
				if (char.IsLower(text3.ToLower()[text3.Length / 2]))
				{
					text = text + Fix(text2) + text3 + " ";
					text2 = "";
				}
				else
				{
					text2 = text2 + text3 + " ";
				}
			}
			if (text2 != "")
			{
				text += Fix(text2);
			}
			return text;
		}

		public static string Fix(string str, bool showTashkeel, bool useHinduNumbers)
		{
			ArabicFixerTool.showTashkeel = showTashkeel;
			ArabicFixerTool.useHinduNumbers = useHinduNumbers;
			if (str.Contains("\n"))
			{
				str = str.Replace("\n", Environment.NewLine);
			}
			if (str.Contains(Environment.NewLine))
			{
				string[] separator = new string[1] { Environment.NewLine };
				string[] array = str.Split(separator, StringSplitOptions.None);
				if (array.Length == 0)
				{
					return ArabicFixerTool.FixLine(str);
				}
				if (array.Length == 1)
				{
					return ArabicFixerTool.FixLine(str);
				}
				string text = ArabicFixerTool.FixLine(array[0]);
				int i = 1;
				if (array.Length > 1)
				{
					for (; i < array.Length; i++)
					{
						text = text + Environment.NewLine + ArabicFixerTool.FixLine(array[i]);
					}
				}
				return text;
			}
			return ArabicFixerTool.FixLine(str);
		}

		public static string Fix(string str, bool showTashkeel, bool combineTashkeel, bool useHinduNumbers)
		{
			ArabicFixerTool.combineTashkeel = combineTashkeel;
			return Fix(str, showTashkeel, useHinduNumbers);
		}
	}
}