Skip to content

Commit

Permalink
Shorter plugin name; fixed chara/coord load toggles not being aligned…
Browse files Browse the repository at this point in the history
… properly
  • Loading branch information
ManlyMarco committed May 1, 2019
1 parent 7355eda commit c2b80e3
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 22 deletions.
3 changes: 3 additions & 0 deletions API/Maker/UI/BaseGuiEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ protected internal static Transform GuiCacheTransfrom
}
}

/// <summary>
/// Find first control of this name under the specified category transform
/// </summary>
protected static Transform GetExistingControl(string categoryPath, string controlName)
{
var cat = GameObject.Find(categoryPath);
Expand Down
18 changes: 11 additions & 7 deletions API/Maker/UI/MakerCoordinateLoadToggle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal static void CreateCustomToggles()
for (var index = 0; index < _baseToggles.Count; index++)
{
var baseToggle = _baseToggles[index];
baseToggle.localPosition = new Vector3(-380 + singleWidth * index, 52, 0);
baseToggle.localPosition = new Vector3(_baseToggle.localPosition.x + singleWidth * index, 52, 0);
baseToggle.offsetMax = new Vector2(baseToggle.offsetMin.x + singleWidth, baseToggle.offsetMin.y + 26);
}
}
Expand All @@ -78,7 +78,7 @@ protected override GameObject OnCreateControl(Transform loadBoxTransform)
var singleWidth = TotalWidth / (_baseToggles.Count + Toggles.Count);

var rt = copy.GetComponent<RectTransform>();
rt.localPosition = new Vector3(-380 + singleWidth * _createdCount, 52, 0);
rt.localPosition = new Vector3(_baseToggle.localPosition.x + singleWidth * _createdCount, 52, 0);
rt.offsetMax = new Vector2(rt.offsetMin.x + singleWidth, rt.offsetMin.y + 26);

copy.gameObject.SetActive(true);
Expand Down Expand Up @@ -110,15 +110,19 @@ internal static void Setup()
Reset();

_root = GetRootObject();
var allChildren = _root.transform.Cast<Transform>().Select(x => x.GetComponent<RectTransform>()).ToList();

_baseToggles = _root.transform.Cast<Transform>()
.Where(x => x.name.StartsWith("tglItem0"))
.Select(x => x.GetComponent<RectTransform>())
_baseToggles = allChildren
.Where(x => x.name.StartsWith("tglItem"))
.ToList();

_createdCount = _baseToggles.Count;

_baseToggle = _root.transform.Find("tglItem01");

#if EC
// Disable the text since there's no space
allChildren.FirstOrDefault(x => x.name.StartsWith("Text"))?.gameObject.SetActive(false);
#endif

/*var allon = _root.transform.Find("btnAllOn");
allon.GetComponentInChildren<Button>().onClick.AddListener(OnAllOn);
Expand Down
13 changes: 7 additions & 6 deletions API/Maker/UI/MakerLoadToggle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected override GameObject OnCreateControl(Transform loadBoxTransform)
var singleItemWidth = TotalWidth / Toggles.Count;

var rt = copy.GetComponent<RectTransform>();
rt.localPosition = new Vector3(-380 + singleItemWidth * _createdCount, 26);
rt.localPosition = new Vector3(_baseToggle.localPosition.x + singleItemWidth * _createdCount, 26);
rt.offsetMax = new Vector2(rt.offsetMin.x + singleItemWidth, rt.offsetMin.y + 26);

copy.gameObject.SetActive(true);
Expand Down Expand Up @@ -101,21 +101,22 @@ internal static void Setup()
Reset();

_root = GetRootObject();
var baseToggles = _root.transform.Cast<Transform>()
var allChildren = _root.transform.Cast<Transform>().Select(x => x.GetComponent<RectTransform>()).ToList();

var baseToggles = allChildren
.Where(x => x.name.StartsWith("tglItem"))
.Select(x => x.GetComponent<RectTransform>())
.ToList();

_baseToggle = _root.transform.Find("tglItem01");

var singleWidth = TotalWidth / baseToggles.Count;
for (var index = 0; index < baseToggles.Count; index++)
{
var baseToggle = baseToggles[index];
baseToggle.localPosition = new Vector3(-380 + singleWidth * index, 52, 0);
baseToggle.localPosition = new Vector3(_baseToggle.localPosition.x + singleWidth * index, 52, 0);
baseToggle.offsetMax = new Vector2(baseToggle.offsetMin.x + singleWidth, baseToggle.offsetMin.y + 26);
}

_baseToggle = _root.transform.Find("tglItem01");

var allon = _root.transform.Find("btnAllOn");
allon.GetComponentInChildren<Button>().onClick.AddListener(OnAllOn);
var alloff = _root.transform.Find("btnAllOff");
Expand Down
2 changes: 1 addition & 1 deletion ECAPI/KoikatuAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace KKAPI
/// like synchronization of threads or checking if required plugins are installed.
/// More information is available in project wiki at https://github.com/ManlyMarco/KKAPI/wiki
/// </summary>
[BepInPlugin(GUID, "Modding API for Emotion Creators!", VersionConst)]
[BepInPlugin(GUID, "Modding API", VersionConst)]
public class KoikatuAPI : BaseUnityPlugin
{
/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions ECAPI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
// associated with an assembly.
[assembly: AssemblyTitle("ECAPI")]
[assembly: AssemblyDescription("Modding API for EmotionCreators!")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ManlyMarco")]
[assembly: AssemblyProduct("ECAPI")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
Expand Down
2 changes: 1 addition & 1 deletion KKAPI/KoikatuAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace KKAPI
/// like synchronization of threads or checking if required plugins are installed.
/// More information is available in project wiki at https://github.com/ManlyMarco/KKAPI/wiki
/// </summary>
[BepInPlugin(GUID, "Modding API for Koikatsu!", VersionConst)]
[BepInPlugin(GUID, "Modding API", VersionConst)]
public class KoikatuAPI : BaseUnityPlugin
{
/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions KKAPI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
// associated with an assembly.
[assembly: AssemblyTitle("KKAPI")]
[assembly: AssemblyDescription("Modding API for Koikatsu!")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ManlyMarco")]
[assembly: AssemblyProduct("KKAPI")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
Expand Down
2 changes: 1 addition & 1 deletion doc/KKAPI.Maker.UI.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Static Methods

| Type | Name | Summary |
| --- | --- | --- |
| `Transform` | GetExistingControl(`String` categoryPath, `String` controlName) | |
| `Transform` | GetExistingControl(`String` categoryPath, `String` controlName) | Find first control of this name under the specified category transform |


## `MakerButton`
Expand Down

0 comments on commit c2b80e3

Please sign in to comment.