forked from CWX/CWX-mods
Traderscrolling
This commit is contained in:
parent
6ae0a87979
commit
711b0b6f4d
35
Live/TraderScrolling/PlayerCardPatch.cs
Normal file
35
Live/TraderScrolling/PlayerCardPatch.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using Aki.Reflection.Patching;
|
||||||
|
using Aki.Reflection.Utils;
|
||||||
|
using EFT.UI;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace TraderScrolling
|
||||||
|
{
|
||||||
|
public class PlayerCardPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
Logger.LogError("Patching Show");
|
||||||
|
return typeof(DisplayMoneyPanelTMPText).GetMethod("Show", PatchConstants.PublicFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
public static void PatchPostFix()
|
||||||
|
{
|
||||||
|
var go = GameObject.Find("Menu UI");
|
||||||
|
var check = go.GetComponentInChildren<PlayerCardScript>();
|
||||||
|
|
||||||
|
|
||||||
|
if (check != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
go.AddComponent<PlayerCardScript>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
Live/TraderScrolling/PlayerCardScript.cs
Normal file
48
Live/TraderScrolling/PlayerCardScript.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using BepInEx.Logging;
|
||||||
|
using EFT.UI;
|
||||||
|
using EFT.UI.Ragfair;
|
||||||
|
|
||||||
|
namespace TraderScrolling
|
||||||
|
{
|
||||||
|
public class PlayerCardScript : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
//Adjusts Money position
|
||||||
|
var rightPerson = GameObject.Find("Right Person");
|
||||||
|
var list = rightPerson.GetComponentsInChildren<RectTransform>(true).ToList();
|
||||||
|
var money = list.FirstOrDefault(x => x.name == "Money");
|
||||||
|
var moneyRect = money.RectTransform();
|
||||||
|
moneyRect.anchoredPosition = new Vector2(moneyRect.anchoredPosition.x + 60f, moneyRect.anchoredPosition.y);
|
||||||
|
//End of Money position Change
|
||||||
|
|
||||||
|
// Change spacing
|
||||||
|
var list2 = rightPerson.GetComponentsInChildren<HorizontalLayoutGroup>(true).ToList();
|
||||||
|
var money2 = list2.FirstOrDefault(x => x.name == "Money");
|
||||||
|
money2.spacing = 10;
|
||||||
|
// End of Money Spacing
|
||||||
|
|
||||||
|
// Make tile simple
|
||||||
|
var tile = rightPerson.GetComponentsInChildren<Image>(true).ToList();
|
||||||
|
var tileImage = tile.FirstOrDefault(x => x.name == "Background Tile");
|
||||||
|
tileImage.type = Image.Type.Simple;
|
||||||
|
|
||||||
|
var foundObject = rightPerson.transform.Find("Background Tile");
|
||||||
|
foundObject.gameObject.SetActive(true);
|
||||||
|
|
||||||
|
var tileList = rightPerson.GetComponentsInChildren<RectTransform>(true).ToList();
|
||||||
|
var tileRect = tileList.FirstOrDefault(x => x.name == "Background Tile");
|
||||||
|
tileRect.sizeDelta = new Vector2(500f, 0);
|
||||||
|
|
||||||
|
|
||||||
|
var background = tile.FirstOrDefault(x => x.name == "Background");
|
||||||
|
background.color = new Color(0, 0, 0, 1);
|
||||||
|
// Change Colour alpha to max for background
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,14 @@
|
|||||||
using BepInEx;
|
using BepInEx;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace TraderScrolling
|
namespace TraderScrolling
|
||||||
{
|
{
|
||||||
[BepInPlugin("com.kaeno.TraderScrolling", "Kaeno-TraderScrolling", "1.0.0")]
|
[BepInPlugin("com.kaeno.TraderScrolling", "Kaeno-TraderScrolling", "1.0.0")]
|
||||||
public class TraderScrolling : BaseUnityPlugin
|
public class TraderScrolling : BaseUnityPlugin
|
||||||
{
|
{
|
||||||
public void awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
new TraderScrollingPatch().Enable();
|
new TraderScrollingPatch().Enable();
|
||||||
|
new PlayerCardPatch().Enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,4 @@
|
|||||||
using Aki.Reflection.Patching;
|
namespace TraderScrolling
|
||||||
using Aki.Reflection.Utils;
|
|
||||||
using EFT.UI;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace TraderScrolling
|
|
||||||
{
|
{
|
||||||
public class TraderScrollingPatch : ModulePatch
|
public class TraderScrollingPatch : ModulePatch
|
||||||
{
|
{
|
||||||
@ -18,38 +10,14 @@ namespace TraderScrolling
|
|||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
public static void PatchPostFix()
|
public static void PatchPostFix()
|
||||||
{
|
{
|
||||||
Debug.LogError("test 1");
|
var go = GameObject.Find("Menu UI");
|
||||||
var traderCards = GameObject.Find("TraderCards");
|
var check = go.GetComponentInChildren<TraderScrollingScript>();
|
||||||
|
if (check != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Debug.LogError(traderCards);
|
go.AddComponent<TraderScrollingScript>();
|
||||||
var traderCardsRect = traderCards.RectTransform();
|
|
||||||
Debug.LogError(traderCardsRect);
|
|
||||||
|
|
||||||
traderCardsRect.anchorMax = new Vector2(1f, 1f);
|
|
||||||
traderCardsRect.anchorMin = new Vector2(0.385f, 1f);
|
|
||||||
|
|
||||||
var menuUI = GameObject.Find("Menu UI");
|
|
||||||
Debug.LogError(menuUI);
|
|
||||||
|
|
||||||
var list = menuUI.GetComponentsInChildren<RectTransform>(true).ToList();
|
|
||||||
Debug.LogError(list.Count);
|
|
||||||
|
|
||||||
var container = list.FirstOrDefault(x => x.name == "Container");
|
|
||||||
Debug.LogError(container);
|
|
||||||
|
|
||||||
var containerRect = container.RectTransform();
|
|
||||||
Debug.LogError(containerRect);
|
|
||||||
|
|
||||||
containerRect.anchorMin = new Vector2(1f, 1f);
|
|
||||||
containerRect.anchorMax = new Vector2(0.01f, 0f);
|
|
||||||
|
|
||||||
var scrollrect = traderCards.AddComponent<ScrollRect>();
|
|
||||||
Debug.LogError(scrollrect);
|
|
||||||
|
|
||||||
scrollrect.content = traderCardsRect;
|
|
||||||
scrollrect.vertical = false;
|
|
||||||
scrollrect.movementType = ScrollRect.MovementType.Elastic;
|
|
||||||
scrollrect.viewport = containerRect;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,40 @@
|
|||||||
using System;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using UnityEngine;
|
||||||
using System.Linq;
|
using UnityEngine.UI;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace TraderScrolling
|
namespace TraderScrolling
|
||||||
{
|
{
|
||||||
public class TraderScrollingScript
|
public class TraderScrollingScript : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
var traderCards = GameObject.Find("TraderCards");
|
||||||
|
var menuUI = GameObject.Find("Menu UI");
|
||||||
|
var list = menuUI.GetComponentsInChildren<RectTransform>(true).ToList();
|
||||||
|
var container = list.FirstOrDefault(x => x.name == "Container");
|
||||||
|
var scrollrect = traderCards.AddComponent<ScrollRect>();
|
||||||
|
var traderCardsRect = traderCards.RectTransform();
|
||||||
|
var containerRect = container.RectTransform();
|
||||||
|
|
||||||
|
var countCards = traderCards.transform.childCount;
|
||||||
|
|
||||||
|
var count = countCards - 10;
|
||||||
|
//THIS IS DEFAULT anchorMin For anything below 11
|
||||||
|
traderCardsRect.anchorMin = new Vector2(0.595f, 1f);
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
var offset = -0.065f * count;
|
||||||
|
traderCardsRect.anchorMin = new Vector2((0.595f + offset), 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
traderCardsRect.anchorMax = new Vector2(1f, 1f);
|
||||||
|
containerRect.anchorMax = new Vector2(1f, 1f);
|
||||||
|
containerRect.anchorMin = new Vector2(0.01f, 0f);
|
||||||
|
scrollrect.content = traderCardsRect;
|
||||||
|
scrollrect.vertical = false;
|
||||||
|
scrollrect.movementType = ScrollRect.MovementType.Elastic;
|
||||||
|
scrollrect.viewport = containerRect;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user