/*
* Copyright 2022 Peter Han
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
using PeterHan.PLib.Detours;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using SideScreenRef = DetailsScreen.SideScreenRef;
namespace PeterHan.PLib.UI {
///
/// Stores detours used for Klei UI components. Klei loves adding optional parameters and
/// changing fields to/from properties, which while source compatible is binary
/// incompatible. These lazy detours (resolved on first use) can bridge over a variety of
/// such differences with minimal overhead and no recompilation.
///
internal static class UIDetours {
#region ConfirmDialogScreen
public delegate void PCD(ConfirmDialogScreen dialog, string text,
System.Action on_confirm, System.Action on_cancel, string configurable_text,
System.Action on_configurable_clicked, string title_text, string confirm_text,
string cancel_text);
public static readonly DetouredMethod POPUP_CONFIRM = typeof(ConfirmDialogScreen).DetourLazy(nameof(ConfirmDialogScreen.PopupConfirmDialog));
#endregion
#region DetailsScreen
public static readonly IDetouredField> SIDE_SCREENS = PDetours.DetourFieldLazy>("sideScreens");
public static readonly IDetouredField SS_CONTENT_BODY = PDetours.DetourFieldLazy("sideScreenContentBody");
#endregion
#region KButton
public static readonly IDetouredField ADDITIONAL_K_IMAGES = PDetours.DetourFieldLazy(nameof(KButton.additionalKImages));
public static readonly IDetouredField BG_IMAGE = PDetours.DetourFieldLazy(nameof(KButton.bgImage));
public static readonly IDetouredField FG_IMAGE = PDetours.DetourFieldLazy(nameof(KButton.fgImage));
public static readonly IDetouredField IS_INTERACTABLE = PDetours.DetourFieldLazy(nameof(KButton.isInteractable));
public static readonly IDetouredField SOUND_PLAYER_BUTTON = PDetours.DetourFieldLazy(nameof(KButton.soundPlayer));
#endregion
#region KImage
public static readonly IDetouredField COLOR_STYLE_SETTING = PDetours.DetourFieldLazy(nameof(KImage.colorStyleSetting));
public static readonly DetouredMethod> APPLY_COLOR_STYLE = typeof(KImage).DetourLazy>(nameof(KImage.ApplyColorStyleSetting));
#endregion
#region KScreen
public static readonly DetouredMethod> ACTIVATE_KSCREEN = typeof(KScreen).DetourLazy>(nameof(KScreen.Activate));
public static readonly DetouredMethod> DEACTIVATE_KSCREEN = typeof(KScreen).DetourLazy>(nameof(KScreen.Deactivate));
#endregion
#region KToggle
public static readonly IDetouredField ART_EXTENSION = PDetours.DetourFieldLazy(nameof(KToggle.artExtension));
public static readonly IDetouredField IS_ON = PDetours.DetourFieldLazy(nameof(KToggle.isOn));
public static readonly IDetouredField SOUND_PLAYER_TOGGLE = PDetours.DetourFieldLazy(nameof(KToggle.soundPlayer));
#endregion
#region LocText
public static readonly IDetouredField LOCTEXT_KEY = PDetours.DetourFieldLazy(nameof(LocText.key));
public static readonly IDetouredField LOCTEXT_STYLE = PDetours.DetourFieldLazy(nameof(LocText.textStyleSetting));
#endregion
#region MultiToggle
public static readonly IDetouredField CURRENT_STATE = PDetours.DetourFieldLazy(nameof(MultiToggle.CurrentState));
public static readonly IDetouredField PLAY_SOUND_CLICK = PDetours.DetourFieldLazy(nameof(MultiToggle.play_sound_on_click));
public static readonly IDetouredField PLAY_SOUND_RELEASE = PDetours.DetourFieldLazy(nameof(MultiToggle.play_sound_on_release));
public static readonly DetouredMethod> CHANGE_STATE = typeof(MultiToggle).DetourLazy>(nameof(MultiToggle.ChangeState));
#endregion
#region SideScreenContent
public static readonly IDetouredField SS_CONTENT_CONTAINER = PDetours.DetourFieldLazy(nameof(SideScreenContent.ContentContainer));
#endregion
#region SideScreenRef
public static readonly IDetouredField SS_OFFSET = PDetours.DetourFieldLazy(nameof(SideScreenRef.offset));
public static readonly IDetouredField SS_PREFAB = PDetours.DetourFieldLazy(nameof(SideScreenRef.screenPrefab));
public static readonly IDetouredField SS_INSTANCE = PDetours.DetourFieldLazy(nameof(SideScreenRef.screenInstance));
#endregion
}
}