using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using LLBML;
using LLBML.Bundles;
using LLBML.Networking;
using LLBML.Players;
using LLBML.States;
using LLBML.Utils;
using LLGUI;
using LLHandlers;
using LLScreen;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("InputViewer (uk.daioutzu.plugins.llb.inputviewer)")]
[assembly: AssemblyProduct("InputViewer")]
[assembly: AssemblyVersion("3.0.0.0")]
namespace InputViewer;
public class InputWindow : LLClickable
{
private RectTransform rectTransform;
public bool isMiniSize;
public Player boundPlayer;
private ConfigEntry<Vector2> savedPosition;
private bool isDraggable;
private TextMeshProUGUI lbHeader;
private Image imgBG;
private Image imgStripe;
private InputDisplay inputJump;
private InputDisplay inputUp;
private InputDisplay inputDown;
private InputDisplay inputLeft;
private InputDisplay inputRight;
private InputDisplay inputSwing;
private InputDisplay inputBunt;
private InputDisplay inputGrab;
private InputDisplay inputTaunt;
private InputDisplay inputNice;
private InputDisplay inputWow;
private InputDisplay inputBringIt;
private InputDisplay inputOops;
private bool isDragging;
private Vector2 cursorStartPos;
private Vector2 windowStartPos;
public static InputWindow Create(Transform parent, string name, ConfigEntry<Vector2> savedPosition, bool isMiniSize, bool isDraggable)
{
GameObject obj = Object.Instantiate<GameObject>(IVStyle.uiPrefabAssets[isMiniSize ? "ViewerMini" : "ViewerRegular"], parent);
((Object)obj).name = name;
InputWindow inputWindow = obj.AddComponent<InputWindow>();
inputWindow.imgBG = ((Component)inputWindow).GetComponent<Image>();
inputWindow.savedPosition = savedPosition;
inputWindow.isMiniSize = isMiniSize;
inputWindow.isDraggable = isDraggable;
inputWindow.InitUI();
return inputWindow;
}
private void InitUI()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Expected O, but got Unknown
rectTransform = ((Component)this).GetComponent<RectTransform>();
rectTransform.anchoredPosition = new Vector2(savedPosition.Value.x, savedPosition.Value.y);
lbHeader = ((Component)((Transform)rectTransform).Find("Header")).gameObject.AddComponent<TextMeshProUGUI>();
((TMP_Text)lbHeader).alignment = (TextAlignmentOptions)514;
((TMP_Text)lbHeader).fontSize = 20f;
TextHandler.SetText((TMP_Text)(object)lbHeader, isMiniSize ? "Inputs" : "Input Viewer");
imgStripe = ((Component)((Transform)rectTransform).Find("Stripe")).GetComponent<Image>();
Transform val = ((Transform)rectTransform).Find("Movement");
inputJump = ((Component)val.Find("Jump")).gameObject.AddComponent<InputDisplay>();
inputJump.Init("JumpOn", "JumpOff");
inputUp = ((Component)val.Find("Up")).gameObject.AddComponent<InputDisplay>();
inputUp.Init("ArrowUOn", "ArrowUOff");
inputDown = ((Component)val.Find("Down")).gameObject.AddComponent<InputDisplay>();
inputDown.Init("ArrowDOn", "ArrowDOff");
inputLeft = ((Component)val.Find("Left")).gameObject.AddComponent<InputDisplay>();
inputLeft.Init("ArrowLOn", "ArrowLOff");
inputRight = ((Component)val.Find("Right")).gameObject.AddComponent<InputDisplay>();
inputRight.Init("ArrowROn", "ArrowROff");
Transform val2 = ((Transform)rectTransform).Find("Actions");
inputSwing = ((Component)val2.Find("Swing")).gameObject.AddComponent<InputDisplay>();
inputSwing.Init("SwingOn", "SwingOff");
inputBunt = ((Component)val2.Find("Bunt")).gameObject.AddComponent<InputDisplay>();
inputBunt.Init("BuntOn", "BuntOff");
inputGrab = ((Component)val2.Find("Grab")).gameObject.AddComponent<InputDisplay>();
inputGrab.Init("GrabOn", "GrabOff");
inputTaunt = ((Component)val2.Find("Taunt")).gameObject.AddComponent<InputDisplay>();
inputTaunt.Init("TauntOn", "TauntOff");
Transform val3 = ((Transform)rectTransform).Find("Expressions");
inputNice = ((Component)val3.Find("Nice")).gameObject.AddComponent<InputDisplay>();
inputNice.Init("NiceOn", "NiceOff");
inputWow = ((Component)val3.Find("Wow")).gameObject.AddComponent<InputDisplay>();
inputWow.Init("WowOn", "WowOff");
inputBringIt = ((Component)val3.Find("Bring It")).gameObject.AddComponent<InputDisplay>();
inputBringIt.Init("BringItOn", "BringItOff");
inputOops = ((Component)val3.Find("Oops")).gameObject.AddComponent<InputDisplay>();
inputOops.Init("OopsOn", "OopsOff");
((Component)val3).gameObject.SetActive(!isMiniSize);
UpdateColor();
base.onClick = new ControlDelegate(StartStopDrag);
}
public void UpdateColor()
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
Team val = ((boundPlayer == null) ? Team.NONE : boundPlayer.Team);
float a = InputViewer.Instance.backgroundTransparency.Value switch
{
5 => 0.5f,
4 => 0.6f,
3 => 0.7f,
2 => 0.8f,
1 => 0.9f,
0 => 1f,
_ => 0f,
};
Color color = Color.white;
if ((EnumWrapper<BGHNEHPFHGC>)(object)val != (EnumWrapper<BGHNEHPFHGC>)(object)Team.NONE && InputViewer.Instance.useTeamColors.Value)
{
color = Assets.GetTeamColor(val, false);
}
color.a = a;
Color white = Color.white;
white.a = a;
((Graphic)imgStripe).color = color;
((Graphic)imgBG).color = white;
}
public void BindPlayer(Player player)
{
boundPlayer = player;
}
private void LateUpdate()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
if (isDragging)
{
Vector2 val = Vector2.op_Implicit(UIScreen.activeCamera.ScreenToViewportPoint(Vector2.op_Implicit(UIInput.mainCursor.GetPosition())));
Vector2 val2 = new Vector2(1280f * (val.x - 0.5f) + 32f, 720f * (val.y - 0.5f) - 32f) - cursorStartPos;
((Transform)rectTransform).localPosition = Vector2.op_Implicit(windowStartPos + val2);
}
if (boundPlayer != null)
{
inputJump.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.JUMP, false));
inputUp.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.UP, false));
inputDown.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.DOWN, false));
inputLeft.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.LEFT, false));
inputRight.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.RIGHT, false));
inputSwing.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.SWING, false));
inputBunt.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.BUNT, false));
inputGrab.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.GRAB, false));
inputTaunt.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.TAUNT, false));
if (!isMiniSize)
{
inputNice.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.EXPRESS_UP, false));
inputWow.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.EXPRESS_RIGHT, false));
inputBringIt.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.EXPRESS_DOWN, false));
inputOops.SetState(InputHandler.GetInput(Player.op_Implicit(boundPlayer), InputAction.EXPRESS_LEFT, false));
}
}
}
public bool IsPositionUnsaved()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
return rectTransform.anchoredPosition != savedPosition.Value;
}
public void SavePosition()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
savedPosition.Value = rectTransform.anchoredPosition;
}
private void StartStopDrag(int playerNr)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
if (!isDraggable)
{
return;
}
if (!isDragging)
{
if (ModDependenciesUtils.InModOptions())
{
Vector2 val = Vector2.op_Implicit(UIScreen.activeCamera.ScreenToViewportPoint(Vector2.op_Implicit(UIInput.mainCursor.GetPosition())));
cursorStartPos = new Vector2(1280f * (val.x - 0.5f) + 32f, 720f * (val.y - 0.5f) - 32f);
windowStartPos = Vector2.op_Implicit(((Transform)rectTransform).localPosition);
isDragging = true;
}
}
else
{
isDragging = false;
}
}
}
public class InputDisplay : MonoBehaviour
{
private Image image;
public Sprite spriteOn;
public Sprite spriteOff;
private void Awake()
{
image = ((Component)this).GetComponent<Image>();
}
public void Init(string on, string off)
{
spriteOn = IVStyle.uiSprites[on];
spriteOff = IVStyle.uiSprites[off];
}
public void SetState(bool state)
{
image.sprite = (state ? spriteOn : spriteOff);
}
}
public static class IVStyle
{
private static readonly string bundlesFolder = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)InputViewer.Instance).Info.Location), "Bundles");
public static AssetBundle uiBundle;
public static Font inputViewerFont;
public static Dictionary<string, Texture2D> uiTexture2DAssets = new Dictionary<string, Texture2D>();
public static Dictionary<string, GameObject> uiPrefabAssets = new Dictionary<string, GameObject>();
public static Dictionary<string, Sprite> uiSprites = new Dictionary<string, Sprite>();
public static Texture2D viewerBG;
private static string[] transparencyNames = new string[6] { "", "_90", "_80", "_70", "_60", "_50" };
private static void LoadAssets()
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
uiBundle = AssetBundle.LoadFromFile(Path.Combine(bundlesFolder, "ui"));
Texture2D[] array = uiBundle.LoadAllAssets<Texture2D>();
for (int i = 0; i < array.Length; i++)
{
uiTexture2DAssets.Add(((Object)array[i]).name, array[i]);
}
uiTexture2DAssets.Add("BlankTexture", new Texture2D(0, 0));
inputViewerFont = uiBundle.LoadAsset<Font>("assets/ui/elements.ttf");
GameObject[] array2 = uiBundle.LoadAllAssets<GameObject>();
for (int j = 0; j < array2.Length; j++)
{
uiPrefabAssets.Add(((Object)array2[j]).name, array2[j]);
}
foreach (KeyValuePair<string, Texture2D> uiTexture2DAsset in uiTexture2DAssets)
{
string key = uiTexture2DAsset.Key;
Texture2D value = uiTexture2DAsset.Value;
Sprite value2 = Sprite.Create(value, new Rect(0f, 0f, (float)((Texture)value).width, (float)((Texture)value).height), new Vector2(0.5f, 0.5f));
uiSprites.Add(key, value2);
}
}
public static void ATInit()
{
LoadAssets();
}
}
[BepInPlugin("uk.daioutzu.plugins.llb.inputviewer", "InputViewer", "3.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("LLBlaze.exe")]
internal class InputViewer : BaseUnityPlugin
{
private enum ViewMode
{
Off,
Training,
Local,
Online,
All
}
private RectTransform inputWindowContainer;
private InputWindow inputWindowMain;
private InputWindow inputWindow1v1Left;
private InputWindow inputWindow1v1Right;
private InputWindow inputWindowFfaP1;
private InputWindow inputWindowFfaP2;
private InputWindow inputWindowFfaP3;
private InputWindow inputWindowFfaP4;
private InputWindow[] PlayerInputWindows;
private InputWindow[] AllInputWindows;
private bool inputWindowsCreated;
private float saveTimer;
public ConfigEntry<int> selectViewingMode;
public ConfigEntry<int> backgroundTransparency;
public ConfigEntry<bool> excludeExpressions;
public ConfigEntry<bool> useTeamColors;
public ConfigEntry<bool> enableLocalViewer;
public ConfigEntry<bool> trackLocalCPUs;
public ConfigEntry<Vector2> inputViewerPosition_main;
public ConfigEntry<Vector2> inputViewerPosition_1v1_left;
public ConfigEntry<Vector2> inputViewerPosition_1v1_right;
public ConfigEntry<Vector2> inputViewerPosition_FFA_P1;
public ConfigEntry<Vector2> inputViewerPosition_FFA_P2;
public ConfigEntry<Vector2> inputViewerPosition_FFA_P3;
public ConfigEntry<Vector2> inputViewerPosition_FFA_P4;
private bool queueSave;
public static InputViewer Instance { get; private set; }
public static ManualLogSource LogGlobal { get; private set; }
private bool InGame
{
get
{
if ((Object)(object)World.instance != (Object)null && ((EnumWrapper<JOFJHDJHJGI>)(object)GameStates.GetCurrent() == (EnumWrapper<JOFJHDJHJGI>)(object)GameState.GAME || (EnumWrapper<JOFJHDJHJGI>)(object)GameStates.GetCurrent() == (EnumWrapper<JOFJHDJHJGI>)(object)GameState.GAME_PAUSE))
{
return !UIScreen.loadingScreenActive;
}
return false;
}
}
private int LocalPlayerCount
{
get
{
int num = 0;
for (int i = 0; i < Player.MAX_PLAYERS; i++)
{
Player player = Player.GetPlayer(i);
if (IsLocalPlayer(player, allowCPUs: true))
{
num++;
}
}
return num;
}
}
private void ConfigInit()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Expected O, but got Unknown
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
selectViewingMode = ((BaseUnityPlugin)this).Config.Bind<int>("General", "selectViewingMode", 4, new ConfigDescription("Viewing mode index", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 4), new object[0]));
backgroundTransparency = ((BaseUnityPlugin)this).Config.Bind<int>("General", "backgroundTransparency", 0, new ConfigDescription("Background transparency", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 6), new object[0]));
excludeExpressions = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "miniInputViewer", false, (ConfigDescription)null);
useTeamColors = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "useTeamColors", false, (ConfigDescription)null);
((BaseUnityPlugin)this).Config.Bind<int>("gap", "mm_header_gap", 20, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_gap" }));
((BaseUnityPlugin)this).Config.Bind<string>("localViewer", "mm_header_localViewer", "Local Viewer", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_header" }));
enableLocalViewer = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "enableLocalViewer", false, (ConfigDescription)null);
trackLocalCPUs = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "trackLocalCPUs", true, (ConfigDescription)null);
inputViewerPosition_main = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Position", "inputViewerPosition_main", new Vector2(-520f, -300f), (ConfigDescription)null);
inputViewerPosition_1v1_left = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Position", "inputViewerPosition_1v1_left", new Vector2(-520f, -300f), (ConfigDescription)null);
inputViewerPosition_1v1_right = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Position", "inputViewerPosition_1v1_right", new Vector2(520f, -300f), (ConfigDescription)null);
inputViewerPosition_FFA_P1 = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Position", "inputViewerPosition_FFA_P1", new Vector2(-570f, -300f), (ConfigDescription)null);
inputViewerPosition_FFA_P2 = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Position", "inputViewerPosition_FFA_P2", new Vector2(-450f, -300f), (ConfigDescription)null);
inputViewerPosition_FFA_P3 = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Position", "inputViewerPosition_FFA_P3", new Vector2(450f, -300f), (ConfigDescription)null);
inputViewerPosition_FFA_P4 = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Position", "inputViewerPosition_FFA_P4", new Vector2(570f, -300f), (ConfigDescription)null);
}
private void Awake()
{
Instance = this;
LogGlobal = ((BaseUnityPlugin)this).Logger;
IVStyle.ATInit();
ConfigInit();
((BaseUnityPlugin)this).Config.SettingChanged += SettingChanged;
}
public bool ForceLocalViewers()
{
return false;
}
private void CreateInputWindows()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
inputWindowContainer = LLControl.CreatePanel(UIScreen.tfUIRoot, "Input Windows", 0f, 0f);
inputWindowContainer.anchorMin = new Vector2(0f, 0f);
inputWindowContainer.anchorMax = new Vector2(1f, 1f);
((Transform)inputWindowContainer).localPosition = Vector2.op_Implicit(Vector2.zero);
inputWindow1v1Left = InputWindow.Create((Transform)(object)inputWindowContainer, "inputWindow1v1Left", inputViewerPosition_1v1_left, isMiniSize: false, isDraggable: false);
inputWindow1v1Right = InputWindow.Create((Transform)(object)inputWindowContainer, "inputWindow1v1Right", inputViewerPosition_1v1_right, isMiniSize: false, isDraggable: false);
inputWindowFfaP1 = InputWindow.Create((Transform)(object)inputWindowContainer, "inputWindowFfaP1", inputViewerPosition_FFA_P1, isMiniSize: true, isDraggable: false);
inputWindowFfaP2 = InputWindow.Create((Transform)(object)inputWindowContainer, "inputWindowFfaP2", inputViewerPosition_FFA_P2, isMiniSize: true, isDraggable: false);
inputWindowFfaP3 = InputWindow.Create((Transform)(object)inputWindowContainer, "inputWindowFfaP3", inputViewerPosition_FFA_P3, isMiniSize: true, isDraggable: false);
inputWindowFfaP4 = InputWindow.Create((Transform)(object)inputWindowContainer, "inputWindowFfaP4", inputViewerPosition_FFA_P4, isMiniSize: true, isDraggable: false);
inputWindowMain = InputWindow.Create((Transform)(object)inputWindowContainer, "inputWindowMain", inputViewerPosition_main, excludeExpressions.Value, isDraggable: true);
PlayerInputWindows = new InputWindow[4] { inputWindowFfaP1, inputWindowFfaP2, inputWindowFfaP3, inputWindowFfaP4 };
AllInputWindows = new InputWindow[7] { inputWindowMain, inputWindow1v1Left, inputWindow1v1Right, inputWindowFfaP1, inputWindowFfaP2, inputWindowFfaP3, inputWindowFfaP4 };
inputWindowsCreated = true;
}
private void Start()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"InputViewer Started");
ModDependenciesUtils.RegisterToModMenu(((BaseUnityPlugin)this).Info, new List<string> { "<b>Select View Mode Index</b>:", "0 : <b>Off</b>", "1 : <b>Training Mode</b>", "2 : <b>Local Games</b>", "3 : <b>Online Games</b>", "4 : <b>All Games</b>", "", "<b>Enable local viewer</b>: shows an individual input viewer window for each player in LAN games", "Local viewer windows are not draggable to prevent accidental moving, and each have their own saved position in the config" });
}
private void OnDestroy()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"InputViewer Destroyed");
}
private void SettingChanged(object sender, SettingChangedEventArgs e)
{
if (inputWindowMain.isMiniSize != excludeExpressions.Value)
{
InputWindow inputWindow = inputWindowMain;
InputWindow inputWindow2 = InputWindow.Create((Transform)(object)inputWindowContainer, "inputWindowMain", inputViewerPosition_main, excludeExpressions.Value, isDraggable: true);
inputWindow2.BindPlayer(inputWindow.boundPlayer);
Object.Destroy((Object)(object)((Component)inputWindow).gameObject);
inputWindowMain = inputWindow2;
AllInputWindows[0] = inputWindowMain;
}
}
private void LateUpdate()
{
if (AllInputWindows == null)
{
return;
}
InputWindow[] allInputWindows = AllInputWindows;
for (int i = 0; i < allInputWindows.Length; i++)
{
allInputWindows[i].UpdateColor();
}
if (ModDependenciesUtils.InModOptions())
{
if (inputWindowMain.IsPositionUnsaved())
{
queueSave = true;
}
}
else if (queueSave)
{
inputWindowMain.SavePosition();
((BaseUnityPlugin)this).Config.Save();
LogGlobal.LogInfo((object)"Saved InputViewer position");
queueSave = false;
}
}
private void Update()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Invalid comparison between Unknown and I4
if (!inputWindowsCreated && (Object)(object)UIScreen.tfUIRoot != (Object)null)
{
CreateInputWindows();
}
if (!inputWindowsCreated)
{
return;
}
((Transform)inputWindowContainer).SetAsLastSibling();
InputWindow[] allInputWindows = AllInputWindows;
for (int i = 0; i < allInputWindows.Length; i++)
{
((Component)allInputWindows[i]).gameObject.SetActive(false);
}
int localPlayerCount = LocalPlayerCount;
if (((localPlayerCount == 1 || (int)StateApi.CurrentGameMode == 100 || (!enableLocalViewer.Value && !ForceLocalViewers())) && ViewingMode((ViewMode)selectViewingMode.Value) && InGame) || ModDependenciesUtils.InModOptions())
{
inputWindowMain.BindPlayer(GetFirstLocalPlayer(allowCPUs: false));
((Component)inputWindowMain).gameObject.SetActive(true);
}
else
{
if (!enableLocalViewer.Value && !ForceLocalViewers())
{
return;
}
if (localPlayerCount == 2 && ViewingMode((ViewMode)selectViewingMode.Value) && InGame)
{
Player firstLocalPlayer = GetFirstLocalPlayer(allowCPUs: true);
Player secondLocalPlayer = GetSecondLocalPlayer(firstLocalPlayer, allowCPUs: true);
inputWindow1v1Left.BindPlayer(firstLocalPlayer);
inputWindow1v1Right.BindPlayer(secondLocalPlayer);
((Component)inputWindow1v1Left).gameObject.SetActive(!firstLocalPlayer.IsAI || trackLocalCPUs.Value || ForceLocalViewers());
((Component)inputWindow1v1Right).gameObject.SetActive(!secondLocalPlayer.IsAI || trackLocalCPUs.Value || ForceLocalViewers());
}
else
{
if (localPlayerCount <= 2 || !ViewingMode((ViewMode)selectViewingMode.Value) || !InGame)
{
return;
}
for (int j = 0; j < Player.MAX_PLAYERS; j++)
{
Player player = Player.GetPlayer(j);
if (IsLocalPlayer(player, allowCPUs: true))
{
InputWindow obj = PlayerInputWindows[j];
obj.BindPlayer(player);
((Component)obj).gameObject.SetActive(!player.IsAI || trackLocalCPUs.Value || ForceLocalViewers());
}
}
}
}
}
private bool ViewingMode(ViewMode selectedView)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Invalid comparison between Unknown and I4
return selectedView switch
{
ViewMode.Off => false,
ViewMode.Training => (int)StateApi.CurrentGameMode == 100,
ViewMode.Local => !NetworkApi.IsOnline,
ViewMode.Online => NetworkApi.IsOnline,
ViewMode.All => true,
_ => false,
};
}
private bool IsLocalPlayer(Player player, bool allowCPUs)
{
bool num = player.IsLocalPeer && player.IsInMatch;
bool flag = player.IsAI && !allowCPUs;
if (num)
{
if (flag)
{
return ForceLocalViewers();
}
return true;
}
return false;
}
private Player GetFirstLocalPlayer(bool allowCPUs)
{
Player result = Player.GetPlayer(0);
for (int i = 0; i < Player.MAX_PLAYERS; i++)
{
Player player = Player.GetPlayer(i);
if (IsLocalPlayer(player, allowCPUs))
{
result = player;
break;
}
}
return result;
}
private Player GetSecondLocalPlayer(Player firstPlayer, bool allowCPUs)
{
Player result = Player.GetPlayer(0);
for (int i = firstPlayer.nr + 1; i < Player.MAX_PLAYERS; i++)
{
Player player = Player.GetPlayer(i);
if (IsLocalPlayer(player, allowCPUs))
{
result = player;
break;
}
}
return result;
}
}
internal static class PluginInfos
{
public const string PLUGIN_NAME = "InputViewer";
public const string PLUGIN_ID = "uk.daioutzu.plugins.llb.inputviewer";
public const string PLUGIN_VERSION = "3.0.0";
}