Skip to content

Commit

Permalink
Merge pull request #2 from Falki-git/fix-for-0.1.3.0
Browse files Browse the repository at this point in the history
Support for 0.1.3.0 + nudge & move
  • Loading branch information
Falki-git authored Jul 2, 2023
2 parents 24b2a67 + 1b29567 commit f7dfc4f
Show file tree
Hide file tree
Showing 8 changed files with 501 additions and 119 deletions.
6 changes: 3 additions & 3 deletions CustomizableUIProject/CustomizableUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<AssemblyName>com.github.falki.customizable-ui</AssemblyName>
<Product>Customizable UI</Product>
<Description></Description>
<Version>1.0.0</Version>
<Version>0.3.0</Version>
<RestoreAdditionalProjectSources>
https://nuget.spacewarp.org/v3/index.json
</RestoreAdditionalProjectSources>
Expand All @@ -21,8 +21,8 @@
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
<PackageReference Include="HarmonyX" Version="2.10.1" />
<PackageReference Include="SpaceWarp" Version="1.1.1" />
<PackageReference Include="UnityEngine.Modules" Version="2020.3.33" IncludeAssets="compile" />
<PackageReference Include="SpaceWarp" Version="1.3.0" />
<PackageReference Include="UnityEngine.Modules" Version="2020.3.33.1" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
Expand Down
90 changes: 78 additions & 12 deletions CustomizableUIProject/Groups/BaseGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace CustomizableUI
[JsonObject(MemberSerialization.OptIn)]
public class BaseGroup
{
private Vector3 _moveLeft = new Vector3 (-1f, 0f, 0f);
private Vector3 _moveRight = new Vector3(1f, 0f, 0f);
private Vector3 _moveUp = new Vector3(0f, 1f, 0f);
private Vector3 _moveDown = new Vector3(0f, -1f, 0f);

[JsonProperty]
public string Name;
public Transform Transform;
Expand All @@ -14,11 +19,26 @@ public class BaseGroup
public int SelectedChild = 0;
public Vector3 DefaultPosition;
public Vector2 ToCenterOffset;
public Vector2 OffsetToZero;
public Vector2 ToMaxOffset;
[JsonProperty]
public Vector3 Position;
[JsonProperty]
private bool isActive;

public RectTransform RectTransform;

public float HorizontalLeftFar { get => (float)Math.Round(0f + OffsetToZero.x, 0); }
public float HorizontalLeftMiddle { get => (float)Math.Round((HorizontalLeftFar + HorizontalCenter) / 2, 0); }
public float HorizontalCenter { get => (float)Math.Round(0f + OffsetToZero.x + Screen.width / 2 - RectTransform.rect.width / 2 * Manager.Instance.ScaleFactor + ToCenterOffset.x, 0); }
public float HorizontalRightMiddle { get => (float)Math.Round((HorizontalCenter + HorizontalRightFar) / 2, 0); }
public float HorizontalRightFar { get => (float)Math.Round(0f + OffsetToZero.x + Screen.width - RectTransform.rect.width * Manager.Instance.ScaleFactor + ToMaxOffset.x, 0); }
public float VerticalUpperTop { get => (float)Math.Round(0f + OffsetToZero.y + Screen.height - RectTransform.rect.height * Manager.Instance.ScaleFactor + ToMaxOffset.y, 0); }
public float VerticalUpperMiddle { get => (float)Math.Round((VerticalCenter + VerticalUpperTop) / 2, 0); }
public float VerticalCenter { get => (float)Math.Round(0f + OffsetToZero.y + Screen.height / 2 - RectTransform.rect.height / 2 * Manager.Instance.ScaleFactor + ToCenterOffset.y, 0); }
public float VerticalLowerMiddle { get => (float)Math.Round((VerticalLowerBottom + VerticalCenter) / 2, 0); }
public float VerticalLowerBottom { get => (float)Math.Round(0f + OffsetToZero.y, 0); }

public bool IsActive
{
get => isActive;
Expand All @@ -27,8 +47,7 @@ public bool IsActive
isActive = value;
Transform?.gameObject?.SetActive(value);
}
}

}

public override string ToString()
{
Expand All @@ -53,33 +72,80 @@ public void ResetToDefault()
IsActive = true;
}


///// MOVE METHODS /////

public void MoveToHorizontalLeftFar()
{
Transform.position = new Vector3(this.HorizontalLeftFar, Transform.position.y, Transform.position.z);
}

public void MoveToHorizontalLeftMiddle()
{
Transform.position = new Vector3(this.HorizontalLeftMiddle, Transform.position.y, Transform.position.z);
}

public void MoveToHorizontalCenter()
{
Transform.position = new Vector3(0f + ToCenterOffset.x, Transform.position.y, Transform.position.z);
Transform.position = new Vector3(this.HorizontalCenter, Transform.position.y, Transform.position.z);
}

public void MoveToHorizontalRightMiddle()
{
Transform.position = new Vector3(this.HorizontalRightMiddle, Transform.position.y, Transform.position.z);
}

public void MoveToHorizontalRightFar()
{
Transform.position = new Vector3(this.HorizontalRightFar, Transform.position.y, Transform.position.z);
}

public void MoveToVerticalUpperTop()
{
Transform.position = new Vector3(Transform.position.x, this.VerticalUpperTop, Transform.position.z);
}

public void MoveToVerticalUpperMiddle()
{
Transform.position = new Vector3(Transform.position.x, this.VerticalUpperMiddle, Transform.position.z);
}

public void MoveToVerticalCenter()
{
Transform.position = new Vector3(Transform.position.x, 0f + ToCenterOffset.y, Transform.position.z);
Transform.position = new Vector3(Transform.position.x, this.VerticalCenter, Transform.position.z);
}

public void MoveToTop()
public void MoveToVerticalLowerMiddle()
{
// TODO
Transform.position = new Vector3(Transform.position.x, this.VerticalLowerMiddle, Transform.position.z);
}
public void MoveToBottom()

public void MoveToVerticalLowerBottom()
{
// TODO
Transform.position = new Vector3(Transform.position.x, this.VerticalLowerBottom, Transform.position.z);
}


///// NUDGE METHODS /////

public void NudgeLeft()
{
Transform.position += _moveLeft;
}

public void MoveToFarLeft()
public void NudgeRight()
{
// TODO
Transform.position += _moveRight;
}

public void MoveToFarRight()
public void NudgeUp()
{
// TODO
Transform.position += _moveUp;
}

public void NudgeDown()
{
Transform.position += _moveDown;
}

public void AdjustScale()
Expand Down
Loading

0 comments on commit f7dfc4f

Please sign in to comment.